@oxog/utils 1.0.0
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/CHANGELOG.md +44 -0
- package/LICENSE +21 -0
- package/README.md +297 -0
- package/dist/index.cjs +645 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +780 -0
- package/dist/index.d.ts +780 -0
- package/dist/index.js +611 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/async.cjs +188 -0
- package/dist/plugins/async.cjs.map +1 -0
- package/dist/plugins/async.d.cts +169 -0
- package/dist/plugins/async.d.ts +169 -0
- package/dist/plugins/async.js +182 -0
- package/dist/plugins/async.js.map +1 -0
- package/dist/plugins/deep.cjs +157 -0
- package/dist/plugins/deep.cjs.map +1 -0
- package/dist/plugins/deep.d.cts +157 -0
- package/dist/plugins/deep.d.ts +157 -0
- package/dist/plugins/deep.js +152 -0
- package/dist/plugins/deep.js.map +1 -0
- package/dist/plugins/guard.cjs +47 -0
- package/dist/plugins/guard.cjs.map +1 -0
- package/dist/plugins/guard.d.cts +213 -0
- package/dist/plugins/guard.d.ts +213 -0
- package/dist/plugins/guard.js +38 -0
- package/dist/plugins/guard.js.map +1 -0
- package/dist/plugins/transform.cjs +49 -0
- package/dist/plugins/transform.cjs.map +1 -0
- package/dist/plugins/transform.d.cts +231 -0
- package/dist/plugins/transform.d.ts +231 -0
- package/dist/plugins/transform.js +42 -0
- package/dist/plugins/transform.js.map +1 -0
- package/dist/types-XmRC5wYO.d.cts +97 -0
- package/dist/types-XmRC5wYO.d.ts +97 -0
- package/package.json +115 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin interface for extending kernel functionality.
|
|
3
|
+
*
|
|
4
|
+
* @typeParam TContext - Shared context type between plugins
|
|
5
|
+
*/
|
|
6
|
+
interface Plugin<TContext = unknown> {
|
|
7
|
+
/** Unique plugin identifier (kebab-case) */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Semantic version (e.g., "1.0.0") */
|
|
10
|
+
version: string;
|
|
11
|
+
/** Other plugins this plugin depends on */
|
|
12
|
+
dependencies?: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Called when plugin is registered.
|
|
15
|
+
* @param kernel - The kernel instance
|
|
16
|
+
*/
|
|
17
|
+
install: (kernel: any) => void;
|
|
18
|
+
/**
|
|
19
|
+
* Called after all plugins are installed.
|
|
20
|
+
* @param context - Shared context object
|
|
21
|
+
*/
|
|
22
|
+
onInit?: (context: TContext) => void | Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Called when plugin is unregistered.
|
|
25
|
+
*/
|
|
26
|
+
onDestroy?: () => void | Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Called on error in this plugin.
|
|
29
|
+
* @param error - The error that occurred
|
|
30
|
+
*/
|
|
31
|
+
onError?: (error: Error) => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options for debounce() function.
|
|
35
|
+
*/
|
|
36
|
+
interface DebounceOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Invoke on leading edge of timeout.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
leading?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Invoke on trailing edge of timeout.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
trailing?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Maximum time to wait.
|
|
49
|
+
* @default undefined
|
|
50
|
+
*/
|
|
51
|
+
maxWait?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Options for retry() function.
|
|
55
|
+
*/
|
|
56
|
+
interface RetryOptions<T = any> {
|
|
57
|
+
/**
|
|
58
|
+
* Number of retry attempts.
|
|
59
|
+
* @default 3
|
|
60
|
+
*/
|
|
61
|
+
attempts?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Delay between retries in ms.
|
|
64
|
+
* @default 1000
|
|
65
|
+
*/
|
|
66
|
+
delay?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Backoff strategy.
|
|
69
|
+
* @default 'exponential'
|
|
70
|
+
*/
|
|
71
|
+
backoff?: 'linear' | 'exponential' | 'none';
|
|
72
|
+
/**
|
|
73
|
+
* Condition to retry.
|
|
74
|
+
* @default () => true
|
|
75
|
+
*/
|
|
76
|
+
retryIf?: (error: Error) => boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Function to retry.
|
|
79
|
+
*/
|
|
80
|
+
fn: () => Promise<T>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Result object for diff() function.
|
|
84
|
+
*/
|
|
85
|
+
interface DiffResult {
|
|
86
|
+
/** Values that changed */
|
|
87
|
+
changed: Record<string, {
|
|
88
|
+
from: any;
|
|
89
|
+
to: any;
|
|
90
|
+
}>;
|
|
91
|
+
/** Values that were added */
|
|
92
|
+
added: Record<string, any>;
|
|
93
|
+
/** Values that were removed */
|
|
94
|
+
removed: Record<string, any>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type { DebounceOptions as D, Plugin as P, RetryOptions as R, DiffResult as a };
|
package/package.json
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@oxog/utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Zero-dependency, type-safe utility functions for Node.js backends",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"./deep": {
|
|
21
|
+
"import": {
|
|
22
|
+
"types": "./dist/plugins/deep.d.ts",
|
|
23
|
+
"default": "./dist/plugins/deep.js"
|
|
24
|
+
},
|
|
25
|
+
"require": {
|
|
26
|
+
"types": "./dist/plugins/deep.d.cts",
|
|
27
|
+
"default": "./dist/plugins/deep.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"./async": {
|
|
31
|
+
"import": {
|
|
32
|
+
"types": "./dist/plugins/async.d.ts",
|
|
33
|
+
"default": "./dist/plugins/async.js"
|
|
34
|
+
},
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./dist/plugins/async.d.cts",
|
|
37
|
+
"default": "./dist/plugins/async.cjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"./guard": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/plugins/guard.d.ts",
|
|
43
|
+
"default": "./dist/plugins/guard.js"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/plugins/guard.d.cts",
|
|
47
|
+
"default": "./dist/plugins/guard.cjs"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./transform": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/plugins/transform.d.ts",
|
|
53
|
+
"default": "./dist/plugins/transform.js"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/plugins/transform.d.cts",
|
|
57
|
+
"default": "./dist/plugins/transform.cjs"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"files": [
|
|
62
|
+
"dist",
|
|
63
|
+
"README.md",
|
|
64
|
+
"LICENSE",
|
|
65
|
+
"CHANGELOG.md"
|
|
66
|
+
],
|
|
67
|
+
"sideEffects": false,
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsup",
|
|
70
|
+
"test": "jest",
|
|
71
|
+
"test:watch": "jest --watch",
|
|
72
|
+
"test:coverage": "c8 --reporter=text --reporter=lcov --reporter=json jest",
|
|
73
|
+
"lint": "eslint src/",
|
|
74
|
+
"format": "prettier --write .",
|
|
75
|
+
"typecheck": "tsc --noEmit",
|
|
76
|
+
"prepublishOnly": "npm run build && npm run test:coverage"
|
|
77
|
+
},
|
|
78
|
+
"keywords": [
|
|
79
|
+
"utils",
|
|
80
|
+
"utilities",
|
|
81
|
+
"lodash-alternative",
|
|
82
|
+
"typescript",
|
|
83
|
+
"backend",
|
|
84
|
+
"nodejs",
|
|
85
|
+
"tree-shakeable",
|
|
86
|
+
"zero-dependencies",
|
|
87
|
+
"type-safe",
|
|
88
|
+
"functional"
|
|
89
|
+
],
|
|
90
|
+
"author": "Ersin Koç",
|
|
91
|
+
"license": "MIT",
|
|
92
|
+
"repository": {
|
|
93
|
+
"type": "git",
|
|
94
|
+
"url": "git+https://github.com/ersinkoc/utils.git"
|
|
95
|
+
},
|
|
96
|
+
"bugs": {
|
|
97
|
+
"url": "https://github.com/ersinkoc/utils/issues"
|
|
98
|
+
},
|
|
99
|
+
"homepage": "https://utils.oxog.dev",
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">=18"
|
|
102
|
+
},
|
|
103
|
+
"devDependencies": {
|
|
104
|
+
"@jest/globals": "^30.2.0",
|
|
105
|
+
"@types/jest": "^30.0.0",
|
|
106
|
+
"@types/node": "^20.0.0",
|
|
107
|
+
"c8": "^10.1.3",
|
|
108
|
+
"eslint": "^9.0.0",
|
|
109
|
+
"jest": "^30.2.0",
|
|
110
|
+
"prettier": "^3.0.0",
|
|
111
|
+
"ts-jest": "^29.4.6",
|
|
112
|
+
"tsup": "^8.0.0",
|
|
113
|
+
"typescript": "^5.0.0"
|
|
114
|
+
}
|
|
115
|
+
}
|