Comparing version
{ | ||
"name": "undefine", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"description": "Universal Module Loader, for node.js, browser scripts, bundles, and AMD define loaders", | ||
@@ -5,0 +5,0 @@ "main": "undefine.js", |
@@ -13,4 +13,13 @@ # Undefine | ||
Stability: Feature complete, used by [toubkal](https://github.com/ReactiveSets/toubkal), needs CI testing. | ||
Stability: Stable, used by [toubkal](https://github.com/ReactiveSets/toubkal). | ||
## Features | ||
- Allows dual dependencies definitions for the browser and node | ||
- Shortest module biolerplate | ||
- Comprehensive, trully works in all situations, unlike UMD which is broken | ||
- Smallest footprint | ||
- Compatible with AMD module loaders such as require.js and curl-amd | ||
- Does not require a build process | ||
## Example | ||
@@ -135,4 +144,4 @@ | ||
As an extension to AMD dependencies specification, a dependency may be specified with | ||
an Array of two strings where the first string is the exported name and the second | ||
string is the Node.js module name. | ||
an Array of two strings where the first string is the exported name in the browser and | ||
the second string is a Nodejs module name. | ||
@@ -150,2 +159,20 @@ Example: the following **loggable** module has two dependencies, the first is | ||
Also, if a module is not available on the browser or in node, one can specify a non-string | ||
value, typically falsy, where the module is not available. | ||
Example: Node module **css-select** emulates CSS3 querySelector() method. To use this module | ||
one can apply the following definition for dependencies: | ||
```javascript | ||
( this.undefine || require( 'undefine' )( module, require ) )() | ||
( 'query_selector', [ [ 0, 'css-select' ] ], function( css_select ) { | ||
var selector = '#comments'; | ||
return css_select | ||
? css_select.selectOne( selector, [] /* should be an htmlparse2 document or element */ ) | ||
: document.querySelector( selector ) | ||
; | ||
} ) | ||
``` | ||
## Licence | ||
@@ -152,0 +179,0 @@ |
@@ -174,5 +174,9 @@ /* undefine.js | ||
var f = 'require_global()' | ||
, name = disambiguate( dependency ).split( '/' ).pop() | ||
, name = disambiguate( dependency ) | ||
; | ||
if ( typeof name != 'string' ) return name; // dependency name is the exported value | ||
name = name.split( '/' ).pop(); | ||
de&&ug( f, 'name:', name ); | ||
@@ -179,0 +183,0 @@ |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
29263
35.3%13
8.33%184
1.1%198
15.79%1
Infinity%