Skip to content

Commit 628efcd

Browse files
committed
Require Node.js 12 and move to ESM
1 parent 43eb861 commit 628efcd

File tree

10 files changed

+75
-97
lines changed

10 files changed

+75
-97
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[{package.json,*.yml}]
10+
[*.yml]
1111
indent_style = space
1212
indent_size = 2

.gitattributes

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

.github/workflows/main.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@ jobs:
1212
node-version:
1313
- 14
1414
- 12
15-
- 10
16-
- 8
17-
- 6
18-
- 4
1915
steps:
2016
- uses: actions/checkout@v2
21-
- uses: actions/setup-node@v1
17+
- uses: actions/setup-node@v2
2218
with:
2319
node-version: ${{ matrix.node-version }}
2420
- run: npm install

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
yarn.lock

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
'use strict';
2-
const split = require('split2');
3-
const through = require('through2');
4-
const pumpify = require('pumpify');
1+
import split from 'split2';
2+
import through from 'through2';
3+
import pumpify from 'pumpify';
54

6-
module.exports = (count, indent) => {
5+
export default function padStream(count, indent) {
76
if (!Number.isSafeInteger(count)) {
87
throw new TypeError(`Expected \`count\` to be a integer, got \`${count}\` (${typeof count})`);
98
}
109

1110
indent = typeof indent === 'string' ? indent : ' ';
1211

13-
return pumpify(split(), through((data, enc, cb) => {
14-
cb(null, indent.repeat(count) + data + '\n');
12+
return pumpify(split(), through((data, enc, callback) => {
13+
callback(null, indent.repeat(count) + data + '\n');
1514
}));
16-
};
15+
}

license

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
The MIT License (MIT)
1+
MIT License
22

3-
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
44

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:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

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
21-
THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
11
{
2-
"name": "pad-stream",
3-
"version": "2.0.0",
4-
"description": "Pad each line in a stream",
5-
"license": "MIT",
6-
"repository": "sindresorhus/pad-stream",
7-
"author": {
8-
"name": "Sindre Sorhus",
9-
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11-
},
12-
"engines": {
13-
"node": ">=4"
14-
},
15-
"scripts": {
16-
"test": "xo && ava"
17-
},
18-
"files": [
19-
"index.js"
20-
],
21-
"keywords": [
22-
"pad",
23-
"lpad",
24-
"padding",
25-
"indent",
26-
"left",
27-
"left-pad",
28-
"string",
29-
"str",
30-
"stream",
31-
"streaming",
32-
"line",
33-
"lines"
34-
],
35-
"dependencies": {
36-
"pumpify": "^1.3.3",
37-
"split2": "^2.1.1",
38-
"through2": "^2.0.0"
39-
},
40-
"devDependencies": {
41-
"ava": "*",
42-
"get-stream": "^3.0.0",
43-
"into-stream": "^3.1.0",
44-
"xo": "*"
45-
}
2+
"name": "pad-stream",
3+
"version": "2.0.0",
4+
"description": "Pad each line in a stream",
5+
"license": "MIT",
6+
"repository": "sindresorhus/pad-stream",
7+
"funding": "https://github.com/sponsors/sindresorhus",
8+
"author": {
9+
"name": "Sindre Sorhus",
10+
"email": "[email protected]",
11+
"url": "https://sindresorhus.com"
12+
},
13+
"type": "module",
14+
"exports": "./index.js",
15+
"engines": {
16+
"node": ">=12"
17+
},
18+
"scripts": {
19+
"test": "xo && ava"
20+
},
21+
"files": [
22+
"index.js"
23+
],
24+
"keywords": [
25+
"pad",
26+
"lpad",
27+
"padding",
28+
"indent",
29+
"left",
30+
"left-pad",
31+
"string",
32+
"str",
33+
"stream",
34+
"streaming",
35+
"line",
36+
"lines"
37+
],
38+
"dependencies": {
39+
"pumpify": "^2.0.1",
40+
"split2": "^3.2.2",
41+
"through2": "^4.0.2"
42+
},
43+
"devDependencies": {
44+
"ava": "^3.15.0",
45+
"get-stream": "^6.0.0",
46+
"into-stream": "^6.0.0",
47+
"xo": "^0.38.2"
48+
}
4649
}

readme.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22

33
> Pad each line in a stream
44
5-
65
## Install
76

87
```
9-
$ npm install --save pad-stream
8+
$ npm install pad-stream
109
```
1110

12-
1311
## Usage
1412

1513
```js
1614
// pad.js
17-
const padStream = require('pad-stream');
15+
import padStream from 'pad-stream';
1816

1917
process.stdin.pipe(padStream(2, '>')).pipe(process.stdout);
2018
```
@@ -25,10 +23,9 @@ $ echo 'foo\nbar' | node pad.js
2523
>>bar
2624
```
2725

28-
2926
## API
3027

31-
### padStream(count, [indent])
28+
### padStream(count, indent?)
3229

3330
Returns a [transform stream](https://nodejs.org/api/stream.html#stream_duplex_and_transform_streams).
3431

@@ -40,18 +37,12 @@ Number of times to repeat `indent`.
4037

4138
#### indent
4239

43-
Type: `string`<br>
40+
Type: `string`\
4441
Default: `' '`
4542

4643
String to use as indent.
4744

48-
4945
## Related
5046

5147
- [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string
5248
- [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - Indent each line in some text or stdin
53-
54-
55-
## License
56-
57-
MIT © [Sindre Sorhus](https://sindresorhus.com)

test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import test from 'ava';
22
import intoStream from 'into-stream';
33
import getStream from 'get-stream';
4-
import m from '.';
4+
import padStream from './index.js';
55

66
const fixture = 'foo\nbar';
77

88
test('pad', async t => {
9-
const ret = await getStream(intoStream(fixture).pipe(m(1)));
10-
t.is(ret, ' foo\n bar\n');
9+
const string = await getStream(intoStream(fixture).pipe(padStream(1)));
10+
t.is(string, ' foo\n bar\n');
1111
});
1212

1313
test('count 0', async t => {
14-
const ret = await getStream(intoStream(fixture).pipe(m(0)));
15-
t.is(ret, 'foo\nbar\n');
14+
const string = await getStream(intoStream(fixture).pipe(padStream(0)));
15+
t.is(string, 'foo\nbar\n');
1616
});
1717

1818
test('options', async t => {
19-
const ret = await getStream(intoStream(fixture).pipe(m(2, '@@')));
20-
t.is(ret, '@@@@foo\n@@@@bar\n');
19+
const string = await getStream(intoStream(fixture).pipe(padStream(2, '@@')));
20+
t.is(string, '@@@@foo\n@@@@bar\n');
2121
});

0 commit comments

Comments
 (0)