Merge branch 'master' into update_react-leaflet

This commit is contained in:
Kanchalai Tanglertsampan
2017-05-04 16:03:59 -07:00
301 changed files with 30632 additions and 3409 deletions
+7
View File
@@ -89,6 +89,13 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
* Make changes. Remember to edit tests.
* You may also want to add yourself to "Definitions by" section of the package header.
- Do this by adding your name to the end of the line, as in `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
- Or if there are more people, it can be multiline
```typescript
// Definitions by: Alice <https://github.com/alice>
// Bob <https://github.com/bob>
// Steve <https://github.com/steve>
// John <https://github.com/john>
```
* `npm install -g typescript@2.0` and run `tsc`.
When you make a PR to edit an existing package, `dt-bot` should @-mention previous authors.
+6
View File
@@ -354,6 +354,12 @@
"sourceRepoURL": "https://github.com/blakeembrey/path-case",
"asOfVersion": "1.1.2"
},
{
"libraryName": "path-to-regexp",
"typingsPackageName": "path-to-regexp",
"sourceRepoURL": "https://github.com/pillarjs/path-to-regexp",
"asOfVersion": "1.7.0"
},
{
"libraryName": "pg-promise",
"typingsPackageName": "pg-promise",
+4 -4
View File
@@ -27,7 +27,7 @@ declare module 'angular' {
escapeToClose?: boolean;
resolve?: ResolveObject;
controllerAs?: string;
parent?: ((scope: ng.IScope, element: JQuery) => Element | JQuery) | string | Element | JQuery; // default: root node
parent?: ((scope: angular.IScope, element: JQuery) => Element | JQuery) | string | Element | JQuery; // default: root node
disableParentScroll?: boolean; // default: true
}
@@ -107,9 +107,9 @@ declare module 'angular' {
resolve?: ResolveObject;
controllerAs?: string;
parent?: string | Element | JQuery; // default: root node
onShowing?(scope: ng.IScope, element: JQuery): void;
onComplete?(scope: ng.IScope, element: JQuery): void;
onRemoving?(element: JQuery, removePromise: ng.IPromise<any>): void;
onShowing?(scope: angular.IScope, element: JQuery): void;
onComplete?(scope: angular.IScope, element: JQuery): void;
onRemoving?(element: JQuery, removePromise: angular.IPromise<any>): void;
skipHide?: boolean;
multiple?: boolean;
fullscreen?: boolean; // default: false
+72 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for Angular JS 1.6
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Georgii Dolzhykov <http://github.com/thorn0>
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Georgii Dolzhykov <http://github.com/thorn0>, Caleb St-Denis <https://github.com/calebstdenis>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery" />
@@ -1847,6 +1847,77 @@ declare namespace angular {
$postLink?(): void;
}
/**
* Interface for the $onInit lifecycle hook
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
*/
interface IOnInit {
/**
* Called on each controller after all the controllers on an element have been constructed and had their bindings
* initialized (and before the pre & post linking functions for the directives on this element). This is a good
* place to put initialization code for your controller.
*/
$onInit(): void;
}
/**
* Interface for the $doCheck lifecycle hook
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
*/
interface IDoCheck {
/**
* Called on each turn of the digest cycle. Provides an opportunity to detect and act on changes.
* Any actions that you wish to take in response to the changes that you detect must be invoked from this hook;
* implementing this has no effect on when `$onChanges` is called. For example, this hook could be useful if you wish
* to perform a deep equality check, or to check a `Dat`e object, changes to which would not be detected by Angular's
* change detector and thus not trigger `$onChanges`. This hook is invoked with no arguments; if detecting changes,
* you must store the previous value(s) for comparison to the current values.
*/
$doCheck(): void;
}
/**
* Interface for the $onChanges lifecycle hook
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
*/
interface IOnChanges {
/**
* Called whenever one-way bindings are updated. The onChangesObj is a hash whose keys are the names of the bound
* properties that have changed, and the values are an {@link IChangesObject} object of the form
* { currentValue, previousValue, isFirstChange() }. Use this hook to trigger updates within a component such as
* cloning the bound value to prevent accidental mutation of the outer value.
*/
$onChanges(onChangesObj: IOnChangesObject): void;
}
/**
* Interface for the $onDestroy lifecycle hook
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
*/
interface IOnDestroy {
/**
* Called on a controller when its containing scope is destroyed. Use this hook for releasing external resources,
* watches and event handlers.
*/
$onDestroy(): void;
}
/**
* Interface for the $postLink lifecycle hook
* https://docs.angularjs.org/api/ng/service/$compile#life-cycle-hooks
*/
interface IPostLink {
/**
* Called after this controller's element and its children have been linked. Similar to the post-link function this
* hook can be used to set up DOM event handlers and do direct DOM manipulation. Note that child elements that contain
* templateUrl directives will not have been compiled and linked since they are waiting for their template to load
* asynchronously and their own compilation and linking has been suspended until that occurs. This hook can be considered
* analogous to the ngAfterViewInit and ngAfterContentInit hooks in Angular 2. Since the compilation process is rather
* different in Angular 1 there is no direct mapping and care should be taken when upgrading.
*/
$postLink(): void;
}
interface IOnChangesObject {
[property: string]: IChangesObject<any>;
}
+1 -1
View File
@@ -17,4 +17,4 @@
"unified-signatures": false,
"void-return": false
}
}
}
+20 -10
View File
@@ -1,26 +1,36 @@
import Archiver = require('archiver');
import FS = require('fs');
import * as Archiver from 'archiver';
import * as fs from 'fs';
const archiver = Archiver.create('zip');
const writeStream = FS.createWriteStream('./archiver.d.ts');
const readStream = FS.createReadStream('./archiver.d.ts');
const writeStream = fs.createWriteStream('./archiver.d.ts');
const readStream = fs.createReadStream('./archiver.d.ts');
archiver.abort();
archiver.pipe(writeStream);
archiver.append(readStream, { name: 'archiver.d.ts' });
archiver.append(readStream, {name: 'archiver.d.ts'})
.append(readStream, {name: 'archiver.d.ts'});
archiver.bulk({ mappaing: {} });
archiver.directory('./path', './someOtherPath');
archiver.directory('./path', { name: "testName"} );
archiver.directory('./path', { name: "testName" });
archiver.directory('./', "", {});
archiver.directory('./', {name: 'test'}, {});
archiver.directory('./', { name: 'test' }, {});
archiver.append(readStream, {
name: "sub/folder.xml"
});
archiver.glob("**", {
cwd: 'path/to/files',
});
archiver.glob('./path', {}, {});
archiver.file('./path', { name: 'test' });
archiver.glob('./path', {}, {});
archiver.finalize();
archiver.setFormat('zip');
archiver.setModule(() => {});
@@ -28,4 +38,4 @@ archiver.setModule(() => {});
archiver.pointer();
archiver.use(() => {});
archiver.pipe(writeStream);
archiver.finalize();
+29 -13
View File
@@ -1,51 +1,67 @@
// Type definitions for archiver 1.3
// Project: https://github.com/archiverjs/node-archiver
// Definitions by: Esri <https://github.com/archiverjs/node-archiver>
// Definitions by: Esri <https://github.com/archiverjs/node-archiver>, Dolan Miu <https://github.com/dolanmiu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* =================== USAGE ===================
import Archiver = require('archiver);
var archiver = Archiver.create('zip');
archiver.pipe(FS.createWriteStream('xxx'));
archiver.append(FS.createReadStream('xxx'));
archiver.pipe(fs.createWriteStream('xxx'));
archiver.append(fs.createReadStream('xxx'));
archiver.finalize();
=============================================== */
/// <reference types="node" />
import * as FS from 'fs';
import * as STREAM from 'stream';
import * as fs from 'fs';
import * as stream from 'stream';
import * as express from 'express';
import * as glob from 'glob';
declare function archiver(format: string, options?: {}): archiver.Archiver;
declare function archiver(format: archiver.Format, options?: archiver.ArchiverOptions): archiver.Archiver;
declare namespace archiver {
function create(format: string, options?: {}): Archiver;
type Format = 'zip' | 'tar';
function create(format: string, options?: ArchiverOptions): Archiver;
function registerFormat(format: string, module: Function): void;
interface nameInterface {
interface EntryData {
name?: string;
prefix?: string;
stats?: string;
}
interface Archiver extends STREAM.Transform {
interface Archiver extends stream.Transform {
abort(): this;
append(source: STREAM.Readable | Buffer | string, name: nameInterface): this;
append(source: stream.Readable | Buffer | string, name?: EntryData): this;
bulk(mappings: any): this;
directory(dirpath: string, destpath: nameInterface | string, data?: any | Function): this;
directory(dirpath: string, options: EntryData | string, data?: EntryData): this;
file(filepath: string, data: any): this;
glob(pattern: string, options: {}, data: any): this;
file(filename: string, data: EntryData): this;
glob(pattern: string, options?: glob.IOptions, data?: EntryData): this;
finalize(): this;
pipe(stream: fs.WriteStream | express.Response): void;
setFormat(format: string): this;
setModule(module: Function): this;
pointer(): number;
use(plugin: Function): this;
}
interface ArchiverOptions {
store?: boolean;
gzip?: boolean;
gzipOptions?: {
level: number,
};
}
}
export = archiver;
+8 -2
View File
@@ -1,6 +1,6 @@
// Type definitions for AutobahnJS v0.9.7
// Project: http://autobahn.ws/js/
// Definitions by: Elad Zelingher <https://github.com/darkl/>, Andy Hawkins <https://github.com/a904guy/,http://a904guy.com/,http://www.bmbsqd.com>
// Definitions by: Elad Zelingher <https://github.com/darkl/>, Andy Hawkins <https://github.com/a904guy/,http://a904guy.com/,http://www.bmbsqd.com>, Wladimir Totino <https://github.com/valepu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="when" />
@@ -167,8 +167,14 @@ declare namespace autobahn {
interface IPublishOptions {
acknowledge?: boolean;
exclude?: number[];
exclude_authid?: string[];
exclude_authrole?: string[];
eligible?: number[];
disclose_me?: Boolean;
eligible_authid?: string[];
eligible_authrole?: string[];
retain?: boolean;
disclose_me?: boolean;
exclude_me?: boolean;
}
interface ISubscribeOptions {
+4 -3
View File
@@ -5,10 +5,11 @@
/// <reference types="babel-types" />
import * as t from 'babel-types';
type Node = t.Node;
import { File, Expression } from 'babel-types';
export function parse(code: string, opts?: BabylonOptions): Node;
export function parse(code: string, opts?: BabylonOptions): File;
export function parseExpression(input: string, options?: BabylonOptions): Expression;
export interface BabylonOptions {
/**
+5
View File
@@ -190,6 +190,11 @@ function CommonMethodsInEventStreamsAndProperties() {
console.log(sum); // returns [-1, 2, 8] in an order
});
}
{
var src = Bacon.fromArray([1, 2, 3]);
src.doLog('element value');
}
}
function EventStream() {
+9 -7
View File
@@ -1,6 +1,6 @@
// Type definitions for Bacon.js 0.7.0
// Project: https://baconjs.github.io/
// Definitions by: Alexander Matsievsky <https://github.com/alexander-matsievsky>
// Definitions by: Alexander Matsievsky <https://github.com/alexander-matsievsky>, Joonas Javanainen <https://github.com/gekkio>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery" />
@@ -69,7 +69,7 @@ declare namespace Bacon {
/**
* @function
* @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the optional `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream.
* @param {Promise<A>|JQueryXHR} promise
* @param {PromiseLike<A>|JQueryXHR} promise
* @param {boolean} [abort]
* @returns {EventStream<E, A>}
* @example
@@ -78,7 +78,7 @@ declare namespace Bacon {
* Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true);
* Bacon.fromPromise(Promise.resolve(1), false);
*/
function fromPromise<E, A>(promise:Promise<A>|JQueryXHR, abort?:boolean):EventStream<E, A>;
function fromPromise<E, A>(promise:PromiseLike<A>|JQueryXHR, abort?:boolean):EventStream<E, A>;
/**
* @callback Bacon.fromPromise~eventTransformer
@@ -88,7 +88,7 @@ declare namespace Bacon {
/**
* @function Bacon.fromPromise
* @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream, and also pass a function `eventTransformer` that transforms the promise value into Events. The default is to transform the value into `[new Bacon.Next(value), new Bacon.End()]`.
* @param {Promise<A>|JQueryXHR} promise
* @param {PromiseLike<A>|JQueryXHR} promise
* @param {boolean} abort
* @param {Bacon.fromPromise~eventTransformer} eventTransformer
* @returns {EventStream<E, B>}
@@ -100,7 +100,7 @@ declare namespace Bacon {
* return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
* });
*/
function fromPromise<E, A, B>(promise:Promise<A>|JQueryXHR, abort:boolean, eventTransformer:(value:A) => (Initial<B>|Next<B>|End<B>|Error<E>)[]):EventStream<E, B>;
function fromPromise<E, A, B>(promise:PromiseLike<A>|JQueryXHR, abort:boolean, eventTransformer:(value:A) => (Initial<B>|Next<B>|End<B>|Error<E>)[]):EventStream<E, B>;
/**
* @function
@@ -1026,9 +1026,10 @@ declare namespace Bacon {
/**
* @method EventStream#doLog
* @description Logs each value of the [EventStream]{@link Bacon.EventStream} to the console. [doLog]{@link Bacon.EventStream#doLog} behaves like [log]{@link Bacon.EventStream#log} but does not subscribe to the EventStream. You can think of `doLog` as a logger function that – unlike `log` – is safe to use in production. `doLog` is safe, because it does not cause the same surprising side-effects as `log` does.
* @param {string} [label]
* @returns {EventStream<E, A>}
*/
doLog():EventStream<E, A>;
doLog(label?:string):EventStream<E, A>;
/**
* @method
@@ -1613,9 +1614,10 @@ declare namespace Bacon {
/**
* @method Property#doLog
* @description Logs each value of the [Property]{@link Bacon.Property} to the console. [doLog]{@link Bacon.Property#doLog} behaves like [log]{@link Bacon.Property#log} but does not subscribe to the Property. You can think of `doLog` as a logger function that – unlike `log` – is safe to use in production. `doLog` is safe, because it does not cause the same surprising side-effects as `log` does.
* @param {string} [label]
* @returns {Property<E, A>}
*/
doLog():Property<E, A>;
doLog(label?:string):Property<E, A>;
/**
* @method
+56
View File
@@ -0,0 +1,56 @@
import * as Bleno from 'bleno';
export class EchoCharacteristic extends Bleno.Characteristic {
_value: any;
_updateValueCallback: any;
constructor() {
super({
uuid: 'ec0e',
properties: ['read', 'write', 'notify'],
value: null
});
this._value = new ArrayBuffer(0);
this._updateValueCallback = null;
}
onReadRequest(offset: number, callback: any) {
callback(Bleno.Characteristic.RESULT_SUCCESS, this._value);
}
onWriteRequest(data: any, offset: number, withoutResponse: boolean, callback: any) {
this._value = data;
if (this._updateValueCallback) {
this._updateValueCallback(this._value);
}
callback(Bleno.Characteristic.RESULT_SUCCESS);
}
onSubscribe(maxValueSize: number, updateValueCallback: any) {
this._updateValueCallback = updateValueCallback;
}
onUnsubscribefunction() {
this._updateValueCallback = null;
}
}
Bleno.on('stateChange', (state: string) => {
if (state === 'poweredOn') {
Bleno.startAdvertising('echo', ['ec00'], () => {});
} else {
Bleno.stopAdvertising(() => {});
}
});
let characteristic = new EchoCharacteristic();
Bleno.on('advertisingStart', (error: string) => {
if (!error) {
Bleno.setServices(
[new Bleno.PrimaryService({uuid: 'ec00', characteristics: [ characteristic ] })],
() => {}
);
}
});
+128
View File
@@ -0,0 +1,128 @@
// Type definitions for bleno 0.4
// Project: https://github.com/sandeepmistry/bleno
// Definitions by: Manuel Francisco Naranjo <naranjo.manuel@gmail.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export class Characteristic {
uuid: any;
properties: any;
secure: any;
value: any;
descriptors: any;
constructor(options: any);
onIndicate(): void;
onNotify(): void;
onReadRequest(offset: any, callback: any): void;
onSubscribe(maxValueSize: any, updateValueCallback: any): void;
onUnsubscribe(): void;
onWriteRequest(data: any, offset: any, withoutResponse: any, callback: any): void;
toString(): any;
static RESULT_ATTR_NOT_LONG: number;
static RESULT_INVALID_ATTRIBUTE_LENGTH: number;
static RESULT_INVALID_OFFSET: number;
static RESULT_SUCCESS: number;
static RESULT_UNLIKELY_ERROR: number;
}
export class Descriptor {
uuid: any;
value: any;
constructor(options: any);
toString(): any;
}
export class PrimaryService {
uuid: any;
characteristics: any;
constructor(options: any);
toString(): any;
}
export const address: string;
export const domain: any;
export const mtu: number;
export const platform: string;
export const rssi: number;
export const state: string;
export function addListener(type: any, listener: any): any;
export function disconnect(): void;
export function emit(type: any, ...args: any[]): any;
export function eventNames(): any;
export function getMaxListeners(): any;
export function listenerCount(type: any): any;
export function listeners(type: any): any;
export function on(type: any, listener: any): any;
export function onAccept(clientAddress: any): void;
export function onAddressChange(address: any): void;
export function onAdvertisingStart(error: any): void;
export function onAdvertisingStop(): void;
export function onDisconnect(clientAddress: any): void;
export function onMtuChange(mtu: any): void;
export function onPlatform(platform: any): void;
export function onRssiUpdate(rssi: any): void;
export function onServicesSet(error: any): void;
export function onStateChange(state: any): void;
export function once(type: any, listener: any): any;
export function prependListener(type: any, listener: any): any;
export function prependOnceListener(type: any, listener: any): any;
export function removeAllListeners(type: any, ...args: any[]): any;
export function removeListener(type: any, listener: any): any;
export function setMaxListeners(n: any): any;
export function setServices(services: any, callback: any): void;
export function startAdvertising(name: any, serviceUuids: any, callback: any): void;
export function startAdvertisingIBeacon(uuid: any, major: any, minor: any, measuredPower: any, callback: any): void;
export function startAdvertisingWithEIRData(advertisementData: any, scanData: any, callback: any): void;
export function stopAdvertising(callback: any): void;
export function updateRssi(callback: any): void;
@@ -2,11 +2,11 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es5"
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -17,6 +17,6 @@
},
"files": [
"index.d.ts",
"promise-tests.ts"
"bleno-tests.ts"
]
}
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+30 -1
View File
@@ -481,6 +481,15 @@ new Book({'ISBN-13': '9780440180296'})
/* model.fetchAll(), see http://bookshelfjs.org/#Model-instance-fetchAll */
{
(new User).fetchAll({
columns: ['id', 'name'],
withRelated: ['posts.tags']
}).then((user: any) => {
console.log(user);
})
}
/* model.format(), see http://bookshelfjs.org/#Model-instance-format */
/* model.get(), see http://bookshelfjs.org/#Model-instance-get */
@@ -637,6 +646,16 @@ customer.on('fetching', (model, columns) => {
/* model.once(), see http://bookshelfjs.org/#Model-instance-once */
/* model.orderBy(), see http://bookshelfjs.org/#Model-instance-orderBy */
{
(new User)
.orderBy('name', 'ASC')
.fetchAll()
.then((users: Bookshelf.Collection<User>) => {
console.log(users)
});
}
/* model.parse(), see http://bookshelfjs.org/#Model-instance-parse */
// Example of a "parse" to convert snake_case to camelCase, using `underscore.string`
@@ -1096,6 +1115,16 @@ ships.on('fetched', (collection, response) => {
/* collection.once(), see http://bookshelfjs.org/#Collection-instance-once */
/* collection.orderBy(), see http://bookshelfjs.org/#Collection-instance-orderBy */
{
User.collection()
.orderBy('-name')
.fetch()
.then((users: Bookshelf.Collection<User>) => {
console.log(users);
})
}
/* collection.parse(), see http://bookshelfjs.org/#Collection-instance-parse */
/* collection.pluck(), see http://bookshelfjs.org/#Collection-instance-pluck */
@@ -1376,4 +1405,4 @@ new User({name: 'John'}).fetchAll({require: true})
new Country({id: 1}).capital().fetch().then(model => {
// ...
});
}
}
+7 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for bookshelfjs v0.8.2
// Type definitions for bookshelfjs v0.9.3
// Project: http://bookshelfjs.org/
// Definitions by: Andrew Schurman <http://github.com/arcticwaters>
// Definitions by: Andrew Schurman <http://github.com/arcticwaters>, Vesa Poikajärvi <https://github.com/vesse>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -23,6 +23,8 @@ interface Bookshelf extends Bookshelf.Events<any> {
declare function Bookshelf(knex: knex): Bookshelf;
declare namespace Bookshelf {
type SortOrder = 'ASC'|'asc'|'DESC'|'desc';
abstract class Events<T> {
on(event?: string, callback?: EventFunction<T>, context?: any): void;
off(event?: string): void;
@@ -105,6 +107,7 @@ declare namespace Bookshelf {
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;
orderBy(column: string, order?: SortOrder): T;
// Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
query(): Knex.QueryBuilder;
@@ -242,6 +245,7 @@ declare namespace Bookshelf {
detach(options?: SyncOptions): BlueBird<any>;
fetchOne(options?: CollectionFetchOneOptions): BlueBird<T>;
load(relations: string | string[], options?: SyncOptions): BlueBird<Collection<T>>;
orderBy(column: string, order?: SortOrder): T;
// Declaration order matters otherwise TypeScript gets confused between query() and query(...query: string[])
query(): Knex.QueryBuilder;
@@ -278,8 +282,7 @@ declare namespace Bookshelf {
[index: string]: (query: Knex.QueryBuilder) => Knex.QueryBuilder;
}
interface FetchAllOptions extends SyncOptions {
require?: boolean;
interface FetchAllOptions extends FetchOptions {
}
interface SaveOptions extends SyncOptions {
+21 -21
View File
@@ -337,16 +337,16 @@ export interface DatetimepickerOptions {
/** Shows the week of the year to the left of first day of the week.
* @default: false
*/
calendarWeeks?: boolean;
calendarWeeks?: boolean;
/** Using a Bootstraps collapse to switch between date/time pickers.
* @default: true
*/
collapse?: boolean;
collapse?: boolean;
/** Disables the section of days of the week, e.g. weekends.
* Accepts: array of numbers from 0-6
* @default: false
*/
daysOfWeekDisabled?: number[] | boolean;
daysOfWeekDisabled?: number[] | boolean;
/** Changes the heading of the datepicker when in "days" view.
* @default: "MMMM YYYY"
*/
@@ -358,14 +358,14 @@ export interface DatetimepickerOptions {
/** Sets the picker default date/time. Overrides useCurrent
* @default: false
*/
defaultDate?: boolean | moment.Moment | Date | string;
defaultDate?: boolean | moment.Moment | Date | string;
/** Disables selection of dates in the array, e.g. holidays
* @default: false
* IMPORTANT! The getter returns an Object NOT an Array, with keys being the dates, values being true.
* eg disabledDates = ["2010-10-10"]; -> disabledDated will be { "2010-01-01": true }
* https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1499
*/
disabledDates?: boolean | Array<moment.Moment | Date | string> | any;
disabledDates?: boolean | Array<moment.Moment | Date | string> | any;
/** Will allow or disallow hour selections (much like disabledTimeIntervals) but will affect all days
* @default: false
* IMPORTANT! The getter returns an Object NOT an Array, with keys being the hours, values being true.
@@ -384,7 +384,7 @@ export interface DatetimepickerOptions {
* eg enabledDates = ["2010-10-10"]; -> enabledDated will be { "2010-01-01": true }
* https://github.com/Eonasdan/bootstrap-datetimepicker/issues/1499
*/
enabledDates?: boolean | Array<moment.Moment | Date | string> | any;
enabledDates?: boolean | Array<moment.Moment | Date | string> | any;
/** Will allow or disallow hour selections (much like disabledTimeIntervals) but will affect all days
* @default: false
* IMPORTANT! The getter returns an Object NOT an Array, with keys being the hours, values being true.
@@ -403,17 +403,17 @@ export interface DatetimepickerOptions {
/** See momentjs' docs for valid formats. Format also dictates what components are shown, e.g. MM/dd/YYYY will not display the time picker.
* @default: false
*/
format?: boolean | string | moment.MomentBuiltinFormat;
format?: boolean | string | moment.MomentBuiltinFormat;
/** Change the default icons for the pickers functions. */
icons?: Icons;
icons?: Icons;
/** Allow date picker show event to fire even when the associated input element has the readonly="readonly"property.
* @default: false
*/
ignoreReadonly?: boolean;
ignoreReadonly?: boolean;
/** Will display the picker inline without the need of a input field. This will also hide borders and shadows.
* @default: false
*/
inline?: boolean;
inline?: boolean;
/** Allows for custom events to fire on keyboard press.
* eg: keybinds: {
* up: (widget) => console.log(widget),
@@ -433,17 +433,17 @@ export interface DatetimepickerOptions {
/** See momentjs for valid locales. You must include moment-with-locales.js or a local js file.
* @default: moment.locale()
*/
locale?: string;
locale?: string;
/** Prevents date/time selections after this date.
* maxDate will override defaultDate and useCurrent if either of these settings are the same day since both options are invalid according to the rules you've selected.
* @default: false
*/
maxDate?: boolean | moment.Moment | Date | string;
maxDate?: boolean | moment.Moment | Date | string;
/** Prevents date/time selections before this date.
* minDate will override defaultDate and useCurrent if either of these settings are the same day since both options are invalid according to the rules you've selected.
* @default: false
*/
minDate?: boolean | moment.Moment | Date | string;
minDate?: boolean | moment.Moment | Date | string;
/** Allows custom input formatting For example: the user can enter "yesterday"" or "30 days ago".
* {@link http://eonasdan.github.io/bootstrap-datetimepicker/Functions/#parseinputdate}
*/
@@ -452,7 +452,7 @@ export interface DatetimepickerOptions {
* Clicking the "Clear" button will set the calendar to null.
* @default: false
*/
showClear?: boolean;
showClear?: boolean;
/** Show the "Close" button in the icon toolbar.
* Clicking the "Close" button will call hide()
* @default: false
@@ -462,11 +462,11 @@ export interface DatetimepickerOptions {
* Clicking the "Today" button will set the calendar view and set the date to now.
* @default: false
*/
showTodayButton?: boolean;
showTodayButton?: boolean;
/** Shows the picker side by side when using the time and date together.
* @default: false
*/
sideBySide?: boolean;
sideBySide?: boolean;
/** Number of minutes the up/down arrow's will move the minutes value in the time picker
* @default: 1
*/
@@ -479,17 +479,17 @@ export interface DatetimepickerOptions {
/** Changes the placement of the icon toolbar.
* @default: "default"
*/
toolbarPlacement?: "default" | "top" | "bottom";
toolbarPlacement?: "default" | "top" | "bottom";
/** This will change the tooltips over each icon to a custom string */
tooltips?: Tooltips;
/** On show, will set the picker to the current date/time
* @default: true
*/
useCurrent?: boolean;
useCurrent?: boolean;
/** Defines if moment should use strict date parsing when considering a date to be valid
* @default: false
*/
useStrict?: boolean;
useStrict?: boolean;
/** This will change the viewDate without changing or setting the selected date.
* @default: false
*/
@@ -498,7 +498,7 @@ export interface DatetimepickerOptions {
* Note: To limit the picker to selecting, for instance the year and month, use format: MM/YYYY
* @default: "days"
*/
viewMode?: "decades" | "years" | "months" | "days";
viewMode?: "decades" | "years" | "months" | "days";
/** On picker show, places the widget at the identifier (string) or jQuery object if the element has css position: "relative"
* @default: null
*/
@@ -520,7 +520,7 @@ export interface Icons {
/** default: "glyphicon glyphicon-screenshot" */
previous?: string;
/** default: "glyphicon glyphicon-chevron-right" */
time?: string;
time?: string;
/** default: "glyphicon glyphicon-chevron-down" */
today?: string;
/** default: "glyphicon glyphicon-chevron-up" */
+76
View File
@@ -0,0 +1,76 @@
import { expect } from 'chai';
import { assert } from 'chai';
import chai = require('chai');
import ChaiArrays = require('chai-arrays');
chai.use(ChaiArrays);
chai.should();
const arr: any[] = [1, 2, 3];
const str: string = 'abcdef';
const otherArr: number[] = [1, 2, 3];
const anotherArr: number[] = [2, 4];
const yetAnotherArr: number[] = [8, 5, 7];
arr.should.be.array();
str.should.not.be.array();
expect(arr).to.be.array();
expect(str).not.to.be.array();
assert.array(arr, 'is array');
arr.should.be.ofSize(3);
arr.should.not.be.ofSize(4);
expect(arr).to.be.ofSize(3);
expect(str).not.to.be.ofSize(4);
assert.ofSize(arr, 3, 'has 3 elements');
arr.should.be.equalTo(otherArr);
arr.should.not.be.equalTo(anotherArr);
expect(arr).to.be.equalTo(otherArr);
expect(str).to.be.not.equalTo(anotherArr);
assert.equalTo(arr, otherArr, 'is equal to');
arr.should.be.containing(1);
arr.should.not.be.containing(4);
expect(arr).to.be.containing(1);
expect(str).to.be.not.containing(4);
assert.containing(arr, 1, 'contains');
arr.should.be.containingAllOf(otherArr);
arr.should.not.be.containingAllOf(anotherArr);
expect(arr).to.be.containingAllOf(otherArr);
expect(str).to.be.not.containingAllOf(anotherArr);
assert.containingAllOf(arr, otherArr, 'contains all of');
arr.should.be.containingAnyOf(otherArr);
arr.should.be.containingAnyOf(anotherArr);
arr.should.not.be.containingAnyOf(yetAnotherArr);
expect(arr).to.be.containingAnyOf(otherArr);
expect(str).to.be.containingAnyOf(anotherArr);
expect(str).to.be.not.containingAnyOf(yetAnotherArr);
assert.containingAnyOf(arr, otherArr, 'contains any of');
assert.containingAnyOf(arr, anotherArr, 'contains any of');
arr.should.be.sorted();
anotherArr.should.be.sorted();
yetAnotherArr.should.be.sorted();
expect(arr).to.be.sorted();
expect(anotherArr).to.be.sorted();
expect(yetAnotherArr).to.be.not.sorted();
assert.sorted(arr, 'sorted');
+37
View File
@@ -0,0 +1,37 @@
// Type definitions for chai-arrays 1.0
// Project: https://github.com/GaneshSPatil/chai-arrays
// Definitions by: Clément Prévot <https://github.com/clementprevot/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="chai" />
declare global {
namespace Chai {
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
array(): Assertion;
ofSize(size: number): Assertion;
equalTo(arr: any[]): Assertion;
containing(value: any): Assertion;
containingAllOf(values: any[]): Assertion;
containingAnyOf(values: any[]): Assertion;
sorted(): Assertion;
}
interface Assert {
array(val: any[], msg?: string): void;
ofSize(val: any[], size: number, msg?: string): void;
equalTo(val: any[], array: any[], msg?: string): void;
containing(val: any[], value: any, msg?: string): void;
containingAllOf(val: any[], values: any[], msg?: string): void;
containingAnyOf(val: any[], values: any[], msg?: string): void;
sorted(val: any[], msg?: string): void;
}
}
interface Array<T> {
should: Chai.Assertion;
}
}
declare function chaiArrays(chai: any, utils: any): void;
export = chaiArrays;
+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",
"chai-arrays-tests.ts"
]
}
+2 -2
View File
@@ -438,7 +438,7 @@ interface ChocolateChipStatic {
/**
* Serialize
*/
serialize(form: HTMLFormElement | ChocolateChipElementArray): string;
serialize(form: HTMLFormElement | ChocolateChipElementArray): string;
/**
* Grabs values from a form and converts them into a JSON object.
@@ -862,7 +862,7 @@ interface ChocolateChipElementArray extends Array<HTMLElement> {
* @param property The property to remove.
* @return HTMLElement[]
*/
removeProp(property: string): ChocolateChipElementArray;
removeProp(property: string): ChocolateChipElementArray;
/**
* Adds the specified class(es) to each of the set of matched elements.
+1
View File
@@ -59,3 +59,4 @@ var chain: Color.Color = color
.opaquer(0)
.rotate(0)
.mix(colorOther, 0)
.hsl();
+1
View File
@@ -85,6 +85,7 @@ declare namespace Color {
opaquer(value: number): Color;
rotate(value: number): Color;
mix(color: Color, value?: number): Color;
hsl(): Color;
}
}
@@ -0,0 +1,43 @@
/**
* Display Messenger
*/
NativeKeyboard.showMessenger({
onSubmit: (text) => {},
onKeyboardDidHide: () => {},
onKeyboardDidShow: () => {},
onKeyboardWillShow: () => {},
onTextChanged: (text) => {},
onKeyboardWillHide: () => {},
});
/**
* Display Messenger Keyboard
*/
NativeKeyboard.showMessengerKeyboard(
() => {},
() => {});
/**
* Hide Messenger
*/
NativeKeyboard.hideMessenger(
{ animated: true},
() => {},
() => {});
NativeKeyboard.hideMessenger();
/**
* Hide Messenger Keyboard
*/
NativeKeyboard.hideMessengerKeyboard(
() => {},
() => {});
/**
* Update Messenger Keyboard
*/
NativeKeyboard.updateMessenger(
{text: 'FooBar'},
() => {},
() => {});
+303
View File
@@ -0,0 +1,303 @@
// Type definitions for cordova-plugin-native-keyboard 1.3
// Project: https://github.com/EddyVerbruggen/cordova-plugin-native-keyboard#readme
// Definitions by: Daniel Brolli <https://github.com/lobo87>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface NativeKeyboard {
/**
* Show the messenger, the bare minimum which has to be passed to the function is
* the onSubmit callback
* @param options
*/
showMessenger(
options: NativeKeyboardShowOptions
): void;
/**
* It's likely your app only has 1 one page where you want to show the messenger,
* so you want to hide it when the user navigates away. You can choose to do this
* either animated (a quick slide down animation) or not.
*
* @param options
* @param onSuccess
* @param onError
*/
hideMessenger(
options?: NativeKeyboardHideOptions,
onSuccess?: () => void,
onError?: (err: any) => void
): void;
/**
* Show a previously hidden keyboard
*
* @param onSuccess
* @param onError
*/
showMessengerKeyboard(
onSuccess?: () => void,
onError?: (err: any) => void,
): void;
/**
* Hide the keyboard, but not the messenger bar
*
* @param onSuccess
* @param onError
*/
hideMessengerKeyboard(
onSuccess?: () => void,
onError?: (err: any) => void,
): void;
/**
* Manipulate the messenger while it's open. For instance if you want to
* update the text programmatically based on what the user typed (by responding to
* onTextChanged events).
*
* @param options
* @param onSuccess
* @param onError
*/
updateMessenger(
options: NativeKeyboardUpdateOptions,
onSuccess?: () => void,
onError?: (err: any) => void
): void;
}
interface NativeKeyboardUpdateOptions {
/**
* Replace the messenger's text by this. The current text remains if omitted.
*/
text?: string;
/**
* Position the cursor anywhere in the text range. Defaults to the end of the text.
*/
caretIndex?: number;
/**
* If false or omitted no changes to the keyboard state are made.
*/
showKeyboard?: boolean;
}
interface NativeKeyboardHideOptions {
/**
* A boolean flag inidicating if the keyboard should be shown/hidden with an animation
*/
animated?: boolean;
}
interface NativeKeyboardShowOptions {
/**
* Callback function, which is being called as soon as the user submits
* @param text
*/
onSubmit(text: string): void;
/**
* Callback function which is being executed as soon as the keyboard will show
*/
onKeyboardWillShow?(): void;
/**
* Callback function which is being executed as soon as the keyboard did show
*/
onKeyboardDidShow?(): void;
/**
* Callback function which is being executed as soon as the keyboard will hide
*/
onKeyboardWillHide?(): void;
/**
* Callback function which is being executed as soon as the keyboard did hide
*/
onKeyboardDidHide?(): void;
/**
* Callback function which is being executed as soon as the entered text changes. Will
* return the new text
*
* @param text
*/
onTextChanged?(text: string): void;
/**
* DOM element, which should be scrolled automatically
*/
autoscrollElement?: any;
/**
* Boolean value indicating if the content should be scrolled to the end after the messenger is
* shown
*/
scrollToBottomAfterMessengerShows?: boolean;
/**
* Boolean value indicating if the keyboard should be kept open after submitting the entered
* text
*
* Default: false
*/
keepOpenAfterSubmit?: boolean;
/**
* Makes the messenger bar slide in from the bottom.
*
* Default: false
*/
animated?: boolean;
/**
* Open the keyboard when showing the messenger.
*
* Default: false
*/
showKeyboard?: boolean;
/**
* A text which will be in the messenger bar, when opening
*/
text?: string;
/**
* The color of the typed text in HEX.
*
* Default: #444
*/
textColor?: string;
/**
* A placeholder which will be in the messenger bar, when opening and the input field is
* empty
*/
placeholder?: string;
/**
* The color of the placeholder.
*
* Default: #ccc
*/
placeholderColor?: string;
/**
* The background color of the messenger bar.
*
* Default: #F6F6F6
*/
backgroundColor?: string;
/**
* The background color of the textview. Looks nicest on Android
* if it's the same color as the backgroundColor property.
*
* Default: #F6F6F6
*/
textViewBackgroundColor?: string;
/**
* The border color of the textview.
*
* Default: #666666
*/
textViewBorderColor?: string;
/**
* Maximum amount of chars that can be entered
*/
maxChars?: number;
/**
* Options are: "none", "split", "countdown", "countdownreversed".
* Note that if maxChars is set, "none" will still show a counter.
*
* Default: "none"
*/
counterStyle?: string;
/**
* Options are: "default", "decimalpad", "phonepad", "numberpad", "namephonepad",
* "number", "email", "twitter", "url", "alphabet", "search", "ascii"
*
* Default: "default"
*/
type?: string;
/**
* Options are: "light", "dark".
*
* Default: "default"
*/
appearance?: string;
/**
* Disables things like the Emoji keyboard and the Predicive text entry bar
*
* Default: false
*/
secure?: boolean;
/**
* The left button of the messenger bar
*/
leftButton?: LeftButtonOptions;
/**
* The right button of the messenger bar
*/
rightButton?: ButtonOptions;
}
interface ButtonOptions {
/**
* The type of the button.
* Either "text", "fontawesome" or "ionicon".
*
* Default: "text"
*/
type?: string;
/**
* The value of the button. On "text" the string is used as label
* On fonatawesome or ionicon the icon name is used (e.g. fa-rocket)
*
* Default: "Send"
*/
value?: string;
/**
* If type is "text" you can set this to either "normal", "bold" or "italic".
*
* Default: "normal"
*/
textStyle?: string;
/**
* The color of the button in HEX
*
* Default: #000
*/
color: string;
/**
* A callback being executed as soon as the button is clicked
*/
onPress(): void;
}
interface LeftButtonOptions extends ButtonOptions {
/**
* Set to true to disable the button once text has been entered.
*
* Default: false
*/
disabledWhenTextEntered?: boolean;
}
/** NativeKeyboard instance */
declare var NativeKeyboard: NativeKeyboard;
interface Window {
NativeKeyboard: NativeKeyboard;
}
@@ -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",
"cordova-plugin-native-keyboard-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -3,7 +3,7 @@
var QRScanner: QRScanner = window.QRScanner;
QRScanner.prepare();
QRScanner.prepare((err, status) => { var error: QRScannerError = err; var obj: QRScannerStatus = status; });
QRScanner.scan((err, results) => { var error: QRScannerError = err; var contents: String = results; });
QRScanner.scan((err, results) => { var error: QRScannerError = err; var contents: string = results; });
QRScanner.cancelScan();
QRScanner.cancelScan((status) => {var obj: QRScannerStatus = status; });
QRScanner.show();
@@ -31,12 +31,12 @@ QRScanner.destroy((status) => {var obj: QRScannerStatus = status; });
QRScanner.prepare((err, status) => {
var error: QRScannerError = err;
var num: Number = error.code;
var str: String = error.name;
var num: number = error.code;
var str: string = error.name;
str = error._message;
var obj: QRScannerStatus = status;
var bool: Boolean = status.authorized;
var bool: boolean = status.authorized;
bool = status.denied;
bool = status.restricted;
bool = status.prepared;
@@ -46,5 +46,5 @@ QRScanner.prepare((err, status) => {
bool = status.lightEnabled;
bool = status.canOpenSettings;
bool = status.canEnableLight;
var num: Number = status.currentCamera;
var num: number = status.currentCamera;
});
+20 -19
View File
@@ -1,6 +1,7 @@
// Type definitions for cordova-plugin-qrscanner v1.0.0
// Type definitions for cordova-plugin-qrscanner v1.0.1
// Project: https://github.com/bitpay/cordova-plugin-qrscanner
// Definitions by: Jason Dreyzehner <https://github.com/bitjson/>
// Josh Bronson <https://github.com/jab>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
@@ -32,7 +33,7 @@ interface QRScanner {
* not need to be visible for scanning to function.
* @param {function} callback Callback that gets an error or the results string.
*/
scan: (callback: (error: QRScannerError, result: String) => any) => void;
scan: (callback: (error: QRScannerError, result: string) => any) => void;
/**
* Cancels the current scan. If `QRScanner.prepare()` has not been called,
@@ -82,7 +83,7 @@ interface QRScanner {
* @param {number} index A number representing the index of the camera to use.
* @param {function} [callback] Callback that gets an error or the QRScannerStatus object.
*/
useCamera: (index: Number, callback?: (error: QRScannerError, status: QRScannerStatus) => any) => void;
useCamera: (index: number, callback?: (error: QRScannerError, status: QRScannerStatus) => any) => void;
/**
* Switch video capture to the device's front camera. If `QRScanner.prepare()`
@@ -150,7 +151,7 @@ interface QRScannerStatus {
* (`AVAuthorizationStatus.Authorized`). On platforms with permissions granted
* at install (Android pre-6.0, Windows Phone) this property is always true.
*/
authorized: Boolean,
authorized: boolean,
/**
* A boolean value which is true if the user permenantly denied camera access
@@ -158,59 +159,59 @@ interface QRScannerStatus {
* only be gained by requesting the user change their decision (consider
* offering a link to the setting via `openSettings()`).
*/
denied: Boolean,
denied: boolean,
/**
* A boolean value which is true if the user is unable to grant permissions due
* to parental controls, organization security configuration profiles, or
* similar reasons.
*/
restricted: Boolean,
restricted: boolean,
/**
* A boolean value which is true if QRScanner is prepared to capture video and
* render it to the view.
*/
prepared: Boolean,
prepared: boolean,
/**
* A boolean value which is true if QRScanner is actively scanning for a QR code.
*/
scanning: Boolean,
scanning: boolean,
/**
* A boolean value which is true if QRScanner is displaying a live preview
* from the device's camera. Set to false when the preview is paused.
*/
previewing: Boolean,
previewing: boolean,
/**
* A boolean value which is true when the native webview background is transparent.
*/
webviewBackgroundIsTransparent: Boolean,
webviewBackgroundIsTransparent: boolean,
/**
* A boolean value which is true if the light is enabled.
*/
lightEnabled: Boolean,
lightEnabled: boolean,
/**
* A boolean value which is true only if the users' operating system is able
* to `QRScanner.openSettings()`.
*/
canOpenSettings: Boolean,
canOpenSettings: boolean,
/**
* A boolean value which is true only if the users' device can enable a light
* in the direction of the currentCamera.
*/
canEnableLight: Boolean,
canEnableLight: boolean,
/**
* A number representing the index of the currentCamera. `0` is the back
* camera, `1` is the front.
*/
currentCamera: Number
currentCamera: number
}
/**
@@ -218,8 +219,8 @@ interface QRScannerStatus {
*
* Many QRScanner functions accept a callback with an `error` parameter. When
* QRScanner experiences errors, this parameter contains a QRScannerError object
* with properties `name` (_String_), `code` (_Number_), and `_message`
* (_String_). When handling errors, rely only on the `name` or `code` parameter,
* with properties `name` (_string_), `code` (_number_), and `_message`
* (_string_). When handling errors, rely only on the `name` or `code` parameter,
*as the specific content of `_message` is not considered part of the plugin's
* stable API.
*
@@ -242,17 +243,17 @@ interface QRScannerError {
/**
* The standard string identifying the type of this QRScannerError.
*/
name: String,
name: string,
/**
* The standard number identifying the type of this QRScannerError.
*/
code: Number,
code: number,
/**
* A simple message describing this QRScannerError.
*/
_message: String
_message: string
}
declare var QRScanner: QRScanner;
+4 -4
View File
@@ -7,7 +7,7 @@ function StepSample() {
type HookScenarioResult = cucumber.HookScenarioResult;
cucumber.defineSupportCode(function ({setWorldConstructor, defineParameterType, After, Around, Before, registerHandler, Given, When, Then}) {
setWorldConstructor(function ({attach, parameters}) {
setWorldConstructor(function ({attach, parameters}: any) {
this.attach = attach;
this.parameters = parameters;
this.visit = function (url: string, callback: Callback) {
@@ -19,7 +19,7 @@ function StepSample() {
console.log(scenarioResult.status === "failed");
callback();
});
Before({ timeout: 1000 }, function (scenarioResult: HookScenarioResult, callback: Callback) {
console.log(scenarioResult.status === "failed");
callback();
@@ -35,7 +35,7 @@ function StepSample() {
console.log("After");
callback();
});
After({ timeout: 1000 }, (scenarioResult: HookScenarioResult, callback?: Callback) => {
console.log("After");
callback();
@@ -48,7 +48,7 @@ function StepSample() {
Given(/^a variable set to (\d+)$/, (x: string) => {
console.log("the number is: " + x);
});
Given(/^a variable set to (\d+)$/, (x: number) => {
console.log(typeof x);
});
@@ -0,0 +1,76 @@
/// <reference types='node' />
import * as parse from 'cwise-parser';
import * as ndarray from 'ndarray';
import * as compile from 'cwise-compiler';
import * as tape from 'tape';
tape("block tests", (t) => {
const ops = require('ndarray-ops');
const body2 = parse((a: number, b: number[]) => {
a = b[0] + b[1] + 1;
});
const body23 = parse((a: number, b: number[][]) => {
a = b[0][0] * b[1][0] + b[0][1] * b[1][1] + b[0][2] * b[1][2];
});
// Test with block index at the front of the indices
const c1 = compile({
args: ["array", { blockIndices: 1 }],
pre: parse(() => { }),
body: body2,
post: parse(() => { }),
debug: false,
funcName: "cwise",
blockSize: 64
});
const a1 = ndarray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 4]);
const b1 = ndarray([57, 17, 95, 78, 16, 96, 85, 93, 38, 42, 16, 66, 23, 77, 17, 36, 30, 52, 16, 18, 23, 69, 67, 27], [2, 3, 4]);
const ref1 = ndarray([81, 95, 113, 115, 47, 149, 102, 112, 62, 112, 84, 94], [3, 4]);
c1(a1, b1);
t.ok(ops.equals(a1, ref1), "front block");
// Test with block index at the back of the indices
const c2 = compile({
args: ["array", { blockIndices: -1 }],
pre: parse(() => { }),
body: body2,
post: parse(() => { }),
debug: false,
funcName: "cwise",
blockSize: 64
});
const a2 = ndarray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 4]);
const b2 = ndarray([57, 17, 95, 78, 16, 96, 85, 93, 38, 42, 16, 66, 23, 77, 17, 36, 30, 52, 16, 18, 23, 69, 67, 27], [3, 4, 2]);
const ref2 = ndarray([75, 174, 113, 179, 81, 83, 101, 54, 83, 35, 93, 95], [3, 4]);
c2(a2, b2);
t.ok(ops.equals(a2, ref2), "back block");
// Multiple block indices
const c3 = compile({
args: ["array", { blockIndices: -2 }],
pre: parse(() => { }),
body: body23,
post: parse(() => { }),
debug: false,
funcName: "cwise",
blockSize: 64
});
const a3 = ndarray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [3, 4]);
const b3 = ndarray([48, 46, 89, 64, 72, 96, 38, 37, 79, 92, 89, 62, 84, 41, 13, 81, 53, 30, 68, 78, 34, 81, 90, 50,
82, 97, 46, 18, 11, 79, 15, 68, 88, 58, 71, 84, 76, 35, 74, 82, 27, 47, 59, 25, 78, 61, 10, 43,
96, 59, 21, 74, 41, 67, 11, 72, 38, 62, 95, 66, 57, 44, 93, 10, 51, 59, 50, 85, 71, 41, 79, 45], [3, 4, 2, 3]);
const ref = ndarray([14928, 11687, 9367, 14228, 6177, 13090, 10655, 7203, 10930, 10030, 8301, 11960], [3, 4]);
c3(a3, b3);
t.ok(ops.equals(a3, ref), "block with two indices");
t.end();
});
+49
View File
@@ -0,0 +1,49 @@
// Type definitions for cwise-compiler 1.1
// Project: https://github.com/scijs/cwise-compiler
// Definitions by: taoqf <https://github.com/taoqf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { CompiledRoutine } from 'cwise-parser';
import * as ndarray from 'ndarray';
declare namespace cwise_compiler {
interface BlockIndice {
blockIndices: number;
}
interface OffsetArg {
offset: number[];
array: number;
}
type ArgType = 'array' | 'offset' | 'shape' | 'scalar' | 'index' | BlockIndice | OffsetArg;
interface UserArgs {
args: ArgType[];
pre: CompiledRoutine;
body: CompiledRoutine;
post: CompiledRoutine;
debug: boolean;
funcName: string;
blockSize: number;
printCode?: boolean;
}
interface Procedure {
argTypes: ArgType[];
shimArgs: string[];
arrayArgs: number[];
arrayBlockIndices: number[];
scalarArgs: number[];
offsetArgs: OffsetArg[];
offsetArgIndex: number[];
indexArgs: number[];
shapeArgs: number[];
funcName: string;
pre: CompiledRoutine;
body: CompiledRoutine;
post: CompiledRoutine;
debug: boolean;
blockSize?: number;
}
}
declare function cwise_compiler(user_args: cwise_compiler.UserArgs): (a: ndarray, b: ndarray, ...args: ndarray[]) => ndarray;
export = cwise_compiler;
+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",
"cwise-compiler-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+26
View File
@@ -0,0 +1,26 @@
import * as parser from "cwise-parser";
// import parser = require("cwise-parser");
import * as tape from "tape";
tape("basic tests", (t) => {
const parsed = parser((a: number, b: number, c: number) => {
a += b;
c = Math.cos(b);
});
t.equals(parsed.args.length, 3);
t.equals(parsed.args[0].lvalue, true);
t.equals(parsed.args[0].rvalue, true);
t.equals(parsed.args[0].count, 1);
t.equals(parsed.args[1].lvalue, false);
t.equals(parsed.args[1].rvalue, true);
t.equals(parsed.args[1].count, 2);
t.equals(parsed.args[2].lvalue, true);
t.equals(parsed.args[2].rvalue, false);
t.equals(parsed.args[2].count, 1);
t.end();
});
+22
View File
@@ -0,0 +1,22 @@
// Type definitions for cwise-parser 1.0
// Project: https://github.com/scijs/cwise-parser#readme
// Definitions by: taoqf <https://github.com/taoqf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace cwise_parser {
interface CompiledArgument {
name: string;
lvalue: boolean;
rvalue: boolean;
count: number;
}
interface CompiledRoutine {
body: string;
args: CompiledArgument[];
thisVars: string[];
localVars: string[];
}
}
declare function cwise_parser<T>(func: (a: number, ...args: T[]) => any): cwise_parser.CompiledRoutine;
export = cwise_parser;
+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",
"cwise-parser-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+366
View File
@@ -0,0 +1,366 @@
import * as cwise from 'cwise';
import * as ndarray from 'ndarray';
import * as tape from 'tape';
// basic
tape("only allow same shape", (t) => {
const op1 = cwise({
args: ["array"],
body: (a: number) => { a = 1; }
});
const op2 = cwise({
args: ["array", "array"],
body: (a: number, b: number) => { a = b; }
});
const op3 = cwise({
args: ["array", "array", "array"],
body: (a: number, b: number, c: number) => { a = b + c; }
});
const op2block_pos = cwise({
args: ["array", { blockIndices: 1 }],
body: (a: number, b: number[]) => { a = b[1]; }
});
const op2block_neg = cwise({
args: ["array", { blockIndices: -1 }],
body: (a: number, b: number[]) => { a = b[1]; }
});
t.doesNotThrow(() => { op1(ndarray([1, 2, 3], [3])); });
t.doesNotThrow(() => { op2(ndarray([1, 2, 3], [3]), ndarray([1, 2, 3], [3])); });
t.doesNotThrow(() => { op2(ndarray([1, 2, 3, 4, 5, 6], [3, 2]), ndarray([1, 2, 3, 4, 5, 6], [3, 2])); });
t.doesNotThrow(() => { op3(ndarray([1, 2, 3], [3]), ndarray([1, 2, 3], [3]), ndarray([1, 2, 3], [3])); });
t.doesNotThrow(() => { op2block_pos(ndarray([1, 2], [2]), ndarray([1, 2, 3, 4, 5, 6], [3, 2])); });
t.doesNotThrow(() => { op2block_neg(ndarray([1, 2, 3], [3]), ndarray([1, 2, 3, 4, 5, 6], [3, 2])); });
t.throws(() => { op2(ndarray([1, 2, 3], [3]), ndarray([1, 2], [2])); });
t.throws(() => { op2(ndarray([1, 2, 3, 4, 5, 6], [3, 2]), ndarray([1, 2, 3], [3, 1])); });
t.throws(() => { op2(ndarray([1, 2, 3, 4, 5, 6], [3, 2]), ndarray([1, 2, 3, 4], [2, 2])); });
t.throws(() => { op3(ndarray([1, 2, 3], [3]), ndarray([1, 2, 3], [3]), ndarray([1, 2], [2])); });
t.throws(() => { op3(ndarray([1, 2, 3], [3]), ndarray([1, 2], [2]), ndarray([1, 2, 3], [3])); });
t.throws(() => { op3(ndarray([1, 2], [2]), ndarray([1, 2, 3], [3]), ndarray([1, 2, 3], [3])); });
t.throws(() => { op2block_pos(ndarray([1, 2, 3], [3]), ndarray([1, 2, 3, 4, 5, 6], [3, 2])); });
t.throws(() => { op2block_neg(ndarray([1, 2], [2]), ndarray([1, 2, 3, 4, 5, 6], [3, 2])); });
t.throws(() => { op2block_pos(ndarray([1, 2, 3, 4, 5, 6], [3, 2]), ndarray([1, 2, 3, 4], [2, 2])); });
t.throws(() => { op2block_neg(ndarray([1, 2, 3, 4, 5, 6], [3, 2]), ndarray([1, 2, 3, 4], [2, 2])); });
t.end();
});
// binarry
class DumbStorage {
data: Int32Array;
length: number;
constructor(n: number) {
this.data = new Int32Array(n);
this.length = n;
}
get(i: number) {
return this.data[i];
}
set(i: number, v: number) {
return this.data[i] = v;
}
}
tape("binary", (t) => {
const binary = cwise({
args: ["array", "array", "scalar", "shape", "index"],
body(a: number, b: number, t: tape.Test, s: number[], idx: number) {
if (!(a === 0)) t.fail("idx:" + idx + ", shape:" + s + ",a:" + a);
a = b + 1001;
}
});
function testBinary1D(P: ndarray, Q: ndarray, testName: string) {
t.equals(P.shape[0], Q.shape[0], testName + "; shape");
for (let i = 0; i < P.shape[0]; ++i) {
Q.set(i, i);
P.set(i, 0);
}
binary(P, Q, t);
for (let i = 0; i < P.shape[0]; ++i) {
if (!(P.get(i) === i + 1001)) {
t.fail(testName + "; encountered " + P.get(i) + " instead of " + (i + 1001) + " at " + i);
return;
}
}
t.pass(testName);
}
const A1 = ndarray(new Int32Array(128));
const B1 = ndarray(new Int32Array(128));
testBinary1D(ndarray(new Int32Array(0)), ndarray(new Int32Array(0)), "length==0");
testBinary1D(ndarray(new Int32Array(1)), ndarray(new Int32Array(1)), "length==1");
testBinary1D(A1, B1, "A, B");
testBinary1D(A1.lo(32), B1.hi(128 - 32), "A.lo(32), B.hi(128-32)");
testBinary1D(A1.step(-1), B1, "A.step(-1), B");
testBinary1D(A1, B1.step(-1), "A, B.step(-1)");
const A2 = ndarray(new DumbStorage(128) as any);
const B2 = ndarray(new DumbStorage(128) as any);
testBinary1D(ndarray(new DumbStorage(0) as any), ndarray(new DumbStorage(0) as any), "DS; length==0");
testBinary1D(ndarray(new DumbStorage(1) as any), ndarray(new DumbStorage(1) as any), "DS; length==0");
testBinary1D(A2, B2, "DS; A, B");
testBinary1D(A2.lo(32), B2.hi(128 - 32), "DS; A.lo(32), B.hi(128-32)");
testBinary1D(A2.step(-1), B2, "DS; A.step(-1), B");
testBinary1D(A2, B2.step(-1), "DS; A, B.step(-1)");
const X = ndarray(new Int32Array(64 * 64), [64, 64]);
const Y = ndarray(new Int32Array(64 * 64), [64, 64]);
function testBinary2D(P: ndarray, Q: ndarray, testName: string) {
for (let i = 0; i < X.shape[0]; ++i) {
for (let j = 0; j < X.shape[1]; ++j) {
X.set(i, j, -10000);
Y.set(i, j, -256);
}
}
t.equals(P.shape[0], Q.shape[0], testName + "; shape[0]");
t.equals(P.shape[1], Q.shape[1], testName + "; shape[1]");
for (let i = 0; i < P.shape[0]; ++i) {
for (let j = 0; j < P.shape[1]; ++j) {
Q.set(i, j, i * 1000 + j);
P.set(i, j, 0);
}
}
binary(P, Q, t, P.shape);
for (let i = 0; i < P.shape[0]; ++i) {
for (let j = 0; j < P.shape[1]; ++j) {
if (!(P.get(i, j) === i * 1000 + j + 1001)) {
t.fail(testName + "; encountered " + P.get(i, j) + " instead of " + (i * 1000 + j + 1001) + " at (" + i + "," + j + ")");
return;
}
}
}
t.pass(testName);
}
testBinary2D(X, Y, "X, Y");
testBinary2D(X.transpose(1, 0), Y.transpose(1, 0), "X.T, Y.T");
testBinary2D(X.transpose(1, 0), Y, "X.T, Y");
testBinary2D(X, Y.transpose(1, 0), "X, Y.T");
testBinary2D(X.hi(32, 32), Y.hi(32, 32), "X.hi(32,32), Y.hi(32,32)");
testBinary2D(X.hi(31, 31), Y.hi(31, 31), "X.hi(31,31), Y.hi(31,31)");
testBinary2D(X.hi(0, 32), Y.hi(0, 32), "X.hi(0,32), Y.hi(0,32)");
testBinary2D(X.transpose(1, 0).hi(0, 32), Y.hi(0, 32), "X.T.hi(0,32), Y.hi(0,32)");
testBinary2D(X.transpose(1, 0).hi(33, 33), Y.hi(33, 33), "X.T.hi(33,33), Y.hi(33,33)");
testBinary2D(X.transpose(1, 0).hi(31, 31), Y.hi(31, 31), "X.T.hi(31,31), Y.hi(31,31)");
t.end();
});
// browserify
import * as browserify from "browserify";
import * as vm from 'vm';
import * as path from 'path';
const cases = ["unary", "binary", "offset", "fill"];
bundleCasesFrom(0);
function bundleCasesFrom(i: number) {
if (i >= cases.length) return;
const b = browserify();
b.ignore("tape");
b.add(__dirname + "/" + cases[i] + ".js");
b.transform(path.normalize(__dirname + "/../cwise.js"));
tape(cases[i], (t) => { // Without nested tests, the asynchronous nature of bundle causes issues with tape...
b.bundle((err, src) => {
if (err) {
throw new Error("failed to bundle!");
}
vm.runInNewContext(src.toString(), {
test: t.test.bind(t),
Buffer,
Int8Array,
Int16Array,
Int32Array,
Float32Array,
Float64Array,
Uint8Array,
Uint16Array,
Uint32Array,
Uint8ClampedArray,
console: { log: console.log.bind(console) }
});
t.end();
});
});
bundleCasesFrom(i + 1);
}
// fill
tape("fill", (t) => {
const fill = cwise({
args: ["index", "array", "scalar"],
body(idx, out, f) {
out = f.apply(undefined, idx);
}
});
const xlen = 10;
const ylen = 5;
const array = ndarray(new Float32Array(xlen * ylen), [xlen, ylen]);
fill(array, (row: number, col: number) => {
return 0;
});
for (let i = 0; i < xlen; i++) {
for (let j = 0; j < ylen; j++) {
t.equals(array.get(i, j), 0, 'fill (' + i + ',' + j + ')');
}
}
fill(array, (row: number, col: number) => {
return 10 * (row + col);
});
for (let i = 0; i < xlen; i++) {
for (let j = 0; j < ylen; j++) {
t.equals(array.get(i, j), 10 * (i + j), 'fill (' + i + ',' + j + ')');
}
}
t.end();
});
// offset
tape("offset", (t) => {
const binary = cwise({
args: ["array", "array", { offset: [1], array: 1 }, "scalar", "shape", "index"],
body(a, b, c, t, s, idx) {
if (!(a === 0)) t.fail("idx:" + idx + ", shape:" + s + ",a:" + a);
a = c + b + 1000;
}
});
function testBinary1D(P: ndarray, Q: ndarray, testName: string) {
t.equals(P.shape[0], Q.shape[0] - 1, testName + "; shape");
for (let i = 0; i < P.shape[0]; ++i) {
Q.set(i, i);
P.set(i, 0);
}
Q.set(P.shape[0], P.shape[0]);
binary(P, Q.hi(Q.shape[0] - 1), t);
for (let i = 0; i < P.shape[0]; ++i) {
if (!(P.get(i) === 2 * i + 1001)) {
t.fail(testName + "; encountered " + P.get(i) + " instead of " + (2 * i + 1001) + " at " + i);
return;
}
}
t.pass(testName);
}
const A1 = ndarray(new Int32Array(128));
const B1 = ndarray(new Int32Array(129));
testBinary1D(ndarray(new Int32Array(0)), ndarray(new Int32Array(1)), "length==0");
testBinary1D(ndarray(new Int32Array(1)), ndarray(new Int32Array(2)), "length==1");
testBinary1D(A1, B1, "A, B");
testBinary1D(A1.lo(32), B1.lo(32), "A.lo(32), B.lo(32)");
testBinary1D(A1.step(-1), B1, "A.step(-1), B");
testBinary1D(A1, B1.step(-1), "A, B.step(-1)");
const A2 = ndarray(new DumbStorage(128) as any);
const B2 = ndarray(new DumbStorage(129) as any);
testBinary1D(ndarray(new DumbStorage(0) as any), ndarray(new DumbStorage(1) as any), "DS; length==0");
testBinary1D(ndarray(new DumbStorage(1) as any), ndarray(new DumbStorage(2) as any), "DS; length==1");
testBinary1D(A2, B2, "DS; A, B");
testBinary1D(A2.lo(32), B2.lo(32), "DS; A.lo(32), B.lo(32)");
testBinary1D(A2.step(-1), B2, "DS; A.step(-1), B");
testBinary1D(A2, B2.step(-1), "DS; A, B.step(-1)");
t.end();
});
// unary
tape("unary", (t) => {
const unary = cwise({
args: ["array"],
body(a) {
++a;
}
});
function testUnary1D(arr: ndarray, testName: string) {
for (let i = 0; i < arr.shape[0]; ++i) {
arr.set(i, i);
}
unary(arr);
for (let i = 0; i < arr.shape[0]; ++i) {
if (!(arr.get(i) === i + 1)) {
t.fail(testName + "; encountered " + arr.get(i) + " instead of " + (i + 1) + " at " + i);
return;
}
}
t.pass(testName);
}
const simple_zeros = ndarray(new Int32Array(4096));
testUnary1D(simple_zeros.hi(0), "simple_zeros.hi(0)");
testUnary1D(simple_zeros.hi(1), "simple_zeros.hi(1)");
testUnary1D(simple_zeros.hi(2), "simple_zeros.hi(2)");
testUnary1D(simple_zeros, "simple_zeros");
testUnary1D(simple_zeros.hi(31), "simple_zeros.hi(31)");
testUnary1D(simple_zeros.hi(32), "simple_zeros.hi(32)");
testUnary1D(simple_zeros.hi(33), "simple_zeros.hi(33)");
testUnary1D(simple_zeros.step(-1), "simple_zeros.step(-1)");
testUnary1D(simple_zeros.step(3), "simple_zeros.step(3)");
testUnary1D(simple_zeros.step(4), "simple_zeros.step(4)");
testUnary1D(simple_zeros.step(5).lo(10), "simple_zeros.step(5).lo(10)");
const custom_zeros = ndarray(new DumbStorage(4096) as any);
testUnary1D(custom_zeros.hi(0), "custom_zeros.hi(0)");
testUnary1D(custom_zeros.hi(1), "custom_zeros.hi(1)");
testUnary1D(custom_zeros.hi(2), "custom_zeros.hi(2)");
testUnary1D(custom_zeros, "custom_zeros");
testUnary1D(custom_zeros.hi(31), "custom_zeros.hi(31)");
testUnary1D(custom_zeros.hi(32), "custom_zeros.hi(32)");
testUnary1D(custom_zeros.hi(33), "custom_zeros.hi(33)");
testUnary1D(custom_zeros.step(-1), "custom_zeros.step(-1)");
testUnary1D(custom_zeros.step(3), "custom_zeros.step(3)");
testUnary1D(custom_zeros.step(4), "custom_zeros.step(4)");
testUnary1D(custom_zeros.step(5).lo(10), "custom_zeros.step(5).lo(10)");
function testUnary2D(arr: ndarray, testName: string) {
for (let i = 0; i < arr.shape[0]; ++i) {
for (let j = 0; j < arr.shape[1]; ++j) {
arr.set(i, j, i + j * arr.shape[0]);
}
}
unary(arr);
for (let i = 0; i < arr.shape[0]; ++i) {
for (let j = 0; j < arr.shape[1]; ++j) {
if (!(arr.get(i, j) === 1 + i + j * arr.shape[0])) {
t.fail(testName + "; encountered " + arr.get(i, j) + " instead of " + (1 + i + j * arr.shape[0]) + " at (" + i + "," + j + ")");
return;
}
}
}
t.pass(testName);
}
const M1 = ndarray(new Int32Array(128 * 128), [128, 128]);
testUnary2D(M1, "M");
testUnary2D(M1.hi(10, 10), "M.hi(10, 10)");
testUnary2D(M1.lo(100, 1), "M.lo(100,1)");
testUnary2D(M1.transpose(1, 0), "M.transpose(1,0)");
testUnary2D(M1.step(-1, 1), "M.step(-1, 1)");
testUnary2D(M1.step(-5, -2), "M.step(-5, -2)");
testUnary2D(M1.step(16, 3), "M.step(16, 3)");
const M2 = ndarray(new DumbStorage(128 * 128) as any, [128, 128]);
testUnary2D(M2, "DS; M");
testUnary2D(M2.hi(10, 10), "DS; M.hi(10, 10)");
testUnary2D(M2.lo(100, 1), "DS; M.lo(100,1)");
testUnary2D(M2.transpose(1, 0), "DS; M.transpose(1,0)");
testUnary2D(M2.step(-1, 1), "DS; M.step(-1, 1)");
testUnary2D(M2.step(-5, -2), "DS; M.step(-5, -2)");
testUnary2D(M2.step(16, 3), "DS; M.step(16, 3)");
t.end();
});
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for cwise 1.0
// Project: https://github.com/scijs/cwise#readme
// Definitions by: taoqf <https://github.com/taoqf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ArgType } from "cwise-compiler";
import * as ndarray from "ndarray";
declare function cwise(a: string | cwise.UserArgs): cwise.Return;
declare namespace cwise {
type Arg = ndarray | ((row: number, col: number) => number) | number[] | any;
type Return = (a: ndarray, ...b: Arg[]) => void;
interface UserArgs {
args: ArgType[];
pre?(a: number, ...args: any[]): void;
body(a: number, ...args: any[]): void;
post?(a: number, ...args: any[]): void;
funcName?: string;
blockSize?: number;
printCode?: boolean;
}
}
export = cwise;
+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",
"cwise-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+189
View File
@@ -0,0 +1,189 @@
/**
* Typescript definition tests for d3/d3-contour module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Contour from 'd3-contour';
import {
range,
thresholdSturges,
ThresholdArrayGenerator,
ThresholdCountGenerator
} from 'd3-array';
import { geoPath } from 'd3-geo';
import { randomNormal } from 'd3-random';
// -----------------------------------------------------------------------------
// Preparatory Steps
// -----------------------------------------------------------------------------
// Some test setup is based on Contour Plot II Golstein-Price function at https://bl.ocks.org/mbostock/f48ff9c1af4d637c9a518727f5fdfef5
const n = 256;
const m = 256;
const values: number[] = new Array(n * m);
for (let j = 0.5, k = 0; j < m; ++j) {
for (let i = 0.5; i < n; ++i, ++k) {
values[k] = goldsteinPrice(i / n * 4 - 2, 1 - j / m * 3);
}
}
function goldsteinPrice(x: number, y: number) {
return (1 + Math.pow(x + y + 1, 2) * (19 - 14 * x + 3 * x * x - 14 * y + 6 * x * x + 3 * y * y))
* (30 + Math.pow(2 * x - 3 * y, 2) * (18 - 32 * x + 12 * x * x + 48 * y - 36 * x * y + 27 * y * y));
}
let size: [number, number];
let boolFlag: boolean;
const thresholdArrayGen: ThresholdArrayGenerator<number> = (values: number[], min: number, max: number) => {
let thresholds: number[];
thresholds = [values[1], values[2], values[4]];
return thresholds;
};
let thresholdGenerator: ThresholdArrayGenerator<number> | ThresholdCountGenerator;
let pathStringMaybe: string | null;
let num: number;
const pathSolo = geoPath<any, d3Contour.ContourMultiPolygon>();
// -----------------------------------------------------------------------------
// Test Contour Generator
// -----------------------------------------------------------------------------
// Get contour generator -------------------------------------------------------
let contGen: d3Contour.Contours = d3Contour.contours();
// Configure contour generator =================================================
// size(...) -------------------------------------------------------------------
// set with chainability
contGen = contGen.size([n, m]);
size = contGen.size();
// smooth(...) -----------------------------------------------------------------
// set with chainability
contGen = contGen.smooth(true);
boolFlag = contGen.smooth();
// thresholds(...) -------------------------------------------------------------
// set with count
contGen = contGen.thresholds(10);
// set with array
const thresholds1 = range(1, 21)
.map(p => Math.pow(2, p));
contGen = contGen.thresholds(thresholds1);
// set with threshold array generator
contGen = contGen.thresholds(thresholdArrayGen); // mock
// set with threshold count generator
contGen = contGen.thresholds(thresholdSturges);
// get
thresholdGenerator = contGen.thresholds();
// Use contour generator =======================================================
pathStringMaybe = pathSolo(contGen(values)[0]);
// -----------------------------------------------------------------------------
// Test Contour Generator for Density Estimates
// -----------------------------------------------------------------------------
interface CustomDatum {
x: number;
y: number;
}
// Get contour generator -------------------------------------------------------
let contDensDefault: d3Contour.ContourDensity<[number, number]> = d3Contour.contourDensity();
let contDensCustom: d3Contour.ContourDensity<CustomDatum> = d3Contour.contourDensity<CustomDatum>();
// Configure contour generator =================================================
// x(...) ----------------------------------------------------------------------
// set with chainability
contDensCustom = contDensCustom.x((datum) => {
const d: CustomDatum = datum; // check passed in argument type
return d.x;
});
// get
const xAcc: (d: CustomDatum) => number = contDensCustom.x();
// y(...) ----------------------------------------------------------------------
// set with chainability
contDensCustom = contDensCustom.y((datum) => {
const d: CustomDatum = datum; // check passed in argument type
return d.y;
});
// get
const yAcc: (d: CustomDatum) => number = contDensCustom.y();
// size(...) -------------------------------------------------------------------
// set with chainability
contDensCustom = contDensCustom.size([900, 600]);
size = contDensCustom.size();
// cellSize(...) -----------------------------------------------------------------
// set with chainability
contDensCustom = contDensCustom.cellSize(3);
num = contDensCustom.cellSize();
// thresholds(...) -------------------------------------------------------------
// set with count
contDensCustom = contDensCustom.thresholds(10);
// set with array
contDensCustom = contDensCustom.thresholds([0.1, 0.25, 0.5, 0.75, 1]);
// set with threshold array generator
contDensCustom = contDensCustom.thresholds(thresholdArrayGen); // mock
// set with threshold count generator
contDensCustom = contDensCustom.thresholds(thresholdSturges);
// get
thresholdGenerator = contDensCustom.thresholds();
// bandwidth(...) --------------------------------------------------------------
// set with chainability
contDensCustom = contDensCustom.bandwidth(40);
// get
num = contDensCustom.bandwidth();
// Use contour generator =======================================================
const indNorm: CustomDatum[] = [];
const rX = randomNormal();
const rY = randomNormal(1, 2);
for (let i = 0; i < 1000; i++) {
indNorm.push({
x: rX(),
y: rY()
});
}
pathStringMaybe = pathSolo(contDensCustom(indNorm)[0]);
+246
View File
@@ -0,0 +1,246 @@
// Type definitions for d3-contour 1.1
// Project: https://d3js.org/d3-contour/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Hugues Stefanski <https://github.com/Ledragon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 1.1.0
import { MultiPolygon } from 'geojson';
import { ThresholdArrayGenerator, ThresholdCountGenerator } from 'd3-array';
/**
* An extended GeoJSON MultiPolygon representing a contour.
*/
export interface ContourMultiPolygon extends MultiPolygon {
/**
* Threshold value of the contour.
*/
value: number;
}
/**
* A contour generator which computes contour polygons by applying marching squares to a rectangular array of numeric values.
*
* For each threshold value, the contour generator constructs a GeoJSON MultiPolygon geometry object representing the area
* where the input values are greater than or equal to the threshold value.
* The geometry is in planar coordinates, where ⟨i + 0.5, j + 0.5⟩ corresponds to element i + jn in the input values array.
*
*/
export interface Contours {
/**
* Computes the contours for the given array of values, returning an array of GeoJSON MultiPolygon geometry objects.
* Each geometry object represents the area where the input values are greater than or equal to the corresponding threshold value;
* the threshold value for each geometry object is exposed as geometry.value.
*
* The returned geometry objects are typically passed to d3.geoPath to display,
* using null or d3.geoIdentity as the associated projection
*
* @param values Array of input values. The input values must be an array of length n×m where [n, m] is the contour generator’s size;
* furthermore, each values[i + jn] must represent the value at the position ⟨i, j⟩.
*/
(values: number[]): ContourMultiPolygon[];
/**
* Return the expected size of the input values grid, which defaults to [1,1].
*/
size(): [number, number];
/**
* Sets the expected size of the input values grid to the contour generator and returns the contour generator.
*
* @param size Size of the input values grid specified as an array [n, m]
* where n is the number of columns in the grid and m is the number of rows; n and m must be positive integers.
*/
size(size: [number, number]): this;
/**
* Returns the current smoothing flag, which defaults to true.
*/
smooth(): boolean;
/**
* Sets whether or not the generated contour polygons are smoothed using linear interpolation and returns the contour generator.
*
* @param smooth Flag to enable linear interpolation. The default is "true".
*/
smooth(smooth: boolean): this;
/**
* Returns the current threshold generator, which by default implements Sturges’ formula.
*/
thresholds(): ThresholdCountGenerator | ThresholdArrayGenerator<number>;
/**
* Sets the threshold generator to use the specified count and returns this contour generator.
* The input values’ extent will be uniformly divided into approximately count bins.
*
* @param count Expected number of threshold bins.
*/
thresholds(count: number): this;
/**
* Sets the threshold generator to the specified array and returns this contour generator.
*
* Thresholds are defined as an array of values [x0, x1, …].
* The first generated contour corresponds to the area where the input values are greater than or equal to x0;
* the second contour corresponds to the area where the input values are greater than or equal to x1, and so on.
* Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value;
* the threshold value is exposed as geometry.value.
*
* @param thresholds Array of thresholds to use.
*/
thresholds(thresholds: number[]): this;
/**
* Sets the threshold generator to the specified function and returns this contour generator.
*
* Thresholds are defined as an array of values [x0, x1, …].
* The first generated contour corresponds to the area where the input values are greater than or equal to x0;
* the second contour corresponds to the area where the input values are greater than or equal to x1, and so on.
* Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value;
* the threshold value is exposed as geometry.value.
*
* @param thresholds A threshold generator function. The threshold generator function is passed the array of input values
* as its argument and returns either an array of calculated thresholds, or the count of thresholds to use.
*/
thresholds(thresholds: ThresholdCountGenerator | ThresholdArrayGenerator<number>): this;
}
/**
* Construct a new contour generator with the default settings.
*/
export function contours(): Contours;
/**
* A contour generator for density estimates.
*/
export interface ContourDensity<Datum> {
/**
* Estimates the density contours for the given array of data, returning an array of GeoJSON MultiPolygon geometry objects.
* Each geometry object represents the area where the estimated number of points per square pixel is greater than or equal to
* the corresponding threshold value; the threshold value for each geometry object is exposed as geometry.value.
* The returned geometry objects are typically passed to d3.geoPath to display, using null or d3.geoIdentity as the associated projection.
* See also d3.contours.
*
* The x- and y-coordinate for each data point are computed using density.x and density.y.
* The generated contours are only accurate within the estimator’s defined size.
*
* @param data Array of input data.
*/
(data: Datum[]): ContourMultiPolygon[];
/**
* Returns the current x-coordinate accessor.
* The default x-coordinate accessor is a functions which accepts as input a two-element array of numbers
* and returns the element at index 0.
*/
x(): (d: Datum) => number;
/**
* Sets the x-coordinate accessor and returns the density contour estimator.
*
* @param x An x-coordinate accessor function, which accepts as input an element of the input data array and returns the
* x-coordinate.
*/
x(x: (d: Datum) => number): this;
/**
* Returns the current y-coordinate accessor.
* The default y-coordinate accessor is a functions which accepts as input a two-element array of numbers
* and returns the element at index 1.
*/
y(): (d: Datum) => number;
/**
* Sets the y-coordinate accessor and returns the density contour estimator.
*
* @param y An y-coordinate accessor function, which accepts as input an element of the input data array and returns the
* y-coordinate.
*/
y(y: (d: Datum) => number): this;
/**
* Returns the current size, which defaults to [960, 500].
*/
size(): [number, number];
/**
* Sets the size of the density estimator to the specified bounds and returns the density contour estimator.
*
* @param size The size is specified as an array [width, height], where width is the maximum x-value and height is the maximum y-value.
*/
size(size: [number, number]): this;
/**
* Returns the current cell size, which defaults to 4.
*/
cellSize(): number;
/**
* Sets the size of individual cells in the underlying bin grid to the specified positive integer and returns the density contour estimator.
*
* The cell size is rounded down to the nearest power of two. Smaller cells produce more detailed contour polygons, but are more expensive to compute.
*
* @param cellSize Cell size, a positive integer.
*/
cellSize(cellSize: number): this;
/**
* Returns the current threshold generator, which by default generates about twenty nicely-rounded density thresholds.
*/
thresholds(): ThresholdCountGenerator | ThresholdArrayGenerator<number>;
/**
* Sets the threshold generator to use the specified count and returns this density contour estimator.
* Approximately count uniformly-spaced nicely-rounded thresholds will be generated.
*
* @param count Expected number of thresholds.
*/
thresholds(count: number): this;
/**
* Sets the threshold generator to the specified array and returns this density contour estimator.
*
* Thresholds are defined as an array of values [x0, x1, …]. The first generated density contour corresponds to the area
* where the estimated density is greater than or equal to x0; the second contour corresponds to the area
* where the estimated density is greater than or equal to x1, and so on.
* Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value;
* the threshold value is exposed as geometry.value. The first value x0 should typically be greater than zero.
*
* @param thresholds Array of thresholds to use.
*/
thresholds(thresholds: number[]): this;
/**
* Sets the threshold generator to the specified function and returns this density contour estimator.
*
* Thresholds are defined as an array of values [x0, x1, …]. The first generated density contour corresponds to the area
* where the estimated density is greater than or equal to x0; the second contour corresponds to the area
* where the estimated density is greater than or equal to x1, and so on.
* Thus, there is exactly one generated MultiPolygon geometry object for each specified threshold value;
* the threshold value is exposed as geometry.value. The first value x0 should typically be greater than zero.
*
* @param thresholds A threshold generator function. The threshold generator function is passed the array of input values
* as its argument and returns either an array of calculated thresholds, or the count of thresholds to use.
*/
thresholds(thresholds: ThresholdCountGenerator | ThresholdArrayGenerator<number>): this;
/**
* Returns the current bandwidth, which defaults to 20.4939….
*/
bandwidth(): number;
/**
* Sets the bandwidth (the standard deviation) of the Gaussian kernel and returns the density contour estimator.
*
* @param bandwidth Bandwidth (the standard deviation) of the Gaussian kernel.
* The specified bandwidth is currently rounded to the nearest supported value by this implementation, and must be nonnegative.
*/
bandwidth(bandwidth: number): this;
}
/**
* Construct a new contour generator for density estimates with the default settings.
*
* The default settings assume that, the elements of the data array used
* with the density contour generator are two-element arrays. The first element
* corresponds to the x-dimension, the second to the y-dimension.
*/
export function contourDensity(): ContourDensity<[number, number]>;
/**
* Construct a new contour generator for density estimates.
*
* The generic refers to the data type of an element in the data array
* used with the density contour generator.
*
* Important: ensure that the x- and y-accessor functions are configured to
* match the data type used for the generic Datum.
*/
export function contourDensity<Datum>(): ContourDensity<Datum>;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"d3-contour-tests.ts"
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"unified-signatures": false
}
}
+10 -10
View File
@@ -87,7 +87,7 @@ export interface PolynomialEasingFactory {
*
* @param e Exponent for polynomial easing.
*/
exponent(e: number): PolynomialEasingFactory;
exponent(e: number): PolynomialEasingFactory;
}
/**
@@ -240,7 +240,7 @@ export interface BackEasingFactory {
*
* @param s Overshoot parameter
*/
overshoot(s: number): BackEasingFactory;
overshoot(s: number): BackEasingFactory;
}
/**
@@ -282,14 +282,14 @@ export interface ElasticEasingFactory {
*
* @param a Amplitude for elastic easing.
*/
amplitude(a: number): ElasticEasingFactory;
/**
* Returns a new elastic easing with the specified amplitude a.
* Defaults to 0.3,if not specified.
*
* @param p Period for elastic easing.
*/
period(p: number): ElasticEasingFactory;
amplitude(a: number): ElasticEasingFactory;
/**
* Returns a new elastic easing with the specified amplitude a.
* Defaults to 0.3,if not specified.
*
* @param p Period for elastic easing.
*/
period(p: number): ElasticEasingFactory;
}
/**
+34 -4
View File
@@ -3,10 +3,10 @@
// Definitions by: Hugues Stefanski <https://github.com/Ledragon>, Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="geojson" />
// Last module patch version validated against: 1.6.1
import * as GeoJSON from 'geojson';
// ----------------------------------------------------------------------
// Shared Interfaces and Types
// ----------------------------------------------------------------------
@@ -926,7 +926,8 @@ export interface GeoPath<This, DatumObject extends GeoPermissibleObjects> {
*
* Any additional arguments are passed along to the pointRadius accessor.
*
* If the rendering context is null, the function returns an SVG Path string, otherwise the function renders to the current context.
* IMPORTANT: If the rendering context of the geoPath generator is null,
* then the geoPath is returned as an SVG path data string.
*
* Separate path elements are typically slower than a single path element. However, distinct path elements are useful for styling and interation (e.g., click or mouseover).
* Canvas rendering (see path.context) is typically faster than SVG, but requires more effort to implement styling and interaction.
@@ -935,7 +936,36 @@ export interface GeoPath<This, DatumObject extends GeoPermissibleObjects> {
*
* @param object An object to be rendered.
*/
(this: This, object: DatumObject, ...args: any[]): string | undefined;
(this: This, object: DatumObject, ...args: any[]): string | null;
/**
* Renders the given object, which may be any GeoJSON feature or geometry object:
*
* + Point - a single position.
* + MultiPoint - an array of positions.
* + LineString - an array of positions forming a continuous line.
* + MultiLineString - an array of arrays of positions forming several lines.
* + Polygon - an array of arrays of positions forming a polygon (possibly with holes).
* + MultiPolygon - a multidimensional array of positions forming multiple polygons.
* + GeometryCollection - an array of geometry objects.
* + Feature - a feature containing one of the above geometry objects.
* + FeatureCollection - an array of feature objects.
*
* The type Sphere is also supported, which is useful for rendering the outline of the globe; a sphere has no coordinates.
*
*
* Any additional arguments are passed along to the pointRadius accessor.
*
* IMPORTANT: If the geoPath generator has been configured with a rendering context,
* then the geoPath is rendered to this context as a sequence of path method calls and this function returns void.
*
* Separate path elements are typically slower than a single path element. However, distinct path elements are useful for styling and interation (e.g., click or mouseover).
* Canvas rendering (see path.context) is typically faster than SVG, but requires more effort to implement styling and interaction.
*
* The first generic type of the GeoPath generator used, must correspond to the "this" context bound to the function upon invocation.
*
* @param object An object to be rendered.
*/
(this: This, object: DatumObject, ...args: any[]): void;
/**
* Returns the projected planar area (typically in square pixels) for the specified GeoJSON object.
+258
View File
@@ -0,0 +1,258 @@
/**
* Typescript definition tests for d3/d3-sankey module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Sankey from 'd3-sankey';
import {select, Selection} from 'd3-selection';
// ---------------------------------------------------------------------------
// Preparatory Steps
// ---------------------------------------------------------------------------
// Create interfaces for the user-provided node/link attributes, which are NOT mandated or calculated by
// the Sankey layout generator. The latter are reflected in the SankeyNode and SankeyLink interfaces provided
// by the definitions file
interface SNodeExtra {
nodeId: number;
name: string;
}
interface SLinkExtra {
uom: string;
}
// For convenience
type SNode = d3Sankey.SankeyNode<SNodeExtra, SLinkExtra>;
type SLink = d3Sankey.SankeyLink<SNodeExtra, SLinkExtra>;
interface DAG {
nodes: SNode[];
links: SLink[];
}
const graph: DAG = {
nodes: [{
nodeId: 0,
name: "node0"
}, {
nodeId: 1,
name: "node1"
}, {
nodeId: 2,
name: "node2"
}, {
nodeId: 3,
name: "node3"
}, {
nodeId: 4,
name: "node4"
}],
links: [{
source: 0,
target: 2,
value: 2,
uom: 'Widget(s)'
}, {
source: 1,
target: 2,
value: 2,
uom: 'Widget(s)'
}, {
source: 1,
target: 3,
value: 2,
uom: 'Widget(s)'
}, {
source: 0,
target: 4,
value: 2,
uom: 'Widget(s)'
}, {
source: 2,
target: 3,
value: 2,
uom: 'Widget(s)'
}, {
source: 2,
target: 4,
value: 2,
uom: 'Widget(s)'
}, {
source: 3,
target: 4,
value: 4,
uom: 'Widget(s)'
}]
};
let sNodes: SNode[];
let sLinks: SLink[];
let num: number;
let numMaybe: number | undefined;
let str: string;
let size: [number, number];
const svgLinkPaths = select<SVGSVGElement, undefined>('svg').selectAll<SVGPathElement, SLink>('.linkPath'); // assume mock DOM
// ---------------------------------------------------------------------------
// Obtain SankeyLayout Generator
// ---------------------------------------------------------------------------
let slgDefault: d3Sankey.SankeyLayout<{}, {}> = d3Sankey.sankey();
let slgDAG: d3Sankey.SankeyLayout<SNodeExtra, SLinkExtra> = d3Sankey.sankey<SNodeExtra, SLinkExtra>();
// ---------------------------------------------------------------------------
// NodeWidth
// ---------------------------------------------------------------------------
// Set -----------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.nodeWidth(32);
// Get -----------------------------------------------------------------------
num = slgDAG.nodeWidth();
// ---------------------------------------------------------------------------
// NodePadding
// ---------------------------------------------------------------------------
// Set -----------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.nodePadding(8);
// Get -----------------------------------------------------------------------
num = slgDAG.nodePadding();
// ---------------------------------------------------------------------------
// Size
// ---------------------------------------------------------------------------
// Set -----------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.size([1200, 800]);
// Get -----------------------------------------------------------------------
size = slgDAG.size();
// ---------------------------------------------------------------------------
// Nodes
// ---------------------------------------------------------------------------
// Set -----------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.nodes(graph.nodes);
// Get -----------------------------------------------------------------------
sNodes = slgDAG.nodes();
// ---------------------------------------------------------------------------
// Links
// ---------------------------------------------------------------------------
// Set -----------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.links(graph.links);
// Get -----------------------------------------------------------------------
sLinks = slgDAG.links();
// ---------------------------------------------------------------------------
// Compute Layout
// ---------------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.layout(22);
// ---------------------------------------------------------------------------
// Relayout
// ---------------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.relayout();
// ---------------------------------------------------------------------------
// Obtain and Use Link SVG Path Generator
// ---------------------------------------------------------------------------
let pathGen: d3Sankey.SankeyLinkPathGenerator<SNodeExtra, SLinkExtra>;
pathGen = slgDAG.link();
// Adjust Link SVG Path Generator curvature ----------------------------------
// test return type
pathGen = pathGen.curvature(0.6);
num = pathGen.curvature();
// uses
let svgPathString: string = pathGen(slgDAG.links()[0]);
svgLinkPaths.attr('d', pathGen);
// ---------------------------------------------------------------------------
// Shape test Node/Link related interfaces and types
// ---------------------------------------------------------------------------
// Sankey Node --------------------------------------------------------------
let sNode = sNodes[0];
// User-specified extra properties:
num = sNode.nodeId;
str = sNode.name;
// Sankey Layout calculated (if layout has been run, otherwise undefined):
numMaybe = sNode.dx;
numMaybe = sNode.x;
numMaybe = sNode.dy;
numMaybe = sNode.y;
numMaybe = sNode.value;
let linksArrMaybe: SLink[] | undefined;
linksArrMaybe = sNode.sourceLinks;
linksArrMaybe = sNode.targetLinks;
// Sankey Link --------------------------------------------------------------
let sLink = sLinks[0];
// User-specified extra properties:
str = sLink.uom;
// Sankey Layout mandated link properties:
num = sLink.value;
// Node depending on initialization strategy and whether
// layout(...) was invoked, the source and target nodes may be numbers
// objects without the Sankey layout coordinates, or objects with calculated
// information
let numOrSankeyNode: number | SNode;
numOrSankeyNode = sLink.source;
numOrSankeyNode = sLink.target;
// Sankey Layout calculated (if layout has been run, otherwise undefined):
numMaybe = sLink.sy;
numMaybe = sLink.ty;
numMaybe = sLink.dy;
+267
View File
@@ -0,0 +1,267 @@
// Type definitions for D3JS d3-sankey module 0.4
// Project: https://github.com/d3/d3-sankey/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 0.4.2
/**
* A helper interface as an extension reference for user-provided properties of
* nodes and links in the graph, which are not required or calculated by
* the Sankey Layout Generator
*/
export interface SankeyExtraProperties { [key: string]: any; }
/**
* Helper interface to define the properties of Sankey Nodes. Calculated properties may only be defined,
* once the layout(...) method of the Sankey layout generator has been invoked.
*
* The first generic N refers to user-defined properties contained in the node data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyNodeMinimal interface.
*
* The second generic L refers to user-defined properties contained in the link data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyLinkMinimal interface.
*/
export interface SankeyNodeMinimal<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
/**
* Array of links which have this node as their source.
* This property is calculated internally by the Sankey layout generator.
*/
sourceLinks?: Array<SankeyLink<N, L>>;
/**
* Array of links which have this node as their target.
* This property is calculated internally by the Sankey layout generator.
*/
targetLinks?: Array<SankeyLink<N, L>>;
/**
* Node value calculated by Sankey Layout Generator based on values of incoming and outgoing links
*/
value?: number;
/**
* Node horizontal position calculated by Sankey layout generator
*/
x?: number;
/**
* Node width calculated by Sankey layout generator
*/
dx?: number;
/**
* Node vertical position (depth) calculated by Sankey layout generator
*/
y?: number;
/**
* Node height (vertical extent based on node value) calculated by Sankey layout generator
*/
dy?: number;
}
/**
* Sankey Node type including both user-defined node data elements as well as those
* calculated once the layout(...) method of the Sankey layout generators has been invoked.
*
* The first generic N refers to user-defined properties contained in the node data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyNodeMinimal interface.
*
* The second generic L refers to user-defined properties contained in the link data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyLinkMinimal interface.
*/
export type SankeyNode<N extends SankeyExtraProperties, L extends SankeyExtraProperties> = N & SankeyNodeMinimal<N, L>;
/**
* Helper interface to define the properties of Sankey Links. Calculated properties may only be defined,
* once the layout(...) method of the Sankey layout generator has been invoked.
*
* The first generic N refers to user-defined properties contained in the node data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyNodeMinimal interface.
*
* The second generic L refers to user-defined properties contained in the link data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyLinkMinimal interface.
*/
export interface SankeyLinkMinimal<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
/**
* Source node of the link. For convenience, when initializing a Sankey layout, source may be the index of the source node in the nodes array
* passed into the Sankey layout generator. Once the layout(...) method is invoked, the numeric index will be replaced with the corresponding
* source node object.
*/
source: number | SankeyNode<N, L>;
/**
* Target node of the link. For convenience, when initializing a Sankey layout, target may be the index of the target node in the nodes array
* passed into the Sankey layout generator. Once the layout(...) method is invoked, the numeric index will be replaced with the corresponding
* target node object.
*/
target: number | SankeyNode<N, L>;
/**
* Value of the link
*/
value: number;
/**
* Link breadth calculated by Sankey layout generator based on the link value
*/
dy?: number;
/**
* Vertical starting position of the link (at source node) calculated by Sankey layout generator
*/
sy?: number;
/**
* Vertical end position of the link (at target node) calculated by Sankey layout generator
*/
ty?: number;
}
/**
* Sankey Link type including both user-defined link data elements, those required by the Sankey layout generator,
* as well as those calculated once the layout(...) method of the layout generator has been invoked.
*
* The first generic N refers to user-defined properties contained in the node data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyNodeMinimal interface.
*
* The second generic L refers to user-defined properties contained in the link data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyLinkMinimal interface.
*/
export type SankeyLink<N extends SankeyExtraProperties, L extends SankeyExtraProperties> = L & SankeyLinkMinimal<N, L>;
/**
* An svg path generator factory for the link paths in a calculated Sankey Layout.
*/
export interface SankeyLinkPathGenerator<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
/**
* Return svg path string for a given link.
*
* IMPORTANT: Only invoke for link data with Sankey Layout information previously calculated.
*
* @param link A Sankey diagram link, for which the layout has already been calculated.
*/
(link: SankeyLink<N, L>): string;
/**
* Returns the current curvature used to calculate svg paths for links.
* The default curvature is 0.5.
*/
curvature(): number;
/**
* Set the curvature used to calculate svg paths for links and return the updated link path generator.
*
* @param curvature Curvature to be used when calculating svg paths for links. The default curvature is 0.5.
*/
curvature(curvature: number): this;
}
/**
* A Sankey layout generator.
*
* The first generic N refers to user-defined properties contained in the node data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyNodeMinimal interface.
*
* The second generic L refers to user-defined properties contained in the link data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyLinkMinimal interface.
*/
export interface SankeyLayout<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
/**
* Return the current node width, which defaults to 24.
*/
nodeWidth(): number;
/**
* Set the node width to the specified number and return this Sankey layout generator.
*
* @param width Width of node in pixels, which defaults to 24.
*/
nodeWidth(width: number): this;
/**
* Return the current node padding, which defaults to 8.
*
* Node padding refers to the vertical space between nodes which occupy the same horizontal space.
*/
nodePadding(): number;
/**
* Set the node padding to the specified number and return this Sankey layout generator.
*
* Node padding refers to the vertical space between nodes which occupy the same horizontal space.
*
* @param padding Node padding in pixels, which defaults to 8.
*/
nodePadding(padding: number): this;
/**
* Return the current array of nodes, which defaults to [].
*/
nodes(): Array<SankeyNode<N, L>>;
/**
* Set the sankey generator's nodes to the specified array of objects and returns this sankey layout generator.
*
* @param nodes Array of nodes.
*/
nodes(nodes: Array<SankeyNode<N, L>>): this;
/**
* Return the current array of links, which defaults to [].
*/
links(): Array<SankeyLink<N, L>>;
/**
* Set the sankey generator's links to the specified array of objects and returns this sankey layout generator.
*
* @param links Array of links.
*/
links(links: Array<SankeyLink<N, L>>): this;
/**
* Runs the sankey layout algorithm updating the nodes and links with their respective layout information and returns this sankey generator.
*
* @param iterations Number of passes to be used in the iterative relaxation algorithm for node placement.
*/
layout(iterations: number): this;
/**
* Recalculate the depth of links and return this Sankey layout generator.
* This methods is primarily used when a node is moved vertically, e.g. using d3-drag.
*/
relayout(): this;
/**
* Return the current layout size in pixels. The size is a two element array of [width, height] which defaults to [1, 1].
*/
size(): [number, number];
/**
* Set the size of the layout and return this Sankey layout generator.
*
* @param size A two element array of [width, height] in pixels which defaults to [1, 1].
*/
size(size: [number, number]): this;
/**
* Return a Sankey link path generator for the links based on the calculated Sankey diagram layout.
* The link path generator can be invoked as a function being passed as its argument a link object
* with calculated layout information. It returns the computed <svg> path string for the link.
* By default the link path generator uses a curvature of 0.5.
*/
link(): SankeyLinkPathGenerator<N, L>;
}
/**
* Get a Sankey layout generator.
*
* Invoking sankey() without generics, means the node type and link type assume no user-defined attributes, i.e.
* only the attributes internally used by the Sankey layout generator.
*/
export function sankey(): SankeyLayout<{}, {}>;
/**
* Get a Sankey layout generator.
*
* The first generic N refers to user-defined properties contained in the node data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyNodeMinimal interface.
*
* The second generic L refers to user-defined properties contained in the link data passed into
* Sankey layout generator. These properties are IN EXCESS to the properties explicitly identified in the
* SankeyLinkMinimal interface.
*/
export function sankey<N extends SankeyExtraProperties, L extends SankeyExtraProperties>(): SankeyLayout<N, L>;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"d3-sankey-tests.ts"
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"unified-signatures": false
}
}
+13 -7
View File
@@ -1,13 +1,19 @@
import * as deepmerge from "deepmerge";
const x = { foo: { bar: 3 },
array: [ { does: 'work', too: [ 1, 2, 3 ] } ] };
const y = { foo: { baz: 4 },
const x = {
foo: { bar: 3 },
array: [{ does: 'work', too: [1, 2, 3] }]
};
const y = {
foo: { baz: 4 },
quux: 5,
array: [ { does: 'work', too: [ 4, 5, 6 ] }, { really: 'yes' } ] };
array: [{ does: 'work', too: [4, 5, 6] }, { really: 'yes' }]
};
const expected = { foo: { bar: 3, baz: 4 },
array: [ { does: 'work', too: [ 1, 2, 3, 4, 5, 6 ] }, { really: 'yes' } ],
quux: 5 };
const expected = {
foo: { bar: 3, baz: 4 },
array: [{ does: 'work', too: [1, 2, 3, 4, 5, 6] }, { really: 'yes' }],
quux: 5
};
const result = deepmerge<any>(x, y);
+101
View File
@@ -0,0 +1,101 @@
function dwtOnReady() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer'); // Get the Dynamic Web TWAIN object that is embeded in the div with id 'dwtcontrolContainer'
if (DWObject) {
let count = DWObject.SourceCount;
if (count === 0) {
DWObject.CloseSourceManager();
DWObject.ImageCaptureDriverType = 0;
DWObject.OpenSourceManager();
count = DWObject.SourceCount;
}
}
}
function acquireImage() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
if (DWObject) {
DWObject.SelectSourceByIndex(0); // Use method SelectSourceByIndex to avoid the 'Select Source' dialog
DWObject.OpenSource();
DWObject.IfDisableSourceAfterAcquire = true; // Scanner source will be disabled/closed automatically after the scan.
DWObject.AcquireImage({}, () => {}, (errorCode: number, errorString: string) => {DWObject.CloseSource(); });
}
}
function registerEvent() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
if (DWObject) {
// The event OnPostTransfer fires after each image is scanned and transferred
DWObject.RegisterEvent("OnPostTransfer", function () {});
// The event OnPostLoad fires after the images from a local directory have been loaded into the control
DWObject.RegisterEvent("OnPostLoad", function () {});
// The event OnMouseClick fires when the mouse clicks on an image on Dynamic Web TWAIN viewer
DWObject.RegisterEvent("OnMouseClick", function () {});
// The event OnTopImageInTheViewChanged fires when the top image currently displayed in the viewer changes
DWObject.RegisterEvent("OnTopImageInTheViewChanged", function (index: number) {
DWObject.CurrentImageIndexInBuffer = index;
});
}
}
function editImage() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
if (DWObject) {
if (DWObject.HowManyImagesInBuffer > 0)
DWObject.RotateLeft(DWObject.CurrentImageIndexInBuffer);
if (DWObject.HowManyImagesInBuffer > 0)
DWObject.RotateRight(DWObject.CurrentImageIndexInBuffer);
if (DWObject.HowManyImagesInBuffer > 0)
DWObject.Mirror(DWObject.CurrentImageIndexInBuffer);
if (DWObject.HowManyImagesInBuffer > 0)
DWObject.Flip(DWObject.CurrentImageIndexInBuffer);
}
}
function showImageEditor() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
if (DWObject) {
DWObject.ShowImageEditor();
}
}
function saveImage() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
if (DWObject) {
DWObject.ConvertToGrayScale(DWObject.CurrentImageIndexInBuffer);
DWObject.SaveAsJPEG("DynamicWebTWAIN.jpg", DWObject.CurrentImageIndexInBuffer);
DWObject.SaveAllAsMultiPageTIFF("DynamicWebTWAIN.tiff", () => {}, (errorCode: number, errorString: string) => {});
DWObject.SaveAllAsPDF("DynamicWebTWAIN.pdf", () => {}, (errorCode: number, errorString: string) => {});
}
}
function updateLargeViewer() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
let DWObjectLargeViewer = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainerLargeViewer');
if (DWObject) {
DWObject.CopyToClipboard(DWObject.CurrentImageIndexInBuffer); // Copy the current image in the thumbnail to clipboard in DIB format.
DWObjectLargeViewer.LoadDibFromClipboard(); // Load the image from Clipboard into the large viewer.
}
}
function uploadImage() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
if (DWObject) {
DWObject.HTTPPort = 80;
DWObject.IfSSL = false;
DWObject.HTTPUploadThroughPost("www.dynamsoft.com", DWObject.CurrentImageIndexInBuffer, "upload", "tmp.jpg", () => {}, (errorCode: number, errorString: string) => {});
}
}
function downloadImage() {
let DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
if (DWObject) {
DWObject.HTTPPort = 80;
DWObject.HTTPDownload("www.dynamsoft.com", "img.png", () => {}, (errorCode: number, errorString: string) => {});
}
}
+3459
View File
File diff suppressed because it is too large Load Diff
@@ -17,6 +17,6 @@
},
"files": [
"index.d.ts",
"path-to-regexp-tests.ts"
"dwt-tests.ts"
]
}
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "dtslint/dt.json",
"rules": {
"max-line-length": [false],
"no-trailing-whitespace": false,
"space-before-function-paren": false,
"only-arrow-functions": [false]
}
}
@@ -2,6 +2,6 @@
import ere = require("element-resize-event");
var domNode: Element = null;
ere(domNode, (): void => {
});
ere(domNode, (): void => {});
ere.unbind(domNode, (): void => {});
+7 -5
View File
@@ -1,8 +1,10 @@
// Type definitions for element-resize-event 1.0.1
// Type definitions for element-resize-event 2.0.9
// Project: https://github.com/KyleAMathews/element-resize-event
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>, Pierre-Luc Gregoire <https://github.com/plgregoire>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function elementResizeEvent(domNode: Element, callback: () => void): void;
export = elementResizeEvent;
export = element_resize_event;
declare function element_resize_event(omNode: Element, callback: () => void): void;
declare namespace element_resize_event {
function unbind(omNode: Element, callback: () => void): void;
}
+11
View File
@@ -105,6 +105,17 @@ App.userController = Em.Object.create({
})
});
Ember.Helper.helper((params) => {
let cents = params[0];
return `${cents * 0.01}`;
});
Ember.Helper.helper((params, hash) => {
let cents = params[0];
let currency = hash.currency;
return `${currency}${cents * 0.01}`;
});
Handlebars.registerHelper('highlight', (property: string, options: any) =>
new Handlebars.SafeString('<span class="highlight">' + "some value" + '</span>'));
+7 -7
View File
@@ -548,9 +548,9 @@ declare namespace Ember {
toArray(): any[];
uniq(): Enumerable;
without(value: any): Enumerable;
'@each': EachProxy;
'@each': EachProxy;
Boolean: boolean;
'[]': any[];
'[]': any[];
firstObject: any;
hasEnumerableObservers: boolean;
lastObject: any;
@@ -630,8 +630,8 @@ declare namespace Ember {
unshiftObject(object: any): any;
unshiftObjects(objects: any[]): any[];
without(value: any): Enumerable;
'[]': any[];
'@each': EachProxy;
'[]': any[];
'@each': EachProxy;
Boolean: boolean;
firstObject: any;
hasEnumerableObservers: boolean;
@@ -1030,7 +1030,7 @@ declare namespace Ember {
toArray(): any[];
uniq(): Enumerable;
without(value: any): Enumerable;
'[]': any[];
'[]': any[];
firstObject: any;
hasEnumerableObservers: boolean;
lastObject: any;
@@ -1137,7 +1137,7 @@ declare namespace Ember {
service(name?: string): Service;
};
class Helper extends Object {
static helper( h: (a: any) => any): Helper;
static helper( h: (params: any, hash?: any) => any): Helper;
compute(params: any[], hash: any): any;
recompute(params: any[], hash: any): any;
}
@@ -1291,7 +1291,7 @@ declare namespace Ember {
toArray(): any[];
uniq(): Enumerable;
without(value: any): Enumerable;
'[]': any[];
'[]': any[];
firstObject: any;
hasEnumerableObservers: boolean;
lastObject: any;
+65 -19
View File
@@ -1,6 +1,6 @@
import * as React from "react";
import {shallow, mount, render, ShallowWrapper, ReactWrapper} from "enzyme";
import {Component, ReactElement, HTMLAttributes, ComponentClass, StatelessComponent} from "react";
import { shallow, mount, render, ShallowWrapper, ReactWrapper } from "enzyme";
import { Component, ReactElement, HTMLAttributes, ComponentClass, StatelessComponent } from "react";
// Help classes/interfaces
interface MyComponentProps {
@@ -27,9 +27,11 @@ const MyStatelessComponent = (props: StatelessProps) => <span />;
// ShallowWrapper
function ShallowWrapperTest() {
let shallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState> =
shallow<MyComponentProps, MyComponentState>(<MyComponent stringProp="value"/>);
shallow<MyComponentProps, MyComponentState>(<MyComponent stringProp="value" />);
let reactElement: ReactElement<any>;
let reactElements: Array<ReactElement<any>>;
let domElement: Element;
let boolVal: boolean;
let stringVal: string;
let numOrStringVal: number | string;
@@ -44,7 +46,7 @@ function ShallowWrapperTest() {
}
function test_shallow_options() {
shallow(<MyComponent stringProp="1"/>, {
shallow(<MyComponent stringProp="1" />, {
context: {
test: "a",
},
@@ -80,19 +82,19 @@ function ShallowWrapperTest() {
}
function test_contains() {
boolVal = shallowWrapper.contains(<div className="foo bar"/>);
boolVal = shallowWrapper.contains(<div className="foo bar" />);
}
function test_containsMatchingElement() {
boolVal = shallowWrapper.contains(<div className="foo bar"/>);
boolVal = shallowWrapper.contains(<div className="foo bar" />);
}
function test_containsAllMatchingElements() {
boolVal = shallowWrapper.containsAllMatchingElements([<div className="foo bar"/>]);
boolVal = shallowWrapper.containsAllMatchingElements([<div className="foo bar" />]);
}
function test_containsAnyMatchingElement() {
boolVal = shallowWrapper.containsAnyMatchingElements([<div className="foo bar"/>]);
boolVal = shallowWrapper.containsAnyMatchingElements([<div className="foo bar" />]);
}
function test_dive() {
@@ -104,15 +106,15 @@ function ShallowWrapperTest() {
bar: any;
}
const diveWrapper: ShallowWrapper<TmpProps, TmpState> = shallowWrapper.dive<TmpProps, TmpState>({ context: { foobar: 'barfoo' }});
const diveWrapper: ShallowWrapper<TmpProps, TmpState> = shallowWrapper.dive<TmpProps, TmpState>({ context: { foobar: 'barfoo' } });
}
function test_equals() {
boolVal = shallowWrapper.equals(<div className="foo bar"/>);
boolVal = shallowWrapper.equals(<div className="foo bar" />);
}
function test_matchesElement() {
boolVal = shallowWrapper.matchesElement(<div className="foo bar"/>);
boolVal = shallowWrapper.matchesElement(<div className="foo bar" />);
}
function test_hasClass() {
@@ -196,6 +198,18 @@ function ShallowWrapperTest() {
reactElement = shallowWrapper.get(1);
}
function test_getNode() {
reactElement = shallowWrapper.getNode();
}
function test_getNodes() {
reactElements = shallowWrapper.getNodes();
}
function test_getDOMNode() {
domElement = shallowWrapper.getDOMNode();
}
function test_at() {
shallowWrapper = shallowWrapper.at(1);
}
@@ -208,6 +222,15 @@ function ShallowWrapperTest() {
shallowWrapper = shallowWrapper.last();
}
function test_slice() {
shallowWrapper = shallowWrapper.slice(1);
shallowWrapper = shallowWrapper.slice(1, 3);
}
function test_tap() {
shallowWrapper.tap((intercepter) => { });
}
function test_state() {
const state: MyComponentState = shallowWrapper.state();
const prop: string = shallowWrapper.state('stateProperty');
@@ -333,9 +356,11 @@ function ShallowWrapperTest() {
// ReactWrapper
function ReactWrapperTest() {
let reactWrapper: ReactWrapper<MyComponentProps, MyComponentState> =
mount<MyComponentProps, MyComponentState>(<MyComponent stringProp="value"/>);
mount<MyComponentProps, MyComponentState>(<MyComponent stringProp="value" />);
let reactElement: ReactElement<any>;
let reactElements: Array<ReactElement<any>>;
let domElement: Element;
let boolVal: boolean;
let stringVal: string;
let elementWrapper: ReactWrapper<HTMLAttributes<{}>, {}>;
@@ -355,7 +380,7 @@ function ReactWrapperTest() {
function test_mount() {
reactWrapper = reactWrapper.mount();
mount(<MyComponent stringProp='1'/>, {
mount(<MyComponent stringProp='1' />, {
attachTo: document.getElementById('test'),
context: {
a: "b"
@@ -409,27 +434,27 @@ function ReactWrapperTest() {
}
function test_contains() {
boolVal = reactWrapper.contains(<div className="foo bar"/>);
boolVal = reactWrapper.contains(<div className="foo bar" />);
}
function test_containsMatchingElement() {
boolVal = reactWrapper.contains(<div className="foo bar"/>);
boolVal = reactWrapper.contains(<div className="foo bar" />);
}
function test_containsAllMatchingElements() {
boolVal = reactWrapper.containsAllMatchingElements([<div className="foo bar"/>]);
boolVal = reactWrapper.containsAllMatchingElements([<div className="foo bar" />]);
}
function test_containsAnyMatchingElement() {
boolVal = reactWrapper.containsAnyMatchingElements([<div className="foo bar"/>]);
boolVal = reactWrapper.containsAnyMatchingElements([<div className="foo bar" />]);
}
function test_equals() {
boolVal = reactWrapper.equals(<div className="foo bar"/>);
boolVal = reactWrapper.equals(<div className="foo bar" />);
}
function test_matchesElement() {
boolVal = reactWrapper.matchesElement(<div className="foo bar"/>);
boolVal = reactWrapper.matchesElement(<div className="foo bar" />);
}
function test_hasClass() {
@@ -501,6 +526,18 @@ function ReactWrapperTest() {
reactElement = reactWrapper.get(1);
}
function test_getNode() {
reactElement = reactWrapper.getNode();
}
function test_getNodes() {
reactElements = reactWrapper.getNodes();
}
function test_getDOMNode() {
domElement = reactWrapper.getDOMNode();
}
function test_at() {
reactWrapper = reactWrapper.at(1);
}
@@ -513,6 +550,15 @@ function ReactWrapperTest() {
reactWrapper = reactWrapper.last();
}
function test_slice() {
reactWrapper = reactWrapper.slice(1);
reactWrapper = reactWrapper.slice(1, 3);
}
function test_tap() {
reactWrapper.tap((intercepter) => { });
}
function test_state() {
const state: MyComponentState = reactWrapper.state();
const prop: string = reactWrapper.state('stateProperty');
+32 -3
View File
@@ -1,4 +1,4 @@
// Type definitions for Enzyme 2.7
// Type definitions for Enzyme 2.8
// Project: https://github.com/airbnb/enzyme
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>
// Cap3 <http://www.cap3.de>
@@ -6,6 +6,7 @@
// Tom Crockett <https://github.com/pelotom>
// jwbay <https://github.com/jwbay>
// huhuanming <https://github.com/huhuanming>
// MartynasZilinskas <https://github.com/MartynasZilinskas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
@@ -22,7 +23,7 @@ export class ElementClass extends Component<any, any> {
* all specified in the implementation. TS chooses the EnzymePropSelector overload and loses the generics
*/
export interface ComponentClass<Props> {
new(props?: Props, context?: any): Component<Props, any>;
new (props?: Props, context?: any): Component<Props, any>;
}
export type StatelessComponent<Props> = (props: Props, context?: any) => JSX.Element;
@@ -42,6 +43,8 @@ export interface EnzymePropSelector {
}
export type EnzymeSelector = string | StatelessComponent<any> | ComponentClass<any> | EnzymePropSelector;
export type Intercepter<T> = (intercepter: T) => void;
export interface CommonWrapper<P, S> {
/**
* Returns a new wrapper with only the nodes of the current wrapper that, when passed into the provided predicate function, return true.
@@ -97,6 +100,7 @@ export interface CommonWrapper<P, S> {
/**
* Returns whether or not the current node is empty.
* @deprecated Use .exists() instead.
*/
isEmpty(): boolean;
@@ -134,6 +138,21 @@ export interface CommonWrapper<P, S> {
*/
get(index: number): ReactElement<any>;
/**
* Returns the wrapper's underlying node.
*/
getNode(): ReactElement<any>;
/**
* Returns the wrapper's underlying nodes.
*/
getNodes(): Array<ReactElement<any>>;
/**
* Returns the outer most DOMComponent of the current wrapper.
*/
getDOMNode(): Element;
/**
* Returns a wrapper around the node at a given index of the current wrapper.
* @param index
@@ -150,6 +169,16 @@ export interface CommonWrapper<P, S> {
*/
last(): this;
/**
* Returns a new wrapper with a subset of the nodes of the original wrapper, according to the rules of `Array#slice`.
*/
slice(begin?: number, end?: number): this;
/**
* Taps into the wrapper method chain. Helpful for debugging.
*/
tap(intercepter: Intercepter<this>): this;
/**
* Returns the state hash for the root node of the wrapper. Optionally pass in a prop name and it will return just that value.
* @param [key]
@@ -335,7 +364,7 @@ export interface CommonWrapper<P, S> {
*
* Note: can only be called on a wrapper of a single node.
*/
type(): string | ComponentClass<P> | StatelessComponent<P> ;
type(): string | ComponentClass<P> | StatelessComponent<P>;
length: number;
}
+82
View File
@@ -0,0 +1,82 @@
import * as Excel from 'exceljs';
// most examples taken and adapted from README.md
const workbook = new Excel.Workbook();
workbook.creator = 'Me';
workbook.lastModifiedBy = 'Her';
workbook.created = new Date(1985, 8, 30);
workbook.modified = new Date();
workbook.lastPrinted = new Date(2016, 9, 27);
workbook.properties.date1904 = true;
workbook.views = [
{
x: 0, y: 0, width: 10000, height: 20000,
firstSheet: 0, activeTab: 1, visibility: 'visible'
}
];
const worksheet: Excel.Worksheet = workbook.addWorksheet('My Sheet');
const worksheet2 = workbook.getWorksheet('My Sheet');
const worksheet3 = workbook.getWorksheet(1);
const sheet = workbook.addWorksheet('My Sheet', {views: [{showGridLines: false}]});
const row: Excel.Row = worksheet.addRow([3, 'Sam', new Date()]);
row.getCell(1).value = 5;
worksheet.eachRow((row: Excel.Row, rowNumber: number): void => {
// nothing
});
row.eachCell((cell: Excel.Cell, colNumber: number): void => {
// nothing
});
worksheet.mergeCells('A4:B5');
worksheet.getCell('A1').numFmt = '0.00%';
worksheet.getCell('A1').font = {
name: 'Comic Sans MS',
family: 4,
size: 16,
underline: true,
bold: true
};
worksheet.getCell('A1').alignment = { vertical: 'top', horizontal: 'left' };
worksheet.getCell('B1').alignment = { vertical: 'middle', horizontal: 'center' };
worksheet.getCell('C1').alignment = { vertical: 'bottom', horizontal: 'right' };
worksheet.getCell('D1').alignment = { wrapText: true };
worksheet.getCell('E1').alignment = { indent: 1 };
worksheet.getCell('A1').border = {
top: {style: 'thin'},
left: {style: 'thin'},
bottom: {style: 'thin'},
right: {style: 'thin'}
};
worksheet.getCell('A3').border = {
top: {style: 'double', color: {argb: 'FF00FF00'}},
left: {style: 'double', color: {argb: 'FF00FF00'}},
bottom: {style: 'double', color: {argb: 'FF00FF00'}},
right: {style: 'double', color: {argb: 'FF00FF00'}}
};
worksheet.getCell('A1').fill = {
type: 'pattern',
pattern: 'solid',
fgColor: {argb: 'FFFF0000'}
};
workbook.xlsx.readFile("/home/john/bla.xlsx")
.then((): void => {
// use workbook
});
workbook.xlsx.writeFile("/home/john/bla.xlsx")
.then((): void => {
// done
});
+231
View File
@@ -0,0 +1,231 @@
// Type definitions for exceljs 0.4
// Project: https://github.com/guyonroche/exceljs
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export const enum ValueType {
Null = 0,
Merge = 1,
Number = 2,
String = 3,
Date = 4,
Hyperlink = 5,
Formula = 6,
SharedString = 7,
RichText = 8,
Boolean = 9,
Error = 10
}
export const enum FormulaType {
None = 0,
Master = 1,
Shared = 2
}
export const enum RelationshipType {
None = 0,
OfficeDocument = 1,
Worksheet = 2,
CalcChain = 3,
SharedStrings = 4,
Styles = 5,
Theme = 6,
Hyperlink = 7
}
export const enum DocumentType {
Xlsx = 1
}
export const enum ReadingOrder {
RightToLeft = 1,
LeftToRight = 2,
}
export interface ErrorValue {
error: "#N/A" | "#REF!" | "#NAME?" | "#DIV/0!" | "#NULL!" | "#VALUE!" | "#NUM!";
}
export interface WorksheetView {
state?: "normal" | "split" | "frozen";
showRuler?: boolean;
showRowColHeaders?: boolean;
showGridLines?: boolean;
zoomScale?: number;
zoomScaleNormal?: number;
style?: "pageBreakPreview" | "pageLayout";
}
export interface WorkbookView {
x?: number;
y?: number;
width?: number;
height?: number;
firstSheet?: number;
activeTab?: number;
visibility?: string;
}
export interface Fill {
type: "pattern" | "gradient";
pattern?: "none" | "solid";
fgColor?: Color;
bgColor?: Color;
}
export interface Font {
name: string;
size?: number;
family?: number;
schema?: "minor" | "major" | "none";
charset?: number;
color?: Color;
bold?: boolean;
italic?: boolean;
underline?: true | false | "none" | "single" | "double" | "singleAccounting" | "doubleAccounting";
strike?: boolean;
outline?: boolean;
}
export type BorderStyle =
"thin" | "dotted" | "dashDot" | "hair" | "dashDotDot" | "slantDashDot" | "mediumDashed" | "mediumDashDotDot" |
"mediumDashDot" | "medium" | "double" | "thick";
export interface Color {
/**
* Hex string for alpha-red-green-blue e.g. FF00FF00
*/
argb: string;
}
export interface Border {
style?: BorderStyle;
color?: Color;
}
export interface Borders {
top?: Border;
left?: Border;
bottom?: Border;
right?: Border;
}
export interface Alignment {
horizontal?: "left" | "center" | "right" | "fill" | "justify" | "centerContinuous" | "distributed";
vertical?: "top" | "middle" | "bottom" | "distributed" | "justify";
wrapText?: boolean;
indent?: number;
readingOrder?: "rtl" | "ltr";
textrotation?: number | "vertical";
}
export interface Cell {
border?: Borders;
font?: Font;
alignment?: Alignment;
numFmt?: string;
value?: any;
fill?: Fill;
}
export interface Row {
/**
* The row number
*/
number: number;
height: number;
hidden: boolean;
collapsed: boolean;
values: any[];
outlineLevel?: number;
readonly cellCount: number;
readonly actualCellCount: number;
getCell(index: number): Cell;
eachCell(callback: (cell: Cell, colNumber: number) => void): void;
eachCell(opts: { includeEmpty: boolean}, callback: (cell: Cell, colNumber: number) => void): void;
}
export interface Column {
width: number;
}
export interface Worksheet {
/**
* The total row size of the document. Equal to the row number of the last row that has values.
*/
rowCount: number;
/**
* A count of the number of rows that have values. If a mid-document row is empty, it will not be included in the count.
*/
actualRowCount: number;
/**
* The total column size of the document. Equal to the maximum cell count from all of the rows
*/
columnCount: number;
/**
* A count of the number of columns that have values.
*/
actualColumnCount: number;
/**
* Get or create a column
*/
getColumn(index: number): Column;
/**
* Create a new row
*/
addRow(data: any[]): Row;
/**
* Get or create row by 0-based index
*/
getRow(index: number): Row;
eachRow(callback: (row: Row, rowNumber: number) => void): void;
/**
* Get or create cell
*/
getCell(ref: string): Cell;
/**
* Merge cells, either:
* tlbr string
* tl string, br string
* t, l, b, r numbers
*/
mergeCells(a: number | string, b?: number | string, c?: number, d?: number): void;
}
export interface Xlsx {
readFile(path: string): Promise<void>;
writeFile(path: string): Promise<void>;
}
export interface WorksheetProps {
showGridLines: boolean;
}
export class Workbook {
constructor();
creator: string;
lastModifiedBy: string;
created: Date;
modified: Date;
lastPrinted: Date;
properties: {
date1904: boolean;
};
views: WorkbookView[];
addWorksheet(name: string, opts?: { properties?: WorksheetProps, views?: WorksheetView[] }): Worksheet;
getWorksheet(indexOrName: number | string): Worksheet;
xlsx: Xlsx;
}
+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",
"exceljs-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+124
View File
@@ -0,0 +1,124 @@
import fecha = require('fecha');
// test fecha.parse
fecha.parse("February 3rd, 2014", "MMMM Do, YYYY");
fecha.parse("5/3/98", "shortDate");
// test override fecha.i18n
fecha.i18n = {
dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"],
dayNames: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
monthNamesShort: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
monthNames: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
amPm: ["am", "pm"],
DoFn(D: number) {
return D + "th";
}
};
// just change one default mask
fecha.masks.shortDate = "M/D/YY";
// test override fecha.masks with an object. Must implement all keys.
// if you want to implement partially, use
// fecha.masks = Object.assign(fecha.masks, {shortDate: 'M/D/YY'}) for example.
fecha.masks = {
default: "ddd MMM DD YYYY HH:mm:ss",
shortDate: "M/D/YY",
mediumDate: "MMM D, YYYY",
longDate: "MMMM D, YYYY",
fullDate: "dddd, MMMM D, YYYY",
shortTime: "HH:mm",
mediumTime: "HH:mm:ss",
longTime: "HH:mm:ss.SSS"
};
// test add custom named mask.
// fecha.masks.myMask = "HH:mm:ss YY/MM/DD"; does not work for now.
fecha.masks['myMask'] = "HH:mm:ss YY/MM/DD";
// test fecha.format without i18nSettings, with Date object.
fecha.format(new Date(2014, 5, 6, 14, 10, 45), "myMask");
// test fecha.format without i18nSettings with number.
fecha.format(Date.now(), "myMask");
// test override i18nSettings with fecha.format
fecha.format(new Date(2014, 5, 6, 14, 10, 45), "myMask", {
dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thur", "Fri", "Sat"],
dayNames: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
monthNamesShort: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
monthNames: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
amPm: ["am", "pm"],
DoFn(D: number) {
return D + "th";
}
});
+52
View File
@@ -0,0 +1,52 @@
// Type definitions for fecha 2.3
// Project: https://github.com/taylorhakes/fecha
// Definitions by: Goh Yisheng <https://github.com/9y5>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type Days = [string, string, string, string, string, string, string];
export type Months = [
string,
string,
string,
string,
string,
string,
string,
string,
string,
string,
string,
string
];
export interface i18nSettings {
amPm: [string, string];
dayNames: Days;
dayNamesShort: Days;
monthNames: Months;
monthNamesShort: Months;
DoFn(D: number): string;
}
export interface Masks {
default: string;
fullDate: string;
longDate: string;
longTime: string;
mediumDate: string;
mediumTime: string;
shortDate: string;
shortTime: string;
[myMask: string]: string;
}
export let masks: Masks;
export let i18n: i18nSettings;
export function format(dateObj: Date | number, mask: string, i18nSettings?: i18nSettings): string;
export function parse(dateStr: string, format: string, i18nSettings?: i18nSettings): Date;
export as namespace Fecha;
+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",
"fecha-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+7 -1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/overlookmotel/fs-extra-promise
// Definitions by: midknight41 <https://github.com/midknight41>, Jason Swearingen <https://github.com/jasonswearingen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
/// <reference types="bluebird" />
@@ -10,10 +11,15 @@
import * as stream from 'stream';
import { Stats } from 'fs';
import * as Promise from 'bluebird';
import { CopyFilter, CopyOptions, ReadOptions, WriteOptions, MkdirOptions, MoveOptions } from 'fs-extra';
import { CopyFilter, CopyOptions, ReadOptions, WriteOptions, MoveOptions } from 'fs-extra';
export * from 'fs-extra';
export interface MkdirOptions {
fs?: any;
mode?: number;
}
//promisified versions
export declare function copyAsync(src: string, dest: string): Promise<void>;
export declare function copyAsync(src: string, dest: string, filter: CopyFilter): Promise<void>;
+133 -25
View File
@@ -1,106 +1,214 @@
import * as fs from 'fs-extra';
import * as Path from 'path';
const len = 2;
const src = "";
const dest = "";
const file = "";
const dir = "";
const path = "";
const data = "";
const uid = 0;
const gid = 0;
const fd = 0;
const modeNum = 0;
const modeStr = "";
const object = {};
const errorCallback = (err: Error) => {};
const errorCallback = (err: Error) => { };
const readOptions: fs.ReadOptions = {
reviver : {}
reviver: {}
};
const writeOptions: fs.WriteOptions = {
replacer: {}
replacer: {}
};
fs.moveSync(src, dest, {});
fs.move(src, dest, {}).then(() => {
// stub
});
fs.move(src, dest).then(() => {
// stub
});
fs.move(src, dest, {}, () => {
// stub
});
fs.move(src, dest, () => {
// stub
});
fs.copy(src, dest).then(() => {
// stub
});
fs.copy(src, dest, { overwrite: true }).then(() => {
// stub
});
fs.copy(src, dest, errorCallback);
fs.copy(src, dest, (src: string) => {
return false;
}, errorCallback);
fs.copy(src, dest, (src: string) => false, errorCallback);
fs.copy(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: (src: string) => { return false; }
filter: (src: string) => false
},
errorCallback
);
fs.copy(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: /.*/
},
errorCallback
);
fs.copySync(src, dest);
fs.copySync(src, dest, (src: string) => {
return false;
});
fs.copySync(src, dest, (src: string) => false);
fs.copySync(src, dest, /.*/);
fs.copySync(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: (src: string) => { return false; }
filter: (src: string) => false
}
);
fs.copySync(src, dest,
{
clobber: true,
overwrite: true,
preserveTimestamps: true,
filter: /.*/
}
);
fs.createFile(file).then(() => {
// stub
});
fs.createFile(file, errorCallback);
fs.createFileSync(file);
fs.mkdirs(dir).then(() => {
// stub
});
fs.mkdirp(dir).then(() => {
// stub
});
fs.mkdirs(dir, errorCallback);
fs.mkdirs(dir, {}, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirsSync(dir, {});
fs.mkdirp(dir, errorCallback);
fs.mkdirp(dir, {}, errorCallback);
fs.mkdirpSync(dir);
fs.mkdirpSync(dir, {});
fs.outputFile(file, data).then(() => {
// stub
});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
fs.outputJson(file, data, errorCallback);
fs.outputJson(file, data, {
spaces: 2
}).then(() => {
// stub
});
fs.outputJson(file, data, {
spaces: 2
}, errorCallback);
fs.outputJSON(file, data, errorCallback);
fs.outputJSON(file, data).then(() => {
// stub
});
fs.outputJsonSync(file, data);
fs.outputJSONSync(file, data);
fs.readJson(file, (error: Error, jsonObject: any) => {});
fs.readJson(file, readOptions, (error: Error, jsonObject: any) => {});
fs.readJSON(file, (error: Error, jsonObject: any) => {});
fs.readJSON(file, readOptions, (error: Error, jsonObject: any) => {});
fs.readJson(file).then(() => {
// stub
});
fs.readJson(file, readOptions).then(() => {
// stub
});
fs.readJson(file, (error: Error, jsonObject: any) => { });
fs.readJson(file, readOptions, (error: Error, jsonObject: any) => { });
fs.readJSON(file, (error: Error, jsonObject: any) => { });
fs.readJSON(file, readOptions, (error: Error, jsonObject: any) => { });
fs.readJsonSync(file, readOptions);
fs.readJSONSync(file, readOptions);
fs.remove(dir, errorCallback);
fs.remove(dir).then(() => {
// stub
});
fs.removeSync(dir);
fs.writeJson(file, object).then(() => {
// stub
});
fs.writeJSON(file, object).then(() => {
// stub
});
fs.writeJson(file, object, errorCallback);
fs.writeJson(file, object, writeOptions, errorCallback);
fs.writeJSON(file, object, errorCallback);
fs.writeJSON(file, object, writeOptions, errorCallback);
fs.writeJson(file, object, writeOptions).then(() => {
// stub
});
fs.writeJSON(file, object, writeOptions).then(() => {
// stub
});
fs.writeJsonSync(file, object, writeOptions);
fs.writeJSONSync(file, object, writeOptions);
fs.ensureDir(path).then(() => {
// stub
});
fs.ensureDir(path, errorCallback);
fs.ensureDirSync(path);
fs.ensureFile(path).then(() => {
// stub
});
fs.ensureFile(path, errorCallback);
fs.ensureFileSync(path);
fs.ensureLink(path).then(() => {
// stub
});
fs.ensureLink(path, errorCallback);
fs.ensureLinkSync(path);
fs.ensureSymlink(path).then(() => {
// stub
});
fs.ensureSymlink(path, errorCallback);
fs.ensureSymlinkSync(path);
fs.emptyDir(path).then(() => {
// stub
});
fs.emptyDir(path, errorCallback);
fs.emptyDirSync(path);
fs.pathExists(path).then((_exist: boolean) => {
// stub
});
fs.pathExists(path, (_err: Error, _exists: boolean) => { });
const x: boolean = fs.pathExistsSync(path);
fs.rename(src, dest, errorCallback);
fs.renameSync(src, dest);
fs.truncate(path, len, errorCallback);
fs.truncateSync(path, len);
fs.chown(path, uid, gid, errorCallback);
fs.chownSync(path, uid, gid);
fs.fchown(fd, uid, gid, errorCallback);
fs.fchownSync(fd, uid, gid);
fs.lchown(path, uid, gid, errorCallback);
fs.lchownSync(path, uid, gid);
fs.chmod(path, modeNum, errorCallback);
fs.chmod(path, modeStr, errorCallback);
fs.chmodSync(path, modeNum);
fs.chmodSync(path, modeStr);
fs.fchmod(fd, modeNum, errorCallback);
fs.fchmod(fd, modeStr, errorCallback);
fs.fchmodSync(fd, modeNum);
fs.fchmodSync(fd, modeStr);
fs.lchmod(path, modeStr, errorCallback);
fs.lchmod(path, modeNum, errorCallback);
fs.lchmodSync(path, modeNum);
fs.lchmodSync(path, modeStr);
fs.statSync(path);
fs.lstatSync(path);
+227 -101
View File
@@ -1,9 +1,8 @@
// Type definitions for fs-extra 2.1
// Type definitions for fs-extra 3.0
// Project: https://github.com/jprichardson/node-fs-extra
// Definitions by: midknight41 <https://github.com/midknight41>, Brendan Forster <https://github.com/shiftkey>
// Definitions by: Alan Agius <https://github.com/alan-agius4>, midknight41 <https://github.com/midknight41>, Brendan Forster <https://github.com/shiftkey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/fs-extra.d.ts
// TypeScript Version: 2.2
/// <reference types="node" />
@@ -11,123 +10,255 @@ import { Stats } from "fs";
export * from "fs";
export declare function copy(src: string, dest: string, callback?: (err: Error) => void): void;
export declare function copy(src: string, dest: string, filter: CopyFilter, callback?: (err: Error) => void): void;
export declare function copy(src: string, dest: string, options: CopyOptions, callback?: (err: Error) => void): void;
export function copy(src: string, dest: string, options?: CopyOptions): Promise<void>;
export function copy(src: string, dest: string, callback: (err: Error) => void): void;
export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error) => void): void;
export function copySync(src: string, dest: string, options?: CopyOptions): void;
export declare function copySync(src: string, dest: string): void;
export declare function copySync(src: string, dest: string, filter: CopyFilter): void;
export declare function copySync(src: string, dest: string, options: CopyOptions): void;
export function move(src: string, dest: string, options?: MoveOptions): Promise<void>;
export function move(src: string, dest: string, callback: (err: Error) => void): void;
export function move(src: string, dest: string, options: MoveOptions, callback: (err: Error) => void): void;
export function moveSync(src: string, dest: string, options?: MoveOptions): void;
export declare function move(src: string, dest: string, callback?: (err: Error) => void): void;
export declare function move(src: string, dest: string, options: MoveOptions, callback?: (err: Error) => void): void;
export function createFile(file: string): Promise<void>;
export function createFile(file: string, callback: (err: Error) => void): void;
export function createFileSync(file: string): void;
export declare function createFile(file: string, callback?: (err: Error) => void): void;
export declare function createFileSync(file: string): void;
export function ensureDir(path: string): Promise<void>;
export function ensureDir(path: string, callback: (err: Error) => void): void;
export function ensureDirSync(path: string): void;
export declare function mkdirs(dir: string, callback?: (err: Error) => void): void;
export declare function mkdirp(dir: string, callback?: (err: Error) => void): void;
export declare function mkdirs(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void;
export declare function mkdirp(dir: string, options?: MkdirOptions, callback?: (err: Error) => void): void;
export declare function mkdirsSync(dir: string, options?: MkdirOptions): void;
export declare function mkdirpSync(dir: string, options?: MkdirOptions): void;
export function mkdirs(dir: string): Promise<void>;
export function mkdirs(dir: string, callback: (err: Error) => void): void;
export function mkdirp(dir: string): Promise<void>;
export function mkdirp(dir: string, callback: (err: Error) => void): void;
export function mkdirsSync(dir: string): void;
export function mkdirpSync(dir: string): void;
export declare function outputFile(file: string, data: any, callback?: (err: Error) => void): void;
export declare function outputFileSync(file: string, data: any): void;
export function outputFile(file: string, data: any): Promise<void>;
export function outputFile(file: string, data: any, callback: (err: Error) => void): void;
export function outputFileSync(file: string, data: any): void;
export declare function outputJson(file: string, data: any, callback?: (err: Error) => void): void;
export declare function outputJSON(file: string, data: any, callback?: (err: Error) => void): void;
export declare function outputJsonSync(file: string, data: any): void;
export declare function outputJSONSync(file: string, data: any): void;
export function readJson(file: string, options?: ReadOptions): Promise<any>;
export function readJson(file: string, callback: (err: Error, jsonObject: any) => void): void;
export function readJson(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export function readJSON(file: string, options?: ReadOptions): Promise<any>;
export function readJSON(file: string, callback: (err: Error, jsonObject: any) => void): void;
export function readJSON(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJson(file: string, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJson(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJSON(file: string, callback: (err: Error, jsonObject: any) => void): void;
export declare function readJSON(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void;
export function readJsonSync(file: string, options?: ReadOptions): any;
export function readJSONSync(file: string, options?: ReadOptions): any;
export declare function readJsonSync(file: string, options?: ReadOptions): any;
export declare function readJSONSync(file: string, options?: ReadOptions): any;
export function remove(dir: string): Promise<void>;
export function remove(dir: string, callback: (err: Error) => void): void;
export function removeSync(dir: string): void;
export declare function remove(dir: string, callback?: (err: Error) => void): void;
export declare function removeSync(dir: string): void;
export function outputJSON(file: string, data: any, options?: WriteOptions): Promise<void>;
export function outputJSON(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void;
export function outputJSON(file: string, data: any, callback: (err: Error) => void): void;
export function outputJson(file: string, data: any, options?: WriteOptions): Promise<void>;
export function outputJson(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void;
export function outputJson(file: string, data: any, callback: (err: Error) => void): void;
export function outputJsonSync(file: string, data: any, options?: WriteOptions): void;
export function outputJSONSync(file: string, data: any, options?: WriteOptions): void;
export declare function writeJson(file: string, object: any, callback?: (err: Error) => void): void;
export declare function writeJson(file: string, object: any, options?: WriteOptions, callback?: (err: Error) => void): void;
export declare function writeJSON(file: string, object: any, callback?: (err: Error) => void): void;
export declare function writeJSON(file: string, object: any, options?: WriteOptions, callback?: (err: Error) => void): void;
export function writeJSON(file: string, object: any, options?: WriteOptions): Promise<void>;
export function writeJSON(file: string, object: any, callback: (err: Error) => void): void;
export function writeJSON(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void;
export function writeJson(file: string, object: any, options?: WriteOptions): Promise<void>;
export function writeJson(file: string, object: any, callback: (err: Error) => void): void;
export function writeJson(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void;
export declare function writeJsonSync(file: string, object: any, options?: WriteOptions): void;
export declare function writeJSONSync(file: string, object: any, options?: WriteOptions): void;
export function writeJsonSync(file: string, object: any, options?: WriteOptions): void;
export function writeJSONSync(file: string, object: any, options?: WriteOptions): void;
export declare function ensureDir(path: string, callback: (err: Error) => void): void;
export declare function ensureDirSync(path: string): void;
export function ensureFile(path: string): Promise<void>;
export function ensureFile(path: string, callback: (err: Error) => void): void;
export function ensureFileSync(path: string): void;
export declare function ensureFile(path: string, callback: (err: Error) => void): void;
export declare function ensureFileSync(path: string): void;
export function ensureLink(path: string): Promise<void>;
export function ensureLink(path: string, callback: (err: Error) => void): void;
export function ensureLinkSync(path: string): void;
export declare function ensureLink(path: string, callback: (err: Error) => void): void;
export declare function ensureLinkSync(path: string): void;
export function ensureSymlink(path: string): Promise<void>;
export function ensureSymlink(path: string, callback: (err: Error) => void): void;
export function ensureSymlinkSync(path: string): void;
export declare function ensureSymlink(path: string, callback: (err: Error) => void): void;
export declare function ensureSymlinkSync(path: string): void;
export function emptyDir(path: string): Promise<void>;
export function emptyDir(path: string, callback: (err: Error) => void): void;
export function emptyDirSync(path: string): void;
export declare function emptyDir(path: string, callback?: (err: Error) => void): void;
export declare function emptyDirSync(path: string): boolean;
export function pathExists(path: string): Promise<boolean>;
export function pathExists(path: string, callback: (err: Error, exists: boolean) => void): void;
export function pathExistsSync(path: string): boolean;
export interface WalkEventEmitter extends NodeJS.ReadableStream {
on(event: 'data', callback: (file: WalkEventFile) => void): this;
on(event: 'readable', callback: (this: PathEntryStream) => void): this;
on(event: 'error', callback: (error: Error, item: PathEntry) => void): this;
on(event: 'end', callback: () => void): this;
on(event: string | symbol, callback: Function): this;
}
// fs async methods
// copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v6/index.d.ts
export interface WalkEventFile {
/** Tests a user's permissions for the file specified by path. */
export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void;
export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
export function access(path: string | Buffer, mode?: number): Promise<void>;
export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number | string; flag?: string; }, callback: (err: NodeJS.ErrnoException) => void): void;
export function appendFile(filename: string, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
export function appendFile(filename: string, data: any, options?: { encoding?: string; mode?: number | string; flag?: string; }): Promise<void>;
export function chmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function chmod(path: string | Buffer, mode: string | number): Promise<void>;
export function chown(path: string | Buffer, uid: number, gid: number): Promise<void>;
export function chown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function close(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function close(fd: number): Promise<void>;
export function fchmod(fd: number, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function fchmod(fd: number, mode: string | number): Promise<void>;
export function fchown(fd: number, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function fchown(fd: number, uid: number, gid: number): Promise<void>;
export function fdatasync(fd: number, callback: () => void): void;
export function fdatasync(fd: number): Promise<void>;
export function fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function fstat(fd: number): Promise<Stats>;
export function fsync(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function fsync(fd: number): Promise<void>;
export function ftruncate(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function ftruncate(fd: number, len: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function ftruncate(fd: number, len?: number): Promise<void>;
export function futimes(fd: number, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function futimes(fd: number, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void;
export function futimes(fd: number, atime: number, mtime: number): Promise<void>;
export function futimes(fd: number, atime: Date, mtime: Date): Promise<void>;
export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function lchown(path: string | Buffer, uid: number, gid: number): Promise<void>;
export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function link(srcpath: string | Buffer, dstpath: string | Buffer): Promise<void>;
export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function lstat(path: string | Buffer): Promise<Stats>;
/**
* Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
/**
* Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
*
* @param path
* @param mode
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function mkdir(path: string | Buffer, mode: number | string, callback: (err?: NodeJS.ErrnoException) => void): void;
export function mkdir(path: string | Buffer): Promise<void>;
export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void;
export function open(path: string | Buffer, flags: string | number, mode?: number): Promise<number>;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null): Promise<[number, Buffer]>;
export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
export function readFile(filename: string, options: { flag?: string; } | { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
export function readFile(filename: string, options: { flag?: string; } | { encoding: string; flag?: string; }): Promise<string>;
// tslint:disable-next-line:unified-signatures
export function readFile(filename: string, encoding: string): Promise<string>;
export function readFile(filename: string): Promise<Buffer>;
export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void;
export function readdir(path: string | Buffer): Promise<string[]>;
export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void;
export function readlink(path: string | Buffer): Promise<string>;
export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
export function realpath(path: string | Buffer, cache?: { [path: string]: string }): Promise<string>;
export function rename(oldPath: string, newPath: string, callback: (err?: NodeJS.ErrnoException) => void): void;
export function rename(oldPath: string, newPath: string): Promise<void>;
/**
* Asynchronous rmdir - removes the directory specified in {path}
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function rmdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function rmdir(path: string | Buffer): Promise<void>;
export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
export function stat(path: string | Buffer): Promise<Stats>;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err?: NodeJS.ErrnoException) => void): void;
export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): Promise<void>;
export function truncate(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function truncate(path: string | Buffer, len: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function truncate(path: string | Buffer, len?: number): Promise<void>;
/**
* Asynchronous unlink - deletes the file specified in {path}
*
* @param path
* @param callback No arguments other than a possible exception are given to the completion callback.
*/
export function unlink(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void;
export function unlink(path: string | Buffer): Promise<void>;
export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void;
export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void;
export function utimes(path: string | Buffer, atime: number, mtime: number): Promise<void>;
export function utimes(path: string | Buffer, atime: Date, mtime: Date): Promise<void>;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, data: any, offset: number, encoding: string, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
export function write(fd: number, buffer: Buffer, offset: number, length: number, position?: number | null): Promise<[number, Buffer]>;
export function write(fd: number, data: any, offset: number, encoding?: string): Promise<[number, string]>;
export function writeFile(filename: string, data: any, callback: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
export function writeFile(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): Promise<void>;
/**
* Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
*
* @param prefix
* @param callback The created folder path is passed as a string to the callback's second parameter.
*/
export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void;
export function mkdtemp(prefix: string): Promise<string>;
export interface PathEntry {
path: string;
stats: Stats;
}
export interface WalkOptions {
/**
* Control how results are enumerated from `readdir`:
* - 'shift' will return the first element from the array.
* - 'pop' will return the last element from the array.
*
* If not specified, the default behaviour is 'shift'
*/
queueMethod?: 'pop' | 'shift';
/**
* Provide a function to sort the paths before they are enumerated
*/
pathSorter?: (left: string, right: string) => number;
/**
* An optional object to override the default `fs` APIs for testing purposes
*/
fs?: Object;
/**
* Provide a function to exclude certain file paths. The function should
* return true when the element should be kept, and false otherwise.
*/
filter?: (path: string, index: number, array: Array<PathEntry>) => boolean;
export interface PathEntryStream {
read(): PathEntry | null;
}
export type PathEntry = {
path: string;
stats: Stats;
}
export type PathEntryStream = {
read(): PathEntry | null
}
export interface CopyFilterFunction {
(src: string): boolean
}
export type CopyFilterFunction = (src: string) => boolean;
export type CopyFilter = CopyFilterFunction | RegExp;
export interface CopyOptions {
clobber?: boolean;
dereference?: boolean;
overwrite?: boolean;
preserveTimestamps?: boolean;
@@ -137,28 +268,23 @@ export interface CopyOptions {
}
export interface MoveOptions {
clobber? : boolean;
overwrite?: boolean;
limit?: number;
}
export interface ReadOptions {
throws?: boolean;
fs?: Object;
fs?: object;
reviver?: any;
encoding?: string;
flag?: string;
}
export interface WriteOptions {
fs?: Object;
fs?: object;
replacer?: any;
spaces?: number;
encoding?: string;
flag?: string;
mode?: number;
}
export interface MkdirOptions {
fs?: any;
mode?: number;
}
+21 -21
View File
@@ -1,22 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fs-extra-tests.ts"
]
}
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"fs-extra-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -7
View File
@@ -417,13 +417,7 @@ $('#calendar').fullCalendar({
});
$('#calendar').fullCalendar({
dayClick(date, allDay, jsEvent, view) {
if (allDay) {
alert('Clicked on the entire day: ' + date);
} else {
alert('Clicked on the slot: ' + date);
}
dayClick(date, jsEvent, view) {
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
alert('Current view: ' + view.name);
+1 -1
View File
@@ -90,7 +90,7 @@ export interface Options extends AgendaOptions, EventDraggingResizingOptions, Dr
// Clicking & Hovering - http://fullcalendar.io/docs/mouse/
dayClick?(date: Date, allDay: boolean, jsEvent: MouseEvent, view: ViewObject): void;
dayClick?(date: Date, jsEvent: MouseEvent, view: ViewObject): void;
eventClick?(event: EventObject, jsEvent: MouseEvent, view: ViewObject): any; // return type boolean or void
eventMouseover?(event: EventObject, jsEvent: MouseEvent, view: ViewObject): void;
eventMouseout?(event: EventObject, jsEvent: MouseEvent, view: ViewObject): void;
+1
View File
@@ -11,6 +11,7 @@ let map = new google.maps.Map(
fullscreenControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
gestureHandling: "cooperative",
scrollwheel: true,
zoom: 4
});
+11 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for Google Maps JavaScript API 3.26
// Project: https://developers.google.com/maps/
// Definitions by: Folia A/S <http://www.folia.dk>, Chris Wrench <https://github.com/cgwrench>, Kiarash Ghiaseddin <https://github.com/Silver-Connection/DefinitelyTyped>, Grant Hutchins <https://github.com/nertzy>, Denis Atyasov <https://github.com/xaolas>, Michael McMullin <https://github.com/mrmcnerd>
// Definitions by: Folia A/S <http://www.folia.dk>, Chris Wrench <https://github.com/cgwrench>, Kiarash Ghiaseddin <https://github.com/Silver-Connection/DefinitelyTyped>, Grant Hutchins <https://github.com/nertzy>, Denis Atyasov <https://github.com/xaolas>, Michael McMullin <https://github.com/mrmcnerd>, Martin Costello <https://github.com/martincostello>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/*
@@ -95,6 +95,10 @@ declare namespace google.maps {
fullscreenControl?: boolean;
/** The display options for the Fullscreen control. */
fullscreenControlOptions?: FullscreenControlOptions;
/**
* This setting controls how gestures on the map are handled.
*/
gestureHandling?: GestureHandlingOptions;
/**
* The heading for aerial imagery in degrees measured clockwise from cardinal
* direction North. Headings are snapped to the nearest available angle for
@@ -250,6 +254,12 @@ declare namespace google.maps {
opened?: boolean;
}
export type GestureHandlingOptions =
"cooperative" |
"greedy" |
"none" |
"auto";
/** Options for the rendering of the pan control. */
export interface PanControlOptions {
/**
+26 -15
View File
@@ -1,22 +1,33 @@
var params: ReCaptchaV2.Parameters = {
"sitekey": "mySuperSecretKey",
"theme": "light",
"type": "image",
"size": "normal",
"tabindex": 5,
"callback": (response: string) => { },
const params: ReCaptchaV2.Parameters = {
sitekey: "mySuperSecretKey",
theme: "light",
type: "image",
size: "normal",
tabindex: 5,
callback: (response: string) => { },
"expired-callback": () => { },
}
};
var id1: number = grecaptcha.render("foo");
var id2: number = grecaptcha.render("foo", params);
var id3: number = grecaptcha.render(document.getElementById("foo"));
var id4: number = grecaptcha.render(document.getElementById("foo"), params);
const size1: ReCaptchaV2.Size = "compact";
const size2: ReCaptchaV2.Size = "invisible";
const size3: ReCaptchaV2.Size = "normal";
const badge1: ReCaptchaV2.Badge = "bottomleft";
const badge2: ReCaptchaV2.Badge = "bottomright";
const badge3: ReCaptchaV2.Badge = "inline";
const invisibleParams: ReCaptchaV2.Parameters = {
sitekey: "siteKey",
badge: badge1,
};
const id1: number = grecaptcha.render("foo");
const id2: number = grecaptcha.render("foo", params);
const id3: number = grecaptcha.render(document.getElementById("foo"));
const id4: number = grecaptcha.render(document.getElementById("foo"), params);
// response takes a number and returns a string
var response1: string = grecaptcha.getResponse(id1);
const response1: string = grecaptcha.getResponse(id1);
// reset takes a number
grecaptcha.reset(id1);
+55 -50
View File
@@ -1,85 +1,90 @@
// Type definitions for Google Recaptcha 2.0
// Project: https://www.google.com/recaptcha
// Definitions by: Kristof Mattei <http://kristofmattei.be>, Martin Costello <https://martincostello.com/>
// Definitions by: Kristof Mattei <http://kristofmattei.be>, Martin Costello <https://martincostello.com/>, Ruslan Arkhipau <https://github.com/DethAriel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var grecaptcha: ReCaptchaV2.ReCaptcha;
declare namespace ReCaptchaV2
{
class ReCaptcha
{
declare namespace ReCaptchaV2 {
class ReCaptcha {
/**
* Renders the container as a reCAPTCHA widget and returns the ID of the newly created widget.
* @param container The HTML element to render the reCAPTCHA widget. Specify either the ID of the container (string) or the DOM element itself.
* @param parameters An object containing parameters as key=value pairs, for example, {"sitekey": "your_site_key", "theme": "light"}. See @see render parameters.
* @return the ID of the newly created widget.
**/
* Renders the container as a reCAPTCHA widget and returns the ID of the newly created widget.
* @param container The HTML element to render the reCAPTCHA widget. Specify either the ID of the container (string) or the DOM element itself.
* @param parameters An object containing parameters as key=value pairs, for example, {"sitekey": "your_site_key", "theme": "light"}. See @see render parameters.
* @return the ID of the newly created widget.
*/
render(container: (string | HTMLElement), parameters?: Parameters): number;
/**
* Resets the reCAPTCHA widget.
* @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified.
**/
* Resets the reCAPTCHA widget.
* @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified.
*/
reset(opt_widget_id?: number): void;
/**
* Gets the response for the reCAPTCHA widget.
* @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified.
* @return the response of the reCAPTCHA widget.
**/
* Gets the response for the reCAPTCHA widget.
* @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified.
* @return the response of the reCAPTCHA widget.
*/
getResponse(opt_widget_id?: number): string;
/**
* Programatically invoke the reCAPTCHA check. Used if the invisible reCAPTCHA is on a div instead of a button.
* @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified.
**/
* Programatically invoke the reCAPTCHA check. Used if the invisible reCAPTCHA is on a div instead of a button.
* @param opt_widget_id Optional widget ID, defaults to the first widget created if unspecified.
*/
execute(opt_widget_id?: number): void;
}
type Theme = "light" | "dark";
type Type = "image" | "audio";
type Size = "normal" | "compact";
type Size = "normal" | "compact" | "invisible";
type Badge = "bottomright" | "bottomleft" | "inline";
interface Parameters
{
interface Parameters {
/**
* Your sitekey.
**/
* Your sitekey.
*/
sitekey: string;
/**
* Optional. The color theme of the widget.
* Accepted values: "light", "dark"
* @default "light"
* @type {Theme}
**/
* Optional. The color theme of the widget.
* Accepted values: "light", "dark"
* @default "light"
* @type {Theme}
*/
theme?: Theme;
/**
* Optional. The type of CAPTCHA to serve.
* Accepted values: "audio", "image"
* @default "image"
* @type {Type}
**/
* Optional. The type of CAPTCHA to serve.
* Accepted values: "audio", "image"
* @default "image"
* @type {Type}
*/
type?: Type;
/**
* Optional. The size of the widget.
* Accepted values: "compact", "normal"
* @default "compact"
* @type {Size}
*/
* Optional. The size of the widget.
* Accepted values: "compact", "normal", "invisible".
* @default "compact"
* @type {Size}
*/
size?: Size;
/**
* Optional. The tabindex of the widget and challenge.
* If other elements in your page use tabindex, it should be set to make user navigation easier.
**/
* Optional. The tabindex of the widget and challenge.
* If other elements in your page use tabindex, it should be set to make user navigation easier.
*/
tabindex?: number;
/**
* Optional. Your callback function that's executed when the user submits a successful CAPTCHA response.
* The user's response, g-recaptcha-response, will be the input for your callback function.
**/
callback?: (response: string) => void;
* Optional. Your callback function that's executed when the user submits a successful CAPTCHA response.
* The user's response, g-recaptcha-response, will be the input for your callback function.
*/
callback?(response: string): void;
/**
* Optional. Your callback function that's executed when the recaptcha response expires and the user needs to solve a new CAPTCHA.
**/
* Optional. The badge location for g-recaptcha with size of "invisible".
*
* @default "bottomright"
* @type {Badge}
*/
badge?: Badge;
/**
* Optional. Your callback function that's executed when the recaptcha response expires and the user needs to solve a new CAPTCHA.
*/
// Notice to the reader
// I need to surround this object with quotes, this will however break intellisense in VS 2013.
"expired-callback"?: () => void;
"expired-callback"?(): void;
}
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+3 -2
View File
@@ -29,13 +29,14 @@ function validate(decoded: User, request: Hapi.Request, callback: hapiAuthJwt2.V
}
server.register(hapiAuthJwt2, err => {
server.auth.strategy('jwt', 'jwt', <hapiAuthJwt2.Options> {
const options: hapiAuthJwt2.Options = {
key: 'NeverShareYourSecret',
validateFunc: validate,
verifyOptions: {
algorithms: ['HS256']
}
});
};
server.auth.strategy('jwt', 'jwt', options);
});
server.start();
+44 -28
View File
@@ -120,8 +120,8 @@ export interface IServerConnectionOptions extends IConnectionConfigurationServer
export interface IConnectionConfigurationServerDefaults {
/** application-specific connection configuration which can be accessed via connection.settings.app. Provides a safe place to store application configuration without potential conflicts with the framework internals. Should not be used to configure plugins which should use plugins[name]. Note the difference between connection.settings.app which is used to store configuration values and connection.app which is meant for storing run-time state. */
app?: any;
/** if false, response content encoding is disabled. Defaults to true */
compression?: boolean;
/** if false, response content encoding is disabled. Defaults to true */
compression?: boolean;
/** connection load limits configuration where: */
load?: {
/** maximum V8 heap size over which incoming requests are rejected with an HTTP Server Timeout (503) response. Defaults to 0 (no limit). */
@@ -408,7 +408,7 @@ export interface IProxyHandlerConfig {
maxSockets?: boolean | number;
}
/** TODO: fill in joi definition */
export interface IJoi {}
export interface IJoi { }
/** a validation function using the signature function(value, options, next) */
export interface IValidationFunction {
@@ -514,7 +514,7 @@ export interface IRouteAdditionalConfigurationOptions {
};
/** an alternative location for the route handler option. */
handler?: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig;
handler?: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig;
/** an optional unique identifier used to look up the route using server.lookup(). */
id?: number;
/** optional arguments passed to JSON.stringify() when converting an object or error response to a string payload.Supports the following: */
@@ -764,14 +764,21 @@ export interface IServerRealm {
/** server.state(name, [options]) http://hapijs.com/api#serverstatename-options
HTTP state management uses client cookies to persist a state across multiple requests. Registers a cookie definitions where:*/
export interface IServerState {
/** - the cookie name string. */name: string;
/** - the cookie name string. */
name: string;
/** - are the optional cookie settings: */options: {
/** - time - to - live in milliseconds.Defaults to null (session time- life - cookies are deleted when the browser is closed).*/ttl: number;
/** - sets the 'Secure' flag.Defaults to false.*/isSecure: boolean;
/** - sets the 'HttpOnly' flag.Defaults to false.*/isHttpOnly: boolean
/** - the path scope.Defaults to null (no path).*/path: any;
/** - the domain scope.Defaults to null (no domain). */domain: any;
/** - are the optional cookie settings: */
options: {
/** - time - to - live in milliseconds.Defaults to null (session time- life - cookies are deleted when the browser is closed).*/
ttl: number;
/** - sets the 'Secure' flag.Defaults to false.*/
isSecure: boolean;
/** - sets the 'HttpOnly' flag.Defaults to false.*/
isHttpOnly: boolean
/** - the path scope.Defaults to null (no path).*/
path: any;
/** - the domain scope.Defaults to null (no domain). */
domain: any;
/** if present and the cookie was not received from the client or explicitly set by the route handler, the cookie is automatically added to the response with the provided value. The value can be a function with signature function(request, next) where:
request - the request object.
next - the continuation function using the function(err, value) signature.*/
@@ -783,16 +790,25 @@ export interface IServerState {
'form' - object value is encoded using the x-www-form-urlencoded method.
'iron' - Encrypts and sign the value using iron.*/
encoding: string;
/** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are:*/sign: {
/** - algorithm options.Defaults to require('iron').defaults.integrity.*/integrity: any;
/** - password used for HMAC key generation.*/password: string;
/** - an object used to calculate an HMAC for cookie integrity validation.This does not provide privacy, only a mean to verify that the cookie value was generated by the server.Redundant when 'iron' encoding is used.Options are:*/
sign: {
/** - algorithm options.Defaults to require('iron').defaults.integrity.*/
integrity: any;
/** - password used for HMAC key generation.*/
password: string;
};
/** - password used for 'iron' encoding.*/password: string;
/** - options for 'iron' encoding.Defaults to require('iron').defaults.*/iron: any;
/** - if false, errors are ignored and treated as missing cookies.*/ignoreErrors: boolean;
/** - if true, automatically instruct the client to remove invalid cookies.Defaults to false.*/clearInvalid: boolean;
/** - if false, allows any cookie value including values in violation of RFC 6265. Defaults to true.*/strictHeader: boolean;
/** - overrides the default proxy localStatePassThrough setting.*/passThrough: any;
/** - password used for 'iron' encoding.*/
password: string;
/** - options for 'iron' encoding.Defaults to require('iron').defaults.*/
iron: any;
/** - if false, errors are ignored and treated as missing cookies.*/
ignoreErrors: boolean;
/** - if true, automatically instruct the client to remove invalid cookies.Defaults to false.*/
clearInvalid: boolean;
/** - if false, allows any cookie value including values in violation of RFC 6265. Defaults to true.*/
strictHeader: boolean;
/** - overrides the default proxy localStatePassThrough setting.*/
passThrough: any;
};
}
@@ -915,7 +931,7 @@ export interface IRouteConfiguration {
/** - an optional domain string or an array of domain strings for limiting the route to only requests with a matching host header field.Matching is done against the hostname part of the header only (excluding the port).Defaults to all hosts.*/
vhost?: string;
/** - (required) the function called to generate the response after successful authentication and validation.The handler function is described in Route handler.If set to a string, the value is parsed the same way a prerequisite server method string shortcut is processed.Alternatively, handler can be assigned an object with a single key using the name of a registered handler type and value with the options passed to the registered handler.*/
handler?: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig;
handler?: ISessionHandler | IStrictSessionHandler | string | IRouteHandlerConfig;
/** - additional route options.*/
config?: IRouteAdditionalConfigurationOptions;
}
@@ -1122,7 +1138,7 @@ export interface IServerMethod {
generateKey - a function used to generate a unique key (for caching) from the arguments passed to the method function (the callback argument is not passed as input). The server will automatically generate a unique key if the function's arguments are all of types 'string', 'number', or 'boolean'. However if the method uses other types of arguments, a key generation function must be provided which takes the same arguments as the function and returns a unique string (or null if no key can be generated).*/
export interface IServerMethodOptions {
bind?: any;
cache?: ICatBoxCachePolicyOptions;
cache?: ICatBoxCachePolicyOptions;
callback?: boolean;
generateKey?(args: any[]): string;
}
@@ -1891,9 +1907,9 @@ export class Server extends Events.EventEmitter {
* }
* });
*/
strategy(name: string, scheme: string, mode?: boolean | string, options?: any): void;
strategy(name: string, scheme: string, mode?: boolean | string): void;
strategy(name: string, scheme: string, options?: any): void;
strategy(name: string, scheme: string, mode?: boolean | string, options?: any): void;
strategy(name: string, scheme: string, mode?: boolean | string): void;
strategy(name: string, scheme: string, options?: any): void;
/** server.auth.test(strategy, request, next)
Tests a request against an authentication strategy where:
@@ -1959,7 +1975,7 @@ export class Server extends Events.EventEmitter {
// value === { capital: 'oslo' };
});
});*/
cache(options: ICatBoxCachePolicyOptions): void;
cache(options: ICatBoxCachePolicyOptions): void;
/** server.connection([options])
Adds an incoming server connection
@@ -2295,7 +2311,7 @@ export class Server extends Events.EventEmitter {
register(
plugins: any | any[],
options: {
select: string | string[];
select?: string | string[];
routes: {
prefix: string; vhost?: string | string[]
};
@@ -2304,7 +2320,7 @@ export class Server extends Events.EventEmitter {
register(
plugins: any | any[],
options: {
select: string | string[];
select?: string | string[];
routes: {
prefix: string; vhost?: string | string[]
};
+28
View File
@@ -59,6 +59,18 @@ i18n.init({
wait: false
});
i18n.init({
fallbackLng: ['en', 'ru'],
});
i18n.init({
fallbackLng: {
'de-CH': ['fr', 'it'],
'zh-HANT': ['zh-HANS', 'en'],
'default': ['en']
},
});
i18n.t('helloWorld', <i18n.TranslationOptions> {
defaultValue: 'default',
count: 10
@@ -70,6 +82,22 @@ i18n.t('helloWorldInterpolated', <i18n.TranslationOptions> {
name: "world"
});
i18n.t('helloSingleFallbackLng', <i18n.TranslationOptions> {
fallbackLng: 'en'
});
i18n.t('helloMultiFallbackLng', <i18n.TranslationOptions> {
fallbackLng: ['en', 'ru']
});
i18n.t('helloObjectFallbackLng', <i18n.TranslationOptions> {
fallbackLng: {
'de-CH': ['fr', 'it'],
'zh-HANT': ['zh-HANS', 'en'],
'default': ['en']
},
});
i18n.exists("helloWorld");
const options:i18n.Options = i18n.options;
+10 -4
View File
@@ -1,6 +1,6 @@
// Type definitions for i18next v2.3.4
// Type definitions for i18next v2.3.5
// Project: http://i18next.com
// Definitions by: Michael Ledin <https://github.com/mxl>
// Definitions by: Michael Ledin <https://github.com/mxl>, Budi Irawan <https://github.com/deerawan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Sources: https://github.com/i18next/i18next/
@@ -19,6 +19,12 @@ declare namespace i18n {
[key: string]: any;
}
interface FallbackLngObjList {
[language: string]: string[]
}
type FallbackLng = string | string[] | FallbackLngObjList;
interface InterpolationOptions {
escapeValue?: boolean;
prefix?: string;
@@ -41,7 +47,7 @@ declare namespace i18n {
replace?: any;
lng?: string;
lngs?: string[];
fallbackLng?: string;
fallbackLng?: FallbackLng;
ns?: string | string[];
keySeparator?: string;
nsSeparator?: string;
@@ -57,7 +63,7 @@ declare namespace i18n {
debug?: boolean;
resources?: ResourceStore;
lng?: string;
fallbackLng?: string;
fallbackLng?: FallbackLng;
ns?: string | string[];
defaultNS?: string;
fallbackNS?: string | string[];
+12 -12
View File
@@ -27,13 +27,13 @@ interface JasmineAjaxRequest extends XMLHttpRequest {
}
interface JasmineAjaxRequestTracker {
track(request: JasmineAjaxRequest): void;
first(): JasmineAjaxRequest;
count(): number;
reset(): void;
mostRecent(): JasmineAjaxRequest;
at(index: number): JasmineAjaxRequest;
filter(urlToMatch: RegExp): JasmineAjaxRequest[];
track(request: JasmineAjaxRequest): void;
first(): JasmineAjaxRequest;
count(): number;
reset(): void;
mostRecent(): JasmineAjaxRequest;
at(index: number): JasmineAjaxRequest;
filter(urlToMatch: RegExp): JasmineAjaxRequest[];
filter(urlToMatch: Function): JasmineAjaxRequest[];
filter(urlToMatch: string): JasmineAjaxRequest[];
}
@@ -48,14 +48,14 @@ interface JasmineAjaxRequestStubReturnOptions {
interface JasmineAjaxRequestStub {
data?: string;
method?: string;
andReturn(options: JasmineAjaxRequestStubReturnOptions): void;
matches(fullUrl: string, data: string, method: string): boolean;
method?: string;
andReturn(options: JasmineAjaxRequestStubReturnOptions): void;
matches(fullUrl: string, data: string, method: string): boolean;
}
interface JasmineAjaxStubTracker {
addStub(stub: JasmineAjaxRequestStub): void;
reset(): void;
addStub(stub: JasmineAjaxRequestStub): void;
reset(): void;
findStub(url: string, data?: string, method?: string): JasmineAjaxRequestStub;
}
+1 -1
View File
@@ -1779,7 +1779,7 @@ describe("mockAjax", () => {
mockAjax.install();
mockAjax.requests.track(<any> { url: '/testurl' });
// mockAjax.requests.track(<any> { url: '/testurl' });
mockAjax.stubRequest('/bobcat');
expect(mockAjax.requests.count()).toEqual(1);
+1
View File
@@ -291,6 +291,7 @@ declare function pending(reason?: string): void;
/** Fails a test when called within one. */
declare function fail(error?: any): void;
declare namespace jasmine {
var DEFAULT_TIMEOUT_INTERVAL: number;
var clock: () => Clock;
function any(aclass: any): Any;
function anything(): Any;
+8
View File
@@ -167,6 +167,14 @@ export interface Reference extends Schema {
}
export interface AnySchema<T extends AnySchema<Schema>> {
/**
* Validates a value using the schema and options.
*/
validate<T>(value: T): ValidationResult<T>;
validate<T>(value: T, options: ValidationOptions): ValidationResult<T>;
validate<T, R>(value: T, callback: (err: ValidationError, value: T) => R): R;
validate<T, R>(value: T, options: ValidationOptions, callback: (err: ValidationError, value: T) => R): R;
/**
* Whitelists a value
*/
+406 -401
View File
@@ -50,87 +50,87 @@ var ref: Joi.Reference = null;
var validOpts: Joi.ValidationOptions = null;
validOpts = {abortEarly: bool};
validOpts = {convert: bool};
validOpts = {allowUnknown: bool};
validOpts = {skipFunctions: bool};
validOpts = {stripUnknown: bool};
validOpts = {stripUnknown: {arrays: bool}};
validOpts = {stripUnknown: {objects: bool}};
validOpts = {stripUnknown: {arrays: bool, objects: bool}};
validOpts = {language: bool};
validOpts = {presence: str};
validOpts = {context: obj};
validOpts = {noDefaults: bool};
validOpts = { abortEarly: bool };
validOpts = { convert: bool };
validOpts = { allowUnknown: bool };
validOpts = { skipFunctions: bool };
validOpts = { stripUnknown: bool };
validOpts = { stripUnknown: { arrays: bool } };
validOpts = { stripUnknown: { objects: bool } };
validOpts = { stripUnknown: { arrays: bool, objects: bool } };
validOpts = { language: bool };
validOpts = { presence: str };
validOpts = { context: obj };
validOpts = { noDefaults: bool };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var renOpts: Joi.RenameOptions = null;
renOpts = {alias: bool};
renOpts = {multiple: bool};
renOpts = {override: bool};
renOpts = {ignoreUndefined: bool};
renOpts = { alias: bool };
renOpts = { multiple: bool };
renOpts = { override: bool };
renOpts = { ignoreUndefined: bool };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var emailOpts: Joi.EmailOptions = null;
emailOpts = {errorLevel: num};
emailOpts = {errorLevel: bool};
emailOpts = {tldWhitelist: strArr};
emailOpts = {tldWhitelist: obj};
emailOpts = {minDomainAtoms: num};
emailOpts = { errorLevel: num };
emailOpts = { errorLevel: bool };
emailOpts = { tldWhitelist: strArr };
emailOpts = { tldWhitelist: obj };
emailOpts = { minDomainAtoms: num };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var ipOpts: Joi.IpOptions = null;
ipOpts = {version: str};
ipOpts = {version: strArr};
ipOpts = {cidr: str};
ipOpts = { version: str };
ipOpts = { version: strArr };
ipOpts = { cidr: str };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var uriOpts: Joi.UriOptions = null;
uriOpts = {scheme: str};
uriOpts = {scheme: exp};
uriOpts = {scheme: strArr};
uriOpts = {scheme: expArr};
uriOpts = { scheme: str };
uriOpts = { scheme: exp };
uriOpts = { scheme: strArr };
uriOpts = { scheme: expArr };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var whenOpts: Joi.WhenOptions<any> = null;
whenOpts = {is: x};
whenOpts = {is: schema, then: schema};
whenOpts = {is: schema, otherwise: schema};
whenOpts = { is: x };
whenOpts = { is: schema, then: schema };
whenOpts = { is: schema, otherwise: schema };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var refOpts: Joi.ReferenceOptions = null;
refOpts = {separator: str};
refOpts = {contextPrefix: str};
refOpts = { separator: str };
refOpts = { contextPrefix: str };
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
var validErr: Joi.ValidationError = null;
var validErrItem: Joi.ValidationErrorItem;
validErrItem= {
message: str,
type: str,
path: str
validErrItem = {
message: str,
type: str,
path: str
};
validErrItem = {
message: str,
type: str,
path: str,
options: validOpts,
context: obj
message: str,
type: str,
path: str,
options: validOpts,
context: obj
};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -162,23 +162,23 @@ anySchema = objSchema;
var schemaMap: Joi.SchemaMap = null;
schemaMap = {
a: numSchema,
b: strSchema
a: numSchema,
b: strSchema
};
schemaMap = {
a: numSchema,
b: {
b1: strSchema,
b2: anySchema
}
a: numSchema,
b: {
b1: strSchema,
b2: anySchema
}
};
schemaMap = {
a: numSchema,
b: [
{ b1: strSchema },
{ b2: anySchema }
],
c: arrSchema
a: numSchema,
b: [
{ b1: strSchema },
{ b2: anySchema }
],
c: arrSchema
};
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -186,63 +186,63 @@ schemaMap = {
anySchema = Joi.any();
namespace common {
anySchema = anySchema.allow(x);
anySchema = anySchema.allow(x, x);
anySchema = anySchema.allow([x, x, x]);
anySchema = anySchema.valid(x);
anySchema = anySchema.valid(x, x);
anySchema = anySchema.valid([x, x, x]);
anySchema = anySchema.only(x);
anySchema = anySchema.only(x, x);
anySchema = anySchema.only([x, x, x]);
anySchema = anySchema.equal(x);
anySchema = anySchema.equal(x, x);
anySchema = anySchema.equal([x, x, x]);
anySchema = anySchema.invalid(x);
anySchema = anySchema.invalid(x, x);
anySchema = anySchema.invalid([x, x, x]);
anySchema = anySchema.disallow(x);
anySchema = anySchema.disallow(x, x);
anySchema = anySchema.disallow([x, x, x]);
anySchema = anySchema.not(x);
anySchema = anySchema.not(x, x);
anySchema = anySchema.not([x, x, x]);
anySchema = anySchema.allow(x);
anySchema = anySchema.allow(x, x);
anySchema = anySchema.allow([x, x, x]);
anySchema = anySchema.valid(x);
anySchema = anySchema.valid(x, x);
anySchema = anySchema.valid([x, x, x]);
anySchema = anySchema.only(x);
anySchema = anySchema.only(x, x);
anySchema = anySchema.only([x, x, x]);
anySchema = anySchema.equal(x);
anySchema = anySchema.equal(x, x);
anySchema = anySchema.equal([x, x, x]);
anySchema = anySchema.invalid(x);
anySchema = anySchema.invalid(x, x);
anySchema = anySchema.invalid([x, x, x]);
anySchema = anySchema.disallow(x);
anySchema = anySchema.disallow(x, x);
anySchema = anySchema.disallow([x, x, x]);
anySchema = anySchema.not(x);
anySchema = anySchema.not(x, x);
anySchema = anySchema.not([x, x, x]);
anySchema = anySchema.default();
anySchema = anySchema.default(x);
anySchema = anySchema.default(x, str);
anySchema = anySchema.default();
anySchema = anySchema.default(x);
anySchema = anySchema.default(x, str);
anySchema = anySchema.required();
anySchema = anySchema.optional();
anySchema = anySchema.forbidden();
anySchema = anySchema.strip();
anySchema = anySchema.required();
anySchema = anySchema.optional();
anySchema = anySchema.forbidden();
anySchema = anySchema.strip();
anySchema = anySchema.description(str);
anySchema = anySchema.notes(str);
anySchema = anySchema.notes(strArr);
anySchema = anySchema.tags(str);
anySchema = anySchema.tags(strArr);
anySchema = anySchema.description(str);
anySchema = anySchema.notes(str);
anySchema = anySchema.notes(strArr);
anySchema = anySchema.tags(str);
anySchema = anySchema.tags(strArr);
anySchema = anySchema.meta(obj);
anySchema = anySchema.example(obj);
anySchema = anySchema.unit(str);
anySchema = anySchema.meta(obj);
anySchema = anySchema.example(obj);
anySchema = anySchema.unit(str);
anySchema = anySchema.options(validOpts);
anySchema = anySchema.strict();
anySchema = anySchema.strict(bool);
anySchema = anySchema.concat(x);
anySchema = anySchema.options(validOpts);
anySchema = anySchema.strict();
anySchema = anySchema.strict(bool);
anySchema = anySchema.concat(x);
altSchema = anySchema.when(str, whenOpts);
altSchema = anySchema.when(ref, whenOpts);
altSchema = anySchema.when(str, whenOpts);
altSchema = anySchema.when(ref, whenOpts);
anySchema = anySchema.label(str);
anySchema = anySchema.raw();
anySchema = anySchema.raw(bool);
anySchema = anySchema.empty();
anySchema = anySchema.empty(str);
anySchema = anySchema.empty(anySchema);
anySchema = anySchema.label(str);
anySchema = anySchema.raw();
anySchema = anySchema.raw(bool);
anySchema = anySchema.empty();
anySchema = anySchema.empty(str);
anySchema = anySchema.empty(anySchema);
anySchema = anySchema.error(err);
anySchema = anySchema.error(err);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -275,51 +275,51 @@ arrSchema = arrSchema.items([schemaMap, schemaMap]);
// - - - - - - - -
namespace common_copy_paste {
// use search & replace from any
arrSchema = arrSchema.allow(x);
arrSchema = arrSchema.allow(x, x);
arrSchema = arrSchema.allow([x, x, x]);
arrSchema = arrSchema.valid(x);
arrSchema = arrSchema.valid(x, x);
arrSchema = arrSchema.valid([x, x, x]);
arrSchema = arrSchema.only(x);
arrSchema = arrSchema.only(x, x);
arrSchema = arrSchema.only([x, x, x]);
arrSchema = arrSchema.equal(x);
arrSchema = arrSchema.equal(x, x);
arrSchema = arrSchema.equal([x, x, x]);
arrSchema = arrSchema.invalid(x);
arrSchema = arrSchema.invalid(x, x);
arrSchema = arrSchema.invalid([x, x, x]);
arrSchema = arrSchema.disallow(x);
arrSchema = arrSchema.disallow(x, x);
arrSchema = arrSchema.disallow([x, x, x]);
arrSchema = arrSchema.not(x);
arrSchema = arrSchema.not(x, x);
arrSchema = arrSchema.not([x, x, x]);
// use search & replace from any
arrSchema = arrSchema.allow(x);
arrSchema = arrSchema.allow(x, x);
arrSchema = arrSchema.allow([x, x, x]);
arrSchema = arrSchema.valid(x);
arrSchema = arrSchema.valid(x, x);
arrSchema = arrSchema.valid([x, x, x]);
arrSchema = arrSchema.only(x);
arrSchema = arrSchema.only(x, x);
arrSchema = arrSchema.only([x, x, x]);
arrSchema = arrSchema.equal(x);
arrSchema = arrSchema.equal(x, x);
arrSchema = arrSchema.equal([x, x, x]);
arrSchema = arrSchema.invalid(x);
arrSchema = arrSchema.invalid(x, x);
arrSchema = arrSchema.invalid([x, x, x]);
arrSchema = arrSchema.disallow(x);
arrSchema = arrSchema.disallow(x, x);
arrSchema = arrSchema.disallow([x, x, x]);
arrSchema = arrSchema.not(x);
arrSchema = arrSchema.not(x, x);
arrSchema = arrSchema.not([x, x, x]);
arrSchema = arrSchema.default(x);
arrSchema = arrSchema.default(x);
arrSchema = arrSchema.required();
arrSchema = arrSchema.optional();
arrSchema = arrSchema.forbidden();
arrSchema = arrSchema.required();
arrSchema = arrSchema.optional();
arrSchema = arrSchema.forbidden();
arrSchema = arrSchema.description(str);
arrSchema = arrSchema.notes(str);
arrSchema = arrSchema.notes(strArr);
arrSchema = arrSchema.tags(str);
arrSchema = arrSchema.tags(strArr);
arrSchema = arrSchema.description(str);
arrSchema = arrSchema.notes(str);
arrSchema = arrSchema.notes(strArr);
arrSchema = arrSchema.tags(str);
arrSchema = arrSchema.tags(strArr);
arrSchema = arrSchema.meta(obj);
arrSchema = arrSchema.example(obj);
arrSchema = arrSchema.unit(str);
arrSchema = arrSchema.meta(obj);
arrSchema = arrSchema.example(obj);
arrSchema = arrSchema.unit(str);
arrSchema = arrSchema.options(validOpts);
arrSchema = arrSchema.strict();
arrSchema = arrSchema.concat(x);
arrSchema = arrSchema.options(validOpts);
arrSchema = arrSchema.strict();
arrSchema = arrSchema.concat(x);
altSchema = arrSchema.when(str, whenOpts);
altSchema = arrSchema.when(ref, whenOpts);
altSchema = arrSchema.when(str, whenOpts);
altSchema = arrSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -328,68 +328,68 @@ boolSchema = Joi.bool();
boolSchema = Joi.boolean();
namespace common_copy_paste {
boolSchema = boolSchema.allow(x);
boolSchema = boolSchema.allow(x, x);
boolSchema = boolSchema.allow([x, x, x]);
boolSchema = boolSchema.valid(x);
boolSchema = boolSchema.valid(x, x);
boolSchema = boolSchema.valid([x, x, x]);
boolSchema = boolSchema.only(x);
boolSchema = boolSchema.only(x, x);
boolSchema = boolSchema.only([x, x, x]);
boolSchema = boolSchema.equal(x);
boolSchema = boolSchema.equal(x, x);
boolSchema = boolSchema.equal([x, x, x]);
boolSchema = boolSchema.invalid(x);
boolSchema = boolSchema.invalid(x, x);
boolSchema = boolSchema.invalid([x, x, x]);
boolSchema = boolSchema.disallow(x);
boolSchema = boolSchema.disallow(x, x);
boolSchema = boolSchema.disallow([x, x, x]);
boolSchema = boolSchema.not(x);
boolSchema = boolSchema.not(x, x);
boolSchema = boolSchema.not([x, x, x]);
boolSchema = boolSchema.allow(x);
boolSchema = boolSchema.allow(x, x);
boolSchema = boolSchema.allow([x, x, x]);
boolSchema = boolSchema.valid(x);
boolSchema = boolSchema.valid(x, x);
boolSchema = boolSchema.valid([x, x, x]);
boolSchema = boolSchema.only(x);
boolSchema = boolSchema.only(x, x);
boolSchema = boolSchema.only([x, x, x]);
boolSchema = boolSchema.equal(x);
boolSchema = boolSchema.equal(x, x);
boolSchema = boolSchema.equal([x, x, x]);
boolSchema = boolSchema.invalid(x);
boolSchema = boolSchema.invalid(x, x);
boolSchema = boolSchema.invalid([x, x, x]);
boolSchema = boolSchema.disallow(x);
boolSchema = boolSchema.disallow(x, x);
boolSchema = boolSchema.disallow([x, x, x]);
boolSchema = boolSchema.not(x);
boolSchema = boolSchema.not(x, x);
boolSchema = boolSchema.not([x, x, x]);
boolSchema = boolSchema.default(x);
boolSchema = boolSchema.default(x);
boolSchema = boolSchema.required();
boolSchema = boolSchema.optional();
boolSchema = boolSchema.forbidden();
boolSchema = boolSchema.required();
boolSchema = boolSchema.optional();
boolSchema = boolSchema.forbidden();
boolSchema = boolSchema.description(str);
boolSchema = boolSchema.notes(str);
boolSchema = boolSchema.notes(strArr);
boolSchema = boolSchema.tags(str);
boolSchema = boolSchema.tags(strArr);
boolSchema = boolSchema.description(str);
boolSchema = boolSchema.notes(str);
boolSchema = boolSchema.notes(strArr);
boolSchema = boolSchema.tags(str);
boolSchema = boolSchema.tags(strArr);
boolSchema = boolSchema.meta(obj);
boolSchema = boolSchema.example(obj);
boolSchema = boolSchema.unit(str);
boolSchema = boolSchema.meta(obj);
boolSchema = boolSchema.example(obj);
boolSchema = boolSchema.unit(str);
boolSchema = boolSchema.options(validOpts);
boolSchema = boolSchema.strict();
boolSchema = boolSchema.concat(x);
boolSchema = boolSchema.options(validOpts);
boolSchema = boolSchema.strict();
boolSchema = boolSchema.concat(x);
boolSchema = boolSchema.truthy(str);
boolSchema = boolSchema.truthy(num);
boolSchema = boolSchema.truthy(strArr);
boolSchema = boolSchema.truthy(numArr);
boolSchema = boolSchema.truthy(str, str);
boolSchema = boolSchema.truthy(strArr, str);
boolSchema = boolSchema.truthy(str, strArr);
boolSchema = boolSchema.truthy(strArr, strArr);
boolSchema = boolSchema.falsy(str);
boolSchema = boolSchema.falsy(num);
boolSchema = boolSchema.falsy(strArr);
boolSchema = boolSchema.falsy(numArr);
boolSchema = boolSchema.falsy(str, str);
boolSchema = boolSchema.falsy(strArr, str);
boolSchema = boolSchema.falsy(str, strArr);
boolSchema = boolSchema.falsy(strArr, strArr);
boolSchema = boolSchema.insensitive(bool);
boolSchema = boolSchema.truthy(str);
boolSchema = boolSchema.truthy(num);
boolSchema = boolSchema.truthy(strArr);
boolSchema = boolSchema.truthy(numArr);
boolSchema = boolSchema.truthy(str, str);
boolSchema = boolSchema.truthy(strArr, str);
boolSchema = boolSchema.truthy(str, strArr);
boolSchema = boolSchema.truthy(strArr, strArr);
boolSchema = boolSchema.falsy(str);
boolSchema = boolSchema.falsy(num);
boolSchema = boolSchema.falsy(strArr);
boolSchema = boolSchema.falsy(numArr);
boolSchema = boolSchema.falsy(str, str);
boolSchema = boolSchema.falsy(strArr, str);
boolSchema = boolSchema.falsy(str, strArr);
boolSchema = boolSchema.falsy(strArr, strArr);
boolSchema = boolSchema.insensitive(bool);
altSchema = boolSchema.when(str, whenOpts);
altSchema = boolSchema.when(ref, whenOpts);
altSchema = boolSchema.when(str, whenOpts);
altSchema = boolSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -402,50 +402,50 @@ binSchema = binSchema.max(num);
binSchema = binSchema.length(num);
namespace common {
binSchema = binSchema.allow(x);
binSchema = binSchema.allow(x, x);
binSchema = binSchema.allow([x, x, x]);
binSchema = binSchema.valid(x);
binSchema = binSchema.valid(x, x);
binSchema = binSchema.valid([x, x, x]);
binSchema = binSchema.only(x);
binSchema = binSchema.only(x, x);
binSchema = binSchema.only([x, x, x]);
binSchema = binSchema.equal(x);
binSchema = binSchema.equal(x, x);
binSchema = binSchema.equal([x, x, x]);
binSchema = binSchema.invalid(x);
binSchema = binSchema.invalid(x, x);
binSchema = binSchema.invalid([x, x, x]);
binSchema = binSchema.disallow(x);
binSchema = binSchema.disallow(x, x);
binSchema = binSchema.disallow([x, x, x]);
binSchema = binSchema.not(x);
binSchema = binSchema.not(x, x);
binSchema = binSchema.not([x, x, x]);
binSchema = binSchema.allow(x);
binSchema = binSchema.allow(x, x);
binSchema = binSchema.allow([x, x, x]);
binSchema = binSchema.valid(x);
binSchema = binSchema.valid(x, x);
binSchema = binSchema.valid([x, x, x]);
binSchema = binSchema.only(x);
binSchema = binSchema.only(x, x);
binSchema = binSchema.only([x, x, x]);
binSchema = binSchema.equal(x);
binSchema = binSchema.equal(x, x);
binSchema = binSchema.equal([x, x, x]);
binSchema = binSchema.invalid(x);
binSchema = binSchema.invalid(x, x);
binSchema = binSchema.invalid([x, x, x]);
binSchema = binSchema.disallow(x);
binSchema = binSchema.disallow(x, x);
binSchema = binSchema.disallow([x, x, x]);
binSchema = binSchema.not(x);
binSchema = binSchema.not(x, x);
binSchema = binSchema.not([x, x, x]);
binSchema = binSchema.default(x);
binSchema = binSchema.default(x);
binSchema = binSchema.required();
binSchema = binSchema.optional();
binSchema = binSchema.forbidden();
binSchema = binSchema.required();
binSchema = binSchema.optional();
binSchema = binSchema.forbidden();
binSchema = binSchema.description(str);
binSchema = binSchema.notes(str);
binSchema = binSchema.notes(strArr);
binSchema = binSchema.tags(str);
binSchema = binSchema.tags(strArr);
binSchema = binSchema.description(str);
binSchema = binSchema.notes(str);
binSchema = binSchema.notes(strArr);
binSchema = binSchema.tags(str);
binSchema = binSchema.tags(strArr);
binSchema = binSchema.meta(obj);
binSchema = binSchema.example(obj);
binSchema = binSchema.unit(str);
binSchema = binSchema.meta(obj);
binSchema = binSchema.example(obj);
binSchema = binSchema.unit(str);
binSchema = binSchema.options(validOpts);
binSchema = binSchema.strict();
binSchema = binSchema.concat(x);
binSchema = binSchema.options(validOpts);
binSchema = binSchema.strict();
binSchema = binSchema.concat(x);
altSchema = binSchema.when(str, whenOpts);
altSchema = binSchema.when(ref, whenOpts);
altSchema = binSchema.when(str, whenOpts);
altSchema = binSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -474,50 +474,50 @@ dateSchema = dateSchema.timestamp('javascript');
dateSchema = dateSchema.timestamp('unix');
namespace common {
dateSchema = dateSchema.allow(x);
dateSchema = dateSchema.allow(x, x);
dateSchema = dateSchema.allow([x, x, x]);
dateSchema = dateSchema.valid(x);
dateSchema = dateSchema.valid(x, x);
dateSchema = dateSchema.valid([x, x, x]);
dateSchema = dateSchema.only(x);
dateSchema = dateSchema.only(x, x);
dateSchema = dateSchema.only([x, x, x]);
dateSchema = dateSchema.equal(x);
dateSchema = dateSchema.equal(x, x);
dateSchema = dateSchema.equal([x, x, x]);
dateSchema = dateSchema.invalid(x);
dateSchema = dateSchema.invalid(x, x);
dateSchema = dateSchema.invalid([x, x, x]);
dateSchema = dateSchema.disallow(x);
dateSchema = dateSchema.disallow(x, x);
dateSchema = dateSchema.disallow([x, x, x]);
dateSchema = dateSchema.not(x);
dateSchema = dateSchema.not(x, x);
dateSchema = dateSchema.not([x, x, x]);
dateSchema = dateSchema.allow(x);
dateSchema = dateSchema.allow(x, x);
dateSchema = dateSchema.allow([x, x, x]);
dateSchema = dateSchema.valid(x);
dateSchema = dateSchema.valid(x, x);
dateSchema = dateSchema.valid([x, x, x]);
dateSchema = dateSchema.only(x);
dateSchema = dateSchema.only(x, x);
dateSchema = dateSchema.only([x, x, x]);
dateSchema = dateSchema.equal(x);
dateSchema = dateSchema.equal(x, x);
dateSchema = dateSchema.equal([x, x, x]);
dateSchema = dateSchema.invalid(x);
dateSchema = dateSchema.invalid(x, x);
dateSchema = dateSchema.invalid([x, x, x]);
dateSchema = dateSchema.disallow(x);
dateSchema = dateSchema.disallow(x, x);
dateSchema = dateSchema.disallow([x, x, x]);
dateSchema = dateSchema.not(x);
dateSchema = dateSchema.not(x, x);
dateSchema = dateSchema.not([x, x, x]);
dateSchema = dateSchema.default(x);
dateSchema = dateSchema.default(x);
dateSchema = dateSchema.required();
dateSchema = dateSchema.optional();
dateSchema = dateSchema.forbidden();
dateSchema = dateSchema.required();
dateSchema = dateSchema.optional();
dateSchema = dateSchema.forbidden();
dateSchema = dateSchema.description(str);
dateSchema = dateSchema.notes(str);
dateSchema = dateSchema.notes(strArr);
dateSchema = dateSchema.tags(str);
dateSchema = dateSchema.tags(strArr);
dateSchema = dateSchema.description(str);
dateSchema = dateSchema.notes(str);
dateSchema = dateSchema.notes(strArr);
dateSchema = dateSchema.tags(str);
dateSchema = dateSchema.tags(strArr);
dateSchema = dateSchema.meta(obj);
dateSchema = dateSchema.example(obj);
dateSchema = dateSchema.unit(str);
dateSchema = dateSchema.meta(obj);
dateSchema = dateSchema.example(obj);
dateSchema = dateSchema.unit(str);
dateSchema = dateSchema.options(validOpts);
dateSchema = dateSchema.strict();
dateSchema = dateSchema.concat(x);
dateSchema = dateSchema.options(validOpts);
dateSchema = dateSchema.strict();
dateSchema = dateSchema.concat(x);
altSchema = dateSchema.when(str, whenOpts);
altSchema = dateSchema.when(ref, whenOpts);
altSchema = dateSchema.when(str, whenOpts);
altSchema = dateSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -548,50 +548,50 @@ numSchema = numSchema.positive();
numSchema = numSchema.negative();
namespace common {
numSchema = numSchema.allow(x);
numSchema = numSchema.allow(x, x);
numSchema = numSchema.allow([x, x, x]);
numSchema = numSchema.valid(x);
numSchema = numSchema.valid(x, x);
numSchema = numSchema.valid([x, x, x]);
numSchema = numSchema.only(x);
numSchema = numSchema.only(x, x);
numSchema = numSchema.only([x, x, x]);
numSchema = numSchema.equal(x);
numSchema = numSchema.equal(x, x);
numSchema = numSchema.equal([x, x, x]);
numSchema = numSchema.invalid(x);
numSchema = numSchema.invalid(x, x);
numSchema = numSchema.invalid([x, x, x]);
numSchema = numSchema.disallow(x);
numSchema = numSchema.disallow(x, x);
numSchema = numSchema.disallow([x, x, x]);
numSchema = numSchema.not(x);
numSchema = numSchema.not(x, x);
numSchema = numSchema.not([x, x, x]);
numSchema = numSchema.allow(x);
numSchema = numSchema.allow(x, x);
numSchema = numSchema.allow([x, x, x]);
numSchema = numSchema.valid(x);
numSchema = numSchema.valid(x, x);
numSchema = numSchema.valid([x, x, x]);
numSchema = numSchema.only(x);
numSchema = numSchema.only(x, x);
numSchema = numSchema.only([x, x, x]);
numSchema = numSchema.equal(x);
numSchema = numSchema.equal(x, x);
numSchema = numSchema.equal([x, x, x]);
numSchema = numSchema.invalid(x);
numSchema = numSchema.invalid(x, x);
numSchema = numSchema.invalid([x, x, x]);
numSchema = numSchema.disallow(x);
numSchema = numSchema.disallow(x, x);
numSchema = numSchema.disallow([x, x, x]);
numSchema = numSchema.not(x);
numSchema = numSchema.not(x, x);
numSchema = numSchema.not([x, x, x]);
numSchema = numSchema.default(x);
numSchema = numSchema.default(x);
numSchema = numSchema.required();
numSchema = numSchema.optional();
numSchema = numSchema.forbidden();
numSchema = numSchema.required();
numSchema = numSchema.optional();
numSchema = numSchema.forbidden();
numSchema = numSchema.description(str);
numSchema = numSchema.notes(str);
numSchema = numSchema.notes(strArr);
numSchema = numSchema.tags(str);
numSchema = numSchema.tags(strArr);
numSchema = numSchema.description(str);
numSchema = numSchema.notes(str);
numSchema = numSchema.notes(strArr);
numSchema = numSchema.tags(str);
numSchema = numSchema.tags(strArr);
numSchema = numSchema.meta(obj);
numSchema = numSchema.example(obj);
numSchema = numSchema.unit(str);
numSchema = numSchema.meta(obj);
numSchema = numSchema.example(obj);
numSchema = numSchema.unit(str);
numSchema = numSchema.options(validOpts);
numSchema = numSchema.strict();
numSchema = numSchema.concat(x);
numSchema = numSchema.options(validOpts);
numSchema = numSchema.strict();
numSchema = numSchema.concat(x);
altSchema = numSchema.when(str, whenOpts);
altSchema = numSchema.when(ref, whenOpts);
altSchema = numSchema.when(str, whenOpts);
altSchema = numSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -657,50 +657,50 @@ objSchema = objSchema.optionalKeys(str, str);
objSchema = objSchema.optionalKeys(strArr);
namespace common {
objSchema = objSchema.allow(x);
objSchema = objSchema.allow(x, x);
objSchema = objSchema.allow([x, x, x]);
objSchema = objSchema.valid(x);
objSchema = objSchema.valid(x, x);
objSchema = objSchema.valid([x, x, x]);
objSchema = objSchema.only(x);
objSchema = objSchema.only(x, x);
objSchema = objSchema.only([x, x, x]);
objSchema = objSchema.equal(x);
objSchema = objSchema.equal(x, x);
objSchema = objSchema.equal([x, x, x]);
objSchema = objSchema.invalid(x);
objSchema = objSchema.invalid(x, x);
objSchema = objSchema.invalid([x, x, x]);
objSchema = objSchema.disallow(x);
objSchema = objSchema.disallow(x, x);
objSchema = objSchema.disallow([x, x, x]);
objSchema = objSchema.not(x);
objSchema = objSchema.not(x, x);
objSchema = objSchema.not([x, x, x]);
objSchema = objSchema.allow(x);
objSchema = objSchema.allow(x, x);
objSchema = objSchema.allow([x, x, x]);
objSchema = objSchema.valid(x);
objSchema = objSchema.valid(x, x);
objSchema = objSchema.valid([x, x, x]);
objSchema = objSchema.only(x);
objSchema = objSchema.only(x, x);
objSchema = objSchema.only([x, x, x]);
objSchema = objSchema.equal(x);
objSchema = objSchema.equal(x, x);
objSchema = objSchema.equal([x, x, x]);
objSchema = objSchema.invalid(x);
objSchema = objSchema.invalid(x, x);
objSchema = objSchema.invalid([x, x, x]);
objSchema = objSchema.disallow(x);
objSchema = objSchema.disallow(x, x);
objSchema = objSchema.disallow([x, x, x]);
objSchema = objSchema.not(x);
objSchema = objSchema.not(x, x);
objSchema = objSchema.not([x, x, x]);
objSchema = objSchema.default(x);
objSchema = objSchema.default(x);
objSchema = objSchema.required();
objSchema = objSchema.optional();
objSchema = objSchema.forbidden();
objSchema = objSchema.required();
objSchema = objSchema.optional();
objSchema = objSchema.forbidden();
objSchema = objSchema.description(str);
objSchema = objSchema.notes(str);
objSchema = objSchema.notes(strArr);
objSchema = objSchema.tags(str);
objSchema = objSchema.tags(strArr);
objSchema = objSchema.description(str);
objSchema = objSchema.notes(str);
objSchema = objSchema.notes(strArr);
objSchema = objSchema.tags(str);
objSchema = objSchema.tags(strArr);
objSchema = objSchema.meta(obj);
objSchema = objSchema.example(obj);
objSchema = objSchema.unit(str);
objSchema = objSchema.meta(obj);
objSchema = objSchema.example(obj);
objSchema = objSchema.unit(str);
objSchema = objSchema.options(validOpts);
objSchema = objSchema.strict();
objSchema = objSchema.concat(x);
objSchema = objSchema.options(validOpts);
objSchema = objSchema.strict();
objSchema = objSchema.concat(x);
altSchema = objSchema.when(str, whenOpts);
altSchema = objSchema.when(ref, whenOpts);
altSchema = objSchema.when(str, whenOpts);
altSchema = objSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -734,8 +734,8 @@ strSchema = strSchema.ip(ipOpts);
strSchema = strSchema.uri();
strSchema = strSchema.uri(uriOpts);
strSchema = strSchema.guid();
strSchema = strSchema.guid({version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5']});
strSchema = strSchema.guid({version: 'uuidv4'});
strSchema = strSchema.guid({ version: ['uuidv1', 'uuidv2', 'uuidv3', 'uuidv4', 'uuidv5'] });
strSchema = strSchema.guid({ version: 'uuidv4' });
strSchema = strSchema.hex();
strSchema = strSchema.hostname();
strSchema = strSchema.isoDate();
@@ -744,50 +744,50 @@ strSchema = strSchema.uppercase();
strSchema = strSchema.trim();
namespace common {
strSchema = strSchema.allow(x);
strSchema = strSchema.allow(x, x);
strSchema = strSchema.allow([x, x, x]);
strSchema = strSchema.valid(x);
strSchema = strSchema.valid(x, x);
strSchema = strSchema.valid([x, x, x]);
strSchema = strSchema.only(x);
strSchema = strSchema.only(x, x);
strSchema = strSchema.only([x, x, x]);
strSchema = strSchema.equal(x);
strSchema = strSchema.equal(x, x);
strSchema = strSchema.equal([x, x, x]);
strSchema = strSchema.invalid(x);
strSchema = strSchema.invalid(x, x);
strSchema = strSchema.invalid([x, x, x]);
strSchema = strSchema.disallow(x);
strSchema = strSchema.disallow(x, x);
strSchema = strSchema.disallow([x, x, x]);
strSchema = strSchema.not(x);
strSchema = strSchema.not(x, x);
strSchema = strSchema.not([x, x, x]);
strSchema = strSchema.allow(x);
strSchema = strSchema.allow(x, x);
strSchema = strSchema.allow([x, x, x]);
strSchema = strSchema.valid(x);
strSchema = strSchema.valid(x, x);
strSchema = strSchema.valid([x, x, x]);
strSchema = strSchema.only(x);
strSchema = strSchema.only(x, x);
strSchema = strSchema.only([x, x, x]);
strSchema = strSchema.equal(x);
strSchema = strSchema.equal(x, x);
strSchema = strSchema.equal([x, x, x]);
strSchema = strSchema.invalid(x);
strSchema = strSchema.invalid(x, x);
strSchema = strSchema.invalid([x, x, x]);
strSchema = strSchema.disallow(x);
strSchema = strSchema.disallow(x, x);
strSchema = strSchema.disallow([x, x, x]);
strSchema = strSchema.not(x);
strSchema = strSchema.not(x, x);
strSchema = strSchema.not([x, x, x]);
strSchema = strSchema.default(x);
strSchema = strSchema.default(x);
strSchema = strSchema.required();
strSchema = strSchema.optional();
strSchema = strSchema.forbidden();
strSchema = strSchema.required();
strSchema = strSchema.optional();
strSchema = strSchema.forbidden();
strSchema = strSchema.description(str);
strSchema = strSchema.notes(str);
strSchema = strSchema.notes(strArr);
strSchema = strSchema.tags(str);
strSchema = strSchema.tags(strArr);
strSchema = strSchema.description(str);
strSchema = strSchema.notes(str);
strSchema = strSchema.notes(strArr);
strSchema = strSchema.tags(str);
strSchema = strSchema.tags(strArr);
strSchema = strSchema.meta(obj);
strSchema = strSchema.example(obj);
strSchema = strSchema.unit(str);
strSchema = strSchema.meta(obj);
strSchema = strSchema.example(obj);
strSchema = strSchema.unit(str);
strSchema = strSchema.options(validOpts);
strSchema = strSchema.strict();
strSchema = strSchema.concat(x);
strSchema = strSchema.options(validOpts);
strSchema = strSchema.strict();
strSchema = strSchema.concat(x);
altSchema = strSchema.when(str, whenOpts);
altSchema = strSchema.when(ref, whenOpts);
altSchema = strSchema.when(str, whenOpts);
altSchema = strSchema.when(ref, whenOpts);
}
// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
@@ -811,22 +811,22 @@ namespace validate_tests {
Joi.validate(value, schema);
Joi.validate(value, schema, validOpts);
Joi.validate(value, schema, validOpts, (err, value) => {
x = value;
str = err.message;
str = err.details[0].path;
str = err.details[0].message;
str = err.details[0].type;
x = value;
str = err.message;
str = err.details[0].path;
str = err.details[0].message;
str = err.details[0].type;
});
Joi.validate(value, schema, (err, value) => {
x = value;
str = err.message;
str = err.details[0].path;
str = err.details[0].message;
str = err.details[0].type;
x = value;
str = err.message;
str = err.details[0].path;
str = err.details[0].message;
str = err.details[0].type;
});
// variant
Joi.validate(num, schema, validOpts, (err, value) => {
num = value;
num = value;
});
// plain opts
@@ -853,6 +853,11 @@ namespace validate_tests {
returnValue = Joi.validate(value, obj, validOpts);
value = Joi.validate(value, obj, validOpts, (err, value) => value);
value = Joi.validate(value, schema, validOpts, (err, value) => value);
returnValue = schema.validate(value);
returnValue = schema.validate(value, validOpts);
value = schema.validate(value, (err, value) => value);
value = schema.validate(value, validOpts, (err, value) => value);
}
}
+40
View File
@@ -0,0 +1,40 @@
// Type definitions for jquery.growl 1.3
// Project: https://github.com/ksylvest/jquery-growl#readme
// Definitions by: Amir.h Yeganemehr <https://github.com/yeganemehr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference types="jquery" />
declare namespace growl {
interface Options {
// Message
message: string;
// Title
title?: string;
// URL
url?: string;
// while hovering over the alert, prevent it from being dismissed (true | false - default: true)
delayOnHover?: boolean;
// the duration (in milliseconds) for which the alert is displayed (default: 3200)
duration?: number;
// whether the alert should be fixed rather than auto- dismissed(true | false - default: false)
fixed?: boolean;
// the alert's position ('tl' | 'tr' | 'bl' | 'br' | 'tc' | 'bc' - default: 'tr')
location?: string;
// the alert's size ('small' | 'medium' | 'large' - default: 'medium')
size?: string;
// the alert's style ('default' | 'error' | 'notice' | 'warning' - default: 'default')
style?: string;
}
}
interface growl {
(options: growl.Options): void;
error(options: growl.Options): void;
notice(options: growl.Options): void;
warning(options: growl.Options): void;
}
interface JQueryStatic {
growl: growl;
}
+4
View File
@@ -0,0 +1,4 @@
$.growl({ title: "Growl", message: "The kitten is awake!" });
$.growl.error({ message: "The kitten is attacking!" });
$.growl.notice({ message: "The kitten is cute!" });
$.growl.warning({ message: "The kitten is ugly!" });
+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",
"jquery.growl-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+3 -3
View File
@@ -10,7 +10,7 @@ declare namespace JQueryValidation {
type ValidatePredicate = ((element: HTMLElement, event: JQueryEventObject) => void);
type ShouldValidatePredicate = boolean|ValidatePredicate;
type ShouldValidatePredicate = boolean | ValidatePredicate;
interface ValidationOptions {
/**
@@ -218,7 +218,7 @@ declare namespace JQueryValidation {
*
* @param template The string to format.
*/
format(template: string): ( (...args: any[]) => string);
format(template: string): ((...args: any[]) => string);
format(template: string, ...args: any[]): string;
/**
* Modify default settings for validation.
@@ -232,7 +232,7 @@ declare namespace JQueryValidation {
}
interface Validator {
element(element: string|JQuery): boolean;
element(element: string | JQuery): boolean;
checkForm(): boolean;
/**
* Validates the form, returns true if it is valid, false otherwise.
@@ -15,8 +15,8 @@ function test_validate() {
const errors = validator.numberOfInvalids();
if (errors) {
const message = errors === 1
? 'You missed 1 field. It has been highlighted'
: 'You missed ' + errors + ' fields. They have been highlighted';
? 'You missed 1 field. It has been highlighted'
: 'You missed ' + errors + ' fields. They have been highlighted';
$("div.error span").html(message);
$("div.error").show();
} else {
@@ -56,7 +56,7 @@ function test_validate() {
},
errorPlacement: (error, element) => {
if (element.attr("name") === "fname"
|| element.attr("name") === "lname")
|| element.attr("name") === "lname")
error.insertAfter("#lastname");
else
error.insertAfter(element);
@@ -84,7 +84,7 @@ function test_validate() {
onclick: (elt) => { }
});
$(".selector").validate({
onfocusout: (elt, event) => { },
onfocusout: (elt, event) => { },
onkeyup: (elt, event) => { },
onclick: (elt, event) => { }
});
@@ -155,12 +155,12 @@ function test_validate() {
highlight: (element: HTMLInputElement, errorClass, validClass) => {
$(element).addClass(errorClass).removeClass(validClass);
$((<HTMLInputElement> element).form).find("label[for=" + element.id + "]")
.addClass(errorClass);
.addClass(errorClass);
},
unhighlight: (element: HTMLInputElement, errorClass, validClass) => {
$(element).removeClass(errorClass).addClass(validClass);
$((<HTMLInputElement> element).form).find("label[for=" + element.id + "]")
.removeClass(errorClass);
.removeClass(errorClass);
}
});
$(".selector").validate({
@@ -174,8 +174,8 @@ function test_validate() {
onclick: false,
});
$('.selector').validate({
onfocusout: () => {},
onkeyup: () => {},
onfocusout: () => { },
onkeyup: () => { },
onclick: elt => 2,
});
}

Some files were not shown because too many files have changed in this diff Show More