koishi-utils
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -1,4 +0,2 @@ | ||
export declare const CJK = "\u2E80-\u2EFF\u2F00-\u2FDF\u3040-\u309F\u30A0-\u30FA\u30FC-\u30FF\u3100-\u312F\u3200-\u32FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF"; | ||
export declare const RE_CJK: RegExp; | ||
export declare function traditionalize(source: string): string; | ||
export declare function simplify(source: string): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.simplify = exports.traditionalize = exports.RE_CJK = exports.CJK = void 0; | ||
exports.simplify = exports.traditionalize = void 0; | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const [simplified, traditional] = fs_1.readFileSync(path_1.resolve(__dirname, '../chinese.txt'), 'utf-8').split(/\r?\n/); | ||
exports.CJK = '\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30fa\u30fc-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff'; | ||
exports.RE_CJK = new RegExp(`[${exports.CJK}]`, 'g'); | ||
const stMap = new Map(); | ||
@@ -10,0 +8,0 @@ const tsMap = new Map(); |
@@ -11,6 +11,6 @@ declare type CQCodeData = Record<string, string | number | boolean>; | ||
function stringify(type: string, data?: CQCodeData): string; | ||
function stringifyAll(codes: CQCode[]): string; | ||
function stringifyAll(codes: (string | CQCode)[]): string; | ||
function parse(source: string): CQCode; | ||
function parseAll(source: string): CQCode[]; | ||
function parseAll(source: string): (string | CQCode)[]; | ||
} | ||
export default CQCode; |
@@ -35,3 +35,3 @@ "use strict"; | ||
function stringifyAll(codes) { | ||
return codes.map(code => stringify(code.type, code.data)).join(''); | ||
return codes.map(code => typeof code === 'string' ? code : stringify(code.type, code.data)).join(''); | ||
} | ||
@@ -59,3 +59,3 @@ CQCode.stringifyAll = stringifyAll; | ||
if (capture.index) { | ||
codes.push({ type: 'text', data: { text: source.slice(0, capture.index) } }); | ||
codes.push(source.slice(0, capture.index)); | ||
} | ||
@@ -66,3 +66,3 @@ codes.push(result); | ||
if (source) | ||
codes.push({ type: 'text', data: { text: source } }); | ||
codes.push(source); | ||
return codes; | ||
@@ -69,0 +69,0 @@ } |
import CQCode from './cqCode'; | ||
export * from './chinese'; | ||
export * from './date'; | ||
export * from './logger'; | ||
export * from './misc'; | ||
@@ -5,0 +6,0 @@ export * from './observe'; |
@@ -21,2 +21,3 @@ "use strict"; | ||
__exportStar(require("./date"), exports); | ||
__exportStar(require("./logger"), exports); | ||
__exportStar(require("./misc"), exports); | ||
@@ -23,0 +24,0 @@ __exportStar(require("./observe"), exports); |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.observe = exports.defineProperty = exports.pick = void 0; | ||
const debug_1 = __importDefault(require("debug")); | ||
const util_1 = require("util"); | ||
const misc_1 = require("./misc"); | ||
const showObserverLog = debug_1.default('koishi:observer'); | ||
const logger_1 = require("./logger"); | ||
const logger = logger_1.Logger.create('observer'); | ||
const staticTypes = ['number', 'string', 'bigint', 'boolean', 'symbol', 'function']; | ||
@@ -55,3 +52,3 @@ const builtinClasses = ['Date', 'RegExp', 'Set', 'Map', 'WeakSet', 'WeakMap', 'Array']; | ||
if (!hasKey && label) { | ||
showObserverLog(`[diff] ${label}: ${String(key)} (deep)`); | ||
logger.debug(`[diff] ${label}: ${String(key)} (deep)`); | ||
} | ||
@@ -71,3 +68,3 @@ }); | ||
if (!hasKey && label) { | ||
showObserverLog(`[diff] ${label}: ${String(key)}`); | ||
logger.debug(`[diff] ${label}: ${String(key)}`); | ||
} | ||
@@ -149,3 +146,3 @@ } | ||
if (label) | ||
showObserverLog(`[update] ${label}: ${fields.join(', ')}`); | ||
logger.debug(`[update] ${label}: ${fields.join(', ')}`); | ||
for (const key in this._diff) { | ||
@@ -152,0 +149,0 @@ delete this._diff[key]; |
{ | ||
"name": "koishi-utils", | ||
"description": "Utilities for Koishi", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"main": "dist/index.js", | ||
@@ -36,7 +36,7 @@ "typings": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@types/debug": "^4.1.5" | ||
"@types/supports-color": "^5.3.0" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.1.1" | ||
"supports-color": "^7.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
73707
42
779
+ Addedsupports-color@^7.1.0
+ Addedhas-flag@4.0.0(transitive)
+ Addedsupports-color@7.2.0(transitive)
- Removeddebug@^4.1.1
- Removeddebug@4.4.0(transitive)
- Removedms@2.1.3(transitive)