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 getElementTop(elem) { | |
var elemTop = elem.offsetTop; | |
elem = elem.offsetParent; | |
while (elem != null) { | |
elemTop += elem.offsetTop; | |
elem = elem.offsetParent; | |
} | |
return elemTop; |
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
syncApply ({timeout, fn, args = [], scope = this}) { | |
return new Promise((resolve, reject) => { | |
try { | |
setTimeout(() => { | |
resolve(fn.apply(scope, args)) | |
}, timeout) | |
} catch (err) { | |
reject(err) | |
} | |
}) |
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
// array flatten function | |
function flatten (arr) { | |
let result = [].slice.call(arguments)[1] || [] | |
for (let i = 0; i < arr.length; i++) { | |
if (Array.isArray(arr[i])) { | |
flatten(arr[i], result) | |
} else { | |
result.push(arr[i]) | |
} |
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 a {String} | |
* @param b {String} | |
*/ | |
function sumBigNumber(a, b) { | |
if (typeof a !== 'string' || typeof b !== 'string') { | |
throw new Error('param 'a' and 'b' must be string') | |
} | |
var res = '', |
OlderNewer