koishi-utils
Advanced tools
Comparing version 2.1.3 to 2.2.0
@@ -7,4 +7,2 @@ "use strict"; | ||
const supports_color_1 = require("supports-color"); | ||
const tty_1 = require("tty"); | ||
const isTTY = tty_1.isatty(process.stderr.fd); | ||
const colors = supports_color_1.stderr.level < 2 ? [6, 2, 3, 4, 5, 1] : [ | ||
@@ -59,9 +57,5 @@ 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, | ||
} | ||
instances[name] = this; | ||
this.code = colors[Math.abs(hash) % colors.length]; | ||
instances[this.name] = this; | ||
this.displayName = name; | ||
if (name) | ||
this.displayName += ' '; | ||
if (isTTY) | ||
this.displayName = this.color(this.displayName, ';1'); | ||
this.displayName = name ? this.color(name + ' ', ';1') : ''; | ||
this.createMethod('success', '[S] ', 1); | ||
@@ -105,3 +99,3 @@ this.createMethod('error', '[E] ', 1); | ||
Logger.options = { | ||
colors: isTTY, | ||
colors: supports_color_1.stderr.hasBasic, | ||
}; | ||
@@ -108,0 +102,0 @@ Logger.formatters = { |
export declare function noop(): any; | ||
export declare function isInteger(source: any): boolean; | ||
export declare function sleep(ms: number): Promise<void>; | ||
export declare function assertProperty<O, K extends keyof O>(config: O, key: K): O[K]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sleep = exports.isInteger = exports.noop = void 0; | ||
exports.assertProperty = exports.sleep = exports.isInteger = exports.noop = void 0; | ||
function noop() { } | ||
@@ -14,2 +14,8 @@ exports.noop = noop; | ||
exports.sleep = sleep; | ||
function assertProperty(config, key) { | ||
if (!config[key]) | ||
throw new Error(`missing configuration "${key}"`); | ||
return config[key]; | ||
} | ||
exports.assertProperty = assertProperty; | ||
//# sourceMappingURL=misc.js.map |
export declare function pick<T, K extends keyof T>(source: T, keys: Iterable<K>): Pick<T, K>; | ||
export declare function omit<T, K extends keyof T>(source: T, keys: Iterable<K>): Pick<T, Exclude<keyof T, K>>; | ||
export declare function defineProperty<T, K extends keyof T>(object: T, key: K, value: T[K]): void; | ||
@@ -3,0 +4,0 @@ export declare function defineProperty<T, K extends keyof any>(object: T, key: K, value: any): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.observe = exports.defineProperty = exports.pick = void 0; | ||
exports.observe = exports.defineProperty = exports.omit = exports.pick = void 0; | ||
const util_1 = require("util"); | ||
@@ -18,2 +18,10 @@ const misc_1 = require("./misc"); | ||
exports.pick = pick; | ||
function omit(source, keys) { | ||
const result = { ...source }; | ||
for (const key of keys) { | ||
Reflect.deleteProperty(result, key); | ||
} | ||
return result; | ||
} | ||
exports.omit = omit; | ||
function defineProperty(object, key, value) { | ||
@@ -20,0 +28,0 @@ Object.defineProperty(object, key, { writable: true, value }); |
{ | ||
"name": "koishi-utils", | ||
"description": "Utilities for Koishi", | ||
"version": "2.1.3", | ||
"version": "2.2.0", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "typings": "dist/index.d.ts", |
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
73658
837