Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aa

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aa - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

2

package.json
{
"name": "aa",
"version": "0.1.5",
"version": "0.1.6",
"description": "aa - Async-Await. co like library, go like channel, thunkify or promisefy wrap package",

@@ -5,0 +5,0 @@ "main": "aa.js",

@@ -42,4 +42,4 @@ [aa](https://www.npmjs.com/package/aa) - async await

// wait(ms, args,... cb) : node style normal callback
function wait(ms) {
// sleep(ms, args,... cb) : node style normal callback
function sleep(ms) {
var args = [].slice.call(arguments, 1);

@@ -49,3 +49,3 @@ setTimeout.apply(null, [args.pop(), ms, null].concat(args));

wait(1000, function (err, val) { console.log('1000 ms OK'); });
sleep(1000, function (err, val) { console.log('1000 ms OK'); });

@@ -57,3 +57,3 @@

return function (cb) {
wait.apply(null, args.concat(cb));
sleep.apply(null, args.concat(cb));
};

@@ -68,12 +68,12 @@ }

// aa(fn) | aa.wrap(fn) : returns wrapped function a.k.a thunkify and promisefy
// sleep(ms, args,...) : returns promise & thunk
var sleep = aa(wait);
// wait(ms, args,...) : returns promise & thunk
var wait = aa(sleep);
// sleep() : as a thunk
sleep(1200)(
// wait() : as a thunk
wait(1200)(
function (err, val) { console.log('1200 ms OK'); }
);
// sleep() : as a promise
sleep(1300).then(
// wait() : as a promise
wait(1300).then(
function (val) { console.log('1300 ms OK'); },

@@ -103,7 +103,7 @@ function (err) { console.log('1300 ms NG', err); }

// wait for promise or thunk
yield sleep(800);
yield wait(800);
console.log('0:', yield sleep(300, 0));
console.log('1:', yield sleep(300, 1));
console.log('0:', yield wait(300, 0));
console.log('1:', yield wait(300, 1));

@@ -113,3 +113,3 @@

console.log('[1, 2, 3]:',
yield Promise.all([sleep(200, 1), sleep(300, 2), sleep(100, 3)]));
yield Promise.all([wait(200, 1), wait(300, 2), wait(100, 3)]));

@@ -119,3 +119,3 @@

console.log('[4, 5, 6]:',
yield [sleep(200, 4), sleep(300, 5), sleep(100, 6)]);
yield [wait(200, 4), wait(300, 5), wait(100, 6)]);

@@ -125,3 +125,3 @@

console.log('{x:7, y:8, z:9}:',
yield {x:sleep(200, 7), y:sleep(300, 8), z:sleep(100, 9)});
yield {x:wait(200, 7), y:wait(300, 8), z:wait(100, 9)});

@@ -132,4 +132,4 @@

wait(300, 20, chan); // send value to channel
wait(200, 10, chan); // send value to channel
sleep(300, 20, chan); // send value to channel
sleep(200, 10, chan); // send value to channel
var a = yield chan; // recv value from channel

@@ -142,3 +142,3 @@ var b = yield chan; // recv value from channel

aa(function *() {
yield sleep(200); // sleep 200
yield wait(200); // wait 200 ms
return 200;

@@ -149,3 +149,3 @@ })(chan); // send 200 to channel

aa(function *() {
yield sleep(100); // sleep 100
yield wait(100); // wait 100 ms
return 100;

@@ -156,3 +156,3 @@ })(chan); // send 100 to channel

aa(function *() {
yield sleep(300); // sleep 300
yield wait(300); // wait 300
return 300;

@@ -162,5 +162,5 @@ })(chan); // send 300 to channel

// join threads - sync threads
var x = yield chan; // wait and recv first value from channel
var y = yield chan; // wait and recv second value from channel
var z = yield chan; // wait and recv third value from channel
var x = yield chan; // wait & recv first value from channel
var y = yield chan; // wait & recv second value from channel
var z = yield chan; // wait & recv third value from channel
console.log('top 3 winners: 100 200 300:', x, y, z);

@@ -174,7 +174,7 @@

aa(function *() {
wait(100, 111, chan1);
sleep(100, 111, chan1);
console.log('222:', yield chan2);
wait(100, 333, chan1);
sleep(100, 333, chan1);
console.log('444:', yield chan2);
wait(100, 555, chan1);
sleep(100, 555, chan1);
return 666;

@@ -186,5 +186,5 @@ })(chan);

console.log('111:', yield chan1);
wait(100, 222, chan2);
sleep(100, 222, chan2);
console.log('333:', yield chan1);
wait(100, 444, chan2);
sleep(100, 444, chan2);
console.log('555:', yield chan1);

@@ -200,20 +200,20 @@ return 777;

console.log('11 val:', val);
return sleep(100, 22); },
return wait(100, 22); },
function (err) {
console.log('11 err:', err);
return sleep(100, 22); }
return wait(100, 22); }
)
(function (err, val) {
console.log('22 val:', val, err ? 'err:' + err : '');
return sleep(100, 33); })
return wait(100, 33); })
(function (err, val) {
console.log('33 val:', val, err ? 'err:' + err : '');
return sleep(100, 44); })
return wait(100, 44); })
.then(
function (val) {
console.log('44 val:', val);
return sleep(100, 55); },
return wait(100, 55); },
function (err) {
console.log('44 err:', err);
return sleep(100, 55); }
return wait(100, 55); }
)

@@ -223,3 +223,3 @@ .catch(

console.log('55 err:', err);
return sleep(100, 66); }
return wait(100, 66); }
);

@@ -226,0 +226,0 @@ ```

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