1.0.0 • Published 5 years ago

@ngard/tiny-omit v1.0.0

Weekly downloads
22
License
MIT
Repository
github
Last release
5 years ago

tiny-omit

source bundle size build status license

A minimal utility equivalent to lodash.omit. For when every byte counts!

lodash.omit: bundle size tiny-omit: bundle size

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' }