@ztimson/utils 0.24.12 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache.d.ts +6 -5
- package/dist/color.d.ts +1 -1
- package/dist/database.d.ts +17 -0
- package/dist/index.cjs +166 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +166 -95
- package/dist/index.mjs.map +1 -1
- package/dist/jwt.d.ts +9 -1
- package/dist/math.d.ts +2 -1
- package/dist/misc.d.ts +8 -0
- package/dist/search.d.ts +9 -0
- package/dist/types.d.ts +1 -21
- package/package.json +2 -1
package/dist/jwt.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Creates a JSON Web Token (JWT) using the provided payload.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} payload The payload to include in the JWT.
|
|
5
|
+
* @param signature Add a JWT signature
|
|
6
|
+
* @return {string} The generated JWT string.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createJwt(payload: object, signature?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Decode a JSON Web Token (JWT) payload, this will not check for tampering so be careful
|
|
3
11
|
*
|
|
4
12
|
* @param {string} token JWT to decode
|
|
5
13
|
* @return {unknown} JWT payload
|
package/dist/math.d.ts
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* ```
|
|
8
8
|
*
|
|
9
9
|
* @param {number} num Number to convert
|
|
10
|
+
* @param maxDen
|
|
10
11
|
* @return {string} Fraction with remainder
|
|
11
12
|
*/
|
|
12
|
-
export declare function dec2Frac(num: number): string;
|
|
13
|
+
export declare function dec2Frac(num: number, maxDen?: number): string;
|
|
13
14
|
/**
|
|
14
15
|
* Convert fraction to decimal number
|
|
15
16
|
*
|
package/dist/misc.d.ts
CHANGED
|
@@ -22,5 +22,13 @@ export declare function gravatar(email: string, def?: string): string;
|
|
|
22
22
|
* @return {string} New escaped sequence
|
|
23
23
|
*/
|
|
24
24
|
export declare function escapeRegex(value: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Represents a function that listens for events and handles them accordingly.
|
|
27
|
+
*
|
|
28
|
+
* @param {PathEvent} event - The event object containing data related to the triggered event.
|
|
29
|
+
* @param {...any} args - Additional arguments that may be passed to the listener.
|
|
30
|
+
* @returns {any} The return value of the listener, which can vary based on implementation.
|
|
31
|
+
*/
|
|
25
32
|
export type Listener = (event: PathEvent, ...args: any[]) => any;
|
|
33
|
+
/** Represents a function that can be called to unsubscribe from an event, stream, or observer */
|
|
26
34
|
export type Unsubscribe = () => void;
|
package/dist/search.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filters an array of objects based on a search term and optional regex checking.
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} rows Array of objects to filter
|
|
5
|
+
* @param {string} search The logic string or regext to filter on
|
|
6
|
+
* @param {boolean} [regex=false] Treat search expression as regex
|
|
7
|
+
* @param {Function} [transform=(r) => r] - Transform rows before filtering
|
|
8
|
+
* @return {Array} The filtered array of objects that matched search
|
|
9
|
+
*/
|
|
1
10
|
export declare function search(rows: any[], search: string, regex?: boolean, transform?: Function): any[];
|
|
2
11
|
/**
|
|
3
12
|
* Test an object against a logic condition. By default values are checked
|
package/dist/types.d.ts
CHANGED
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return keys on a type as an array of strings
|
|
3
|
-
*
|
|
4
|
-
* @example
|
|
5
|
-
* ```ts
|
|
6
|
-
* type Person = {
|
|
7
|
-
* firstName: string;
|
|
8
|
-
* lastName: string;
|
|
9
|
-
* age: number;
|
|
10
|
-
* }
|
|
11
|
-
*
|
|
12
|
-
* const keys = typeKeys<Person>();
|
|
13
|
-
* console.log(keys); // Output: ["firstName", "lastName", "age"]
|
|
14
|
-
* ```
|
|
15
|
-
*
|
|
16
|
-
* @return {Array<keyof T>} Available keys
|
|
17
|
-
*/
|
|
18
|
-
export declare function typeKeys<T extends object>(): Array<keyof T>;
|
|
19
|
-
/**
|
|
20
|
-
* Mark all properties as writable
|
|
21
|
-
*/
|
|
1
|
+
/** Mark all properties as writable */
|
|
22
2
|
export type Writable<T> = {
|
|
23
3
|
-readonly [P in keyof T]: T[P];
|
|
24
4
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ztimson/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"description": "Utility library",
|
|
5
5
|
"author": "Zak Timson",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/jest": "^29.5.12",
|
|
34
|
+
"fake-indexeddb": "^6.0.1",
|
|
34
35
|
"jest": "^29.7.0",
|
|
35
36
|
"jest-junit": "^16.0.0",
|
|
36
37
|
"ts-jest": "^29.1.2",
|