This file contains hidden or 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
/** | |
* 给定数组,转换为对象类型,键/值必须在给定数组中。 | |
**/ | |
// Example: | |
const tuple = ['tesla', 'model 3', 'model X', 'model Y'] as const | |
const result: TupleToObject<typeof tuple> // expected { tesla: 'tesla', 'model 3': 'model 3', 'model X': 'model X', 'model Y': 'model Y'} |
This file contains hidden or 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
/** | |
* | |
* Complete the following 2 types of 'CreateRequest' and 'GetParams'. | |
* 完善下述两个类型 'CreateRequest' 和 'GetParams'。 | |
* | |
**/ | |
// improve type of CreateRequest | |
type CreateRequest = unknown |
This file contains hidden or 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
/** | |
* | |
* Create a function that meets the following requirements: | |
* - Read files and folders from the specified directory. | |
* - Collects metadata about files or folders and returns it as an array. | |
* - Note whether the file has read access. | |
* | |
* 创建一个符合下述要求的函数: | |
* - 读取指定目录下的文件或文件夹,包含子文件夹 | |
* - 收集文件的元信息并作为数组返回 |
This file contains hidden or 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
let getQueryString = (key, queryStr = location.search + location.hash) => { | |
let reg = new RegExp('(^|\\?|&)' + key + '=([^&]*)(\\s|&|$)', 'i') | |
return reg.test(queryStr) ? decodeURIComponent(RegExp.$2) : '' | |
} |
This file contains hidden or 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
'use strict'; | |
let Ajax = {}; | |
Ajax.xhr = () => { | |
let xhr, versions; | |
if(typeof XMLHttpRequest !== undefined) { | |
xhr = new XMLHttpRequest(); | |
} else { |
This file contains hidden or 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 it = document.getElementsByClassName('mui-act-item-yhqbtn'); | |
var i = 0; | |
function get(){ | |
if(it.length <= i) return; | |
it[i++].click(); | |
var c = document.getElementsByClassName('mui-dialog-close')[0]; | |
c && c.click(); | |
setTimeout(function(){get(); console.log(i)}, 500); | |
} |
This file contains hidden or 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
// 颜色 从十六进制转为 rgba | |
exports.convertHex = function(hex, opacity) { | |
hex = hex.replace('#', ''); | |
r = parseInt(hex.substring(0, 2), 16); | |
g = parseInt(hex.substring(2, 4), 16); | |
b = parseInt(hex.substring(4, 6), 16); | |
result = 'rgba(' + r + ',' + g + ',' + b + ',' + opacity / 100 + ')'; | |
return result; | |
}; |
This file contains hidden or 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
// 获取 GUID 方法, from Robert Kieffer | |
Math.guid = function () { | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { | |
var r = Math.random() * 16|0, v = c == 'x' ? r : (r&0x3|0x8) | |
return v.toString(16) | |
}).toUpperCase() | |
} | |
// Object.create 支持 |
This file contains hidden or 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 PubSub = { | |
// 订阅函数 | |
subscribe: function (event, callback) { | |
// 创建事件存储对象 | |
this._events = this._events || {} | |
// 添加回调函数 | |
this._events[event] = this._events[event] || [] | |
this._events[event].push(callback) | |
// 链式调用 | |
return this |
NewerOlder