subtractly
v1.0.3
Published
Javascript utility whose main exported function is a polymorphic subtraction function.
Downloads
3
Maintainers
Readme
Subtractly - Javascript utility to help you with subtraction
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.