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

makepromise

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makepromise - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

19

build/index.js
let erotic = require('erotic'); if (erotic && erotic.__esModule) erotic = erotic.default;
function checkArgumentIndex(length, i) {
/**
* @param {number} length
* @param {number} i
* @param {!Function} fn
*/
function checkArgumentIndex(length, i, fn) {
if (i > length - 2) {
throw new Error('Function does not accept that many arguments.')
throw new Error(`Function${fn.name ? ` ${fn.name}` : ''} does not accept that many arguments (max ${length - 1} + callback).`)
}

@@ -16,5 +21,5 @@ }

*/
async function makePromise(fn, args, resolveValue) {
async function makePromise(fn, args, resolveValue) {
const er = erotic(true)
if (typeof fn !== 'function') {
if (typeof fn != 'function') {
throw new Error('Function must be passed.')

@@ -24,3 +29,3 @@ }

if (!fnLength) {
throw new Error('Function does not accept any arguments.')
throw new Error(`Function${fn.name ? ` ${fn.name}` : ''} does not accept any arguments.`)
}

@@ -41,7 +46,7 @@

args.forEach((arg, i) => {
checkArgumentIndex(fnLength, i)
checkArgumentIndex(fnLength, i, fn)
})
allArgs = [...args, cb]
} else if (Array.from(arguments).length > 1) { // args passed as a single argument, not array
checkArgumentIndex(fnLength, 0)
checkArgumentIndex(fnLength, 0, fn)
allArgs = [args, cb]

@@ -48,0 +53,0 @@ }

@@ -0,1 +1,7 @@

## 3 February 2020
### [3.1.0](git+https://github.com/artdecocode/makepromise/compare/v3.1.0...v3.1.1)
- [fix] Better error messages.
## 10 April 2019

@@ -2,0 +8,0 @@

{
"name": "makepromise",
"version": "3.1.0",
"version": "3.1.1",
"description": "Make a Promise from a function with a callback and preserve its error stack.",

@@ -43,3 +43,3 @@ "main": "build/index.js",

},
"homepage": "https://github.com/artdecocode/makepromise#readme",
"homepage": "https://www.artd.eco",
"devDependencies": {

@@ -50,3 +50,3 @@ "alamode": "^1.9.2",

"wrote": "^1.4.0",
"yarn-s": "1.1.0",
"yarn-s": "1.2.2",
"zoroaster": "^3.11.4"

@@ -53,0 +53,0 @@ },

import erotic from 'erotic'
function checkArgumentIndex(length, i) {
/**
* @param {number} length
* @param {number} i
* @param {!Function} fn
*/
function checkArgumentIndex(length, i, fn) {
if (i > length - 2) {
throw new Error('Function does not accept that many arguments.')
throw new Error(`Function${fn.name ? ` ${fn.name}` : ''} does not accept that many arguments (max ${length - 1} + callback).`)
}

@@ -18,3 +23,3 @@ }

const er = erotic(true)
if (typeof fn !== 'function') {
if (typeof fn != 'function') {
throw new Error('Function must be passed.')

@@ -24,3 +29,3 @@ }

if (!fnLength) {
throw new Error('Function does not accept any arguments.')
throw new Error(`Function${fn.name ? ` ${fn.name}` : ''} does not accept any arguments.`)
}

@@ -41,7 +46,7 @@

args.forEach((arg, i) => {
checkArgumentIndex(fnLength, i)
checkArgumentIndex(fnLength, i, fn)
})
allArgs = [...args, cb]
} else if (Array.from(arguments).length > 1) { // args passed as a single argument, not array
checkArgumentIndex(fnLength, 0)
checkArgumentIndex(fnLength, 0, fn)
allArgs = [args, cb]

@@ -48,0 +53,0 @@ }

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