vfile-find-up
Advanced tools
Comparing version 6.1.0 to 7.0.0
export type Assert = import('./lib/index.js').Assert | ||
export type Callback = import('./lib/index.js').Callback | ||
export type CallbackOne = import('./lib/index.js').CallbackOne | ||
export type CallbackAll = import('./lib/index.js').CallbackAll | ||
export type Result = import('./lib/index.js').Result | ||
export type Test = import('./lib/index.js').Test | ||
export {BREAK, INCLUDE, findUp, findUpOne} from './lib/index.js' | ||
export {findUp, findUpAll} from './lib/index.js' |
/** | ||
* @typedef {import('./lib/index.js').Assert} Assert | ||
* @typedef {import('./lib/index.js').Callback} Callback | ||
* @typedef {import('./lib/index.js').CallbackOne} CallbackOne | ||
* @typedef {import('./lib/index.js').CallbackAll} CallbackAll | ||
* @typedef {import('./lib/index.js').Result} Result | ||
* @typedef {import('./lib/index.js').Test} Test | ||
*/ | ||
export {BREAK, INCLUDE, findUp, findUpOne} from './lib/index.js' | ||
export {findUp, findUpAll} from './lib/index.js' |
@@ -1,66 +0,52 @@ | ||
/** | ||
* Include this file. | ||
*/ | ||
export const INCLUDE: 1 | ||
/** | ||
* Stop searching. | ||
*/ | ||
export const BREAK: 4 | ||
/** | ||
* Find files or folders upwards. | ||
* | ||
* > 👉 **Note**: files are not read (their `value` is not populated). | ||
* | ||
* @param test | ||
* Things to search for. | ||
* @param path | ||
* Place to search from. | ||
* @param callback | ||
* Callback called when done. | ||
* @returns | ||
* Nothing when `callback` is given, otherwise a promise that resolves to | ||
* files. | ||
*/ | ||
export const findUp: (( | ||
export function findUp( | ||
test: Test, | ||
path: string | null | undefined, | ||
callback: Callback | ||
) => void) & | ||
((test: Test, callback: Callback) => void) & | ||
((test: Test, path?: string | null | undefined) => Promise<Array<VFile>>) | ||
/** | ||
* Find the first file or folder upwards. | ||
* | ||
* > 👉 **Note**: files are not read (their `value` is not populated). | ||
* | ||
* @param test | ||
* Things to search for. | ||
* @param path | ||
* Place to search from. | ||
* @param callback | ||
* Callback called when done. | ||
* @returns | ||
* Nothing when `callback` is given, otherwise a promise that resolves to | ||
* a file or `null`. | ||
*/ | ||
export const findUpOne: (( | ||
): undefined | ||
export function findUp(test: Test, callback: Callback): undefined | ||
export function findUp( | ||
test: Test, | ||
path?: string | null | undefined | ||
): Promise<VFile | undefined> | ||
export function findUpAll( | ||
test: Test, | ||
path: string | null | undefined, | ||
callback: CallbackOne | ||
) => void) & | ||
((test: Test, callback: CallbackOne) => void) & | ||
((test: Test, path?: string | null | undefined) => Promise<VFile | null>) | ||
export type VFile = import('vfile').VFile | ||
callback: CallbackAll | ||
): undefined | ||
export function findUpAll(test: Test, callback: CallbackAll): undefined | ||
export function findUpAll( | ||
test: Test, | ||
path?: string | null | undefined | ||
): Promise<Array<VFile>> | ||
/** | ||
* Handle a file. | ||
*/ | ||
export type Assert = (file: VFile) => boolean | null | number | undefined | void | ||
export type Assert = (file: VFile) => Result | undefined | ||
/** | ||
* Callback called when done finding one file. | ||
*/ | ||
export type Callback = ( | ||
error: Error | undefined, | ||
file?: VFile | undefined | ||
) => undefined | ||
/** | ||
* Callback called when done. | ||
*/ | ||
export type Callback = (error: Error | null, files: Array<VFile>) => void | ||
export type CallbackAll = ( | ||
error: Error | undefined, | ||
files?: Array<VFile> | undefined | ||
) => undefined | ||
/** | ||
* Callback called when done finding one file. | ||
* What to do when collecting a file or folder. | ||
*/ | ||
export type CallbackOne = (error: Error | null, file: VFile | null) => void | ||
export type Result = { | ||
/** | ||
* Stop searching after this file or folder. | ||
*/ | ||
break?: boolean | null | undefined | ||
/** | ||
* Include this file or folder. | ||
*/ | ||
include?: boolean | null | undefined | ||
} | ||
/** | ||
@@ -73,1 +59,2 @@ * Things to search for. | ||
export type Test = Array<Assert | string> | Assert | string | ||
import {VFile} from 'vfile' |
378
lib/index.js
/** | ||
* @typedef {import('vfile').VFile} VFile | ||
*/ | ||
/** | ||
* @callback Assert | ||
@@ -10,3 +6,3 @@ * Handle a file. | ||
* File to handle. | ||
* @returns {boolean | null | number | undefined | void} | ||
* @returns {Result | undefined} | ||
* How to handle this file. | ||
@@ -17,23 +13,30 @@ * | ||
* @callback Callback | ||
* Callback called when done finding one file. | ||
* @param {Error | undefined} error | ||
* Error. | ||
* | ||
* > 👉 **Note**: Errors are currently never passed | ||
* @param {VFile | undefined} [file] | ||
* File. | ||
* @returns {undefined} | ||
* Nothing. | ||
* | ||
* @callback CallbackAll | ||
* Callback called when done. | ||
* @param {Error | null} error | ||
* @param {Error | undefined} error | ||
* Error. | ||
* | ||
* > 👉 **Note**: Errors are currently never passed. | ||
* @param {Array<VFile>} files | ||
* @param {Array<VFile> | undefined} [files] | ||
* Files. | ||
* @returns {void} | ||
* @returns {undefined} | ||
* Nothing. | ||
* | ||
* @callback CallbackOne | ||
* Callback called when done finding one file. | ||
* @param {Error | null} error | ||
* Error. | ||
* @typedef Result | ||
* What to do when collecting a file or folder. | ||
* @property {boolean | null | undefined} [break] | ||
* Stop searching after this file or folder. | ||
* @property {boolean | null | undefined} [include] | ||
* Include this file or folder. | ||
* | ||
* > 👉 **Note**: Errors are currently never passed | ||
* @param {VFile | null} file | ||
* File. | ||
* @returns {void} | ||
* Nothing. | ||
* | ||
* @typedef {Array<Assert | string> | Assert | string} Test | ||
@@ -51,17 +54,65 @@ * Things to search for. | ||
import process from 'node:process' | ||
import {toVFile} from 'to-vfile' | ||
import {VFile} from 'vfile' | ||
// To do: use `URL`? | ||
// To do: next major: rename to `findUpAll`? | ||
/** | ||
* Include this file. | ||
*/ | ||
export const INCLUDE = 1 | ||
const include = /** @type {const} */ ({include: true}) | ||
/** | ||
* Stop searching. | ||
* Find the first file or folder upwards. | ||
* | ||
* > 👉 **Note**: files are not read (their `value` is not populated). | ||
* > use `to-vfile` for that. | ||
* | ||
* @overload | ||
* @param {Test} test | ||
* @param {string | null | undefined} path | ||
* @param {Callback} callback | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {Test} test | ||
* @param {Callback} callback | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {Test} test | ||
* @param {string | null | undefined} [path] | ||
* @returns {Promise<VFile | undefined>} | ||
* | ||
* @param {Test} test | ||
* Things to search for. | ||
* @param {Callback | string | null | undefined} [path] | ||
* Place to search from (default: `process.cwd()`). | ||
* @param {Callback | null | undefined} [callback] | ||
* Callback called when done (default: `undefined`). | ||
* @returns {Promise<VFile | undefined> | undefined} | ||
* Nothing when `callback` is given, otherwise a promise that resolves to | ||
* a file or `undefined`. | ||
*/ | ||
export const BREAK = 4 | ||
export function findUp(test, path, callback) { | ||
/** @type {Callback | null | undefined} */ | ||
let callbackOne | ||
/** @type {Promise<Array<VFile>>} */ | ||
let promise | ||
if (typeof path === 'function') { | ||
callbackOne = path | ||
promise = find(test, undefined, true) | ||
} else { | ||
callbackOne = callback | ||
promise = find(test, path || undefined, true) | ||
} | ||
if (!callbackOne) { | ||
return promise.then(pickFirst) | ||
} | ||
promise.then(function (files) { | ||
// @ts-expect-error: `callbackOne` is defined. | ||
callbackOne(undefined, pickFirst(files)) | ||
return files | ||
}, callbackOne) | ||
} | ||
/** | ||
@@ -71,103 +122,120 @@ * Find files or folders upwards. | ||
* > 👉 **Note**: files are not read (their `value` is not populated). | ||
* > use `to-vfile` for that. | ||
* | ||
* @param test | ||
* @overload | ||
* @param {Test} test | ||
* @param {string | null | undefined} path | ||
* @param {CallbackAll} callback | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {Test} test | ||
* @param {CallbackAll} callback | ||
* @returns {undefined} | ||
* | ||
* @overload | ||
* @param {Test} test | ||
* @param {string | null | undefined} [path] | ||
* @returns {Promise<Array<VFile>>} | ||
* | ||
* @param {Test} test | ||
* Things to search for. | ||
* @param path | ||
* Place to search from. | ||
* @param callback | ||
* Callback called when done. | ||
* @returns | ||
* @param {CallbackAll | string | null | undefined} [path] | ||
* Place to search from (default: `process.cwd()`). | ||
* @param {CallbackAll | null | undefined} [callback] | ||
* Callback called when done (default: `undefined`). | ||
* @returns {Promise<Array<VFile>> | undefined} | ||
* Nothing when `callback` is given, otherwise a promise that resolves to | ||
* files. | ||
*/ | ||
export const findUp = | ||
/** | ||
* @type {( | ||
* ((test: Test, path: string | null | undefined, callback: Callback) => void) & | ||
* ((test: Test, callback: Callback) => void) & | ||
* ((test: Test, path?: string | null | undefined) => Promise<Array<VFile>>) | ||
* )} | ||
*/ | ||
( | ||
/** | ||
* @param {Test} test | ||
* @param {Callback | string | null | undefined} [path] | ||
* @param {Callback | null | undefined} [callback] | ||
* @returns {Promise<Array<VFile>> | undefined} | ||
*/ | ||
function (test, path, callback) { | ||
/** @type {Callback | null | undefined} */ | ||
let callbackAll | ||
/** @type {Promise<Array<VFile>>} */ | ||
let promise | ||
export function findUpAll(test, path, callback) { | ||
/** @type {CallbackAll | null | undefined} */ | ||
let callbackAll | ||
/** @type {Promise<Array<VFile>>} */ | ||
let promise | ||
if (typeof path === 'function') { | ||
callbackAll = path | ||
promise = find(test, undefined, false) | ||
} else { | ||
callbackAll = callback | ||
promise = find(test, path || undefined, false) | ||
} | ||
if (typeof path === 'function') { | ||
callbackAll = path | ||
promise = find(test, undefined, false) | ||
} else { | ||
callbackAll = callback | ||
promise = find(test, path || undefined, false) | ||
} | ||
if (!callbackAll) { | ||
return promise | ||
} | ||
if (!callbackAll) { | ||
return promise | ||
} | ||
// @ts-expect-error: `callbackAll` is defined. | ||
promise.then((files) => callbackAll(null, files), callbackAll) | ||
} | ||
) | ||
promise.then(function (files) { | ||
// @ts-expect-error: `callbackAll` is defined. | ||
callbackAll(undefined, files) | ||
return files | ||
}, callbackAll) | ||
} | ||
/** | ||
* Find the first file or folder upwards. | ||
* Convert `test` | ||
* | ||
* > 👉 **Note**: files are not read (their `value` is not populated). | ||
* @param {Test} test | ||
* Test. | ||
* @returns {Assert} | ||
* Assert. | ||
*/ | ||
function convert(test) { | ||
return typeof test === 'function' | ||
? test | ||
: typeof test === 'string' | ||
? convertString(test) | ||
: convertTests(test) | ||
} | ||
/** | ||
* Wrap a string given as a test. | ||
* | ||
* @param test | ||
* Things to search for. | ||
* @param path | ||
* Place to search from. | ||
* @param callback | ||
* Callback called when done. | ||
* @returns | ||
* Nothing when `callback` is given, otherwise a promise that resolves to | ||
* a file or `null`. | ||
* @param {string} test | ||
* Basename or extname. | ||
* @returns {Assert} | ||
* Assert. | ||
*/ | ||
export const findUpOne = | ||
/** | ||
* @type {( | ||
* ((test: Test, path: string | null | undefined, callback: CallbackOne) => void) & | ||
* ((test: Test, callback: CallbackOne) => void) & | ||
* ((test: Test, path?: string | null | undefined) => Promise<VFile | null>) | ||
* )} | ||
*/ | ||
( | ||
/** | ||
* @param {Test} test | ||
* @param {CallbackOne | string | null | undefined} [path] | ||
* @param {CallbackOne | null | undefined} [callback] | ||
* @returns {Promise<VFile | null> | undefined} | ||
*/ | ||
function (test, path, callback) { | ||
/** @type {CallbackOne | null | undefined} */ | ||
let callbackOne | ||
/** @type {Promise<Array<VFile>>} */ | ||
let promise | ||
function convertString(test) { | ||
return check | ||
if (typeof path === 'function') { | ||
callbackOne = path | ||
promise = find(test, undefined, true) | ||
} else { | ||
callbackOne = callback | ||
promise = find(test, path || undefined, true) | ||
} | ||
/** @type {Assert} */ | ||
function check(file) { | ||
return test === file.basename || test === file.extname ? include : undefined | ||
} | ||
} | ||
if (!callbackOne) { | ||
return promise.then(one) | ||
/** | ||
* Check multiple tests. | ||
* | ||
* @param {Array<Assert | string>} test | ||
* Tests. | ||
* @returns {Assert} | ||
* Assert. | ||
*/ | ||
function convertTests(test) { | ||
/** @type {Array<Assert>} */ | ||
const tests = [] | ||
let index = -1 | ||
while (++index < test.length) { | ||
tests[index] = convert(test[index]) | ||
} | ||
return assert | ||
/** @type {Assert} */ | ||
function assert(file) { | ||
let index = -1 | ||
while (++index < tests.length) { | ||
const result = tests[index](file) | ||
if (result) { | ||
return result | ||
} | ||
// @ts-expect-error: `callbackOne` is defined. | ||
promise.then((files) => callbackOne(null, one(files)), callbackOne) | ||
} | ||
) | ||
} | ||
} | ||
@@ -193,6 +261,10 @@ /** | ||
// @ts-expect-error: `undefined` is fine instead of `void`. | ||
return new Promise(executor) | ||
/** | ||
* @param {(files: Array<VFile>) => void} resolve | ||
* @param {(files: Array<VFile>) => undefined} resolve | ||
* Resolve callback. | ||
* @returns {undefined} | ||
* Nothing. | ||
*/ | ||
@@ -209,6 +281,6 @@ function executor(resolve) { | ||
function handle(filePath) { | ||
const file = toVFile(filePath) | ||
const result = Number(assert(file)) | ||
const file = new VFile({path: filePath}) | ||
const result = assert(file) | ||
if ((result & INCLUDE) === INCLUDE) { | ||
if (result && result.include) { | ||
if (one) { | ||
@@ -222,3 +294,3 @@ resolve([file]) | ||
if ((result & BREAK) === BREAK) { | ||
if (result && result.break) { | ||
resolve(one ? [] : results) | ||
@@ -233,3 +305,3 @@ return true | ||
* @param {string} child | ||
* @returns {void} | ||
* @returns {undefined} | ||
*/ | ||
@@ -274,69 +346,13 @@ function once(child) { | ||
/** | ||
* Convert `test` | ||
* Get the first item. | ||
* | ||
* @param {Test} test | ||
* @returns {Assert} | ||
* @template {unknown} T | ||
* Kind. | ||
* @param {Array<T>} values | ||
* List. | ||
* @returns {T | undefined} | ||
* Head. | ||
*/ | ||
function convert(test) { | ||
return typeof test === 'function' | ||
? test | ||
: typeof test === 'string' | ||
? testString(test) | ||
: multiple(test) | ||
function pickFirst(values) { | ||
return values[0] | ||
} | ||
/** | ||
* Check multiple tests. | ||
* | ||
* @param {Array<string|Assert>} test | ||
* @returns {Assert} | ||
*/ | ||
function multiple(test) { | ||
/** @type {Array<Assert>} */ | ||
const tests = [] | ||
let index = -1 | ||
while (++index < test.length) { | ||
tests[index] = convert(test[index]) | ||
} | ||
return check | ||
/** @type {Assert} */ | ||
function check(file) { | ||
let index = -1 | ||
while (++index < tests.length) { | ||
const result = tests[index](file) | ||
if (result) { | ||
return result | ||
} | ||
} | ||
return false | ||
} | ||
} | ||
/** | ||
* Wrap a string given as a test. | ||
* | ||
* @param {string} test | ||
* @returns {Assert} | ||
*/ | ||
function testString(test) { | ||
return check | ||
/** @type {Assert} */ | ||
function check(file) { | ||
return test === file.basename || test === file.extname | ||
} | ||
} | ||
/** | ||
* @param {Array<VFile>} files | ||
* @returns {VFile | null} | ||
*/ | ||
function one(files) { | ||
return files[0] || null | ||
} |
{ | ||
"name": "vfile-find-up", | ||
"version": "6.1.0", | ||
"version": "7.0.0", | ||
"description": "vfile utility to find one or more files by searching the file system upwards", | ||
@@ -30,4 +30,3 @@ "license": "MIT", | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"exports": "./index.js", | ||
"files": [ | ||
@@ -39,8 +38,7 @@ "lib/", | ||
"dependencies": { | ||
"to-vfile": "^7.0.0", | ||
"vfile": "^5.0.0" | ||
"vfile": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^18.0.0", | ||
"c8": "^7.0.0", | ||
"@types/node": "^20.0.0", | ||
"c8": "^8.0.0", | ||
"prettier": "^2.0.0", | ||
@@ -50,4 +48,4 @@ "remark-cli": "^11.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.53.0" | ||
"typescript": "^5.0.0", | ||
"xo": "^0.54.0" | ||
}, | ||
@@ -59,22 +57,16 @@ "scripts": { | ||
"test-api": "node --conditions development test/index.js", | ||
"test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api", | ||
"test-coverage": "c8 --100 --reporter lcov npm run test-api", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "none", | ||
"useTabs": false | ||
}, | ||
"xo": { | ||
"prettier": true, | ||
"rules": { | ||
"no-bitwise": "off" | ||
} | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
"remark-preset-wooorm" | ||
] | ||
@@ -85,4 +77,8 @@ }, | ||
"detail": true, | ||
"ignoreCatch": true, | ||
"strict": true | ||
}, | ||
"xo": { | ||
"prettier": true | ||
} | ||
} |
130
readme.md
@@ -19,9 +19,8 @@ # vfile-find-up | ||
* [API](#api) | ||
* [`findUp(tests[, path][, callback])`](#finduptests-path-callback) | ||
* [`findUpOne(test[, path][, callback])`](#finduponetest-path-callback) | ||
* [`BREAK`](#break) | ||
* [`INCLUDE`](#include) | ||
* [`findUp(test[, path][, callback])`](#finduptest-path-callback) | ||
* [`findUpAll(test[, path][, callback])`](#findupalltest-path-callback) | ||
* [`Assert`](#assert) | ||
* [`Callback`](#callback) | ||
* [`CallbackOne`](#callbackone) | ||
* [`CallbackAll`](#callbackall) | ||
* [`Result`](#result) | ||
* [`Test`](#test) | ||
@@ -46,3 +45,3 @@ * [Types](#types) | ||
This package is [ESM only][esm]. | ||
In Node.js (version 14.14+ and 16.0+), install with [npm][]: | ||
In Node.js (version 16+), install with [npm][]: | ||
@@ -64,7 +63,8 @@ ```sh | ||
```js | ||
[ VFile { | ||
VFile { | ||
cwd: '/Users/tilde/Projects/oss/vfile-find-up', | ||
data: {}, | ||
messages: [], | ||
history: [ '/Users/tilde/projects/oss/vfile-find-up/package.json' ], | ||
cwd: '/Users/tilde/projects/oss/vfile-find-up' } ] | ||
history: [ '/Users/tilde/Projects/oss/vfile-find-up/package.json' ], | ||
messages: [] | ||
} | ||
``` | ||
@@ -74,19 +74,17 @@ | ||
This package exports the identifiers | ||
[`BREAK`][api-break], | ||
[`INCLUDE`][api-include], | ||
[`findUp`][api-find-up], and | ||
[`findUpOne`][api-find-up-one]. | ||
This package exports the identifiers [`findUp`][api-find-up] and | ||
[`findUpAll`][api-find-up-all]. | ||
There is no default export. | ||
### `findUp(tests[, path][, callback])` | ||
### `findUp(test[, path][, callback])` | ||
Find files or folders upwards. | ||
Find the first file or folder upwards. | ||
> 👉 **Note**: files are not read (their `value` is not populated). | ||
> use [`to-vfile`][to-vfile] for that. | ||
###### Signatures | ||
* `(test[, path], callback) => void` | ||
* `(test[, path]) => Promise<Array<VFile>>` | ||
* `(test[, path], callback) => undefined` | ||
* `(test[, path]) => Promise<VFile>` | ||
@@ -97,3 +95,3 @@ ###### Parameters | ||
— things to search for | ||
* `paths` (`string`, default: `process.cwd()`) | ||
* `path` (`string`, default: `process.cwd()`) | ||
— place to search from | ||
@@ -105,15 +103,16 @@ * `callback` ([`Callback`][api-callback], optional) | ||
Nothing when `callback` is given (`void`), otherwise a promise that resolves to | ||
files ([`Array<VFile>`][vfile]). | ||
Nothing when `callback` is given (`undefined`), otherwise a promise that | ||
resolves to a file ([`VFile | undefined`][vfile]). | ||
### `findUpOne(test[, path][, callback])` | ||
### `findUpAll(test[, path][, callback])` | ||
Find the first file or folder upwards. | ||
Find files or folders upwards. | ||
> 👉 **Note**: files are not read (their `value` is not populated). | ||
> use [`to-vfile`][to-vfile] for that. | ||
###### Signatures | ||
* `(test[, path], callback) => void` | ||
* `(test[, path]) => Promise<VFile>` | ||
* `(test[, path], callback) => undefined` | ||
* `(test[, path]) => Promise<Array<VFile>>` | ||
@@ -124,5 +123,5 @@ ###### Parameters | ||
— things to search for | ||
* `path` (`string`, default: `process.cwd()`) | ||
* `paths` (`string`, default: `process.cwd()`) | ||
— place to search from | ||
* `callback` ([`CallbackOne`][api-callback-one], optional) | ||
* `callback` ([`CallbackAll`][api-callback-all], optional) | ||
— callback called when done | ||
@@ -132,13 +131,5 @@ | ||
Nothing when `callback` is given (`void`), otherwise a promise that resolves to | ||
a file ([`VFile | null`][vfile]). | ||
Nothing when `callback` is given (`undefined`), otherwise a promise that | ||
resolves to files ([`Array<VFile>`][vfile]). | ||
### `BREAK` | ||
Stop searching (`number`). | ||
### `INCLUDE` | ||
Include this file (`number`). | ||
### `Assert` | ||
@@ -155,36 +146,45 @@ | ||
How to handle this file (`boolean | number`, optional). | ||
How to handle this file ([`Result`][api-result], optional). | ||
`true` is treated as `INCLUDE`. | ||
### `Callback` | ||
Callback called when done (TypeScript type). | ||
Callback called when done finding one file (TypeScript type). | ||
###### Parameters | ||
* `error` (`Error | null`) | ||
* `error` (`Error | undefined`) | ||
— error; errors are currently never passed | ||
* `files` ([`Array<VFile>`][vfile]) | ||
— files | ||
* `file` ([`VFile | undefined`][vfile]) | ||
— file | ||
###### Returns | ||
Nothing (`void`). | ||
Nothing (`undefined`). | ||
### `CallbackOne` | ||
### `CallbackAll` | ||
Callback called when done finding one file (TypeScript type). | ||
Callback called when done (TypeScript type). | ||
###### Parameters | ||
* `error` (`Error | null`) | ||
* `error` (`Error | undefined`) | ||
— error; errors are currently never passed | ||
* `file` ([`VFile | null`][vfile]) | ||
— file | ||
* `files` ([`Array<VFile>`][vfile]) | ||
— files | ||
###### Returns | ||
Nothing (`void`). | ||
Nothing (`undefined`). | ||
### `Result` | ||
What to do when collecting a file or folder (TypeScript type). | ||
###### Fields | ||
* `break` (`boolean`, default: `false`) | ||
— stop searching after this file or folder | ||
* `include` (`boolean`, default: `false`) | ||
— include this file or folder | ||
### `Test` | ||
@@ -209,3 +209,4 @@ | ||
[`Callback`][api-callback], | ||
[`CallbackOne`][api-callback-one], and | ||
[`CallbackAll`][api-callback-all], | ||
[`Result`][api-result], and | ||
[`Test`][api-test]. | ||
@@ -215,7 +216,10 @@ | ||
Projects maintained by the unified collective are compatible with all maintained | ||
Projects maintained by the unified collective are compatible with maintained | ||
versions of Node.js. | ||
As of now, that is Node.js 14.14+ and 16.0+. | ||
Our projects sometimes work with older versions, but this is not guaranteed. | ||
When we cut a new major release, we drop support for unmaintained versions of | ||
Node. | ||
This means we try to keep the current release line, `vfile-find-up@^7`, | ||
compatible with Node.js 16. | ||
## Contribute | ||
@@ -279,12 +283,10 @@ | ||
[to-vfile]: https://github.com/vfile/to-vfile | ||
[vfile-find-down]: https://github.com/vfile/vfile-find-down | ||
[api-break]: #break | ||
[api-find-up]: #finduptest-path-callback | ||
[api-include]: #include | ||
[api-find-up-all]: #findupalltest-path-callback | ||
[api-find-up]: #finduptests-path-callback | ||
[api-find-up-one]: #finduponetest-path-callback | ||
[api-assert]: #assert | ||
@@ -294,4 +296,6 @@ | ||
[api-callback-one]: #callbackone | ||
[api-callback-all]: #callbackall | ||
[api-result]: #result | ||
[api-test]: #test |
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
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
19727
1
385
289
+ Added@types/unist@3.0.3(transitive)
+ Addedunist-util-stringify-position@4.0.0(transitive)
+ Addedvfile@6.0.3(transitive)
+ Addedvfile-message@4.0.2(transitive)
- Removedto-vfile@^7.0.0
- Removed@types/unist@2.0.11(transitive)
- Removedis-buffer@2.0.5(transitive)
- Removedto-vfile@7.2.4(transitive)
- Removedunist-util-stringify-position@3.0.3(transitive)
- Removedvfile@5.3.7(transitive)
- Removedvfile-message@3.1.4(transitive)
Updatedvfile@^6.0.0