Skip to content

Commit fda3b3d

Browse files
authoredAug 8, 2024··
Add ESM support and move to a named export
This is a breaking change due to the named export
1 parent dd5b94d commit fda3b3d

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed
 

Diff for: ‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is a very simple zero-dependency implementation.
1111
## Usage
1212

1313
```javascript
14-
const arrayifyStream = require('arrayify-stream');
14+
import { arrayifyStream } from 'arrayify-stream';
1515
...
1616
let myArray = await arrayifyStream(myStream);
1717
```

Diff for: ‎index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function promisifyEventEmitter<T>(event: EventEmitter, result: T): Promise<T> {
77
});
88
}
99

10-
export default function arrayifyStream<T = any>(stream: EventEmitter): Promise<T[]> {
10+
export function arrayifyStream<T = any>(stream: EventEmitter): Promise<T[]> {
1111
const array: T[] = [];
1212
return promisifyEventEmitter(stream.on('data', data => array.push(data)), array);
1313
}

Diff for: ‎package.json

+22-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,22 @@
88
"readable stream"
99
],
1010
"main": "index.js",
11+
"module": "esm/index.js",
12+
"types": "index.d.ts",
1113
"typings": "index",
14+
"exports": {
15+
"./package.json": "./package.json",
16+
".": {
17+
"require": {
18+
"types": "./index.d.ts",
19+
"default": "./index.js"
20+
},
21+
"import": {
22+
"types": "./esm/index.d.ts",
23+
"default": "./esm/index.js"
24+
}
25+
}
26+
},
1227
"repository": "git@github.com:rubensworks/arrayify-stream.js.git",
1328
"author": "Ruben Taelman <rubensworks@gmail.com>",
1429
"bugs": {
@@ -19,7 +34,10 @@
1934
"files": [
2035
"index.d.ts",
2136
"index.js",
22-
"index.js.map"
37+
"index.js.map",
38+
"esm/index.d.ts",
39+
"esm/index.js",
40+
"esm/index.js.map"
2341
],
2442
"pre-commit": [
2543
"build",
@@ -76,7 +94,9 @@
7694
"coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls",
7795
"validate": "npm ls",
7896
"lint": "eslint index.ts test/**.ts ",
79-
"build": "tsc",
97+
"build": "npm run build:cjs && npm run build:esm",
98+
"build:cjs": "tsc",
99+
"build:esm": "tsc -d --module es2015 --moduleResolution nodenext --outDir esm",
80100
"prepare": "npm run build",
81101
"version": "manual-git-changelog onversion"
82102
}

Diff for: ‎test/arrayify-stream-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Readable } from 'stream';
22
import { fromArray } from 'asynciterator';
3-
import arrayifyStream from '..';
3+
import { arrayifyStream } from '..';
44

55
describe('arrayify-stream', () => {
66
it('should handle an empty stream', async() => {

0 commit comments

Comments
 (0)
Please sign in to comment.