当不是用node方式启动时
NODE_OPTIONS=--max_old_space_size=4096 webpack xxx
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>regex基准</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
function javaEnumToTs(code) { | |
return code.replace( | |
/(?![\n\r]+)(\w+)\((-?\d+),\s"([^"]+)"[^\n\r]+/g, | |
(match, g1, g2,g3) => `/**${g3}**/ | |
${g1}:${g2},` | |
); | |
} | |
{ | |
"pp-api": { | |
"prefix": "ppa", | |
"body": [ | |
"import { message } from 'antd';", | |
"import { AxiosResponse } from 'axios';", | |
"import http from 'helper/http';", | |
"import microservice from 'helper/microservice';", | |
"import { get as _get } from 'lodash';", | |
"const { javaAdmin } = microservice;", |
当不是用node方式启动时
NODE_OPTIONS=--max_old_space_size=4096 webpack xxx
/** | |
* 计算文本长度 | |
* @param text | |
* @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript | |
*/ | |
function getTextWidth(text: string) { | |
// @ts-ignore | |
const canvas: HTMLCanvasElement = getTextWidth.canvas || (getTextWidth.canvas = document.createElement('canvas')); | |
const context = canvas.getContext('2d'); | |
context!.font = '14px sans-serif'; // 14px是猜测的,不能确定 |
<template> | |
</template> | |
<script lang="ts"> | |
const onSomethingScrollFactory = () => { | |
const SCROLL_HIDE_TIMEOUT = 150; | |
const removeScrolling = debounce((el) => { | |
el.classList.remove('scrolling'); | |
}, SCROLL_HIDE_TIMEOUT); |
namespace Api { | |
type PageParam<T = {}> = T & { pageNum?: number; pageSize?: number }; | |
type ApiResult<T = {}> = { | |
[key: string]: any; // 其他基本用不到,想知道看文档 | |
/** | |
* 调用是否成功 | |
*/ | |
success: boolean; | |
/** | |
* 业务状态码 |
::-webkit-scrollbar {/* 滚动条整体样式 */ | |
width: 4px; /* 高宽分别对应横竖滚动条的尺寸 */ | |
height: 0; | |
} | |
::-webkit-scrollbar-thumb {/* 滚动条里面小方块 */ | |
border-radius: 2px; | |
background: rgba(0, 0, 0, 0.13); | |
height: 60px; | |
} |
const j = require('jscodeshift') | |
/** | |
* 为代码插入import语句,只能处理import不能处理require,只能插入import语句,其他代码会被忽略 | |
* @param {*} source | |
* @param {*} imports | |
* @copyright 抄自vue-cli/packages/@vue/cli/lib/util/codemods/injectImports.js | |
*/ | |
module.exports.injectImports = function(source, imports) { | |
const root = j(source) |
{ | |
"scripts": [ | |
"https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.25.3/moment.min.js" | |
], | |
"styles": [], | |
"showConsole": true, | |
"scriptType": "module" | |
} |