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
Math.mod = function (a, b) { | |
return (a - Math.floor(a / b) * b); | |
}; | |
Math.rem = function (a, b) { | |
return (a - ((a / b) | 0) * b); | |
}; | |
Math.sign = function (a) { | |
return 0 > a ? -1 : 1; | |
}; |
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
var Uint32 = { | |
"~": function (a) { | |
return ~a >>> 0; | |
}, | |
not: function (a) { | |
return this["~"](a); | |
}, | |
"&": function (a, b) { | |
return (a & b) >>> 0; |
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 toChineseNumerals(num) { | |
if (!/^(\d+)(?:\.(\d{1,2}))?$/.test(num)) return ""; | |
var m = RegExp["$1"], n = RegExp["$2"]; | |
var a = ["", "萬", "億", "兆", "京", "垓", "秭", "穰", "沟", "涧", "正", "载"]; | |
var b = ["", "十", "百", "千"]; | |
var c = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"]; | |
var d = ["角", "分"]; | |
return "(大写)" + m.split("").reverse().join("").match(/.{1,4}/g).map(function (item, index, array) { | |
return b.reduceRight(function (prev, cur, idx, arr) { | |
return prev += c[item[idx] >>> 0] + cur; |
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 dom1(el, isBack) { | |
isBack || ++idx; | |
if (!el) { | |
return; | |
} | |
var next = isBack ? el.nextElementSibling : (el.firstElementChild || el.nextElementSibling); | |
return dom1(next ? next : el.parentNode, !next); | |
} |
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 (global, factory) { | |
"use strict"; | |
var moduleName = "FastClick"; | |
if (typeof define === "function" && define.amd) { | |
define(function () { | |
return (global[moduleName] = factory(global)); | |
}); | |
} else if (typeof module === "object" && module.exports) { |
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
/* | |
* UnitBezier | |
* from: https://chromium.googlesource.com/chromium/blink/+/master/Source/platform/animation/UnitBezier.h | |
* version: 0.0.1 | |
*/ | |
"use strict"; | |
;(function (global, factory) { | |
if ("function" === typeof define && define.amd) { | |
define(function () { |
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
/* | |
* spiral matrix | |
* 根据给出的行(row)与列(col),生成一个螺旋数组([[x0, y0], .., [x, y]]]) | |
* 如 row = 3, col = 4 | |
* 01, 02, 03, 04 | |
* 10, 11, 12, 05 | |
* 09, 08, 07, 06 | |
* 将生成: | |
* [[0, 0], [1, 0], [2, 0], [3, 0], [3, 1], [3, 2], [2, 2], [1, 2], [0, 2], [0, 1], [1, 1], [2, 1]] | |
* |
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
/* | |
* @param {Function} func | |
* 需要进行节流的函数 | |
* @param {number} wait | |
* 节流的时间间隔 | |
* @param {boolean} [trail] | |
* 是否要在结尾执行 | |
* @returns {Function} | |
* 返回一个节流函数 | |
*/ |
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
/* | |
* @param {Function} func | |
* 需要进行去抖的函数 | |
* @param {number} wait | |
* 去抖的时间间隔 | |
* @param {boolean} [lead = false] | |
* 是否要在开始执行 | |
* @returns {Function} | |
* 返回一个去抖函数 | |
*/ |
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
/** | |
* quote function | |
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/quote|MDN} | |
* @param {string} str | |
* @param {string} quote | |
* @returns {string} quote a string | |
*/ | |
function quoteString(str, quote) { | |
str = "" + str; | |
quote = "" + (quote || "\""); |
OlderNewer