Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
/ this-drop Public archive

Return the `this` object stripped of some properties.

License

Notifications You must be signed in to change notification settings

b12-archive/this-drop

Repository files navigation

Coveralls – test coverage Travis – build status David – status of dependencies Code style: airbnb

 

::drop()

Return the this object stripped of some properties.

 

const drop = require('this-drop');
const abc = {a: 1, b: 2, c: 3};

abc::drop(['a', 'c']);
//» {b: 2}

 

Installation

$ npm install this-drop

 

Usage

object::drop(keys)
  ⇒ newObject

See the example above.

keys should be iterable – you’ll probably want to use an array here.

We don’t mutate the object. We make a shallow copy instead:

const xyz = {x: 1, y: '2', z: [3]};
const xz = xyz::drop(['y']);

xyz.z === xz.z;
//» true

Note that the example uses the ES 2016 function bind syntax. You can still use the library in any JS engine down to ES5 though:

drop.call(abc, ['a', 'c']);
//» {b: 2}

 

License

MIT © Studio B12 GmbH

About

Return the `this` object stripped of some properties.

Resources

License

Stars

Watchers

Forks

Packages

No packages published