How to use denodeify - 10 common examples

To help you get started, we’ve selected a few denodeify 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 taskcluster / mozilla-taskcluster / test / kue.js View on Github external
export async function clear(runtime) {
  let Jobs = runtime.kue.Job;
  let jobs = runtime.jobs;

  let completed = await denodeify(jobs.complete).call(jobs);
  let failed = await denodeify(jobs.failed).call(jobs);
  let active = await denodeify(jobs.active).call(jobs);
  let delayed = await denodeify(jobs.delayed).call(jobs);
  let remove = denodeify(Jobs.remove.bind(Jobs));

  // Note we don't really care about errors in this case as there are race
  // conditions between when the workers complete tasks and when we attempt to
  // clear them.
  let list = completed.concat(failed).concat(active).concat(delayed);
  await Promise.all(list.map((id) => {
    return remove(id);
  })).catch(() => {});
}
github taskcluster / mozilla-taskcluster / test / kue.js View on Github external
export async function clear(runtime) {
  let Jobs = runtime.kue.Job;
  let jobs = runtime.jobs;

  let completed = await denodeify(jobs.complete).call(jobs);
  let failed = await denodeify(jobs.failed).call(jobs);
  let active = await denodeify(jobs.active).call(jobs);
  let delayed = await denodeify(jobs.delayed).call(jobs);
  let remove = denodeify(Jobs.remove.bind(Jobs));

  // Note we don't really care about errors in this case as there are race
  // conditions between when the workers complete tasks and when we attempt to
  // clear them.
  let list = completed.concat(failed).concat(active).concat(delayed);
  await Promise.all(list.map((id) => {
    return remove(id);
  })).catch(() => {});
}
github taskcluster / mozilla-taskcluster / test / kue.js View on Github external
export async function stats(runtime) {
  let jobs = runtime.jobs;
  let complete = await denodeify(jobs.completeCount).call(jobs);
  let incomplete = await denodeify(jobs.inactiveCount).call(jobs);
  let active = await denodeify(jobs.activeCount).call(jobs);

  return { complete, incomplete, active };
}
github taskcluster / mozilla-taskcluster / test / kue.js View on Github external
export async function stats(runtime) {
  let jobs = runtime.jobs;
  let complete = await denodeify(jobs.completeCount).call(jobs);
  let incomplete = await denodeify(jobs.inactiveCount).call(jobs);
  let active = await denodeify(jobs.activeCount).call(jobs);

  return { complete, incomplete, active };
}
github brunocodutra / webapp-webpack-plugin / test / index.js View on Github external
import test from 'ava';
import path from 'path';
import rimraf from 'rimraf';
import denodeify from 'denodeify';
import dircompare from 'dir-compare';

import HtmlWebpackPlugin from 'html-webpack-plugin';
import WebappWebpackPlugin from '..';

const webpack = denodeify(require('webpack'));

const compareOptions = {compareSize: true};

const FIXTURES = path.resolve(__dirname, 'fixtures');
const LOGO = path.resolve(FIXTURES, 'logo.svg');
const DIST = path.resolve(__dirname, 'dist');

rimraf.sync(DIST);

let outputId = 0;
function baseWebpackConfig (...plugins) {
  return {
    entry: path.resolve(FIXTURES, 'entry.js'),
    output: {
      filename: 'bundle.js',
      path: path.resolve(DIST, 'test-' + (outputId++)),
github SpencerCDixon / redux-cli / src / tasks / git-pull.js View on Github external
import Task from '../models/task';
import denodeify from 'denodeify';

const exec = denodeify(require('child_process').exec);

export default class extends Task {
  constructor(environment) {
    super(environment);
  }

  run(gitUrl) {
    const ui = this.ui;
    ui.startProgress(`Fetching ${gitUrl} from github.`);

    return exec(`git pull ${gitUrl}`, {
      silent: true
    }).then((err, stdout, stderr) => {
      ui.stopProgress();

      if (err) {
github taskcluster / mozilla-taskcluster / src / treeherder / action_handler.js View on Github external
async function scheduleAction(jobs, type, body) {
  let msg = jobs.create(type, body).
    attempts(JOB_ATTEMPTS).
    searchKeys(['taskId']).
    backoff({ type: 'exponential', delay: JOB_RETRY_DELAY });

  await denodeify(msg.save.bind(msg))();
}
github Satyam / book-react-redux / server / server.js View on Github external
import bodyParser from 'body-parser';
import fs from 'fs';
import denodeify from 'denodeify';
import sqlJS from 'sql.js';
import isomorphic from '_server/isomorphic';

import projects from './projects';

const absPath = relPath => join(ROOT_DIR, relPath);
const readFile = denodeify(fs.readFile);

const app = express();
const server = http.createServer(app);

const listen = denodeify(server.listen.bind(server));
const close = denodeify(server.close.bind(server));

const dataRouter = createRouter();
app.use(REST_API_PATH, bodyParser.json(), dataRouter);

app.use('/bootstrap', express.static(absPath('node_modules/bootstrap/dist')));
app.use(express.static(absPath('public')));

app.use(isomorphic);

app.get('*', (req, res) => res.sendFile(absPath('server/index.html')));

export function start() {
  global.db = new sqlJS.Database();
  return readFile(absPath('server/data.sql'), 'utf8')
  .then(data => db.exec(data))
  .then(() => Promise.all([

denodeify

Tool to turn functions with Node-style callback APIs into functions that return Promises

MIT
Latest version published 10 years ago

Package Health Score

67 / 100
Full package analysis

Popular denodeify functions