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.. ๐
- Manipulating & testing values.. ๐
- Creating composite functions.. ๐
- And many more cool things! ๐
Check out our WIKI for more info!!
A huuugeee Thanks to Dark-error-Honor for helping me create UtilityX!
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'
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.
Tested in Chrome 74-75, Firefox 66-67, IE 11, Edge 18, Safari 11-12, & Node.js 8-12.
Please read this document before contributing to UtilityX! All bug fixes, improvements are appreciated โฅ
Please read this document.
UtilityX is released under the MIT license & supports modern environments.
> Thank you for reading this to the end! ๐