Gathering detailed insights and metrics for escalade
Gathering detailed insights and metrics for escalade
Gathering detailed insights and metrics for escalade
Gathering detailed insights and metrics for escalade
@escaladesports/zygote-plugin-esca-api
Zygote plugin for Escalade Sports API
react-escalade-priceline
Dynamically fetch or prefetch Escalade stock & pricing.
@escaladesports/babel-preset
Escalade Sport's babel preset
@escaladesports/utils
Utility functions for use in Escalade Sports projects
A tiny (183B to 210B) and fast utility to ascend parent directories
npm install escalade
97.6
Supply Chain
99.4
Quality
77.4
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
149 Stars
47 Commits
8 Forks
4 Watching
1 Branches
4 Contributors
Updated on 26 Oct 2024
JavaScript (74.85%)
TypeScript (25.15%)
Cumulative downloads
Total Downloads
Last day
-1%
11,055,698
Compared to previous day
Last week
4.3%
59,894,680
Compared to previous week
Last month
14.3%
241,053,272
Compared to previous month
Last year
36.1%
2,249,525,806
Compared to previous year
A tiny (183B to 210B) and fast utility to ascend parent directories
With escalade, you can scale parent directories until you've found what you're looking for.
Given an input file or directory, escalade
will continue executing your callback function until either:
escalade
has reached the system root directory (eg, /
)Important:
Please note thatescalade
only deals with direct ancestry – it will not dive into parents' sibling directories.
Notice: As of v3.1.0, escalade
now includes Deno support! Please see Deno Usage below.
$ npm install --save escalade
There are two "versions" of escalade
available:
Node.js: >= 8.x
Size (gzip): 210 bytes
Availability: CommonJS, ES Module
This is the primary/default mode. It makes use of async
/await
and util.promisify
.
Node.js: >= 6.x
Size (gzip): 183 bytes
Availability: CommonJS, ES Module
This is the opt-in mode, ideal for scenarios where async
usage cannot be supported.
Example Structure
/Users/lukeed
└── oss
├── license
└── escalade
├── package.json
└── test
└── fixtures
├── index.js
└── foobar
└── demo.js
Example Usage
1//~> demo.js 2import { join } from 'path'; 3import escalade from 'escalade'; 4 5const input = join(__dirname, 'demo.js'); 6// or: const input = __dirname; 7 8const pkg = await escalade(input, (dir, names) => { 9 console.log('~> dir:', dir); 10 console.log('~> names:', names); 11 console.log('---'); 12 13 if (names.includes('package.json')) { 14 // will be resolved into absolute 15 return 'package.json'; 16 } 17}); 18 19//~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar 20//~> names: ['demo.js'] 21//--- 22//~> dir: /Users/lukeed/oss/escalade/test/fixtures 23//~> names: ['index.js', 'foobar'] 24//--- 25//~> dir: /Users/lukeed/oss/escalade/test 26//~> names: ['fixtures'] 27//--- 28//~> dir: /Users/lukeed/oss/escalade 29//~> names: ['package.json', 'test'] 30//--- 31 32console.log(pkg); 33//=> /Users/lukeed/oss/escalade/package.json 34 35// Now search for "missing123.txt" 36// (Assume it doesn't exist anywhere!) 37const missing = await escalade(input, (dir, names) => { 38 console.log('~> dir:', dir); 39 return names.includes('missing123.txt') && 'missing123.txt'; 40}); 41 42//~> dir: /Users/lukeed/oss/escalade/test/fixtures/foobar 43//~> dir: /Users/lukeed/oss/escalade/test/fixtures 44//~> dir: /Users/lukeed/oss/escalade/test 45//~> dir: /Users/lukeed/oss/escalade 46//~> dir: /Users/lukeed/oss 47//~> dir: /Users/lukeed 48//~> dir: /Users 49//~> dir: / 50 51console.log(missing); 52//=> undefined
Note: To run the above example with "sync" mode, import from
escalade/sync
and remove theawait
keyword.
Returns: string|void
or Promise<string|void>
When your callback
locates a file, escalade
will resolve/return with an absolute path.
If your callback
was never satisfied, then escalade
will resolve/return with nothing (undefined).
Important:
Thesync
andasync
versions share the same API.
The only difference is thatsync
is not Promise-based.
Type: string
The path from which to start ascending.
This may be a file or a directory path.
However, when input
is a file, escalade
will begin with its parent directory.
Important: Unless given an absolute path,
input
will be resolved fromprocess.cwd()
location.
Type: Function
The callback to execute for each ancestry level. It always is given two arguments:
dir
- an absolute path of the current parent directorynames
- a list (string[]
) of contents relative to the dir
parentNote: The
names
list can contain names of files and directories.
When your callback returns a falsey value, then escalade
will continue with dir
's parent directory, re-invoking your callback with new argument values.
When your callback returns a string, then escalade
stops iteration immediately.
If the string is an absolute path, then it's left as is. Otherwise, the string is resolved into an absolute path from the dir
that housed the satisfying condition.
Important: Your
callback
can be aPromise/AsyncFunction
when using the "async" version ofescalade
.
Running on Node.js v10.13.0
# Load Time
find-up 3.891ms
escalade 0.485ms
escalade/sync 0.309ms
# Levels: 6 (target = "foo.txt"):
find-up x 24,856 ops/sec ±6.46% (55 runs sampled)
escalade x 73,084 ops/sec ±4.23% (73 runs sampled)
find-up.sync x 3,663 ops/sec ±1.12% (83 runs sampled)
escalade/sync x 9,360 ops/sec ±0.62% (88 runs sampled)
# Levels: 12 (target = "package.json"):
find-up x 29,300 ops/sec ±10.68% (70 runs sampled)
escalade x 73,685 ops/sec ± 5.66% (66 runs sampled)
find-up.sync x 1,707 ops/sec ± 0.58% (91 runs sampled)
escalade/sync x 4,667 ops/sec ± 0.68% (94 runs sampled)
# Levels: 18 (target = "missing123.txt"):
find-up x 21,818 ops/sec ±17.37% (14 runs sampled)
escalade x 67,101 ops/sec ±21.60% (20 runs sampled)
find-up.sync x 1,037 ops/sec ± 2.86% (88 runs sampled)
escalade/sync x 1,248 ops/sec ± 0.50% (93 runs sampled)
As of v3.1.0, escalade
is available on the Deno registry.
Please note that the API is identical and that there are still two modes from which to choose:
1// Choose "async" mode 2import escalade from 'https://deno.land/escalade/async.ts'; 3 4// Choose "sync" mode 5import escalade from 'https://deno.land/escalade/sync.ts';
Important: The
allow-read
permission is required!
MIT © Luke Edwards
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
3 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 2
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More