Skip to content

moeriki/get-destructor

Repository files navigation

get-destructor

Create a getter that supports destructuring.

npm version Build Status Coverage Status dependencies Status


Quick start

npm install --save get-destructor
const beatles = {
  john: { name: 'John', age: 40 },
  paul: { name: 'Paul', age: 75 },
};

const getter = getDestructor((key) => beatles[key]);

getter('john'); // = { name: 'John', age: 40 }

const { john, paul } = getter();

// john = { name: 'John', age: 40 }
// paul = { name: 'Paul', age: 75 }

API

getDestructor(getter:function) :function

getter is called with all arguments or just the key in case of destructuring.

About

Create a getter that supports destructuring.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published