@jackens/nnn 2026.2.24 → 2026.2.26
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/nnn.d.ts +12 -0
- package/nnn.js +20 -25
- package/package.json +1 -1
- package/readme.md +43 -1
package/nnn.d.ts
CHANGED
|
@@ -170,6 +170,18 @@ export declare const isArray: (arg: unknown) => arg is unknown[];
|
|
|
170
170
|
* `true` if `arg` is a finite number, `false` otherwise.
|
|
171
171
|
*/
|
|
172
172
|
export declare const isFiniteNumber: (arg: unknown) => arg is number;
|
|
173
|
+
/**
|
|
174
|
+
* Checks whether the argument is an integer number.
|
|
175
|
+
*
|
|
176
|
+
* @param arg
|
|
177
|
+
*
|
|
178
|
+
* The value to check.
|
|
179
|
+
*
|
|
180
|
+
* @returns
|
|
181
|
+
*
|
|
182
|
+
* `true` if `arg` is an integer number, `false` otherwise.
|
|
183
|
+
*/
|
|
184
|
+
export declare const isInteger: (arg: unknown) => arg is number;
|
|
173
185
|
/**
|
|
174
186
|
* Checks whether the argument is of type `number` (includes `NaN` and `±Infinity`).
|
|
175
187
|
*
|
package/nnn.js
CHANGED
|
@@ -12,9 +12,6 @@ var _c = (node, prefix, result, splitter) => {
|
|
|
12
12
|
const queue = [[node, prefix]];
|
|
13
13
|
while (queue.length > 0) {
|
|
14
14
|
const [style0, prefix0] = queue.shift();
|
|
15
|
-
if (style0 == null || prefix0 == null) {
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
15
|
if (isArray(style0)) {
|
|
19
16
|
result.push(prefix0, prefix0 !== "" ? "{" : "", style0.join(";"), prefix0 !== "" ? "}" : "");
|
|
20
17
|
} else {
|
|
@@ -185,7 +182,7 @@ var jsOnParse = (handlers, text) => JSON.parse(text, (key, value) => {
|
|
|
185
182
|
});
|
|
186
183
|
// src/nnn/monokai.ts
|
|
187
184
|
var monokai = {
|
|
188
|
-
":root": {
|
|
185
|
+
":root$$monokai": {
|
|
189
186
|
__bg: "#faf4f2",
|
|
190
187
|
__fg: "#29242a",
|
|
191
188
|
__comment: "#918c8e",
|
|
@@ -201,7 +198,7 @@ var monokai = {
|
|
|
201
198
|
__punctuation: "#918c8e",
|
|
202
199
|
__string: "#cc7a0a"
|
|
203
200
|
},
|
|
204
|
-
pre: {
|
|
201
|
+
pre$$monokai: {
|
|
205
202
|
backgroundColor: "var(--bg)",
|
|
206
203
|
color: "var(--fg)",
|
|
207
204
|
margin: 0,
|
|
@@ -212,7 +209,7 @@ var monokai = {
|
|
|
212
209
|
padding: 0
|
|
213
210
|
}
|
|
214
211
|
},
|
|
215
|
-
"code>span
|
|
212
|
+
"code>span.$$monokai": {
|
|
216
213
|
bg: { color: "var(--bg)" },
|
|
217
214
|
fg: { color: "var(--fg)" },
|
|
218
215
|
comment: { color: "var(--comment)" },
|
|
@@ -228,7 +225,7 @@ var monokai = {
|
|
|
228
225
|
punctuation: { color: "var(--punctuation)" },
|
|
229
226
|
string: { color: "var(--string)" }
|
|
230
227
|
},
|
|
231
|
-
"@media only screen and (prefers-color-scheme: dark)": {
|
|
228
|
+
"@media only screen and (prefers-color-scheme: dark)$$monokai": {
|
|
232
229
|
":root": {
|
|
233
230
|
__bg: "#2d2a2e",
|
|
234
231
|
__fg: "#fcfcfa",
|
|
@@ -314,24 +311,22 @@ var pick = (ref, keys) => Object.fromEntries(Object.entries(ref).filter(([key])
|
|
|
314
311
|
var ARRAY_INDEX_REGEXP = /^(0|[1-9]\d*)$/;
|
|
315
312
|
var isObject = (ref) => typeof ref === "object";
|
|
316
313
|
var getTarget = (parent, parentKey, key) => parent[parentKey] ??= isString(key) && ARRAY_INDEX_REGEXP.test(key) ? [] : {};
|
|
317
|
-
var _vivify = (parent, parentKey) => {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}) : parent?.[parentKey];
|
|
334
|
-
};
|
|
314
|
+
var _vivify = (parent, parentKey) => new Proxy(parent, {
|
|
315
|
+
get(_, key) {
|
|
316
|
+
const target = getTarget(parent, parentKey, key);
|
|
317
|
+
const value = target[key];
|
|
318
|
+
return isString(key) && isObject(target) && (value == null || isObject(value)) ? _vivify(target, key) : value;
|
|
319
|
+
},
|
|
320
|
+
set(_, key, value) {
|
|
321
|
+
const target = getTarget(parent, parentKey, key);
|
|
322
|
+
target[key] = value;
|
|
323
|
+
return true;
|
|
324
|
+
},
|
|
325
|
+
deleteProperty(_, key) {
|
|
326
|
+
const target = getTarget(parent, parentKey, key);
|
|
327
|
+
return delete target[key];
|
|
328
|
+
}
|
|
329
|
+
});
|
|
335
330
|
var vivify = (ref) => _vivify({ _: ref }, "_");
|
|
336
331
|
|
|
337
332
|
// src/nnn/rwd.ts
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# nnn
|
|
2
2
|
|
|
3
|
-
A collection of Jackens’ JavaScript helper utilities (version: `2026.2.
|
|
3
|
+
A collection of Jackens’ JavaScript helper utilities (version: `2026.2.26`).
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
hasOwn,
|
|
27
27
|
isArray,
|
|
28
28
|
isFiniteNumber,
|
|
29
|
+
isInteger,
|
|
29
30
|
isNumber,
|
|
30
31
|
isRecord,
|
|
31
32
|
isString,
|
|
@@ -60,6 +61,7 @@ import {
|
|
|
60
61
|
- [`hasOwn`](#hasOwn): Checks whether an object has the specified key as its own property.
|
|
61
62
|
- [`isArray`](#isArray): Checks whether the argument is an array.
|
|
62
63
|
- [`isFiniteNumber`](#isFiniteNumber): Checks whether the argument is a finite number (excludes `±Infinity` and `NaN`).
|
|
64
|
+
- [`isInteger`](#isInteger): Checks whether the argument is an integer number.
|
|
63
65
|
- [`isNumber`](#isNumber): Checks whether the argument is of type `number` (includes `NaN` and `±Infinity`).
|
|
64
66
|
- [`isRecord`](#isRecord): Checks whether the argument is a plain object (not `null` and not an array).
|
|
65
67
|
- [`isString`](#isString): Checks whether the argument is a string.
|
|
@@ -627,6 +629,34 @@ expect(isFiniteNumber(NaN)).to.be.false
|
|
|
627
629
|
expect(isFiniteNumber(Infinity)).to.be.false
|
|
628
630
|
```
|
|
629
631
|
|
|
632
|
+
### isInteger
|
|
633
|
+
|
|
634
|
+
```ts
|
|
635
|
+
const isInteger: (arg: unknown) => arg is number;
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
Checks whether the argument is an integer number.
|
|
639
|
+
|
|
640
|
+
#### arg
|
|
641
|
+
|
|
642
|
+
The value to check.
|
|
643
|
+
|
|
644
|
+
#### Returns
|
|
645
|
+
|
|
646
|
+
`true` if `arg` is an integer number, `false` otherwise.
|
|
647
|
+
|
|
648
|
+
#### Usage Examples
|
|
649
|
+
|
|
650
|
+
```ts
|
|
651
|
+
expect(isInteger(42)).to.be.true
|
|
652
|
+
expect(isInteger(42.00000000000001)).to.be.false
|
|
653
|
+
expect(isInteger(42.000000000000001)).to.be.true // because of loss of precision
|
|
654
|
+
expect(isInteger(Number(42))).to.be.true
|
|
655
|
+
expect(isInteger(new Number(42))).to.be.false
|
|
656
|
+
expect(isInteger(NaN)).to.be.false
|
|
657
|
+
expect(isInteger(Infinity)).to.be.false
|
|
658
|
+
```
|
|
659
|
+
|
|
630
660
|
### isNumber
|
|
631
661
|
|
|
632
662
|
```ts
|
|
@@ -1325,6 +1355,18 @@ expect(ref).to.deep.equal({ one: { two: { three: { four: 5 } } } })
|
|
|
1325
1355
|
expect(vivify(ref).one.two.three.four.toString.name).to.equal('toString')
|
|
1326
1356
|
|
|
1327
1357
|
expect(ref).to.deep.equal({ one: { two: { three: { four: 5 } } } })
|
|
1358
|
+
|
|
1359
|
+
const u = undefined
|
|
1360
|
+
|
|
1361
|
+
vivify(u).one.two = 3
|
|
1362
|
+
|
|
1363
|
+
expect(u).to.be.undefined
|
|
1364
|
+
|
|
1365
|
+
const n = null
|
|
1366
|
+
|
|
1367
|
+
delete vivify(n).one.two.three
|
|
1368
|
+
|
|
1369
|
+
expect(n).to.be.null
|
|
1328
1370
|
```
|
|
1329
1371
|
|
|
1330
1372
|
## License
|