@darthcav/ts-utils 0.12.2 → 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/README.md +152 -81
- package/dist/core/guards.d.ts +176 -0
- package/dist/core/guards.d.ts.map +1 -0
- package/dist/core/guards.js +207 -0
- package/dist/core/guards.js.map +1 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +16 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/millisecondsToString.d.ts.map +1 -0
- package/dist/{millisecondsToString.js → core/millisecondsToString.js} +3 -4
- package/dist/core/millisecondsToString.js.map +1 -0
- package/dist/core/noop.d.ts +3 -0
- package/dist/core/noop.d.ts.map +1 -0
- package/dist/core/noop.js +3 -0
- package/dist/core/noop.js.map +1 -0
- package/dist/index.d.ts +13 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/dist/loggers/getConsoleLogger.d.ts +11 -12
- package/dist/loggers/getConsoleLogger.d.ts.map +1 -1
- package/dist/loggers/getConsoleLogger.js +14 -19
- package/dist/loggers/getConsoleLogger.js.map +1 -1
- package/dist/loggers/index.d.ts +14 -0
- package/dist/loggers/index.d.ts.map +1 -0
- package/dist/loggers/index.js +14 -0
- package/dist/loggers/index.js.map +1 -0
- package/dist/node/index.d.ts +15 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +15 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/main.d.ts +156 -0
- package/dist/node/main.d.ts.map +1 -0
- package/dist/node/main.js +261 -0
- package/dist/node/main.js.map +1 -0
- package/dist/{monitorMemory.d.ts → node/monitorMemory.d.ts} +3 -5
- package/dist/node/monitorMemory.d.ts.map +1 -0
- package/dist/{monitorMemory.js → node/monitorMemory.js} +4 -7
- package/dist/node/monitorMemory.js.map +1 -0
- package/dist/node/osRelease.d.ts +55 -0
- package/dist/node/osRelease.d.ts.map +1 -0
- package/dist/{osRelease.js → node/osRelease.js} +77 -24
- package/dist/node/osRelease.js.map +1 -0
- package/dist/type-testing/index.d.ts +18 -0
- package/dist/type-testing/index.d.ts.map +1 -0
- package/dist/type-testing/index.js +12 -0
- package/dist/type-testing/index.js.map +1 -0
- package/package.json +23 -8
- package/src/core/guards.ts +243 -0
- package/src/core/index.ts +31 -0
- package/src/{millisecondsToString.ts → core/millisecondsToString.ts} +3 -4
- package/src/core/noop.ts +2 -0
- package/src/index.ts +13 -49
- package/src/loggers/getConsoleLogger.ts +14 -19
- package/src/loggers/index.ts +14 -0
- package/src/node/index.ts +21 -0
- package/src/node/main.ts +427 -0
- package/src/{monitorMemory.ts → node/monitorMemory.ts} +4 -7
- package/src/node/osRelease.ts +251 -0
- package/src/type-testing/index.ts +18 -0
- package/dist/main.d.ts +0 -112
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -219
- package/dist/main.js.map +0 -1
- package/dist/millisecondsToString.d.ts.map +0 -1
- package/dist/millisecondsToString.js.map +0 -1
- package/dist/monitorMemory.d.ts.map +0 -1
- package/dist/monitorMemory.js.map +0 -1
- package/dist/noop.d.ts +0 -7
- package/dist/noop.d.ts.map +0 -1
- package/dist/noop.js +0 -7
- package/dist/noop.js.map +0 -1
- package/dist/osRelease.d.ts +0 -46
- package/dist/osRelease.d.ts.map +0 -1
- package/dist/osRelease.js.map +0 -1
- package/dist/types.d.ts +0 -70
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -84
- package/dist/types.js.map +0 -1
- package/src/main.ts +0 -302
- package/src/noop.ts +0 -6
- package/src/osRelease.ts +0 -174
- package/src/types.ts +0 -98
- /package/dist/{millisecondsToString.d.ts → core/millisecondsToString.d.ts} +0 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard that checks whether a value is a plain object that can be treated
|
|
3
|
+
* as a runtime JSON object.
|
|
4
|
+
*
|
|
5
|
+
* Plain objects are object literals, `JSON.parse` results, and
|
|
6
|
+
* `Object.create(null)` objects, including those from another realm (e.g. a
|
|
7
|
+
* `node:vm` context). Arrays, class instances, and built-ins such as `Date`,
|
|
8
|
+
* `Map`, `Set`, `RegExp`, or module namespace objects are rejected.
|
|
9
|
+
*
|
|
10
|
+
* The check is shallow and keys are not sanitized: an own `__proto__` or
|
|
11
|
+
* `constructor` key (as `JSON.parse` can produce from untrusted input) is kept.
|
|
12
|
+
* Do not merge the value into other objects key by key without guarding
|
|
13
|
+
* against those keys, or prototype pollution becomes possible.
|
|
14
|
+
*
|
|
15
|
+
* @param value - Value to check.
|
|
16
|
+
* @returns `true` when the value is a plain object, narrowing it to
|
|
17
|
+
* {@link RuntimeObject}.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const body: unknown = JSON.parse(input)
|
|
22
|
+
* if (isRuntimeObject(body)) {
|
|
23
|
+
* console.log(Object.keys(body)) // body: RuntimeObject
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function isRuntimeObject(value) {
|
|
28
|
+
if (typeof value !== "object" || value === null) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const prototype = Object.getPrototypeOf(value);
|
|
32
|
+
// A null prototype, or a realm's root `Object.prototype` (whose own
|
|
33
|
+
// prototype is null), marks a plain object.
|
|
34
|
+
if (prototype !== null &&
|
|
35
|
+
prototype !== Object.prototype &&
|
|
36
|
+
Object.getPrototypeOf(prototype) !== null) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
// Exclude null-prototype exotics such as module namespace objects.
|
|
40
|
+
return !(Symbol.toStringTag in value || Symbol.iterator in value);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Returns the input when it is a plain object, as decided by
|
|
44
|
+
* {@link isRuntimeObject} (see there for the caveats about unsanitized keys).
|
|
45
|
+
*
|
|
46
|
+
* @param value - Value to narrow.
|
|
47
|
+
* @returns The same value as a {@link RuntimeObject}, or `undefined` when the
|
|
48
|
+
* value is not a plain object.
|
|
49
|
+
*/
|
|
50
|
+
export function asRuntimeObject(value) {
|
|
51
|
+
return isRuntimeObject(value) ? value : undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Type guard that checks whether a value is a string.
|
|
55
|
+
*
|
|
56
|
+
* @param value - Value to check.
|
|
57
|
+
* @returns `true` when the value is a string, narrowing it to `string`.
|
|
58
|
+
*/
|
|
59
|
+
export function isString(value) {
|
|
60
|
+
return typeof value === "string";
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns the input when it is a string.
|
|
64
|
+
*
|
|
65
|
+
* @param value - Value to narrow.
|
|
66
|
+
* @returns The same value as a string, or `undefined` when the value is not a string.
|
|
67
|
+
*/
|
|
68
|
+
export function asString(value) {
|
|
69
|
+
return isString(value) ? value : undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Type guard that checks whether a value is a boolean primitive (`true` or
|
|
73
|
+
* `false`). Boxed `Boolean` objects are rejected.
|
|
74
|
+
*
|
|
75
|
+
* @param value - Value to check.
|
|
76
|
+
* @returns `true` when the value is a boolean, narrowing it to `boolean`.
|
|
77
|
+
*/
|
|
78
|
+
export function isBoolean(value) {
|
|
79
|
+
return typeof value === "boolean";
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns the input when it is a boolean primitive, as decided by
|
|
83
|
+
* {@link isBoolean}.
|
|
84
|
+
*
|
|
85
|
+
* @param value - Value to narrow.
|
|
86
|
+
* @returns The same value as a boolean, or `undefined` when the value is not
|
|
87
|
+
* a boolean.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* const enabled = asBoolean(config["enabled"]) ?? false
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export function asBoolean(value) {
|
|
95
|
+
return isBoolean(value) ? value : undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Type guard that checks whether a value is a finite number primitive. `NaN`,
|
|
99
|
+
* `Infinity`, `-Infinity`, boxed `Number` objects, bigints, and numeric
|
|
100
|
+
* strings are rejected.
|
|
101
|
+
*
|
|
102
|
+
* @param value - Value to check.
|
|
103
|
+
* @returns `true` when the value is a finite number, narrowing it to
|
|
104
|
+
* `number`.
|
|
105
|
+
*/
|
|
106
|
+
export function isFiniteNumber(value) {
|
|
107
|
+
return Number.isFinite(value);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the input when it is a finite number primitive, as decided by
|
|
111
|
+
* {@link isFiniteNumber}.
|
|
112
|
+
*
|
|
113
|
+
* @param value - Value to narrow.
|
|
114
|
+
* @returns The same value as a number, or `undefined` when the value is not a
|
|
115
|
+
* finite number.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* const port = asFiniteNumber(config["port"]) ?? 3000
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function asFiniteNumber(value) {
|
|
123
|
+
return isFiniteNumber(value) ? value : undefined;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Type guard that checks whether a value is an array whose elements all pass
|
|
127
|
+
* `guard`. A single invalid element makes it fail (use {@link filterByGuard}
|
|
128
|
+
* to keep only the valid ones); an empty array passes. Holes in sparse arrays
|
|
129
|
+
* are checked as `undefined`.
|
|
130
|
+
*
|
|
131
|
+
* @typeParam T - The element type the guard narrows to.
|
|
132
|
+
* @param value - Value to check.
|
|
133
|
+
* @param guard - Type guard every element must pass.
|
|
134
|
+
* @returns `true` when the value is an array of `T`, narrowing it to `T[]`.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const body: unknown = JSON.parse(input)
|
|
139
|
+
* if (isArrayOf(body, isString)) {
|
|
140
|
+
* body.map((tag) => tag.toUpperCase()) // body: string[]
|
|
141
|
+
* }
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
export function isArrayOf(value, guard) {
|
|
145
|
+
if (!Array.isArray(value)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
// An indexed loop, unlike `every`, also checks the holes of sparse arrays.
|
|
149
|
+
for (let i = 0; i < value.length; i++) {
|
|
150
|
+
if (!guard(value[i])) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Returns the input when it is an array whose elements all pass `guard`, as
|
|
158
|
+
* decided by {@link isArrayOf}.
|
|
159
|
+
*
|
|
160
|
+
* @typeParam T - The element type the guard narrows to.
|
|
161
|
+
* @param value - Value to narrow.
|
|
162
|
+
* @param guard - Type guard every element must pass.
|
|
163
|
+
* @returns The same array as `T[]`, or `undefined` when the value is not an
|
|
164
|
+
* array or any element fails the guard.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```ts
|
|
168
|
+
* const tags = asArrayOf(asRuntimeObject(body)?.["tags"], isString) ?? []
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
export function asArrayOf(value, guard) {
|
|
172
|
+
return isArrayOf(value, guard) ? value : undefined;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Keeps the elements of an array that pass `guard` and silently drops the
|
|
176
|
+
* others, unlike {@link isArrayOf}, which rejects the whole array. A value
|
|
177
|
+
* that is not an array yields an empty array, and holes in sparse arrays are
|
|
178
|
+
* skipped.
|
|
179
|
+
*
|
|
180
|
+
* @typeParam T - The element type the guard narrows to.
|
|
181
|
+
* @param value - Value that may be an array.
|
|
182
|
+
* @param guard - Type guard deciding which elements to keep.
|
|
183
|
+
* @returns A new array with the elements that pass the guard.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* filterByGuard(["a", 1, "b", null], isString) // ["a", "b"]
|
|
188
|
+
* filterByGuard("not an array", isString) // []
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export function filterByGuard(value, guard) {
|
|
192
|
+
return Array.isArray(value)
|
|
193
|
+
? value.filter((element) => guard(element))
|
|
194
|
+
: [];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Keeps the plain objects of an array: {@link filterByGuard} with
|
|
198
|
+
* {@link isRuntimeObject}, whose caveats about unsanitized keys apply. A value
|
|
199
|
+
* that is not an array yields an empty array.
|
|
200
|
+
*
|
|
201
|
+
* @param value - Value that may contain runtime objects.
|
|
202
|
+
* @returns Only the elements that can be treated as {@link RuntimeObject} values.
|
|
203
|
+
*/
|
|
204
|
+
export function toRuntimeObjectArray(value) {
|
|
205
|
+
return filterByGuard(value, isRuntimeObject);
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/core/guards.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable helpers: type guards and narrowing helpers, duration formatting,
|
|
3
|
+
* and `noop`. They import no Node.js built-ins or packages, so they run in any
|
|
4
|
+
* ES2025 runtime (`millisecondsToString` needs `Intl.DurationFormat`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { asString, millisecondsToString } from "@darthcav/ts-utils/core"
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @module core
|
|
12
|
+
*/
|
|
13
|
+
export { asArrayOf, asBoolean, asFiniteNumber, asRuntimeObject, asString, filterByGuard, isArrayOf, isBoolean, isFiniteNumber, isRuntimeObject, isString, type RuntimeObject, type TypeGuard, toRuntimeObjectArray, } from "./guards.ts";
|
|
14
|
+
export { millisecondsToString } from "./millisecondsToString.ts";
|
|
15
|
+
export { noop } from "./noop.ts";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACH,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EACR,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,oBAAoB,GACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Portable helpers: type guards and narrowing helpers, duration formatting,
|
|
3
|
+
* and `noop`. They import no Node.js built-ins or packages, so they run in any
|
|
4
|
+
* ES2025 runtime (`millisecondsToString` needs `Intl.DurationFormat`).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { asString, millisecondsToString } from "@darthcav/ts-utils/core"
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @module core
|
|
12
|
+
*/
|
|
13
|
+
export { asArrayOf, asBoolean, asFiniteNumber, asRuntimeObject, asString, filterByGuard, isArrayOf, isBoolean, isFiniteNumber, isRuntimeObject, isString, toRuntimeObjectArray, } from "./guards.js";
|
|
14
|
+
export { millisecondsToString } from "./millisecondsToString.js";
|
|
15
|
+
export { noop } from "./noop.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACH,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EACR,aAAa,EACb,SAAS,EACT,SAAS,EACT,cAAc,EACd,eAAe,EACf,QAAQ,EAGR,oBAAoB,GACvB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"millisecondsToString.d.ts","sourceRoot":"","sources":["../../src/core/millisecondsToString.ts"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,SAAO,GAAG,MAAM,CAmBtE"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Maximum number of
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* least-recently-inserted entry is evicted.
|
|
2
|
+
* Maximum number of cached formatters, so many distinct locales (e.g. from
|
|
3
|
+
* untrusted input) cannot grow memory without bound. The oldest entry is
|
|
4
|
+
* evicted first.
|
|
6
5
|
*/
|
|
7
6
|
const MAX_CACHED_FORMATTERS = 64;
|
|
8
7
|
const durationFormatters = new Map();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"millisecondsToString.js","sourceRoot":"","sources":["../../src/core/millisecondsToString.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAEhC,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAA+B,CAAA;AAEjE,SAAS,oBAAoB,CAAC,MAAc;IACxC,IAAI,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC9C,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC1B,IAAI,CAAC;YACD,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE;gBACxC,KAAK,EAAE,QAAQ;aAClB,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,IAAI,UAAU,CAChB,yCAAyC,MAAM,GAAG,EAClD,EAAE,KAAK,EAAE,CACZ,CAAA;QACL,CAAC;QACD,IAAI,kBAAkB,CAAC,IAAI,IAAI,qBAAqB,EAAE,CAAC;YACnD,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAA;YACrD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACvB,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACrC,CAAC;QACL,CAAC;QACD,kBAAkB,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC7C,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAU,EAAE,MAAM,GAAG,IAAI;IAC1D,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,UAAU,CAChB,gEAAgE,EAAE,EAAE,CACvE,CAAA;IACL,CAAC;IAED,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACxC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;IAE7C,MAAM,SAAS,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QAClD,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,UAAU,CAAC;QACxC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC;QACvD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC;QACrD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC;QAChD,YAAY,EAAE,SAAS,GAAG,IAAI;KACjC,CAAC,CAAA;IAEF,OAAO,iBAAiB,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AAC3E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../src/core/noop.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,eAAO,MAAM,IAAI,QAAO,IAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop.js","sourceRoot":"","sources":["../../src/core/noop.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,MAAM,CAAC,MAAM,IAAI,GAAG,GAAS,EAAE,GAAE,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A collection of utility functions for TypeScript applications and modules.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The root entry point re-exports every public utility. Import from a subpath
|
|
5
|
+
* to load only one domain:
|
|
6
|
+
*
|
|
7
|
+
* - `@darthcav/ts-utils/core`: portable helpers (no Node.js built-ins).
|
|
8
|
+
* - `@darthcav/ts-utils/node`: Node.js process utilities.
|
|
9
|
+
* - `@darthcav/ts-utils/loggers`: LogTape logger helpers.
|
|
10
|
+
* - `@darthcav/ts-utils/type-testing`: type-level testing helpers.
|
|
11
|
+
*
|
|
12
|
+
* @module @darthcav/ts-utils
|
|
5
13
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { monitorMemory } from "./monitorMemory.ts";
|
|
11
|
-
import { noop } from "./noop.ts";
|
|
12
|
-
import { type OsRelease, osRelease } from "./osRelease.ts";
|
|
13
|
-
import type { Assert } from "./type-testing/Assert.ts";
|
|
14
|
-
import type { Equal } from "./type-testing/Equal.ts";
|
|
15
|
-
import type { Extends } from "./type-testing/Extends.ts";
|
|
16
|
-
import type { IsAny } from "./type-testing/IsAny.ts";
|
|
17
|
-
import type { IsNever } from "./type-testing/IsNever.ts";
|
|
18
|
-
import type { IsUnknown } from "./type-testing/IsUnknown.ts";
|
|
19
|
-
import type { Not } from "./type-testing/Not.ts";
|
|
20
|
-
import { asRuntimeObject, asString, isRuntimeObject, isString, type RuntimeObject, toRuntimeObjectArray } from "./types.ts";
|
|
21
|
-
export { type Assert, asRuntimeObject, asString, type Equal, type Extends, getConsoleLogger, getDummyLogger, type IsAny, type IsNever, type IsUnknown, isRuntimeObject, isString, type LauncherFunction, type MainOptions, main, millisecondsToString, monitorMemory, type Not, noop, type OsRelease, osRelease, type RuntimeObject, toRuntimeObjectArray, };
|
|
14
|
+
export * from "./core/index.ts";
|
|
15
|
+
export * from "./loggers/index.ts";
|
|
16
|
+
export * from "./node/index.ts";
|
|
17
|
+
export type * from "./type-testing/index.ts";
|
|
22
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,yBAAyB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A collection of utility functions for TypeScript applications and modules.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* The root entry point re-exports every public utility. Import from a subpath
|
|
5
|
+
* to load only one domain:
|
|
6
|
+
*
|
|
7
|
+
* - `@darthcav/ts-utils/core`: portable helpers (no Node.js built-ins).
|
|
8
|
+
* - `@darthcav/ts-utils/node`: Node.js process utilities.
|
|
9
|
+
* - `@darthcav/ts-utils/loggers`: LogTape logger helpers.
|
|
10
|
+
* - `@darthcav/ts-utils/type-testing`: type-level testing helpers.
|
|
11
|
+
*
|
|
12
|
+
* @module @darthcav/ts-utils
|
|
5
13
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import { millisecondsToString } from "./millisecondsToString.js";
|
|
10
|
-
import { monitorMemory } from "./monitorMemory.js";
|
|
11
|
-
import { noop } from "./noop.js";
|
|
12
|
-
import { osRelease } from "./osRelease.js";
|
|
13
|
-
import { asRuntimeObject, asString, isRuntimeObject, isString, toRuntimeObjectArray, } from "./types.js";
|
|
14
|
-
export { asRuntimeObject, asString, getConsoleLogger, getDummyLogger, isRuntimeObject, isString, main, millisecondsToString, monitorMemory, noop, osRelease, toRuntimeObjectArray, };
|
|
14
|
+
export * from "./core/index.js";
|
|
15
|
+
export * from "./loggers/index.js";
|
|
16
|
+
export * from "./node/index.js";
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { type Logger, type LogLevel } from "@logtape/logtape";
|
|
2
2
|
/**
|
|
3
|
-
* Configures
|
|
3
|
+
* Configures LogTape globally and returns a {@link Logger} for the given
|
|
4
|
+
* category.
|
|
4
5
|
*
|
|
5
|
-
* Records at or above `lowestLevel`
|
|
6
|
-
* timestamps and full level names
|
|
6
|
+
* Records at or above `lowestLevel` go to the console with RFC 3339
|
|
7
|
+
* timestamps and full level names; the internal `logtape/meta` logger is
|
|
7
8
|
* silenced.
|
|
8
9
|
*
|
|
9
|
-
* ANSI colors are used only when both stdout and stderr are terminals
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* value enables them. The decision is made when this function is called.
|
|
10
|
+
* ANSI colors are used only when both stdout and stderr are color terminals
|
|
11
|
+
* (respecting `NO_COLOR`, `NODE_DISABLE_COLORS`, and `TERM=dumb`), so
|
|
12
|
+
* redirected output has no escape codes. `FORCE_COLOR` overrides this: `"0"`
|
|
13
|
+
* or `"false"` disables colors, any other value enables them.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* configured.)
|
|
15
|
+
* Each call replaces the whole global LogTape configuration, so the latest
|
|
16
|
+
* call wins. Applications that configure LogTape themselves should use
|
|
17
|
+
* LogTape's `getLogger` instead.
|
|
19
18
|
*
|
|
20
19
|
* @param name - The top-level category name (typically the application name).
|
|
21
20
|
* @param lowestLevel - The minimum log level to output. Defaults to `"info"`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConsoleLogger.d.ts","sourceRoot":"","sources":["../../src/loggers/getConsoleLogger.ts"],"names":[],"mappings":"AACA,OAAO,EAMH,KAAK,MAAM,EACX,KAAK,QAAQ,EAEhB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"getConsoleLogger.d.ts","sourceRoot":"","sources":["../../src/loggers/getConsoleLogger.ts"],"names":[],"mappings":"AACA,OAAO,EAMH,KAAK,MAAM,EACX,KAAK,QAAQ,EAEhB,MAAM,kBAAkB,CAAA;AAuBzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,gBAAgB,CAClC,IAAI,EAAE,MAAM,EACZ,WAAW,GAAE,QAAiB,GAC/B,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
|
|
@@ -6,13 +6,9 @@ const FORMATTER_OPTIONS = {
|
|
|
6
6
|
level: "FULL",
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* value enables them). Otherwise colors are used only when both stdout and
|
|
13
|
-
* stderr are terminals that support them, since the console sink writes
|
|
14
|
-
* warnings and errors to stderr. `hasColors()` also honors `NO_COLOR`,
|
|
15
|
-
* `NODE_DISABLE_COLORS`, and `TERM=dumb`.
|
|
9
|
+
* Whether console output should use ANSI colors. `FORCE_COLOR` wins when set;
|
|
10
|
+
* otherwise both stdout and stderr must support colors, since the console
|
|
11
|
+
* sink writes warnings and errors to stderr.
|
|
16
12
|
*/
|
|
17
13
|
function useColors() {
|
|
18
14
|
const force = process.env["FORCE_COLOR"];
|
|
@@ -22,22 +18,21 @@ function useColors() {
|
|
|
22
18
|
return [process.stdout, process.stderr].every((stream) => stream.isTTY === true && stream.hasColors());
|
|
23
19
|
}
|
|
24
20
|
/**
|
|
25
|
-
* Configures
|
|
21
|
+
* Configures LogTape globally and returns a {@link Logger} for the given
|
|
22
|
+
* category.
|
|
26
23
|
*
|
|
27
|
-
* Records at or above `lowestLevel`
|
|
28
|
-
* timestamps and full level names
|
|
24
|
+
* Records at or above `lowestLevel` go to the console with RFC 3339
|
|
25
|
+
* timestamps and full level names; the internal `logtape/meta` logger is
|
|
29
26
|
* silenced.
|
|
30
27
|
*
|
|
31
|
-
* ANSI colors are used only when both stdout and stderr are terminals
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* value enables them. The decision is made when this function is called.
|
|
28
|
+
* ANSI colors are used only when both stdout and stderr are color terminals
|
|
29
|
+
* (respecting `NO_COLOR`, `NODE_DISABLE_COLORS`, and `TERM=dumb`), so
|
|
30
|
+
* redirected output has no escape codes. `FORCE_COLOR` overrides this: `"0"`
|
|
31
|
+
* or `"false"` disables colors, any other value enables them.
|
|
36
32
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* configured.)
|
|
33
|
+
* Each call replaces the whole global LogTape configuration, so the latest
|
|
34
|
+
* call wins. Applications that configure LogTape themselves should use
|
|
35
|
+
* LogTape's `getLogger` instead.
|
|
41
36
|
*
|
|
42
37
|
* @param name - The top-level category name (typically the application name).
|
|
43
38
|
* @param lowestLevel - The minimum log level to output. Defaults to `"info"`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConsoleLogger.js","sourceRoot":"","sources":["../../src/loggers/getConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,gBAAgB,GAInB,MAAM,kBAAkB,CAAA;AAEzB,uEAAuE;AACvE,MAAM,iBAAiB,GAAyB;IAC5C,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,MAAM;CAChB,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"getConsoleLogger.js","sourceRoot":"","sources":["../../src/loggers/getConsoleLogger.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,cAAc,CAAA;AAClC,OAAO,EACH,SAAS,EACT,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,gBAAgB,GAInB,MAAM,kBAAkB,CAAA;AAEzB,uEAAuE;AACvE,MAAM,iBAAiB,GAAyB;IAC5C,SAAS,EAAE,SAAS;IACpB,KAAK,EAAE,MAAM;CAChB,CAAA;AAED;;;;GAIG;AACH,SAAS,SAAS;IACd,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;IACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,OAAO,CAAA;IAC7C,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CACzC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,SAAS,EAAE,CAC1D,CAAA;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAClC,IAAY,EACZ,cAAwB,MAAM;IAE9B,MAAM,SAAS,CAAC;QACZ,KAAK,EAAE;YACH,OAAO,EAAE,cAAc,CAAC;gBACpB,SAAS,EAAE,SAAS,EAAE;oBAClB,CAAC,CAAC,qBAAqB,CAAC,iBAAiB,CAAC;oBAC1C,CAAC,CAAC,gBAAgB,CAAC,iBAAiB,CAAC;aAC5C,CAAC;SACL;QACD,OAAO,EAAE;YACL,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE;YACjD;gBACI,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;gBAC7B,KAAK,EAAE,EAAE;gBACT,WAAW,EAAE,UAAU;aAC1B;SACJ;QACD,KAAK,EAAE,IAAI;KACd,CAAC,CAAA;IACF,OAAO,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogTape logger helpers: a configured console logger and a no-op logger for
|
|
3
|
+
* tests.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { getConsoleLogger } from "@darthcav/ts-utils/loggers"
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @module loggers
|
|
11
|
+
*/
|
|
12
|
+
export { getConsoleLogger } from "./getConsoleLogger.ts";
|
|
13
|
+
export { getDummyLogger } from "./getDummyLogger.ts";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loggers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogTape logger helpers: a configured console logger and a no-op logger for
|
|
3
|
+
* tests.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { getConsoleLogger } from "@darthcav/ts-utils/loggers"
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @module loggers
|
|
11
|
+
*/
|
|
12
|
+
export { getConsoleLogger } from "./getConsoleLogger.js";
|
|
13
|
+
export { getDummyLogger } from "./getDummyLogger.js";
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loggers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js process utilities: application bootstrap and shutdown (`main`),
|
|
3
|
+
* memory monitoring, and OS release information.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { main, osRelease } from "@darthcav/ts-utils/node"
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @module node
|
|
11
|
+
*/
|
|
12
|
+
export { type LauncherFunction, type MainOptions, main, type ShutdownContext, type ShutdownFunction, } from "./main.ts";
|
|
13
|
+
export { monitorMemory } from "./monitorMemory.ts";
|
|
14
|
+
export { type OsRelease, osRelease } from "./osRelease.ts";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,IAAI,EACJ,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACxB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js process utilities: application bootstrap and shutdown (`main`),
|
|
3
|
+
* memory monitoring, and OS release information.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { main, osRelease } from "@darthcav/ts-utils/node"
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @module node
|
|
11
|
+
*/
|
|
12
|
+
export { main, } from "./main.js";
|
|
13
|
+
export { monitorMemory } from "./monitorMemory.js";
|
|
14
|
+
export { osRelease } from "./osRelease.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGH,IAAI,GAGP,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAkB,SAAS,EAAE,MAAM,gBAAgB,CAAA"}
|