Skip to content

Commit

Permalink
UMD-ified js file so can work as is outaide of Node
Browse files Browse the repository at this point in the history
  • Loading branch information
railsagainstignorance committed May 31, 2017
1 parent f8740e0 commit 74acd22
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/js/crossword_parser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Using UMD (Universal Module Definition), see https://github.com/umdjs/umd, and Jake,
// for a js file to be included as-is in Node code and in browser code.
(function (root, factory) {
if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory();
} else {
// Browser globals (root is window)
root.CrosswordDSL = factory();
}
}(this, function () {
// given the DSL, ensure we have all the relevant pieces,
// and assume there will be subsequent checking to ensure they are valid
function parseDSL(text){
Expand Down Expand Up @@ -489,7 +502,8 @@
return jsonText;
}

module.exports = {
return {
'whateverItIs' : parseWhateverItIs,
'intoSpecJson' : parseWhateverItIsIntoSpecJson
};
}));

0 comments on commit 74acd22

Please sign in to comment.