@waiting/shared-core
Advanced tools
Comparing version 22.0.0 to 23.0.0
@@ -1,2 +0,1 @@ | ||
import { Observable } from 'rxjs'; | ||
export declare function assertNever(x: never): never; | ||
@@ -6,3 +5,2 @@ /** | ||
*/ | ||
export declare function assertNeverRx(x: never): Observable<never>; | ||
//# sourceMappingURL=asset.d.ts.map |
@@ -1,2 +0,1 @@ | ||
import { throwError, } from 'rxjs'; | ||
export function assertNever(x) { | ||
@@ -9,6 +8,6 @@ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands | ||
*/ | ||
export function assertNeverRx(x) { | ||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands | ||
return throwError(() => new Error('Assert Never Unexpected object: ' + x)); | ||
} | ||
// export function assertNeverRx(x: never): Observable<never> { | ||
// // eslint-disable-next-line @typescript-eslint/restrict-plus-operands | ||
// return throwError(() => new Error('Assert Never Unexpected object: ' + x)) | ||
// } | ||
//# sourceMappingURL=asset.js.map |
@@ -63,10 +63,10 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
assert(site, 'stack empty'); | ||
// @ts-expect-error | ||
// @ts-ignore | ||
const enclosingLineNumber = site.getEnclosingLineNumber | ||
// @ts-expect-error | ||
// @ts-ignore | ||
? site.getEnclosingLineNumber() | ||
: 0; | ||
// @ts-expect-error | ||
// @ts-ignore | ||
const enclosingColNumber = site.getEnclosingColumnNumber | ||
// @ts-expect-error | ||
// @ts-ignore | ||
? site.getEnclosingColumnNumber() | ||
@@ -73,0 +73,0 @@ : 0; |
@@ -1,2 +0,1 @@ | ||
import { Observable } from 'rxjs'; | ||
/** | ||
@@ -7,4 +6,3 @@ * Read file line by line | ||
*/ | ||
export declare function readFileLineRx(path: string): Observable<string>; | ||
export declare function genAbsolutePath(path: string, fileUrlPrefix?: boolean): string; | ||
//# sourceMappingURL=file.d.ts.map |
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import assert from 'node:assert'; | ||
import { createReadStream } from 'node:fs'; | ||
import { isAbsolute, resolve } from 'node:path'; | ||
import { createInterface } from 'node:readline'; | ||
import { Observable } from 'rxjs'; | ||
import { isWin32 } from './consts.js'; | ||
// import { createReadStream } from 'node:fs' | ||
// import { createInterface } from 'node:readline' | ||
/** | ||
@@ -13,23 +12,29 @@ * Read file line by line | ||
*/ | ||
export function readFileLineRx(path) { | ||
const fileStream = createReadStream(path); | ||
const rline = 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$ = Observable.create((obv: Observer<string>) => { | ||
// rline.on('line', line => obv.next(line)) | ||
// rline.once('close', () => obv.complete()) | ||
// return () => rline.removeAllListeners() | ||
// }) as Observable<string> | ||
const line$ = new Observable((subscriber) => { | ||
rline.on('line', line => subscriber.next(line)); | ||
rline.once('close', () => subscriber.complete()); | ||
rline.once('error', err => subscriber.error(err)); | ||
return () => rline.removeAllListeners(); | ||
}); | ||
return line$; | ||
} | ||
/* | ||
export function readFileLineRx(path: string): Observable<string> { | ||
const fileStream = createReadStream(path) | ||
const rline = 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$ = Observable.create((obv: Observer<string>) => { | ||
// rline.on('line', line => obv.next(line)) | ||
// rline.once('close', () => obv.complete()) | ||
// return () => rline.removeAllListeners() | ||
// }) as Observable<string> | ||
const line$ = new Observable<string>((subscriber) => { | ||
rline.on('line', line => subscriber.next(line)) | ||
rline.once('close', () => subscriber.complete()) | ||
rline.once('error', err => subscriber.error(err)) | ||
return () => rline.removeAllListeners() | ||
}) | ||
return line$ | ||
} */ | ||
export function genAbsolutePath(path, fileUrlPrefix = false) { | ||
@@ -36,0 +41,0 @@ assert(path, 'path is empty'); |
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
/// <reference types="node" resolution-mode="require"/> | ||
import { WriteFileOptions } from 'node:fs'; | ||
import { resolve as pathResolve } from 'node:path'; | ||
import { Observable } from 'rxjs'; | ||
export { pathResolve }; | ||
/** Return path if accessible, blank if not accessible */ | ||
export declare function pathAccessible(path: string): Observable<string>; | ||
export declare function isPathAccessible(path: string): Promise<boolean>; | ||
/** Check folder path exists, return path if exists, blank if not exists */ | ||
export declare function dirExists(path: string): Observable<string>; | ||
export declare function isDirExists(path: string): Promise<boolean>; | ||
/** Check file exists, return path if exists, blank if not exists */ | ||
export declare function fileExists(path: string): Observable<string>; | ||
export declare function isFileExists(path: string): Promise<boolean>; | ||
@@ -17,0 +14,0 @@ export declare function isDirFileExists(path: string, type: 'DIR' | 'FILE'): Promise<boolean>; |
@@ -7,9 +7,10 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
import { TextDecoder, TextEncoder } from 'node:util'; | ||
import { defer, of, map, } from 'rxjs'; | ||
export { pathResolve }; | ||
// export { tmpdir } from 'node:os' | ||
/** Return path if accessible, blank if not accessible */ | ||
export function pathAccessible(path) { | ||
return defer(() => isPathAccessible(path)).pipe(map(exists => exists ? normalize(path) : '')); | ||
} | ||
// export function pathAccessible(path: string): Observable<string> { | ||
// return defer(() => isPathAccessible(path)).pipe( | ||
// map(exists => exists ? normalize(path) : ''), | ||
// ) | ||
// } | ||
// support relative file ('./foo') | ||
@@ -22,9 +23,11 @@ export function isPathAccessible(path) { | ||
/** Check folder path exists, return path if exists, blank if not exists */ | ||
export function dirExists(path) { | ||
if (!path) { | ||
return of(''); | ||
} | ||
const dir = normalize(path); | ||
return defer(() => isDirExists(dir)).pipe(map(exists => exists ? dir : '')); | ||
} | ||
// export function dirExists(path: string): Observable<string> { | ||
// if (! path) { | ||
// return of('') | ||
// } | ||
// const dir = normalize(path) | ||
// return defer(() => isDirExists(dir)).pipe( | ||
// map(exists => exists ? dir : ''), | ||
// ) | ||
// } | ||
export function isDirExists(path) { | ||
@@ -34,6 +37,8 @@ return path ? isDirFileExists(path, 'DIR') : Promise.resolve(false); | ||
/** Check file exists, return path if exists, blank if not exists */ | ||
export function fileExists(path) { | ||
const file = normalize(path); | ||
return defer(() => isFileExists(file)).pipe(map(exists => exists ? file : '')); | ||
} | ||
// export function fileExists(path: string): Observable<string> { | ||
// const file = normalize(path) | ||
// return defer(() => isFileExists(file)).pipe( | ||
// map(exists => exists ? file : ''), | ||
// ) | ||
// } | ||
export function isFileExists(path) { | ||
@@ -40,0 +45,0 @@ return path ? isDirFileExists(path, 'FILE') : Promise.resolve(false); |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "22.0.0", | ||
"version": "23.0.0", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -33,5 +33,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@waiting/shared-types": "^22.0.0", | ||
"@waiting/shared-types": "^23.0.0", | ||
"minimist": "^1.2.8", | ||
"rxjs": "^7.8.0", | ||
"semver": "^7.5.4", | ||
@@ -44,3 +43,3 @@ "zx": "^7.2.3" | ||
"engines": { | ||
"node": ">=16.13.0" | ||
"node": ">=18.12.0" | ||
}, | ||
@@ -65,3 +64,3 @@ "files": [ | ||
"scripts": { | ||
"build": "npm run tsc && tsc-alias", | ||
"build": "npm run tsc && tsc-alias && npm run rp", | ||
"clean": "npm run clean:lock && npm run clean:dist && npm run clean:log", | ||
@@ -75,7 +74,8 @@ "clean:cache": "rm -rf .eslintcache .tsbuildinfo", | ||
"lint:nofix": "eslint --cache {src,test}/**/*.ts", | ||
"rp": "rollup -c rollup.config.js --context this", | ||
"pretest": "npm run build", | ||
"rp": "tsx bin-hashbang.js", | ||
"test": "cross-env NODE_ENV=test TS_NODE_PROJECT=test/tsconfig.json mocha --jobs=4", | ||
"tsc": "tsc -b" | ||
}, | ||
"gitHead": "52f304b67139fe3615c7e8f324988815d744504f" | ||
"gitHead": "82346e1800df8018a92b118131a3c4685e09f9d3" | ||
} |
@@ -1,7 +0,2 @@ | ||
import { | ||
throwError, | ||
Observable, | ||
} from 'rxjs' | ||
export function assertNever(x: never): never { | ||
@@ -14,6 +9,6 @@ // eslint-disable-next-line @typescript-eslint/restrict-plus-operands | ||
*/ | ||
export function assertNeverRx(x: never): Observable<never> { | ||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands | ||
return throwError(() => new Error('Assert Never Unexpected object: ' + x)) | ||
} | ||
// export function assertNeverRx(x: never): Observable<never> { | ||
// // eslint-disable-next-line @typescript-eslint/restrict-plus-operands | ||
// return throwError(() => new Error('Assert Never Unexpected object: ' + x)) | ||
// } | ||
@@ -81,11 +81,11 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ | ||
// @ts-expect-error | ||
// @ts-ignore | ||
const enclosingLineNumber: number | undefined = site.getEnclosingLineNumber | ||
// @ts-expect-error | ||
// @ts-ignore | ||
? site.getEnclosingLineNumber() as unknown as number | ||
: 0 | ||
// @ts-expect-error | ||
// @ts-ignore | ||
const enclosingColNumber: number | undefined = site.getEnclosingColumnNumber | ||
// @ts-expect-error | ||
// @ts-ignore | ||
? site.getEnclosingColumnNumber() as unknown as number | ||
@@ -92,0 +92,0 @@ : 0 |
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
import assert from 'node:assert' | ||
import { createReadStream } from 'node:fs' | ||
import { isAbsolute, resolve } from 'node:path' | ||
import { createInterface } from 'node:readline' | ||
import { Observable } from 'rxjs' | ||
import { isWin32 } from './consts.js' | ||
// import { createReadStream } from 'node:fs' | ||
// import { createInterface } from 'node:readline' | ||
/** | ||
@@ -17,2 +15,3 @@ * Read file line by line | ||
*/ | ||
/* | ||
export function readFileLineRx(path: string): Observable<string> { | ||
@@ -43,3 +42,3 @@ const fileStream = createReadStream(path) | ||
return line$ | ||
} | ||
} */ | ||
@@ -46,0 +45,0 @@ |
@@ -19,10 +19,3 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ | ||
import { | ||
defer, | ||
of, | ||
map, | ||
Observable, | ||
} from 'rxjs' | ||
export { pathResolve } | ||
@@ -32,7 +25,7 @@ // export { tmpdir } from 'node:os' | ||
/** Return path if accessible, blank if not accessible */ | ||
export function pathAccessible(path: string): Observable<string> { | ||
return defer(() => isPathAccessible(path)).pipe( | ||
map(exists => exists ? normalize(path) : ''), | ||
) | ||
} | ||
// export function pathAccessible(path: string): Observable<string> { | ||
// return defer(() => isPathAccessible(path)).pipe( | ||
// map(exists => exists ? normalize(path) : ''), | ||
// ) | ||
// } | ||
// support relative file ('./foo') | ||
@@ -46,11 +39,11 @@ export function isPathAccessible(path: string): Promise<boolean> { | ||
/** Check folder path exists, return path if exists, blank if not exists */ | ||
export function dirExists(path: string): Observable<string> { | ||
if (! path) { | ||
return of('') | ||
} | ||
const dir = normalize(path) | ||
return defer(() => isDirExists(dir)).pipe( | ||
map(exists => exists ? dir : ''), | ||
) | ||
} | ||
// export function dirExists(path: string): Observable<string> { | ||
// if (! path) { | ||
// return of('') | ||
// } | ||
// const dir = normalize(path) | ||
// return defer(() => isDirExists(dir)).pipe( | ||
// map(exists => exists ? dir : ''), | ||
// ) | ||
// } | ||
export function isDirExists(path: string): Promise<boolean> { | ||
@@ -62,8 +55,8 @@ return path ? isDirFileExists(path, 'DIR') : Promise.resolve(false) | ||
/** Check file exists, return path if exists, blank if not exists */ | ||
export function fileExists(path: string): Observable<string> { | ||
const file = normalize(path) | ||
return defer(() => isFileExists(file)).pipe( | ||
map(exists => exists ? file : ''), | ||
) | ||
} | ||
// export function fileExists(path: string): Observable<string> { | ||
// const file = normalize(path) | ||
// return defer(() => isFileExists(file)).pipe( | ||
// map(exists => exists ? file : ''), | ||
// ) | ||
// } | ||
export function isFileExists(path: string): Promise<boolean> { | ||
@@ -70,0 +63,0 @@ return path ? isDirFileExists(path, 'FILE') : Promise.resolve(false) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
4
129093
2676
+ Added@types/node@18.19.66(transitive)
+ Added@waiting/shared-types@23.24.0(transitive)
- Removedrxjs@^7.8.0
- Removed@types/node@18.19.65(transitive)
- Removed@waiting/shared-types@22.0.0(transitive)
- Removedrxjs@7.8.1(transitive)
- Removedtslib@2.8.1(transitive)