utils

utils

Utility methods used by CacheFactory.

Source:

Example

import { utils } from 'cachefactory'
console.log(utils.isString('foo')) // true

Methods

(static) equals(a, a) → {booleal}

Returns whether the two values are strictly equal.

Parameters:
Name Type Description
a *

The first value.

a *

The second value.

Source:
Returns:

Whether the two values are strictly equal.

Type
booleal
Example
import { utils } from 'cachefactory'

console.log(utils.equals(4, 4) // true
console.log(utils.equals(4, '4') // false

(static) fromJson(json) → {object}

Proxy for JSON.parse.

Parameters:
Name Type Description
json string

JSON to parse.

Source:
See:
Returns:

The parsed object.

Type
object
Example
import { utils } from 'cachefactory'

const a = utils.fromJson('{"name":"John"}')
console.log(a) // { name: 'John' }

(static) isFunction(value) → {boolean}

Returns whether the provided value is a function.

Parameters:
Name Type Description
value *

The value to test.

Source:
Returns:

Whether the provided value is a function.

Type
boolean
Example
import { utils } from 'cachefactory'
const a = function (){ console.log('foo bar')}
const b = { foo: "bar" }
console.log(utils.isFunction(a)) // true
console.log(utils.isFunction(b)) // false

(static) isNumber(value) → {boolean}

Returns whether the provided value is a number.

Parameters:
Name Type Description
value *

The value to test.

Source:
Returns:

Whether the provided value is a number.

Type
boolean
Example
import { utils } from 'js-data'
const a = 1
const b = -1.25
const c = '1'
console.log(utils.isNumber(a)) // true
console.log(utils.isNumber(b)) // true
console.log(utils.isNumber(c)) // false

(static) isObject(value) → {boolean}

Returns whether the provided value is an object.

Parameters:
Name Type Description
value *

The value to test.

Source:
Returns:

Whether the provided value is an object.

Type
boolean
Example
import { utils } from 'cachefactory'
const a = { foo: "bar" }
const b = 'foo bar'
console.log(utils.isObject(a)) // true
console.log(utils.isObject(b)) // false

(static) isString(value) → {boolean}

Returns whether the provided value is a string.

Parameters:
Name Type Description
value *

The value to test.

Source:
Returns:

Whether the provided value is a string.

Type
boolean
Example
import { utils } from 'cachefactory'
console.log(utils.isString('')) // true
console.log(utils.isString('my string')) // true
console.log(utils.isString(100)) // false
console.log(utils.isString([1,2,4])) // false

(static) toJson(value) → {string}

Proxy for JSON.stringify.

Parameters:
Name Type Description
value *

Value to serialize to JSON.

Source:
See:
Returns:

JSON string.

Type
string
Example
import { utils } from 'cachefactory'

const a = { name: 'John' }
console.log(utils.toJson(a)) // '{"name":"John"}'