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

flyd-group-within

v0.0.3

Published

buffer stream values within x millisecond

Downloads

3

Readme

flyd-group-within

Build Status

                                     500 ms        500 ms
(S = start, E = End) Timer          S        E    S       E
                                    |        |    |       |     
upstream: (ticks represent 100ms) [-:1-2-3---:----:5-6----:-----]
groupWithin(500,stream):          [----------.------------.-----]
downstream:                                  [1,2,3]      [5,6]

install..

npm install flyd-group-within
npm install sourcevault/flyd-group-within#dist 

simple example ..


var groupWithin = require ("flyd-group-within") 

var send = flyd.stream()

setTimeout (function(){send(1)},100)
setTimeout (function(){send(2},200)
setTimeout (function(){send(3)},300)
setTimeout (function(){send(4)},1000)
setTimeout (function(){send(5)},1100)

groupWithin(500,send)
.map function (x){
   console.log(x) 
}
// [1,2,3]
// [4,5]

Why ? ..

Lower Bound Buffering

  • Lets say you are sendind data to a server over HTTP.

  • You kown the lower bound overhead to physically send a packet and process the date is 200 ms.

  • you have a send function that can be used to send the data.

  • If the send function is called every < 200ms, by definition there will be backpressure which if left unresolved will cause the recieving server to either run of memory, be unresponsive or in the worst case crash.

  • A simple protective measure is to multiplex multiple send operation into a single packet minimizing the handshake overhead - it's the same principal of using trains and buses to reduce road traffic.

Any type of IO where there is an constant overhead of doing the IO itself can find this type of buffering useful. There is another option that involves grouping n send calls, however that type of design provides no garantee regarding maxmimum wait time for the buffered send to be dispatched.

setTimeout also does not give a hard garantee regarding dispatch time - you can observe it when send operations are queud in the timeout boundaries of flyd-group-within, but that is besides the point since no system that does cooperative concurrency will give you that anyway. Just make sure your callbacks in the main eventloops is not blocking or running a long loop.

GUI IO Time Slicing

Double mouse click is a good example of this application, buffer all mouse clicks in a 200ms windows, if there are 2 mouse clicks within a 200ms window, it becomes a double click, 3 mouse click becomes a triple click, so on and so on . .

I am sure it can be used in other ways that others are better cable of finding out than me, if you would like to add your usecase do not hesitate to submit a pull request.

LICENCE

Code and documentation is released under MIT Licence, see LICENSE for details.