NoBey
NoBey
> 因为从`VueTemplate`中是无法可知数据`json`是什么形式的,如果知道也无需转换,因此写为`html2json`,即`HtmlParser`。 > > 而`createTemplate`可以实现,具体看链接。 > > [在线示例](https://stackblitz.com/edit/typescript-2oikhm?file=index.ts) 这个逻辑上应该 是 Template => Json(Template Ast tree) => View Template 和 ast tree 可以互转 从 View 向往回转是转不到 Template 的
```js const swap = ( i, j, a = $$("li")[i], b = $$("li")[j], t = document.createElement("div"), t2 = document.createElement("div") ) => a.replaceWith(t) || b.replaceWith(t2) || t.replaceWith(b) || t2.replaceWith(a); swap(0, 2)...
异步函数 那个就是骗人, 不用 async 输出也是对的, 想到与 setTimeout(fn, 0), 宏任务也是按照顺序输出 其实方法就两种 1. 破坏 setTimeout 的时间参数, 时期不是随机或者不生效 2. 还是记录变量 改变 n 的引用, 不在全局变量可以挂在 print 上 print.n++, 或者挂在外部数据 api store 之类的 ```js function...
```js const getUrlQurey = () => location.search .slice(1) .split('&') .reduce((obj, str) => (([k, v]) => ({...obj, [k]: v }) )(str.split('=')), {}) ```
```js function numSum(nums, n, m, arr = [], ans = [], index = 0) { if(arr.length === n) return arr.reduce((a,b) => a + b, 0) === m && ans.push([...arr]) for(let...
```js function mostCharInStr(str){ return ((obj, k = Object.keys(obj).sort((a, b) => obj[b] - obj[a])[0]) => [k, obj[k]] )(str .split('') .reduce((obj, k) => ({...obj, [k]: (obj[k]||0)+1 }), {}) ) } ```
```js function createFlow(arr){ arr.run = async (cb) => { for(let fn of arr.flat(99)){ await fn() } cb && cb() } return arr } ```
```js const delneighbor = (str) => [...str].reduce((ans, cur) => ans[ans.length-1] === cur ? ans : ans + cur , '') delneighbor('aabbaaaaccdeee') ```
好吧
下午吧,我重新整理下代码