eject 0.2.2 → 0.3.2
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/LICENSE +1 -1
- package/Makefile +6 -0
- package/README.md +66 -11
- package/eject.js +3 -3
- package/package.json +1 -1
package/LICENSE
CHANGED
package/Makefile
ADDED
package/README.md
CHANGED
|
@@ -1,20 +1,75 @@
|
|
|
1
|
-
[](https://github.com/bigeasy/eject/actions)
|
|
2
|
+
[](https://codecov.io/gh/bigeasy/eject)
|
|
3
3
|
[](https://opensource.org/licenses/MIT)
|
|
4
4
|
|
|
5
5
|
Convert a single set of events on an EventEmitter into a Promise.
|
|
6
6
|
|
|
7
|
-
| What | Where
|
|
7
|
+
| What | Where |
|
|
8
8
|
| --- | --- |
|
|
9
|
-
| Discussion | https://github.com/bigeasy/
|
|
10
|
-
| Documentation | https://bigeasy.github.io/
|
|
11
|
-
| Source | https://github.com/bigeasy/
|
|
12
|
-
| Issues | https://github.com/bigeasy/
|
|
13
|
-
| CI | https://travis-ci.org/bigeasy/
|
|
14
|
-
| Coverage: | https://codecov.io/gh/bigeasy/
|
|
15
|
-
| License: | MIT
|
|
9
|
+
| Discussion | https://github.com/bigeasy/eject/issues/1 |
|
|
10
|
+
| Documentation | https://bigeasy.github.io/eject |
|
|
11
|
+
| Source | https://github.com/bigeasy/eject |
|
|
12
|
+
| Issues | https://github.com/bigeasy/eject/issues |
|
|
13
|
+
| CI | https://travis-ci.org/bigeasy/eject |
|
|
14
|
+
| Coverage: | https://codecov.io/gh/bigeasy/eject |
|
|
15
|
+
| License: | MIT |
|
|
16
16
|
|
|
17
|
+
Eject installs from NPM.
|
|
17
18
|
|
|
18
19
|
```
|
|
19
|
-
npm install
|
|
20
|
+
npm install eject
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Overview
|
|
24
|
+
|
|
25
|
+
Extant is an implementation of SQL's COALESCE that I've used for some time to
|
|
26
|
+
deal with the fact that JavaScript truthiness will treat `''` and `0` as true so
|
|
27
|
+
the `||` operator can't always be used to create given or default one-liner.
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
const { compare, raise, equal } = require('eject')
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
We use the name "extant" on NPM because we want the first extant argument.
|
|
34
|
+
|
|
35
|
+
## Living `README.md`
|
|
36
|
+
|
|
37
|
+
This `README.md` is also a unit test using the
|
|
38
|
+
[Proof](https://github.com/bigeasy/proof) unit test framework. We'll use the
|
|
39
|
+
Proof `okay` function to assert out statements in the readme. A Proof unit test
|
|
40
|
+
generally looks like this.
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
require('proof')(4, async okay => {
|
|
44
|
+
okay('always okay')
|
|
45
|
+
okay(true, 'okay if true')
|
|
46
|
+
okay(1, 1, 'okay if equal')
|
|
47
|
+
okay({ value: 1 }, { value: 1 }, 'okay if deep strict equal')
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
You can run this unit test yourself to see the output from the various
|
|
52
|
+
code sections of the readme.
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
git clone git@github.com:bigeasy/eject.git
|
|
56
|
+
cd eject
|
|
57
|
+
npm install --no-package-lock --no-save
|
|
58
|
+
node test/readme.t.js
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
The `'extant'` module exports a single `coalesce` function.
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
const { compare, raise, equal } = require('depature')
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Note that Extant is SQL's `COALESCE`. It returns the first non-null-like value,
|
|
70
|
+
that is the first value that is not `== null`, which would be `null` or
|
|
71
|
+
`undefined`. If there is no such argument it returns `null`.
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
okay('test')
|
|
20
75
|
```
|
package/eject.js
CHANGED
|
@@ -39,7 +39,7 @@ class Once {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
exports.once = function (ee, events) {
|
|
43
43
|
return new Once({
|
|
44
44
|
ee: ee,
|
|
45
45
|
events: Array.isArray(events) ? events : [ events ],
|
|
@@ -47,6 +47,6 @@ module.exports = function (ee, events) {
|
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
exports.once.NULL = {
|
|
51
|
+
emit: () => {}
|
|
52
52
|
}
|