@naturalcycles/js-lib 15.47.0 → 15.47.2
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/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +1 -0
- package/dist/object/{keySortedMap2.d.ts → lazyKeySortedMap.d.ts} +4 -4
- package/dist/object/{keySortedMap2.js → lazyKeySortedMap.js} +2 -2
- package/dist/semver.js +0 -1
- package/package.json +1 -1
- package/src/object/index.ts +1 -0
- package/src/object/{keySortedMap2.ts → lazyKeySortedMap.ts} +5 -5
- package/src/semver.ts +0 -1
package/dist/object/index.d.ts
CHANGED
package/dist/object/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Comparator } from '../types.js';
|
|
2
|
-
export interface
|
|
2
|
+
export interface LazyKeySortedMapOptions<K> {
|
|
3
3
|
/**
|
|
4
4
|
* Defaults to undefined.
|
|
5
5
|
* Undefined (default comparator) works well for String keys.
|
|
@@ -14,16 +14,16 @@ export interface KeySortedMapOptions<K> {
|
|
|
14
14
|
*
|
|
15
15
|
* @experimental
|
|
16
16
|
*/
|
|
17
|
-
export declare class
|
|
17
|
+
export declare class LazyKeySortedMap<K, V> implements Map<K, V> {
|
|
18
18
|
#private;
|
|
19
19
|
private readonly map;
|
|
20
20
|
private readonly maybeSortedKeys;
|
|
21
21
|
private keysAreSorted;
|
|
22
|
-
constructor(entries?: [K, V][], opt?:
|
|
22
|
+
constructor(entries?: [K, V][], opt?: LazyKeySortedMapOptions<K>);
|
|
23
23
|
/**
|
|
24
24
|
* Convenience way to create KeySortedMap from object.
|
|
25
25
|
*/
|
|
26
|
-
static of<V>(obj: Record<any, V>):
|
|
26
|
+
static of<V>(obj: Record<any, V>): LazyKeySortedMap<string, V>;
|
|
27
27
|
get size(): number;
|
|
28
28
|
clear(): void;
|
|
29
29
|
has(key: K): boolean;
|
|
@@ -5,7 +5,7 @@ import { _assert } from '../error/index.js';
|
|
|
5
5
|
*
|
|
6
6
|
* @experimental
|
|
7
7
|
*/
|
|
8
|
-
export class
|
|
8
|
+
export class LazyKeySortedMap {
|
|
9
9
|
map;
|
|
10
10
|
maybeSortedKeys;
|
|
11
11
|
keysAreSorted = false;
|
|
@@ -19,7 +19,7 @@ export class KeySortedMap2 {
|
|
|
19
19
|
* Convenience way to create KeySortedMap from object.
|
|
20
20
|
*/
|
|
21
21
|
static of(obj) {
|
|
22
|
-
return new
|
|
22
|
+
return new LazyKeySortedMap(Object.entries(obj));
|
|
23
23
|
}
|
|
24
24
|
get size() {
|
|
25
25
|
return this.map.size;
|
package/dist/semver.js
CHANGED
package/package.json
CHANGED
package/src/object/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _assert } from '../error/index.js'
|
|
2
2
|
import type { Comparator } from '../types.js'
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface LazyKeySortedMapOptions<K> {
|
|
5
5
|
/**
|
|
6
6
|
* Defaults to undefined.
|
|
7
7
|
* Undefined (default comparator) works well for String keys.
|
|
@@ -17,12 +17,12 @@ export interface KeySortedMapOptions<K> {
|
|
|
17
17
|
*
|
|
18
18
|
* @experimental
|
|
19
19
|
*/
|
|
20
|
-
export class
|
|
20
|
+
export class LazyKeySortedMap<K, V> implements Map<K, V> {
|
|
21
21
|
private readonly map: Map<K, V>
|
|
22
22
|
private readonly maybeSortedKeys: K[]
|
|
23
23
|
private keysAreSorted = false
|
|
24
24
|
|
|
25
|
-
constructor(entries: [K, V][] = [], opt:
|
|
25
|
+
constructor(entries: [K, V][] = [], opt: LazyKeySortedMapOptions<K> = {}) {
|
|
26
26
|
this.#comparator = opt.comparator
|
|
27
27
|
this.map = new Map(entries)
|
|
28
28
|
this.maybeSortedKeys = [...this.map.keys()]
|
|
@@ -33,8 +33,8 @@ export class KeySortedMap2<K, V> implements Map<K, V> {
|
|
|
33
33
|
/**
|
|
34
34
|
* Convenience way to create KeySortedMap from object.
|
|
35
35
|
*/
|
|
36
|
-
static of<V>(obj: Record<any, V>):
|
|
37
|
-
return new
|
|
36
|
+
static of<V>(obj: Record<any, V>): LazyKeySortedMap<string, V> {
|
|
37
|
+
return new LazyKeySortedMap(Object.entries(obj))
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
get size(): number {
|
package/src/semver.ts
CHANGED