1.0.1 • Published 10 years ago
underscore-mixins2 v1.0.1
underscore-mixins2
Exports underscore with additional methods (see below).
Important!
We don't modify underscore from cache see: library-mixin-fake
install
npm install --save underscore-mixins2usage
var _ = require('underscore-mixins2');Additional methods
_.lookup
returns value of error.responseJSON.error.message if it exists otherwise undefined
_.lookup(error, 'responseJSON.error.message');returns value of error.responseJSON.error.message if it exists otherwise false
_.lookup(error, 'responseJSON.error.message', false); returns value of error.responseJSON.error.message if it exists and evaluates to true
otherwise returns 'not exists'
_.lookup(error, 'responseJSON.error.message', 'not exists', 'not exists')_.lookupLength
returns value of error.responseJSON.error.stack.length if it exists otherwise 0
_.lookupLength(error, 'responseJSON.error.stack', 0);_.deepExtend
returns object:
{ db: { a: 1, b: 22, c: 3 }, ldap: 1 }_.deepExtend({db: {a:1, b:2}}, {ldap: 1, db: {b: 22, c: 3}});