@types/color-hash
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Installation

npm install --save @types/color-hash

Summary

This package contains type definitions for color-hash (https://github.com/zenozeng/color-hash).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/color-hash.

index.d.ts

type ColorValueArray = [number, number, number];

interface HueObject {
    min: number;
    max: number;
}

type Hue = number | HueObject | readonly HueObject[];
type Lightness = number | number[];
type Saturation = number | number[];

type HashFunction = (input: string) => number;

interface ColorHashOptions {
    lightness?: Lightness | undefined;
    saturation?: Saturation | undefined;
    hue?: Hue | undefined;
    hash?: HashFunction | undefined;
}

declare class ColorHash {
    constructor(options?: ColorHashOptions);

    /**
     * Returns the hash in [h, s, l].
     * Note that H ∈ [0, 360); S ∈ [0, 1]; L ∈ [0, 1];
     *
     * @param input string to hash
     * @returns [h, s, l]
     */
    hsl(input: string): ColorValueArray;

    /**
     * Returns the hash in [r, g, b].
     * Note that R, G, B ∈ [0, 255]
     *
     * @param input string to hash
     * @returns [r, g, b]
     */
    rgb(input: string): ColorValueArray;

    /**
     * Returns the hash in hex.
     *
     * @param input string to hash
     * @returns hex with #
     */
    hex(input: string): string;
}

export as namespace ColorHash;
export = ColorHash;

Additional Details

  • Last updated: Mon, 20 Nov 2023 23:36:24 GMT
  • Dependencies: none

Credits

These definitions were written by Johannes Hoppe, and Kamil Socha.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/color-hash

Weekly Downloads

50,404

Version

1.0.5

License

MIT

Unpacked Size

5.08 kB

Total Files

5

Last publish

Collaborators

  • types