Add types for multiple vigour.io projects (#35629)

Included projects:
* is-number-like
* quick-hash
* turbostatus
* vigour-ua
This commit is contained in:
Florian Keller 2019-05-22 18:07:08 +02:00 committed by Ryan Cavanaugh
parent b244a1ab2e
commit b1ca386416
16 changed files with 206 additions and 0 deletions

13
types/is-number-like/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// Type definitions for is-number-like 1.0
// Project: https://github.com/vigour-io/is-number-like#readme
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Checks whether provided parameter looks like a number
* @param val the value to check
* @returns `true` if `val` looks like a number, `false` otherwise
*/
declare function isNumberLike(val: any): boolean;
export = isNumberLike;

View File

@ -0,0 +1,4 @@
import isNumberLike = require('is-number-like');
isNumberLike('2'); // $ExpectType boolean
isNumberLike('a'); // $ExpectType boolean

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"is-number-like-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

13
types/quick-hash/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// Type definitions for quick-hash 1.0
// Project: https://github.com/vigour-io/quick-hash#readme
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Murmur hash optimized for performance, not collision avoidance.
* @param key the string to hash
* @param seed a seed for hashing
* @returns A string of 5 to 7 alpha-numeric characters
*/
declare function quickHash(key: string, seed?: number): string;
export = quickHash;

View File

@ -0,0 +1,3 @@
import hash = require('quick-hash');
hash('Any string'); // $ExpectType string
hash('Another string', 100); // $ExpectType string

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"quick-hash-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

31
types/turbostatus/index.d.ts vendored Normal file
View File

@ -0,0 +1,31 @@
// Type definitions for turbostatus 2.4
// Project: https://github.com/vigour-io/turbostatus#readme
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Repository {
name: string;
path: string;
}
export interface Description {
commitsSinceTag: string | false;
hash: string;
nearestTag: string | false;
}
export function checkout(folder: string, commit: string): Promise<string>;
export function clone(origin: string, folder: string): Promise<string>;
export function describe(folder: string): Promise<Description>;
export function getBranch(folder: string): Promise<string>;
export function getBranchFast(folder: string): Promise<string>;
export function getLocalCommit(folder: string): Promise<string>;
export function getMergeBase(folder: string): Promise<string>;
export function getOrigin(folder: string): Promise<string>;
export function getRemoteCommit(folder: string): Promise<string>;
export function getRepos(folder: string, wildcard?: string): Promise<Repository[]>;
export function hasUncommited(folder: string): Promise<boolean>;
export function hasUntracked(folder: string): Promise<boolean>;
export function info(repo: Repository, remotes?: boolean): Promise<Repository>;
export function isRepo(folder: string): Promise<boolean>;
export function references(folder: string): Promise<string>;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"turbostatus-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,5 @@
import * as turbostatus from 'turbostatus';
turbostatus.checkout('./', 'master');
turbostatus.isRepo('./');
turbostatus.describe('./');

30
types/vigour-ua/index.d.ts vendored Normal file
View File

@ -0,0 +1,30 @@
// Type definitions for vigour-ua 4.0
// Project: https://github.com/vigour-io/ua#readme
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace ua {
interface UserAgent {
[value: string]: string | number;
browser: string;
prefix: string;
version: number;
}
}
/**
* Returns an object representing the user agent including data such as browser, device and platform
* @param _ua the raw user agent string to be converted
* @param obj object to be merged to the output result
* @returns object representing your user agent
*/
declare function ua(_ua: string): ua.UserAgent;
/**
* Returns an object representing the user agent including data such as browser, device and platform
* @param _ua the raw user agent string to be converted
* @returns object representing your user agent
*/
declare function ua<T extends object>(_ua: string, obj: T): ua.UserAgent & T;
export = ua;

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"vigour-ua-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,11 @@
import ua = require('vigour-ua');
const userAgent =
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.3';
const someObject = {
randomField: true,
};
ua(userAgent, someObject);
ua(userAgent);