loudo-ds-map-interfaces 0.0.6 → 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 +1 -0
- package/dist/index.js +23 -20
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -28,3 +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 forEach<K extends {}, V extends {}>(input: MapInput<K, V>, f: (k: K, v: V) => void): void;
|
package/dist/index.js
CHANGED
@@ -15,30 +15,33 @@ export class BaseMap {
|
|
15
15
|
mixin(BaseMap, [Tin]);
|
16
16
|
export class MapChange {
|
17
17
|
putAll(input) {
|
18
|
-
|
19
|
-
|
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
|
-
}
|
18
|
+
const me = this;
|
19
|
+
forEach(input, (k, v) => me.put(k, v));
|
38
20
|
}
|
39
21
|
}
|
40
22
|
mixin(MapChange, [BaseMap, Loud]);
|
41
23
|
export class MapRemove {
|
42
24
|
}
|
43
25
|
mixin(MapRemove, [BaseMap, Loud]);
|
26
|
+
export function forEach(input, f) {
|
27
|
+
if (input instanceof Map) {
|
28
|
+
for (const x of input) {
|
29
|
+
f(x[0], x[1]);
|
30
|
+
}
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
if (Symbol.iterator in input) {
|
34
|
+
for (const x of input) {
|
35
|
+
if (Array.isArray(x)) {
|
36
|
+
f(x[0], x[1]);
|
37
|
+
}
|
38
|
+
else {
|
39
|
+
f(x.key, x.value);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
for (const [k, v] of Object.entries(input))
|
45
|
+
f(k, v);
|
46
|
+
}
|
44
47
|
//# sourceMappingURL=index.js.map
|