form0-core 0.5.0 → 0.5.1
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/package.json
CHANGED
|
@@ -9,8 +9,14 @@ function copy(value, seen = new Map()) {
|
|
|
9
9
|
if (value === null || typeof value !== 'object') return value;
|
|
10
10
|
if (seen.has(value)) return seen.get(value);
|
|
11
11
|
if (value instanceof Date) return new Date(value.getTime());
|
|
12
|
+
// Media controls retain native binary handles. Copy their immutable data and standard metadata
|
|
13
|
+
// without serializing custom properties or loading the bytes into JavaScript memory.
|
|
14
|
+
if (typeof File === 'function' && value instanceof File)
|
|
15
|
+
return new File([value], value.name, { type: value.type, lastModified: value.lastModified });
|
|
16
|
+
if (typeof Blob === 'function' && value instanceof Blob)
|
|
17
|
+
return Blob.prototype.slice.call(value, 0, value.size, value.type);
|
|
12
18
|
if (!Array.isArray(value) && ![Object.prototype, null].includes(Object.getPrototypeOf(value)))
|
|
13
|
-
throw new Error('Event data must use plain objects, arrays or
|
|
19
|
+
throw new Error('Event data must use plain objects, arrays, dates or native media handles.');
|
|
14
20
|
const result = Array.isArray(value) ? [] : {};
|
|
15
21
|
seen.set(value, result);
|
|
16
22
|
for (const key of Object.keys(value)) {
|