Add type definitions for url-assembler library.

This commit is contained in:
Wolfgang Faust
2017-05-16 23:35:04 -04:00
parent 2a89f40ab7
commit 9f5deb7171
4 changed files with 58 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for url-assembler 1.2
// Project: https://github.com/Floby/node-url-assembler
// Definitions by: Wolfgang Faust <https://github.com/wolfgang42>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface UrlAssembler {
template(template: string): UrlAssembler;
prefix(subPath: string): UrlAssembler;
segment(subPathTemplate: string): UrlAssembler;
param(key: string, value: string, strict: boolean): UrlAssembler;
param(params: {[s: string]: any}, strict: boolean): UrlAssembler;
query(key: string, value: any): UrlAssembler;
query(params: {[s: string]: any}): UrlAssembler;
toString(): string;
valueOf(): string;
toJSON(): string;
}
interface UrlAssemblerConstructor {
(baseUrl?: string): UrlAssembler;
(urlAssembler: UrlAssembler): UrlAssembler;
new (baseUrl?: string): UrlAssembler;
new (urlAssembler: UrlAssembler): UrlAssembler;
}
declare const UrlAssembler: UrlAssemblerConstructor;
export = UrlAssembler;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"url-assembler-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{"extends": "dtslint/dt.json"}
@@ -0,0 +1,7 @@
import UrlAssembler = require('url-assembler');
UrlAssembler('http://goggle.com').segment('string');
const f = new UrlAssembler('https://foo/bar/');
function printUrl(u: UrlAssembler) {
return u.toJSON();
}