Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

colors-option

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colors-option - npm Package Compare versions

Comparing version 4.3.1 to 4.4.0

14

build/src/main.js

@@ -16,3 +16,2 @@ import{Chalk}from"chalk";

const{colors,stream,chalkOpts}=getOpts(opts);
const level=getLevel(colors,stream);

@@ -29,16 +28,7 @@ const chalk=new Chalk({...chalkOpts,level});

const terminalLevel=getTerminalLevel(stream);
if(colors===undefined){
return terminalLevel;
}
return Math.max(terminalLevel,1);
return colors===undefined?terminalLevel:Math.max(terminalLevel,1);
};
const getTerminalLevel=function(stream){
if(!stream.isTTY){
return 0;
}
return DEPTH_TO_LEVEL[stream.getColorDepth()];
return stream.isTTY?DEPTH_TO_LEVEL[stream.getColorDepth()]:0;
};

@@ -45,0 +35,0 @@

42

build/src/options.js
import{stdout}from"process";
import{Stream}from"stream";
import{excludeKeys}from"filter-obj";
import isPlainObj from"is-plain-obj";
import{validate}from"jest-validate";
export const getOpts=function(opts={}){
validateOpts(opts);
const optsA=excludeKeys(opts,isUndefined);
const{
colors:colorsA,
stream,
...chalkOpts}=
{
...DEFAULT_OPTS,
...optsA};
return{colors:colorsA,stream,chalkOpts};
};
const validateOpts=function(opts){
validateBasicOpts(opts);
validate(opts,{exampleConfig:EXAMPLE_OPTS,recursiveDenylist:["stream"]});
validateStream(opts);
const{colors,stream=stdout,...chalkOpts}=opts;
validateColors(colors);
validateStream(stream);
return{colors,stream,chalkOpts};
};

@@ -35,19 +21,13 @@

const validateStream=function({stream}){
if(stream!==undefined&&!(stream instanceof Stream)){
throw new TypeError(`"stream" option must be a stream: ${stream}`);
const validateColors=function(colors){
if(colors!==undefined&&typeof colors!=="boolean"){
throw new TypeError(`"colors" option must be a boolean: ${colors}`);
}
};
const isUndefined=function(key,value){
return value===undefined;
const validateStream=function(stream){
if(!(stream instanceof Stream)){
throw new TypeError(`"stream" option must be a stream: ${stream}`);
}
};
const DEFAULT_OPTS={
stream:stdout};
const EXAMPLE_OPTS={
...DEFAULT_OPTS,
colors:true};
//# sourceMappingURL=options.js.map
{
"name": "colors-option",
"version": "4.3.1",
"version": "4.4.0",
"type": "module",

@@ -50,5 +50,3 @@ "exports": "./build/src/main.js",

"chalk": "^5.0.1",
"filter-obj": "^5.1.0",
"is-plain-obj": "^4.1.0",
"jest-validate": "^29.0.1"
"is-plain-obj": "^4.1.0"
},

@@ -55,0 +53,0 @@ "devDependencies": {

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