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
/** | |
* @module useStateMachine | |
* @see https://github.com/cassiozen/useStateMachine | |
*/ | |
import { useCallback, useEffect, useMemo, useReducer } from 'react'; | |
const enum ActionType { | |
Update, | |
Transition |
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
/** | |
* @module crypto | |
*/ | |
/** | |
* @function safeAtob | |
* @description 安全模式的 atob | |
* @param text 要 Base64 解码的文本 | |
*/ | |
function safeAtob(text: 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
/** | |
* @module treeShake | |
*/ | |
import MagicString from 'magic-string'; | |
/*** | |
* @function treeShake | |
* @description Fixed tree shaking for typescript and rollup preserve modules. | |
* @return {import('rollup').Plugin} |
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
/** | |
* @module bigint | |
*/ | |
function getByteLength(value: bigint): number { | |
if (value === 0n || value === -1n) { | |
return 1; | |
} | |
if (value < 0n) { |
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
/** | |
* @module getFiles | |
*/ | |
import { Dirent } from 'fs'; | |
import { join, resolve } from 'path'; | |
import { readdir } from 'fs/promises'; | |
type Waiting = [ | |
// Current dirname |
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
/** | |
* @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 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
// 使用位运算将数字转换为8位有符号整数 | |
function toInt8(value: number): number { | |
return (value << 24) >> 24; | |
} | |
// 使用位运算将数字转换为8位无符号整数 | |
function toUint8(value: number): number { | |
return value & 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
// 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 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
/** | |
* @module BitArray | |
*/ | |
const LOAD_FACTOR = 0.75; | |
function toUInt32(uint32: number): number { | |
// 防止溢出 0-0xffffffff | |
return uint32 >>> 0; | |
} |
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
/** | |
* @module BitMatrix | |
*/ | |
function toUint32(uint32: number): number { | |
// 防止溢出 0-0xffffffff | |
return uint32 >>> 0; | |
} | |
export class BitMatrix { |
NewerOlder