How to use the deferred.map function in deferred

To help you get started, we’ve selected a few deferred 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 shubik / prometheus_deprecated / lib / helpers / form_parser.js View on Github external
this._attributes[key] = (params[key].toLowerCase() === 'true') ? true : false;
                        break;

                    default:
                        this._attributes[key] = params[key];
                }

            } else {
                this._attributes[key] = this._schema[key].default;
            }
        }
    }

    /* --- Handle file uploads --- */

    deferred.map(files, _.bind(uploader, this))
    (function (result) {
        def.resolve(self);
    }, function(err) {
        def.resolve(err);
    });

    return def.promise;
}
github medikoo / modules-webmake / test / lib / parser.js View on Github external
.readInput(input)(path => {
				a(path, "__playground/lib/program", "Path");
				a.deep(Object.keys(parser.modules).sort(), ["__playground"], "Modules");
				return deferred.map(keys(map), filePath =>
					readFile(filePath)(content => { a(map[filePath], String(content), filePath); })
				)(() => null);
			})
			.done(d, d);
github GMOD / jbrowse / node / add-track-json.js View on Github external
}) (function() {
		deferred.map (replacedTracks, function (track) {
		    return client.publish ("/tracks/replace", track)
			.then (function() {
			    console.log ("Announced replacement track " + track.label)
			}, function() {
			    console.log ("Failed to announce replacement track " + track.label)
			    process.exit()
			})
		}) (function() {
		    process.exit()
		})
	    })
	} else {
github medikoo / modules-webmake / lib / parser.js View on Github external
return read(filename, this, filename.split(sep).slice(-2 - tree.length).join("/"))(data => {
			this.modulesFiles.push(filename);
			scope[name] = data.content;
			return deferred
				.map(data.deps, this.resolve.bind(this, filename, dirname(filename), scope, tree))
				.aside(filePath => { this.depsMap[filename] = filePath; });
		});
	},
github medikoo / fs2 / copy-dir.js View on Github external
function (files) {
			return deferred.map(files, function (relativePath) {
				var filename = resolve(source, relativePath);
				return lstat(filename)(function (stats) {
					if (stats.isDirectory()) {
						return mkdir(resolve(dest, relativePath), { intermediate: true });
					}
					if (stats.isFile()) {
						return copyFile(filename, resolve(dest, relativePath), {
							intermediate: true
						});
					}
					if (!stats.isSymbolicLink()) return null;
					return readlink(filename)(function (linkPath) {
						linkPath = resolve(dirname(filename), linkPath);
						var linkDirname = dirname(linkPath);
						if (
							linkDirname === sourceTop ||
github medikoo / fs2 / readdir.js View on Github external
function (nextData) {
							deferred
								.map(
									nextData.added,
									function (dir) {
										return self.call(
											this,
											this.read(this.path + sep + rootPath + dir, depth - 1),
											rootPath + dir + sep, depth - 1
										);
									},
									this
								)
								.done();
							nextData.removed.forEach(
								function (dir) {
									var path = rootPath + dir + sep, reader = this.readers[path];
									if (reader) {
github medikoo / modules-webmake / lib / parser.js View on Github external
readFileContent(fileContent, name, this, name)(data => {
					scope[name] = data.content;
					return deferred.map(
						data.deps, this.resolve.bind(this, input, dirname(input), scope, [])
					);
				})
			);
github medikoo / cjs-vs-amd-benchmark / scripts / generate.js View on Github external
generate = function (path, tpl, stringify, map) {
	return deferred.map(Object.keys(map), function (name) {
		return writeFile(resolve(path, name + '.js'),
			tpl.replace('$DEPS$', stringify(map[name])));
	});
};
github JamieMason / image-optimisation-tools-comparison / src / images.js View on Github external
exports.setSize = function(results) {
    var measureImages = deferred.map(
        results.images,
        deferred.gate(function(result) {
            return result.setFileSize();
        }, 50)
    );
    return measureImages().then(function() {
        return results;
    });
};
github shubik / prometheus_deprecated / lib / helpers / image_resizer.js View on Github external
module.exports = function(path, basename, ext, sizes) {
    deferred.map(sizes, function(size) {
        var def     = deferred(),
            dim     = size.substr(1),
            dims    = (size[0] === 's') ? dim : dim + 'x' + dim,
            src     = path + basename + ext,
            dest    = path + basename + '_' + size + ext,
            args    = {},
            command = '';

        size = size.toLowerCase();

        if (size[0] === 'c') {
            args.resize = format('%s^', dims);
            args.crop = format('%s+0+0', dims);
            args.background = 'white';
            args.gravity = 'center';
            convert(src, dest, args, def);

deferred

Modular and fast Promises implementation

ISC
Latest version published 5 years ago

Package Health Score

65 / 100
Full package analysis