value-enhancer
Advanced tools
Comparing version 5.0.2 to 5.0.3
@@ -128,3 +128,2 @@ import { R as ReadonlyVal } from './typings-2bae36c2.js'; | ||
* @param count The number of elements to remove. Default 1. | ||
* @returns An array containing the elements that were deleted. | ||
*/ | ||
@@ -219,2 +218,3 @@ delete(index: number, count?: number): void; | ||
replace(entries: Iterable<readonly [TKey, TValue]>): Iterable<TValue>; | ||
toJSON(): object; | ||
/** | ||
@@ -278,2 +278,3 @@ * Dispose the map. | ||
replace(items: Iterable<TValue>): Iterable<TValue>; | ||
toJSON(): object[]; | ||
/** | ||
@@ -280,0 +281,0 @@ * Dispose the reactive set. |
@@ -244,2 +244,13 @@ 'use strict'; | ||
} | ||
toJSON() { | ||
const result = {}; | ||
for (const [key, value] of this) { | ||
if (key != null) { | ||
const k = String(key); | ||
const v = value; | ||
result[k] = v && v.toJSON ? v.toJSON(k) : v; | ||
} | ||
} | ||
return result; | ||
} | ||
dispose() { | ||
@@ -321,2 +332,7 @@ this.$.dispose(); | ||
} | ||
toJSON() { | ||
return [...this].map( | ||
(value, i) => value && value.toJSON ? value.toJSON(i) : value | ||
); | ||
} | ||
}; | ||
@@ -323,0 +339,0 @@ var reactiveSet = (values) => new ReactiveSetImpl(values); |
{ | ||
"name": "value-enhancer", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "A tiny library to enhance value with reactive wrapper.", |
@@ -148,3 +148,2 @@ import { readonlyVal } from "../readonly-val"; | ||
* @param count The number of elements to remove. Default 1. | ||
* @returns An array containing the elements that were deleted. | ||
*/ | ||
@@ -151,0 +150,0 @@ delete(index: number, count?: number): void; |
@@ -33,2 +33,4 @@ import { readonlyVal } from "../readonly-val"; | ||
toJSON(): object; | ||
/** | ||
@@ -139,2 +141,17 @@ * Dispose the map. | ||
public toJSON(): object { | ||
const result: Record<any, any> = {}; | ||
for (const [key, value] of this) { | ||
if (key != null) { | ||
const k = String(key); | ||
const v = value as | ||
| undefined | ||
| null | ||
| { toJSON?: (key: string) => object }; | ||
result[k] = v && v.toJSON ? v.toJSON(k) : v; | ||
} | ||
} | ||
return result; | ||
} | ||
public dispose(): void { | ||
@@ -141,0 +158,0 @@ this.$.dispose(); |
@@ -33,2 +33,4 @@ import { readonlyVal } from "../readonly-val"; | ||
toJSON(): object[]; | ||
/** | ||
@@ -134,2 +136,8 @@ * Dispose the reactive set. | ||
} | ||
public toJSON(): object[] { | ||
return [...this].map((value: any, i) => | ||
value && value.toJSON ? value.toJSON(i) : value | ||
); | ||
} | ||
} | ||
@@ -136,0 +144,0 @@ |
Sorry, the diff of this file is not supported yet
149130
4236