alexpozdnyakof / future

custom promise implementation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Future is a custom Promise implementation

Why? Just 4 fun.

Example

const future = Future(resolve => resolve('in future'))
future.then(x => console.log({ x })) // {x: in future}
FutureFactory(resolve => resolve(0))
  .then(x => x + 1)
  .then(x => x + 1)
  .then(x => x + 1) // 3
const panic = new Error('Panic!')

FutureFactory((_, reject) => reject(new Error('Not Panic!')))
  .then(() => {
    throw panic
  })
  .catch(e => e)

About

custom promise implementation


Languages

Language:TypeScript 97.1%Language:JavaScript 1.9%Language:Shell 1.0%