@waiting/shared-core
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -5,2 +5,9 @@ # Changelog | ||
## [2.1.0](https://github.com/waitingsong/node-shared-core/compare/v2.0.1...v2.1.0) (2019-08-14) | ||
### Features | ||
* add readFileLineRx() ([9da8b50](https://github.com/waitingsong/node-shared-core/commit/9da8b50)) | ||
### [2.0.1](https://github.com/waitingsong/node-shared-core/compare/v2.0.0...v2.0.1) (2019-08-11) | ||
@@ -7,0 +14,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* @version 2.0.1 | ||
* @version 2.1.0 | ||
* @author waiting | ||
@@ -22,2 +22,3 @@ * @license MIT | ||
var os = require('os'); | ||
var readline = require('readline'); | ||
@@ -270,2 +271,24 @@ function assertNever(x) { | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** | ||
* Read file line by line | ||
* | ||
* @see https://nodejs.org/dist/latest-v12.x/docs/api/readline.html#readline_example_read_file_stream_line_by_line | ||
*/ | ||
function readFileLineRx(path) { | ||
const fileStream = fs.createReadStream(path); | ||
const rline = readline.createInterface({ | ||
input: fileStream, | ||
crlfDelay: Infinity, | ||
}); | ||
// Note: we use the crlfDelay option to recognize all instances of CR LF | ||
// ('\r\n') in input.txt as a single line break. | ||
const line$ = rxjs.Observable.create((obv) => { | ||
rline.on('line', line => obv.next(line)); | ||
rline.once('close', () => obv.complete()); | ||
return () => rline.removeAllListeners(); | ||
}); | ||
return line$; | ||
} | ||
/** Set loading path for node-ffi linking dll */ | ||
@@ -426,2 +449,3 @@ function setPathDirectory(path) { | ||
exports.readFileAsync = readFileAsync; | ||
exports.readFileLineRx = readFileLineRx; | ||
exports.rimraf = rimraf; | ||
@@ -428,0 +452,0 @@ exports.rmdirAsync = rmdirAsync; |
export * from './asset'; | ||
export * from './consts'; | ||
export * from './file'; | ||
export * from './utils'; | ||
@@ -4,0 +5,0 @@ export * from './helper'; |
export * from './asset'; | ||
export * from './consts'; | ||
export * from './file'; | ||
export * from './utils'; | ||
@@ -4,0 +5,0 @@ export * from './helper'; |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -59,3 +59,3 @@ "keywords": [ | ||
"@types/yargs": "^13.0.0", | ||
"@waiting/eslint-config": "^1.10.0", | ||
"@waiting/eslint-config": "^2.1.0", | ||
"coveralls": "^3.0.5", | ||
@@ -88,3 +88,3 @@ "cross-env": "^5.2.0", | ||
"cov:coveralls": "cross-env TS_NODE_PROJECT=test/tsconfig.json nyc mocha && nyc report --reporter=text-lcov | coveralls", | ||
"doc": "typedoc src/index.ts src/lib/index.ts src/lib/model.ts", | ||
"doc": "typedoc src/index.ts src/lib/index.ts src/lib/model.ts src/lib/file.ts src/lib/utils.ts", | ||
"jslint": "eslint --fix dist/**/*.js", | ||
@@ -91,0 +91,0 @@ "link_global": "npm link typescript", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
70051
29
988
10