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 gogogo() { | |
firstLoop: | |
for (let outer = 0; outer < 4; outer++) { | |
secondLoop: | |
for (let inner = 0; inner < 5; inner++) { | |
if (inner === 3) { | |
// Use continue to avoid runs 4 and 5 | |
continue firstLoop; | |
} | |
console.warn(`outer: ${outer}; inner: ${inner}`); |
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
requestIdleCallback(() => { | |
fetch("xxx/a.html").then(res => res.text()).then(html => { | |
const reg = /target*.js/gi; | |
const scripts = html.match(reg); | |
if(scripts && scripts.length) { | |
scripts.forEach(src => { | |
const link = document.createElement("link"); | |
link.rel = "prefetch"; | |
link.href = src; | |
document.head.appendChild(link); |
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
import Koa from 'koa'; | |
const mnsUtil = require('@mtfe/mns-util'); | |
const httpProxy = require('http-proxy'); | |
import config = require('config'); | |
const proxy = httpProxy.createProxyServer({ | |
headers: { | |
Host: 'alitest.e.fanxiaojian.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
/** | |
* 把平铺的 array 转成 树 | |
* | |
* 比如原始数列: | |
* [ | |
* {id: "13300", parentId: "13300", name: "蔬菜", status: 1}, | |
* {id: "13301", parentId: "13301", name: "饮料", status: 1}, | |
* {id: "13413", parentId: "13413", name: "青菜类", status: 1}, | |
* {id: "13696", parentId: "13696", name: "肉类", status: 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
// 快递地址从百度获取。(百度首页输入快递,查看请求url) | |
let url = "https://sp0.baidu.com/9_Q4sjW91Qh3otqbppnN2DJv/pae/channel/data/asyncqury?appid=4001&com=zhongtong&nu=541247425507&vcode=&token=&_=1538102135046" | |
let req = new Request(url) | |
let json = await req.loadJSON() | |
let items = json.data.info.context | |
let table = new UITable() | |
for (item of items) { | |
let row = new UITableRow() | |
let time = item.time | |
let title = decode(item.desc) |
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
<html> | |
<head> | |
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> | |
<style> | |
.cls1 { | |
color: black; | |
} | |
.flex { |
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
// 测量字符串长度 | |
export function measureText(pText: string, pFontSize: number) { | |
let lDiv = document.createElement('div'); | |
document.body.appendChild(lDiv); | |
lDiv.style.fontSize = '' + pFontSize + 'px'; | |
lDiv.style.position = 'absolute'; | |
lDiv.style.visibility = 'hidden'; | |
lDiv.innerHTML = pText; |