New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

colorikeet

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colorikeet - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

10

lib/colorikeet.js

@@ -7,2 +7,3 @@ "use strict";

exports.HSLA = hsla_1.HSLA;
const messages_1 = require("./messages");
class Colorikeet {

@@ -25,11 +26,10 @@ constructor(color) {

}
if (input.startsWith("#")) {
else if (input.startsWith("#")) {
color = rgba_1.RGBA.fromHexString(input);
}
if (input.startsWith("rgb")) {
else if (input.startsWith("rgb")) {
color = rgba_1.RGBA.fromRgbString(input);
}
// @ts-ignore
if (!color) {
color = rgba_1.RGBA.fromNameString(input);
else {
color = new Error(`${messages_1.fallThrough} ${input}`);
}

@@ -36,0 +36,0 @@ if (color instanceof Error) {

@@ -17,3 +17,3 @@ export declare const hslaCount: string;

export declare const rgbaAlpha: string;
export declare const namedNotFound: string;
export declare const hslaPattern: string;
export declare const fallThrough: string;

@@ -51,7 +51,7 @@ "use strict";

: "N";
exports.namedNotFound = process.env.NODE_ENV === "development"
? "Could not resolve as named color, received"
: "O";
exports.hslaPattern = process.env.NODE_ENV === "development"
? "Could not parse as hsla color, it must match pattern hsla?([0-255], [0-100]%, [0-100%], [0 - 1]?), received"
: "P";
exports.fallThrough = process.env.NODE_ENV === "development"
? "Could not parse as hsla, hex or rgba color, received"
: "Q";

@@ -13,5 +13,4 @@ import { HSLAColor, RGBAColor } from "./types";

static fromRgbString(input: string): RGBA | Error;
static fromNameString(input: string): RGBA | Error;
toRgb(): RGBAColor;
toHsla(): HSLAColor;
}
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const colors = __importStar(require("color-name"));
const messages_1 = require("./messages");

@@ -93,9 +85,2 @@ class RGBA {

}
static fromNameString(input) {
if (input in colors) {
const [r, g, b] = colors[input];
return new RGBA(r, g, b, 1);
}
return new Error(`${messages_1.namedNotFound} ${JSON.stringify(input)}`);
}
toRgb() {

@@ -102,0 +87,0 @@ return { r: this.r, g: this.g, b: this.b, a: this.a };

import { RGBA } from "./rgba";
import { HSLA } from "./hsla";
import { fallThrough } from "./messages";
export { RGBA, HSLA };

@@ -21,11 +22,10 @@ export class Colorikeet {

}
if (input.startsWith("#")) {
else if (input.startsWith("#")) {
color = RGBA.fromHexString(input);
}
if (input.startsWith("rgb")) {
else if (input.startsWith("rgb")) {
color = RGBA.fromRgbString(input);
}
// @ts-ignore
if (!color) {
color = RGBA.fromNameString(input);
else {
color = new Error(`${fallThrough} ${input}`);
}

@@ -32,0 +32,0 @@ if (color instanceof Error) {

@@ -17,3 +17,3 @@ export declare const hslaCount: string;

export declare const rgbaAlpha: string;
export declare const namedNotFound: string;
export declare const hslaPattern: string;
export declare const fallThrough: string;

@@ -49,7 +49,7 @@ export const hslaCount = process.env.NODE_ENV === "development"

: "N";
export const namedNotFound = process.env.NODE_ENV === "development"
? "Could not resolve as named color, received"
: "O";
export const hslaPattern = process.env.NODE_ENV === "development"
? "Could not parse as hsla color, it must match pattern hsla?([0-255], [0-100]%, [0-100%], [0 - 1]?), received"
: "P";
export const fallThrough = process.env.NODE_ENV === "development"
? "Could not parse as hsla, hex or rgba color, received"
: "Q";

@@ -13,5 +13,4 @@ import { HSLAColor, RGBAColor } from "./types";

static fromRgbString(input: string): RGBA | Error;
static fromNameString(input: string): RGBA | Error;
toRgb(): RGBAColor;
toHsla(): HSLAColor;
}

@@ -1,3 +0,2 @@

import * as colors from "color-name";
import { rgbaChannelsTuple, rgbaAlpha, hexHash, hexLength, hexPatternMatach, hexDataType, rgbaCount, rgbaPattern, rgbaLength, rgbaChannels, rgbaAlphaTuple, namedNotFound, } from "./messages";
import { rgbaChannelsTuple, rgbaAlpha, hexHash, hexLength, hexPatternMatach, hexDataType, rgbaCount, rgbaPattern, rgbaLength, rgbaChannels, rgbaAlphaTuple, } from "./messages";
export class RGBA {

@@ -84,9 +83,2 @@ constructor(r, g, b, a) {

}
static fromNameString(input) {
if (input in colors) {
const [r, g, b] = colors[input];
return new RGBA(r, g, b, 1);
}
return new Error(`${namedNotFound} ${JSON.stringify(input)}`);
}
toRgb() {

@@ -93,0 +85,0 @@ return { r: this.r, g: this.g, b: this.b, a: this.a };

{
"name": "colorikeet",
"version": "1.0.8",
"version": "1.0.9",
"description": "A minimal color math toolset",

@@ -5,0 +5,0 @@ "main": "lib/colorikeet.js",

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