Socket
Socket
Sign inDemoInstall

ansis

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansis - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

1

index.d.ts
type ColorExtend = Record<string, string | { open: string, close: string }>
declare const ansis: Ansis;
interface Ansis {
isSupported: () => boolean;
(string: string): string;

@@ -5,0 +6,0 @@ (string: TemplateStringsArray, ...parameters: string[]): string;

2

index.js

@@ -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,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=i.env||{},a=-1;if(o)try{u=u.toObject()}catch(e){a=0}const f="FORCE_COLOR",g=u[f],p=parseInt(g),d="false"===g?0:isNaN(p)?3:p,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):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)})(),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,N=/(\r?\n)/g,A={},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(N,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));A[e]={get(){const t=P(this,r);return C(this,e,{value:t}),t}}}G=E({},A),w(e,G)},e.extend(x),e};for(let e in R)A[e]={get(){return(...t)=>P(this,R[e](...t))}};let G;A.ansi256=A.fg,A.bgAnsi256=A.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,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;
{
"name": "ansis",
"version": "3.1.1",
"version": "3.2.0",
"description": "Colorize terminal with ANSI colors & styles",

@@ -5,0 +5,0 @@ "keywords": [

@@ -56,2 +56,3 @@ <p align="center">

- [Correct style break](https://github.com/webdiscus/ansis#new-line) at the `end of line` when used `\n` in string
- Detect [color support](https://github.com/webdiscus/ansis#color-support) using `ansis.isSupported()` method
- Supports [CLI](https://github.com/webdiscus/ansis#cli-vars) `NO_COLOR` `FORCE_COLOR` `--no-color` `--color`

@@ -58,0 +59,0 @@ - Doesn't extend `String.prototype`

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc