@naturalcycles/js-lib 15.65.0 → 15.67.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.
@@ -313,11 +313,6 @@ declare class LocalTimeFactory {
313
313
  fromMillis(millis: UnixTimestampMillis): LocalTime;
314
314
  fromDateTimeObject(o: DateTimeObjectInput): LocalTime;
315
315
  private createDateFromDateTimeObject;
316
- /**
317
- * Returns the IANA timezone e.g `Europe/Stockholm`.
318
- * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
319
- */
320
- getTimezone(): IANATimezone;
321
316
  /**
322
317
  * Returns true if passed IANA timezone is valid/supported.
323
318
  * E.g `Europe/Stockholm` is valid, but `Europe/Stockholm2` is not.
@@ -852,13 +852,6 @@ class LocalTimeFactory {
852
852
  // input,
853
853
  // })
854
854
  // }
855
- /**
856
- * Returns the IANA timezone e.g `Europe/Stockholm`.
857
- * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
858
- */
859
- getTimezone() {
860
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
861
- }
862
855
  /**
863
856
  * Returns true if passed IANA timezone is valid/supported.
864
857
  * E.g `Europe/Stockholm` is valid, but `Europe/Stockholm2` is not.
@@ -1,3 +1,4 @@
1
+ import type { IANATimezone } from '../types.js';
1
2
  /**
2
3
  * Returns cached Intl.* formatters, because they are known to be
3
4
  * very slow to create.
@@ -8,6 +9,11 @@
8
9
  * to be able to cache them better. Just pass {} for options.
9
10
  */
10
11
  declare class MemoizedIntl {
12
+ /**
13
+ * Returns the IANA timezone e.g `Europe/Stockholm`.
14
+ * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
15
+ */
16
+ getTimezone(): IANATimezone;
11
17
  DateTimeFormat(locales: Intl.LocalesArgument, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
12
18
  RelativeTimeFormat(locales: Intl.LocalesArgument, options: Intl.RelativeTimeFormatOptions): Intl.RelativeTimeFormat;
13
19
  NumberFormat(locales: Intl.LocalesArgument, options: Intl.NumberFormatOptions): Intl.NumberFormat;
package/dist/intl/intl.js CHANGED
@@ -10,6 +10,13 @@ import { _Memo } from '../decorators/memo.decorator.js';
10
10
  * to be able to cache them better. Just pass {} for options.
11
11
  */
12
12
  class MemoizedIntl {
13
+ /**
14
+ * Returns the IANA timezone e.g `Europe/Stockholm`.
15
+ * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
16
+ */
17
+ getTimezone() {
18
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
19
+ }
13
20
  DateTimeFormat(locales, options) {
14
21
  return new Intl.DateTimeFormat(locales, options);
15
22
  }
@@ -32,6 +39,9 @@ class MemoizedIntl {
32
39
  return new Intl.DisplayNames(locales, options);
33
40
  }
34
41
  }
42
+ __decorate([
43
+ _Memo()
44
+ ], MemoizedIntl.prototype, "getTimezone", null);
35
45
  __decorate([
36
46
  _Memo()
37
47
  ], MemoizedIntl.prototype, "DateTimeFormat", null);
@@ -19,7 +19,9 @@ export interface KeySortedMapOptions<K> {
19
19
  *
20
20
  * @experimental
21
21
  */
22
- export declare class KeySortedMap<K, V> implements Map<K, V> {
22
+ export interface KeySortedMap<K, V> extends Map<K, V> {
23
+ }
24
+ export declare class KeySortedMap<K, V> {
23
25
  #private;
24
26
  private readonly map;
25
27
  constructor(entries?: [K, V][], opt?: KeySortedMapOptions<K>);
@@ -52,7 +54,7 @@ export declare class KeySortedMap<K, V> implements Map<K, V> {
52
54
  entries(): MapIterator<[K, V]>;
53
55
  [Symbol.iterator](): MapIterator<[K, V]>;
54
56
  toString(): string;
55
- [Symbol.toStringTag]: string;
57
+ readonly [Symbol.toStringTag] = "KeySortedMap";
56
58
  /**
57
59
  * Zero-allocation callbacks over sorted data (faster than spreading to arrays).
58
60
  */
@@ -1,15 +1,5 @@
1
1
  import { _assert } from '../error/index.js';
2
- /**
3
- * Maintains sorted array of keys.
4
- * Sorts **on insertion**, not on retrieval.
5
- *
6
- * - set(): O(log n) search + O(n) splice only when inserting a NEW key
7
- * - get/has: O(1)
8
- * - delete: O(log n) search + O(n) splice if present
9
- * - iteration: O(n) over pre-sorted keys (no sorting at iteration time)
10
- *
11
- * @experimental
12
- */
2
+ // oxlint-disable-next-line no-unsafe-declaration-merging -- Map<K,V> workaround for oxlint TS2420 false positive
13
3
  export class KeySortedMap {
14
4
  map;
15
5
  #sortedKeys;
@@ -14,7 +14,9 @@ export interface LazyKeySortedMapOptions<K> {
14
14
  *
15
15
  * @experimental
16
16
  */
17
- export declare class LazyKeySortedMap<K, V> implements Map<K, V> {
17
+ export interface LazyKeySortedMap<K, V> extends Map<K, V> {
18
+ }
19
+ export declare class LazyKeySortedMap<K, V> {
18
20
  #private;
19
21
  private readonly map;
20
22
  private readonly maybeSortedKeys;
@@ -48,7 +50,7 @@ export declare class LazyKeySortedMap<K, V> implements Map<K, V> {
48
50
  values(): MapIterator<V>;
49
51
  entries(): MapIterator<[K, V]>;
50
52
  [Symbol.iterator](): MapIterator<[K, V]>;
51
- [Symbol.toStringTag]: string;
53
+ readonly [Symbol.toStringTag] = "KeySortedMap";
52
54
  /**
53
55
  * Zero-allocation callbacks over sorted data (faster than spreading to arrays).
54
56
  */
@@ -1,10 +1,5 @@
1
1
  import { _assert } from '../error/index.js';
2
- /**
3
- * Maintains sorted array of keys.
4
- * Sorts **data access**, not on insertion.
5
- *
6
- * @experimental
7
- */
2
+ // oxlint-disable-next-line no-unsafe-declaration-merging -- Map<K,V> workaround for oxlint TS2420 false positive
8
3
  export class LazyKeySortedMap {
9
4
  map;
10
5
  maybeSortedKeys;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
3
  "type": "module",
4
- "version": "15.65.0",
4
+ "version": "15.67.0",
5
5
  "dependencies": {
6
6
  "tslib": "^2"
7
7
  },
@@ -24,7 +24,7 @@
24
24
  "@typescript/native-preview": "7.0.0-dev.20260201.1",
25
25
  "crypto-js": "^4",
26
26
  "dayjs": "^1",
27
- "@naturalcycles/dev-lib": "18.4.2"
27
+ "@naturalcycles/dev-lib": "20.36.0"
28
28
  },
29
29
  "exports": {
30
30
  ".": "./dist/index.js",
@@ -1000,14 +1000,6 @@ class LocalTimeFactory {
1000
1000
  // })
1001
1001
  // }
1002
1002
 
1003
- /**
1004
- * Returns the IANA timezone e.g `Europe/Stockholm`.
1005
- * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
1006
- */
1007
- getTimezone(): IANATimezone {
1008
- return Intl.DateTimeFormat().resolvedOptions().timeZone as IANATimezone
1009
- }
1010
-
1011
1003
  /**
1012
1004
  * Returns true if passed IANA timezone is valid/supported.
1013
1005
  * E.g `Europe/Stockholm` is valid, but `Europe/Stockholm2` is not.
package/src/intl/intl.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { _Memo } from '../decorators/memo.decorator.js'
2
+ import type { IANATimezone } from '../types.js'
2
3
 
3
4
  /**
4
5
  * Returns cached Intl.* formatters, because they are known to be
@@ -10,6 +11,15 @@ import { _Memo } from '../decorators/memo.decorator.js'
10
11
  * to be able to cache them better. Just pass {} for options.
11
12
  */
12
13
  class MemoizedIntl {
14
+ /**
15
+ * Returns the IANA timezone e.g `Europe/Stockholm`.
16
+ * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
17
+ */
18
+ @_Memo()
19
+ getTimezone(): IANATimezone {
20
+ return Intl.DateTimeFormat().resolvedOptions().timeZone as IANATimezone
21
+ }
22
+
13
23
  @_Memo()
14
24
  DateTimeFormat(
15
25
  locales: Intl.LocalesArgument,
@@ -22,7 +22,11 @@ export interface KeySortedMapOptions<K> {
22
22
  *
23
23
  * @experimental
24
24
  */
25
- export class KeySortedMap<K, V> implements Map<K, V> {
25
+ // oxlint-disable-next-line no-unsafe-declaration-merging -- Map<K,V> workaround for oxlint TS2420 false positive
26
+ export interface KeySortedMap<K, V> extends Map<K, V> {}
27
+
28
+ // oxlint-disable-next-line no-unsafe-declaration-merging -- Map<K,V> workaround for oxlint TS2420 false positive
29
+ export class KeySortedMap<K, V> {
26
30
  private readonly map: Map<K, V>
27
31
  readonly #sortedKeys: K[]
28
32
 
@@ -140,7 +144,7 @@ export class KeySortedMap<K, V> implements Map<K, V> {
140
144
  return 'abc'
141
145
  }
142
146
 
143
- [Symbol.toStringTag] = 'KeySortedMap'
147
+ readonly [Symbol.toStringTag] = 'KeySortedMap'
144
148
 
145
149
  /**
146
150
  * Zero-allocation callbacks over sorted data (faster than spreading to arrays).
@@ -148,7 +152,7 @@ export class KeySortedMap<K, V> implements Map<K, V> {
148
152
  forEach(cb: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void {
149
153
  const { map } = this
150
154
  for (const k of this.#sortedKeys) {
151
- cb.call(thisArg, map.get(k)!, k, this)
155
+ cb.call(thisArg, map.get(k)!, k, this as unknown as Map<K, V>)
152
156
  }
153
157
  }
154
158
 
@@ -17,7 +17,11 @@ export interface LazyKeySortedMapOptions<K> {
17
17
  *
18
18
  * @experimental
19
19
  */
20
- export class LazyKeySortedMap<K, V> implements Map<K, V> {
20
+ // oxlint-disable-next-line no-unsafe-declaration-merging -- Map<K,V> workaround for oxlint TS2420 false positive
21
+ export interface LazyKeySortedMap<K, V> extends Map<K, V> {}
22
+
23
+ // oxlint-disable-next-line no-unsafe-declaration-merging -- Map<K,V> workaround for oxlint TS2420 false positive
24
+ export class LazyKeySortedMap<K, V> {
21
25
  private readonly map: Map<K, V>
22
26
  private readonly maybeSortedKeys: K[]
23
27
  private keysAreSorted = false
@@ -117,7 +121,7 @@ export class LazyKeySortedMap<K, V> implements Map<K, V> {
117
121
  return this.entries()
118
122
  }
119
123
 
120
- [Symbol.toStringTag] = 'KeySortedMap'
124
+ readonly [Symbol.toStringTag] = 'KeySortedMap'
121
125
 
122
126
  /**
123
127
  * Zero-allocation callbacks over sorted data (faster than spreading to arrays).
@@ -125,7 +129,7 @@ export class LazyKeySortedMap<K, V> implements Map<K, V> {
125
129
  forEach(cb: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void {
126
130
  const { map } = this
127
131
  for (const k of this.getSortedKeys()) {
128
- cb.call(thisArg, map.get(k)!, k, this)
132
+ cb.call(thisArg, map.get(k)!, k, this as unknown as Map<K, V>)
129
133
  }
130
134
  }
131
135