JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9
  • Score
    100M100P100Q42279F
  • License ISC

A modern collection of reusable utility functions for JavaScript and TypeScript, designed to simplify everyday development tasks.

Package Exports

  • xrg-utils
  • xrg-utils/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xrg-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

xjs-utils

A collection of utility functions for common JavaScript/TypeScript.A modern collection of reusable utility functions for JavaScript and TypeScript, designed to simplify everyday development tasks.

Installation

npm install xjs-utils

Available Utilities

pipeline
import { pipeline } from "xjs-utils";

const [op1, op2] = 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]
generatePassword
import { generatePassword } from "xjs-utils";

generatePassword(12); // Generates a 12-character password
getBase64
import { getBase64 } from "xjs-utils";

// For files:
const fileBase64 = await getBase64(file);
slug
import { slug } from "xjs-utils";

const urlSlug = slug("Some String to Slugify"); // "some-string-to-slugify"
truncate
import { truncate } from "xjs-utils";

const shortText = truncate("Very long text here", 10); // "Very long..."
const customEllipsis = truncate("Very long text here", 10, " >>"); // "Very long >>"

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to contribute to this project.

License

This package is open-source and available under the MIT License.