Namespace: numbr

numbr

Function wrapper for creating new Numbr instances, it also has useful static methods to control the global module behaviour.
Source:

Classes

CompiledFormat
Consumer
Numbr
Step

Members

(static) echoConsumer :Consumer

A simple consumer that echoes back as many characters as possible in one step. This is the default consumer.
Type:
  • Consumer
Source:

(static) noopConsumer :Consumer

A simple consumer that consumes the single character is given and does nothing else. You can set this consumer as the default by using numbr.setDefaultConsumer
Type:
  • Consumer
Source:

Methods

(static) addConsumer(consumer)

Adds a consumer to the list of global consumers. Consumers are used to translate the string format input into actual transforming steps.
Parameters:
Name Type Description
consumer Consumer
Source:

(static) cacheEnabled(enabled)

Enables or disables the format cache. By default every format is compiled into a series of transformation functions that are cached and reused every time Numbr.format is called. Disabling the cache may cause a significant performance hit and it is not recommended. Most applications will probably use just a handful of formats, so the memory overhead is non-existent.
Parameters:
Name Type Description
enabled boolean Whether to enable or disable the cache
Source:

(static) compile(fmt) → {CompiledFormat}

Compiles the given string into a CompiledFormat object ready to be used.
Parameters:
Name Type Description
fmt string
Source:
Returns:
Type
CompiledFormat

(static) defaultFormat(fmt)

Sets the default format. The default format is used if Numbr#format is called without arguments.
Parameters:
Name Type Description
fmt
Source:

(static) language(langCodeopt, langDefopt)

Gets the global language, sets the global language or loads a language. If called with no arguments, returns the global language. If called with just the language code, it sets the global language. If called with both arguments, the language is just loaded.
Parameters:
Name Type Attributes Description
langCode string <optional>
The language code
langDef object <optional>
A valid language definition
Source:

(static) setDefaultConsumer(consumer)

Sets the default consumer. The default consumer is used when no other consumer is able to consume a slice of the input format string. By default, this is numbr.echoConsumer.
Parameters:
Name Type Description
consumer
Source:

(static) setGlobalLang(langCode)

Sets the global language.
Parameters:
Name Type Description
langCode
Source:

(static) zeroFormat(fmt)

Sets the global zero format. If defined, the zero format is used as the outout of Numbr#format whenever the wrapped value === 0.
Parameters:
Name Type Description
fmt
Source: