Comparing version 0.5.2 to 0.5.3
45
mate.js
@@ -767,22 +767,23 @@ // Generated by CoffeeScript 1.6.3 | ||
EventField = (function() { | ||
function EventField() { | ||
this._listeners = []; | ||
} | ||
EventField.prototype.bind = function(listener) { | ||
if (__indexOf.call(this._listeners, listener) < 0) { | ||
this._listeners.push(listener); | ||
} | ||
EventField = function() { | ||
var f; | ||
f = function(method, arg) { | ||
assert(typeof method === "string"); | ||
f[method](arg); | ||
return this; | ||
}; | ||
EventField.prototype.unbind = function(listener) { | ||
this._listeners.removeAll(listener); | ||
return this; | ||
f._listeners = []; | ||
f.bind = function(listener) { | ||
if (__indexOf.call(f._listeners, listener) < 0) { | ||
f._listeners.push(listener); | ||
} | ||
return f; | ||
}; | ||
EventField.prototype.fire = function(arg) { | ||
f.unbind = function(listener) { | ||
f._listeners.removeAll(listener); | ||
return f; | ||
}; | ||
f.fire = function(arg) { | ||
var m, _i, _len, _ref; | ||
_ref = this._listeners; | ||
_ref = f._listeners; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
@@ -797,7 +798,5 @@ m = _ref[_i]; | ||
}; | ||
return f; | ||
}; | ||
return EventField; | ||
})(); | ||
ObjectWithEvents = (function() { | ||
@@ -1387,3 +1386,3 @@ function ObjectWithEvents() { | ||
this.precision = 30; | ||
this.onElapse = new EventField(); | ||
this.onElapse = EventField(); | ||
} | ||
@@ -1452,3 +1451,3 @@ | ||
this.includesEnd = false; | ||
this.onStart = new EventField(); | ||
this.onStart = EventField(); | ||
this.onElapse.bind(function(event) { | ||
@@ -1497,3 +1496,3 @@ _this.targetTime = event.idealTime.add(_this.interval); | ||
"name": "mate", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "A library that extends native JavaScript / CoffeeScript.", | ||
@@ -1500,0 +1499,0 @@ "keywords": ["library", "app", "javascript", "coffeescript", "js"], |
@@ -7,2 +7,2 @@ /* @preserve | ||
*/ | ||
var $mate,ArrayLazyWrapper,EventField,ObjectWithEvents,Point,assert,cmath,compose,fail,repeat,spread,__indexOf=[].indexOf||function(t){for(var e=0,r=this.length;e<r;e++){if(e in this&&this[e]===t)return e}return-1},__hasProp={}.hasOwnProperty,__extends=function(t,e){for(var r in e){if(__hasProp.call(e,r))t[r]=e[r]}function n(){this.constructor=t}n.prototype=e.prototype;t.prototype=new n;t.__super__=e.prototype;return t};$mate={};$mate.environmentType=typeof exports!=="undefined"&&exports!==null&&(typeof module!=="undefined"&&module!==null?module.exports:void 0)!=null?"node":typeof window!=="undefined"&&window!==null?"browser":void 0;ArrayLazyWrapper=function(){function t(t,e,r){var n=this;this._value=t;this._chain=(e!=null?e:[]).slice(0);if(r!=null){this._chain.push(r)}Object.getter(this,"length",function(){return n.force().length})}t.prototype.force=function(){var t,e,r,n,o;e=this._value;o=this._chain;for(r=0,n=o.length;r<n;r++){t=o[r];e=t.fun.apply(e,t.args)}return e};t.prototype.map=function(){return this._pushChain(Array.prototype.map,arguments)};t.prototype.filter=function(){return this._pushChain(Array.prototype.filter,arguments)};t.prototype.concat=function(){return this._pushChain(Array.prototype.concat,arguments)};t.prototype.portion=function(){return this._pushChain(Array.prototype.portion,arguments)};t.prototype.funSort=function(){return this._pushChain(Array.prototype.funSort,arguments)};t.prototype.funSortDescending=function(){return this._pushChain(Array.prototype.funSortDescending,arguments)};t.prototype.funReverse=function(){return this._pushChain(Array.prototype.funReverse,arguments)};t.prototype.except=function(){return this._pushChain(Array.prototype.except,arguments)};t.prototype.group=function(){return this._pushChain(Array.prototype.group,arguments)};t.prototype.flatten=function(){return this._pushChain(Array.prototype.flatten,arguments)};t.prototype.random=function(){return this._pushChain(Array.prototype.random,arguments)};t.prototype.some=function(){return this._unwrapAndDo(Array.prototype.some,arguments)};t.prototype.every=function(){return this._unwrapAndDo(Array.prototype.every,arguments)};t.prototype.isEmpty=function(){return this._unwrapAndDo(Array.prototype.isEmpty,arguments)};t.prototype.at=function(){return this._unwrapAndDo(Array.prototype.at,arguments)};t.prototype.atOrNull=function(){return this._unwrapAndDo(Array.prototype.atOrNull,arguments)};t.prototype.contains=function(){return this._unwrapAndDo(Array.prototype.contains,arguments)};t.prototype.first=function(){return this._unwrapAndDo(Array.prototype.first,arguments)};t.prototype.firstOrNull=function(){return this._unwrapAndDo(Array.prototype.firstOrNull,arguments)};t.prototype.last=function(){return this._unwrapAndDo(Array.prototype.last,arguments)};t.prototype.lastOrNull=function(){return this._unwrapAndDo(Array.prototype.lastOrNull,arguments)};t.prototype.single=function(){return this._unwrapAndDo(Array.prototype.single,arguments)};t.prototype.singleOrNull=function(){return this._unwrapAndDo(Array.prototype.singleOrNull,arguments)};t.prototype.withMax=function(){return this._unwrapAndDo(Array.prototype.withMax,arguments)};t.prototype.withMin=function(){return this._unwrapAndDo(Array.prototype.withMin,arguments)};t.prototype.max=function(){return this._unwrapAndDo(Array.prototype.max,arguments)};t.prototype.min=function(){return this._unwrapAndDo(Array.prototype.min,arguments)};t.prototype.sum=function(){return this._unwrapAndDo(Array.prototype.sum,arguments)};t.prototype.average=function(){return this._unwrapAndDo(Array.prototype.average,arguments)};t.prototype.median=function(){return this._unwrapAndDo(Array.prototype.median,arguments)};t.prototype.product=function(){return this._unwrapAndDo(Array.prototype.product,arguments)};t.prototype.randomOne=function(){return this._unwrapAndDo(Array.prototype.randomOne,arguments)};t.prototype._pushChain=function(e,r){return new t(this._value,this._chain,{fun:e,args:r})};t.prototype._unwrapAndDo=function(t,e){return t.apply(this.force(),e)};return t}();Array._elementOrUseSelector=function(t,e){if(e!=null){return e(t)}else{return t}};Array.prototype._numberToIndex=function(t){if(0<t&&t<1){return t=Math.round(t*(this.length-1))}else{return t}};Array.prototype._numberToLength=function(t){if(0<t&&t<1){return t=Math.round(t*this.length)}else{return t}};Array.prototype.copy=function(){return this.slice(0)};Array.prototype.isEmpty=function(){return this.length===0};Array.prototype.lazy=function(){return new ArrayLazyWrapper(this)};Array.prototype.portion=function(t,e,r){if(Number.isFraction(t)||Number.isFraction(e)||Number.isFraction(r)){if(t===0){t=0+Number.EPSILON}if(t===1){t=1-Number.EPSILON}if(e===0){e=0+Number.EPSILON}if(e===1){e=1-Number.EPSILON}if(r===0){r=0+Number.EPSILON}if(r===1){r=1-Number.EPSILON}}t=this._numberToIndex(t);e=this._numberToLength(e);r=this._numberToIndex(r);return this.slice(t,e!=null?t+e:r+1)};Array.prototype.at=function(t){t=this._numberToIndex(t);assert(0<=t&&t<this.length);return this[t]};Array.prototype.atOrNull=function(t){try{return this.at(t)}catch(t){return null}};Array.prototype.contains=function(t){return __indexOf.call(this,t)>=0};Array.prototype.first=function(t){var e;e=t!=null?this.filter(t):this;return e.at(0)};Array.prototype.firstOrNull=function(t){try{return this.first(t)}catch(t){return null}};Array.prototype.last=function(t){var e;e=t!=null?this.filter(t):this;return e.at(e.length-1)};Array.prototype.lastOrNull=function(t){try{return this.last(t)}catch(t){return null}};Array.prototype.single=function(t){var e;e=t!=null?this.filter(t):this;assert(e.length===1);return e.at(0)};Array.prototype.singleOrNull=function(t){try{return this.single(t)}catch(t){return null}};Array.prototype.withMax=function(t){var e=this;return this.reduce(function(e,r,n){if(Array._elementOrUseSelector(e,t)>Array._elementOrUseSelector(r,t)){return e}else{return r}})};Array.prototype.withMin=function(t){var e=this;return this.reduce(function(e,r,n){if(Array._elementOrUseSelector(e,t)<Array._elementOrUseSelector(r,t)){return e}else{return r}})};Array.prototype.max=function(t){return Array._elementOrUseSelector(this.withMax(t),t)};Array.prototype.min=function(t){return Array._elementOrUseSelector(this.withMin(t),t)};Array.prototype.sum=function(t){var e=this;if(this.length===1){return Array._elementOrUseSelector(this.first(),t)}else{return this.reduce(function(e,r,n){return(n===1?Array._elementOrUseSelector(e,t):e)+Array._elementOrUseSelector(r,t)})}};Array.prototype.average=function(t){return this.sum(t)/this.length};Array.prototype.median=function(t){var e,r,n,o,i;i=this.funSort(t);e=i.at(.5-Number.EPSILON);r=i.at(.5+Number.EPSILON);n=Array._elementOrUseSelector(e,t);o=Array._elementOrUseSelector(r,t);return(n+o)/2};Array.prototype.product=function(t){var e=this;if(this.length===1){return Array._elementOrUseSelector(this.first(),t)}else{return this.reduce(function(e,r,n){return(n===1?Array._elementOrUseSelector(e,t):e)*Array._elementOrUseSelector(r,t)})}};Array.prototype.group=function(t,e){var r,n,o,i,u,a,s,p;if(this.isEmpty()){return[]}a=this.funSort(t);o=[];r=Array._elementOrUseSelector(a.first(),t);n=[];for(s=0,p=a.length;s<p;s++){u=a[s];i=Array._elementOrUseSelector(u,t);if(i!==r){o.push({key:r,result:Array._elementOrUseSelector(n,e)});r=i;n=[]}n.push(u)}o.push({key:r,result:Array._elementOrUseSelector(n,e)});return o};Array.prototype._sort=function(t,e){var r=this;return this.copy().sort(function(r,n){var o,i;o=Array._elementOrUseSelector(r,t);i=Array._elementOrUseSelector(n,t);if(o<i){if(e){return 1}else{return-1}}else if(o>i){if(e){return-1}else{return 1}}else{return 0}})};Array.prototype.funSort=function(t){return this._sort(t,false)};Array.prototype.funSortDescending=function(t){return this._sort(t,true)};Array.prototype.funReverse=function(){return this.copy().reverse()};Array.prototype.except=function(t){return this.filter(function(e){return __indexOf.call(t,e)<0})};Array.prototype.flatten=function(t){var e,r,n,o,i,u,a,s;if(t<=0){return fail()}else{o=[];e=false;for(i=0,a=this.length;i<a;i++){r=this[i];if(Array.isArray(r)){e=true;for(u=0,s=r.length;u<s;u++){n=r[u];o.push(n)}}else{o.push(r)}}if(e){if(t!=null){if(t===1){return o}else{return o.flatten(t-1)}}else{return o.flatten()}}else{return o}}};Array.prototype.randomOne=function(){return this[Math.randomInt(this.length)]};Array.prototype.random=function(t){return this.copy().takeRandom(t)};Array.prototype.takeRandomOne=function(){var t,e;t=Math.randomInt(this.length);e=this[t];this.removeAt(t);return e};Array.prototype.takeRandom=function(t){var e=this;if(t==null){t=this.length}t=this._numberToLength(t);return repeat(t,function(){return e.takeRandomOne()})};Array.prototype.removeAt=function(t){this.splice(t,1);return this};Array.prototype.remove=function(t){var e;e=this.indexOf(t);assert(e>-1);return this.removeAt(e)};Array.prototype.removeAll=function(t){var e;while(true){e=this.indexOf(t);if(e===-1){break}this.removeAt(e)}return this};Array.prototype.removeMatch=function(t){var e;e=this.findIndex(t);assert(e>-1);return this.removeAt(e)};Array.prototype.removeAllMatch=function(t){var e;while(true){e=this.findIndex(t);if(e===-1){break}this.removeAt(e)}return this};if($mate.environmentType==="browser"&&window.global===void 0){window.global=window}if(Number.EPSILON===void 0){Number.EPSILON=2.220446049250313e-16}if(Number.isInteger===void 0){Number.isInteger=function(t){return typeof t==="number"&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t}}if(String.prototype.startsWith===void 0){String.prototype.startsWith=function(t){return this.indexOf(t)===0}}if(String.prototype.endsWith===void 0){String.prototype.endsWith=function(t){return this.lastIndexOf(t)===this.length-t.length}}if(String.prototype.contains===void 0){String.prototype.contains=function(t){return this.indexOf(t)!==-1}}if(Array.from===void 0){Array.from=function(t){var e,r,n,o;o=[];for(r=0,n=t.length;r<n;r++){e=t[r];o.push(e)}return o}}if(Array.prototype.find===void 0){Array.prototype.find=function(t){var e;assert(typeof t==="function");e=this.filter(t);if(!e.isEmpty()){return e.at(0)}else{return void 0}}}if(Array.prototype.findIndex===void 0){Array.prototype.findIndex=function(t){var e;e=this.find(t);if(e===void 0){return-1}else{return this.indexOf(e)}}}if(Math.sign===void 0){Math.sign=function(t){if(typeof t==="number"){if(t===0){return 0}else if(t>0){return 1}else if(t<0){return-1}else{return NaN}}else{return NaN}}}if(global.setImmediate===void 0){global.setImmediate=function(t,e){return setTimeout(t,0,e)}}if(global.clearImmediate===void 0){global.clearImmediate=clearTimeout}compose=function(t){if(arguments.length>1){t=Array.from(arguments)}return function(){var e,r,n,o;e=arguments;for(n=0,o=t.length;n<o;n++){r=t[n];e=[r.apply(this,e)]}return e[0]}};fail=function(t){throw new Error(t)};assert=function(t,e){if(!t){return fail(e)}};repeat=function(t,e){var r,n,o;o=[];for(r=n=0;0<=t?n<t:n>t;r=0<=t?++n:--n){o.push(e())}return o};spread=function(t,e){var r,n,o;o=[];for(r=n=0;0<=e?n<e:n>e;r=0<=e?++n:--n){o.push(t)}return o};Object.getter=function(t,e,r){return Object.defineProperty(t,e,{get:r,configurable:true})};Object.setter=function(t,e,r){return Object.defineProperty(t,e,{set:r,configurable:true})};Object.clone=function(t){var e,r,n,o,i;r={};i=Object.keys(t);for(n=0,o=i.length;n<o;n++){e=i[n];r[e]=t[e]}return r};JSON.clone=function(t){return JSON.parse(JSON.stringify(t))};Number.isFraction=function(t){return typeof t==="number"&&isFinite(t)&&Math.floor(t)!==t};Number.parseFloatExt=function(t){return parseFloat(t)*(t.endsWith("%")?.01:1)};String.prototype.matches=function(t){var e,r,n;e=new RegExp(t.source,"g");n=[];while(true){r=e.exec(this);if(r!=null){n.push(r)}else{break}}return n};String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.substr(1)};Date.prototype.add=function(t){return new Date(this- -t)};Date.prototype.subtract=function(t){if(typeof t==="number"){return new Date(this-t)}else{return this-t}};Date.prototype.equals=function(t){return t<=this&&this<=t};console.logt=function(){return console.log.apply(null,[(new Date).toISOString()].concat(Array.from(arguments)))};EventField=function(){function t(){this._listeners=[]}t.prototype.bind=function(t){if(__indexOf.call(this._listeners,t)<0){this._listeners.push(t)}return this};t.prototype.unbind=function(t){this._listeners.removeAll(t);return this};t.prototype.fire=function(t){var e,r,n,o;o=this._listeners;for(r=0,n=o.length;r<n;r++){e=o[r];if(t!=null?t.blocksListeners:void 0){break}e(t)}return void 0};return t}();ObjectWithEvents=function(){function t(){this._eventList={}}t.prototype.on=function(t,e){var r;if((r=this._eventList)[t]==null){r[t]=[]}if(__indexOf.call(this._eventList[t],e)<0){this._eventList[t].push(e)}return this};t.prototype.off=function(t,e){this._eventList[t].removeAll(e);return this};t.prototype.trigger=function(t,e){var r,n,o,i,u;if((n=this._eventList)[t]==null){n[t]=[]}u=this._eventList[t];for(o=0,i=u.length;o<i;o++){r=u[o];r(e)}return void 0};t.prototype.listeners=function(t){return this._eventList[t]};return t}();Math.nearlyEquals=function(t,e){var r,n;r=1+1/65536;return 1/r<(n=t/e)&&n<r};Math.nearlyGreaterThan=function(t,e){return t>e||Math.nearlyEquals(t,e)};Math.nearlyLessThan=function(t,e){return t<e||Math.nearlyEquals(t,e)};Math.radiansToDegrees=function(t){return t/Math.PI*180};Math.degreesToRadians=function(t){return t/180*Math.PI};Math.principalRadians=function(t){var e;e=t%(2*Math.PI);if(e<=-Math.PI){return e+2*Math.PI}else if(e>Math.PI){return e-2*Math.PI}else{return e}};Math.principalDegrees=function(t){var e;e=t%360;if(e<=-180){return e+360}else if(e>180){return e-360}else{return e}};Math.randomNumber=function(t,e){if(t<e){return t+Math.random()*(e-t)}else{return fail()}};Math.randomInt=function(t,e){var r,n;n=e===void 0?0:t;r=e===void 0?t:e;return Math.floor(Math.randomNumber(n,r))};Number.prototype.nearlyEquals=function(t){return Math.nearlyEquals(this,t)};Number.prototype.nearlyGreaterThan=function(t){return Math.nearlyGreaterThan(this,t)};Number.prototype.nearlyLessThan=function(t){return Math.nearlyLessThan(this,t)};Point=function(){function t(t,e){this.x=t;this.y=e}t.from=function(e){if(typeof e==="number"){return new t(e,0)}else if(e instanceof t){return e.clone()}else if(typeof e==="string"){return t.fromString(e)}else if(Array.isArray(e)){return t.fromArray(e)}else{return fail()}};t.fromArray=function(e){return new t(e[0],e[1])};t.fromString=function(e){var r,n,o,i,u,a,s;r=e.replace(/[\x20()]/g,"");i=r.match(/^([^,]*),(.*)$/);if(i!=null){return new t(Number.parseFloatExt(i[1]),Number.parseFloatExt(i[2]))}else{n=r.match(/^([+-]?[0-9]*\.?[0-9]*(?:[Ee][+-]?[0-9]+)?(?![i0-9Ee.]))?(?:([+-]?[0-9]*\.?[0-9]*(?:[Ee][+-]?[0-9]+)?)i)?$/);if(n!=null){u=(a=n[1])!=null?a:"0";o=(s=n[2])!=null?s:"0";if(u===""){u="1"}if(o===""){o="1"}if(u==="+"){u="1"}if(o==="+"){o="1"}if(u==="-"){u="-1"}if(o==="-"){o="-1"}return new t(parseFloat(u),parseFloat(o))}else{return fail()}}};t.fromPolar=function(e,r){return new t(e*Math.cos(r),e*Math.sin(r))};t.fromPolarInDegrees=function(e,r){switch(Math.principalDegrees(r)){case 0:return new t(e,0);case 90:return new t(0,e);case-90:return new t(0,-e);case 180:return new t(-e,0);default:return t.fromPolar(e,Math.degreesToRadians(r))}};t.prototype.real=function(){return this.x};t.prototype.imaginary=function(){return this.y};t.prototype.toString=function(){return"("+this.x+","+this.y+")"};t.prototype.toComplexString=function(){var t;t=this.y>=0?"+":"-";return""+this.x+t+Math.abs(this.y)+"i"};t.prototype.clone=function(){return new t(this.x,this.y)};t.prototype.equals=function(t){return cmath.equals(this,t)};t.prototype.nearlyEquals=function(t){return cmath.nearlyEquals(this,t)};t.prototype.opposite=function(){return cmath.opposite(this)};t.prototype.reciprocal=function(){return cmath.reciprocal(this)};t.prototype.conjugate=function(){return cmath.conjugate(this)};t.prototype.abs=function(){return cmath.abs(this)};t.prototype.add=function(t){return cmath.add(this,t)};t.prototype.subtract=function(t){return cmath.subtract(this,t)};t.prototype.multiply=function(t){return cmath.multiply(this,t)};t.prototype.divide=function(t){return cmath.divide(this,t)};t.prototype.distance=function(t){return cmath.distance(this,t)};t.prototype.dotProduct=function(e){e=t.from(e);return this.x*e.x+this.y*e.y};t.prototype.crossProduct=function(e){e=t.from(e);return this.x*e.y-this.y*e.x};t.prototype.isOppositeTo=function(t){return this.opposite().equals(t)};t.prototype.phase=function(){return cmath.phase(this)};t.prototype.phaseTo=function(e){e=t.from(e);return Math.principalRadians(e.phase()-this.phase())};t.prototype.phaseInDegrees=function(){return cmath.phaseInDegrees(this)};t.prototype.phaseInDegreesTo=function(e){e=t.from(e);return Math.principalDegrees(e.phaseInDegrees()-this.phaseInDegrees())};t.prototype.scale=function(e){e=t.from(e);return new t(this.x*e.x,this.y*e.y)};t.prototype.rotate=function(e){return this.multiply(t.fromPolar(1,e))};t.prototype.rotateDegrees=function(e){return this.multiply(t.fromPolarInDegrees(1,e))};return t}();cmath={equals:function(t,e){t=Point.from(t);e=Point.from(e);return t.x===e.x&&t.y===e.y},nearlyEquals:function(t,e){t=Point.from(t);e=Point.from(e);return t.x.nearlyEquals(e.x)&&t.y.nearlyEquals(e.y)},opposite:function(t){t=Point.from(t);return new Point(-t.x,-t.y)},reciprocal:function(t){var e;t=Point.from(t);e=t.x*t.x+t.y*t.y;return new Point(t.x/e,-t.y/e)},conjugate:function(t){t=Point.from(t);return new Point(t.x,-t.y)},abs:function(t){t=Point.from(t);if(t.x===0){return Math.abs(t.y)}else if(t.y===0){return Math.abs(t.x)}else{return Math.sqrt(t.x*t.x+t.y*t.y)}},phase:function(t){t=Point.from(t);return Math.atan2(t.y,t.x)},phaseInDegrees:function(t){var e;t=Point.from(t);if(t.x===0&&t.y===0){return 0}else if(t.x===0&&t.y>0){return 90}else if(t.x===0&&t.y<0){return-90}else if(t.x>0&&t.y===0){return 0}else if(t.x<0&&t.y===0){return 180}else{e=Math.radiansToDegrees(cmath.phase(t));if(e<=-180){return 180}else{return e}}},add:function(t,e){t=Point.from(t);e=Point.from(e);return new Point(t.x+e.x,t.y+e.y)},subtract:function(t,e){return cmath.add(t,cmath.opposite(e))},multiply:function(t,e){t=Point.from(t);e=Point.from(e);return new Point(t.x*e.x-t.y*e.y,t.x*e.y+t.y*e.x)},divide:function(t,e){return cmath.multiply(t,cmath.reciprocal(e))},distance:function(t,e){return cmath.abs(cmath.subtract(t,e))},exp:function(t){t=Point.from(t);return Point.fromPolar(Math.exp(t.x),t.y)},log:function(t){return new Point(Math.log(cmath.abs(t)),cmath.phase(t))},pow:function(t,e){return cmath.exp(cmath.multiply(cmath.log(t),e))},sqrt:function(t){var e;t=Point.from(t);e=cmath.abs(t);return new Point(Math.sqrt((e+t.x)/2),Math.sign(t.y)*Math.sqrt((e-t.x)/2))},cos:function(t){return cmath.divide(cmath.add(cmath.exp(cmath.multiply(t,new Point(0,1))),cmath.exp(cmath.multiply(cmath.opposite(t),new Point(0,1)))),2)},sin:function(t){return cmath.divide(cmath.subtract(cmath.exp(cmath.multiply(t,new Point(0,1))),cmath.exp(cmath.multiply(cmath.opposite(t),new Point(0,1)))),new Point(0,2))},tan:function(t){return cmath.divide(cmath.sin(t),cmath.cos(t))},acos:function(t){return cmath.opposite(cmath.multiply(cmath.log(cmath.add(t,cmath.multiply(cmath.sqrt(cmath.add(cmath.opposite(cmath.multiply(t,t)),1)),new Point(0,1)))),new Point(0,1)))},asin:function(t){return cmath.opposite(cmath.multiply(cmath.log(cmath.add(cmath.multiply(t,new Point(0,1)),cmath.sqrt(cmath.add(cmath.opposite(cmath.multiply(t,t)),1)))),new Point(0,1)))},atan:function(t){return cmath.multiply(cmath.subtract(cmath.log(cmath.subtract(1,cmath.multiply(t,new Point(0,1)))),cmath.log(cmath.add(1,cmath.multiply(t,new Point(0,1))))),new Point(0,.5))}};if(!(typeof $mate==="object"&&$mate!==null)){$mate={}}$mate.test={add:function(t,e,r,n){var o=this;if(typeof t!=="string"){n=r;r=e;e=t;t="Test_"+this._defaultNameCounter;this._defaultNameCounter++}if(typeof e==="function"){e=[e]}if(r==null){r=0}if(n==null){n=864e5}this._list[t]={contexts:e.map(function(e){var r;r={name:t,fun:e,setState:function t(e){if(t.context._state!==true&&t.context._state!==false){if(e!==true&&e!==false){e=true}t.context._state=e}},getState:function(){return this._state},_state:null};r.setState.context=r;return r}),delay:r,timeout:n};return this},run:function(){var t,e,r,n=this;t=new Date;Object.keys(this._list).forEach(function(t){var e;e=n._list[t];return e.contexts.forEach(function(t){return setTimeout(function(){var e,r,n,o;n=t.fun.toString().match(/function *\(([^)]*)\)/);r=n!=null&&n[1].trim().length>0;o=function(){if(r){return t.fun(t.setState)}else{if(t.fun()!==false){return t.setState(true)}else{return t.setState(false)}}};if(typeof exports!=="undefined"&&exports!==null&&(typeof module!=="undefined"&&module!==null?module.exports:void 0)!=null){e=require("domain").create();e.on("error",function(e){t.setState(false);return t.errorMessage=e.stack});return e.run(o)}else{try{return o()}catch(e){return t.setState(false)}}},e.delay)})});console.log();r=function(){var r,o,i,u,a;a=new Date;r=[];Object.keys(n._list).forEach(function(e){var o;o=n._list[e];return o.contexts.forEach(function(e){if(e.getState()==null){if(a.getTime()-t.getTime()>n.timeout||a.getTime()-(t.getTime()+o.delay)>o.timeout){e.setState(false)}}return r.push(e)})});u=r.filter(function(t){return t.getState()===true});o=r.filter(function(t){return t.getState()===false});i=r.filter(function(t){return t.getState()!==true&&t.getState()!==false});console.log(""+(new Date).toISOString()+" Success: "+u.length+", "+("Failure: "+o.length+", Pending: "+i.length));if(i.length===0){clearInterval(e);o.forEach(function(t){console.log('\nFailure "'+t.name+'":');console.log(t.fun.toString());if(t.errorMessage!=null){return console.log(t.errorMessage)}});console.log("\n"+(o.length===0?"Completed. All succeeded.":"Completed. "+o.length+" failures.")+"\n");if(typeof process!=="undefined"&&process!==null){return process.exit()}}};e=setInterval(r,1e3);setTimeout(r,0);return this},timeout:864e5,_list:{},_defaultNameCounter:0};Date.Timer=function(){t._endOfTime=new Date("9999-12-30T00:00:00Z");function t(t){this.targetTime=t!=null?t:Date.Timer._endOfTime;this._elapsedCount=0;this._internalTimer=null;this._running=false;this.allowsEqual=true;this.precision=30;this.onElapse=new EventField}t.prototype.run=function(){var t=this;if(this._running){return}this._elapsedCount=0;this._internalTimer=setInterval(function(){var e,r;r=new Date;if(t.allowsEqual?r>=t.targetTime:r>t.targetTime){t._elapsedCount++;e=t.targetTime;t.targetTime=Date.Timer._endOfTime;return t.onElapse.fire({idealTime:e,nowTime:r,index:t._elapsedCount-1})}},this.precision);this._running=true;return this};t.prototype.stop=function(){if(!this._running){return}clearInterval(this._internalTimer);this._running=false;return this};t.prototype.getRunning=function(){return this._running};t.prototype.resetCounter=function(){return this._elapsedCount=0};t.prototype.getElapsedCount=function(){return this._elapsedCount};return t}();Date.IntervalTimer=function(t){__extends(e,t);function e(t,r,n){var o=this;this.interval=t!=null?t:1e3;this.startTime=r!=null?r:new Date;this.timesOrEndTime=n;e.__super__.constructor.call(this);this._started=false;this.includesStart=true;this.includesEnd=false;this.onStart=new EventField;this.onElapse.bind(function(t){o.targetTime=t.idealTime.add(o.interval);if(!o._started){o._started=true;if(!o.includesStart){o.resetCounter();t.blocksListeners=true}o.onStart.fire()}if(o.timesOrEndTime!=null&&(typeof o.timesOrEndTime==="number"&&o.getElapsedCount()===o.timesOrEndTime||typeof o.timesOrEndTime==="object"&&(o.includesEnd?o.targetTime>o.timesOrEndTime:o.targetTime>=o.timesOrEndTime))){return o.stop()}})}e.prototype.run=function(){if(this.getRunning()){return}this.targetTime=this.startTime;return e.__super__.run.call(this)};return e}(Date.Timer);if($mate.environmentType==="node"){global.$mate=$mate;global.compose=compose;global.fail=fail;global.assert=assert;global.repeat=repeat;global.spread=spread;global.cmath=cmath;global.Point=Point;global.EventField=EventField;global.ObjectWithEvents=ObjectWithEvents}$mate.nodePackageInfo={name:"mate",version:"0.5.2",description:"A library that extends native JavaScript / CoffeeScript.",keywords:["library","app","javascript","coffeescript","js"],author:"Zhenzhen Zhan <zhanzhenzhen@hotmail.com>",homepage:"https://github.com/zhanzhenzhen/mate",licenses:[{type:"MIT",url:"https://github.com/zhanzhenzhen/mate/blob/master/LICENSE.txt"}],repository:{type:"git",url:"https://github.com/zhanzhenzhen/mate.git"},main:"mate"}; | ||
var $mate,ArrayLazyWrapper,EventField,ObjectWithEvents,Point,assert,cmath,compose,fail,repeat,spread,__indexOf=[].indexOf||function(t){for(var e=0,r=this.length;e<r;e++){if(e in this&&this[e]===t)return e}return-1},__hasProp={}.hasOwnProperty,__extends=function(t,e){for(var r in e){if(__hasProp.call(e,r))t[r]=e[r]}function n(){this.constructor=t}n.prototype=e.prototype;t.prototype=new n;t.__super__=e.prototype;return t};$mate={};$mate.environmentType=typeof exports!=="undefined"&&exports!==null&&(typeof module!=="undefined"&&module!==null?module.exports:void 0)!=null?"node":typeof window!=="undefined"&&window!==null?"browser":void 0;ArrayLazyWrapper=function(){function t(t,e,r){var n=this;this._value=t;this._chain=(e!=null?e:[]).slice(0);if(r!=null){this._chain.push(r)}Object.getter(this,"length",function(){return n.force().length})}t.prototype.force=function(){var t,e,r,n,o;e=this._value;o=this._chain;for(r=0,n=o.length;r<n;r++){t=o[r];e=t.fun.apply(e,t.args)}return e};t.prototype.map=function(){return this._pushChain(Array.prototype.map,arguments)};t.prototype.filter=function(){return this._pushChain(Array.prototype.filter,arguments)};t.prototype.concat=function(){return this._pushChain(Array.prototype.concat,arguments)};t.prototype.portion=function(){return this._pushChain(Array.prototype.portion,arguments)};t.prototype.funSort=function(){return this._pushChain(Array.prototype.funSort,arguments)};t.prototype.funSortDescending=function(){return this._pushChain(Array.prototype.funSortDescending,arguments)};t.prototype.funReverse=function(){return this._pushChain(Array.prototype.funReverse,arguments)};t.prototype.except=function(){return this._pushChain(Array.prototype.except,arguments)};t.prototype.group=function(){return this._pushChain(Array.prototype.group,arguments)};t.prototype.flatten=function(){return this._pushChain(Array.prototype.flatten,arguments)};t.prototype.random=function(){return this._pushChain(Array.prototype.random,arguments)};t.prototype.some=function(){return this._unwrapAndDo(Array.prototype.some,arguments)};t.prototype.every=function(){return this._unwrapAndDo(Array.prototype.every,arguments)};t.prototype.isEmpty=function(){return this._unwrapAndDo(Array.prototype.isEmpty,arguments)};t.prototype.at=function(){return this._unwrapAndDo(Array.prototype.at,arguments)};t.prototype.atOrNull=function(){return this._unwrapAndDo(Array.prototype.atOrNull,arguments)};t.prototype.contains=function(){return this._unwrapAndDo(Array.prototype.contains,arguments)};t.prototype.first=function(){return this._unwrapAndDo(Array.prototype.first,arguments)};t.prototype.firstOrNull=function(){return this._unwrapAndDo(Array.prototype.firstOrNull,arguments)};t.prototype.last=function(){return this._unwrapAndDo(Array.prototype.last,arguments)};t.prototype.lastOrNull=function(){return this._unwrapAndDo(Array.prototype.lastOrNull,arguments)};t.prototype.single=function(){return this._unwrapAndDo(Array.prototype.single,arguments)};t.prototype.singleOrNull=function(){return this._unwrapAndDo(Array.prototype.singleOrNull,arguments)};t.prototype.withMax=function(){return this._unwrapAndDo(Array.prototype.withMax,arguments)};t.prototype.withMin=function(){return this._unwrapAndDo(Array.prototype.withMin,arguments)};t.prototype.max=function(){return this._unwrapAndDo(Array.prototype.max,arguments)};t.prototype.min=function(){return this._unwrapAndDo(Array.prototype.min,arguments)};t.prototype.sum=function(){return this._unwrapAndDo(Array.prototype.sum,arguments)};t.prototype.average=function(){return this._unwrapAndDo(Array.prototype.average,arguments)};t.prototype.median=function(){return this._unwrapAndDo(Array.prototype.median,arguments)};t.prototype.product=function(){return this._unwrapAndDo(Array.prototype.product,arguments)};t.prototype.randomOne=function(){return this._unwrapAndDo(Array.prototype.randomOne,arguments)};t.prototype._pushChain=function(e,r){return new t(this._value,this._chain,{fun:e,args:r})};t.prototype._unwrapAndDo=function(t,e){return t.apply(this.force(),e)};return t}();Array._elementOrUseSelector=function(t,e){if(e!=null){return e(t)}else{return t}};Array.prototype._numberToIndex=function(t){if(0<t&&t<1){return t=Math.round(t*(this.length-1))}else{return t}};Array.prototype._numberToLength=function(t){if(0<t&&t<1){return t=Math.round(t*this.length)}else{return t}};Array.prototype.copy=function(){return this.slice(0)};Array.prototype.isEmpty=function(){return this.length===0};Array.prototype.lazy=function(){return new ArrayLazyWrapper(this)};Array.prototype.portion=function(t,e,r){if(Number.isFraction(t)||Number.isFraction(e)||Number.isFraction(r)){if(t===0){t=0+Number.EPSILON}if(t===1){t=1-Number.EPSILON}if(e===0){e=0+Number.EPSILON}if(e===1){e=1-Number.EPSILON}if(r===0){r=0+Number.EPSILON}if(r===1){r=1-Number.EPSILON}}t=this._numberToIndex(t);e=this._numberToLength(e);r=this._numberToIndex(r);return this.slice(t,e!=null?t+e:r+1)};Array.prototype.at=function(t){t=this._numberToIndex(t);assert(0<=t&&t<this.length);return this[t]};Array.prototype.atOrNull=function(t){try{return this.at(t)}catch(t){return null}};Array.prototype.contains=function(t){return __indexOf.call(this,t)>=0};Array.prototype.first=function(t){var e;e=t!=null?this.filter(t):this;return e.at(0)};Array.prototype.firstOrNull=function(t){try{return this.first(t)}catch(t){return null}};Array.prototype.last=function(t){var e;e=t!=null?this.filter(t):this;return e.at(e.length-1)};Array.prototype.lastOrNull=function(t){try{return this.last(t)}catch(t){return null}};Array.prototype.single=function(t){var e;e=t!=null?this.filter(t):this;assert(e.length===1);return e.at(0)};Array.prototype.singleOrNull=function(t){try{return this.single(t)}catch(t){return null}};Array.prototype.withMax=function(t){var e=this;return this.reduce(function(e,r,n){if(Array._elementOrUseSelector(e,t)>Array._elementOrUseSelector(r,t)){return e}else{return r}})};Array.prototype.withMin=function(t){var e=this;return this.reduce(function(e,r,n){if(Array._elementOrUseSelector(e,t)<Array._elementOrUseSelector(r,t)){return e}else{return r}})};Array.prototype.max=function(t){return Array._elementOrUseSelector(this.withMax(t),t)};Array.prototype.min=function(t){return Array._elementOrUseSelector(this.withMin(t),t)};Array.prototype.sum=function(t){var e=this;if(this.length===1){return Array._elementOrUseSelector(this.first(),t)}else{return this.reduce(function(e,r,n){return(n===1?Array._elementOrUseSelector(e,t):e)+Array._elementOrUseSelector(r,t)})}};Array.prototype.average=function(t){return this.sum(t)/this.length};Array.prototype.median=function(t){var e,r,n,o,i;i=this.funSort(t);e=i.at(.5-Number.EPSILON);r=i.at(.5+Number.EPSILON);n=Array._elementOrUseSelector(e,t);o=Array._elementOrUseSelector(r,t);return(n+o)/2};Array.prototype.product=function(t){var e=this;if(this.length===1){return Array._elementOrUseSelector(this.first(),t)}else{return this.reduce(function(e,r,n){return(n===1?Array._elementOrUseSelector(e,t):e)*Array._elementOrUseSelector(r,t)})}};Array.prototype.group=function(t,e){var r,n,o,i,u,a,s,p;if(this.isEmpty()){return[]}a=this.funSort(t);o=[];r=Array._elementOrUseSelector(a.first(),t);n=[];for(s=0,p=a.length;s<p;s++){u=a[s];i=Array._elementOrUseSelector(u,t);if(i!==r){o.push({key:r,result:Array._elementOrUseSelector(n,e)});r=i;n=[]}n.push(u)}o.push({key:r,result:Array._elementOrUseSelector(n,e)});return o};Array.prototype._sort=function(t,e){var r=this;return this.copy().sort(function(r,n){var o,i;o=Array._elementOrUseSelector(r,t);i=Array._elementOrUseSelector(n,t);if(o<i){if(e){return 1}else{return-1}}else if(o>i){if(e){return-1}else{return 1}}else{return 0}})};Array.prototype.funSort=function(t){return this._sort(t,false)};Array.prototype.funSortDescending=function(t){return this._sort(t,true)};Array.prototype.funReverse=function(){return this.copy().reverse()};Array.prototype.except=function(t){return this.filter(function(e){return __indexOf.call(t,e)<0})};Array.prototype.flatten=function(t){var e,r,n,o,i,u,a,s;if(t<=0){return fail()}else{o=[];e=false;for(i=0,a=this.length;i<a;i++){r=this[i];if(Array.isArray(r)){e=true;for(u=0,s=r.length;u<s;u++){n=r[u];o.push(n)}}else{o.push(r)}}if(e){if(t!=null){if(t===1){return o}else{return o.flatten(t-1)}}else{return o.flatten()}}else{return o}}};Array.prototype.randomOne=function(){return this[Math.randomInt(this.length)]};Array.prototype.random=function(t){return this.copy().takeRandom(t)};Array.prototype.takeRandomOne=function(){var t,e;t=Math.randomInt(this.length);e=this[t];this.removeAt(t);return e};Array.prototype.takeRandom=function(t){var e=this;if(t==null){t=this.length}t=this._numberToLength(t);return repeat(t,function(){return e.takeRandomOne()})};Array.prototype.removeAt=function(t){this.splice(t,1);return this};Array.prototype.remove=function(t){var e;e=this.indexOf(t);assert(e>-1);return this.removeAt(e)};Array.prototype.removeAll=function(t){var e;while(true){e=this.indexOf(t);if(e===-1){break}this.removeAt(e)}return this};Array.prototype.removeMatch=function(t){var e;e=this.findIndex(t);assert(e>-1);return this.removeAt(e)};Array.prototype.removeAllMatch=function(t){var e;while(true){e=this.findIndex(t);if(e===-1){break}this.removeAt(e)}return this};if($mate.environmentType==="browser"&&window.global===void 0){window.global=window}if(Number.EPSILON===void 0){Number.EPSILON=2.220446049250313e-16}if(Number.isInteger===void 0){Number.isInteger=function(t){return typeof t==="number"&&isFinite(t)&&t>-9007199254740992&&t<9007199254740992&&Math.floor(t)===t}}if(String.prototype.startsWith===void 0){String.prototype.startsWith=function(t){return this.indexOf(t)===0}}if(String.prototype.endsWith===void 0){String.prototype.endsWith=function(t){return this.lastIndexOf(t)===this.length-t.length}}if(String.prototype.contains===void 0){String.prototype.contains=function(t){return this.indexOf(t)!==-1}}if(Array.from===void 0){Array.from=function(t){var e,r,n,o;o=[];for(r=0,n=t.length;r<n;r++){e=t[r];o.push(e)}return o}}if(Array.prototype.find===void 0){Array.prototype.find=function(t){var e;assert(typeof t==="function");e=this.filter(t);if(!e.isEmpty()){return e.at(0)}else{return void 0}}}if(Array.prototype.findIndex===void 0){Array.prototype.findIndex=function(t){var e;e=this.find(t);if(e===void 0){return-1}else{return this.indexOf(e)}}}if(Math.sign===void 0){Math.sign=function(t){if(typeof t==="number"){if(t===0){return 0}else if(t>0){return 1}else if(t<0){return-1}else{return NaN}}else{return NaN}}}if(global.setImmediate===void 0){global.setImmediate=function(t,e){return setTimeout(t,0,e)}}if(global.clearImmediate===void 0){global.clearImmediate=clearTimeout}compose=function(t){if(arguments.length>1){t=Array.from(arguments)}return function(){var e,r,n,o;e=arguments;for(n=0,o=t.length;n<o;n++){r=t[n];e=[r.apply(this,e)]}return e[0]}};fail=function(t){throw new Error(t)};assert=function(t,e){if(!t){return fail(e)}};repeat=function(t,e){var r,n,o;o=[];for(r=n=0;0<=t?n<t:n>t;r=0<=t?++n:--n){o.push(e())}return o};spread=function(t,e){var r,n,o;o=[];for(r=n=0;0<=e?n<e:n>e;r=0<=e?++n:--n){o.push(t)}return o};Object.getter=function(t,e,r){return Object.defineProperty(t,e,{get:r,configurable:true})};Object.setter=function(t,e,r){return Object.defineProperty(t,e,{set:r,configurable:true})};Object.clone=function(t){var e,r,n,o,i;r={};i=Object.keys(t);for(n=0,o=i.length;n<o;n++){e=i[n];r[e]=t[e]}return r};JSON.clone=function(t){return JSON.parse(JSON.stringify(t))};Number.isFraction=function(t){return typeof t==="number"&&isFinite(t)&&Math.floor(t)!==t};Number.parseFloatExt=function(t){return parseFloat(t)*(t.endsWith("%")?.01:1)};String.prototype.matches=function(t){var e,r,n;e=new RegExp(t.source,"g");n=[];while(true){r=e.exec(this);if(r!=null){n.push(r)}else{break}}return n};String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.substr(1)};Date.prototype.add=function(t){return new Date(this- -t)};Date.prototype.subtract=function(t){if(typeof t==="number"){return new Date(this-t)}else{return this-t}};Date.prototype.equals=function(t){return t<=this&&this<=t};console.logt=function(){return console.log.apply(null,[(new Date).toISOString()].concat(Array.from(arguments)))};EventField=function(){var t;t=function(e,r){assert(typeof e==="string");t[e](r);return this};t._listeners=[];t.bind=function(e){if(__indexOf.call(t._listeners,e)<0){t._listeners.push(e)}return t};t.unbind=function(e){t._listeners.removeAll(e);return t};t.fire=function(e){var r,n,o,i;i=t._listeners;for(n=0,o=i.length;n<o;n++){r=i[n];if(e!=null?e.blocksListeners:void 0){break}r(e)}return void 0};return t};ObjectWithEvents=function(){function t(){this._eventList={}}t.prototype.on=function(t,e){var r;if((r=this._eventList)[t]==null){r[t]=[]}if(__indexOf.call(this._eventList[t],e)<0){this._eventList[t].push(e)}return this};t.prototype.off=function(t,e){this._eventList[t].removeAll(e);return this};t.prototype.trigger=function(t,e){var r,n,o,i,u;if((n=this._eventList)[t]==null){n[t]=[]}u=this._eventList[t];for(o=0,i=u.length;o<i;o++){r=u[o];r(e)}return void 0};t.prototype.listeners=function(t){return this._eventList[t]};return t}();Math.nearlyEquals=function(t,e){var r,n;r=1+1/65536;return 1/r<(n=t/e)&&n<r};Math.nearlyGreaterThan=function(t,e){return t>e||Math.nearlyEquals(t,e)};Math.nearlyLessThan=function(t,e){return t<e||Math.nearlyEquals(t,e)};Math.radiansToDegrees=function(t){return t/Math.PI*180};Math.degreesToRadians=function(t){return t/180*Math.PI};Math.principalRadians=function(t){var e;e=t%(2*Math.PI);if(e<=-Math.PI){return e+2*Math.PI}else if(e>Math.PI){return e-2*Math.PI}else{return e}};Math.principalDegrees=function(t){var e;e=t%360;if(e<=-180){return e+360}else if(e>180){return e-360}else{return e}};Math.randomNumber=function(t,e){if(t<e){return t+Math.random()*(e-t)}else{return fail()}};Math.randomInt=function(t,e){var r,n;n=e===void 0?0:t;r=e===void 0?t:e;return Math.floor(Math.randomNumber(n,r))};Number.prototype.nearlyEquals=function(t){return Math.nearlyEquals(this,t)};Number.prototype.nearlyGreaterThan=function(t){return Math.nearlyGreaterThan(this,t)};Number.prototype.nearlyLessThan=function(t){return Math.nearlyLessThan(this,t)};Point=function(){function t(t,e){this.x=t;this.y=e}t.from=function(e){if(typeof e==="number"){return new t(e,0)}else if(e instanceof t){return e.clone()}else if(typeof e==="string"){return t.fromString(e)}else if(Array.isArray(e)){return t.fromArray(e)}else{return fail()}};t.fromArray=function(e){return new t(e[0],e[1])};t.fromString=function(e){var r,n,o,i,u,a,s;r=e.replace(/[\x20()]/g,"");i=r.match(/^([^,]*),(.*)$/);if(i!=null){return new t(Number.parseFloatExt(i[1]),Number.parseFloatExt(i[2]))}else{n=r.match(/^([+-]?[0-9]*\.?[0-9]*(?:[Ee][+-]?[0-9]+)?(?![i0-9Ee.]))?(?:([+-]?[0-9]*\.?[0-9]*(?:[Ee][+-]?[0-9]+)?)i)?$/);if(n!=null){u=(a=n[1])!=null?a:"0";o=(s=n[2])!=null?s:"0";if(u===""){u="1"}if(o===""){o="1"}if(u==="+"){u="1"}if(o==="+"){o="1"}if(u==="-"){u="-1"}if(o==="-"){o="-1"}return new t(parseFloat(u),parseFloat(o))}else{return fail()}}};t.fromPolar=function(e,r){return new t(e*Math.cos(r),e*Math.sin(r))};t.fromPolarInDegrees=function(e,r){switch(Math.principalDegrees(r)){case 0:return new t(e,0);case 90:return new t(0,e);case-90:return new t(0,-e);case 180:return new t(-e,0);default:return t.fromPolar(e,Math.degreesToRadians(r))}};t.prototype.real=function(){return this.x};t.prototype.imaginary=function(){return this.y};t.prototype.toString=function(){return"("+this.x+","+this.y+")"};t.prototype.toComplexString=function(){var t;t=this.y>=0?"+":"-";return""+this.x+t+Math.abs(this.y)+"i"};t.prototype.clone=function(){return new t(this.x,this.y)};t.prototype.equals=function(t){return cmath.equals(this,t)};t.prototype.nearlyEquals=function(t){return cmath.nearlyEquals(this,t)};t.prototype.opposite=function(){return cmath.opposite(this)};t.prototype.reciprocal=function(){return cmath.reciprocal(this)};t.prototype.conjugate=function(){return cmath.conjugate(this)};t.prototype.abs=function(){return cmath.abs(this)};t.prototype.add=function(t){return cmath.add(this,t)};t.prototype.subtract=function(t){return cmath.subtract(this,t)};t.prototype.multiply=function(t){return cmath.multiply(this,t)};t.prototype.divide=function(t){return cmath.divide(this,t)};t.prototype.distance=function(t){return cmath.distance(this,t)};t.prototype.dotProduct=function(e){e=t.from(e);return this.x*e.x+this.y*e.y};t.prototype.crossProduct=function(e){e=t.from(e);return this.x*e.y-this.y*e.x};t.prototype.isOppositeTo=function(t){return this.opposite().equals(t)};t.prototype.phase=function(){return cmath.phase(this)};t.prototype.phaseTo=function(e){e=t.from(e);return Math.principalRadians(e.phase()-this.phase())};t.prototype.phaseInDegrees=function(){return cmath.phaseInDegrees(this)};t.prototype.phaseInDegreesTo=function(e){e=t.from(e);return Math.principalDegrees(e.phaseInDegrees()-this.phaseInDegrees())};t.prototype.scale=function(e){e=t.from(e);return new t(this.x*e.x,this.y*e.y)};t.prototype.rotate=function(e){return this.multiply(t.fromPolar(1,e))};t.prototype.rotateDegrees=function(e){return this.multiply(t.fromPolarInDegrees(1,e))};return t}();cmath={equals:function(t,e){t=Point.from(t);e=Point.from(e);return t.x===e.x&&t.y===e.y},nearlyEquals:function(t,e){t=Point.from(t);e=Point.from(e);return t.x.nearlyEquals(e.x)&&t.y.nearlyEquals(e.y)},opposite:function(t){t=Point.from(t);return new Point(-t.x,-t.y)},reciprocal:function(t){var e;t=Point.from(t);e=t.x*t.x+t.y*t.y;return new Point(t.x/e,-t.y/e)},conjugate:function(t){t=Point.from(t);return new Point(t.x,-t.y)},abs:function(t){t=Point.from(t);if(t.x===0){return Math.abs(t.y)}else if(t.y===0){return Math.abs(t.x)}else{return Math.sqrt(t.x*t.x+t.y*t.y)}},phase:function(t){t=Point.from(t);return Math.atan2(t.y,t.x)},phaseInDegrees:function(t){var e;t=Point.from(t);if(t.x===0&&t.y===0){return 0}else if(t.x===0&&t.y>0){return 90}else if(t.x===0&&t.y<0){return-90}else if(t.x>0&&t.y===0){return 0}else if(t.x<0&&t.y===0){return 180}else{e=Math.radiansToDegrees(cmath.phase(t));if(e<=-180){return 180}else{return e}}},add:function(t,e){t=Point.from(t);e=Point.from(e);return new Point(t.x+e.x,t.y+e.y)},subtract:function(t,e){return cmath.add(t,cmath.opposite(e))},multiply:function(t,e){t=Point.from(t);e=Point.from(e);return new Point(t.x*e.x-t.y*e.y,t.x*e.y+t.y*e.x)},divide:function(t,e){return cmath.multiply(t,cmath.reciprocal(e))},distance:function(t,e){return cmath.abs(cmath.subtract(t,e))},exp:function(t){t=Point.from(t);return Point.fromPolar(Math.exp(t.x),t.y)},log:function(t){return new Point(Math.log(cmath.abs(t)),cmath.phase(t))},pow:function(t,e){return cmath.exp(cmath.multiply(cmath.log(t),e))},sqrt:function(t){var e;t=Point.from(t);e=cmath.abs(t);return new Point(Math.sqrt((e+t.x)/2),Math.sign(t.y)*Math.sqrt((e-t.x)/2))},cos:function(t){return cmath.divide(cmath.add(cmath.exp(cmath.multiply(t,new Point(0,1))),cmath.exp(cmath.multiply(cmath.opposite(t),new Point(0,1)))),2)},sin:function(t){return cmath.divide(cmath.subtract(cmath.exp(cmath.multiply(t,new Point(0,1))),cmath.exp(cmath.multiply(cmath.opposite(t),new Point(0,1)))),new Point(0,2))},tan:function(t){return cmath.divide(cmath.sin(t),cmath.cos(t))},acos:function(t){return cmath.opposite(cmath.multiply(cmath.log(cmath.add(t,cmath.multiply(cmath.sqrt(cmath.add(cmath.opposite(cmath.multiply(t,t)),1)),new Point(0,1)))),new Point(0,1)))},asin:function(t){return cmath.opposite(cmath.multiply(cmath.log(cmath.add(cmath.multiply(t,new Point(0,1)),cmath.sqrt(cmath.add(cmath.opposite(cmath.multiply(t,t)),1)))),new Point(0,1)))},atan:function(t){return cmath.multiply(cmath.subtract(cmath.log(cmath.subtract(1,cmath.multiply(t,new Point(0,1)))),cmath.log(cmath.add(1,cmath.multiply(t,new Point(0,1))))),new Point(0,.5))}};if(!(typeof $mate==="object"&&$mate!==null)){$mate={}}$mate.test={add:function(t,e,r,n){var o=this;if(typeof t!=="string"){n=r;r=e;e=t;t="Test_"+this._defaultNameCounter;this._defaultNameCounter++}if(typeof e==="function"){e=[e]}if(r==null){r=0}if(n==null){n=864e5}this._list[t]={contexts:e.map(function(e){var r;r={name:t,fun:e,setState:function t(e){if(t.context._state!==true&&t.context._state!==false){if(e!==true&&e!==false){e=true}t.context._state=e}},getState:function(){return this._state},_state:null};r.setState.context=r;return r}),delay:r,timeout:n};return this},run:function(){var t,e,r,n=this;t=new Date;Object.keys(this._list).forEach(function(t){var e;e=n._list[t];return e.contexts.forEach(function(t){return setTimeout(function(){var e,r,n,o;n=t.fun.toString().match(/function *\(([^)]*)\)/);r=n!=null&&n[1].trim().length>0;o=function(){if(r){return t.fun(t.setState)}else{if(t.fun()!==false){return t.setState(true)}else{return t.setState(false)}}};if(typeof exports!=="undefined"&&exports!==null&&(typeof module!=="undefined"&&module!==null?module.exports:void 0)!=null){e=require("domain").create();e.on("error",function(e){t.setState(false);return t.errorMessage=e.stack});return e.run(o)}else{try{return o()}catch(e){return t.setState(false)}}},e.delay)})});console.log();r=function(){var r,o,i,u,a;a=new Date;r=[];Object.keys(n._list).forEach(function(e){var o;o=n._list[e];return o.contexts.forEach(function(e){if(e.getState()==null){if(a.getTime()-t.getTime()>n.timeout||a.getTime()-(t.getTime()+o.delay)>o.timeout){e.setState(false)}}return r.push(e)})});u=r.filter(function(t){return t.getState()===true});o=r.filter(function(t){return t.getState()===false});i=r.filter(function(t){return t.getState()!==true&&t.getState()!==false});console.log(""+(new Date).toISOString()+" Success: "+u.length+", "+("Failure: "+o.length+", Pending: "+i.length));if(i.length===0){clearInterval(e);o.forEach(function(t){console.log('\nFailure "'+t.name+'":');console.log(t.fun.toString());if(t.errorMessage!=null){return console.log(t.errorMessage)}});console.log("\n"+(o.length===0?"Completed. All succeeded.":"Completed. "+o.length+" failures.")+"\n");if(typeof process!=="undefined"&&process!==null){return process.exit()}}};e=setInterval(r,1e3);setTimeout(r,0);return this},timeout:864e5,_list:{},_defaultNameCounter:0};Date.Timer=function(){t._endOfTime=new Date("9999-12-30T00:00:00Z");function t(t){this.targetTime=t!=null?t:Date.Timer._endOfTime;this._elapsedCount=0;this._internalTimer=null;this._running=false;this.allowsEqual=true;this.precision=30;this.onElapse=EventField()}t.prototype.run=function(){var t=this;if(this._running){return}this._elapsedCount=0;this._internalTimer=setInterval(function(){var e,r;r=new Date;if(t.allowsEqual?r>=t.targetTime:r>t.targetTime){t._elapsedCount++;e=t.targetTime;t.targetTime=Date.Timer._endOfTime;return t.onElapse.fire({idealTime:e,nowTime:r,index:t._elapsedCount-1})}},this.precision);this._running=true;return this};t.prototype.stop=function(){if(!this._running){return}clearInterval(this._internalTimer);this._running=false;return this};t.prototype.getRunning=function(){return this._running};t.prototype.resetCounter=function(){return this._elapsedCount=0};t.prototype.getElapsedCount=function(){return this._elapsedCount};return t}();Date.IntervalTimer=function(t){__extends(e,t);function e(t,r,n){var o=this;this.interval=t!=null?t:1e3;this.startTime=r!=null?r:new Date;this.timesOrEndTime=n;e.__super__.constructor.call(this);this._started=false;this.includesStart=true;this.includesEnd=false;this.onStart=EventField();this.onElapse.bind(function(t){o.targetTime=t.idealTime.add(o.interval);if(!o._started){o._started=true;if(!o.includesStart){o.resetCounter();t.blocksListeners=true}o.onStart.fire()}if(o.timesOrEndTime!=null&&(typeof o.timesOrEndTime==="number"&&o.getElapsedCount()===o.timesOrEndTime||typeof o.timesOrEndTime==="object"&&(o.includesEnd?o.targetTime>o.timesOrEndTime:o.targetTime>=o.timesOrEndTime))){return o.stop()}})}e.prototype.run=function(){if(this.getRunning()){return}this.targetTime=this.startTime;return e.__super__.run.call(this)};return e}(Date.Timer);if($mate.environmentType==="node"){global.$mate=$mate;global.compose=compose;global.fail=fail;global.assert=assert;global.repeat=repeat;global.spread=spread;global.cmath=cmath;global.Point=Point;global.EventField=EventField;global.ObjectWithEvents=ObjectWithEvents}$mate.nodePackageInfo={name:"mate",version:"0.5.3",description:"A library that extends native JavaScript / CoffeeScript.",keywords:["library","app","javascript","coffeescript","js"],author:"Zhenzhen Zhan <zhanzhenzhen@hotmail.com>",homepage:"https://github.com/zhanzhenzhen/mate",licenses:[{type:"MIT",url:"https://github.com/zhanzhenzhen/mate/blob/master/LICENSE.txt"}],repository:{type:"git",url:"https://github.com/zhanzhenzhen/mate.git"},main:"mate"}; |
{ | ||
"name": "mate", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "A library that extends native JavaScript / CoffeeScript.", | ||
@@ -5,0 +5,0 @@ "keywords": ["library", "app", "javascript", "coffeescript", "js"], |
@@ -8,2 +8,3 @@ Mate is your JavaScript/CoffeeScript mate that brings these key features: | ||
- Complex Math | ||
- Unit Test | ||
- ECMAScript 6th Features | ||
@@ -10,0 +11,0 @@ |
@@ -13,3 +13,3 @@ // Generated by CoffeeScript 1.6.3 | ||
function Obj() { | ||
this.onClick = new EventField(); | ||
this.onClick = EventField(); | ||
} | ||
@@ -16,0 +16,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
106216
1411
32