Comparing version 3.3.0 to 3.3.1
174
index.d.ts
@@ -1,173 +0,1 @@ | ||
type ColorExtend = Record<string, string | { open: string, close: string }> | ||
declare const ansis: Ansis; | ||
interface Ansis { | ||
isSupported: () => boolean; | ||
(string: string): string; | ||
(string: TemplateStringsArray, ...parameters: string[]): string; | ||
ansi256: (code: number) => this; | ||
fg: (code: number) => this; | ||
bgAnsi256: (code: number) => this; | ||
bg: (code: number) => this; | ||
rgb: (red: number, green: number, blue: number) => this; | ||
hex: (color: string) => this; | ||
bgRgb: (red: number, green: number, blue: number) => this; | ||
bgHex: (color: string) => this; | ||
strip: (string: string) => string; | ||
extend: (colors: ColorExtend) => void; | ||
readonly open: string; | ||
readonly close: string; | ||
readonly reset: this; | ||
readonly inverse: this; | ||
readonly hidden: this; | ||
readonly visible: this; | ||
readonly bold: this; | ||
readonly dim: this; | ||
readonly italic: this; | ||
readonly underline: this; | ||
readonly strikethrough: this; | ||
readonly strike: this; | ||
readonly black: this; | ||
readonly red: this; | ||
readonly green: this; | ||
readonly yellow: this; | ||
readonly blue: this; | ||
readonly magenta: this; | ||
readonly cyan: this; | ||
readonly white: this; | ||
readonly grey: this; | ||
readonly gray: this; | ||
readonly blackBright: this; | ||
readonly redBright: this; | ||
readonly greenBright: this; | ||
readonly yellowBright: this; | ||
readonly blueBright: this; | ||
readonly magentaBright: this; | ||
readonly cyanBright: this; | ||
readonly whiteBright: this; | ||
readonly bgBlack: this; | ||
readonly bgRed: this; | ||
readonly bgGreen: this; | ||
readonly bgYellow: this; | ||
readonly bgBlue: this; | ||
readonly bgMagenta: this; | ||
readonly bgCyan: this; | ||
readonly bgWhite: this; | ||
readonly bgGrey: this; | ||
readonly bgGray: this; | ||
readonly bgBlackBright: this; | ||
readonly bgRedBright: this; | ||
readonly bgGreenBright: this; | ||
readonly bgYellowBright: this; | ||
readonly bgBlueBright: this; | ||
readonly bgMagentaBright: this; | ||
readonly bgCyanBright: this; | ||
readonly bgWhiteBright: this; | ||
} | ||
declare const Ansis: new () => Ansis; | ||
type AnsiStyles = ( | ||
| 'reset' | ||
| 'inverse' | ||
| 'hidden' | ||
| 'visible' | ||
| 'bold' | ||
| 'dim' | ||
| 'italic' | ||
| 'underline' | ||
| 'strikethrough' | ||
| 'strike' | ||
); | ||
type AnsiColors = ( | ||
| 'black' | ||
| 'red' | ||
| 'green' | ||
| 'yellow' | ||
| 'blue' | ||
| 'magenta' | ||
| 'cyan' | ||
| 'white' | ||
| 'grey' | ||
| 'gray' | ||
| 'blackBright' | ||
| 'redBright' | ||
| 'greenBright' | ||
| 'yellowBright' | ||
| 'blueBright' | ||
| 'magentaBright' | ||
| 'cyanBright' | ||
| 'whiteBright' | ||
| 'bgBlack' | ||
| 'bgRed' | ||
| 'bgGreen' | ||
| 'bgYellow' | ||
| 'bgBlue' | ||
| 'bgMagenta' | ||
| 'bgCyan' | ||
| 'bgWhite' | ||
| 'bgGrey' | ||
| 'bgGray' | ||
| 'bgBlackBright' | ||
| 'bgRedBright' | ||
| 'bgGreenBright' | ||
| 'bgYellowBright' | ||
| 'bgBlueBright' | ||
| 'bgMagentaBright' | ||
| 'bgCyanBright' | ||
| 'bgWhiteBright' | ||
); | ||
type StringUnion<T, B extends string> = T | (B & Record<never, never>); | ||
type AnsiColorsExtend<T extends string> = StringUnion<AnsiColors, T>; | ||
declare function ansi256(code: number): Ansis; | ||
declare function fg(code: number): Ansis; | ||
declare function bgAnsi256(code: number): Ansis; | ||
declare function bg(code: number): Ansis; | ||
declare function rgb(red: number, green: number, blue: number): Ansis; | ||
declare function bgRgb(red: number, green: number, blue: number): Ansis; | ||
declare function hex(code: string): Ansis; | ||
declare function bgHex(code: string): Ansis; | ||
declare const reset: Ansis; | ||
declare const inverse: Ansis; | ||
declare const hidden: Ansis; | ||
declare const visible: Ansis; | ||
declare const bold: Ansis; | ||
declare const dim: Ansis; | ||
declare const italic: Ansis; | ||
declare const underline: Ansis; | ||
declare const strikethrough: Ansis; | ||
declare const strike: Ansis; | ||
declare const black: Ansis; | ||
declare const red: Ansis; | ||
declare const green: Ansis; | ||
declare const yellow: Ansis; | ||
declare const blue: Ansis; | ||
declare const magenta: Ansis; | ||
declare const cyan: Ansis; | ||
declare const white: Ansis; | ||
declare const gray: Ansis; | ||
declare const grey: Ansis; | ||
declare const blackBright: Ansis; | ||
declare const redBright: Ansis; | ||
declare const greenBright: Ansis; | ||
declare const yellowBright: Ansis; | ||
declare const blueBright: Ansis; | ||
declare const magentaBright: Ansis; | ||
declare const cyanBright: Ansis; | ||
declare const whiteBright: Ansis; | ||
declare const bgBlack: Ansis; | ||
declare const bgRed: Ansis; | ||
declare const bgGreen: Ansis; | ||
declare const bgYellow: Ansis; | ||
declare const bgBlue: Ansis; | ||
declare const bgMagenta: Ansis; | ||
declare const bgCyan: Ansis; | ||
declare const bgWhite: Ansis; | ||
declare const bgBlackBright: Ansis; | ||
declare const bgRedBright: Ansis; | ||
declare const bgGreenBright: Ansis; | ||
declare const bgYellowBright: Ansis; | ||
declare const bgBlueBright: Ansis; | ||
declare const bgMagentaBright: Ansis; | ||
declare const bgCyanBright: Ansis; | ||
declare const bgWhiteBright: Ansis; | ||
export { type AnsiColors, type AnsiColorsExtend, type AnsiStyles, Ansis, ansi256, bg, bgAnsi256, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGreen, bgGreenBright, bgHex, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgRgb, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, ansis as default, dim, fg, gray, green, greenBright, grey, hex, hidden, inverse, italic, magenta, magentaBright, red, redBright, reset, rgb, strike, strikethrough, underline, visible, white, whiteBright, yellow, yellowBright }; | ||
type ColorExtend = Record<string, string | { open: string, close: string }>;declare const ansis: Ansis;interface Ansis { isSupported: () => boolean; (string: string): string; (string: TemplateStringsArray, ...parameters: string[]): string; ansi256: (code: number) => this; fg: (code: number) => this; bgAnsi256: (code: number) => this; bg: (code: number) => this; rgb: (red: number, green: number, blue: number) => this; hex: (color: string) => this; bgRgb: (red: number, green: number, blue: number) => this; bgHex: (color: string) => this; strip: (string: string) => string; extend: (colors: ColorExtend) => void; readonly open: string; readonly close: string; readonly reset: this; readonly inverse: this; readonly hidden: this; readonly visible: this; readonly bold: this; readonly dim: this; readonly italic: this; readonly underline: this; readonly strikethrough: this; readonly strike: this; readonly black: this; readonly red: this; readonly green: this; readonly yellow: this; readonly blue: this; readonly magenta: this; readonly cyan: this; readonly white: this; readonly grey: this; readonly gray: this; readonly blackBright: this; readonly redBright: this; readonly greenBright: this; readonly yellowBright: this; readonly blueBright: this; readonly magentaBright: this; readonly cyanBright: this; readonly whiteBright: this; readonly bgBlack: this; readonly bgRed: this; readonly bgGreen: this; readonly bgYellow: this; readonly bgBlue: this; readonly bgMagenta: this; readonly bgCyan: this; readonly bgWhite: this; readonly bgGrey: this; readonly bgGray: this; readonly bgBlackBright: this; readonly bgRedBright: this; readonly bgGreenBright: this; readonly bgYellowBright: this; readonly bgBlueBright: this; readonly bgMagentaBright: this; readonly bgCyanBright: this; readonly bgWhiteBright: this;}declare const Ansis: new () => Ansis;type AnsiStyles = ( | 'reset' | 'inverse' | 'hidden' | 'visible' | 'bold' | 'dim' | 'italic' | 'underline' | 'strikethrough' | 'strike' );type AnsiColors = ( | 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'grey' | 'gray' | 'blackBright' | 'redBright' | 'greenBright' | 'yellowBright' | 'blueBright' | 'magentaBright' | 'cyanBright' | 'whiteBright' | 'bgBlack' | 'bgRed' | 'bgGreen' | 'bgYellow' | 'bgBlue' | 'bgMagenta' | 'bgCyan' | 'bgWhite' | 'bgGrey' | 'bgGray' | 'bgBlackBright' | 'bgRedBright' | 'bgGreenBright' | 'bgYellowBright' | 'bgBlueBright' | 'bgMagentaBright' | 'bgCyanBright' | 'bgWhiteBright' );type StringUnion<T, B extends string> = T | (B & Record<never, never>);type AnsiColorsExtend<T extends string> = StringUnion<AnsiColors, T>;declare function ansi256(code: number): Ansis;declare function fg(code: number): Ansis;declare function bgAnsi256(code: number): Ansis;declare function bg(code: number): Ansis;declare function rgb(red: number, green: number, blue: number): Ansis;declare function bgRgb(red: number, green: number, blue: number): Ansis;declare function hex(code: string): Ansis;declare function bgHex(code: string): Ansis;declare const reset: Ansis;declare const inverse: Ansis;declare const hidden: Ansis;declare const visible: Ansis;declare const bold: Ansis;declare const dim: Ansis;declare const italic: Ansis;declare const underline: Ansis;declare const strikethrough: Ansis;declare const strike: Ansis;declare const black: Ansis;declare const red: Ansis;declare const green: Ansis;declare const yellow: Ansis;declare const blue: Ansis;declare const magenta: Ansis;declare const cyan: Ansis;declare const white: Ansis;declare const gray: Ansis;declare const grey: Ansis;declare const blackBright: Ansis;declare const redBright: Ansis;declare const greenBright: Ansis;declare const yellowBright: Ansis;declare const blueBright: Ansis;declare const magentaBright: Ansis;declare const cyanBright: Ansis;declare const whiteBright: Ansis;declare const bgBlack: Ansis;declare const bgRed: Ansis;declare const bgGreen: Ansis;declare const bgYellow: Ansis;declare const bgBlue: Ansis;declare const bgMagenta: Ansis;declare const bgCyan: Ansis;declare const bgWhite: Ansis;declare const bgBlackBright: Ansis;declare const bgRedBright: Ansis;declare const bgGreenBright: Ansis;declare const bgYellowBright: Ansis;declare const bgBlueBright: Ansis;declare const bgMagentaBright: Ansis;declare const bgCyanBright: Ansis;declare const bgWhiteBright: Ansis;export { type AnsiColors, type AnsiColorsExtend, type AnsiStyles, Ansis, ansi256, bg, bgAnsi256, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGreen, bgGreenBright, bgHex, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgRgb, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, ansis as default, dim, fg, gray, green, greenBright, grey, hex, hidden, inverse, italic, magenta, magentaBright, red, redBright, reset, rgb, strike, strikethrough, underline, visible, white, whiteBright, yellow, yellowBright }; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const{round:e,floor:t,max:n}=Math,r=(e,t,n)=>{if(""===t)return e;let r,o=t.length,i=0,s="";for(;~(r=e.indexOf(t,i));)s+=e.slice(i,r)+n,i=r+o;return i?s+e.slice(i):e},o=e=>{let[,t]=/([a-f\d]{3,6})/i.exec(e)||[],n=t?t.length:0;if(3===n)t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2];else if(6!==n)return[0,0,0];let r=parseInt(t,16);return[r>>16&255,r>>8&255,255&r]},i=(t,n,r)=>t===n&&n===r?t<8?16:t>248?231:e((t-8)/247*24)+232:16+36*e(t/51)+6*e(n/51)+e(r/51),s=r=>{let o,i,s;if(r<8)return 30+r;if(r<16)return r-8+90;if(r>=232)o=i=s=(10*(r-232)+8)/255;else{const e=(r-=16)%36;o=t(r/36)/5,i=t(e/6)/5,s=e%6/5}const l=2*n(o,i,s);if(0===l)return 30;let c=30+(e(s)<<2|e(i)<<1|e(o));return 2===l?c+60:c},l=(e,t,n)=>s(i(e,t,n)),c=(e=>{const t=e=>!!c.find((t=>e.test(t))),n=globalThis,r=n.Deno,o=null!=r,i=n.process||r||{},s=i.stdout,l="win32"===(o?r.build.os:i.platform),c=i.argv||i.args||[];let u=i.env||{},a=-1;if(o)try{u=u.toObject()}catch(e){a=0}const f="FORCE_COLOR",p=u[f],g=parseInt(p),d="false"===p?0:isNaN(g)?3:g,b="NO_COLOR"in u||0===d||t(/^-{1,2}(no-color|color=(false|never))$/),_=f in u&&d||t(/^-{1,2}color=?(true|always)?$/),O=(u.NEXT_RUNTIME||"").indexOf("edge")>-1||"PM2_HOME"in u&&"pm_id"in u||(o?r.isatty(1):s&&"isTTY"in s);return b?0:(a<0&&(a=l?3:((e,t)=>{const{TERM:n,COLORTERM:r}=e;return"TF_BUILD"in e?1:"TEAMCITY_VERSION"in e?2:"CI"in e?["GITHUB_ACTIONS","GITEA_ACTIONS"].some((t=>t in e))?3:1:!t||/-mono|dumb/i.test(n)?0:"truecolor"===r||"24bit"===r||"xterm-kitty"===n?3:/-256(colou?r)?$/i.test(n)?2:/^screen|^tmux|^xterm|^vt[1-5][0-9]([0-9])?|^ansi|color|cygwin|linux|mintty|rxvt/i.test(n)?1:3})(u,O)),_&&0===a?3:a)})(),u=c>0,a={open:"",close:""},f=u?(e,t)=>({open:`[${e}m`,close:`[${t}m`}):()=>a,p=39,g=49;let d=e=>f(`38;5;${e}`,p),b=e=>f(`48;5;${e}`,g),_=(e,t,n)=>f(`38;2;${e};${t};${n}`,p),O=(e,t,n)=>f(`48;2;${e};${t};${n}`,g);const m=e=>(t,n,r)=>e(i(t,n,r)),x=e=>t=>{let[n,r,i]=o(t);return e(n,r,i)};1===c?(d=e=>f(s(e),p),b=e=>f(s(e)+10,g),_=(e,t,n)=>f(l(e,t,n),p),O=(e,t,n)=>f(l(e,t,n)+10,g)):2===c&&(_=m(d),O=m(b));const y={visible:a,reset:f(0,0),inverse:f(7,27),hidden:f(8,28),bold:f(1,22),dim:f(2,22),italic:f(3,23),underline:f(4,24),strikethrough:f(9,29),strike:f(9,29),grey:f(90,p),gray:f(90,p),bgGrey:f(100,g),bgGray:f(100,g)};let h,T,$=["black","red","green","yellow","blue","magenta","cyan","white"],I="Bright",R=30;for(h of $)T="bg"+h[0].toUpperCase()+h.slice(1),y[h]=f(R,p),y[h+I]=f(R+60,p),y[T]=f(R+10,g),y[T+I]=f(R+70,g),R++;const v={fg:d,bg:b,rgb:_,bgRgb:O,hex:x(_),bgHex:x(O)},C=_,{defineProperty:E,defineProperties:w,setPrototypeOf:M}=Object,N=/[][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,A=/(\r?\n)/g,P={},S=({_p:e},{open:t,close:n})=>{const o=(e,...t)=>((e,t,n)=>{if(!e)return"";const{_a:o,_b:i}=n;let s=null!=e.raw?String.raw(e,...t):e+"";if(s.includes(""))for(;null!=n;)s=r(s,n.close,n.open),n=n._p;return s.includes("\n")&&(s=s.replace(A,i+"$1"+o)),o+s+i})(e,t,o._p);let i=t,s=n;return null!=e&&(i=e._a+t,s=n+e._b),M(o,G),o._p={open:t,close:n,_a:i,_b:s,_p:e},o.open=i,o.close=s,o},k=function(){const e=e=>e+"";return e.isSupported=()=>u,e.strip=e=>e.replace(N,""),e.extend=t=>{for(let e in t){let n=t[e],r=null!=n.open?n:C(...o(n));P[e]={get(){const t=S(this,r);return E(this,e,{value:t}),t}}}G=w({},P),M(e,G)},e.extend(y),e};for(let e in v)P[e]={get(){return(...t)=>S(this,v[e](...t))}};let G;P.ansi256=P.fg,P.bgAnsi256=P.bg;const L=new k;module.exports=L,module.exports.Ansis=k; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const{round:e,floor:t,max:n}=Math,r=e=>{let[,t]=/([a-f\d]{3,6})/i.exec(e)||[],n=t?t.length:0;if(3===n)t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2];else if(6!==n)return[0,0,0];let r=parseInt(t,16);return[r>>16&255,r>>8&255,255&r]},o=(t,n,r)=>t===n&&n===r?t<8?16:t>248?231:e((t-8)/247*24)+232:16+36*e(t/51)+6*e(n/51)+e(r/51),i=r=>{let o,i,l,s,c,u;return r<8?30+r:r<16?r-8+90:(r>=232?o=i=l=(10*(r-232)+8)/255:(u=(r-=16)%36,o=t(r/36)/5,i=t(u/6)/5,l=u%6/5),s=2*n(o,i,l),0===s?30:(c=30+(e(l)<<2|e(i)<<1|e(o)),2===s?c+60:c))},l=(e,t,n)=>i(o(e,t,n)),s=(e=>{const t=e=>!!c.find((t=>e.test(t))),n=globalThis,r=n.Deno,o=null!=r,i=n.process||r||{},l=i.stdout,s="win32"===(o?r.build.os:i.platform),c=i.argv||i.args||[];let u=i.env||{},a=-1;if(o)try{u=u.toObject()}catch(e){a=0}const p="FORCE_COLOR",g=u[p],f=parseInt(g),d="false"===g?0:isNaN(f)?3:f,b="NO_COLOR"in u||0===d||t(/^-{1,2}(no-color|color=(false|never))$/),_=p in u&&d||t(/^-{1,2}color=?(true|always)?$/),O=(u.NEXT_RUNTIME||"").indexOf("edge")>-1||"PM2_HOME"in u&&"pm_id"in u||(o?r.isatty(1):l&&"isTTY"in l);return b?0:(a<0&&(a=s?3:((e,t)=>{const{TERM:n,COLORTERM:r}=e;return"TF_BUILD"in e?1:"TEAMCITY_VERSION"in e?2:"CI"in e?["GITHUB_ACTIONS","GITEA_ACTIONS"].some((t=>t in e))?3:1:!t||/-mono|dumb/i.test(n)?0:"truecolor"===r||"24bit"===r||"xterm-kitty"===n?3:/-256(colou?r)?$/i.test(n)?2:/^screen|^tmux|^xterm|^vt[1-5][0-9]([0-9])?|^ansi|color|cygwin|linux|mintty|rxvt/i.test(n)?1:3})(u,O)),_&&0===a?3:a)})(),c=s>0,u={open:"",close:""},a=c?(e,t)=>({open:`[${e}m`,close:`[${t}m`}):()=>u,p=39,g=49;let f=e=>a(`38;5;${e}`,p),d=e=>a(`48;5;${e}`,g),b=(e,t,n)=>a(`38;2;${e};${t};${n}`,p),_=(e,t,n)=>a(`48;2;${e};${t};${n}`,g);const O=e=>(t,n,r)=>e(o(t,n,r)),m=e=>t=>{let[n,o,i]=r(t);return e(n,o,i)};1===s?(f=e=>a(i(e),p),d=e=>a(i(e)+10,g),b=(e,t,n)=>a(l(e,t,n),p),_=(e,t,n)=>a(l(e,t,n)+10,g)):2===s&&(b=O(f),_=O(d));const x={visible:u,reset:a(0,0),inverse:a(7,27),hidden:a(8,28),bold:a(1,22),dim:a(2,22),italic:a(3,23),underline:a(4,24),strikethrough:a(9,29),strike:a(9,29),grey:a(90,p),gray:a(90,p),bgGrey:a(100,g),bgGray:a(100,g)};let y,h,T=["black","red","green","yellow","blue","magenta","cyan","white"],$="Bright",I=30;for(y of T)h="bg"+y[0].toUpperCase()+y.slice(1),x[y]=a(I,p),x[y+$]=a(I+60,p),x[h]=a(I+10,g),x[h+$]=a(I+70,g),I++;const R={fg:f,bg:d,rgb:b,bgRgb:_,hex:m(b),bgHex:m(_)},v=b,{defineProperty:C,defineProperties:E,setPrototypeOf:w}=Object,M=/[][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,N=/(\r?\n)/g,A={},P=({_p:e},{open:t,close:n})=>{const r=(e,...t)=>{if(!e)return"";let n=r._p,{_a:o,_b:i}=n,l=null!=e.raw?String.raw(e,...t):""+e;if(l.includes(""))for(;null!=n;){let e=n.close,t=e.length;if(t){let r,o=0,i="";for(;~(r=l.indexOf(e,o));)i+=l.slice(o,r)+n.open,o=r+t;o&&(l=i+l.slice(o))}n=n._p}return l.includes("\n")&&(l=l.replace(N,i+"$1"+o)),o+l+i};let o=t,i=n;return null!=e&&(o=e._a+t,i=n+e._b),w(r,k),r._p={open:t,close:n,_a:o,_b:i,_p:e},r.open=o,r.close=i,r},S=function(){const e=e=>""+e;return e.isSupported=()=>c,e.strip=e=>e.replace(M,""),e.extend=t=>{for(let e in t){let n=t[e],o=null!=n.open?n:v(...r(n));A[e]={get(){const t=P(this,o);return C(this,e,{value:t}),t}}}k=E({},A),w(e,k)},e.extend(x),e};for(let e in R)A[e]={get(){return(...t)=>P(this,R[e](...t))}};let k;A.ansi256=A.fg,A.bgAnsi256=A.bg;const G=new S;module.exports=G,module.exports.Ansis=S; |
{ | ||
"name": "ansis", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "Colorize terminal output with ANSI colors & styles", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -23,34 +23,4 @@ <p align="center"> | ||
## Usage | ||
--- | ||
```js | ||
import ansis, { red, green, black, ansi256, hex } from 'ansis'; | ||
ansis.cyan('file') | ||
green('Ok') | ||
red`Error` | ||
black.bgYellow`Warning` | ||
ansi256(214)`Orange` | ||
hex('#E0115F').bold('TrueColor') | ||
``` | ||
## Highlights | ||
![ANSI demo](https://github.com/webdiscus/ansis/raw/master/docs/img/ansis-demo.png) | ||
- Supports ESM, CJS, TypeScript, Bun, Deno, Next.JS | ||
- Named import: `import ansis, { red, bold, hex } from 'ansis'` | ||
- Chained syntax: `red.bold.underline('text')` | ||
- Nested template strings: ``` red`RED ${green`GREEN`} RED` ``` | ||
- ANSI styles: `dim` **`bold`** _`italic`_ <u>`underline`</u> <s>`strikethrough`</s> | ||
- ANSI 16 colors: ``` red`Error!` ``` ``` redBright`Error!` ``` ``` bgRed`Error!` ``` ``` bgRedBright`Error!` ``` | ||
- ANSI 256 colors: ``` fg(56)`violet` ``` ``` bg(208)`orange` ``` | ||
- TrueColor: ``` rgb(224, 17, 95)`Ruby` ``` ``` hex('#96C')`Amethyst` ``` | ||
- Color fallback: TrueColor → 256 colors → 16 colors → no colors | ||
- Raw ANSI codes: ``` `foo ${red.open}bar{red.close} foo` ``` | ||
- Strip ANSI codes: `ansis.strip()` | ||
- Detect color support: `ansis.isSupported()` | ||
- Supports CLI: `NO_COLOR` `FORCE_COLOR` `--no-color` `--color` | ||
- Correct style break at the `end of line` when used `\n` | ||
- Doesn't extend `String.prototype` | ||
- No dependencies | ||
![ANSI demo](https://github.com/webdiscus/ansis/raw/master/docs/img/screenshot-readme-npm.png) |
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
11363
14
26
1