Latest Socket ResearchMalicious Chrome Extension Performs Hidden Affiliate Hijacking.Details
Socket
Book a DemoInstallSign in
Socket

find-path

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-path

Given a search string and a list of file paths, find the closest path.

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
4
100%
Maintainers
1
Weekly downloads
 
Created
Source

find-path NPM version

Given a search string and a list of file paths, find the closest path.

Install

Install with npm:

npm i find-path --save

Options

all

Type: Boolean Default value: false

This returns all of the found paths instead of the "nearest" path.

Examples

Example #1

Find the nearest path for the provided search string.

var findPath = require('find-path');
var search = 'index';
var paths = [
  'foo/bar/baz/about.md',
  'foo/bar/baz/index.md',
  'foo/bar/about.md',
  'foo/bar/index.md',
  'foo/about.md',
  'foo/index.md'
];

var foundPath = findPath(search, paths);
console.log('foundPath: ', foundPath);

Outputs 'foundPath: foo/index.md'

Example #2

Find all paths for the provided search string.

var findPath = require('find-path');
var options = {
  all: true
};
var search = 'index';
var paths = [
  'foo/bar/baz/about.md',
  'foo/bar/baz/index.md',
  'foo/bar/about.md',
  'foo/bar/index.md',
  'foo/about.md',
  'foo/index.md'
];

var foundPaths = findPath(search, paths, options);
console.log('foundPaths: ', foundPaths);

Outputs 'foundPaths: foo/bar/baz/index.md,foo/bar/index.md/foo/index.md'

Author

  • Brian Woodward

License

Copyright (c) 2014 Brian Woodward, contributors. Released under the MIT license

This file was generated by verb-cli on March 22, 2014.

Keywords

docs

FAQs

Package last updated on 22 Mar 2014

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