From 4eb951c3079978734ce0b1055ee3f21026bf17dd Mon Sep 17 00:00:00 2001 From: William Comartin Date: Tue, 24 May 2016 10:10:12 -0400 Subject: [PATCH] Adding Definitions for js-quantities (#9411) * Add js-quantities library definitions * Change Module to Namespace * Remove intl-tel-input --- js-quantities/js-quantities-tests.ts | 9 ++++ js-quantities/js-quantities.d.ts | 79 ++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 js-quantities/js-quantities-tests.ts create mode 100644 js-quantities/js-quantities.d.ts diff --git a/js-quantities/js-quantities-tests.ts b/js-quantities/js-quantities-tests.ts new file mode 100644 index 0000000000..c8d00eef53 --- /dev/null +++ b/js-quantities/js-quantities-tests.ts @@ -0,0 +1,9 @@ +/// + +var Val1 = Qty('1 m') + +var Val2 = Qty(1); + +var Val3 = Qty(1, 'm'); + +var Val4 = Qty(Val1); \ No newline at end of file diff --git a/js-quantities/js-quantities.d.ts b/js-quantities/js-quantities.d.ts new file mode 100644 index 0000000000..a2e3c2d96c --- /dev/null +++ b/js-quantities/js-quantities.d.ts @@ -0,0 +1,79 @@ +// Type definitions for JS-quantities +// Project: http://gentooboontoo.github.io/js-quantities/ +// Definitions by: William Comartin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare var Qty: QtyModule.QtyStatic; + +declare namespace QtyModule { + interface QtyStatic { + (value: string): Qty; + (value: number): Qty; + (value: number, unit: string): Qty; + (value: Qty): Qty; + } + + interface Qty { + version: string; + + scalar: number; + baseScalar: number; + + parse(value: string): Qty; + + swiftConverter(srcUnits:string, dstUnits:string): (value:number) => number; + + getkinds(): string[]; + + getUnits(kind:string): string[]; + + getAliases(unitName:string): string[]; + + formatter(scalar:number, units:string):string; + + toFloat(): number; + + isUnitless(): boolean; + + isCompatible(other:string|Qty): boolean; + + isInverse(other:string|Qty): boolean + + kind(): string; + + isBase(): boolean; + + toBase(): Qty; + + units(): string; + + eq(other:Qty): boolean; + lt(other:Qty): boolean; + lte(other:Qty): boolean; + gt(other:Qty): boolean; + gte(other:Qty): boolean; + + toPrec(precQuantity: Qty|string|number): Qty; + + toString(targetUnitsOrMaxDecimalsOrPrec?:number|string|Qty, maxDecimals?: number): string; + + format(targetUnits?:string, formatter?:(scalar:number, units:string) => string): string; + + compareTo(other:Qty|string): number; + + same(other: Qty): boolean; + + inverse(): Qty; + + isDegrees(): boolean; + + isTemperature(): boolean; + + to(other:string|Qty): Qty; + + add(other:string|Qty): Qty; + sub(other:string|Qty): Qty; + mul(other:number|string|Qty): Qty; + div(other:number|string|Qty): Qty; + } +} \ No newline at end of file