Fix polifilled promise name

This commit is contained in:
Kagami Hiiragi 2015-02-01 16:10:03 +03:00
parent c8d92d78b6
commit 156a3f7e56
4 changed files with 24 additions and 24 deletions

View File

@ -10,7 +10,7 @@ var eccrypto = require("eccrypto");
var assert = require("./_util").assert;
var platform = require("./platform");
var promise = platform.promise;
var PPromise = platform.Promise;
/**
* Calculate SHA-1 hash.
@ -170,7 +170,7 @@ exports.encrypt = function(publicKeyTo, msg, opts) {
* plaintext on successful decryption and rejects on failure.
*/
exports.decrypt = function(privateKey, buf) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var encObj = encrypted.decode(buf);
resolve(eccrypto.decrypt(privateKey, encObj));
});

View File

@ -15,7 +15,7 @@
var objectAssign = Object.assign || require("object-assign");
var bufferEqual = require("buffer-equal");
var assert = require("./_util").assert;
var promise = require("./platform").promise;
var PPromise = require("./platform").Promise;
var bmcrypto = require("./crypto");
var Address = require("./address");
var structs = require("./structs");
@ -67,7 +67,7 @@ exports.getPayloadType = function(buf) {
// Prepend nonce to a given object without nonce.
function prependNonce(obj, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
assert(obj.length <= 262136, "object message payload is too big");
opts = objectAssign({}, opts);
var nonce, target, powp;
@ -109,7 +109,7 @@ var getpubkey = exports.getpubkey = {
* `getpubkey` object structure when fulfilled.
*/
decodeAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var decoded = message.decode(buf);
assert(decoded.command === "object", "Bad command");
resolve(getpubkey.decodePayloadAsync(decoded.payload, opts));
@ -124,7 +124,7 @@ var getpubkey = exports.getpubkey = {
* `getpubkey` object structure when fulfilled.
*/
decodePayloadAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var decoded = object.decodePayload(buf, opts);
assert(decoded.type === object.GETPUBKEY, "Wrong object type");
assert(decoded.version >= 2, "getpubkey version is too low");
@ -162,7 +162,7 @@ var getpubkey = exports.getpubkey = {
* payload when fulfilled.
*/
encodePayloadAsync: function(opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
opts = objectAssign({}, opts);
opts.type = object.GETPUBKEY;
// Bitmessage address of recepeint of `getpubkey` message.
@ -250,7 +250,7 @@ var pubkey = exports.pubkey = {
* object structure when fulfilled.
*/
decodeAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var decoded = message.decode(buf);
assert(decoded.command === "object", "Bad command");
resolve(pubkey.decodePayloadAsync(decoded.payload, opts));
@ -265,7 +265,7 @@ var pubkey = exports.pubkey = {
* object structure when fulfilled.
*/
decodePayloadAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
opts = opts || {};
var decoded = object.decodePayload(buf, opts);
assert(decoded.type === object.PUBKEY, "Wrong object type");
@ -357,7 +357,7 @@ var pubkey = exports.pubkey = {
* payload when fulfilled.
*/
encodePayloadAsync: function(opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
opts = objectAssign({}, opts);
opts.type = object.PUBKEY;
// Originator of `pubkey` message.
@ -438,7 +438,7 @@ function tryDecryptMsg(identities, buf) {
function inner(i) {
if (i > last) {
var err = new Error("Failed to decrypt msg with given identities");
return promise.reject(err);
return PPromise.reject(err);
}
return bmcrypto
.decrypt(identities[i].encPrivateKey, buf)
@ -547,7 +547,7 @@ var msg = exports.msg = {
* object structure when fulfilled.
*/
decodeAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var decoded = message.decode(buf);
assert(decoded.command === "object", "Bad command");
resolve(msg.decodePayloadAsync(decoded.payload, opts));
@ -562,7 +562,7 @@ var msg = exports.msg = {
* object structure when fulfilled.
*/
decodePayloadAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var decoded = object.decodePayload(buf, opts);
assert(decoded.type === object.MSG, "Bad object type");
assert(decoded.version === 1, "Bad msg version");
@ -673,7 +673,7 @@ var msg = exports.msg = {
* payload when fulfilled.
*/
encodePayloadAsync: function(opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
// Deal with options.
opts = objectAssign({}, opts);
opts.type = object.MSG;
@ -749,7 +749,7 @@ function tryDecryptBroadcastV4(subscriptions, buf) {
function inner(i) {
if (i > last) {
var err = new Error("Failed to decrypt broadcast with given identities");
return promise.reject(err);
return PPromise.reject(err);
}
return bmcrypto
.decrypt(subscriptions[i].getBroadcastPrivateKey(), buf)
@ -790,7 +790,7 @@ var broadcast = exports.broadcast = {
* `broadcast` object structure when fulfilled.
*/
decodeAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var decoded = message.decode(buf);
assert(decoded.command === "object", "Bad command");
resolve(broadcast.decodePayloadAsync(decoded.payload, opts));
@ -805,7 +805,7 @@ var broadcast = exports.broadcast = {
* object structure when fulfilled.
*/
decodePayloadAsync: function(buf, opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
var decoded = object.decodePayload(buf, opts);
assert(decoded.type === object.BROADCAST, "Bad object type");
var version = decoded.version;
@ -945,7 +945,7 @@ var broadcast = exports.broadcast = {
* payload when fulfilled.
*/
encodePayloadAsync: function(opts) {
return new promise(function(resolve) {
return new PPromise(function(resolve) {
// Deal with options.
opts = objectAssign({}, opts);
opts.type = object.BROADCAST;

View File

@ -140,4 +140,4 @@ exports.pow = function(opts) {
return powp;
};
exports.promise = window.Promise;
exports.Promise = window.Promise;

View File

@ -6,9 +6,9 @@
var os = require("os");
var crypto = require("crypto");
var promise = typeof Promise === "undefined" ?
require("es6-promise").Promise :
Promise;
var PPromise = typeof Promise === "undefined" ?
require("es6-promise").Promise :
Promise;
var bignum = require("bignum");
var assert = require("./_util").assert;
var worker = require("./worker");
@ -55,7 +55,7 @@ exports.getTarget = function(opts) {
exports.pow = function(opts) {
// TODO(Kagami): Allow to cancel a POW (see `platform.browser.js`).
return new promise(function(resolve, reject) {
return new PPromise(function(resolve, reject) {
var poolSize = opts.poolSize || os.cpus().length;
worker.powAsync(
poolSize,
@ -72,4 +72,4 @@ exports.pow = function(opts) {
});
};
exports.promise = promise;
exports.Promise = PPromise;