bakayaro

1.0.0 • Public • Published

Bakayaro


Promsify your functions, bakayaro!

Installation

npm install bakayaro

Usage

Promisifes all

const {bakayaro} = require('bakayaro');
const fs = bakayaro(require('fs'), 'Yaro'); // You can change 'Yaro' to anything you want.
/* Notice the new function will have suffix you've defined.
  By default, it will have suffix of 'Async'.
*/

/* Use promisified readFile function with .then and .catch */
fs.readFileYaro('text.txt').then(text => console.log(text)).catch(err => console.log(err));

/* Use with async/await */
try {
  const text =  await fs.readFileYaro('text.txt');
  console.log(text);
} catch(err) {
  console.log(err);
}

Promisifies a function

const {baka} = require('bakayaro');
const fs = require('fs');

const readFileYaro = baka(fs.readFile);

/* Use promisified readFile function */
readFileYaro('text.txt').then(text => console.log(text)).catch(err => console.log(err));

/* With async/await */
try {
  const text = await readFileYaro('text.txt');
  console.log(text)
} catch(err) {
  console.log(err);
}

Readme

Keywords

Package Sidebar

Install

npm i bakayaro

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

4.23 kB

Total Files

7

Last publish

Collaborators

  • seasonalmatcha