@am-work-28/npm-starter-test
v1.0.0
Published
A comprehensive utility library for common JavaScript operations
Downloads
67
Readme
npm-starter-test
A comprehensive utility library for common JavaScript operations.
Installation
npm install npm-starter-test
Features
String Utilities
greet(name)
: Returns a greeting messagecapitalize(str)
: Capitalizes the first letterreverse(str)
: Reverses a stringcountWords(str)
: Counts words in a stringtruncate(str, length)
: Truncates string with ellipsis
Math Utilities
add(a, b)
: Adds two numberssubtract(a, b)
: Subtracts two numbersmultiply(a, b)
: Multiplies two numbersdivide(a, b)
: Divides two numberspower(base, exponent)
: Calculates power
Array Utilities
shuffle(arr)
: Randomly shuffles an arrayunique(arr)
: Returns unique valuesgroupBy(arr, key)
: Groups array by object keychunk(arr, size)
: Splits array into chunks
Usage
const utils = require("npm-starter-test ");
// String utilities
console.log(utils.greet("World")); // Hello, World!
console.log(utils.capitalize("hello")); // Hello
console.log(utils.reverse("hello")); // olleh
// Math utilities
console.log(utils.add(2, 3)); // 5
console.log(utils.power(2, 3)); // 8
// Array utilities
console.log(utils.unique([1, 1, 2, 2, 3])); // [1, 2, 3]
console.log(utils.chunk([1, 2, 3, 4], 2)); // [[1, 2], [3, 4]]
License
MIT