ansi-construct
Advanced tools
Comparing version
@@ -36,16 +36,2 @@ export { default as colors } from 'picocolors'; | ||
declare type AnsiLines = AnsiItems[]; | ||
interface ConstructOptions { | ||
/** | ||
* Enable colors or not. | ||
* | ||
* @default auto | ||
*/ | ||
colors?: boolean; | ||
/** | ||
* Padding between each item | ||
* | ||
* @default '' | ||
*/ | ||
padding?: string; | ||
} | ||
declare type BuiltinColors = 'reset' | 'bold' | 'dim' | 'italic' | 'underline' | 'inverse' | 'hidden' | 'strikethrough' | 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | 'bgBlack' | 'bgRed' | 'bgGreen' | 'bgYellow' | 'bgBlue' | 'bgMagenta' | 'bgCyan' | 'bgWhite'; | ||
@@ -56,6 +42,7 @@ | ||
declare function c(...items: AnsiItem[]): string; | ||
declare function construct(items: AnsiItem[], options?: ConstructOptions): string; | ||
declare function constructLines(items: AnsiLines, options?: ConstructOptions): string; | ||
declare function normalizeItem(item: AnsiItem, toString?: boolean): AnsiObject; | ||
declare function ansi(text: string, ...colors: BuiltinColors[]): AnsiObject; | ||
declare function ansi(item: AnsiItem): AnsiObject; | ||
declare function construct(items: AnsiItem[]): string; | ||
export { AnsiArray, AnsiItem, AnsiItems, AnsiLines, AnsiObject, AnsiObjectShorthand, BuiltinColors, ConstructOptions, c, construct, constructLines, newline, space }; | ||
export { AnsiArray, AnsiItem, AnsiItems, AnsiLines, AnsiObject, AnsiObjectShorthand, BuiltinColors, ansi, construct, newline, normalizeItem, space }; |
{ | ||
"name": "ansi-construct", | ||
"type": "module", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"packageManager": "pnpm@7.2.1", | ||
@@ -56,9 +56,9 @@ "description": "", | ||
"@antfu/utils": "^0.5.2", | ||
"@types/node": "^17.0.44", | ||
"bumpp": "^8.0.0", | ||
"eslint": "^8.17.0", | ||
"@types/node": "^18.0.0", | ||
"bumpp": "^8.2.1", | ||
"eslint": "^8.18.0", | ||
"esno": "^0.16.3", | ||
"pnpm": "^7.2.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.7.3", | ||
"typescript": "^4.7.4", | ||
"unbuild": "^0.7.4", | ||
@@ -65,0 +65,0 @@ "vite": "^2.9.12", |
@@ -10,2 +10,27 @@ # ansi-construct | ||
```ts | ||
import { ansi } from 'ansi-construct' | ||
const item = ansi({ text: 'foo', color: ['red', 'bold'], padStart: 5 }) | ||
// change it after creation | ||
item.padStart = 6 | ||
// stringify | ||
console.log(`${item}`) // ' foo' | ||
``` | ||
```ts | ||
import { ansi } from 'ansi-construct' | ||
const items = [ | ||
ansi({ text: 'foo', color: ['red', 'bold'], padStart: 5 }), | ||
ansi({ text: 'bar', color: 'underline' }), | ||
ansi('baz', 'blue'), | ||
] | ||
// stringify | ||
console.log(items.join('')) // ' foo\n\u001b[4mbar\u001b[0mbaz\u001b[0m' | ||
``` | ||
```ts | ||
import type { AnsiItem } from 'ansi-construct' | ||
@@ -12,0 +37,0 @@ import { construct } from 'ansi-construct' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10103
14.43%190
9.83%59
73.53%