qind

1.0.0 • Public • Published

qind

Bind callback function as promise function.

Install

npm install qind

Usage

let qind = require("qind")
let p = {};

function toi(arg1) {
  let v = parseInt(arg1);
  if (isNaN(v)) {
    throw new Error("unval");
  }
  return v;
}

function cal(arg1, arg2, cb) {
  console.log("arg1, arg2", arg1, arg2);
  try {
    cb(null, toi(arg1) + toi(arg2));
  } catch (e) {
    cb(e);
  }
}

let qcal = qind(cal, p);

qcal("1", "ss").then(
  (val) => {
    console.log("get val: ", val);
  },
  (err) => {
    console.log("Error:", err);
  }
);

Readme

Keywords

Package Sidebar

Install

npm i qind

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

3.13 kB

Total Files

4

Last publish

Collaborators

  • hain