From 9bd0cd73fcd890e3d0ce52cb88ca4ff865942dc2 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Sat, 30 Jul 2016 14:55:34 -0400 Subject: [PATCH] inline Date.now, remove redundant comment --- api/throttle.js | 8 ++------ bundler/bundle.js | 1 - mithril.min.js | 40 ++++++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 27 deletions(-) diff --git a/api/throttle.js b/api/throttle.js index 7cb4b2d7..6655b07c 100644 --- a/api/throttle.js +++ b/api/throttle.js @@ -1,16 +1,12 @@ "use strict" -var ts = Date.now || function() { - return new Date().getTime() -} - module.exports = function(callback) { //60fps translates to 16.6ms, round it down since setTimeout requires int var time = 16 var last = 0, pending = null var timeout = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout return function(synchronous) { - var now = ts() + var now = Date.now() if (synchronous === true || last === 0 || now - last >= time) { last = now callback() @@ -19,7 +15,7 @@ module.exports = function(callback) { pending = timeout(function() { pending = null callback() - last = ts() + last = Date.now() }, time - (now - last)) } } diff --git a/bundler/bundle.js b/bundler/bundle.js index 0656d05d..9352fe71 100644 --- a/bundler/bundle.js +++ b/bundler/bundle.js @@ -74,7 +74,6 @@ module.exports = function(input, output, options) { function fixCollisions(code) { for (var variable in usedVariables) { var collision = new RegExp("([^\\.])\\b" + variable + "\\b(?![\"'`])", "g") - // var collision = new RegExp("([^\\.])" + variable + "\\b(?![\"'`])", "g") var exported = new RegExp("module\\.exports\\s*=\\s*" + variable) if (collision.test(code) && !exported.test(code) && !globals[variable.match(/[^\.]+/)]) { var fixed = variable + usedVariables[variable]++ diff --git a/mithril.min.js b/mithril.min.js index dad08474..e687f9a6 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,4 +1,4 @@ -(function(){function y(){function a(){0a.indexOf("?")?"?":"&";a+=g+d}return a}function d(a){try{return""!==a?JSON.parse(a):null}catch(b){throw Error(a);}}function g(a){return a.responseText}var k=0,m;return{xhr:function(e){var n=C.stream();void 0!==e.initialValue&&n(e.initialValue);var v="boolean"===typeof e.useBody?e.useBody:"GET"!==e.method&&"TRACE"!==e.method; -"function"!==typeof e.serialize&&(e.serialize=e.data instanceof FormData?function(a){return a}:JSON.stringify);"function"!==typeof e.deserialize&&(e.deserialize=d);"function"!==typeof e.extract&&(e.extract=g);e.url=b(e.url,e.data);v?e.data=e.serialize(e.data):e.url=h(e.url,e.data);var k=new a.XMLHttpRequest;k.open(e.method,e.url,"boolean"===typeof e.async?e.async:!0,"string"===typeof e.user?e.user:void 0,"string"===typeof e.password?e.password:void 0);e.serialize===JSON.stringify&&v&&k.setRequestHeader("Content-Type", -"application/json; charset=utf-8");e.deserialize===d&&k.setRequestHeader("Accept","application/json, text/*");"function"===typeof e.config&&(k=e.config(k,e)||k);k.onreadystatechange=function(){if(4===k.readyState){try{var a=e.deserialize(e.extract(k,e));if(200<=k.status&&300>k.status){if("function"===typeof e.type)if(a instanceof Array)for(var b=0;bk.status){if("function"===typeof e.type)if(a instanceof Array)for(var b=0;b