+6
-0
| # Changelog | ||
| ## Unreleased | ||
| ## 0.3.12 (2023-12-11) | ||
| - added: Support the JavaScript `Set` and `Map` types in serialized data. | ||
| ## 0.3.11 (2023-07-27) | ||
@@ -4,0 +10,0 @@ |
+28
-0
@@ -203,2 +203,4 @@ 'use strict'; | ||
| if (data instanceof Uint8Array) return 'u8'; | ||
| if (data instanceof Map) return 'M'; | ||
| if (data instanceof Set) return 'S'; | ||
@@ -312,2 +314,10 @@ if (data[MAGIC_KEY] != null) { | ||
| case 'M': | ||
| // $FlowFixMe - Flow is incorrect. This is fine. | ||
| return packData(table, Array.from(data.entries())); | ||
| case 'S': | ||
| // $FlowFixMe - Flow is incorrect. This is fine. | ||
| return packData(table, Array.from(data.values())); | ||
| default: | ||
@@ -433,2 +443,20 @@ { | ||
| case 'M': | ||
| { | ||
| if (typeof raw !== 'object' || raw === null) { | ||
| throw new TypeError("Expecting an Map description at " + path); | ||
| } | ||
| return new Map(unpackData(table, raw, path)); | ||
| } | ||
| case 'S': | ||
| { | ||
| if (typeof raw !== 'object' || raw === null) { | ||
| throw new TypeError("Expecting an Set description at " + path); | ||
| } | ||
| return new Set(unpackData(table, raw, path)); | ||
| } | ||
| default: | ||
@@ -435,0 +463,0 @@ { |
+28
-0
@@ -199,2 +199,4 @@ import { base64 } from 'rfc4648'; | ||
| if (data instanceof Uint8Array) return 'u8'; | ||
| if (data instanceof Map) return 'M'; | ||
| if (data instanceof Set) return 'S'; | ||
@@ -308,2 +310,10 @@ if (data[MAGIC_KEY] != null) { | ||
| case 'M': | ||
| // $FlowFixMe - Flow is incorrect. This is fine. | ||
| return packData(table, Array.from(data.entries())); | ||
| case 'S': | ||
| // $FlowFixMe - Flow is incorrect. This is fine. | ||
| return packData(table, Array.from(data.values())); | ||
| default: | ||
@@ -429,2 +439,20 @@ { | ||
| case 'M': | ||
| { | ||
| if (typeof raw !== 'object' || raw === null) { | ||
| throw new TypeError("Expecting an Map description at " + path); | ||
| } | ||
| return new Map(unpackData(table, raw, path)); | ||
| } | ||
| case 'S': | ||
| { | ||
| if (typeof raw !== 'object' || raw === null) { | ||
| throw new TypeError("Expecting an Set description at " + path); | ||
| } | ||
| return new Set(unpackData(table, raw, path)); | ||
| } | ||
| default: | ||
@@ -431,0 +459,0 @@ { |
+1
-1
| { | ||
| "name": "yaob", | ||
| "version": "0.3.11", | ||
| "version": "0.3.12", | ||
| "description": "Bridges an object-oriented API across a messaging layer", | ||
@@ -5,0 +5,0 @@ "repository": { |
+28
-2
@@ -34,7 +34,9 @@ // @flow | ||
| | 'e' // Error | ||
| | 'o' // Object | ||
| | 's' // Shared data | ||
| | 'o' // Bridged object | ||
| | 's' // Global shared object | ||
| | 'u' // Undefined | ||
| | 'ab' // ArrayBuffer | ||
| | 'u8' // Uint8Array | ||
| | 'M' // Map | ||
| | 'S' // Set | ||
@@ -126,2 +128,4 @@ /** | ||
| if (data instanceof Uint8Array) return 'u8' | ||
| if (data instanceof Map) return 'M' | ||
| if (data instanceof Set) return 'S' | ||
| if (data[MAGIC_KEY] != null) { | ||
@@ -223,2 +227,10 @@ return data[MAGIC_KEY].shareId != null ? 's' : 'o' | ||
| case 'M': | ||
| // $FlowFixMe - Flow is incorrect. This is fine. | ||
| return packData(table, Array.from(data.entries())) | ||
| case 'S': | ||
| // $FlowFixMe - Flow is incorrect. This is fine. | ||
| return packData(table, Array.from(data.values())) | ||
| default: { | ||
@@ -336,2 +348,16 @@ // Arrays: | ||
| case 'M': { | ||
| if (typeof raw !== 'object' || raw === null) { | ||
| throw new TypeError(`Expecting an Map description at ${path}`) | ||
| } | ||
| return new Map(unpackData(table, raw, path)) | ||
| } | ||
| case 'S': { | ||
| if (typeof raw !== 'object' || raw === null) { | ||
| throw new TypeError(`Expecting an Set description at ${path}`) | ||
| } | ||
| return new Set(unpackData(table, raw, path)) | ||
| } | ||
| default: { | ||
@@ -338,0 +364,0 @@ if (typeof map !== 'object' || map === null) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
263906
2.22%3509
1.92%