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
type SpilitStrToTupleByItem<Str extends string, StrItem extends string, TupleRes extends string[] = []> = Str extends `${infer RestStr}${StrItem}` ? | |
SpilitStrToTupleByItem<RestStr,StrItem,[...TupleRes, 'ssh']>: TupleRes; | |
type RepeatCount<Str extends string, StrItem extends string> = Str extends "" ? 0 : SpilitStrToTupleByItem<Str, StrItem>['length']; | |
type RepeatStr<Str extends string, Count extends number, StrItem extends string = Str> = RepeatCount<Str, StrItem> extends Count ? Str : RepeatStr<`${Str}${StrItem}`, Count, StrItem> ; | |
type r = RepeatStr<'Abc', 3>; | |
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 cancable(p) { | |
var cancel; | |
var promise = new Promise((resolve, reject) => { | |
p.then(resolve, reject); | |
cancel = reject; | |
}); | |
return { | |
promise: promise, | |
cancel: cancel | |
}; |
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 parse(template, options) { | |
// 处理options | |
var stack = []; | |
var currentParent; | |
var root; | |
function closeElement(element) { | |
currentParent.children.push(element); | |
element.parent = currentParent; | |
} | |
parseHTML(template, { |
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 { desktopCapturer } from 'electron'; | |
let video: HTMLVideoElement; | |
/** | |
* 获取窗口截图,转成base64 | |
* @param document | |
*/ | |
export default function getScreenshotData(document: Document) { |
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 walkers = { | |
"string": function(str) { | |
return [ "string", str ]; | |
}, | |
"num": function(num) { | |
return [ "num", num ]; | |
}, | |
"name": function(name) { | |
return [ "name", name ]; | |
}, |
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 parser = require('@babel/parser'); | |
const traverse = require('@babel/traverse').default; | |
const generate = require('@babel/generator').default; | |
const code1 = ` | |
const ssh = 'sshssh'; | |
(function parc(moo, man){ | |
try { | |
console.log(ssh); | |
var foobar = 10; | |
function bbb() { |
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 base54 = (function(){ | |
var DIGITS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_"; | |
return function(num) { | |
var ret = ""; | |
do { | |
ret = DIGITS.charAt(num % 54) + ret; | |
num = Math.floor(num / 54); | |
} while (num > 0); | |
return ret; | |
}; |