nested-object-mask

0.1.5 • Public • Published

nested-object-mask (NOM)

NPM Version Build Status Built with Grunt

Like object-mask, but nested

Note: This library contains a rich nested object masking implementation, and has more complicated semantics than similar libraries for flat object masking. If you do not specifically need the nesting support from this library, try object-mask instead for a simpler mental model.

Although the API is fairly simple, this module is well tested and thoroughly documented.

Installation Instructions

Install the module via npm: npm install --save nested-object-mask

Usage

NB: nested-object-mask works happily with plain JS, but it is written in coffeescript, and so are the examples below (because it's 2015).

Basic

At its simplest, nested-object-mask does this:

# the hero of our story 
masker = require 'nested-object-mask'
 
# the source object we'd like to mask 
object =
  keepThisKey: 'some value'
  dontKeepThisKey: 'good bye :<'
 
# a mask that determines which keys will be kept from the original object. if a 
# property has a truthy value in the mask, it is kept from the original object 
mask =
  keepThisKey: true
 
# our result should look like this 
expected = 
  keepThisKey: 'some value'
 
# do the thing! 
result = masker.mask objectmask
 
# looks good :) 
assert.deepEqual resultexpected

License

This software is licensed under the MIT License. See the LICENSE file for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i nested-object-mask

Weekly Downloads

12

Version

0.1.5

License

none

Last publish

Collaborators

  • kaen