typeson-registry 1.0.0-alpha.7 → 2.0.0

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.
Files changed (215) hide show
  1. package/{LICENSE → LICENSE-MIT.txt} +0 -0
  2. package/README.md +189 -77
  3. package/dist/index.js +1205 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.min.js +2 -0
  6. package/dist/index.min.js.map +1 -0
  7. package/dist/index.umd.js +2274 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/index.umd.min.js +2 -0
  10. package/dist/index.umd.min.js.map +1 -0
  11. package/dist/presets/array-nonindex-keys.umd.js +2 -0
  12. package/dist/presets/array-nonindex-keys.umd.js.map +1 -0
  13. package/dist/presets/builtin.umd.js +2 -0
  14. package/dist/presets/builtin.umd.js.map +1 -0
  15. package/dist/presets/postmessage.umd.js +2 -0
  16. package/dist/presets/postmessage.umd.js.map +1 -0
  17. package/dist/presets/socketio.umd.js +2 -0
  18. package/dist/presets/socketio.umd.js.map +1 -0
  19. package/dist/presets/sparse-undefined.umd.js +2 -0
  20. package/dist/presets/sparse-undefined.umd.js.map +1 -0
  21. package/dist/presets/special-numbers.umd.js +2 -0
  22. package/dist/presets/special-numbers.umd.js.map +1 -0
  23. package/dist/presets/structured-cloning-throwing.umd.js +2 -0
  24. package/dist/presets/structured-cloning-throwing.umd.js.map +1 -0
  25. package/dist/presets/structured-cloning.umd.js +2 -0
  26. package/dist/presets/structured-cloning.umd.js.map +1 -0
  27. package/dist/presets/undef.umd.js +2 -0
  28. package/dist/presets/undef.umd.js.map +1 -0
  29. package/dist/presets/universal.umd.js +2 -0
  30. package/dist/presets/universal.umd.js.map +1 -0
  31. package/dist/types/arraybuffer.umd.js +2 -0
  32. package/dist/types/arraybuffer.umd.js.map +1 -0
  33. package/dist/types/bigint-object.umd.js +2 -0
  34. package/dist/types/bigint-object.umd.js.map +1 -0
  35. package/dist/types/bigint.umd.js +2 -0
  36. package/dist/types/bigint.umd.js.map +1 -0
  37. package/dist/types/blob.umd.js +2 -0
  38. package/dist/types/blob.umd.js.map +1 -0
  39. package/dist/types/cloneable.umd.js +2 -0
  40. package/dist/types/cloneable.umd.js.map +1 -0
  41. package/dist/types/cryptokey.umd.js +2 -0
  42. package/dist/types/cryptokey.umd.js.map +1 -0
  43. package/dist/types/dataview.umd.js +2 -0
  44. package/dist/types/dataview.umd.js.map +1 -0
  45. package/dist/types/date.umd.js +2 -0
  46. package/dist/types/date.umd.js.map +1 -0
  47. package/dist/types/error.umd.js +2 -0
  48. package/dist/types/error.umd.js.map +1 -0
  49. package/dist/types/errors.umd.js +2 -0
  50. package/dist/types/errors.umd.js.map +1 -0
  51. package/dist/types/file.umd.js +2 -0
  52. package/dist/types/file.umd.js.map +1 -0
  53. package/dist/types/filelist.umd.js +2 -0
  54. package/dist/types/filelist.umd.js.map +1 -0
  55. package/dist/types/imagebitmap.umd.js +2 -0
  56. package/dist/types/imagebitmap.umd.js.map +1 -0
  57. package/dist/types/imagedata.umd.js +2 -0
  58. package/dist/types/imagedata.umd.js.map +1 -0
  59. package/dist/types/infinity.umd.js +2 -0
  60. package/dist/types/infinity.umd.js.map +1 -0
  61. package/dist/types/intl-types.umd.js +2 -0
  62. package/dist/types/intl-types.umd.js.map +1 -0
  63. package/dist/types/map.umd.js +2 -0
  64. package/dist/types/map.umd.js.map +1 -0
  65. package/dist/types/nan.umd.js +2 -0
  66. package/dist/types/nan.umd.js.map +1 -0
  67. package/dist/types/negative-infinity.umd.js +2 -0
  68. package/dist/types/negative-infinity.umd.js.map +1 -0
  69. package/dist/types/nonbuiltin-ignore.umd.js +2 -0
  70. package/dist/types/nonbuiltin-ignore.umd.js.map +1 -0
  71. package/dist/types/primitive-objects.umd.js +2 -0
  72. package/dist/types/primitive-objects.umd.js.map +1 -0
  73. package/dist/types/regexp.umd.js +2 -0
  74. package/dist/types/regexp.umd.js.map +1 -0
  75. package/dist/types/resurrectable.umd.js +2 -0
  76. package/dist/types/resurrectable.umd.js.map +1 -0
  77. package/dist/types/set.umd.js +2 -0
  78. package/dist/types/set.umd.js.map +1 -0
  79. package/dist/types/typed-arrays-socketio.umd.js +2 -0
  80. package/dist/types/typed-arrays-socketio.umd.js.map +1 -0
  81. package/dist/types/typed-arrays.umd.js +2 -0
  82. package/dist/types/typed-arrays.umd.js.map +1 -0
  83. package/dist/types/undef.umd.js +2 -0
  84. package/dist/types/undef.umd.js.map +1 -0
  85. package/dist/types/user-object.umd.js +2 -0
  86. package/dist/types/user-object.umd.js.map +1 -0
  87. package/package.json +98 -27
  88. package/polyfills/createObjectURL.js +96 -0
  89. package/polyfills/createObjectURL.umd.js +2 -0
  90. package/polyfills/createObjectURL.umd.js.map +1 -0
  91. package/utils/generateUUID.js +29 -0
  92. package/utils/stringArrayBuffer.js +72 -0
  93. package/CHANGES +0 -126
  94. package/browser-test/index.html +0 -30
  95. package/browser-test/testLoading.js +0 -57
  96. package/browser-test/worker.html +0 -31
  97. package/browser-test/worker.js +0 -16
  98. package/build.js +0 -99
  99. package/dist/all.js +0 -126
  100. package/dist/all.js.map +0 -89
  101. package/dist/presets/builtin.js +0 -78
  102. package/dist/presets/builtin.js.map +0 -59
  103. package/dist/presets/post-message.js +0 -21
  104. package/dist/presets/post-message.js.map +0 -23
  105. package/dist/presets/socketio.js +0 -87
  106. package/dist/presets/socketio.js.map +0 -63
  107. package/dist/presets/sparse-undefined.js +0 -12
  108. package/dist/presets/sparse-undefined.js.map +0 -19
  109. package/dist/presets/special-numbers.js +0 -21
  110. package/dist/presets/special-numbers.js.map +0 -25
  111. package/dist/presets/structured-cloning-throwing.js +0 -90
  112. package/dist/presets/structured-cloning-throwing.js.map +0 -69
  113. package/dist/presets/structured-cloning.js +0 -87
  114. package/dist/presets/structured-cloning.js.map +0 -67
  115. package/dist/presets/undefined.js +0 -18
  116. package/dist/presets/undefined.js.map +0 -23
  117. package/dist/presets/universal.js +0 -81
  118. package/dist/presets/universal.js.map +0 -61
  119. package/dist/types/Infinity.js +0 -12
  120. package/dist/types/Infinity.js.map +0 -19
  121. package/dist/types/NaN.js +0 -12
  122. package/dist/types/NaN.js.map +0 -19
  123. package/dist/types/NegativeInfinity.js +0 -12
  124. package/dist/types/NegativeInfinity.js.map +0 -19
  125. package/dist/types/arraybuffer.js +0 -15
  126. package/dist/types/arraybuffer.js.map +0 -21
  127. package/dist/types/blob.js +0 -12
  128. package/dist/types/blob.js.map +0 -19
  129. package/dist/types/cloneable.js +0 -12
  130. package/dist/types/cloneable.js.map +0 -19
  131. package/dist/types/dataview.js +0 -15
  132. package/dist/types/dataview.js.map +0 -21
  133. package/dist/types/date.js +0 -12
  134. package/dist/types/date.js.map +0 -19
  135. package/dist/types/error.js +0 -12
  136. package/dist/types/error.js.map +0 -19
  137. package/dist/types/errors.js +0 -15
  138. package/dist/types/errors.js.map +0 -19
  139. package/dist/types/file.js +0 -12
  140. package/dist/types/file.js.map +0 -19
  141. package/dist/types/filelist.js +0 -15
  142. package/dist/types/filelist.js.map +0 -21
  143. package/dist/types/imagebitmap.js +0 -12
  144. package/dist/types/imagebitmap.js.map +0 -19
  145. package/dist/types/imagedata.js +0 -12
  146. package/dist/types/imagedata.js.map +0 -19
  147. package/dist/types/intl-types.js +0 -12
  148. package/dist/types/intl-types.js.map +0 -19
  149. package/dist/types/map.js +0 -15
  150. package/dist/types/map.js.map +0 -21
  151. package/dist/types/nonbuiltin-ignore.js +0 -12
  152. package/dist/types/nonbuiltin-ignore.js.map +0 -19
  153. package/dist/types/primitive-objects.js +0 -12
  154. package/dist/types/primitive-objects.js.map +0 -19
  155. package/dist/types/regexp.js +0 -12
  156. package/dist/types/regexp.js.map +0 -19
  157. package/dist/types/resurrectable.js +0 -12
  158. package/dist/types/resurrectable.js.map +0 -19
  159. package/dist/types/set.js +0 -15
  160. package/dist/types/set.js.map +0 -21
  161. package/dist/types/special-numbers.js +0 -12
  162. package/dist/types/special-numbers.js.map +0 -19
  163. package/dist/types/typed-arrays-socketio.js +0 -15
  164. package/dist/types/typed-arrays-socketio.js.map +0 -19
  165. package/dist/types/typed-arrays.js +0 -18
  166. package/dist/types/typed-arrays.js.map +0 -21
  167. package/dist/types/undefined.js +0 -12
  168. package/dist/types/undefined.js.map +0 -19
  169. package/dist/types/user-object.js +0 -12
  170. package/dist/types/user-object.js.map +0 -19
  171. package/index.js +0 -39
  172. package/presets/builtin.js +0 -24
  173. package/presets/post-message.js +0 -15
  174. package/presets/socketio.js +0 -5
  175. package/presets/sparse-undefined.js +0 -19
  176. package/presets/special-numbers.js +0 -5
  177. package/presets/structured-cloning-throwing.js +0 -32
  178. package/presets/structured-cloning.js +0 -24
  179. package/presets/undefined.js +0 -4
  180. package/presets/universal.js +0 -4
  181. package/server.js +0 -10
  182. package/test/Flag_of_the_United_Nations.png +0 -0
  183. package/test/createObjectURL.js +0 -28
  184. package/test/test-entry.js +0 -49
  185. package/test/test-environment.js +0 -119
  186. package/test/test-node.js +0 -56
  187. package/test/test-utils.js +0 -38
  188. package/test/test.js +0 -885
  189. package/types/Infinity.js +0 -5
  190. package/types/NaN.js +0 -5
  191. package/types/NegativeInfinity.js +0 -5
  192. package/types/arraybuffer.js +0 -9
  193. package/types/blob.js +0 -36
  194. package/types/cloneable.js +0 -30
  195. package/types/dataview.js +0 -7
  196. package/types/date.js +0 -17
  197. package/types/error.js +0 -11
  198. package/types/errors.js +0 -20
  199. package/types/file.js +0 -41
  200. package/types/filelist.js +0 -23
  201. package/types/imagebitmap.js +0 -49
  202. package/types/imagedata.js +0 -14
  203. package/types/intl-types.js +0 -18
  204. package/types/map.js +0 -7
  205. package/types/nonbuiltin-ignore.js +0 -16
  206. package/types/primitive-objects.js +0 -23
  207. package/types/regexp.js +0 -11
  208. package/types/resurrectable.js +0 -28
  209. package/types/set.js +0 -7
  210. package/types/typed-arrays-socketio.js +0 -32
  211. package/types/typed-arrays.js +0 -23
  212. package/types/undefined.js +0 -9
  213. package/types/user-object.js +0 -6
  214. package/utils/array-from-iterator.js +0 -7
  215. package/windows-devinstall.js +0 -41
