additional_hof
Version:
A package that adds additional HOF to array
32 lines (22 loc) • 1.11 kB
Markdown
A simple and lightweight npm package that extends JavaScript arrays with additional higher-order functions (HOFs) for data manipulation and formatting.
## 📦 Installation
```bash
npm install hw_3_npm_package_hof
import addHOF from "hw_3_npm_package_hof";
addHOF(); // Adds custom HOFs to the Array prototype
const arr = [1, 2, 3, 4];
console.log(arr.addAllElements()); // 10
console.log(arr.multiplyAllElements()); // 24
["2+3", "5*2"].calculate(); // [5, 10]
[].logAll(); // Logs elements
[].logAll("el", "index"); // Logs elements and indexes
[].logAll("el", "index", "arr"); // Logs elements, indexes and array
["hello", "world"].joinAndCapitalize(" "); // "HELLO WORLD"
["hello", "world"].joinAndCapitalize(" "); // "HELLO WORLD"
["Hello", "WORLD"].joinLowerCase(" "); // "hello world"
["JavaScript", "HOF"].joinSnakeCase(); // "javascript_hof"
["JavaScript", "HOF"].joinKababCase(); // "javascript-hof"
["hello", "world"].joinCamelCase(); // "helloWorld"
[].precizeValuesBy(2); // ["1.23", "6.79"]
```