How to use the one-time/async function in one-time

To help you get started, we’ve selected a few one-time examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github godaddy / ekke / native / console.js View on Github external
async function intercept({ send }) {
  const ocm = ['log', 'info', 'warn', 'error'];
  const oc = {};

  ocm.forEach(function each(method) {
    oc[method] = console[method];
    console[method] = send.bind(send, `console.${method}`);
  });

  return once(async function after() {
    ocm.forEach(function each(method) {
      console[method] = oc[method];
      delete oc[method];
    });
  });
}
github godaddy / ekke / runners / index.js View on Github external
complete() {
    return once(async function completed(err) {
      debug('completed the run', err);

      if (err) {
        if (typeof err === 'number') {
          err = new Error(`Test are failing with exit code ${err}`);
        }

        this.subway.send('complete', failure(err));
      } else {
        this.subway.send('complete');
      }

      await this.teardown();
    }.bind(this));
  }

one-time

Run the supplied function exactly one time (once)

MIT
Latest version published 5 years ago

Package Health Score

68 / 100
Full package analysis

Popular one-time functions