Amigo JS offers developers a powerful and easy-to-use toolset. With its clean, modular and scalable code structure, it accelerates development processes and reduces code complexity. With a wide range of functions, it offers ready-made methods for solving common problems.
## Installationnpm install amigo-js
yarn add amigo-js
Clone data from any data (disconnect any data binding)
deepClone(val: any): typeof val
const clonedVal = deepClone({ name: "test" });
expect(clonedVal).not.toBe({ name: "test" }); // reference equal
expect(clonedVal).toEqual(clonedVal); // soft equal
Checks the equality of two values.
isDeepEqual(valOne: any, valTwo: any): boolean
isDeepEqual(10, 10); // true
isDeepEqual("test", 1); // false
isDeepEqual(null, 1); // false
isDeepEqual(null, NaN); // false
isDeepEqual(NaN, NaN); // false
isDeepEqual({ name: "john" }, { name: "john" }); // true
isDeepEqual(["john"], ["john"]); // true
isDeepEqual([{ key: "value" }], [{ key: "value" }]); // true
Check if val is an object
isObject(val: any): boolean
isObject([]); // true
isObject(null); // false
isObject(undefined); // false
isObject(NaN); // false
isObject({}); //
isObject(new Date()); // true
Check if val is an date
isDate(val: any): boolean
isDate(Date); // false
isDate(null); // false
isDate("12-22-2023"); // false
isDate(new Date()); // true
Check if val is true or false (boolean)
isBoolean(val: any): boolean
isBoolean(null); // false
isBoolean(false); // true
isBoolean(true); // true
isBoolean(Boolean); // false
isBoolean(0); // false
Check if val is an array
isArray(val: any): boolean
isArray(null); // false
isArray({}); // false
isArray([]); // true
isArray(new Array([])); // true
Check if val is an number
isNumber(val: any): boolean
isNumber(null); // false
isNumber(NaN); // true
isNumber(1); // true
isNumber("1"); // false
Check if val is an function
isFunction(val: any): boolean
isFunction(NaN); // false
isFunction(() => {}); // true
File | % Stmts | % Branch | % Funcs | % Lines |
---|---|---|---|---|
All files | 95.23 | 91.66 | 100 | 100 |
lib | 0 | 0 | 0 | 0 |
index.ts | 0 | 0 | 0 | 0 |
lib/enums | 0 | 0 | 0 | 0 |
NodeEnum.ts | 0 | 0 | 0 | 0 |
lib/helpers | 100 | 75 | 100 | 100 |
node.helper.ts | 100 | 75 | 100 | 100 |
lib/modules | 94.91 | 92.64 | 100 | 100 |
deep-clone.ts | 100 | 90 | 100 | 100 |
is-array.ts | 100 | 100 | 100 | 100 |
is-boolean.ts | 100 | 100 | 100 | 100 |
is-date.ts | 100 | 100 | 100 | 100 |
is-deep-equal.ts | 90.62 | 90.69 | 100 | 100 |
is-function.ts | 100 | 100 | 100 | 100 |
is-number.ts | 100 | 100 | 100 | 100 |
is-object.ts | 100 | 100 | 100 | 100 |
created by Ahmet ilhan