UNPKG

@jsenv/util

Version:

Set of functions often needed when using Node.js.

10 lines (8 loc) 298 B
import { pathToFileURL } from "url" import { isFileSystemPath } from "./isFileSystemPath.js" export const fileSystemPathToUrl = (value) => { if (!isFileSystemPath(value)) { throw new Error(`received an invalid value for fileSystemPath: ${value}`) } return String(pathToFileURL(value)) }