@handy-common-utils/misc-utils
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -11,4 +11,5 @@ /** | ||
* Encode an unsigned 32-bit integer into BASE64 string. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @returns BASE64 string representing the integer input, or the original input if it is null or undefined. | ||
@@ -19,4 +20,5 @@ */ | ||
* Encode an unsigned 32-bit integer into BASE64 string without trailing '='. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @returns BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined. | ||
@@ -27,4 +29,5 @@ */ | ||
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @param replacements A string containing replacement characters for "/", "+", and "=". | ||
@@ -37,4 +40,5 @@ * If omitted, default value of '_-=' would be used. | ||
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string without trailling '='. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @param replacements A string containing replacement characters for "/" and "+". | ||
@@ -45,2 +49,3 @@ * If omitted, default value of '_-' would be used. | ||
export declare function shortBase64UrlFromUInt32<T extends number | undefined | null>(ui32: T, replacements?: string): Exclude<T, number> | string; | ||
export * from './line-logger'; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.shortBase64UrlFromUInt32 = exports.base64UrlFromUInt32 = exports.shortBase64FromUInt32 = exports.base64FromUInt32 = exports.urlSafe = void 0; | ||
const tslib_1 = require("tslib"); | ||
/** | ||
@@ -22,4 +23,5 @@ * Make a "normal" (BASE64) string URL/path safe. | ||
* Encode an unsigned 32-bit integer into BASE64 string. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @returns BASE64 string representing the integer input, or the original input if it is null or undefined. | ||
@@ -38,4 +40,5 @@ */ | ||
* Encode an unsigned 32-bit integer into BASE64 string without trailing '='. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @returns BASE64 string without trailing '=' representing the integer input, or the original input if it is null or undefined. | ||
@@ -52,4 +55,5 @@ */ | ||
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @param replacements A string containing replacement characters for "/", "+", and "=". | ||
@@ -65,4 +69,5 @@ * If omitted, default value of '_-=' would be used. | ||
* Encode an unsigned 32-bit integer into URL/path safe BASE64 string without trailling '='. | ||
* @param ui32 A number which could also be null or undefined. | ||
* @param ui32 A 32-bit integer number which could also be null or undefined. | ||
* It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | ||
* If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | ||
* @param replacements A string containing replacement characters for "/" and "+". | ||
@@ -76,1 +81,2 @@ * If omitted, default value of '_-' would be used. | ||
exports.shortBase64UrlFromUInt32 = shortBase64UrlFromUInt32; | ||
tslib_1.__exportStar(require("./line-logger"), exports); |
{ | ||
"name": "@handy-common-utils/misc-utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Miscellaneous utilities", | ||
@@ -18,4 +18,8 @@ "scripts": { | ||
"devDependencies": { | ||
"@handy-common-utils/dev-dependencies": "^1.0.30", | ||
"@types/node": "^16.11.12" | ||
"@handy-common-utils/dev-dependencies": "^1.1.2", | ||
"@types/node": "^16.11.12", | ||
"@types/sinon": "^10.0.11", | ||
"@types/sinon-chai": "^3.2.8", | ||
"sinon": "^14.0.0", | ||
"sinon-chai": "^3.7.0" | ||
}, | ||
@@ -22,0 +26,0 @@ "publishConfig": { |
335
README.md
@@ -26,2 +26,12 @@ # @handy-common-utils/misc-utils | ||
```javascript | ||
// use chalk (chalk is not a dependency of this package, you need to add chalk as a dependency separately) | ||
import chalk from 'chalk'; | ||
import { LineLogger } from '@handy-common-utils/misc-utils'; | ||
// this.flags is an object with properties "debug" and "quiet" | ||
this.output = LineLogger.consoleWithColour(this.flags, chalk); | ||
this.output.warn('Configuration file not found, default configuration would be used.'); // it would be printed out in yellow | ||
``` | ||
# API | ||
@@ -32,20 +42,197 @@ | ||
@handy-common-utils/misc-utils | ||
## @handy-common-utils/misc-utils | ||
### Table of contents | ||
### Modules | ||
#### Functions | ||
- [index](#modulesindexmd) | ||
- [line-logger](#modulesline_loggermd) | ||
- [base64FromUInt32](#base64fromuint32) | ||
- [base64UrlFromUInt32](#base64urlfromuint32) | ||
- [shortBase64FromUInt32](#shortbase64fromuint32) | ||
- [shortBase64UrlFromUInt32](#shortbase64urlfromuint32) | ||
- [urlSafe](#urlsafe) | ||
## Classes | ||
### Functions | ||
#### base64FromUInt32 | ||
<a name="classesline_loggerlineloggermd"></a> | ||
### Class: LineLogger<DEBUG_FUNC, INFO_FUNC, WARN_FUNC, ERROR_FUNC\> | ||
[line-logger](#modulesline_loggermd).LineLogger | ||
A LineLogger logs/prints one entire line of text before advancing to another line. | ||
This class is useful for encapsulating console.log/info/warn/error functions. | ||
By having an abstraction layer, your code can switching to a different output with nearly no change. | ||
Please note that although the name contains "Logger", this class is not intended to be used as a generic logger. | ||
It is intended for "logging for humans to read" scenario. | ||
`LineLogger.console()` and `LineLogger.consoleWithColour()` are ready to use convenient functions. | ||
Or you can use the constructor to build your own wrappers. | ||
**`example`** | ||
```javascript | ||
// Just a wrapper of console.log/info/warn/error | ||
const consoleLogger = LineLogger.console(); | ||
// Wrapper of console.log/info/warn/error but it mutes console.log | ||
const lessVerboseConsoleLogger = LineLogger.console({debug: false}); | ||
// Wrapper of console.log/info/warn/error but it mutes console.log and console.info | ||
const lessVerboseConsoleLogger = LineLogger.console({quiet: true}); | ||
// use chalk (chalk is not a dependency of this package, you need to add chalk as a dependency separately) | ||
import chalk from 'chalk'; | ||
// this.flags is an object with properties "debug" and "quiet" | ||
this.output = LineLogger.consoleWithColour(this.flags, chalk); | ||
this.output.warn('Configuration file not found, default configuration would be used.'); // it would be printed out in yellow | ||
``` | ||
#### Type parameters | ||
| Name | Type | | ||
| :------ | :------ | | ||
| `DEBUG_FUNC` | extends `Function` | | ||
| `INFO_FUNC` | extends `Function` | | ||
| `WARN_FUNC` | extends `Function` | | ||
| `ERROR_FUNC` | extends `Function` | | ||
#### Constructors | ||
##### constructor | ||
• **new LineLogger**<`DEBUG_FUNC`, `INFO_FUNC`, `WARN_FUNC`, `ERROR_FUNC`\>(`debugFunction`, `infoFunction`, `warnFunction`, `errorFunction`, `isDebug?`, `isQuiet?`) | ||
Constructor | ||
###### Type parameters | ||
| Name | Type | | ||
| :------ | :------ | | ||
| `DEBUG_FUNC` | extends `Function` | | ||
| `INFO_FUNC` | extends `Function` | | ||
| `WARN_FUNC` | extends `Function` | | ||
| `ERROR_FUNC` | extends `Function` | | ||
###### Parameters | ||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `debugFunction` | `DEBUG_FUNC` | `undefined` | function for outputting debug information | | ||
| `infoFunction` | `INFO_FUNC` | `undefined` | function for outputting info information | | ||
| `warnFunction` | `WARN_FUNC` | `undefined` | function for outputting warn information | | ||
| `errorFunction` | `ERROR_FUNC` | `undefined` | function for outputting error information | | ||
| `isDebug` | `boolean` | `false` | is debug output enabled or not, it could be overriden by isQuiet | | ||
| `isQuiet` | `boolean` | `false` | is quiet mode enabled or not. When quiet mode is enabled, both debug and info output would be discarded. | | ||
#### Properties | ||
| Property | Description | | ||
| --- | --- | | ||
| • **debug**: `DEBUG_FUNC` | | | ||
| • **error**: `ERROR_FUNC` | | | ||
| • **info**: `INFO_FUNC` | | | ||
| • **isDebug**: `boolean` = `false` | | | ||
| • **isQuiet**: `boolean` = `false` | | | ||
| • **warn**: `WARN_FUNC` | | | ||
| ▪ `Static` `Protected` **NO\_OP\_FUNC**: () => `void` | **Type declaration:**<br>▸ (): `void`<br><br>**Returns:**<br>`void` | | ||
#### Methods | ||
##### console | ||
▸ `Static` **console**<`FLAGS`\>(`flags?`, `debugFlagName?`, `quietFlagName?`): [`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
Build an instance with console.log/info/warn/error. | ||
###### Type parameters | ||
| Name | Type | | ||
| :------ | :------ | | ||
| `FLAGS` | extends `Record`<`string`, `any`\> | | ||
###### Parameters | ||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `flags` | `FLAGS` | `undefined` | The flag object that contains fields for knowning whether debug is enabled and whether quiet mode is enabled. Values of those fields are evaluated only once within this function. They are not evaluated when debug/info/warn/error functions are called. | | ||
| `debugFlagName` | keyof `FLAGS` | `'debug'` | Name of the debug field in the flags object | | ||
| `quietFlagName` | keyof `FLAGS` | `'quiet'` | Name of the quiet field in the flags object | | ||
###### Returns | ||
[`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
An instance that uses console.log/info/warn/error. | ||
___ | ||
##### consoleWithColour | ||
▸ `Static` **consoleWithColour**<`FLAGS`, `COLOURER`\>(`flags`, `colourer`, `debugColourFuncName?`, `infoColourFuncName?`, `warnColourFuncName?`, `errorColourFuncName?`, `debugFlagName?`, `quietFlagName?`): [`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
Build an instance with console.log/info/warn/error and chalk/colors/cli-color. | ||
This package does not depend on chalk or colors or cli-color, | ||
you need to add them as dependencies separately. | ||
###### Type parameters | ||
| Name | Type | | ||
| :------ | :------ | | ||
| `FLAGS` | extends `Record`<`string`, `any`\> | | ||
| `COLOURER` | extends `Record`<`string`, `any`\> | | ||
###### Parameters | ||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `flags` | `FLAGS` | `undefined` | The flag object that contains fields for knowning whether debug is enabled and whether quiet mode is enabled. Values of those fields are evaluated only once within this function. They are not evaluated when debug/info/warn/error functions are called. | | ||
| `colourer` | `COLOURER` | `undefined` | Supplier of the colouring function, such as chalk or colors or cli-color | | ||
| `debugColourFuncName` | keyof `COLOURER` | `'grey'` | Name of the function within colourer that will be used to add colour to debug messages, or null if colouring is not desired. | | ||
| `infoColourFuncName?` | keyof `COLOURER` | `undefined` | Name of the function within colourer that will be used to add colour to info messages, or null if colouring is not desired. | | ||
| `warnColourFuncName` | keyof `COLOURER` | `'yellow'` | Name of the function within colourer that will be used to add colour to warn messages, or null if colouring is not desired. | | ||
| `errorColourFuncName` | keyof `COLOURER` | `'red'` | Name of the function within colourer that will be used to add colour to error messages, or null if colouring is not desired. | | ||
| `debugFlagName` | keyof `FLAGS` | `'debug'` | Name of the debug field in the flags object | | ||
| `quietFlagName` | keyof `FLAGS` | `'quiet'` | Name of the quiet field in the flags object | | ||
###### Returns | ||
[`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
An instance that uses console.log/info/warn/error and also adds colour to the messages using chalk/colors/cli-color. | ||
## Modules | ||
<a name="modulesindexmd"></a> | ||
### Module: index | ||
#### References | ||
##### ConsoleLineLogger | ||
Re-exports [ConsoleLineLogger](#consolelinelogger) | ||
___ | ||
##### LineLogger | ||
Re-exports [LineLogger](#classesline_loggerlineloggermd) | ||
___ | ||
##### consoleWithColour | ||
Re-exports [consoleWithColour](#consolewithcolour) | ||
___ | ||
##### consoleWithoutColour | ||
Re-exports [consoleWithoutColour](#consolewithoutcolour) | ||
#### Functions | ||
##### base64FromUInt32 | ||
▸ **base64FromUInt32**<`T`\>(`ui32`): `Exclude`<`T`, `number`\> \| `string` | ||
@@ -55,3 +242,3 @@ | ||
##### Type parameters | ||
###### Type parameters | ||
@@ -62,9 +249,9 @@ | Name | Type | | ||
##### Parameters | ||
###### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `ui32` | `T` | A number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | | ||
| `ui32` | `T` | A 32-bit integer number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | | ||
##### Returns | ||
###### Returns | ||
@@ -77,3 +264,3 @@ `Exclude`<`T`, `number`\> \| `string` | ||
#### base64UrlFromUInt32 | ||
##### base64UrlFromUInt32 | ||
@@ -84,3 +271,3 @@ ▸ **base64UrlFromUInt32**<`T`\>(`ui32`, `replacements?`): `Exclude`<`T`, `number`\> \| `string` | ||
##### Type parameters | ||
###### Type parameters | ||
@@ -91,10 +278,10 @@ | Name | Type | | ||
##### Parameters | ||
###### Parameters | ||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `ui32` | `T` | `undefined` | A number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | | ||
| `ui32` | `T` | `undefined` | A 32-bit integer number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | | ||
| `replacements` | `string` | `'_-='` | A string containing replacement characters for "/", "+", and "=". If omitted, default value of '_-=' would be used. | | ||
##### Returns | ||
###### Returns | ||
@@ -107,3 +294,3 @@ `Exclude`<`T`, `number`\> \| `string` | ||
#### shortBase64FromUInt32 | ||
##### shortBase64FromUInt32 | ||
@@ -114,3 +301,3 @@ ▸ **shortBase64FromUInt32**<`T`\>(`ui32`): `Exclude`<`T`, `number`\> \| `string` | ||
##### Type parameters | ||
###### Type parameters | ||
@@ -121,9 +308,9 @@ | Name | Type | | ||
##### Parameters | ||
###### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `ui32` | `T` | A number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | | ||
| `ui32` | `T` | A 32-bit integer number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | | ||
##### Returns | ||
###### Returns | ||
@@ -136,3 +323,3 @@ `Exclude`<`T`, `number`\> \| `string` | ||
#### shortBase64UrlFromUInt32 | ||
##### shortBase64UrlFromUInt32 | ||
@@ -143,3 +330,3 @@ ▸ **shortBase64UrlFromUInt32**<`T`\>(`ui32`, `replacements?`): `Exclude`<`T`, `number`\> \| `string` | ||
##### Type parameters | ||
###### Type parameters | ||
@@ -150,10 +337,10 @@ | Name | Type | | ||
##### Parameters | ||
###### Parameters | ||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `ui32` | `T` | `undefined` | A number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. | | ||
| `ui32` | `T` | `undefined` | A 32-bit integer number which could also be null or undefined. It must be a valid unsigned 32-bit integer. Behavior is undefined when valueis anything other than an unsigned 32-bit integer. If you don't care about loosing precision, you can convert a number by doing `n >>> 0` (See https://stackoverflow.com/questions/22335853/hack-to-convert-javascript-number-to-uint32) | | ||
| `replacements` | `string` | `'_-'` | A string containing replacement characters for "/" and "+". If omitted, default value of '_-' would be used. | | ||
##### Returns | ||
###### Returns | ||
@@ -166,3 +353,3 @@ `Exclude`<`T`, `number`\> \| `string` | ||
#### urlSafe | ||
##### urlSafe | ||
@@ -173,3 +360,3 @@ ▸ **urlSafe**<`T`\>(`base64Input`, `replacements?`): `T` | ||
##### Type parameters | ||
###### Type parameters | ||
@@ -180,3 +367,3 @@ | Name | Type | | ||
##### Parameters | ||
###### Parameters | ||
@@ -188,3 +375,3 @@ | Name | Type | Default value | Description | | ||
##### Returns | ||
###### Returns | ||
@@ -194,2 +381,82 @@ `T` | ||
URL/path safe version of the (BASE64) input string, or the original input if it is null or undefined. | ||
<a name="modulesline_loggermd"></a> | ||
### Module: line-logger | ||
#### Classes | ||
- [LineLogger](#classesline_loggerlineloggermd) | ||
#### Type aliases | ||
##### ConsoleLineLogger | ||
Ƭ **ConsoleLineLogger**: `ReturnType`<typeof [`console`](#console)\> | ||
Type of the object returned by `LineLogger.console()` or `LineLogger.consoleWithColour()`. | ||
It has the same function signatures as console.log/info/warn/error. | ||
#### Functions | ||
##### consoleWithColour | ||
▸ **consoleWithColour**<`FLAGS`, `COLOURER`\>(`flags`, `colourer`, `debugColourFuncName?`, `infoColourFuncName?`, `warnColourFuncName?`, `errorColourFuncName?`, `debugFlagName?`, `quietFlagName?`): [`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
Build an encapsulation of console output functions with console.log/info/warn/error and chalk/colors/cli-color. | ||
###### Type parameters | ||
| Name | Type | | ||
| :------ | :------ | | ||
| `FLAGS` | extends `Record`<`string`, `any`\> | | ||
| `COLOURER` | extends `Record`<`string`, `any`\> | | ||
###### Parameters | ||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `flags` | `FLAGS` | `undefined` | The flag object that contains fields for knowning whether debug is enabled and whether quiet mode is enabled. Values of those fields are evaluated only once within this function. They are not evaluated when debug/info/warn/error functions are called. | | ||
| `colourer` | `COLOURER` | `undefined` | Supplier of the colouring function, such as chalk or colors or cli-color | | ||
| `debugColourFuncName` | keyof `COLOURER` | `'grey'` | Name of the function within colourer that will be used to add colour to debug messages, or null if colouring is not desired. | | ||
| `infoColourFuncName?` | keyof `COLOURER` | `undefined` | Name of the function within colourer that will be used to add colour to info messages, or null if colouring is not desired. | | ||
| `warnColourFuncName` | keyof `COLOURER` | `'yellow'` | Name of the function within colourer that will be used to add colour to warn messages, or null if colouring is not desired. | | ||
| `errorColourFuncName` | keyof `COLOURER` | `'red'` | Name of the function within colourer that will be used to add colour to error messages, or null if colouring is not desired. | | ||
| `debugFlagName` | keyof `FLAGS` | `'debug'` | Name of the debug field in the flags object | | ||
| `quietFlagName` | keyof `FLAGS` | `'quiet'` | Name of the quiet field in the flags object. Quiet flag can override debug flag. | | ||
###### Returns | ||
[`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
An LineLogger instance that uses console.log/info/warn/error and also adds colour to the messages using chalk/colors/cli-color. | ||
___ | ||
##### consoleWithoutColour | ||
▸ **consoleWithoutColour**<`FLAGS`\>(`flags?`, `debugFlagName?`, `quietFlagName?`): [`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
Build an encapsulation of console output functions with console.log/info/warn/error. | ||
###### Type parameters | ||
| Name | Type | | ||
| :------ | :------ | | ||
| `FLAGS` | extends `Record`<`string`, `any`\> | | ||
###### Parameters | ||
| Name | Type | Default value | Description | | ||
| :------ | :------ | :------ | :------ | | ||
| `flags` | `FLAGS` | `undefined` | The flag object that contains fields for knowning whether debug is enabled and whether quiet mode is enabled. Values of those fields are evaluated only once within this function. They are not evaluated when debug/info/warn/error functions are called. | | ||
| `debugFlagName` | keyof `FLAGS` | `'debug'` | Name of the debug field in the flags object | | ||
| `quietFlagName` | keyof `FLAGS` | `'quiet'` | Name of the quiet field in the flags object. Quiet flag can override debug flag. | | ||
###### Returns | ||
[`LineLogger`](#classesline_loggerlineloggermd)<(`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`, (`message?`: `any`, ...`optionalParams`: `any`[]) => `void`\> | ||
An LineLogger instance that uses console.log/info/warn/error. | ||
<!-- API end --> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59291
9
370
445
6
1