\ / _. | _ ._ _|_ o ._ _
\/ (_| | (/_ | | |_ | | | (/_
JavaScript's Sister, and protector — inspired by Underscore; Valentine provides you with type checking, functional iterators, and common utility helpers such as waterfalls, queues, and parallels; all utilizing native JavaScript methods for optimal speed.
Deprecation notice
As of version 2.0.0
— Valentine no longer supports <= IE8
and <= Safari 4
. It's been real, but time to move on. To access this level of support, use the 1.8 tag.
Browser usage:
Node users
npm install valentine
var v =// showcase object style; // => 'A B C'
API
iterators
-
v.each(array || object, callback[, scope]) => void
-
v.map(array || object, callback[, scope]) => array
-
v.every(array || object, *callback[, scope]) => boolean
-
v.some(array || object, *callback[, scope]) => boolean
-
v.filter(array || object, *callback[, scope]) => array || object
-
v.reject(ar, *callback[, scope])
-
v.indexOf(ar, item[, start])
-
v.lastIndexOf(ar, item[, start])
-
v.reduce(ar, **callback, memo[, scope])
-
v.reduceRight(ar, **callback, memo[, scope])
*callback
is defined as:
// when array{}// when object{}
**calback
is defined as:
{}
utility
- v.extend(obj[, obj2[, obj3[...]]]) => object
- v.merge(ar1, ar2) => array (ar1 modified)
- v.pluck(array||object, key) => array
- v.toArray(sparse) => array (duh)
- v.size(array) => number
- v.find(array, key) => *value
- v.compact(array) => array
- v.flatten(array) => array
- v.uniq(array) => array
- v.first(array) => *value
- v.last(array) => *value
- v.keys(object) => array
- v.values(object) => array
- v.trim(string) => string
- v.bind(scope, fn, [curried args]) => function
- v.curry(fn, [curried args]) => function
- v.inArray(array, needle) => boolean
- v.memo(fn, hasher) => function
// use memo to cache expensive methodsvar getAllTheDom = v
parallel api
- v.parallel([fn args]) => void
v
waterfall api
- v.waterfall([fn args])
- v.waterfall([fn1, fn2<, fn3>], callback)
v
series api
- similar to
waterfall
except passing along args to next function is not a concern - v.series([fn1, fn2<, fn3>], callback)
v
Queue api
- v.queue([fn args])
var it = vitnext
throttle, debounce, throttleDebounce
- v.throttle(ms, fn, opt_scope) => function
- v.debounce(ms, fn, opt_scope) => function
- v.throttleDebounce(throttleMs, debounceMs, fn, opt_scope) => function
windowonscroll = vwindowmousemove = vtextareaonkeypress = v
type checking
Each method returns a boolean
- v.is.func(o)
- v.is.string(o)
- v.is.element(o)
- v.is.array(o)
- v.is.arrLike(o)
- v.is.num(o)
- v.is.bool(o)
- v.is.args(o)
- v.is.empty(o)
- v.is.date(o)
- v.is.nan(o)
- v.is.nil(o)
- v.is.undef(o)
- is.regexp(o)
- v.is.obj(o)
Object Style
; // => ['A', 'B', 'C']
Chains
compactvalue; // => ['A', 'B', 'C']
Ender Support
ender add valentine
// available as a top level method on `$`$// top level methods in bridge$eachmapmergeextendtoArraykeysvaluestrimbindcurryparallelwaterfallinArrayqueue
Or just require the valentine module
! {}
Developers
Care to contribute? Make your edits to src/valentine.js
and get your environment up and running
npm installmakemake testopen tests/index.html
Happy iterating!