@waiting/shared-core
Advanced tools
Comparing version 21.4.2 to 21.5.0
export declare const appDir: string; | ||
export declare function fileShortPath(importUrl: string): string; | ||
export declare function fileShortPath(importUrl: string, separator?: string): string; | ||
/** | ||
* generate __filename for ESM | ||
* Generate __filename for ESM | ||
* @param inputUrl import.meta.url | ||
*/ | ||
export declare function genCurrentFilename(inputUrl: string): string; | ||
export declare function genCurrentFilename(inputUrl: string, separator?: string): string; | ||
/** | ||
* generate __dirname for ESM | ||
* Generate __dirname for ESM | ||
* @param inputUrl import.meta.url | ||
*/ | ||
export declare function genCurrentDirname(inputUrl: string): string; | ||
export declare function genCurrentDirname(inputUrl: string, separator?: string): string; | ||
/** Set loading path for node-ffi linking dll */ | ||
@@ -19,3 +19,3 @@ export declare function setPathDirectory(path: string): void; | ||
*/ | ||
export declare function nFormatter(positiveNum: number, digits?: number, sep?: string): string; | ||
export declare function nFormatter(positiveNum: number, digits?: number, separator?: string): string; | ||
//# sourceMappingURL=helper.d.ts.map |
@@ -1,22 +0,32 @@ | ||
import { join, relative } from 'node:path'; | ||
import { dirname, relative, sep } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
export const appDir = process.cwd(); | ||
export function fileShortPath(importUrl) { | ||
const path = relative(appDir, genCurrentFilename(importUrl)).replace(/\\/ug, '/'); | ||
export function fileShortPath(importUrl, separator = '/') { | ||
let path = relative(appDir, genCurrentFilename(importUrl)); | ||
if (separator && separator !== sep) { | ||
path = path.replaceAll(sep, separator); | ||
} | ||
return path; | ||
} | ||
/** | ||
* generate __filename for ESM | ||
* Generate __filename for ESM | ||
* @param inputUrl import.meta.url | ||
*/ | ||
export function genCurrentFilename(inputUrl) { | ||
return fileURLToPath(inputUrl).replace(/\\/ug, '/'); | ||
export function genCurrentFilename(inputUrl, separator = '/') { | ||
let path = fileURLToPath(inputUrl); | ||
if (separator && separator !== sep) { | ||
path = path.replaceAll(sep, separator); | ||
} | ||
return path; | ||
} | ||
/** | ||
* generate __dirname for ESM | ||
* Generate __dirname for ESM | ||
* @param inputUrl import.meta.url | ||
*/ | ||
export function genCurrentDirname(inputUrl) { | ||
const __filename = genCurrentFilename(inputUrl); | ||
const dir = join(__filename, '..').replace(/\\/ug, '/'); | ||
export function genCurrentDirname(inputUrl, separator = '/') { | ||
const __filename = genCurrentFilename(inputUrl, sep); | ||
let dir = dirname(__filename); | ||
if (separator && separator !== sep) { | ||
dir = dir.replaceAll(sep, separator); | ||
} | ||
return dir; | ||
@@ -44,3 +54,3 @@ } | ||
*/ | ||
export function nFormatter(positiveNum, digits = 2, sep = '') { | ||
export function nFormatter(positiveNum, digits = 2, separator = '') { | ||
if (positiveNum <= 0) { | ||
@@ -56,5 +66,5 @@ return positiveNum.toString(); | ||
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/u; | ||
const ret = (positiveNum / item.value).toFixed(digits).replace(rx, '$1') + sep + item.symbol; | ||
const ret = (positiveNum / item.value).toFixed(digits).replace(rx, '$1') + separator + item.symbol; | ||
return ret; | ||
} | ||
//# sourceMappingURL=helper.js.map |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "21.4.2", | ||
"version": "21.5.0", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -31,3 +31,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@waiting/shared-types": "^21.4.2", | ||
"@waiting/shared-types": "^21.5.0", | ||
"minimist": "^1.2.8", | ||
@@ -72,4 +72,2 @@ "rxjs": "^7.8.0", | ||
"rp": "rollup -c rollup.config.js --context this", | ||
"pretest": "npm run build", | ||
"pretest:local": "npm run build", | ||
"test": "cross-env TS_NODE_PROJECT=test/tsconfig.json mocha", | ||
@@ -79,3 +77,3 @@ "test:local": "cross-env TS_NODE_PROJECT=test/tsconfig.json ../../node_modules/.bin/mocha", | ||
}, | ||
"gitHead": "aef3706822fb6420023d0ce193f9943c472b38dd" | ||
"gitHead": "a0e4831705a6ded574191b53759237867d2b9d14" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { join, relative } from 'node:path' | ||
import { dirname, relative, sep } from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
@@ -7,4 +7,7 @@ | ||
export function fileShortPath(importUrl: string): string { | ||
const path = relative(appDir, genCurrentFilename(importUrl)).replace(/\\/ug, '/') | ||
export function fileShortPath(importUrl: string, separator = '/'): string { | ||
let path = relative(appDir, genCurrentFilename(importUrl)) | ||
if (separator && separator !== sep) { | ||
path = path.replaceAll(sep, separator) | ||
} | ||
return path | ||
@@ -14,15 +17,22 @@ } | ||
/** | ||
* generate __filename for ESM | ||
* Generate __filename for ESM | ||
* @param inputUrl import.meta.url | ||
*/ | ||
export function genCurrentFilename(inputUrl: string): string { | ||
return fileURLToPath(inputUrl).replace(/\\/ug, '/') | ||
export function genCurrentFilename(inputUrl: string, separator = '/'): string { | ||
let path = fileURLToPath(inputUrl) | ||
if (separator && separator !== sep) { | ||
path = path.replaceAll(sep, separator) | ||
} | ||
return path | ||
} | ||
/** | ||
* generate __dirname for ESM | ||
* Generate __dirname for ESM | ||
* @param inputUrl import.meta.url | ||
*/ | ||
export function genCurrentDirname(inputUrl: string): string { | ||
const __filename = genCurrentFilename(inputUrl) | ||
const dir = join(__filename, '..').replace(/\\/ug, '/') | ||
export function genCurrentDirname(inputUrl: string, separator = '/'): string { | ||
const __filename = genCurrentFilename(inputUrl, sep) | ||
let dir = dirname(__filename) | ||
if (separator && separator !== sep) { | ||
dir = dir.replaceAll(sep, separator) | ||
} | ||
return dir | ||
@@ -57,3 +67,3 @@ } | ||
*/ | ||
export function nFormatter(positiveNum: number, digits = 2, sep = ''): string { | ||
export function nFormatter(positiveNum: number, digits = 2, separator = ''): string { | ||
if (positiveNum <= 0) { | ||
@@ -70,4 +80,4 @@ return positiveNum.toString() | ||
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/u | ||
const ret = (positiveNum / item.value).toFixed(digits).replace(rx, '$1') + sep + item.symbol | ||
const ret = (positiveNum / item.value).toFixed(digits).replace(rx, '$1') + separator + item.symbol | ||
return ret | ||
} |
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
208688
3813
+ Added@types/node@18.19.65(transitive)
+ Addedyaml@2.6.1(transitive)
- Removed@types/node@18.19.64(transitive)
- Removedyaml@2.6.0(transitive)