@live-change/serialization 0.9.162 → 0.9.164

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
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@live-change/serialization",
3
- "version": "0.9.162",
3
+ "version": "0.9.164",
4
4
  "scripts": {},
5
5
  "type": "module",
6
6
  "main": "index.js",
7
7
  "author": "Michał Łaszczewski <michal@laszczewski.pl>",
8
8
  "license": "ISC",
9
9
  "description": "",
10
- "gitHead": "59cd1485ca6d76bd87a6634a92d6e661e5803d5e"
10
+ "gitHead": "38f9fb8b01a9527d8f6036e174edd1fa41443301"
11
11
  }
package/serialization.js CHANGED
@@ -5,11 +5,12 @@ export const typeMap = Object.freeze({
5
5
  'boolean': 'b',
6
6
  'object': 'o',
7
7
  'null': 'z',
8
- 'array': 'a'
8
+ 'array': 'a',
9
+ 'undefined': 'u'
9
10
  })
10
11
 
11
12
  export const types = Object.freeze(Object.fromEntries(
12
- Object.entries(typeMap).map(([type, key]) => [key, type])
13
+ Object.entries(typeMap).map(([type, key]) => [key, type])
13
14
  ))
14
15
 
15
16
  /** Serialize any data using writer
@@ -38,6 +39,7 @@ export function write(data, writer) {
38
39
  write(value, writer)
39
40
  }
40
41
  return writer
42
+ case 'undefined': return writer.writeType(typeMap.undefined)
41
43
  default:
42
44
  throw new Error(`Unsupported type: ${typeof data}`)
43
45
  }
package/stringKey.js CHANGED
@@ -174,6 +174,12 @@ export function serializeKeyToString(key) {
174
174
  return writer.getOutput()
175
175
  }
176
176
 
177
+ export function serializeKeyDataToString(key) {
178
+ const writer = new StringKeyWriter()
179
+ write(key, writer)
180
+ return writer.getData()
181
+ }
182
+
177
183
  export function deserializeKeyFromString(serialized, structure) {
178
184
  const reader = new StringKeyReader(serialized, structure)
179
185
  return read(reader)