New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

look-up

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

look-up - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

42

index.js

@@ -10,3 +10,5 @@ 'use strict';

var normalize = require('normalize-path');
var isGlob = require('is-glob');
var mm = require('multimatch');
var dir = sanitize(process.cwd());

@@ -17,24 +19,35 @@ /**

module.exports = function lookup(pattern, options) {
if (typeof pattern !== 'string' && !Array.isArray(pattern)) {
module.exports = function lookup(patterns, options) {
if (typeof patterns !== 'string' && !Array.isArray(patterns)) {
throw new TypeError('look-up expects a string or array as the first argument.');
}
pattern = typeof pattern === 'string'
? [pattern]
: pattern;
patterns = typeof patterns === 'string'
? [patterns]
: patterns;
options = options || {matchBase: true};
var cwd = options.cwd || process.cwd();
var plen = patterns.length;
var cwd = options.cwd || process.cwd();
while (plen--) {
var pattern = patterns[plen];
if (isGlob(pattern)) {
continue;
}
var tmp = path.join(cwd, pattern);
if (fs.existsSync(tmp)) {
return tmp;
}
}
var files = fs.readdirSync(cwd);
var len = files.length;
var i = 0;
while (i < len) {
var fp = path.join(cwd, files[i++]);
if (path.dirname(fp) === '.') {
break;
}
var match = mm(fp, pattern, options);
while (len--) {
var fp = path.join(cwd, files[len]);
if (path.dirname(fp) === '.') break;
var match = mm(fp, patterns, options);
if (match.length === 0) {

@@ -46,3 +59,2 @@ continue;

var dir = sanitize(process.cwd());
if (dir === sanitize(cwd)) {

@@ -58,3 +70,3 @@ return cwd;

options.cwd = cwd;
return lookup(pattern, options);
return lookup(patterns, options);
};

@@ -61,0 +73,0 @@

{
"name": "look-up",
"description": "Like findup-sync and supports the same features but 20x-40x faster on avg.",
"version": "0.3.1",
"version": "0.4.0",
"homepage": "https://github.com/jonschlinkert/look-up",

@@ -29,2 +29,3 @@ "author": {

"dependencies": {
"is-glob": "^0.1.0",
"multimatch": "^1.0.1",

@@ -38,2 +39,3 @@ "normalize-path": "^0.3.0"

"mocha": "*",
"resolve": "^1.0.0",
"should": "^4.1.0"

@@ -40,0 +42,0 @@ },

@@ -74,5 +74,5 @@ # look-up [![NPM version](https://badge.fury.io/js/look-up.svg)](http://badge.fury.io/js/look-up)

_This file was generated by [verb](https://github.com/assemble/verb) on December 13, 2014. To update, run `npm i -g verb && verb`._
_This file was generated by [verb](https://github.com/assemble/verb) on December 18, 2014._
[minimatch]: http://github.com/isaacs/minimatch
[findup-sync]: https://github.com/cowboy/node-findup-sync
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc