loudo-ds-map-interfaces 0.0.2 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -16,12 +16,15 @@ 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>;
package/dist/index.js CHANGED
@@ -14,6 +14,28 @@ export class BaseMap {
14
14
  }
15
15
  mixin(BaseMap, [Tin]);
16
16
  export class MapChange {
17
+ putAll(input) {
18
+ if (input instanceof Map) {
19
+ for (const x of input) {
20
+ this.put(x[0], x[1]);
21
+ }
22
+ return;
23
+ }
24
+ if (Symbol.iterator in input) {
25
+ for (const x of input) {
26
+ if (Array.isArray(x)) {
27
+ this.put(x[0], x[1]);
28
+ }
29
+ else {
30
+ this.put(x.key, x.value);
31
+ }
32
+ }
33
+ return;
34
+ }
35
+ for (const k in input) {
36
+ this.put(k, input[k]);
37
+ }
38
+ }
17
39
  }
18
40
  mixin(MapChange, [BaseMap, Loud]);
19
41
  export class MapRemove {
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.2",
4
+ "version": "0.0.6",
5
5
  "description": "Core interfaces for loud maps (dictionaries.)",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -31,6 +31,6 @@
31
31
  "vitest": "^1.2.2"
32
32
  },
33
33
  "dependencies": {
34
- "loudo-ds-core": "^0.0.22"
34
+ "loudo-ds-core": "^0.0.24"
35
35
  }
36
36
  }