npm.io
2.0.0 • Published 2 years ago

@types/color-hash

Licence
MIT
Version
2.0.0
Deps
0
Size
5 kB
Vulns
0
Weekly
0
Stars
51.4K

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

declare namespace ColorHash {
    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;
        saturation?: Saturation;
        hue?: Hue;
        hash?: HashFunction | "bkdr";
    }
}

declare class ColorHash {
    constructor(options?: ColorHash.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): ColorHash.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): ColorHash.ColorValueArray;

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

export = ColorHash;

Additional Details

  • Last updated: Fri, 31 May 2024 1025 GMT
  • Dependencies: none

Credits

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