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.
- package/.travis.yml +2 -0
- package/README.md +10 -0
- package/dist/msgpack5.js +2711 -1755
- package/dist/msgpack5.min.js +1 -4
- package/example.js +4 -1
- package/index.js +8 -3
- package/lib/decoder.js +12 -1
- package/lib/encoder.js +35 -29
- package/lib/streams.js +2 -0
- package/package.json +13 -13
- package/test/1-byte-length-buffers.js +6 -5
- package/test/1-byte-length-exts.js +4 -3
- package/test/1-byte-length-strings.js +4 -3
- package/test/1-byte-length-uint8arrays.js +43 -0
- package/test/15-elements-arrays.js +2 -1
- package/test/15-elements-maps.js +3 -2
- package/test/16-bits-signed-integers.js +3 -2
- package/test/16-bits-unsigned-integers.js +3 -2
- package/test/2-bytes-length-arrays.js +3 -2
- package/test/2-bytes-length-buffers.js +5 -4
- package/test/2-bytes-length-exts.js +4 -3
- package/test/2-bytes-length-maps.js +3 -2
- package/test/2-bytes-length-strings.js +8 -7
- package/test/2-bytes-length-uint8arrays.js +43 -0
- package/test/31-chars-strings.js +3 -2
- package/test/32-bits-signed-integers.js +3 -2
- package/test/32-bits-unsigned-integers.js +3 -2
- package/test/32-bytes-strings.js +2 -1
- package/test/4-bytes-length-arrays.js +3 -2
- package/test/4-bytes-length-buffers.js +5 -4
- package/test/4-bytes-length-exts.js +4 -3
- package/test/4-bytes-length-strings.js +7 -6
- package/test/4-bytes-length-uint8arrays.js +42 -0
- package/test/5-bits-negative-integers.js +2 -1
- package/test/64-bits-signed-integers.js +2 -1
- package/test/64-bits-unsigned-integers.js +2 -1
- package/test/7-bits-positive-integers.js +2 -1
- package/test/8-bits-positive-integers.js +3 -2
- package/test/8-bits-signed-integers.js +3 -2
- package/test/booleans.js +3 -2
- package/test/doubles.js +3 -2
- package/test/ext-custom-encode-check.js +3 -2
- package/test/fixexts.js +21 -20
- package/test/floats.js +3 -2
- package/test/levelup-encoding.js +4 -4
- package/test/null.js +2 -1
- package/test/object-prototype-poisoning.js +49 -0
- package/test/object-with-buffers.js +4 -3
- package/test/streams.js +3 -2
- package/.npmignore +0 -27
package/.travis.yml
CHANGED
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.
|