Skip to content

Commit

Permalink
Can register under window and global if available
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Aug 31, 2015
1 parent 805282f commit 7b3f154
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "lazy-ass",
"main": "index.js",
"version": "0.5.8",
"version": "0.6.0",
"homepage": "https://github.com/bahmutov/lazy-ass",
"license": "MIT",
"ignore": [
Expand Down
10 changes: 8 additions & 2 deletions index.js
Expand Up @@ -99,12 +99,18 @@
};

function register(value, name) {
var registered;
if (typeof window === 'object') {
/* global window */
window[name] = value;
} else if (typeof global === 'object') {
registered = true;
}
if (typeof global === 'object') {
global[name] = value;
} else {
registered = true;
}

if (!registered) {
throw new Error('Do not know how to register ' + name);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "lazy-ass",
"description": "Lazy assertions without performance penalty",
"version": "0.5.8",
"version": "0.6.0",
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",
"bugs": {
"url": "https://github.com/bahmutov/lazy-ass/issues"
Expand Down

0 comments on commit 7b3f154

Please sign in to comment.