
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
#Dotcall ###Dotcall is a callback hell remedy.
Instead of building complex async ladders, you can write your code in a manner similar to conventional synchronous style.
The theory behind it is this:
async(callback), usually it does nothing and returns. Sometimes the asynchronous function could return something useful, but most of the time it just returns undefined and the real stuff is returned with callback(result).The syntax of dotcall is very simple, when the call's brace is preceeded with a dot .(, then the call is converted (hence the name):
var a = f.()
console.log(a)
Is replaced with
f(function(DOTCALL1) { var a = DOTCALL1
console.log(a)
})
###New: loops with for.() and while.()
You can use for.() and while.() syntax. break statement is supported. Nesting loops are not tested, they will probably not work. You can use very long loops, there will be no stack overflow, because async calls are made with setImmediate.
function bar(s,f) {
setTimeout(function() {
console.log('bar'+s)
f()
}, 200)
}
function main() {
for.(var i = 0; i < 5; i++) {
bar.('X'::2)
}
console.log('AFTER')
}
the above loop is translated to this:
function main() {
var i = 0; function DOTCALL2(DOTCALL3) {
if ((i < 5) == false) { DOTCALL3(); return }
bar('X', function (DOTCALL5,DOTCALL6) { DOTCALL6
i++; setImmediate(DOTCALL2, DOTCALL3)
}) }
DOTCALL2(function() {
console.log('AFTER')
})}
In case your callback uses more than one parameter, there is an extended syntax, called double colon syntax.
redis.set.('a', 12345)
redis.get.('a' :: err, data)
if (err) console.log(err)
console.log(data) // outputs 12345
Another case of double colon notation is to specify the useful argument number like this:
redis.set.('a', 12345)
console.log(redis.get.('a' :: 2))
the above outputs 12345, because Redis function get(err, data) uses data as a second parameter
###Usage tips
this, because it will be bound to silently created functions, use known patterns like var me = this and then use me instead..(return can be used to abort your block of functions, but remember that although the execution will not happen after the line with return, the return is actually rather just an exit, returning values from nested hell entries is way too tricky.dotcall.js manually###install with npm
npm install dotcall
###install with git
git clone https://github.com/exebook/dotcall.git
require('dotcall')
require('./sample.dc')
###console invocation:
node .call.js sample.dc
###Complete minimalistic example sample.dc:
function foo(f) {
setTimeout(function() { f(true) }, 200)
}
function bar(x, f) {
setTimeout(function() { f(500 + x) }, 200)
}
function main() {
if (foo.()) {
var d = bar.(55)
console.log(d)// outputs 555
}
}
main()
###Minimalistic Redis example:
var redis = require("redis").createClient()
function main() {
redis.set.('a', 555)
redis.get.('a' :: e, d)
console.log(d)
if (d == '555') {
redis.set.('b', parseInt(d) + 1)
var d = redis.get.('b' :: 2)
console.log(d)
redis.del.('a')
redis.del.('b')
redis.quit()
} else {
redis.quit()
}
}
main()
###extension handling
By default dotcall require() will only handle .dc file extension, leaving normal .js intact. But if you want you can tell it to handle any extension you want like this:
var dotcall = require('dotcall')
dotcall.handleExt('.js')
require('./sample.js') // now .js is handled with dotcall, beware
###implementation details dotcall does not use any established lexers or parsers, instead it has a very simple lexer, and then does some logic with the array of returned tokens.
###files
##further reading
https://bjouhier.wordpress.com/2012/03/11/fibers-and-threads-in-node-js-what-for/
FAQs
callback hell remedy, syntax sugar
The npm package dotcall receives a total of 2 weekly downloads. As such, dotcall popularity was classified as not popular.
We found that dotcall 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.