How to use any-promise - 10 common examples

To help you get started, we’ve selected a few any-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 ethereum / web3.js / packages / web3-eth-accounts / src / index.js View on Github external
callback(e);
            return Promise.reject(e);
        }

        callback(null, result);
        return result;
    }


    // Resolve immediately if nonce, chainId, price and signing options are provided
    if (tx.nonce !== undefined && tx.chainId !== undefined && tx.gasPrice !== undefined && hasTxSigningOptions) {
        return Promise.resolve(signed(tx));
    }

    // Otherwise, get the missing info from the Ethereum Node
    return Promise.all([
        isNot(tx.chainId) ? _this._ethereumCall.getChainId() : tx.chainId,
        isNot(tx.gasPrice) ? _this._ethereumCall.getGasPrice() : tx.gasPrice,
        isNot(tx.nonce) ? _this._ethereumCall.getTransactionCount(_this.privateKeyToAccount(privateKey).address) : tx.nonce,
        isNot(hasTxSigningOptions) ? _this._ethereumCall.getNetworkId() : 1
    ]).then(function(args) {
        if (isNot(args[0]) || isNot(args[1]) || isNot(args[2]) || isNot(args[3])) {
            throw new Error('One of the values "chainId", "networkId", "gasPrice", or "nonce" couldn\'t be fetched: ' + JSON.stringify(args));
        }
        return signed(_.extend(tx, {chainId: args[0], gasPrice: args[1], nonce: args[2], networkId: args[3]}));
    });
};
github sebinsua / neo4j-simple / src / database.js View on Github external
case 'Neo.ClientError.Security.AuthenticationFailed':
    case 'Neo.ClientError.Security.AuthenticationRateLimit':
    case 'Neo.ClientError.Security.AuthorizationFailed':
      error.name = 'Neo4jAuthError';
      break;
    default:
      error.name = 'Neo4jError';
      break;
  }

  throw error;
};

// This adds extra methods to the promises returned by Bluebird so that
// we can use these in place of `then()`.
sourceifyPromises(Promise.prototype, responseParser);

// This only does something in the case of ES6 Promises.
tapifyPromises(Promise.prototype);

// This create promise-returning versions of all of the standard
// node-style callback-returning methods.
Neo4j.prototype = thenifyAll(Neo4j.prototype);

module.exports = function (url, options) {
  options = options || {};
  options.idName = options.idName || 'id';
  url = url || "http://localhost:7474/";

  var hasCredentials = options.auth !== undefined;

  var client;
github sebinsua / neo4j-simple / src / database.js View on Github external
error.name = 'Neo4jAuthError';
      break;
    default:
      error.name = 'Neo4jError';
      break;
  }

  throw error;
};

// This adds extra methods to the promises returned by Bluebird so that
// we can use these in place of `then()`.
sourceifyPromises(Promise.prototype, responseParser);

// This only does something in the case of ES6 Promises.
tapifyPromises(Promise.prototype);

// This create promise-returning versions of all of the standard
// node-style callback-returning methods.
Neo4j.prototype = thenifyAll(Neo4j.prototype);