File without changes
package/README.md CHANGED
@@ -1,43 +1,91 @@
1
1
  # typeson-registry
2
2
 
3
- The type registry for [typeson](https://github.com/dfahlander/typeson)
3
+ The type registry for [typeson](https://github.com/dfahlander/typeson).
4
4
 
5
- - Types listed under [types](https://github.com/dfahlander/typeson-registry/tree/master/types)
6
- - Presets listed under [presets](https://github.com/dfahlander/typeson-registry/tree/master/presets)
5
+ - Types listed under
6
+ [types](https://github.com/dfahlander/typeson-registry/tree/master/types)
7
+ - Presets listed under
8
+ [presets](https://github.com/dfahlander/typeson-registry/tree/master/presets)
7
9
 
8
10
  See below for notes on these types and presets.
9
11
 
10
- Note that some types will require polyfills in Node such as via [`jsdom`](https://github.com/tmpvar/jsdom/).
12
+ Note that some types will require polyfills in Node such as via
13
+ [`jsdom`](https://github.com/jsdom/jsdom).
11
14
  See the testing environment of `test/test.js` for some examples.
12
15
 
13
16
  ## Installation
14
17
 
15
- You must run `npm run build` if you wish to get the individual browser scripts built locally (into `dist`)
16
- (or in development to get `index.js` to be rebuilt based on existing presets and types).
18
+ Note that for Node.js, to use the `file` or `blob` types (or the `filelist`
19
+ type or `structuredCloning` and `structuredCloningThrowing` presets which
20
+ include them), you will need a polyfill for `Blob` or `File`, respectively,
21
+ as well as `FileReader` and `URL.createObjectURL` (and a
22
+ polyfill for `URL` if you are using Node < 10.0.0 or an older browser).
23
+ Note that our `URL.createObjectURL` polyfill expects a global
24
+ `XMLHttpRequest` and `location.href` predefined before it as well (and one
25
+ which can handle `data:` URLs). For Node, you can add it like this:
17
26
 
18
- ## Usage
27
+ ```js
28
+ const url = require('url'); // This line only needed to support Node < 10.0.0
29
+ const {createObjectURL} = require('typeson-registry/polyfills/createObjectURL.umd.js');
30
+
31
+ const URL = url.Url; // This line only needed to support Node < 10.0.0
32
+ URL.createObjectURL = createObjectURL;
33
+ ```
34
+
35
+ We have not added `jsdom` as a dependency, but it is required if this
36
+ polyfill is used.
37
+
38
+ Besides the polyfills for `file` or `blob`, the `structuredCloningThrowing`
39
+ preset also needs a global `DOMException` polyfill.
40
+
41
+ The `filelist` type, in addition to the polyfills for `file`, will need
42
+ a `FileList` polyfill (including a `FileList` string tag).
43
+
44
+ The `imagebitmap` type requires a global `createImageBitmap` polyfill (and
45
+ an `ImageBitmap` polyfill (including an `ImageBitmap` string tag).
46
+
47
+ The `imagedata` type requires a global `ImageData` polyfill (including an
48
+ `ImageData` string tag).
49
+
50
+ You may wish to see our `test-node.js` and `test-environment.js` files
51
+ for how some polyfilling may be done (largely using `jsdom`).
52
+
53
+ The `cloneable` and `resurrectable` types (and the `createObjectURL`
54
+ polyill) each accept an optional global `performance` polyfill (through
55
+ the common file `utils/generateUUID.js`).
56
+
57
+ ### Building files from Git clone (as opposed to npm installs)
58
+
59
+ If you have cloned the repo (and not the npm package), you must run
60
+ `npm install` to get the `devDependencies` and then run
61
+ `npm run rollup` to get the individual browser scripts built locally
62
+ (into `dist`) or to get `index.js` to be rebuilt based on existing
63
+ presets and types).
64
+
65
+ ## Usage (Pre-rollup in Node or browser)
19
66
 
20
67
  ```js
21
- var Typeson = require ('typeson');
22
- var TSON = new Typeson().register([
23
- require('typeson-registry/types/date'),
24
- require('typeson-registry/types/error'),
25
- require('typeson-registry/types/regexp'),
26
- require('typeson-registry/types/typed-arrays'),
68
+ import {Typeson, date, error, regexp, typedArrays} from 'typeson-registry';
69
+
70
+ const TSON = new Typeson().register([
71
+ date,
72
+ error,
73
+ regexp,
74
+ typedArrays
27
75
  // ...
28
76
  ]);
29
77
 
30
- var tson = TSON.stringify({
31
- Hello: "world",
78
+ const tson = TSON.stringify({
79
+ Hello: 'world',
32
80
  date: new Date(),
33
- error: new Error(),
81
+ error: new Error('test'),
34
82
  inner: {
35
- x: /foo/ig,
83
+ x: /foo/gui,
36
84
  bin: new Uint8Array(64)
37
85
  }
38
86
  }, null, 2);
39
87
 
40
- console.log(tson);
88
+ console.log(tson);
41
89
  /* Output:
42
90
 
43
91
  {
@@ -45,7 +93,7 @@ console.log(tson);
45
93
  "date": 1464049031538,
46
94
  "error": {
47
95
  "name": "Error",
48
- "message": ""
96
+ "message": "test"
49
97
  },
50
98
  "inner": {
51
99
  "x": {
@@ -63,37 +111,60 @@ console.log(tson);
63
111
  }
64
112
  */
65
113
 
66
- var parsedBack = TSON.parse(tson);
114
+ const parsedBack = TSON.parse(tson);
67
115
 
68
- assert(parsedBack.date instanceof Date);
69
- assert(parsedBack.inner.bin instanceof Uint8Array);
116
+ console.log(parsedBack.date instanceof Date);
117
+ console.log(parsedBack.inner.bin instanceof Uint8Array);
118
+ ```
119
+
120
+ ## Usage (Node without own Rollup)
121
+
122
+ ```js
123
+ const {Typeson, builtin} = require('typeson-registry');
124
+
125
+ const tson = new Typeson().register([
126
+ builtin
127
+ ]);
128
+ ```
70
129
 
130
+ ## Usage (`import` in supporting browsers without own Rollup)
131
+
132
+ ```html
133
+ <script type="module">
134
+
135
+ import {Typeson, builtin} from './node_modules/typeson-registry/dist/index.js';
136
+
137
+ const TSON = new Typeson().register([
138
+ builtin
139
+ ]);
140
+ </script>
71
141
  ```
72
142
 
73
- ## Usage (with plain script tags)
143
+ ## Usage (with plain script tags without own Rollup)
74
144
 
75
- All types and presets under dist are UMD modules so you could also require them as AMD modules with requirejs if you prefer.
145
+ All types and presets under `dist/` are UMD modules so you could also
146
+ require them as AMD modules with requirejs if you prefer.
76
147
 
77
148
  ```html
78
149
  <!DOCTYPE html>
79
150
  <html>
80
151
  <head>
81
- <script src="https://unpkg.com/typeson/dist/typeson.js"></script>
82
- <script src="https://unpkg.com/typeson-registry/dist/presets/builtin.js"></script>
152
+ <script src="https://unpkg.com/typeson/dist/typeson.umd.min.js"></script>
153
+ <script src="https://unpkg.com/typeson-registry/dist/presets/builtin.umd.js"></script>
83
154
  <script>
84
155
 
85
- var TSON = new Typeson().register(Typeson.presets.builtin);
86
- var tson = TSON.stringify({
87
- Hello: "world",
156
+ const TSON = new Typeson().register(builtin);
157
+ const tson = TSON.stringify({
158
+ Hello: 'world',
88
159
  date: new Date(),
89
- error: new Error(),
160
+ error: new Error('err'),
90
161
  inner: {
91
- x: /foo/ig,
162
+ x: /foo/giu,
92
163
  bin: new Uint8Array(64)
93
164
  }
94
165
  }, null, 2);
95
166
 
96
- alert(tson);
167
+ alert(tson);
97
168
  /* Alerts:
98
169
 
99
170
  {
@@ -101,7 +172,7 @@ All types and presets under dist are UMD modules so you could also require them
101
172
  "date": 1464049031538,
102
173
  "error": {
103
174
  "name": "Error",
104
- "message": ""
175
+ "message": "err"
105
176
  },
106
177
  "inner": {
107
178
  "x": {
@@ -126,101 +197,142 @@ All types and presets under dist are UMD modules so you could also require them
126
197
 
127
198
  ## Notes on types and presets
128
199
 
200
+ Note that the type name corresponds to the file name in the following manner:
201
+
202
+ 1. Genuine separate words are camel-cased in the type name but hyphenated in
203
+ the file name (e.g., `negativeInfinity` and `negativity-infinity.js`);
204
+ names whose original API is camel-cased are not hyphenated, however
205
+ (e.g., `arraybuffer` and `arraybuffer.js` given `ArrayBuffer`).
206
+ 1. All other portions of names are lower-cased (e.g., `date` and `date.js`).
207
+ 1. Type names that would clash with existing objects when exported (even after
208
+ lower-casing) must have a separate, preferably abbreviated form (e.g.,
209
+ the type and preset `undef` and `undef.js` was necessary for `undefined`)
210
+ 1. Type names which are not allowed as ES6 exports (e.g., periods in `Intl`
211
+ types are now removed: `Intl.Collator` -> `IntlCollator`)
212
+ 1. Type names should indicate the singular (e.g., `userObject`) except for
213
+ files containing multiple related exports (e.g., `errors`, `typed-arrays`,
214
+ and `typed-arrays-socketio.js`); files with multiple exports whose extra
215
+ exports are incidental (e.g., `filelist`) do not need a plural.
216
+
129
217
  ### Types
130
218
 
131
- - `ArrayBuffer`
132
- - `Blob` - Has sync and async encapsulation/replacements (though sync only
219
+ - `arraybuffer`
220
+ - `bigintObject`
221
+ - `bigint`
222
+ - `blob` - Has sync and async encapsulation/replacements (though sync only
133
223
  via deprecated means)
134
- - `cloneable` - Looks for `__cloneEncapsulate` and `__cloneRevive` methods to allow
224
+ - `cloneable` - Looks for `Symbol.for('cloneEncapsulate')` and
225
+ `Symbol.for('cloneRevive')` methods to allow
135
226
  for a means of extending our built-in structured cloning presets (though if
136
227
  you are polyfilling a standard object, we welcome you to submit back as a
137
- PR!). The clones cannot be revived past the current window session, however.
138
- - `DataView`
139
- - `Date`
228
+ PR!). The clones cannot be revived past the current window session,
229
+ however.
230
+ - `dataview`
231
+ - `date`
140
232
  - `error.js` (`Error`) and `errors.js` (`TypeError`, `RangeError`, `SyntaxError`, `ReferenceError`, `EvalError`, `URIError`, `InternalError`) - These
141
233
  provide a means of resurrecting error object across cloning boundaries
142
234
  (since they are not otherwise treated as cloneable by the Structured
143
235
  Cloning Algorithm).
144
- - `File` - Has sync and async encapsulation/replacements (though sync only
236
+ - `file` - Has sync and async encapsulation/replacements (though sync only
145
237
  via deprecated means)
146
- - `FileList` - HTML does not provide a means of creating a `FileList` object
238
+ - `filelist` - HTML does not provide a means of creating a `FileList` object
147
239
  dynamically, so we polyfill one for revival. This method also sets `File`
148
- - `ImageBitmap` - Has sync and async revivers. The sync method does not produce
240
+ - `imagebitmap` - Has sync and async revivers. The sync method does not produce
149
241
  a genuine `ImageBitmap` but instead produces a canvas element which can
150
242
  frequently be used in a similar context to `ImageBitmap`.
151
- - `ImageData`
152
- - `Infinity` - Preserves positive infinity
243
+ - `imagedata`
244
+ - `infinity` - Preserves positive infinity
153
245
  - `intl-types.js` (`Intl.Collator`, `Intl.DateTimeFormat`, `Intl.NumberFormat`) -
154
246
  Not all properties can be preserved
155
- - `Map`
156
- - `NaN` - Preserves `NaN` (not a number)
247
+ - `map`
248
+ - `nan` - Preserves `NaN` (not a number)
157
249
  - `NegativeInfinity` - Preserves negative infinity
158
250
  - `nonBuiltInIgnore` - For roughly detecting non-builtin objects and to avoid
159
251
  adding them as properties
160
252
  - `primitive-objects.js` (`StringObject`, `BooleanObject`, `NumberObject`)
161
- - `RegExp`
253
+ - `regexp`
162
254
  - `resurrectable` - Resurrects any non-array object, function, or symbol; can
163
255
  only be revived for the current window session.
164
- - `Set`
165
- - `typed-arrays-socketio.js` (`Int8Array`, `Uint8Array`, `Uint8ClampedArray`, `Int16Array`, `Uint16Array`, `Int32Array`, `Uint32Array`, `Float32Array`, `Float64Array`) - See [typeson#environmentformat-support](https://github.com/dfahlander/typeson#environmentformat-support) and `presets/socketio.js`
166
- - `typed-arrays.js` (`Int8Array`, `Uint8Array`, `Uint8ClampedArray`, `Int16Array`, `Uint16Array`, `Int32Array`, `Uint32Array`, `Float32Array`, `Float64Array`) - Base64-encodes
167
- - `undefined` (See also `presets/undefined.js` and `presets/sparse-undefined.js`)
256
+ - `set`
257
+ - `typed-arrays-socketio.js` (`Int8Array`, `Uint8Array`, `Uint8ClampedArray`,
258
+ `Int16Array`, `Uint16Array`, `Int32Array`, `Uint32Array`, `Float32Array`,
259
+ `Float64Array`) - See
260
+ [typeson#environmentformat-support](https://github.com/dfahlander/typeson#environmentformat-support)
261
+ and `presets/socketio.js`
262
+ - `typed-arrays.js` (`Int8Array`, `Uint8Array`, `Uint8ClampedArray`,
263
+ `Int16Array`, `Uint16Array`, `Int32Array`, `Uint32Array`,
264
+ `Float32Array`, `Float64Array`) - Base64-encodes
265
+ - `undef` (for `undefined`) (See also `presets/undefined.js` and
266
+ `presets/sparse-undefined.js`)
168
267
  - `userObjects` - Allows for inherited objects but ensures the prototype chain
169
- inherits from `Object` (or `null`). Should be low priority if one is matching
170
- other objects as it will readily match many objects.
268
+ inherits from `Object` (or `null`). Should be low priority if one is
269
+ matching other objects as it will readily match many objects.
171
270
 
172
271
  ### Presets
173
272
 
174
- - `builtin.js` - Types that are built into the JavaScript language itself. Types
175
- that were added in ES6 or beyond will be checked before inclusion
176
- so that this module can be consumed by both ES5 and ES6 environments. Some
177
- imperfectly serializable objects (such as functions and Symbols) are not included
178
- in this preset.
179
- - `post-message.js` - This preset is intended as a utility to expand on what is
273
+ - `array-nonindex-keys.js`
274
+ - `builtin.js` - Types that are built into the JavaScript language itself.
275
+ Types that were added in ES6 or beyond will be checked before inclusion
276
+ so that this module can be consumed by both ES5 and ES6 environments.
277
+ Some imperfectly serializable objects (such as functions and Symbols)
278
+ are not included in this preset.
279
+ - `postmessage.js` - This preset is intended as a utility to expand on what is
180
280
  cloneable via `strcutured-cloning.js` and supports Error objects.
281
+ - `socketio.js`
181
282
  - `sparse-undefined.js` (`sparseArrays` and `sparseUndefined`) - Supports
182
283
  reconstructing sparse arrays (with missing properties not even assigned
183
- an explicit `undefined`). See `types/undefined.js` for the explicit case or `presets/undefined.js` for a utility combining both.
284
+ an explicit `undefined`). See `types/undefined.js` for the explicit case
285
+ or `presets/undefined.js` for a utility combining both.
184
286
  - `special-numbers.js` (preserves `NaN`, `Infinity`, `-Infinity`)
185
- - `structured-cloning.js` - For the Structured Cloning Algorithm used by the likes of `postMessage` and `indexedDB`. See also the `cloneable` type.
186
- - `structured-cloning-throwing.js` - Same as `structured-cloning.js` but throws with non-recognized types. See also the `cloneable` type.
187
- - `undefined.js` - Supports reconstructing explicit and implicit (sparse) uses of `undefined`.
188
- - `universal.js`- Meant for de-facto universal types. Currently includes built-ins only.
287
+ - `structured-cloning.js` - For the Structured Cloning Algorithm used by the
288
+ likes of `postMessage` and `indexedDB`. See also the `cloneable` type.
289
+ - `structured-cloning-throwing.js` - Same as `structured-cloning.js` but
290
+ throws with non-recognized types. See also the `cloneable` type.
291
+ - `undef.js` - Supports reconstructing explicit and implicit (sparse)
292
+ uses of `undefined`.
293
+ - `universal.js`- Meant for de-facto universal types. Currently includes
294
+ built-ins only.
189
295
 
190
296
  ### Functions (support not included)
191
297
 
192
298
  If you are looking for a way to resurrect functions, you can use the following,
193
299
  but please bear in mind that it uses `eval` which is prohibited by some
194
300
  Content Security Policies (CSP) (so we are not packaging it with our builds),
195
- that it is unsafe, and also that the function might not behave deterministically
196
- when revived (e.g., if the function were provided from another context).
301
+ that it is unsafe, and also that the function might not behave
302
+ deterministically when revived (e.g., if the function were provided from
303
+ another context).
197
304
 
198
305
  ```js
199
- var functionType = {functionType: [
306
+ const functionType = {functionType: [
200
307
  function (x) { return typeof x === 'function'; },
201
- function (functionType) { return '(' + functionType.toString() + ')'; },
308
+ function (funcType) { return '(' + funcType.toString() + ')'; },
309
+ // eslint-disable-next-line no-eval
202
310
  function (o) { return eval(o); }
203
311
  ]};
204
312
 
205
- var typeson = new Typeson().register(functionType);
206
- var tson = typeson.stringify(function () { return 'abc'; });
207
- var back = typeson.parse(tson);
208
- back() // 'abc'
313
+ const typeson = new Typeson().register(functionType);
314
+ const tson = typeson.stringify(function () { return 'abc'; });
315
+ const back = typeson.parse(tson);
316
+ back(); // 'abc'
209
317
  ```
210
318
 
211
319
  ## Development
212
320
 
213
- [node-canvas](https://github.com/Automattic/node-canvas) is used to test `ImageData`.
321
+ [node-canvas](https://github.com/Automattic/node-canvas) is used to test
322
+ `ImageData`.
323
+
214
324
  Be sure to follow the installation steps.
215
325
 
216
- On Windows, besides following the [Windows installation steps](https://github.com/Automattic/node-canvas/wiki/Installation---Windows), [this](https://github.com/nodejs/node-gyp/issues/94#issuecomment-278587021)
326
+ On Windows, besides following the
327
+ [Windows installation steps](https://github.com/Automattic/node-canvas/wiki/Installation---Windows),
328
+ [this](https://github.com/nodejs/node-gyp/issues/94#issuecomment-278587021)
217
329
  helped complete the installation. If you need to have it rebuilt, you can
218
330
  run `npm i` inside of the `node_modules/canvas` directory.
219
331
 
220
332
  [These steps](https://github.com/Automattic/node-canvas/issues/191#issuecomment-7681555)
221
- were also necessary but you can run `npm run windows` after install to get these steps
222
- applied. These are the only steps which should need to be re-run if you have deleted
223
- your local `node-canvas` copy.
333
+ were also necessary but you can run `npm run windows` after install to get
334
+ these steps applied. These are the only steps which should need to be re-run
335
+ if you have deleted your local `node-canvas` copy.
224
336
 
225
337
  ## See also
226
338