node package manager
Painless code sharing. npm Orgs help your team discover, share, and reuse code. Create a free org »

@eins78/active-lodash

active-lodash

NPM version Build Status Coveralls Status Dependency Status

A version of lodash customized to feel more like Ruby/Rails/ActiveSupport.

Features

  • custom, reduced, modern build of lodash

  • non-destructive merge, assign, extend, etc.
    (They are always returning a new object)

  • present() and presence()

  • Does not extend prototypes.
    (If you want that, have a look at rodash or activesupport)

  • <your idea here>

Install

npm i -D @eins78/active-lodash

Usage

import f from '@eins78/active-lodash'

or

var f = require('@eins78/active-lodash')
 

then

assert.equal((f(23).presence() || 42), 23)
assert.equal((f(null).presence() || 42), 42)
 
assert.equal(f.present({a: 1}), true)
assert.equal(f.present([1]), true)
assert.equal(f.present(true), true)
assert.equal(f.present(false), true)
assert.equal(f.present(function () {}), true)
 
assert.equal(f.present({}), false)
assert.equal(f.present([]), false)
assert.equal(f.present(undefined), false)
assert.equal(f.present(null), false)

(See tests for more Examples.)

License

CC-0 © Max F. Albrecht