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

promise-breaker

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-breaker - npm Package Compare versions

Comparing version 5.0.0 to 6.0.0

.github/dependabot.yml

52

index.d.ts

@@ -106,2 +106,52 @@ // Global variable exported in browsers.

declare const PromiseBreaker: PromiseBreaker.PromiseBreaker;
export = PromiseBreaker;
export default PromiseBreaker;
export function make<R>(
options: PromiseBreaker.MakeBreakOptions,
asyncFn: (cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn0<R>;
export function make<T1, R>(
options: PromiseBreaker.MakeBreakOptions,
asyncFn: (p1: T1, cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn1<T1, R>;
export function make<T1, T2, R>(
options: PromiseBreaker.MakeBreakOptions,
asyncFn: (p1: T1, p2: T2, cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn2<T1, T2, R>;
export function make<T1, T2, T3, R>(
options: PromiseBreaker.MakeBreakOptions,
asyncFn: (p1: T1, p2: T2, p3: T3, cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn3<T1, T2, T3, R>;
export function make<R = any>(
options: PromiseBreaker.MakeBreakOptions,
asyncFn: (...args: any[]) => any
): (...args: any[]) => Promise<R>;
export function make<R>(
asyncFn: (cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn0<R>;
export function make<T1, R>(
asyncFn: (p1: T1, cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn1<T1, R>;
export function make<T1, T2, R>(
asyncFn: (p1: T1, p2: T2, cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn2<T1, T2, R>;
export function make<T1, T2, T3, R>(
asyncFn: (p1: T1, p2: T2, p3: T3, cb: PromiseBreaker.Callback<R>) => void
): PromiseBreaker.BrokenFn3<T1, T2, T3, R>;
export function make<R = any>(asyncFn: (...args: any[]) => any): (...args: any[]) => Promise<R>;
export function addPromise<R>(
done: PromiseBreaker.Callback<R> | undefined | null,
asyncFn: (cb: PromiseBreaker.Callback<R>) => void
): Promise<R>;
export function addCallback<R>(
done: PromiseBreaker.Callback<R> | undefined | null,
promise: (() => Promise<R>) | (() => R) | Promise<R>
): Promise<R>;
export function apply(fn: Function, thisArg?: any, args?: any[] | undefined): Promise<any>;
export function apply(fn: Function, thisArg: any, args: any[] | undefined, done: Function): void;
export function call(fn: Function, thisArg?: any, ...parameters: any[]): Promise<any>;
export function callWithCb(fn: Function, thisArg: any, ...parametersAndCallback: any[]): void;

54

index.js

@@ -1,2 +0,2 @@

(function(root, factory) {
(function (root, factory) {
/* istanbul ignore next */

@@ -13,3 +13,3 @@ if (typeof define === 'function' && define.amd) {

}
})(this, function(exports) {
})(this, function (exports) {
/* istanbul ignore next */

@@ -57,3 +57,3 @@ var globals = global || window;

/* Note if `promiseImpl` is `null`, this will use globals.Promise. */
exports.withPromise = function(promiseImpl) {
exports.withPromise = function (promiseImpl) {
// If a promise implementation is provided, we can validate it right away, and fail

@@ -68,3 +68,3 @@ // earlier. If not, we can't validate globals.Promise, since globals.Promise might

pb.make = function(options, asyncFn) {
pb.make = function (options, asyncFn) {
if (!asyncFn) {

@@ -118,3 +118,3 @@ asyncFn = options;

pb['break'] = function(options, promiseFn) {
pb['break'] = function (options, promiseFn) {
if (!promiseFn) {

@@ -158,3 +158,3 @@ promiseFn = options;

pb.addPromise = function(done, fn) {
pb.addPromise = function (done, fn) {
var answer = null;

@@ -164,4 +164,4 @@ if (done) {

} else {
answer = new Promise(function(resolve, reject) {
fn(function(err, result) {
answer = new Promise(function (resolve, reject) {
fn(function (err, result) {
if (err) {

@@ -181,3 +181,3 @@ reject(err);

pb.addCallback = function(done, promise) {
pb.addCallback = function (done, promise) {
var answer;

@@ -189,3 +189,3 @@ if (!promise) {

} else if (isFunction(promise)) {
answer = Promise.resolve().then(function() {
answer = Promise.resolve().then(function () {
return promise();

@@ -201,9 +201,9 @@ });

answer.then(
function(result) {
setTimeout(function() {
function (result) {
setTimeout(function () {
done(null, result);
}, 0);
},
function(err) {
setTimeout(function() {
function (err) {
setTimeout(function () {
done(err);

@@ -219,3 +219,3 @@ }, 0);

pb.applyFn = function(fn, argumentCount, thisArg, args, done) {
pb.applyFn = function (fn, argumentCount, thisArg, args, done) {
argumentCount = argumentCount || 0;

@@ -244,3 +244,3 @@ args = args || [];

done,
Promise.resolve().then(function() {
Promise.resolve().then(function () {
var isCallbackFn = argumentCount < fn.length;

@@ -260,3 +260,3 @@ var donePromise;

if (isCallbackFn) {
donePromise = new (promiseImpl || globals.Promise)(function(
donePromise = new (promiseImpl || globals.Promise)(function (
resolve,

@@ -266,3 +266,3 @@ reject

// Pass in a callback.
args[argumentCount] = function(err, result) {
args[argumentCount] = function (err, result) {
if (err) {

@@ -284,3 +284,3 @@ reject(err);

pb.apply = function(fn, thisArg, args, done) {
pb.apply = function (fn, thisArg, args, done) {
args = args || [];

@@ -290,3 +290,3 @@ return pb.applyFn(fn, args.length, thisArg, args, done);

pb.callFn = function(fn, argumentCount, thisArg) {
pb.callFn = function (fn, argumentCount, thisArg) {
argumentCount = argumentCount || 0;

@@ -306,3 +306,3 @@

pb.call = function(fn, thisArg) {
pb.call = function (fn, thisArg) {
var args = [].slice.call(arguments, 2);

@@ -312,3 +312,3 @@ return pb.applyFn(fn, args.length, thisArg, args);

pb.callWithCb = function(fn, thisArg) {
pb.callWithCb = function (fn, thisArg) {
var args = [].slice.call(arguments, 2, arguments.length - 1);

@@ -325,11 +325,11 @@ var done = arguments[arguments.length - 1];

var usingDefaultPromise = exports.withPromise();
for (var k in usingDefaultPromise) {
exports.default = exports.withPromise();
for (var k in exports.default) {
/* istanbul ignore else */
if ({}.hasOwnProperty.call(usingDefaultPromise, k)) {
exports[k] = usingDefaultPromise[k];
if ({}.hasOwnProperty.call(exports.default, k)) {
exports[k] = exports.default[k];
}
}
exports.usingDefaultPromise = usingDefaultPromise;
exports.usingDefaultPromise = exports.default;
});
{
"name": "promise-breaker",
"version": "5.0.0",
"description": "Library to help write libraries that accept both promises and callbacks.",
"main": "index.js",
"types": "index.d.ts",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "https://github.com/jwalton/node-promise-breaker"
},
"dependencies": {},
"devDependencies": {
"@jwalton/semantic-release-config": "^1.0.0",
"@semantic-release/changelog": "^3.0.1",
"@semantic-release/git": "^7.0.5",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.0.2",
"es6-promise": "^4.2.5",
"eslint": "^6.0.1",
"husky": "^2.0.0",
"istanbul": "^0.4.5",
"mocha": "^6.1.4",
"semantic-release": "^15.13.15"
},
"scripts": {
"test": "eslint ./index.js && istanbul cover _mocha",
"semantic-release": "semantic-release"
},
"keywords": [
"promise",
"callback",
"library"
],
"author": "Jason Walton <dev@lucid.thedreaming.org> (https://github.com/jwalton)",
"license": "MIT"
"name": "promise-breaker",
"version": "6.0.0",
"description": "Library to help write libraries that accept both promises and callbacks.",
"main": "index.js",
"types": "index.d.ts",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "https://github.com/jwalton/node-promise-breaker"
},
"devDependencies": {
"@jwalton/semantic-release-config": "^1.0.0",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"coveralls": "^3.0.2",
"es6-promise": "^4.2.5",
"eslint": "^8.21.0",
"husky": "^8.0.1",
"istanbul": "^0.4.5",
"lint-staged": "^13.0.3",
"mocha": "^10.0.0",
"prettier": "^2.3.1",
"pretty-quick": "^3.1.1",
"semantic-release": "^19.0.3"
},
"scripts": {
"test": "eslint ./index.js && istanbul cover _mocha",
"semantic-release": "semantic-release",
"prepare": "husky install"
},
"lint-staged": {
"src/**/*.js": [
"eslint"
],
"test/**/*.js": [
"tslint"
]
},
"keywords": [
"promise",
"callback",
"library"
],
"author": "Jason Walton <dev@lucid.thedreaming.org> (https://github.com/jwalton)",
"license": "MIT"
}

@@ -1,2 +0,2 @@

[![Build Status](https://travis-ci.org/jwalton/node-promise-breaker.svg)](https://travis-ci.org/jwalton/node-promise-breaker)
![Build Status](https://github.com/jwalton/node-promise-breaker/workflows/GitHub%20CI/badge.svg)
[![Coverage Status](https://coveralls.io/repos/jwalton/node-promise-breaker/badge.svg)](https://coveralls.io/r/jwalton/node-promise-breaker)

@@ -3,0 +3,0 @@ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

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