npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fiberit

v0.2.0

Published

This is just a copy of the wait.for implementation of [luciotato/Wait.for](https://github.com/luciotato/waitfor) but in Typescript.

Downloads

12

Readme

Fiberit

This is just a copy of the wait.for implementation of luciotato/Wait.for but in Typescript.

Sequential programming for node.js, end of callback hell. Simple, straightforward abstraction over Fibers.

By using wait.for, you can call any nodejs standard async function in sequential/Sync mode, waiting for result data, without blocking node's event loop (thanks to fibers)

A nodejs standard async function is a function in which the last parameter is a callback: function(err,data)

Advantages:

  • Avoid callback hell / pyramid of doom
  • Simpler, sequential programming when required, without blocking node's event loop (thanks to fibers)
  • Simpler, try-catch exception programming. (default callback handler is: if (err) throw err; else return data)
  • You can also launch multiple parallel non-concurrent fibers.
  • No multi-threaded debugging nightmares, only one fiber running at a given time (thanks to fibers)
  • Can use any node-standard async function with callback(err,data) as last parameter.
  • Plays along with node programming style. Write your async functions with callback(err,data), but use them in sequential/SYNC mode when required.
  • Plays along with node cluster. You design for one thread/processor, then scale with cluster on multicores.

Install

With npm installed, run

$ npm install --save fiberit

Usage

import { Fiberit } from 'fiberit';

const someAsyncFunction = (param: number, cb: NodeCallback<number>) => setTimeout(() => cb(null, param * 2), 100);

Fiberit.launchFiber(() => {
  const result = Fiberit.for(someAsyncFunction, 5);
  console.log(result); // 10
})

API

Fiberit.launchFiber(fn)

Calls the function inside a fiber.

fn

Required Type: Function

Function to run inside the fiber

Fiberit.for(asyncFunction, params)

Calls the function inside a fiber.

asyncFunction

Required Type: Function

Async function with node-style callback

params

Type: any

N parameters that will be passed to the asyncFunction

Fiberit.forMethod(object, method, params)

Calls the function inside a fiber.

object

Required Type: Object

Object that has the method that will be called inside the fiber

method

Required Type: String

Method of the object with node-style callback

params

Type: any

N parameters that will be passed to the object.method

Fiberit.forPromise(object, method, params)

Calls the function inside a fiber.

object

Required Type: Object

Object that has the method that will be called inside the fiber

method

Required Type: String

Method of the object which return a Promise

params

Type: any

N parameters that will be passed to the object.method