Socket
Socket
Sign inDemoInstall

to-vfile

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-vfile - npm Package Compare versions

Comparing version 7.1.0 to 7.2.0

71

lib/index.d.ts

@@ -15,23 +15,34 @@ /// <reference types="node" />

export {writeSync}
export function read(
description: Compatible,
options: ReadOptions,
callback: Callback
): void
export function read(description: Compatible, callback: Callback): void
export function read(
description: Compatible,
options?: ReadOptions
): Promise<VFile>
export function write(
description: Compatible,
options: WriteOptions,
callback: Callback
): void
export function write(description: Compatible, callback: Callback): void
export function write(
description: Compatible,
options?: WriteOptions
): Promise<VFile>
export {read}
export {write}
}
/**
* Create a virtual file and read it in, synchronously.
*
* @param {Compatible} description
* @param {ReadOptions} [options]
* @returns {VFile}
*/
export function readSync(description: Compatible, options?: ReadOptions): VFile
/**
* Create a virtual file and write it in, synchronously.
*
* @param {Compatible} description
* @param {WriteOptions} [options]
* @returns {VFile}
*/
export function writeSync(
description: Compatible,
options?: WriteOptions
): VFile
export const read: {
(description: Compatible, options: ReadOptions, callback: Callback): void
(description: Compatible, callback: Callback): void
(description: Compatible, options?: ReadOptions): Promise<VFile>
}
export const write: {
(description: Compatible, options: WriteOptions, callback: Callback): void
(description: Compatible, callback: Callback): void
(description: Compatible, options?: WriteOptions): Promise<VFile>
}
export type Value = import('vfile').VFileValue

@@ -68,22 +79,2 @@ export type Options = import('vfile').VFileOptions

import {VFile} from 'vfile'
/**
* Create a virtual file and read it in, synchronously.
*
* @param {Compatible} description
* @param {ReadOptions} [options]
* @returns {VFile}
*/
declare function readSync(description: Compatible, options?: ReadOptions): VFile
/**
* Create a virtual file and write it in, synchronously.
*
* @param {Compatible} description
* @param {WriteOptions} [options]
* @returns {VFile}
*/
declare function writeSync(
description: Compatible,
options?: WriteOptions
): VFile
import {URL} from 'url'
export {}

@@ -43,8 +43,5 @@ /**

return options instanceof VFile ? options : new VFile(options)
return looksLikeAVFile(options) ? options : new VFile(options)
}
toVFile.readSync = readSync
toVFile.writeSync = writeSync
/**

@@ -57,3 +54,3 @@ * Create a virtual file and read it in, synchronously.

*/
function readSync(description, options) {
export function readSync(description, options) {
var file = toVFile(description)

@@ -71,3 +68,3 @@ file.value = fs.readFileSync(path.resolve(file.cwd, file.path), options)

*/
function writeSync(description, options) {
export function writeSync(description, options) {
var file = toVFile(description)

@@ -78,3 +75,3 @@ fs.writeFileSync(path.resolve(file.cwd, file.path), file.value || '', options)

toVFile.read =
export const read =
/**

@@ -148,3 +145,3 @@ * @type {{

toVFile.write =
export const write =
/**

@@ -216,1 +213,19 @@ * @type {{

)
/**
* @param {Compatible} value
* @returns {value is VFile}
*/
function looksLikeAVFile(value) {
return (
value &&
typeof value === 'object' &&
'message' in value &&
'messages' in value
)
}
toVFile.readSync = readSync
toVFile.writeSync = writeSync
toVFile.read = read
toVFile.write = write
{
"name": "to-vfile",
"version": "7.1.0",
"version": "7.2.0",
"description": "vfile utility to create a vfile from a filepath",

@@ -59,3 +59,3 @@ "license": "MIT",

"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run format && npm run test-coverage"
"test": "npm run build && npm run format && npm run test-coverage"
},

@@ -62,0 +62,0 @@ "prettier": {

@@ -28,8 +28,8 @@ # to-vfile

```js
import {toVFile} from 'to-vfile'
import {toVFile, readSync} from 'to-vfile'
console.log(toVFile('readme.md'))
console.log(toVFile(new URL('./readme.md', import.meta.url)))
console.log(toVFile.readSync('.git/HEAD'))
console.log(toVFile.readSync('.git/HEAD', 'utf8'))
console.log(readSync('.git/HEAD'))
console.log(readSync('.git/HEAD', 'utf8'))
```

@@ -70,3 +70,4 @@

This package exports the following identifiers: `toVFile`.
This package exports the following identifiers: `toVFile`, `read`, `readSync`,
`write`, and `writeSync`.
There is no default export.

@@ -82,3 +83,3 @@

### `toVFile.read(options[, encoding][, callback])`
### `read(options[, encoding][, callback])`

@@ -93,8 +94,8 @@ Creates a virtual file from options (`toVFile(options)`), reads the file from

### `toVFile.readSync(options[, encoding])`
### `readSync(options[, encoding])`
Like `toVFile.read` but synchronous.
Like `read` but synchronous.
Either throws an error or returns a populated virtual file.
### `toVFile.write(options[, fsOptions][, callback])`
### `write(options[, fsOptions][, callback])`

@@ -108,5 +109,5 @@ Creates a virtual file from `options` (`toVFile(options)`), writes the file to

### `toVFile.writeSync(options[, fsOptions])`
### `writeSync(options[, fsOptions])`
Like `toVFile.write` but synchronous.
Like `write` but synchronous.
Either throws an error or returns a populated virtual file.

@@ -113,0 +114,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc