Skip to content

kolodny/yieldish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yieldish

NPM version Build status Downloads

Generate a sync and async variant of some function. This is useful when you want to ensure the same code is used for both sync and async without needing to duplicate the implementation code.adders.sync(3)

Usage

const { yieldish } = require('yieldish');

const adders = yieldish(isSync => function *(firstNumber) {
  const secondNumber = yield isSync ? 1 : Promise.resolve(1);
  return firstNumber + secondNumber;
});

adders.sync(3) === 4; // true
await adders.sync(3) === 4; // true

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published