
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@opentf/utils
Advanced tools
A collection of JavaScript utility functions.
npm install @opentf/utils
yarn add @opentf/utils
pnpm add @opentf/utils
bun add @opentf/utils
import {
isNum,
pascalCase,
sort,
clone,
isEql,
isEqlArr,
sleep,
} from '@opentf/utils';
isNum(NaN); //=> false
pascalCase('pascal case'); //=> PascalCase
sort([1, 10, 21, 2], 'desc'); //=> [ 21, 10, 2, 1 ]
const obj = {
a: 1,
b: 'abc',
c: new Map([['key', 'val']]),
};
clone(obj); // It returns deeply cloned value.
const mapA = new Map([
['a', 1],
['b', 2],
]);
const mapB = new Map([
['b', 2],
['a', 1],
]);
isEql(mapA, mapB); //=> false
isEqlArr([1, 2, 3], [2, 3, 1]); //=> true
await sleep(1000); // It suspends the exection for 1 second.
Some benchmark outputs are shown here for reference.
[!IMPORTANT]
Our priorities are reliability and accuracy rather than performance.
clone:
┌───┬──────────────────────────┬─────────┬────────────────────┬────────┬─────────┐
│ │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├───┼──────────────────────────┼─────────┼────────────────────┼────────┼─────────┤
│ 0 │ structuredClone (Native) │ 246,358 │ 4059.129038804869 │ ±1.65% │ 24636 │
│ 1 │ _.cloneDeep (Lodash) │ 169,432 │ 5902.043319168882 │ ±2.53% │ 16944 │
│ 2 │ R.clone (ramda) │ 178,957 │ 5587.9189808343945 │ ±2.26% │ 17897 │
│ 3 │ R2.clone (remeda) │ 314,247 │ 3182.204862216371 │ ±1.75% │ 31426 │
│ 4 │ clone │ 399,634 │ 2502.2859323385046 │ ±2.06% │ 39964 │
└───┴──────────────────────────┴─────────┴────────────────────┴────────┴─────────┘
*Note: Here the ramda & remeda does not support cloning Map & Set.
sortBy:
┌───┬────────────────────┬───────────┬───────────────────┬────────┬─────────┐
│ │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├───┼────────────────────┼───────────┼───────────────────┼────────┼─────────┤
│ 0 │ _.orderBy (Lodash) │ 1,231,295 │ 812.1529684071648 │ ±3.09% │ 123130 │
│ 1 │ R.sortWith (Ramda) │ 1,279,200 │ 781.7380570822326 │ ±2.27% │ 127921 │
│ 2 │ R2.sortBy (Remeda) │ 1,419,707 │ 704.3703291518029 │ ±2.81% │ 141971 │
│ 3 │ sort (Moderndash) │ 2,697,568 │ 370.7042634668106 │ ±1.82% │ 269757 │
│ 4 │ sortBy │ 2,728,366 │ 366.5196435965459 │ ±2.19% │ 272837 │
└───┴────────────────────┴───────────┴───────────────────┴────────┴─────────┘
*Note: Here the Moderndash does not support passing object prop as string.
isEql:
┌───┬─────────────────────────────────────┬─────────┬───────────────────┬────────┬─────────┐
│ │ Task Name │ ops/sec │ Average Time (ns) │ Margin │ Samples │
├───┼─────────────────────────────────────┼─────────┼───────────────────┼────────┼─────────┤
│ 0 │ deepStrictEqual (Native) │ 927,921 │ 1077.676882954431 │ ±0.38% │ 92793 │
│ 1 │ fastDeepEqual (fast-deep-equal/es6) │ 638,108 │ 1567.132684562446 │ ±1.42% │ 63813 │
│ 2 │ _.isEqual (Lodash) │ 142,592 │ 7013.003366058248 │ ±2.13% │ 14260 │
│ 3 │ R.equals (Ramda) │ 50,346 │ 19862.42184707051 │ ±1.83% │ 5035 │
│ 4 │ isEql │ 109,127 │ 9163.615962614227 │ ±1.28% │ 10913 │
└───┴─────────────────────────────────────┴─────────┴───────────────────┴────────┴─────────┘
*Note:
- The native util `deepStrictEqual` not available in browsers, does not check `Map` ordering & returns false for same invalid dates.
- The `fast-deep-equal/es6` does not support cyclic refs, Map ordering check, invalid dates, symbols, objects values in Set & TypedArrays.
- The lodash `isEqual` does not check `Map` ordering & object values in `Set`.
- The ramda `equals` does not check `Map` ordering & symbols.
$ bun run build
$ bun benchmark.js
Copyright (c) Thanga Ganapathy (MIT License).
FAQs
A collection of JavaScript utility functions.
We found that @opentf/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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

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.