New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

udefine

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

udefine

udefine =======

  • 0.7.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

udefine

Define a module as an AMD module and handle it as if it's an UMD module

Features

  • Provides a handy function wrapper for UMD modules
  • Same fuction signature as AMD modules
  • No need for boilerplate definitions
  • Less than 0.4 kB minified and gzipped

Usage

(function(root) {
  // This definition only needs to be done once, not per module
  root.udefine.globals.jquery = this.jQuery;
})(this);

udefine('mymodule', ['jquery'], function($) {
  $.fn.myModule = function() { /* ... */ };
});

If an AMD module loader like RequireJS has been integrated and configured, it will resolve through the AMD loader.

Alright, that's really great for jQuery modules. But what if you want to bind a module the global namespace if there is no AMD or CommonJS.

(function(root) {
  root.udefine.inject['myothermodule'] = {
    root: root,
    name: 'myOtherModule'
  };
})(this);

udefine('myothermodule', function() {
  return {
    a: function() { return 5; },
    b: 2
  };
});

// root.myOtherModule now is an object with the properties a and b.
// (In a non-AMD or non-CommonJS environment.)

udefine is not and does not replace a module loader. It is primarily intended for developers who want their library to target AMD modules, CommonJS modules and/or the classic way of binding object to the global window object.

For more examples, take a look at the examples folder.

License
This is public domain. See UNLICENSE.md for more information.

FAQs

Package last updated on 04 Sep 2013

Did you know?

Socket

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.

Install

Related posts

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