@waiting/shared-core
Advanced tools
Comparing version 23.21.0 to 23.22.0
export declare const appDir: string; | ||
/** | ||
* Generate __filename for ESM | ||
* @example retrieveFilename(import.meta) | ||
* @link https://nodejs.org/docs/latest/api/esm.html#importmetafilename | ||
*/ | ||
export declare function retrieveFilename(importMeta: ImportMeta): string; | ||
/** | ||
* | ||
* Generate __dirname for ESM | ||
* @example retrieveDirname(import.meta) | ||
* @link https://nodejs.org/docs/latest/api/esm.html#importmetadirname | ||
*/ | ||
export declare function retrieveDirname(importMeta: ImportMeta): string; | ||
export declare function fileShortPath(importUrl: string, separator?: string): string; | ||
@@ -3,0 +16,0 @@ /** |
import { dirname, relative, sep } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
export const appDir = process.cwd(); | ||
/** | ||
* Generate __filename for ESM | ||
* @example retrieveFilename(import.meta) | ||
* @link https://nodejs.org/docs/latest/api/esm.html#importmetafilename | ||
*/ | ||
export function retrieveFilename(importMeta) { | ||
if (typeof importMeta.filename === 'string') { | ||
return importMeta.filename; | ||
} | ||
return genCurrentFilename(importMeta.url); | ||
} | ||
/** | ||
* | ||
* Generate __dirname for ESM | ||
* @example retrieveDirname(import.meta) | ||
* @link https://nodejs.org/docs/latest/api/esm.html#importmetadirname | ||
*/ | ||
export function retrieveDirname(importMeta) { | ||
if (typeof importMeta.dirname === 'string') { | ||
return importMeta.dirname; | ||
} | ||
return genCurrentDirname(importMeta.url); | ||
} | ||
export function fileShortPath(importUrl, separator = '/') { | ||
@@ -5,0 +28,0 @@ let path = relative(appDir, genCurrentFilename(importUrl)); |
{ | ||
"name": "@waiting/shared-core", | ||
"author": "waiting", | ||
"version": "23.21.0", | ||
"version": "23.22.0", | ||
"description": "node core function re export with Promise or Observable", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
"@types/minimist": "^1.2.5", | ||
"@waiting/shared-types": "^23.21.0", | ||
"@waiting/shared-types": "^23.22.0", | ||
"minimist": "^1.2.8", | ||
@@ -84,3 +84,3 @@ "semver": "^7.6.2", | ||
}, | ||
"gitHead": "34e3a649e3ce27f8ceaa681e0a0a0da1c33fd606" | ||
"gitHead": "704e9cc57d1468cd7e094cbf8aa963d88f3ad0bc" | ||
} |
@@ -7,2 +7,28 @@ import { dirname, relative, sep } from 'node:path' | ||
/** | ||
* Generate __filename for ESM | ||
* @example retrieveFilename(import.meta) | ||
* @link https://nodejs.org/docs/latest/api/esm.html#importmetafilename | ||
*/ | ||
export function retrieveFilename(importMeta: ImportMeta): string { | ||
if (typeof importMeta.filename === 'string') { | ||
return importMeta.filename | ||
} | ||
return genCurrentFilename(importMeta.url) | ||
} | ||
/** | ||
* | ||
* Generate __dirname for ESM | ||
* @example retrieveDirname(import.meta) | ||
* @link https://nodejs.org/docs/latest/api/esm.html#importmetadirname | ||
*/ | ||
export function retrieveDirname(importMeta: ImportMeta): string { | ||
if (typeof importMeta.dirname === 'string') { | ||
return importMeta.dirname | ||
} | ||
return genCurrentDirname(importMeta.url) | ||
} | ||
export function fileShortPath(importUrl: string, separator = '/'): string { | ||
@@ -49,7 +75,7 @@ let path = relative(appDir, genCurrentFilename(importUrl)) | ||
interface Formater { | ||
interface Formatter { | ||
value: number | ||
symbol: string | ||
} | ||
const lookup: Formater[] = [ | ||
const lookup: Formatter[] = [ | ||
{ value: 1, symbol: '' }, | ||
@@ -56,0 +82,0 @@ { value: 1e3, symbol: 'k' }, |
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
171325
3439
+ Added@types/node@22.10.0(transitive)
+ Addedundici-types@6.20.0(transitive)
- Removed@types/node@22.9.3(transitive)
- Removedundici-types@6.19.8(transitive)