'use strict'
// 兼容模式,兼容老版本浏览器
function pad(value, length, placeholder) {
length = length || 15;
placeholder = placeholder || ' ';
var diff = Math.max(0, length - value.length) + 1;
This file contains hidden or 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
| # 配置运行环境 | |
| FROM node:alpine AS deps | |
| # 配置工作目录 | |
| WORKDIR /wwwroot | |
| # 切换国内软件源 | |
| RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories | |
| # 安装编译环境 | |
| RUN apk update && apk upgrade -f && apk add --no-cache g++ make python3 |
This file contains hidden or 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
| # 配置运行环境 | |
| FROM node:alpine | |
| # 配置工作目录 | |
| WORKDIR /wwwroot | |
| # 配置 Node 运行模式 | |
| ENV NODE_ENV production | |
| # 禁用 Next 数据遥测 | |
| ENV NEXT_TELEMETRY_DISABLED 1 |
This file contains hidden or 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 hashCode | |
| * @param {string} string | |
| * @returns {number} | |
| */ | |
| function hashCode(string: string): number { | |
| let hash: number = 0; | |
| const { length }: string = string; |
This file contains hidden or 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 rgb2hex(red, green, blue) { | |
| const rgb = (red << 16) | (green << 8) | blue; | |
| return `#${rgb.toString(16).padStart(6, '0')}`; | |
| } | |
| function hex2rgb(hex) { | |
| return [(hex >> 16) & 0xff, (hex >> 8) & 0xff, hex & 0xff]; | |
| } |
This file contains hidden or 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 LCGRandom | |
| * @description 线性同余随机数 | |
| * @param {number} seed | |
| * @returns {number} | |
| * @see https://gist.github.com/Protonk/5389384 | |
| */ | |
| function LCGRandom1(seed = 0) { | |
| return ((seed * 11 + 17) % 25) / 25; | |
| } |
This file contains hidden or 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
| // https://jsperf.com/utf8-encoder-decoder | |
| var encoder = new TextEncoder(); | |
| var decoder = new TextDecoder(); | |
| // https://developer.mozilla.org/zh-CN/docs/Web/API/TextEncoder | |
| var native = { | |
| encode: encoder.encode.bind(encoder), | |
| decode: decoder.decode.bind(decoder) | |
| }; |
This file contains hidden or 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() { | |
| // refactor process.argv to determine the app entry point and remove the interceptor parameter | |
| var appFile; | |
| var newArgs = []; | |
| process.argv.forEach(function(item, index) { | |
| if (index === 2) appFile = item; | |
| if (index !== 1) newArgs.push(item); | |
| }); |
/**
* strip utf-8 BOM
*
* @param {any} buffer
* @returns {Buffer}
*/
function stripBOM(buffer) {
//EF BB BF 239 187 191
if (buffer[0] === 0xef && buffer[1] === 0xbb && buffer[2] === 0xbf) {
This file contains hidden or 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
| /** | |
| * Base64 | |
| * http://blog.csdn.net/cuixiping/article/details/409468 | |
| * ADODB.Stream 实例有 LoadFromFile 方法可以读取文件内容 | |
| * ADODB.Stream 实例有 state 属性 0 和 1,分别对应 Open 状态: adStateClosed 和 adStateOpen | |
| * ADODB.Stream 实例有 LineSeparator 属性 13、-1 和 10,分别对应换行符: adCR、adCRLF 和 adLF | |
| * ADODB.Stream 实例的其他属性和方法可参考相应文档 | |
| */ | |
| var Base64 = { | |
| /** |