Skip to content
This repository has been archived by the owner on Aug 27, 2019. It is now read-only.
/ blacklist Public archive

A module that shallow copies an object, ignoring keys depending on the filter object passed to it.

License

Notifications You must be signed in to change notification settings

dcousens/blacklist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blacklist

Build Status Version

This module shallow copies an object, ignoring keys depending on the filter object passed to it.

Filters can be provided as an object (truthy keys are blacklisted) or string arguments.

ESNext alternative

If you can, don't use this library. Use ESNext destructuring assignment instead.

let { a, ...filtered } = { a: 1, b: 2, c: 3 }
// filtered => { b: 2, c: 3 }

Example

var blacklist = require('blacklist')

// ...

var someInput = { a: 1, b: 2, c: 3 }

blacklist(someInput, 'a')
// => { b: 2, c: 3 }

Protip: you can also use a filter object

blacklist(someInput, {
  a: true,   // a will not be in the result
  b: false,  // b will be in the result
  c: 1 > 2   // false, therefore c will be in the result
})
// => { b: 2, c: 3 }

LICENSE MIT

About

A module that shallow copies an object, ignoring keys depending on the filter object passed to it.

Resources

License

Stars

Watchers

Forks

Packages