Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to work in non-browser env #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/convnet_export.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(function(lib) {
"use strict";
if (typeof module === "undefined" || typeof module.exports === "undefined") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already takes care of seeing if you are in browser env or not. Node env has module/module.exports, otherwise you are loading the lib from browser, thus window will be defined.

window.convnetjs = lib; // in ordinary browser attach library to window
// By declaring convnetjs globally, we have already made it available.
// Nothing to do here.
} else {
module.exports = lib; // in nodejs
}
Expand Down