Lead Maintainer: Oliver Wang
Node utilities shared amongst the extended baiji universe
npm install bue
var biu = require('bue');
bue.isArray([1,2,3]);
// => true
All the functions used in Bue is based on lodash(v4.0.0-pre), some of them have been customized(italic) in the following list.
- clone
Creates a shallow clone structured clone algorithm ofvalue
.bue.clone(value)
- isArray
Checks ifvalue
is classified as anArray
object.bue.isArrayLike(value)
- isBoolean
Checks ifvalue
is classified as a boolean primitive or object.bue.isBoolean(value)
- isDate
Checks ifvalue
is classified as aDate
object.bue.isDate(value)
- isEmpty
Checks ifvalue
is empty. A value is considered empty unless it's anarguments
object, array, string, or jQuery-like collection with a length greater than0
, an object with own enumerable properties or a number.bue.isEmpty(value)
- isFunction
Checks ifvalue
is classified as aFunction
object.bue.isFunction(value)
- isLength
Checks ifvalue
is a valid array-like length.bue.isLength(value)
- isNil
Checks ifvalue
isnull
orundefined
.bue.isNil(value)
- isNull
Checks ifvalue
isnull
.bue.isNull(value)
- isNullOrUndefined
Checks if
value
isnull
orundefined
.bue.isNullOrUndefined(value)
- isNumber
Checks ifvalue
is classified as aNumber
primitive or object.bue.isNumber(value)
- isInteger
Checks if
value
is an integer.bue.isInteger(value)
- isObject
Checks ifvalue
is the language type ofObject
.bue.isObject(value)
- isPlainObject
Checks ifvalue
is a plain object, that is, an object created by theObject
constructor or one with a[[Prototype]]
ofnull
.bue.isPlainObject(value)
- isPresent
Check ifvalue
is notEmpty
bue.isPresent(value)
- isRegExp
Checks ifvalue
is classified as aRegExp
object.bue.isRegExp(value)
- isString
Checks ifvalue
is classified as aString
primitive or object.bue.isString(value)
- isUndefined
Checks ifvalue
isundefined
.bue.isUndefined(value)
- compact
Creates an array with all falsey values removed. The valuesfalse
,null
,0
,""
,undefined
, andNaN
are falsey.bue.compact(array)
- flatten
Flattensarray
a single level.bue.flatten(array)
- first
Gets the first element ofarray
.bue.first(array)
- last
Gets the last element ofarray
.bue.last(array)
- extend
Assigns own enumerable properties of source objects to the destination object. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources but it iterates over own and inherited source properties.bue.entend(object, [sources])
- get
Gets the value atpath
ofobject
. If the resolved value isundefined
thedefaultValue
is used in its place.bue.get(object, path, [defaultValue])
- hasIn
Checks ifpath
is a direct or inherited property ofobject
.bue.hasIn(object, path)
- keys
Creates an array of the own enumerable property names ofobject
.bue.keys(object)
- keysIn
Creates an array of the own and inherited enumerable property names ofobject
.bue.keysIn(object)
- values
Creates an array of the own enumerable property values ofobject
.bue.values(object)
- pad
Padsstring
on the left and right sides if it's shorter thanlength
. Padding characters are truncated if they can't be evenly divided bylength
.bue.pad([string=''], [length=0], [chars=' '])
- padLeft
Padsstring
on the left side if it's shorter thanlength
. Padding characters are truncated if they exceedlength
.bue.padLeft([string=''], [length=0], [chars=' '])
- padRight
Padsstring
on the right side if it's shorter thanlength
. Padding characters are truncated if they exceedlength
.bue.padRight([string=''], [length=0], [chars=' '])
- escapeRegExp
Escape RegExp special characters.
bue.escapeRegExp([string=''])
bue.iteratee
: a function that a invokesfunc
with the arguments of the created function.
- each
Iterates over elements ofcollection
invokingiteratee
for each element. The iteratee is invoked with three arguments: (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returningfalse
.bue.each(collection, [iteratee = bue.identity])
- eachRight
This method is likebue.each
except that it iterates over elements ofcollection
from right to left.bue.eachRight(collection, [iteratee = bue.identity])
- map
Creates an array of values by running each element incollection
throughiteratee
. The iteratee is invoked with three arguments: (value, index|key, collection).bue.map(collection, [iteratee = bue.identity])
- max
Computes the maximum value ofarray
. Ifarray
is empty or falseyundefined
is returned.bue.max(array)
- min
Computes the minimum value ofarray
. Ifarray
is empty or falseyundefined
is returned.bue.min(array)
- assert
The
assert
module provides a simple set of assertion tests that can be used to test invariants, based on nodejs core moduleassert
MIT