rumious 2.1.4 → 2.1.5
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.js +10 -0
- package/dist/state/state.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -318,6 +318,16 @@ class RumiousState {
|
|
318
318
|
return Object.entries(this.value);
|
319
319
|
return [];
|
320
320
|
}
|
321
|
+
map(callback) {
|
322
|
+
const val = this.value;
|
323
|
+
if (Array.isArray(val)) {
|
324
|
+
return val.map((v, i) => callback(v, i));
|
325
|
+
}
|
326
|
+
if (val && typeof val === "object") {
|
327
|
+
return Object.entries(val).map(([k, v]) => callback(v, k));
|
328
|
+
}
|
329
|
+
return [];
|
330
|
+
}
|
321
331
|
}
|
322
332
|
function createState(value) {
|
323
333
|
return new RumiousState(value);
|
package/dist/state/state.d.ts
CHANGED
@@ -12,6 +12,7 @@ export declare class RumiousState<T> {
|
|
12
12
|
equal(value: T): boolean;
|
13
13
|
trigger(): void;
|
14
14
|
entries(): [any, any][];
|
15
|
+
map<R>(callback: (value: unknown, key: any) => R): R[];
|
15
16
|
}
|
16
17
|
export declare function createState<T>(value: T): RumiousState<T>;
|
17
18
|
type StateBindFor<M> = RumiousStateBind<RumiousState<M>>;
|