Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appolo-utils

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appolo-utils - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

33

lib/promises.js

@@ -55,4 +55,37 @@ "use strict";

}
static fromCallback(resolver) {
return new Promise((resolve, reject) => {
resolver((err, data) => {
if (err !== null) {
reject(err);
}
else {
resolve(data);
}
});
});
}
static defer() {
return new Deferred();
}
}
exports.Promises = Promises;
class Deferred {
constructor() {
this._promise = new Promise((resolve, reject) => {
this._resolveSelf = resolve;
this._rejectSelf = reject;
});
}
get promise() {
return this._promise;
}
resolve(val) {
this._resolveSelf(val);
}
reject(reason) {
this._rejectSelf(reason);
}
}
exports.Deferred = Deferred;
//# sourceMappingURL=promises.js.map

48

lib/promises.ts

@@ -13,3 +13,3 @@ type Resolvable<R> = R | PromiseLike<R>

let params = {index:0}, results = [], iterator = iterable[Symbol.iterator](), promises = [];
let params = {index: 0}, results = [], iterator = iterable[Symbol.iterator](), promises = [];

@@ -50,3 +50,3 @@ while (concurrency-- > 0) {

let params = {index:0}, results = [], predicates = [], iterator = iterable[Symbol.iterator](), promises = [];
let params = {index: 0}, results = [], predicates = [], iterator = iterable[Symbol.iterator](), promises = [];

@@ -83,2 +83,46 @@ while (concurrency-- > 0) {

}
public static fromCallback<T>(resolver: (callback: (err: any, result?: T) => void) => void): Promise<T> {
return new Promise((resolve, reject) => {
resolver((err, data) => {
if (err !== null) {
reject(err);
} else {
resolve(data);
}
})
})
}
private static defer<T>(): Deferred<T> {
return new Deferred();
}
}
export class Deferred<T> {
private _resolveSelf;
private _rejectSelf;
private readonly _promise: Promise<T>;
constructor() {
this._promise = new Promise((resolve, reject) => {
this._resolveSelf = resolve;
this._rejectSelf = reject;
})
}
public get promise(): Promise<T> {
return this._promise;
}
public resolve(val: T): void {
this._resolveSelf(val)
}
public reject(reason: any): void {
this._rejectSelf(reason)
}
}

2

package.json

@@ -17,3 +17,3 @@ {

"main": "./index.js",
"version": "0.0.14",
"version": "0.0.15",
"license": "MIT",

@@ -20,0 +20,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc