Comparing version 7.0.0 to 7.1.0
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
/** | ||
@@ -60,3 +61,3 @@ * Create a virtual file from a description. | ||
*/ | ||
export type Compatible = Path | Options | VFile | ||
export type Compatible = Path | URL | Options | VFile | ||
export type Callback = ( | ||
@@ -86,2 +87,3 @@ error: NodeJS.ErrnoException | null, | ||
): VFile | ||
import {URL} from 'url' | ||
export {} |
@@ -11,3 +11,3 @@ /** | ||
* @typedef {string|Uint8Array} Path Path of the file. | ||
* @typedef {Path|Options|VFile} Compatible Things that can be | ||
* @typedef {Path|URL|Options|VFile} Compatible Things that can be | ||
* passed to the function. | ||
@@ -24,2 +24,3 @@ */ | ||
import path from 'path' | ||
import {URL, fileURLToPath} from 'url' | ||
import buffer from 'is-buffer' | ||
@@ -40,2 +41,4 @@ import {VFile} from 'vfile' | ||
options = {path: String(options)} | ||
} else if (options instanceof URL) { | ||
options = {path: fileURLToPath(options)} | ||
} | ||
@@ -42,0 +45,0 @@ |
{ | ||
"name": "to-vfile", | ||
"version": "7.0.0", | ||
"version": "7.1.0", | ||
"description": "vfile utility to create a vfile from a filepath", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -31,2 +31,3 @@ # to-vfile | ||
console.log(toVFile('readme.md')) | ||
console.log(toVFile(new URL('./readme.md', import.meta.url))) | ||
console.log(toVFile.readSync('.git/HEAD')) | ||
@@ -48,2 +49,8 @@ console.log(toVFile.readSync('.git/HEAD', 'utf8')) | ||
messages: [], | ||
history: ['readme.md'], | ||
cwd: '/Users/tilde/projects/oss/to-vfile' | ||
} | ||
VFile { | ||
data: {}, | ||
messages: [], | ||
history: ['.git/HEAD'], | ||
@@ -72,3 +79,4 @@ cwd: '/Users/tilde/projects/oss/to-vfile', | ||
`Buffer`, in which case it’s treated as `{path: options}` instead of | ||
`{value: options}`. | ||
`{value: options}`, or when `options` is a WHATWG `URL` object, in which case | ||
it’s treated as `{path: fileURLToPath(options)}`. | ||
@@ -75,0 +83,0 @@ ### `toVFile.read(options[, encoding][, callback])` |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
16060
288
164
0