Skip to content

Commit

Permalink
add AMD compat; export in Node.js as a function instead of object
Browse files Browse the repository at this point in the history
  • Loading branch information
mourner committed Jun 1, 2013
1 parent 9f52288 commit 6d0406e
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions simplify.js
Expand Up @@ -161,13 +161,9 @@
}


var root = (typeof exports !== undefined + '')
? exports
: global;

// both algorithms combined for awesome performance

root.simplify = function (points, tolerance, highestQuality) {
function simplify(points, tolerance, highestQuality) {

var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;

Expand All @@ -177,4 +173,19 @@
return points;
};

}(this));

// export either as a Node.js module, AMD module or a global browser variable

if (typeof exports === 'object') {
module.exports = simplify;

} else if (typeof define === 'function' && define.amd) {
define(function () {
return simplify;
});

} else {
global.simplify = simplify;
}

}(this));

0 comments on commit 6d0406e

Please sign in to comment.