Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hailiang-wang/qind
Bind callback fn as promise fn.
https://github.com/hailiang-wang/qind
nodejs promise
Last synced: 5 days ago
JSON representation
Bind callback fn as promise fn.
- Host: GitHub
- URL: https://github.com/hailiang-wang/qind
- Owner: hailiang-wang
- License: mit
- Created: 2020-04-06T10:30:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-06T10:41:02.000Z (over 4 years ago)
- Last Synced: 2024-11-01T17:02:29.324Z (14 days ago)
- Topics: nodejs, promise
- Language: JavaScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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);
}
);
```## Give credits to
[q](https://github.com/kriskowal/q)
## License
Copyright (2020) 北京华夏春松科技有限公司
[The MIT License](./LICENSE)
[![chatoper banner][co-banner-image]][co-url]
[co-banner-image]: https://user-images.githubusercontent.com/3538629/42383104-da925942-8168-11e8-8195-868d5fcec170.png
[co-url]: https://www.chatopera.com