Skip to content
This repository has been archived by the owner on Dec 23, 2022. It is now read-only.
/ foster Public archive

Helps for an easy functions relay to manage callbacks as promises and viceversa

Notifications You must be signed in to change notification settings

rolandolucio/foster

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Foster

Install

npm install foster

Usage

'use strict';

const Foster= require('foster');

let f1= new Foster();
let f2= Foster.new();

class FosterChild extends Foster{}

let f3=new FosterChild();

function testFuncCb (foo,cb){
  //console.log('testFuncCb');
  if(foo=='bar'){
    cb(null,foo);
  }
  cb(foo);
}


f1.cbToPromise(testFuncCb,'foo')
.then((val)=>{
  console.log('P ok');
  console.log(val)
  console.log('==============');
}).catch((e)=>{
  console.log('p F');
  console.error(e);
});

f2.cbToPromise(testFuncCb,'bar')
.then((val)=>{
  console.log('P ok');
  console.log(val)
  console.log('==============');
}).catch((e)=>{
  console.log('p F');
  console.error(e);
});

About

Helps for an easy functions relay to manage callbacks as promises and viceversa

Resources

Stars

Watchers

Forks

Packages

No packages published