Skip to content

Instantly share code, notes, and snippets.

View GitaiQAQ's full-sized avatar
🏠
Working for home

Gitai GitaiQAQ

🏠
Working for home
View GitHub Profile
import byteSize from 'byte-size';
const manifest = [];
process.on('beforeExit', () => {
console.table(manifest);
});
export default () => ({
name: 'Size',
{
name: 'InlineScriptHTMLRender',
async generateBundle(_, bundles, isWrite) {
if (isWrite) {
return new Promise((resolve) => {
Object.values(bundles).map((bundle) => {
Object.keys(bundles).map(key => delete bundles[key]);
if (bundle.name === 'bootloader') {
renderFile('src/index.ejs', {
inlineScript: bundle.code,
import replace from '@rollup/plugin-replace';
let manifest = {};
export const replaceManifest = () => {
return replace({
__MANIFEST__: () => JSON.stringify(manifest),
});
};
export const doThis = count => Array.prototype.map.bind(Array.from({ length: count }));
export const Timeout = (timeout, promise?: Promise<any>) =>
new Promise((resolve, reject) => {
const timer = setTimeout(() => {
reject(new Error(`Timeout(${timeout})`));
}, timeout);
// 如果完成了得清理
const clear = () => clearTimeout(timer);
promise.then(clear, clear);
interface Test<T> {
g?: Test<T>;
}
function mixinPerson<T extends Constructor<{}>>(Base: T) {
return class Base {
constructor(public name: string) { }
}
#!/bin/ts-node
const SymbolCache = Symbol.for("cache");
let miss = 0;
function computed(...args) {
const _cache = {};
return function (
target,
propertyKey: string,
@GitaiQAQ
GitaiQAQ / .u.js
Last active February 28, 2022 15:52
A tiny unit test module or function powered by ES6/Promise.
#!/usr/bin/env node
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
// Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
@GitaiQAQ
GitaiQAQ / main.rs
Last active February 8, 2019 09:01
假装写了个 v-dom,实际上只有最简单的 diff
#![allow(dead_code)]
use std::collections::HashMap;
use std::collections::HashSet;
trait Renderable {
fn render(&mut self) {
unimplemented!()
}
}
@GitaiQAQ
GitaiQAQ / AutoACE.js
Created January 9, 2019 15:13
自动挂载 ACE 替换普通文本域。
(function() {
'use strict';
jQuery(document).ready(function() {
let Language = {
"C": "c_cpp",
"C++": "c_cpp",
"Java": "java",
"JavaScript": "javascript",
"Python": "python"
};
@GitaiQAQ
GitaiQAQ / tingyun.js
Created April 22, 2018 08:28
听云 JS 加了点注释。。。
var TINGYUN = function (t, e, n) {
function r(t) {
var e = !!t && "length" in t && t.length, n = typeof t;
return "function" !== n && ("array" === n || 0 === e || "number" == typeof e && e > 0 && e - 1 in t)
}
function i(t, e) {
var n, i = 0;
if (t) if (r(t)) for (n = t.length; i < n && !1 !== e.call(t[i], t[i], i); i++) ; else for (i in t) if (!1 === e.call(t[i], t[i], i)) break;
return t