Fix various lint errors (#15529)

This commit is contained in:
Andy 2017-03-30 15:33:16 -07:00 committed by GitHub
parent b5619e813f
commit ff0d451b56
60 changed files with 838 additions and 979 deletions

View File

@ -29,4 +29,4 @@ artyom.getVoices();
artyom.getLanguage();
// Get the artyom.js version
artyom.getVersion();
artyom.getVersion();

View File

@ -22,16 +22,16 @@ interface SpeechRecognition extends EventTarget {
start(): void;
stop(): void;
abort(): void;
onaudiostart: (ev: Event) => any;
onsoundstart: (ev: Event) => any;
onspeechstart: (ev: Event) => any;
onspeechend: (ev: Event) => any;
onsoundend: (ev: Event) => any;
onresult: (ev: SpeechRecognitionEvent) => any;
onnomatch: (ev: SpeechRecognitionEvent) => any;
onerror: (ev: SpeechRecognitionError) => any;
onstart: (ev: Event) => any;
onend: (ev: Event) => any;
onaudiostart(ev: Event): any;
onsoundstart(ev: Event): any;
onspeechstart(ev: Event): any;
onspeechend(ev: Event): any;
onsoundend(ev: Event): any;
onresult(ev: SpeechRecognitionEvent): any;
onnomatch(ev: SpeechRecognitionEvent): any;
onerror(ev: SpeechRecognitionError): any;
onstart(ev: Event): any;
onend(ev: Event): any;
}
interface SpeechRecognitionStatic {
@ -106,7 +106,7 @@ interface SpeechSynthesis extends EventTarget {
speaking: boolean;
paused: boolean;
onvoiceschanged: (ev: Event) => any;
onvoiceschanged(ev: Event): any;
speak(utterance: SpeechSynthesisUtterance): void;
cancel(): void;
pause(): void;
@ -128,13 +128,13 @@ interface SpeechSynthesisUtterance extends EventTarget {
rate: number;
pitch: number;
onstart: (ev: SpeechSynthesisEvent) => any;
onend: (ev: SpeechSynthesisEvent) => any;
onerror: (ev: SpeechSynthesisErrorEvent) => any;
onpause: (ev: SpeechSynthesisEvent) => any;
onresume: (ev: SpeechSynthesisEvent) => any;
onmark: (ev: SpeechSynthesisEvent) => any;
onboundary: (ev: SpeechSynthesisEvent) => any;
onstart(ev: SpeechSynthesisEvent): any;
onend(ev: SpeechSynthesisEvent): any;
onerror(ev: SpeechSynthesisErrorEvent): any;
onpause(ev: SpeechSynthesisEvent): any;
onresume(ev: SpeechSynthesisEvent): any;
onmark(ev: SpeechSynthesisEvent): any;
onboundary(ev: SpeechSynthesisEvent): any;
}
interface SpeechSynthesisUtteranceStatic {
@ -211,7 +211,7 @@ declare namespace Artyom {
/** Triggers of the command */
indexes: string[];
/** Logic to execute when the command is triggered */
action: (i: number, wildcard?: string, full?: string) => void;
action(i: number, wildcard?: string, full?: string): void;
/** Description of the command */
description?: string;
/** Flag to specify is a command is either normal or smart */
@ -502,7 +502,7 @@ declare namespace Artyom {
/**
* Method to bla, bla, bla...
*/
static getInstance(): ArtyomJS
static getInstance(): ArtyomJS;
}
}

View File

@ -1,9 +1,9 @@
import BigInteger = require('bigi');
var b1 = BigInteger.fromHex("188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012");
var b2 = BigInteger.fromHex("07192B95FFC8DA78631011ED6B24CDD573F977A11E794811");
const b1 = BigInteger.fromHex("188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012");
const b2 = BigInteger.fromHex("07192B95FFC8DA78631011ED6B24CDD573F977A11E794811");
var b3 = b1.multiply(b2);
const b3 = b1.multiply(b2);
console.log(b3.toHex());
// => ae499bfe762edfb416d0ce71447af67ff33d1760cbebd70874be1d7a5564b0439a59808cb1856a91974f7023f72132
// => ae499bfe762edfb416d0ce71447af67ff33d1760cbebd70874be1d7a5564b0439a59808cb1856a91974f7023f72132

View File

@ -3,9 +3,9 @@
import bigi = require('bigi');
import bitcoin = require('bitcoinjs-lib');
declare var it: any;
declare var describe: any;
declare var assert: any;
declare const it: any;
declare const describe: any;
declare const assert: any;
describe('bitcoinjs-lib (basic)', () => {
it('can generate a random bitcoin address', () => {
@ -13,18 +13,18 @@ describe('bitcoinjs-lib (basic)', () => {
function rng() { return new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'); }
// generate random keyPair
var keyPair = bitcoin.ECPair.makeRandom({ rng });
var address = keyPair.getAddress();
const keyPair = bitcoin.ECPair.makeRandom({ rng });
const address = keyPair.getAddress();
assert.strictEqual(address, '1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64');
});
it('can generate an address from a SHA256 hash', () => {
var hash = bitcoin.crypto.sha256('correct horse battery staple');
var d = bigi.fromBuffer(hash);
const hash = bitcoin.crypto.sha256('correct horse battery staple');
const d = bigi.fromBuffer(hash);
var keyPair = new bitcoin.ECPair(d);
var address = keyPair.getAddress();
const keyPair = new bitcoin.ECPair(d);
const address = keyPair.getAddress();
assert.strictEqual(address, '1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8');
});
@ -33,26 +33,26 @@ describe('bitcoinjs-lib (basic)', () => {
// for testing only
function rng() { return new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'); }
var litecoin = bitcoin.networks.litecoin;
const litecoin = bitcoin.networks.litecoin;
var keyPair = bitcoin.ECPair.makeRandom({ network: litecoin, rng });
var wif = keyPair.toWIF();
var address = keyPair.getAddress();
const keyPair = bitcoin.ECPair.makeRandom({ network: litecoin, rng });
const wif = keyPair.toWIF();
const address = keyPair.getAddress();
assert.strictEqual(address, 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn');
assert.strictEqual(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS');
});
it('can import an address via WIF', () => {
var keyPair = bitcoin.ECPair.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct');
var address = keyPair.getAddress();
const keyPair = bitcoin.ECPair.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct');
const address = keyPair.getAddress();
assert.strictEqual(address, '19AAjaTUbRjQCMuVczepkoPswiZRhjtg31');
});
it('can create a Transaction', () => {
var keyPair = bitcoin.ECPair.fromWIF('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy');
var tx = new bitcoin.TransactionBuilder();
const keyPair = bitcoin.ECPair.fromWIF('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy');
const tx = new bitcoin.TransactionBuilder();
tx.addInput('aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31', 0);
tx.addOutput('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000);

View File

@ -1,4 +1,4 @@
var someInput = { a: 1, b: 2, c: 3 };
const someInput = { a: 1, b: 2, c: 3 };
import blacklist = require('blacklist');
@ -10,4 +10,4 @@ blacklist(someInput, {
b: false, // b will be in the result
c: 1 > 2 // false, therefore c will be in the result
});
// => { b: 2, c: 3 }
// => { b: 2, c: 3 }

View File

@ -89,4 +89,4 @@ myCalendar
.setEvents([])
.addEvents([])
.removeEvents(event => event.id === 'idToRemove')
.destroy();
.destroy();

View File

@ -3,9 +3,9 @@ import * as http from 'http';
const server = http.createServer((req, res) => {
const cookies = new Cookies(req, res);
let unsigned: string,
signed: string,
tampered: string;
let unsigned: string;
let signed: string;
let tampered: string;
if (req.url === "/set") {
cookies

View File

@ -4,7 +4,6 @@ cpy(['src/*.png', '!src/goat.png'], 'dist').then(() => {
console.log('files copied');
});
cpy('foo.js', 'destination', {
rename: basename => `prefix-${basename}`
});
});

View File

@ -4,4 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = cpy;
declare function cpy(src: string | string[], dest: string, opts?: { cwd?: string, parents?: boolean, rename?: (s: string) => string }): Promise<void>;
declare function cpy(
src: string | string[],
dest: string,
opts?: { cwd?: string, parents?: boolean, rename?(s: string): string }): Promise<void>;

View File

@ -183,7 +183,7 @@ declare namespace csvtojson {
* @param {string} str the string to convert
* @return {Converter} returns this object for chaining
*/
fromString(str: string): this
fromString(str: string): this;
/**
* Reads in a CSV from a string.
@ -197,7 +197,7 @@ declare namespace csvtojson {
* @param {string} filePath the path to the CSV file
* @return {Converter} returns this object for chaining
*/
fromFile(filePath: string): this
fromFile(filePath: string): this;
/**
* Reads in a CSV from a file.
@ -211,7 +211,7 @@ declare namespace csvtojson {
* @param {Stream} stream the stream
* @return {Converter} returns this object for chaining
*/
fromStream(stream: NodeJS.ReadableStream): this
fromStream(stream: NodeJS.ReadableStream): this;
/**
* Reads in a CSV from a stream.

View File

@ -1 +1,6 @@
{ "extends": "../tslint.json" }
{
"extends": "../tslint.json",
"rules": {
"ban-types": false
}
}

View File

@ -1,6 +1,6 @@
import del = require("del");
var paths = ["build", "dist/**/*.js"];
let paths = ["build", "dist/**/*.js"];
del(["tmp/*.js", "!tmp/unicorn.js"]);
@ -26,7 +26,6 @@ del("tmp/*.js", {force: true}).then((paths: string[]) => {
console.log('Deleted files/folders:\n', paths.join('\n'));
});
var paths: string[];
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"]);
paths = del.sync(["tmp/*.js", "!tmp/unicorn.js"], {force: true});

View File

@ -55,4 +55,4 @@ docker.createContainer({ Tty: true }, (err, container) => {
container.start((err, data) => {
// NOOP
});
});
});

View File

@ -8,7 +8,6 @@
import * as stream from 'stream';
import * as events from 'events';
declare namespace Dockerode {
interface Container {
inspect(options: {}, callback: Callback<ContainerInspectInfo>): void;

View File

@ -4,8 +4,7 @@ import crypto = require('crypto');
import BigInteger = require('bigi');
import cs = require('coinstring');
var ecparams = ecurve.getCurveByName('secp256k1');
let ecparams = ecurve.getCurveByName('secp256k1');
console.log(ecparams.n.toString(16));
// => fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
console.log(ecparams.G.getEncoded().toString('hex')); // getEncoded() returns type 'Buffer' instead of 'BigInteger'
@ -13,15 +12,14 @@ console.log(ecparams.G.getEncoded().toString('hex')); // getEncoded() returns ty
console.log(ecparams.h.toString(16));
// => 1
const privateKey = new Buffer("1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd", 'hex');
var privateKey = new Buffer("1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd", 'hex');
ecparams = ecurve.getCurveByName('secp256k1');
const curvePt = ecparams.G.multiply(BigInteger.fromBuffer(privateKey));
const x = curvePt.affineX.toBuffer(32);
const y = curvePt.affineY.toBuffer(32);
var ecparams = ecurve.getCurveByName('secp256k1');
var curvePt = ecparams.G.multiply(BigInteger.fromBuffer(privateKey));
var x = curvePt.affineX.toBuffer(32);
var y = curvePt.affineY.toBuffer(32);
var publicKey = Buffer.concat([new Buffer([0x04]), x, y]);
let publicKey = Buffer.concat([new Buffer([0x04]), x, y]);
console.log(publicKey.toString('hex'));
// => 04d0988bfa799f7d7ef9ab3de97ef481cd0f75d2367ad456607647edde665d6f6fbdd594388756a7beaf73b4822bc22d36e9bda7db82df2b8b623673eefc0b7495
@ -35,8 +33,8 @@ publicKey = curvePt.getEncoded(true); // true forces compressed public key
console.log(publicKey.toString('hex'));
// => 03d0988bfa799f7d7ef9ab3de97ef481cd0f75d2367ad456607647edde665d6f6f
var sha = crypto.createHash('sha256').update(publicKey).digest();
var pubkeyHash = crypto.createHash('rmd160').update(sha).digest();
const sha = crypto.createHash('sha256').update(publicKey).digest();
const pubkeyHash = crypto.createHash('rmd160').update(sha).digest();
// pubkeyHash of compressed public key
console.log(pubkeyHash.toString('hex'));
@ -50,4 +48,4 @@ console.log(cs.encode(privateKey, 0x80)); // <--- 0x80 is for private addresses
// => 5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD
console.log(cs.encode(Buffer.concat([privateKey, new Buffer([0])]), 0x80)); // <-- compressed private address
// => KwomKti1X3tYJUUMb1TGSM2mrZk1wb1aHisUNHCQXTZq5aqzCxDY
// => KwomKti1X3tYJUUMb1TGSM2mrZk1wb1aHisUNHCQXTZq5aqzCxDY

View File

@ -1,5 +1,5 @@
import F1 = require("f1");
var ui = F1();
const ui = F1();
ui.states({
out: {
@ -23,8 +23,6 @@ ui.states({
}
});
ui.transitions( [
{ from: 'idle', to: 'rollOver', animation: { duration: 0.25 } },
{ from: 'rollOver', to: 'idle', animation: { duration: 0.1 } }

4
types/f1/index.d.ts vendored
View File

@ -6,8 +6,8 @@
/// <reference types="node" />
interface F1Options {
onState?: (...args: any[]) => void;
onUpdate?: (...args: any[]) => void;
onState?(...args: any[]): void;
onUpdate?(...args: any[]): void;
name: string;

View File

@ -39,21 +39,21 @@ export {
* Every DataSource is associated with a single JSON Graph object.
* Models execute JSON Graph operations (get, set, and call) to retrieve values from the DataSources JSON Graph object.
* DataSources may retrieve JSON Graph information from anywhere, including device memory, a remote machine, or even a lazily-run computation.
**/
*/
export abstract class DataSource {
/**
* The get method retrieves values from the DataSource's associated JSONGraph object.
**/
*/
get(pathSets: PathSet[]): Observable<JSONGraphEnvelope>;
/**
* The set method accepts values to set in the DataSource's associated JSONGraph object.
**/
*/
set(jsonGraphEnvelope: JSONGraphEnvelope): Observable<JSONGraphEnvelope>;
/**
* Invokes a function in the DataSource's JSONGraph object.
**/
*/
call(functionPath: Path, args?: any[], refSuffixes?: PathSet[], thisPaths?: PathSet[]): Observable<JSONGraphEnvelope>;
}
@ -73,30 +73,30 @@ interface ModelOptions {
/**
* This callback is invoked when the Model's cache is changed.
**/
*/
type ModelOnChange = () => void;
/**
* This function is invoked on every JSONGraph Error retrieved from the DataSource. This function allows Error objects to be transformed before being stored in the Model's cache.
**/
*/
type ModelErrorSelector = (jsonGraphError: any) => any;
/**
* This function is invoked every time a value in the Model cache is about to be replaced with a new value.
* If the function returns true, the existing value is replaced with a new value and the version flag on all of the value's ancestors in the tree are incremented.
**/
*/
type ModelComparator = (existingValue: any, newValue: any) => boolean;
/**
* A Model object is used to execute commands against a {@link JSONGraph} object
* {@link Model}s can work with a local JSONGraph cache, or it can work with a remote {@link JSONGraph} object through a {@link DataSource}.
**/
*/
export class Model {
constructor(options?: ModelOptions);
/**
* The get method retrieves several {@link Path}s or {@link PathSet}s from a {@link Model}. The get method loads each value into a JSON object and returns in a ModelResponse.
**/
*/
get(...path: Array<string | PathSet>): ModelResponse<JSONEnvelope<any>>;
get<T>(...path: Array<string | PathSet>): ModelResponse<JSONEnvelope<T>>;
@ -104,7 +104,7 @@ export class Model {
* Sets the value at one or more places in the JSONGraph model.
* The set method accepts one or more {@link PathValue}s, each of which is a combination of a location in the document and the value to place there.
* In addition to accepting {@link PathValue}s, the set method also returns the values after the set operation is complete.
**/
*/
set(...args: PathValue[]): ModelResponse<JSONEnvelope<any>>;
set<T>(...args: PathValue[]): ModelResponse<JSONEnvelope<T>>;
set(jsonGraph: JSONGraph): ModelResponse<JSONEnvelope<any>>;
@ -112,12 +112,12 @@ export class Model {
/**
* The preload method retrieves several {@link Path}s or {@link PathSet}s from a {@link Model} and loads them into the Model cache.
**/
*/
preload(...path: PathSet[]): void;
/**
* Invokes a function in the JSON Graph.
**/
*/
// NOTE: In http://netflix.github.io/falcor/doc/Model.html#call, it says that refPaths should be an PathSet[].
// However, model implementation returns an error with setting refPaths as PathSet[] and it works with refPaths as PathSet.
// So refPaths is defined as a PathSet in this .d.ts.
@ -126,7 +126,7 @@ export class Model {
/**
* The invalidate method synchronously removes several {@link Path}s or {@link PathSet}s from a {@link Model} cache.
**/
*/
invalidate(...path: PathSet[]): void;
/**
@ -136,78 +136,78 @@ export class Model {
* - Expose only a fragment of the {@link JSONGraph} to components, rather than the entire graph
* - Hide the location of a {@link JSONGraph} fragment from components
* - Optimize for executing multiple operations and path looksup at/below the same location in the {@link JSONGraph}
**/
*/
deref(responseObject: any): Model;
/**
* Get data for a single {@link Path}.
**/
*/
getValue(path: string | Path): ModelResponse<any>;
getValue<T>(path: string | Path): ModelResponse<T>;
/**
* Set value for a single {@link Path}.
**/
*/
setValue(path: string | Path, value: any): ModelResponse<any>;
setValue<T>(path: string | Path, value: any): ModelResponse<T>;
/**
* Set the local cache to a {@link JSONGraph} fragment. This method can be a useful way of mocking a remote document, or restoring the local cache from a previously stored state.
**/
*/
setCache(jsonGraph: JSONGraph): void;
/**
* Get the local {@link JSONGraph} cache. This method can be a useful to store the state of the cache.
**/
*/
getCache(...path: PathSet[]): JSONGraph;
/**
* Retrieves a number which is incremented every single time a value is changed underneath the Model or the object at an optionally-provided Path beneath the Model.
**/
*/
getVersion(path?: Path): number;
/**
* Returns a clone of the {@link Model} that enables batching. Within the configured time period, paths for get operations are collected and sent to the {@link DataSource} in a batch.
* Batching can be more efficient if the {@link DataSource} access the network, potentially reducing the number of HTTP requests to the server.
**/
*/
batch(schedulerOrDelay?: number | Scheduler): Model; // FIXME what's a valid type for scheduler?
/**
* Returns a clone of the {@link Model} that disables batching. This is the default mode. Each get operation will be executed on the {@link DataSource} separately.
**/
*/
unbatch(): Model;
/**
* Returns a clone of the {@link Model} that treats errors as values. Errors will be reported in the same callback used to report data.
* Errors will appear as objects in responses, rather than being sent to the {@link Observable~onErrorCallback} callback of the {@link ModelResponse}.
**/
*/
treatErrorsAsValues(): Model;
/**
* Adapts a Model to the {@link DataSource} interface.
**/
*/
asDataSource(): DataSource;
/**
* Returns a clone of the {@link Model} that boxes values returning the wrapper ({@link Atom}, {@link Reference}, or {@link Error}), rather than the value inside it.
* This allows any metadata attached to the wrapper to be inspected.
**/
*/
boxValues(): Model;
/**
* Returns a clone of the {@link Model} that unboxes values, returning the value inside of the wrapper ({@link Atom}, {@link Reference}, or {@link Error}), rather than the wrapper itself.
* This is the default mode.
**/
*/
unboxValues(): Model;
/**
* Returns a clone of the {@link Model} that only uses the local {@link JSONGraph} and never uses a {@link DataSource} to retrieve missing paths.
**/
*/
withoutDataSource(): Model;
/**
* Returns the {@link Path} to the object within the JSON Graph that this Model references.
**/
*/
getPath(): Path;
}
@ -237,38 +237,38 @@ export class Observable<T>{
* An Observable is like a pipe of water that is closed.
* When forEach is called, we open the valve and the values within are pushed at us.
* These values can be received using either callbacks or an {@link Observer} object.
**/
*/
forEach(onNext?: ObservableOnNextCallback<T>, onError?: ObservableOnErrorCallback , onCompleted?: ObservableOnCompletedCallback ): Subscription;
/**
* The subscribe method is a synonym for {@link Observable.prototype.forEach} and triggers the execution of the Observable, causing the values within to be pushed to a callback.
* An Observable is like a pipe of water that is closed.
* When forEach is called, we open the valve and the values within are pushed at us. These values can be received using either callbacks or an {@link Observer} object.
**/
*/
subscribe(onNext?: ObservableOnNextCallback<T>, onError?: ObservableOnErrorCallback , onCompleted?: ObservableOnCompletedCallback ): Subscription;
}
/**
* This callback accepts a value that was emitted while evaluating the operation underlying the {@link Observable} stream.
**/
*/
type ObservableOnNextCallback<T> = (value: T) => void;
/**
* This callback accepts an error that occurred while evaluating the operation underlying the {@link Observable} stream.
* When this callback is invoked, the {@link Observable} stream ends and no more values will be received by the {@link Observable~onNextCallback}.
**/
*/
type ObservableOnErrorCallback = (error: Error) => void;
/**
* This callback is invoked when the {@link Observable} stream ends.
* When this callback is invoked the {@link Observable} stream has ended, and therefore the {@link Observable~onNextCallback} will not receive any more values.
**/
*/
type ObservableOnCompletedCallback = () => void;
export class Subscription {
/**
* When this method is called on the Subscription, the Observable that created the Subscription will stop sending values to the callbacks passed when the Subscription was created.
**/
*/
dispose(): void;
}

View File

@ -30,7 +30,7 @@ interface Options extends RequestInit {
afterJSON?(body: any): void;
}
declare class Request {
export class Request {
constructor(method: TMethod, url: TUrl, options: Options)
/**
@ -66,51 +66,51 @@ declare class Request {
/**
* Set Options
*/
config(key: string, value: any): this
config(key: string, value: any): this;
config(opts: {[key: string]: any}): this
config(opts: {[key: string]: any}): this;
/**
* Set Header
*/
set(key: string, value: any): this
set(key: string, value: any): this;
set(opts: {[key: string]: any}): this
set(opts: {[key: string]: any}): this;
/**
* Set Content-Type
*/
type(type: 'json' | 'form' | 'urlencoded'): this
type(type: 'json' | 'form' | 'urlencoded'): this;
/**
* Add query string
*/
query(object: {[key: string]: any}): this
query(object: {[key: string]: any}): this;
/**
* Send data
*/
send(data: {[key: string]: any}): this
send(data: {[key: string]: any}): this;
/**
* ppend formData
*/
append(key: string, value: string): this
append(key: string, value: string): this;
/**
* Get Response directly
*/
then(resolve: (value?: Response) => void, reject?: (reason?: any) => void): Promise<any>
then(resolve: (value?: Response) => void, reject?: (reason?: any) => void): Promise<any>;
/**
* Make Response to JSON
*/
json(strict?: boolean): Promise<any>
json(strict?: boolean): Promise<any>;
/**
* Make Response to string
*/
text(): Promise<string>
text(): Promise<string>;
}
export default class Fetch extends Request {

View File

@ -21,7 +21,7 @@ interface MappingOptions extends FindOptions {
ext?: string;
extDot?: 'first' | 'last';
flatten?: boolean;
rename?: (p: string) => string;
rename?(p: string): string;
}
interface OneMapping {

View File

@ -1,3 +1,16 @@
{
"extends": "../tslint.json"
"extends": "../tslint.json",
"rules": {
"align": false,
"array-type": false,
"new-parens": false,
"no-consecutive-blank-lines": false,
"no-redundant-modifiers": false,
"interface-over-type-literal": false,
"no-relative-import-in-test": false,
"no-var": false,
"prefer-declare-function": false,
"semicolon": false,
"trim-file": false
}
}

View File

@ -12,4 +12,4 @@
/// <reference types="node" />
export var inert: any;
export const inert: any;

View File

@ -7,4 +7,4 @@ isAbsoluteUrl('//sindresorhus.com');
// => false
isAbsoluteUrl('foo/bar');
// => false
// => false

View File

@ -3,7 +3,6 @@
// Definitions by: Jørgen Elgaard Larsen <https://github.com/elhaard/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
type IGroups = any;
export class ISBNcodes {

View File

@ -1,6 +1,5 @@
import * as isbn from 'isbn-utils';
const isbn10a: isbn.ISBN|null = isbn.parse('4873113369');
let b: boolean;
let s: string;

View File

@ -9,16 +9,16 @@
// -------------------------------
/**
* Copyright 2016 Mattijs Perdeck.
*
* This project is licensed under the MIT license.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
* Copyright 2016 Mattijs Perdeck.
*
* This project is licensed under the MIT license.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Declarations of all interfaces and ambient objects, except for JL itself.
// Provides strong typing in both jsnlog.ts itself and in TypeScript programs that use
@ -31,8 +31,8 @@ declare namespace JL {
defaultAjaxUrl?: string;
clientIP?: string;
requestId?: string;
defaultBeforeSend?: (xhr: XMLHttpRequest) => void;
serialize?: (obj: any) => string;
defaultBeforeSend?(xhr: XMLHttpRequest): void;
serialize?(obj: any): string;
}
interface JSNLogFilterOptions {
@ -57,7 +57,7 @@ declare namespace JL {
interface JSNLogAjaxAppenderOptions extends JSNLogAppenderOptions {
url?: string;
beforeSend?: (xhr: XMLHttpRequest) => void;
beforeSend?(xhr: XMLHttpRequest): void;
}
interface JSNLogLogger {

View File

@ -10,17 +10,17 @@ interface JSONErrorOptions {
/**
* Perform some task before calling `options.format`. Must be a function with the original err as its only argument.
*/
preFormat?: (err: Error) => any;
preFormat?(err: Error): any;
/**
* Runs inmediatly after `options.preFormat`. It receives two arguments: the original `err` and the output of `options.preFormat`. It should `return` a newly formatted error.
*/
format?: (err: Error, obj: any) => any;
format?(err: Error, obj: any): any;
/**
* Runs inmediatly after `options.format`. It receives two arguments: the original `err` and the output of `options.format`. It should `return` a newly formatted error.
*/
postFormat?: (err: Error, obj: any) => any;
postFormat?(err: Error, obj: any): any;
}
/**

View File

@ -13,7 +13,7 @@ declare namespace jwt {
interface Options {
secret: string | Buffer;
key?: string;
getToken?: (opts: jwt.Options) => string;
getToken?(opts: jwt.Options): string;
passthrough?: boolean;
cookie?: string;
debug?: boolean;

View File

@ -4,9 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace later {
interface ScheduleData {
/**
* A list of recurrence information as a composite schedule.
*/
@ -25,7 +23,6 @@ declare namespace later {
}
interface Recurrence {
/** Time in seconds from midnight.
*/
t?: number[];
@ -142,11 +139,10 @@ declare namespace later {
* For acces to custom time periods created as extension to the later static type
* and modifiers created on the later modifier static type.
*/
[ timeperiodAndModifierName: string ]: number[] | undefined;
[timeperiodAndModifierName: string]: number[] | undefined;
}
interface ParseStatic {
/**
* Create a recurrence builder for building schedule data.
*/
@ -168,7 +164,6 @@ declare namespace later {
}
interface Timer {
/**
* Clear the timer and end execution.
*/
@ -176,58 +171,56 @@ declare namespace later {
}
interface Schedule {
/**
* Finds the next valid instance or instances of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* smaller than end date.
*
* @param {number} numberOfInst: The number of instances to return
* @param {Date} dateFrom: The earliest a valid instance can occur
* @param {Date} dateTo: The latest a valid instance can occur
*/
* Finds the next valid instance or instances of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* smaller than end date.
*
* @param {number} numberOfInst: The number of instances to return
* @param {Date} dateFrom: The earliest a valid instance can occur
* @param {Date} dateTo: The latest a valid instance can occur
*/
next(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
/**
* Finds the next valid range or ranges of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* greater than end date.
*
* @param {number} numberOfInst: The number of ranges to return
* @param {Date} dateFrom: The earliest a valid range can occur
* @param {Date} dateTo: The latest a valid range can occur
*/
* Finds the next valid range or ranges of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* greater than end date.
*
* @param {number} numberOfInst: The number of ranges to return
* @param {Date} dateFrom: The earliest a valid range can occur
* @param {Date} dateTo: The latest a valid range can occur
*/
nextRange(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
/**
* Finds the previous valid instance or instances of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* greater than end date.
*
* @param {number} numberOfInst: The number of instances to return
* @param {Date} dateFrom: The earliest a valid instance can occur
* @param {Date} dateTo: The latest a valid instance can occur
*/
* Finds the previous valid instance or instances of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* greater than end date.
*
* @param {number} numberOfInst: The number of instances to return
* @param {Date} dateFrom: The earliest a valid instance can occur
* @param {Date} dateTo: The latest a valid instance can occur
*/
prev(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
/**
* Finds the previous valid range or ranges of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* greater than end date.
*
* @param {number} numberOfInst: The number of ranges to return
* @param {Date} dateFrom: The earliest a valid range can occur
* @param {Date} dateTo: The latest a valid range can occur
*/
* Finds the previous valid range or ranges of the current schedule,
* optionally between a specified start and end date. Start date is
* Date.now() by default, end date is unspecified. Start date must be
* greater than end date.
*
* @param {number} numberOfInst: The number of ranges to return
* @param {Date} dateFrom: The earliest a valid range can occur
* @param {Date} dateTo: The latest a valid range can occur
*/
prevRange(numberOfInst: number, dateFrom?: Date, dateTo?: Date): Date[];
}
interface RecurrenceBuilder extends ScheduleData {
/** a time period
*/
second(): RecurrenceBuilder;
@ -268,7 +261,6 @@ declare namespace later {
/** a time period
*/
fullDate(): RecurrenceBuilder;
/**
* Specifies one or more specific vals of a time period information provider.
* When used to specify a time, a string indicating the 24-hour time may be used.
@ -371,7 +363,6 @@ declare namespace later {
}
interface DateProvider {
/**
* Set later to use UTC time.
*/
@ -434,7 +425,6 @@ declare namespace later {
}
interface TimePeriod {
/**
* The name of the time period information provider.
*/
@ -515,7 +505,6 @@ declare namespace later {
}
interface ModifierStatic {
/**
* After Modifier
*/
@ -528,7 +517,6 @@ declare namespace later {
}
interface Static {
/**
* Schedule
* Generates instances from schedule data.

View File

@ -1,16 +1,15 @@
import later = require("later");
namespace LaterTest_DefineSchedule {
// define a new schedule
var textSched = later.parse.text('at 10:15am every weekday');
var cronSched = later.parse.cron('0 0/5 14,18 * * ?');
var recurSched = later.parse.recur().last().dayOfMonth();
var manualSched = <later.ScheduleData> { schedules: [ <later.Recurrence> { M: [ 3 ], D: [ 21 ] } ] };
const textSched = later.parse.text('at 10:15am every weekday');
const cronSched = later.parse.cron('0 0/5 14,18 * * ?');
const recurSched = later.parse.recur().last().dayOfMonth();
const manualSched = <later.ScheduleData> { schedules: [ <later.Recurrence> { M: [ 3 ], D: [ 21 ] } ] };
// this schedule will fire on the closest weekday to the 15th
// every month at 2:00 am except in March
var complexSched = later.parse.recur()
const complexSched = later.parse.recur()
.on(15).dayOfMonth().onWeekday().on(2).hour()
.and()
.on(14).dayOfMonth().on(6).dayOfWeek().on(2).hour()
@ -21,7 +20,6 @@ namespace LaterTest_DefineSchedule {
}
namespace LaterTest_ConfigureTimezone {
// set later to use UTC (the default)
later.date.UTC();
@ -31,7 +29,7 @@ namespace LaterTest_ConfigureTimezone {
namespace LaterTest_TimePeriods {
export function second() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.second.name;
// 'second'
@ -62,7 +60,7 @@ namespace LaterTest_TimePeriods {
}
export function minute() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.minute.name;
// 'minute'
@ -93,7 +91,7 @@ namespace LaterTest_TimePeriods {
}
export function hour() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.hour.name;
// 'hour'
@ -124,7 +122,7 @@ namespace LaterTest_TimePeriods {
}
export function time() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.time.name;
// 'time'
@ -155,7 +153,7 @@ namespace LaterTest_TimePeriods {
}
export function day() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.day.name;
// 'day'
@ -186,7 +184,7 @@ namespace LaterTest_TimePeriods {
}
export function day_of_week() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.dayOfWeek.name;
// 'day of week'
@ -217,7 +215,7 @@ namespace LaterTest_TimePeriods {
}
export function day_of_week_count() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.dayOfWeekCount.name;
// 'day of week count'
@ -252,7 +250,7 @@ namespace LaterTest_TimePeriods {
}
export function day_of_year() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.dayOfYear.name;
// 'day of year'
@ -283,7 +281,7 @@ namespace LaterTest_TimePeriods {
}
export function week_of_month() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.weekOfMonth.name;
// 'week of month'
@ -314,7 +312,7 @@ namespace LaterTest_TimePeriods {
}
export function week_of_year() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.weekOfYear.name;
// 'week of year'
@ -345,7 +343,7 @@ namespace LaterTest_TimePeriods {
}
export function month() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.month.name;
// 'month'
@ -376,7 +374,7 @@ namespace LaterTest_TimePeriods {
}
export function year() {
var d = new Date('2013-03-22T10:02:05Z');
const d = new Date('2013-03-22T10:02:05Z');
later.year.name;
// 'year'
@ -411,11 +409,9 @@ namespace LaterTest_TimePeriods {
}
export function custom() {
var customLater = <PartOfDayLater> later;
const customLater = <PartOfDayLater> later;
customLater.partOfDay = {
name: 'part of day',
range: later.hour.range * 6,
@ -437,7 +433,7 @@ namespace LaterTest_TimePeriods {
},
start(date: Date) {
var hour = customLater.partOfDay.val(date) === 0
const hour = customLater.partOfDay.val(date) === 0
? 0
: customLater.partOfDay.val(date) === 1
? 12
@ -452,7 +448,7 @@ namespace LaterTest_TimePeriods {
},
end(date: Date) {
var hour = customLater.partOfDay.val(date) === 0
const hour = customLater.partOfDay.val(date) === 0
? 11
: customLater.partOfDay.val(date) === 1
? 5
@ -467,7 +463,7 @@ namespace LaterTest_TimePeriods {
},
next(date: Date, val: any) {
var hour = val === 0
const hour = val === 0
? 0
: val === 1
? 12
@ -483,7 +479,7 @@ namespace LaterTest_TimePeriods {
},
prev(date: Date, val: any) {
var hour = val === 0
const hour = val === 0
? 11
: val === 1
? 5
@ -502,7 +498,6 @@ namespace LaterTest_TimePeriods {
}
namespace LaterTest_GenerateRecurences {
export function on_method() {
// fires on the 2nd minute every hour
later.parse.recur().on(2).minute();
@ -575,7 +570,7 @@ namespace LaterTest_GenerateRecurences {
export function and_method() {
// fires every 2 hours on the first day of every month
// and 8:00am and 8:00pm on the last day of every month
var sched = later.parse.recur()
const sched = later.parse.recur()
.every(2).hour().first().dayOfMonth()
.and()
.on(8, 20).hour().last().dayOfMonth();
@ -583,42 +578,39 @@ namespace LaterTest_GenerateRecurences {
export function except_method() {
// fires every minute of every hour except on multiples of 2 and 3
var sched = later.parse.recur()
const sched = later.parse.recur()
.every().minute()
.except()
.every(2).minute().between(2, 59)
.and()
.every(3).minute().between(3, 59);
}
}
namespace LaterTest_CalculateOccurences {
// Initialise next variable.
var next: Date[] = [];
let next: Date[] = [];
// calculate the next 10 occurrences of a recur schedule
var recurSched = later.parse.recur().last().dayOfMonth();
const recurSched = later.parse.recur().last().dayOfMonth();
next = later.schedule(recurSched).next(10);
// calculate the previous occurrence starting from March 21, 2013
var cronSched = later.parse.cron('0 0/5 14,18 * * ?');
const cronSched = later.parse.cron('0 0/5 14,18 * * ?');
next = later.schedule(cronSched).prev(1, new Date(2013, 2, 21));
}
namespace LaterTest_ExecuteCodeUsingSchedule {
// will fire every 5 minutes
var textSched = later.parse.text('every 5 min');
const textSched = later.parse.text('every 5 min');
// execute logTime one time on the next occurrence of the text schedule
var timer = later.setTimeout(logTime, textSched);
const timer = later.setTimeout(logTime, textSched);
// execute logTime for each successive occurrence of the text schedule
var timer2 = later.setInterval(logTime, textSched);
const timer2 = later.setInterval(logTime, textSched);
// function to execute
function logTime() {

View File

@ -6,32 +6,32 @@ namespace main {
if (expected !== undefined && typeof expected !== 'string') {
throw new Error();
}
};
}
function isArray(expected?: any[]): void {
if (expected !== undefined && !Array.isArray(expected)) {
throw new Error();
}
};
}
function isNumber(expected?: number): void {
if (expected !== undefined && typeof expected !== 'number') {
throw new Error();
}
};
}
function isBoolean(expected?: boolean): void {
if (expected !== undefined && typeof expected !== 'boolean') {
throw new Error();
}
};
}
function isFunction(expected?: (...args: any[]) => void): void {
if (expected !== undefined && typeof expected !== 'function') {
throw new Error();
}
};
}
function isVoid(expected?: undefined): void {
if (expected !== undefined) {
throw new Error();
}
};
}
namespace test_global_options {
Memcached.config.maxKeySize = 250;
@ -116,11 +116,11 @@ namespace main {
isNumber(expected.totalReconnectsFailed);
isNumber(expected.totalDownTime);
}
memcached.on('issue', err => isIssue(err));
memcached.on('failure', err => isIssue(err));
memcached.on('reconnecting', err => isIssue(err));
memcached.on('reconnect', err => isIssue(err));
memcached.on('remove', err => isIssue(err));
memcached.on('issue', isIssue);
memcached.on('failure', isIssue);
memcached.on('reconnecting', isIssue);
memcached.on('reconnect', isIssue);
memcached.on('remove', isIssue);
}
function isCommandData(expected: Memcached.CommandData) {
@ -372,7 +372,7 @@ namespace main {
isString(stat.server);
}
});
};
}
namespace test_settings {
memcached.settings((err: any, data: Memcached.StatusData[]) => {
isArray(data);
@ -380,7 +380,7 @@ namespace main {
isString(setting.server);
}
});
};
}
namespace test_slabs {
memcached.slabs((err: any, data: Memcached.StatusData[]) => {
isArray(data);
@ -388,7 +388,7 @@ namespace main {
isString(setting.server);
}
});
};
}
let promise: Promise<any>;
namespace test_items {
promise = new Promise(resolve => {
@ -400,7 +400,7 @@ namespace main {
resolve(data);
});
});
};
}
namespace test_cachedump {
promise.then(data => {
for (const node of data) {
@ -418,12 +418,12 @@ namespace main {
});
}
});
};
}
namespace test_flush {
memcached.flush(function(err, results) {
isVoid(this);
isArray(results);
});
};
}
}

View File

@ -4,9 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace MockRaf {
interface Options {
/** The time that should pass during each requestAnimationFrame step in milliseconds. Default is roughly equivalent to default browser behavior. */
time?: number;
@ -16,7 +14,6 @@ declare namespace MockRaf {
/** Creates a mockRaf instance, exposing the functions you'll use to interact with the mock. */
interface Creator {
/**
* Returns the current now value of the mock. Starts at 0 and increases with each step() taken.
* Useful for stubbing out performance.now() or a polyfill when using requestAnimationFrame with timers.
@ -32,9 +29,8 @@ declare namespace MockRaf {
/** Takes requestAnimationFrame steps. Fires currently queued callbacks for each step and increments now time for each step. The primary way to interact with a mockRaf instance for testing. */
step(options?: Options): void;
}
}
declare function MockRaf(): MockRaf.Creator;
export = MockRaf;
export = MockRaf;

View File

@ -6,4 +6,4 @@ const id = mockRaf.raf(() => {
});
mockRaf.step({ count: 10 });
mockRaf.cancel(id);
console.log(mockRaf.now());
console.log(mockRaf.now());

View File

@ -181,11 +181,11 @@ declare namespace Nedb {
nodeWebkitAppName?: boolean; // Optional, specify the name of your NW app if you want options.filename to be relative to the directory where
autoload?: boolean; // Optional, defaults to false
// Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown
onload?: (error: Error) => any;
onload?(error: Error): any;
// (optional): hook you can use to transform data after it was serialized and before it is written to disk.
// Can be used for example to encrypt data before writing database to disk.
// This function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, which must absolutely not contain a \n character (or data will be lost)
afterSerialization?: (line: string) => string;
afterSerialization?(line: string): string;
// (optional): reverse of afterSerialization.
// Make sure to include both and not just one or you risk data loss.
// For the same reason, make sure both functions are inverses of one another.
@ -193,7 +193,7 @@ declare namespace Nedb {
// NeDB checks that never one is declared without the other, and checks that they are reverse of one another by testing on random strings of various lengths.
// In addition, if too much data is detected as corrupt,
// NeDB will refuse to start as it could mean you're not using the deserialization hook corresponding to the serialization hook used before (see below)
beforeDeserialization?: (line: string) => string;
beforeDeserialization?(line: string): string;
// (optional): between 0 and 1, defaults to 10%. NeDB will refuse to start if more than this percentage of the datafile is corrupt.
// 0 means you don't tolerate any corruption, 1 means you don't care
corruptAlertThreshold?: number;

View File

@ -21,7 +21,7 @@ export interface Options {
*
* You shouldn't need to set this unless you are debugging.
*/
normalizeQuery?: (graphQLResolveInfo: any) => string;
normalizeQuery?(graphQLResolveInfo: any): string;
/**
* Where to send the reports. Defaults to the production Optics endpoint, or the OPTICS_ENDPOINT_URL environment variable if it is set.

View File

@ -75,7 +75,7 @@ declare namespace Parsimmon {
interface Parser<T> {
/**
* parse the string
*/
*/
parse(input: string): Result<T>;
/**
* Like parser.parse(input) but either returns the parsed value or throws
@ -91,7 +91,7 @@ declare namespace Parsimmon {
* returns a new parser which tries parser, and on success calls the given function
* with the result of the parse, which is expected to return another parser, which
* will be tried next
*/
*/
chain<U>(next: (result: T) => Parser<U>): Parser<U>;
/**
* returns a new parser which tries parser, and on success calls the given function
@ -254,8 +254,8 @@ declare namespace Parsimmon {
type SuccessFunctionType<U> = (index: number, result: U) => Result<U>;
type FailureFunctionType<U> = (index: number, msg: string) => Result<U>;
type ParseFunctionType<U> = (stream: StreamType, index: number) => Result<U>;
/**
* allows to add custom primitive parsers.
/**
* allows to add custom primitive parsers.
*/
function custom<U>(parsingFunction: (success: SuccessFunctionType<U>, failure: FailureFunctionType<U>) => ParseFunctionType<U>): Parser<U>;

View File

@ -1,8 +1,8 @@
import { Progressbar, create } from 'progressbar';
let str: string = '',
progressbar: Progressbar,
num: number = 1;
let str: string = '';
let progressbar: Progressbar;
let num: number = 1;
const fn: () => void = () => {};
progressbar = create();

View File

@ -11,8 +11,8 @@ declare function pump(streams: pump.Stream[], callback?: pump.Callback): pump.St
declare function pump(...streams: Array<pump.Stream | pump.Callback>): pump.Stream[];
declare namespace pump {
export type Callback = (err: Error) => any;
export type Stream = NodeJS.ReadableStream | NodeJS.WritableStream;
type Callback = (err: Error) => any;
type Stream = NodeJS.ReadableStream | NodeJS.WritableStream;
}
export = pump;

View File

@ -8,26 +8,25 @@
import { IncomingMessage, ServerResponse } from 'http';
import { EventEmitter } from 'events';
export const version: string;
export function config(dsn: string | false, options?: ConstructorOptions): Client;
export function wrap(func: () => void, onErr?: () => void): () => void;
export function wrap(options: any, func: () => void, onErr?: () => void): () => void;
export function interceptErr(ctx: any): Client;
export function setContext(ctx: any): Client;
export function captureException(e: Error, cb?: CaptureCallback): Client;
export function captureException(e: Error, options?: CaptureOptions, cb?: CaptureCallback): Client;
export function mergeContext(ctx: any): Client;
export function getContext(): any;
export function errorHandler(): (e: Error, req: IncomingMessage, res: ServerResponse, next: () => void) => void;
export function context(ctx: any, func: () => void, onErr?: () => void): Client;
export function context(func: () => void, onErr?: () => void): Client;
export function captureBreadcrumb(breadcrumb: any): void;
export function disableConsoleAlerts(): void;
export function consoleAlert(msg: string): void;
export function parseDSN(dsn: string | false): parsedDSN;
declare const version: string;
declare function config(dsn: string | false, options?: ConstructorOptions): Client;
declare function wrap(func: () => void, onErr?: () => void): () => void;
declare function wrap(options: any, func: () => void, onErr?: () => void): () => void;
declare function interceptErr(ctx: any): Client;
declare function setContext(ctx: any): Client;
declare function captureException(e: Error, cb?: CaptureCallback): Client;
declare function captureException(e: Error, options?: CaptureOptions, cb?: CaptureCallback): Client;
declare function mergeContext(ctx: any): Client;
declare function getContext(): any;
declare function errorHandler(): (e: Error, req: IncomingMessage, res: ServerResponse, next: () => void) => void;
declare function context(ctx: any, func: () => void, onErr?: () => void): Client;
declare function context(func: () => void, onErr?: () => void): Client;
declare function captureBreadcrumb(breadcrumb: any): void;
declare function disableConsoleAlerts(): void;
declare function consoleAlert(msg: string): void;
declare function parseDSN(dsn: string | false): parsedDSN;
declare class Client extends EventEmitter {
export class Client extends EventEmitter {
constructor(options: ConstructorOptions);
constructor(dsn: string, options?: ConstructorOptions);
config(dsn: string, options?: ConstructorOptions): Client;
@ -48,7 +47,7 @@ declare class Client extends EventEmitter {
process(eventId: string, kwargs: any, cb?: () => void): void;
}
declare interface ConstructorOptions {
export interface ConstructorOptions {
name?: string;
logger?: string;
release?: string;
@ -56,17 +55,17 @@ declare interface ConstructorOptions {
tags?: { string: string };
extra?: { string: any };
dataCallback?: DataCallback;
transport?: () => void;
transport?(): void;
captureUnhandledRejections?: boolean;
autoBreadcrumbs?: boolean | any;
}
declare interface UserData {
export interface UserData {
id: string;
handle?: string;
}
declare interface parsedDSN {
export interface parsedDSN {
protocol: string;
public_key: string;
private_key: string;
@ -76,19 +75,13 @@ declare interface parsedDSN {
port: number;
}
declare interface CaptureCallback {
(err: { string: any }, eventId: any): void;
}
export type CaptureCallback = (err: { string: any }, eventId: any) => void;
declare interface DataCallback {
(data: { string: any }): void;
}
export type DataCallback = (data: { string: any }) => void;
declare interface TransportCallback {
(options: { string: any }): void;
}
export type TransportCallback = (options: { string: any }) => void;
declare interface CaptureOptions {
export interface CaptureOptions {
tags?: { string: string };
extra?: { string: any };
fingerprint?: string;

View File

@ -16,7 +16,7 @@ new Raven.Client(dsn);
try {
throw new Error();
} catch (e) {
var eventId = Raven.captureException(e, (sendErr, eventId) => { });
const eventId = Raven.captureException(e, (sendErr, eventId) => { });
}
Raven.setContext({});
@ -24,6 +24,5 @@ Raven.mergeContext({});
Raven.context(() => {
Raven.captureBreadcrumb({});
});
var doIt = () => { }
setTimeout(Raven.wrap(doIt), 1000)
Raven.parseDSN('https://8769c40cf49c4cc58b51fa45d8e2d166:296768aa91084e17b5ac02d3ad5bc7e7@app.getsentry.com/269')
setTimeout(Raven.wrap(() => {}), 1000);
Raven.parseDSN('https://8769c40cf49c4cc58b51fa45d8e2d166:296768aa91084e17b5ac02d3ad5bc7e7@app.getsentry.com/269');

View File

@ -20,13 +20,13 @@ export interface PublicState {
}
export interface Events {
onClick?: () => any;
onChange?: (publicState: PublicState) => any;
onKeyPress?: () => any;
onSliderDragEnd?: () => any;
onSliderDragMove?: () => any;
onSliderDragStart?: () => any;
onValuesUpdated?: (publicState: PublicState) => any;
onClick?(): any;
onChange?(publicState: PublicState): any;
onKeyPress?(): any;
onSliderDragEnd?(): any;
onSliderDragMove?(): any;
onSliderDragStart?(): any;
onValuesUpdated?(publicState: PublicState): any;
}
export interface Props extends Events {
@ -46,4 +46,3 @@ export interface Props extends Events {
}
export default class Rheostat extends React.Component<Props, never> {}

View File

@ -1,29 +1,6 @@
import fs = require("fs");
import sha1 = require("sha1");
/**
* API
* sha1(message)
* message -- String or Buffer
* returns String
*
* Usage
****************************************************
* var sha1 = require('sha1'); *
* console.log(sha1('message')); *
****************************************************
* This will print the following
* 6f9b9af3cd6e8b8a73c2cdced37fe9f59226e27d
*
* It supports buffers, too
****************************************************
* var fs = require('fs'); *
* var sha1 = require('sha1'); *
* *
* fs.readFile('example.txt', function(err, buf) { *
* console.log(sha1(buf)); *
* }); *
* **************************************************
*/
console.log(sha1('message')); // should print 6f9b9af3cd6e8b8a73c2cdced37fe9f59226e27d
const testTwo = sha1('message', {asString: true});

View File

@ -47,7 +47,7 @@ sharp('input.jpg')
// containing a scaled and cropped version of input.jpg
});
var transformer = sharp()
let transformer = sharp()
.resize(300)
.on('info', (info: sharp.OutputInfo) => {
console.log('Image height is ' + info.height);

View File

@ -3,7 +3,6 @@
// Definitions by: Alex Wall <https://github.com/alexwall>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var phantom: Phantom;
declare var slimer: Slimer;
@ -19,7 +18,6 @@ interface Slimer {
}
interface Phantom {
// Properties
args: string[]; // DEPRECATED
cookies: Cookie[];
@ -40,7 +38,7 @@ interface Phantom {
injectJs(filename: string): boolean;
// Callbacks
onError: (msg: string, trace: string[]) => any;
onError(msg: string, trace: string[]): any;
}
interface Std {
@ -69,11 +67,10 @@ interface SystemModule {
interface HttpConf {
operation: string;
data: any;
headers: any
headers: any;
}
interface WebPage {
// Properties
canGoBack: boolean;
canGoForward: boolean;
@ -106,7 +103,7 @@ interface WebPage {
viewportSize: Size;
windowName: string;
zoomFactor: number;
captureContent: Array<RegExp>; // slimerjs only
captureContent: RegExp[]; // slimerjs only
// Functions
addCookie(cookie: Cookie): boolean;
@ -142,9 +139,9 @@ interface WebPage {
release(): void; // DEPRECATED
reload(): void;
// render(filename: string): Promise<void>;
render(filename: string): void;
render(filename: string, options?: { format?: string; quality?: string; ratio?: number; onlyViewport?: boolean }): Promise<void>;
renderBase64(type: string): Promise<string>;
render(filename: string): void;
renderBase64(format: string): string;
sendEvent(mouseEventType: string, mouseX?: number, mouseY?: number, button?: string): Promise<void>;
sendEvent(keyboardEventType: string, key: string, null1?: null, null2?: null, modifier?: number): Promise<void>;
@ -163,23 +160,23 @@ interface WebPage {
uploadFile(selector: string, filename: string): void;
// Callbacks
onAlert: (msg: string) => any;
onCallback: () => void; // EXPERIMENTAL
onClosing: (closingPage: WebPage) => any;
onConfirm: (msg: string) => boolean;
onConsoleMessage: (msg: string, lineNum?: number, sourceId?: string) => any;
onError: (msg: string, trace: string[]) => any;
onFilePicker: (oldFile: string) => string;
onInitialized: () => any;
onLoadFinished: (status: string) => any;
onLoadStarted: () => any;
onNavigationRequested: (url: string, type: string, willNavigate: boolean, main: boolean) => any;
onPageCreated: (newPage: WebPage) => any;
onPrompt: (msg: string, defaultVal: string) => string;
onResourceError: (resourceError: ResourceError) => any;
onResourceReceived: (response: ResourceResponse) => any;
onResourceRequested: (requestData: ResourceRequest, networkRequest: NetworkRequest) => any;
onUrlChanged: (targetUrl: string) => any;
onAlert(msg: string): any;
onCallback(): void; // EXPERIMENTAL
onClosing(closingPage: WebPage): any;
onConfirm(msg: string): boolean;
onConsoleMessage(msg: string, lineNum?: number, sourceId?: string): any;
onError(msg: string, trace: string[]): any;
onFilePicker(oldFile: string): string;
onInitialized(): any;
onLoadFinished(status: string): any;
onLoadStarted(): any;
onNavigationRequested(url: string, type: string, willNavigate: boolean, main: boolean): any;
onPageCreated(newPage: WebPage): any;
onPrompt(msg: string, defaultVal: string): string;
onResourceError(resourceError: ResourceError): any;
onResourceReceived(response: ResourceResponse): any;
onResourceRequested(requestData: ResourceRequest, networkRequest: NetworkRequest): any;
onUrlChanged(targetUrl: string): any;
// Callback triggers
closing(closingPage: WebPage): void;
@ -203,8 +200,8 @@ interface ResourceError {
}
interface HttpVersion {
major: number,
minor: number
major: number;
minor: number;
}
interface ResourceResponse {
@ -261,7 +258,6 @@ interface WebPageSettings {
}
interface FileSystem {
// Properties
separator: string;
workingDirectory: string;
@ -316,12 +312,11 @@ interface Stream {
interface WebServerModule {
registerDirectory(urlpath: string, directoryPath: string): void;
registerFile(urlpath: string, filePath: string): void;
registerPathHandler(urlpath: string, handlerCallback: (request: WebServerRequest, response: WebServerResponse) => void): void
registerPathHandler(urlpath: string, handlerCallback: (request: WebServerRequest, response: WebServerResponse) => void): void;
port: number;
listen(port: number | string, cb?: (request: WebServerRequest, response: WebServerResponse) => void): boolean;
// listen(ipAddressPort: string, cb?: (request: IWebServerRequest, response: IWebServerResponse) => void): boolean;
close(): void;
}
interface WebServerRequest {
@ -359,14 +354,14 @@ interface ClipRect extends TopLeft, Size {
}
interface Cookie {
name: string,
value: string,
domain?: string,
path: string,
httponly?: boolean,
secure?: boolean,
expires?: string,
expiry: number
name: string;
value: string;
domain?: string;
path: string;
httponly?: boolean;
secure?: boolean;
expires?: string;
expiry: number;
}
interface WebPageModule {

View File

@ -1,21 +1,17 @@
var webpageMod = require('webpage');
var webserverMod = require('webserver')
const webpageMod = require('webpage'); // tslint:disable-line no-var-requires
const webserverMod = require('webserver'); // tslint:disable-line no-var-requires
let page = webpageMod.create();
let vUrl = 'https://www.w3c.org';
function testWebserver () {
webserverMod.close()
function testWebserver() {
webserverMod.close();
webserverMod.listen(1234);
webserverMod.registerFile("urlPath", "filePath");
webserverMod.registerDirectory("urlPath", "dirPath");
}
let vUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8'
let vUserAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8';
page.settings.userAgent = vUserAgent;
page.onConsoleMessage = (vMsg) => {
@ -27,7 +23,7 @@ page.onAlert = (vMsg) => {
page.onLoadStarted = () => {
};
page.captureContent = [ /json/ ]
page.captureContent = [/json/];
page.onResourceReceived = (oResponse) => {
oResponse.id;
@ -45,7 +41,6 @@ page.onResourceRequested = (oRequestData, oNetworkRequest) => {
oRequestData.url;
};
page.onLoadFinished = (vStatus) => {
phantom.exit();
};
@ -54,18 +49,16 @@ page.onInitialized = () => {
};
page.onPageCreated = (oPage) => {
let oCookie: Cookie
let oCookie: Cookie;
oPage.addCookie(oCookie);
};
page.open(vUrl) // loads a page
.then(() => { // executed after loading
page.viewportSize = { width: 414, height: 736 };
let vFilename = `../data/page01.png`;
page.render(vFilename, {onlyViewport: true})
page.render(vFilename, {onlyViewport: true});
// then open a second page
return page.open('http://');
@ -73,5 +66,5 @@ page.open(vUrl) // loads a page
.then(() => {
// click somewhere on the second page
page.sendEvent("click", 5, 5, 'left', 0);
slimer.exit()
slimer.exit();
});

128
types/sshpk/index.d.ts vendored
View File

@ -5,19 +5,16 @@
/// <reference types="node" />
declare class SshPK {
}
declare class SshPK {}
declare namespace SshPK {
export class Algo {
class Algo {
parts: string[];
sizePart?: string;
normalize?: boolean;
}
export class algInfo {
class algInfo {
dsa: Algo;
rsa: Algo;
ecdsa: Algo;
@ -25,7 +22,7 @@ declare namespace SshPK {
curve25519: Algo;
}
export class algPrivInfo {
class algPrivInfo {
dsa: Algo;
rsa: Algo;
ecdsa: Algo;
@ -33,7 +30,7 @@ declare namespace SshPK {
curve25519: Algo;
}
export class hashAlgs {
class hashAlgs {
md5: boolean;
sha1: boolean;
sha256: boolean;
@ -41,7 +38,7 @@ declare namespace SshPK {
sha512: boolean;
}
export class Curve {
class Curve {
size: number;
pkcs8oid: string;
p: Buffer;
@ -52,21 +49,20 @@ declare namespace SshPK {
G: Buffer;
}
export class curves {
class curves {
nistp256: Curve;
nistp384: Curve;
nistp512: Curve;
}
export class algs {
class algs {
info: algInfo;
privInfo: algPrivInfo;
hashAlgs: hashAlgs;
curves: curves;
}
export class Certificate {
class Certificate {
subjects: Identity[];
issuer: string;
subjectKey: string;
@ -101,12 +97,9 @@ declare namespace SshPK {
static parse(data: string|Buffer, format: string, options: any): Certificate;
static isCertificate(data: string|Buffer, ver: string): boolean;
}
export class DiffieHellman {
class DiffieHellman {
constructor(key: Key);
getPublicKey(): Key;
@ -121,24 +114,23 @@ declare namespace SshPK {
generateKeys(): PrivateKey;
}
export class X9ECParameters {
class X9ECParameters {
G: any;
g: any;
n: any;
h: any;
}
export class ECPublic {
class ECPublic {
constructor(params: X9ECParameters, buffer: Buffer);
}
export class ECPrivate {
class ECPrivate {
constructor(params: X9ECParameters, buffer: Buffer);
deriveSharedSecret(pk: Key): Buffer;
}
export class Verifier {
class Verifier {
constructor(key: Key, hashAlgo: string);
update(chunk: string|Buffer): void;
@ -146,53 +138,50 @@ declare namespace SshPK {
verify(signature: string): boolean;
}
export class Signer {
class Signer {
constructor(key: Key, hashAlgo: string);
update(chunk: string|Buffer): void;
sign(): Signature;
}
export class FingerprintFormatError implements Error {
class FingerprintFormatError implements Error {
name: string;
message: string;
constructor(fp: Fingerprint, format: string);
}
export class InvalidAlgorithmError implements Error {
class InvalidAlgorithmError implements Error {
name: string;
message: string;
constructor(algo: string);
}
export class KeyParseError implements Error {
class KeyParseError implements Error {
name: string;
message: string;
constructor(name: string, format: string, innerErr: any);
}
export class SignatureParseError implements Error {
class SignatureParseError implements Error {
name: string;
message: string;
constructor(type: string, format: string, innerErr: any);
}
export class CertificateParseError implements Error {
class CertificateParseError implements Error {
name: string;
message: string;
constructor(name: string, format: string, innerErr: any);
}
export class KeyEncryptedError implements Error {
class KeyEncryptedError implements Error {
name: string;
message: string;
constructor(name: string, format: string);
}
export class Fingerprint {
class Fingerprint {
algorithm: string;
hash: string;
type: string;
@ -206,10 +195,9 @@ declare namespace SshPK {
isFingerprint(obj: string|Buffer, ver: string): boolean;
static parse(fp: string, options: any): Fingerprint;
}
export class Identity {
class Identity {
cn: string;
components: string[];
componentLookup: any;
@ -233,13 +221,12 @@ declare namespace SshPK {
static isIdentity(dn: Buffer|string, ver: string): boolean;
}
export class Format {
class Format {
read: (buf: Buffer, options?: any) => Buffer;
write: (key: Key, options?: any) => Buffer;
}
export class Formats {
class Formats {
auto: Format;
pem: Format;
pkcs1: Format;
@ -250,11 +237,11 @@ declare namespace SshPK {
openssh: Format;
}
export class Verify {
class Verify {
verify(data: string, fmt: string): boolean;
}
export class Key {
class Key {
type: string;
parts: string;
part: string;
@ -278,10 +265,9 @@ declare namespace SshPK {
static parse(data: string|Buffer, format: string, options: any): Key;
static isKey(obj: string|Buffer, ver: string): boolean;
}
export class PrivateKey {
class PrivateKey {
constructor(opts: any);
static formats: Formats;
toBuffer(format: string, options: any): Buffer;
@ -293,11 +279,9 @@ declare namespace SshPK {
static parse(data: string|Buffer, format: string, options: any): PrivateKey;
static isPrivateKey(data: string|Buffer, ver: string): boolean;
}
export class Signature {
class Signature {
constructor(opts: any);
toBuffer(format: string): Buffer;
toString(format: string): string;
@ -305,14 +289,13 @@ declare namespace SshPK {
static parse(data: string|Buffer, type: string, format: string): Signature;
static isSignature(obj: string|Buffer, ver: string): boolean;
}
export class SSHPart {
class SSHPart {
data: Buffer;
}
export class SSHBuffer {
class SSHBuffer {
constructor(opts: any);
toBuffer(): Buffer;
atEnd(): boolean;
@ -333,47 +316,44 @@ declare namespace SshPK {
writeChar(buf: string): void;
writePart(buf: SSHPart): void;
write(buf: Buffer): void;
}
export function bufferSplit(buf: Buffer, chr: string): Buffer[];
export function addRSAMissing(key: PrivateKey): void;
export function calculateDSAPublic(g: Buffer, p: Buffer, x: Buffer): Buffer;
export function mpNormalize(buf: Buffer): Buffer;
export function ecNormalize(buf: Buffer, addZero: boolean): Buffer;
export function countZeros(buf: Buffer): number;
export function assertCompatible(obj: any, klass: any, needVer: string, name: string): void;
export function isCompatible(obj: any, klass: any, needVer: string): boolean;
export class OpenSllKeyDeriv {
function bufferSplit(buf: Buffer, chr: string): Buffer[];
function addRSAMissing(key: PrivateKey): void;
function calculateDSAPublic(g: Buffer, p: Buffer, x: Buffer): Buffer;
function mpNormalize(buf: Buffer): Buffer;
function ecNormalize(buf: Buffer, addZero: boolean): Buffer;
function countZeros(buf: Buffer): number;
function assertCompatible(obj: any, klass: any, needVer: string, name: string): void;
function isCompatible(obj: any, klass: any, needVer: string): boolean;
class OpenSllKeyDeriv {
key: Buffer;
iv: Buffer;
}
export function opensslKeyDeriv(cipher: string, salt: string, passphrase: string, count: number): OpenSllKeyDeriv;
function opensslKeyDeriv(cipher: string, salt: string, passphrase: string, count: number): OpenSllKeyDeriv;
export class OpensshCipherInfo {
class OpensshCipherInfo {
keySize: number;
blockSize: number;
opensslName: string;
}
export function opensshCipherInfo(cipber: string): OpensshCipherInfo;
function opensshCipherInfo(cipber: string): OpensshCipherInfo;
export function parseKey(data: string|Buffer, format: string, options?: any): Key;
export function parseFingerprint(fp: string, options?: any): Fingerprint;
export function parseSignature(data: string|Buffer, type: string, format: string): Signature;
export function parsePrivateKey(data: string|Buffer, format: string, options?: any): PrivateKey;
function parseKey(data: string|Buffer, format: string, options?: any): Key;
function parseFingerprint(fp: string, options?: any): Fingerprint;
function parseSignature(data: string|Buffer, type: string, format: string): Signature;
function parsePrivateKey(data: string|Buffer, format: string, options?: any): PrivateKey;
export function parseCertificate(data: string|Buffer, format: string, options?: any): Certificate;
export function createSelfSignedCertificate(subjectOrSubjects: string, key: Key, options?: any): Certificate;
export function createCertificate(
function parseCertificate(data: string|Buffer, format: string, options?: any): Certificate;
function createSelfSignedCertificate(subjectOrSubjects: string, key: Key, options?: any): Certificate;
function createCertificate(
subjectOrSubjects: string, key: Key, issuer: string,
issuerKey: PrivateKey, options?: any): Certificate;
export function identityFromDN(dn: string): Identity;
export function identityForHost(hostname: string): Identity;
export function identityForUser(uid: string): Identity;
export function identityForEmail(email: string): Identity;
function identityFromDN(dn: string): Identity;
function identityForHost(hostname: string): Identity;
function identityForUser(uid: string): Identity;
function identityForEmail(email: string): Identity;
}
export = SshPK;

View File

@ -1,4 +1,3 @@
import * as sshpk from 'sshpk';
const cert = sshpk.parseCertificate("", "pem");

View File

@ -1,4 +1,4 @@
import stripBom = require('strip-bom');
stripBom('\uFEFFunicorn');
// => 'unicorn'
// => 'unicorn'

View File

@ -97,10 +97,10 @@ interface SwiperOptions {
paginationHide?: boolean;
paginationClickable?: boolean;
paginationElement?: string;
paginationBulletRender?: (swiper: Swiper, index: number, className: string) => void;
paginationFractionRender?: (swiper: Swiper, currentClassName: string, totalClassName: string) => void;
paginationProgressRender?: (swiper: Swiper, progressbarClass: string) => void;
paginationCustomRender?: (swiper: Swiper, current: number, total: number) => void;
paginationBulletRender?(swiper: Swiper, index: number, className: string): void;
paginationFractionRender?(swiper: Swiper, currentClassName: string, totalClassName: string): void;
paginationProgressRender?(swiper: Swiper, progressbarClass: string): void;
paginationCustomRender?(swiper: Swiper, current: number, total: number): void;
// Navigation Buttons
nextButton?: string | Element;
@ -112,7 +112,6 @@ interface SwiperOptions {
scrollbarDraggable?: boolean;
scrollbarSnapOnRelease?: boolean;
// Accessibility
a11y?: boolean;
prevSlideMessage?: string;
@ -121,7 +120,6 @@ interface SwiperOptions {
lastSlideMessage?: string;
paginationBulletMessage?: string;
// Keyboard / Mousewheel
keyboardControl?: boolean;
mousewheelControl?: boolean;
@ -135,7 +133,6 @@ interface SwiperOptions {
hashnavWatchState?: boolean;
history?: string;
// Images
preloadImages?: boolean;
updateOnImagesReady?: boolean;
@ -165,36 +162,36 @@ interface SwiperOptions {
// Callbacks
runCallbacksOnInit?: boolean;
onInit?: (swiper: Swiper) => void;
onSlideChangeStart?: (swiper: Swiper) => void;
onSlideChangeEnd?: (swiper: Swiper) => void;
onSlideNextStart?: (swiper: Swiper) => void;
onSlideNextEnd?: (swiper: Swiper) => void;
onSlidePrevStart?: (swiper: Swiper) => void;
onSlidePrevEnd?: (swiper: Swiper) => void;
onTransitionStart?: (swiper: Swiper) => void;
onTransitionEnd?: (swiper: Swiper) => void;
onTouchStart?: (swiper: Swiper, event: Event) => void;
onTouchMove?: (swiper: Swiper, event: Event) => void;
onTouchMoveOpposite?: (swiper: Swiper, event: Event) => void;
onSliderMove?: (swiper: Swiper, event: Event) => void;
onTouchEnd?: (swiper: Swiper, event: Event) => void;
onClick?: (swiper: Swiper, event: Event) => void;
onTap?: (swiper: Swiper, event: Event) => void;
onDoubleTap?: (swiper: Swiper, event: Event) => void;
onImagesReady?: (swiper: Swiper) => void;
onProgress?: (swiper: Swiper, progress: number) => void;
onReachBeginning?: (swiper: Swiper) => void;
onReachEnd?: (swiper: Swiper) => void;
onDestroy?: (swiper: Swiper) => void;
onSetTranslate?: (swiper: Swiper, translate: any) => void;
onSetTransition?: (swiper: Swiper, transition: any) => void;
onAutoplay?: (swiper: Swiper) => void;
onAutoplayStart?: (swiper: Swiper) => void;
onAutoplayStop?: (swiper: Swiper) => void;
onLazyImageLoad?: (swiper: Swiper, slide: any, image: any) => void;
onLazyImageReady?: (swiper: Swiper, slide: any, image: any) => void;
onPaginationRendered?: (swiper: Swiper, paginationContainer: any) => void;
onInit?(swiper: Swiper): void;
onSlideChangeStart?(swiper: Swiper): void;
onSlideChangeEnd?(swiper: Swiper): void;
onSlideNextStart?(swiper: Swiper): void;
onSlideNextEnd?(swiper: Swiper): void;
onSlidePrevStart?(swiper: Swiper): void;
onSlidePrevEnd?(swiper: Swiper): void;
onTransitionStart?(swiper: Swiper): void;
onTransitionEnd?(swiper: Swiper): void;
onTouchStart?(swiper: Swiper, event: Event): void;
onTouchMove?(swiper: Swiper, event: Event): void;
onTouchMoveOpposite?(swiper: Swiper, event: Event): void;
onSliderMove?(swiper: Swiper, event: Event): void;
onTouchEnd?(swiper: Swiper, event: Event): void;
onClick?(swiper: Swiper, event: Event): void;
onTap?(swiper: Swiper, event: Event): void;
onDoubleTap?(swiper: Swiper, event: Event): void;
onImagesReady?(swiper: Swiper): void;
onProgress?(swiper: Swiper, progress: number): void;
onReachBeginning?(swiper: Swiper): void;
onReachEnd?(swiper: Swiper): void;
onDestroy?(swiper: Swiper): void;
onSetTranslate?(swiper: Swiper, translate: any): void;
onSetTransition?(swiper: Swiper, transition: any): void;
onAutoplay?(swiper: Swiper): void;
onAutoplayStart?(swiper: Swiper): void;
onAutoplayStop?(swiper: Swiper): void;
onLazyImageLoad?(swiper: Swiper, slide: any, image: any): void;
onLazyImageReady?(swiper: Swiper, slide: any, image: any): void;
onPaginationRendered?(swiper: Swiper, paginationContainer: any): void;
// Namespace
slideClass?: string;
@ -321,7 +318,7 @@ declare class Swiper {
setGrabCursor(): void;
plugins?: {
debugger?: (swiper: any, params: any) => void;
debugger?(swiper: any, params: any): void;
};
}

View File

@ -1,4 +1,3 @@
/// <reference types="jquery" />
//
@ -7,18 +6,18 @@
// 01-default.html
function defaultDemo() {
var swiper = new Swiper('.swiper-container');
const swiper = new Swiper('.swiper-container');
}
// 02-responsive.html
function responsive() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true
});
}
// 03-vertical.html
function vertical() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
direction: 'vertical'
@ -26,7 +25,7 @@ function vertical() {
}
// 04-space-between.html
function spaceBetween() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
spaceBetween: 30,
@ -34,7 +33,7 @@ function spaceBetween() {
}
// 05-slides-per-view.html
function slidesPerView() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 3,
paginationClickable: true,
@ -43,7 +42,7 @@ function slidesPerView() {
}
// 06-slides-per-view-auto.html
function slidesPerViewAuto() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 'auto',
paginationClickable: true,
@ -52,7 +51,7 @@ function slidesPerViewAuto() {
}
// 07-centered.html
function centered() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 4,
centeredSlides: true,
@ -62,7 +61,7 @@ function centered() {
}
// 08-centered-auto.html
function centeredAuto() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 'auto',
centeredSlides: true,
@ -72,7 +71,7 @@ function centeredAuto() {
}
// 09-freemode.html
function freemode() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 3,
paginationClickable: true,
@ -82,7 +81,7 @@ function freemode() {
}
// 10-slides-per-column.html
function slidesPerColumn() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 3,
slidesPerColumn: 2,
@ -92,12 +91,12 @@ function slidesPerColumn() {
}
// 11-nested.html
function nested() {
var swiperH = new Swiper('.swiper-container-h', {
const swiperH = new Swiper('.swiper-container-h', {
pagination: '.swiper-pagination-h',
paginationClickable: true,
spaceBetween: 50
});
var swiperV = new Swiper('.swiper-container-v', {
const swiperV = new Swiper('.swiper-container-v', {
pagination: '.swiper-pagination-v',
paginationClickable: true,
direction: 'vertical',
@ -106,7 +105,7 @@ function nested() {
}
// 12-grab-cursor.html
function grabCursor() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 4,
centeredSlides: true,
@ -117,7 +116,7 @@ function grabCursor() {
}
// 13-scrollbar.html
function scrollbar() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
scrollbar: '.swiper-scrollbar',
scrollbarHide: true,
slidesPerView: 'auto',
@ -128,7 +127,7 @@ function scrollbar() {
}
// 14-nav-arrows.html
function navArrows() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
@ -138,7 +137,7 @@ function navArrows() {
}
// 15-infinite-loop.html
function infiniteLoop() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
@ -150,7 +149,7 @@ function infiniteLoop() {
}
// 16-effect-fade.html
function effectFade() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
@ -161,7 +160,7 @@ function effectFade() {
}
// 17-effect-cube.html
function effectCube() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
effect: 'cube',
grabCursor: true,
@ -175,7 +174,7 @@ function effectCube() {
}
// 18-effect-coverflow.html
function effectCoverflow() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
effect: 'coverflow',
grabCursor: true,
@ -192,7 +191,7 @@ function effectCoverflow() {
}
// 19-keyboard-control.html
function keyboardControl() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 1,
paginationClickable: true,
@ -204,7 +203,7 @@ function keyboardControl() {
}
// 20-mousewheel-control.html
function mousewheelControl() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
direction: 'vertical',
slidesPerView: 1,
@ -215,7 +214,7 @@ function mousewheelControl() {
}
// 21-autoplay.html
function autoplay() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
@ -228,9 +227,9 @@ function autoplay() {
}
// 22-dynamic-slides.html
function dynamicSlides() {
var appendNumber = 4;
var prependNumber = 1;
var swiper = new Swiper('.swiper-container', {
let appendNumber = 4;
let prependNumber = 1;
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
@ -264,14 +263,14 @@ function dynamicSlides() {
}
// 23-thumbs-gallery-loop.html
function thumbsGalleryLoop() {
var galleryTop = new Swiper('.gallery-top', {
const galleryTop = new Swiper('.gallery-top', {
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
spaceBetween: 10,
loop: true,
loopedSlides: 5, // looped slides should be the same
});
var galleryThumbs = new Swiper('.gallery-thumbs', {
const galleryThumbs = new Swiper('.gallery-thumbs', {
spaceBetween: 10,
slidesPerView: 4,
touchRatio: 0.2,
@ -281,16 +280,15 @@ function thumbsGalleryLoop() {
});
galleryTop.params.control = galleryThumbs;
galleryThumbs.params.control = galleryTop;
}
// 23-thumbs-gallery.html
function thumbsGallery() {
var galleryTop = new Swiper('.gallery-top', {
const galleryTop = new Swiper('.gallery-top', {
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
spaceBetween: 10,
});
var galleryThumbs = new Swiper('.gallery-thumbs', {
const galleryThumbs = new Swiper('.gallery-thumbs', {
spaceBetween: 10,
centeredSlides: true,
slidesPerView: 'auto',
@ -299,21 +297,20 @@ function thumbsGallery() {
});
galleryTop.params.control = galleryThumbs;
galleryThumbs.params.control = galleryTop;
}
// 24-multiple-swipers.html
function multipleSwipers() {
var swiper1 = new Swiper('.swiper1', {
const swiper1 = new Swiper('.swiper1', {
pagination: '.swiper-pagination1',
paginationClickable: true,
spaceBetween: 30,
});
var swiper2 = new Swiper('.swiper2', {
const swiper2 = new Swiper('.swiper2', {
pagination: '.swiper-pagination2',
paginationClickable: true,
spaceBetween: 30,
});
var swiper3 = new Swiper('.swiper3', {
const swiper3 = new Swiper('.swiper3', {
pagination: '.swiper-pagination3',
paginationClickable: true,
spaceBetween: 30,
@ -321,7 +318,7 @@ function multipleSwipers() {
}
// 25-hash-navigation.html
function hashNavigation() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
@ -333,7 +330,7 @@ function hashNavigation() {
}
// 26-rtl.html
function rtl() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
@ -342,7 +339,7 @@ function rtl() {
}
// 27-jquery.html
function jquery() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
@ -351,7 +348,7 @@ function jquery() {
}
// 28-parallax.html
function parallax() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
@ -362,7 +359,7 @@ function parallax() {
}
// 29-custom-pagination.html
function customPagination() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
paginationBulletRender(swiper, index, className) {
@ -372,7 +369,7 @@ function customPagination() {
}
// 30-lazy-load-images.html
function lazyLoadImages() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
pagination: '.swiper-pagination',
@ -430,7 +427,7 @@ function customPlugin() {
}
// 32-scroll-container.html
function scrollContainer() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
scrollbar: '.swiper-scrollbar',
direction: 'vertical',
slidesPerView: 'auto',
@ -440,34 +437,34 @@ function scrollContainer() {
}
// 32-slideable-menu.html
function slideableMenu() {
var toggleMenu = () => {
const toggleMenu = () => {
if (swiper.previousIndex === 0)
swiper.slidePrev();
}
, menuButton = document.getElementsByClassName('menu-button')[0]
, swiper = new Swiper('.swiper-container', {
slidesPerView: 'auto'
, initialSlide: 1
, resistanceRatio: .00000000000001
, onSlideChangeStart: (slider) => {
if (slider.activeIndex === 0) {
menuButton.classList.add('cross');
menuButton.removeEventListener('click', toggleMenu, false);
} else
menuButton.classList.remove('cross');
}
, onSlideChangeEnd: (slider) => {
if (slider.activeIndex === 0)
menuButton.removeEventListener('click', toggleMenu, false);
else
menuButton.addEventListener('click', toggleMenu, false);
}
, slideToClickedSlide: true
});
};
const menuButton = document.getElementsByClassName('menu-button')[0];
const swiper = new Swiper('.swiper-container', {
slidesPerView: 'auto',
initialSlide: 1,
resistanceRatio: .00000000000001,
onSlideChangeStart: (slider) => {
if (slider.activeIndex === 0) {
menuButton.classList.add('cross');
menuButton.removeEventListener('click', toggleMenu, false);
} else
menuButton.classList.remove('cross');
},
onSlideChangeEnd: (slider) => {
if (slider.activeIndex === 0)
menuButton.removeEventListener('click', toggleMenu, false);
else
menuButton.addEventListener('click', toggleMenu, false);
},
slideToClickedSlide: true
});
}
// 33-responsive-breakpoints.html
function responsiveBreakpoints() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
slidesPerView: 5,
@ -494,7 +491,7 @@ function responsiveBreakpoints() {
}
// 34-autoheight.html
function autoheight() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
paginationClickable: true,
nextButton: '.swiper-button-next',
@ -504,7 +501,7 @@ function autoheight() {
}
// 35-effect-flip.html
function effectFlip() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
effect: 'flip',
grabCursor: true,
@ -514,7 +511,7 @@ function effectFlip() {
}
// 36-pagination-fraction.html
function paginationFraction() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
pagination: '.swiper-pagination',
@ -523,7 +520,7 @@ function paginationFraction() {
}
// 37-pagination-progress.html
function paginationProgress() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
nextButton: '.swiper-button-next',
prevButton: '.swiper-button-prev',
pagination: '.swiper-pagination',
@ -532,7 +529,7 @@ function paginationProgress() {
}
// 38-history.html
function historyDemo() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
spaceBetween: 50,
slidesPerView: 2,
centeredSlides: true,
@ -547,7 +544,7 @@ function historyDemo() {
}
// 38-jquery-ie9-loop.html
function jqueryIe9Loop() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
loop: true,
pagination: '.swiper-pagination',
paginationClickable: true,
@ -557,7 +554,7 @@ function jqueryIe9Loop() {
}
// 39-zoom.html
function zoom() {
var swiper = new Swiper('.swiper-container', {
const swiper = new Swiper('.swiper-container', {
zoom: true,
pagination: '.swiper-pagination',
nextButton: '.swiper-button-next',

View File

@ -3,7 +3,6 @@
// Definitions by: Sebastián Galiano <https://github.com/sgaliano/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface SwiperOptions {
speed?: number;
autoplay?: number;
@ -77,18 +76,18 @@ interface SwiperOptions {
// Callbacks
queueStartCallbacks?: boolean;
queueEndCallbacks?: boolean;
onTouchStart?: (swiper: Swiper) => void;
onTouchMove?: (swiper: Swiper) => void;
onTouchEnd?: (swiper: Swiper) => void;
onSlideReset?: (swiper: Swiper) => void;
onSlideChangeStart?: (swiper: Swiper) => void;
onSlideChangeEnd?: (swiper: Swiper) => void;
onSlideClick?: (swiper: Swiper) => void;
onSlideTouch?: (swiper: Swiper) => void;
onImagesReady?: (swiper: Swiper) => void;
onMomentumBounce?: (swiper: Swiper) => void;
onResistanceBefore?: (swiper: Swiper, distance: any) => void;
onResistanceAfter?: (swiper: Swiper, distance: any) => void;
onTouchStart?(swiper: Swiper): void;
onTouchMove?(swiper: Swiper): void;
onTouchEnd?(swiper: Swiper): void;
onSlideReset?(swiper: Swiper): void;
onSlideChangeStart?(swiper: Swiper): void;
onSlideChangeEnd?(swiper: Swiper): void;
onSlideClick?(swiper: Swiper): void;
onSlideTouch?(swiper: Swiper): void;
onImagesReady?(swiper: Swiper): void;
onMomentumBounce?(swiper: Swiper): void;
onResistanceBefore?(swiper: Swiper, distance: any): void;
onResistanceAfter?(swiper: Swiper, distance: any): void;
// Slides Loader
loader?: {

View File

@ -1,4 +1,3 @@
/// <reference types="jquery" />
//
@ -7,7 +6,7 @@
// 01-default.html
function defaultDemo() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
loop: true,
grabCursor: true,
@ -27,7 +26,7 @@ function defaultDemo() {
// 02-vertical-mode.html
function verticalMode() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
mode: 'vertical'
@ -36,17 +35,17 @@ function verticalMode() {
// 03-dynamic-slides.html
function dynamicSlides() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true
});
function randomColor() {
var colors = ('blue red green orange pink').split(' ');
const colors = ('blue red green orange pink').split(' ');
return colors[Math.floor(Math.random() * colors.length)];
}
var count = 4;
let count = 4;
$('.sdl-append').click(e => {
e.preventDefault();
@ -90,7 +89,7 @@ function dynamicSlides() {
// 04-scroll-container.html
function scrollContainer() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
scrollContainer: true,
scrollbar: {
container: '.swiper-scrollbar'
@ -100,7 +99,7 @@ function scrollContainer() {
// 05-free-mode.html
function freeMode() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
freeMode: true,
@ -110,7 +109,7 @@ function freeMode() {
// 06-carousel-mode.html
function carouselMode() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
slidesPerView: 3
@ -119,7 +118,7 @@ function carouselMode() {
// 07-carousel-loop.html
function carouselLoop() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
slidesPerView: 3,
@ -129,20 +128,20 @@ function carouselLoop() {
// 08-nested.html
function nested() {
var swiperParent = new Swiper('.swiper-parent', {
const swiperParent = new Swiper('.swiper-parent', {
pagination: '.pagination-parent',
paginationClickable: true,
slidesPerView: 3
});
var swiperNested1 = new Swiper('.swiper-nested-1', {
const swiperNested1 = new Swiper('.swiper-nested-1', {
mode: 'vertical',
pagination: '.pagination-nested-1',
paginationClickable: true,
slidesPerView: 2
});
var swiperNested2 = new Swiper('.swiper-nested-2', {
const swiperNested2 = new Swiper('.swiper-nested-2', {
mode: 'vertical',
pagination: '.pagination-nested-2',
paginationClickable: true,
@ -152,14 +151,14 @@ function nested() {
// 09-nested-loop.html
function nestedLoop() {
var swiperParent = new Swiper('.swiper-parent', {
const swiperParent = new Swiper('.swiper-parent', {
pagination: '.pagination-parent',
paginationClickable: true,
loop: true,
slidesPerView: 3
});
var swiperNested1 = new Swiper('.swiper-nested', {
const swiperNested1 = new Swiper('.swiper-nested', {
mode: 'vertical',
pagination: '.pagination-nested',
paginationClickable: true,
@ -169,7 +168,7 @@ function nestedLoop() {
// 10-tabs.html
function tabs() {
var tabsSwiper = new Swiper('.swiper-container', {
const tabsSwiper = new Swiper('.swiper-container', {
onlyExternal: true,
speed: 500
});
@ -188,7 +187,7 @@ function tabs() {
// 11-tabs-feedback.html
function tabsFeedback() {
var tabsSwiper = new Swiper('.swiper-container', {
const tabsSwiper = new Swiper('.swiper-container', {
speed: 500,
onSlideChangeStart: () => {
$(".tabs .active").removeClass('active');
@ -210,7 +209,7 @@ function tabsFeedback() {
// 12-partial-display.html
function partialDisplay() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
slidesPerView: 'auto'
@ -219,7 +218,7 @@ function partialDisplay() {
// 13-threshold.html
function threshold() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
moveStartThreshold: 100
@ -228,7 +227,7 @@ function threshold() {
// 14-different-widths.html
function differentWidths() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
slidesPerView: 'auto'
@ -237,7 +236,7 @@ function differentWidths() {
// 15-centered-slides.html
function centeredSlides() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
centeredSlides: true,
@ -247,7 +246,7 @@ function centeredSlides() {
// 16-visibility-api.html
function visibilityApi() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true,
centeredSlides: true,
@ -258,20 +257,19 @@ function visibilityApi() {
// 17 - responsive.html
function responsive() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
pagination: '.pagination',
paginationClickable: true
});
}
//
// Scrollbar
//
// demo-1.html
function demo1() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
scrollbar: {
container: '.swiper-scrollbar',
hide: false,
@ -282,7 +280,7 @@ function demo1() {
// demo-2.html
function demo2() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
scrollbar: {
container: '.swiper-scrollbar',
hide: false,
@ -293,7 +291,7 @@ function demo2() {
// demo-3.html
function demo3() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
scrollbar: {
container: '.swiper-scrollbar',
hide: true,
@ -304,7 +302,7 @@ function demo3() {
// demo-4.html
function demo4() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
slidesPerView: 3,
scrollbar: {
container: '.swiper-scrollbar',
@ -317,7 +315,7 @@ function demo4() {
// demo-5.html
function demo5() {
var mySwiper = new Swiper('.swiper-container', {
const mySwiper = new Swiper('.swiper-container', {
scrollContainer: true,
mousewheelControl: true,
mode: 'vertical',
@ -327,4 +325,4 @@ function demo5() {
draggable: false
}
});
}
}

View File

@ -861,7 +861,7 @@ describe('struct', () => {
});
it('should support prototypal inheritance', () => {
interface Rectangle { w: number; h: number; area(): number; };
interface Rectangle { w: number; h: number; area(): number; }
const Rectangle = struct({
w: Num,
h: Num

105
types/uikit/index.d.ts vendored
View File

@ -153,7 +153,7 @@ declare namespace UIkit {
* <th>Parameter</th>
* <th>Description</th>
* </tr>
*
* <tr>
* <td><code>show.uk.modal</code></td>
* <td>event</td>
@ -168,15 +168,14 @@ declare namespace UIkit {
* @example
* <pre><code>
* $('.modalSelector').on({
*
* 'show.uk.modal': function(){
* console.log("Modal is visible.");
* },
*
* 'hide.uk.modal': function(){
* console.log("Element is not visible.");
* }
* });
* 'show.uk.modal': function(){
* console.log("Modal is visible.");
* },
*
* 'hide.uk.modal': function(){
* console.log("Element is not visible.");
* }
* });
* </code></pre>
*/
interface Modal {
@ -227,10 +226,10 @@ declare namespace UIkit {
* var modal = UIkit.modal(".modalSelector");
*
* if ( modal.isActive() ) {
* modal.hide();
* } else {
* modal.show();
* }
* modal.hide();
* } else {
* modal.show();
* }
* </code></pre>
*/
(selector: string|JQuery, options?: ModalOptions): ModalElement;
@ -326,7 +325,6 @@ declare namespace UIkit {
* Init element manually
*/
(element: string|JQuery, options?: LightBoxOptions): LightBoxElement;
}
type CallbackAutoComplete = () => string;
interface AutoCompleteOptions {
@ -420,7 +418,6 @@ declare namespace UIkit {
* @default 'auto'
*/
pos?: string;
}
/**
* Create a toggleable dropdown with an datepicker
@ -711,7 +708,6 @@ declare namespace UIkit {
*/
type SlideShow = (element: string|JQuery, options: SlideShowOptions) => any;
interface ParallaxOptions {
/**
* Animation velocity during scrolling
* @default 0.5
@ -736,7 +732,6 @@ declare namespace UIkit {
* integer / string
*/
media?: number|string;
}
/**
* Animate CSS properties depending on the scroll position of the document.
@ -899,7 +894,6 @@ declare namespace UIkit {
* integer
*/
delay?: number;
}
/**
* Easily create a nicely looking search.
@ -1020,7 +1014,6 @@ declare namespace UIkit {
* string
*/
emptyClass?: string;
}
/**
* Create nestable lists that can be sorted by drag and drop.
@ -1091,7 +1084,6 @@ declare namespace UIkit {
* string
*/
dragCustomClass?: string;
}
/**
* Create sortable grids and lists to rearrange the order of its elements.
@ -1197,7 +1189,6 @@ declare namespace UIkit {
* mixed
*/
boundary?: boolean|string;
}
/**
* Make elements remain at the top of the viewport, like a sticky navbar.
@ -1244,7 +1235,6 @@ declare namespace UIkit {
* Integer between 0 and 24
*/
end?: number;
}
/**
* Create a timepicker which can easily be used by selecting a time value from a pre filled dropdown.
@ -1294,7 +1284,6 @@ declare namespace UIkit {
* string
*/
activeClass?: string;
}
/**
* Easily create a nicely looking tooltip.
@ -1351,19 +1340,19 @@ declare namespace UIkit {
* (text|json)
*/
"type"?: string;
before?: (settings: UploadOptions, files: string|string[]) => any;
beforeAll?: (files: string|string[]) => any;
beforeSend?: (xhr: XMLHttpRequest) => any;
progress?: (percent: number) => any;
complete?: (response: any, xhr: XMLHttpRequest) => any;
allcomplete?: (response: any, xhr: XMLHttpRequest) => any;
notallowed?: (file: string|string[], settings: UploadOptions) => any;
loadstart?: (event: any) => any;
load?: (event: any) => any;
loadend?: (event: any) => any;
error?: (event: any) => any;
abort?: (event: any) => any;
readystatechange?: (event: any) => any;
before?(settings: UploadOptions, files: string|string[]): any;
beforeAll?(files: string|string[]): any;
beforeSend?(xhr: XMLHttpRequest): any;
progress?(percent: number): any;
complete?(response: any, xhr: XMLHttpRequest): any;
allcomplete?(response: any, xhr: XMLHttpRequest): any;
notallowed?(file: string|string[], settings: UploadOptions): any;
loadstart?(event: any): any;
load?(event: any): any;
loadend?(event: any): any;
error?(event: any): any;
abort?(event: any): any;
readystatechange?(event: any): any;
}
/**
@ -1430,25 +1419,25 @@ declare namespace UIkit {
* </table>
*/
type Upload = (element: string|JQuery, options: UploadOptions) => any;
var dropdown: Dropdown;
var modal: Modal;
var lightbox: LightBox;
var offcanvas: OffCanvas;
var autocomplete: AutoComplete;
var datepicker: DatePicker;
var htmleditor: HtmlEditor;
var slider: Slider;
var slideset: SlideSet;
var slideshow: SlideShow;
var parallax: Parallax;
var accordion: Accordion;
var notify: Notify;
var search: Search;
var nestable: Nestable;
var sortable: Sortable;
var sticky: Sticky;
var timepicker: Timepicker;
var tooltip: Tooltip;
var uploadSelect: Upload;
var uploadDrop: Upload;
const dropdown: Dropdown;
const modal: Modal;
const lightbox: LightBox;
const offcanvas: OffCanvas;
const autocomplete: AutoComplete;
const datepicker: DatePicker;
const htmleditor: HtmlEditor;
const slider: Slider;
const slideset: SlideSet;
const slideshow: SlideShow;
const parallax: Parallax;
const accordion: Accordion;
const notify: Notify;
const search: Search;
const nestable: Nestable;
const sortable: Sortable;
const sticky: Sticky;
const timepicker: Timepicker;
const tooltip: Tooltip;
const uploadSelect: Upload;
const uploadDrop: Upload;
}

View File

@ -13,7 +13,7 @@ function testDropdown() {
hoverDelayIdle: 200,
preventflip: 'x'
};
var dropdown = UIkit.dropdown("$parent", options);
const dropdown = UIkit.dropdown("$parent", options);
dropdown.show();
dropdown.hide();
@ -40,10 +40,10 @@ function testModal() {
UIkit.modal.prompt("Name:", 'value', (newvalue: string) => {
// will be executed on submit.
});
var modal = UIkit.modal.blockUI("Any content...");
let modal = UIkit.modal.blockUI("Any content...");
modal.hide();
modal.show();
var modal = UIkit.modal(".modalSelector");
modal = UIkit.modal(".modalSelector");
if (modal.isActive()) {
modal.hide();
@ -59,14 +59,14 @@ function testOffCanvas() {
}
function testLightBox() {
var element = "#group";
var lightbox = UIkit.lightbox(element, {/* options */});
var lightbox2 = UIkit.lightbox.create([
const element = "#group";
const lightbox = UIkit.lightbox(element, {/* options */});
const lightbox2 = UIkit.lightbox.create([
{source: 'http://url/to/video.mp4', type: 'video'},
{source: 'http://url/to/image.jpg', type: 'image'}
]);
lightbox2.show();
var lightbox3 = UIkit.lightbox(element);
const lightbox3 = UIkit.lightbox(element);
}
function testAutoComplete() {
@ -75,31 +75,30 @@ function testAutoComplete() {
}
function testDatepicker() {
var datepicker = UIkit.datepicker("#element", {});
const datepicker = UIkit.datepicker("#element", {});
}
function testHtmlEditor() {
var htmleditor = UIkit.htmleditor("textarea", {/* options */});
const htmleditor = UIkit.htmleditor("textarea", {/* options */});
}
function testSlider() {
var slider = UIkit.slider("element", {});
const slider = UIkit.slider("element", {});
}
function testSlideSet() {
var slideset = UIkit.slideset("element", {});
const slideset = UIkit.slideset("element", {});
}
function testSlideShow() {
var slideshow = UIkit.slideshow("element", {});
const slideshow = UIkit.slideshow("element", {});
}
function testParallax() {
var parallax = UIkit.parallax("element", {});
const parallax = UIkit.parallax("element", {});
}
function testAccordion() {
var accordion = UIkit.accordion("element", {});
const accordion = UIkit.accordion("element", {});
}
function testNotify() {
UIkit.notify({
message: 'Bazinga!',
@ -108,8 +107,7 @@ function testNotify() {
pos: 'top-center'
});
// Shortcuts
// Shortcuts
UIkit.notify('My message');
UIkit.notify('My message', status);
UIkit.notify('My message', {/* options */});
@ -119,100 +117,70 @@ function testNotify() {
UIkit.notify("...", {status: 'info'});
}
function testSearch() {
var search = UIkit.search("element", {});
const search = UIkit.search("element", {});
}
function testNestable() {
var nestable = UIkit.nestable('element', {});
const nestable = UIkit.nestable('element', {});
}
function testSortable() {
var sortable = UIkit.sortable('element', {});
const sortable = UIkit.sortable('element', {});
}
function testStick() {
var sticky = UIkit.sticky('element', {});
const sticky = UIkit.sticky('element', {});
}
function testTimePicker() {
var timepicker = UIkit.timepicker('element', {});
const timepicker = UIkit.timepicker('element', {});
}
function testTooltip() {
var tooltip = UIkit.tooltip('element', {});
const tooltip = UIkit.tooltip('element', {});
}
function testUpload() {
$(() => {
const progressbar = $("#progressbar");
const bar = progressbar.find('.uk-progress-bar');
const settings = {
action: '/', // upload url
allow : '*.(jpg|jpeg|gif|png)', // allow only images
loadstart() {
bar.css("width", "0%").text("0%");
progressbar.removeClass("uk-hidden");
},
progress(percent: number) {
percent = Math.ceil(percent);
bar.css("width", percent + "%").text(percent + "%");
},
allcomplete(response: any) {
bar.css("width", "100%").text("100%");
var progressbar = $("#progressbar"),
bar = progressbar.find('.uk-progress-bar'),
settings = {
setTimeout(() => {
progressbar.addClass("uk-hidden");
}, 250);
action: '/', // upload url
alert("Upload Completed");
}
};
allow : '*.(jpg|jpeg|gif|png)', // allow only images
loadstart() {
bar.css("width", "0%").text("0%");
progressbar.removeClass("uk-hidden");
},
progress(percent: number) {
percent = Math.ceil(percent);
bar.css("width", percent + "%").text(percent + "%");
},
allcomplete(response: any) {
bar.css("width", "100%").text("100%");
setTimeout(() => {
progressbar.addClass("uk-hidden");
}, 250);
alert("Upload Completed");
}
};
var select = UIkit.uploadSelect($("#upload-select"), settings),
drop = UIkit.uploadDrop($("#upload-drop"), settings);
const select = UIkit.uploadSelect($("#upload-select"), settings);
const drop = UIkit.uploadDrop($("#upload-drop"), settings);
});
// Test with object literal
var select2 = UIkit.uploadSelect($("#upload-select"), {
const select2 = UIkit.uploadSelect($("#upload-select"), {
action: '/', // upload url
allow: '*.(jpg|jpeg|gif|png)', // allow only images
loadstart: () => {
},
progress: (percent: number) => {
},
allcomplete: (response: any) => {
}
loadstart: () => {},
progress: (percent: number) => {},
allcomplete: (response: any) => {}
});
var drop2 = UIkit.uploadDrop($("#upload-drop"), {
const drop2 = UIkit.uploadDrop($("#upload-drop"), {
action: '/', // upload url
allow: '*.(jpg|jpeg|gif|png)', // allow only images
loadstart: () => {
},
progress: (percent: number) => {
},
allcomplete: (response: any) => {
}
loadstart: () => {},
progress: (percent: number) => {},
allcomplete: (response: any) => {}
});
}

View File

@ -1,28 +1,24 @@
import UUID = require('uuid-js');
// Generate a V4 UUID
var uuid4 = UUID.create();
const uuid4 = UUID.create();
console.log(uuid4.toString());
// Prints: 896b677f-fb14-11e0-b14d-d11ca798dbac
// Generate a V1 TimeUUID
var uuid1 = UUID.create(1);
const uuid1 = UUID.create(1);
console.log(uuid1.toString());
// First and last possible v1 TimeUUID for a given timestamp:
var date = new Date().getTime();
var uuidFirst = UUID.fromTime(date, false);
var uuidLast = UUID.fromTime(date, true);
const date = new Date().getTime();
const uuidFirst = UUID.fromTime(date, false);
const uuidLast = UUID.fromTime(date, true);
console.log(uuidFirst.toString(), uuidLast.toString());
// Prints: aa0f9af0-0e1f-11e1-0000-000000000000 aa0f9af0-0e1f-11e1-c0ff-ffffffffffff
// Use these TimeUUID's to perform range queries in cassandra:
var today = new Date().getTime();
var last30days = (new Date().setDate(today - 30));
const today = new Date().getTime();
const last30days = (new Date().setDate(today - 30));
var rangeStart = UUID.firstFromTime(last30days);
var rangeEnd = UUID.lastFromTime(today);
const rangeStart = UUID.firstFromTime(last30days);
const rangeEnd = UUID.lastFromTime(today);

64
types/vis/index.d.ts vendored
View File

@ -71,7 +71,6 @@ interface PointItem extends DataItem {
y: number;
}
interface DataGroup {
className?: string;
content: string;
@ -154,14 +153,14 @@ interface TimelineOptions {
groupEditable?: TimelineOptionsGroupEditableType;
groupOrder?: TimelineOptionsGroupOrderType;
groupOrderSwap?: TimelineOptionsGroupOrderSwapFunction;
groupTemplate?: () => void; // TODO
groupTemplate?(): void; // TODO
height?: HeightWidthType;
hiddenDates?: any; // TODO
horizontalScroll?: boolean;
itemsAlwaysDraggable?: boolean;
locale?: string;
locales?: any; // TODO
moment?: () => void; // TODO
moment?(): void; // TODO
margin?: TimelineOptionsMarginType;
max?: DateType;
maxHeight?: HeightWidthType;
@ -171,15 +170,15 @@ interface TimelineOptions {
moveable?: boolean;
multiselect?: boolean;
multiselectPerGroup?: boolean;
onAdd?: () => void; // TODO
onAddGroup?: () => void; // TODO
onUpdate?: () => void; // TODO
onMove?: () => void; // TODO
onMoveGroup?: () => void; // TODO
onMoving?: () => void; // TODO
onRemove?: () => void; // TODO
onRemoveGroup?: () => void; // TODO
order?: () => void; // TODO
onAdd?(): void; // TODO
onAddGroup?(): void; // TODO
onUpdate?(): void; // TODO
onMove?(): void; // TODO
onMoveGroup?(): void; // TODO
onMoving?(): void; // TODO
onRemove?(): void; // TODO
onRemoveGroup?(): void; // TODO
order?(): void; // TODO
orientation?: TimelineOptionsOrientationType;
rollingMode: boolean;
selectable?: boolean;
@ -189,11 +188,11 @@ interface TimelineOptions {
stack?: boolean;
snap?: TimelineOptionsSnapFunction;
start?: DateType;
template?: () => void; // TODO
template?(): void; // TODO
throttleRedraw?: number;
timeAxis?: TimelineTimeAxisOption;
type?: string;
tooltipOnItemUpdateTime?: boolean | { template: (item: any) => any };
tooltipOnItemUpdateTime?: boolean | { template(item: any): any };
verticalScroll?: boolean;
width?: HeightWidthType;
zoomable?: boolean;
@ -276,7 +275,6 @@ interface DataSetQueueOptions {
}
export class DataSet<T extends DataItem | DataGroup | Node | Edge> {
/**
* Creates an instance of DataSet.
*
@ -539,7 +537,7 @@ interface DataSelectionOptions<T> {
*
* @memberOf DataSelectionOptions
*/
filter?: (item: T) => boolean;
filter?(item: T): boolean;
/**
* Order the items by a field name or custom sort function.
@ -581,7 +579,7 @@ interface RangeType {
interface DataAxisSideOption {
range?: RangeType;
format?: () => string;
format?(): string;
title?: TitleOption;
}
@ -611,7 +609,7 @@ interface Graph2dDataAxisOption {
interface Graph2dDrawPointsOption {
enabled?: boolean;
onRender?: () => boolean; // TODO
onRender?(): boolean; // TODO
size?: number;
style: Graph2dDrawPointsStyle;
}
@ -642,7 +640,7 @@ interface Graph2dOptions {
legend?: Graph2dLegendOption;
locale?: string;
locales?: any; // TODO
moment?: () => void; // TODO
moment?(): void; // TODO
max?: DateType;
maxHeight?: HeightWidthType;
maxMinorChars?: number;
@ -840,7 +838,6 @@ type NetworkEvents =
* @implements {INetwork}
*/
export class Network {
/**
* Creates an instance of Network.
*
@ -1476,12 +1473,12 @@ export interface ViewPortOptions {
offset?: Position;
/**
* For animation you can either use a Boolean to use it with the default options or
* disable it or you can define the duration (in milliseconds) and easing function manually.
*
* @type {(IAnimationOptions | boolean)}
* @memberOf IFitOptions
*/
* For animation you can either use a Boolean to use it with the default options or
* disable it or you can define the duration (in milliseconds) and easing function manually.
*
* @type {(IAnimationOptions | boolean)}
* @memberOf IFitOptions
*/
animation?: AnimationOptions | boolean;
}
@ -1510,7 +1507,6 @@ export interface MoveToOptions extends ViewPortOptions {
* @interface IAnimationOptions
*/
export interface AnimationOptions {
/**
* The duration (in milliseconds).
*
@ -1539,7 +1535,6 @@ export interface AnimationOptions {
* @interface IFitOptions
*/
export interface FitOptions {
/**
* The nodes can be used to zoom to fit only specific nodes in the view.
*
@ -1583,7 +1578,6 @@ export interface BoundingBox {
* @interface IClusterOptions
*/
export interface ClusterOptions {
/**
* Optional for all but the cluster method.
* The cluster module loops over all nodes that are selected to be in the cluster
@ -1593,7 +1587,7 @@ export interface ClusterOptions {
*
* @memberOf IClusterOptions
*/
joinCondition?: (nodeOptions: any) => boolean;
joinCondition?(nodeOptions: any): boolean;
/**
* Optional.
@ -1605,7 +1599,7 @@ export interface ClusterOptions {
* @type {(clusterOptions: any, childNodesOptions: any[], childEdgesOptions: any[])}
* @memberOf IClusterOptions
*/
processProperties?: (clusterOptions: any, childNodesOptions: any[], childEdgesOptions: any[]) => any;
processProperties?(clusterOptions: any, childNodesOptions: any[], childEdgesOptions: any[]): any;
/**
* Optional.
@ -1641,7 +1635,6 @@ export interface ClusterOptions {
* @interface IOpenClusterOptions
*/
export interface OpenClusterOptions {
/**
* A function that can be used to manually position the nodes after the cluster is opened.
* The containedNodesPositions contain the positions of the nodes in the cluster at the
@ -1656,9 +1649,9 @@ export interface OpenClusterOptions {
*
* @memberOf IOpenClusterOptions
*/
releaseFunction: (
releaseFunction(
clusterPosition: Position,
containedNodesPositions: { [nodeId: string]: Position }) => { [nodeId: string]: Position };
containedNodesPositions: { [nodeId: string]: Position }): { [nodeId: string]: Position };
}
export interface Position {
@ -1667,7 +1660,6 @@ export interface Position {
}
export interface Properties {
nodes: string[];
edges: string[];
@ -1686,7 +1678,7 @@ export interface Properties {
}
export interface Callback {
callback?: (params?: any) => void;
callback?(params?: any): void;
}
export interface Data {

View File

@ -21,8 +21,8 @@ interface TestData {
}
// create a DataSet
var options = {};
var data = new vis.DataSet<TestData>(options);
let options = {};
let data = new vis.DataSet<TestData>(options);
// add items
// note that the data items can contain different properties and data formats
@ -45,15 +45,15 @@ data.update({ id: 2, group: 1 });
data.remove(4);
// get all ids
var ids = data.getIds();
const ids = data.getIds();
console.log('ids', ids);
// get a specific item
var item1 = data.get(1);
const item1 = data.get(1);
console.log('item1', item1);
// retrieve a filtered subset of the data
var items = data.get({
let items = data.get({
filter: (item) => {
return item.group === 1;
}
@ -61,7 +61,7 @@ var items = data.get({
console.log('filtered items', items);
// retrieve formatted items
var items = data.get({
items = data.get({
fields: ['id', 'date'],
type: {
date: 'ISODate'
@ -74,7 +74,7 @@ console.log('formatted items', items);
//
// create a DataSet
var data = new vis.DataSet<TestData>();
data = new vis.DataSet<TestData>();
// subscribe to any change in the DataSet
data.on('*', (event, properties, senderId) => {
@ -91,7 +91,7 @@ data.remove(1); // triggers an 'remove' event
//
// create a DataSet
var data = new vis.DataSet<TestData>();
data = new vis.DataSet<TestData>();
// add items
data.add([
@ -111,7 +111,7 @@ data.remove(3);
//
// create a DataSet
var data = new vis.DataSet<TestData>();
data = new vis.DataSet<TestData>();
data.add([
{ id: 1, text: 'item 1', date: '2013-06-20', group: 1, first: true },
{ id: 2, text: 'item 2', date: '2013-06-23', group: 2 },
@ -120,7 +120,7 @@ data.add([
]);
// retrieve formatted items
var items = data.get({
items = data.get({
fields: ['id', 'date', 'group'], // output the specified fields only
type: {
date: 'Date', // convert the date fields to Date objects
@ -128,19 +128,19 @@ var items = data.get({
}
});
var dataset = new vis.DataSet<TestData>();
const dataset = new vis.DataSet<TestData>();
// retrieve all items having a property group with value 2
var group2 = dataset.get({
const group2 = dataset.get({
filter: (item) => {
return (item.group === 2);
}
});
// retrieve all items having a property balance with a value above zero
var positiveBalance = dataset.get({
const positiveBalance = dataset.get({
filter: (item) => {
return (item.balance > 0);
return item.balance !== undefined && item.balance > 0;
}
});
@ -149,7 +149,7 @@ var positiveBalance = dataset.get({
//
// create an array with nodes
var nodes = new vis.DataSet([
const nodes = new vis.DataSet([
{ id: 1, label: 'Node 1' },
{ id: 2, label: 'Node 2' },
{ id: 3, label: 'Node 3' },
@ -158,7 +158,7 @@ var nodes = new vis.DataSet([
]);
// create an array with edges
var edges = new vis.DataSet([
const edges = new vis.DataSet([
{ from: 1, to: 3 },
{ from: 1, to: 2 },
{ from: 2, to: 4 },
@ -166,21 +166,21 @@ var edges = new vis.DataSet([
]);
// create a network
var container = <HTMLElement> document.getElementById('mynetwork');
const container = <HTMLElement> document.getElementById('mynetwork');
// provide the data in the vis format
var data2 = { nodes, edges };
var options = {};
const data2 = { nodes, edges };
options = {};
// initialize your network!
var network = new vis.Network(container, data2, options);
const network = new vis.Network(container, data2, options);
//
// Test code sample from http://visjs.org/docs/network/configure.html#
//
// these are all options in full.
var options2 = {
const options2 = {
configure: {
enabled: true,
filter: 'nodes,edges',
@ -189,4 +189,4 @@ var options2 = {
}
};
network.setOptions(options2);
network.setOptions(options2);

View File

@ -9,187 +9,187 @@ import * as https from 'https';
export = Config;
declare class Config {
devServer: Config.DevServer
entryPoints: Config.EntryPoints
module: Config.Module
node: Config.ChainedMap<this>
output: Config.Output
performance: Config.Performance
plugins: Config.Plugins<this>
resolve: Config.Resolve
resolveLoader: Config.ResolveLoader
devServer: Config.DevServer;
entryPoints: Config.EntryPoints;
module: Config.Module;
node: Config.ChainedMap<this>;
output: Config.Output;
performance: Config.Performance;
plugins: Config.Plugins<this>;
resolve: Config.Resolve;
resolveLoader: Config.ResolveLoader;
amd(value: { [moduleName: string]: boolean }): this
bail(value: boolean): this
cache(value: boolean | any): this
devtool(value: Config.DevTool): this
context(value: string): this
externals(value: webpack.ExternalsElement | webpack.ExternalsElement[]): this
loader(value: any): this
profile(value: boolean): this
recordsPath(value: string): this
recordsInputPath(value: string): this
recordsOutputPath(value: string): this
stats(value: webpack.Options.Stats): this
target(value: string): this
watch(value: boolean): this
watchOptions(value: webpack.Options.WatchOptions): this
amd(value: { [moduleName: string]: boolean }): this;
bail(value: boolean): this;
cache(value: boolean | any): this;
devtool(value: Config.DevTool): this;
context(value: string): this;
externals(value: webpack.ExternalsElement | webpack.ExternalsElement[]): this;
loader(value: any): this;
profile(value: boolean): this;
recordsPath(value: string): this;
recordsInputPath(value: string): this;
recordsOutputPath(value: string): this;
stats(value: webpack.Options.Stats): this;
target(value: string): this;
watch(value: boolean): this;
watchOptions(value: webpack.Options.WatchOptions): this;
entry(name: string): Config.ChainedSet<this>
plugin(name: string): Config.Plugin<this>
entry(name: string): Config.ChainedSet<this>;
plugin(name: string): Config.Plugin<this>;
toConfig(): webpack.Configuration
merge(obj: any): this
toConfig(): webpack.Configuration;
merge(obj: any): this;
}
declare namespace Config {
export class Chained<Parent> {
end(): Parent
class Chained<Parent> {
end(): Parent;
}
export class TypedChainedMap<Parent, Value> extends Chained<Parent> {
clear(): this
delete(key: string): this
has(key: string): boolean
get(key: string): Value
set(key: string, value: Value): this
merge(obj: { [key: string]: Value }): this
entries(): { [key: string]: Value }
values(): Array<Value>
class TypedChainedMap<Parent, Value> extends Chained<Parent> {
clear(): this;
delete(key: string): this;
has(key: string): boolean;
get(key: string): Value;
set(key: string, value: Value): this;
merge(obj: { [key: string]: Value }): this;
entries(): { [key: string]: Value };
values(): Value[];
}
export class ChainedMap<Parent> extends TypedChainedMap<Parent, any> {}
class ChainedMap<Parent> extends TypedChainedMap<Parent, any> {}
export class TypedChainedSet<Parent, Value> extends Chained<Parent> {
add(value: Value): this
prepend(value: Value): this
clear(): this
delete(key: string): this
has(key: string): boolean
merge(arr: Array<Value>): this
values(): Array<Value>
class TypedChainedSet<Parent, Value> extends Chained<Parent> {
add(value: Value): this;
prepend(value: Value): this;
clear(): this;
delete(key: string): this;
has(key: string): boolean;
merge(arr: Value[]): this;
values(): Value[];
}
export class ChainedSet<Parent> extends TypedChainedSet<Parent, any> {}
class ChainedSet<Parent> extends TypedChainedSet<Parent, any> {}
export class Plugins<Parent> extends TypedChainedMap<Parent, Plugin<Parent>> {}
class Plugins<Parent> extends TypedChainedMap<Parent, Plugin<Parent>> {}
export class Plugin<Parent> extends ChainedMap<Parent> {
init(value: (plugin: PluginClass, args: any[]) => webpack.Plugin): this
use(plugin: PluginClass, args?: any[]): this
tap(f: (args: any[]) => any[]): this
class Plugin<Parent> extends ChainedMap<Parent> {
init(value: (plugin: PluginClass, args: any[]) => webpack.Plugin): this;
use(plugin: PluginClass, args?: any[]): this;
tap(f: (args: any[]) => any[]): this;
}
export class Module extends ChainedMap<Config> {
rules: TypedChainedMap<this, Rule>
rule(name: string): Rule
class Module extends ChainedMap<Config> {
rules: TypedChainedMap<this, Rule>;
rule(name: string): Rule;
}
export class Output extends ChainedMap<Config> {
chunkFilename(value: string): this
crossOriginLoading(value: boolean | string): this
filename(value: string): this
library(value: string): this
libraryTarget(value: string): this
devtoolFallbackModuleFilenameTemplate(value: any): this
devtoolLineToLine(value: any): this
devtoolModuleFilenameTemplate(value: any): this
hashFunction(value: string): this
hashDigest(value: string): this
hashDigestLength(value: number): this
hashSalt(value: any): this
hotUpdateChunkFilename(value: string): this
hotUpdateFunction(value: any): this
hotUpdateMainFilename(value: string): this
jsonpFunction(value: string): this
path(value: string): this
pathinfo(value: boolean): this
publicPath(value: string): this
sourceMapFilename(value: string): this
sourcePrefix(value: string): this
strictModuleExceptionHandling(value: boolean): this
umdNamedDefine(value: boolean): this
class Output extends ChainedMap<Config> {
chunkFilename(value: string): this;
crossOriginLoading(value: boolean | string): this;
filename(value: string): this;
library(value: string): this;
libraryTarget(value: string): this;
devtoolFallbackModuleFilenameTemplate(value: any): this;
devtoolLineToLine(value: any): this;
devtoolModuleFilenameTemplate(value: any): this;
hashFunction(value: string): this;
hashDigest(value: string): this;
hashDigestLength(value: number): this;
hashSalt(value: any): this;
hotUpdateChunkFilename(value: string): this;
hotUpdateFunction(value: any): this;
hotUpdateMainFilename(value: string): this;
jsonpFunction(value: string): this;
path(value: string): this;
pathinfo(value: boolean): this;
publicPath(value: string): this;
sourceMapFilename(value: string): this;
sourcePrefix(value: string): this;
strictModuleExceptionHandling(value: boolean): this;
umdNamedDefine(value: boolean): this;
}
export class DevServer extends ChainedMap<Config> {
clientLogLevel(value: 'none' | 'error' | 'warning' | 'info'): this
compress(value: boolean): this
contentBase(value: boolean | string | string[]): this
filename(value: string): this
headers(value: { [header: string]: string }): this
historyApiFallback(value: boolean | any): this
host(value: string): this
hot(value: boolean): this
hotOnly(value: boolean): this
https(value: boolean | https.ServerOptions): this
inline(value: boolean): this
lazy(value: boolean): this
noInfo(value: boolean): this
overlay(value: boolean | { warnings?: boolean, errors?: boolean }): this
port(value: number): this
proxy(value: any): this
quiet(value: boolean): this
setup(value: (expressApp: any) => void): this
stats(value: webpack.Options.Stats): this
watchContentBase(value: boolean): this
class DevServer extends ChainedMap<Config> {
clientLogLevel(value: 'none' | 'error' | 'warning' | 'info'): this;
compress(value: boolean): this;
contentBase(value: boolean | string | string[]): this;
filename(value: string): this;
headers(value: { [header: string]: string }): this;
historyApiFallback(value: boolean | any): this;
host(value: string): this;
hot(value: boolean): this;
hotOnly(value: boolean): this;
https(value: boolean | https.ServerOptions): this;
inline(value: boolean): this;
lazy(value: boolean): this;
noInfo(value: boolean): this;
overlay(value: boolean | { warnings?: boolean, errors?: boolean }): this;
port(value: number): this;
proxy(value: any): this;
quiet(value: boolean): this;
setup(value: (expressApp: any) => void): this;
stats(value: webpack.Options.Stats): this;
watchContentBase(value: boolean): this;
}
export class Performance extends ChainedMap<Config> {
hints(value: boolean | 'error' | 'warning'): this
maxEntrypointSize(value: number): this
maxAssetSize(value: number): this
assetFilter(value: (assetFilename: string) => boolean): this
class Performance extends ChainedMap<Config> {
hints(value: boolean | 'error' | 'warning'): this;
maxEntrypointSize(value: number): this;
maxAssetSize(value: number): this;
assetFilter(value: (assetFilename: string) => boolean): this;
}
export class EntryPoints extends TypedChainedMap<Config, ChainedMap<Config>> {}
class EntryPoints extends TypedChainedMap<Config, ChainedMap<Config>> {}
export class Resolve extends ChainedMap<Config> {
alias: TypedChainedMap<this, string>
aliasFields: TypedChainedSet<this, string>
descriptionFiles: TypedChainedSet<this, string>
extensions: TypedChainedSet<this, string>
mainFields: TypedChainedSet<this, string>
mainFiles: TypedChainedSet<this, string>
modules: TypedChainedSet<this, string>
plugins: TypedChainedMap<this, Plugin<this>>
class Resolve extends ChainedMap<Config> {
alias: TypedChainedMap<this, string>;
aliasFields: TypedChainedSet<this, string>;
descriptionFiles: TypedChainedSet<this, string>;
extensions: TypedChainedSet<this, string>;
mainFields: TypedChainedSet<this, string>;
mainFiles: TypedChainedSet<this, string>;
modules: TypedChainedSet<this, string>;
plugins: TypedChainedMap<this, Plugin<this>>;
enforceExtension(value: boolean): this
enforceModuleExtension(value: boolean): this
unsafeCache(value: boolean | RegExp | RegExp[]): this
symlinks(value: boolean): this
cachePredicate(value: (data: { path: string, request: string }) => boolean): this
enforceExtension(value: boolean): this;
enforceModuleExtension(value: boolean): this;
unsafeCache(value: boolean | RegExp | RegExp[]): this;
symlinks(value: boolean): this;
cachePredicate(value: (data: { path: string, request: string }) => boolean): this;
plugin(name: string): Plugin<this>
plugin(name: string): Plugin<this>;
}
export class ResolveLoader extends ChainedMap<Config> {
extensions: TypedChainedSet<this, string>
modules: TypedChainedSet<this, string>
moduleExtensions: TypedChainedSet<this, string>
packageMains: TypedChainedSet<this, string>
class ResolveLoader extends ChainedMap<Config> {
extensions: TypedChainedSet<this, string>;
modules: TypedChainedSet<this, string>;
moduleExtensions: TypedChainedSet<this, string>;
packageMains: TypedChainedSet<this, string>;
}
export class Rule extends ChainedMap<Module> {
uses: TypedChainedMap<this, Use>
include: TypedChainedSet<this, webpack.Condition>
exclude: TypedChainedSet<this, webpack.Condition>
class Rule extends ChainedMap<Module> {
uses: TypedChainedMap<this, Use>;
include: TypedChainedSet<this, webpack.Condition>;
exclude: TypedChainedSet<this, webpack.Condition>;
parser(value: { [optName: string]: any }): this
test(value: webpack.Condition | webpack.Condition[]): this
enforce(value: 'pre' | 'post'): this
parser(value: { [optName: string]: any }): this;
test(value: webpack.Condition | webpack.Condition[]): this;
enforce(value: 'pre' | 'post'): this;
use(name: string): Use
pre(): this
post(): this
use(name: string): Use;
pre(): this;
post(): this;
}
type LoaderOptions = { [name: string]: any }
interface LoaderOptions { [name: string]: any; }
export class Use extends ChainedMap<Rule> {
loader(value: string): this
options(value: LoaderOptions): this
class Use extends ChainedMap<Rule> {
loader(value: string): this;
options(value: LoaderOptions): this;
tap(f: (options: LoaderOptions) => LoaderOptions): this
tap(f: (options: LoaderOptions) => LoaderOptions): this;
}
type DevTool = 'eval' | 'inline-source-map' | 'cheap-eval-source-map' | 'cheap-source-map' |
@ -204,9 +204,9 @@ declare namespace Config {
'#@eval' | '#@inline-source-map' | '#@cheap-eval-source-map' | '#@cheap-source-map' |
'#@cheap-module-eval-source-map' | '#@cheap-module-source-map' | '#@eval-source-map' |
'#@source-map' | '#@nosources-source-map' | '#@hidden-source-map' | '#@nosources-source-map' |
boolean
boolean;
interface PluginClass {
new (...opts: any[]): webpack.Plugin
new (...opts: any[]): webpack.Plugin;
}
}

View File

@ -13,7 +13,7 @@ config
.context('')
.externals('foo')
.externals(/node_modules/)
.externals({ 'test': false, 'foo': 'bar' })
.externals({ test: false, foo: 'bar' })
.externals(['foo', 'bar'])
.externals((context, request, cb) => cb(null, true))
.loader({})