mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-07 09:49:07 +00:00
Added types for color-namer
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import namer = require('color-namer');
|
||||
|
||||
const colors1 = namer('#ffffff');
|
||||
|
||||
colors1.basic[0].distance;
|
||||
colors1.basic[0].hex;
|
||||
colors1.basic[0].name;
|
||||
colors1.html;
|
||||
colors1.ntc;
|
||||
colors1.pantone;
|
||||
colors1.roygbiv;
|
||||
colors1.x11;
|
||||
|
||||
const colors2 = namer('#ffffff', { pick: ['basic', 'html', 'ntc'] });
|
||||
|
||||
colors2.basic;
|
||||
colors2.html;
|
||||
colors2.ntc;
|
||||
|
||||
const colors3 = namer('#ffffff', { omit: ['basic', 'html', 'ntc'] });
|
||||
|
||||
colors3.pantone;
|
||||
colors3.roygbiv;
|
||||
colors3.x11;
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// Type definitions for color-namer 1.3
|
||||
// Project: https://github.com/zeke/color-namer
|
||||
// Definitions by: Dmitriy Serdtsev <https://github.com/in19farkt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export = ColorNamer;
|
||||
export as namespace ColorNamer;
|
||||
|
||||
declare function ColorNamer<T extends ColorNamer.Palette>(color: string, options?: { pick: T[] }): ColorNamer.Colors<T>;
|
||||
declare function ColorNamer<T extends ColorNamer.Palette>(color: string, options?: { omit: T[] }): ColorNamer.Colors<Diff<ColorNamer.Palette, T>>;
|
||||
|
||||
type Diff<T extends string, U extends string> = ({[P in T]: P} & {[P in U]: never } & { [x: string]: never })[T];
|
||||
|
||||
declare namespace ColorNamer {
|
||||
type Colors<T extends Palette> = Record<T, Color[]>;
|
||||
|
||||
type Palette = 'roygbiv' | 'basic' | 'html' | 'x11' | 'pantone' | 'ntc';
|
||||
|
||||
interface Color {
|
||||
name: string;
|
||||
hex: string;
|
||||
distance: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"color-namer-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user