module.exports = function (url, options) {
  options = options || {};
  options.idName = options.idName || 'id';
  url = url || "http://localhost:7474/";

  var hasCredentials = options.auth !== undefined;

  var client;
  if (hasCredentials) {
    var username = options.auth.username;
    var password = options.auth.password;
github VadimDez / ng2-pdf-viewer / node_modules / typings-core / dist / lib / compile.js View on Github external
function stringifyDependencyPath(path, options) {
    var resolved = getPath(path, options);
    var tree = options.tree, ambient = options.ambient, cwd = options.cwd, browser = options.browser, name = options.name, readFiles = options.readFiles, imported = options.imported, meta = options.meta, entry = options.entry, emitter = options.emitter;
    var importedPath = importPath(path, path_3.pathFromDefinition(path), options);
    if (has(imported, importedPath)) {
        return Promise.resolve(null);
    }
    imported[importedPath] = true;
    emitter.emit('compile', { name: name, path: path, tree: tree, browser: browser });
    function loadByModuleName(path) {
        var _a = getModuleNameParts(path, tree), moduleName = _a[0], modulePath = _a[1];
        var compileOptions = { cwd: cwd, browser: browser, readFiles: readFiles, imported: imported, emitter: emitter, name: moduleName, ambient: false, meta: meta };
        var stringifyOptions = cachedStringifyOptions(moduleName, compileOptions, options);
        if (!stringifyOptions) {
            return Promise.resolve(null);
        }
        return compileDependencyPath(modulePath, stringifyOptions);
    }
    if (path_3.isModuleName(resolved)) {
        return loadByModuleName(resolved);
    }
    return cachedReadFileFrom(resolved, options)
github kevinbeaty / underarm / build / underarm.nolodash.js View on Github external
Delay.prototype.init = function(){
  var self = this,
      task = self.task;
  if(task.resolved){
    return task.resolved;
  }

  return Prom
    .resolve(self.xf.init());
};
Delay.prototype.step = function(value, input) {
github ranjithprabhuk / ng2-Dashboard / node_modules / typings-core / dist / install.js View on Github external
.then(function (tree) {
        var name = expName || tree.name;
        if (!name) {
            return Promise.reject(new TypeError("Unable to install dependency from \"" + tree.raw + "\" without a name"));
        }
        if (tree.postmessage) {
            emitter.emit('postmessage', { name: name, message: tree.postmessage });
        }
        return compile_1.compile(tree, Object.keys(resolutions), {
            cwd: cwd,
            name: name,
            global: global,
            emitter: emitter,
            meta: true
        });
    });
}
github SwellRT / swellrt / pad / node_modules / typings / node_modules / typings-core / dist / prune.js View on Github external
function rmDependency(options) {
    var path = options.path, emitter = options.emitter;
    var _a = path_2.getDependencyPath(options), directory = _a.directory, definition = _a.definition, config = _a.config;
    function remove(path) {
        return fs_1.isFile(path)
            .then(function (exists) {
            if (!exists) {
                emitter.emit('enoent', { path: path });
                return;
            }
            return fs_1.unlink(path);
        });
    }
    return Promise.all([
        remove(config),
        remove(definition)
    ])
        .then(function () { return fs_1.rmdirUntil(directory, path); });
}
exports.rmDependency = rmDependency;
github ranjithprabhuk / ng2-Dashboard / node_modules / typings-core / dist / utils / fs.js View on Github external
function rmdirUntil(path, until) {
    if (path === until) {
        return Promise.resolve();
    }
    return exports.readdir(path)
        .then(function (files) {
        if (files.length) {
            return;
        }
        return exports.rmdir(path)
            .then(function () { return rmdirUntil(path_1.dirname(path), until); });
    })
        .catch(function (err) {
        if (err.code === 'ENOENT') {
            return;
        }
        return Promise.reject(err);
    });
}
github VadimDez / ng2-pdf-viewer / node_modules / typings-core / dist / utils / fs.js View on Github external
function rmdirUntil(path, options) {
    if (path === options.cwd) {
        return Promise.resolve();
    }
    return exports.readdir(path)
        .then(function (files) {
        if (files.length) {
            return;
        }
        return exports.rmdir(path)
            .then(function () { return rmdirUntil(path_1.dirname(path), options); });
    })
        .catch(function (err) {
        if (err.code === 'ENOENT') {
            return;
        }
        return Promise.reject(err);
    });
}
github ranjithprabhuk / ng2-Dashboard / node_modules / typings-core / dist / install.js View on Github external
}
                }
                else if (options.savePeer) {
                    if (options.global) {
                        throw new TypeError('Unable to use `savePeer` with the `global` flag');
                    }
                    else {
                        config.peerDependencies = extend(config.peerDependencies, (_f = {}, _f[name] = raw, _f));
                    }
                }
            }
            return config;
            var _b, _c, _d, _e, _f;
        });
    }
    return Promise.resolve();
}
function writeBundle(results, options) {

any-promise

Resolve any installed ES6 compatible promise

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis