mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
Type definitions and tests for generic-functions (#9309)
* Create generic-functions.d.ts * Create genetic-functions-tests.ts * Update generic-functions.d.ts
This commit is contained in:
committed by
Masahiro Wakame
parent
eeede9d1ad
commit
e653cba45e
15
generic-functions/generic-functions.d.ts
vendored
Normal file
15
generic-functions/generic-functions.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
// Type definitions for generic-functions
|
||||
// Project: https://github.com/stpettersens/generic-functions
|
||||
// Definitions by: Sam Saint-Pettersen <https://github.com/stpettersens>
|
||||
// Definitions: https://github.com/definitelytyped/DefinitelyTyped
|
||||
|
||||
declare module "generic-functions" {
|
||||
function strcmp(str1: string, str2: string): boolean;
|
||||
function icstrcmp(str1: string, str2: string): boolean;
|
||||
function strendswith(str: string, suffix: string): boolean;
|
||||
function icstrendswith(str: string, suffix: string): boolean;
|
||||
function endswithdot(str: string): string;
|
||||
function println(message: string): void;
|
||||
function printlns(message: string[]): void;
|
||||
function objGetKeyByValue(object: Object, value: any): string;
|
||||
}
|
||||
16
generic-functions/genetic-functions-tests.ts
Normal file
16
generic-functions/genetic-functions-tests.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/// <reference path="generic-functions.d.ts" />
|
||||
|
||||
import g = require('generic-functions');
|
||||
|
||||
var tvShow: Object = {
|
||||
seasons: 2,
|
||||
show: "Better Call Saul"
|
||||
};
|
||||
|
||||
console.log(g.strcmp("foo", "foo")); // => true
|
||||
console.log(g.icstrcmp("BAR", "bar")); // => true
|
||||
console.log(g.strendswith("file.pdf", "pdf")); // => true
|
||||
console.log(g.icstrendswith("file.PDF", "pdf")); // => true
|
||||
console.log(g.endswithdot("file.pdf")); // => ".pdf"
|
||||
console.log(g.objGetKeyByValue(tvShow, 2)); // => "seasons"
|
||||
console.log(g.objGetKeyByValue(tvShow, "Better Call Saul")); // => "show"
|
||||
Reference in New Issue
Block a user