1.3.0 • Published 4 months ago

@tfadev/utils.js v1.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

@tfadev/utils.js

Useful JavaScript and TypeScript utilities for string, array, boolean, and number. The library supports ES6 and CommonJS modules!

Install

npm install @tfadev/utils.js

Usage

Import everything that is defined globally:

// TypeScript:
import '@tfadev/utils.js';

// JavaScript (CommonJS):
require('@tfadev/utils.js');

Examples

For: String

const string = 'ABCDEF';

string.reverse();
string.prefix('111001FF');

string.isAlpha();
string.isASCII();

string.toBase64();
string.toHex();
string.toDec();

And many more...

For: Number

const number = 49;

number.isPrime();
number.isPalindrome();

number.toBalanceFormat();
number.toRomanNumeral();
number.toRadians();

number.factorial(2); // 6.0828186 * 10^62
number.sqrt(); // 7
number.root(3); // 16.3333333333

And many more...

For: Array

const array = ['A', 'B', 'C', 'D', 'E'];

array.pull('B', 'E');
array.unique();
array.chunk();
array.partition((item) => item === 'B');
array.compact();

And many more...

For: Boolean

const boolean = true;

boolean.toString(); // 'true'
boolean.toLogic(); // 1
boolean.toggle(); // false

boolean.and(false); // false
boolean.nand(false); // true
boolean.or(false); // true
boolean.nor(false); // false
boolean.xor(false); // true
boolean.xnor(false); // false

License

The MIT License (View here)

1.3.0

4 months ago

1.2.0

6 months ago

1.1.0

6 months ago

1.0.0

6 months ago

0.1.0

6 months ago