golike-promisify

1.0.0 • Public • Published

golike-promisify

Provides function transformations for callback-based functions sort of in the style of Go, using array destructuring.

Why return error-first tuples?

In error-first callbacks, the values after the error are undefined and can't be grabbed with varargs, so we don't know jow many values to backfill the tuple with to get an error-last result.

Installation

npm install golike-promisify

Example

import fs from "fs";
import * as golp from "../golike-promisify";
const readFile = golp.promisify(fs.readFile);

(async () => {
    const [err, data] = await readFile("blah.js");
    if (err) {
        console.log(err);
    }
})();

Readme

Keywords

none

Package Sidebar

Install

npm i golike-promisify

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

2.09 kB

Total Files

3

Last publish

Collaborators

  • karashiiro