Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

escalade 3.1.2

A tiny (183B to 210B) and fast utility to ascend parent directories
Package summary
Share
0
issues
0
licenses
Package created
19 Jun 2020
Version published
5 Feb 2024
Maintainers
1
Total deps
0
Direct deps
0
License
MIT
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does escalade do?

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.

How do you use escalade?

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.

Where are the escalade docs?

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.