url-or-path
Advanced tools
Comparing version 2.3.0 to 2.3.1
15
index.js
import {fileURLToPath, pathToFileURL} from 'node:url' | ||
/** @typedef {URL | string} UrlOrPath */ | ||
const URL_STRING_PREFIX = 'file:' | ||
/** | ||
@typedef {typeof URL_STRING_PREFIX} UrlStringPrefix | ||
@typedef {`${UrlStringPrefix}${string}`} UrlString | ||
@typedef {URL | UrlString} UrlOrUrlString | ||
@typedef {URL | string} UrlOrPath | ||
*/ | ||
/** @type {(value: unknown) => value is URL} */ | ||
const isUrlInstance = (value) => value instanceof URL | ||
/** @type {(value: unknown) => value is string} */ | ||
/** @type {(value: unknown) => value is UrlString} */ | ||
const isUrlString = (value) => | ||
typeof value === 'string' && value.startsWith('file://') | ||
/** @type {(urlOrPath: unknown) => urlOrPath is UrlOrPath} */ | ||
typeof value === 'string' && value.startsWith(URL_STRING_PREFIX) | ||
/** @type {(urlOrPath: unknown) => urlOrPath is UrlOrUrlString} */ | ||
const isUrl = (urlOrPath) => isUrlInstance(urlOrPath) || isUrlString(urlOrPath) | ||
@@ -12,0 +19,0 @@ |
{ | ||
"name": "url-or-path", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Convert between file URL and path.", | ||
@@ -26,5 +26,5 @@ "homepage": "https://github.com/fisker/url-or-path#readme", | ||
"scripts": { | ||
"build": "run-p build:*", | ||
"build:types": "tsc", | ||
"clean": "run-p clean:*", | ||
"build": "yarn clean && run-p \"build:*\"", | ||
"build:types": "tsc --emitDeclarationOnly --noEmit false", | ||
"clean": "run-p \"clean:*\"", | ||
"clean:dist": "del-cli index.d.ts index.d.ts.map", | ||
@@ -44,5 +44,7 @@ "dist": "run-p dist:*", | ||
"prepare": "husky install", | ||
"release": "run-s format clean build test dist", | ||
"test": "ava", | ||
"test-coverage": "c8 ava" | ||
"release": "run-s format build test dist", | ||
"test": "run-p \"test:*\"", | ||
"test-coverage": "c8 yarn test", | ||
"test:js": "ava", | ||
"test:types": "yarn build && tsd" | ||
}, | ||
@@ -75,2 +77,3 @@ "ava": { | ||
"sort-package-json": "2.6.0", | ||
"tsd": "0.29.0", | ||
"typescript": "5.2.2" | ||
@@ -77,0 +80,0 @@ }, |
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
6964
18
4
45