New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

resolves

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resolves

Resolve parent directories, execute a function on every dir found until a result is returned

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
284
4.03%
Maintainers
1
Weekly downloads
 
Created
Source

resolves

Resolves is a small utility that will resolve the parent folder of the supplied root until the iterator function returns a given value.

Installation

npm install --save resolves

Usage

var resolves = require('resolves');
var path = require('path');
var fs = require('fs');

var gitignore = resolves(process.cwd(), function next(dir) {
  var ignore = path.join(dir, '.gitignore');

  if (fs.existsSync(ignore)) return fs.readFileSync(ignore, 'utf-8');
});

As seen in the snippet above, the resolve method requires 2 arguments:

  • dir The initial directory that we start resolving in.
  • iteractor A function that is called for every directory until it returns a value that can be returned. This includes the directory you initially provided.

If the iterator does not find anything, it will keep iterating until it reaches the root folder.

License

MIT

Keywords

resolve

FAQs

Package last updated on 22 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts