get-destructor
v1.0.0
Published
Create a getter that supports destructuring.
Downloads
6
Readme
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.