look-up

Faster drop-in replacement for find-up and findup-sync.

Deprecated in favor of findup-sync, please use that library instead.
Last updated 4 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install look-up 
SYNC missed versions from official npm registry.

look-up NPM version Build Status

Faster drop-in replacement for find-up and findup-sync.

Install

Install with npm

$ npm i look-up --save

See the benchmarks or unit tests.

Usage

var lookup = require('look-up');
lookup('package.json');
//=> '/Users/jonschlinkert/dev/look-up/package.json'

look-up will recurse up from the cwd until it finds the given file.

lookup('package.json', { cwd: 'foo/bar' });
//=> '/Users/jonschlinkert/dev/look-up/package.json'

Glob patterns are also supported (string or array):

lookup(['*.json', '*.foo'], { cwd: 'foo/bar' });
//=> '/Users/jonschlinkert/dev/look-up/package.json'

Running benchmarks

Benchmarks were run on mac and windows. look-up is 5x-20x faster than findup-sync and 3x faster than find-up

Note that find-up does not support glob patterns, so these benchmarks only include arguments that are supported by all three libs.

As of November 20, 2015:

#1: deep-close
  findup-sync x 5,797 ops/sec ±1.66% (90 runs sampled)
  findup x 22,972 ops/sec ±0.82% (92 runs sampled)
  lookup x 64,389 ops/sec ±0.75% (92 runs sampled)

#2: deep-far
  findup-sync x 2,165 ops/sec ±1.01% (92 runs sampled)
  findup x 8,250 ops/sec ±0.78% (96 runs sampled)
  lookup x 12,730 ops/sec ±0.93% (92 runs sampled)

#3: nested
  findup-sync x 21,603 ops/sec ±0.76% (93 runs sampled)
  findup x 103,427 ops/sec ±0.93% (95 runs sampled)
  lookup x 381,425 ops/sec ±0.91% (91 runs sampled)

#4: shallow
  findup-sync x 6,565 ops/sec ±0.66% (92 runs sampled)
  findup x 23,674 ops/sec ±0.89% (95 runs sampled)
  lookup x 57,029 ops/sec ±0.83% (93 runs sampled)

To run the benchmarks, install dev dependencies:

npm i -d && npm run benchmark

Related

  • is-glob: Returns true if the given string looks like a glob pattern or an extglob pattern.… more | homepage
  • look-up-cli: Find a file matching a pattern by walking up parent directories | homepage
  • micromatch: Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. Just… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Coverage

As of November 20, 2015:

Statements : 100% (57/57)
Branches   : 100% (26/26)
Functions  : 100% (5/5)
Lines      : 100% (55/55)

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on November 20, 2015.

Current Tags

  • 0.8.3                                ...           latest (4 years ago)

20 Versions

  • 0.8.3 [deprecated]           ...           4 years ago
  • 0.8.2                                ...           5 years ago
  • 0.8.1                                ...           5 years ago
  • 0.8.0                                ...           5 years ago
  • 0.7.2                                ...           5 years ago
  • 0.7.1                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.2                                ...           5 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago

Copyright 2014 - 2016 © taobao.org |