@rgx/utils
A collection of utility functions for common JavaScript/TypeScript.
Installation
npm install @rgx/utils
Available Utilities
pipeline
import { pipeline } from '@rgx/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);
console.log("op2:", op2);
generatePassword
import { generatePassword } from '@rgx/utils';
generatePassword(12);
getBase64
import { getBase64 } from '@rgx/utils';
const fileBase64 = await getBase64(file);
slug
import { slug } from '@rgx/utils';
const urlSlug = slug('Some String to Slugify');
truncate
import { truncate } from '@rgx/utils';
const shortText = truncate('Very long text here', 10);
const customEllipsis = truncate('Very long text here', 10, ' >>');
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.