Skip to content

szepeviktor/amd-global

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amd-global

Helps grabbing the global object. Works in a browser window, in node.js global, in Web Workers self.

Usage with curl.js

Your AMD module should depend on AMD global:

// Uses AMD or browser globals to create a jQuery plugin.
(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['jquery', 'amd-global'], factory);
    } else {
        // Browser globals
        factory(jQuery, this);
    }
}(function ($, global, undefined) {
...
}));

Why protect undefined?

You can read about it in this SO question

Are you looking for browser-only version?

amd-window

Idea of unscriptable and briancavalier.

Available in the Bower Registry

bower install amd-global

About

A module that grabs the current global for multiple environments

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published