Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
fantail
Advanced tools
Readme
var Fantail = require('fantail');
var sch = new Fantail;
Options are set at instantiation and can't be modified afterwards.
var sch = new Fantail({
debug: false, // Expose queues and handlers.
throttle: 200, // Run handlers (at most once) every 200 milliseconds
immediate: false // .start() immediately.
});
You can push to the queue whenever you wish.
sch.push(foo);
You can push multiple values at the same time.
sch.push(bar, baz);
Handlers process items. They are named.
sch.addHandler('something', function(item) {
// do something
});
Pickers filter the queue. They are run every time
milliseconds, and can
be limited to limit
items per run (limit
is optional); the default is to go
through everything. They are passed the item and nothing else, and have access
to two methods on the this
object:
this.stop()
stops the current picker run after the present iteration.
this.handle(name: string)
schedules the handler name
to be
executed with the item as parameter. As soon as this.handle()
is called, the item is removed from the queue. Subsequent calls
to this.handle()
within the same function will schedule
additional handlers for the same item.
var pickerId = sch.addPicker(function(item) {
if (item % 2 === 0) {
this.handle('something');
}
if (item === 42) {
this.stop();
}
});
It returns the pickerId
, which can be used to modify the picker at runtime.
This is mostly useful to adjust the interval
or limit
. A limit of 0 will
disable the picker.
Start processing the queue. Useful if you need to do some preparation before firing things off but still want to be able to push things onto the queue.
Access the array of pickers. This is useful to modify a picker, see above.
You may want to know whether you've called start() yet. Or not.
Using debug: true
in the instantiation config exposes both internal queues
(todo
and doing
) and the handlers
object. These are not useful for most
cases, but if you need them they're just a flag away, no need to tweak shit.
package.json
.npm test
to ensure it works.npm run-script lint
to ensure you're good.FAQs
Simple schedule-managed queue
The npm package fantail receives a total of 126 weekly downloads. As such, fantail popularity was classified as not popular.
We found that fantail 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.