
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@celleb/js-utils
Advanced tools
Javascript/Typescript utilities
npm i @celleb/js-utils --save
Utils for arrays
Usage:
import arrays from '@celleb/js-utils/arrays';
// or
import { arrays } from '@celleb/js-utils';
A filter to return unique values in an array
Example:
import { uniqueFilter } from '@celleb/js-utils/arrays';
const cities = ['Windhoek', 'Bloemfontein', 'Windhoek'].filter(uniqueFilter); // ['Windhoek', 'Bloemfontein']
Returns an array of unique values
Example:
import { filterUnique } from '@celleb/js-utils/arrays';
const cities = filterUnique(['Windhoek', 'Bloemfontein', 'Windhoek']); // ['Windhoek', 'Bloemfontein']
Sort function to sort strings in alphabetical order
import { stringSorter } from '@celleb/js-utils/arrays';
['a', 'b', '1', '5'].sort(stringSorter)) // ['1', '5', 'a', 'b'];
Sort function to sort strings in alphabetical order
import { sortStrings } from '@celleb/js-utils/arrays';
sortStrings(['a', 'b', '1', '5']); // ['1', '5', 'a', 'b'];
Sort an array base on the order of the reference array.
import { sortByReference } from '@celleb/js-utils/arrays';
const order = ['faceTime', 'name'];
const input = ['name', 'lastName', 'faceTime', 'taxi'];
sortByReference(input, order)); // ['faceTime', 'name', 'lastName', 'taxi']
Utils for collections. A collection is an array of objects.
Usage:
import coll from '@celleb/js-utils/coll';
// or
import { coll } from '@celleb/js-utils';
Filters for unique items in a collection by the specified key
Example
import { uniqueFilterByKey } from '@celleb/js-utils/coll';
const coll = [
{ id: 1, name: 'Jonas' },
{ id: 1, name: 'Tomanga' },
];
coll.filter(uniqueFilterByKey('id')); // [{id: 1, name: 'Jonas'}]
Returns a collection of items filtered by unique key
Example
import { filterByUniqueKey } from '@celleb/js-utils/coll';
const coll = [
{ id: 1, name: 'Jonas' },
{ id: 1, name: 'Tomanga' },
];
filterByUniqueKey(coll, 'id'); // [{id: 1, name: 'Jonas'}]
Adds or update items of a collection based on the specified key
Example
import { updateColl } from '@celleb/js-utils/coll';
const coll = [
{ id: 1, name: 'Jonas' },
{ id: 2, name: 'Tomanga' },
];
updateColl('id', coll, [{ id: '2', name: 'Manga' }]); // [{id: 1, name: 'Jonas'}, {id: 2, name: 'Manga'}]
Utils for objects.
Usage:
import obj from '@celleb/js-utils/obj';
// or
import { obj } from '@celleb/js-utils';
Returns an object with the specified keys omitted
The first parameter is the object, and the subsequent parameters are the keys to be omitted. There's an autocomplete for keys in typescript.
Example
import { omit } from '@celleb/js-utils/obj';
const data = { 1: 'one', id: 'one', city: 'Opuwo', country: 'Namibia' };
omit(data, 1, 'id'); // {city: 'Opuwo', country: 'Namibia'}
Same as omit
but also accounts for symbol keys
Example
import { omitExtra } from '@celleb/js-utils/obj';
const ID = Symbol('id');
const data = { [ID]: 'one', id: 'one', city: 'Opuwo', country: 'Namibia' };
omitExtra(data, ID, 'id'); // {city: 'Opuwo', country: 'Namibia'}
Transforms the keys of the input object to the values of the given dictionary.
Example
import { shallowTransform } from '@celleb/js-utils/obj';
const input = { town: 'Windhoek', state: 'Namibia' };
const dictionary = { town: 'city', state: 'country' };
shallowTransform(input, dictionary); // {city: 'Windhoek', country: 'Namibia'}
Additional utils
Usage:
import utils from '@celleb/js-utils/utils';
// or
import { utils } from '@celleb/js-utils';
Creates and returns a copy of the input
Example
import { clone } from '@celleb/js-utils/obj';
clone({ id: 3 }); // {id: 3}
Returns true
when the stringify
value of two items are identical.
Example
import { compare } from '@celleb/js-utils/obj';
const obj1 = { one: 1 };
const obj2 = { one: 1 };
obj1 === obj2; // false
compare(obj1, obj2); // true
FAQs
Typescript/Javascript utils
The npm package @celleb/js-utils receives a total of 38 weekly downloads. As such, @celleb/js-utils popularity was classified as not popular.
We found that @celleb/js-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.