typetify 0.1.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/LICENSE +21 -0
- package/README.md +327 -0
- package/dist/async/index.d.mts +152 -0
- package/dist/async/index.d.ts +152 -0
- package/dist/async/index.js +49 -0
- package/dist/async/index.js.map +1 -0
- package/dist/async/index.mjs +4 -0
- package/dist/async/index.mjs.map +1 -0
- package/dist/chunk-2LJ6NZ6K.js +108 -0
- package/dist/chunk-2LJ6NZ6K.js.map +1 -0
- package/dist/chunk-44Y5JSGU.js +145 -0
- package/dist/chunk-44Y5JSGU.js.map +1 -0
- package/dist/chunk-4NXETABV.mjs +116 -0
- package/dist/chunk-4NXETABV.mjs.map +1 -0
- package/dist/chunk-6ZBTL74K.js +129 -0
- package/dist/chunk-6ZBTL74K.js.map +1 -0
- package/dist/chunk-CN3GYRJN.mjs +137 -0
- package/dist/chunk-CN3GYRJN.mjs.map +1 -0
- package/dist/chunk-CNTE6ZVH.js +359 -0
- package/dist/chunk-CNTE6ZVH.js.map +1 -0
- package/dist/chunk-DBENOSTA.js +156 -0
- package/dist/chunk-DBENOSTA.js.map +1 -0
- package/dist/chunk-DWIG5GF2.js +135 -0
- package/dist/chunk-DWIG5GF2.js.map +1 -0
- package/dist/chunk-EAUTTWTQ.mjs +231 -0
- package/dist/chunk-EAUTTWTQ.mjs.map +1 -0
- package/dist/chunk-FXWYPHA3.mjs +13 -0
- package/dist/chunk-FXWYPHA3.mjs.map +1 -0
- package/dist/chunk-GS3PP67B.js +200 -0
- package/dist/chunk-GS3PP67B.js.map +1 -0
- package/dist/chunk-J5LGTIGS.mjs +9 -0
- package/dist/chunk-J5LGTIGS.mjs.map +1 -0
- package/dist/chunk-JAOGY4JO.mjs +1007 -0
- package/dist/chunk-JAOGY4JO.mjs.map +1 -0
- package/dist/chunk-JB6UXRKD.mjs +97 -0
- package/dist/chunk-JB6UXRKD.mjs.map +1 -0
- package/dist/chunk-JQHUBZ4M.js +88 -0
- package/dist/chunk-JQHUBZ4M.js.map +1 -0
- package/dist/chunk-L3M7LGKL.mjs +128 -0
- package/dist/chunk-L3M7LGKL.mjs.map +1 -0
- package/dist/chunk-LT7JK7RJ.js +87 -0
- package/dist/chunk-LT7JK7RJ.js.map +1 -0
- package/dist/chunk-OEJK37LO.mjs +328 -0
- package/dist/chunk-OEJK37LO.mjs.map +1 -0
- package/dist/chunk-OPVES6W2.js +16 -0
- package/dist/chunk-OPVES6W2.js.map +1 -0
- package/dist/chunk-OWNUKWXV.js +291 -0
- package/dist/chunk-OWNUKWXV.js.map +1 -0
- package/dist/chunk-PQTXSQ4P.js +369 -0
- package/dist/chunk-PQTXSQ4P.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +11 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-QFR7DVAJ.mjs +63 -0
- package/dist/chunk-QFR7DVAJ.mjs.map +1 -0
- package/dist/chunk-SGQNLTRK.js +73 -0
- package/dist/chunk-SGQNLTRK.js.map +1 -0
- package/dist/chunk-SIA5BSVY.js +1054 -0
- package/dist/chunk-SIA5BSVY.js.map +1 -0
- package/dist/chunk-SRDWUHDY.mjs +188 -0
- package/dist/chunk-SRDWUHDY.mjs.map +1 -0
- package/dist/chunk-TXU7NTT4.js +249 -0
- package/dist/chunk-TXU7NTT4.js.map +1 -0
- package/dist/chunk-TZEWREAC.mjs +277 -0
- package/dist/chunk-TZEWREAC.mjs.map +1 -0
- package/dist/chunk-V6CWFDIJ.mjs +123 -0
- package/dist/chunk-V6CWFDIJ.mjs.map +1 -0
- package/dist/chunk-YBJC5WMX.mjs +341 -0
- package/dist/chunk-YBJC5WMX.mjs.map +1 -0
- package/dist/chunk-YOPAXITF.mjs +75 -0
- package/dist/chunk-YOPAXITF.mjs.map +1 -0
- package/dist/chunk-ZE4FDBRI.mjs +79 -0
- package/dist/chunk-ZE4FDBRI.mjs.map +1 -0
- package/dist/collection/index.d.mts +291 -0
- package/dist/collection/index.d.ts +291 -0
- package/dist/collection/index.js +125 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/index.mjs +4 -0
- package/dist/collection/index.mjs.map +1 -0
- package/dist/core/index.d.mts +85 -0
- package/dist/core/index.d.ts +85 -0
- package/dist/core/index.js +41 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/index.mjs +4 -0
- package/dist/core/index.mjs.map +1 -0
- package/dist/decorator/index.d.mts +165 -0
- package/dist/decorator/index.d.ts +165 -0
- package/dist/decorator/index.js +57 -0
- package/dist/decorator/index.js.map +1 -0
- package/dist/decorator/index.mjs +4 -0
- package/dist/decorator/index.mjs.map +1 -0
- package/dist/dx/index.d.mts +125 -0
- package/dist/dx/index.d.ts +125 -0
- package/dist/dx/index.js +53 -0
- package/dist/dx/index.js.map +1 -0
- package/dist/dx/index.mjs +4 -0
- package/dist/dx/index.mjs.map +1 -0
- package/dist/flow/index.d.mts +165 -0
- package/dist/flow/index.d.ts +165 -0
- package/dist/flow/index.js +50 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/index.mjs +5 -0
- package/dist/flow/index.mjs.map +1 -0
- package/dist/fn/index.d.mts +77 -0
- package/dist/fn/index.d.ts +77 -0
- package/dist/fn/index.js +37 -0
- package/dist/fn/index.js.map +1 -0
- package/dist/fn/index.mjs +4 -0
- package/dist/fn/index.mjs.map +1 -0
- package/dist/guards/index.d.mts +165 -0
- package/dist/guards/index.d.ts +165 -0
- package/dist/guards/index.js +69 -0
- package/dist/guards/index.js.map +1 -0
- package/dist/guards/index.mjs +4 -0
- package/dist/guards/index.mjs.map +1 -0
- package/dist/index.d.mts +228 -0
- package/dist/index.d.ts +228 -0
- package/dist/index.js +775 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +51 -0
- package/dist/index.mjs.map +1 -0
- package/dist/input/index.d.mts +185 -0
- package/dist/input/index.d.ts +185 -0
- package/dist/input/index.js +74 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/index.mjs +5 -0
- package/dist/input/index.mjs.map +1 -0
- package/dist/iterator/index.d.mts +209 -0
- package/dist/iterator/index.d.ts +209 -0
- package/dist/iterator/index.js +522 -0
- package/dist/iterator/index.js.map +1 -0
- package/dist/iterator/index.mjs +502 -0
- package/dist/iterator/index.mjs.map +1 -0
- package/dist/logic/index.d.mts +531 -0
- package/dist/logic/index.d.ts +531 -0
- package/dist/logic/index.js +416 -0
- package/dist/logic/index.js.map +1 -0
- package/dist/logic/index.mjs +367 -0
- package/dist/logic/index.mjs.map +1 -0
- package/dist/math/index.d.mts +86 -0
- package/dist/math/index.d.ts +86 -0
- package/dist/math/index.js +45 -0
- package/dist/math/index.js.map +1 -0
- package/dist/math/index.mjs +4 -0
- package/dist/math/index.mjs.map +1 -0
- package/dist/narrowing/index.d.mts +429 -0
- package/dist/narrowing/index.d.ts +429 -0
- package/dist/narrowing/index.js +220 -0
- package/dist/narrowing/index.js.map +1 -0
- package/dist/narrowing/index.mjs +186 -0
- package/dist/narrowing/index.mjs.map +1 -0
- package/dist/object/index.d.mts +327 -0
- package/dist/object/index.d.ts +327 -0
- package/dist/object/index.js +113 -0
- package/dist/object/index.js.map +1 -0
- package/dist/object/index.mjs +4 -0
- package/dist/object/index.mjs.map +1 -0
- package/dist/result/index.d.mts +201 -0
- package/dist/result/index.d.ts +201 -0
- package/dist/result/index.js +86 -0
- package/dist/result/index.js.map +1 -0
- package/dist/result/index.mjs +5 -0
- package/dist/result/index.mjs.map +1 -0
- package/dist/schema/index.d.mts +216 -0
- package/dist/schema/index.d.ts +216 -0
- package/dist/schema/index.js +410 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/index.mjs +384 -0
- package/dist/schema/index.mjs.map +1 -0
- package/dist/string/index.d.mts +102 -0
- package/dist/string/index.d.ts +102 -0
- package/dist/string/index.js +49 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/index.mjs +4 -0
- package/dist/string/index.mjs.map +1 -0
- package/dist/typed/index.d.mts +1962 -0
- package/dist/typed/index.d.ts +1962 -0
- package/dist/typed/index.js +193 -0
- package/dist/typed/index.js.map +1 -0
- package/dist/typed/index.mjs +4 -0
- package/dist/typed/index.mjs.map +1 -0
- package/dist/types-Db0vauC3.d.mts +258 -0
- package/dist/types-Db0vauC3.d.ts +258 -0
- package/dist/types-VsDp2t8s.d.mts +30 -0
- package/dist/types-VsDp2t8s.d.ts +30 -0
- package/package.json +157 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkCNTE6ZVH_js = require('../chunk-CNTE6ZVH.js');
|
|
4
|
+
require('../chunk-PZ5AY32C.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "chunk", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkCNTE6ZVH_js.chunk; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "compact", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkCNTE6ZVH_js.compact; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "countBy", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkCNTE6ZVH_js.countBy; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "difference", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkCNTE6ZVH_js.difference; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "drop", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkCNTE6ZVH_js.drop; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "dropWhile", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkCNTE6ZVH_js.dropWhile; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "findLast", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkCNTE6ZVH_js.findLast; }
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "first", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return chunkCNTE6ZVH_js.first; }
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "flatten", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () { return chunkCNTE6ZVH_js.flatten; }
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(exports, "groupBy", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () { return chunkCNTE6ZVH_js.groupBy; }
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "head", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function () { return chunkCNTE6ZVH_js.head; }
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(exports, "indexBy", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function () { return chunkCNTE6ZVH_js.indexBy; }
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(exports, "init", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function () { return chunkCNTE6ZVH_js.init; }
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "intersection", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function () { return chunkCNTE6ZVH_js.intersection; }
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(exports, "last", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () { return chunkCNTE6ZVH_js.last; }
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(exports, "maxBy", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get: function () { return chunkCNTE6ZVH_js.maxBy; }
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "minBy", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () { return chunkCNTE6ZVH_js.minBy; }
|
|
75
|
+
});
|
|
76
|
+
Object.defineProperty(exports, "partition", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () { return chunkCNTE6ZVH_js.partition; }
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(exports, "range", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
get: function () { return chunkCNTE6ZVH_js.range; }
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "sample", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function () { return chunkCNTE6ZVH_js.sample; }
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(exports, "shuffle", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
get: function () { return chunkCNTE6ZVH_js.shuffle; }
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(exports, "sortBy", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
get: function () { return chunkCNTE6ZVH_js.sortBy; }
|
|
95
|
+
});
|
|
96
|
+
Object.defineProperty(exports, "sumBy", {
|
|
97
|
+
enumerable: true,
|
|
98
|
+
get: function () { return chunkCNTE6ZVH_js.sumBy; }
|
|
99
|
+
});
|
|
100
|
+
Object.defineProperty(exports, "tail", {
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get: function () { return chunkCNTE6ZVH_js.tail; }
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(exports, "take", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return chunkCNTE6ZVH_js.take; }
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "takeWhile", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () { return chunkCNTE6ZVH_js.takeWhile; }
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "unique", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () { return chunkCNTE6ZVH_js.unique; }
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, "unzip", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () { return chunkCNTE6ZVH_js.unzip; }
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "zip", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () { return chunkCNTE6ZVH_js.zip; }
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { chunk, compact, countBy, difference, drop, dropWhile, findLast, first, flatten, groupBy, head, indexBy, init, intersection, last, maxBy, minBy, partition, range, sample, shuffle, sortBy, sumBy, tail, take, takeWhile, unique, unzip, zip } from '../chunk-OEJK37LO.mjs';
|
|
2
|
+
import '../chunk-J5LGTIGS.mjs';
|
|
3
|
+
//# sourceMappingURL=index.mjs.map
|
|
4
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is defined (not null and not undefined).
|
|
3
|
+
* Perfect for use with Array.filter() to narrow types.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const items = [1, null, 2, undefined, 3]
|
|
7
|
+
* const defined = items.filter(isDefined) // number[]
|
|
8
|
+
*/
|
|
9
|
+
declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Checks if a value is null or undefined.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* if (isNil(value)) {
|
|
16
|
+
* // value is null | undefined
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
declare function isNil(value: unknown): value is null | undefined;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Asserts that a condition is truthy. Throws an error if not.
|
|
23
|
+
* TypeScript will narrow the type after this assertion.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const user: User | null = getUser()
|
|
27
|
+
* assert(user, 'User not found')
|
|
28
|
+
* // user is now User (not null)
|
|
29
|
+
*/
|
|
30
|
+
declare function assert(condition: unknown, message?: string): asserts condition;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Asserts that a value is defined (not null and not undefined).
|
|
34
|
+
* Throws an error if the value is null or undefined.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const user: User | null = getUser()
|
|
38
|
+
* assertDefined(user, 'User not found')
|
|
39
|
+
* // user is now User
|
|
40
|
+
*/
|
|
41
|
+
declare function assertDefined<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Throws an error with the given message.
|
|
45
|
+
* Useful for inline error throwing in expressions.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const value = maybeValue ?? fail('Value is required')
|
|
49
|
+
*/
|
|
50
|
+
declare function fail(message: string): never;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A function that does nothing.
|
|
54
|
+
* Useful for default callbacks, placeholders, or tests.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const onClick = props.onClick ?? noop
|
|
58
|
+
*/
|
|
59
|
+
declare function noop(): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns the value passed to it.
|
|
63
|
+
* Useful for default transformers or as a placeholder function.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const transform = options.transform ?? identity
|
|
67
|
+
* const result = transform(value)
|
|
68
|
+
*/
|
|
69
|
+
declare function identity<T>(value: T): T;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Marks a code path as unreachable.
|
|
73
|
+
* TypeScript will error if this function can be reached.
|
|
74
|
+
* Useful for exhaustive switch statements.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* switch (status) {
|
|
78
|
+
* case 'pending': return handlePending()
|
|
79
|
+
* case 'done': return handleDone()
|
|
80
|
+
* default: unreachable(status)
|
|
81
|
+
* }
|
|
82
|
+
*/
|
|
83
|
+
declare function unreachable(value: never, message?: string): never;
|
|
84
|
+
|
|
85
|
+
export { assert, assertDefined, fail, identity, isDefined, isNil, noop, unreachable };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a value is defined (not null and not undefined).
|
|
3
|
+
* Perfect for use with Array.filter() to narrow types.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const items = [1, null, 2, undefined, 3]
|
|
7
|
+
* const defined = items.filter(isDefined) // number[]
|
|
8
|
+
*/
|
|
9
|
+
declare function isDefined<T>(value: T | null | undefined): value is T;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Checks if a value is null or undefined.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* if (isNil(value)) {
|
|
16
|
+
* // value is null | undefined
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
declare function isNil(value: unknown): value is null | undefined;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Asserts that a condition is truthy. Throws an error if not.
|
|
23
|
+
* TypeScript will narrow the type after this assertion.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const user: User | null = getUser()
|
|
27
|
+
* assert(user, 'User not found')
|
|
28
|
+
* // user is now User (not null)
|
|
29
|
+
*/
|
|
30
|
+
declare function assert(condition: unknown, message?: string): asserts condition;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Asserts that a value is defined (not null and not undefined).
|
|
34
|
+
* Throws an error if the value is null or undefined.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const user: User | null = getUser()
|
|
38
|
+
* assertDefined(user, 'User not found')
|
|
39
|
+
* // user is now User
|
|
40
|
+
*/
|
|
41
|
+
declare function assertDefined<T>(value: T | null | undefined, message?: string): asserts value is T;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Throws an error with the given message.
|
|
45
|
+
* Useful for inline error throwing in expressions.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const value = maybeValue ?? fail('Value is required')
|
|
49
|
+
*/
|
|
50
|
+
declare function fail(message: string): never;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A function that does nothing.
|
|
54
|
+
* Useful for default callbacks, placeholders, or tests.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* const onClick = props.onClick ?? noop
|
|
58
|
+
*/
|
|
59
|
+
declare function noop(): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns the value passed to it.
|
|
63
|
+
* Useful for default transformers or as a placeholder function.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const transform = options.transform ?? identity
|
|
67
|
+
* const result = transform(value)
|
|
68
|
+
*/
|
|
69
|
+
declare function identity<T>(value: T): T;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Marks a code path as unreachable.
|
|
73
|
+
* TypeScript will error if this function can be reached.
|
|
74
|
+
* Useful for exhaustive switch statements.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* switch (status) {
|
|
78
|
+
* case 'pending': return handlePending()
|
|
79
|
+
* case 'done': return handleDone()
|
|
80
|
+
* default: unreachable(status)
|
|
81
|
+
* }
|
|
82
|
+
*/
|
|
83
|
+
declare function unreachable(value: never, message?: string): never;
|
|
84
|
+
|
|
85
|
+
export { assert, assertDefined, fail, identity, isDefined, isNil, noop, unreachable };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkSGQNLTRK_js = require('../chunk-SGQNLTRK.js');
|
|
4
|
+
require('../chunk-PZ5AY32C.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.defineProperty(exports, "assert", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunkSGQNLTRK_js.assert; }
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "assertDefined", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () { return chunkSGQNLTRK_js.assertDefined; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "fail", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunkSGQNLTRK_js.fail; }
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "identity", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () { return chunkSGQNLTRK_js.identity; }
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "isDefined", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () { return chunkSGQNLTRK_js.isDefined; }
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "isNil", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () { return chunkSGQNLTRK_js.isNil; }
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports, "noop", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () { return chunkSGQNLTRK_js.noop; }
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "unreachable", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () { return chunkSGQNLTRK_js.unreachable; }
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.mjs"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memoizes a method, caching its results based on arguments.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* class Calculator {
|
|
6
|
+
* @Memoize()
|
|
7
|
+
* fibonacci(n: number): number {
|
|
8
|
+
* if (n <= 1) return n
|
|
9
|
+
* return this.fibonacci(n - 1) + this.fibonacci(n - 2)
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
declare function Memoize(resolver?: (...args: unknown[]) => unknown): MethodDecorator;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Debounces a method, delaying execution until after wait milliseconds.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* class SearchBox {
|
|
20
|
+
* @Debounce(300)
|
|
21
|
+
* search(query: string) {
|
|
22
|
+
* console.log('Searching:', query)
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
declare function Debounce(wait: number): MethodDecorator;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Throttles a method, limiting execution to once per wait milliseconds.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* class ScrollHandler {
|
|
33
|
+
* @Throttle(100)
|
|
34
|
+
* onScroll(event: Event) {
|
|
35
|
+
* console.log('Scroll event')
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
*/
|
|
39
|
+
declare function Throttle(wait: number): MethodDecorator;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Binds a method to its class instance.
|
|
43
|
+
* Useful for event handlers and callbacks.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* class Button {
|
|
47
|
+
* @Bind()
|
|
48
|
+
* onClick() {
|
|
49
|
+
* console.log(this) // Always the Button instance
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
*/
|
|
53
|
+
declare function Bind(): MethodDecorator;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Logs method calls with arguments and return values.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* class Calculator {
|
|
60
|
+
* @Log()
|
|
61
|
+
* add(a: number, b: number): number {
|
|
62
|
+
* return a + b
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* // Logs: "add(1, 2) => 3"
|
|
66
|
+
*/
|
|
67
|
+
declare function Log(options?: {
|
|
68
|
+
prefix?: string;
|
|
69
|
+
}): MethodDecorator;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Measures and logs the execution time of a method.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* class DataProcessor {
|
|
76
|
+
* @Measure()
|
|
77
|
+
* processData(data: unknown[]) {
|
|
78
|
+
* // Heavy processing
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* // Logs: "processData took 123.45ms"
|
|
82
|
+
*/
|
|
83
|
+
declare function Measure(options?: {
|
|
84
|
+
label?: string;
|
|
85
|
+
}): MethodDecorator;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Retries a method on failure.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* class ApiClient {
|
|
92
|
+
* @Retry({ attempts: 3, delay: 1000 })
|
|
93
|
+
* async fetchData(): Promise<Data> {
|
|
94
|
+
* return fetch('/api/data').then(r => r.json())
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
*/
|
|
98
|
+
declare function Retry(options?: {
|
|
99
|
+
attempts?: number;
|
|
100
|
+
delay?: number;
|
|
101
|
+
onRetry?: (error: unknown, attempt: number) => void;
|
|
102
|
+
}): MethodDecorator;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Marks a method as deprecated and logs a warning when called.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* class Api {
|
|
109
|
+
* @Deprecated('Use newMethod() instead')
|
|
110
|
+
* oldMethod() {
|
|
111
|
+
* // ...
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
*/
|
|
115
|
+
declare function Deprecated(message?: string): MethodDecorator;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Seals a class, preventing new properties from being added.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* @Sealed()
|
|
122
|
+
* class Config {
|
|
123
|
+
* readonly apiUrl = 'https://api.example.com'
|
|
124
|
+
* }
|
|
125
|
+
*/
|
|
126
|
+
declare function Sealed(): <T extends new (...args: any[]) => object>(constructor: T) => T;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Freezes a class, making it completely immutable.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* @Frozen()
|
|
133
|
+
* class Constants {
|
|
134
|
+
* static readonly PI = 3.14159
|
|
135
|
+
* }
|
|
136
|
+
*/
|
|
137
|
+
declare function Frozen(): <T extends new (...args: any[]) => object>(constructor: T) => T;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Validates method arguments using a predicate.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* class User {
|
|
144
|
+
* @Validate((age: number) => age >= 0 && age <= 150, 'Invalid age')
|
|
145
|
+
* setAge(age: number) {
|
|
146
|
+
* this.age = age
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
*/
|
|
150
|
+
declare function Validate(predicate: (...args: unknown[]) => boolean, errorMessage?: string): MethodDecorator;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Lazily initializes a property on first access.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* class Service {
|
|
157
|
+
* @Lazy()
|
|
158
|
+
* get expensiveData(): Data {
|
|
159
|
+
* return computeExpensiveData()
|
|
160
|
+
* }
|
|
161
|
+
* }
|
|
162
|
+
*/
|
|
163
|
+
declare function Lazy(): MethodDecorator;
|
|
164
|
+
|
|
165
|
+
export { Bind, Debounce, Deprecated, Frozen, Lazy, Log, Measure, Memoize, Retry, Sealed, Throttle, Validate };
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memoizes a method, caching its results based on arguments.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* class Calculator {
|
|
6
|
+
* @Memoize()
|
|
7
|
+
* fibonacci(n: number): number {
|
|
8
|
+
* if (n <= 1) return n
|
|
9
|
+
* return this.fibonacci(n - 1) + this.fibonacci(n - 2)
|
|
10
|
+
* }
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
declare function Memoize(resolver?: (...args: unknown[]) => unknown): MethodDecorator;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Debounces a method, delaying execution until after wait milliseconds.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* class SearchBox {
|
|
20
|
+
* @Debounce(300)
|
|
21
|
+
* search(query: string) {
|
|
22
|
+
* console.log('Searching:', query)
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*/
|
|
26
|
+
declare function Debounce(wait: number): MethodDecorator;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Throttles a method, limiting execution to once per wait milliseconds.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* class ScrollHandler {
|
|
33
|
+
* @Throttle(100)
|
|
34
|
+
* onScroll(event: Event) {
|
|
35
|
+
* console.log('Scroll event')
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
*/
|
|
39
|
+
declare function Throttle(wait: number): MethodDecorator;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Binds a method to its class instance.
|
|
43
|
+
* Useful for event handlers and callbacks.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* class Button {
|
|
47
|
+
* @Bind()
|
|
48
|
+
* onClick() {
|
|
49
|
+
* console.log(this) // Always the Button instance
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
*/
|
|
53
|
+
declare function Bind(): MethodDecorator;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Logs method calls with arguments and return values.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* class Calculator {
|
|
60
|
+
* @Log()
|
|
61
|
+
* add(a: number, b: number): number {
|
|
62
|
+
* return a + b
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* // Logs: "add(1, 2) => 3"
|
|
66
|
+
*/
|
|
67
|
+
declare function Log(options?: {
|
|
68
|
+
prefix?: string;
|
|
69
|
+
}): MethodDecorator;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Measures and logs the execution time of a method.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* class DataProcessor {
|
|
76
|
+
* @Measure()
|
|
77
|
+
* processData(data: unknown[]) {
|
|
78
|
+
* // Heavy processing
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* // Logs: "processData took 123.45ms"
|
|
82
|
+
*/
|
|
83
|
+
declare function Measure(options?: {
|
|
84
|
+
label?: string;
|
|
85
|
+
}): MethodDecorator;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Retries a method on failure.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* class ApiClient {
|
|
92
|
+
* @Retry({ attempts: 3, delay: 1000 })
|
|
93
|
+
* async fetchData(): Promise<Data> {
|
|
94
|
+
* return fetch('/api/data').then(r => r.json())
|
|
95
|
+
* }
|
|
96
|
+
* }
|
|
97
|
+
*/
|
|
98
|
+
declare function Retry(options?: {
|
|
99
|
+
attempts?: number;
|
|
100
|
+
delay?: number;
|
|
101
|
+
onRetry?: (error: unknown, attempt: number) => void;
|
|
102
|
+
}): MethodDecorator;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Marks a method as deprecated and logs a warning when called.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* class Api {
|
|
109
|
+
* @Deprecated('Use newMethod() instead')
|
|
110
|
+
* oldMethod() {
|
|
111
|
+
* // ...
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
*/
|
|
115
|
+
declare function Deprecated(message?: string): MethodDecorator;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Seals a class, preventing new properties from being added.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* @Sealed()
|
|
122
|
+
* class Config {
|
|
123
|
+
* readonly apiUrl = 'https://api.example.com'
|
|
124
|
+
* }
|
|
125
|
+
*/
|
|
126
|
+
declare function Sealed(): <T extends new (...args: any[]) => object>(constructor: T) => T;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Freezes a class, making it completely immutable.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* @Frozen()
|
|
133
|
+
* class Constants {
|
|
134
|
+
* static readonly PI = 3.14159
|
|
135
|
+
* }
|
|
136
|
+
*/
|
|
137
|
+
declare function Frozen(): <T extends new (...args: any[]) => object>(constructor: T) => T;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Validates method arguments using a predicate.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* class User {
|
|
144
|
+
* @Validate((age: number) => age >= 0 && age <= 150, 'Invalid age')
|
|
145
|
+
* setAge(age: number) {
|
|
146
|
+
* this.age = age
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
*/
|
|
150
|
+
declare function Validate(predicate: (...args: unknown[]) => boolean, errorMessage?: string): MethodDecorator;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Lazily initializes a property on first access.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* class Service {
|
|
157
|
+
* @Lazy()
|
|
158
|
+
* get expensiveData(): Data {
|
|
159
|
+
* return computeExpensiveData()
|
|
160
|
+
* }
|
|
161
|
+
* }
|
|
162
|
+
*/
|
|
163
|
+
declare function Lazy(): MethodDecorator;
|
|
164
|
+
|
|
165
|
+
export { Bind, Debounce, Deprecated, Frozen, Lazy, Log, Measure, Memoize, Retry, Sealed, Throttle, Validate };
|