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

@pushrocks/smartpromise

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pushrocks/smartpromise - npm Package Compare versions

Comparing version 2.0.5 to 3.0.0

9

dist/index.d.ts

@@ -1,3 +0,1 @@

/// <reference types="node" />
import * as util from 'util';
export interface IResolve<T> {

@@ -26,3 +24,6 @@ (value?: T | Promise<T>): void;

export declare let rejectedPromise: (err: any) => Promise<never>;
export declare let promisify: typeof util.promisify;
export declare let map: <T>(inputArg: T[], functionArg: any) => Promise<any[]>;
interface IAsyncFunction<T> {
(someArg: T): Promise<T>;
}
export declare let map: <T>(inputArg: T[], functionArg: IAsyncFunction<T>) => Promise<any[]>;
export {};

@@ -11,3 +11,2 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const util = require("util");
class Deferred {

@@ -38,9 +37,7 @@ constructor() {

};
exports.promisify = util.promisify;
exports.map = (inputArg, functionArg) => __awaiter(this, void 0, void 0, function* () {
let promisifedFunction = exports.promisify(functionArg);
let promiseArray = [];
let resultArray = [];
for (let item of inputArg) {
let promise = promisifedFunction(item);
let promise = functionArg(item);
promiseArray.push(promise);

@@ -54,2 +51,2 @@ promise.then(x => {

});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsNkJBQTZCO0FBWTdCO0lBS0U7UUFDRSxJQUFJLENBQUMsT0FBTyxHQUFHLElBQUksT0FBTyxDQUFJLENBQUMsT0FBTyxFQUFFLE1BQU0sRUFBRSxFQUFFO1lBQ2hELElBQUksQ0FBQyxPQUFPLEdBQUcsT0FBTyxDQUFDO1lBQ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0FBQyxHQUFHLENBQUMsQ0FBQztBQUM3QixDQUFDLENBQUM7QUFNUyxRQUFBLEdBQUcsR0FBRyxDQUFVLFFBQWEsRUFBRSxXQUE4QixFQUFHLEVBQUU7SUFDM0UsSUFBSSxZQUFZLEdBQW1CLEVBQUUsQ0FBQztJQUN0QyxJQUFJLFdBQVcsR0FBRyxFQUFFLENBQUM7SUFDckIsS0FBSyxJQUFJLElBQUksSUFBSSxRQUFRLEVBQUU7UUFDekIsSUFBSSxPQUFPLEdBQWlCLFdBQVcsQ0FBQyxJQUFJLENBQUMsQ0FBQztRQUM5QyxZQUFZLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO1FBQzNCLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLEVBQUU7WUFDZixXQUFXLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ3RCLENBQUMsQ0FBQyxDQUFDO0tBQ0o7SUFDRCxNQUFNLE9BQU8sQ0FBQyxHQUFHLENBQUMsWUFBWSxDQUFDLENBQUM7SUFDaEMsT0FBTyxXQUFXLENBQUM7QUFDckIsQ0FBQyxDQUFBLENBQUMifQ==
{
"name": "@pushrocks/smartpromise",
"private": false,
"version": "2.0.5",
"version": "3.0.0",
"description": "dropin replacement for q",

@@ -6,0 +6,0 @@ "main": "dist/index.js",

import { expect, tap } from 'tapbundle';
import * as q from '../ts/index';
let myCallback = (someValue1: string, cb?) => {
cb(null, someValue1);
};
tap.test('should return a Deferred for .defer()', async () => {

@@ -23,12 +19,6 @@ let myDeferred = q.defer();

tap.test('should promisify a callback', async () => {
let myPromisified = q.promisify(myCallback);
let expectPromise = expect(myPromisified('hi')).to.eventually.equal('hi');
return await expectPromise;
});
tap.test('should map callbacks', async () => {
let inputArray = ['hi', 'awesome'];
let myPromisified = q.promisify(myCallback);
let expectPromise = expect(q.map(inputArray, myPromisified)).to.eventually.deep.equal(inputArray);
const myPromisified = async (myInput) => { return myInput };
const expectPromise = expect(q.map(inputArray, myPromisified)).to.eventually.deep.equal(inputArray);
return expectPromise;

@@ -35,0 +25,0 @@ });

@@ -1,3 +0,1 @@

import * as util from 'util';
export interface IResolve<T> {

@@ -45,10 +43,11 @@ (value?: T | Promise<T>): void;

export let promisify = util.promisify;
interface IAsyncFunction<T> {
(someArg: T):Promise<T>
}
export let map = async <T>(inputArg: T[], functionArg) => {
let promisifedFunction = promisify(functionArg);
export let map = async <T>(inputArg: T[], functionArg: IAsyncFunction<T> ) => {
let promiseArray: Promise<any>[] = [];
let resultArray = [];
for (let item of inputArg) {
let promise: Promise<any> = promisifedFunction(item);
let promise: Promise<any> = functionArg(item);
promiseArray.push(promise);

@@ -55,0 +54,0 @@ promise.then(x => {

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