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

colortranslator

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colortranslator - npm Package Compare versions

Comparing version 1.3.2 to 1.3.3

5

CHANGELOG.md
# Changelog
## [1.3.2] - 2020-05-16
- Fix type definitions bugs
- Increase coverage with more tests
## [1.3.1] - 2020-03-09

@@ -4,0 +9,0 @@

45

dist/@types/index.d.ts
export declare type NumberOrString = number | string;
export interface HEXObject {
r: string;
g: string;
b: string;
a?: string;
}
export interface RGBObject {
r: number;
g: number;
b: number;
a?: number;
}
export interface RGBObjectGeneric {
r: NumberOrString;

@@ -8,9 +20,9 @@ g: NumberOrString;

}
export interface RGBObjectFinal {
r: number;
g: number;
b: number;
export interface HSLObject {
h: number;
s: number;
l: number;
a?: number;
}
export interface HSLObject {
export interface HSLObjectGeneric {
h: number;

@@ -21,9 +33,9 @@ s: NumberOrString;

}
export interface HSLObjectFinal {
h: number;
s: number;
l: number;
a?: number;
export interface CMYKObject {
c: number;
m: number;
y: number;
k: number;
}
export interface CMYKObject {
export interface CMYKObjectGeneric {
c: NumberOrString;

@@ -34,14 +46,9 @@ m: NumberOrString;

}
export interface CMYKObjectFinal {
c: number;
m: number;
y: number;
k: number;
}
export declare type Color = RGBObject | HSLObject | CMYKObject;
export declare type Color = RGBObjectGeneric | HSLObjectGeneric | CMYKObjectGeneric;
export declare type ColorInput = string | Color;
export declare type HEXOutput = string | HEXObject;
export declare type RGBOutput = string | RGBObject;
export declare type HSLOutput = string | HSLObject;
export declare type CMYKOutput = string | CMYKObject;
export declare type ColorOutput = RGBOutput | HSLOutput | CMYKOutput;
export declare type ColorOutput = RGBOutput | HSLOutput;
export declare type Omit<T, K> = Exclude<T, K>;

@@ -48,0 +55,0 @@ export interface ObjectProps<T> {

import { ColorModel } from '../constants';
import { RGBObject, HSLObject, CMYKObject } from '../@types';
import { HEXObject, RGBObject, HSLObject, CMYKObject } from '../@types';
export declare const CSS: {
HEX: (color: RGBObject) => string;
HEX: (color: RGBObject | HEXObject) => string;
RGB: (color: RGBObject) => string;

@@ -6,0 +6,0 @@ HSL: (color: HSLObject) => string;

@@ -1,6 +0,6 @@

import { RGBObjectFinal, HSLObjectFinal, CMYKObjectFinal } from '../@types';
import { RGBObject, HSLObject, CMYKObject } from '../@types';
export declare const hueToRGB: (t1: number, t2: number, hue: number) => number;
export declare const hslToRGB: (h: number, s: number, l: number) => RGBObjectFinal;
export declare const cmykToRGB: (c: number, m: number, y: number, k: number) => RGBObjectFinal;
export declare const rgbToCMYK: (r: number, g: number, b: number) => CMYKObjectFinal;
export declare const rgbToHSL: (r: number, g: number, b: number, a?: number) => HSLObjectFinal;
export declare const hslToRGB: (h: number, s: number, l: number) => RGBObject;
export declare const cmykToRGB: (c: number, m: number, y: number, k: number) => RGBObject;
export declare const rgbToCMYK: (r: number, g: number, b: number) => CMYKObject;
export declare const rgbToHSL: (r: number, g: number, b: number, a?: number) => HSLObject;

@@ -1,48 +0,48 @@

import { ColorInput, RGBObject, HSLObject, HSLObjectFinal, CMYKObject, RGBObjectFinal, RGBOutput, HSLOutput } from '../@types';
import { ColorInput, RGBObjectGeneric, HSLObjectGeneric, CMYKObjectGeneric, CMYKObject, HSLObject, RGBObject, HEXObject, RGBOutput, HSLOutput, HEXOutput } from '../@types';
import { ColorModel } from '../constants';
declare type HarmonyFunction = (color: HSLObjectFinal) => HSLObjectFinal[];
declare type HarmonyFunction = (color: HSLObject) => HSLObject[];
export declare const normalizeHue: (hue: number) => number;
export declare const normalizeAlpha: (alpha: number) => number;
export declare const analogous: (color: HSLObjectFinal) => HSLObjectFinal[];
export declare const complementary: (color: HSLObjectFinal) => HSLObjectFinal[];
export declare const splitComplementary: (color: HSLObjectFinal) => HSLObjectFinal[];
export declare const triadic: (color: HSLObjectFinal) => HSLObjectFinal[];
export declare const tetradic: (color: HSLObjectFinal) => HSLObjectFinal[];
export declare const square: (color: HSLObjectFinal) => HSLObjectFinal[];
export declare const analogous: (color: HSLObject) => HSLObject[];
export declare const complementary: (color: HSLObject) => HSLObject[];
export declare const splitComplementary: (color: HSLObject) => HSLObject[];
export declare const triadic: (color: HSLObject) => HSLObject[];
export declare const tetradic: (color: HSLObject) => HSLObject[];
export declare const square: (color: HSLObject) => HSLObject[];
export declare const getColorModel: (color: ColorInput) => ColorModel;
export declare const getRGBObjectFromString: {
HEX(color: string): RGBObjectFinal;
RGB(color: string): RGBObjectFinal;
RGBA(color: string): RGBObjectFinal;
HSL(color: string): RGBObjectFinal;
HSLA(color: string): RGBObjectFinal;
CMYK(color: string): RGBObjectFinal;
HEX(color: string): RGBObject;
RGB(color: string): RGBObject;
RGBA(color: string): RGBObject;
HSL(color: string): RGBObject;
HSLA(color: string): RGBObject;
CMYK(color: string): RGBObject;
};
export declare const getRGBObjectFromObject: {
RGB(color: RGBObject): RGBObjectFinal;
RGBA(color: RGBObject): RGBObjectFinal;
HSL(color: HSLObject): RGBObjectFinal;
HSLA(color: HSLObject): RGBObjectFinal;
CMYK(color: CMYKObject): RGBObjectFinal;
RGB(color: RGBObjectGeneric): RGBObject;
RGBA(color: RGBObjectGeneric): RGBObject;
HSL(color: HSLObjectGeneric): RGBObject;
HSLA(color: HSLObjectGeneric): RGBObject;
CMYK(color: CMYKObjectGeneric): RGBObject;
};
export declare const getRGBObject: (color: ColorInput, model?: ColorModel) => RGBObjectFinal;
export declare const getRGBObject: (color: ColorInput, model?: ColorModel) => RGBObject;
export declare const translateColor: {
HEX(color: RGBObjectFinal): RGBObject;
HEXA(color: RGBObjectFinal): RGBObject;
RGB(color: RGBObjectFinal): RGBObject;
RGBA(color: RGBObjectFinal): RGBObject;
HSL(color: RGBObjectFinal): HSLObject;
HSLA(color: RGBObjectFinal): HSLObject;
CMYK(color: RGBObjectFinal): CMYKObject;
HEX(color: RGBObject): HEXObject;
HEXA(color: RGBObject): HEXObject;
RGB(color: RGBObject): RGBObject;
RGBA(color: RGBObject): RGBObject;
HSL(color: RGBObject): HSLObject;
HSLA(color: RGBObject): HSLObject;
CMYK(color: RGBObject): CMYKObject;
};
export declare const blend: (from: RGBObjectFinal, to: RGBObjectFinal, steps: number) => RGBObjectFinal[];
export declare const blend: (from: RGBObject, to: RGBObject, steps: number) => RGBObject[];
export declare const colorHarmony: {
buildHarmony(color: ColorInput, harmonyFunction: HarmonyFunction): string[];
HEX(color: HSLObjectFinal, harmonyFunction: HarmonyFunction, css: boolean): RGBOutput[];
HEXA(color: HSLObjectFinal, harmonyFunction: HarmonyFunction, css: boolean): RGBOutput[];
RGB(color: HSLObjectFinal, harmonyFunction: HarmonyFunction, css: boolean): RGBOutput[];
RGBA(color: HSLObjectFinal, harmonyFunction: HarmonyFunction, css: boolean): RGBOutput[];
HSL(color: HSLObjectFinal, harmonyFunction: HarmonyFunction, css: boolean): HSLOutput[];
HSLA(color: HSLObjectFinal, harmonyFunction: HarmonyFunction, css: boolean): HSLOutput[];
HEX(color: HSLObject, harmonyFunction: HarmonyFunction, css: boolean): HEXOutput[];
HEXA(color: HSLObject, harmonyFunction: HarmonyFunction, css: boolean): HEXOutput[];
RGB(color: HSLObject, harmonyFunction: HarmonyFunction, css: boolean): RGBOutput[];
RGBA(color: HSLObject, harmonyFunction: HarmonyFunction, css: boolean): RGBOutput[];
HSL(color: HSLObject, harmonyFunction: HarmonyFunction, css: boolean): HSLOutput[];
HSLA(color: HSLObject, harmonyFunction: HarmonyFunction, css: boolean): HSLOutput[];
};
export {};

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

import { ColorInput, RGBObject, HSLObject, CMYKObject, RGBOutput, HSLOutput, CMYKOutput, ColorOutput } from './@types';
import { ColorInput, HEXObject, RGBObject, HSLObject, CMYKObject } from './@types';
import { Harmony } from './constants';

@@ -37,4 +37,4 @@ export declare class ColorTranslator {

get K(): number;
get HEXObject(): RGBObject;
get HEXAObject(): RGBObject;
get HEXObject(): HEXObject;
get HEXAObject(): HEXObject;
get RGBObject(): RGBObject;

@@ -52,17 +52,44 @@ get RGBAObject(): RGBObject;

get CMYK(): string;
static toHEX(color: ColorInput, css?: boolean): RGBOutput;
static toHEXA(color: ColorInput, css?: boolean): RGBOutput;
static toRGB(color: ColorInput, css?: boolean): RGBOutput;
static toRGBA(color: ColorInput, css?: boolean): RGBOutput;
static toHSL(color: ColorInput, css?: boolean): HSLOutput;
static toHSLA(color: ColorInput, css?: boolean): HSLOutput;
static toCMYK(color: ColorInput, css?: boolean): CMYKOutput;
static getBlendHEX(from: ColorInput, to: ColorInput, steps?: number, css?: boolean): RGBOutput[];
static getBlendHEXA(from: ColorInput, to: ColorInput, steps?: number, css?: boolean): RGBOutput[];
static getBlendRGB(from: ColorInput, to: ColorInput, steps?: number, css?: boolean): RGBOutput[];
static getBlendRGBA(from: ColorInput, to: ColorInput, steps?: number, css?: boolean): RGBOutput[];
static getBlendHSL(from: ColorInput, to: ColorInput, steps?: number, css?: boolean): HSLOutput[];
static getBlendHSLA(from: ColorInput, to: ColorInput, steps?: number, css?: boolean): HSLOutput[];
static getHarmony(color: ColorInput, armony?: Harmony): ColorOutput[];
static toHEX(color: ColorInput): string;
static toHEX(color: ColorInput, css: true): string;
static toHEX(color: ColorInput, css: false): HEXObject;
static toHEXA(color: ColorInput): string;
static toHEXA(color: ColorInput, css: true): string;
static toHEXA(color: ColorInput, css: false): HEXObject;
static toRGB(color: ColorInput): string;
static toRGB(color: ColorInput, css: true): string;
static toRGB(color: ColorInput, css: false): RGBObject;
static toRGBA(color: ColorInput): string;
static toRGBA(color: ColorInput, css: true): string;
static toRGBA(color: ColorInput, css: false): RGBObject;
static toHSL(color: ColorInput): string;
static toHSL(color: ColorInput, css: true): string;
static toHSL(color: ColorInput, css: false): HSLObject;
static toHSLA(color: ColorInput): string;
static toHSLA(color: ColorInput, css: true): string;
static toHSLA(color: ColorInput, css: false): HSLObject;
static toCMYK(color: ColorInput): string;
static toCMYK(color: ColorInput, css: true): string;
static toCMYK(color: ColorInput, css: false): CMYKObject;
static getBlendHEX(from: ColorInput, to: ColorInput, steps?: number): string[];
static getBlendHEX(from: ColorInput, to: ColorInput, steps: number, css: true): string[];
static getBlendHEX(from: ColorInput, to: ColorInput, steps: number, css: false): HEXObject[];
static getBlendHEXA(from: ColorInput, to: ColorInput, steps?: number): string[];
static getBlendHEXA(from: ColorInput, to: ColorInput, steps: number, css: true): string[];
static getBlendHEXA(from: ColorInput, to: ColorInput, steps: number, css: false): HEXObject[];
static getBlendRGB(from: ColorInput, to: ColorInput, steps?: number): string[];
static getBlendRGB(from: ColorInput, to: ColorInput, steps: number, css: true): string[];
static getBlendRGB(from: ColorInput, to: ColorInput, steps: number, css: false): RGBObject[];
static getBlendRGBA(from: ColorInput, to: ColorInput, steps: number): string[];
static getBlendRGBA(from: ColorInput, to: ColorInput, steps: number, css: true): string[];
static getBlendRGBA(from: ColorInput, to: ColorInput, steps: number, css: false): RGBObject[];
static getBlendHSL(from: ColorInput, to: ColorInput, steps?: number): string[];
static getBlendHSL(from: ColorInput, to: ColorInput, steps: number, css: true): string[];
static getBlendHSL(from: ColorInput, to: ColorInput, steps: number, css: false): HSLObject[];
static getBlendHSLA(from: ColorInput, to: ColorInput, steps?: number): string[];
static getBlendHSLA(from: ColorInput, to: ColorInput, steps: number, css: true): string[];
static getBlendHSLA(from: ColorInput, to: ColorInput, steps: number, css: false): HSLObject[];
static getHarmony(color: string, armony?: Harmony): string[];
static getHarmony<T>(color: string, armony?: Harmony): T[];
}
export { Harmony };
export { Harmony, HEXObject, RGBObject, HSLObject, CMYKObject };
{
"name": "colortranslator",
"version": "1.3.2",
"version": "1.3.3",
"description": "A JavaScript library, written in TypeScript, to convert among different color models",

@@ -49,29 +49,27 @@ "main": "dist/index.js",

"@types/jest": "^25.2.1",
"@types/node": "^13.11.0",
"@typescript-eslint/eslint-plugin": "^2.27.0",
"@typescript-eslint/parser": "^2.27.0",
"@types/node": "^13.13.5",
"@typescript-eslint/eslint-plugin": "^2.32.0",
"@typescript-eslint/parser": "^2.32.0",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.1.1",
"coveralls": "^3.0.11",
"css-loader": "^3.5.0",
"eslint": "^6.8.0",
"eslint-utils": "^2.0.0",
"coveralls": "^3.1.0",
"css-loader": "^3.5.3",
"eslint": "^7.0.0",
"google-code-prettify": "^1.0.5",
"html-webpack-plugin": "^4.0.4",
"html-webpack-plugin": "^4.3.0",
"jest": "^25.2.7",
"mini-css-extract-plugin": "^0.9.0",
"node-sass": "^4.13.1",
"node-sass": "^4.14.1",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.3",
"terser-webpack-plugin": "^2.3.5",
"ts-jest": "^25.3.1",
"ts-loader": "^6.2.2",
"tsconfig-paths": "^3.9.0",
"style-loader": "^1.2.1",
"terser-webpack-plugin": "^3.0.1",
"ts-jest": "^25.5.1",
"ts-loader": "^7.0.4",
"tscpaths": "^0.0.9",
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
"webpack-dev-server": "^3.11.0"
}
}

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

```
```javascript
npm install colortranslator

@@ -26,3 +26,3 @@ ```

```
```javascript
yarn add colortranslator

@@ -401,2 +401,61 @@ ```

You can also consult the [demo 6](https://elchininet.github.io/ColorTranslator/#demo6) to check the use of these static methods.
You can also consult the [demo 6](https://elchininet.github.io/ColorTranslator/#demo6) to check the use of these static methods.
## TypeScript Support
The package has its own type definitions, so it can be used in a `TypeScript` project without any issues. The next interfaces are exposed and can be imported in your project:
###### HEXObject
This type is returned by the `HEXObject`, and `HEXAObject` properties, the `toHEX`, `toHEXA`, `getBlendHEX`, and `getBlendHEXA` methods (when the `css` property is `false`), and the `getHarmony` method (when this type is send as a [Generic][1]).
```typescript
interface HEXObject {
r: string;
g: string;
b: string;
a?: string;
}
```
###### RGBObject
This type is returned by the `RGBObject`, and `RGBAObject` properties, the `toRGB`, `toRGBA`, `getBlendRGB`, and `getBlendRGBA` methods (when the `css` property is `false`), and the `getHarmony` method (when this type is send as a [Generic][1]).
```typescript
interface RGBObject {
r: number;
g: number;
b: number;
a?: number;
}
```
###### HSLObject
This type is returned by the `HSLObject`, and `HSLAObject` properties, the `toHSL`, `toHSLA`, `getBlendHSL`, and `getBlendHSLA` methods (when the `css` property is `false`), and the `getHarmony` method (when this type is send as a [Generic][1]).
```typescript
interface HSLObject {
h: number;
s: number;
l: number;
a?: number;
}
```
###### CMYKObject
This type is returned by the `CMYKObject` property, and the `toCMYK` method.
```typescript
interface CMYKObject {
c: number;
m: number;
y: number;
k: number;
}
```
[1]: https://www.typescriptlang.org/docs/handbook/generics.html
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