/**
* 计算字符串所占的内存字节数,默认使用UTF-8的编码方式计算,也可制定为UTF-16
* UTF-8 是一种可变长度的 Unicode 编码格式,使用一至四个字节为每个字符编码
*
* 000000 - 00007F(128个代码) 0zzzzzzz(00-7F) 一个字节
* 000080 - 0007FF(1920个代码) 110yyyyy(C0-DF) 10zzzzzz(80-BF) 两个字节
* 000800 - 00D7FF
* 00E000 - 00FFFF(61440个代码) 1110xxxx(E0-EF) 10yyyyyy 10zzzzzz 三个字节
* 010000 - 10FFFF(1048576个代码) 11110www(F0-F7) 10xxxxxx 10yyyyyy 10zzzzzz 四个字节
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
/** | |
* @module import-meta-glob | |
*/ | |
import path from 'path'; | |
import glob from 'fast-glob'; | |
import { Plugin } from 'rollup'; | |
import MagicString from 'magic-string'; | |
import { stripLiteral } from 'strip-literal'; | |
import acorn, { parseExpressionAt } from 'acorn'; |
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
/** | |
* @module getFiles | |
*/ | |
import { Dirent } from 'fs'; | |
import { join, resolve } from 'path'; | |
import { readdir } from 'fs/promises'; | |
type Waiting = [ | |
// Current dirname |
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
/** | |
* @module compose | |
*/ | |
export interface Next { | |
(): Promise<void>; | |
} | |
export interface Composed<C> { | |
(context: C, next?: Next): Promise<void>; |
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
/** | |
* @module compose | |
*/ | |
interface CallStack { | |
index: number; | |
} | |
export interface Next { | |
(): Promise<void>; |
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
/** | |
* @module BitMatrix | |
*/ | |
function toUint32(uint32: number): number { | |
// 防止溢出 0-0xffffffff | |
return uint32 >>> 0; | |
} | |
export class BitMatrix { |
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
// 使用位运算将数字转换为8位有符号整数 | |
function toInt8(value: number): number { | |
return (value << 24) >> 24; | |
} | |
// 使用位运算将数字转换为8位无符号整数 | |
function toUint8(value: number): number { | |
return value & 0xff; | |
} |
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
// prettier-ignore | |
// @see https://github.com/soldair/node-qrcode/blob/master/helper/to-sjis.js | |
// @see https://github.com/soldair/node-qrcode/pull/319 | |
// @see http://ash.jp/code/unitbl21.htm | |
// @see https://seiai.ed.jp/sys/text/java/shiftjis_table.html | |
const SJIS_TABLE: [offset: number, sjis: string][] = [ | |
[0x8140, ' 、。,.・:;?!゛゜´`¨^ ̄_ヽヾゝゞ〃仝々〆〇ー―‐/\~∥|…‥‘’“”()〔〕[]{}〈〉《》「」『』【】+-±×'], | |
[0x8180, '÷=≠<>≦≧∞∴♂♀°′″℃¥$¢£%#&*@§☆★○●◎◇◆□■△▲▽▼※〒→←↑↓〓'], | |
[0x81b8, '∈∋⊆⊇⊂⊃∪∩'], | |
[0x81c8, '∧∨¬⇒⇔∀∃'], |
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
/** | |
* @module BitArray | |
*/ | |
const LOAD_FACTOR = 0.75; | |
function toUInt32(uint32: number): number { | |
// 防止溢出 0-0xffffffff | |
return uint32 >>> 0; | |
} |
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
/** | |
* @module compose | |
*/ | |
export interface Next { | |
(): Promise<void>; | |
} | |
export interface Composed<C> { | |
(context: C, next?: Next): Promise<void>; |
NewerOlder