extra-filesystem 0.4.2 → 0.4.5

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/README.md CHANGED
@@ -195,7 +195,18 @@ getShortBasename('file.tar.gz') // 'file'
195
195
 
196
196
  ### readFileLineByLine
197
197
  ```ts
198
- function readFileLineByLine(filename: string, encoding: BufferEncoding = 'utf-8'): AsyncIterable<string>
198
+ function readFileLineByLine(
199
+ filename: string
200
+ , encoding: BufferEncoding = 'utf-8'
201
+ ): AsyncIterable<string>
202
+ ```
203
+
204
+ ### readFileLineByLineSync
205
+ ```ts
206
+ function* readFileLineByLineSync(
207
+ filename: string
208
+ , encoding: BufferEncoding = 'utf-8'
209
+ ): Iterable<string>
199
210
  ```
200
211
 
201
212
  ### writeIterableToFile
@@ -18,6 +18,7 @@ export * from './write-json-file';
18
18
  export * from './write-json-file-sync';
19
19
  export * from './write-iterable-to-file';
20
20
  export * from './read-file-line-by-line';
21
+ export * from './read-file-line-by-line-sync';
21
22
  export * from './move';
22
23
  export * from './move-sync';
23
24
  export * from './copy';
@@ -34,6 +34,7 @@ __exportStar(require("./write-json-file"), exports);
34
34
  __exportStar(require("./write-json-file-sync"), exports);
35
35
  __exportStar(require("./write-iterable-to-file"), exports);
36
36
  __exportStar(require("./read-file-line-by-line"), exports);
37
+ __exportStar(require("./read-file-line-by-line-sync"), exports);
37
38
  __exportStar(require("./move"), exports);
38
39
  __exportStar(require("./move-sync"), exports);
