loudo-ds-map-interfaces 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.d.ts CHANGED
@@ -28,4 +28,4 @@ export interface MapRemove<K extends {}, V extends {}> extends BaseMap<K, V>, Lo
28
28
  }
29
29
  export type Object<K extends {}, V extends {}> = K extends string ? Record<string, V> : never;
30
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;
31
+ export declare function forEach<K extends {}, V extends {}>(input: MapInput<K, V>, f: (k: K, v: V) => void): void;
package/dist/index.js CHANGED
@@ -15,33 +15,33 @@ export class BaseMap {
15
15
  mixin(BaseMap, [Tin]);
16
16
  export class MapChange {
17
17
  putAll(input) {
18
- putAll(this, input);
18
+ const me = this;
19
+ forEach(input, (k, v) => me.put(k, v));
19
20
  }
20
21
  }
21
22
  mixin(MapChange, [BaseMap, Loud]);
22
23
  export class MapRemove {
23
24
  }
24
25
  mixin(MapRemove, [BaseMap, Loud]);
25
- export function putAll(map, input) {
26
+ export function forEach(input, f) {
26
27
  if (input instanceof Map) {
27
28
  for (const x of input) {
28
- map.put(x[0], x[1]);
29
+ f(x[0], x[1]);
29
30
  }
30
31
  return;
31
32
  }
32
33
  if (Symbol.iterator in input) {
33
34
  for (const x of input) {
34
35
  if (Array.isArray(x)) {
35
- map.put(x[0], x[1]);
36
+ f(x[0], x[1]);
36
37
  }
37
38
  else {
38
- map.put(x.key, x.value);
39
+ f(x.key, x.value);
39
40
  }
40
41
  }
41
42
  return;
42
43
  }
43
- for (const k in input) {
44
- map.put(k, input[k]);
45
- }
44
+ for (const [k, v] of Object.entries(input))
45
+ f(k, v);
46
46
  }
47
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.8",
4
+ "version": "0.0.10",
5
5
  "description": "Core interfaces for loud maps (dictionaries.)",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",