How to use the pinkie-promise.reject function in pinkie-promise

To help you get started, we’ve selected a few pinkie-promise 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 rafaelrinaldi / npm-downloads / src / index.js View on Github external
const npmDownloads = options => {
  if (!options.module || typeof options.module !== 'string') {
    return Promise.reject(new Error('module name required'));
  } else if (/^@/.test(options.module)) {
    return Promise.reject(new Error('private modules not supported'));
  }

  spinner.start(`Fetching ${chalk.bold(options.module)} downloads`);

  return fetchDownloadsCount(options)
    .then(response => {
      return response.map(item => item.body);
    })
    .then(response => {
      spinner.stop();

      if (isNonexistentPackage(response)) {
        return Promise.reject(new Error('nonexistent package'));
      }

      printDownloadsCount(options.module, response);
github sx1989827 / DOClever / Desktop / node_modules / opn / index.js View on Github external
module.exports = function (target, opts) {
	if (typeof target !== 'string') {
		return Promise.reject(new Error('Expected a `target`'));
	}

	opts = objectAssign({wait: true}, opts);

	var cmd;
	var appArgs = [];
	var args = [];
	var cpOpts = {};

	if (Array.isArray(opts.app)) {
		appArgs = opts.app.slice(1);
		opts.app = opts.app[0];
	}

	if (process.platform === 'darwin') {
		cmd = 'open';
github tidys / CocosCreatorPlugins / packages / res-compress / node_modules / bin-wrapper / node_modules / got / index.js View on Github external
function got(url, opts, cb) {
	if (typeof opts === 'function') {
		cb = opts;
		opts = {};
	}

	if (cb) {
		asCallback(normalizeArguments(url, opts), cb);
		return null;
	}

	try {
		return asPromise(normalizeArguments(url, opts));
	} catch (err) {
		return PinkiePromise.reject(err);
	}
}
github sx1989827 / DOClever / Desktop / node_modules / globby / index.js View on Github external
module.exports = function (patterns, opts) {
	var globTasks;

	try {
		globTasks = generateGlobTasks(patterns, opts);
	} catch (err) {
		return Promise.reject(err);
	}

	return Promise.all(globTasks.map(function (task) {
		return globP(task.pattern, task.opts);
	})).then(function (paths) {
		return arrayUnion.apply(null, paths);
	});
};
github gillstrom / osx-brightness / index.js View on Github external
exports.set = function (val) {
	if (process.platform !== 'darwin') {
		return Promise.reject(new Error('Only OS X systems are supported'));
	}

	if (typeof val !== 'number' || isNaN(val)) {
		return Promise.reject(new TypeError('Expected a number'));
	}

	if (!inRange(val, 1)) {
		return Promise.reject(new Error('Expected a value between 0 and 1'));
	}

	return pify(execFile, Promise)('./main', [val], {cwd: __dirname});
};
github vadimdemedes / crown / index.js View on Github external
.catch(function () {
			var message = format('Feature `%s` does not exist', name);

			return Promise.reject(message);
		});
};
github abhaydoke09 / Deep-Learning-For-Surveillance / FrontEnd / node_modules / opn / index.js View on Github external
module.exports = function (target, opts) {
	if (typeof target !== 'string') {
		return Promise.reject(new Error('Expected a `target`'));
	}

	opts = objectAssign({wait: true}, opts);

	var cmd;
	var appArgs = [];
	var args = [];
	var cpOpts = {};

	if (Array.isArray(opts.app)) {
		appArgs = opts.app.slice(1);
		opts.app = opts.app[0];
	}

	if (process.platform === 'darwin') {
		cmd = 'open';
github kevva / xdg-trash / index.js View on Github external
module.exports = function (paths) {
	if (process.platform !== 'linux') {
		return Promise.reject(new Error('Only Linux systems are supported'));
	}

	if (!Array.isArray(paths)) {
		return Promise.reject(new TypeError('Expected an array'));
	}

	if (paths.length === 0) {
		return Promise.resolve();
	}

	return Promise.all(paths.map(function (p) {
		return trash(path.resolve(String(p)));
	}));
};
github kevva / xdg-trash / index.js View on Github external
module.exports = function (paths) {
	if (process.platform !== 'linux') {
		return Promise.reject(new Error('Only Linux systems are supported'));
	}

	if (!Array.isArray(paths)) {
		return Promise.reject(new TypeError('Expected an array'));
	}

	if (paths.length === 0) {
		return Promise.resolve();
	}

	return Promise.all(paths.map(function (p) {
		return trash(path.resolve(String(p)));
	}));
};
github daviddbarrero / Ionic-4-firebase / node_modules / path-type / index.js View on Github external
function type(fn, fn2, fp) {
	if (typeof fp !== 'string') {
		return Promise.reject(new TypeError('Expected a string'));
	}

	return pify(fs[fn], Promise)(fp).then(function (stats) {
		return stats[fn2]();
	});
}

pinkie-promise

ES2015 Promise ponyfill

MIT
Latest version published 9 years ago

Package Health Score

67 / 100
Full package analysis