README
❗❕ What is this? ❕❗
UtilityX makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc. UtilityX’s modular methods are great for:
- Iterating arrays, objects, & strings.. :heart_eyes:
- Manipulating & testing values.. :smirk:
- Creating composite functions.. :sunglasses:
- And many more cool things! :wink:
Check out our WIKI for more info!!
A letter of Appreciation ❣
A huuugeee Thanks to Dark-error-Honor for helping me create UtilityX!
How can I use this? 🤔
Installation ⚙
> npm i utilityx
> const x = require("utilityx");
Docs ✔
Equality Checker 🔰
// parameters: (string, string, string, ......)
x.checker("utilityx", "utilityx", "utilityx", "utilityx")
// => true
Random Array Picker 💯
// parameters: (string, string, string, ......)
x.checker("utilityx", "utilityx", "utilityx", "utilityx")
// => true
Longest String Length Sorter 💥
// parameters: (array)
x.sortByLongestLength(["aaaaaaaa", "a", "aa"])
// => ["aaaaaaaa", "aa", "a"]
Shortest String Length Sorter 🎧
// parameters: (array)
x.sortByLetter(["aaaaaaaa", "a", "aa"])
// => ["aa", "a", "aaaaaaaa"]
Letter Sorter 🎂
// parameters: (array)
x.sortByLetter(["hello", "bye", "apple"])
// => ["apple", "bye", "hello"]
Descending Number Sorter 😇
// parameters: (array)
x.sortNumsDescending([1,3,2,5,4])
// => [5,4,3,2,1]
Ascending Number Sorter 😉
// parameters: (array)
x.sortNumsAscending([1,3,2,5,4])
// => [1,2,3,4,5]
Vowel Keeper 🎵
// parameters: (string)
x.keepVowels("utilityx")
// => "uii"
Vowel Remover 🎶
// parameters: (string)
x.removeVowels("utilityx");
// => "tltyx"
Space Counter 🔧
// parameters: (string)
x.spaceCount("utilityx is a util lib.");
// => 4
Character Counter 😱
// parameters: (string, characters)
x.charCount("utilityx", "x")
// => 1
Check For Integers 🔢
// parameters: (number)
x.isInt(1);
// => true
Check For Floats 💥
// parameters: (number)
x.isFloat(1.1);
// => true
Check For Strings 🔠
// paramters: (string)
x.isString('Hello World!');
// => true
Check For Arrays ✔
// parameters: (array)
x.isArray(["Hello", "World", "!"]);
// => true
Round Numbers ⭕
// parameters: (number, amount of decimal places)
x.round(10.55555555, 2)
// => 10.56
Remove duplicates from array ❌
// parameters: (array)
x.removeDuplicates([1, 2, 3, 4, 2, 3]);
// => [1, 2, 3, 4]
Remove falsy values from array ✔
// parameters: (array)
x.compact([null, "", undefined, 0, 5, "hello"]);
// => [5, 'hello']
Get last index of array 💢
// parameters: (array)
x.lastIndex([1, 2, 3, 4, "Hi"]);
// => 'Hi'
Flatten an array ➡⬅
// parameters: (array, depth to flatten(Number))
x.flatten([1, [2, [3, [4, [5]]]]]);
// => [1, 2, 3, 4, 5]
positive and negative indexing ➖
// parameters: (array, index(negative or positive Number))
x.nth(["first", "second", "third"], -2);
// => 'second'
Pull items out of array ⬆
// parameters: (array, values to pull out)
x.pull([1, 2, 3, "hello", 4], 1, "hello");
// => [1, 2, 3, 4]
Get all items except last item ❌
// parameters: (array)
x.head([1, 2, 3, 4, 5]);
// => [1, 2, 3, 4]
Get all items except first item 🚫
// parameters: (array)
x.removeDuplicates([1, 2, 3, 4, 5]);
// => [2, 3, 4, 5]
Make union of arrays ☮
// parameters: (array, array, array, ...)
x.union([1, 2, 3, 4, 5], [1, 2], [3, 6]);
// => [1, 2, 3, 4, 5, 6]
Make sorted union of arrays 🤞
// parameters: (array, array, array, ...)
x.sortedUnion([5, 2, 4], [6, 4, 9]);
// => [2, 4, 5, 6, 9]
Deep copy an array ©
// parameters: (array)
arr = [1, 2, 3];
x.deepCopy(arr);
// => [1, 2, 3]
Clamp function 🍤
// parameters: (lower bound, number, upper bound)
x.clamp([2, 5, 8]);
// => 5
x.clamp([8, 2, 10]);
// => 8
x.clamp([2, 10, 5]);
// => 5
Range function (yes, like in python) 😁
// parameters: (Number)
x.range(5);
// => [0, 1, 2, 3, 4]
Convert to camelCase 🐫
// parameters: (String)
x.camelCase("caMel caSe");
// => 'camelCase'
Convert to PascalCase 🔠
// parameters: (String)
x.pascalCase("paScAl caSe");
// => 'PascalCase'
Convert to snake_case 🐍
// parameters: (String)
x.snakeCase("snAke caSe");
// => 'sn_ake_cas_e'
x.snakeCase("snake case");
// => 'snake_case'
Convert to kebab-case 🥙
// parameters: (String)
x.kebabCase("keBab caSe");
// => 'ke-bab-ca-se'
x.kebabCase("kebab case");
// => 'kebab-case'
Capitalize 🤙
// parameters: (String)
x.camelCase("caPs");
// => 'CaPs'
Why use UtilityX? 🚀
UtilityX helps programmers write more concise and easier to maintain JavaScript code. UtilityX contains tools to simplify programming with strings, numbers, arrays, functions and obfljects. By convention, UtilityX module is mapped to the x character.
Is it tested? 🧪
Tested in Chrome 74-75, Firefox 66-67, IE 11, Edge 18, Safari 11-12, & Node.js 8-12.
How can I contribute? 🎉
Please read this document before contributing to UtilityX! All bug fixes, improvements are appreciated ♥
Did you find an issue? ⚠️
Please read this document.
What about the license? 📃
UtilityX is released under the MIT license & supports modern environments.
> Thank you for reading this to the end! 😎