mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Vendored
+4
-3
@@ -8,10 +8,11 @@ interface HeadroomOptions {
|
||||
tolerance?: any;
|
||||
classes?: {
|
||||
initial?: string;
|
||||
pinned?: string;
|
||||
unpinned?: string;
|
||||
top?: string;
|
||||
notBottom?:string;
|
||||
notTop?: string;
|
||||
pinned?: string;
|
||||
top?: string;
|
||||
unpinned?: string;
|
||||
};
|
||||
scroller?: Element;
|
||||
onPin?: () => void;
|
||||
|
||||
Vendored
+1
@@ -137,6 +137,7 @@ declare module "apn" {
|
||||
}
|
||||
export interface NotificationAlertOptions {
|
||||
title?:string;
|
||||
subtitle?:string;
|
||||
body:string;
|
||||
"title-loc-key"?:string;
|
||||
"title-loc-args"?:string[];
|
||||
|
||||
Vendored
+1
-1
@@ -346,7 +346,7 @@ declare module "babel-traverse" {
|
||||
|
||||
getData(key: string, def?: any): any;
|
||||
|
||||
buildCodeFrameError(msg: string, Error: Error): Error;
|
||||
buildCodeFrameError<TError extends Error>(msg: string, Error?: new (msg: string) => TError): TError;
|
||||
|
||||
traverse(visitor: Visitor, state?: any): void;
|
||||
|
||||
|
||||
+5
-2
@@ -36,7 +36,10 @@ interface NotifySettings {
|
||||
from?: string;
|
||||
align?: string;
|
||||
};
|
||||
offset?: number;
|
||||
offset?: number | {
|
||||
x?: number;
|
||||
y?: number;
|
||||
};
|
||||
spacing?: number;
|
||||
z_index?: number;
|
||||
delay?: number;
|
||||
@@ -59,4 +62,4 @@ interface NotifyReturn {
|
||||
$ele: JQueryStatic;
|
||||
close: () => void;
|
||||
update: (command: string, update: any) => void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference path="bunyan-config.d.ts"/>
|
||||
|
||||
import * as bunyan from "bunyan";
|
||||
import bunyanConfig from "bunyan-config";
|
||||
import bunyanConfig = require("bunyan-config");
|
||||
|
||||
var jsonConfig = {
|
||||
name: "myLogger",
|
||||
|
||||
Vendored
+1
-1
@@ -27,5 +27,5 @@ declare module "bunyan-config" {
|
||||
* @return {LoggerOptions} A logger options.
|
||||
*/
|
||||
function bunyanConfig(jsonConfig?: Configuration): bunyan.LoggerOptions;
|
||||
export default bunyanConfig;
|
||||
export = bunyanConfig;
|
||||
}
|
||||
|
||||
Vendored
+495
@@ -0,0 +1,495 @@
|
||||
// Type definitions for Cash
|
||||
// Project: https://github.com/kenwheeler/cash
|
||||
// Definitions by: Ashok Vishwakarma <https://github.com/akvlko>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* OffsetType
|
||||
* return type for cash.offset(), cash.position()
|
||||
*/
|
||||
interface OffsetType {
|
||||
top: number;
|
||||
left: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* CashStatic
|
||||
* Static declaration for CashJs accessible directly using Cash object or $
|
||||
*/
|
||||
interface CashStatic {
|
||||
/**
|
||||
* isArray
|
||||
* Check if the argument is an array.
|
||||
* @type method
|
||||
* @argument any
|
||||
* @return boolean
|
||||
*/
|
||||
isArray(n: any): boolean;
|
||||
|
||||
/**
|
||||
* isFunction
|
||||
* Check if the argument is a function.
|
||||
* @type method
|
||||
* @argument any
|
||||
* @return boolean
|
||||
*/
|
||||
isFunction(n: any): boolean;
|
||||
|
||||
/**
|
||||
* isNumeric
|
||||
* Check if the argument is numeric.
|
||||
* @type method
|
||||
* @type method
|
||||
* @argument any
|
||||
* @return boolean
|
||||
*/
|
||||
isNumeric(n: any): boolean;
|
||||
|
||||
/**
|
||||
* isString
|
||||
* Check if the argument is a string.
|
||||
* @type method
|
||||
* @argument str any
|
||||
* @return boolean
|
||||
*/
|
||||
isString(str: any): boolean;
|
||||
|
||||
/**
|
||||
* extend
|
||||
* Extends target object with properties from the source object. If no target is provided, cash itself will be extended.
|
||||
* @type method
|
||||
* @argument target any, source any
|
||||
*/
|
||||
extend(target: any, source: any): any;
|
||||
|
||||
/**
|
||||
* matches
|
||||
* Checks a selector against an element, returning a boolean value for match.
|
||||
* @type method
|
||||
* @argument element Cash, selector string
|
||||
* @return boolean
|
||||
*/
|
||||
matches(element: Cash, selector: string): boolean;
|
||||
|
||||
/**
|
||||
* parseHTML
|
||||
* Returns a collection from an HTML string.
|
||||
* @type method
|
||||
* @argument htmlString string
|
||||
* @return Cash
|
||||
*/
|
||||
parseHTML(htmlString: string): Cash;
|
||||
|
||||
/**
|
||||
* each
|
||||
* Iterates through a collection and calls the callback method on each.
|
||||
* @type method
|
||||
* @argument collection Array, callback Function
|
||||
* @return Array
|
||||
*/
|
||||
each(collection: Array<any>, callback: Function): Array<any>;
|
||||
|
||||
/**
|
||||
* fn: use to extend cash for plugin development
|
||||
* @type property
|
||||
*/
|
||||
fn: any;
|
||||
|
||||
/**
|
||||
* selector declaration for Cash to use $(<argument>)
|
||||
*/
|
||||
(selector: string, context?: Element|Cash): Cash;
|
||||
(element: Element): Cash;
|
||||
(elementArray: Element[]): Cash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cash
|
||||
* Interface for CashJs
|
||||
* Refer https://github.com/kenwheeler/cash for documentation and uses of the methods and properties
|
||||
*/
|
||||
interface Cash {
|
||||
/**
|
||||
* add
|
||||
* Returns a new collection with the element(s) added to the end.
|
||||
*/
|
||||
add(selector: string|Cash|Element, context?: Element): Cash;
|
||||
|
||||
/**
|
||||
* addClass
|
||||
* Adds the className argument to collection elements.
|
||||
*/
|
||||
addClass(c: string): Cash;
|
||||
|
||||
/**
|
||||
* after
|
||||
* Inserts content or elements after the collection.
|
||||
*/
|
||||
after(selector: Element|String): Cash;
|
||||
|
||||
/**
|
||||
* append
|
||||
* Appends the target element to the each element in the collection.
|
||||
*/
|
||||
append(content: string|Element|Cash): Cash;
|
||||
|
||||
/**
|
||||
* appendTo
|
||||
* Adds the elements in a collection to the target element(s).
|
||||
*/
|
||||
appendTo(parent: string|Element|Cash): Cash;
|
||||
|
||||
/**
|
||||
* attr
|
||||
* Without attrValue, returns the attribute value of the first element in the collection.
|
||||
* With attrValue, sets the attribute value of each element of the collection.
|
||||
*/
|
||||
attr(name: string): any;
|
||||
attr(name: string, value: string): Cash;
|
||||
|
||||
/**
|
||||
* before
|
||||
* Inserts content or elements before the collection.
|
||||
*/
|
||||
before(selector: string|Element): Cash;
|
||||
|
||||
/**
|
||||
* children
|
||||
* Without a selector specified, returns a collection of child elements.
|
||||
* With a selector, returns child elements that match the selector.
|
||||
*/
|
||||
children(selector?: string): Cash;
|
||||
|
||||
/**
|
||||
* closest
|
||||
* Returns the closest matching selector up the DOM tree.
|
||||
*/
|
||||
closest(selector?: string): Cash;
|
||||
|
||||
/**
|
||||
* clone
|
||||
* Returns a clone of the collection.
|
||||
*/
|
||||
clone(): Cash;
|
||||
|
||||
/**
|
||||
* css
|
||||
* Returns a CSS property value when just property is supplied.
|
||||
* Sets a CSS property when property and value are supplied, and set multiple properties when an object is supplied.
|
||||
* Properties will be autoprefixed if needed for the user's browser.
|
||||
*/
|
||||
css(prop: any): any;
|
||||
css(prop: string, value: any): Cash;
|
||||
|
||||
/**
|
||||
* data
|
||||
* Link some data (string, object, array, etc.) to an element when both key and value are supplied.
|
||||
* If only a key is supplied, returns the linked data and falls back to data attribute value if no data is already linked.
|
||||
* Multiple data can be set when an object is supplied.
|
||||
*/
|
||||
data(name: any): any;
|
||||
data(name: string, value: any): Cash;
|
||||
|
||||
/**
|
||||
* each
|
||||
* Iterates over a collection with callback(value, index, array).
|
||||
*/
|
||||
each(callback: Function): Cash;
|
||||
|
||||
/**
|
||||
* empty
|
||||
* Empties an elements interior markup.
|
||||
*/
|
||||
empty(): Cash;
|
||||
|
||||
/**
|
||||
* eq
|
||||
* Returns a collection with the element at index.
|
||||
*/
|
||||
eq(index: number): Cash;
|
||||
|
||||
/**
|
||||
* extend
|
||||
* Adds properties to the cash collection prototype.
|
||||
*/
|
||||
extend(target: any): any;
|
||||
|
||||
/**
|
||||
* filter
|
||||
* Returns the collection that results from applying the filter method.
|
||||
*/
|
||||
filter(selector: Function): Cash;
|
||||
|
||||
/**
|
||||
* find
|
||||
* Returns selector match descendants from the first element in the collection.
|
||||
*/
|
||||
find(selector: string): Cash;
|
||||
|
||||
/**
|
||||
* first
|
||||
* Returns the first element in the collection.
|
||||
*/
|
||||
first(): Cash;
|
||||
|
||||
/**
|
||||
* get
|
||||
* Returns the element at the index.
|
||||
*/
|
||||
get(index: number): HTMLElement;
|
||||
|
||||
/**
|
||||
* has
|
||||
* Returns boolean result of the selector argument against the collection.
|
||||
*/
|
||||
has(selector: string): boolean;
|
||||
|
||||
/**
|
||||
* hasClass
|
||||
* Returns the boolean result of checking if the first element in the collection has the className attribute.
|
||||
*/
|
||||
hasClass(c: string): boolean;
|
||||
|
||||
/**
|
||||
* height
|
||||
* Returns the height of the element.
|
||||
*/
|
||||
height(): number;
|
||||
|
||||
/**
|
||||
* html
|
||||
* Returns the HTML text of the first element in the collection, sets the HTML if provided.
|
||||
*/
|
||||
html(): string;
|
||||
html(content: string): Cash;
|
||||
|
||||
/**
|
||||
* index
|
||||
* Returns the index of the element in its parent if an element or selector isn't provided.
|
||||
* Returns index within element or selector if it is.
|
||||
*/
|
||||
index(elem?: Element): number;
|
||||
|
||||
/**
|
||||
* innerHeight
|
||||
* Returns the height of the element + padding.
|
||||
*/
|
||||
innerHeight(): number;
|
||||
|
||||
/**
|
||||
* innerWidth
|
||||
* Returns the width of the element + padding.
|
||||
*/
|
||||
innerWidth(): number;
|
||||
|
||||
/**
|
||||
* insertAfter
|
||||
* Inserts collection after specified element.
|
||||
*/
|
||||
insertAfter(selector: string|Element|Cash): Cash;
|
||||
|
||||
/**
|
||||
* insertBefore
|
||||
* Inserts collection before specified element.
|
||||
*/
|
||||
insertBefore(selector: string|Element|Cash): Cash;
|
||||
|
||||
/**
|
||||
* is
|
||||
* Returns whether the provided selector, element or collection matches any element in the collection.
|
||||
*/
|
||||
is(selector: string|Element|Cash): boolean;
|
||||
|
||||
/**
|
||||
* last
|
||||
* Returns last element in the collection.
|
||||
*/
|
||||
last(): Cash;
|
||||
|
||||
/**
|
||||
* next
|
||||
* Returns next sibling.
|
||||
*/
|
||||
next(): Cash;
|
||||
|
||||
/**
|
||||
* not
|
||||
* Filters collection by false match on selector.
|
||||
*/
|
||||
not(selector: string|Element|Cash): Cash;
|
||||
|
||||
/**
|
||||
* off
|
||||
* Removes event listener from collection elements.
|
||||
*/
|
||||
off(eventName: string, callback: Function): Cash;
|
||||
|
||||
/**
|
||||
* offset
|
||||
* Get the coordinates of the first element in a collection relative to the document.
|
||||
*/
|
||||
offset(): OffsetType;
|
||||
|
||||
/**
|
||||
* offsetParent
|
||||
* Get the first element's ancestor that's positioned.
|
||||
*/
|
||||
offsetParent(): OffsetType;
|
||||
|
||||
/**
|
||||
* on
|
||||
* Adds event listener to collection elements. Event is delegated if delegate is supplied.
|
||||
*/
|
||||
on(eventName: string|Array<string>, delegate: any, callback?: Function, runOnce?: boolean): Cash;
|
||||
|
||||
/**
|
||||
* one
|
||||
* Adds event listener to collection elements that only triggers once for each element.
|
||||
* Event is delegated if delegate is supplied.
|
||||
*/
|
||||
one(eventName: string|Array<string>, delegate: any, callback?: Function, runOnce?: boolean): Cash;
|
||||
|
||||
/**
|
||||
* outerHeight
|
||||
* Returns the outer height of the element. Includes margins if margin is set to true.
|
||||
*/
|
||||
outerHeight(flag?: boolean): number;
|
||||
|
||||
/**
|
||||
* outerWidth
|
||||
* Returns the outer width of the element. Includes margins if margin is set to true.
|
||||
*/
|
||||
outerWidth(flag?: boolean): number;
|
||||
|
||||
/**
|
||||
* parent
|
||||
* Returns parent element.
|
||||
*/
|
||||
parent(): Cash;
|
||||
|
||||
/**
|
||||
* parents
|
||||
* Returns collection of elements who are parents of element. Optionally filtering by selector.
|
||||
*/
|
||||
parents(selector?: string): Cash;
|
||||
|
||||
/**
|
||||
* position
|
||||
* Get the coordinates of the first element in a collection relative to its offsetParent.
|
||||
*/
|
||||
position(): OffsetType;
|
||||
|
||||
/**
|
||||
* prepend
|
||||
* Prepends element to the each element in collection.
|
||||
*/
|
||||
prepend(content: string): Cash;
|
||||
|
||||
/**
|
||||
* prependTo
|
||||
* Prepends elements in a collection to the target element(s).
|
||||
*/
|
||||
prependTo(parent: string|Element|Cash): Cash;
|
||||
|
||||
/**
|
||||
* prev
|
||||
* Returns the previous adjacent element.
|
||||
*/
|
||||
prev(): Cash;
|
||||
|
||||
/**
|
||||
* prop
|
||||
* Returns a property value when just property is supplied.
|
||||
* Sets a property when property and value are supplied, and sets multiple properties when an object is supplied.
|
||||
*/
|
||||
prop(name: string): any;
|
||||
prop(name: string, value: string): Cash;
|
||||
|
||||
/**
|
||||
* ready
|
||||
* Calls callback method on DOMContentLoaded.
|
||||
*/
|
||||
ready(fn: Function): void;
|
||||
|
||||
/**
|
||||
* remove
|
||||
* Removes collection elements from the DOM.
|
||||
*/
|
||||
remove(): Cash;
|
||||
|
||||
/**
|
||||
* removeAttr
|
||||
* Removes attribute from collection elements.
|
||||
*/
|
||||
removeAttr(name: string): Cash;
|
||||
|
||||
/**
|
||||
* removeClass
|
||||
* Removes className from collection elements.
|
||||
* Accepts space-separated classNames for removing multiple classes.
|
||||
* Providing no arguments will remove all classes.
|
||||
*/
|
||||
removeClass(c?: string): Cash;
|
||||
|
||||
/**
|
||||
* removeData
|
||||
* Removes linked data and data-attributes from collection elements.
|
||||
*/
|
||||
removeData(key: string): Cash;
|
||||
|
||||
/**
|
||||
* removeProp
|
||||
* Removes property from collection elements.
|
||||
*/
|
||||
removeProp(name: string): Cash;
|
||||
|
||||
/**
|
||||
* serialize
|
||||
* When called on a form, serializes and returns form data.
|
||||
*/
|
||||
serialize(): string;
|
||||
|
||||
/**
|
||||
* siblings
|
||||
* Returns a collection of sibling elements.
|
||||
*/
|
||||
siblings(): Cash;
|
||||
|
||||
/**
|
||||
* text
|
||||
* Returns the inner text of the first element in the collection, sets the text if textContent is provided.
|
||||
*/
|
||||
text(): string;
|
||||
text(content?: string): Cash;
|
||||
|
||||
/**
|
||||
* toggleClass
|
||||
* Adds or removes className from collection elements based on if the element already has the class.
|
||||
* Accepts space-separated classNames for toggling multiple classes, and an optional force boolean to ensure classes are added (true) or removed (false).
|
||||
*/
|
||||
toggleClass(c: string, state?: boolean): Cash;
|
||||
|
||||
/**
|
||||
* trigger
|
||||
* Triggers supplied event on elements in collection. Data can be passed along as the second parameter.
|
||||
*/
|
||||
trigger(eventName: string, data?: any): Cash;
|
||||
|
||||
/**
|
||||
* val
|
||||
* Returns an inputs value. If value is supplied, sets all inputs in collection's value to the value argument.
|
||||
*/
|
||||
val(): any;
|
||||
val(value?: string): Cash;
|
||||
|
||||
/**
|
||||
* width
|
||||
* Returns the width of the element.
|
||||
*/
|
||||
width(): number;
|
||||
}
|
||||
|
||||
declare module "cash" {
|
||||
export = CashStatic;
|
||||
}
|
||||
declare var cash: CashStatic;
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="./cropperjs.d.ts"/>
|
||||
import * as Cropper from 'cropperjs';
|
||||
import Cropper from 'cropperjs';
|
||||
|
||||
var image = <HTMLImageElement>document.getElementById('image');
|
||||
var cropper = new Cropper(image, {
|
||||
|
||||
Vendored
+1
-1
@@ -467,5 +467,5 @@ declare module cropperjs {
|
||||
|
||||
declare module "cropperjs" {
|
||||
const Cropper: typeof cropperjs.Cropper;
|
||||
export = Cropper;
|
||||
export default Cropper;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference path="defaults.d.ts" />
|
||||
|
||||
import defaults = require('defaults');
|
||||
|
||||
defaults({}, {user: 'developer', locale: 'fr-FR'});
|
||||
defaults(undefined, 'hello world');
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// Type definitions for defaults 1.0.3
|
||||
// Project: https://github.com/tmpvar/defaults/
|
||||
// Definitions by: Ibtihel CHNAB <https://github.com/IbtihelCHNAB/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function defaults(options: any, defaultOptions: any): any;
|
||||
|
||||
declare module "defaults" {
|
||||
export = defaults;
|
||||
}
|
||||
Vendored
+1
-2
@@ -16,9 +16,8 @@ declare module "ejs" {
|
||||
function renderFile(path: string, data?: Data, opts?: Options, cb?: Function): any;// TODO RenderFileCallback return type
|
||||
function clearCache(): any;
|
||||
|
||||
function TemplateFunction(data: Data): any;
|
||||
interface TemplateFunction {
|
||||
dependencies: Dependencies;
|
||||
(data: Data): any;
|
||||
}
|
||||
interface Options {
|
||||
cache?: any;
|
||||
|
||||
Vendored
+2
-2
@@ -10,8 +10,8 @@ declare module "express-mung" {
|
||||
import { Request, Response } from "express";
|
||||
import * as http from "http";
|
||||
|
||||
type Transform = (body: {}, request: Request, response: Response) => {};
|
||||
type TransformHeader = (body: http.IncomingMessage, request: Request, response: Response) => {};
|
||||
type Transform = (body: {}, request: Request, response: Response) => any;
|
||||
type TransformHeader = (body: http.IncomingMessage, request: Request, response: Response) => any;
|
||||
|
||||
/**
|
||||
* Transform the JSON body of the response.
|
||||
|
||||
@@ -170,5 +170,14 @@ resultStr = faker.random.objectElement({foo: 'bar', field: 'foo'});
|
||||
resultStr = faker.random.uuid();
|
||||
resultBool = faker.random.boolean();
|
||||
|
||||
resultStr = faker.system.fileName( "foo", "bar" );
|
||||
resultStr = faker.system.commonFileName( "foo", "bar" );
|
||||
resultStr = faker.system.mimeType();
|
||||
resultStr = faker.system.commonFileType();
|
||||
resultStr = faker.system.commonFileExt();
|
||||
resultStr = faker.system.fileType();
|
||||
resultStr = faker.system.fileExt( "foo" );
|
||||
resultStr = faker.system.semver();
|
||||
|
||||
import fakerEn = require('faker/locale/en');
|
||||
resultStr = faker.name.firstName();
|
||||
|
||||
Vendored
+13
@@ -173,6 +173,19 @@ declare namespace Faker {
|
||||
boolean(): boolean;
|
||||
};
|
||||
|
||||
system: {
|
||||
fileName(ext: string, type: string): string;
|
||||
commonFileName(ext: string, type: string): string;
|
||||
mimeType(): string;
|
||||
commonFileType(): string;
|
||||
commonFileExt(): string;
|
||||
fileType(): string;
|
||||
fileExt(mimeType: string): string;
|
||||
//directoryPath(): string;
|
||||
//filePath(): string;
|
||||
semver(): string;
|
||||
};
|
||||
|
||||
seed(value: number): void;
|
||||
}
|
||||
|
||||
|
||||
+22
-7
@@ -3,16 +3,16 @@
|
||||
window.fbAsyncInit = function() {
|
||||
FB.init(
|
||||
{
|
||||
appId : '{your-app-id}',
|
||||
appId : "{your-app-id}",
|
||||
xfbml : true,
|
||||
version : 'v2.0'
|
||||
version : "v2.0"
|
||||
}
|
||||
);
|
||||
|
||||
FB.ui(
|
||||
{
|
||||
method: 'share',
|
||||
href: 'https://developers.facebook.com/docs/dialogs/'
|
||||
method: "share",
|
||||
href: "https://developers.facebook.com/docs/dialogs/"
|
||||
},
|
||||
function(response) {
|
||||
console.log(response);
|
||||
@@ -21,9 +21,24 @@ window.fbAsyncInit = function() {
|
||||
|
||||
FB.api(
|
||||
"/me",
|
||||
"POST",
|
||||
function (fbResponse){
|
||||
"post",
|
||||
function (fbResponse) {
|
||||
console.log(fbResponse);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
function checkAuth(response: FB.LoginStatusResponse): void {
|
||||
if (response.status === "connected") {
|
||||
console.log(response.authResponse.accessToken);
|
||||
console.log(response.authResponse.expiresIn);
|
||||
console.log(response.authResponse.signedRequest);
|
||||
console.log(response.authResponse.userID);
|
||||
} else if (response.status === "unknown") {
|
||||
console.log("not logged in");
|
||||
}
|
||||
}
|
||||
|
||||
FB.login(checkAuth);
|
||||
|
||||
FB.getLoginStatus(checkAuth);
|
||||
};
|
||||
|
||||
Vendored
+34
-5
@@ -171,23 +171,44 @@ interface FBResponseObject {
|
||||
error: any;
|
||||
}
|
||||
|
||||
declare type LoginStatus = "connected" | "not_authorized" | "unknown";
|
||||
declare type ApiMethod = "get" | "post" | "delete";
|
||||
|
||||
interface AuthResponse {
|
||||
accessToken: string;
|
||||
expiresIn: number;
|
||||
signedRequest: string;
|
||||
userID: string;
|
||||
}
|
||||
|
||||
interface FBError {
|
||||
type: string;
|
||||
message: string;
|
||||
code: number;
|
||||
error_subcode?: number;
|
||||
error_user_msg?: string;
|
||||
error_user_title?: string;
|
||||
fbtrace_id: string;
|
||||
}
|
||||
|
||||
interface FBSDK{
|
||||
/* This method is used to initialize and setup the SDK. */
|
||||
init(fbInitObject : FBInitParams) : void;
|
||||
|
||||
/* This method lets you make calls to the Graph API. */
|
||||
api(path : string, method : string, callback : (fbResponseObject : Object) => any) : Object;
|
||||
api(path : string, params : Object, callback : (fbResponseObject : FBResponseObject) => any) : Object;
|
||||
api(path : string, method : string, params : Object, callback : (fbResponseObject : Object) => any) : Object;
|
||||
api(path: string, callback: (response: any) => void): void;
|
||||
api(path: string, method: ApiMethod, callback: (response: any) => void): void;
|
||||
api(path: string, params: any, callback: (response: any) => void): void;
|
||||
api(path: string, method: ApiMethod, params: any, callback: (response: any) => void): void;
|
||||
|
||||
/* This method is used to trigger different forms of Facebook created UI dialogs. */
|
||||
ui(params : FBUIParams, handler : (fbResponseObject : Object) => any) : void;
|
||||
|
||||
/* Allows you to determine if a user is logged in to Facebook and has authenticated your app */
|
||||
getLoginStatus(handler : Function, force?: Boolean) : void;
|
||||
getLoginStatus(handler : (fbResponseObject : FB.LoginStatusResponse) => any, force?: Boolean) : void;
|
||||
|
||||
/* Calling FB.login prompts the user to authenticate your application using the Login Dialog. */
|
||||
login(handler : (fbResponseObject : Object) => any, params?: FBLoginOptions): void;
|
||||
login(handler : (fbResponseObject : FB.LoginStatusResponse) => any, params?: FBLoginOptions): void;
|
||||
|
||||
/* Log the user out of your site and Facebook */
|
||||
logout(handler : (fbResponseObject : Object) => any) : void;
|
||||
@@ -198,6 +219,7 @@ interface FBSDK{
|
||||
Event : FBSDKEvents;
|
||||
XFBML : FBSDKXFBML;
|
||||
Canvas : FBSDKCanvas;
|
||||
Error: FBError;
|
||||
}
|
||||
|
||||
interface Window{
|
||||
@@ -208,4 +230,11 @@ declare module "FB" {
|
||||
export = FB;
|
||||
}
|
||||
|
||||
declare namespace FB {
|
||||
export interface LoginStatusResponse {
|
||||
authResponse?: AuthResponse;
|
||||
status: LoginStatus;
|
||||
}
|
||||
}
|
||||
|
||||
declare var FB : FBSDK;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/// <reference path="../hapi/hapi.d.ts" />
|
||||
/// <reference path="hapi-decorators.d.ts" />
|
||||
|
||||
import * as hapi from 'hapi';
|
||||
import { controller, get, post, put, cache, config, route, validate, Controller } from 'hapi-decorators';
|
||||
|
||||
@controller('/test')
|
||||
class TestController implements Controller {
|
||||
baseUrl: string;
|
||||
routes: () => hapi.IRouteConfiguration[];
|
||||
|
||||
@get('/')
|
||||
@config({
|
||||
auth: false
|
||||
})
|
||||
@cache({
|
||||
expiresIn: 42000
|
||||
})
|
||||
@validate({
|
||||
payload: false
|
||||
})
|
||||
getHandler(request: hapi.Request, reply: hapi.IReply) {
|
||||
reply({ success: true });
|
||||
}
|
||||
|
||||
@post('/')
|
||||
postHandler(request: hapi.Request, reply: hapi.IReply) {
|
||||
reply({ success: true });
|
||||
}
|
||||
|
||||
@put('/{id}')
|
||||
putHandler(request: hapi.Request, reply: hapi.IReply) {
|
||||
reply({ success: true });
|
||||
}
|
||||
|
||||
@route('delete', '/{id}')
|
||||
deleteHandler(request: hapi.Request, reply: hapi.IReply) {
|
||||
reply({ success: true });
|
||||
}
|
||||
}
|
||||
|
||||
const server = new hapi.Server();
|
||||
|
||||
server.route(new TestController().routes());
|
||||
Vendored
+98
@@ -0,0 +1,98 @@
|
||||
// Type definitions for hapi-decorators v0.4.3
|
||||
// Project: https://github.com/knownasilya/hapi-decorators
|
||||
// Definitions by: Ken Howard <http://github.com/kenhowardpdx>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../hapi/hapi.d.ts" />
|
||||
|
||||
declare module 'hapi-decorators' {
|
||||
import * as hapi from 'hapi';
|
||||
interface ControllerStatic {
|
||||
new (): Controller;
|
||||
}
|
||||
export interface Controller {
|
||||
baseUrl: string;
|
||||
routes: () => hapi.IRouteConfiguration[];
|
||||
}
|
||||
export function controller(baseUrl: string): (target: ControllerStatic) => void;
|
||||
interface IRouteSetup {
|
||||
(target: any, key: any, descriptor: any): any;
|
||||
}
|
||||
interface IRouteDecorator {
|
||||
(method: string, path: string): IRouteSetup;
|
||||
}
|
||||
interface IRouteConfig {
|
||||
(path: string): IRouteSetup;
|
||||
}
|
||||
export const route: IRouteDecorator;
|
||||
export const get: IRouteConfig;
|
||||
export const post: IRouteConfig;
|
||||
export const put: IRouteConfig;
|
||||
// export const delete: IRouteConfig;
|
||||
export const patch: IRouteConfig;
|
||||
export const all: IRouteConfig;
|
||||
export function config(config: hapi.IRouteAdditionalConfigurationOptions): (target: any, key: any, descriptor: any) => any;
|
||||
interface IValidateConfig {
|
||||
/** validation rules for incoming request headers.Values allowed:
|
||||
* trueany headers allowed (no validation performed).This is the default.
|
||||
falseno headers allowed (this will cause all valid HTTP requests to fail).
|
||||
a Joi validation object.
|
||||
a validation function using the signature function(value, options, next) where:
|
||||
valuethe object containing the request headers.
|
||||
optionsthe server validation options.
|
||||
next(err, value)the callback function called when validation is completed.
|
||||
*/
|
||||
headers?: boolean | hapi.IJoi | hapi.IValidationFunction;
|
||||
/** validation rules for incoming request path parameters, after matching the path against the route and extracting any parameters then stored in request.params.Values allowed:
|
||||
trueany path parameters allowed (no validation performed).This is the default.
|
||||
falseno path variables allowed.
|
||||
a Joi validation object.
|
||||
a validation function using the signature function(value, options, next) where:
|
||||
valuethe object containing the path parameters.
|
||||
optionsthe server validation options.
|
||||
next(err, value)the callback function called when validation is completed. */
|
||||
params?: boolean | hapi.IJoi | hapi.IValidationFunction;
|
||||
/** validation rules for an incoming request URI query component (the key- value part of the URI between '?' and '#').The query is parsed into its individual key- value pairs (using the qs module) and stored in request.query prior to validation.Values allowed:
|
||||
trueany query parameters allowed (no validation performed).This is the default.
|
||||
falseno query parameters allowed.
|
||||
a Joi validation object.
|
||||
a validation function using the signature function(value, options, next) where:
|
||||
valuethe object containing the query parameters.
|
||||
optionsthe server validation options.
|
||||
next(err, value)the callback function called when validation is completed. */
|
||||
query?: boolean | hapi.IJoi | hapi.IValidationFunction;
|
||||
/** validation rules for an incoming request payload (request body).Values allowed:
|
||||
trueany payload allowed (no validation performed).This is the default.
|
||||
falseno payload allowed.
|
||||
a Joi validation object.
|
||||
a validation function using the signature function(value, options, next) where:
|
||||
valuethe object containing the payload object.
|
||||
optionsthe server validation options.
|
||||
next(err, value)the callback function called when validation is completed. */
|
||||
payload?: boolean | hapi.IJoi | hapi.IValidationFunction;
|
||||
/** an optional object with error fields copied into every validation error response. */
|
||||
errorFields?: any;
|
||||
/** determines how to handle invalid requests.Allowed values are:
|
||||
'error'return a Bad Request (400) error response.This is the default value.
|
||||
'log'log the error but continue processing the request.
|
||||
'ignore'take no action.
|
||||
OR a custom error handler function with the signature 'function(request, reply, source, error)` where:
|
||||
requestthe request object.
|
||||
replythe continuation reply interface.
|
||||
sourcethe source of the invalid field (e.g. 'path', 'query', 'payload').
|
||||
errorthe error object prepared for the client response (including the validation function error under error.data). */
|
||||
failAction?: string | hapi.IRouteFailFunction;
|
||||
/** options to pass to Joi.Useful to set global options such as stripUnknown or abortEarly (the complete list is available here: https://github.com/hapijs/joi#validatevalue-schema-options-callback ).Defaults to no options. */
|
||||
options?: any;
|
||||
}
|
||||
export function validate(config: IValidateConfig): (target: any, key: any, descriptor: any) => any;
|
||||
interface ICacheConfig {
|
||||
privacy?: string;
|
||||
expiresIn?: number;
|
||||
expiresAt?: number;
|
||||
}
|
||||
export function cache(cacheConfig: ICacheConfig): (target: any, key: any, descriptor: any) => any;
|
||||
export function pre(pre: {
|
||||
[key: string]: any;
|
||||
}): (target: any, key: any, descriptor: any) => any;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2015",
|
||||
"experimentalDecorators": true
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for Highcharts 4.2.6 (boost module)
|
||||
// Project: http://www.highcharts.com/
|
||||
// Definitions by: Daniel Martin <http://github.com/inad9300>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="highcharts.d.ts" />
|
||||
|
||||
declare var HighchartsBoost: (H: HighchartsStatic) => HighchartsStatic;
|
||||
|
||||
declare module "highcharts/modules/boost" {
|
||||
export = HighchartsBoost;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// Type definitions for Highcharts 4.2.6 (offline exporting module)
|
||||
// Project: http://www.highcharts.com/
|
||||
// Definitions by: Daniel Martin <http://github.com/inad9300>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="highcharts.d.ts" />
|
||||
|
||||
declare var HighchartsOfflineExporting: (H: HighchartsStatic) => HighchartsStatic;
|
||||
|
||||
declare module "highcharts/modules/offline-exporting" {
|
||||
export = HighchartsOfflineExporting;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/// <reference path="./hyperscript.d.ts" />
|
||||
import * as h from 'hyperscript'
|
||||
|
||||
// Test/example code adapted from https://github.com/dominictarr/hyperscript/blob/master/README.md
|
||||
|
||||
// example
|
||||
h('div#page',
|
||||
h('div#header',
|
||||
h('h1.classy', 'h', { style: {'background-color': '#22f'} })),
|
||||
h('div#menu', { style: {'background-color': '#2f2'} },
|
||||
h('ul',
|
||||
h('li', 'one'),
|
||||
h('li', 'two'),
|
||||
h('li', 'three'))),
|
||||
h('h2', 'content title', { style: {'background-color': '#f22'} }),
|
||||
h('p',
|
||||
"so it's just like a templating engine,\n",
|
||||
"but easy to use inline with javascript\n"),
|
||||
h('p',
|
||||
"the intension is for this to be used to create\n",
|
||||
"reusable, interactive html widgets. "))
|
||||
|
||||
// event
|
||||
h('a', {href: '#',
|
||||
onclick: function (e: Event) {
|
||||
alert('you are 1,000,000th visitor!')
|
||||
e.preventDefault()
|
||||
}
|
||||
}, 'click here to win a prize')
|
||||
|
||||
// array of children
|
||||
const obj: {[id: string]: string} = {
|
||||
a: 'Apple',
|
||||
b: 'Banana',
|
||||
c: 'Cherry',
|
||||
d: 'Durian',
|
||||
e: 'Elder Berry'
|
||||
}
|
||||
h('table',
|
||||
h('tr', h('th', 'letter'), h('th', 'fruit')),
|
||||
Object.keys(obj).map(function (k) {
|
||||
return h('tr',
|
||||
h('th', k),
|
||||
h('td', obj[k])
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
// new context
|
||||
const h2 = h.context()
|
||||
h2('a', {href: '#',
|
||||
onclick: function (e: Event) {
|
||||
alert('you are 1,000,000th visitor!')
|
||||
e.preventDefault()
|
||||
}
|
||||
}, "Click this")
|
||||
|
||||
h2.cleanup()
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for hyperscript
|
||||
// Project: https://github.com/dominictarr/hyperscript
|
||||
// Definitions by: Mike Linkovich <https://github.com/spacejack>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'hyperscript' {
|
||||
|
||||
interface HyperScript {
|
||||
/** Creates an HTML element */
|
||||
(tagName: string, ...args: any[]): HTMLElement;
|
||||
/** Cleans up any event handlers created by this hyperscript context */
|
||||
cleanup(): void;
|
||||
/** Creates a new hyperscript context */
|
||||
context(): HyperScript;
|
||||
}
|
||||
|
||||
const h: HyperScript;
|
||||
export = h;
|
||||
}
|
||||
@@ -904,6 +904,23 @@ describe("Custom matcher: 'toBeGoofy'", function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Randomize Tests", function() {
|
||||
it("should allow randomization of the order of tests", function() {
|
||||
expect(function() {
|
||||
var env = jasmine.getEnv();
|
||||
return env.randomizeTests(true);
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it("should allow a seed to be passed in for randomization", function() {
|
||||
expect(function() {
|
||||
var env = jasmine.getEnv();
|
||||
env.randomizeTests(true);
|
||||
return env.seed(1234);
|
||||
}).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
(() => {
|
||||
// from boot.js
|
||||
var env = jasmine.getEnv();
|
||||
|
||||
Vendored
+38
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Jasmine 2.2
|
||||
// Type definitions for Jasmine 2.5
|
||||
// Project: http://jasmine.github.io/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Theodore Brown <https://github.com/theodorejb>, David Pärsson <https://github.com/davidparsson/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -65,6 +65,7 @@ declare namespace jasmine {
|
||||
function addMatchers(matchers: CustomMatcherFactories): void;
|
||||
function stringMatching(str: string): Any;
|
||||
function stringMatching(str: RegExp): Any;
|
||||
function formatErrorMsg(domain: string, usage: string) : (msg: string) => string
|
||||
|
||||
interface Any {
|
||||
|
||||
@@ -115,6 +116,7 @@ declare namespace jasmine {
|
||||
/** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
|
||||
tick(ms: number): void;
|
||||
mockDate(date?: Date): void;
|
||||
withMock(func: () => void): void;
|
||||
}
|
||||
|
||||
interface CustomEqualityTester {
|
||||
@@ -180,6 +182,12 @@ declare namespace jasmine {
|
||||
addMatchers(matchers: CustomMatcherFactories): void;
|
||||
specFilter(spec: Spec): boolean;
|
||||
throwOnExpectationFailure(value: boolean): void;
|
||||
seed(seed: string | number): string | number;
|
||||
provideFallbackReporter(reporter: Reporter): void;
|
||||
throwingExpectationFailures(): boolean;
|
||||
allowRespy(allow: boolean): void;
|
||||
randomTests(): boolean;
|
||||
randomizeTests(b: boolean): void;
|
||||
}
|
||||
|
||||
interface FakeTimer {
|
||||
@@ -234,6 +242,26 @@ declare namespace jasmine {
|
||||
trace: Trace;
|
||||
}
|
||||
|
||||
interface Order {
|
||||
new (options: {random: boolean, seed: string}): any;
|
||||
random: boolean;
|
||||
seed: string;
|
||||
sort<T>(items: T[]) : T[];
|
||||
}
|
||||
|
||||
namespace errors {
|
||||
class ExpectationFailed extends Error {
|
||||
constructor();
|
||||
stack: any;
|
||||
}
|
||||
}
|
||||
|
||||
interface TreeProcessor {
|
||||
new (attrs: any): any;
|
||||
execute: (done: Function) => void;
|
||||
processTree() : any;
|
||||
}
|
||||
|
||||
interface Trace {
|
||||
name: string;
|
||||
message: string;
|
||||
@@ -301,7 +329,9 @@ declare namespace jasmine {
|
||||
toHaveBeenCalledTimes(expected: number): boolean;
|
||||
toContain(expected: any, expectationFailOutput?: any): boolean;
|
||||
toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeLessThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeGreaterThanOrEqual(expected: number, expectationFailOutput?: any): boolean;
|
||||
toBeCloseTo(expected: number, precision?: any, expectationFailOutput?: any): boolean;
|
||||
toThrow(expected?: any): boolean;
|
||||
toThrowError(message?: string | RegExp): boolean;
|
||||
@@ -371,6 +401,7 @@ declare namespace jasmine {
|
||||
runs(func: SpecFunction): Spec;
|
||||
addToQueue(block: Block): void;
|
||||
addMatcherResult(result: Result): void;
|
||||
getResult(): any;
|
||||
expect(actual: any): any;
|
||||
waits(timeout: number): Spec;
|
||||
waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
|
||||
@@ -380,11 +411,12 @@ declare namespace jasmine {
|
||||
finishCallback(): void;
|
||||
finish(onComplete?: () => void): void;
|
||||
after(doAfter: SpecFunction): void;
|
||||
execute(onComplete?: () => void): any;
|
||||
execute(onComplete?: () => void, enabled?: boolean): any;
|
||||
addBeforesAndAftersToQueue(): void;
|
||||
explodes(): void;
|
||||
spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
|
||||
removeAllSpies(): void;
|
||||
throwOnExpectationFailure: boolean;
|
||||
}
|
||||
|
||||
interface XSpec {
|
||||
@@ -484,6 +516,10 @@ declare namespace jasmine {
|
||||
finished: boolean;
|
||||
result: any;
|
||||
messages: any;
|
||||
runDetails: {
|
||||
failedExpectations: ExpectationResult[];
|
||||
order: jasmine.Order
|
||||
}
|
||||
|
||||
new (): any;
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/// <reference path="jquery-alertable.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
//
|
||||
// Examples from https://github.com/claviska/jquery-alertable
|
||||
//
|
||||
|
||||
function example_alerts_tests() {
|
||||
|
||||
// Basic example
|
||||
$.alertable.alert('Howdy!');
|
||||
|
||||
// Example with action when the modal is dismissed
|
||||
$.alertable.alert('Howdy!').always(function() {
|
||||
// Modal was dismissed
|
||||
});
|
||||
}
|
||||
|
||||
function example_confirmations_tests() {
|
||||
|
||||
// Basic example
|
||||
$.alertable.confirm('You sure?').then(function() {
|
||||
// OK was selected
|
||||
});
|
||||
|
||||
// Example with then/always
|
||||
$.alertable.confirm('You sure?').then(function() {
|
||||
// OK was selected
|
||||
}, function() {
|
||||
// Cancel was selected
|
||||
}).always(function() {
|
||||
// Modal was dismissed
|
||||
});
|
||||
}
|
||||
|
||||
function example_prompts_tests() {
|
||||
|
||||
// Basic example
|
||||
$.alertable.prompt('How many?').then(function(data) {
|
||||
// Prompt was submitted
|
||||
});
|
||||
|
||||
// Example with then/always
|
||||
$.alertable.prompt('How many?').then(function(data) {
|
||||
// Prompt was submitted
|
||||
}, function() {
|
||||
// Prompt was canceled
|
||||
}).always(function() {
|
||||
// Modal was dismissed
|
||||
});
|
||||
}
|
||||
|
||||
function options_tests() {
|
||||
$.alertable.alert('Howdy!', {
|
||||
container: 'body',
|
||||
html: false,
|
||||
cancelButton: '<button class="alertable-cancel" type="button">Cancel</button>',
|
||||
okButton: '<button class="alertable-ok" type="button">OK</button>',
|
||||
overlay: '<div class="alertable-overlay"></div>',
|
||||
prompt: '<input class="alertable-input" type="text" name="value">',
|
||||
modal: `<form class="alertable">
|
||||
<div class="alertable-message"></div>
|
||||
<div class="alertable-prompt"></div>
|
||||
<div class="alertable-buttons"></div>
|
||||
</form>`,
|
||||
hide: () => $(this.modal).add(this.overlay).fadeOut(100),
|
||||
show: () => $(this.modal).add(this.overlay).fadeIn(100)
|
||||
});
|
||||
|
||||
$.alertable.confirm('You sure?', {
|
||||
container: 'body'
|
||||
});
|
||||
|
||||
$.alertable.prompt('How many?', {
|
||||
container: 'body'
|
||||
});
|
||||
|
||||
$.alertable.defaults.container = 'body';
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// Type definitions for jquery-alertable 1.0.2
|
||||
// Project: https://github.com/claviska/jquery-alertable
|
||||
// Definitions by: Steven Robertson <https://github.com/stever>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
|
||||
interface JQueryStatic {
|
||||
alertable: Alertable;
|
||||
}
|
||||
|
||||
interface Alertable {
|
||||
alert(message: string, options?: AlertableOptions): JQueryPromise<void>;
|
||||
confirm(message: string, options?: AlertableOptions): JQueryPromise<void>;
|
||||
prompt(message: string, options?: AlertableOptions): JQueryPromise<void>;
|
||||
defaults: AlertableOptions;
|
||||
}
|
||||
|
||||
interface AlertableOptions {
|
||||
container?: string;
|
||||
html?: boolean;
|
||||
cancelButton?: string;
|
||||
okButton?: string;
|
||||
overlay?: string;
|
||||
prompt?: string;
|
||||
modal?: string;
|
||||
hide?: Function;
|
||||
show?: Function;
|
||||
}
|
||||
+7
@@ -902,6 +902,13 @@ declare namespace DataTables {
|
||||
* @param d Data to use for the row.
|
||||
*/
|
||||
data(d: any[] | Object): DataTable;
|
||||
|
||||
/**
|
||||
* Get the id of the selected row.
|
||||
*
|
||||
* @param hash Set to true to append a hash (#) to the start of the row id.
|
||||
*/
|
||||
id(hash?: boolean): string;
|
||||
|
||||
/**
|
||||
* Get the row index of the row column.
|
||||
|
||||
Vendored
+27
-24
@@ -19,34 +19,37 @@ add methods:
|
||||
- [ ] noConflict
|
||||
*/
|
||||
|
||||
interface Base64 {
|
||||
/**
|
||||
* .encode
|
||||
* @param {String} string
|
||||
* @return {String}
|
||||
*/
|
||||
encode(base64: string): string;
|
||||
declare namespace Base64 {
|
||||
const Base64: Base64Static
|
||||
interface Base64Static {
|
||||
/**
|
||||
* .encode
|
||||
* @param {String} string
|
||||
* @return {String}
|
||||
*/
|
||||
encode(base64: string): string;
|
||||
|
||||
/**
|
||||
* .encodeURI
|
||||
* @param {String} string
|
||||
* @return {String}
|
||||
*/
|
||||
encodeURI(base64: string): string
|
||||
/**
|
||||
* .encodeURI
|
||||
* @param {String} string
|
||||
* @return {String}
|
||||
*/
|
||||
encodeURI(base64: string): string
|
||||
|
||||
/**
|
||||
* .decode
|
||||
* @param {String} string
|
||||
* @return {String}
|
||||
*/
|
||||
decode(base64: string): string
|
||||
/**
|
||||
* .decode
|
||||
* @param {String} string
|
||||
* @return {String}
|
||||
*/
|
||||
decode(base64: string): string
|
||||
|
||||
/**
|
||||
* Library version
|
||||
*/
|
||||
VERSION:string
|
||||
/**
|
||||
* Library version
|
||||
*/
|
||||
VERSION:string
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'js-base64' {
|
||||
const Base64: Base64
|
||||
export = Base64
|
||||
}
|
||||
Vendored
+9
@@ -1529,6 +1529,15 @@ declare namespace kendo.drawing.pdf {
|
||||
}
|
||||
|
||||
declare namespace kendo.ui {
|
||||
class AgendaView implements kendo.ui.SchedulerView {
|
||||
static fn: AgendaView;
|
||||
|
||||
startDate(): Date;
|
||||
endDate(): Date;
|
||||
|
||||
static extend(proto: Object): AgendaView;
|
||||
}
|
||||
|
||||
class Alert extends kendo.ui.Widget {
|
||||
|
||||
static fn: Alert;
|
||||
|
||||
Vendored
+10
-12
@@ -815,36 +815,34 @@ declare namespace L {
|
||||
* Represents a GeoJSON object or an array of GeoJSON objects.
|
||||
* Allows you to parse GeoJSON data and display it on the map. Extends FeatureGroup.
|
||||
*/
|
||||
export interface GeoJSON extends FeatureGroup {}
|
||||
|
||||
export namespace GeoJSON {
|
||||
export interface GeoJSON extends FeatureGroup {
|
||||
/**
|
||||
* Adds a GeoJSON object to the layer.
|
||||
*/
|
||||
export function addData(data: Object): Layer;
|
||||
addData(data: Object): Layer;
|
||||
|
||||
/**
|
||||
* Resets the given vector layer's style to the original GeoJSON style,
|
||||
* useful for resetting style after hover events.
|
||||
*/
|
||||
export function resetStyle(layer: Layer): Layer;
|
||||
resetStyle(layer: Layer): Layer;
|
||||
|
||||
/**
|
||||
* Changes styles of GeoJSON vector layers with the given style function.
|
||||
*/
|
||||
export function setStyle(style: PathOptions | StyleFunction): Layer;
|
||||
setStyle(style: PathOptions | StyleFunction): this;
|
||||
|
||||
/**
|
||||
* Creates a Layer from a given GeoJSON feature. Can use a custom pointToLayer
|
||||
* and/or coordsToLatLng functions if provided as options.
|
||||
*/
|
||||
export function geometryToLayer(featureData: Object, options?: GeoJSONOptions): Layer;
|
||||
geometryToLayer(featureData: Object, options?: GeoJSONOptions): Layer;
|
||||
|
||||
/**
|
||||
* Creates a LatLng object from an array of 2 numbers (longitude, latitude) or
|
||||
* 3 numbers (longitude, latitude, altitude) used in GeoJSON for points.
|
||||
*/
|
||||
export function coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng;
|
||||
coordsToLatLng(coords: [number, number] | [number, number, number]): LatLng;
|
||||
|
||||
/**
|
||||
* Creates a multidimensional array of LatLngs from a GeoJSON coordinates array.
|
||||
@@ -852,24 +850,24 @@ declare namespace L {
|
||||
* arrays of points, etc., 0 by default).
|
||||
* Can use a custom coordsToLatLng function.
|
||||
*/
|
||||
export function coordsToLatLngs(coords: Array<number>, levelsDeep?: number, coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): LatLng[]; // Not entirely sure how to define arbitrarily nested arrays
|
||||
coordsToLatLngs(coords: Array<number>, levelsDeep?: number, coordsToLatLng?: (coords: [number, number] | [number, number, number]) => LatLng): LatLng[]; // Not entirely sure how to define arbitrarily nested arrays
|
||||
|
||||
/**
|
||||
* Reverse of coordsToLatLng
|
||||
*/
|
||||
export function latLngToCoords(latlng: LatLng): [number, number] | [number, number, number];
|
||||
latLngToCoords(latlng: LatLng): [number, number] | [number, number, number];
|
||||
|
||||
/**
|
||||
* Reverse of coordsToLatLngs closed determines whether the first point should be
|
||||
* appended to the end of the array to close the feature, only used when levelsDeep is 0.
|
||||
* False by default.
|
||||
*/
|
||||
export function latLngsToCoords(latlngs: Array<LatLng>, levelsDeep?: number, closed?: boolean): [number, number] | [number, number, number];
|
||||
latLngsToCoords(latlngs: Array<LatLng>, levelsDeep?: number, closed?: boolean): [number, number] | [number, number, number];
|
||||
|
||||
/**
|
||||
* Normalize GeoJSON geometries/features into GeoJSON features.
|
||||
*/
|
||||
export function asFeature(geojson: Object): Object;
|
||||
asFeature(geojson: Object): Object;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/// <reference path="localforage-cordovasqlitedriver.d.ts" />
|
||||
|
||||
declare var cordovaSQLiteDriver: LocalForageDriver;
|
||||
|
||||
() => {
|
||||
|
||||
var driverName: string = cordovaSQLiteDriver._driver;
|
||||
|
||||
var config = {
|
||||
driver: driverName,
|
||||
name: 'localforage'
|
||||
};
|
||||
|
||||
cordovaSQLiteDriver._initStorage(config);
|
||||
|
||||
cordovaSQLiteDriver.clear((err: any) => {
|
||||
var newError: any = err;
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.length((err: any, num: number) => {
|
||||
var newError: any = err;
|
||||
var newNumber: number = num;
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.key(0, (err: any, value: string) => {
|
||||
var newError: any = err;
|
||||
var newValue: string = value;
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.keys((err: any, keys: Array<string>) => {
|
||||
var newError: any = err;
|
||||
var newArray: Array<string> = keys;
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.getItem("key",(err: any, str: string) => {
|
||||
var newError: any = err;
|
||||
var newStr: string = str
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.setItem("key", "value", (err: any, str: string) => {
|
||||
var newError: any = err;
|
||||
var newStr: string = str
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.setItem("key", "value", (str: string) => {
|
||||
var newStr: string = str;
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.removeItem("key",(err: any) => {
|
||||
var newError: any = err;
|
||||
});
|
||||
|
||||
cordovaSQLiteDriver.removeItem("key", (err: any) => {
|
||||
var newError: any = err;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Type definitions for localforage-cordovasqlitedriver module v1.0+
|
||||
// Project: https://github.com/thgreasi/localForage-cordovaSQLiteDriver
|
||||
// Definitions by: Thodoris Greasidis <https://github.com/thgreasi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../localForage/localForage.d.ts" />
|
||||
|
||||
declare module "localforage-cordovasqlitedriver" {
|
||||
var cordovaSQLiteDriver: LocalForageDriver;
|
||||
export = cordovaSQLiteDriver;
|
||||
}
|
||||
@@ -141,6 +141,14 @@ result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).splice(1);
|
||||
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).splice(1, 2, 5, 6);
|
||||
result = <_.LoDashImplicitArrayWrapper<number>>_([1, 2, 3, 4]).unshift(5, 6);
|
||||
|
||||
result = <_.LoDashExplicitObjectWrapper<number>>_.chain([1, 2, 3, 4]).pop();
|
||||
result = <_.LoDashExplicitArrayWrapper<number>>_.chain([1, 2, 3, 4]).push(5, 6, 7);
|
||||
result = <_.LoDashExplicitObjectWrapper<number>>_.chain([1, 2, 3, 4]).shift();
|
||||
result = <_.LoDashExplicitArrayWrapper<number>>_.chain([1, 2, 3, 4]).sort((a, b) => 1);
|
||||
result = <_.LoDashExplicitArrayWrapper<number>>_.chain([1, 2, 3, 4]).splice(1);
|
||||
result = <_.LoDashExplicitArrayWrapper<number>>_.chain([1, 2, 3, 4]).splice(1, 2, 5, 6);
|
||||
result = <_.LoDashExplicitArrayWrapper<number>>_.chain([1, 2, 3, 4]).unshift(5, 6);
|
||||
|
||||
/*********
|
||||
* Array *
|
||||
*********/
|
||||
|
||||
Vendored
+9
-1
@@ -384,7 +384,15 @@ declare module _ {
|
||||
unshift(...items: T[]): LoDashImplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashExplicitArrayWrapper<T> extends LoDashExplicitWrapperBase<T[], LoDashExplicitArrayWrapper<T>> { }
|
||||
interface LoDashExplicitArrayWrapper<T> extends LoDashExplicitWrapperBase<T[], LoDashExplicitArrayWrapper<T>> {
|
||||
pop(): LoDashExplicitObjectWrapper<T>;
|
||||
push(...items: T[]): LoDashExplicitArrayWrapper<T>;
|
||||
shift(): LoDashExplicitObjectWrapper<T>;
|
||||
sort(compareFn?: (a: T, b: T) => number): LoDashExplicitArrayWrapper<T>;
|
||||
splice(start: number): LoDashExplicitArrayWrapper<T>;
|
||||
splice(start: number, deleteCount: number, ...items: any[]): LoDashExplicitArrayWrapper<T>;
|
||||
unshift(...items: T[]): LoDashExplicitArrayWrapper<T>;
|
||||
}
|
||||
|
||||
interface LoDashImplicitNumberArrayWrapper extends LoDashImplicitArrayWrapper<number> { }
|
||||
|
||||
|
||||
Vendored
+1
@@ -759,6 +759,7 @@ declare namespace __MaterialUI {
|
||||
namespace Card {
|
||||
|
||||
interface CardProps extends React.Props<Card> {
|
||||
className?: string;
|
||||
actAsExpander?: boolean;
|
||||
containerStyle?: React.CSSProperties;
|
||||
expandable?: boolean;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// Type definitions for moment-duration-format v1.3.0
|
||||
// Project: https://github.com/jsmreese/moment-duration-format
|
||||
// Definitions by: Swint De Coninck <https://github.com/SwintDC>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare namespace moment {
|
||||
interface Duration {
|
||||
format(template: string, precision?: string, settings?: any): string;
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -696,7 +696,7 @@ declare module "mongoose" {
|
||||
/** defaults to true */
|
||||
validateBeforeSave?: boolean;
|
||||
/** defaults to "__v" */
|
||||
versionKey?: boolean;
|
||||
versionKey?: string;
|
||||
/**
|
||||
* skipVersioning allows excluding paths from
|
||||
* versioning (the internal revision will not be
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
/// <reference path="msgpack-lite.d.ts" />
|
||||
import * as msgpack from "msgpack-lite";
|
||||
|
||||
var encoded = msgpack.encode("");
|
||||
msgpack.decode(encoded);
|
||||
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
// Type definitions for msgpack-lite 0.1.20
|
||||
// Project: https://github.com/kawanet/msgpack-lite
|
||||
// Definitions by: Endel Dreyer <https://github.com/endel/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
declare module "msgpack-lite" {
|
||||
import { Transform } from "stream";
|
||||
|
||||
namespace MsgpackLite {
|
||||
interface BufferOptions { codec: any; }
|
||||
|
||||
interface Encoder {
|
||||
bufferish: any;
|
||||
maxBufferSize: number;
|
||||
minBufferSize: number;
|
||||
offset: number;
|
||||
start: number;
|
||||
write: (chunk: any) => void;
|
||||
fetch: () => void;
|
||||
flush: () => void;
|
||||
push: (chunk: any) => void;
|
||||
pull: () => number;
|
||||
read: () => number;
|
||||
reserve: (length: number) => number;
|
||||
send: (buffer: Buffer) => void;
|
||||
encode: (chunk: any) => void;
|
||||
end: (chunk: any) => void;
|
||||
}
|
||||
|
||||
interface Decoder {
|
||||
bufferish: any;
|
||||
offset: number;
|
||||
fetch: () => void;
|
||||
flush: () => void;
|
||||
pull: () => number;
|
||||
read: () => number;
|
||||
write: (chunk: any) => void;
|
||||
reserve: (length: number) => number;
|
||||
decode: (chunk: any) => void;
|
||||
push: (chunk: any) => void;
|
||||
end: (chunk: any) => void;
|
||||
}
|
||||
|
||||
interface EncodeStream extends Transform {
|
||||
encoder: Encoder;
|
||||
}
|
||||
interface DecodeStream extends Transform {
|
||||
decoder: Decoder;
|
||||
}
|
||||
|
||||
interface Codec {
|
||||
new (options?: any): Codec;
|
||||
options: any;
|
||||
init (): void;
|
||||
}
|
||||
|
||||
export function encode(input: any, options?: BufferOptions): any;
|
||||
export function decode(input: Buffer | Uint8Array | Array<number>, options?: BufferOptions): any;
|
||||
export function createEncodeStream (): EncodeStream;
|
||||
export function createDecodeStream (): DecodeStream;
|
||||
export function createCodec (options?: any): Codec;
|
||||
export function codec (): { preset: Codec };
|
||||
}
|
||||
|
||||
export = MsgpackLite;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
///<reference path="ngeohash.d.ts"/>
|
||||
|
||||
import geohash = require('ngeohash');
|
||||
|
||||
console.log(geohash.encode(37.8324, 112.5584));
|
||||
// prints ww8p1r4t8
|
||||
|
||||
var latlon = geohash.decode('ww8p1r4t8');
|
||||
console.log(latlon.latitude);
|
||||
console.log(latlon.longitude);
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// Type definitions for ngeohash v0.6.0
|
||||
// Project: https://github.com/sunng87/node-geohash
|
||||
// Definitions by: Erik Rothoff Andersson <https://github.com/erkie>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/
|
||||
|
||||
declare namespace ngeohash {
|
||||
interface GeographicPoint {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
type GeographicBoundingBox = [number, number, number, number];
|
||||
type NSEW = [number, number];
|
||||
|
||||
function encode(latitude: number, longitude: number, precision?: number): string;
|
||||
function decode(hashstring: string): GeographicPoint;
|
||||
function decode_bbox(hashstring: string): GeographicBoundingBox;
|
||||
function bboxes(minlat: number, minlon: number, maxlat: number, maxlon: number, precision?: number): Array<string>;
|
||||
function neighbor(hashstring: string, direction: NSEW): string;
|
||||
function neighbors(hashstring: string): Array<string>;
|
||||
|
||||
function encode_int(latitude: number, longitude: number, bitDepth?: number): number;
|
||||
function decode_int(hashinteger: number, bitDepth?: number): GeographicPoint;
|
||||
function decode_bbox_int(hashinteger: number, bitDepth?: number): GeographicBoundingBox;
|
||||
function bboxes_int(minlat: number, minlon: number, maxlat: number, maxlon: number, bitDepth?: number): number;
|
||||
function neighbor_int(hashinteger: number, direction: NSEW, bitDepth?: number): number;
|
||||
function neighbors_int(hashinteger: number, bitDepth?: number): number;
|
||||
}
|
||||
|
||||
declare module "ngeohash" {
|
||||
export = ngeohash;
|
||||
}
|
||||
@@ -21,13 +21,13 @@ function test_configuration() {
|
||||
});
|
||||
|
||||
NProgress.configure({
|
||||
ease: 'ease',
|
||||
easing: 'ease',
|
||||
minimum: 0.09,
|
||||
showSpinner: false,
|
||||
speed: 420,
|
||||
template: "<div>blah</div>",
|
||||
trickle: false,
|
||||
trickleRate: 0.42,
|
||||
trickleSpeed: 42
|
||||
trickleSpeed: 42,
|
||||
parent: 'body',
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+7
-7
@@ -68,16 +68,16 @@ interface NProgressStatic {
|
||||
|
||||
interface NProgressConfigureOptions {
|
||||
|
||||
/**
|
||||
* CSS selector to change the parent DOM element of the progress. Default is body.
|
||||
*/
|
||||
parent?: string
|
||||
|
||||
/**
|
||||
* The minimum progress percentage. Default is 0.08.
|
||||
*/
|
||||
minimum?: number;
|
||||
|
||||
/**
|
||||
* How much to increase per trickle. Example: .02. Default is true.
|
||||
*/
|
||||
trickleRate?: number;
|
||||
|
||||
/**
|
||||
* How often to trickle, in milliseconds. Default is 800.
|
||||
*/
|
||||
@@ -94,9 +94,9 @@ interface NProgressConfigureOptions {
|
||||
trickle?: boolean;
|
||||
|
||||
/**
|
||||
* The CSS easing animation to use. Default is 'ease'.
|
||||
* The CSS easing animation to use. Default is 'linear'.
|
||||
*/
|
||||
ease?: string;
|
||||
easing?: string;
|
||||
|
||||
/**
|
||||
* The animation speed in milliseconds. Default is 200.
|
||||
|
||||
Vendored
+25
-10
@@ -75,10 +75,6 @@ declare namespace Office {
|
||||
* @param callback Optional. Accepts a callback method to handle the dialog creation attempt.
|
||||
*/
|
||||
displayDialogAsync(startAddress: string, options?: DialogOptions, callback?: (result: AsyncResult) => void): void;
|
||||
/**
|
||||
* When called from an active add-in dialog, asynchronously closes the dialog.
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Synchronously delivers a message from the dialog to its parent add-in.
|
||||
* @param messageObject Accepts a message from the dialog to deliver to the add-in.
|
||||
@@ -94,15 +90,26 @@ declare namespace Office {
|
||||
* Optional. Defines the height of the dialog as a percentage of the current display. Defaults to 99%. 150px minimum.
|
||||
*/
|
||||
width?: number,
|
||||
/**
|
||||
* Optional. Specifies whether the dialog can only display pages that have HTTPS URLs.
|
||||
*/
|
||||
requireHTTPS?: boolean,
|
||||
/**
|
||||
* Optional. Determines whether the dialog is safe to display within a Web frame.
|
||||
*/
|
||||
xFrameDenySafe?: boolean,
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog object returned as part of the displayDialogAsync callback. The object exposes methods for registering event handlers and closing the dialog
|
||||
*/
|
||||
export interface DialogHandler {
|
||||
/**
|
||||
* When called from an active add-in dialog, asynchronously closes the dialog.
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Adds an event handler for DialogMessageReceived or DialogEventReceived
|
||||
*/
|
||||
addEventHandler(eventType: Office.EventType, handler: Function): void;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
declare module OfficeExtension {
|
||||
@@ -130,7 +137,7 @@ declare module OfficeExtension {
|
||||
load(object: ClientObject, option?: string | string[] | LoadOption): void;
|
||||
/** Adds a trace message to the queue. If the promise returned by "context.sync()" is rejected due to an error, this adds a ".traceMessages" array to the OfficeExtension.Error object, containing all trace messages that were executed. These messages can help you monitor the program execution sequence and detect the cause of the error. */
|
||||
trace(message: string): void;
|
||||
/** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code. This method returns a promise, which is resolved when the synchronization is complete. */
|
||||
/** Synchronizes the state between JavaScript proxy objects and the Office document, by executing instructions queued on the request context and retrieving properties of loaded Office objects for use in your code. This method returns a promise, which is resolved when the synchronization is complete. */
|
||||
sync<T>(passThroughValue?: T): IPromise<T>;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +265,7 @@ declare module OfficeExtension {
|
||||
/**
|
||||
* Creates a new promise based on a function that accepts resolve and reject handlers.
|
||||
*/
|
||||
constructor(func: (resolve : (value?: R | IPromise<R>) => void, reject: (error?: any) => void) => void);
|
||||
constructor(func: (resolve: (value?: R | IPromise<R>) => void, reject: (error?: any) => void) => void);
|
||||
|
||||
/**
|
||||
* Creates a promise that resolves when all of the child promises resolve.
|
||||
@@ -462,6 +469,14 @@ declare namespace Office {
|
||||
* Triggers when a binding level selection happens
|
||||
*/
|
||||
BindingSelectionChanged,
|
||||
/**
|
||||
* Triggers when Dialog sends a message via MessageParent.
|
||||
*/
|
||||
DialogMessageReceived,
|
||||
/**
|
||||
* Triggers when Dialog has a event, such as dialog closed, dialog navigation failed.
|
||||
*/
|
||||
DialogEventReceived,
|
||||
/**
|
||||
* Triggers when a document level selection happens
|
||||
*/
|
||||
|
||||
@@ -60,5 +60,6 @@ fragment.quirksMode = true;
|
||||
fragment.namespaceURI = '';
|
||||
fragment.nodeName = '';
|
||||
fragment.value = '';
|
||||
fragment.data = '';
|
||||
fragment = fragment.childNodes[0];
|
||||
fragment = fragment.parentNode;
|
||||
|
||||
Vendored
+1
@@ -56,6 +56,7 @@ declare module 'parse5' {
|
||||
export interface ASTNode {
|
||||
attrs: ASTAttribute[];
|
||||
childNodes?: ASTNode[];
|
||||
data?: string;
|
||||
namespaceURI?: string;
|
||||
parentNode?: ASTNode;
|
||||
nodeName: string;
|
||||
|
||||
@@ -108,7 +108,8 @@ strPar = P.regex(regex);
|
||||
fooPar = P.succeed(foo);
|
||||
|
||||
fooArrPar = P.seq(fooPar, fooPar);
|
||||
anyArrPar = P.seq(barPar, fooPar, numPar);
|
||||
var par: Parser<[Bar, Foo, number]> = P.seq(barPar, fooPar, numPar);
|
||||
var par2: Parser<number> = P.seq(barPar, fooPar, numPar).map(([a, b, c]: [Bar, Foo, number]) => 42);
|
||||
|
||||
fooPar = P.custom<Foo>((success, failure) => (stream, i) => { str = stream; num = i; return success(num, foo); });
|
||||
fooPar = P.custom<Foo>((success, failure) => (stream, i) => failure(num, str));
|
||||
@@ -139,3 +140,33 @@ strPar = P.any;
|
||||
strPar = P.all;
|
||||
voidPar = P.eof;
|
||||
numPar = P.index;
|
||||
|
||||
// -- -- -- -- -- -- -- -- -- -- -- -- --
|
||||
|
||||
bool = P.isParser(numPar);
|
||||
bool = P.isParser(null);
|
||||
bool = P.isParser(42);
|
||||
|
||||
strPar = P.oneOf('a');
|
||||
strPar = P.noneOf('a');
|
||||
|
||||
strPar = P.regex(/foo/);
|
||||
strPar = P.regex(/foo/, 3);
|
||||
strPar = P.regexp(/bar/);
|
||||
strPar = P.regexp(/bar/, 3);
|
||||
|
||||
fooPar = P.of(foo);
|
||||
|
||||
str = P.formatError('foo', strPar.parse('bar'));
|
||||
|
||||
strPar = P.seqMap(P.digit, (a: string) => 'foo');
|
||||
numPar = P.seqMap(P.digit, P.digits, (a: string, b: string) => 42);
|
||||
strPar = P.seqMap(P.digit, P.digits, P.letter, (a: string, b: string, c: string) => 'foo');
|
||||
strPar = P.seqMap(P.digit, P.digits, P.letter, P.letters.map(Number), (a: string, b: string, c: string, d: number) => 'foo');
|
||||
|
||||
strPar = P.sepBy(P.string('foo'), P.string('bar'));
|
||||
strPar = P.sepBy1(P.string('foo'), P.string('bar'));
|
||||
|
||||
strPar = P.test((a: string) => false);
|
||||
|
||||
strPar = P.takeWhile((a: string) => true);
|
||||
Vendored
+152
-71
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Parsimmon 0.5.0
|
||||
// Type definitions for Parsimmon 0.9.2
|
||||
// Project: https://github.com/jneen/parsimmon
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Mizunashi Mana <https://github.com/mizunashi-mana>
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Mizunashi Mana <https://github.com/mizunashi-mana>, Boris Cherny <https://github.com/bcherny>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TODO convert to generics
|
||||
@@ -24,153 +24,234 @@ declare module 'parsimmon' {
|
||||
}
|
||||
|
||||
export interface Parser<T> {
|
||||
/*
|
||||
parse the string
|
||||
/**
|
||||
* parse the string
|
||||
*/
|
||||
parse(input: string): Result<T>;
|
||||
/*
|
||||
returns a new parser which tries parser, and if it fails uses otherParser.
|
||||
/**
|
||||
* returns a new parser which tries parser, and if it fails uses otherParser.
|
||||
*/
|
||||
or(otherParser: Parser<T>): Parser<T>;
|
||||
or<U>(otherParser: Parser<U>): Parser<any>;
|
||||
/*
|
||||
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
|
||||
/**
|
||||
* 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 with the result of the parse, which is expected to return another parser.
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
then<U>(call: (result: T) => Parser<U>): Parser<U>;
|
||||
/*
|
||||
expects anotherParser to follow parser, and yields the result of anotherParser. NB: the result of parser here is ignored.
|
||||
/**
|
||||
* expects anotherParser to follow parser, and yields the result of anotherParser.
|
||||
* NB: the result of parser here is ignored.
|
||||
*/
|
||||
then<U>(anotherParser: Parser<U>): Parser<U>;
|
||||
/*
|
||||
transforms the output of parser with the given function.
|
||||
/**
|
||||
* transforms the output of parser with the given function.
|
||||
*/
|
||||
map<U>(call: (result: T) => U): Parser<U>;
|
||||
/*
|
||||
expects otherParser after parser, but preserves the yield value of parser.
|
||||
/**
|
||||
* expects otherParser after parser, but preserves the yield value of parser.
|
||||
*/
|
||||
skip<U>(otherParser: Parser<U>): Parser<T>;
|
||||
/*
|
||||
returns a new parser with the same behavior, but which yields aResult.
|
||||
/**
|
||||
* returns a new parser with the same behavior, but which yields aResult.
|
||||
*/
|
||||
result<U>(aResult: U): Parser<U>;
|
||||
/*
|
||||
expects parser zero or more times, and yields an array of the results.
|
||||
/**
|
||||
* expects parser zero or more times, and yields an array of the results.
|
||||
*/
|
||||
many(): Parser<T[]>;
|
||||
/*
|
||||
expects parser exactly n times, and yields an array of the results.
|
||||
/**
|
||||
* expects parser exactly n times, and yields an array of the results.
|
||||
*/
|
||||
times(n: number): Parser<T[]>;
|
||||
/*
|
||||
expects parser between min and max times, and yields an array of the results.
|
||||
/**
|
||||
* expects parser between min and max times, and yields an array of the results.
|
||||
*/
|
||||
times(min: number, max: number): Parser<T[]>;
|
||||
/*
|
||||
expects parser at most n times. Yields an array of the results.
|
||||
/**
|
||||
* expects parser at most n times. Yields an array of the results.
|
||||
*/
|
||||
atMost(n: number): Parser<T[]>;
|
||||
/*
|
||||
expects parser at least n times. Yields an array of the results.
|
||||
/**
|
||||
* expects parser at least n times. Yields an array of the results.
|
||||
*/
|
||||
atLeast(n: number): Parser<T[]>;
|
||||
/*
|
||||
returns a new parser whose failure message is the passed description.
|
||||
/**
|
||||
* returns a new parser whose failure message is the passed description.
|
||||
*/
|
||||
mark(): Parser<Mark<T>>;
|
||||
|
||||
/**
|
||||
* Returns a new parser whose failure message is description.
|
||||
* For example, string('x').desc('the letter x') will indicate that 'the letter x' was expected.
|
||||
*/
|
||||
desc(description: string): Parser<T>;
|
||||
}
|
||||
/*
|
||||
is a parser that expects to find "my-string", and will yield the same.
|
||||
*/
|
||||
export function string(mystring: string): Parser<string>;
|
||||
|
||||
/*
|
||||
is a parser that expects the stream to match the given regex.
|
||||
/**
|
||||
* Returns true if obj is a Parsimmon parser, otherwise false.
|
||||
*/
|
||||
export function regex(myregex: RegExp): Parser<string>;
|
||||
export function isParser(obj: any): boolean;
|
||||
|
||||
/*
|
||||
is a parser that doesn't consume any of the string, and yields result.
|
||||
/**
|
||||
* is a parser that expects to find "my-string", and will yield the same.
|
||||
*/
|
||||
export function string(string: string): Parser<string>;
|
||||
|
||||
/**
|
||||
* Returns a parser that looks for exactly one character from string, and yields that character.
|
||||
*/
|
||||
export function oneOf(string: string): Parser<string>;
|
||||
|
||||
/**
|
||||
* Returns a parser that looks for exactly one character NOT from string, and yields that character.
|
||||
*/
|
||||
export function noneOf(string: string): Parser<string>;
|
||||
|
||||
/**
|
||||
* Returns a parser that looks for a match to the regexp and yields the given match group
|
||||
* (defaulting to the entire match). The regexp will always match starting at the current
|
||||
* parse location. The regexp may only use the following flags: imu. Any other flag will
|
||||
* result in an error being thrown.
|
||||
*/
|
||||
export function regexp(myregex: RegExp, group?: number): Parser<string>;
|
||||
|
||||
/**
|
||||
* This was the original name for Parsimmon.regexp, but now it is just an alias.
|
||||
*/
|
||||
export function regex(myregex: RegExp, group?: number): Parser<string>;
|
||||
|
||||
/**
|
||||
* Returns a parser that doesn't consume any of the string, and yields result.
|
||||
*/
|
||||
export function succeed<U>(result: U): Parser<U>;
|
||||
|
||||
/*
|
||||
accepts a variable number of parsers that it expects to find in order, yielding an array of the results.
|
||||
/**
|
||||
* This is an alias for Parsimmon.succeed(result).
|
||||
*/
|
||||
export function seq<U>(...parsers: Parser<U>[]): Parser<U[]>;
|
||||
export function of<U>(result: U): Parser<U>;
|
||||
|
||||
/**
|
||||
* accepts a variable number of parsers that it expects to find in order, yielding an array of the results.
|
||||
*/
|
||||
export function seq<T>(p1: Parser<T>): Parser<[T]>;
|
||||
export function seq<T, U>(p1: Parser<T>, p2: Parser<U>): Parser<[T, U]>;
|
||||
export function seq<T, U, V>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>): Parser<[T, U, V]>;
|
||||
export function seq<T, U, V, W>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, p4: Parser<W>): Parser<[T, U, V, W]>;
|
||||
export function seq<T, U, V, W, X>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, p4: Parser<W>, p5: Parser<X>): Parser<[T, U, V, W, X]>;
|
||||
export function seq<T, U, V, W, X, Y>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, p4: Parser<W>, p5: Parser<X>, p6: Parser<Y>): Parser<[T, U, V, W, X, Y]>;
|
||||
export function seq<T, U, V, W, X, Y, Z>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, p4: Parser<W>, p5: Parser<X>, p6: Parser<Y>, p7: Parser<Z>): Parser<[T, U, V, W, X, Y, Z]>;
|
||||
export function seq<T>(...parsers: Parser<T>[]): Parser<T[]>;
|
||||
export function seq(...parsers: Parser<any>[]): Parser<any[]>;
|
||||
|
||||
/**
|
||||
* Takes the string passed to parser.parse(string) and the error returned from
|
||||
* parser.parse(string) and turns it into a human readable error message string.
|
||||
* Note that there are certainly better ways to format errors, so feel free to write your own.
|
||||
*/
|
||||
export function formatError<T>(string: string, error: Result<T>): string;
|
||||
|
||||
/**
|
||||
* Matches all parsers sequentially, and passes their results as the arguments to a function.
|
||||
* Similar to calling Parsimmon.seq and then .map, but the values are not put in an array.
|
||||
*/
|
||||
export function seqMap<T, U>(p1: Parser<T>, cb: (a1: T) => U): Parser<U>;
|
||||
export function seqMap<T, U, V>(p1: Parser<T>, p2: Parser<U>, cb: (a1: T, a2: U) => V): Parser<V>;
|
||||
export function seqMap<T, U, V, W>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, cb: (a1: T, a2: U, a3: V) => W): Parser<W>;
|
||||
export function seqMap<T, U, V, W, X>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, p4: Parser<W>, cb: (a1: T, a2: U, a3: V, a4: W) => X): Parser<X>;
|
||||
export function seqMap<T, U, V, W, X, Y>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, p4: Parser<W>, p5: Parser<X>, cb: (a1: T, a2: U, a3: V, a4: W, a5: X) => Y): Parser<Y>;
|
||||
export function seqMap<T, U, V, W, X, Y, Z>(p1: Parser<T>, p2: Parser<U>, p3: Parser<V>, p4: Parser<W>, p5: Parser<X>, p6: Parser<Y>, cb: (a1: T, a2: U, a3: V, a4: W, a5: X, a6: Y) => Z): Parser<Z>;
|
||||
|
||||
export type SuccessFunctionType<U> = (index: number, result: U) => Result<U>;
|
||||
export type FailureFunctionType<U> = (index: number, msg: string) => Result<U>;
|
||||
export type ParseFunctionType<U> = (stream: StreamType, index: number) => Result<U>;
|
||||
/*
|
||||
allows to add custom primitive parsers.
|
||||
/**
|
||||
* allows to add custom primitive parsers.
|
||||
*/
|
||||
export function custom<U>(parsingFunction: (success: SuccessFunctionType<U>, failure: FailureFunctionType<U>) => ParseFunctionType<U>): Parser<U>;
|
||||
|
||||
/*
|
||||
accepts a variable number of parsers, and yields the value of the first one that succeeds, backtracking in between.
|
||||
/**
|
||||
* accepts a variable number of parsers, and yields the value of the first one that succeeds,
|
||||
* backtracking in between.
|
||||
*/
|
||||
export function alt<U>(...parsers: Parser<U>[]): Parser<U>;
|
||||
export function alt(...parsers: Parser<any>[]): Parser<any>;
|
||||
|
||||
/*
|
||||
accepts a function that returns a parser, which is evaluated the first time the parser is used. This is useful for referencing parsers that haven't yet been defined.
|
||||
/**
|
||||
* Accepts two parsers, and expects zero or more matches for content, separated by separator, yielding an array.
|
||||
*/
|
||||
export function sepBy<T>(content: Parser<T>, separator: Parser<T>): Parser<T>
|
||||
|
||||
/**
|
||||
* This is the same as Parsimmon.sepBy, but matches the content parser at least once.
|
||||
*/
|
||||
export function sepBy1<T>(content: Parser<T>, separator: Parser<T>): Parser<T>
|
||||
|
||||
/**
|
||||
* accepts a function that returns a parser, which is evaluated the first time the parser is used.
|
||||
* This is useful for referencing parsers that haven't yet been defined.
|
||||
*/
|
||||
export function lazy<U>(f: () => Parser<U>): Parser<U>;
|
||||
export function lazy<U>(description: string, f: () => Parser<U>): Parser<U>;
|
||||
|
||||
/*
|
||||
fail paring with a message
|
||||
/**
|
||||
* fail paring with a message
|
||||
*/
|
||||
export function fail(message: string): Parser<void>;
|
||||
export function fail<U>(message: string): Parser<U>;
|
||||
|
||||
/*
|
||||
is equivalent to Parsimmon.regex(/[a-z]/i)
|
||||
/**
|
||||
* is equivalent to Parsimmon.regex(/[a-z]/i)
|
||||
*/
|
||||
export var letter: Parser<string>;
|
||||
/*
|
||||
is equivalent to Parsimmon.regex(/[a-z]*`/i)
|
||||
/**
|
||||
* is equivalent to Parsimmon.regex(/[a-z]*`/i)
|
||||
*/
|
||||
export var letters: Parser<string>;
|
||||
/*
|
||||
is equivalent to Parsimmon.regex(/[0-9]/)
|
||||
/**
|
||||
* is equivalent to Parsimmon.regex(/[0-9]/)
|
||||
*/
|
||||
export var digit: Parser<string>;
|
||||
/*
|
||||
is equivalent to Parsimmon.regex(/[0-9]*`/)
|
||||
/**
|
||||
* is equivalent to Parsimmon.regex(/[0-9]*`/)
|
||||
*/
|
||||
export var digits: Parser<string>;
|
||||
/*
|
||||
is equivalent to Parsimmon.regex(/\s+/)
|
||||
/**
|
||||
* is equivalent to Parsimmon.regex(/\s+/)
|
||||
*/
|
||||
export var whitespace: Parser<string>;
|
||||
/*
|
||||
is equivalent to Parsimmon.regex(/\s*`/)
|
||||
/**
|
||||
* is equivalent to Parsimmon.regex(/\s*`/)
|
||||
*/
|
||||
export var optWhitespace: Parser<string>;
|
||||
/*
|
||||
consumes and yields the next character of the stream.
|
||||
/**
|
||||
* consumes and yields the next character of the stream.
|
||||
*/
|
||||
export var any: Parser<string>;
|
||||
/*
|
||||
consumes and yields the entire remainder of the stream.
|
||||
/**
|
||||
* consumes and yields the entire remainder of the stream.
|
||||
*/
|
||||
export var all: Parser<string>;
|
||||
/*
|
||||
expects the end of the stream.
|
||||
/**
|
||||
* expects the end of the stream.
|
||||
*/
|
||||
export var eof: Parser<void>;
|
||||
/*
|
||||
is a parser that yields the current index of the parse.
|
||||
/**
|
||||
* is a parser that yields the current index of the parse.
|
||||
*/
|
||||
export var index: Parser<number>;
|
||||
/**
|
||||
* Returns a parser that yield a single character if it passes the predicate
|
||||
*/
|
||||
export function test(predicate: (char: string) => boolean): Parser<string>;
|
||||
/**
|
||||
* Returns a parser yield a string containing all the next characters that pass the predicate
|
||||
*/
|
||||
export function takeWhile(predicate: (char: string) => boolean): Parser<string>;
|
||||
}
|
||||
|
||||
export = Parsimmon;
|
||||
|
||||
Vendored
+34
-48
@@ -27,30 +27,11 @@ declare namespace Express {
|
||||
declare module 'passport' {
|
||||
import express = require('express');
|
||||
|
||||
function use(strategy: Strategy): Passport;
|
||||
function use(name: string, strategy: Strategy): Passport;
|
||||
function unuse(name: string): Passport;
|
||||
function framework(fw: Framework): Passport;
|
||||
function initialize(options?: { userProperty: string; }): express.Handler;
|
||||
function session(options?: { pauseStream: boolean; }): express.Handler;
|
||||
|
||||
function authenticate(strategy: string, callback?: Function): express.Handler;
|
||||
function authenticate(strategy: string, options: Object, callback?: Function): express.Handler;
|
||||
function authenticate(strategies: string[], callback?: Function): express.Handler;
|
||||
function authenticate(strategies: string[], options: Object, callback?: Function): express.Handler;
|
||||
function authorize(strategy: string, callback?: Function): express.Handler;
|
||||
function authorize(strategy: string, options: Object, callback?: Function): express.Handler;
|
||||
function authorize(strategies: string[], callback?: Function): express.Handler;
|
||||
function authorize(strategies: string[], options: Object, callback?: Function): express.Handler;
|
||||
function serializeUser(fn: (user: any, done: (err: any, id: any) => void) => void): void;
|
||||
function deserializeUser(fn: (id: any, done: (err: any, user: any) => void) => void): void;
|
||||
function transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
|
||||
|
||||
interface Passport {
|
||||
use(strategy: Strategy): Passport;
|
||||
use(name: string, strategy: Strategy): Passport;
|
||||
use(strategy: passport.Strategy): Passport;
|
||||
use(name: string, strategy: passport.Strategy): Passport;
|
||||
unuse(name: string): Passport;
|
||||
framework(fw: Framework): Passport;
|
||||
framework(fw: passport.Framework): Passport;
|
||||
initialize(options?: { userProperty: string; }): express.Handler;
|
||||
session(options?: { pauseStream: boolean; }): express.Handler;
|
||||
|
||||
@@ -66,33 +47,38 @@ declare module 'passport' {
|
||||
deserializeUser(fn: (id: any, done: (err: any, user: any) => void) => void): void;
|
||||
transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
|
||||
}
|
||||
const passport: Passport;
|
||||
export = passport;
|
||||
|
||||
interface Strategy {
|
||||
name?: string;
|
||||
authenticate(req: express.Request, options?: Object): void;
|
||||
namespace passport {
|
||||
interface Strategy {
|
||||
name?: string;
|
||||
authenticate(req: express.Request, options?: Object): void;
|
||||
}
|
||||
|
||||
interface Profile {
|
||||
provider: string;
|
||||
id: string;
|
||||
displayName: string;
|
||||
name?: {
|
||||
familyName: string;
|
||||
givenName: string;
|
||||
middleName?: string;
|
||||
};
|
||||
emails?: {
|
||||
value: string;
|
||||
type?: string;
|
||||
}[];
|
||||
photos?: {
|
||||
value: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
interface Framework {
|
||||
initialize(passport: Passport, options?: Object): Function;
|
||||
authenticate(passport: Passport, name: string, options?: Object, callback?: Function): Function;
|
||||
authorize?(passport: Passport, name: string, options?: Object, callback?: Function): Function;
|
||||
}
|
||||
}
|
||||
|
||||
interface Profile {
|
||||
provider: string;
|
||||
id: string;
|
||||
displayName: string;
|
||||
name?: {
|
||||
familyName: string;
|
||||
givenName: string;
|
||||
middleName?: string;
|
||||
};
|
||||
emails?: {
|
||||
value: string;
|
||||
type?: string;
|
||||
}[];
|
||||
photos?: {
|
||||
value: string;
|
||||
}[];
|
||||
}
|
||||
|
||||
interface Framework {
|
||||
initialize(passport: Passport, options?: Object): Function;
|
||||
authenticate(passport: Passport, name: string, options?: Object, callback?: Function): Function;
|
||||
authorize?(passport: Passport, name: string, options?: Object, callback?: Function): Function;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,727 @@
|
||||
/// <reference path="pem.d.ts" />
|
||||
|
||||
import * as pem from 'pem';
|
||||
|
||||
const tests = {
|
||||
|
||||
'Create default sized dhparam key': (test: any) => {
|
||||
pem.createDhparam((error: any, data: any) => {
|
||||
var dhparam = (data && data.dhparam || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(dhparam);
|
||||
test.ok(dhparam.match(/^\n*\-\-\-\-\-BEGIN DH PARAMETERS\-\-\-\-\-\n/));
|
||||
test.ok(dhparam.match(/\n\-\-\-\-\-END DH PARAMETERS\-\-\-\-\-\n*$/));
|
||||
test.ok(dhparam.trim().length > 150 && dhparam.trim().length < 160);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create 2048bit dhparam key': (test: any) => {
|
||||
pem.createDhparam(2048, (error: any, data: any) => {
|
||||
var dhparam = (data && data.dhparam || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(dhparam);
|
||||
test.ok(dhparam.match(/^\n*\-\-\-\-\-BEGIN DH PARAMETERS\-\-\-\-\-\n/));
|
||||
test.ok(dhparam.match(/\n\-\-\-\-\-END DH PARAMETERS\-\-\-\-\-\n*$/));
|
||||
test.ok(dhparam.trim().length > 420 && dhparam.trim().length < 430);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create default sized Private key': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
test.ok(key.match(/^\n*\-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\-\n/));
|
||||
test.ok(key.match(/\n\-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\-\n*$/));
|
||||
test.ok(key.trim().length > 850 && key.trim().length < 1900);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create 2048bit Private key': (test: any) => {
|
||||
pem.createPrivateKey(2048, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
test.ok(key.match(/^\n*\-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\-\n/));
|
||||
test.ok(key.match(/\n\-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\-\n*$/));
|
||||
test.ok(key.trim().length > 1650 && key.trim().length < 1700);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create 2048bit Private key with Password': (test: any) => {
|
||||
pem.createPrivateKey(2048,{cipher:'des',password:'TestMe'}, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
test.ok(key.match(/ENCRYPTED\n/));
|
||||
test.ok(key.match(/^\n*\-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\-\n/));
|
||||
test.ok(key.match(/\n\-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\-\n*$/));
|
||||
test.ok(key.trim().length > 1700 && key.trim().length < 1780);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create default CSR': (test: any) => {
|
||||
pem.createCSR((error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
test.ok(csr.match(/\n\-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\-\n*$/));
|
||||
|
||||
test.ok(data && data.clientKey);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create CSR using config file': (test: any) => {
|
||||
var certInfo = {
|
||||
issuer : {},
|
||||
country: 'EE',
|
||||
state: 'Harjumaa',
|
||||
locality: 'Tallinn',
|
||||
organization: 'Node.ee',
|
||||
organizationUnit: 'test',
|
||||
commonName: 'www.node.ee',
|
||||
emailAddress: 'andris@node.ee'
|
||||
};
|
||||
|
||||
pem.createCSR({ csrConfigFile: './test/fixtures/test.cnf' }, (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
test.ok(csr.match(/\n\-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\-\n*$/));
|
||||
|
||||
test.ok(data && data.clientKey);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.readCertificateInfo(csr, (error: any, data: any) => {
|
||||
test.ifError(error);
|
||||
test.deepEqual(data, certInfo);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Create CSR with own key': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCSR({
|
||||
clientKey: key
|
||||
}, (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
test.ok(csr.match(/\n\-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\-\n*$/));
|
||||
|
||||
test.equal(data && data.clientKey, key);
|
||||
|
||||
test.ok(data && data.clientKey);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Create CSR with own encrypted key': (test: any) => {
|
||||
var password = 'my:secure! "password\'s\nawesome';
|
||||
pem.createPrivateKey(2048, { cipher: 'des3', password: password }, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCSR({
|
||||
clientKey: key,
|
||||
clientKeyPassword: password
|
||||
}, (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(csr);
|
||||
test.ok(csr.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE REQUEST\-\-\-\-\-\n/));
|
||||
test.ok(csr.match(/\n\-\-\-\-\-END CERTIFICATE REQUEST\-\-\-\-\-\n*$/));
|
||||
|
||||
test.equal(data && data.clientKey, key);
|
||||
|
||||
test.ok(data && data.clientKey);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Create default certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
test.ok(certificate.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-\n/));
|
||||
test.ok(certificate.match(/\n\-\-\-\-\-END CERTIFICATE\-\-\-\-\-\n*$/));
|
||||
|
||||
test.ok((data && data.clientKey) !== (data && data.serviceKey));
|
||||
|
||||
test.ok(data && data.clientKey);
|
||||
test.ok(data && data.serviceKey);
|
||||
test.ok(data && data.csr);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create self signed certificate': (test: any) => {
|
||||
pem.createCertificate({
|
||||
selfSigned: true
|
||||
}, (error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
test.ok(certificate.match(/^\n*\-\-\-\-\-BEGIN CERTIFICATE\-\-\-\-\-\n/));
|
||||
test.ok(certificate.match(/\n\-\-\-\-\-END CERTIFICATE\-\-\-\-\-\n*$/));
|
||||
|
||||
test.ok((data && data.clientKey) === (data && data.serviceKey));
|
||||
|
||||
test.ok(data && data.clientKey);
|
||||
test.ok(data && data.serviceKey);
|
||||
test.ok(data && data.csr);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Read default cert data from CSR': (test: any) => {
|
||||
pem.createCSR((error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.readCertificateInfo(csr, (error: any, data: any) => {
|
||||
test.ifError(error);
|
||||
test.deepEqual(data, {
|
||||
issuer : {},
|
||||
country: '',
|
||||
state: '',
|
||||
locality: '',
|
||||
organization: '',
|
||||
organizationUnit: '',
|
||||
commonName: 'localhost',
|
||||
emailAddress: ''
|
||||
});
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Read edited cert data from CSR': (test: any) => {
|
||||
var certInfo = {
|
||||
issuer : {},
|
||||
country: 'EE',
|
||||
state: 'Harjumaa',
|
||||
locality: 'Tallinn',
|
||||
organization: 'Node.ee',
|
||||
organizationUnit: 'test',
|
||||
commonName: 'www.node.ee',
|
||||
emailAddress: 'andris@node.ee'
|
||||
};
|
||||
pem.createCSR(Object.create(certInfo), (error: any, data: any) => {
|
||||
var csr = (data && data.csr || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.readCertificateInfo(csr, (error: any, data: any) => {
|
||||
test.ifError(error);
|
||||
test.deepEqual(data, certInfo);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Read default cert data from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.readCertificateInfo(certificate, (error: any, data: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
if (data.validity) {
|
||||
delete data.validity;
|
||||
}
|
||||
if (data.serial) {
|
||||
delete data.serial;
|
||||
}
|
||||
|
||||
test.deepEqual(data, {
|
||||
issuer : {
|
||||
country: '',
|
||||
state: '',
|
||||
locality: '',
|
||||
organization: '',
|
||||
organizationUnit: '',
|
||||
commonName: 'localhost'
|
||||
},
|
||||
country: '',
|
||||
state: '',
|
||||
locality: '',
|
||||
organization: '',
|
||||
organizationUnit: '',
|
||||
commonName: 'localhost',
|
||||
emailAddress: ''
|
||||
});
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Read edited cert data from certificate': (test: any) => {
|
||||
var certInfo = {
|
||||
issuer : {
|
||||
country: 'EE',
|
||||
state: 'Harjumaa',
|
||||
locality: 'Tallinn',
|
||||
organization: 'Node.ee',
|
||||
organizationUnit: 'test',
|
||||
commonName: 'www.node.ee'
|
||||
},
|
||||
country: 'EE',
|
||||
state: 'Harjumaa',
|
||||
locality: 'Tallinn',
|
||||
organization: 'Node.ee',
|
||||
organizationUnit: 'test',
|
||||
commonName: 'www.node.ee',
|
||||
emailAddress: 'andris@node.ee'
|
||||
};
|
||||
pem.createCertificate(Object.create(certInfo), (error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.readCertificateInfo(certificate, (error: any, data: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
if (data.validity) {
|
||||
delete data.validity;
|
||||
}
|
||||
if (data.serial) {
|
||||
delete data.serial;
|
||||
}
|
||||
|
||||
test.deepEqual(data, certInfo);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Get public key from private key': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getPublicKey(key, (error: any, data: any) => {
|
||||
var pubkey = (data && data.publicKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(pubkey);
|
||||
|
||||
test.ok(pubkey.match(/^\n*\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-\n/));
|
||||
test.ok(pubkey.match(/\n\-\-\-\-\-END PUBLIC KEY\-\-\-\-\-\n*$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Get public key from CSR': (test: any) => {
|
||||
pem.createCSR((error: any, data: any) => {
|
||||
var key = (data && data.clientKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getPublicKey(key, (error: any, data: any) => {
|
||||
var pubkey = (data && data.publicKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(pubkey);
|
||||
|
||||
test.ok(pubkey.match(/^\n*\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-\n/));
|
||||
test.ok(pubkey.match(/\n\-\-\-\-\-END PUBLIC KEY\-\-\-\-\-\n*$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Get public key from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var key = (data && data.clientKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(key);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getPublicKey(key, (error: any, data: any) => {
|
||||
var pubkey = (data && data.publicKey || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(pubkey);
|
||||
|
||||
test.ok(pubkey.match(/^\n*\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-\n/));
|
||||
test.ok(pubkey.match(/\n\-\-\-\-\-END PUBLIC KEY\-\-\-\-\-\n*$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Get fingerprint from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getFingerprint(certificate, (error: any, data: any) => {
|
||||
var fingerprint = (data && data.fingerprint || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(fingerprint);
|
||||
test.ok(fingerprint.match(/^[0-9A-F]{2}(:[0-9A-F]{2}){19}$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Get modulus from certificate': (test: any) => {
|
||||
pem.createCertificate((error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certificate);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.getModulus(certificate, (error: any, data: any) => {
|
||||
var certmodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certmodulus);
|
||||
test.ok(certmodulus.match(/^[0-9A-F]*$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
pem.getModulus(certificate, (error: any, data: any) => {
|
||||
var keymodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(keymodulus);
|
||||
test.ok(keymodulus.match(/^[0-9A-F]*$/));
|
||||
test.ok(keymodulus === certmodulus);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
'Get modulus from a protected key': (test: any) => {
|
||||
var certificate = ''; // fs.readFileSync('./test/fixtures/test.crt').toString();
|
||||
var key = ''; // fs.readFileSync('./test/fixtures/test.key').toString();
|
||||
|
||||
pem.getModulus(certificate, (error: any, data: any) => {
|
||||
var certmodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(certmodulus);
|
||||
test.ok(certmodulus.match(/^[0-9A-F]*$/));
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
pem.getModulus(key, 'password', (error: any, data: any) => {
|
||||
var keymodulus = (data && data.modulus || '').toString();
|
||||
test.ifError(error);
|
||||
test.ok(keymodulus);
|
||||
test.ok(keymodulus.match(/^[0-9A-F]*$/));
|
||||
test.ok(keymodulus === certmodulus);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
'Get DH param info': (test: any) => {
|
||||
var dh = ''; // fs.readFileSync('./test/fixtures/test.dh').toString();
|
||||
|
||||
pem.getDhparamInfo(dh, (error: any, data: any) => {
|
||||
var size = data && data.size || 0;
|
||||
var prime = (data && data.prime || '').toString();
|
||||
test.ifError(error);
|
||||
test.equal(size, 1024);
|
||||
test.ok(prime);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.equal(typeof size, 'number');
|
||||
test.ok(/([0-9a-f][0-9a-f]:)+[0-9a-f][0-9a-f]$/g.test(prime));
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
|
||||
'Create and verify wildcard certificate': (test: any) => {
|
||||
var certInfo = {
|
||||
commonName: '*.node.ee'
|
||||
};
|
||||
pem.createCertificate(Object.create(certInfo), (error: any, data: any) => {
|
||||
var certificate = (data && data.certificate || '').toString();
|
||||
test.ifError(error);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.readCertificateInfo(certificate, (error: any, data: any) => {
|
||||
test.ifError(error);
|
||||
test.equal(data.commonName, certInfo.commonName);
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
'Return an error if openssl was not found': (test: any) => {
|
||||
pem.config({
|
||||
pathOpenSSL: 'zzzzzzzzzzz'
|
||||
});
|
||||
|
||||
pem.createPrivateKey((error: any) => {
|
||||
test.ok(error);
|
||||
pem.config({
|
||||
pathOpenSSL: 'openssl'
|
||||
});
|
||||
pem.createPrivateKey((error: any) => {
|
||||
test.ifError(error);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
},
|
||||
'Create PKCS12 without key password': (test: any) => {
|
||||
pem.createPrivateKey((error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCertificate({
|
||||
clientKey: key,
|
||||
selfSigned: true
|
||||
}, (error: any, csr: any) => {
|
||||
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', function(err: any, pkcs12: any){
|
||||
test.ifError(err);
|
||||
test.ok(pkcs12);
|
||||
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'Create PKCS12 with key password': (test: any) => {
|
||||
pem.createPrivateKey({cipher:'aes128',password:'xxx'}, (error: any, data: any) => {
|
||||
var key = (data && data.key || '').toString();
|
||||
|
||||
pem.createCertificate({
|
||||
clientKey: key,
|
||||
selfSigned: true
|
||||
}, (error: any, csr: any) => {
|
||||
|
||||
pem.createPkcs12(csr.clientKey, csr.certificate, 'mypassword', {cipher: 'aes256', clientKeyPassword: 'xxx'}, function(err: any, pkcs12: any){
|
||||
test.ifError(err);
|
||||
test.ok(pkcs12);
|
||||
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'Create PKCS12 with ca certificates': (test: any) => {
|
||||
pem.createCertificate({
|
||||
commonName: 'CA Certificate'
|
||||
}, (error: any, ca: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
serviceKey: ca.serviceKey,
|
||||
serviceCertificate: ca.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, cert: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createPkcs12(cert.clientKey, cert.certificate, '', {certFiles: [ca.certificate]}, (error: any, pkcs12: any) => {
|
||||
test.ifError(error);
|
||||
test.ok(pkcs12.pkcs12);
|
||||
|
||||
// test.ok(fs.readdirSync('./tmp').length === 0);
|
||||
|
||||
pem.readPkcs12(pkcs12.pkcs12, (error: any, keystore: any) => {
|
||||
test.ifError(error);
|
||||
test.ok(keystore);
|
||||
|
||||
test.equal(ca.certificate, keystore.ca[0]);
|
||||
test.equal(cert.certificate, keystore.cert);
|
||||
test.equal(cert.clientKey, keystore.key);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'Respond with ENOENT for missing PKCS12 file': (test: any) => {
|
||||
pem.readPkcs12('/i/do/not/exist.p12', (error: any) => {
|
||||
test.ok(error);
|
||||
test.equal(error.code, 'ENOENT');
|
||||
|
||||
test.done();
|
||||
});
|
||||
},
|
||||
'Verify sigining chain': (test: any) => {
|
||||
pem.createCertificate({
|
||||
commonName: 'CA Certificate'
|
||||
}, (error: any, ca: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
serviceKey: ca.serviceKey,
|
||||
serviceCertificate: ca.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, cert: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.verifySigningChain(cert.certificate, ca.certificate, (error: any, valid: any) => {
|
||||
test.ifError(error);
|
||||
test.ok(valid === true);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'Verify deep sigining chain': (test: any) => {
|
||||
pem.createCertificate({
|
||||
commonName: 'CA Certificate'
|
||||
}, (error: any, ca: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
commonName: 'Intermediate CA Certificate',
|
||||
serviceKey: ca.serviceKey,
|
||||
serviceCertificate: ca.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, intermediate: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
serviceKey: intermediate.clientKey,
|
||||
serviceCertificate: intermediate.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, cert: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.verifySigningChain(cert.certificate, [ca.certificate, intermediate.certificate], (error: any, valid: any) => {
|
||||
test.ifError(error);
|
||||
test.ok(valid === true);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'Fail to verify invalid sigining chain': (test: any) => {
|
||||
pem.createCertificate({
|
||||
commonName: 'CA Certificate'
|
||||
}, (error: any, ca: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
serviceKey: ca.serviceKey,
|
||||
serviceCertificate: ca.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, cert: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.verifySigningChain(cert.certificate, cert.certificate, (error: any, valid: any) => {
|
||||
test.ifError(error);
|
||||
test.ok(valid === false);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'Fail to verify deep sigining chain with missing CA certificate': (test: any) => {
|
||||
pem.createCertificate({
|
||||
commonName: 'CA Certificate'
|
||||
}, (error: any, ca: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
commonName: 'Intermediate CA Certificate',
|
||||
serviceKey: ca.serviceKey,
|
||||
serviceCertificate: ca.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, intermediate: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
serviceKey: intermediate.clientKey,
|
||||
serviceCertificate: intermediate.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, cert: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.verifySigningChain(cert.certificate, [intermediate.certificate], (error: any, valid: any) => {
|
||||
test.ifError(error);
|
||||
test.ok(valid === false);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
'Fail to verify deep sigining chain with missing intermediate certificate': (test: any) => {
|
||||
pem.createCertificate({
|
||||
commonName: 'CA Certificate'
|
||||
}, (error: any, ca: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
commonName: 'Intermediate CA Certificate',
|
||||
serviceKey: ca.serviceKey,
|
||||
serviceCertificate: ca.certificate,
|
||||
serial: Date.now(),
|
||||
}, (error: any, intermediate: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.createCertificate({
|
||||
serviceKey: intermediate.clientKey,
|
||||
serviceCertificate: intermediate.certificate,
|
||||
serial: Date.now(),
|
||||
days: 1024
|
||||
}, (error: any, cert: any) => {
|
||||
test.ifError(error);
|
||||
|
||||
pem.verifySigningChain(cert.certificate, [ca.certificate], (error: any, valid: any) => {
|
||||
test.ifError(error);
|
||||
test.ok(valid === false);
|
||||
|
||||
test.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
Vendored
+155
@@ -0,0 +1,155 @@
|
||||
// Type definitions for PEM v1.8.3
|
||||
// Project: https://github.com/andris9/pem
|
||||
// Definitions by: Anthony Trinh <https://github.com/tony19>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "pem" {
|
||||
/**
|
||||
* Creates a private key
|
||||
*
|
||||
* @param {Number} [keyBitsize=2048] Size of the key, defaults to 2048bit (can also be a function)
|
||||
* @param {Object} [options] object of cipher and password {cipher:'aes128',password:'xxx'}, defaults empty object
|
||||
* @param {Function} callback Callback function with an error object and {key}
|
||||
*/
|
||||
function createPrivateKey(keyBitsize: Number, options: Object, callback: Function): void;
|
||||
function createPrivateKey(keyBitsize: Number, callback: Function): void;
|
||||
function createPrivateKey(options: Object, callback: Function): void;
|
||||
function createPrivateKey(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Creates a dhparam key
|
||||
*
|
||||
* @param {Number} [keyBitsize=512] Size of the key, defaults to 512bit
|
||||
* @param {Function} callback Callback function with an error object and {dhparam}
|
||||
*/
|
||||
function createDhparam(keyBitsize: Number, callback: Function): void;
|
||||
function createDhparam(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Creates a Certificate Signing Request
|
||||
*
|
||||
* If client key is undefined, a new key is created automatically. The used key is included
|
||||
* in the callback return as clientKey
|
||||
*
|
||||
* @param {Object} [options] Optional options object
|
||||
* @param {String} [options.clientKey] Optional client key to use
|
||||
* @param {Number} [options.keyBitsize] If clientKey is undefined, bit size to use for generating a new key (defaults to 2048)
|
||||
* @param {String} [options.hash] Hash function to use (either md5 sha1 or sha256, defaults to sha256)
|
||||
* @param {String} [options.country] CSR country field
|
||||
* @param {String} [options.state] CSR state field
|
||||
* @param {String} [options.locality] CSR locality field
|
||||
* @param {String} [options.organization] CSR organization field
|
||||
* @param {String} [options.organizationUnit] CSR organizational unit field
|
||||
* @param {String} [options.commonName='localhost'] CSR common name field
|
||||
* @param {String} [options.emailAddress] CSR email address field
|
||||
* @param {String} [options.csrConfigFile] CSR config file
|
||||
* @param {Array} [options.altNames] is a list of subjectAltNames in the subjectAltName field
|
||||
* @param {Function} callback Callback function with an error object and {csr, clientKey}
|
||||
*/
|
||||
function createCSR(options: Object, callback: Function): void;
|
||||
function createCSR(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Creates a certificate based on a CSR. If CSR is not defined, a new one
|
||||
* will be generated automatically. For CSR generation all the options values
|
||||
* can be used as with createCSR.
|
||||
*
|
||||
* @param {Object} [options] Optional options object
|
||||
* @param {String} [options.serviceKey] Private key for signing the certificate, if not defined a new one is generated
|
||||
* @param {String} [options.serviceKeyPassword] Password of the service key
|
||||
* @param {Boolean} [options.selfSigned] If set to true and serviceKey is not defined, use clientKey for signing
|
||||
* @param {String} [options.hash] Hash function to use (either md5 sha1 or sha256, defaults to sha256)
|
||||
* @param {String} [options.csr] CSR for the certificate, if not defined a new one is generated
|
||||
* @param {Number} [options.days] Certificate expire time in days
|
||||
* @param {String} [options.clientKeyPassword] Password of the client key
|
||||
* @param {String} [options.extFile] extension config file - without '-extensions v3_req'
|
||||
* @param {String} [options.config] extension config file - with '-extensions v3_req'
|
||||
* @param {Function} callback Callback function with an error object and {certificate, csr, clientKey, serviceKey}
|
||||
*/
|
||||
function createCertificate(options: Object, callback: Function): void;
|
||||
function createCertificate(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Reads subject data from a certificate or a CSR
|
||||
*
|
||||
* @param {String} certificate PEM encoded CSR or certificate
|
||||
* @param {Function} callback Callback function with an error object and {country, state, locality, organization, organizationUnit, commonName, emailAddress}
|
||||
*/
|
||||
function readCertificateInfo(certificate: string, callback: Function): void;
|
||||
function readCertificateInfo(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Exports a public key from a private key, CSR or certificate
|
||||
*
|
||||
* @param {String} certificate PEM encoded private key, CSR or certificate
|
||||
* @param {Function} callback Callback function with an error object and {publicKey}
|
||||
*/
|
||||
function getPublicKey(certificate: string, callback: Function): void;
|
||||
function getPublicKey(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Gets the fingerprint for a certificate
|
||||
*
|
||||
* @param {String} certificate PEM encoded certificate
|
||||
* @param {String} hash Hash function to use (either md5 sha1 or sha256, defaults to sha256)
|
||||
* @param {Function} callback Callback function with an error object and {fingerprint}
|
||||
*/
|
||||
function getFingerprint(certificate: string, hash: string, callback: Function): void;
|
||||
function getFingerprint(certificate: string, callback: Function): void;
|
||||
function getFingerprint(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Gets the modulus from a certificate, a CSR or a private key
|
||||
*
|
||||
* @param {String} certificate PEM encoded, CSR PEM encoded, or private key
|
||||
* @param {String} password password for the certificate
|
||||
* @param {Function} callback Callback function with an error object and {modulus}
|
||||
*/
|
||||
function getModulus(certificate: string, password: string, callback: Function): void;
|
||||
function getModulus(certificate: string, callback: Function): void;
|
||||
|
||||
/**
|
||||
* Gets the size and prime of DH parameters
|
||||
*
|
||||
* @param {String} dh DH parameters PEM encoded
|
||||
* @param {Function} callback Callback function with an error object and {size, prime}
|
||||
*/
|
||||
function getDhparamInfo(dh: string, callback: Function): void;
|
||||
|
||||
/**
|
||||
* Exports private key and certificate to a PKCS12 keystore
|
||||
*
|
||||
* @param {String} key PEM encoded private key
|
||||
* @param {String} certificate PEM encoded certificate
|
||||
* @param {String} password Password of the result PKCS12 file
|
||||
* @param {Object} [options] object of cipher and optional client key password {cipher:'aes128', clientKeyPassword: 'xxx'}
|
||||
* @param {Function} callback Callback function with an error object and {pkcs12}
|
||||
*/
|
||||
function createPkcs12(key: string, certificate: string, password: string, options: Object, callback: Function): void;
|
||||
function createPkcs12(key: string, certificate: string, password: string, callback: Function): void;
|
||||
|
||||
/**
|
||||
* Reads private key and certificate from a PKCS12 keystore
|
||||
* @param {String} bufferOrPath
|
||||
* @param {Object} [options] object of cipher and optional client key password {cipher:'aes128', clientKeyPassword: 'xxx'}
|
||||
* @param {Function} callback Callback function with an error object and {pkcs12}
|
||||
* @returns the result of the callback
|
||||
*/
|
||||
function readPkcs12(bufferOrPath: string, options: Object, callback: Function): any;
|
||||
function readPkcs12(options: Object, callback: Function): any;
|
||||
|
||||
/**
|
||||
* Verifies the signing chain of the passed certificate
|
||||
*
|
||||
* @param {String} certificate PEM encoded certificate
|
||||
* @param {Array} ca List of CA certificates
|
||||
* @param {Function} callback Callback function with an error object and a boolean valid
|
||||
*/
|
||||
function verifySigningChain(certificate: string, ca: Array<string>, callback: Function): void;
|
||||
|
||||
/**
|
||||
* config the pem module
|
||||
* @param {Object} options
|
||||
*/
|
||||
function config(options: Object): void;
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
import q = require('q');
|
||||
|
||||
Q(8).then(x => console.log(x.toExponential()));
|
||||
Q().then(() => console.log("nothing"));
|
||||
|
||||
var delay = function (delay: number) {
|
||||
var d = Q.defer<void>();
|
||||
|
||||
@@ -12,6 +12,10 @@ declare function Q<T>(promise: Q.IPromise<T>): Q.Promise<T>;
|
||||
* If value is not a promise, returns a promise that is fulfilled with value.
|
||||
*/
|
||||
declare function Q<T>(value: T): Q.Promise<T>;
|
||||
/**
|
||||
* Calling with nothing at all creates a void promise
|
||||
*/
|
||||
declare function Q(): Q.Promise<void>;
|
||||
|
||||
declare namespace Q {
|
||||
interface IPromise<T> {
|
||||
|
||||
Vendored
+2
-2
@@ -8,7 +8,7 @@
|
||||
declare module "redux-devtools" {
|
||||
import * as React from 'react'
|
||||
|
||||
interface IDevTools {
|
||||
export interface IDevTools {
|
||||
new (): JSX.ElementClass
|
||||
instrument(): (opts: any) => any;
|
||||
}
|
||||
@@ -19,4 +19,4 @@ declare module "redux-devtools" {
|
||||
var factory: { instrument(): (opts: any) => any }
|
||||
|
||||
export default factory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
/// <reference path="./riot.d.ts"/>
|
||||
|
||||
import * as riot from 'riot';
|
||||
|
||||
// Version
|
||||
console.log(riot.version.charAt(0));
|
||||
|
||||
// Settings
|
||||
riot.settings.brackets = '[% %]';
|
||||
|
||||
// errorHandler
|
||||
riot.util.tmpl.errorHandler = function (err: riot.TemplateError) {
|
||||
console.error(err.message + ' in ' + err.riotData.tagName);
|
||||
};
|
||||
|
||||
// vdom
|
||||
console.log(riot.vdom[0].opts);
|
||||
|
||||
const mockOpts: any = {
|
||||
foo: true,
|
||||
bar: 1,
|
||||
baz: [1, '2', [3]]
|
||||
};
|
||||
|
||||
const tag = riot.mount('test')[0];
|
||||
|
||||
// Mounting
|
||||
// mount all custom tags with a class name .customer
|
||||
var tags: riot.Tag[] = riot.mount('.customer');
|
||||
console.log(tags.length);
|
||||
// mount <account> tag and pass an object as options
|
||||
riot.mount('account', mockOpts);
|
||||
// mounts custom tag "my-tag" to div#main with some options
|
||||
riot.mount('div#main', 'my-tag', mockOpts);
|
||||
// mounts "users" tag to #slide node and some options
|
||||
riot.mount(document.getElementById('slide'), 'users', mockOpts);
|
||||
|
||||
// Rendering
|
||||
console.log(riot.render('test', mockOpts).substr(0, 10));
|
||||
|
||||
// Updating
|
||||
// update tag instance
|
||||
tag.update();
|
||||
// update tag instance with context data
|
||||
tag.update(mockOpts);
|
||||
// update all mounted tags
|
||||
riot.update();
|
||||
|
||||
// Unmounting
|
||||
// unmount tag
|
||||
tag.unmount();
|
||||
// unmount tag and keep parent tag
|
||||
tag.unmount(true);
|
||||
|
||||
// Nested tags
|
||||
// tag should have `tags` property
|
||||
console.log(tag.tags);
|
||||
// nested tags can be accessed by name
|
||||
// multiple tags with same name are collected into array
|
||||
const nestedTag = tag.tags['test'];
|
||||
if (nestedTag instanceof riot.Tag) {
|
||||
nestedTag.unmount();
|
||||
} else if (nestedTag instanceof Array) {
|
||||
nestedTag.push(tag);
|
||||
}
|
||||
|
||||
// Mixins
|
||||
interface OptsMixin extends riot.TagMixin {
|
||||
getOpts(): any;
|
||||
setOpts(opts: any, update: boolean): OptsMixin;
|
||||
}
|
||||
const optsMixin: OptsMixin = {
|
||||
init() {
|
||||
this.on('updated', function() { console.log('Updated!') });
|
||||
},
|
||||
|
||||
getOpts() {
|
||||
return this.opts;
|
||||
},
|
||||
|
||||
setOpts(opts, update): OptsMixin {
|
||||
this.opts = opts;
|
||||
if (!update) this.update();
|
||||
return this;
|
||||
}
|
||||
};
|
||||
// mixin object
|
||||
tag.mixin(optsMixin);
|
||||
// register shared mixin
|
||||
riot.mixin('optsMixin', optsMixin);
|
||||
// use shared mixin
|
||||
tag.mixin('optsMixin');
|
||||
// register global mixin and add it to all tag instances
|
||||
riot.mixin(optsMixin);
|
||||
// using mixin in tag instances
|
||||
abstract class TagWithOptsMixin extends riot.Tag implements OptsMixin {
|
||||
getOpts: () => any;
|
||||
setOpts: (opts: any, update: boolean) => this;
|
||||
}
|
||||
(<TagWithOptsMixin>tag).setOpts(mockOpts, true).getOpts();
|
||||
|
||||
|
||||
// Manual construction
|
||||
riot.tag('timer',
|
||||
'<p>Seconds Elapsed: { time }</p>',
|
||||
'timer { display: block; border: 2px }',
|
||||
'class="tic-toc"',
|
||||
function (opts) {
|
||||
var self = this;
|
||||
this.time = opts.start || 0;
|
||||
|
||||
this.tick = function () {
|
||||
self.update({ time: ++self.time })
|
||||
};
|
||||
|
||||
var timer = setInterval(this.tick, 1000);
|
||||
|
||||
this.on('unmount', function () {
|
||||
clearInterval(timer)
|
||||
});
|
||||
});
|
||||
|
||||
// Observable
|
||||
const cb = () => true;
|
||||
// can create new observable object
|
||||
riot.observable().on('test', cb);
|
||||
// can add observable functionality to existing object
|
||||
riot.observable({}).on('test', cb);
|
||||
// all observable methods support fluent interface
|
||||
riot.observable().on('test', cb).one('test', cb).off('test').off('test', cb)
|
||||
.trigger('test').trigger('test', 1, 'arg1').on('test', cb);
|
||||
// tags are observable
|
||||
tag.on('test', cb).one('test', cb).off('test').off('test', cb)
|
||||
.trigger('test').trigger('test', 1, 'arg1').unmount();
|
||||
|
||||
|
||||
// Custom tag
|
||||
class MyTag extends riot.Tag {
|
||||
public msg: string;
|
||||
constructor(el: Node) {
|
||||
super({ tmpl: MyTag.template() }, { root: el });
|
||||
this.msg = 'hello';
|
||||
}
|
||||
bye() {
|
||||
this.msg = 'goodbye';
|
||||
}
|
||||
static template() {
|
||||
return `<p onclick="{ bye }">{ msg }</p>`;
|
||||
}
|
||||
}
|
||||
|
||||
new MyTag(document.getElementById('my-div')).bye();
|
||||
|
||||
// Router
|
||||
// URL change callback
|
||||
riot.route(function(collection, id, action) {
|
||||
console.log(collection + id + action);
|
||||
});
|
||||
// route with filter
|
||||
riot.route('/fruit', function(name) {
|
||||
console.log('The list of fruits');
|
||||
});
|
||||
// query
|
||||
riot.route('/search..', function() {
|
||||
var q = riot.route.query();
|
||||
console.log('Search keyword: ' + q['keyword'])
|
||||
});
|
||||
// new routing context
|
||||
var subRoute = riot.route.create();
|
||||
subRoute('/fruit/apple', function() { /* */ });
|
||||
subRoute.stop();
|
||||
// route to URL
|
||||
riot.route('customers/267393/edit');
|
||||
riot.route('customers/267393/edit', 'Editing customer page');
|
||||
riot.route('not-found', 'Not found', true);
|
||||
// start
|
||||
riot.route.start();
|
||||
riot.route.start(true);
|
||||
// stop
|
||||
riot.route.stop();
|
||||
// exec
|
||||
riot.route.exec();
|
||||
riot.route.exec(cb);
|
||||
// base
|
||||
riot.route.base('/app');
|
||||
// parser
|
||||
const firstParser = function first(path: string): string[] {
|
||||
const raw = path.slice(2).split('?');
|
||||
return raw[0].split('/');
|
||||
};
|
||||
riot.route.parser(firstParser);
|
||||
const secondParser = function second(path: string, filter: string): string[] {
|
||||
const re = new RegExp('^' + filter.replace(/\*/g, '([^/?#]+?)').replace(/\.\./, '.*') + '$');
|
||||
const args = path.match(re);
|
||||
if (args) {
|
||||
return args.slice(1);
|
||||
}
|
||||
};
|
||||
riot.route.parser(firstParser, secondParser);
|
||||
|
||||
// Compile
|
||||
// compiling all tags
|
||||
riot.compile(function() {
|
||||
riot.mount('*')
|
||||
});
|
||||
// compiling url
|
||||
riot.compile('my/tags.tag', function() {
|
||||
// the loaded tags are ready to be used
|
||||
});
|
||||
// compiling tag definition
|
||||
let compiled = riot.compile(`<my-tag><p>Hello, World!</p></my-tag>`);
|
||||
console.log(compiled.charAt(0));
|
||||
// compiling without execution
|
||||
compiled = riot.compile(`<my-tag><p>Hello, World!</p></my-tag>`, true);
|
||||
console.log(compiled.charAt(0));
|
||||
Vendored
+425
@@ -0,0 +1,425 @@
|
||||
// Type definitions for riot v2.6.0
|
||||
// Project: https://github.com/riot/riot
|
||||
// Definitions by: Boriss Nazarovs <https://github.com/Stubb0rn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace riot {
|
||||
/**
|
||||
* Current version number as string
|
||||
*/
|
||||
const version: string;
|
||||
|
||||
/**
|
||||
* Riot settings
|
||||
*/
|
||||
interface Settings {
|
||||
/**
|
||||
* Setting used to customize the start and end tokens of the expression
|
||||
*/
|
||||
brackets: string;
|
||||
}
|
||||
|
||||
const settings: Settings;
|
||||
|
||||
interface TemplateError extends Error {
|
||||
riotData: {
|
||||
tagName: string;
|
||||
}
|
||||
}
|
||||
|
||||
interface Util {
|
||||
tmpl: {
|
||||
errorHandler(error: TemplateError): void;
|
||||
}
|
||||
}
|
||||
|
||||
const util: Util;
|
||||
|
||||
/**
|
||||
* Internal riot tags cache
|
||||
*/
|
||||
const vdom: Tag[];
|
||||
|
||||
interface Observable {
|
||||
/**
|
||||
* Register callback for specified events.
|
||||
* Callback is executed each time event is triggered
|
||||
* @param events Space separated list of events or wildcard '*' that matches all events
|
||||
* @param callback Callback function
|
||||
*/
|
||||
on?(events: string, callback: Function): Observable;
|
||||
|
||||
/**
|
||||
* Register callback for specified events.
|
||||
* Callback is executed at most once.
|
||||
* @param events Space separated list of events.
|
||||
* @param callback Callback function
|
||||
*/
|
||||
one?(events: string, callback: Function): Observable;
|
||||
|
||||
/**
|
||||
* Remove all registered callbacks for specified events
|
||||
* @param events Space separated list of events or wildcard '*' that matches all events
|
||||
*/
|
||||
off?(events: string): Observable;
|
||||
|
||||
/**
|
||||
* Remove specified callback for specified events
|
||||
* @param events Space separated list of events or wildcard '*' that matches all events
|
||||
* @param callback Callback function to remove
|
||||
*/
|
||||
off?(events: string, callback: Function): Observable;
|
||||
|
||||
/**
|
||||
* Execute all callback functions registered for specified list of events
|
||||
* @param events Space separated list of events
|
||||
* @param args Arguments provided to callbacks
|
||||
*/
|
||||
trigger?(events: string, ...args: any[]): Observable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Riot Router
|
||||
*/
|
||||
interface Route {
|
||||
/**
|
||||
* Register callback that is executed when the URL changes
|
||||
* @param callback Callback function
|
||||
*/
|
||||
(callback: (...args: any[]) => void): void;
|
||||
|
||||
/**
|
||||
* Register callback that is executed when the URL changes and new URL matches specified filter
|
||||
* @param filter URL filter
|
||||
* @param callback Callback function
|
||||
*/
|
||||
(filter: string, callback: (...any: string[]) => void): void;
|
||||
|
||||
/**
|
||||
* Change the browser URL and notify all the listeners registered with `Route(callback)`
|
||||
* @param to New URL
|
||||
* @param title Document title for new URL
|
||||
* @param shouldReplace Should new url replace the current history
|
||||
*/
|
||||
(to: string, title?: string, shouldReplace?: boolean): void;
|
||||
|
||||
/**
|
||||
* Return a new routing context
|
||||
*/
|
||||
create(): Route;
|
||||
|
||||
/**
|
||||
* Start listening for url changes
|
||||
* @param autoExec Should router exec routing on the current url
|
||||
*/
|
||||
start(autoExec?: boolean): void;
|
||||
|
||||
/**
|
||||
* Stop all the routings.
|
||||
* Removes the listeners and clears the callbacks.
|
||||
*/
|
||||
stop(): void;
|
||||
|
||||
/**
|
||||
* Study the current browser path “in place” and emit routing without waiting for it to change.
|
||||
*/
|
||||
exec(): void;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
exec(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Extract query from the url
|
||||
*/
|
||||
query(): { [key: string]: string };
|
||||
|
||||
/**
|
||||
* Change the base path
|
||||
* @param base Base path
|
||||
*/
|
||||
base(base: string): void;
|
||||
|
||||
/**
|
||||
* Change the default parsers to the custom ones.
|
||||
* @param parser Replacement parser for default parser
|
||||
* @param secondParser Replacement parser for handling url filters
|
||||
*/
|
||||
parser(parser: (path: string) => any[], secondParser?: (path: string, filter: string) => any[]): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Observer support for the given object or
|
||||
* if the argument is empty a new observable instance is created and returned.
|
||||
* @param el Object to become observable
|
||||
*/
|
||||
function observable(el?: any): Observable;
|
||||
|
||||
const route: Route;
|
||||
|
||||
/**
|
||||
* Mount custom tags with specified tag name. Returns an array of mounted tag instances.
|
||||
* @param selector Tag selector.
|
||||
* It can be tag name, css selector or special '*' selector that matches all tags on the page.
|
||||
* @param opts Optional object passed for the tags to consume.
|
||||
*/
|
||||
function mount(selector: string, opts?: any): Tag[];
|
||||
|
||||
/**
|
||||
* Mount a custom tag on DOM nodes matching provided selector. Returns an array of mounted tag instances.
|
||||
* @param selector CSS selector
|
||||
* @param tagName Custom tag name
|
||||
* @param opts Optional object passed for the tag to consume.
|
||||
*/
|
||||
function mount(selector: string, tagName: string, opts?: any): Tag[];
|
||||
|
||||
/**
|
||||
* Mount a custom tag on a given DOM node. Returns an array of mounted tag instances.
|
||||
* @param domNode DOM node
|
||||
* @param tagName Tag name
|
||||
* @param opts Optional object passed for the tag to consume.
|
||||
*/
|
||||
function mount(domNode: Node, tagName: string, opts?: any): Tag[];
|
||||
|
||||
/**
|
||||
* Render a tag to html. This method is only available on server-side.
|
||||
* @param tagName Custom tag name
|
||||
* @param opts Optional object passed for the tag to consume.
|
||||
*/
|
||||
function render(tagName: string, opts?: any): string;
|
||||
|
||||
/**
|
||||
* Update all the mounted tags and their expressions on the page.
|
||||
* Returns an array of tag instances that are mounted on the page.
|
||||
*/
|
||||
function update(): Tag[];
|
||||
|
||||
/**
|
||||
* Register a global mixin and automatically add it to all tag instances.
|
||||
* @param mixinObject Mixin object
|
||||
*/
|
||||
function mixin(mixinObject: TagMixin): void;
|
||||
|
||||
/**
|
||||
* Register a shared mixin, globally available to be used in any tag using `TagInstance.mixin(mixinName)`
|
||||
* @param mixinName Name of the mixin
|
||||
* @param mixinObject Mixin object
|
||||
*/
|
||||
function mixin(mixinName: string, mixinObject: TagMixin): void;
|
||||
|
||||
/**
|
||||
* Create a new custom tag “manually” without the compiler. Returns name of the tag.
|
||||
* @param tagName The tag name
|
||||
* @param html The layout with expressions
|
||||
* @param css The style of the tag
|
||||
* @param attrs String of attributes for the tag
|
||||
* @param constructor The initialization function being called before
|
||||
* the tag expressions are calculated and before the tag is mounted
|
||||
*/
|
||||
function tag(tagName: string, html: string, css?: string, attrs?: string, constructor?: (opts: any) => void): string;
|
||||
|
||||
|
||||
interface TagImplementation {
|
||||
/**
|
||||
* Tag template
|
||||
*/
|
||||
tmpl: string;
|
||||
/**
|
||||
* The callback function called on the mount event
|
||||
* @param opts Tag options object
|
||||
*/
|
||||
fn?(opts: any): void;
|
||||
/**
|
||||
* Root tag html attributes as object (key => value)
|
||||
*/
|
||||
attrs?: {
|
||||
[key: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
interface TagConfiguration {
|
||||
/**
|
||||
* DOM node where you will mount the tag template
|
||||
*/
|
||||
root: Node;
|
||||
/**
|
||||
* Tag options
|
||||
*/
|
||||
opts?: any;
|
||||
/**
|
||||
* Is it used in as loop tag
|
||||
*/
|
||||
isLoop?: boolean;
|
||||
/**
|
||||
* Is already registered using `riot.tag`
|
||||
*/
|
||||
hasImpl?: boolean;
|
||||
/**
|
||||
* Loop item in the loop assigned to this instance
|
||||
*/
|
||||
item?: any;
|
||||
}
|
||||
|
||||
interface TagInterface extends Observable {
|
||||
/**
|
||||
* options object
|
||||
*/
|
||||
opts?: any;
|
||||
/**
|
||||
* the parent tag if any
|
||||
*/
|
||||
parent?: Tag;
|
||||
/**
|
||||
* root DOM node
|
||||
*/
|
||||
root?: Node;
|
||||
/**
|
||||
* nested custom tags
|
||||
*/
|
||||
tags?: {
|
||||
[key: string]: Tag | Tag[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates all the expressions on the current tag instance as well as on all the children.
|
||||
* @param data Context data
|
||||
*/
|
||||
update?(data?: any): void;
|
||||
|
||||
/**
|
||||
* Extend tag with functionality available on shared mixin registered with `riot.mixin(mixinName, mixinObject)`
|
||||
* @param mixinName Name of shared mixin
|
||||
*/
|
||||
mixin?(mixinName: string): void;
|
||||
|
||||
/**
|
||||
* Extend tag functionality with functionality available on provided mixin object.
|
||||
* @param mixinObject Mixin object
|
||||
*/
|
||||
mixin?(mixinObject: TagMixin): void;
|
||||
|
||||
/**
|
||||
* Mount the tag
|
||||
*/
|
||||
mount?(): void;
|
||||
|
||||
/**
|
||||
* Detach the tag and its children from the page.
|
||||
* @param keepTheParent If `true` unmounting tag doesn't remove the parent tag
|
||||
*/
|
||||
unmount?(keepTheParent?: boolean): void;
|
||||
}
|
||||
|
||||
|
||||
class Tag implements TagInterface {
|
||||
/**
|
||||
* Tag constructor
|
||||
* @param impl Tag implementation
|
||||
* @param conf Tag configuration
|
||||
* @param innerHTML HTML that can be used replacing a nested `yield` tag in its template
|
||||
*/
|
||||
constructor(impl: TagImplementation, conf: TagConfiguration, innerHTML?: string);
|
||||
|
||||
/**
|
||||
* options object
|
||||
*/
|
||||
opts: any;
|
||||
/**
|
||||
* the parent tag if any
|
||||
*/
|
||||
parent: Tag;
|
||||
/**
|
||||
* root DOM node
|
||||
*/
|
||||
root: Node;
|
||||
/**
|
||||
* nested custom tags
|
||||
*/
|
||||
tags: {
|
||||
[key: string]: Tag | Tag[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates all the expressions on the current tag instance as well as on all the children.
|
||||
* @param data Context data
|
||||
*/
|
||||
update(data?: any): void;
|
||||
|
||||
/**
|
||||
* Extend tag with functionality available on shared mixin registered with `riot.mixin(mixinName, mixinObject)`
|
||||
* @param mixinName Name of shared mixin
|
||||
*/
|
||||
mixin(mixinName: string): void;
|
||||
|
||||
/**
|
||||
* Extend tag functionality with functionality available on provided mixin object.
|
||||
* @param mixinObject Mixin object
|
||||
*/
|
||||
mixin(mixinObject: TagMixin): void;
|
||||
|
||||
/**
|
||||
* Mount the tag
|
||||
*/
|
||||
mount(): void;
|
||||
|
||||
/**
|
||||
* Detach the tag and its children from the page.
|
||||
* @param keepTheParent If `true` unmounting tag doesn't remove the parent tag
|
||||
*/
|
||||
unmount(keepTheParent?: boolean): void;
|
||||
|
||||
// Observable methods
|
||||
on(events: string, callback: Function): this;
|
||||
one(events: string, callback: Function): this;
|
||||
off(events: string): this;
|
||||
off(events: string, callback: Function): this;
|
||||
trigger(events: string, ...args: any[]): this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mixin object for extending tag functionality.
|
||||
* When it gets mixed in it has access to all tag properties.
|
||||
* It should not override any built in tag properties
|
||||
*/
|
||||
interface TagMixin extends TagInterface {
|
||||
/**
|
||||
* Special method which can initialize
|
||||
* the mixin when it's loaded to the tag and is not
|
||||
* accessible from the tag its mixed in
|
||||
*/
|
||||
init?(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile all tags defined with <script type="riot/tag"> to JavaScript.
|
||||
* @param callback Function that is called after all scripts are compiled
|
||||
*/
|
||||
function compile(callback: Function): void;
|
||||
|
||||
/**
|
||||
* Compiles and executes the given tag.
|
||||
* @param tag Tag definition
|
||||
* @return {string} Compiled JavaScript as string
|
||||
*/
|
||||
function compile(tag: string): string;
|
||||
|
||||
/**
|
||||
* Compiles the given tag but doesn't execute it, if `skipExecution` parameter is `true`
|
||||
* @param tag Tag definition
|
||||
* @param skipExecution If `true` tag is not executed after compilation
|
||||
* @return {string} Compiled JavaScript as string
|
||||
*/
|
||||
function compile(tag: string, skipExecution: boolean): string;
|
||||
|
||||
/**
|
||||
* Loads the given URL and compiles all tags after which the callback is called
|
||||
* @param url URL to load
|
||||
* @param callback Function that is called after all tags are compiled
|
||||
*/
|
||||
function compile(url: string, callback: Function): void;
|
||||
}
|
||||
|
||||
declare module 'riot' {
|
||||
export = riot;
|
||||
}
|
||||
Vendored
+1629
File diff suppressed because it is too large
Load Diff
@@ -119,6 +119,21 @@ shell.chmod("u+x", "/Users/brandon");
|
||||
|
||||
shell.exit(0);
|
||||
|
||||
shell.touch('/Users/brandom/test1');
|
||||
shell.touch('/Users/brandom/test1', '/Users/brandom/test2');
|
||||
|
||||
shell.touch(['/Users/brandom/test1']);
|
||||
shell.touch(['/Users/brandom/test1', '/Users/brandom/test2']);
|
||||
|
||||
shell.touch('-c', '/Users/brandom/test1');
|
||||
shell.touch('-c', '/Users/brandom/test1', '/Users/brandom/test2');
|
||||
shell.touch('-c', ['/Users/brandom/test1', '/Users/brandom/test2']);
|
||||
|
||||
shell.touch({ '-r': '/some/file.txt' }, '/Users/brandom/test1');
|
||||
shell.touch({ '-r': '/some/file.txt' }, '/Users/brandom/test1', '/Users/brandom/test2');
|
||||
shell.touch({ '-r': '/oome/file.txt' }, ['/Users/brandom/test1', '/Users/brandom/test2']);
|
||||
|
||||
|
||||
var tmp = shell.tempdir(); // "/tmp" for most *nix platforms
|
||||
|
||||
var errorlol = shell.error();
|
||||
|
||||
Vendored
+23
-2
@@ -128,7 +128,7 @@ declare module "shelljs"
|
||||
* @param {string} dest The destination.
|
||||
*/
|
||||
export function mv(source: string, dest: string): void;
|
||||
|
||||
|
||||
/**
|
||||
* Moves files. The wildcard * is accepted.
|
||||
* @param {string[]} source The source.
|
||||
@@ -436,7 +436,7 @@ declare module "shelljs"
|
||||
* Object containing environment variables (both getter and setter). Shortcut to process.env.
|
||||
*/
|
||||
export var env: { [key: string]: string };
|
||||
|
||||
|
||||
/**
|
||||
* Executes the given command synchronously.
|
||||
* @param {string} command The command to execute.
|
||||
@@ -511,6 +511,27 @@ declare module "shelljs"
|
||||
*/
|
||||
export function error(): string;
|
||||
|
||||
|
||||
|
||||
export function touch(...files: string[]): void;
|
||||
export function touch(files: string[]): void;
|
||||
|
||||
type TouchOptionsLiteral = "-a" | "-c" | "-m" | "-d" | "-r";
|
||||
|
||||
export function touch(options: TouchOptionsLiteral, ...files: string[]): void;
|
||||
export function touch(options: TouchOptionsLiteral, files: string[]): void;
|
||||
|
||||
/**
|
||||
* Update the access and modification times of each FILE to the current time. A FILE argument that does not exist is created empty, unless -c is supplied
|
||||
*/
|
||||
type touchOptionsArray = {
|
||||
'-d'?: string;
|
||||
'-r'?: string;
|
||||
};
|
||||
|
||||
export function touch(options: touchOptionsArray, ...files: string[]): void;
|
||||
export function touch(options: touchOptionsArray, files: string[]): void;
|
||||
|
||||
// Configuration
|
||||
|
||||
interface ShellConfig
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/// <reference path="./simple-url-cache.d.ts" />
|
||||
|
||||
import simpleUrlCache = require("simple-url-cache");
|
||||
|
||||
const fileStorageConfig = {
|
||||
type: 'file',
|
||||
dir: './cache'
|
||||
};
|
||||
|
||||
const redisStorageConfig = {
|
||||
type: 'redis',
|
||||
host: '127.00.1',
|
||||
port: 1234
|
||||
}
|
||||
|
||||
const regexRules = {
|
||||
cacheMaxAge: [
|
||||
{
|
||||
regex: /.*/,
|
||||
maxAge: 3600
|
||||
}
|
||||
],
|
||||
cacheAlways: [
|
||||
{
|
||||
regex: /always/
|
||||
}
|
||||
],
|
||||
cacheNever: [
|
||||
{
|
||||
regex: /never/
|
||||
}
|
||||
],
|
||||
default: 'never'
|
||||
};
|
||||
|
||||
const cacheEngine1 = new simpleUrlCache.CacheEngine(fileStorageConfig, regexRules);
|
||||
|
||||
let url1 = cacheEngine1.url('/someUrl.html');
|
||||
|
||||
url1.cache('<b>some HTML');
|
||||
url1.isCached();
|
||||
url1.getUrl();
|
||||
url1.removeUrl();
|
||||
url1.destroy();
|
||||
|
||||
const cacheEngine2 = new simpleUrlCache.CacheEngine(redisStorageConfig, regexRules);
|
||||
|
||||
let url2 = cacheEngine2.url('/someUrl.html');
|
||||
url2.cache('<b>some HTML');
|
||||
url2.isCached();
|
||||
url2.getUrl();
|
||||
url2.removeUrl();
|
||||
url2.destroy();
|
||||
|
||||
|
||||
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
// Type definitions for simple-url-cache
|
||||
// Project: https://github.com/a-lucas/simple-url-cache
|
||||
// Definitions by: Antoine LUCAS <https://github.com/a-lucas>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../redis/redis.d.ts" />
|
||||
|
||||
declare module 'simple-url-cache' {
|
||||
import redis = require("redis");
|
||||
|
||||
export class CacheEngine {
|
||||
constructor(storageConfig: FileStorageConfig, cacheRules: CacheRules);
|
||||
constructor(storageConfig: RedisStorageConfig, cacheRules: CacheRules);
|
||||
url(url: string): FileStorage;
|
||||
url(url: string): RedisStorage;
|
||||
}
|
||||
|
||||
export interface RegexRule {
|
||||
regex:RegExp
|
||||
}
|
||||
|
||||
export interface MaxAgeRegexRule extends RegexRule {
|
||||
maxAge:number
|
||||
}
|
||||
|
||||
export interface CacheRules {
|
||||
cacheMaxAge:MaxAgeRegexRule[],
|
||||
cacheAlways:RegexRule[],
|
||||
cacheNever:RegexRule[],
|
||||
default:string
|
||||
}
|
||||
|
||||
export interface FileStorageConfig extends privateN.StorageConfig {
|
||||
dir:string;
|
||||
}
|
||||
|
||||
export interface RedisStorageConfig extends privateN.StorageConfig {
|
||||
host:string;
|
||||
port:number;
|
||||
path?:string;
|
||||
url?:string;
|
||||
socket_keepalive?:boolean;
|
||||
password?:string;
|
||||
db?:string;
|
||||
}
|
||||
|
||||
namespace privateN {
|
||||
interface StorageConfig {
|
||||
type:string
|
||||
}
|
||||
|
||||
interface CacheStorage {
|
||||
isCached():Promise<boolean>;
|
||||
removeUrl():Promise<boolean>;
|
||||
getUrl():Promise<string>;
|
||||
cache(html:string):Promise<boolean>;
|
||||
cache(html:string, force:boolean):Promise<boolean>;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
abstract class CacheCategory {
|
||||
constructor(currentUrl:string, _config:CacheRules) ;
|
||||
private getRegexTest(u:RegexRule):boolean;
|
||||
private getCacheCategory():string;
|
||||
public getCategory():string;
|
||||
public getCurrentUrl():string;
|
||||
}
|
||||
|
||||
module RedisPool {
|
||||
export function connect(config:RedisStorageConfig): redis.RedisClient;
|
||||
export function isOnline():boolean;
|
||||
export function kill():void;
|
||||
}
|
||||
}
|
||||
|
||||
export class FileStorage extends privateN.CacheCategory implements privateN.CacheStorage {
|
||||
constructor(_url:string, _storageConfig: FileStorageConfig, _regexRules: CacheRules);
|
||||
isCached():Promise<boolean>;
|
||||
removeUrl():Promise<boolean>;
|
||||
getUrl():Promise<string>;
|
||||
cache(html:string):Promise<boolean>
|
||||
cache(html:string, force:boolean):Promise<boolean>;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export class RedisStorage extends privateN.CacheCategory implements privateN.CacheStorage {
|
||||
constructor(_url:string, _storageConfig: RedisStorageConfig, _regexRules: CacheRules);
|
||||
isCached():Promise<boolean>;
|
||||
removeUrl():Promise<boolean>;
|
||||
getUrl():Promise<string>;
|
||||
cache(html:string):Promise<boolean>;
|
||||
cache(html:string, force:boolean):Promise<boolean>;
|
||||
destroy(): void;
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -66,6 +66,7 @@ declare namespace SourceMap {
|
||||
public setSourceContent(sourceFile: string, sourceContent: string): void;
|
||||
public applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void;
|
||||
public toString(): string;
|
||||
public toJSON(): RawSourceMap;
|
||||
}
|
||||
|
||||
class SourceNode {
|
||||
|
||||
@@ -0,0 +1,682 @@
|
||||
/// <reference path="spdy.d.ts" />
|
||||
|
||||
// copied unit tests from https://github.com/indutny/node-spdy/tree/a583cf6/test
|
||||
|
||||
import * as spdy from 'spdy';
|
||||
|
||||
let describe: any;
|
||||
let it: any;
|
||||
let fixtures: any;
|
||||
let http: any;
|
||||
let https: any;
|
||||
let util: any;
|
||||
let assert: any;
|
||||
let afterEach: any;
|
||||
let beforeEach: any;
|
||||
let net: any;
|
||||
let tls: any;
|
||||
let transport: any;
|
||||
|
||||
describe('SPDY Client', () => {
|
||||
describe('regular', () => {
|
||||
fixtures.everyConfig((protocol: any, npn: string, version: string, plain: boolean) => {
|
||||
let server: any;
|
||||
let agent: any;
|
||||
let hmodule: any;
|
||||
|
||||
beforeEach((done: any) => {
|
||||
hmodule = plain ? http : https;
|
||||
|
||||
const options = util._extend({
|
||||
spdy: {
|
||||
plain: plain
|
||||
}
|
||||
}, fixtures.keys);
|
||||
server = spdy.createServer(options, (req: any, res: any) => {
|
||||
let body = '';
|
||||
req.on('data', (chunk: any) => {
|
||||
body += chunk;
|
||||
});
|
||||
req.on('end', () => {
|
||||
res.writeHead(200, req.headers);
|
||||
res.addTrailers({ trai: 'ler' });
|
||||
|
||||
const push = res.push('/push', {
|
||||
request: {
|
||||
push: 'yes'
|
||||
}
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
push.end('push');
|
||||
push.on('error', () => {
|
||||
});
|
||||
|
||||
res.end(body || 'okay');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(fixtures.port, () => {
|
||||
agent = spdy.createAgent({
|
||||
rejectUnauthorized: false,
|
||||
port: <number>fixtures.port,
|
||||
spdy: {
|
||||
plain: plain,
|
||||
protocol: plain ? npn : null,
|
||||
protocols: [ npn ]
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach((done: any) => {
|
||||
let waiting = 2;
|
||||
agent.close(next);
|
||||
server.close(next);
|
||||
|
||||
function next() {
|
||||
if (--waiting === 0)
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should send GET request', (done: any) => {
|
||||
const req = hmodule.request({
|
||||
agent: agent,
|
||||
|
||||
method: 'GET',
|
||||
path: '/get',
|
||||
headers: {
|
||||
a: 'b'
|
||||
}
|
||||
}, (res: any) => {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(res.headers.a, 'b');
|
||||
|
||||
fixtures.expectData(res, 'okay', done);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
|
||||
it('should send POST request', (done: any) => {
|
||||
const req = hmodule.request({
|
||||
agent: agent,
|
||||
|
||||
method: 'POST',
|
||||
path: '/post',
|
||||
|
||||
headers: {
|
||||
post: 'headers'
|
||||
}
|
||||
}, (res: any) => {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(res.headers.post, 'headers');
|
||||
|
||||
fixtures.expectData(res, 'post body', done);
|
||||
});
|
||||
|
||||
agent._spdyState.socket.once(plain ? 'connect' : 'secureConnect',
|
||||
() => {
|
||||
req.end('post body');
|
||||
});
|
||||
});
|
||||
|
||||
it('should receive PUSH_PROMISE', (done: any) => {
|
||||
const req = hmodule.request({
|
||||
agent: agent,
|
||||
|
||||
method: 'GET',
|
||||
path: '/get'
|
||||
}, (res: any) => {
|
||||
assert.equal(res.statusCode, 200);
|
||||
|
||||
res.resume();
|
||||
});
|
||||
req.on('push', (push: any) => {
|
||||
assert.equal(push.path, '/push');
|
||||
assert.equal(push.headers.push, 'yes');
|
||||
|
||||
push.resume();
|
||||
push.once('end', done);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
|
||||
it('should receive trailing headers', (done: any) => {
|
||||
var req = hmodule.request({
|
||||
agent: agent,
|
||||
|
||||
method: 'GET',
|
||||
path: '/get'
|
||||
}, (res: any) => {
|
||||
assert.equal(res.statusCode, 200);
|
||||
|
||||
res.on('trailers', (headers: any) => {
|
||||
assert.equal(headers.trai, 'ler');
|
||||
fixtures.expectData(res, 'okay', done);
|
||||
});
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('x-forwarded-for', () => {
|
||||
fixtures.everyConfig((protocol: any, npn: any, version: string, plain: boolean) => {
|
||||
let server: any;
|
||||
let agent: any;
|
||||
let hmodule: any;
|
||||
|
||||
beforeEach((done: any) => {
|
||||
hmodule = plain ? http : https;
|
||||
|
||||
const options = util._extend({
|
||||
spdy: {
|
||||
plain: plain,
|
||||
'x-forwarded-for': true
|
||||
}
|
||||
}, fixtures.keys);
|
||||
server = spdy.createServer(options, (req: any, res: any) => {
|
||||
res.writeHead(200, req.headers);
|
||||
res.end();
|
||||
});
|
||||
|
||||
server.listen(fixtures.port, () => {
|
||||
agent = spdy.createAgent({
|
||||
rejectUnauthorized: false,
|
||||
port: fixtures.port,
|
||||
spdy: {
|
||||
'x-forwarded-for': '1.2.3.4',
|
||||
plain: plain,
|
||||
protocol: plain ? npn : null,
|
||||
protocols: [ npn ]
|
||||
}
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach((done: any) => {
|
||||
let waiting = 2;
|
||||
agent.close(next);
|
||||
server.close(next);
|
||||
|
||||
function next() {
|
||||
if (--waiting === 0)
|
||||
done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should send x-forwarded-for', (done: any) => {
|
||||
var req = hmodule.request({
|
||||
agent: agent,
|
||||
|
||||
method: 'GET',
|
||||
path: '/get'
|
||||
}, (res: any) => {
|
||||
assert.equal(res.statusCode, 200);
|
||||
assert.equal(res.headers['x-forwarded-for'], '1.2.3.4');
|
||||
|
||||
res.resume();
|
||||
res.once('end', done);
|
||||
});
|
||||
req.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('SPDY Server', () => {
|
||||
fixtures.everyConfig((protocol: any, npn: any, version: number, plain: boolean) => {
|
||||
let server: any; // spdy.Server;
|
||||
let client: any;
|
||||
|
||||
beforeEach((done: any) => {
|
||||
server = spdy.createServer(util._extend({
|
||||
spdy: {
|
||||
'x-forwarded-for': true,
|
||||
plain: plain
|
||||
}
|
||||
}, fixtures.keys));
|
||||
|
||||
server.listen(fixtures.port, () => {
|
||||
const socket = (plain ? net : tls).connect({
|
||||
rejectUnauthorized: false,
|
||||
port: fixtures.port,
|
||||
NPNProtocols: [ npn ]
|
||||
}, () => {
|
||||
client = transport.connection.create(socket, {
|
||||
protocol: protocol,
|
||||
isServer: false
|
||||
});
|
||||
client.start(version);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach((done: any) => {
|
||||
client.socket.destroy();
|
||||
server.close(done);
|
||||
});
|
||||
|
||||
it('should process GET request', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'GET',
|
||||
path: '/get',
|
||||
headers: {
|
||||
a: 'b'
|
||||
}
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.on('response', (status: any, headers: any) => {
|
||||
assert.equal(status, 200);
|
||||
assert.equal(headers.ok, 'yes');
|
||||
|
||||
fixtures.expectData(stream, 'response', done);
|
||||
});
|
||||
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
assert.equal(req.isSpdy, res.isSpdy);
|
||||
assert.equal(req.spdyVersion, res.spdyVersion);
|
||||
assert(req.isSpdy);
|
||||
if (!plain) {
|
||||
const socket = <any>req.socket;
|
||||
assert(socket.encrypted);
|
||||
assert(socket.getPeerCertificate());
|
||||
}
|
||||
|
||||
// Auto-detection
|
||||
if (version === 3.1)
|
||||
assert(req.spdyVersion >= 3 && req.spdyVersion <= 3.1);
|
||||
else
|
||||
assert.equal(req.spdyVersion, version);
|
||||
assert(req.spdyStream);
|
||||
assert(res.spdyStream);
|
||||
|
||||
assert.equal(req.method, 'GET');
|
||||
assert.equal(req.url, '/get');
|
||||
assert.deepEqual(req.headers, { a: 'b', host: 'localhost' });
|
||||
|
||||
req.on('end', () => {
|
||||
res.writeHead(200, {
|
||||
ok: 'yes'
|
||||
});
|
||||
res.end('response');
|
||||
assert(res.finished, 'res.finished should be set');
|
||||
});
|
||||
req.resume();
|
||||
});
|
||||
});
|
||||
|
||||
it('should process POST request', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'POST',
|
||||
path: '/post'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.on('response', (status: any, headers: any) => {
|
||||
assert.equal(status, 200);
|
||||
assert.equal(headers.ok, 'yes');
|
||||
|
||||
fixtures.expectData(stream, 'response', next);
|
||||
});
|
||||
|
||||
stream.end('request');
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
assert.equal(req.method, 'POST');
|
||||
assert.equal(req.url, '/post');
|
||||
|
||||
res.writeHead(200, {
|
||||
ok: 'yes'
|
||||
});
|
||||
res.end('response');
|
||||
|
||||
fixtures.expectData(req, 'request', next);
|
||||
});
|
||||
|
||||
let waiting = 2;
|
||||
function next() {
|
||||
if (--waiting === 0)
|
||||
return done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should process expect-continue request', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'GET',
|
||||
path: '/get',
|
||||
headers: {
|
||||
Expect: '100-continue'
|
||||
}
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.on('response', (status: any, headers: any) => {
|
||||
assert.equal(status, 100);
|
||||
|
||||
fixtures.expectData(stream, 'response', done);
|
||||
});
|
||||
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
req.on('end', () => {
|
||||
res.end('response');
|
||||
});
|
||||
req.resume();
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit `checkContinue` request', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'GET',
|
||||
path: '/get',
|
||||
headers: {
|
||||
Expect: '100-continue'
|
||||
}
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.on('response', (status: any, headers: any) => {
|
||||
assert.equal(status, 100);
|
||||
|
||||
fixtures.expectData(stream, 'response', done);
|
||||
});
|
||||
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('checkContinue', (req: any, res: any) => {
|
||||
req.on('end', () => {
|
||||
res.writeContinue();
|
||||
res.end('response');
|
||||
});
|
||||
req.resume();
|
||||
});
|
||||
});
|
||||
|
||||
it('should send PUSH_PROMISE', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'POST',
|
||||
path: '/page'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.on('pushPromise', (push: any) => {
|
||||
assert.equal(push.path, '/push');
|
||||
assert.equal(push.headers.yes, 'push');
|
||||
|
||||
fixtures.expectData(push, 'push', next);
|
||||
fixtures.expectData(stream, 'response', next);
|
||||
});
|
||||
|
||||
stream.end('request');
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
assert.equal(req.method, 'POST');
|
||||
assert.equal(req.url, '/page');
|
||||
|
||||
res.writeHead(200, {
|
||||
ok: 'yes'
|
||||
});
|
||||
|
||||
const push = res.push('/push', {
|
||||
request: {
|
||||
yes: 'push'
|
||||
}
|
||||
});
|
||||
push.end('push');
|
||||
|
||||
res.end('response');
|
||||
|
||||
fixtures.expectData(req, 'request', next);
|
||||
});
|
||||
|
||||
let waiting = 3;
|
||||
function next() {
|
||||
if (--waiting === 0)
|
||||
return done();
|
||||
}
|
||||
});
|
||||
|
||||
it('should receive trailing headers', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'POST',
|
||||
path: '/post'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.sendHeaders({ trai: 'ler' });
|
||||
stream.end();
|
||||
|
||||
stream.on('response', (status: any, headers: any) => {
|
||||
assert.equal(status, 200);
|
||||
assert.equal(headers.ok, 'yes');
|
||||
|
||||
fixtures.expectData(stream, 'response', done);
|
||||
});
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
let gotHeaders = false;
|
||||
req.on('trailers', (headers: any) => {
|
||||
gotHeaders = true;
|
||||
assert.equal(headers.trai, 'ler');
|
||||
});
|
||||
|
||||
req.on('end', () => {
|
||||
assert(gotHeaders);
|
||||
|
||||
res.writeHead(200, {
|
||||
ok: 'yes'
|
||||
});
|
||||
res.end('response');
|
||||
});
|
||||
req.resume();
|
||||
});
|
||||
});
|
||||
|
||||
it('should call .writeHead() automatically', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'POST',
|
||||
path: '/post'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.on('response', (status: any, headers: any) => {
|
||||
assert.equal(status, 300);
|
||||
|
||||
fixtures.expectData(stream, 'response', done);
|
||||
});
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
req.on('end', () => {
|
||||
res.statusCode = 300;
|
||||
res.end('response');
|
||||
});
|
||||
req.resume();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not crash on .writeHead() after socket close', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'POST',
|
||||
path: '/post'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
setTimeout(() => {
|
||||
client.socket.destroy();
|
||||
}, 50);
|
||||
stream.on('error', () => {});
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
req.connection.on('close', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
res.writeHead(200);
|
||||
res.end('response');
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not crash on .push() after socket close', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'POST',
|
||||
path: '/post'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
setTimeout(() => {
|
||||
client.socket.destroy();
|
||||
}, 50);
|
||||
stream.on('error', () => {});
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
req.connection.on('close', () => {
|
||||
assert.doesNotThrow(() => {
|
||||
assert.equal(res.push('/push', {}), undefined);
|
||||
res.end('response');
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should end response after writing everything down', (done: any) => {
|
||||
const stream = client.request({
|
||||
method: 'GET',
|
||||
path: '/post'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.on('response', (status: any, headers: any) => {
|
||||
assert.equal(status, 200);
|
||||
|
||||
fixtures.expectData(stream, 'hello world, what\'s up?', done);
|
||||
});
|
||||
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
req.resume();
|
||||
res.writeHead(200);
|
||||
res.write('hello ');
|
||||
res.write('world');
|
||||
res.write(', what\'s');
|
||||
res.write(' up?');
|
||||
res.end();
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle x-forwarded-for', (done: any) => {
|
||||
client.sendXForwardedFor('1.2.3.4');
|
||||
|
||||
const stream = client.request({
|
||||
method: 'GET',
|
||||
path: '/post'
|
||||
}, (err: any) => {
|
||||
assert(!err);
|
||||
|
||||
stream.resume();
|
||||
stream.on('end', done);
|
||||
stream.end();
|
||||
});
|
||||
|
||||
server.on('request', (req: any, res: any) => {
|
||||
assert.equal(req.headers['x-forwarded-for'], '1.2.3.4');
|
||||
req.resume();
|
||||
res.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should respond to http/1.1', (done: any) => {
|
||||
const server = spdy.createServer(fixtures.keys, (req: any, res: any) => {
|
||||
assert.equal(req.isSpdy, res.isSpdy);
|
||||
assert.equal(req.spdyVersion, res.spdyVersion);
|
||||
assert(!req.isSpdy);
|
||||
assert.equal(req.spdyVersion, 1);
|
||||
|
||||
res.writeHead(200);
|
||||
res.end();
|
||||
});
|
||||
|
||||
server.listen(fixtures.port, () => {
|
||||
const req = https.request({
|
||||
agent: false,
|
||||
rejectUnauthorized: false,
|
||||
NPNProtocols: [ 'http/1.1' ],
|
||||
port: fixtures.port,
|
||||
method: 'GET',
|
||||
path: '/'
|
||||
}, (res: any) => {
|
||||
assert.equal(res.statusCode, 200);
|
||||
res.resume();
|
||||
res.on('end', () => {
|
||||
server.close(done);
|
||||
});
|
||||
});
|
||||
|
||||
req.end();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support custom base', (done: any) => {
|
||||
function Pseuver(options: spdy.ServerOptions, listener: Function) {
|
||||
https.Server.call(this, options, listener);
|
||||
}
|
||||
util.inherits(Pseuver, https.Server);
|
||||
|
||||
const server = spdy.createServer(Pseuver, fixtures.keys, (req: any, res: any) => {
|
||||
assert.equal(req.isSpdy, res.isSpdy);
|
||||
assert.equal(req.spdyVersion, res.spdyVersion);
|
||||
assert(!req.isSpdy);
|
||||
assert.equal(req.spdyVersion, 1);
|
||||
|
||||
res.writeHead(200);
|
||||
res.end();
|
||||
});
|
||||
|
||||
server.listen(fixtures.port, () => {
|
||||
const req = https.request({
|
||||
agent: false,
|
||||
rejectUnauthorized: false,
|
||||
NPNProtocols: [ 'http/1.1' ],
|
||||
port: fixtures.port,
|
||||
method: 'GET',
|
||||
path: '/'
|
||||
}, (res: any) => {
|
||||
assert.equal(res.statusCode, 200);
|
||||
res.resume();
|
||||
res.on('end', () => {
|
||||
server.close(done);
|
||||
});
|
||||
});
|
||||
|
||||
req.end();
|
||||
});
|
||||
});
|
||||
});
|
||||
Vendored
+412
@@ -0,0 +1,412 @@
|
||||
// Type definitions for node-spdy v3.4.3
|
||||
// Project: https://github.com/indutny/node-spdy
|
||||
// Definitions by: Anthony Trinh <https://github.com/tony19>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "spdy" {
|
||||
// lib/spdy/agent.js
|
||||
namespace agent {
|
||||
export class Agent extends node.https.Agent {}
|
||||
export class PlainAgent extends node.http.Agent {}
|
||||
export function create(base: any, options: AgentOptions): Agent | PlainAgent;
|
||||
|
||||
export interface AgentOptions extends node.https.AgentOptions {
|
||||
port?: number,
|
||||
spdy?: {
|
||||
plain?: boolean,
|
||||
ssl?: boolean,
|
||||
'x-forwarded-for'?: string,
|
||||
protocol?: string,
|
||||
protocols?: string[]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// lib/spdy/handle.js
|
||||
export interface Handle {
|
||||
create(options: Object, stream: any, socket: Socket): Handle;
|
||||
getStream(callback?: Function): any;
|
||||
assignSocket(socket: Socket, options: Object): void;
|
||||
assignClientRequest(req: any): void;
|
||||
assignRequest(req: any): void;
|
||||
assignResponse(res: any): void;
|
||||
emitRequest(): void;
|
||||
emitResponse(status: any, headers: any): void;
|
||||
}
|
||||
|
||||
// lib/spdy/request.js
|
||||
namespace request {
|
||||
export function onNewListener(type: string): void;
|
||||
}
|
||||
|
||||
// lib/spdy/response.js
|
||||
namespace response {
|
||||
export function writeHead(statusCode: number, reason: string, obj: Object): void;
|
||||
export function writeHead(statusCode: number, obj: Object): void;
|
||||
export function end(data: any, encoding: string, callback: Function): void;
|
||||
}
|
||||
|
||||
// lib/spdy/server.js
|
||||
namespace server {
|
||||
export interface Server extends node.https.Server {}
|
||||
export interface PlainServer extends node.http.Server {}
|
||||
export interface IncomingMessage extends node.http.IncomingMessage {}
|
||||
export interface ServerResponse extends node.http.ServerResponse {
|
||||
push(filename: string, options: PushOptions): any;
|
||||
}
|
||||
export function create(base: any,
|
||||
options: node.https.ServerOptions,
|
||||
handler: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
export function create(options: node.https.ServerOptions,
|
||||
handler: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
export function create(handler: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
|
||||
export type Protocol =
|
||||
'h2'
|
||||
| 'spdy/3.1'
|
||||
| 'spdy/3'
|
||||
| 'spdy/2'
|
||||
| 'http/1.1'
|
||||
| 'http/1.0';
|
||||
|
||||
export interface PushOptions {
|
||||
status?: number,
|
||||
method?: string,
|
||||
request?: any,
|
||||
response?: any
|
||||
}
|
||||
|
||||
export interface ServerOptions extends node.https.ServerOptions {
|
||||
spdy?: {
|
||||
protocols?: Protocol[],
|
||||
plain?: boolean,
|
||||
'x-forwarded-for'?: boolean,
|
||||
connection?: {
|
||||
windowSize?: number,
|
||||
autoSpdy31?: boolean,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// copied from definitions of Node 6.7.0
|
||||
namespace node {
|
||||
namespace http {
|
||||
interface Server extends net.Server {
|
||||
setTimeout(msecs: number, callback: Function): any;
|
||||
|
||||
maxHeadersCount: number;
|
||||
timeout: number;
|
||||
listening: boolean;
|
||||
}
|
||||
|
||||
interface AgentOptions {
|
||||
/**
|
||||
* Keep sockets around in a pool to be used by other requests in the future. Default = false
|
||||
*/
|
||||
keepAlive?: boolean;
|
||||
/**
|
||||
* When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
|
||||
* Only relevant if keepAlive is set to true.
|
||||
*/
|
||||
keepAliveMsecs?: number;
|
||||
/**
|
||||
* Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
|
||||
*/
|
||||
maxSockets?: number;
|
||||
/**
|
||||
* Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
|
||||
*/
|
||||
maxFreeSockets?: number;
|
||||
}
|
||||
|
||||
class Agent {
|
||||
maxSockets: number;
|
||||
sockets: any;
|
||||
requests: any;
|
||||
|
||||
constructor(opts?: AgentOptions);
|
||||
|
||||
/**
|
||||
* Destroy any sockets that are currently in use by the agent.
|
||||
* It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
|
||||
* then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
|
||||
* sockets may hang open for quite a long time before the server terminates them.
|
||||
*/
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
export interface IncomingMessage {
|
||||
path: string;
|
||||
httpVersion: string;
|
||||
httpVersionMajor: number;
|
||||
httpVersionMinor: number;
|
||||
connection: any;
|
||||
headers: any;
|
||||
rawHeaders: string[];
|
||||
trailers: any;
|
||||
rawTrailers: any;
|
||||
setTimeout(msecs: number, callback: Function): any;
|
||||
/**
|
||||
* Only valid for request obtained from http.Server.
|
||||
*/
|
||||
method?: string;
|
||||
/**
|
||||
* Only valid for request obtained from http.Server.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Only valid for response obtained from http.ClientRequest.
|
||||
*/
|
||||
statusCode?: number;
|
||||
/**
|
||||
* Only valid for response obtained from http.ClientRequest.
|
||||
*/
|
||||
statusMessage?: string;
|
||||
socket: any;
|
||||
destroy(error?: Error): void;
|
||||
get(name: string): string;
|
||||
}
|
||||
|
||||
export interface ServerResponse {
|
||||
// Extended base methods
|
||||
write(buffer: any): boolean;
|
||||
write(buffer: any, cb?: Function): boolean;
|
||||
write(str: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, cb?: Function): boolean;
|
||||
write(str: string, encoding?: string, fd?: string): boolean;
|
||||
|
||||
writeContinue(): void;
|
||||
writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
|
||||
writeHead(statusCode: number, headers?: any): void;
|
||||
statusCode: number;
|
||||
statusMessage: string;
|
||||
headersSent: boolean;
|
||||
setHeader(name: string, value: string | string[]): void;
|
||||
setTimeout(msecs: number, callback: Function): ServerResponse;
|
||||
sendDate: boolean;
|
||||
getHeader(name: string): string;
|
||||
removeHeader(name: string): void;
|
||||
write(chunk: any, encoding?: string): any;
|
||||
addTrailers(headers: any): void;
|
||||
finished: boolean;
|
||||
|
||||
// Extended base methods
|
||||
end(): void;
|
||||
end(buffer: any, cb?: Function): void;
|
||||
end(str: string, cb?: Function): void;
|
||||
end(str: string, encoding?: string, cb?: Function): void;
|
||||
end(data?: any, encoding?: string): void;
|
||||
}
|
||||
}
|
||||
|
||||
namespace https {
|
||||
interface Server extends tls.Server {
|
||||
close(callback?: Function): Server;
|
||||
}
|
||||
|
||||
interface ServerOptions {
|
||||
pfx?: any;
|
||||
key?: any;
|
||||
passphrase?: string;
|
||||
cert?: any;
|
||||
ca?: any;
|
||||
crl?: any;
|
||||
ciphers?: string;
|
||||
honorCipherOrder?: boolean;
|
||||
requestCert?: boolean;
|
||||
rejectUnauthorized?: boolean;
|
||||
NPNProtocols?: any;
|
||||
SNICallback?: (servername: string, cb: (err: Error, ctx: tls.SecureContext) => any) => any;
|
||||
}
|
||||
|
||||
class Agent extends http.Agent {}
|
||||
|
||||
interface AgentOptions extends http.AgentOptions {
|
||||
pfx?: any;
|
||||
key?: any;
|
||||
passphrase?: string;
|
||||
cert?: any;
|
||||
ca?: any;
|
||||
ciphers?: string;
|
||||
rejectUnauthorized?: boolean;
|
||||
secureProtocol?: string;
|
||||
maxCachedSessions?: number;
|
||||
}
|
||||
}
|
||||
|
||||
namespace tls {
|
||||
interface Server extends net.Server {
|
||||
close(): Server;
|
||||
address(): { port: number; family: string; address: string; };
|
||||
addContext(hostName: string, credentials: {
|
||||
key: string;
|
||||
cert: string;
|
||||
ca: string;
|
||||
}): void;
|
||||
maxConnections: number;
|
||||
connections: number;
|
||||
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. tlsClientError
|
||||
* 2. newSession
|
||||
* 3. OCSPRequest
|
||||
* 4. resumeSession
|
||||
* 5. secureConnection
|
||||
**/
|
||||
addListener(event: string, listener: Function): this;
|
||||
addListener(event: "tlsClientError", listener: (err: Error, tlsSocket: any) => void): this;
|
||||
addListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: any) => void) => void): this;
|
||||
addListener(event: "OCSPRequest", listener: (certificate: any, issuer: any, callback: Function) => void): this;
|
||||
addListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
|
||||
addListener(event: "secureConnection", listener: (tlsSocket: any) => void): this;
|
||||
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: "tlsClientError", err: Error, tlsSocket: any): boolean;
|
||||
emit(event: "newSession", sessionId: any, sessionData: any, callback: (err: Error, resp: any) => void): boolean;
|
||||
emit(event: "OCSPRequest", certificate: any, issuer: any, callback: Function): boolean;
|
||||
emit(event: "resumeSession", sessionId: any, callback: (err: Error, sessionData: any) => void): boolean;
|
||||
emit(event: "secureConnection", tlsSocket: any): boolean;
|
||||
|
||||
on(event: string, listener: Function): this;
|
||||
on(event: "tlsClientError", listener: (err: Error, tlsSocket: any) => void): this;
|
||||
on(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: any) => void) => void): this;
|
||||
on(event: "OCSPRequest", listener: (certificate: any, issuer: any, callback: Function) => void): this;
|
||||
on(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
|
||||
on(event: "secureConnection", listener: (tlsSocket: any) => void): this;
|
||||
|
||||
once(event: string, listener: Function): this;
|
||||
once(event: "tlsClientError", listener: (err: Error, tlsSocket: any) => void): this;
|
||||
once(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: any) => void) => void): this;
|
||||
once(event: "OCSPRequest", listener: (certificate: any, issuer: any, callback: Function) => void): this;
|
||||
once(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
|
||||
once(event: "secureConnection", listener: (tlsSocket: any) => void): this;
|
||||
|
||||
prependListener(event: string, listener: Function): this;
|
||||
prependListener(event: "tlsClientError", listener: (err: Error, tlsSocket: any) => void): this;
|
||||
prependListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: any) => void) => void): this;
|
||||
prependListener(event: "OCSPRequest", listener: (certificate: any, issuer: any, callback: Function) => void): this;
|
||||
prependListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
|
||||
prependListener(event: "secureConnection", listener: (tlsSocket: any) => void): this;
|
||||
|
||||
prependOnceListener(event: string, listener: Function): this;
|
||||
prependOnceListener(event: "tlsClientError", listener: (err: Error, tlsSocket: any) => void): this;
|
||||
prependOnceListener(event: "newSession", listener: (sessionId: any, sessionData: any, callback: (err: Error, resp: any) => void) => void): this;
|
||||
prependOnceListener(event: "OCSPRequest", listener: (certificate: any, issuer: any, callback: Function) => void): this;
|
||||
prependOnceListener(event: "resumeSession", listener: (sessionId: any, callback: (err: Error, sessionData: any) => void) => void): this;
|
||||
prependOnceListener(event: "secureConnection", listener: (tlsSocket: any) => void): this;
|
||||
}
|
||||
|
||||
interface SecureContext {
|
||||
context: any;
|
||||
}
|
||||
}
|
||||
|
||||
namespace net {
|
||||
interface Server {
|
||||
// net.Server
|
||||
listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server;
|
||||
listen(port: number, hostname?: string, listeningListener?: Function): Server;
|
||||
listen(port: number, backlog?: number, listeningListener?: Function): Server;
|
||||
listen(port: number, listeningListener?: Function): Server;
|
||||
listen(path: string, backlog?: number, listeningListener?: Function): Server;
|
||||
listen(path: string, listeningListener?: Function): Server;
|
||||
listen(handle: any, backlog?: number, listeningListener?: Function): Server;
|
||||
listen(handle: any, listeningListener?: Function): Server;
|
||||
listen(options: ListenOptions, listeningListener?: Function): Server;
|
||||
|
||||
close(callback?: Function): Server;
|
||||
|
||||
address(): { port: number; family: string; address: string; };
|
||||
|
||||
getConnections(cb: (error: Error, count: number) => void): void;
|
||||
|
||||
ref(): Server;
|
||||
|
||||
unref(): Server;
|
||||
|
||||
maxConnections: number;
|
||||
connections: number;
|
||||
|
||||
/**
|
||||
* events.EventEmitter
|
||||
* 1. close
|
||||
* 2. connection
|
||||
* 3. error
|
||||
* 4. listening
|
||||
*/
|
||||
addListener(event: string, listener: Function): this;
|
||||
addListener(event: "close", listener: () => void): this;
|
||||
addListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||
addListener(event: "error", listener: (err: Error) => void): this;
|
||||
addListener(event: "listening", listener: () => void): this;
|
||||
|
||||
emit(event: string, ...args: any[]): boolean;
|
||||
emit(event: "close"): boolean;
|
||||
emit(event: "connection", socket: Socket): boolean;
|
||||
emit(event: "error", err: Error): boolean;
|
||||
emit(event: "listening"): boolean;
|
||||
|
||||
on(event: string, listener: Function): this;
|
||||
on(event: "close", listener: () => void): this;
|
||||
on(event: "connection", listener: (socket: Socket) => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "listening", listener: () => void): this;
|
||||
|
||||
once(event: string, listener: Function): this;
|
||||
once(event: "close", listener: () => void): this;
|
||||
once(event: "connection", listener: (socket: Socket) => void): this;
|
||||
once(event: "error", listener: (err: Error) => void): this;
|
||||
once(event: "listening", listener: () => void): this;
|
||||
|
||||
prependListener(event: string, listener: Function): this;
|
||||
prependListener(event: "close", listener: () => void): this;
|
||||
prependListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||
prependListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependListener(event: "listening", listener: () => void): this;
|
||||
|
||||
prependOnceListener(event: string, listener: Function): this;
|
||||
prependOnceListener(event: "close", listener: () => void): this;
|
||||
prependOnceListener(event: "connection", listener: (socket: Socket) => void): this;
|
||||
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
||||
prependOnceListener(event: "listening", listener: () => void): this;
|
||||
}
|
||||
|
||||
interface ListenOptions {
|
||||
port?: number;
|
||||
host?: string;
|
||||
backlog?: number;
|
||||
path?: string;
|
||||
exclusive?: boolean;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// lib/spdy/socket.js
|
||||
namespace socket {
|
||||
export interface Socket {
|
||||
// net.Socket
|
||||
}
|
||||
}
|
||||
|
||||
// lib/spdy.js
|
||||
export type Agent = agent.Agent;
|
||||
export type PlainAgent = agent.PlainAgent;
|
||||
export type AgentOptions = agent.AgentOptions;
|
||||
export type Socket = socket.Socket;
|
||||
export type Server = server.Server;
|
||||
export type IncomingMessage = server.IncomingMessage;
|
||||
export type ServerRequest = server.IncomingMessage;
|
||||
export type ServerResponse = server.ServerResponse;
|
||||
export type PlainServer = server.PlainServer;
|
||||
export type ServerOptions = server.ServerOptions;
|
||||
export function createAgent(base: any, options: AgentOptions): Agent | PlainAgent;
|
||||
export function createAgent(options: AgentOptions): Agent | PlainAgent;
|
||||
export function createServer(base: any,
|
||||
options: ServerOptions,
|
||||
handler: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
export function createServer(options: ServerOptions,
|
||||
handler: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
export function createServer(handler: (request: IncomingMessage, response: ServerResponse) => void): Server;
|
||||
}
|
||||
Vendored
+6
-1
@@ -3076,6 +3076,11 @@ interface ObjectConstructor {
|
||||
**/
|
||||
map<T, U>(obj: T, map: (key: string, value: any) => any): U;
|
||||
|
||||
/**
|
||||
* @see map
|
||||
**/
|
||||
each(obj: any, map: (key: string, value: any) => void): void;
|
||||
|
||||
/**
|
||||
* @see map
|
||||
**/
|
||||
@@ -4174,7 +4179,7 @@ interface DateConstructor {
|
||||
* @example
|
||||
* Date.now() -> ex. 1311938296231
|
||||
**/
|
||||
now(): string;
|
||||
now(): number;
|
||||
|
||||
/**
|
||||
* Alternate form of %Date.create% with any ambiguity assumed to be the past.
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/// <reference path="transducers-js.d.ts" />
|
||||
/// <reference path="../lodash/lodash.d.ts" />
|
||||
/// <reference path="../immutable/immutable.d.ts" />
|
||||
|
||||
// tests taken from https://github.com/cognitect-labs/transducers-js
|
||||
|
||||
import * as t from 'transducers-js';
|
||||
|
||||
var map = t.map,
|
||||
filter = t.filter,
|
||||
comp = t.comp,
|
||||
into = t.into;
|
||||
|
||||
// basic usage
|
||||
|
||||
var inc = function(n: number) { return n + 1; };
|
||||
var isEven = function(n: number) { return n % 2 == 0; };
|
||||
var xf = comp(map(inc), filter(isEven));
|
||||
|
||||
console.log(into([], xf, [0,1,2,3,4])); // [2,4]
|
||||
|
||||
// integration
|
||||
|
||||
var arr = [0,1,2,3,4,5,6,7,8,9,10],
|
||||
apush = function(arr: number[], x: number) { arr.push(x); return arr; },
|
||||
xf = comp(map(inc), filter(isEven)),
|
||||
toFn = t.toFn;
|
||||
|
||||
arr.reduce(toFn(xf, apush), []); // native
|
||||
_(arr).reduce(toFn(xf, apush), []); // underscore or lodash
|
||||
|
||||
// immutable-js
|
||||
|
||||
import * as Immutable from 'immutable';
|
||||
|
||||
var inc = function(n: number): number { return n + 1; };
|
||||
var isEven = function(n: number): boolean { return n % 2 == 0; };
|
||||
var sum = function(a: number, b: number): number { return a + b; };
|
||||
var transduce = t.transduce;
|
||||
|
||||
var largeVector = Immutable.List();
|
||||
|
||||
for(var i = 0; i < 1000000; i++) {
|
||||
largeVector = largeVector.push(i);
|
||||
}
|
||||
|
||||
// built in Immutable-js functionality
|
||||
largeVector.map(inc).filter(isEven).reduce(sum);
|
||||
|
||||
// faster with transducers
|
||||
var xf = comp(map(inc),filter(isEven));
|
||||
transduce(xf, sum, 0, largeVector);
|
||||
|
||||
// source examples
|
||||
|
||||
function mapExample () {
|
||||
var inc = function(n: number) { return n+1; };
|
||||
var xf = t.map(inc);
|
||||
t.into([], xf, [1,2,3]); // [2,3,4]
|
||||
}
|
||||
|
||||
function filterExample () {
|
||||
var isEven = function(n: number) { return n % 2 == 0; };
|
||||
var xf = t.filter(isEven);
|
||||
t.into([], xf, [0,1,2,3,4]); // [0,2,4];
|
||||
}
|
||||
|
||||
function removeExample () {
|
||||
var isEven = function(n: number) { return n % 2 == 0; };
|
||||
var xf = t.remove(isEven);
|
||||
t.into([], xf, [0,1,2,3,4]); // [1,3];
|
||||
}
|
||||
|
||||
function complementExample () {
|
||||
var isEven = function(n: number) { return n % 2 == 0; };
|
||||
var isOdd = t.complement(isEven);
|
||||
}
|
||||
|
||||
function keepIndexedExample () {
|
||||
var xf = t.keepIndexed(function(i: number, x: string|number) { if (typeof x == "string") return "cool"; });
|
||||
t.into([], xf, [0,1,"foo",3,4,"bar"]); // ["foo","bar"]
|
||||
}
|
||||
|
||||
function takeExample () {
|
||||
var xf = t.take(3);
|
||||
t.into([], xf, [0,1,2,3,4,5]); // [0,1,2];
|
||||
}
|
||||
|
||||
function takeWhileExample () {
|
||||
var xf = t.takeWhile(function(n) { return n < 3; });
|
||||
t.into([], xf, [0,1,2,3,4,5]); // [0,1,2];
|
||||
}
|
||||
|
||||
function intoExample () {
|
||||
var inc = function(n: number) { return n+1; };
|
||||
var isEven = function(n: number) { return n % 2 == 0; };
|
||||
var apush = function(arr: number[], x: number) { arr.push(x); return arr; };
|
||||
var xf = t.comp(t.map(inc),t.filter(isEven));
|
||||
t.into([], xf, [1,2,3,4]); // [2,4]
|
||||
}
|
||||
|
||||
function toFnExample () {
|
||||
var arr = [0,1,2,3,4,5];
|
||||
var apush = function(arr: number[], x: number) { arr.push(x); return arr; };
|
||||
var xf = t.comp(t.map(inc),t.filter(isEven));
|
||||
arr.reduce(t.toFn(xf, apush), []); // [2,4,6]
|
||||
}
|
||||
|
||||
function takeNthExample () {
|
||||
var xf = t.takeNth(3);
|
||||
t.into([], xf, [0,1,2,3,4,5]); // [2,5];
|
||||
}
|
||||
|
||||
function dropExample () {
|
||||
var xf = t.drop(3);
|
||||
t.into([], xf, [0,1,2,3,4,5]); // [3,4,5];
|
||||
}
|
||||
|
||||
function dropWhileExample () {
|
||||
var xf = t.dropWhile(function(n: number) { return n < 3; });
|
||||
t.into([], xf, [0,1,2,3,4,5]); // [3,4,5];
|
||||
}
|
||||
|
||||
function partitionByExample () {
|
||||
var xf = t.partitionBy(function(x: string|number) { return typeof x == "string"; });
|
||||
t.into([], xf, [0,1,"foo","bar",2,3,"bar","baz"]); // [[0,1],["foo","bar"],[2,3],["bar","baz"]];
|
||||
}
|
||||
|
||||
function partitionAllExample () {
|
||||
var xf = t.partitionAll(3);
|
||||
t.into([], xf, [0,1,2,3,4,5]); // [[0,1,2],[3,4,5]]
|
||||
}
|
||||
|
||||
function wrapExample () {
|
||||
var arrayPush = t.wrap(function(arr: number[], x: number) { arr.push(x); return arr; });
|
||||
}
|
||||
|
||||
function ensureReducedExample () {
|
||||
var x = t.ensureReduced(1);
|
||||
var y = t.ensureReduced(x);
|
||||
x === y; // true
|
||||
}
|
||||
|
||||
function unreducedExample () {
|
||||
var x = t.reduced(1);
|
||||
t.unreduced(x); // 1
|
||||
t.unreduced(t.unreduced(x)); // 1
|
||||
}
|
||||
|
||||
function catExample () {
|
||||
var reverse = function(arr: number[]) {
|
||||
var arr: number[] = Array.prototype.slice.call(arr, 0);
|
||||
arr.reverse();
|
||||
return arr;
|
||||
};
|
||||
var xf = t.comp(t.map(reverse), t.cat);
|
||||
t.into([], xf, [[3,2,1],[6,5,4]]); // [1,2,3,4,5,6]
|
||||
}
|
||||
|
||||
function mapcatExample () {
|
||||
var reverse = function(arr: number[]) {
|
||||
var arr: number[] = Array.prototype.slice.call(arr, 0);
|
||||
arr.reverse();
|
||||
return arr;
|
||||
};
|
||||
var xf = t.mapcat(reverse);
|
||||
t.into([], xf, [[3,2,1],[6,5,4]]); // [1,2,3,4,5,6]
|
||||
}
|
||||
Vendored
+304
@@ -0,0 +1,304 @@
|
||||
// Type definitions for transducers-js
|
||||
// Project: https://github.com/cognitect-labs/transducers-js
|
||||
// Definitions by: Colin Kahn <https://github.com/colinkahn>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module 'transducers-js' {
|
||||
export interface IteratorResult<T> {
|
||||
done: boolean;
|
||||
value?: T
|
||||
}
|
||||
|
||||
export interface Iterator<T> {
|
||||
next (value?: any): IteratorResult<T>;
|
||||
return? (value?: any): IteratorResult<T>;
|
||||
throw? (e?: any): IteratorResult<T>;
|
||||
}
|
||||
|
||||
export interface Reduced<TResult> {
|
||||
['@@transducer/reduced']: boolean;
|
||||
['@@transducer/value']: TResult;
|
||||
}
|
||||
|
||||
export interface Reducer<TResult, TInput> {
|
||||
(result: TResult, input: TInput): TResult;
|
||||
}
|
||||
|
||||
export interface Transducer<TResult, TInput, TOutput> {
|
||||
(xf: Transformer<TResult, TOutput>): Transformer<TResult, TInput>;
|
||||
}
|
||||
|
||||
export interface CompletingTransformer <TResult, TCompleteResult, TInput> {
|
||||
['@@transducer/init'] (): TResult | void;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult | Reduced<TResult>;
|
||||
['@@transducer/result'] (result: TResult): TCompleteResult;
|
||||
}
|
||||
|
||||
export interface Transformer<TResult, TInput> extends CompletingTransformer<TResult, TResult, TInput> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reduced value. Reduced values short circuit transduce.
|
||||
*/
|
||||
export function reduced<TResult> (x: TResult): Reduced<TResult>;
|
||||
|
||||
/**
|
||||
* Check if a value is reduced.
|
||||
*/
|
||||
export function isReduced (x : any) : Boolean;
|
||||
|
||||
/**
|
||||
* Function composition. Take N function and return their composition.
|
||||
*/
|
||||
export function comp<T> (...args: T[]): T;
|
||||
|
||||
/**
|
||||
* Take a predicate function and return its complement.
|
||||
*/
|
||||
export function complement (f: Function): Function;
|
||||
|
||||
/**
|
||||
* Identity function.
|
||||
*/
|
||||
export function identity<T> (arg: T): T;
|
||||
|
||||
export class Map<TResult, TInput, TOutput> implements Transformer<TResult, TInput> {
|
||||
constructor (f: (x: TInput) => TOutput, xf: Transformer<TResult, TOutput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mapping transducer constructor
|
||||
*/
|
||||
export function map<TResult, TInput, TOutput> (f: (x: TInput) => TOutput): Transducer<TResult, TInput, TOutput>;
|
||||
|
||||
export class Filter<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (pred: (x: TInput) => boolean, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filtering transducer constructor
|
||||
*/
|
||||
export function filter<TResult, TInput> (pred: (x: TInput) => boolean): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
/**
|
||||
* Similar to filter except the predicate is used to
|
||||
* eliminate values.
|
||||
*/
|
||||
export function remove<TResult, TInput> (pred: (x: TInput) => boolean): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class Keep<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (f: (x: TInput) => any, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* A keeping transducer. Keep inputs as long as the provided
|
||||
* function does not return null or undefined.
|
||||
*/
|
||||
export function keep<TResult, TInput> (f: (x: TInput) => any): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class KeepIndexed<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (f: (i: number, x:TInput) => any, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like keep but the provided function will be passed the
|
||||
* index as the fist argument.
|
||||
*/
|
||||
export function keepIndexed<TResult, TInput> (f: (i: number, x: TInput) => any): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class Take<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (n: number, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult | Reduced<TResult>;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* A take transducer constructor. Will take n values before
|
||||
* returning a reduced result.
|
||||
*/
|
||||
export function take<TResult, TInput> (n: number): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class TakeWhile<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (pred: (n: TInput) => boolean, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult | Reduced<TResult>;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like the take transducer except takes as long as the pred
|
||||
* return true for inputs.
|
||||
*/
|
||||
export function takeWhile<TResult, TInput> (pred: (n: TInput) => boolean): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class TakeNth<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (n: number, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* A transducer that takes every Nth input
|
||||
*/
|
||||
export function takeNth<TResult, TInput> (n: number): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class Drop<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (n: number, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* A dropping transducer constructor
|
||||
*/
|
||||
export function drop<TResult, TInput> (n: number): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class DropWhile<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (pred: (input: TInput) => boolean, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult;
|
||||
['@@transducer/result'] (result: TResult): TResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* A dropping transducer that drop inputs as long as
|
||||
* pred is true.
|
||||
*/
|
||||
export function dropWhile<TResult, TInput> (pred: (input: TInput) => boolean): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
export class PartitionBy<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (f: (input: TInput) => any, xf: Transformer<TResult, TInput[]>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult
|
||||
['@@transducer/result'] (result: TResult): TResult
|
||||
}
|
||||
|
||||
/**
|
||||
* A partitioning transducer. Collects inputs into
|
||||
* arrays as long as predicate remains true for contiguous
|
||||
* inputs.
|
||||
*/
|
||||
export function partitionBy<TResult, TInput> (f: (input: TInput) => any): Transducer<TResult, TInput, TInput[]>;
|
||||
|
||||
export class PartitionAll<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (n: number, xf: Transformer<TResult, TInput[]>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult
|
||||
['@@transducer/result'] (result: TResult): TResult
|
||||
}
|
||||
|
||||
/**
|
||||
* A partitioning transducer. Collects inputs into
|
||||
* arrays of size N.
|
||||
*/
|
||||
export function partitionAll<TResult, TInput> (n: number): Transducer<TResult, TInput, TInput[]>;
|
||||
|
||||
export class Completing<TResult, TCompleteResult, TInput> implements CompletingTransformer<TResult, TCompleteResult, TInput> {
|
||||
constructor (cf: (result: TResult) => TCompleteResult, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult
|
||||
['@@transducer/result'] (result: TResult): TCompleteResult
|
||||
}
|
||||
|
||||
/**
|
||||
* A completing transducer constructor. Useful to provide cleanup
|
||||
* logic at the end of a reduction/transduction.
|
||||
*/
|
||||
export function completing<TResult, TCompleteResult, TInput> (cf: (result: TResult) => TCompleteResult): CompletingTransformer<TResult, TCompleteResult, TInput>;
|
||||
|
||||
export class Wrap<TResult, TInput> implements Transformer<TResult, TInput> {
|
||||
constructor (stepFn: Reducer<TResult, TInput>, xf: Transformer<TResult, TInput>);
|
||||
['@@transducer/init'] (): TResult;
|
||||
['@@transducer/step'] (result: TResult, input: TInput): TResult
|
||||
['@@transducer/result'] (result: TResult): TResult
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a two-arity reducing function where the first argument is the
|
||||
* accumluation and the second argument is the next input and convert
|
||||
* it into a transducer transformer object.
|
||||
*/
|
||||
export function wrap<TResult, TInput> (stepFn: Reducer<TResult, TInput>): Transducer<TResult, TInput, TInput>;
|
||||
|
||||
/**
|
||||
* Given a transformer return a concatenating transformer
|
||||
*/
|
||||
export function cat<TResult, TInput> (xf: Transformer<TResult, TInput>): Transformer<TResult, TInput> ;
|
||||
|
||||
/**
|
||||
* A mapping concatenating transformer
|
||||
*/
|
||||
export function mapcat<TResult, TInput, TOutput> (f: (arr: TInput[]) => TOutput[]): Transducer<TResult, TInput[], TOutput>;
|
||||
|
||||
/**
|
||||
* Given a transducer, a builder function, an initial value
|
||||
* and a iterable collection - returns the reduction.
|
||||
*/
|
||||
export function transduce<TResult, TInput, TOutput> (
|
||||
xf: Transducer<TResult, TInput, TOutput>,
|
||||
f: Transformer<TResult, TInput> | Reducer<TResult, TInput>,
|
||||
init: TResult,
|
||||
coll: TInput[] | Iterator<TInput> | string | Object): TResult;
|
||||
|
||||
/**
|
||||
* Given a transducer, an intial value and a
|
||||
* collection - returns the reduction.
|
||||
*/
|
||||
export function reduce<TResult, TInput, TOutput> (
|
||||
xf: Transducer<TResult, TInput, TOutput>,
|
||||
init: TResult,
|
||||
coll: TInput[] | Iterator<TInput> | string | Object): TResult
|
||||
|
||||
/**
|
||||
* Reduce a value into the given empty value using a transducer.
|
||||
*/
|
||||
export function into<TResult, TInput, TOutput>(
|
||||
empty: TResult,
|
||||
xf: Transducer<TResult, TInput, TOutput>,
|
||||
coll: TInput[] | Iterator<TInput> | string | Object): TResult;
|
||||
|
||||
/**
|
||||
* Convert a transducer transformer object into a function so
|
||||
* that it can be used with existing reduce implementation i.e. native,
|
||||
* Underscore, lodash
|
||||
*/
|
||||
export function toFn<TResult, TInput, TOutput> (
|
||||
xf: Transducer<TResult, TInput, TOutput>,
|
||||
builder: Reducer<TResult, TInput> | Transformer<TResult, TInput>
|
||||
): Reducer<TResult, TInput>;
|
||||
|
||||
/**
|
||||
* A transformer which simply returns the first input.
|
||||
*/
|
||||
export function first<TResult, TInput> (): Wrap<TResult, TInput>;
|
||||
|
||||
/**
|
||||
* Ensure that a value is reduced. If already reduced will not re-wrap.
|
||||
*/
|
||||
export function ensureReduced<TResult> (x: TResult | Reduced<TResult>): Reduced<TResult>;
|
||||
|
||||
/**
|
||||
* Ensure a value is not reduced. Unwraps if reduced.
|
||||
*/
|
||||
export function unreduced<TResult> (x: TResult | Reduced<TResult>): TResult;
|
||||
|
||||
/**
|
||||
* Returns the value of a reduced result.
|
||||
*/
|
||||
export function deref<TResult> (x: Reduced<TResult>): TResult;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/// <reference path="tz-format.d.ts" />
|
||||
|
||||
import * as format from 'tz-format';
|
||||
|
||||
format();
|
||||
format(new Date());
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// Type definitions for tz-format
|
||||
// Project: https://github.com/SamVerschueren/tz-format
|
||||
// Definitions by: Sam Verschueren <https://github.com/samverschueren>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "tz-format" {
|
||||
function format(date?: Date): string;
|
||||
namespace format { }
|
||||
export = format;
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
/// <reference path="vitalsigns.d.ts"/>
|
||||
|
||||
import * as express from "express";
|
||||
import VitalSigns = require("vitalsigns");
|
||||
|
||||
var vitals = new VitalSigns();
|
||||
|
||||
vitals.monitor('cpu');
|
||||
vitals.monitor('mem', {units: 'MB'});
|
||||
vitals.monitor('mem', { units: 'MB' });
|
||||
vitals.monitor('tick');
|
||||
|
||||
vitals.unhealthyWhen('cpu', 'usage').equals(100);
|
||||
@@ -13,7 +14,7 @@ vitals.unhealthyWhen('tick', 'maxMs').greaterThan(500);
|
||||
|
||||
vitals.monitor({
|
||||
connections: () => new Object()
|
||||
}, {name: 'game'});
|
||||
}, { name: 'game' });
|
||||
|
||||
var vitals = new VitalSigns({
|
||||
autoCheck: 5000,
|
||||
@@ -21,5 +22,8 @@ var vitals = new VitalSigns({
|
||||
httpUnhealthy: 503
|
||||
});
|
||||
|
||||
vitals.monitor('cpu', {name: 'foo'});
|
||||
vitals.monitor('cpu', { name: 'foo' });
|
||||
vitals.unhealthyWhen('foo', 'bar').not.greaterThan(5);
|
||||
|
||||
var app = express();
|
||||
app.get('/health', vitals.express);
|
||||
|
||||
Vendored
+13
-3
@@ -3,7 +3,11 @@
|
||||
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference path="../express/express.d.ts"/>
|
||||
|
||||
declare module "vitalsigns" {
|
||||
import { RequestHandler } from "express";
|
||||
|
||||
namespace vitalsigns {
|
||||
/**
|
||||
* Contraint.
|
||||
@@ -148,6 +152,12 @@ declare module "vitalsigns" {
|
||||
*/
|
||||
destroy(): void;
|
||||
|
||||
/**
|
||||
* Gets a request handler.
|
||||
* @type {RequestHandler}
|
||||
*/
|
||||
express: RequestHandler;
|
||||
|
||||
/**
|
||||
* Retrieves an array of human-readable messages that define the specific health constraints that failed when running the last health check.
|
||||
* @returns {Array<string>} An array of failure messages.
|
||||
@@ -160,7 +170,7 @@ declare module "vitalsigns" {
|
||||
* @param {ReportOptions} [options] A mapping of options to customize this report.
|
||||
* @return {Object} The full health report.
|
||||
*/
|
||||
getReport(options?: vitalsigns.ReportOptions): Object;
|
||||
getReport(options?: vitalsigns.ReportOptions): {};
|
||||
|
||||
/**
|
||||
* Generates a health report and checks each health constraint against it. Any constraints that fail will be added to the 'failed' array in the form of
|
||||
@@ -168,14 +178,14 @@ declare module "vitalsigns" {
|
||||
* @param {Object} [report] A report object on which to run the health constraints. If omitted, this function will generate a health report automatically.
|
||||
* @return {boolean} true if all health constraints passed; false otherwise.
|
||||
*/
|
||||
isHealthy(report?: Object): boolean;
|
||||
isHealthy(report?: {}): boolean;
|
||||
|
||||
/**
|
||||
* Registers monitor.
|
||||
* @param {string} monitorName A monitor name.
|
||||
* @param {MonitorField} [field] Options.
|
||||
*/
|
||||
monitor(monitor: string | vitalsigns.Monitor | Object, field?: vitalsigns.MonitorField): void;
|
||||
monitor(monitor: string | vitalsigns.Monitor | {}, field?: vitalsigns.MonitorField): void;
|
||||
|
||||
/**
|
||||
* Defines a new health constraint in a chainable, more easily readable format.
|
||||
|
||||
@@ -81,3 +81,17 @@ var WebSocketServer = WebSocket.Server;
|
||||
console.log(ws.protocol)
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
new WebSocket.Server({ perMessageDeflate: false });
|
||||
new WebSocket.Server({ perMessageDeflate: { } });
|
||||
new WebSocket.Server({
|
||||
perMessageDeflate: {
|
||||
serverNoContextTakeover: true,
|
||||
clientNoContextTakeover: true,
|
||||
serverMaxWindowBits: 0,
|
||||
clientMaxWindowBits: 0,
|
||||
memLevel: 0
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+9
@@ -96,6 +96,14 @@ declare module "ws" {
|
||||
ciphers?: string;
|
||||
rejectUnauthorized?: boolean;
|
||||
}
|
||||
|
||||
export interface IPerMessageDeflateOptions {
|
||||
serverNoContextTakeover?: boolean;
|
||||
clientNoContextTakeover?: boolean;
|
||||
serverMaxWindowBits?: number;
|
||||
clientMaxWindowBits?: number;
|
||||
memLevel?: number;
|
||||
}
|
||||
|
||||
export interface IServerOptions {
|
||||
host?: string;
|
||||
@@ -107,6 +115,7 @@ declare module "ws" {
|
||||
noServer?: boolean;
|
||||
disableHixie?: boolean;
|
||||
clientTracking?: boolean;
|
||||
perMessageDeflate?: boolean | IPerMessageDeflateOptions;
|
||||
}
|
||||
|
||||
export class Server extends events.EventEmitter {
|
||||
|
||||
Reference in New Issue
Block a user