Permalink
Browse files

Add UMD support

PR-URL: #212
Fixes: #197
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
  • Loading branch information...
budnix authored and trevnorris committed Jul 12, 2017
1 parent 60e866c commit 096c933485a7e066f97d52f803369eaf18c94337
Showing with 51 additions and 8 deletions.
  1. +3 −1 Makefile
  2. +5 −0 src/_footer.js
  3. +9 −0 src/_header.js
  4. +1 −1 src/core.js
  5. +1 −1 src/distribution.js
  6. +1 −1 src/linearalgebra.js
  7. +1 −1 src/models.js
  8. +1 −1 src/special.js
  9. +1 −1 src/test.js
  10. +1 −1 src/vector.js
  11. +27 −0 test/umd/commonjs-test.js
View
@@ -17,13 +17,15 @@ clean:
core: jstat.js jstat.min.js
jstat.js: \
src/_header.js \
src/core.js \
src/vector.js \
src/special.js \
src/distribution.js \
src/linearalgebra.js \
src/test.js \
src/models.js
src/models.js \
src/_footer.js
@echo 'Building jStat'
@mkdir -p $(DIST_DIR)
@cat $^ > $(DIST_DIR)/$@
View
@@ -0,0 +1,5 @@
// Make it compatible with previous version.
jStat.jStat = jStat;
return jStat;
});
View
@@ -0,0 +1,9 @@
(function (window, factory) {
if (typeof exports === 'object') {
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
define(factory);
} else {
window.jStat = factory();
}
})(this, function () {
View
@@ -1,4 +1,4 @@
this.j$ = this.jStat = (function(Math, undefined) {
var jStat = (function(Math, undefined) {
// For quick reference.
var concat = Array.prototype.concat;
View
@@ -1515,4 +1515,4 @@ jStat.extend(jStat.tukey, {
}
});
}(this.jStat, Math));
}(jStat, Math));
View
@@ -1018,4 +1018,4 @@ jStat.extend({
}(funcs[i]));
}('add divide multiply subtract dot pow exp log abs norm angle'.split(' ')));
}(this.jStat, Math));
}(jStat, Math));
View
@@ -1,4 +1,4 @@
this.jStat.models=(function(){
jStat.models = (function(){
function sub_regress(endog, exog) {
return ols(endog, exog);
View
@@ -465,4 +465,4 @@ jStat.randg = function randg(shape, n, m) {
})(funcs[i]);
})('randn'.split(' '));
}(this.jStat, Math));
}(jStat, Math));
View
@@ -340,4 +340,4 @@ jStat.extend(jStat.fn, {
}
});
}(this.jStat, Math));
}(jStat, Math));
View
@@ -547,4 +547,4 @@ var jProto = jStat.prototype;
})(funcs[i]);
})('quantiles percentileOfScore'.split(' '));
}(this.jStat, Math));
}(jStat, Math));
View
@@ -0,0 +1,27 @@
var vows = require('vows');
var assert = require('assert');
var suite = vows.describe('jStat.commonjs');
suite.addBatch({
'jStat': {
'topic': function() {
return require('./../../dist/jstat.js');
},
'should be defined': function(jStat) {
assert.equal(typeof jStat, 'function');
// Check some random functions
assert.equal(typeof jStat.rows, 'function');
assert.equal(typeof jStat.min, 'function');
assert.equal(typeof jStat.betafn, 'function');
assert.equal(typeof jStat.beta.pdf, 'function');
assert.equal(typeof jStat.add, 'function');
assert.equal(typeof jStat.zscore, 'function');
},
'should export jStat object under the "jStat" property for compatibility reasons': function(jStat) {
assert.equal(jStat.jStat, jStat);
},
}
});
suite.export(module);

0 comments on commit 096c933

Please sign in to comment.