Merge pull request #26052 from RafaelKr/master

Add typings for gtin
This commit is contained in:
Daniel Rosenwasser
2018-05-26 22:21:50 -07:00
committed by GitHub
4 changed files with 53 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
import * as gtin from 'gtin';
gtin.isGTIN('12341238'); // $ExpectType boolean
gtin.validate('12341238'); // $ExpectType boolean
gtin.minify('0000012341238'); // $ExpectType string
gtin.getFormat('12341238'); // $ExpectType GtinFormat
gtin.getRealFormat('1234123412344'); // $ExpectType GtinFormat
gtin.upce.compress('1200000789'); // $ExpectType string | null
gtin.upce.expand('127890'); // $ExpectType string
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for gtin 0.3
// Project: https://github.com/xbpf/gtin
// Definitions by: RafaelKr <https://github.com/RafaelKr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace gtin;
export type GtinFormat = 'GTIN-8' | 'GTIN-12' | 'GTIN-13' | 'GTIN-14';
export function isGTIN(gtin: string): boolean;
export function validate(gtin: string): boolean;
export function minify(gtin: string): string;
export function getFormat(gtin: string): GtinFormat;
export function getRealFormat(gtin: string): GtinFormat;
export namespace upce {
function compress(gtin: string): string | null;
function expand(gtin: string): string;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"strictFunctionTypes": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"gtin-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }