![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A fork of thenify to support modern CJS/ESM modules with typescript support.
Promisify a callback-based function using any-promise
.
bluebird
Array
, also support change the behavior by options.multiArgs
An added benefit is that throw
n errors in that async function will be caught by the promise!
Promisifies a function.
options
are optional.
options.withCallback
- support both callback and promise style, default to false
.
options.multiArgs
- change the behavior when callback have multiple arguments. default to true
.
true
- converts multiple arguments to an arrayfalse
- always use the first argumentArray
- converts multiple arguments to an object with keys provided in options.multiArgs
Turn async functions into promises
import { thenify } from 'thenify';
const somethingAsync = thenify(function somethingAsync(a, b, c, callback) {
callback(null, a, b, c)
})
import { thenify } from 'thenify';
const somethingAsync = thenify(
function somethingAsync(a, b, c, callback) {
callback(null, a, b, c)
},
{ withCallback: true },
)
// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);
// somethingAsync(a, b, c, function () {});
or use withCallback()
import { withCallback} from "thenify";
var somethingAsync = withCallback(function somethingAsync(a, b, c, callback) {
callback(null, a, b, c)
})
// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);
// somethingAsync(a, b, c, function () {});
import { thenify} from "thenify";
var promise = thenify(
function (callback) {
callback(null, 1, 2, 3)
},
{ multiArgs: false },
)
// promise().then(function onFulfilled(value) {
// assert.equal(value, 1);
// });
import { thenify} from "thenify";
var promise = thenify(
function (callback) {
callback(null, 1, 2, 3)
},
{ multiArgs: ['one', 'tow', 'three'] },
)
// promise().then(function onFulfilled(value) {
// assert.deepEqual(value, {
// one: 1,
// tow: 2,
// three: 3
// });
// });
FAQs
Promisify a callback-based function
The npm package thenify-ex receives a total of 0 weekly downloads. As such, thenify-ex popularity was classified as not popular.
We found that thenify-ex demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.