@polkadot/util
Advanced tools
Comparing version 0.8.3 to 0.9.1
@@ -22,2 +22,3 @@ 'use strict'; | ||
var promisify = require('./promisify'); | ||
var string = require('./string'); | ||
var u8a = require('./u8a'); | ||
@@ -28,2 +29,2 @@ | ||
*/ | ||
module.exports = (0, _assign2.default)({}, array, { assert: assert }, bn, buffer, ext, hex, is, jsonrpc, keccak, { logger: logger }, number, { promisify: promisify }, u8a); | ||
module.exports = (0, _assign2.default)({}, array, { assert: assert }, bn, buffer, ext, hex, is, jsonrpc, keccak, { logger: logger }, number, { promisify: promisify }, string, u8a); |
{ | ||
"name": "@polkadot/util", | ||
"version": "0.8.3", | ||
"version": "0.9.1", | ||
"description": "A collection of useful utilities for @polkadot", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,3 +15,3 @@ 'use strict'; | ||
@name promisify | ||
@signature function promisify (fn: (any) => void, ...params: Array<any>): Promise<any> | ||
@signature function promisify (this: any, fn: Function, ...params: Array<any>): Promise<any> | ||
@summary Wraps an async callback into a `Promise` | ||
@@ -23,8 +23,8 @@ @description | ||
await promisify((a, cb) => cb(null, a), true); // resolves with `true` | ||
await promisify((cb) => cb(new Error('error!'))); // rejects with `error!` | ||
await promisify(null, ((a, cb) => cb(null, a), true); // resolves with `true` | ||
await promisify(null, (cb) => cb(new Error('error!'))); // rejects with `error!` | ||
*/ | ||
module.exports = function promisify(fn) { | ||
for (var _len = arguments.length, params = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
params[_key - 1] = arguments[_key]; | ||
module.exports = function promisify(self, fn) { | ||
for (var _len = arguments.length, params = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
params[_key - 2] = arguments[_key]; | ||
} | ||
@@ -35,3 +35,3 @@ | ||
return new _promise2.default(function (resolve, reject) { | ||
fn.apply(null, [].concat(params, [function (error, result) { | ||
fn.apply(self, [].concat(params, [function (error, result) { | ||
if (error) { | ||
@@ -38,0 +38,0 @@ reject(error); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
100657
169
1041