README
Classes
Objects
Functions
- deduplicate(array) ⇒
Array
- debounce(func, wait, [immediate]) ⇒
function
- feature(policy, method) ⇒
*
- opt(method, value) ⇒
*
- nextTick(func) ⇒
number
- wait(timeout) ⇒
Promise.<any>
Assert
Kind: global class
Summary: Encapsulates common assertions providing a clear API.
- Assert
- .isNull(value) ⇒
boolean
- .isEmpty(value) ⇒
boolean
- .isUndefined(value) ⇒
boolean
- .isZero(value) ⇒
boolean
- .exists(value) ⇒
boolean
- .isNullOrEmpty(value) ⇒
boolean
- .isArray(value) ⇒
boolean
- .isBool(value) ⇒
boolean
- .isTrue(value) ⇒
boolean
- .isFalse(value) ⇒
boolean
- .isDate(value) ⇒
boolean
- .isNumber(value) ⇒
boolean
- .isEven(value) ⇒
boolean
- .isOdd(value) ⇒
boolean
- .isString(value) ⇒
boolean
- .isFunction(value) ⇒
boolean
- .isAsyncFunction(value) ⇒
boolean
- .isPromise(value) ⇒
boolean
- .isObject(value) ⇒
boolean
- .isObjectLiteral(value) ⇒
boolean
- .isTruthy(value) ⇒
boolean
- .isFalsy(value) ⇒
boolean
- .isNull(value) ⇒
boolean
Assert.isNull(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is null.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isEmpty(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is an empty string, empty array, or empty object literal.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isUndefined(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is undefined.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isZero(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is zero.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.exists(value) ⇒ Kind: static method of Assert
Summary: Returns true if value is null or undefined.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isNullOrEmpty(value) ⇒ Kind: static method of Assert
Summary: Returns true if value not {exists} or {isEmpty}.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isArray(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is an Array.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isBool(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is a boolean.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isTrue(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is true
.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isFalse(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is false
.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isDate(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is a Date.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isNumber(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is a number.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isEven(value) ⇒ Kind: static method of Assert
Summary: Returns true if value is a number and is even.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isOdd(value) ⇒ Kind: static method of Assert
Summary: Returns true if value is a number and is odd.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isString(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is a string.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isFunction(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is a function.
Note: AsyncFunction will also return true for this check.
It is advisable to check first for AsyncFunction, then for
Function where you may be expecting either.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isAsyncFunction(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is a function.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isPromise(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is a Promise.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isObject(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is an Object.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isObjectLiteral(value) ⇒ Kind: static method of Assert
Summary: Returns true if and only if value is an object literal.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isTruthy(value) ⇒ Kind: static method of Assert
Summary: Returns true if value is not {isFalsy}.
Param | Type | Description |
---|---|---|
value | * |
value to test |
boolean
Assert.isFalsy(value) ⇒ Kind: static method of Assert
Summary: Returns true if value {isZero}, {isFalse}, {isNullOrEmpty}, or {isNaN}.
Param | Type | Description |
---|---|---|
value | * |
value to test |
Name
Kind: global class
Summary: A person's proper name
- Name
- new Name(first, middle, last)
- .first ⇒
string
- .middle ⇒
string
- .last ⇒
string
- .full ⇒
string
- .initials ⇒
string
- .equals(other) ⇒
boolean
- .toString([format]) ⇒
string
new Name(first, middle, last)
Param | Type |
---|---|
first | string |
middle | string |
last | string |
string
name.first ⇒ Kind: instance property of Name
Summary: First name.
Access: public
string
name.middle ⇒ Kind: instance property of Name
Summary: Middle name.
Access: public
string
name.last ⇒ Kind: instance property of Name
Summary: Last name.
Access: public
string
name.full ⇒ Kind: instance property of Name
Summary: Space delimited first, [middle] and last name.
Access: public
string
name.initials ⇒ Kind: instance property of Name
Summary: Initials delimited by '.'.
Access: public
boolean
name.equals(other) ⇒ Kind: instance method of Name
Summary: Returns true if this is equal to another Name.
Access: public
Param | Type |
---|---|
other | Name |
string
name.toString([format]) ⇒ Kind: instance method of Name
Access: public
Param | Type | Description |
---|---|---|
[format] | string |
An optional format that can include: F, M, L, f, m, l where F, M, L represent the first, middle, and last name values respectively, and f, m, l represent the first initial, middle initial, and last initial respectively. Example: new Name('John', 'Bob', 'Doe').toString('F m. L') === 'John B. Doe' |
Rolodex
Kind: global class
Summary: Serially traverses an array forward and backward.
new Rolodex(list)
Param | Type | Description |
---|---|---|
list | Array |
An array of items to manage. |
boolean
rolodex.isEmpty ⇒ Kind: instance property of Rolodex
Summary: Returns true if is empty.
Access: public
boolean
rolodex.index ⇒ Kind: instance property of Rolodex
Summary: Returns true if is empty.
Access: public
number
rolodex.length ⇒ Kind: instance property of Rolodex
Summary: Returns number of values in the Rolodex.
Access: public
*
rolodex.current ⇒ Kind: instance property of Rolodex
Summary: Returns current value at Rolodex head.
Access: public
*
rolodex.next ⇒ Kind: instance property of Rolodex
Summary: Advance the head of the Rolodex one position moving
to the zero index if at the last index and return that value.
Access: public
*
rolodex.prev ⇒ Kind: instance property of Rolodex
Summary: Recede the head of the Rolodex one position moving
to the last index if at the zero index and return that value.
Access: public
*
rolodex.peekNext ⇒ Kind: instance property of Rolodex
Summary: Return the next value without moving the head.
Access: public
*
rolodex.peekPrev ⇒ Kind: instance property of Rolodex
Summary: Return the previous value without moving the head.
Access: public
DayPoint
Kind: global class
Summary: Date utility class.
- DayPoint
- new DayPoint(year, month, date)
- instance
- .value ⇒
number
- .day ⇒
number
- .date ⇒
number
- .month ⇒
number
- .year ⇒
number
- .shortYear ⇒
number
- .isWeekday ⇒
boolean
- .isWeekend ⇒
boolean
- .isLeapYear ⇒
boolean
- .nextDay ⇒
DayPoint
- .prevDay ⇒
DayPoint
- .nextMonth ⇒
DayPoint
- .prevMonth ⇒
DayPoint
- .nextYear ⇒
DayPoint
- .prevYear ⇒
DayPoint
- .firstDayOfMonth ⇒
DayPoint
- .lastDayOfMonth ⇒
DayPoint
- .add(years, months, days) ⇒
DayPoint
- .isBefore(other) ⇒
boolean
- .isAfter(other) ⇒
boolean
- .equals(other) ⇒
boolean
- .toString(formatString) ⇒
string
- .toDate() ⇒
Date
- .toJson() ⇒
string
- .value ⇒
- static
- .today ⇒
DayPoint
- .canParse(value) ⇒
boolean
- .parse(value) ⇒
DayPoint
- .tryParse(value) ⇒
DayPoint
|null
- .assumeNow(dayPoint)
- .today ⇒
new DayPoint(year, month, date)
Param | Type | Description |
---|---|---|
year | number |
a valid year. |
month | number |
a valid month (1-12) where 1 = January and 12 = December. |
date | number |
a valid date for a given month. |
number
dayPoint.value ⇒ Kind: instance property of DayPoint
Summary: Returns value.
Access: public
number
dayPoint.day ⇒ Kind: instance property of DayPoint
Summary: Returns day.
Access: public
number
dayPoint.date ⇒ Kind: instance property of DayPoint
Summary: Returns date.
Access: public
number
dayPoint.month ⇒ Kind: instance property of DayPoint
Summary: Returns month.
Access: public
number
dayPoint.year ⇒ Kind: instance property of DayPoint
Summary: Returns year.
Access: public
number
dayPoint.shortYear ⇒ Kind: instance property of DayPoint
Summary: Returns a truncated two digit year.
Access: public
boolean
dayPoint.isWeekday ⇒ Kind: instance property of DayPoint
Summary: Returns true for days Monday-Friday.
Access: public
boolean
dayPoint.isWeekend ⇒ Kind: instance property of DayPoint
Summary: Returns true for days Saturday and Sunday
Access: public
boolean
dayPoint.isLeapYear ⇒ Kind: instance property of DayPoint
Summary: Returns true for years that have a February 29th date.
Access: public
DayPoint
dayPoint.nextDay ⇒ Kind: instance property of DayPoint
Summary: Returns the day following this day.
Access: public
DayPoint
dayPoint.prevDay ⇒ Kind: instance property of DayPoint
Summary: Returns the day preceding this day.
Access: public
DayPoint
dayPoint.nextMonth ⇒ Kind: instance property of DayPoint
Summary: Returns the month following this month.
Warning: This method will error when navigating to next months that do not include a current day.
Access: public
DayPoint
dayPoint.prevMonth ⇒ Kind: instance property of DayPoint
Summary: Returns the month preceding this month.
Warning: This method will error when navigating to previous months that do not include a current day.
Access: public
DayPoint
dayPoint.nextYear ⇒ Kind: instance property of DayPoint
Summary: Returns the month following this month.
Warning: This method will error when navigating to next years that do not include a current day.
Access: public
DayPoint
dayPoint.prevYear ⇒ Kind: instance property of DayPoint
Summary: Returns the month preceding this month.
Warning: This method will error when navigating to previous years that do not include a current day.
Access: public
DayPoint
dayPoint.firstDayOfMonth ⇒ Kind: instance property of DayPoint
Summary: Returns the first day of this month and year.
Access: public
DayPoint
dayPoint.lastDayOfMonth ⇒ Kind: instance property of DayPoint
Summary: Returns the last day of this month and year.
Access: public
DayPoint
dayPoint.add(years, months, days) ⇒ Kind: instance method of DayPoint
Summary: Returns a DayPoint modified by the number of years, months, and days passed.
Access: public
Param | Type | Description |
---|---|---|
years | number |
The number of years to add or subtract from this DayPoint. |
months | number |
The number of months to add or subtract from this DayPoint. |
days | number |
The number of days to add or subtract from this DayPoint. |
boolean
dayPoint.isBefore(other) ⇒ Kind: instance method of DayPoint
Summary: Returns true if the other DayPoint is before this DayPoint.
Access: public
Param | Type | Description |
---|---|---|
other | DayPoint |
DayPoint to compare. |
boolean
dayPoint.isAfter(other) ⇒ Kind: instance method of DayPoint
Summary: Returns true if the other DayPoint is after this DayPoint.
Access: public
Param | Type | Description |
---|---|---|
other | DayPoint |
DayPoint to compare. |
boolean
dayPoint.equals(other) ⇒ Kind: instance method of DayPoint
Summary: Returns true if the other DayPoint is equal to this DayPoint.
Access: public
Param | Type | Description |
---|---|---|
other | DayPoint |
DayPoint to compare. |
string
dayPoint.toString(formatString) ⇒ Kind: instance method of DayPoint
Summary: Returns a date string formatted per the passed format string.
Access: public
Param | Type | Default | Description |
---|---|---|---|
formatString | string |
"mm/dd/yyyy" |
format string where m = month, d = date, y = year. Example: For date, January, 12, 2018, 'mm/dd/yy' -> '01/12/18' & 'dd/mm/yyyy' -> '12/01/2018' . |
Date
dayPoint.toDate() ⇒ Kind: instance method of DayPoint
Summary: Returns a Date
value of this.
Access: public
string
dayPoint.toJson() ⇒ Kind: instance method of DayPoint
Summary: Returns a JSON string value of this.
Access: public
DayPoint
DayPoint.today ⇒ Kind: static property of DayPoint
Summary: Returns a DayPoint with value now.
Access: public
boolean
DayPoint.canParse(value) ⇒ Kind: static method of DayPoint
Summary: Returns true if the value can be successfully parsed.
Access: public
Param | Type | Description |
---|---|---|
value | string |
A string value to test. |
DayPoint
DayPoint.parse(value) ⇒ Kind: static method of DayPoint
Summary: Returns a DayPoint with the parsed value of the passed value.
Warning: this method will throw an error for values that cannot be parsed.
Access: public
Param | Type |
---|---|
value | string |
DayPoint
| null
DayPoint.tryParse(value) ⇒ Kind: static method of DayPoint
Summary: Returns a DayPoint with the parsed value of the passed value.
Note: Will return null for values that cannot be parsed.
Access: public
Param | Type |
---|---|
value | string |
DayPoint.assumeNow(dayPoint)
Kind: static method of DayPoint
Summary: Sets the concept of now to the passed value instead of using
now as defined by the system clock.
Access: public
Param | Type |
---|---|
dayPoint | DayPoint |
Money
Kind: global class
- Money
- new Money(amount, [currency])
- instance
- .cents ⇒
number
- .dollars ⇒
number
- .currency ⇒
number
- .value ⇒
number
- .nearestWhole ⇒
Money
- .nearestDollar ⇒
Money
- .add(other) ⇒
Money
- .subtract(other) ⇒
Money
- .multiply(factor) ⇒
Money
- .divide(divisor) ⇒
Money
- .equals(other) ⇒
boolean
- .isGreaterThan(other) ⇒
boolean
- .isLessThan(other) ⇒
boolean
- .round([to]) ⇒
Money
- .roundDown([to]) ⇒
Money
- .roundUp([to]) ⇒
Money
- .exchange(rate, currency) ⇒
Money
- .isOfCurrency(other) ⇒
boolean
- .toString([format], [delimiter]) ⇒
string
- .cents ⇒
- static
- .zero(currency) ⇒
Money
- .isMoney(other) ⇒
boolean
- .canParse(value) ⇒
boolean
- .parse(value) ⇒
Money
- .tryParse(value) ⇒
Money
- .zero(currency) ⇒
new Money(amount, [currency])
Param | Type |
---|---|
amount | number |
[currency] | string |
number
money.cents ⇒ Kind: instance property of Money
Summary: Returns cents.
Access: public
number
money.dollars ⇒ Kind: instance property of Money
Summary: Returns dollars.
Access: public
number
money.currency ⇒ Kind: instance property of Money
Summary: Returns currency.
Access: public
number
money.value ⇒ Kind: instance property of Money
Summary: Returns value.
Access: public
Money
money.nearestWhole ⇒ Kind: instance property of Money
Summary: Returns Money
rounded to the nearest whole value.
Access: public
Money
money.nearestDollar ⇒ Kind: instance property of Money
Summary: Returns a Money
rounded to the nearest whole value.
_Note: This property is simply an API for common US usage.
Access: public
Money
money.add(other) ⇒ Kind: instance method of Money
Summary: Returns the sum two Money
s.
Warning: will throw an error for dissimilar currencies.
Use isOfCurrency
to check currencies and exchange
as necessary.
Access: public
Param | Type | Description |
---|---|---|
other | Money |
{Money} of currency to add to this |
Money
money.subtract(other) ⇒ Kind: instance method of Money
Summary: Returns the difference two Money
s.
Warning: will throw an error for dissimilar currencies.
Use isOfCurrency
to check currencies and exchange
as necessary.
Access: public
Param | Type |
---|---|
other | Money |
Money
money.multiply(factor) ⇒ Kind: instance method of Money
Summary: Returns the product of this
multiplied by factor
Access: public
Param | Type |
---|---|
factor | number |
Money
money.divide(divisor) ⇒ Kind: instance method of Money
Summary: Returns the quotient of this
divided by divisor.
Access: public
Param | Type |
---|---|
divisor | number |
boolean
money.equals(other) ⇒ Kind: instance method of Money
Summary: Returns true if this
and another Money
have equal values and currencies.
Access: public
Param | Type |
---|---|
other | Money |
boolean
money.isGreaterThan(other) ⇒ Kind: instance method of Money
Summary: Returns true if this
value is greater than another Money
of the same currency's value.
Access: public
Param | Type |
---|---|
other | Money |
boolean
money.isLessThan(other) ⇒ Kind: instance method of Money
Summary: Returns true if this
value is less than another Money
of the same currency's value.
Access: public
Param | Type |
---|---|
other | Money |
Money
money.round([to]) ⇒ Kind: instance method of Money
Summary: Returns a Money
rounded to the nearest tens exponent.
Access: public
Param | Type | Description |
---|---|---|
[to] | number |
tens exponent to round to. |
Money
money.roundDown([to]) ⇒ Kind: instance method of Money
Summary: Returns a Money
rounded down to the nearest tens exponent.
Access: public
Param | Type | Description |
---|---|---|
[to] | number |
tens exponent to round to. |
Money
money.roundUp([to]) ⇒ Kind: instance method of Money
Summary: Returns a Money
rounded up to the nearest tens exponent.
Access: public
Param | Type | Description |
---|---|---|
[to] | number |
tens exponent to round to. |
Money
money.exchange(rate, currency) ⇒ Kind: instance method of Money
Summary: Returns a Money
with type currency and value calculated over the passed rate of exchange.
Access: public
Param | Type | Description |
---|---|---|
rate | number |
rate of exchange |
currency | string |
symbol for target currency |
boolean
money.isOfCurrency(other) ⇒ Kind: instance method of Money
Summary: Returns true if the target Money
is of the same currency.
Access: public
Param | Type | Description |
---|---|---|
other | Money |
other Money |
string
money.toString([format], [delimiter]) ⇒ Kind: instance method of Money
Summary: Returns a string representation of this formatted to the
passed format, where format follows the following rules:
<wholeValue(d)><decimalCharacter(.|,)><fractionalValue(c)><numberOfFractionalValues(_)>
Example: for money with value 1234.5678
and currency 'C', d,c2
would return 'C1.234,56'
Access: public
Param | Type | Default | Description |
---|---|---|---|
[format] | string |
"d.c2" |
format string. |
[delimiter] | string |
a 1000x grouping delimiter. |
Money
Money.zero(currency) ⇒ Kind: static method of Money
Summary: Returns Money
with a zero value.
Access: public
Param | Type |
---|---|
currency | string |
boolean
Money.isMoney(other) ⇒ Kind: static method of Money
Summary: Returns true if other is an instance of Money
.
Access: public
Param | Type | Description |
---|---|---|
other | * |
value to test |
boolean
Money.canParse(value) ⇒ Kind: static method of Money
Summary: Returns true if value can be parsed to Money
.
Access: public
Param | Type |
---|---|
value | * |
Money
Money.parse(value) ⇒ Kind: static method of Money
Summary: Returns Money
with value and currency calculated from passed value
if value can be parsed into Money
. Otherwise will throw an error.
Access: public
Param | Type | Description |
---|---|---|
value | * |
value to parse to Money |
Money
Money.tryParse(value) ⇒ Kind: static method of Money
Summary: Returns Money
with value and currency calculated from passed value
if value can be parsed into Money
, otherwise null.
Access: public
Param | Type | Description |
---|---|---|
value | * |
value to parse to Money |
Coord
Kind: global class
Summary: Coordindate
- Coord
- new Coord(x, y)
- instance
- .x ⇒
number
- .y ⇒
number
- .value ⇒
Object
- .half ⇒
Coord
- .abs ⇒
Coord
- .equals(other) ⇒
boolean
- .add(other) ⇒
Coord
- .subtract(other) ⇒
Coord
- .multiply(other) ⇒
Coord
- .divide(other) ⇒
Coord
- .round(toNearest) ⇒
Coord
- .toString() ⇒
string
- .x ⇒
- static
- .canParse(value) ⇒
boolean
- .parse(obj) ⇒
Coord
- .tryParse(obj) ⇒
Coord
|null
- .canParse(value) ⇒
new Coord(x, y)
Param | Type |
---|---|
x | number |
y | number |
number
coord.x ⇒ Kind: instance property of Coord
Summary: x value.
Access: public
number
coord.y ⇒ Kind: instance property of Coord
Summary: y value.
Access: public
Object
coord.value ⇒ Kind: instance property of Coord
Summary: Returns an object containing the x and y values.
Access: public
Coord
coord.half ⇒ Kind: instance property of Coord
Summary: Returns a Coord with value half of this Coord.
Access: public
Coord
coord.abs ⇒ Kind: instance property of Coord
Summary: Returns a Coord with absolute value of this Coord.
Access: public
boolean
coord.equals(other) ⇒ Kind: instance method of Coord
Summary: Returns true if this equals other.
Access: public
Param | Type |
---|---|
other | Coord |
Coord
coord.add(other) ⇒ Kind: instance method of Coord
Summary: Returns a Coord whose value is the sum of this and other.
Access: public
Param | Type |
---|---|
other | Coord |
Coord
coord.subtract(other) ⇒ Kind: instance method of Coord
Summary: Returns a Coord whose value is the difference of this and other.
Access: public
Param | Type |
---|---|
other | Coord |
Coord
coord.multiply(other) ⇒ Kind: instance method of Coord
Summary: Returns a Coord whose value is the product of this and other.
Access: public
Param | Type |
---|---|
other | Coord |
Coord
coord.divide(other) ⇒ Kind: instance method of Coord
Summary: Returns a Coord whose value is the quotient of this and other.
Access: public
Param | Type |
---|---|
other | Coord |
Coord
coord.round(toNearest) ⇒ Kind: instance method of Coord
Summary: Returns a Coord whose value is this rounded to nearest tens exponent.
Access: public
Param | Type | Default |
---|---|---|
toNearest | number |
0 |
string
coord.toString() ⇒ Kind: instance method of Coord
Summary: Returns string value.
Access: public
boolean
Coord.canParse(value) ⇒ Kind: static method of Coord
Summary: Returns true if the value can be successfully parsed.
Access: public
Param | Type | Description |
---|---|---|
value | string |
A string value to test. |
Coord
Coord.parse(obj) ⇒ Kind: static method of Coord
Summary: Returns a Coord with the parsed value of the passed value.
Warning: this method will throw an error for values that cannot be parsed.
Access: public
Param | Type |
---|---|
obj | Object |
Coord
| null
Coord.tryParse(obj) ⇒ Kind: static method of Coord
Summary: Returns a Coord with the parsed value of the passed value.
Note: Will return null for values that cannot be parsed.
Access: public
Param | Type |
---|---|
obj | Object |
Interval
Kind: global class
Summary: encapsulates timer boilerplate
- Interval
- new Interval(milliseconds)
- .isRunning ⇒
boolean
- .onInterval() ⇒
this
- .start() ⇒
this
- .clear() ⇒
this
new Interval(milliseconds)
Param | Type |
---|---|
milliseconds | number |
boolean
interval.isRunning ⇒ Kind: instance property of Interval
Summary: Returns true if this Interval is running.
Access: public
this
interval.onInterval() ⇒ Kind: instance method of Interval
Summary: Sets method to call on interval.
Access: public
Param | Type |
---|---|
method. | function |
this
interval.start() ⇒ Kind: instance method of Interval
Summary: Starts timer.
Access: public
this
interval.clear() ⇒ Kind: instance method of Interval
Summary: Clears timer.
Access: public
Timeout
Kind: global class
Summary: encapsulates timer boilerplate
- Timeout
- new Timeout(milliseconds)
- .isRunning ⇒
boolean
- .onTimeout() ⇒
this
- .start() ⇒
this
- .clear() ⇒
this
new Timeout(milliseconds)
Param | Type |
---|---|
milliseconds | number |
boolean
timeout.isRunning ⇒ Kind: instance property of Timeout
Summary: Returns true if this Timeout is running.
Access: public
this
timeout.onTimeout() ⇒ Kind: instance method of Timeout
Summary: Sets method to call on timeout.
Access: public
Param | Type |
---|---|
method. | function |
this
timeout.start() ⇒ Kind: instance method of Timeout
Summary: Starts timer.
Access: public
this
timeout.clear() ⇒ Kind: instance method of Timeout
Summary: Clears timer.
Access: public
object
math : Kind: global namespace
- math :
object
- .random([min], [max]) ⇒
number
- .round(value, toNearest) ⇒
number
- .roundUp(value, toNearest) ⇒
number
- .roundDown(value, toNearest) ⇒
number
- .roundTowardZero(value, toNearest) ⇒
number
- .gcd(a, b) ⇒
number
- .fib(n) ⇒
number
- .fib2(n) ⇒
number
- .fibArray(n) ⇒
number
- .fibArray2(n) ⇒
number
- .tryParseInt(value, valueIfNan) ⇒
number
- .tryParseFloat(value, valueIfNan) ⇒
number
- .random([min], [max]) ⇒
number
math.random([min], [max]) ⇒ Kind: static method of math
Summary: Returns a random value between 0 and 1 by default. Will
return a random number between a min an max value if passed.
Param | Type | Description |
---|---|---|
[min] | number |
random number will not precede this value. |
[max] | number |
random number will not exceed this value. |
number
math.round(value, toNearest) ⇒ Kind: static method of math
Summary: Rounds a value to the nearest tens exponent.
Param | Type |
---|---|
value | number |
toNearest | number |
number
math.roundUp(value, toNearest) ⇒ Kind: static method of math
Summary: Rounds a value up to the nearest tens exponent.
Param | Type |
---|---|
value | number |
toNearest | number |
number
math.roundDown(value, toNearest) ⇒ Kind: static method of math
Summary: Rounds a value down to the nearest tens exponent.
Param | Type |
---|---|
value | number |
toNearest | number |
number
math.roundTowardZero(value, toNearest) ⇒ Kind: static method of math
Summary: Rounds a value toward zero to the nearest tens exponent.
Param | Type |
---|---|
value | number |
toNearest | number |
number
math.gcd(a, b) ⇒ Kind: static method of math
Summary: Returns the greatest common denominator for arguments a and b.
Param | Type |
---|---|
a | number |
b | number |
number
math.fib(n) ⇒ Kind: static method of math
Summary: Returns the nth number in a Fibonacci set.
Note: zero indexed.
Warning: Due to this function's attempt at leveraging tail-calls
it can cause stack overflows for large values of n.
Param | Type | Description |
---|---|---|
n | number |
index. |
number
math.fib2(n) ⇒ Kind: static method of math
Summary: Returns the nth number in a Fibonacci set.
Note: zero indexed.
Warning: This function has better performance and is not
prone to stack overflows as is fib.
Param | Type | Description |
---|---|---|
n | number |
index. |
number
math.fibArray(n) ⇒ Kind: static method of math
Summary: Returns an array of length n with Fibonacci values.
Warning: Due to this function's attempt at leveraging tail-calls
it can cause stack overflows for large values of n.
Param | Type | Description |
---|---|---|
n | number |
length. |
number
math.fibArray2(n) ⇒ Kind: static method of math
Summary: Returns an array of length n with Fibonacci values.
Warning: This function has better performance and is not
prone to stack overflows as is fibArray.
Param | Type | Description |
---|---|---|
n | number |
length. |
number
math.tryParseInt(value, valueIfNan) ⇒ Kind: static method of math
Summary: Returns a parsed integer value for values that can be parsed,
or a set value if passed, or zero.
Param | Type | Description |
---|---|---|
value | string |
value to parse. |
valueIfNan | number |
value to return if {value} cannot be parsed. |
number
math.tryParseFloat(value, valueIfNan) ⇒ Kind: static method of math
Summary: Returns a parsed float value for values that can be parsed,
or a set value if passed, or zero.
Param | Type | Description |
---|---|---|
value | string |
value to parse. |
valueIfNan | number |
value to return if {value} cannot be parsed. |
object
regex : Kind: global namespace
- regex :
object
- .alpha :
RegExp
- .alphaNumeric :
RegExp
- .base64 :
RegExp
- .dataUrl :
RegExp
- .email :
RegExp
- .empty :
RegExp
- .numeric :
RegExp
- .script :
RegExp
- .uid :
RegExp
- .url :
RegExp
- .uuid :
RegExp
- .debounce(regex) ⇒
string
- .escape(string) ⇒
string
- .alpha :
RegExp
regex.alpha : Kind: static constant of regex
RegExp
regex.alphaNumeric : Kind: static constant of regex
RegExp
regex.base64 : Kind: static constant of regex
RegExp
regex.dataUrl : Kind: static constant of regex
RegExp
regex.email : Kind: static constant of regex
RegExp
regex.empty : Kind: static constant of regex
RegExp
regex.numeric : Kind: static constant of regex
RegExp
regex.script : Kind: static constant of regex
RegExp
regex.uid : Kind: static constant of regex
RegExp
regex.url : Kind: static constant of regex
RegExp
regex.uuid : Kind: static constant of regex
string
regex.debounce(regex) ⇒ Kind: static method of regex
Summary: Converts a RegExp to a Regular Expression pattern string.
Returns: string
- - Regular Expression pattern
Param | Type | Description |
---|---|---|
regex | RegExp |
RegExp to convert to pattern |
string
regex.escape(string) ⇒ Kind: static method of regex
Param | Type | Description |
---|---|---|
string | string |
A regex string to escape for using in RegExp(string) |
object
string : Kind: global namespace
- string :
object
- .exports.build(rest) ⇒
string
- .exports.chunk(string, size) ⇒
Array.<string>
- .exports.format(format, rest) ⇒
string
- .exports.trim(string) ⇒
string
- .exports.trimStart(string) ⇒
string
- .exports.trimEnd(string) ⇒
string
- .exports.capitalize(string) ⇒
string
- .exports.mask(string, template, [char]) ⇒
string
- .exports.unmask(string, template, [char]) ⇒
string
- .exports.build(rest) ⇒
string
string.exports.build(rest) ⇒ Kind: static method of string
Summary: Builds a string from string arguments.
Param |
---|
rest |
Array.<string>
string.exports.chunk(string, size) ⇒ Kind: static method of string
Summary: Returns an array of substring strings of size.
Param | Type | Description |
---|---|---|
string | string |
the string value to chunk. |
size | number |
the size of each chunk. |
string
string.exports.format(format, rest) ⇒ Kind: static method of string
Summary: Returns a string template filled with passed values.
Param | Type | Description |
---|---|---|
format | string |
String format in the form "${0} indexed ${1}." |
rest | string |
Value arguments e.g. "Zero", "arguments" |
string
string.exports.trim(string) ⇒ Kind: static method of string
Summary: Returns a string with leading and trailing whitespace trimmed.
Param |
---|
string |
string
string.exports.trimStart(string) ⇒ Kind: static method of string
Summary: Returns a string with leading whitespace trimmed.
Param |
---|
string |
string
string.exports.trimEnd(string) ⇒ Kind: static method of string
Summary: Returns a string with trailing whitespace trimmed.
Param |
---|
string |
string
string.exports.capitalize(string) ⇒ Kind: static method of string
Summary: Returns a string with the first character capitalized.
Param |
---|
string |
string
string.exports.mask(string, template, [char]) ⇒ Kind: static method of string
Summary: Returns a string masked over the passed template.
Param | Type | Description |
---|---|---|
string | string |
String to mask |
template | string | function |
Mask template |
[char] | string |
Mask character in template defaults to '_'. |
string
string.exports.unmask(string, template, [char]) ⇒ Kind: static method of string
Summary: Returns a string unmasked over the passed template.
Param | Type | Description |
---|---|---|
string | string |
String to unmask |
template | string | function |
Mask template |
[char] | string |
Mask character in template defaults to '_'. |
Array
deduplicate(array) ⇒ Kind: global function
Summary: Returns a new array with values of input array having duplicates removed.
Param | Type |
---|---|
array | Array |
function
debounce(func, wait, [immediate]) ⇒ Kind: global function
Summary: Returns a debounced function per the function and wait passed
Param | Type | Description |
---|---|---|
func | function |
The function to debounce. |
wait | number |
The time to wait between calls of func. |
[immediate] | boolean |
True if func should be called immediately. |
*
feature(policy, method) ⇒ Kind: global function
Summary: Feature flag that takes a feature policy
and a method and will call the method IFF the policy
value is or returns true.
Param | Type |
---|---|
policy | boolean | function | Promise |
method | function |
*
opt(method, value) ⇒ Kind: global function
Summary: returns that return value of the passed method
or the value if the passed method throws an error.
Param | Type | Description |
---|---|---|
method | function |
method to execute. |
value | * |
Value to return if method fails. |
*
opt.async(method, value) ⇒ Kind: static method of opt
Summary: returns that return value of the passed method
or the value if the passed method throws an error.
Param | Type | Description |
---|---|---|
method | AsyncFunction | Promise |
method to execute. |
value | * |
Value to return if method fails. |
number
nextTick(func) ⇒ Kind: global function
Summary: Postpones function execution until the next event loop.
Param | Type | Description |
---|---|---|
func | function |
function to move to the next event loop |
Promise.<any>
wait(timeout) ⇒ Kind: global function
Summary: A promisified setTimeout.
Param | Type | Description |
---|---|---|
timeout | number |
the number of milliseconds to wait |