loudo-ds-map-interfaces 0.0.4 → 0.0.8

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/index.d.ts CHANGED
@@ -16,12 +16,16 @@ export interface BaseMap<K extends {}, V extends {}> extends Tin<Entry<K, V>> {
16
16
  }
17
17
  export declare abstract class MapChange<K extends {}, V extends {}> {
18
18
  abstract put(key: K, value: V): V | undefined;
19
+ putAll(input: MapInput<K, V>): void;
19
20
  }
20
21
  export interface MapChange<K extends {}, V extends {}> extends BaseMap<K, V>, Loud<Entry<K, V>> {
21
22
  }
22
23
  export declare abstract class MapRemove<K extends {}, V extends {}> {
23
- abstract remove(key: K): V | undefined;
24
+ abstract removeKey(key: K): V | undefined;
24
25
  abstract clear(): void;
25
26
  }
26
27
  export interface MapRemove<K extends {}, V extends {}> extends BaseMap<K, V>, Loud<Entry<K, V>> {
27
28
  }
29
+ export type Object<K extends {}, V extends {}> = K extends string ? Record<string, V> : never;
30
+ export type MapInput<K extends {}, V extends {}> = Map<K, V> | Iterable<Entry<K, V> | [K, V]> | Object<K, V>;
31
+ export declare function putAll<K extends {}, V extends {}>(map: MapChange<K, V>, input: MapInput<K, V>): void;
package/dist/index.js CHANGED
@@ -14,9 +14,34 @@ export class BaseMap {
14
14
  }
15
15
  mixin(BaseMap, [Tin]);
16
16
  export class MapChange {
17
+ putAll(input) {
18
+ putAll(this, input);
19
+ }
17
20
  }
18
21
  mixin(MapChange, [BaseMap, Loud]);
19
22
  export class MapRemove {
20
23
  }
21
24
  mixin(MapRemove, [BaseMap, Loud]);
25
+ export function putAll(map, input) {
26
+ if (input instanceof Map) {
27
+ for (const x of input) {
28
+ map.put(x[0], x[1]);
29
+ }
30
+ return;
31
+ }
32
+ if (Symbol.iterator in input) {
33
+ for (const x of input) {
34
+ if (Array.isArray(x)) {
35
+ map.put(x[0], x[1]);
36
+ }
37
+ else {
38
+ map.put(x.key, x.value);
39
+ }
40
+ }
41
+ return;
42
+ }
43
+ for (const k in input) {
44
+ map.put(k, input[k]);
45
+ }
46
+ }
22
47
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "loudo-ds-map-interfaces",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.8",
5
5
  "description": "Core interfaces for loud maps (dictionaries.)",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",