In answer to http://stackoverflow.com/questions/44034049/why-doesnt-rollup-js-treeshake-my-library/44036934?noredirect=1#comment75114138_44036934 — paste this code into https://rollupjs.org/repl
Created
May 18, 2017 23:56
-
-
Save Rich-Harris/7861d982561a4d1457171ed783cde49c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _Calc() { | |
} | |
_Calc.prototype._ = function () { | |
return new _Calc(); | |
}; | |
_Calc.prototype.Sign = function (x) { | |
return typeof x === "number" ? x ? x < 0 ? -1 : 1 : x === x ? 0 : NaN : NaN; | |
}; | |
_Calc.prototype.RotationDeg = function (rotation) { | |
var rot = (rotation * _Calc.ROTATION_DEGREE_PRECISION) | 0; | |
while (rot < 0) { | |
rot += _Calc.DEG360; | |
} | |
while (rot >= _Calc.DEG360) { | |
rot -= _Calc.DEG360; | |
} | |
return _Calc.ROTATION_LOOKUP[rot]; | |
}; | |
_Calc.prototype.RotationRad = function (rotation) { | |
var rot = rotation * _Calc.DEGREE_FACTOR * _Calc.ROTATION_DEGREE_PRECISION | 0; | |
return this.RotationDeg(rot / _Calc.ROTATION_DEGREE_PRECISION); | |
}; | |
_Calc.prototype.ClosestRadianRotation = function (rotation) { | |
var rot = rotation * _Calc.DEGREE_FACTOR * _Calc.ROTATION_DEGREE_PRECISION | 0; | |
while (rot < 0) { | |
rot += _Calc.DEG360; | |
} | |
while (rot >= _Calc.DEG360) { | |
rot -= _Calc.DEG360; | |
} | |
return rot * _Calc.RADIAN_FACTOR / _Calc.ROTATION_DEGREE_PRECISION; | |
}; | |
_Calc.ROTATION_DEGREE_PRECISION = 1; | |
_Calc.RADIAN_FACTOR = (1 / 360) * (2 * Math.PI); | |
_Calc.DEGREE_FACTOR = (1 / (2 * Math.PI) * 360); | |
_Calc.DEG360 = 360 * _Calc.ROTATION_DEGREE_PRECISION; | |
//_Calc.ROTATION_LOOKUP = (function () { | |
// var lookup = []; | |
// for (var i = 0; i < 360 * _Calc.ROTATION_DEGREE_PRECISION; i++) { | |
// lookup.push([Math.cos(i * _Calc.RADIAN_FACTOR), Math.sin(i * _Calc.RADIAN_FACTOR)]); | |
// } | |
// return lookup; | |
//})(); | |
//var Calc = new _Calc(); | |
export { _Calc as Calc }; | |
//# sourceMappingURL=goodcore.es.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Calc } from './goodcore.js'; | |
// console.log( new Calc() ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment