New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

object-funcs

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-funcs

A very limited subset of object functions I use every day

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
20
100%
Maintainers
1
Weekly downloads
 
Created
Source

object-funcs

A very limited subset of object functions I use every day

Install

npm i object-funcs

Package on npm

API

defined([arg], [arg], [...])

Return the first defined arg

arg is considered not defined when

  • arg is null
  • arg is undefined
  • arg is NaN
const defined = require('object-funcs/defined')

var opts = {y:false, w:4}

// false
defined(opts.x, opts.y, 100)

// 'yes'
defined(null, undefined, NaN, 'yes')

merge([obj], [obj], [...])

Merge properties of a Plain Object or a serie of Plain Objects into a new one

const merge = require('object-funcs/merge')

var ref = {a:'foo'}

// {a:'foo', b:'bar'}
var obj = merge(ref, {b:'bar'})

// {a:'foo'}
ref

Always overwrite properties

const merge = require('object-funcs/merge')

// {a:'foo', b:'baz', c:'quux'}
merge({a:'foo'}, {b:'bar'}, {b:'baz'}, {c:'quux'})

No deep merge, only first level of properties are injected

const merge = require('object-funcs/merge')

var ref = {foo:{bar:'baz'}}

// {foo:{bar:'baz'}, a:1}
merge(ref, {a:1})

// {foo:{b:2}}
merge(ref, {foo:{b:2}})

only(obj, keys)

Return a new Plain Object with filtered properties

keys can be a String or an Array of targeted keys

keys can also be a RegExp

const only = require('object-funcs/only')

// {a:1, b:2}
only({a:1, b:2, c:3}, 'a b')

// {b:2, c:3}
only({a:1, b:2, c:3}, ['b', 'c'])

// {bar:1, baz:2}
only({foo:0, bar:1, baz:2, quux:3}, /^ba/)

Partial comparison of two objects

Check if the keys / values in search are equals in obj

const similar = require('object-funcs/similar')

// true
similar({foo:'bar', baz:54}, {baz:54})

// false
similar({foo:'bar', baz:54}, {baz:54, a:1})

// true
similar({foo:{bar:{baz:'quux', c:3}, b:2}, a:1}, {foo:{bar:{baz:'quux'}}})

Thanks

Mainly forked / inspired on

License

MIT

Keywords

object

FAQs

Package last updated on 12 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts