1.0.4 • Published 10 years ago
bue v1.0.4
Bue
Lead Maintainer: Oliver Wang
Node utilities shared amongst the extended baiji universe
Usage
Installation
npm install bueUsage
var biu = require('bue');
bue.isArray([1,2,3]);
// => trueMethod
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.
Language Functions
- clone
Creates a shallow clone structured clone algorithm ofvalue.bue.clone(value) - isArray
Checks ifvalueis classified as anArrayobject.bue.isArrayLike(value) - isBoolean
Checks ifvalueis classified as a boolean primitive or object.bue.isBoolean(value) - isDate
Checks ifvalueis classified as aDateobject.bue.isDate(value) - isEmpty
Checks ifvalueis empty. A value is considered empty unless it's anargumentsobject, 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 ifvalueis classified as aFunctionobject.bue.isFunction(value) - isLength
Checks ifvalueis a valid array-like length.bue.isLength(value) - isNil
Checks ifvalueisnullorundefined.bue.isNil(value) - isNull
Checks ifvalueisnull.bue.isNull(value) - isNullOrUndefined
Checks if
valueisnullorundefined.bue.isNullOrUndefined(value) - isNumber
Checks ifvalueis classified as aNumberprimitive or object.bue.isNumber(value) - isInteger
Checks if
valueis an integer.bue.isInteger(value) - isObject
Checks ifvalueis the language type ofObject.bue.isObject(value) - isPlainObject
Checks ifvalueis a plain object, that is, an object created by theObjectconstructor or one with a[[Prototype]]ofnull.bue.isPlainObject(value) - isPresent
Check ifvalueis notEmptybue.isPresent(value) - isRegExp
Checks ifvalueis classified as aRegExpobject.bue.isRegExp(value) - isString
Checks ifvalueis classified as aStringprimitive or object.bue.isString(value) - isUndefined
Checks ifvalueisundefined.bue.isUndefined(value)
Array Functions
- compact
Creates an array with all falsey values removed. The valuesfalse,null,0,"",undefined, andNaNare falsey.bue.compact(array) - flatten
Flattensarraya single level.bue.flatten(array) - first
Gets the first element ofarray.bue.first(array) - last
Gets the last element ofarray.bue.last(array)
Object Functions
- 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 atpathofobject. If the resolved value isundefinedthedefaultValueis used in its place.bue.get(object, path, [defaultValue]) - hasIn
Checks ifpathis 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)
String Functions
- pad
Padsstringon 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
Padsstringon the left side if it's shorter thanlength. Padding characters are truncated if they exceedlength.bue.padLeft([string=''], [length=0], [chars=' ']) - padRight
Padsstringon 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=''])
Collection Functions
bue.iteratee: a function that a invokesfuncwith the arguments of the created function.
- each
Iterates over elements ofcollectioninvokingiterateefor 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.eachexcept that it iterates over elements ofcollectionfrom right to left.bue.eachRight(collection, [iteratee = bue.identity]) - map
Creates an array of values by running each element incollectionthroughiteratee. The iteratee is invoked with three arguments: (value, index|key, collection).bue.map(collection, [iteratee = bue.identity])
Math Functions
- max
Computes the maximum value ofarray. Ifarrayis empty or falseyundefinedis returned.bue.max(array) - min
Computes the minimum value ofarray. Ifarrayis empty or falseyundefinedis returned.bue.min(array)
Assertion Testing
- assert
The
assertmodule provides a simple set of assertion tests that can be used to test invariants, based on nodejs core moduleassert
License
MIT
1.0.4
10 years ago