![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
asynk
Advanced tools
Readme
Asynk is a small tool for javascript asynchronous task management.
asynk.add(fs.open).args('./TEST.txt','w',asynk.callback)
.add(fs.write).args(asynk.data(0),new Buffer('hello world'),0,11,null,asynk.callback)
.add(fs.close).args(asynk.data(-2),asynk.callback)
.add(fs.readFile).args('./TEST.txt', "utf8",asynk.callback).alias('content')
.serie(console.log,[asynk.data('content')]);
//Log 'hello world' in console
Asynk adapt to fit your functions syntax without writting a warper function and can dynimaquely get results from a task output back to an other input and more... see full documentation below.
Install from NPM.
$ npm install asynk
Asynk command must start by adding one or more task using functions:
add(fct)
add one task
arguments:
asynk.add(my_function).args(my_first_argument,asynk.callback) //...
this make asynk create a manager with one task
each(array_data,fct)
add a task per array's item of the same function
arguments:
asynk.each([0,1,2],my_function).args(asynk.item,asynk.callback) //...
this make asynk create a manager with tree tasks(asynk.item is on value of the array in input) witch is the equivalent of:
asynk.add(my_function).args(0,asynk.callback)
.add(my_function).args(1,asynk.callback)
.add(my_function).args(2,asynk.callback) //...
args(arg1,arg2,...)
arguments:
the args function define arguments of function passed to the task. simply pass arguments like executing the function and replace the callback function by asynk.callback
asynk.add(my_function).args(0,asynk.callback) //...
will execute the function like this :
function callback(err,data){
//the callback function
}
my_function(0,callback); //...
asynk.data(task)
data put output of a task to the input of another one.
arguments:
//create a first task
asynk.add(my_function).args(0,asynk.callback)
//absolute position task data (here first one)
.add(my_function).args(asynk.data(0),asynk.callback)
//relative position task data (here the second one)
.add(my_function).args(asynk.data(-1),asynk.callback)
//assinging an alias name to this task
.add(my_function).args(0,asynk.callback).alias('here')
//alias name task data (here the fourth)
.add(my_function).args(asynk.data('here'),asynk.callback)
//...
require(dependency)
require function make task waiting an other one to finish before start.
arguments:
//create a first task
asynk.add(my_function0).args(0,asynk.callback)
//alias name task requirement (here the fifth)
.add(my_function1).args(4,asynk.callback).require('here')
//absolute position task requirement (here the fifth)
.add(my_function2).args(1,asynk.callback).require(4)
//relative position task requirement (here the third)
.add(my_function3).args(2,asynk.callback).require(-1)
//assinging an alias name to this task
.add(my_function4).args(3,asynk.callback).alias('here')
//...
here my_function0 and my_function4 will be execute first. then on my_function4's end,my_function1 and my_function2 will be execute. and so on my_function2's end,my_function3 will be execute.
Asynk command must finnish by choosing an excution mode:
serie(fct,args)
arguments:
in this mode,all task are execute one by one in the order they where inserted.
asynk.each(['one','two'],my_function).args(asynk.item,asynk.callback)
.serie(console.log,[asynk.data('all')]);
here my_function is called with argument 'one',once this function ended,the same function is called with argument 'two'. when every task are finnished,the function passed to serie is called with args arguments array.
parallel(fct,args)
arguments:
in this mode,all task are started at the same time.
asynk.each(['one','two'],my_function).args(asynk.item,asynk.callback)
.parallel(console.log,[asynk.data('all')]);
here my_function is called with argument 'one' and a second time with 'two' without waiting anything. when every task are finnished,the function passed to parallel is called with args arguments array.
parallelLimited(limit,fct,args)
arguments:
in this mode,a predefined number(limit) of task are running in the same time.
asynk.each([0,0,0,0],my_function).args(asynk.item,asynk.callback)
.parallelLimited(2,console.log,[asynk.data('all')]);
here my_function is called four time with 0 as argument but two time before and one time after a callback is called until all four tasks are done. when every task are finnished,the function passed to parallelLimited is called with args arguments array.
first pushed function are first executed
create a fifo stack object:
var fifo = asynk.fifo();
push(fct) arguments:
return a function that take fct arguments as arguments
var result = '';
var fifo = asynk.fifo();
var f1 = fifo.push(function(err,data){result += data;});
var f2 = fifo.push(function(err,data){result += data;});
var f3 = fifo.push(function(err,data){result += data;});
var f4 = fifo.push(function(err,data){result += data;});
var f5 = fifo.push(function(err,data){result += data;});
var f6 = fifo.push(function(err,data){result += data;});
f6(null,6);
f2(null,2);
f4(null,4);
f1(null,1);
f3(null,3);
f5(null,5);
console.log(result); //123456
function are executed in a predefined order
create a progressive stack object:
var progr = asynk.progressive(start,step);
arguments:
push(order,fct) arguments:
var result = '';
var progr = asynk.progressive();
progr.push(6,function(err,data){result += data;})(null,6);
progr.push(2,function(err,data){result += data;})(null,2);
progr.push(4,function(err,data){result += data;})(null,4);
progr.push(1,function(err,data){result += data;})(null,1);
progr.push(3,function(err,data){result += data;})(null,3);
progr.push(5,function(err,data){result += data;})(null,5);
console.log(result); //123456
FAQs
Asynk is a feature-rich JavaScript library designed to simplify common asynchronous JavaScript programming tasks.
The npm package asynk receives a total of 58 weekly downloads. As such, asynk popularity was classified as not popular.
We found that asynk 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
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.