Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

More robust check for running under node #10

Merged
merged 1 commit into from

2 participants

@gmethvin

Check if module.exports exists, since this is a more reliable check if
we are running under node. Checking for window conflicts with some
node modules like d3 that define a global window object.

@gmethvin gmethvin More robust check for running under node
Check if module.exports exists, since this is a more reliable check if
we are running under node. Checking for window conflicts with some
node modules like d3 that define a global window object.
b4fb631
@gmethvin

Fixes #7.

@alexgorbatchev I know this will still not work correctly if module.exports is defined on the browser, but I think that's far less likely than window being defined in node. I've seen many other modules use a similar strategy for detecting node.

@alexgorbatchev alexgorbatchev merged commit 3f931f9 into alexgorbatchev:master
@alexgorbatchev

Thank you very much for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. @gmethvin

    More robust check for running under node

    gmethvin authored
    Check if module.exports exists, since this is a more reliable check if
    we are running under node. Checking for window conflicts with some
    node modules like d3 that define a global window object.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/crc.js
View
2  lib/crc.js
@@ -399,7 +399,7 @@
var target, property;
- if(typeof(window) == 'undefined')
+ if(typeof(module) !== 'undefined' && module.exports)
{
target = module;
property = 'exports';
Something went wrong with that request. Please try again.