@ngard/tiny-omit
v1.0.0
Published
A minimal-weight utility equivalent to lodash.omit
Downloads
1
Readme
tiny-omit
A minimal utility equivalent to lodash.omit
. For when every byte counts!
Install
npm install @ngard/tiny-omit
Syntax
omit(/* source, key [, key2, ...] */);
Parameters
source
- [Object|Array]
The object whose key/value pairs will be omitted.
key [, key2, ...]
- [String|Array<String>]
An array or list of key names.
Returns
An object comprised of the un-omitted key/value pairs.
Example
import { omit } from '@ngard/tiny-omit';
const person = {
name: 'Luke Skywalker',
description: 'whiny Jedi',
address: '312 Sand St, Tatooine',
SSN: '123456789'
}
const safe = omit(person, 'address', 'SSN');
// { name: 'Luke Skywalker', description: 'whiny Jedi' }
const safe = omit(person, ['address', 'SSN']);
// { name: 'Luke Skywalker', description: 'whiny Jedi' }
/* Omitting Array indexes */
omit(['a', 'b', 'c'], 0, 2); // { 1: 'b' }