first-existing-path

Get the first existing path

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
first-existing-path
1.0.18 years ago8 years agoMinified + gzip package size for first-existing-path in KB

Readme

First existing path
Build Status
Get the first existing path from an array of strings

Install

npm install first-existing-path [--save]

Usage

const firstExistingPath = require('first-existing-path')

firstExistingPath([
  process.env.CONFIG, '~/.config', '.config'
], function(err, path) {

})

Or as a promise:
const firstExistingPath = require('first-existing-path')

firstExistingPath([
  process.env.CONFIG, '~/.config', '.config'
])
.then((path) => {

})

Or synchronous:
const firstExistingPath = require('first-existing-path')

let path = firstExistingPath.sync([
  process.env.CONFIG, '~/.config', '.config'
])

API

/**
 * firstExistingPath
 * Get back the first path that does exist
 * @param {Array} paths
 * @param {Function} cb optional callback
 * @return {String|Boolean} Promise the founded path or false
 */
function firstExistingPath(paths, cb)

/**
 * firstExistingPath sync
 * Get back the first path that does exist
 * @param {Array} paths
 * @return {String|Boolean} the founded path or false
 */

function firstExistingPathSync(paths)

License

MIT