Skip to content

machobearstudio/poly-exclude

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poly-exclude

Excludes given keys from an object or array

Motivation

It's a common task in data transformation pipelines to remove certain keys from incoming objects or arrays.

Features

  • Works with objects and arrays
  • Automatically curried

Installation

npm install poly-exclude

Testing

npm test

Usage

var exclude = require('poly-exclude');

var object = {
  a: 100,
  b: 200,
  c: 'blah, blah'
};

var array = [
  100,
  200,
  'blah, blah'
];

// Complete application
console.log(exclude(['a', 'c'], object)); // => { b: 200 }
console.log(exclude([0, 2], array)); // => [200]

// Partial application
var removeB = exclude('b');
console.log(removeB(object)); // => { a: 100, c: 'blah, blah' }

var remove1 = exclude(1);
console.log(remove1(array)); // => [100, 'blah, blah']

About

Exclude selected fields from an object or array

Resources

License

Stars

Watchers

Forks

Packages

No packages published