39
40
  __exportStar(require("./copy"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,yDAAsC;AACtC,qDAAkC;AAClC,0DAAuC;AACvC,qDAAkC;AAClC,0DAAuC;AACvC,8CAA2B;AAC3B,mDAAgC;AAChC,+CAA4B;AAC5B,oDAAiC;AACjC,gDAA6B;AAC7B,qDAAkC;AAClC,gDAA6B;AAC7B,qDAAkC;AAClC,mDAAgC;AAChC,wDAAqC;AACrC,oDAAiC;AACjC,yDAAsC;AACtC,2DAAwC;AACxC,2DAAwC;AACxC,yCAAsB;AACtB,8CAA2B;AAC3B,yCAAsB;AACtB,8CAA2B;AAC3B,2CAAwB;AACxB,gDAA6B;AAC7B,uDAAoC;AACpC,sDAAmC;AACnC,uDAAoC;AACpC,uDAAoC;AACpC,iDAA8B;AAC9B,sDAAmC;AACnC,4CAAyB;AACzB,iDAA8B;AAC9B,gDAA6B;AAC7B,gDAA6B;AAC7B,mDAAgC;AAChC,kDAA+B;AAC/B,6DAA0C;AAC1C,kEAA+C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,yDAAsC;AACtC,qDAAkC;AAClC,0DAAuC;AACvC,qDAAkC;AAClC,0DAAuC;AACvC,8CAA2B;AAC3B,mDAAgC;AAChC,+CAA4B;AAC5B,oDAAiC;AACjC,gDAA6B;AAC7B,qDAAkC;AAClC,gDAA6B;AAC7B,qDAAkC;AAClC,mDAAgC;AAChC,wDAAqC;AACrC,oDAAiC;AACjC,yDAAsC;AACtC,2DAAwC;AACxC,2DAAwC;AACxC,gEAA6C;AAC7C,yCAAsB;AACtB,8CAA2B;AAC3B,yCAAsB;AACtB,8CAA2B;AAC3B,2CAAwB;AACxB,gDAA6B;AAC7B,uDAAoC;AACpC,sDAAmC;AACnC,uDAAoC;AACpC,uDAAoC;AACpC,iDAA8B;AAC9B,sDAAmC;AACnC,4CAAyB;AACzB,iDAA8B;AAC9B,gDAA6B;AAC7B,gDAA6B;AAC7B,mDAAgC;AAChC,kDAA+B;AAC/B,6DAA0C;AAC1C,kEAA+C"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function readFileLineByLineSync(filename: string, encoding?: BufferEncoding): Iterable<string>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readFileLineByLineSync = void 0;
4
+ const fs = require("fs");
5
+ function* readFileLineByLineSync(filename, encoding = 'utf-8') {
6
+ const fd = fs.openSync(filename, 'r');
7
+ const bufferSize = 1024 * 64;
8
+ const buffer = Buffer.alloc(bufferSize);
9
+ let bytesRead;
10
+ let remainingLine = '';
11
+ while ((bytesRead = fs.readSync(fd, buffer, 0, bufferSize, null)) !== 0) {
12
+ const str = buffer.toString(encoding, 0, bytesRead);
13
+ const lines = str.split(/\r?\n/);
14
+ lines[0] = remainingLine + lines[0];
15
+ while (lines.length > 1) {
16
+ yield lines.shift();
17
+ }
18
+ remainingLine = lines.shift();
19
+ }
20
+ if (remainingLine)
21
+ yield remainingLine;
22
+ fs.closeSync(fd);
23
+ }
24
+ exports.readFileLineByLineSync = readFileLineByLineSync;
25
+ //# sourceMappingURL=read-file-line-by-line-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file-line-by-line-sync.js","sourceRoot":"","sources":["../../src/read-file-line-by-line-sync.ts"],"names":[],"mappings":";;;AAAA,yBAAwB;AAExB,QAAe,CAAC,CAAC,sBAAsB,CACrC,QAAgB,EAChB,WAA2B,OAAO;IAElC,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACrC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,CAAA;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAEvC,IAAI,SAAiB,CAAA;IACrB,IAAI,aAAa,GAAG,EAAE,CAAA;IACtB,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE;QACvE,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAA;QACnD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAChC,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,KAAK,CAAC,KAAK,EAAG,CAAA;SACrB;QACD,aAAa,GAAG,KAAK,CAAC,KAAK,EAAG,CAAA;KAC/B;IACD,IAAI,aAAa;QAAE,MAAM,aAAa,CAAA;IAEtC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAClB,CAAC;AAtBD,wDAsBC"}
@@ -18,6 +18,7 @@ export * from './write-json-file';
18
18
  export * from './write-json-file-sync';
19
19
  export * from './write-iterable-to-file';
20
20
  export * from './read-file-line-by-line';
21
+ export * from './read-file-line-by-line-sync';
21
22
  export * from './move';
22
23
  export * from './move-sync';
23
24
  export * from './copy';
@@ -34,6 +34,7 @@ __exportStar(require("./write-json-file"), exports);
34
34
  __exportStar(require("./write-json-file-sync"), exports);
35
35
  __exportStar(require("./write-iterable-to-file"), exports);
36
36
  __exportStar(require("./read-file-line-by-line"), exports);
37
+ __exportStar(require("./read-file-line-by-line-sync"), exports);
37
38
  __exportStar(require("./move"), exports);
38
39
  __exportStar(require("./move-sync"), exports);
39
40
  __exportStar(require("./copy"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,yDAAsC;AACtC,qDAAkC;AAClC,0DAAuC;AACvC,qDAAkC;AAClC,0DAAuC;AACvC,8CAA2B;AAC3B,mDAAgC;AAChC,+CAA4B;AAC5B,oDAAiC;AACjC,gDAA6B;AAC7B,qDAAkC;AAClC,gDAA6B;AAC7B,qDAAkC;AAClC,mDAAgC;AAChC,wDAAqC;AACrC,oDAAiC;AACjC,yDAAsC;AACtC,2DAAwC;AACxC,2DAAwC;AACxC,yCAAsB;AACtB,8CAA2B;AAC3B,yCAAsB;AACtB,8CAA2B;AAC3B,2CAAwB;AACxB,gDAA6B;AAC7B,uDAAoC;AACpC,sDAAmC;AACnC,uDAAoC;AACpC,uDAAoC;AACpC,iDAA8B;AAC9B,sDAAmC;AACnC,4CAAyB;AACzB,iDAA8B;AAC9B,gDAA6B;AAC7B,gDAA6B;AAC7B,mDAAgC;AAChC,kDAA+B;AAC/B,6DAA0C;AAC1C,kEAA+C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,yDAAsC;AACtC,qDAAkC;AAClC,0DAAuC;AACvC,qDAAkC;AAClC,0DAAuC;AACvC,8CAA2B;AAC3B,mDAAgC;AAChC,+CAA4B;AAC5B,oDAAiC;AACjC,gDAA6B;AAC7B,qDAAkC;AAClC,gDAA6B;AAC7B,qDAAkC;AAClC,mDAAgC;AAChC,wDAAqC;AACrC,oDAAiC;AACjC,yDAAsC;AACtC,2DAAwC;AACxC,2DAAwC;AACxC,gEAA6C;AAC7C,yCAAsB;AACtB,8CAA2B;AAC3B,yCAAsB;AACtB,8CAA2B;AAC3B,2CAAwB;AACxB,gDAA6B;AAC7B,uDAAoC;AACpC,sDAAmC;AACnC,uDAAoC;AACpC,uDAAoC;AACpC,iDAA8B;AAC9B,sDAAmC;AACnC,4CAAyB;AACzB,iDAA8B;AAC9B,gDAA6B;AAC7B,gDAA6B;AAC7B,mDAAgC;AAChC,kDAA+B;AAC/B,6DAA0C;AAC1C,kEAA+C"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function readFileLineByLineSync(filename: string, encoding?: BufferEncoding): Iterable<string>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readFileLineByLineSync = void 0;
4
+ const fs = require("fs");
5
+ function* readFileLineByLineSync(filename, encoding = 'utf-8') {
6
+ const fd = fs.openSync(filename, 'r');
7
+ const bufferSize = 1024 * 64;
8
+ const buffer = Buffer.alloc(bufferSize);
9
+ let bytesRead;
10
+ let remainingLine = '';
11
+ while ((bytesRead = fs.readSync(fd, buffer, 0, bufferSize, null)) !== 0) {
12
+ const str = buffer.toString(encoding, 0, bytesRead);
13
+ const lines = str.split(/\r?\n/);
14
+ lines[0] = remainingLine + lines[0];
15
+ while (lines.length > 1) {
16
+ yield lines.shift();
17
+ }
18
+ remainingLine = lines.shift();
19
+ }
20
+ if (remainingLine)
21
+ yield remainingLine;
22
+ fs.closeSync(fd);
23
+ }
24
+ exports.readFileLineByLineSync = readFileLineByLineSync;
25
+ //# sourceMappingURL=read-file-line-by-line-sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-file-line-by-line-sync.js","sourceRoot":"","sources":["../../src/read-file-line-by-line-sync.ts"],"names":[],"mappings":";;;AAAA,yBAAwB;AAExB,QAAe,CAAC,CAAC,sBAAsB,CACrC,QAAgB,EAChB,WAA2B,OAAO;IAElC,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IACrC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAE,CAAA;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAEvC,IAAI,SAAiB,CAAA;IACrB,IAAI,aAAa,GAAG,EAAE,CAAA;IACtB,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE;QACvE,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,SAAS,CAAC,CAAA;QACnD,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAChC,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACnC,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;YACvB,MAAM,KAAK,CAAC,KAAK,EAAG,CAAA;SACrB;QACD,aAAa,GAAG,KAAK,CAAC,KAAK,EAAG,CAAA;KAC/B;IACD,IAAI,aAAa;QAAE,MAAM,aAAa,CAAA;IAEtC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAClB,CAAC;AAtBD,wDAsBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-filesystem",
3
- "version": "0.4.2",
3
+ "version": "0.4.5",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "files": [
@@ -11,6 +11,7 @@
11
11
  "repository": "git@github.com:BlackGlory/extra-filesystem.git",
12
12
  "author": "BlackGlory <woshenmedoubuzhidao@blackglory.me>",
13
13
  "license": "MIT",
14
+ "sideEffects": false,
14
15
  "engines": {
15
16
  "node": ">=14"
16
17
  },
@@ -38,31 +39,31 @@
38
39
  },
39
40
  "devDependencies": {
40
41
  "@blackglory/jest-matchers": "^0.3.0",
41
- "@commitlint/cli": "^16.2.1",
42
- "@commitlint/config-conventional": "^16.2.1",
42
+ "@commitlint/cli": "^17.0.3",
43
+ "@commitlint/config-conventional": "^17.0.3",
43
44
  "@types/fs-extra": "^9.0.13",
44
45
  "@types/jest": "^27.4.1",
45
46
  "@types/node": "14",
46
47
  "@types/tmp": "^0.2.3",
47
- "@typescript-eslint/eslint-plugin": "^5.13.0",
48
- "@typescript-eslint/parser": "^5.13.0",
49
- "eslint": "^8.10.0",
48
+ "@typescript-eslint/eslint-plugin": "^5.30.5",
49
+ "@typescript-eslint/parser": "^5.30.5",
50
+ "eslint": "^8.19.0",
50
51
  "husky": "^4.3.0",
51
- "iterable-operator": "^1.0.0",
52
+ "iterable-operator": "^1.1.0",
52
53
  "jest": "^27.5.1",
53
54
  "jest-extended": "^2.0.0",
54
55
  "npm-run-all": "^4.1.5",
55
- "return-style": "^0.12.6",
56
+ "return-style": "^1.0.0",
56
57
  "rimraf": "^3.0.2",
57
- "standard-version": "^9.3.2",
58
+ "standard-version": "^9.5.0",
58
59
  "ts-jest": "^27.1.3",
59
60
  "tscpaths": "^0.0.9",
60
- "typescript": "^4.6.2"
61
+ "typescript": "^4.7.4"
61
62
  },
62
63
  "dependencies": {
63
64
  "@blackglory/pass": "^1.0.0",
64
- "extra-promise": "^1.0.0",
65
- "fs-extra": "^10.0.1",
65
+ "extra-promise": "^2.2.0",
66
+ "fs-extra": "^10.1.0",
66
67
  "tmp-promise": "^3.0.3"
67
68
  }
68
69
  }