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
urlencode() { | |
local length="${#1}" | |
for (( i = 0; i < length; i++ )); do | |
local c="${1:i:1}" | |
case $c in | |
[a-zA-Z0-9.~_-]) printf "$c" ;; | |
*) printf "$c" | xxd -p -c1 | while read x;do printf "%%%s" "$x";done | |
esac | |
done | |
} |
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
const UnimplementedError = createErrorType('Unimplemented'); | |
const AuthError = createErrorType('AuthError'); | |
const ResponseError = createErrorType('ResponseError', function(message, data) { | |
this.data = data; | |
}); | |
module.exports = { | |
UnimplementedError, |
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 LOCALES = { | |
'zh_cn': { | |
weekday: function(i) { return '星期' + '日一二三四五六'[i] }, | |
weekday_abbr: function(i) { return '周' + '日一二三四五六'[i] } | |
// 本地月日就免了,因为现在几乎看不到“一月二十三日”这种描述了 | |
} | |
} | |
// XXX: ...默认中文 | |
var LOCALE = LOCALES['zh_cn'] |
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
/*! | |
* decimal-js: Decimal Javascript Library v0.0.2 | |
* https://github.com/shinuza/decimal-js/ | |
*/ | |
/* | |
Copyright (c) 2011 Samori Gorse, http://github.com/shinuza/decimal-js | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, |
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() { | |
window.onresize = function() { | |
setRootFontSize(); | |
}; | |
setRootFontSize(); | |
function setRootFontSize() { | |
var el = document.documentElement; | |
var w = el.clientWidth; | |
// 最大按6Plus,最小按240,因为小于12px可能就有问题了 |
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
/** | |
* 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. The function also has a property 'clear' | |
* that is a function which will clear the timer to prevent previously scheduled executions. | |
* | |
* @source underscore.js | |
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/ | |
* @param {Function} function to wrap |
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
const type = require('./type.js') | |
const clone = require('./clone') | |
const SAME = '__DIFF_SAME__' | |
const REPLACE = '__DIFF_REPLACE__' | |
// 生成两个对象的比较结果 | |
function diff(prev, next) { | |
if (prev === next) return SAME |
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 timeout(ms) { | |
return new Promise((resolve) => setTimeout(resolve, ms)) | |
} | |
async function sleep(time) { | |
await timeout(time) | |
} | |
function throttle (method, context) { | |
clearTimeout(context.timerId); |
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
/** | |
* EventBus 对象解决页面间的传值问题,在需要传值的页面引入这个文件 | |
* | |
* 更新:9-29 | |
* tigger 后自动注销事件,不需要手动管理 | |
* 更新:10-20 | |
* 支持发布-订阅、订阅-发布两种模式 | |
* listen 第三个参数用于控制是否触发cache中的方法(为true开启订阅-发布模式) | |
*/ |
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 validateEmail(email) { | |
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
return re.test(email); | |
} | |
// 验证中文字符 | |
function validateCnText(str) { | |
var pattern = /^([\u4E00-\u9FA5]|[\uFE30-\uFFA0])*$/gi; | |
return pattern.test(str); |
NewerOlder