Socket
Socket
Sign inDemoInstall

walk-back

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    walk-back

Walk up the directory tree until the specified path is found.


Version published
Weekly downloads
347K
decreased by-19.04%
Maintainers
1
Install size
7.21 kB
Created
Weekly downloads
 

Readme

Source

view on npm npm module downloads Gihub repo dependents Gihub package dependents Build Status js-standard-style

walk-back

walk-back

Walk up the directory tree until the specified path is found.

Example

const walkBack = require('walk-back')

walkBack(startAt, lookingFor) ⇒ string

Returns an absolute file path (if found) else null.

Kind: Exported function

ParamTypeDescription
startAtstringthe directory to start in
lookingForstringthe path we're looking for

Example

> walkBack('/Users/lloyd/Documents/75lb/walk-back', 'package.json')
'/Users/lloyd/Documents/75lb/walk-back/package.json'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', '75lb')
'/Users/lloyd/Documents/75lb'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', '.bash_profile')
'/Users/lloyd/.bash_profile'

> walkBack('.', '.bash_profile')
'/Users/lloyd/.bash_profile'

> walkBack('/Users/lloyd/Documents/75lb/walk-back', 'non-existent.file')
null

© 2015-21 Lloyd Brookes <75pound@gmail.com>.

Tested by test-runner. Documented by jsdoc-to-markdown.

Keywords

FAQs

Last updated on 18 Aug 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc