The `utility` package provides a diverse collection of JavaScript and TypeScript utilities primarily designed for Node.js environments. It includes functions for common tasks such as hashing (MD5, SHA1, SHA256, HMAC), various encoding/decoding operations (Base64, URL encoding, HTML escaping), date formatting, string manipulation, and other miscellaneous helpers like `randomString` and `getParamNames`. The current stable version is 2.5.0, with frequent releases, typically monthly or bi-monthly, indicating active maintenance and feature development. Key differentiators include its focus on performance, direct TypeScript support, and a comprehensive set of functions that cover a wide range of backend needs, making it a reliable general-purpose toolkit for Node.js applications.
npm install utilityVerified import paths — ran on the pinned version, not inferred.
Demonstrates common utility functions like hashing, random string generation, date formatting, and Base64 encoding using named imports.
Upgrade your Node.js runtime to version 16.0.0 or higher. Alternatively, pin your `utility` dependency to `<2.0.0` if unable to upgrade Node.js.
Use the dedicated `address` package (e.g., `https://github.com/node-modules/address`) to retrieve IP addresses. Install it separately with `npm install address` and import it as needed.
Be aware of this implicit behavior. If you need a different serialization for object hashing, serialize the object explicitly before passing it to the hash function (e.g., `md5(JSON.stringify(myObject))`).
For new projects or modules configured as ESM, consistently use `import` statements. If you must use `require` in an ESM context, consider dynamic `import()` or ensuring the module is unequivocally CommonJS.
Change `const utils = require('utility');` to `import * as utils from 'utility';` or use specific named imports like `import { md5 } from 'utility';`.Ensure you are using named imports for individual utilities: `import { md5 } from 'utility';`. If you intend to import all utilities as a namespace object, use `import * as utils from 'utility';` and then call `utils.md5()`.Always pass a valid function reference to `utility.getParamNames()`, for example: `utility.getParamNames(function (a, b) {})` or `utility.getParamNames(() => {})`.No dependency data recorded yet.