subtractly

1.0.3 • Public • Published

Subtractly - Javascript utility to help you with subtraction

NPM version (>=0.4) NPM Downloads Coverage Status Build Status Dependencies js-standard-style GitHub license

Exports a polymorphic 'subtract()' that can take numbers, strings, objects, & arrays

Installation

npm install --save subtractly

What is this magic? How does it work?

This super simple library exports a curried function that allows you to subtract numbers, strings, and diff objects & arrays.

  • Subtracting two objects
let obj1 = {foo: 'bar', baz: 'blob'},
    obj2 = {baz: 'foobar'};

subtractly(obj1, obj2);
// => [{ foo: 'bar' }]
  • Deleting properties from an object by passing an array of properties to be removed.
let obj1 = {foo: '123', bar: '456', baz: '789'},

subtractly(obj1, ['foo', 'bar']);
// => [{ baz: '789' }]
  • Diffing arrays
let arr1 = [1,2,3,4,5],
    arr2 = [2,3];

subtractly(arr1, arr2);
// => [1,4,5]
  • Removing all instances of a substring from a string
subtractly('mississippi', 'i');
// => msssspp
  • Subtracting numbers is difficult... subtractly can handle that as well ;)
subtractly(52, 10);
// => 42

License

MIT, see LICENSE.md for more information.

Package Sidebar

Install

npm i subtractly

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • kassabian