New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flaxa

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flaxa

An event function thing

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

Flaxa: event functions

Subscribe to function events

npm version

npm install flaxa --save

Use flaxa to subscribe to events on your function.

Input function can be a promise or async to be more powerful.

Example

const flaxa = require('flaxa')

const addOverTime = flaxa(
  // emit fn from flaxa
  (emit) => 
  // your function that should do stuff... 
  (a) => {
    // emit to all subscribers
    emit('my emit value', a)
    return a
  }
)

// your subscriptions
addOverTime.on('my emit value', (value) => {
  console.log(value) // hello world
})

// run your function
addOverTime('hello world') // hello world

Example


const flaxa = require('flaxa')

const addOverTime = flaxa(
  // flaxa emit function
  (emit) => 
  // your function
  (a, b) => {  
    let i = 0
    const interval = setInterval(() => {

      if(i === 5){
        clearInterval(interval)
        // emit to all subscribers
        // if you emit finally no other emits will work after 
        emit('finally', (a + b) + i)
      }
      // emit to all subscribers
      emit('update', (a + b) + i)

      i++
    }, 500)

    return a + b
})

// your subscriptions
addOverTime.on('update', (files) => {
  console.log('folderDone:', files)
})

addOverTime.on('finally', (value) => {
  console.log('finally:', value)
})

// run your function
addOverTime(1, 1)

Keywords

FAQs

Package last updated on 10 Apr 2017

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