Comparing version 3.0.3 to 3.1.0
@@ -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,l=0,i="";for(;~(r=e.indexOf(t,l));)i+=e.slice(l,r)+n,l=r+o;return l?i+e.slice(l):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]},l=(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,l,i;if(r<8)return 30+r;if(r<16)return r-8+90;if(r>=232)o=l=i=(10*(r-232)+8)/255;else{const e=(r-=16)%36;o=t(r/36)/5,l=t(e/6)/5,i=e%6/5}const s=2*n(o,l,i);if(0===s)return 30;let c=30+(e(i)<<2|e(l)<<1|e(o));return 2===s?c+60:c},s=(e,t,n)=>i(l(e,t,n)),c=(e=>{const t=e=>!!c.find((t=>e.test(t))),n=globalThis,r=n.Deno,o=null!=r,l=n.process||r||{},i=l.stdout,s="win32"===(o?r.build.os:l.platform),c=l.argv||l.args||[];let u,a=l.env||{};if(o)try{a=a.toObject()}catch(e){u=0}const f="FORCE_COLOR",g=f in a,p=a[f],d="true"===p||parseInt(p,10)>0,b="NO_COLOR"in a||g&&!d||t(/^-{1,2}(no-color|color=(false|never))$/),_=g&&d||t(/^-{1,2}color=?(true|always)?$/),O=(a.NEXT_RUNTIME||"").indexOf("edge")>-1||(o?r.isatty(1):i&&"isTTY"in i);return b?0:(null==u&&(u=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})(a,O)),_&&0===u?3:u)})(),u={open:"",close:""},a=c>0?(e,t)=>({open:`[${e}m`,close:`[${t}m`}):()=>u,f=39,g=49;let p=e=>a(`38;5;${e}`,f),d=e=>a(`48;5;${e}`,g),b=(e,t,n)=>a(`38;2;${e};${t};${n}`,f),_=(e,t,n)=>a(`48;2;${e};${t};${n}`,g);const O=e=>(t,n,r)=>e(l(t,n,r)),x=e=>t=>{let[n,r,l]=o(t);return e(n,r,l)};1===c?(p=e=>a(i(e),f),d=e=>a(i(e)+10,g),b=(e,t,n)=>a(s(e,t,n),f),_=(e,t,n)=>a(s(e,t,n)+10,g)):2===c&&(b=O(p),_=O(d));const y={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,f),gray:a(90,f),bgGrey:a(100,g),bgGray:a(100,g)};let m,h,T=["black","red","green","yellow","blue","magenta","cyan","white"],$="Bright",I=30;for(m of T)h="bg"+m[0].toUpperCase()+m.slice(1),y[m]=a(I,f),y[m+$]=a(I+60,f),y[h]=a(I+10,g),y[h+$]=a(I+70,g),I++;const R={fg:p,bg:d,rgb:b,bgRgb:_,hex:x(b),bgHex:x(_)},v=b,{defineProperty:C,defineProperties:w,setPrototypeOf:E}=Object,A=/[][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,M=/(\r?\n)/g,N={},k=({_p:e},{open:t,close:n})=>{const o=(e,...t)=>((e,t,n)=>{if(!e)return"";const{_a:o,_b:l}=n;let i=null!=e.raw?String.raw(e,...t):e+"";if(i.includes(""))for(;null!=n;)i=r(i,n.close,n.open),n=n._p;return i.includes("\n")&&(i=i.replace(M,l+"$1"+o)),o+i+l})(e,t,o._p);let l=t,i=n;return null!=e&&(l=e._a+t,i=n+e._b),E(o,L),o._p={open:t,close:n,_a:l,_b:i,_p:e},o.open=l,o.close=i,o},G=function(){const e=e=>e+"";return e.strip=e=>e.replace(A,""),e.extend=t=>{for(let e in t){let n=t[e],r=null!=n.open?n:v(...o(n));N[e]={get(){const t=k(this,r);return C(this,e,{value:t}),t}}}L=w({},N),E(e,L)},e.extend(y),e};for(let e in R)N[e]={get(){return(...t)=>k(this,R[e](...t))}};let L;N.ansi256=N.fg,N.bgAnsi256=N.bg;const P=new G;module.exports=P,module.exports.Ansis=G; | ||
"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,l="";for(;~(r=e.indexOf(t,i));)l+=e.slice(i,r)+n,i=r+o;return i?l+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),l=r=>{let o,i,l;if(r<8)return 30+r;if(r<16)return r-8+90;if(r>=232)o=i=l=(10*(r-232)+8)/255;else{const e=(r-=16)%36;o=t(r/36)/5,i=t(e/6)/5,l=e%6/5}const s=2*n(o,i,l);if(0===s)return 30;let c=30+(e(l)<<2|e(i)<<1|e(o));return 2===s?c+60:c},s=(e,t,n)=>l(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||{},l=i.stdout,s="win32"===(o?r.build.os:i.platform),c=i.argv||i.args||[];let u,a=i.env||{};if(o)try{a=a.toObject()}catch(e){u=0}const f="FORCE_COLOR",g=f in a,p=a[f],d="true"===p||parseInt(p,10)>0,b="NO_COLOR"in a||g&&!d||t(/^-{1,2}(no-color|color=(false|never))$/),_=g&&d||t(/^-{1,2}color=?(true|always)?$/),O=(a.NEXT_RUNTIME||"").indexOf("edge")>-1||"PM2_HOME"in a&&"pm_id"in a||(o?r.isatty(1):l&&"isTTY"in l);return b?0:(null==u&&(u=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})(a,O)),_&&0===u?3:u)})(),u={open:"",close:""},a=c>0?(e,t)=>({open:`[${e}m`,close:`[${t}m`}):()=>u,f=39,g=49;let p=e=>a(`38;5;${e}`,f),d=e=>a(`48;5;${e}`,g),b=(e,t,n)=>a(`38;2;${e};${t};${n}`,f),_=(e,t,n)=>a(`48;2;${e};${t};${n}`,g);const O=e=>(t,n,r)=>e(i(t,n,r)),m=e=>t=>{let[n,r,i]=o(t);return e(n,r,i)};1===c?(p=e=>a(l(e),f),d=e=>a(l(e)+10,g),b=(e,t,n)=>a(s(e,t,n),f),_=(e,t,n)=>a(s(e,t,n)+10,g)):2===c&&(b=O(p),_=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,f),gray:a(90,f),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,f),x[y+$]=a(I+60,f),x[h]=a(I+10,g),x[h+$]=a(I+70,g),I++;const R={fg:p,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,A=/(\r?\n)/g,N={},P=({_p:e},{open:t,close:n})=>{const o=(e,...t)=>((e,t,n)=>{if(!e)return"";const{_a:o,_b:i}=n;let l=null!=e.raw?String.raw(e,...t):e+"";if(l.includes(""))for(;null!=n;)l=r(l,n.close,n.open),n=n._p;return l.includes("\n")&&(l=l.replace(A,i+"$1"+o)),o+l+i})(e,t,o._p);let i=t,l=n;return null!=e&&(i=e._a+t,l=n+e._b),w(o,G),o._p={open:t,close:n,_a:i,_b:l,_p:e},o.open=i,o.close=l,o},k=function(){const e=e=>e+"";return e.strip=e=>e.replace(M,""),e.extend=t=>{for(let e in t){let n=t[e],r=null!=n.open?n:v(...o(n));N[e]={get(){const t=P(this,r);return C(this,e,{value:t}),t}}}G=E({},N),w(e,G)},e.extend(x),e};for(let e in R)N[e]={get(){return(...t)=>P(this,R[e](...t))}};let G;N.ansi256=N.fg,N.bgAnsi256=N.bg;const L=new k;module.exports=L,module.exports.Ansis=k; |
{ | ||
"name": "ansis", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"description": "Colorize terminal with ANSI colors & styles", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -14,3 +14,3 @@ <p align="center"> | ||
The Node.js library to colorize terminal with ANSI colors & styles, **smaller** and **faster** alternative to [Chalk](https://github.com/chalk/chalk). | ||
Colorize terminal with ANSI colors & styles, **smaller** and **faster** alternative to [Chalk](https://github.com/chalk/chalk). | ||
@@ -53,4 +53,3 @@ #### Usage example | ||
- [TrueColor](https://github.com/webdiscus/ansis#truecolor) (**RGB**, **HEX**) ``` rgb(224, 17, 95)`Ruby` ```, ``` hex('#96C')`Amethyst` ``` | ||
- [Fallback](https://github.com/webdiscus/ansis#fallback) to supported color space: TrueColor —> 256 colors —> 16 colors —> no | ||
colors | ||
- [Fallback](https://github.com/webdiscus/ansis#fallback) to supported color space: TrueColor → 256 colors → 16 colors → no colors | ||
- [ANSI codes](https://github.com/webdiscus/ansis#escape-codes) as `open` and `close` properties ``` `Hello ${red.open}World${red.close}!` ``` | ||
@@ -57,0 +56,0 @@ - [Strip ANSI codes](https://github.com/webdiscus/ansis#strip) method `ansis.strip()` |
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
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
14759
63