mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-01 21:49:21 +03:00
isArray to native Array.isArray
isUnd(*) to native undefined === *
isFunc to native typeof * === 'function'
isObject to native typeof * === 'object'
microtime() to native Date().getTime();
noop to native ()=>{}
noopFalse to native ()=>false
noopTrue to native ()=>true
boolToAjax to native *?'1':'0'
Underscore.js to native
This commit is contained in:
parent
fa39c7ecba
commit
ea48f5060b
72 changed files with 551 additions and 775 deletions
6
vendors/underscore/underscore-min.custom.js
vendored
6
vendors/underscore/underscore-min.custom.js
vendored
|
|
@ -1,6 +0,0 @@
|
|||
// Underscore.js 1.9.2
|
||||
// https://underscorejs.org
|
||||
// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore may be freely distributed under the MIT license.
|
||||
|
||||
(()=>{var e=function(){};("object"==typeof self&&self.self===self&&self||{})._=e;e.defer=(()=>{var e=(e,t,...l)=>setTimeout(()=>e.apply(null,l),t),t=function(...l){for(var n=1,r=[l[0],1];n<l.length;)r.push(l[n++]);return function(e,t,l,n,r){if(!(n instanceof t))return e.apply(l,r);var u=e.prototype,a="object"!=typeof u?{}:Object.create(u),o=e.apply(a,r);return"object"==typeof o?o:a}(e,t,this,this,r)};return t})(),e.throttle=function(e,t,l){l||(l={});var n,r,u,a,o=0,i=function(){o=!1===l.leading?0:Date.now(),n=null,a=e.apply(r,u),n||(r=u=null)},c=(...u)=>{var c=Date.now();o||!1!==l.leading||(o=c);var p=t-(c-o);return r=this,p<=0||p>t?(n&&(clearTimeout(n),n=null),o=c,a=e.apply(r,u),n||(r=u=null)):n||!1===l.trailing||(n=setTimeout(i,p)),a};return c.cancel=(()=>{clearTimeout(n),o=0,n=r=u=null}),c},e.debounce=function(e,t,l){var n,r,u=(t,l)=>{n=null,l&&(r=e.apply(t,l))},a=function(...a){if(n&&clearTimeout(n),l){var o=!n;n=setTimeout(u,t),o&&(r=e.apply(this,a))}else{var i=this;n=setTimeout(()=>u.apply(null,[i,a]),t)}return r};return a.cancel=(()=>{clearTimeout(n),n=null}),a}})();
|
||||
124
vendors/underscore/underscore.custom.js
vendored
124
vendors/underscore/underscore.custom.js
vendored
|
|
@ -1,124 +0,0 @@
|
|||
// Underscore.js 1.9.2
|
||||
// https://underscorejs.org
|
||||
// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||
// Underscore may be freely distributed under the MIT license.
|
||||
/*
|
||||
_.debounce
|
||||
_.defer
|
||||
_.throttle
|
||||
*/
|
||||
|
||||
(() => {
|
||||
|
||||
// Baseline setup
|
||||
// --------------
|
||||
|
||||
// Create a safe reference to the Underscore object for use below.
|
||||
var _ = function() { };
|
||||
|
||||
// Establish the root object, `window` (`self`) in the browser.
|
||||
// We use `self`instead of `window` for `WebWorker` support.
|
||||
(typeof self == 'object' && self.self === self && self || {})._ = _;
|
||||
|
||||
// Function (ahem) Functions
|
||||
// ------------------
|
||||
|
||||
// Determines whether to execute a function as a constructor
|
||||
// or a normal function with the provided arguments.
|
||||
var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
|
||||
if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
|
||||
var fp = sourceFunc.prototype,
|
||||
self = (typeof fp !== 'object') ? {} : Object.create(fp),
|
||||
result = sourceFunc.apply(self, args);
|
||||
return (typeof result === 'object') ? result : self;
|
||||
};
|
||||
|
||||
// Defers a function, scheduling it to run after the current call stack has
|
||||
// cleared.
|
||||
_.defer = (() => {
|
||||
var func = (func, wait, ...args) => setTimeout(() => func.apply(null, args), wait),
|
||||
bound = function(...params) {
|
||||
var pos = 1,
|
||||
args = [params[0], 1];
|
||||
while (pos < params.length) args.push(params[pos++]);
|
||||
return executeBound(func, bound, this, this, args);
|
||||
};
|
||||
return bound;
|
||||
})();
|
||||
|
||||
// Returns a function, that, when invoked, will only be triggered at most once
|
||||
// during a given window of time. Normally, the throttled function will run
|
||||
// as much as it can, without ever going more than once per `wait` duration;
|
||||
// but if you'd like to disable the execution on the leading edge, pass
|
||||
// `{leading: false}`. To disable execution on the trailing edge, ditto.
|
||||
_.throttle = function(func, wait, options) {
|
||||
if (!options) options = {};
|
||||
var timeout, context, args, result,
|
||||
previous = 0,
|
||||
later = function() {
|
||||
previous = options.leading === false ? 0 : Date.now();
|
||||
timeout = null;
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
},
|
||||
throttle = (...args) => {
|
||||
var now = Date.now();
|
||||
if (!previous && options.leading === false) previous = now;
|
||||
var remaining = wait - (now - previous);
|
||||
context = this;
|
||||
if (remaining <= 0 || remaining > wait) {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
previous = now;
|
||||
result = func.apply(context, args);
|
||||
if (!timeout) context = args = null;
|
||||
} else if (!timeout && options.trailing !== false) {
|
||||
timeout = setTimeout(later, remaining);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
throttle.cancel = () => {
|
||||
clearTimeout(timeout);
|
||||
previous = 0;
|
||||
timeout = context = args = null;
|
||||
};
|
||||
|
||||
return throttle;
|
||||
};
|
||||
|
||||
// Returns a function, that, as long as it continues to be invoked, will not
|
||||
// be triggered. The function will be called after it stops being called for
|
||||
// N milliseconds. If `immediate` is passed, trigger the function on the
|
||||
// leading edge, instead of the trailing.
|
||||
_.debounce = function(func, wait, immediate) {
|
||||
var timeout, result,
|
||||
later = (context, args) => {
|
||||
timeout = null;
|
||||
if (args) result = func.apply(context, args);
|
||||
},
|
||||
debounce = function(...args) {
|
||||
if (timeout) clearTimeout(timeout);
|
||||
if (immediate) {
|
||||
var callNow = !timeout;
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) result = func.apply(this, args);
|
||||
} else {
|
||||
var obj = this;
|
||||
timeout = setTimeout(() => later.apply(null, [obj, args]), wait);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
debounce.cancel = () => {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
};
|
||||
|
||||
return debounce;
|
||||
};
|
||||
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue