1.3.0 • Published 2 years ago
borito-utils v1.3.0
Borito Utils
Borito Utils is a collection of handy utility functions for various tasks in JavaScript and TypeScript.
Installation
You can install Borito Utils via npm or yarn:
$ npm install borito-utils
or
$ yarn add borito-utils
Usage
Import the utility functions you need in your JavaScript or TypeScript projects.
import { isEmpty, set, orderBy, groupBy, shuffle } from 'borito-utils';
// Example usage
const data = [1, 2, 3, 5, 4];
if (isEmpty(data)) {
console.log('Data is empty');
// -> true
} else {
console.log('Data is not empty');
// -> false
}
const object = { name: 'John', age: 30 };
set(object, 'address.city', 'New York');
// -> { name: 'John', age: 30, address: { city: 'New York'} }
const sortedData = orderBy(data, 'desc');
console.log('Sorted Data:', sortedData);
// -> [ 1, 2, 3, 4, 5 ]
const groupedData = groupBy(data, 'category');
console.log('Grouped Data:', groupedData);
// -> { undefinedCategory: [ 1, 2, 3, 4, 5 ] }
const shuffledData = shuffle(data);
console.log('Shuffled Data:', shuffledData);
// -> [ 5, 1, 2, 4, 3 ]
Contributing
If you want to contribute to Borito Utils, feel free to submit a pull request. (Make sure to test your changes before submitting a PR)
License
Borito Utils is open-source and released under the MIT License.