UNPKG

additional_hof

Version:
32 lines (22 loc) 1.11 kB
# hw_3_npm_package_hof 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] [1, 2, 3].logAll(); // Logs elements [1, 2, 3].logAll("el", "index"); // Logs elements and indexes [1, 2, 3].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" [1.2345, 6.789].precizeValuesBy(2); // ["1.23", "6.79"] ```