Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qfunction

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qfunction

Make sure specified function runs one at a time.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
Maintainers
1
Weekly downloads
 
Created
Source

Why Serialize?

In some cases, (for example adding users to linux box) if you try to run your functions in parallel it will fail.

You want to have very simple queue, that will register each incoming function, and execute it one by one.

For example:

  serializer = require "serializer"
  
  # here is an example function that will callback after 1 second.
  
  exampleFunction = (x,callback)-> setTimeout (()-> callback "Finished in 1 sec...with #{x} #{y} #{Date.now()}"),1000
  
  # if you run the for loop below, they will approximately all finish at the same time
  
  for i in [0..10] 
    exampleFunction i,(r)->
     console.log r
  
  # now you can serialize this function, and it will finish in 10 seconds, running one after another
  
  serializedExampleFunction = serializer exampleFunction

  # once you get your serialized version of your function, you use it just like you use the original.

  for i in [10..10]
    serializedExampleFunction i,(r)->
     console.log r

Installation

$ npm install serializer

To do

- Queue can be persisted to a db (right now, pending functions will die if node process dies)
- Functions that don't have a callback can be serialized (however, i don't know why those need to be serialized)

Keywords

FAQs

Package last updated on 05 Oct 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc