Merge commit 'upstream/master~440' into types-2.0

This commit is contained in:
Mine Yalcinalp Starks 2016-11-18 14:21:35 -08:00
commit ada1df33d6
34 changed files with 3579 additions and 502 deletions

View File

@ -2,9 +2,9 @@ import angularTouchSpin = require("angular-touchspin");
import * as angular from 'angular';
angular
.module('touchspin-tests', ['lm.touchspin'])
.config(function(touchspinConfigProvider: angularTouchSpin.ITouchSpinConfigProvider) {
touchspinConfigProvider.defaults(<angularTouchSpin.ITouchSpinOptions>{
.module('touchspin-tests', ['nk.touchspin'])
.config(function(touchspinConfigProvider: angular.touchspin.ITouchSpinConfigProvider) {
touchspinConfigProvider.defaults(<angular.touchspin.ITouchSpinOptions>{
min: 0,
max: 0,
step: 0,

View File

@ -8,7 +8,7 @@
declare let angularTouchSpin: string;
export = angularTouchSpin;
declare namespace angularTouchSpin {
declare namespace angular.touchspin {
interface ITouchSpinOptions {
min?: number;
max?: number;

View File

@ -0,0 +1,10 @@
/// <reference path="bit-array.d.ts" />
import BitArray = require("bit-array");
const a = new BitArray(32);
a.set(0, true);
a.set(31, true);
a.toString(); // "10000000000000000000000000000001"
a.get(1); // false
a.get(31); // true

View File

@ -0,0 +1 @@
--noImplicitAny --module commonjs

105
bit-array/bit-array.d.ts vendored Normal file
View File

@ -0,0 +1,105 @@
// Type definitions for bit-array v0.2.2
// Project: https://github.com/bramstein/bit-array
// Definitions by: Mudkip <https://github.com/mudkipme>
// Definitions: https://github.com/mudkipme/DefinitelyTyped
declare module "bit-array" {
class BitArray {
/**
* Creates a new empty BitArray with the given length or initialises the BitArray with the given hex representation.
*/
constructor(size: number, hex?: string);
/**
* Returns the total number of bits in this BitArray.
*/
size(): number;
/**
* Sets the bit at index to a value (boolean.)
*/
set(index: number, value: boolean): BitArray;
/**
* Toggles the bit at index. If the bit is on, it is turned off. Likewise, if the bit is off it is turned on.
*/
toggle(index: number): BitArray;
/**
* Returns the value of the bit at index (boolean.)
*/
get(index: number): boolean;
/**
* Resets the BitArray so that it is empty and can be re-used.
*/
reset(): BitArray;
/**
* Returns a copy of this BitArray.
*/
copy(): BitArray;
/**
* Returns true if this BitArray equals another. Two BitArrays are considered
* equal if both have the same length and bit pattern.
*/
equals(x: BitArray): boolean;
/**
* Returns the JSON representation of this BitArray.
*/
toJSON(): string;
/**
* Returns a string representation of the BitArray with bits
* in mathemetical order.
*/
toBinaryString(): string;
/**
* Returns a hexadecimal string representation of the BitArray
* with bits in logical order.
*/
toHexString(): string;
/**
* Returns a string representation of the BitArray with bits
* in logical order.
*/
toString(): string;
/**
* Convert the BitArray to an Array of boolean values (slow).
*/
toArray(): boolean[];
/**
* Returns the total number of bits set to one in this BitArray.
*/
count(): number;
/**
* Inverts this BitArray.
*/
not(): BitArray;
/**
* Bitwise OR on the values of this BitArray using BitArray x.
*/
or(x: BitArray): BitArray;
/**
* Bitwise AND on the values of this BitArray using BitArray x.
*/
and(x: BitArray): BitArray;
/**
* Bitwise XOR on the values of this BitArray using BitArray x.
*/
xor(x: BitArray): BitArray;
}
export = BitArray;
}

View File

@ -64,6 +64,12 @@ class Tag extends bookshelf.Model<Tag> {
get tableName() { return 'tags'; }
}
User.where<User>('id', 1).fetch({withRelated: ['posts.tags']}).then(function(user) {
console.log(user.related('posts').toJSON());
}).catch(function(err) {
console.error(err);
});
new User().where('id', 1).fetch({withRelated: ['posts.tags']})
.then(user => {
const posts = user.related<Post>('posts');

579
bookshelf/index.d.ts vendored
View File

@ -10,344 +10,345 @@ import Lodash = require('lodash');
import createError = require('create-error');
interface Bookshelf extends Bookshelf.Events<any> {
VERSION: string;
knex: knex;
Model: typeof Bookshelf.Model;
Collection: typeof Bookshelf.Collection;
VERSION: string;
knex: knex;
Model: typeof Bookshelf.Model;
Collection: typeof Bookshelf.Collection;
plugin(name: string | string[] | Function, options?: any): Bookshelf;
transaction<T>(callback: (transaction: knex.Transaction) => T): BlueBird<T>;
plugin(name: string | string[] | Function, options?: any): Bookshelf;
transaction<T>(callback: (transaction: knex.Transaction) => T): BlueBird<T>;
}
declare function Bookshelf(knex: knex): Bookshelf;
declare namespace Bookshelf {
abstract class Events<T> {
on(event?: string, callback?: EventFunction<T>, context?: any): void;
off(event?: string): void;
trigger(event?: string, ...args: any[]): void;
triggerThen(name: string, ...args: any[]): BlueBird<any>;
once(event: string, callback: EventFunction<T>, context?: any): void;
}
abstract class Events<T> {
on(event?: string, callback?: EventFunction<T>, context?: any): void;
off(event?: string): void;
trigger(event?: string, ...args: any[]): void;
triggerThen(name: string, ...args: any[]): BlueBird<any>;
once(event: string, callback: EventFunction<T>, context?: any): void;
}
interface IModelBase {
/** Should be declared as a getter instead of a plain property. */
hasTimestamps?: boolean | string[];
/** Should be declared as a getter instead of a plain property. Should be required, but cannot have abstract properties yet. */
tableName?: string;
}
interface IModelBase {
/** Should be declared as a getter instead of a plain property. */
hasTimestamps?: boolean | string[];
/** Should be declared as a getter instead of a plain property. Should be required, but cannot have abstract properties yet. */
tableName?: string;
}
abstract class ModelBase<T extends Model<any>> extends Events<T | Collection<T>> implements IModelBase {
/** If overriding, must use a getter instead of a plain property. */
idAttribute: string;
abstract class ModelBase<T extends Model<any>> extends Events<T | Collection<T>> implements IModelBase {
/** If overriding, must use a getter instead of a plain property. */
idAttribute: string;
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L178
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L213
id: any;
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L178
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L213
id: any;
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L28
attributes: any;
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/model.js#L28
attributes: any;
constructor(attributes?: any, options?: ModelOptions);
constructor(attributes?: any, options?: ModelOptions);
clear(): T;
clone(): T;
escape(attribute: string): string;
format(attributes: any): any;
get(attribute: string): any;
has(attribute: string): boolean;
hasChanged(attribute?: string): boolean;
isNew(): boolean;
parse(response: Object): Object;
previousAttributes(): any;
previous(attribute: string): any;
related<R extends Model<any>>(relation: string): R | Collection<R>;
serialize(options?: SerializeOptions): any;
set(attribute?: { [key: string]: any }, options?: SetOptions): T;
set(attribute: string, value?: any, options?: SetOptions): T;
timestamp(options?: TimestampOptions): any;
toJSON(options?: SerializeOptions): any;
unset(attribute: string): T;
clear(): T;
clone(): T;
escape(attribute: string): string;
format(attributes: any): any;
get(attribute: string): any;
has(attribute: string): boolean;
hasChanged(attribute?: string): boolean;
isNew(): boolean;
parse(response: Object): Object;
previousAttributes(): any;
previous(attribute: string): any;
related<R extends Model<any>>(relation: string): R | Collection<R>;
serialize(options?: SerializeOptions): any;
set(attribute?: { [key: string]: any }, options?: SetOptions): T;
set(attribute: string, value?: any, options?: SetOptions): T;
timestamp(options?: TimestampOptions): any;
toJSON(options?: SerializeOptions): any;
unset(attribute: string): T;
// lodash methods
invert<R extends {}>(): R;
keys(): string[];
omit<R extends {}>(predicate?: Lodash.ObjectIterator<any, boolean>, thisArg?: any): R;
omit<R extends {}>(...attributes: string[]): R;
pairs(): any[][];
pick<R extends {}>(predicate?: Lodash.ObjectIterator<any, boolean>, thisArg?: any): R;
pick<R extends {}>(...attributes: string[]): R;
values(): any[];
}
// lodash methods
invert<R extends {}>(): R;
keys(): string[];
omit<R extends {}>(predicate?: Lodash.ObjectIterator<any, boolean>, thisArg?: any): R;
omit<R extends {}>(...attributes: string[]): R;
pairs(): any[][];
pick<R extends {}>(predicate?: Lodash.ObjectIterator<any, boolean>, thisArg?: any): R;
pick<R extends {}>(...attributes: string[]): R;
values(): any[];
}
class Model<T extends Model<any>> extends ModelBase<T> {
static collection<T extends Model<any>>(models?: T[], options?: CollectionOptions<T>): Collection<T>;
static count(column?: string, options?: SyncOptions): BlueBird<number>;
/** @deprecated use Typescript classes */
static extend<T extends Model<any>>(prototypeProperties?: any, classProperties?: any): Function; // should return a type
static fetchAll<T extends Model<any>>(): BlueBird<Collection<T>>;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes?: any, options?: ModelOptions): T;
class Model<T extends Model<any>> extends ModelBase<T> {
static collection<T extends Model<any>>(models?: T[], options?: CollectionOptions<T>): Collection<T>;
static count(column?: string, options?: SyncOptions): BlueBird<number>;
/** @deprecated use Typescript classes */
static extend<T extends Model<any>>(prototypeProperties?: any, classProperties?: any): Function; // should return a type
static fetchAll<T extends Model<any>>(): BlueBird<Collection<T>>;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes?: any, options?: ModelOptions): T;
static where<T>(properties: { [key: string]: any }): T;
static where<T>(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | number | boolean): T;
belongsTo<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): R;
belongsToMany<R extends Model<any>>(target: { new (...args: any[]): R }, table?: string, foreignKey?: string, otherKey?: string): Collection<R>;
count(column?: string, options?: SyncOptions): BlueBird<number>;
destroy(options?: DestroyOptions): BlueBird<T>;
fetch(options?: FetchOptions): BlueBird<T>;
fetchAll(options?: FetchAllOptions): BlueBird<Collection<T>>;
hasMany<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): Collection<R>;
hasOne<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): R;
load(relations: string | string[], options?: LoadOptions): BlueBird<T>;
morphMany<R extends Model<any>>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): Collection<R>;
morphOne<R extends Model<any>>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): R;
morphTo(name: string, columnNames?: string[], ...target: typeof Model[]): T;
morphTo(name: string, ...target: typeof Model[]): T;
belongsTo<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): R;
belongsToMany<R extends Model<any>>(target: { new (...args: any[]): R }, table?: string, foreignKey?: string, otherKey?: string): Collection<R>;
count(column?: string, options?: SyncOptions): BlueBird<number>;
destroy(options?: DestroyOptions): BlueBird<T>;
fetch(options?: FetchOptions): BlueBird<T>;
fetchAll(options?: FetchAllOptions): BlueBird<Collection<T>>;
hasMany<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): Collection<R>;
hasOne<R extends Model<any>>(target: { new (...args: any[]): R }, foreignKey?: string): R;
load(relations: string | string[], options?: LoadOptions): BlueBird<T>;
morphMany<R extends Model<any>>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): Collection<R>;
morphOne<R extends Model<any>>(target: { new (...args: any[]): R }, name?: string, columnNames?: string[], morphValue?: string): R;
morphTo(name: string, columnNames?: string[], ...target: typeof Model[]): T;
morphTo(name: string, ...target: typeof Model[]): T;
// Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
query(): Knex.QueryBuilder;
query(callback: (qb: Knex.QueryBuilder) => void): T;
query(...query: string[]): T;
query(query: { [key: string]: any }): T;
// Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
query(): Knex.QueryBuilder;
query(callback: (qb: Knex.QueryBuilder) => void): T;
query(...query: string[]): T;
query(query: { [key: string]: any }): T;
refresh(options?: FetchOptions): BlueBird<T>;
resetQuery(): T;
save(key?: string, val?: any, options?: SaveOptions): BlueBird<T>;
save(attrs?: { [key: string]: any }, options?: SaveOptions): BlueBird<T>;
through<R extends Model<any>>(interim: typeof Model, throughForeignKey?: string, otherKey?: string): R;
where(properties: { [key: string]: any }): T;
where(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | number | boolean): T;
refresh(options?: FetchOptions): BlueBird<T>;
resetQuery(): T;
save(key?: string, val?: any, options?: SaveOptions): BlueBird<T>;
save(attrs?: { [key: string]: any }, options?: SaveOptions): BlueBird<T>;
through<R extends Model<any>>(interim: typeof Model, throughForeignKey?: string, otherKey?: string): R;
where(properties: { [key: string]: any }): T;
where(key: string, operatorOrValue: string | number | boolean, valueIfOperator?: string | number | boolean): T;
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/errors.js
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/model.js#L1280
static NotFoundError: createError.Error<Error>;
static NoRowsUpdatedError: createError.Error<Error>;
static NoRowsDeletedError: createError.Error<Error>;
}
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/errors.js
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/model.js#L1280
static NotFoundError: createError.Error<Error>;
static NoRowsUpdatedError: createError.Error<Error>;
static NoRowsDeletedError: createError.Error<Error>;
}
abstract class CollectionBase<T extends Model<any>> extends Events<T> {
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/collection.js#L573
length: number;
abstract class CollectionBase<T extends Model<any>> extends Events<T> {
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/collection.js#L573
length: number;
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/collection.js#L21
constructor(models?: T[], options?: CollectionOptions<T>);
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/base/collection.js#L21
constructor(models?: T[], options?: CollectionOptions<T>);
add(models: T[] | { [key: string]: any }[], options?: CollectionAddOptions): Collection<T>;
at(index: number): T;
clone(): Collection<T>;
fetch(options?: CollectionFetchOptions): BlueBird<Collection<T>>;
findWhere(match: { [key: string]: any }): T;
get(id: any): T;
invokeThen(name: string, ...args: any[]): BlueBird<any>;
parse(response: any): any;
pluck(attribute: string): any[];
pop(): void;
push(model: any): Collection<T>;
reduceThen<R>(iterator: (prev: R, cur: T, idx: number, array: T[]) => R, initialValue: R, context: any): BlueBird<R>;
remove(model: T, options?: EventOptions): T;
remove(model: T[], options?: EventOptions): T[];
reset(model: any[], options?: CollectionAddOptions): T[];
serialize(options?: SerializeOptions): any[];
set(models: T[] | { [key: string]: any }[], options?: CollectionSetOptions): Collection<T>;
shift(options?: EventOptions): void;
slice(begin?: number, end?: number): void;
toJSON(options?: SerializeOptions): any[];
unshift(model: any, options?: CollectionAddOptions): void;
where(match: { [key: string]: any }, firstOnly: boolean): T | Collection<T>;
add(models: T[] | { [key: string]: any }[], options?: CollectionAddOptions): Collection<T>;
at(index: number): T;
clone(): Collection<T>;
fetch(options?: CollectionFetchOptions): BlueBird<Collection<T>>;
findWhere(match: { [key: string]: any }): T;
get(id: any): T;
invokeThen(name: string, ...args: any[]): BlueBird<any>;
parse(response: any): any;
pluck(attribute: string): any[];
pop(): void;
push(model: any): Collection<T>;
reduceThen<R>(iterator: (prev: R, cur: T, idx: number, array: T[]) => R, initialValue: R, context: any): BlueBird<R>;
remove(model: T, options?: EventOptions): T;
remove(model: T[], options?: EventOptions): T[];
reset(model: any[], options?: CollectionAddOptions): T[];
serialize(options?: SerializeOptions): any[];
set(models: T[] | { [key: string]: any }[], options?: CollectionSetOptions): Collection<T>;
shift(options?: EventOptions): void;
slice(begin?: number, end?: number): void;
toJSON(options?: SerializeOptions): any[];
unshift(model: any, options?: CollectionAddOptions): void;
where(match: { [key: string]: any }, firstOnly: boolean): T | Collection<T>;
// lodash methods
all(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
all<R extends {}>(predicate?: R): boolean;
any(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
any<R extends {}>(predicate?: R): boolean;
chain(): Lodash.LoDashExplicitObjectWrapper<T>;
collect(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
collect<R extends {}>(predicate?: R): T[];
contains(value: any, fromIndex?: number): boolean;
countBy(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): Lodash.Dictionary<number>;
countBy<R extends {}>(predicate?: R): Lodash.Dictionary<number>;
detect(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T;
detect<R extends {}>(predicate?: R): T;
difference(...values: T[]): T[];
drop(n?: number): T[];
each(callback?: Lodash.ListIterator<T, void>, thisArg?: any): Lodash.List<T>;
each(callback?: Lodash.DictionaryIterator<T, void>, thisArg?: any): Lodash.Dictionary<T>;
each(callback?: Lodash.ObjectIterator<T, void>, thisArg?: any): T;
every(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
every<R extends {}>(predicate?: R): boolean;
filter(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
filter<R extends {}>(predicate?: R): T[];
find(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T;
find<R extends {}>(predicate?: R): T;
first(): T;
foldl<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
foldr<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
forEach(callback?: Lodash.ListIterator<T, void>, thisArg?: any): Lodash.List<T>;
forEach(callback?: Lodash.DictionaryIterator<T, void>, thisArg?: any): Lodash.Dictionary<T>;
forEach(callback?: Lodash.ObjectIterator<T, void>, thisArg?: any): T;
groupBy(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): Lodash.Dictionary<T[]>;
groupBy<R extends {}>(predicate?: R): Lodash.Dictionary<T[]>;
head(): T;
include(value: any, fromIndex?: number): boolean;
indexOf(value: any, fromIndex?: number): number;
initial(): T[];
inject<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
invoke(methodName: string | Function, ...args: any[]): any;
isEmpty(): boolean;
keys(): string[];
last(): T;
lastIndexOf(value: any, fromIndex?: number): number;
// lodash methods
all(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
all<R extends {}>(predicate?: R): boolean;
any(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
any<R extends {}>(predicate?: R): boolean;
chain(): Lodash.LoDashExplicitObjectWrapper<T>;
collect(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
collect<R extends {}>(predicate?: R): T[];
contains(value: any, fromIndex?: number): boolean;
countBy(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): Lodash.Dictionary<number>;
countBy<R extends {}>(predicate?: R): Lodash.Dictionary<number>;
detect(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T;
detect<R extends {}>(predicate?: R): T;
difference(...values: T[]): T[];
drop(n?: number): T[];
each(callback?: Lodash.ListIterator<T, void>, thisArg?: any): Lodash.List<T>;
each(callback?: Lodash.DictionaryIterator<T, void>, thisArg?: any): Lodash.Dictionary<T>;
each(callback?: Lodash.ObjectIterator<T, void>, thisArg?: any): T;
every(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
every<R extends {}>(predicate?: R): boolean;
filter(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
filter<R extends {}>(predicate?: R): T[];
find(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T;
find<R extends {}>(predicate?: R): T;
first(): T;
foldl<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
foldr<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
forEach(callback?: Lodash.ListIterator<T, void>, thisArg?: any): Lodash.List<T>;
forEach(callback?: Lodash.DictionaryIterator<T, void>, thisArg?: any): Lodash.Dictionary<T>;
forEach(callback?: Lodash.ObjectIterator<T, void>, thisArg?: any): T;
groupBy(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): Lodash.Dictionary<T[]>;
groupBy<R extends {}>(predicate?: R): Lodash.Dictionary<T[]>;
head(): T;
include(value: any, fromIndex?: number): boolean;
indexOf(value: any, fromIndex?: number): number;
initial(): T[];
inject<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
invoke(methodName: string | Function, ...args: any[]): any;
isEmpty(): boolean;
keys(): string[];
last(): T;
lastIndexOf(value: any, fromIndex?: number): number;
// See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1ec3d51/lodash/lodash-3.10.d.ts#L7119
// See https://github.com/Microsoft/TypeScript/blob/v1.8.10/lib/lib.core.es7.d.ts#L1122
map<U>(predicate?: Lodash.ListIterator<T, U> | string, thisArg?: any): U[];
map<U>(predicate?: Lodash.DictionaryIterator<T, U> | string, thisArg?: any): U[];
map<U>(predicate?: string): U[];
// See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/1ec3d51/lodash/lodash-3.10.d.ts#L7119
// See https://github.com/Microsoft/TypeScript/blob/v1.8.10/lib/lib.core.es7.d.ts#L1122
map<U>(predicate?: Lodash.ListIterator<T, U> | string, thisArg?: any): U[];
map<U>(predicate?: Lodash.DictionaryIterator<T, U> | string, thisArg?: any): U[];
map<U>(predicate?: string): U[];
max(predicate?: Lodash.ListIterator<T, boolean> | string, thisArg?: any): T;
max<R extends {}>(predicate?: R): T;
min(predicate?: Lodash.ListIterator<T, boolean> | string, thisArg?: any): T;
min<R extends {}>(predicate?: R): T;
reduce<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
reduceRight<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
reject(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
reject<R extends {}>(predicate?: R): T[];
rest(): T[];
select(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
select<R extends {}>(predicate?: R): T[];
shuffle(): T[];
size(): number;
some(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
some<R extends {}>(predicate?: R): boolean;
sortBy(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
sortBy<R extends {}>(predicate?: R): T[];
tail(): T[];
take(n?: number): T[];
toArray(): T[];
without(...values: any[]): T[];
}
max(predicate?: Lodash.ListIterator<T, boolean> | string, thisArg?: any): T;
max<R extends {}>(predicate?: R): T;
min(predicate?: Lodash.ListIterator<T, boolean> | string, thisArg?: any): T;
min<R extends {}>(predicate?: R): T;
reduce<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
reduceRight<R>(callback?: Lodash.MemoIterator<T, R>, accumulator?: R, thisArg?: any): R;
reject(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
reject<R extends {}>(predicate?: R): T[];
rest(): T[];
select(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
select<R extends {}>(predicate?: R): T[];
shuffle(): T[];
size(): number;
some(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): boolean;
some<R extends {}>(predicate?: R): boolean;
sortBy(predicate?: Lodash.ListIterator<T, boolean> | Lodash.DictionaryIterator<T, boolean> | string, thisArg?: any): T[];
sortBy<R extends {}>(predicate?: R): T[];
tail(): T[];
take(n?: number): T[];
toArray(): T[];
without(...values: any[]): T[];
}
class Collection<T extends Model<any>> extends CollectionBase<T> {
/** @deprecated use Typescript classes */
static extend<T>(prototypeProperties?: any, classProperties?: any): Function;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes?: any, options?: ModelOptions): T;
class Collection<T extends Model<any>> extends CollectionBase<T> {
/** @deprecated use Typescript classes */
static extend<T>(prototypeProperties?: any, classProperties?: any): Function;
/** @deprecated should use `new` objects instead. */
static forge<T>(attributes?: any, options?: ModelOptions): T;
attach(ids: any | any[], options?: SyncOptions): BlueBird<Collection<T>>;
count(column?: string, options?: SyncOptions): BlueBird<number>;
create(model: { [key: string]: any }, options?: CollectionCreateOptions): BlueBird<T>;
detach(ids: any[], options?: SyncOptions): BlueBird<any>;
detach(options?: SyncOptions): BlueBird<any>;
fetchOne(options?: CollectionFetchOneOptions): BlueBird<T>;
load(relations: string | string[], options?: SyncOptions): BlueBird<Collection<T>>;
attach(ids: any | any[], options?: SyncOptions): BlueBird<Collection<T>>;
count(column?: string, options?: SyncOptions): BlueBird<number>;
create(model: { [key: string]: any }, options?: CollectionCreateOptions): BlueBird<T>;
detach(ids: any[], options?: SyncOptions): BlueBird<any>;
detach(options?: SyncOptions): BlueBird<any>;
fetchOne(options?: CollectionFetchOneOptions): BlueBird<T>;
load(relations: string | string[], options?: SyncOptions): BlueBird<Collection<T>>;
// Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
query(): Knex.QueryBuilder;
query(callback: (qb: Knex.QueryBuilder) => void): Collection<T>;
query(...query: string[]): Collection<T>;
query(query: { [key: string]: any }): Collection<T>;
// Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
query(): Knex.QueryBuilder;
query(callback: (qb: Knex.QueryBuilder) => void): Collection<T>;
query(...query: string[]): Collection<T>;
query(query: { [key: string]: any }): Collection<T>;
resetQuery(): Collection<T>;
through<R extends Model<any>>(interim: typeof Model, throughForeignKey?: string, otherKey?: string): Collection<R>;
updatePivot(attributes: any, options?: PivotOptions): BlueBird<number>;
withPivot(columns: string[]): Collection<T>;
resetQuery(): Collection<T>;
through<R extends Model<any>>(interim: typeof Model, throughForeignKey?: string, otherKey?: string): Collection<R>;
updatePivot(attributes: any, options?: PivotOptions): BlueBird<number>;
withPivot(columns: string[]): Collection<T>;
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/collection.js#L389
static EmptyError: createError.Error<Error>;
}
// See https://github.com/tgriesser/bookshelf/blob/0.9.4/src/collection.js#L389
static EmptyError: createError.Error<Error>;
}
interface ModelOptions {
tableName?: string;
hasTimestamps?: boolean;
parse?: boolean;
}
interface ModelOptions {
tableName?: string;
hasTimestamps?: boolean;
parse?: boolean;
}
interface LoadOptions extends SyncOptions {
withRelated: (string | WithRelatedQuery)[];
}
interface LoadOptions extends SyncOptions {
withRelated: (string | WithRelatedQuery)[];
}
interface FetchOptions extends SyncOptions {
require?: boolean;
columns?: string | string[];
withRelated?: (string | WithRelatedQuery)[];
}
interface FetchOptions extends SyncOptions {
require?: boolean;
columns?: string | string[];
withRelated?: (string | WithRelatedQuery)[];
}
interface WithRelatedQuery {
[index: string]: (query: Knex.QueryBuilder) => Knex.QueryBuilder;
}
interface WithRelatedQuery {
[index: string]: (query: Knex.QueryBuilder) => Knex.QueryBuilder;
}
interface FetchAllOptions extends SyncOptions {
require?: boolean;
}
interface FetchAllOptions extends SyncOptions {
require?: boolean;
}
interface SaveOptions extends SyncOptions {
method?: string;
defaults?: string;
patch?: boolean;
require?: boolean;
}
interface SaveOptions extends SyncOptions {
method?: string;
defaults?: string;
patch?: boolean;
require?: boolean;
}
interface DestroyOptions extends SyncOptions {
require?: boolean;
}
interface DestroyOptions extends SyncOptions {
require?: boolean;
}
interface SerializeOptions {
shallow?: boolean;
omitPivot?: boolean;
}
interface SerializeOptions {
shallow?: boolean;
omitPivot?: boolean;
}
interface SetOptions {
unset?: boolean;
}
interface SetOptions {
unset?: boolean;
}
interface TimestampOptions {
method?: string;
}
interface TimestampOptions {
method?: string;
}
interface SyncOptions {
transacting?: Knex.Transaction;
debug?: boolean;
}
interface SyncOptions {
transacting?: Knex.Transaction;
debug?: boolean;
}
interface CollectionOptions<T> {
comparator?: boolean | string | ((a: T, b: T) => number);
}
interface CollectionOptions<T> {
comparator?: boolean | string | ((a: T, b: T) => number);
}
interface CollectionAddOptions extends EventOptions {
at?: number;
merge?: boolean;
}
interface CollectionAddOptions extends EventOptions {
at?: number;
merge?: boolean;
}
interface CollectionFetchOptions {
require?: boolean;
withRelated?: string | string[];
}
interface CollectionFetchOptions {
require?: boolean;
withRelated?: string | string[];
}
interface CollectionFetchOneOptions {
require?: boolean;
columns?: string | string[];
}
interface CollectionFetchOneOptions {
require?: boolean;
columns?: string | string[];
}
interface CollectionSetOptions extends EventOptions {
add?: boolean;
remove?: boolean;
merge?: boolean;
}
interface CollectionSetOptions extends EventOptions {
add?: boolean;
remove?: boolean;
merge?: boolean;
}
interface PivotOptions {
query?: Function | any;
require?: boolean;
}
interface PivotOptions {
query?: Function | any;
require?: boolean;
}
interface EventOptions {
silent?: boolean;
}
interface EventOptions {
silent?: boolean;
}
interface EventFunction<T> {
(model: T, attrs: any, options: any): BlueBird<any> | void;
}
interface EventFunction<T> {
(model: T, attrs: any, options: any): BlueBird<any> | void;
}
interface CollectionCreateOptions extends ModelOptions, SyncOptions, CollectionAddOptions, SaveOptions { }
interface CollectionCreateOptions extends ModelOptions, SyncOptions, CollectionAddOptions, SaveOptions { }
}
export = Bookshelf;

View File

@ -30,6 +30,7 @@ declare namespace CanvasGauges {
minorTicks?: number,
strokeTicks?: boolean,
animatedValue?: boolean,
animateOnInit?: boolean,
title?: string|boolean,
borders?: boolean,
valueInt?: number,

View File

@ -0,0 +1,174 @@
/// <reference path="./css-modules-require-hook.d.ts" />
/// <reference path="../node/node.d.ts" />
import * as hook from 'css-modules-require-hook';
import * as path from 'path';
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#usage
//
hook({ generateScopedName: '[name]__[local]___[hash:base64:5]' });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#adding-custom-postcss-plugins
//
hook({
prepend: [
() => {
// my prepender
},
],
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#specify-custom-pattern-to-build-generic-names
//
hook({ generateScopedName: '[name]__[local]___[hash:base64:5]' });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#using-stylus-as-a-preprocessor
//
hook({
extensions: ['.styl'],
preprocessCss: (css: string, filepath: string) => {
// my preprocesser
},
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#tuning-options
//
hook({ /* my option */ });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#devmode-boolean
//
hook({ devMode: false });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#extensions-array
//
hook({ extensions: ['.scss', '.sass'] });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#ignore-functionregexstring
//
hook({ ignore: (file: string) => false });
hook({ ignore: 'unused' });
hook({ ignore: /\.test\.(css|scss|sass)/$ });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#preprocesscss-function
//
hook({ preprocessCss: (css: string, filepath: string) => css });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#processcss-function
//
hook({ processCss: (css: string, filepath: string) => css });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#processoropts-object
//
hook({
extensions: '.scss',
processorOpts: {
parser: () => {
// my parser
},
},
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#camelcase-boolean
//
hook({ camelCase: true });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#append-array
//
hook({
append: [
() => {
// another plugin
},
],
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#prepend-array
//
hook({
prepend: [
() => {
// again, another plugin
},
],
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#use-array
//
hook({
use: [
() => {
// they like plugins very much
},
],
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#createimportedname-function
//
hook({
createImportedName: (css: string, filepath: string) => {
// my import name creator
},
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#generatescopedname-stringfunction
//
hook({ generateScopedName: '[name]__[local]___[hash:base64:5]' });
hook({
generateScopedName: () => {
// should generate something
},
});
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#hashprefix-string
//
hook({ hashPrefix: 'awesome_' });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#mode-string
//
hook({ mode: 'global' });
hook({ mode: 'local' });
hook({ mode: 'pure' });
//
// https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#rootdir-string
//
hook({ rootDir: path.resolve('./my-folder') });

View File

@ -0,0 +1,43 @@
// Type definitions for css-modules-require-hook 4.0.3
// Project: https://github.com/css-modules/css-modules-require-hook
// Definitions by: Cedric van Putten <https://bycedric.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'css-modules-require-hook' {
interface Options {
/** Helps you to invalidate cache of all require calls. */
devMode?: boolean;
/** Attach the require hook to additional file extensions. */
extensions?: string | string[];
/** Provides possibility to exclude particular files from processing. */
ignore?: string | RegExp | ((filepath: string) => boolean);
/** In rare cases you may want to precompile styles, before they will be passed to the PostCSS pipeline. */
preprocessCss?: Function;
/** In rare cases you may want to get compiled styles in runtime, so providing this option helps. */
processCss?: Function;
/** Provides possibility to pass custom options to the LazyResult instance. */
processorOpts?: Object;
/** Camelizes exported class names. */
camelCase?: boolean;
/** Appends custom plugins to the end of the PostCSS pipeline. */
append?: any[];
/** Prepends custom plugins to the beginning of the PostCSS pipeline. */
prepend?: any[];
/** Provides the full list of PostCSS plugins to the pipeline. */
use?: any[];
/** Short alias for the postcss-modules-extract-imports plugin's createImportedName option. */
createImportedName?: Function;
/** Short alias for the postcss-modules-scope plugin's option. */
generateScopedName?: string | Function;
/** Short alias for the generic-names helper option. */
hashPrefix?: string;
/** Short alias for the postcss-modules-local-by-default plugin's option. */
mode?: string;
/** Provides absolute path to the project directory. */
rootDir?: string;
}
var requireHook: (options?: Options) => void;
export = requireHook;
}

View File

@ -0,0 +1,58 @@
/// <reference path='dateformat.d.ts' />
/**
* https://github.com/felixge/node-dateformat#usage
*/
import * as dateFormat from 'dateformat'
const now = new Date()
// Basic usage
dateFormat(now, 'dddd, mmmm dS, yyyy, h:MM:ss TT')
// Saturday, June 9th, 2007, 5:46:21 PM
// You can use one of several named masks
dateFormat(now, 'isoDateTime')
// 2007-06-09T17:46:21
// ...Or add your own
dateFormat.masks['hammerTime'] = `HH:MM! "Can't touch this!"`
dateFormat(now, 'hammerTime')
// 17:46! Can't touch this!
// When using the standalone dateFormat function,
// you can also provide the date as a string
dateFormat('Jun 9 2007', 'fullDate')
// Saturday, June 9, 2007
// Note that if you don't include the mask argument,
// dateFormat.masks.default is used
dateFormat(now)
// Sat Jun 09 2007 17:46:21
// And if you don't include the date argument,
// the current date and time is used
dateFormat()
// Sat Jun 09 2007 17:46:22
// You can also skip the date argument (as long as your mask doesn't
// contain any numbers), in which case the current date/time is used
dateFormat('longTime')
// 5:46:22 PM EST
// And finally, you can convert local time to UTC time. Simply pass in
// true as an additional argument (no argument skipping allowed in this case):
dateFormat(now, 'longTime', true)
// 10:46:21 PM UTC
// ...Or add the prefix 'UTC:' or 'GMT:' to your mask.
dateFormat(now, 'UTC:h:MM:ss TT Z')
// 10:46:21 PM UTC
// You can also get the ISO 8601 week of the year:
dateFormat(now, 'W')
// 42
// and also get the ISO 8601 numeric representation of the day of the week:
dateFormat(now, 'N')
// 6

77
dateformat/dateformat.d.ts vendored Normal file
View File

@ -0,0 +1,77 @@
// Type definitions for dateformat v1.0.12
// Project: https://github.com/felixge/node-dateformat
// Definitions by: Kombu <https://github.com/aicest>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* dateFormat.masks
*
* Predefined Formats
*
* https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L107
*/
interface DateFormatMasks {
default: string;
shortDate: string;
mediumDate: string;
longDate: string;
fullDate: string;
shortTime: string;
mediumTime: string;
longTime: string;
isoDate: string;
isoTime: string;
isoDateTime: string;
isoUtcDateTime: string;
expiresHeaderFormat: string;
[key: string]: string;
}
/**
* dateFormat.i18n
*
* Internationalization strings
*
* Example:
*
* ```
* dateFormat.i18n = {
* dayNames: [
* 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat',
* 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
* ],
* monthNames: [
* 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec',
* 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
* ]
* }
* ```
*
* https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L124
*/
interface DateFormatI18n {
dayNames: string[];
monthNames: string[];
}
/**
* dateFormat()
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*
* https://github.com/felixge/node-dateformat/blob/master/lib/dateformat.js#L18
*/
interface DateFormatStatic {
(date?: Date | string | number, mask?: string, utc?: boolean, gmt?: boolean): string;
(mask?: string, utc?: boolean, gmt?: boolean): string;
masks: DateFormatMasks;
i18n: DateFormatI18n;
}
declare module 'dateformat' {
const dateFormat: DateFormatStatic;
export = dateFormat;
}

File diff suppressed because it is too large Load Diff

599
dygraphs/dygraphs-tests.ts Normal file
View File

@ -0,0 +1,599 @@
// These tests are copied more or less directly from http://dygraphs.com/tests/
/// <reference path="dygraphs.d.ts" />
function demo() {
const g14 = new Dygraph(
document.getElementById("div_g14"),
'data', {
rollPeriod: 14,
errorBars: true,
labelsDivWidth: 100,
labelsDivStyles: {
'boxShadow': '4px 4px 4px #888'
},
labelsSeparateLines: true,
}
);
}
function twoAxes() {
var data = [] as number[][];
var g = new Dygraph(
document.getElementById("demodiv"),
data,
{
labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
series: {
'Y3': {
axis: 'y2'
},
'Y4': {
axis: 'y2'
},
},
axes: {
y2: {
// set axis-related properties here
labelsKMB: true
},
y: {
axisLabelWidth: 60
}
},
ylabel: 'Primary y-axis',
y2label: 'Secondary y-axis',
}
);
var g2 = new Dygraph(
document.getElementById("demodiv_y2_primary"),
data,
{
labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
ylabel: 'Primary y-axis',
y2label: 'Secondary y-axis',
series : {
'Y3': {
axis: 'y2'
},
'Y4': {
axis: 'y2'
}
},
axes: {
y: {
// set axis-related properties here
drawGrid: false,
independentTicks: false
},
y2: {
// set axis-related properties here
labelsKMB: true,
drawGrid: true,
independentTicks: true
}
}
}
);
var g3 = new Dygraph(
document.getElementById("demodiv_two_grids"),
data,
{
labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
ylabel: 'Primary y-axis',
y2label: 'Secondary y-axis',
series : {
'Y3': {
axis: 'y2'
},
'Y4': {
axis: 'y2'
}
},
axes: {
y2: {
// set axis-related properties here
labelsKMB: true,
drawGrid: true,
independentTicks: true,
gridLinePattern: [2,2]
}
}
}
);
var g4 = new Dygraph(
document.getElementById("demodiv_one"),
data,
{
labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
labelsKMB: true,
ylabel: 'Primary y-axis',
y2label: 'Secondary y-axis',
}
);
var g5 = new Dygraph(
document.getElementById("demodiv_one_right"),
data,
{
labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
ylabel: 'Primary y-axis',
y2label: 'Secondary y-axis',
series : {
'Y1': {
axis: 'y2'
},
'Y2': {
axis: 'y2'
},
'Y3': {
axis: 'y2'
},
'Y4': {
axis: 'y2'
}
},
axes: {
y: {
// set axis-related properties here
drawGrid: false,
independentTicks: false
},
y2: {
// set axis-related properties here
labelsKMB: true,
drawGrid: true,
independentTicks: true
}
}
}
);
function update(el: HTMLInputElement) {
g.updateOptions( { fillGraph: el.checked } );
g2.updateOptions( { fillGraph: el.checked } );
g3.updateOptions( { fillGraph: el.checked } );
g4.updateOptions( { fillGraph: el.checked } );
g5.updateOptions( { fillGraph: el.checked } );
}
}
function perSeries() {
var data = '1234';
var g = new Dygraph(
document.getElementById("demodiv"),
data,
{
strokeWidth: 2,
series : {
'parabola': {
strokeWidth: 0.0,
drawPoints: true,
pointSize: 4,
highlightCircleSize: 6
},
'line': {
strokeWidth: 1.0,
drawPoints: true,
pointSize: 1.5
},
'sine wave': {
strokeWidth: 3,
highlightCircleSize: 10
},
'sine wave2': {
strokePattern: [10, 2, 5, 2],
strokeWidth: 2,
highlightCircleSize: 3
}
}
}
);
var g2 = new Dygraph(
document.getElementById("demodiv2"),
data,
{
legend: 'always',
strokeWidth: 2,
series: {
'parabola': {
strokePattern: null,
drawPoints: true,
pointSize: 4,
highlightCircleSize: 6
},
'line': {
strokePattern: Dygraph.DASHED_LINE,
strokeWidth: 1.0,
drawPoints: true,
pointSize: 1.5
},
'another line': {
strokePattern: [25, 5]
},
'sine wave': {
strokePattern: Dygraph.DOTTED_LINE,
strokeWidth: 3,
highlightCircleSize: 10
},
'sine wave2': {
strokePattern: Dygraph.DOT_DASH_LINE,
strokeWidth: 2,
highlightCircleSize: 3
}
}
}
);
var g3 = new Dygraph(
document.getElementById("demodiv3"),
data,
{
strokeWidth: 2,
series: {
'parabola': {
strokeWidth: 0.0,
drawPoints: true,
pointSize: 4,
highlightCircleSize: 6
},
'line': {
strokeWidth: 1.0,
drawPoints: true,
pointSize: 1.5
},
'sine wave': {
strokeWidth: 3,
highlightCircleSize: 10
},
'sine wave2': {
strokePattern: [10, 2, 5, 2],
strokeWidth: 2,
highlightCircleSize: 3
}
}
}
);
}
function highlightedRegion() {
var highlight_start = 0, highlight_end = 0;
var g = new Dygraph(
document.getElementById("div_g"),
[],
{
labels: ['X', 'Est.', 'Actual'],
animatedZooms: true,
underlayCallback: function(canvas, area, g) {
var bottom_left = g.toDomCoords(highlight_start, -20);
var top_right = g.toDomCoords(highlight_end, +20);
var left = bottom_left[0];
var right = top_right[0];
canvas.fillStyle = "rgba(255, 255, 102, 1.0)";
canvas.fillRect(left, area.y, right - left, area.h);
}
}
);
}
function makeGraph(className: string, numSeries: number, numRows: number, isStacked: boolean) {
var div = document.createElement('div');
div.className = className;
div.style.display = 'inline-block';
document.body.appendChild(div);
var labels = ['x'];
for (var i = 0; i < numSeries; ++i) {
var label = '' + i;
label = 's' + '000'.substr(label.length) + label;
labels[i + 1] = label;
}
var g = new Dygraph(
div,
'data',
{
width: 480,
height: 320,
labels: labels.slice(),
stackedGraph: isStacked,
highlightCircleSize: 2,
strokeWidth: 1,
strokeBorderWidth: isStacked ? null : 1,
highlightSeriesOpts: {
strokeWidth: 3,
strokeBorderWidth: 1,
highlightCircleSize: 5,
},
});
g.setSelection(false, 's005');
};
function linearRegressionAddSeries() {
var labels = ['X', 'Y1', 'Y2'];
var orig_colors = [] as string[];
var g = new Dygraph(
document.getElementById("demodiv"),
'data',
{
labels: labels,
drawPoints: true,
strokeWidth: 0.0,
drawCallback: function(g, is_initial) {
if (!is_initial) return;
var c = g.getColors();
for (var i = 0; i < c.length; i++) orig_colors.push(c[i]);
}
}
);
}
function callbacks() {
var s = document.getElementById("status");
var g: Dygraph = null;
var pts_info = function(e: MouseEvent, x: number, pts: dygraphs.Point[], row?: number) {
var str = "(" + x + ") ";
for (var i = 0; i < pts.length; i++) {
var p = pts[i];
if (i) str += ", ";
str += p.name + ": " + p.yval;
}
var x = e.offsetX;
var y = e.offsetY;
var dataXY = g.toDataCoords(x, y);
str += ", (" + x + ", " + y + ")";
str += " -> (" + dataXY[0] + ", " + dataXY[1] + ")";
str += ", row #"+row;
return str;
};
g = new Dygraph(
document.getElementById("div_g"),
'NoisyData', {
rollPeriod: 7,
showRoller: true,
errorBars: true,
highlightCallback: function(e, x, pts, row) {
s.innerHTML += "<b>Highlight</b> " + pts_info(e,x,pts,row) + "<br/>";
},
unhighlightCallback: function(e) {
s.innerHTML += "<b>Unhighlight</b><br/>";
},
clickCallback: function(e, x, pts) {
s.innerHTML += "<b>Click</b> " + pts_info(e,x,pts) + "<br/>";
},
pointClickCallback: function(e, p) {
s.innerHTML += "<b>Point Click</b> " + p.name + ": " + p.x + "<br/>";
},
zoomCallback: function(minX, maxX, yRanges) {
s.innerHTML += "<b>Zoom</b> [" + minX + ", " + maxX + ", [" + yRanges + "]]<br/>";
},
drawCallback: function(g) {
s.innerHTML += "<b>Draw</b> [" + g.xAxisRange() + "]<br/>";
}
}
);
}
function valueAxisFormatters() {
function formatDate(d: Date) {
var yyyy = d.getFullYear(),
mm = d.getMonth() + 1,
dd = d.getDate();
return yyyy + '-' + (mm < 10 ? '0' : '') + mm + (dd < 10 ? '0' : '') + dd;
}
var g = new Dygraph(
document.getElementById("demodiv"),
'data',
{
labels: [ 'Date', 'Y1', 'Y2', 'Y3', 'Y4' ],
width: 640,
height: 350,
series: {
'Y3': { axis: 'y2' },
'Y4': { axis: 'y2' }
},
axes: {
x: {
valueFormatter: function(ms) {
return 'xvf(' + formatDate(new Date(ms)) + ')';
},
axisLabelFormatter: function(d: Date) {
return 'xalf(' + formatDate(d) + ')';
},
pixelsPerLabel: 100,
axisLabelWidth: 100,
},
y: {
valueFormatter: function(y) {
return 'yvf(' + y.toPrecision(2) + ')';
},
axisLabelFormatter: function(y: number) {
return 'yalf(' + y.toPrecision(2) + ')';
},
axisLabelWidth: 100,
},
y2: {
valueFormatter: function(y2) {
return 'y2vf(' + y2.toPrecision(2) + ')';
},
axisLabelFormatter: function(y2: number) {
return 'y2alf(' + y2.toPrecision(2) + ')';
}
}
}
});
}
function annotation() {
var eventDiv = document.getElementById("events");
function nameAnnotation(ann: dygraphs.Annotation) {
return "(" + ann.series + ", " + ann.x + ")";
}
var annotations = [] as dygraphs.Annotation[];
var graph_initialized = false;
var g = new Dygraph(
document.getElementById("g_div"),
function() {
var zp = function(x: number) { if (x < 10) return "0"+x; else return ''+x; };
var r = "date,parabola,line,another line,sine wave\n";
for (var i=1; i<=31; i++) {
r += "200610" + zp(i);
r += "," + 10*(i*(31-i));
r += "," + 10*(8*i);
r += "," + 10*(250 - 8*i);
r += "," + 10*(125 + 125 * Math.sin(0.3*i));
r += "\n";
}
return r;
},
{
rollPeriod: 1,
showRoller: true,
width: 480,
height: 320,
drawCallback: function(g, is_initial) {
if (is_initial) {
graph_initialized = true;
if (annotations.length > 0) {
g.setAnnotations(annotations);
}
}
var ann = g.annotations();
var html = "";
for (var i = 0; i < ann.length; i++) {
var name = nameAnnotation(ann[i]);
html += "<span id='" + name + "'>"
html += name + ": " + (ann[i].shortText || '(icon)')
html += " -> " + ann[i].text + "</span><br/>";
}
document.getElementById("list").innerHTML = html;
}
}
);
var last_ann = 0;
for (var x = 10; x < 15; x += 2) {
annotations.push( {
series: 'sine wave',
x: "200610" + x,
shortText: '' + x,
text: 'Stock Market Crash ' + x
} );
last_ann = x;
}
annotations.push( {
series: 'another line',
x: "20061013",
icon: 'dollar.png',
width: 18,
height: 23,
tickHeight: 4,
text: 'Another one',
cssClass: 'annotation',
clickHandler: function() {
document.getElementById("events").innerHTML += "special handler<br/>";
}
} );
annotations.push( {
series: 'parabola',
x: '20061012',
shortText: 'P',
text: 'Parabola Annotation at same x-coord'
} );
if (graph_initialized) {
g.setAnnotations(annotations);
}
function add() {
var x = last_ann + 2;
var annnotations = g.annotations();
annotations.push({
series: 'line',
x: "200610" + x,
shortText: ''+x,
text: 'Line ' + x,
tickHeight: 10
} );
last_ann = x;
g.setAnnotations(annotations);
}
function bottom(el: HTMLInputElement) {
var to_bottom = true;
if (el.value != 'Shove to bottom') to_bottom = false;
var anns = g.annotations();
for (var i = 0; i < anns.length; i++) {
anns[i].attachAtBottom = to_bottom;
}
g.setAnnotations(anns);
if (to_bottom) {
el.value = 'Lift back up';
} else {
el.value = 'Shove to bottom';
}
}
var saveBg = '';
var num = 0;
g.updateOptions( {
annotationClickHandler: function(ann, point, dg, event) {
eventDiv.innerHTML += "click: " + nameAnnotation(ann) + "<br/>";
},
annotationDblClickHandler: function(ann, point, dg, event) {
eventDiv.innerHTML += "dblclick: " + nameAnnotation(ann) + "<br/>";
},
annotationMouseOverHandler: function(ann, point, dg, event) {
document.getElementById(nameAnnotation(ann)).style.fontWeight = 'bold';
saveBg = ann.div.style.backgroundColor;
ann.div.style.backgroundColor = '#ddd';
},
annotationMouseOutHandler: function(ann, point, dg, event) {
document.getElementById(nameAnnotation(ann)).style.fontWeight = 'normal';
ann.div.style.backgroundColor = saveBg;
},
pointClickCallback: function(event, p) {
// Check if the point is already annotated.
if (p.annotation) return;
// If not, add one.
var ann = {
series: p.name,
xval: p.xval,
shortText: '' + num,
text: "Annotation #" + num
};
var anns = g.annotations();
anns.push(ann);
g.setAnnotations(anns);
num++;
}
});
}

1270
dygraphs/dygraphs.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

2
empower/index.d.ts vendored
View File

@ -1,4 +1,4 @@
// Type definitions for empower
// Type definitions for empower 1.2.1
// Project: https://github.com/twada/empower
// Definitions by: vvakame <https://github.com/vvakame>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

View File

@ -2130,6 +2130,7 @@ declare enum TokenFlag {
SO_PIN_FINAL_TRY,
SO_PIN_LOCKED,
SO_PIN_TO_BE_CHANGED,
ERROR_STATE,
}
declare class Token extends HandleObject {

2
kue/index.d.ts vendored
View File

@ -83,7 +83,7 @@ export declare class Job extends events.EventEmitter {
delay(ms: number | Date): Job;
removeOnComplete(param: any): void;
backoff(param: any): void;
ttl(param: any): void;
ttl(param: any): Job;
private _getBackoffImpl(): void;
priority(level: string | number): Job;
attempt(fn: Function): Job;

19
logat/logat-tests.ts Normal file
View File

@ -0,0 +1,19 @@
/// <reference path="logat.d.ts" />
import logat = require('logat');
logat.on('LogConfigError', function(err: any){
})
logat.error('This is error');
logat.error( new Error('This is error instance') );
logat.error( String('object1'), String('object2') );
logat.warn('This is warn');
logat.info('This is info');
logat.debug('This is debug');
logat.setOptions( {
logLevel: 4,
logMethod: 1
});
logat.getOptions();

26
logat/logat.d.ts vendored Normal file
View File

@ -0,0 +1,26 @@
// Type definitions for logat 1.x.x
// Project: https://github.com/krvikash35/logat
// Definitions by: Vikash <https://github.com/krvikash35/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../node/node.d.ts" />
declare module 'logat'{
interface LogOptionsI {
logLevel?: number,
logMethod?: number,
logFileName?: string
}
class Logger extends NodeJS.EventEmitter {
error(...args: any[]): void;
warn(...args: any[]): void;
info(...args: any[]): void;
debug(...args: any[]): void;
getOptions(): LogOptionsI;
setOptions(options: LogOptionsI): void;
}
export = new Logger();
}

View File

@ -20,6 +20,6 @@ declare namespace e {
}
declare function e(getter?: string, options?: e.MethodOverrideOptions): express.RequestHandler;
declare function e(getter?: (req: express.Request, res: express.Response) => string, options?: e.MethodOverrideOptions): express.RequestHandler;
declare function e(getter?: string | ((req: express.Request, res: express.Response) => string), options?: e.MethodOverrideOptions): express.RequestHandler;
export = e;

27
node/index.d.ts vendored
View File

@ -817,6 +817,14 @@ declare module "cluster" {
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
addListener(event: "online", listener: () => void): this;
emit(event: string, listener: Function): boolean
emit(event: "disconnect", listener: () => void): boolean
emit(event: "error", listener: (code: number, signal: string) => void): boolean
emit(event: "exit", listener: (code: number, signal: string) => void): boolean
emit(event: "listening", listener: (address: Address) => void): boolean
emit(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): boolean
emit(event: "online", listener: () => void): boolean
on(event: string, listener: Function): this;
on(event: "disconnect", listener: () => void): this;
on(event: "error", listener: (code: number, signal: string) => void): this;
@ -883,6 +891,15 @@ declare module "cluster" {
addListener(event: "online", listener: (worker: Worker) => void): this;
addListener(event: "setup", listener: (settings: any) => void): this;
emit(event: string, listener: Function): boolean;
emit(event: "disconnect", listener: (worker: Worker) => void): boolean;
emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean;
emit(event: "fork", listener: (worker: Worker) => void): boolean;
emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean;
emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean;
emit(event: "online", listener: (worker: Worker) => void): boolean;
emit(event: "setup", listener: (settings: any) => void): boolean;
on(event: string, listener: Function): this;
on(event: "disconnect", listener: (worker: Worker) => void): this;
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
@ -952,6 +969,15 @@ declare module "cluster" {
export function addListener(event: "online", listener: (worker: Worker) => void): Cluster;
export function addListener(event: "setup", listener: (settings: any) => void): Cluster;
export function emit(event: string, listener: Function): boolean;
export function emit(event: "disconnect", listener: (worker: Worker) => void): boolean;
export function emit(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): boolean;
export function emit(event: "fork", listener: (worker: Worker) => void): boolean;
export function emit(event: "listening", listener: (worker: Worker, address: Address) => void): boolean;
export function emit(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): boolean;
export function emit(event: "online", listener: (worker: Worker) => void): boolean;
export function emit(event: "setup", listener: (settings: any) => void): boolean;
export function on(event: string, listener: Function): Cluster;
export function on(event: "disconnect", listener: (worker: Worker) => void): Cluster;
export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): Cluster;
@ -975,7 +1001,6 @@ declare module "cluster" {
export function setMaxListeners(n: number): Cluster;
export function getMaxListeners(): number;
export function listeners(event: string): Function[];
export function emit(event: string, ...args: any[]): boolean;
export function listenerCount(type: string): number;
export function prependListener(event: string, listener: Function): Cluster;

View File

@ -0,0 +1,42 @@
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="perfect-scrollbar.d.ts" />
/**
* https://github.com/noraesae/perfect-scrollbar#how-to-use
*/
import * as Ps from 'perfect-scrollbar'
const container = document.body
// To initialise the plugin, `Ps.initialize` is used.
Ps.initialize(container)
// It can be initialised with optional parameters.
Ps.initialize(container, {
wheelSpeed: 2,
wheelPropagation: true,
minScrollbarLength: 20
})
// If the size of your container or content changes, call `update`.
Ps.update(container)
// If you want to destroy the scrollbar, use `destroy`.
Ps.destroy(container)
// If you want to scroll to somewhere, just use a `scrollTop` property and update.
container.scrollTop = 0
Ps.update(container)
/**
* https://github.com/noraesae/perfect-scrollbar#jquery
*/
import * as $ from 'jquery'
import mountJQuery = require('perfect-scrollbar/jquery')
mountJQuery($)
$('#container').perfectScrollbar() // Initialize
$('#container').perfectScrollbar({ /*...*/ }) // with options
$('#container').perfectScrollbar('update') // Update
$('#container').perfectScrollbar('destroy') // Destroy

134
perfect-scrollbar/perfect-scrollbar.d.ts vendored Normal file
View File

@ -0,0 +1,134 @@
// Type definitions for perfect-scrollbar v0.6.12
// Project: https://github.com/noraesae/perfect-scrollbar
// Definitions by: Kombu <https://github.com/aicest>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
/**
* https://github.com/noraesae/perfect-scrollbar/blob/master/src/js/plugin/default-setting.js#L3
* https://github.com/noraesae/perfect-scrollbar#optional-parameters
*/
interface PerfectScrollbarSettings {
/**
* It is a list of handlers to use to scroll the element.
* https://github.com/noraesae/perfect-scrollbar#handlers
* https://github.com/noraesae/perfect-scrollbar/blob/master/src/js/plugin/initialize.js#L9
*/
handlers?: ('click-rail' |
'drag-scrollbar' |
'keyboard' |
'wheel' |
'touch' |
'selection')[];
/**
* When set to an integer value, the thumb part of the scrollbar will not expand over that number of pixels.
* https://github.com/noraesae/perfect-scrollbar#maxscrollbarlength
*/
maxScrollbarLength?: number;
/**
* When set to an integer value, the thumb part of the scrollbar will not shrink below that number of pixels.
* https://github.com/noraesae/perfect-scrollbar#minscrollbarlength
*/
minScrollbarLength?: number;
/**
* The number of pixels the content width can surpass the container width without enabling the X axis scroll bar.
* Allows some "wiggle room" or "offset break", so that X axis scroll bar is not enabled just because of a few pixels.
* https://github.com/noraesae/perfect-scrollbar#scrollxmarginoffset
*/
scrollXMarginOffset?: number;
/**
* The number of pixels the content height can surpass the container height without enabling the Y axis scroll bar.
* Allows some "wiggle room" or "offset break", so that Y axis scroll bar is not enabled just because of a few pixels.
* https://github.com/noraesae/perfect-scrollbar#scrollymarginoffset
*/
scrollYMarginOffset?: number;
/**
* When set to false, when clicking on a rail, the click event will be allowed to propagate.
* https://github.com/noraesae/perfect-scrollbar#stoppropagationonclick
*/
stopPropagationOnClick?: boolean;
/**
* When set to true, the scroll bar in X axis will not be available, regardless of the content width.
* https://github.com/noraesae/perfect-scrollbar#suppressscrollx
*/
suppressScrollX?: boolean;
/**
* When set to true, the scroll bar in Y axis will not be available, regardless of the content height.
* https://github.com/noraesae/perfect-scrollbar#suppressscrolly
*/
suppressScrollY?: boolean;
/**
* If this option is true, when the scroll reaches the end of the side, touch scrolling will be propagated to parent element.
* https://github.com/noraesae/perfect-scrollbar#swipepropagation
*/
swipePropagation?: boolean;
/**
* When set to true, and only one (vertical or horizontal) scrollbar is visible then both vertical and horizontal scrolling will affect the scrollbar.
* https://github.com/noraesae/perfect-scrollbar#usebothwheelaxes
*/
useBothWheelAxes?: boolean;
/**
* If this option is true, when the scroll reaches the end of the side, mousewheel event will be propagated to parent element.
* https://github.com/noraesae/perfect-scrollbar#wheelpropagation
*/
wheelPropagation?: boolean;
/**
* The scroll speed applied to mousewheel event.
* https://github.com/noraesae/perfect-scrollbar#wheelspeed
*/
wheelSpeed?: number;
/**
* A string.
* It's a class name added to the container element.
* The class name is prepended with `ps-theme-`.
* So default theme class name is `ps-theme-default`.
* In order to create custom themes with scss use `ps-container($theme)` mixin, where `$theme` is a scss map.
* https://github.com/noraesae/perfect-scrollbar#theme
*/
theme?: string;
}
declare module 'perfect-scrollbar' {
/**
* https://github.com/noraesae/perfect-scrollbar/blob/master/src/js/plugin/initialize.js#L19
*/
export function initialize(element: HTMLElement, settings?: PerfectScrollbarSettings): void;
/**
* https://github.com/noraesae/perfect-scrollbar/blob/master/src/js/plugin/update.js#L9
*/
export function update(element: HTMLElement): void;
/**
* https://github.com/noraesae/perfect-scrollbar/blob/master/src/js/plugin/destroy.js#L7
*/
export function destroy(element: HTMLElement): void;
}
interface JQuery {
/**
* https://github.com/noraesae/perfect-scrollbar/blob/master/src/js/adaptor/jquery.js#L6
*/
perfectScrollbar(settingOrCommand?: PerfectScrollbarSettings | 'update' | 'destroy'): JQuery;
}
declare module 'perfect-scrollbar/jquery' {
function mountJQuery(jQuery: JQueryStatic): void;
export = mountJQuery;
}

5
pkcs11js/index.d.ts vendored
View File

@ -208,7 +208,7 @@ export class PKCS11 {
* @param {Handle} slot ID of token's slot
* @returns {Handle[]} Gets mech. array
*/
C_GetMechanismList(slot: Handle): number[];
C_GetMechanismList(slot: Handle): Handle[];
/**
* Obtains information about a particular mechanism possibly supported by a token
*
@ -216,7 +216,7 @@ export class PKCS11 {
* @param {Handle} mech Type of mechanism
* @returns {MechanismInfo} Receives mechanism info
*/
C_GetMechanismInfo(slot: Handle, mech: number): MechanismInfo;
C_GetMechanismInfo(slot: Handle, mech: Handle): MechanismInfo;
/* Session management */
@ -1190,6 +1190,7 @@ declare const CKF_GENERATE_KEY_PAIR: number;
declare const CKF_WRAP: number;
declare const CKF_UNWRAP: number;
declare const CKF_DERIVE: number;
declare const CKF_CLOCK_ON_TOKEN: number;
// Certificates
declare const CKC_X_509: number;

View File

@ -1,4 +1,4 @@
// Type definitions for power-assert-formatter
// Type definitions for power-assert-formatter 1.4.1
// Project: https://github.com/twada/power-assert-formatter
// Definitions by: vvakame <https://github.com/vvakame>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

View File

@ -1,4 +1,4 @@
// Type definitions for power-assert
// Type definitions for power-assert 1.4.1
// Project: https://github.com/twada/power-assert
// Definitions by: vvakame <https://github.com/vvakame>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

6
sinon/index.d.ts vendored
View File

@ -3,6 +3,12 @@
// Definitions by: William Sears <https://github.com/mrbigdog2u>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// sinon uses DOM dependencies which are absent in browserless envoronment like node.js
// to avoid compiler errors this monkey patch is used
// see more details in https://github.com/DefinitelyTyped/DefinitelyTyped/issues/11351
interface Event { }
interface Document { }
declare namespace Sinon {
interface SinonSpyCallApi {
// Properties

39
validator/index.d.ts vendored
View File

@ -6,7 +6,8 @@
declare namespace ValidatorJS {
type AlphaLocale = "ar" | "ar-AE" | "ar-BH" | "ar-DZ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MA" | "ar-QA" | "ar-QM" | "ar-SA" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-YE" | "cs-CZ" | "de-DE" | "en-AU" | "en-GB" | "en-HK" | "en-IN" | "en-NZ" | "en-US" | "en-ZA" | "en-ZM" | "es-ES" | "fr-FR" | "hu-HU" | "nl-NL" | "pl-PL" | "pt-BR" | "pt-PT" | "ru-RU" | "sr-RS" | "sr-RS@latin" | "tr-TR";
type AlphanumericLocale = "ar" | "ar-AE" | "ar-BH" | "ar-DZ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MA" | "ar-QA" | "ar-QM" | "ar-SA" | "ar-SD" | "ar-SY" | "ar-TN" | "ar-YE" | "cs-CZ" | "de-DE" | "en-AU" | "en-GB" | "en-HK" | "en-IN" | "en-NZ" | "en-US" | "en-ZA" | "en-ZM" | "es-ES" | "fr-FR" | "fr-BE" | "hu-HU" | "nl-BE" | "nl-NL" | "pl-PL" | "pt-BR" | "pt-PT" | "ru-RU" | "sr-RS" | "sr-RS@latin" | "tr-TR";
type MobilePhoneLocale = "ar-DZ" | "ar-SA" | "ar-SY" | "cs-CZ" | "de-DE" | "da-DK" | "el-GR" | "en-AU" | "en-GB" | "en-HK" | "en-IN" | "en-NZ" | "en-US" | "en-CA" | "en-ZA" | "en-ZM" | "es-ES" | "fi-FI" | "fr-FR" | "hu-HU" | "it-IT" | "ja-JP" | "ms-MY" | "nb-NO" | "nn-NO" | "pl-PL" | "pt-PT" | "ru-RU" | "sr-RS" | "tr-TR" | "vi-VN" | "zh-CN" | "zh-TW"
interface ValidatorStatic {
// **************
@ -17,7 +18,7 @@ declare namespace ValidatorJS {
contains(str: string, elem: any): boolean;
// check if the string matches the comparison.
equals(str: string, comparison: any): boolean;
equals(str: string, comparison: string): boolean;
// check if the string is a date that's after the specified date (defaults to now).
isAfter(str: string, date?: string): boolean;
@ -130,7 +131,7 @@ declare namespace ValidatorJS {
// 'en-IN', 'en-NZ', 'en-US', 'en-CA', 'en-ZA', 'en-ZM', 'es-ES', 'fi-FI', 'fr-FR', 'hu-HU',
// 'it-IT', 'ja-JP', 'ms-MY', 'nb-NO', 'nn-NO', 'pl-PL', 'pt-PT', 'ru-RU', 'sr-RS', 'tr-TR',
// 'vi-VN', 'zh-CN', 'zh-TW']).
isMobilePhone(str: string, locale: string): boolean;
isMobilePhone(str: string, locale: MobilePhoneLocale): boolean;
// check if the string is a valid hex-encoded representation of a MongoDB ObjectId
// (http://docs.mongodb.org/manual/reference/object-id/).
@ -152,7 +153,7 @@ declare namespace ValidatorJS {
isURL(str: string, options?: IsURLOptions): boolean;
// check if the string is a UUID. Must be one of ['3', '4', '5', 'all'], default is all.
isUUID(str: string, version?: string|number): boolean;
isUUID(str: string, version?: string | number): boolean;
// check if the string is uppercase.
isUppercase(str: string): boolean;
@ -161,10 +162,10 @@ declare namespace ValidatorJS {
isVariableWidth(str: string): boolean;
// checks characters if they appear in the whitelist.
isWhitelisted(str: string, chars: string|string[]): boolean;
isWhitelisted(str: string, chars: string | string[]): boolean;
// check if string matches the pattern.
matches(str: string, pattern: RegExp|string, modifiers?: string): boolean;
matches(str: string, pattern: RegExp | string, modifiers?: string): boolean;
// **************
// * Sanitizers *
@ -181,13 +182,13 @@ declare namespace ValidatorJS {
unescape(input: string): string;
// trim characters from the left-side of the input.
ltrim(input: any, chars?: string): string;
ltrim(input: string, chars?: string): string;
// canonicalize an email address.
normalizeEmail(email: string, options?: NormalizeEmailOptions): string;
// trim characters from the right-side of the input.
rtrim(input: any, chars?: string): string;
rtrim(input: string, chars?: string): string;
// remove characters with a numerical value < 32 and 127, mostly control characters. If keep_new_lines is true,
// newline characters are preserved (\n and \r, hex 0xA and 0xD). Unicode-safe in JavaScript.
@ -195,19 +196,19 @@ declare namespace ValidatorJS {
// convert the input to a boolean. Everything except for '0', 'false' and '' returns true. In strict mode only '1'
// and 'true' return true.
toBoolean(input: any, strict?: boolean): boolean;
toBoolean(input: string, strict?: boolean): boolean;
// convert the input to a date, or null if the input is not a date.
toDate(input: any): Date; // Date or null
toDate(input: string): Date; // Date or null
// convert the input to a float, or NaN if the input is not a float.
toFloat(input: any): number; // number or NaN
toFloat(input: string): number; // number or NaN
// convert the input to an integer, or NaN if the input is not an integer.
toInt(input: any, radix?: number): number; // number or NaN
toInt(input: string, radix?: number): number; // number or NaN
// trim characters (whitespace by default) from both sides of the input.
trim(input: any, chars?: string): string;
trim(input: string, chars?: string): string;
// remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will
// need to escape some chars, e.g. whitelist(input, '\\[\\]').
@ -284,8 +285,8 @@ declare namespace ValidatorJS {
require_host: boolean;
require_valid_protocol?: boolean;
allow_underscores?: boolean;
host_whitelist?: (string|RegExp)[];
host_blacklist?: (string|RegExp)[];
host_whitelist?: (string | RegExp)[];
host_blacklist?: (string | RegExp)[];
allow_trailing_dot?: boolean;
allow_protocol_relative_urls?: boolean;
}
@ -304,7 +305,7 @@ declare module "validator" {
}
// deprecated interfaces for backward compatibility, please use ValidatorJS.* instead the ones
interface IValidatorStatic extends ValidatorJS.ValidatorStatic {}
interface IURLoptions extends ValidatorJS.IsURLOptions {}
interface IFQDNoptions extends ValidatorJS.IsFQDNOptions {}
interface IEmailoptions extends ValidatorJS.NormalizeEmailOptions {}
interface IValidatorStatic extends ValidatorJS.ValidatorStatic { }
interface IURLoptions extends ValidatorJS.IsURLOptions { }
interface IFQDNoptions extends ValidatorJS.IsFQDNOptions { }
interface IEmailoptions extends ValidatorJS.NormalizeEmailOptions { }

View File

@ -178,7 +178,39 @@ let any: any;
result = validator.isMD5('sample');
result = validator.isMobilePhone('sample', 'ar-DZ');
result = validator.isMobilePhone('sample', 'ar-SA');
result = validator.isMobilePhone('sample', 'ar-SY');
result = validator.isMobilePhone('sample', 'cs-CZ');
result = validator.isMobilePhone('sample', 'de-DE');
result = validator.isMobilePhone('sample', 'da-DK');
result = validator.isMobilePhone('sample', 'el-GR');
result = validator.isMobilePhone('sample', 'en-AU');
result = validator.isMobilePhone('sample', 'en-GB');
result = validator.isMobilePhone('sample', 'en-HK');
result = validator.isMobilePhone('sample', 'en-IN');
result = validator.isMobilePhone('sample', 'en-NZ');
result = validator.isMobilePhone('sample', 'en-US');
result = validator.isMobilePhone('sample', 'en-CA');
result = validator.isMobilePhone('sample', 'en-ZA');
result = validator.isMobilePhone('sample', 'en-ZM');
result = validator.isMobilePhone('sample', 'es-ES');
result = validator.isMobilePhone('sample', 'fi-FI');
result = validator.isMobilePhone('sample', 'fr-FR');
result = validator.isMobilePhone('sample', 'hu-HU');
result = validator.isMobilePhone('sample', 'it-IT');
result = validator.isMobilePhone('sample', 'ja-JP');
result = validator.isMobilePhone('sample', 'ms-MY');
result = validator.isMobilePhone('sample', 'nb-NO');
result = validator.isMobilePhone('sample', 'nn-NO');
result = validator.isMobilePhone('sample', 'pl-PL');
result = validator.isMobilePhone('sample', 'pt-PT');
result = validator.isMobilePhone('sample', 'ru-RU');
result = validator.isMobilePhone('sample', 'sr-RS');
result = validator.isMobilePhone('sample', 'tr-TR');
result = validator.isMobilePhone('sample', 'vi-VN');
result = validator.isMobilePhone('sample', 'zh-CN');
result = validator.isMobilePhone('sample', 'zh-TW');
result = validator.isMongoId('sample');

5
vinyl/index.d.ts vendored
View File

@ -145,6 +145,11 @@ declare class File {
* Checks if a given object is a vinyl file.
*/
public static isVinyl(obj: any): boolean;
/**
* Checks if a property is not managed internally.
*/
public static isCustomProp(name: string): boolean;
}
export = File;

View File

@ -119,6 +119,31 @@ describe('File', () => {
});
describe('File.isVinyl()', () => {
it('should return true when an object is a Vinyl file', done => {
var file = new File();
File.isVinyl(file).should.equal(true);
done();
});
it('should return false when an object is not a Vinyl file', done => {
File.isVinyl({}).should.equal(false);
done();
});
});
describe('File.isCustomProp()', () => {
it('should return true when a File property is not managed internally', done => {
File.isCustomProp('foobar').should.equal(true);
done();
});
it('should return false when a File property is managed internally', done => {
File.isCustomProp('cwd').should.equal(false);
done();
});
});
describe('isBuffer()', () => {
it('should return true when the contents are a Buffer', done => {
var val = new Buffer("test");

116
yayson/yayson-tests.ts Normal file
View File

@ -0,0 +1,116 @@
/// <reference path="yayson.d.ts" />
import * as Yayson from "yayson";
const yayson = Yayson({ adapter: 'default' }) || Yayson({ adapter: 'sequelize' }) || Yayson();
const Adapter = yayson.Adapter;
const Store = yayson.Store;
const Presenter = yayson.Presenter;
interface Thing {
hello: 'world' | 'you';
}
function test_store() {
const store = new Store();
store.sync('some string').toString();
store.sync(1234).toString();
store.sync({ any: 'thing' }).toString();
store.find('mytype', '1234').toString();
<[]> store.findAll('mytype');
store.remove('mytype', '1234');
store.remove('mytype');
store.reset();
<Yayson.Record[]> store.records;
store.records[0].attributes.toString();
store.records[0].id.toString();
store.records[0].relationships.toString();
<string> store.records[0].type;
store.relations['something'];
}
function test_presenter_static() {
Presenter.render('something').toString();
Presenter.render({}).toString();
Presenter.render({}, { meta: {} }).toString();
<[]> Presenter.render([]);
<[]> Presenter.render([], { meta: {} });
const promiseNum: PromiseLike<number> = null;
Presenter.render(promiseNum).then(data => data.toExponential());
Presenter.render(promiseNum, { meta: { so: 'meta' } }).then(data => data.toExponential());
Presenter.toJSON({ any: 'thing' }).toString();
Presenter.toJSON({ other: 'thing' }, { meta: { so: 'meta' } }).toString();
}
function test_presenter_instance() {
const presenter = new Presenter();
presenter.render({}).toString();
presenter.render({}, { meta: {} }).toString();
<[]> presenter.render([]);
<[]> presenter.render([], { meta: {} });
const promiseNum: PromiseLike<number> = null;
presenter.render(promiseNum).then(data => data.toExponential());
presenter.render(promiseNum, { meta: { so: 'meta' } }).then(data => data.toExponential());
presenter.toJSON({ any: 'thing' }).toString();
presenter.toJSON({ other: 'thing' }, { meta: { so: 'meta' } }).toString();
}
function test_presenter_inheritance() {
class MotorPresenter extends Presenter {
type = 'motors';
relationships() {
return { car: CarPresenter }
};
selfLinks(instance: any) {
return '/cars/' + this.id(instance);
};
}
class CarPresenter extends Presenter {
type = 'cars'
relationships() {
return { motor: MotorPresenter }
};
}
const motor: { id: any; car: any } = {
id: 2,
car: null
}
const car = {
id: 1,
motor: motor
}
motor.car = car;
CarPresenter.toJSON(car).toString();
CarPresenter.toJSON(car, { meta: { so: 'meta' } }).toString();
CarPresenter.render({ id: 3 }).toString();
CarPresenter.render({ id: 3 }, { meta: { so: 'meta' } }).toString();
CarPresenter.render({ id: 3 }, { car: { id: 3 } }).toString();
}
function test_adapter() {
Adapter.get({ name: 'Abraham' }).toString();
Adapter.get({ name: 'Abraham' }, 'name').toString();
<string> Adapter.id({ id: 5 });
}

64
yayson/yayson.d.ts vendored Normal file
View File

@ -0,0 +1,64 @@
// Type definitions for yayson v2.0.1
// Project: https://github.com/confetti/yayson
// Definitions by: David Wood <https://github.com/Codesleuth>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'yayson' {
class Store {
sync(obj: {}): any;
find(type: string, id: string): any;
findAll(type: string): any[];
remove(type: string, id?: string): void;
reset(): void;
records: y.Record[];
relations: { [key: string]: any };
}
interface Adapter {
get(model: {}, key?: string): any;
id(model: {}): string;
}
class Presenter {
static adapter: string;
static render<T>(instanceOrCollection: PromiseLike<T>, options?: y.JsonOptions): PromiseLike<T>;
static render(instanceOrCollection: {}, options?: y.JsonOptions): any;
static toJSON(instanceOrCollection: {}, options?: y.JsonOptions): any;
render<T>(instanceOrCollection: PromiseLike<T>, options?: y.JsonOptions): PromiseLike<T>;
render(instanceOrCollection: {}, options?: y.JsonOptions): any;
toJSON(instanceOrCollection: {}, options?: y.JsonOptions): any;
id(instance: {}): string;
type: string;
}
interface Yayson {
Store: typeof Store;
Presenter: typeof Presenter;
Adapter: Adapter;
}
interface YaysonOptions {
adapter?: 'default' | 'sequelize';
}
function y(arg?: YaysonOptions): Yayson;
namespace y {
interface JsonOptions {
[key: string]: any;
meta?: {};
}
interface Record {
id: any;
type: string;
attributes: any;
relationships: any;
}
}
export = y;
}