Comparing version
const { dirname, resolve } = require('path'); | ||
const { readdir, stat } = require('fs'); | ||
const { promisify } = require('util'); | ||
const { homedir } = require('os'); | ||
@@ -9,3 +10,3 @@ const toStats = promisify(stat); | ||
module.exports = async function (start, callback) { | ||
let tmp, stop = resolve('.'); | ||
let tmp, stop = homedir(); | ||
let dir = resolve('.', start); | ||
@@ -12,0 +13,0 @@ let stats = await toStats(dir); |
{ | ||
"name": "escalade", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"repository": "lukeed/escalade", | ||
"description": "A tiny (186B to 214B) and fast utility to ascend parent directories", | ||
"description": "A tiny (196B to 224B) and fast utility to ascend parent directories", | ||
"module": "dist/index.mjs", | ||
@@ -7,0 +7,0 @@ "main": "dist/index.js", |
# escalade [](https://github.com/lukeed/escalade/actions) [](https://codecov.io/gh/lukeed/escalade) | ||
> A tiny (186B to 214B) and [fast](#benchmarks) utility to ascend parent directories | ||
> A tiny (196B to 224B) and [fast](#benchmarks) utility to ascend parent directories | ||
@@ -8,5 +8,5 @@ With [escalade](https://en.wikipedia.org/wiki/Escalade), you can scale parent directories until you've found what you're looking for.<br>Given an input file or directory, `escalade` will continue executing your callback function until either: | ||
1) the callback returns a truthy value | ||
2) `escalade` has reached the root directory (`process.cwd()`) | ||
2) `escalade` has reached the `$HOME` directory ([`os.homedir()`](https://nodejs.org/api/os.html#os_os_homedir)) | ||
> **Important:**<br>Please note that `escalade` will never traverse _beyond_ the root directory.<br>Additionally, `escalade` only deals with direct ancestry – it will not dive into parents' sibling directories. | ||
> **Important:**<br>Please note that `escalade` will never traverse _beyond_ the user's home directory.<br>Additionally, `escalade` only deals with direct ancestry – it will not dive into parents' sibling directories. | ||
@@ -26,3 +26,3 @@ ## Install | ||
> **Node.js:** >= 8.x<br> | ||
> **Size (gzip):** 214 bytes<br> | ||
> **Size (gzip):** 224 bytes<br> | ||
> **Availability:** [CommonJS](https://unpkg.com/escalade/dist/index.js), [ES Module](https://unpkg.com/escalade/dist/index.mjs) | ||
@@ -34,3 +34,3 @@ | ||
> **Node.js:** >= 6.x<br> | ||
> **Size (gzip):** 186 bytes<br> | ||
> **Size (gzip):** 196 bytes<br> | ||
> **Availability:** [CommonJS](https://unpkg.com/escalade/sync/index.js), [ES Module](https://unpkg.com/escalade/sync/index.mjs) | ||
@@ -158,20 +158,23 @@ | ||
# Load Time | ||
find-up: 3.948ms | ||
escalade: 0.493ms | ||
escalade/sync: 0.327ms | ||
find-up 3.948ms | ||
escalade 0.493ms | ||
escalade/sync 0.327ms | ||
# Levels: 6 (target = "foo.txt"): | ||
find-up x 30,614 ops/sec ±7.80% (46 runs sampled) | ||
escalade x 46,814 ops/sec ±3.38% (74 runs sampled) | ||
escalade/sync x 9,319 ops/sec ±0.53% (89 runs sampled) | ||
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 26,421 ops/sec ±16.54% (32 runs sampled) | ||
escalade x 49,618 ops/sec ±2.82% (80 runs sampled) | ||
escalade/sync x 4,721 ops/sec ±0.51% (92 runs sampled) | ||
find-up x 27,024 ops/sec ±11.20% (68 runs sampled) | ||
escalade x 72,625 ops/sec ±5.18% (79 runs sampled) | ||
find-up.sync x 1,644 ops/sec ±1.16% (92 runs sampled) | ||
escalade/sync x 4,556 ops/sec ±0.57% (94 runs sampled) | ||
# Levels: 14 (target = "missing123.txt"): | ||
find-up x 30,254 ops/sec ±15.38% (66 runs sampled) | ||
escalade x 50,126 ops/sec ±2.45% (84 runs sampled) | ||
escalade/sync x 4,173 ops/sec ±0.45% (93 runs sampled) | ||
# Levels: 16 (target = "missing123.txt"): | ||
find-up x 29,964 ops/sec ±12.71% (76 runs sampled) | ||
escalade x 72,445 ops/sec ±25.38% (29 runs sampled) | ||
find-up.sync x 1,087 ops/sec ±0.57% (93 runs sampled) | ||
escalade/sync x 2,342 ops/sec ±0.51% (94 runs sampled) | ||
``` | ||
@@ -178,0 +181,0 @@ |
const { dirname, resolve } = require('path'); | ||
const { readdirSync, statSync } = require('fs'); | ||
const { homedir } = require('os'); | ||
module.exports = function (start, callback) { | ||
let tmp, stop = resolve('.'); | ||
let tmp, stop = homedir(); | ||
let dir = resolve('.', start); | ||
@@ -7,0 +8,0 @@ let stats = statSync(dir); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
11147
3.01%81
5.19%188
1.62%