![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Universal Module Loader, for node.js, browser scripts, bundles, and AMD define loaders
Universal Module Loader, for node.js, browser scripts, bundles, and AMD define loaders
< 1 kB minified gzip, does not reinvent the wheel, if you need a dynamic AMD script loader pick one, undefine cooperates.
( this.undefine || require( 'undefine' )( module, require ) )()
( 'fibonacci', [], function() {} )
Stability: Stable, used by toubkal.
Fibonacci number calculator module
( this.undefine || require( 'undefine' )( module, require ) )()
( 'fibonacci', [], function() {
return fibonacci;
// Naive recursive implementation of a Fibonacci number calculator
function fibonacci( n ) {
if ( n < 0 ) return;
if ( n < 2 ) return n;
return fibonacci( n - 2 ) + fibonacci( n - 1 );
}
} )
var fibonacci = require( 'fibonacci' );
var n = 10;
console.log( 'fibonacci( ' + n + ' ) =', fibonacci( n ) );
<script src="undefine.js"></script>
<script src="fibonacci.js"></script>
<script>
require( [ 'fibonacci' ], function( fibonacci ) {
var n = 10;
console.log( 'fibonacci( ' + n + ' ) =', fibonacci( n ) );
}
</script>
fibonacci.js loaded dynamically:
<script src="require.js"></script>
<script src="undefine.js"></script>
<script>
require( [ './fibonacci' ], function( fibonacci ) {
var n = 10;
console.log( 'fibonacci( ' + n + ' ) =', fibonacci( n ) );
} )
</script>
Also works with curl-amd.
In first line of module:
( this.undefine || require( 'undefine' )( module, require ) )()
The module definition is then equivalent to:
define( 'fibonacci', [], function() {
// fibonacci implementation here
} )
Module ids must be set to the filename without the js extension, allowing to require modules loaded using script tags. To override global module names registered in the window Object, use the global option described bellow.
The optional Object parameter options can have the following attributes which all default to false and are browser-only options at this time:
Additional options when used in conjunction with an AMD loader:
Example usage to declare the fibonacci module as window.fib with no_conflict():
( this.undefine || require( 'undefine' )( module, require ) )
( { global: 'fib', no_conflict: true } )
( 'fibonacci', [], function() {
// fibonacci implementation here
} )
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 in the browser and the second string is a Nodejs module name.
Example: the following loggable module has two dependencies, the first is ./extend.js, while the second is uuid which is available either in the window global uuid or as Node.js module node-uuid:
( this.undefine || require( 'undefine' )( module, require ) )()
( 'loggable', [ './extend', [ 'uuid', 'node-uuid' ] ], function( extend, uuid ) {
// loggable implementation here
} )
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:
( 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 )
;
} )
The MIT License (MIT)
Copyright (c) 2015, Reactive Sets
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Universal Module Loader, for node.js, browser scripts, bundles, and AMD define loaders
The npm package undefine receives a total of 12 weekly downloads. As such, undefine popularity was classified as not popular.
We found that undefine 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.