@agnostack/verifyd 1.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.
- package/CHANGELOG.md +8 -0
- package/CODE_OF_CONDUCT.md +132 -0
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/SECURITY.md +18 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +20 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/types.d.ts +1 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils/errors.d.ts +6 -0
- package/dist/lib/utils/errors.d.ts.map +1 -0
- package/dist/lib/utils/errors.js +26 -0
- package/dist/lib/utils/errors.js.map +1 -0
- package/dist/lib/utils/index.d.ts +3 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +19 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/rawbody.d.ts +2 -0
- package/dist/lib/utils/rawbody.d.ts.map +1 -0
- package/dist/lib/utils/rawbody.js +60 -0
- package/dist/lib/utils/rawbody.js.map +1 -0
- package/dist/lib/verification.d.ts +10 -0
- package/dist/lib/verification.d.ts.map +1 -0
- package/dist/lib/verification.js +84 -0
- package/dist/lib/verification.js.map +1 -0
- package/dist/react/hooks/index.d.ts +2 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/index.js +18 -0
- package/dist/react/hooks/index.js.map +1 -0
- package/dist/react/hooks/useVerification.d.ts +8 -0
- package/dist/react/hooks/useVerification.d.ts.map +1 -0
- package/dist/react/hooks/useVerification.js +52 -0
- package/dist/react/hooks/useVerification.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +19 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/types.d.ts +1 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +1 -0
- package/dist/react/types.js.map +1 -0
- package/dist/shared/WebCrypto.d.ts +55 -0
- package/dist/shared/WebCrypto.d.ts.map +1 -0
- package/dist/shared/WebCrypto.js +342 -0
- package/dist/shared/WebCrypto.js.map +1 -0
- package/dist/shared/datetime.d.ts +96 -0
- package/dist/shared/datetime.d.ts.map +1 -0
- package/dist/shared/datetime.js +295 -0
- package/dist/shared/datetime.js.map +1 -0
- package/dist/shared/display.d.ts +100 -0
- package/dist/shared/display.d.ts.map +1 -0
- package/dist/shared/display.js +481 -0
- package/dist/shared/display.js.map +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +28 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/request.d.ts +16 -0
- package/dist/shared/request.d.ts.map +1 -0
- package/dist/shared/request.js +60 -0
- package/dist/shared/request.js.map +1 -0
- package/dist/shared/types.d.ts +1 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +1 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/verification.d.ts +31 -0
- package/dist/shared/verification.d.ts.map +1 -0
- package/dist/shared/verification.js +91 -0
- package/dist/shared/verification.js.map +1 -0
- package/dist/umd/lib/index.js +2204 -0
- package/dist/umd/lib/index.js.map +1 -0
- package/dist/umd/lib/lib/index.d.ts +4 -0
- package/dist/umd/lib/lib/index.d.ts.map +1 -0
- package/dist/umd/lib/lib/types.d.ts +1 -0
- package/dist/umd/lib/lib/types.d.ts.map +1 -0
- package/dist/umd/lib/lib/utils/errors.d.ts +6 -0
- package/dist/umd/lib/lib/utils/errors.d.ts.map +1 -0
- package/dist/umd/lib/lib/utils/index.d.ts +3 -0
- package/dist/umd/lib/lib/utils/index.d.ts.map +1 -0
- package/dist/umd/lib/lib/utils/rawbody.d.ts +2 -0
- package/dist/umd/lib/lib/utils/rawbody.d.ts.map +1 -0
- package/dist/umd/lib/lib/verification.d.ts +10 -0
- package/dist/umd/lib/lib/verification.d.ts.map +1 -0
- package/dist/umd/lib/react/hooks/index.d.ts +2 -0
- package/dist/umd/lib/react/hooks/index.d.ts.map +1 -0
- package/dist/umd/lib/react/hooks/useVerification.d.ts +8 -0
- package/dist/umd/lib/react/hooks/useVerification.d.ts.map +1 -0
- package/dist/umd/lib/react/index.d.ts +3 -0
- package/dist/umd/lib/react/index.d.ts.map +1 -0
- package/dist/umd/lib/react/types.d.ts +1 -0
- package/dist/umd/lib/react/types.d.ts.map +1 -0
- package/dist/umd/lib/shared/WebCrypto.d.ts +55 -0
- package/dist/umd/lib/shared/WebCrypto.d.ts.map +1 -0
- package/dist/umd/lib/shared/datetime.d.ts +96 -0
- package/dist/umd/lib/shared/datetime.d.ts.map +1 -0
- package/dist/umd/lib/shared/display.d.ts +100 -0
- package/dist/umd/lib/shared/display.d.ts.map +1 -0
- package/dist/umd/lib/shared/index.d.ts +6 -0
- package/dist/umd/lib/shared/index.d.ts.map +1 -0
- package/dist/umd/lib/shared/request.d.ts +16 -0
- package/dist/umd/lib/shared/request.d.ts.map +1 -0
- package/dist/umd/lib/shared/types.d.ts +1 -0
- package/dist/umd/lib/shared/types.d.ts.map +1 -0
- package/dist/umd/lib/shared/verification.d.ts +31 -0
- package/dist/umd/lib/shared/verification.d.ts.map +1 -0
- package/node_modules/browser-monads-ts/LICENSE +21 -0
- package/node_modules/browser-monads-ts/README.md +46 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js +2 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js.map +1 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js +12 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js.map +1 -0
- package/node_modules/browser-monads-ts/dist/index.d.ts +5 -0
- package/node_modules/browser-monads-ts/dist/index.d.ts.map +1 -0
- package/node_modules/browser-monads-ts/package.json +79 -0
- package/node_modules/bytes/History.md +97 -0
- package/node_modules/bytes/LICENSE +23 -0
- package/node_modules/bytes/Readme.md +152 -0
- package/node_modules/bytes/index.js +170 -0
- package/node_modules/bytes/package.json +42 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/http-errors/HISTORY.md +180 -0
- package/node_modules/http-errors/LICENSE +23 -0
- package/node_modules/http-errors/README.md +169 -0
- package/node_modules/http-errors/index.js +289 -0
- package/node_modules/http-errors/package.json +50 -0
- package/node_modules/iconv-lite/Changelog.md +162 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +156 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
- package/node_modules/iconv-lite/encodings/index.js +22 -0
- package/node_modules/iconv-lite/encodings/internal.js +188 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +177 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/extend-node.js +217 -0
- package/node_modules/iconv-lite/lib/index.d.ts +24 -0
- package/node_modules/iconv-lite/lib/index.js +153 -0
- package/node_modules/iconv-lite/lib/streams.js +121 -0
- package/node_modules/iconv-lite/package.json +46 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/nothing-mock/LICENSE +21 -0
- package/node_modules/nothing-mock/README.md +266 -0
- package/node_modules/nothing-mock/dist/nothing-mock.es.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.es.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js.map +1 -0
- package/node_modules/nothing-mock/index.d.ts +6 -0
- package/node_modules/nothing-mock/package.json +29 -0
- package/node_modules/nothing-mock/src/index.js +15 -0
- package/node_modules/raw-body/HISTORY.md +308 -0
- package/node_modules/raw-body/LICENSE +22 -0
- package/node_modules/raw-body/README.md +223 -0
- package/node_modules/raw-body/SECURITY.md +24 -0
- package/node_modules/raw-body/index.d.ts +87 -0
- package/node_modules/raw-body/index.js +336 -0
- package/node_modules/raw-body/package.json +49 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/setprototypeof/LICENSE +13 -0
- package/node_modules/setprototypeof/README.md +31 -0
- package/node_modules/setprototypeof/index.d.ts +2 -0
- package/node_modules/setprototypeof/index.js +17 -0
- package/node_modules/setprototypeof/package.json +38 -0
- package/node_modules/setprototypeof/test/index.js +24 -0
- package/node_modules/statuses/HISTORY.md +82 -0
- package/node_modules/statuses/LICENSE +23 -0
- package/node_modules/statuses/README.md +136 -0
- package/node_modules/statuses/codes.json +65 -0
- package/node_modules/statuses/index.js +146 -0
- package/node_modules/statuses/package.json +49 -0
- package/node_modules/toidentifier/HISTORY.md +9 -0
- package/node_modules/toidentifier/LICENSE +21 -0
- package/node_modules/toidentifier/README.md +61 -0
- package/node_modules/toidentifier/index.js +32 -0
- package/node_modules/toidentifier/package.json +38 -0
- package/node_modules/unpipe/HISTORY.md +4 -0
- package/node_modules/unpipe/LICENSE +22 -0
- package/node_modules/unpipe/README.md +43 -0
- package/node_modules/unpipe/index.js +69 -0
- package/node_modules/unpipe/package.json +27 -0
- package/package.json +127 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present Vladimir Simonov <slmgc@ya.ru>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# Nothing
|
|
2
|
+
|
|
3
|
+
[![npm package][npm-badge]][npm] [![npm package][npm-downloads]][npm]
|
|
4
|
+
|
|
5
|
+
**Nothing** is a chainable, callable mock object which always returns itself. You can use it instead of `null` and `undefined` values so you don't have to place safety checks all over your code. The implementation uses [Symbol] and [Proxy] behind the hood which are widely supported by modern desktop and mobile browsers and can be used without a polyfill.
|
|
6
|
+
|
|
7
|
+
## How to install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm i -S nothing-mock
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## How to use
|
|
14
|
+
|
|
15
|
+
### A simple example
|
|
16
|
+
```js
|
|
17
|
+
import {Nothing} from 'nothing-mock'
|
|
18
|
+
|
|
19
|
+
const foo = Nothing
|
|
20
|
+
foo.bar.baz.qux().spam.ham[0].map((x) => x + 1).eggs.someFn() // returns Nothing
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Reducing boilerplate
|
|
24
|
+
```js
|
|
25
|
+
import {Nothing} from 'nothing-mock'
|
|
26
|
+
|
|
27
|
+
// A regular function with null-checks
|
|
28
|
+
function someFunctionWithNullChecks(foo) {
|
|
29
|
+
return foo &&
|
|
30
|
+
foo.bar &&
|
|
31
|
+
foo.bar.baz &&
|
|
32
|
+
foo.bar.baz.qux &&
|
|
33
|
+
foo.bar.baz.qux()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// There is no need to check for null/undefined if you use Nothing
|
|
37
|
+
function someFunction(foo) {
|
|
38
|
+
return foo.bar.baz.qux()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
someFunctionWithNullChecks(null) // returns null
|
|
42
|
+
someFunction(Nothing) // returns Nothing
|
|
43
|
+
someFunction(null) // throws an exception
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### JSON serialization/deserialization
|
|
47
|
+
```js
|
|
48
|
+
import {Nothing, deserialize, serialize} from 'nothing-mock'
|
|
49
|
+
|
|
50
|
+
const json = `{
|
|
51
|
+
"posts": [{
|
|
52
|
+
"id": 1,
|
|
53
|
+
"userId": 12,
|
|
54
|
+
"content": "post 1",
|
|
55
|
+
"comments": [{
|
|
56
|
+
"id": 1,
|
|
57
|
+
"userId": 34,
|
|
58
|
+
"content": "comment 1"
|
|
59
|
+
}, {
|
|
60
|
+
"id": 2,
|
|
61
|
+
"userId": 56,
|
|
62
|
+
"content": "comment 2"
|
|
63
|
+
}]
|
|
64
|
+
}, {
|
|
65
|
+
"id": 2,
|
|
66
|
+
"userId": 78,
|
|
67
|
+
"content": "post 2",
|
|
68
|
+
"comments": null
|
|
69
|
+
}]
|
|
70
|
+
}`
|
|
71
|
+
|
|
72
|
+
const {posts} = deserialize(json) /* returns: [{
|
|
73
|
+
"id": 1,
|
|
74
|
+
"userId": 12,
|
|
75
|
+
"content": "post 1",
|
|
76
|
+
"comments": [{
|
|
77
|
+
"id": 1,
|
|
78
|
+
"userId": 34,
|
|
79
|
+
"content": "comment 1"
|
|
80
|
+
}, {
|
|
81
|
+
"id": 2,
|
|
82
|
+
"userId": 56,
|
|
83
|
+
"content": "comment 2"
|
|
84
|
+
}]
|
|
85
|
+
}, {
|
|
86
|
+
"id": 2,
|
|
87
|
+
"userId": 78,
|
|
88
|
+
"content": "post 2",
|
|
89
|
+
"comments": Nothing // null values are replaced with Nothing
|
|
90
|
+
}] */
|
|
91
|
+
|
|
92
|
+
function renderPostWithComments(post) {
|
|
93
|
+
return `<div>
|
|
94
|
+
<p>${post.content}</p>
|
|
95
|
+
<ul>${post.comments.map((comment) =>
|
|
96
|
+
`<li>${comment.content}</li>`).join('')
|
|
97
|
+
}</ul>
|
|
98
|
+
</div>`
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
posts.map(renderPostWithComments).join('') /* returns:
|
|
102
|
+
`<div>
|
|
103
|
+
<p>post 1</p>
|
|
104
|
+
<ul>
|
|
105
|
+
<li>comment 1</li>
|
|
106
|
+
<li>comment 2</li>
|
|
107
|
+
</ul>
|
|
108
|
+
</div>
|
|
109
|
+
<div>
|
|
110
|
+
<p>post 2</p>
|
|
111
|
+
<ul></ul> // Nothing is rendered empty
|
|
112
|
+
</div>` */
|
|
113
|
+
|
|
114
|
+
// Serializes an object to JSON and
|
|
115
|
+
// replaces all Nothing values with null
|
|
116
|
+
serialize({posts})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Helper functions
|
|
120
|
+
```js
|
|
121
|
+
import {Nothing, toBool, isNothing, isSomething} from 'nothing-mock'
|
|
122
|
+
|
|
123
|
+
const list = [Nothing, true, false, null, undefined, 0, 1, NaN, '', {}, []]
|
|
124
|
+
list.filter(toBool) // [true, 1, {}, []]
|
|
125
|
+
list.filter(isNothing) // [Nothing]
|
|
126
|
+
list.filter(isSomething) // [true, false, 0, 1, NaN, "", {}, []]
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Properties which don't return Nothing
|
|
130
|
+
```jsx
|
|
131
|
+
import {Nothing} from 'nothing-mock'
|
|
132
|
+
|
|
133
|
+
Nothing.length // 0
|
|
134
|
+
Nothing.name // a string
|
|
135
|
+
Nothing.prototype // an object with a constructor
|
|
136
|
+
Nothing.toLocaleString() // ""
|
|
137
|
+
Nothing.toString() // ""
|
|
138
|
+
Nothing.valueOf() // false
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Gotchas
|
|
142
|
+
```js
|
|
143
|
+
import {Nothing, toBool} from 'nothing-mock'
|
|
144
|
+
|
|
145
|
+
String(Nothing) // ""
|
|
146
|
+
Nothing.toString() // ""
|
|
147
|
+
Nothing + 'a string' // "a string"
|
|
148
|
+
Nothing * 123 // 0
|
|
149
|
+
Nothing - 123 // -123
|
|
150
|
+
|
|
151
|
+
// Gotcha: concatenation of Nothing and a number returns a string
|
|
152
|
+
Nothing + 123 // "123"
|
|
153
|
+
|
|
154
|
+
// Solution: Nothing can be excplicitly converted to a number
|
|
155
|
+
Number(Nothing) // 0
|
|
156
|
+
Number(Nothing) + 123 // 123
|
|
157
|
+
|
|
158
|
+
// Gotcha: typecasting of Nothing to a boolean returns true
|
|
159
|
+
Boolean(Nothing) // true
|
|
160
|
+
!!Nothing // true
|
|
161
|
+
|
|
162
|
+
// Solution: Nothing can be converted to false
|
|
163
|
+
Nothing.valueOf() // false
|
|
164
|
+
toBool(Nothing) // false
|
|
165
|
+
|
|
166
|
+
// Gotcha: returning Nothing from a promise never
|
|
167
|
+
// resolves as Nothing is a thenable object
|
|
168
|
+
somePromise
|
|
169
|
+
.then(() => Nothing)
|
|
170
|
+
.then((result) => result) // pending indefinitely
|
|
171
|
+
|
|
172
|
+
// Solution: wrapping Nothing resolves the issue
|
|
173
|
+
somePromise
|
|
174
|
+
.then(() => ({result: Nothing}))
|
|
175
|
+
.then((result) => result) // promise resolves
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## FAQ
|
|
179
|
+
|
|
180
|
+
Q-1: Proxies are slow and there is a runtime overhead. Why should I use **Nothing**?
|
|
181
|
+
|
|
182
|
+
A: You should keep a few things in mind:
|
|
183
|
+
|
|
184
|
+
1. "Premature optimization is the root of all evil" - Donald E. Knuth.
|
|
185
|
+
2. Have you checked the performance of **Nothing**? Does it really impact the performance of your code? If it does, you can always opt out using **Nothing** for performance-critical parts of your code.
|
|
186
|
+
3. You can use **Nothing** for writing unit tests which are less likely to be performance-dependant.
|
|
187
|
+
|
|
188
|
+
Q-2: I believe that it's hard to understand the logic as the code will fail silently if I would use **Nothing**. I prefer to use try/catch blocks instead, e.g.:
|
|
189
|
+
|
|
190
|
+
```js
|
|
191
|
+
try {
|
|
192
|
+
foo.bar.baz()
|
|
193
|
+
} catch (e) {
|
|
194
|
+
// deal with it somehow
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
A: Many functional programming languages either don't have or don't endorse the use of imperative constructs such as try/catch blocks because they introduce so-called side effects which actually make it harder to debug and reason about the code. And programs which are written in functional programming languages are considered to be less error-prone and easier to support.
|
|
199
|
+
|
|
200
|
+
You can always check the result if a function call should never return **Nothing** and then handle it properly:
|
|
201
|
+
|
|
202
|
+
```js
|
|
203
|
+
const someFunction = (handleNothing, arg) => {
|
|
204
|
+
const result = foo.bar.baz(arg)
|
|
205
|
+
return isNothing(result) ? handleNothing(arg) : result
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Q-3: Why should I use **Nothing** if there are better alternatives like [optional chaining] or [lodash.get]?
|
|
210
|
+
|
|
211
|
+
A: Each of these solutions have their pros and cons. Your choice should depend on the use-case:
|
|
212
|
+
|
|
213
|
+
1. Optional chaining syntax would be the best choice, but it requires a transpilation step as modern browsers don't support the syntax and it might take a while before it will get into the future ECMAScript standard.
|
|
214
|
+
2. `lodash.get` is good for a basic property chain traversal, but it requires an alien syntax and fails when there is a need to call a method somewhere in a property chain:
|
|
215
|
+
|
|
216
|
+
```js
|
|
217
|
+
import get from 'lodash.get'
|
|
218
|
+
|
|
219
|
+
var foo = null
|
|
220
|
+
get(foo, ['bar', 'baz'])() // this will throw an exception
|
|
221
|
+
|
|
222
|
+
var baz = get(foo, ['bar', 'baz'])
|
|
223
|
+
baz && baz() // this won't work if `baz` should be bound to the context of `bar`
|
|
224
|
+
|
|
225
|
+
// For example:
|
|
226
|
+
var foo = {
|
|
227
|
+
bar: {
|
|
228
|
+
baz() {
|
|
229
|
+
console.log(this.qux)
|
|
230
|
+
},
|
|
231
|
+
qux: 'hello'
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
foo.bar.baz() // "hello"
|
|
236
|
+
get(foo, ['bar', 'baz'])() // undefined
|
|
237
|
+
|
|
238
|
+
// This would be a proper solution:
|
|
239
|
+
var bar = get(foo, ['bar'])
|
|
240
|
+
var baz = get(bar, ['baz'])
|
|
241
|
+
baz && baz.call(bar) // "hello"
|
|
242
|
+
|
|
243
|
+
// But then it's easier to get back to the regular syntax:
|
|
244
|
+
foo && foo.bar && foo.bar.baz && foo.bar.baz()
|
|
245
|
+
|
|
246
|
+
// And good luck using `get` for something like this:
|
|
247
|
+
foo.bar.baz()[0].map(() => { /* do something */ })
|
|
248
|
+
|
|
249
|
+
// BTW, an implementation of a lodash-like `get` helper-function is basically a one-liner:
|
|
250
|
+
const get = (o, a) => a.reduce((p, c) => p && p[c], o)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Q-4: I am still not convinced and ain't gonna use **Nothing**!
|
|
254
|
+
|
|
255
|
+
A: Thanks for letting me know! Seriously, it's your choice, I am down with it.
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
**MIT**
|
|
259
|
+
|
|
260
|
+
[Proxy]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Browser_compatibility
|
|
261
|
+
[Symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility
|
|
262
|
+
[npm]: https://www.npmjs.org/package/nothing-mock
|
|
263
|
+
[npm-badge]: https://img.shields.io/npm/v/nothing-mock.svg
|
|
264
|
+
[npm-downloads]: https://img.shields.io/npm/dm/nothing-mock.svg
|
|
265
|
+
[optional chaining]: https://www.npmjs.com/package/babel-plugin-transform-optional-chaining
|
|
266
|
+
[lodash.get]: https://www.npmjs.com/package/lodash.get
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var n,r=((n=function(){return r}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return""},n.valueOf=function(){return!1},new Proxy(Object.freeze(n),{get:function(n,t){return n.hasOwnProperty(t)?n[t]:r}})),t=function(n){return!(!n||!n.valueOf())},u=function(n){return n===r},e=function(n){return!(n===r||null==n)},o=function(n){return JSON.stringify(n,function(n,t){return t===r?null:t})},i=function(n){return JSON.parse(n,function(n,t){return null===t?r:t})};export{r as Nothing,i as deserialize,u as isNothing,e as isSomething,o as serialize,t as toBool};
|
|
2
|
+
//# sourceMappingURL=nothing-mock.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nothing-mock.es.js","sources":["../src/index.js"],"sourcesContent":["export const Nothing = (() => {\n\tconst fn = () => Nothing\n\tfn.toString = fn.toLocaleString = fn[Symbol.toPrimitive] = () => ''\n\tfn.valueOf = () => false\n\n\treturn new Proxy(Object.freeze(fn), {\n\t\tget: (o, key) => o.hasOwnProperty(key) ? o[key] : Nothing\n\t})\n})()\n\nexport const toBool = (o) => !!(o && o.valueOf())\nexport const isNothing = (o) => o === Nothing\nexport const isSomething = (o) => !(o === Nothing || o == null)\nexport const serialize = (o) => JSON.stringify(o, (k, v) => v === Nothing ? null : v)\nexport const deserialize = (s) => JSON.parse(s, (k, v) => v === null ? Nothing : v)"],"names":["Nothing","fn","toString","toLocaleString","Symbol","toPrimitive","valueOf","Proxy","Object","freeze","get","o","key","hasOwnProperty","toBool","isNothing","isSomething","serialize","JSON","stringify","k","v","deserialize","s","parse"],"mappings":"AAAaA,IACNC,EADMD,IACNC,EAAK,kBAAMD,IACdE,SAAWD,EAAGE,eAAiBF,EAAGG,OAAOC,aAAe,iBAAM,IACjEJ,EAAGK,QAAU,yBAEFC,MAAMC,OAAOC,OAAOR,GAAK,CACnCS,IAAK,SAACC,EAAGC,UAAQD,EAAEE,eAAeD,GAAOD,EAAEC,GAAOZ,MAIvCc,EAAS,SAACH,YAASA,IAAKA,EAAEL,YAC1BS,EAAY,SAACJ,UAAMA,IAAMX,GACzBgB,EAAc,SAACL,WAAQA,IAAMX,GAAgB,MAALW,IACxCM,EAAY,SAACN,UAAMO,KAAKC,UAAUR,EAAG,SAACS,EAAGC,UAAMA,IAAMrB,EAAU,KAAOqB,KACtEC,EAAc,SAACC,UAAML,KAAKM,MAAMD,EAAG,SAACH,EAAGC,UAAY,OAANA,EAAarB,EAAUqB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var n,t=((n=function(){return t}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return""},n.valueOf=function(){return!1},new Proxy(Object.freeze(n),{get:function(n,r){return n.hasOwnProperty(r)?n[r]:t}}));exports.Nothing=t,exports.deserialize=function(n){return JSON.parse(n,function(n,r){return null===r?t:r})},exports.isNothing=function(n){return n===t},exports.isSomething=function(n){return!(n===t||null==n)},exports.serialize=function(n){return JSON.stringify(n,function(n,r){return r===t?null:r})},exports.toBool=function(n){return!(!n||!n.valueOf())};
|
|
2
|
+
//# sourceMappingURL=nothing-mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nothing-mock.js","sources":["../src/index.js"],"sourcesContent":["export const Nothing = (() => {\n\tconst fn = () => Nothing\n\tfn.toString = fn.toLocaleString = fn[Symbol.toPrimitive] = () => ''\n\tfn.valueOf = () => false\n\n\treturn new Proxy(Object.freeze(fn), {\n\t\tget: (o, key) => o.hasOwnProperty(key) ? o[key] : Nothing\n\t})\n})()\n\nexport const toBool = (o) => !!(o && o.valueOf())\nexport const isNothing = (o) => o === Nothing\nexport const isSomething = (o) => !(o === Nothing || o == null)\nexport const serialize = (o) => JSON.stringify(o, (k, v) => v === Nothing ? null : v)\nexport const deserialize = (s) => JSON.parse(s, (k, v) => v === null ? Nothing : v)"],"names":["Nothing","fn","toString","toLocaleString","Symbol","toPrimitive","valueOf","Proxy","Object","freeze","get","o","key","hasOwnProperty","s","JSON","parse","k","v","stringify"],"mappings":"aAAaA,IACNC,EADMD,IACNC,EAAK,kBAAMD,IACdE,SAAWD,EAAGE,eAAiBF,EAAGG,OAAOC,aAAe,iBAAM,IACjEJ,EAAGK,QAAU,yBAEFC,MAAMC,OAAOC,OAAOR,GAAK,CACnCS,IAAK,SAACC,EAAGC,UAAQD,EAAEE,eAAeD,GAAOD,EAAEC,GAAOZ,4CAQzB,SAACc,UAAMC,KAAKC,MAAMF,EAAG,SAACG,EAAGC,UAAY,OAANA,EAAalB,EAAUkB,uBAHxD,SAACP,UAAMA,IAAMX,uBACX,SAACW,WAAQA,IAAMX,GAAgB,MAALW,sBAC5B,SAACA,UAAMI,KAAKI,UAAUR,EAAG,SAACM,EAAGC,UAAMA,IAAMlB,EAAU,KAAOkB,oBAH7D,SAACP,YAASA,IAAKA,EAAEL"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(()=>{const t=()=>e;return t.toString=t.toLocaleString=t[Symbol.toPrimitive]=()=>"",t.valueOf=()=>!1,new Proxy(Object.freeze(t),{get:(t,r)=>t.hasOwnProperty(r)?t[r]:e})})(),t=e=>!(!e||!e.valueOf()),r=t=>t===e,n=t=>!(t===e||null==t),l=t=>JSON.stringify(t,(t,r)=>r===e?null:r),o=t=>JSON.parse(t,(t,r)=>null===r?e:r);export{e as Nothing,o as deserialize,r as isNothing,n as isSomething,l as serialize,t as toBool};
|
|
2
|
+
//# sourceMappingURL=nothing-mock.modern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nothing-mock.modern.js","sources":["../src/index.js"],"sourcesContent":["export const Nothing = (() => {\n\tconst fn = () => Nothing\n\tfn.toString = fn.toLocaleString = fn[Symbol.toPrimitive] = () => ''\n\tfn.valueOf = () => false\n\n\treturn new Proxy(Object.freeze(fn), {\n\t\tget: (o, key) => o.hasOwnProperty(key) ? o[key] : Nothing\n\t})\n})()\n\nexport const toBool = (o) => !!(o && o.valueOf())\nexport const isNothing = (o) => o === Nothing\nexport const isSomething = (o) => !(o === Nothing || o == null)\nexport const serialize = (o) => JSON.stringify(o, (k, v) => v === Nothing ? null : v)\nexport const deserialize = (s) => JSON.parse(s, (k, v) => v === null ? Nothing : v)"],"names":["Nothing","fn","toString","toLocaleString","Symbol","toPrimitive","valueOf","Proxy","Object","freeze","get","o","key","hasOwnProperty","toBool","isNothing","isSomething","serialize","JSON","stringify","k","v","deserialize","s","parse"],"mappings":"AAAaA,MAAAA,EAAU,MACtB,MAAMC,EAAK,IAAMD,EAIjB,OAHAC,EAAGC,SAAWD,EAAGE,eAAiBF,EAAGG,OAAOC,aAAe,IAAM,GACjEJ,EAAGK,QAAU,KAAM,MAERC,MAAMC,OAAOC,OAAOR,GAAK,CACnCS,IAAK,CAACC,EAAGC,IAAQD,EAAEE,eAAeD,GAAOD,EAAEC,GAAOZ,KAN7B,GAUVc,EAAUH,MAASA,IAAKA,EAAEL,WAC1BS,EAAaJ,GAAMA,IAAMX,EACzBgB,EAAeL,KAAQA,IAAMX,GAAgB,MAALW,GACxCM,EAAaN,GAAMO,KAAKC,UAAUR,EAAG,CAACS,EAAGC,IAAMA,IAAMrB,EAAU,KAAOqB,GACtEC,EAAeC,GAAML,KAAKM,MAAMD,EAAG,CAACH,EAAGC,IAAY,OAANA,EAAarB,EAAUqB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n||self).nothingMock={})}(this,function(n){"use strict";var t,e=((t=function(){return e}).toString=t.toLocaleString=t[Symbol.toPrimitive]=function(){return""},t.valueOf=function(){return!1},new Proxy(Object.freeze(t),{get:function(n,t){return n.hasOwnProperty(t)?n[t]:e}}));n.Nothing=e,n.deserialize=function(n){return JSON.parse(n,function(n,t){return null===t?e:t})},n.isNothing=function(n){return n===e},n.isSomething=function(n){return!(n===e||null==n)},n.serialize=function(n){return JSON.stringify(n,function(n,t){return t===e?null:t})},n.toBool=function(n){return!(!n||!n.valueOf())}});
|
|
2
|
+
//# sourceMappingURL=nothing-mock.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nothing-mock.umd.js","sources":["../src/index.js"],"sourcesContent":["export const Nothing = (() => {\n\tconst fn = () => Nothing\n\tfn.toString = fn.toLocaleString = fn[Symbol.toPrimitive] = () => ''\n\tfn.valueOf = () => false\n\n\treturn new Proxy(Object.freeze(fn), {\n\t\tget: (o, key) => o.hasOwnProperty(key) ? o[key] : Nothing\n\t})\n})()\n\nexport const toBool = (o) => !!(o && o.valueOf())\nexport const isNothing = (o) => o === Nothing\nexport const isSomething = (o) => !(o === Nothing || o == null)\nexport const serialize = (o) => JSON.stringify(o, (k, v) => v === Nothing ? null : v)\nexport const deserialize = (s) => JSON.parse(s, (k, v) => v === null ? Nothing : v)"],"names":["fn","Nothing","toString","toLocaleString","Symbol","toPrimitive","valueOf","Proxy","Object","freeze","get","o","key","hasOwnProperty","s","JSON","parse","k","v","stringify"],"mappings":"sPACOA,EADMC,IACND,EAAK,kBAAMC,IACdC,SAAWF,EAAGG,eAAiBH,EAAGI,OAAOC,aAAe,iBAAM,IACjEL,EAAGM,QAAU,yBAEFC,MAAMC,OAAOC,OAAOT,GAAK,CACnCU,IAAK,SAACC,EAAGC,UAAQD,EAAEE,eAAeD,GAAOD,EAAEC,GAAOX,gCAQzB,SAACa,UAAMC,KAAKC,MAAMF,EAAG,SAACG,EAAGC,UAAY,OAANA,EAAajB,EAAUiB,iBAHxD,SAACP,UAAMA,IAAMV,iBACX,SAACU,WAAQA,IAAMV,GAAgB,MAALU,gBAC5B,SAACA,UAAMI,KAAKI,UAAUR,EAAG,SAACM,EAAGC,UAAMA,IAAMjB,EAAU,KAAOiB,cAH7D,SAACP,YAASA,IAAKA,EAAEL"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nothing-mock",
|
|
3
|
+
"version": "1.0.4",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "A chainable, callable mock object which always returns itself",
|
|
6
|
+
"author": "Vladimir Simonov <slmgc@ya.ru>",
|
|
7
|
+
"homepage": "https://github.com/slmgc/Nothing",
|
|
8
|
+
"repository": "github:slmgc/Nothing",
|
|
9
|
+
"main": "dist/nothing-mock.js",
|
|
10
|
+
"module": "dist/nothing-mock.es.js",
|
|
11
|
+
"esmodule": "dist/nothing-mock.modern.js",
|
|
12
|
+
"jsnext:main": "dist/nothing-mock.es.js",
|
|
13
|
+
"unpkg": "dist/nothing-mock.umd.js",
|
|
14
|
+
"source": "src/index.js",
|
|
15
|
+
"types": "index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "microbundle --strict"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"microbundle": "^0.13.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"nothing",
|
|
24
|
+
"chainable",
|
|
25
|
+
"callable",
|
|
26
|
+
"mock",
|
|
27
|
+
"testing"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const Nothing = (() => {
|
|
2
|
+
const fn = () => Nothing
|
|
3
|
+
fn.toString = fn.toLocaleString = fn[Symbol.toPrimitive] = () => ''
|
|
4
|
+
fn.valueOf = () => false
|
|
5
|
+
|
|
6
|
+
return new Proxy(Object.freeze(fn), {
|
|
7
|
+
get: (o, key) => o.hasOwnProperty(key) ? o[key] : Nothing
|
|
8
|
+
})
|
|
9
|
+
})()
|
|
10
|
+
|
|
11
|
+
export const toBool = (o) => !!(o && o.valueOf())
|
|
12
|
+
export const isNothing = (o) => o === Nothing
|
|
13
|
+
export const isSomething = (o) => !(o === Nothing || o == null)
|
|
14
|
+
export const serialize = (o) => JSON.stringify(o, (k, v) => v === Nothing ? null : v)
|
|
15
|
+
export const deserialize = (s) => JSON.parse(s, (k, v) => v === null ? Nothing : v)
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
2.5.2 / 2023-02-21
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* Fix error message for non-stream argument
|
|
5
|
+
|
|
6
|
+
2.5.1 / 2022-02-28
|
|
7
|
+
==================
|
|
8
|
+
|
|
9
|
+
* Fix error on early async hooks implementations
|
|
10
|
+
|
|
11
|
+
2.5.0 / 2022-02-21
|
|
12
|
+
==================
|
|
13
|
+
|
|
14
|
+
* Prevent loss of async hooks context
|
|
15
|
+
* Prevent hanging when stream is not readable
|
|
16
|
+
* deps: http-errors@2.0.0
|
|
17
|
+
- deps: depd@2.0.0
|
|
18
|
+
- deps: statuses@2.0.1
|
|
19
|
+
|
|
20
|
+
2.4.3 / 2022-02-14
|
|
21
|
+
==================
|
|
22
|
+
|
|
23
|
+
* deps: bytes@3.1.2
|
|
24
|
+
|
|
25
|
+
2.4.2 / 2021-11-16
|
|
26
|
+
==================
|
|
27
|
+
|
|
28
|
+
* deps: bytes@3.1.1
|
|
29
|
+
* deps: http-errors@1.8.1
|
|
30
|
+
- deps: setprototypeof@1.2.0
|
|
31
|
+
- deps: toidentifier@1.0.1
|
|
32
|
+
|
|
33
|
+
2.4.1 / 2019-06-25
|
|
34
|
+
==================
|
|
35
|
+
|
|
36
|
+
* deps: http-errors@1.7.3
|
|
37
|
+
- deps: inherits@2.0.4
|
|
38
|
+
|
|
39
|
+
2.4.0 / 2019-04-17
|
|
40
|
+
==================
|
|
41
|
+
|
|
42
|
+
* deps: bytes@3.1.0
|
|
43
|
+
- Add petabyte (`pb`) support
|
|
44
|
+
* deps: http-errors@1.7.2
|
|
45
|
+
- Set constructor name when possible
|
|
46
|
+
- deps: setprototypeof@1.1.1
|
|
47
|
+
- deps: statuses@'>= 1.5.0 < 2'
|
|
48
|
+
* deps: iconv-lite@0.4.24
|
|
49
|
+
- Added encoding MIK
|
|
50
|
+
|
|
51
|
+
2.3.3 / 2018-05-08
|
|
52
|
+
==================
|
|
53
|
+
|
|
54
|
+
* deps: http-errors@1.6.3
|
|
55
|
+
- deps: depd@~1.1.2
|
|
56
|
+
- deps: setprototypeof@1.1.0
|
|
57
|
+
- deps: statuses@'>= 1.3.1 < 2'
|
|
58
|
+
* deps: iconv-lite@0.4.23
|
|
59
|
+
- Fix loading encoding with year appended
|
|
60
|
+
- Fix deprecation warnings on Node.js 10+
|
|
61
|
+
|
|
62
|
+
2.3.2 / 2017-09-09
|
|
63
|
+
==================
|
|
64
|
+
|
|
65
|
+
* deps: iconv-lite@0.4.19
|
|
66
|
+
- Fix ISO-8859-1 regression
|
|
67
|
+
- Update Windows-1255
|
|
68
|
+
|
|
69
|
+
2.3.1 / 2017-09-07
|
|
70
|
+
==================
|
|
71
|
+
|
|
72
|
+
* deps: bytes@3.0.0
|
|
73
|
+
* deps: http-errors@1.6.2
|
|
74
|
+
- deps: depd@1.1.1
|
|
75
|
+
* perf: skip buffer decoding on overage chunk
|
|
76
|
+
|
|
77
|
+
2.3.0 / 2017-08-04
|
|
78
|
+
==================
|
|
79
|
+
|
|
80
|
+
* Add TypeScript definitions
|
|
81
|
+
* Use `http-errors` for standard emitted errors
|
|
82
|
+
* deps: bytes@2.5.0
|
|
83
|
+
* deps: iconv-lite@0.4.18
|
|
84
|
+
- Add support for React Native
|
|
85
|
+
- Add a warning if not loaded as utf-8
|
|
86
|
+
- Fix CESU-8 decoding in Node.js 8
|
|
87
|
+
- Improve speed of ISO-8859-1 encoding
|
|
88
|
+
|
|
89
|
+
2.2.0 / 2017-01-02
|
|
90
|
+
==================
|
|
91
|
+
|
|
92
|
+
* deps: iconv-lite@0.4.15
|
|
93
|
+
- Added encoding MS-31J
|
|
94
|
+
- Added encoding MS-932
|
|
95
|
+
- Added encoding MS-936
|
|
96
|
+
- Added encoding MS-949
|
|
97
|
+
- Added encoding MS-950
|
|
98
|
+
- Fix GBK/GB18030 handling of Euro character
|
|
99
|
+
|
|
100
|
+
2.1.7 / 2016-06-19
|
|
101
|
+
==================
|
|
102
|
+
|
|
103
|
+
* deps: bytes@2.4.0
|
|
104
|
+
* perf: remove double-cleanup on happy path
|
|
105
|
+
|
|
106
|
+
2.1.6 / 2016-03-07
|
|
107
|
+
==================
|
|
108
|
+
|
|
109
|
+
* deps: bytes@2.3.0
|
|
110
|
+
- Drop partial bytes on all parsed units
|
|
111
|
+
- Fix parsing byte string that looks like hex
|
|
112
|
+
|
|
113
|
+
2.1.5 / 2015-11-30
|
|
114
|
+
==================
|
|
115
|
+
|
|
116
|
+
* deps: bytes@2.2.0
|
|
117
|
+
* deps: iconv-lite@0.4.13
|
|
118
|
+
|
|
119
|
+
2.1.4 / 2015-09-27
|
|
120
|
+
==================
|
|
121
|
+
|
|
122
|
+
* Fix masking critical errors from `iconv-lite`
|
|
123
|
+
* deps: iconv-lite@0.4.12
|
|
124
|
+
- Fix CESU-8 decoding in Node.js 4.x
|
|
125
|
+
|
|
126
|
+
2.1.3 / 2015-09-12
|
|
127
|
+
==================
|
|
128
|
+
|
|
129
|
+
* Fix sync callback when attaching data listener causes sync read
|
|
130
|
+
- Node.js 0.10 compatibility issue
|
|
131
|
+
|
|
132
|
+
2.1.2 / 2015-07-05
|
|
133
|
+
==================
|
|
134
|
+
|
|
135
|
+
* Fix error stack traces to skip `makeError`
|
|
136
|
+
* deps: iconv-lite@0.4.11
|
|
137
|
+
- Add encoding CESU-8
|
|
138
|
+
|
|
139
|
+
2.1.1 / 2015-06-14
|
|
140
|
+
==================
|
|
141
|
+
|
|
142
|
+
* Use `unpipe` module for unpiping requests
|
|
143
|
+
|
|
144
|
+
2.1.0 / 2015-05-28
|
|
145
|
+
==================
|
|
146
|
+
|
|
147
|
+
* deps: iconv-lite@0.4.10
|
|
148
|
+
- Improved UTF-16 endianness detection
|
|
149
|
+
- Leading BOM is now removed when decoding
|
|
150
|
+
- The encoding UTF-16 without BOM now defaults to UTF-16LE when detection fails
|
|
151
|
+
|
|
152
|
+
2.0.2 / 2015-05-21
|
|
153
|
+
==================
|
|
154
|
+
|
|
155
|
+
* deps: bytes@2.1.0
|
|
156
|
+
- Slight optimizations
|
|
157
|
+
|
|
158
|
+
2.0.1 / 2015-05-10
|
|
159
|
+
==================
|
|
160
|
+
|
|
161
|
+
* Fix a false-positive when unpiping in Node.js 0.8
|
|
162
|
+
|
|
163
|
+
2.0.0 / 2015-05-08
|
|
164
|
+
==================
|
|
165
|
+
|
|
166
|
+
* Return a promise without callback instead of thunk
|
|
167
|
+
* deps: bytes@2.0.1
|
|
168
|
+
- units no longer case sensitive when parsing
|
|
169
|
+
|
|
170
|
+
1.3.4 / 2015-04-15
|
|
171
|
+
==================
|
|
172
|
+
|
|
173
|
+
* Fix hanging callback if request aborts during read
|
|
174
|
+
* deps: iconv-lite@0.4.8
|
|
175
|
+
- Add encoding alias UNICODE-1-1-UTF-7
|
|
176
|
+
|
|
177
|
+
1.3.3 / 2015-02-08
|
|
178
|
+
==================
|
|
179
|
+
|
|
180
|
+
* deps: iconv-lite@0.4.7
|
|
181
|
+
- Gracefully support enumerables on `Object.prototype`
|
|
182
|
+
|
|
183
|
+
1.3.2 / 2015-01-20
|
|
184
|
+
==================
|
|
185
|
+
|
|
186
|
+
* deps: iconv-lite@0.4.6
|
|
187
|
+
- Fix rare aliases of single-byte encodings
|
|
188
|
+
|
|
189
|
+
1.3.1 / 2014-11-21
|
|
190
|
+
==================
|
|
191
|
+
|
|
192
|
+
* deps: iconv-lite@0.4.5
|
|
193
|
+
- Fix Windows-31J and X-SJIS encoding support
|
|
194
|
+
|
|
195
|
+
1.3.0 / 2014-07-20
|
|
196
|
+
==================
|
|
197
|
+
|
|
198
|
+
* Fully unpipe the stream on error
|
|
199
|
+
- Fixes `Cannot switch to old mode now` error on Node.js 0.10+
|
|
200
|
+
|
|
201
|
+
1.2.3 / 2014-07-20
|
|
202
|
+
==================
|
|
203
|
+
|
|
204
|
+
* deps: iconv-lite@0.4.4
|
|
205
|
+
- Added encoding UTF-7
|
|
206
|
+
|
|
207
|
+
1.2.2 / 2014-06-19
|
|
208
|
+
==================
|
|
209
|
+
|
|
210
|
+
* Send invalid encoding error to callback
|
|
211
|
+
|
|
212
|
+
1.2.1 / 2014-06-15
|
|
213
|
+
==================
|
|
214
|
+
|
|
215
|
+
* deps: iconv-lite@0.4.3
|
|
216
|
+
- Added encodings UTF-16BE and UTF-16 with BOM
|
|
217
|
+
|
|
218
|
+
1.2.0 / 2014-06-13
|
|
219
|
+
==================
|
|
220
|
+
|
|
221
|
+
* Passing string as `options` interpreted as encoding
|
|
222
|
+
* Support all encodings from `iconv-lite`
|
|
223
|
+
|
|
224
|
+
1.1.7 / 2014-06-12
|
|
225
|
+
==================
|
|
226
|
+
|
|
227
|
+
* use `string_decoder` module from npm
|
|
228
|
+
|
|
229
|
+
1.1.6 / 2014-05-27
|
|
230
|
+
==================
|
|
231
|
+
|
|
232
|
+
* check encoding for old streams1
|
|
233
|
+
* support node.js < 0.10.6
|
|
234
|
+
|
|
235
|
+
1.1.5 / 2014-05-14
|
|
236
|
+
==================
|
|
237
|
+
|
|
238
|
+
* bump bytes
|
|
239
|
+
|
|
240
|
+
1.1.4 / 2014-04-19
|
|
241
|
+
==================
|
|
242
|
+
|
|
243
|
+
* allow true as an option
|
|
244
|
+
* bump bytes
|
|
245
|
+
|
|
246
|
+
1.1.3 / 2014-03-02
|
|
247
|
+
==================
|
|
248
|
+
|
|
249
|
+
* fix case when length=null
|
|
250
|
+
|
|
251
|
+
1.1.2 / 2013-12-01
|
|
252
|
+
==================
|
|
253
|
+
|
|
254
|
+
* be less strict on state.encoding check
|
|
255
|
+
|
|
256
|
+
1.1.1 / 2013-11-27
|
|
257
|
+
==================
|
|
258
|
+
|
|
259
|
+
* add engines
|
|
260
|
+
|
|
261
|
+
1.1.0 / 2013-11-27
|
|
262
|
+
==================
|
|
263
|
+
|
|
264
|
+
* add err.statusCode and err.type
|
|
265
|
+
* allow for encoding option to be true
|
|
266
|
+
* pause the stream instead of dumping on error
|
|
267
|
+
* throw if the stream's encoding is set
|
|
268
|
+
|
|
269
|
+
1.0.1 / 2013-11-19
|
|
270
|
+
==================
|
|
271
|
+
|
|
272
|
+
* dont support streams1, throw if dev set encoding
|
|
273
|
+
|
|
274
|
+
1.0.0 / 2013-11-17
|
|
275
|
+
==================
|
|
276
|
+
|
|
277
|
+
* rename `expected` option to `length`
|
|
278
|
+
|
|
279
|
+
0.2.0 / 2013-11-15
|
|
280
|
+
==================
|
|
281
|
+
|
|
282
|
+
* republish
|
|
283
|
+
|
|
284
|
+
0.1.1 / 2013-11-15
|
|
285
|
+
==================
|
|
286
|
+
|
|
287
|
+
* use bytes
|
|
288
|
+
|
|
289
|
+
0.1.0 / 2013-11-11
|
|
290
|
+
==================
|
|
291
|
+
|
|
292
|
+
* generator support
|
|
293
|
+
|
|
294
|
+
0.0.3 / 2013-10-10
|
|
295
|
+
==================
|
|
296
|
+
|
|
297
|
+
* update repo
|
|
298
|
+
|
|
299
|
+
0.0.2 / 2013-09-14
|
|
300
|
+
==================
|
|
301
|
+
|
|
302
|
+
* dump stream on bad headers
|
|
303
|
+
* listen to events after defining received and buffers
|
|
304
|
+
|
|
305
|
+
0.0.1 / 2013-09-14
|
|
306
|
+
==================
|
|
307
|
+
|
|
308
|
+
* Initial release
|