prominence

0.2.0 • Public • Published

prominence

Build Status NPM Version License

Call a callback-based function as ES6 Promise

Installation

NPM

npm install prominence

API

  • prominenct(context: object): Prominence
  • prominence(context: object, methodName: string, [ args: any[] ]): Promise<any>

Examples

ES6 Promise

import fs from "fs";
import prominence from "prominence";
 
// use Prominence proxy
prominence(fs).readFile(filepath, "utf-8").then((text) => {
  console.log(text);
}).catch(console.error.bind(console));
 
// not use a proxy
prominence(fs, "readFile", [ filepath, "utf-8" ]).then((text) => {
  console.log(text);
}).catch(console.error.bind(console));

ES7 Async/Await

import fs from "fs";
import prominence from "prominence";
 
// use Prominence Proxy
async (filepath) => {
  let text = await prominence(fs).readFile(filepath, "utf-8");
 
  console.log(text);
};
 
// not use a proxy
async (filepath) => {
  let text = await prominence(fs, "readFile", [ filepath, "utf-8" ]);
 
  console.log(text);
};

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i prominence

Weekly Downloads

0

Version

0.2.0

License

none

Last publish

Collaborators

  • mohayonao