How to use pinkie-promise - 10 common examples

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 root-systems / catstack / app / util / fetch-all-data.js View on Github external
export default function fetchAllData(components, getState, dispatch, location, params) {
  const fetchers = components
    .filter((component) => !!component) // Weed out 'undefined' routes
    .filter((component) => component.fetchData) // only look at ones with a static fetchData()
    .map((component) => component.fetchData) // pull out fetch data methods
    .map(fetchData => {
      return fetchData(getState, dispatch, location, params)
    }) // call fetch data methods and return promises

  return Promise.all(fetchers)
}
github mauriciopoppe / generator-mnm / test / helpers / set-up-mockery.js View on Github external
mockery.registerMock('deps-object', function (deps) {
      var obj = deps.reduce(function (o, v) {
        var tok = v.split('@')
        if (tok.length === 1) tok.push('*')
        o[tok[0]] = tok[1]
        return o
      }, {})
      return Promise.resolve(obj)
    })
  })
github futurize / futurize / test / futurize-promise.js View on Github external
function time (text, cb) {
    return new Promise((res, rej) =>
      setTimeout(() => res(text), 100)
    );
  }
github futurize / futurize / test / futurize-promise.js View on Github external
function erroring (text, cb) {
    return new Promise((res, rej) =>
      setTimeout(() => rej(text), 100)
    );
  }
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 davidtheclark / cosmiconfig / lib / mergeExtends.js View on Github external
function mergeExtends(config, configDir) {
  if (!config.extends) {
    return Promise.resolve(config);
  }

  var extendLookups = [].concat(config.extends);
  var resultPromise = extendLookups.reduce(function(mergedConfigPromise, extendLookup) {
    return mergedConfigPromise.then(function(priorMergedConfig) {
      return loadExtendConfig(priorMergedConfig, configDir, extendLookup)
        .then(function(extendConfig) {
          return Promise.resolve(_.merge({}, priorMergedConfig, extendConfig));
        });
    });
  }, Promise.resolve(_.omit(config, 'extends')));

  return resultPromise;
}
github davidtheclark / cosmiconfig / lib / mergeExtends.js View on Github external
function mergeExtends(config, configDir) {
  if (!config.extends) {
    return Promise.resolve(config);
  }

  var extendLookups = [].concat(config.extends);
  var resultPromise = extendLookups.reduce(function(mergedConfigPromise, extendLookup) {
    return mergedConfigPromise.then(function(priorMergedConfig) {
      return loadExtendConfig(priorMergedConfig, configDir, extendLookup)
        .then(function(extendConfig) {
          return Promise.resolve(_.merge({}, priorMergedConfig, extendConfig));
        });
    });
  }, Promise.resolve(_.omit(config, 'extends')));

  return resultPromise;
}
github tadatuta / betterc / lib / async.js View on Github external
function findAllConfigs(options) {
    var possibleFiles = possibleConfigs(options);

    return Promise.all(possibleFiles.map(fsHelpers.exists)).then(function(exists) {
        var realFiles = possibleFiles.filter(function(file, idx) {
            return exists[idx];
        });

        return Promise.all(realFiles.map(function(file) {
            var parsedConfig;

            try {
                parsedConfig = require(file);
                parsedConfig.__source = file;

                return Promise.resolve(parsedConfig);
            } catch (err) {
                return fsHelpers.read(file).then(function(content) {
                    parsedConfig = nodeEval('(' + content + ')');
github bem-tools / bem-tools-create / lib / create.js View on Github external
var defaultLevels = levelList.filter(function(level) {
                    return levelsMap[level].default;
                });

                var levelByCwd = levelList.filter(function(level) {
                    return cwd.indexOf(level) === 0;
                }).sort().reverse()[0];

                levels = levelByCwd || (defaultLevels.length ? defaultLevels : cwd);
            }

            Array.isArray(entities) || (entities = [entities]);
            Array.isArray(levels) || (levels = [levels]);

            return Promise.all(entities.map(function(input) {
                var isFileGlob = typeof input === 'string';

                return Promise.all((isFileGlob ? braceExpansion(input) : [input]).map(function(filepathOrInput) {
                    var currentLevels = levels;

                    if (typeof filepathOrInput === 'string') {
                        var currentLevel = path.dirname(filepathOrInput);
                        currentLevel !== '.' && (currentLevels = [currentLevel]);
                    }

                    return Promise.all(currentLevels.map(function(relLevel) {
                        var rootDir = config.rootSync() || cwd,
                            level = path.resolve(rootDir, relLevel);

                        return config.level(level).then(function(levelOptions) {
                            levelOptions || (levelOptions = {});

pinkie-promise

ES2015 Promise ponyfill

MIT
Latest version published 9 years ago

Package Health Score

67 / 100
Full package analysis