
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@devgrid/common
Advanced tools
A comprehensive utility library providing a collection of commonly used JavaScript/TypeScript functions for everyday development tasks.
npm install @devgrid/common
# or
yarn add @devgrid/common
Basic utility functions for common operations.
import { noop, identity, truly, falsely, arrify } from '@devgrid/common';
// noop - Does nothing
noop(); // => undefined
// identity - Returns the input value
identity(5); // => 5
identity({ foo: 'bar' }); // => { foo: 'bar' }
// truly - Always returns true
truly(); // => true
// falsely - Always returns false
falsely(); // => false
// arrify - Converts value to array
arrify(null); // => []
arrify(undefined); // => []
arrify(1); // => [1]
arrify([1, 2, 3]); // => [1, 2, 3]
Functions for type checking and validation.
import {
isString,
isNumber,
isArray,
isObject,
isPromise,
// ... and many more
} from '@devgrid/common';
// Basic type checks
isString('hello'); // => true
isNumber(123); // => true
isArray([1, 2, 3]); // => true
isObject({}); // => true
// Advanced checks
isPromise(Promise.resolve()); // => true
isSubstring('hello', 'hello world'); // => true
isPrefix('hello', 'hello world'); // => true
Advanced promise handling utilities.
import {
timeout,
retry,
delay,
props
} from '@devgrid/common';
// Add timeout to promises
await timeout(fetch('api.example.com'), 5000);
// Retry failed operations
await retry(async () => {
// Your async operation here
}, {
max: 3,
backoffBase: 1000
});
// Delay execution
await delay(1000); // waits for 1 second
// Handle object of promises
await props({
users: fetchUsers(),
posts: fetchPosts()
});
Functions for handling objects and their properties.
import { omit, entries } from '@devgrid/common';
// Omit properties from objects
const user = { name: 'John', age: 30, password: '123' };
omit(user, ['password']); // => { name: 'John', age: 30 }
// Get object entries with advanced options
entries(obj, {
enumOnly: true,
followProto: false
});
const controller = new AbortController();
timeout(longOperation(), 5000, {
signal: controller.signal,
unref: true
});
// Later, if needed:
controller.abort();
await retry(async ({ current }) => {
console.log(`Attempt ${current}`);
// Your operation here
}, {
max: 5,
backoffBase: 1000,
backoffExponent: 2,
match: [NetworkError, TimeoutError],
report: (message, options, error) => {
console.log(`${message}: ${error?.message}`);
}
});
This library is written in TypeScript and includes type definitions. All functions are fully typed and provide excellent IDE support.
// Example of TypeScript inference
const result = identity<number>(5); // result is typed as number
const arr = arrify<string>('hello'); // arr is typed as string[]
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License
FAQs
Some useful primitives
The npm package @devgrid/common receives a total of 43 weekly downloads. As such, @devgrid/common popularity was classified as not popular.
We found that @devgrid/common demonstrated a healthy version release cadence and project activity because the last version was released less than 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
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.