1.0.2 • Published 10 years ago
baiji-meld v1.0.2
Meld
Lead Maintainer: Oliver Wang
Node utilities shared amongst the extended baiji universe
Usage
Installation
npm install baiji-meldUsage
var meld = require('baiji-meld');
meld.isArray([1,2,3]);
// => trueMethod
All the functions used in Meld 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.meld.clone(value) - isArray
Checks ifvalueis classified as anArrayobject.meld.isArrayLike(value) - isBoolean
Checks ifvalueis classified as a boolean primitive or object.meld.isBoolean(value) - isDate
Checks ifvalueis classified as aDateobject.meld.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.meld.isEmpty(value) - isFunction
Checks ifvalueis classified as aFunctionobject.meld.isFunction(value) - isLength
Checks ifvalueis a valid array-like length.meld.isLength(value) - isNil
Checks ifvalueisnullorundefined.meld.isNil(value) - isNull
Checks ifvalueisnull.meld.isNull(value) - isNumber
Checks ifvalueis classified as aNumberprimitive or object.meld.isNumber(value) - isObject
Checks ifvalueis the language type ofObject.meld.isObject(value) - isPlainObject
Checks ifvalueis a plain object, that is, an object created by theObjectconstructor or one with a[[Prototype]]ofnull.meld.isPlainObject(value) - isPresent
Check ifvalueis notEmptymeld.isPresent(value) - isRegExp
Checks ifvalueis classified as aRegExpobject.meld.isRegExp(value) - isString
Checks ifvalueis classified as aStringprimitive or object.meld.isString(value) - isUndefined
Checks ifvalueisundefined.meld.isUndefined(value)
Array Functions
- compact
Creates an array with all falsey values removed. The valuesfalse,null,0,"",undefined, andNaNare falsey.meld.compact(array) - flatten
Flattensarraya single level.meld.flatten(array) - first
Gets the first element ofarray.meld.first(array) - last
Gets the last element ofarray.meld.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.meld.entend(object, [sources]) - get
Gets the value atpathofobject. If the resolved value isundefinedthedefaultValueis used in its place.meld.get(object, path, [defaultValue]) - hasIn
Checks ifpathis a direct or inherited property ofobject.meld.hasIn(object, path) - keys
Creates an array of the own enumerable property names ofobject.meld.keys(object) - keysIn
Creates an array of the own and inherited enumerable property names ofobject.meld.keysIn(object) - values
Creates an array of the own enumerable property values ofobject.meld.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.meld.pad([string=''], [length=0], [chars=' ']) - padLeft
Padsstringon the left side if it's shorter thanlength. Padding characters are truncated if they exceedlength.meld.padLeft([string=''], [length=0], [chars=' ']) - padRight
Padsstringon the right side if it's shorter thanlength. Padding characters are truncated if they exceedlength.meld.padRight([string=''], [length=0], [chars=' ']) - escapeRegExp
Escape RegExp special characters.
meld.escapeRegExp([string=''])
Collection Functions
meld.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.meld.each(collection, [iteratee = meld.identity]) - eachRight
This method is likemeld.eachexcept that it iterates over elements ofcollectionfrom right to left.meld.eachRight(collection, [iteratee = meld.identity]) - map
Creates an array of values by running each element incollectionthroughiteratee. The iteratee is invoked with three arguments: (value, index|key, collection).meld.map(collection, [iteratee = meld.identity])
Math Functions
- max
Computes the maximum value ofarray. Ifarrayis empty or falseyundefinedis returned.meld.max(array) - min
Computes the minimum value ofarray. Ifarrayis empty or falseyundefinedis returned.meld.min(array)
License
MIT