
Company News
Socket Joins New OpenJS Program to Fund Node.js Security Work
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.
A modern collection of reusable utility functions for JavaScript and TypeScript, designed to simplify everyday development tasks.
A modern, lightweight, and tree-shakable collection of reusable utility functions for JavaScript and TypeScript, designed to simplify everyday development tasks.
npm install xrg-utils
Import the utilities you need from xrg-utils/utils:
import utils from "xrg-utils/utils";
pipelineA powerful data processing utility that allows you to chain operations like filtering, mapping, and sorting.
const [op1, op2] = utils.pipeline({
input: [5, 2, 8, 3, 1, 4],
filter: (num) => num % 2 === 0,
map: {
matched: (num) => num * num,
unmatched: (num) => -num,
},
sort: {
matched: (a, b) => a - b,
unmatched: (a, b) => a - b,
},
});
console.log("op1:", op1); // [4, 16, 64]
console.log("op2:", op2); // [-5, -3, -1]
generatePasswordGenerate a random password with a specified length.
const password = utils.generatePassword(12); // Generates a 12-character password
getBase64Convert a file to a Base64 encoded string.
// For files:
const fileBase64 = await utils.getBase64(file);
slugConvert a string to a URL-friendly slug.
const urlSlug = utils.slug("Some String to Slugify"); // "some-string-to-slugify"
truncateTruncate a string to a specified length.
const shortText = utils.truncate("Very long text here", 10);
withSearchA utility to search an array of strings or objects with a given search term.
const searchableData = utils.withSearch({
array: [
"apple",
{ name: "banana" }, // object with top-level key
{ data: { id: "strawberry" } }, // object with deep key
"grapes",
{ name: "orange" },
{ data: { id: "mango" } },
],
searchTerm: "ap",
key: "name", // try "name" or "" ,"data.id" for primitives
});
Contributions are welcome! Feel free to open issues or submit pull requests to contribute to this project.
This package is open-source and available under the MIT License.
FAQs
A modern collection of reusable utility functions for JavaScript and TypeScript, designed to simplify everyday development tasks.
We found that xrg-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.

Company News
Socket is joining the OpenJS Security Stewardship Program to fund Node.js vulnerability research, maintainer remediation, and security releases.

Security News
Two compromised GitHub Actions were re-enabled with malicious tags intact, exposing thousands of downstream repositories to Mini Shai-Hulud.

Research
/Security News
A malicious Firefox extension fetches its payload after installation to evade detection, steal Google session cookies, and automate account takeover.