Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
asva-executors
Advanced tools
Helper classes for your async flow control.
npm install asva-executors
yarn add asva-executors
Conceptually, executors are just wrappers for asynchronous commands (functions). Yet they possess the following benefits:
executor.isRunning
tells whether executor runs command or not. Vanilla JS solutions often involve flags and are much clunkier.Executors are low-level concept, so they might require a bit of time to wrap your head around. After that they're intuitive and fun to use.
This library was not born on the spot and classes were used in various applications big and small by multiple developers for more than a year. Expect it to be reasonably refined and well thought.
Library is armed with TypeScript declarations and tests.
Available classes are:
setInterval
wrapped in class.Here are some possible use cases:
import { Executor } from 'asva-executors'
// This command is just example. Yours should still return promise but hopefully be more useful : 3.
const command = response => Promise.resolve(response)
// Instantiate executor
const executor = new Executor(command)
// Run command and process results
executor.run('data').then(result => console.log(result)) // Outputs 'data' to console
// Do some checks
executor.isRunning // Tells if executor currently runs command.
executor.runCount // Show the number of currently running commands. There could be more than one, yes.
executor.wasRun // Executor was run at least once
executor.wasRunFine // Executor was run without throwing error at least once
executor.wasRunBad // Executor was run with thrown error at least once
executor.wasLastRunFine // Last executor run happened without an error
// We intend to make an expensive ajax call from several places.
import { CacheExecutor } from 'asva-executors'
const executor = new Executor(ajaxExpensiveCall)
// Run the same executor in a number of places simultaneously or not.
// Command will be executed only once.
const result = await executor.run()
// If you have to load anew.
executor.runFresh()
// This example is live search.
import { LadderExecutor } from 'asva-executors'
const executor = new Executor(liveSearchCall)
// Imagine the case when user takes a nap on his keyboard.
executor.run('a') // This request will be run
executor.run('aa') // This request won't be run
executor.run('aaa') // This request won't be run
executor.run('aaaa') // This request will be run only after first one resolves.
// So, in total you have 2 requests instead of 4.
// Being too lazy to implement websockets we decide to check notifications every ten seconds.
import { RepeatExecutor } from 'asva-executors'
const executor = new RepeatExecutor(checkNotificationsCall, 10000)
// Start checking notifications
executor.start()
// Stop checking notifications
executor.stop()
You have to stop RepeatExecutor
if you don't need it anymore. Similar to setInterval
command it won't be garbage collected until then.
Feel free to check source code or tests to get better understanding. Library exposes typings so your IDE should comfortably provide type-hinting.
MIT
FAQs
Helper classes for your async flow control
The npm package asva-executors receives a total of 184 weekly downloads. As such, asva-executors popularity was classified as not popular.
We found that asva-executors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.