koishi-utils
Advanced tools
Comparing version 3.1.3 to 3.1.4
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
export declare class Logger { | ||
private name; | ||
name: string; | ||
private showDiff; | ||
@@ -25,2 +25,3 @@ static readonly SUCCESS = 1; | ||
private displayName; | ||
stream: NodeJS.WritableStream; | ||
constructor(name: string, showDiff?: boolean); | ||
@@ -30,5 +31,5 @@ private color; | ||
get level(): number; | ||
extend: (namespace: string) => Logger; | ||
extend: (namespace: string, showDiff?: boolean) => Logger; | ||
format: (format: any, ...param: any[]) => string; | ||
} | ||
export {}; |
@@ -19,4 +19,5 @@ "use strict"; | ||
this.showDiff = showDiff; | ||
this.extend = (namespace) => { | ||
return new Logger(`${this.name}:${namespace}`); | ||
this.stream = process.stderr; | ||
this.extend = (namespace, showDiff = this.showDiff) => { | ||
return new Logger(`${this.name}:${namespace}`, showDiff); | ||
}; | ||
@@ -33,3 +34,3 @@ this.format = (...args) => { | ||
if (match === '%%') | ||
return match; | ||
return '%'; | ||
index += 1; | ||
@@ -81,3 +82,3 @@ const formatter = Logger.formatters[format]; | ||
return; | ||
process.stderr.write(prefix + this.displayName + this.format(...args) + '\n'); | ||
this.stream.write(prefix + this.displayName + this.format(...args) + '\n'); | ||
}; | ||
@@ -84,0 +85,0 @@ } |
@@ -36,3 +36,10 @@ "use strict"; | ||
Time.fromDateNumber = fromDateNumber; | ||
const timeRegExp = /^(\d+(?:\.\d+)?w(?:eek(?:s)?)?)?(\d+(?:\.\d+)?d(?:ay(?:s)?)?)?(\d+(?:\.\d+)?h(?:our(?:s)?)?)?(\d+(?:\.\d+)?m(?:in(?:ute)?(?:s)?)?)?(\d+(?:\.\d+)?s(?:ec(?:ond)?(?:s)?)?)?$/; | ||
const numeric = /\d+(?:\.\d+)?/.source; | ||
const timeRegExp = new RegExp(`^${[ | ||
'w(?:eek(?:s)?)?', | ||
'd(?:ay(?:s)?)?', | ||
'h(?:our(?:s)?)?', | ||
'm(?:in(?:ute)?(?:s)?)?', | ||
's(?:ec(?:ond)?(?:s)?)?', | ||
].map(unit => `(${numeric}${unit})?`).join('')}$`); | ||
function parseTime(source) { | ||
@@ -39,0 +46,0 @@ const capture = timeRegExp.exec(source); |
{ | ||
"name": "koishi-utils", | ||
"description": "Utilities for Koishi", | ||
"version": "3.1.3", | ||
"version": "3.1.4", | ||
"main": "dist/index.js", | ||
@@ -36,4 +36,3 @@ "typings": "dist/index.d.ts", | ||
"@types/supports-color": "^5.3.0", | ||
"mockdate": "^3.0.2", | ||
"koishi-test-utils": "^4.0.0" | ||
"koishi-test-utils": "^5.0.0" | ||
}, | ||
@@ -40,0 +39,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
77948
2
887