
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
The utilities for working with a collections such as objects, arrays and primitives such as numbers, strings, etc.
The utilities for working with a collections such as objects, arrays and primitives such as numbers, strings, etc.
Install with yarn:
$ yarn add utilitify
Install with npm:
$ npm install --save utilitify
These utilities include a different methods for working with JavaScript collections and primitives.
For example, if you want to merge two objects recursively, you can use a method 'mergeDeep':
import { mergeDeep } from 'utilitify';
mergeDeep({ a: { b: { c: 'c', d: 'd' } } }, { a: { b: { e: 'e', f: 'f' } } });
//=> { a: { b: { c: 'c', d: 'd', e: 'e', f: 'f' } } }
You can find all methods in API section.
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ yarn && yarn test
mergeDeepRecursively merge values in a javascript object.
import { mergeDeep } from 'utilitify';
mergeDeep({ a: 1, b: [2, 3] }, { b: [3, 4], c: 3 });
//=> { a: 1, b: [2, 3, 4], c: 3 }
cloneDeepRecursively (deep) clone JavaScript native types, like Object, Array, RegExp, Date as well as primitives.
import { cloneDeep } from 'utilitify';
const obj = { a: 'b' };
const arr = [obj];
const copy = cloneDeep(arr);
obj.c = 'd';
console.log(copy);
//=> [{ a: 'b' }]
console.log(arr);
//=> [{ a: 'b', c: 'd' }]
cloneShallowCreates a shallow clone of any JavaScript value.
import { cloneShallow } from 'utilitify';
const arr = [{ a: 0 }, { b: 1 }];
const foo = cloneShallow(arr);
// foo => [{ 'a': 0 }, { 'b': 1 }]
// array is cloned
assert(actual === expected); // false
// array elements are not
assert.deepEqual(actual[0], expected[0]); // true
unionCombines a list of arrays, returning a single array with unique values, using strict equality for comparisons.
import { union } from 'utilitify';
union(['a'], ['b', 'c'], ['d', 'e', 'f']);
//=> ['a', 'b', 'c', 'd', 'e', 'f']
union(['a', 'a'], ['b', 'c']);
//=> ['a', 'b', 'c']
isObjectCheck if any JavaScript value is object.
import { isObject } from 'utilitify';
const obj = { a: 1, b: 2 };
isObject(obj);
//=> true
isObject(1);
//=> false
isNilCheck if any JavaScript value is null or undefined.
import { isNil } from 'utilitify';
const obj = { a: 1, b: 2 };
isNil(obj);
//=> false
isNil(null);
//=> true
isNullCheck if any JavaScript value is null.
import { isNull } from 'utilitify';
isNull(undefined);
//=> false
isNull(null);
//=> true
isUndefinedCheck if any JavaScript value is undefined.
import { isUndefined } from 'utilitify';
isUndefined(null);
//=> false
isUndefined(undefined);
//=> true
getObjectWithoutEmptyPropsFromRemove from object all values which equal 'null', 'undefined' or empty string.
import { getObjectWithoutEmptyPropsFrom } from 'utilitify';
const objectWithEmptyProps = {
a: 1,
b: null,
c: 'string',
d: undefined,
e: '',
};
getObjectWithoutEmptyPropsFrom(objectWithEmptyProps);
//=> { a: 1, c: 'string' }
getObjectWithoutUndefinedPropsFromRemove from object all values which equal 'undefined'.
import { getObjectWithoutUndefinedPropsFrom } from 'utilitify';
const objectWithUndefinedProps = {
a: 1,
b: null,
c: 'string',
d: undefined,
e: '',
};
getObjectWithoutUndefinedPropsFrom(objectWithUndefinedProps);
//=> { a: 1, b: null, c: 'string', e: '' }
getTruncatedStringGet truncated string by number of symbols (second argument) with punctuation mark on the end if need.
import { getTruncatedString } from 'utilitify';
getTruncatedString('string', 3);
//=> str
getTruncatedString('string', 3, '...');
//=> str...
upsertObjectToArrayUpdate object in array. If object does not exist, method push new value (third argument) to array.
import { upsertObjectToArray } from 'utilitify';
const arr = [{ a: 1 }, { b: 2 }];
upsertObjectToArray(arr, { a: 1 }, { a: 3 });
console.log(arr);
//=> [{ a: 3 }, { b: 2 }]
getObjectFromArrayByPropGet object from array by it's property.
import { getObjectFromArrayByProp } from 'utilitify';
const arr = [{ a: 1 }, { b: 2 }];
getObjectFromArrayByProp(arr, 'a');
//=> { a: 1 }
getArrayOfObjectsWithoutPropGet new array of objects from which are deleted property (second argument).
import { getArrayOfObjectsWithoutProp } from 'utilitify';
const arr = [{ a: 1, c: 10 }, { b: 2 }];
getArrayOfObjectsWithoutProp(arr, 'a');
//=> [{ c: 10 }, { b: 2 }]
isJsonStringCheck if string is JSON.
import { isJsonString } from 'utilitify';
const str = '{"a":2}';
isJsonString(str);
//=> true
getJsonFromStringGet JSON from string if possibly. If string is not valid JSON string, method returns empty object.
import { getJsonFromString } from 'utilitify';
const validStr = '{"a":2}';
const invalidStr = '{a:2}';
getJsonFromString(validStr);
//=> { a: 2 }
getJsonFromString(invalidStr);
//=> {}
toPascalCaseConvert any string to 'PascalCase' string.
import { toPascalCase } from 'utilitify';
toPascalCase('pascal case');
//=> PascalCase
composeCompose several functions which return some result.
import { compose } from 'utilitify';
const inc = (value) => value + 1;
const mul2 = (value) => value * 2;
compose(inc, mul2)(1);
//=> 4
setInSet new value (second argument) in object by property (third argument) and return new object.
import { setIn } from 'utilitify';
const obj = {
a: 1,
b: 2,
c: {
d: 3,
},
};
const result = setIn(obj, 5, 'd.f.r');
console.log(result);
//=> { a: 1, b: 2, c: { d: 3 }, d: { f: { r: 5 } } }
delInDelete property (second argument) in object and return new object.
import { delIn } from 'utilitify';
const obj = {
a: 1,
b: 2,
c: {
d: 3,
},
};
const result = delIn(obj, 'c.d');
console.log(result);
//=> { a: 1, b: 2, c: {} }
differenceCompare two objects (or arrays) and return a new object (or array) who represent the diff.
import { difference } from 'utilitify';
const obj = {
a: 1,
b: 2,
c: {
d: 3,
},
};
const obj2 = {
c: {
d: {
f: 5,
},
},
g: 5,
};
const testObj = { ...obj, ...obj2 };
const result = difference(obj, testObj);
console.log(result);
//=> { c: { d: 3 } }
isDifferenceCompare two objects (or arrays) and return 'true' if equal or 'false' if not.
import { isDifference } from 'utilitify';
const arr1 = [1, 2, 3];
const arr2 = [2, 3, 4];
isDifference(arr1, arr2);
//=> true
FAQs
The utilities for working with a collections such as objects, arrays and primitives such as numbers, strings, etc.
The npm package utilitify receives a total of 22 weekly downloads. As such, utilitify popularity was classified as not popular.
We found that utilitify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.