Comparing version 0.0.3 to 0.0.4
export interface IDefer<T> { | ||
resolve(v: T): void; | ||
reject(e: Error): void; | ||
promise: Promise<T>; | ||
} | ||
declare const makeDefer: <T = void>() => IDefer<T>; | ||
export default makeDefer; | ||
export default function makeDefer<T = void>(): IDefer<T>; |
24
index.js
@@ -1,10 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const makeDefer = () => { | ||
let resolve = undefined; | ||
let reject = undefined; | ||
'use strict' | ||
Object.defineProperty(exports, '__esModule', {value: true}) | ||
function makeDefer() { | ||
let resolve = undefined | ||
let reject = undefined | ||
const promise = new Promise((rs, rj) => { | ||
resolve = rs; | ||
reject = rj; | ||
}); | ||
resolve = rs | ||
reject = rj | ||
}) | ||
return { | ||
@@ -14,4 +15,5 @@ resolve, | ||
promise | ||
}; | ||
}; | ||
exports.default = makeDefer; | ||
} | ||
} | ||
exports.default = makeDefer |
{ | ||
"name": "jdefer", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "index.js", | ||
@@ -8,4 +8,11 @@ "repository": "https://github.com/tranvansang/jdefer", | ||
"index.js", | ||
"index.d.ts" | ||
"index.d.ts", | ||
"index.mjs" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./index.mjs", | ||
"require": "./index.js" | ||
} | ||
}, | ||
"keywords": [ | ||
@@ -12,0 +19,0 @@ "promise", |
@@ -13,2 +13,4 @@ # Javascript promise defer library | ||
import makeDefer from 'jdefer' | ||
// or | ||
const makeDefer = require('jdefer').default | ||
@@ -15,0 +17,0 @@ const defer = makeDefer() |
1367
5
35
27