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

async-define

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-define - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

3

lib/asyncDefine.js

@@ -43,2 +43,5 @@ (function (w){

function execute (item){
if (item.name in cached_dependencies) { // don't execute twice
return true;
}
var deps = getDepsArray(item.depNames);

@@ -45,0 +48,0 @@ var exp;

2

package.json
{
"name": "async-define",
"version": "1.0.0",
"version": "2.0.0",
"description": "Coordinate the execution of asynchronous scripts",

@@ -5,0 +5,0 @@ "main": "lib/asyncDefine.js",

@@ -44,5 +44,18 @@ asyncDefine

```
It is also protecting you for executing the same common libraries twice. For example:
```js
defineAsync('script1', function (){
// will I be executed ?
return;
});
defineAsync('script1', function (){
// will I be executed ?
return;
});
```
In the previous example only one of these will be executed.
Syntax
------
The syntax resemble a lot AMD (http://requirejs.org/docs/api.html#define). There is only one function:
The syntax resembles a lot AMD (http://requirejs.org/docs/api.html#define). There is only one function:
```js

@@ -131,1 +144,2 @@ defineAsync(name, [array of dependencies], func);

All will be downloaded asynchronously with the maximum performances!
There is also a transformer available https://github.com/tes/browserify-async-define

@@ -62,3 +62,26 @@ var asyncDefine = require('../lib/asyncDefine');

it("mustn't execute the same dep twice", function (done) {
var counter = 0;
setTimeout(function (){
asyncDefine("duplicated", function (){
counter++;
return "duplicated1";
});
}, 10);
setTimeout(function (){
asyncDefine("duplicated", function (hello){
counter++;
return "duplicated2";
});
}, 20);
setTimeout(function (){
assert.equal(counter, 1);
done();
}, 50);
});
});
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