existent
Check if one or more paths exist, promise-less
Last updated 9 years ago by vweevers .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install existent 
SYNC missed versions from official npm registry.

existent

Check if one or more paths exist, promise-less.

npm status Travis build status AppVeyor build status Dependency status

examples

const existent = require('existent')

existent('sheep.txt', (err, missing) => {
  console.log(err.message) // "File does not exist: /cwd/sheep.txt"
  console.log(missing) // ["/cwd/sheep.txt"]
})

// Takes an optional base path
existent(['a', '../b', 'c'], '/things', (err) => {
  if (err) throw err // "2 files do not exist: /b, /things/c"
})

// Synchronous variant (returns boolean)
existent.sync('package.json', ['node_modules', 'chalk'])

// Assertion
existent.assert(['penguin.js', 'flamingo.js'], 'lib')

api

existent(path(s), [base], callback)

Asynchronous variant. If base is provided (a string or array), it will be prepended to each path. The callback receives three arguments:

  1. error or null
  2. array of resolved missing paths
  3. array of resolved existing paths

existent.sync(path(s), [base])

Synchronous variant, returns a boolean.

existent.assert(path(s), [base])

Throws if one or more paths do not exist.

install

With npm do:

npm install existent --save

license

MIT © Vincent Weevers

Current Tags

  • 1.0.1                                ...           latest (9 years ago)

1 Versions

  • 1.0.1                                ...           9 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE