@naturalcycles/js-lib 15.104.0 → 15.105.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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _assert } from '../error/assert.js';
|
|
1
2
|
import { localDate } from './localDate.js';
|
|
2
3
|
/**
|
|
3
4
|
* Class that supports ISO8601 "Time interval" standard that looks like `2022-02-24/2022-03-30`.
|
|
@@ -21,9 +22,7 @@ export class DateInterval {
|
|
|
21
22
|
if (d instanceof DateInterval)
|
|
22
23
|
return d;
|
|
23
24
|
const [start, end] = d.split('/');
|
|
24
|
-
|
|
25
|
-
throw new Error(`Cannot parse "${d}" into DateInterval`);
|
|
26
|
-
}
|
|
25
|
+
_assert(end && start, `Cannot parse "${d}" into DateInterval`);
|
|
27
26
|
return new DateInterval(localDate(start), localDate(end));
|
|
28
27
|
}
|
|
29
28
|
isSame(d) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _assert } from '../error/assert.js';
|
|
1
2
|
import { localTime } from './localTime.js';
|
|
2
3
|
/**
|
|
3
4
|
* Class that supports an "interval of time" between 2 timestamps - start and end.
|
|
@@ -34,9 +35,7 @@ export class TimeInterval {
|
|
|
34
35
|
if (d instanceof TimeInterval)
|
|
35
36
|
return d;
|
|
36
37
|
const [start, end] = d.split('/').map(Number);
|
|
37
|
-
|
|
38
|
-
throw new Error(`Cannot parse "${d}" into TimeInterval`);
|
|
39
|
-
}
|
|
38
|
+
_assert(end && start, `Cannot parse "${d}" into TimeInterval`);
|
|
40
39
|
return new TimeInterval(start, end);
|
|
41
40
|
}
|
|
42
41
|
isSame(d) {
|
package/dist/enum.util.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// oxlint-disable nc/prefer-assert -- no runtime imports here, and the lookups run in hot paths: the message is only built on failure
|
|
1
2
|
/**
|
|
2
3
|
* Creates a runtime Enum object. A replacement for a native TypeScript enum,
|
|
3
4
|
* which is not supported by type-stripping runtimes (e.g `node --experimental-strip-types`).
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.105.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "^2"
|
|
7
7
|
},
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@naturalcycles/dev-lib": "
|
|
17
|
+
"@naturalcycles/dev-lib": "20.73.0",
|
|
18
18
|
"@types/node": "^26",
|
|
19
19
|
"@types/semver": "^7",
|
|
20
20
|
"rolldown": "^1",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _assert } from '../error/assert.js'
|
|
1
2
|
import type { IsoDate } from '../types.js'
|
|
2
3
|
import type { LocalDate, LocalDateInput, LocalDateUnit } from './localDate.js'
|
|
3
4
|
import { localDate } from './localDate.js'
|
|
@@ -28,9 +29,7 @@ export class DateInterval {
|
|
|
28
29
|
|
|
29
30
|
const [start, end] = d.split('/') as IsoDate[]
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
throw new Error(`Cannot parse "${d}" into DateInterval`)
|
|
33
|
-
}
|
|
32
|
+
_assert(end && start, `Cannot parse "${d}" into DateInterval`)
|
|
34
33
|
|
|
35
34
|
return new DateInterval(localDate(start), localDate(end))
|
|
36
35
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _assert } from '../error/assert.js'
|
|
1
2
|
import type { UnixTimestamp } from '../types.js'
|
|
2
3
|
import type { LocalTime, LocalTimeInput } from './localTime.js'
|
|
3
4
|
import { localTime } from './localTime.js'
|
|
@@ -45,9 +46,7 @@ export class TimeInterval {
|
|
|
45
46
|
|
|
46
47
|
const [start, end] = d.split('/').map(Number) as UnixTimestamp[]
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
throw new Error(`Cannot parse "${d}" into TimeInterval`)
|
|
50
|
-
}
|
|
49
|
+
_assert(end && start, `Cannot parse "${d}" into TimeInterval`)
|
|
51
50
|
|
|
52
51
|
return new TimeInterval(start, end)
|
|
53
52
|
}
|
package/src/enum.util.ts
CHANGED
package/src/qr/qr.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
// oxlint-disable no-bitwise, prefer-math-trunc -- QR encoding (Galois field, BCH, bit packing) is
|
|
17
17
|
// inherently bitwise; `(1 << 0)` terms mirror the spec's generator polynomials
|
|
18
|
+
// oxlint-disable nc/prefer-assert -- this module has no imports, to stay small when bundled on its own
|
|
18
19
|
|
|
19
20
|
/// <reference lib="dom" preserve="true" />
|
|
20
21
|
|