GitXplorerGitXplorer
e

wait-file

public
1 stars
1 forks
18 issues

Commits

List of commits on branch master.
Unverified
112c5f16777e071aa7193f4c556d54b0e5a385bd

1.0.6

eendiliey committed 5 years ago
Unverified
5eb6c217832956dbb25f788bf125b72adc46ca1e

chore(deps): bump mixin-deep from 1.3.1 to 1.3.2 (#3)

ddependabot[bot] committed 5 years ago
Unverified
42ce7013d73eacf08547de7f5a23df7687fd12e4

v1.0.5

eendiliey committed 5 years ago
Unverified
bbf595106b83068b503f70ce90f89c08d57dfeb5

1.0.4

eendiliey committed 5 years ago
Unverified
57bd99b86fa30269b60046efbf3903d3c181a9a4

chore: add mit license

eendiliey committed 5 years ago
Unverified
899c32ef17fb14d11e00fcb9b612506ed80486ae

1.0.3

eendiliey committed 5 years ago

README

The README file for this repository.

Wait-file

Wait for file resource(s) to become available in Node.js.

Build Status

Installation

npm install wait-file

Node.js API usage

waitFile(opts, [cb]) - function which triggers resource checks

  • opts - see below example
  • cb(err) - if err is provided then, resource checks did not succeed

Requires Node.js v8+

const { waitFile } = require('wait-file');
const opts = {
  resources: ['file1', '/path/to/file2'],
  delay: 0, // initial delay in ms, default 0ms
  interval: 100, // poll interval in ms, default 250ms
  log: false, // outputs to stdout, remaining resources waited on and when complete or errored, default false
  reverse: false, // resources being NOT available, default false
  timeout: 30000, // timeout in ms, default Infinity
  verbose: false, // optional flag which outputs debug output, default false
  window: 1000, // stabilization time in ms, default 750ms
};

// Usage with callback function
waitFile(opts, function(err) {
  if (err) {
    return console.error(err);
  }
  // once here, all resources are available
});

// Usage with promises
waitFile(opts)
  .then(function() {
    // once here, all resources are available
  })
  .catch(function(err) {
    console.error(err);
  });

// Usage with async await
try {
  await waitFile(opts);
  // once here, all resources are available
} catch (err) {
  console.error(err);
}