msgpack5 3.4.1 → 3.6.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.
Files changed (50) hide show
  1. package/.travis.yml +2 -0
  2. package/README.md +10 -0
  3. package/dist/msgpack5.js +2711 -1755
  4. package/dist/msgpack5.min.js +1 -4
  5. package/example.js +4 -1
  6. package/index.js +8 -3
  7. package/lib/decoder.js +12 -1
  8. package/lib/encoder.js +35 -29
  9. package/lib/streams.js +2 -0
  10. package/package.json +13 -13
  11. package/test/1-byte-length-buffers.js +6 -5
  12. package/test/1-byte-length-exts.js +4 -3
  13. package/test/1-byte-length-strings.js +4 -3
  14. package/test/1-byte-length-uint8arrays.js +43 -0
  15. package/test/15-elements-arrays.js +2 -1
  16. package/test/15-elements-maps.js +3 -2
  17. package/test/16-bits-signed-integers.js +3 -2
  18. package/test/16-bits-unsigned-integers.js +3 -2
  19. package/test/2-bytes-length-arrays.js +3 -2
  20. package/test/2-bytes-length-buffers.js +5 -4
  21. package/test/2-bytes-length-exts.js +4 -3
  22. package/test/2-bytes-length-maps.js +3 -2
  23. package/test/2-bytes-length-strings.js +8 -7
  24. package/test/2-bytes-length-uint8arrays.js +43 -0
  25. package/test/31-chars-strings.js +3 -2
  26. package/test/32-bits-signed-integers.js +3 -2
  27. package/test/32-bits-unsigned-integers.js +3 -2
  28. package/test/32-bytes-strings.js +2 -1
  29. package/test/4-bytes-length-arrays.js +3 -2
  30. package/test/4-bytes-length-buffers.js +5 -4
  31. package/test/4-bytes-length-exts.js +4 -3
  32. package/test/4-bytes-length-strings.js +7 -6
  33. package/test/4-bytes-length-uint8arrays.js +42 -0
  34. package/test/5-bits-negative-integers.js +2 -1
  35. package/test/64-bits-signed-integers.js +2 -1
  36. package/test/64-bits-unsigned-integers.js +2 -1
  37. package/test/7-bits-positive-integers.js +2 -1
  38. package/test/8-bits-positive-integers.js +3 -2
  39. package/test/8-bits-signed-integers.js +3 -2
  40. package/test/booleans.js +3 -2
  41. package/test/doubles.js +3 -2
  42. package/test/ext-custom-encode-check.js +3 -2
  43. package/test/fixexts.js +21 -20
  44. package/test/floats.js +3 -2
  45. package/test/levelup-encoding.js +4 -4
  46. package/test/null.js +2 -1
  47. package/test/object-prototype-poisoning.js +49 -0
  48. package/test/object-with-buffers.js +4 -3
  49. package/test/streams.js +3 -2
  50. package/.npmignore +0 -27
package/.travis.yml CHANGED
@@ -4,3 +4,5 @@ node_js:
4
4
  - "0.12"
5
5
  - "4"
6
6
  - "6"
7
+ - "7"
8
+ - "8"
package/README.md CHANGED
@@ -84,6 +84,7 @@ API
84
84
  ---
85
85
 
86
86
  <a name="api"></a>
87
+
87
88
  ## API
88
89
 
89
90
  * <a href="#msgpack"><code><b>msgpack()</b></code></a>
@@ -97,6 +98,7 @@ API
97
98
 
98
99
  -------------------------------------------------------
99
100
  <a name="msgpack"></a>
101
+
100
102
  ### msgpack(options(obj))
101
103
 
102
104
  Creates a new instance on which you can register new types for being
@@ -106,15 +108,18 @@ options:
106
108
 
107
109
  - `forceFloat64`, a boolean to that forces all floats to be encoded as 64-bits floats. Defaults to false.
108
110
  - `compatibilityMode`, a boolean that enables "compatibility mode" which doesn't use str 8 format. Defaults to false.
111
+ - `protoAction`, a string which can be `error|ignore|remove` that determines what happens when decoding a plain object with a `__proto__` property which would cause prototype poisoning. `error` (default) throws an error, `remove` removes the property, `ignore` (not recommended) allows the property, thereby causing prototype poisoning on the decoded object.
109
112
 
110
113
  -------------------------------------------------------
111
114
  <a name="encode"></a>
115
+
112
116
  ### encode(object)
113
117
 
114
118
  Encodes `object` in msgpack, returns a [bl](http://npm.im/bl).
115
119
 
116
120
  -------------------------------------------------------
117
121
  <a name="decode"></a>
122
+
118
123
  ### decode(buf)
119
124
 
120
125
  Decodes buf from in msgpack. `buf` can be a `Buffer` or a [bl](http://npm.im/bl) instance.
@@ -123,6 +128,7 @@ In order to support a stream interface, a user must pass in a [bl](http://npm.im
123
128
 
124
129
  -------------------------------------------------------
125
130
  <a name="registerEncoder"></a>
131
+
126
132
  ### registerEncoder(check(obj), encode(obj))
127
133
 
128
134
  Register a new custom object type for being automatically encoded.
@@ -136,6 +142,7 @@ The arguments are:
136
142
 
137
143
  -------------------------------------------------------
138
144
  <a name="registerDecoder"></a>
145
+
139
146
  ### registerDecoder(type, decode(buf))
140
147
 
141
148
  Register a new custom object type for being automatically decoded.
@@ -148,6 +155,7 @@ The arguments are:
148
155
 
149
156
  -------------------------------------------------------
150
157
  <a name="register"></a>
158
+
151
159
  ### register(type, constructor, encode(obj), decode(buf))
152
160
 
153
161
  Register a new custom object type for being automatically encoded and
@@ -168,12 +176,14 @@ This is just a commodity that calls
168
176
 
169
177
  -------------------------------------------------------
170
178
  <a name="encoder"></a>
179
+
171
180
  ### encoder()
172
181
 
173
182
  Builds a stream in object mode that encodes msgpack.
174
183
 
175
184
  -------------------------------------------------------
176
185
  <a name="decoder"></a>
186
+
177
187
  ### decoder()
178
188
 
179
189
  Builds a stream in object mode that decodes msgpack.