escalade
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Escalade is a small and fast utility that ascends parent directories. With it, you can scale up the parent directories until you find the item you're searching for. Given an input file or directory, escalade continues executing your callback function until either the callback returns a truthy value, indicating it's located the item, or escalade has reached the system root directory, denoted as '/'. It's important to note that escalade only deals with direct ancestry and doesn't dive into parents' sibling directories.
The usage of Escalade is straightforward and simple, as shown in the following examples. Firstly, you need to install the package in your project using npm package manager like so:
$ npm install --save escalade
After this, you can import and use it in your JavaScript files like so:
import { join } from 'path';
import escalade from 'escalade';
const input = join(__dirname, 'demo.js');
const pkg = await escalade(input, (dir, names) => {
if (names.includes('package.json')) {
return 'package.json';
}
});
console.log(pkg);
In the code above, we're searching for a file named 'package.json' in the parent directories of 'demo.js'. If it's found, the full path of the file is logged to the console. If not, nothing happens.
In "sync" mode, you'll need to import from escalade/sync
, and there's no need for the await
keyword.
The full documentation for Escalade, which includes further usage examples and details about its API, is available directly from the readme content on its GitHub repository. In case of any changes or updates to the package, the GitHub page will be the most up-to-date source of information.