npm-starter-test
v1.0.0
Published
A comprehensive utility library for common JavaScript operations
Downloads
80
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
import {
greet,
capitalize,
reverse,
add,
power,
unique,
chunk,
} from "npm-starter-test";
// String utilities
console.log(greet("World")); // Hello, World!
console.log(capitalize("hello")); // Hello
console.log(reverse("hello")); // olleh
// Math utilities
console.log(add(2, 3)); // 5
console.log(power(2, 3)); // 8
// Array utilities
console.log(unique([1, 1, 2, 2, 3])); // [1, 2, 3]
console.log(chunk([1, 2, 3, 4], 2)); // [[1, 2], [3, 4]]
License
MIT