How to use the neo-async.queue function in neo-async

To help you get started, we’ve selected a few neo-async 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 johandb / svg-drawing-tool / node_modules / sass-loader / lib / loader.js View on Github external
if (implementation === "dart-sass") {
        if (!semver.satisfies(version, "^1.3.0")) {
            throw new Error("Dart Sass version " + version + " is incompatible with ^1.3.0.");
        }
        return module.render.bind(module);
    } else if (implementation === "node-sass") {
        if (!semver.satisfies(version, "^4.0.0")) {
            throw new Error("Node Sass version " + version + " is incompatible with ^4.0.0.");
        }
        // There is an issue with node-sass when async custom importers are used
        // See https://github.com/sass/node-sass/issues/857#issuecomment-93594360
        // We need to use a job queue to make sure that one thread is always available to the UV lib
        if (nodeSassJobQueue === null) {
            const threadPoolSize = Number(process.env.UV_THREADPOOL_SIZE || 4);

            nodeSassJobQueue = async.queue(module.render.bind(module), threadPoolSize - 1);
        }

        return nodeSassJobQueue.push.bind(nodeSassJobQueue);
    }
    throw new Error("Unknown Sass implementation \"" + implementation + "\".");
}
github aermin / ghChat / node_modules / sass-loader / lib / loader.js View on Github external
function sassLoader(content) {
    if (asyncSassJobQueue === null) {
        const sass = require("node-sass");
        const sassVersion = /^(\d+)/.exec(require("node-sass/package.json").version).pop();

        if (Number(sassVersion) < 4) {
            throw new Error(
                "The installed version of `node-sass` is not compatible (expected: >= 4, actual: " + sassVersion + ")."
            );
        }

        asyncSassJobQueue = async.queue(sass.render, threadPoolSize - 1);
    }

    const callback = this.async();
    const isSync = typeof callback !== "function";
    const self = this;
    const resourcePath = this.resourcePath;

    function addNormalizedDependency(file) {
        // node-sass returns POSIX paths
        self.dependency(path.normalize(file));
    }

    if (isSync) {
        throw new Error("Synchronous compilation is not supported anymore. See https://github.com/webpack-contrib/sass-loader/issues/333");
    }
github lambci / lambci / notifications / slack.js View on Github external
function SlackClient(token, options, build) {
  this.token = token
  this.channel = options.channel
  this.username = options.username
  this.iconUrl = options.iconUrl
  this.asUser = options.asUser
  this.lastTs = null // Most recent timestamp

  this.repo = build.repo
  this.branch = build.branch
  this.prNum = build.prNum
  this.commit = build.commit
  this.logUrl = build.logUrl

  this.statusQueue = async.queue(this.updateStatus.bind(this), 1)

  build.statusEmitter.on('start', (build) => {
    var status = {
      color: 'warning',
      fallback: `Started: ${build.repo} #${build.buildNum}`,
      title: `Build #${build.buildNum} started...`,
    }
    this.statusQueue.push(status, log.logIfErr)
  })

  build.statusEmitter.finishTasks.push((build, cb) => {
    var status = {}, elapsedTxt = utils.elapsedTxt(build.startedAt, build.endedAt)
    if (build.error) {
      var txt = build.error.message
      if (build.error.logTail) {
        txt = `${build.error.logTail}\n${txt}`
github fossasia / susper.com / node_modules / sass-loader / lib / loader.js View on Github external
"use strict";

const sass = require("node-sass");
const path = require("path");
const async = require("neo-async");
const formatSassError = require("./formatSassError");
const webpackImporter = require("./webpackImporter");
const normalizeOptions = require("./normalizeOptions");
const pify = require("pify");

// This queue makes sure node-sass leaves one thread available for executing
// fs tasks when running the custom importer code.
// This can be removed as soon as node-sass implements a fix for this.
const threadPoolSize = process.env.UV_THREADPOOL_SIZE || 4;
const asyncSassJobQueue = async.queue(sass.render, threadPoolSize - 1);

/**
 * The sass-loader makes node-sass available to webpack modules.
 *
 * @this {LoaderContext}
 * @param {string} content
 */
function sassLoader(content) {
    const callback = this.async();
    const isSync = typeof callback !== "function";
    const self = this;
    const resourcePath = this.resourcePath;

    function addNormalizedDependency(file) {
        // node-sass returns POSIX paths
        self.dependency(path.normalize(file));
github mcollina / fastq / bench.js View on Github external
'use strict'

var max = 1000000
var fastqueue = require('./')(worker, 1)
var async = require('async')
var neo = require('neo-async')
var asyncqueue = async.queue(worker, 1)
var neoqueue = neo.queue(worker, 1)

function bench (func, done) {
  var key = max + '*' + func.name
  var count = -1

  console.time(key)
  end()

  function end () {
    if (++count < max) {
      func(end)
    } else {
      console.timeEnd(key)
      if (done) {
        done()
      }
github MaxGraey / webpack-butternut-plugin / index.js View on Github external
apply(compiler) {
        let code, inputMap, map, options = this.options;
        let tester = options.test = options.test || /\.js($|\?)/i;

        let queue = async.queue((task, callback) => {
            if (tester.test(task.file) === false) {
                return callback();
            }

            code = task.asset.source();

            try {
                let codeAndMap = squash(code, options);
                code = codeAndMap.code;
                map  = codeAndMap.map;

            } catch (err) {
                task.error(new Error(task.file + ' from ButternutPlugin\n' + err.message));
                return callback();
            }
github lambci / lambci / sources / github.js View on Github external
function GithubClient(build) {
  this.token = build.token
  this.repo = build.repo
  this.commit = build.commit
  this.logUrl = build.logUrl

  this.statusQueue = async.queue(this.updateStatus.bind(this), 1)

  if (!build.statusEmitter) return

  build.statusEmitter.on('start', (build) => {
    var status = {
      state: 'pending',
      description: `Build #${build.buildNum} started...`,
    }
    this.statusQueue.push(status, log.logIfErr)
  })

  build.statusEmitter.finishTasks.push((build, cb) => {
    var status = {
      state: build.error ? 'failure' : 'success',
      description: build.error ? build.error.message : `Build #${build.buildNum} successful!`,
    }