Skip to content

Instantly share code, notes, and snippets.

@VitorLuizC
Last active December 10, 2018 22:39
Show Gist options
  • Save VitorLuizC/16dc1b129e8facc1e355e452bddedd12 to your computer and use it in GitHub Desktop.
Save VitorLuizC/16dc1b129e8facc1e355e452bddedd12 to your computer and use it in GitHub Desktop.
"without" module exports a function. It returns a new object without specified properties.
/**
* Returns new object without specified properties.
* @param {Array.<string>} keys
* @param {Object.<string, *>} object
* @returns {Object.<string, *>}
*/
const without = (
[ key, ...keys ] = [],
{ [key]: _, ...object } = {}
) => keys.length ? object : without(keys, object);
export { without, without as default };
@gtkatakura
Copy link

This code has an infinite recursion, change:

keys.length ? object : without(keys, object);

to:

keys.length ? without(keys, object) : object;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment