const Pluck = require('./Pluck');
// Exaple
const params = {
name : 'Lenivene Bezerra',
email : '[email protected]',
username : 'lenivene'
}
const plucked = Pluck( params, 'name', 'email' );
// This result
// { name : 'Lenivene Bezerra', email : 'lenivene@soufleet.com' }
console.log("Plucked", plucked);
Last active
September 16, 2019 14:02
-
-
Save lenivene/4ee7b24936e5cd4d09cebfc8fae1e4a5 to your computer and use it in GitHub Desktop.
A simple pluck function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (object, ...keys) => { | |
const newObject = {}; | |
keys.forEach(key => newObject[key] = object[key]) | |
return newObject; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment