diff --git a/types/document-ready/document-ready-tests.ts b/types/document-ready/document-ready-tests.ts new file mode 100644 index 0000000000..17c522f1a3 --- /dev/null +++ b/types/document-ready/document-ready-tests.ts @@ -0,0 +1,4 @@ +import ready = require("document-ready"); +ready(() => { + // on load +}); diff --git a/types/document-ready/index.d.ts b/types/document-ready/index.d.ts new file mode 100644 index 0000000000..6d8c6d7499 --- /dev/null +++ b/types/document-ready/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for document-ready 2.0 +// Project: https://github.com/bendrucker/document-ready#readme +// Definitions by: Jack Works +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function ready(callback: () => void): void; +export = ready; diff --git a/types/document-ready/tsconfig.json b/types/document-ready/tsconfig.json new file mode 100644 index 0000000000..15ce7ad650 --- /dev/null +++ b/types/document-ready/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "strictFunctionTypes": true, + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "document-ready-tests.ts" + ] +} diff --git a/types/document-ready/tslint.json b/types/document-ready/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/document-ready/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/linear-gradient/index.d.ts b/types/linear-gradient/index.d.ts new file mode 100644 index 0000000000..0f1110efae --- /dev/null +++ b/types/linear-gradient/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for linear-gradient 1.0 +// Project: https://github.com/karmadata/linear-gradient#readme +// Definitions by: Jack Works +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type Color = [number, number, number]; +declare class Gradient { + constructor(colors: Color[]); + /** + * the input value should be normalized to the range between 0 and 1 + */ + calcArray(normalizedPercent: number): Color; + /** + * the input value should be normalized to the range between 0 and 1 + */ + calcHex(normalizedPrecent: number): string; +} +export = Gradient; diff --git a/types/linear-gradient/linear-gradient-tests.ts b/types/linear-gradient/linear-gradient-tests.ts new file mode 100644 index 0000000000..15b4550643 --- /dev/null +++ b/types/linear-gradient/linear-gradient-tests.ts @@ -0,0 +1,23 @@ +import Gradient = require("linear-gradient"); + +// instantiate with an RGB palette +const grad1 = new Gradient([ + [0, 0, 0], + [0, 80, 0], + [0, 160, 80], + [80, 80, 80], + [160, 40, 40], + [255, 0, 0] +]); + +// now we are ready to calculate the colors +// the input value should be normalized to the range between 0 and 1 + +(grad1.calcArray(0)); // -> [0,0,0] (0 -> first color of the palette) +(grad1.calcArray(1)); // -> [255,0,0] (1 -> last color of the palette) +(grad1.calcArray(0.25)); // -> [0,100,20] (weighted average between [0,80,0] and [0,160,80]) +(grad1.calcArray(0.5)); +(grad1.calcArray(0.75)); + +(grad1.calcHex(1)); // -> '#ffffff' +(grad1.calcHex(0.25)); // -> '#006416' diff --git a/types/linear-gradient/tsconfig.json b/types/linear-gradient/tsconfig.json new file mode 100644 index 0000000000..da95f86d4b --- /dev/null +++ b/types/linear-gradient/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "strictFunctionTypes": true, + "esModuleInterop": true, + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "linear-gradient-tests.ts" + ] +} diff --git a/types/linear-gradient/tslint.json b/types/linear-gradient/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/linear-gradient/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }