mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 15:27:05 +00:00
Merge remote-tracking branch 'upstream/master' into lkay/react-router-update-typings
This commit is contained in:
@@ -112,7 +112,7 @@ Your package should have this structure:
|
||||
|
||||
Generate these by running `npm run new-package -- new-package-name`.
|
||||
|
||||
You may edit the `tsconfig.json` to add new files, to add to `"lib"`, or to add the `"jsx"` compiler option.
|
||||
You may edit the `tsconfig.json` to add new files, to add `"target": "es6"` (needed for async functions), to add to `"lib"`, or to add the `"jsx"` compiler option.
|
||||
|
||||
DefinitelyTyped members routinely monitor for new PRs, though keep in mind that the number of other PRs may slow things down.
|
||||
|
||||
|
||||
+4
-7
@@ -7,6 +7,8 @@ import _atom = require("atom");
|
||||
import PathWatcher = require("pathwatcher");
|
||||
var File = PathWatcher.File;
|
||||
|
||||
const jq: JQuery = $("selector");
|
||||
|
||||
class SampleView extends _atom.ScrollView {
|
||||
|
||||
editorId:string;
|
||||
@@ -33,11 +35,6 @@ class SampleView extends _atom.ScrollView {
|
||||
}
|
||||
}
|
||||
|
||||
get jq():JQuery {
|
||||
// dirty hack
|
||||
return <any>this;
|
||||
}
|
||||
|
||||
serialize() {
|
||||
return {
|
||||
deserializer: 'SampleView',
|
||||
@@ -52,9 +49,9 @@ class SampleView extends _atom.ScrollView {
|
||||
resolveEditor(editorId:string) {
|
||||
var resolve = ()=> {
|
||||
if (this.editor) {
|
||||
this.jq.trigger("title-changed");
|
||||
jq.trigger("title-changed");
|
||||
} else {
|
||||
var view = this.jq.parents('.pane').view();
|
||||
var view = jq.parents('.pane').view();
|
||||
if (view) {
|
||||
view.destroyItem(this);
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -1318,6 +1318,7 @@ declare namespace CKEDITOR {
|
||||
modes?: Object;
|
||||
startDisabled?: boolean;
|
||||
exec(editor: editor, data?: Object): boolean;
|
||||
readOnly?: boolean;
|
||||
refresh?(editor: editor, path: dom.elementPath): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
Vendored
+4
@@ -14,6 +14,10 @@ declare namespace cropperjs {
|
||||
detail: Data;
|
||||
}
|
||||
export interface CropperOptions {
|
||||
/**
|
||||
* Function called when crop box is ready
|
||||
*/
|
||||
ready?: (event: CropperCustomEvent) => void;
|
||||
/**
|
||||
* Function called when crop box is moved or resized
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
function nameSpaceTest() {
|
||||
let components = {} as GaeaModel.ViewportComponentInfo
|
||||
// insert into parent
|
||||
components.props = {
|
||||
gaeaUniqueKey: '123',
|
||||
gaeaName: 'componentName'
|
||||
}
|
||||
}
|
||||
Vendored
+491
@@ -0,0 +1,491 @@
|
||||
// Type definitions for gaea-model 1.0
|
||||
// Project: https://github.com/ascoders/gaea-model
|
||||
// Definitions by: ascoders <https://github.com/ascoders>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
import * as React from 'react';
|
||||
|
||||
export as namespace GaeaModel;
|
||||
|
||||
export type Component = React.ComponentClass<ComponentProps>;
|
||||
|
||||
/**
|
||||
* 组件信息
|
||||
*/
|
||||
export interface ComponentProps extends React.HTMLProps<any> {
|
||||
/**
|
||||
* 唯一的 key,用来唯一标识这个组件,所有盖亚内部组件都以 gaea-old- 为前缀
|
||||
*/
|
||||
gaeaUniqueKey: string;
|
||||
/**
|
||||
* 组件的中文名
|
||||
*/
|
||||
gaeaName: string;
|
||||
/**
|
||||
* 组件图标,为 fontAwesome
|
||||
*/
|
||||
gaeaIcon?: string;
|
||||
/**
|
||||
* 编辑信息
|
||||
*/
|
||||
gaeaEdit?: ComponentPropsGaeaEdit[];
|
||||
/**
|
||||
* 事件定义
|
||||
*/
|
||||
gaeaEvent?: GaeaEvent;
|
||||
/**
|
||||
* 是否在预览模式,preivew 会传入 true
|
||||
*/
|
||||
gaeaPreview?: boolean;
|
||||
/**
|
||||
* 是否可以拖入子元素
|
||||
*/
|
||||
canDragIn?: boolean;
|
||||
/**
|
||||
* 存储事件设置
|
||||
*/
|
||||
gaeaEventData?: EventData[];
|
||||
/**
|
||||
* 存储native事件设置
|
||||
*/
|
||||
gaeaNativeEventData?: EventData[];
|
||||
/**
|
||||
* 存储变量信息
|
||||
*/
|
||||
gaeaVariables?: {
|
||||
[field: string]: VariableData;
|
||||
};
|
||||
|
||||
[x: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件配置中数组配置
|
||||
*/
|
||||
export interface ComponentPropsOptionsArray extends ComponentPropsGaeaEdit {
|
||||
key: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件配置中数组配置的值
|
||||
*/
|
||||
export interface ComponentPropsOptionsArrayValue {
|
||||
/**
|
||||
* ComponentPropsOptionsArray 设置的 key
|
||||
*/
|
||||
key: string;
|
||||
/**
|
||||
* 用户填入的值
|
||||
*/
|
||||
value: number | string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件配置 选择器配置
|
||||
*/
|
||||
export interface ComponentPropsOptionsSelector {
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* number 配置项
|
||||
*/
|
||||
export interface Number {
|
||||
// 为空时,是数字,否则会以字符串加后缀形式赋值
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组件的值
|
||||
*/
|
||||
export type ComponentPropsOptionValue = number | string | boolean | ComponentPropsOptionsArrayValue[] | any;
|
||||
|
||||
/**
|
||||
* 组件配置
|
||||
*/
|
||||
export interface ComponentPropsGaeaEdit {
|
||||
/**
|
||||
* 对应字段名
|
||||
*/
|
||||
field: string;
|
||||
/**
|
||||
* 选项名称
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* 编辑器类型
|
||||
*/
|
||||
editor: string;
|
||||
/**
|
||||
* 是否可被编辑
|
||||
*/
|
||||
editable: boolean;
|
||||
/**
|
||||
* 是否隐藏编辑工具
|
||||
*/
|
||||
hideTool: boolean;
|
||||
/**
|
||||
* 当 editor 为 array 时的数组配置
|
||||
* 数组中的 key,和填入的值,会作为 Array<key:value> 填入到 value 中
|
||||
*/
|
||||
array?: ComponentPropsOptionsArrayValue[];
|
||||
/**
|
||||
* 当 editor 为 selector 时的数组配置
|
||||
*/
|
||||
selector?: ComponentPropsOptionsSelector[];
|
||||
/**
|
||||
* 值类型, 默认为字符串
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* 为空时的值,默认为 null
|
||||
*/
|
||||
emptyValue?: any;
|
||||
/**
|
||||
* 控制 number 单位
|
||||
*/
|
||||
number?: {
|
||||
units: number[];
|
||||
currentUnit: string;
|
||||
max?: number;
|
||||
min?: number;
|
||||
step?: number;
|
||||
speed?: number;
|
||||
inputRange?: number[];
|
||||
outputRange?: number[];
|
||||
slider?: boolean;
|
||||
};
|
||||
/**
|
||||
* 枚举实例
|
||||
*/
|
||||
instance?: Array<{
|
||||
[key: string]: ComponentPropsOptionValue;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组合信息
|
||||
*/
|
||||
export interface ComboComponentInfo extends ViewportComponentFullInfo {
|
||||
// 组合名
|
||||
name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发布列表的返回值
|
||||
*/
|
||||
export interface GetPublishListResult {
|
||||
// 版本
|
||||
version: string;
|
||||
// 描述
|
||||
description: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
export interface VersionInfo {
|
||||
content: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件设置
|
||||
*/
|
||||
export interface GaeaEvent {
|
||||
triggers: EventTriggerCondition[];
|
||||
effects: EventAction[];
|
||||
}
|
||||
|
||||
export interface EventData {
|
||||
type: string;
|
||||
event: string;
|
||||
/**
|
||||
* 因为事件可能 type 相同,因此记录是第几个
|
||||
*/
|
||||
typeIndex: number;
|
||||
eventIndex: number;
|
||||
typeData?: EventTriggerEvent;
|
||||
eventData?: EventActionJumpUrl | EventActionCall | EventActionEvent;
|
||||
}
|
||||
|
||||
export interface EventTriggerCondition {
|
||||
name: string;
|
||||
// 触发类型
|
||||
type: string;
|
||||
// 是否由自己的生命周期触发
|
||||
selfCallback?: boolean;
|
||||
}
|
||||
|
||||
export interface EventAction {
|
||||
name: string;
|
||||
// 动作类型
|
||||
// call: 调用传进来的方法
|
||||
// jumpUrl: 跳转一个网址
|
||||
type: string;
|
||||
call?: EventCallType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件定义类型
|
||||
*/
|
||||
export interface EventCallType {
|
||||
// 调用函数名称
|
||||
functionName: string;
|
||||
// 调用参数
|
||||
param?: EventCallTypeParam[];
|
||||
}
|
||||
|
||||
export interface EventCallTypeParam {
|
||||
label: string;
|
||||
field: string;
|
||||
editor: string; // text
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件触发数据类型
|
||||
*/
|
||||
export interface EventTriggerEvent {
|
||||
listen?: string;
|
||||
}
|
||||
|
||||
export interface EventUpdatePropsEvent {
|
||||
/**
|
||||
* 修改后的 props
|
||||
*/
|
||||
props: ComponentProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* 事件动作数据类型
|
||||
*/
|
||||
export interface EventActionJumpUrl {
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface EventActionCall {
|
||||
// 函数在 map 里的 key
|
||||
key?: string;
|
||||
}
|
||||
|
||||
export interface EventActionEvent {
|
||||
emit?: string;
|
||||
}
|
||||
|
||||
export interface ExternalParameter {
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 类型
|
||||
* number string boolean
|
||||
*/
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 标识哪些字段用什么变量
|
||||
*/
|
||||
export interface VariableData {
|
||||
// 变量类型
|
||||
// 比如是外部传参,还是全局变量
|
||||
variableType: string;
|
||||
// 变量的哪个字段
|
||||
variableField: string;
|
||||
// 值类型 string number boolean
|
||||
valueType: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 插件信息
|
||||
*/
|
||||
export interface Plugin extends React.ComponentClass<any> {
|
||||
// 插件安放位置
|
||||
position: string;
|
||||
Action?: any;
|
||||
Store?: any;
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
* DIff
|
||||
********************************************************************************************************/
|
||||
export interface Diff {
|
||||
// 操作类型
|
||||
type: 'add' | 'move' | 'remove' | 'exchange' | 'update' | 'paste' | 'reset' | 'addCombo' | 'addSource';
|
||||
// 操作组件的 mapUniqueKey
|
||||
mapUniqueKey: string;
|
||||
// 新增操作
|
||||
add?: {
|
||||
// 新增组件的唯一标识 id
|
||||
uniqueId: string;
|
||||
// 父级 mapKey
|
||||
parentMapUniqueKey: string;
|
||||
// 插入的位置
|
||||
index: number;
|
||||
};
|
||||
// 移动到另一个父元素
|
||||
move?: {
|
||||
// 移动到的父级 mapKey
|
||||
targetParentMapUniqueKey: string;
|
||||
// 移动前父级 mapKey
|
||||
sourceParentMapUniqueKey: string;
|
||||
// 插入的位置
|
||||
targetIndex: number;
|
||||
// 移除的位置
|
||||
sourceIndex: number;
|
||||
};
|
||||
// 删除组件
|
||||
remove?: DiffRemove;
|
||||
// 内部交换顺序
|
||||
exchange?: {
|
||||
oldIndex: number;
|
||||
newIndex: number;
|
||||
};
|
||||
// 更新操作
|
||||
update?: {
|
||||
oldValue: ComponentProps;
|
||||
newValue: ComponentProps;
|
||||
};
|
||||
// 粘贴操作
|
||||
paste?: DiffRemove;
|
||||
// 重置组件
|
||||
reset?: {
|
||||
// 重置前的信息
|
||||
beforeProps: ComponentProps;
|
||||
beforeName: string;
|
||||
};
|
||||
// 新增组合
|
||||
addCombo?: {
|
||||
// 父级 mapKey
|
||||
parentMapUniqueKey: string;
|
||||
// 父级的 index
|
||||
index: number;
|
||||
// 组合的完整信息(不是 copy 的, 是真正对应的 mapUniqueKey)
|
||||
componentInfo: ViewportComponentFullInfo;
|
||||
};
|
||||
// 新增模板
|
||||
addSource?: {
|
||||
// 父级 mapKey
|
||||
parentMapUniqueKey: string;
|
||||
// 父级的 index
|
||||
index: number;
|
||||
// 组合的完整信息(不是 copy 的, 是真正对应的 mapUniqueKey)
|
||||
componentInfo: ViewportComponentFullInfo;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DiffRemove extends ViewportComponentFullInfo {
|
||||
// 父级元素 mapKey
|
||||
parentMapUniqueKey: string;
|
||||
// 删除的位置
|
||||
index: number;
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
* Viewport
|
||||
********************************************************************************************************/
|
||||
/**
|
||||
* 在视图中的组件属性
|
||||
*/
|
||||
export interface ViewportComponentInfo {
|
||||
/**
|
||||
* props
|
||||
*/
|
||||
props: ComponentProps;
|
||||
/**
|
||||
* 子元素(canDragIn才有)
|
||||
* 只存子元素在 map 中的 key
|
||||
*/
|
||||
layoutChilds?: string[];
|
||||
/**
|
||||
* 父级 mapUniqueKey, 这样不但方便寻找父级,还能根据是否为 null 判断是否为根元素
|
||||
*/
|
||||
parentMapUniqueKey: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前正在移动元素的信息
|
||||
*/
|
||||
export interface MovingComponent {
|
||||
// 在编辑区域的组件信息
|
||||
mapUniqueKey: string;
|
||||
// 是否是新拖拽的
|
||||
isNew: boolean;
|
||||
// 组件的唯一标识, 新建的时候采用
|
||||
uniqueKey: string;
|
||||
// 直接给 source 就直接用
|
||||
source: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* hover 元素的信息
|
||||
*/
|
||||
export interface HoverComponentSpec {
|
||||
left: number;
|
||||
top: number;
|
||||
width: number;
|
||||
height: number;
|
||||
hovering: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 一个独立组件的完整信息
|
||||
*/
|
||||
export interface ViewportComponentFullInfo {
|
||||
// 组件的 mapUniqueKey
|
||||
mapUniqueKey: string;
|
||||
// 组件信息
|
||||
componentInfo: ViewportComponentInfo;
|
||||
// 子元素列表 (包括非直接子集)
|
||||
childs: {
|
||||
[mapUniqueKey: string]: ViewportComponentInfo;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前拖拽元素信息
|
||||
*/
|
||||
export interface CurrentDragComponentInfo {
|
||||
// 类型
|
||||
type: 'new' | 'combo' | 'viewport';
|
||||
// 开始拖拽父级的 dom
|
||||
dragStartParentElement: HTMLElement;
|
||||
// 开始拖拽在父级中的位置
|
||||
dragStartIndex: number;
|
||||
newInfo?: {
|
||||
// 唯一 key,用来实例化组件
|
||||
uniqueKey: string;
|
||||
};
|
||||
comboInfo?: {
|
||||
// combo 信息
|
||||
source: string;
|
||||
};
|
||||
viewportInfo?: {
|
||||
// 当前拖拽组件的 mapUniqueKey
|
||||
mapUniqueKey: string;
|
||||
// 拖拽目标的 mapUniqueKey
|
||||
targetMapUniqueKey?: string;
|
||||
// 拖拽目标的 index
|
||||
targetIndex?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/********************************************************************************************************
|
||||
* Event
|
||||
********************************************************************************************************/
|
||||
/**
|
||||
* 鼠标移动到组件上/树对应的组件上
|
||||
*/
|
||||
export interface MouseHoverComponentEvent {
|
||||
mapUniqueKey: string;
|
||||
type: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改某个组件选中状态
|
||||
*/
|
||||
export interface ComponentSelectStatusEvent {
|
||||
mapUniqueKey: string;
|
||||
selected: boolean;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"noImplicitThis": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gaea-model-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -2,12 +2,31 @@
|
||||
import * as graphlib from 'graphlib';
|
||||
|
||||
function test_graph() {
|
||||
var g = new graphlib.Graph();
|
||||
var g = new graphlib.Graph({
|
||||
compound: true,
|
||||
directed: true,
|
||||
multigraph: true
|
||||
});
|
||||
g.setEdge('a', 'b');
|
||||
g.setEdge('a', 'b', 1.023);
|
||||
g.setEdge('a', 'b', 1.023, 'test');
|
||||
g.setEdge({ v: 'a', w: 'b', name: 'test' }, 1.023);
|
||||
g.hasEdge('a', 'b', 'test');
|
||||
g.hasEdge({ v: 'a', w: 'b', name: 'test' });
|
||||
g.removeEdge('a', 'b', 'test');
|
||||
g.removeEdge({ v: 'a', w: 'b', name: 'test' });
|
||||
|
||||
g.edge('a', 'b');
|
||||
g.edge({v: 'a', w: 'b'});
|
||||
g.edge('a', 'b', 'test');
|
||||
g.edge({v: 'a', w: 'b', name: 'test'});
|
||||
g.setDefaultNodeLabel({});
|
||||
g.setDefaultNodeLabel(() => 42);
|
||||
g.setDefaultEdgeLabel({});
|
||||
g.setDefaultEdgeLabel(() => 'e42');
|
||||
g.setNodes(['a', 'b', 'c'], 42);
|
||||
g.setParent('d', 'a');
|
||||
g.parent('d');
|
||||
g.children('a');
|
||||
g.filterNodes(v => true);
|
||||
g.setPath(['a', 'b', 'c'], 42);
|
||||
|
||||
graphlib.json.read(graphlib.json.write(g));
|
||||
|
||||
@@ -20,4 +39,6 @@ function test_graph() {
|
||||
graphlib.alg.prim(g, e => g.edge(e));
|
||||
graphlib.alg.tarjan(g);
|
||||
graphlib.alg.topsort(g);
|
||||
graphlib.alg.preorder(g, g.nodes());
|
||||
graphlib.alg.postorder(g, g.nodes());
|
||||
}
|
||||
|
||||
Vendored
+559
-249
@@ -1,291 +1,601 @@
|
||||
// Type definitions for graphlib 2.1.1
|
||||
// Project: https://github.com/cpettitt/graphlib
|
||||
// Definitions by: Dan Vanderkam <http://danvk.org/>
|
||||
// Definitions by: Dan Vanderkam <http://danvk.org/>, Dan Mironenko <wolfson@bracketedrebels.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare module "graphlib" {
|
||||
export interface GraphOptions {
|
||||
directed?: boolean; // default: true.
|
||||
multigraph?: boolean; // default: false.
|
||||
compound?: boolean; // default: false.
|
||||
}
|
||||
export interface GraphOptions {
|
||||
directed?: boolean; // default: true.
|
||||
multigraph?: boolean; // default: false.
|
||||
compound?: boolean; // default: false.
|
||||
}
|
||||
|
||||
export interface Edge {
|
||||
v: string;
|
||||
w: string;
|
||||
/** The name that uniquely identifies a multi-edge. */
|
||||
name?: string;
|
||||
}
|
||||
export interface Edge {
|
||||
v: string;
|
||||
w: string;
|
||||
/** The name that uniquely identifies a multi-edge. */
|
||||
name?: string;
|
||||
}
|
||||
|
||||
// TODO: add template parameters for edge and vertex labels?
|
||||
export class Graph {
|
||||
constructor(options?: GraphOptions);
|
||||
export class Graph {
|
||||
constructor(options?: GraphOptions);
|
||||
|
||||
/**
|
||||
* Creates or updates the value for the node v in the graph. If label is supplied
|
||||
* it is set as the value for the node. If label is not supplied and the node was
|
||||
* created by this call then the default node label will be assigned. Returns the
|
||||
* graph, allowing this to be chained with other functions. Takes O(1) time.
|
||||
*/
|
||||
setNode(name: string, label?: any): Graph;
|
||||
/**
|
||||
* Sets the default node label. This label will be assigned as default label
|
||||
* in case if no label was specified while setting a node.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument label - default node label.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setDefaultNodeLabel(label: any): Graph;
|
||||
|
||||
hasNode(name: string): boolean;
|
||||
/**
|
||||
* Sets the default node label factory function. This function will be invoked
|
||||
* each time when setting a node with no label specified and returned value
|
||||
* will be used as a label for node.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument labelFn - default node label factory function.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setDefaultNodeLabel(labelFn: (v: string) => any): Graph;
|
||||
|
||||
/**
|
||||
* Remove the node with the id v in the graph or do nothing if the node is not in
|
||||
* the graph. If the node was removed this function also removes any incident
|
||||
* edges. Returns the graph, allowing this to be chained with other functions.
|
||||
* Takes O(|E|) time. */
|
||||
removeNode(name: string): Graph;
|
||||
/**
|
||||
* Creates or updates the value for the node v in the graph. If label is supplied
|
||||
* it is set as the value for the node. If label is not supplied and the node was
|
||||
* created by this call then the default node label will be assigned.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument name - node name.
|
||||
* @argument label - value to set for node.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setNode(name: string, label?: any): Graph;
|
||||
|
||||
nodes(): string[];
|
||||
/**
|
||||
* Invokes setNode method for each node in names list.
|
||||
* Complexity: O(|names|).
|
||||
*
|
||||
* @argument names - list of nodes names to be set.
|
||||
* @argument label - value to set for each node in list.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setNodes(names: string[], label?: any): Graph;
|
||||
|
||||
/** Returns the label for this node. */
|
||||
node(name: string): any;
|
||||
/**
|
||||
* Sets node p as a parent for node v. Method throws an exception in case of
|
||||
* invoking it in context of noncompound graph.
|
||||
* Average-case complexity: O(1).
|
||||
*
|
||||
* @argument v - node to be child for p.
|
||||
* @argument p - node to be parent for v.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setParent(v: string, p: string): Graph;
|
||||
|
||||
/**
|
||||
* Creates or updates the label for the edge (v, w) with the optionally supplied
|
||||
* name. If label is supplied it is set as the value for the edge. If label is not
|
||||
* supplied and the edge was created by this call then the default edge label will
|
||||
* be assigned. The name parameter is only useful with multigraphs. Returns the
|
||||
* graph, allowing this to be chained with other functions. Takes O(1) time.
|
||||
*/
|
||||
setEdge(v: string, w: string, label?: any): Graph;
|
||||
/**
|
||||
* Gets parent node for node v.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument v - node to get parent of.
|
||||
* @returns parent node name or void if v has no parent.
|
||||
*/
|
||||
parent(v: string): string | void;
|
||||
|
||||
edges(): Edge[];
|
||||
/**
|
||||
* Gets list of direct children of node v.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument v - node to get children of.
|
||||
* @returns children nodes names list.
|
||||
*/
|
||||
children(v: string): string[];
|
||||
|
||||
/** Returns the label for this edge. */
|
||||
edge(v: string, w: string): any;
|
||||
edge(e: Edge): any;
|
||||
/**
|
||||
* Creates new graph with nodes filtered via filter. Edges incident to rejected node
|
||||
* are also removed. In case of compound graph, if parent is rejected by filter,
|
||||
* than all its children are rejected too.
|
||||
* Average-case complexity: O(|E|+|V|).
|
||||
*
|
||||
* @argument filter - filtration function detecting whether the node should stay or not.
|
||||
* @returns new graph made from current and nodes filtered.
|
||||
*/
|
||||
filterNodes(filter: (v: string) => boolean): Graph;
|
||||
|
||||
/**
|
||||
* Return all edges that point to the node v. Optionally filters those edges down to just those
|
||||
* coming from node u. Behavior is undefined for undirected graphs - use nodeEdges instead.
|
||||
* Returns undefined if node v is not in the graph. Takes O(|E|) time.
|
||||
*/
|
||||
inEdges(v: string, u?: string): Edge[];
|
||||
/**
|
||||
* Sets the default edge label. This label will be assigned as default label
|
||||
* in case if no label was specified while setting an edge.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument label - default edge label.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setDefaultEdgeLabel(label: any): Graph;
|
||||
|
||||
/**
|
||||
* Return all edges that are pointed at by node v. Optionally filters those edges down to just
|
||||
* those point to w. Behavior is undefined for undirected graphs - use nodeEdges instead.
|
||||
* Returns undefined if node v is not in the graph. Takes O(|E|) time.
|
||||
*/
|
||||
outEdges(v: string, w?: string): Edge[];
|
||||
/**
|
||||
* Sets the default edge label factory function. This function will be invoked
|
||||
* each time when setting an edge with no label specified and returned value
|
||||
* will be used as a label for edge.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument labelFn - default edge label factory function.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setDefaultEdgeLabel(labelFn: (v: string) => any): Graph;
|
||||
|
||||
/**
|
||||
* Returns all edges to or from node v regardless of direction. Optionally filters those edges
|
||||
* down to just those between nodes v and w regardless of direction. Returns undefined if node v
|
||||
* is not in the graph. Takes O(|E|) time.
|
||||
*/
|
||||
nodeEdges(v: string, w?: string): Edge[];
|
||||
/**
|
||||
* Establish an edges path over the nodes in nodes list. If some edge is already
|
||||
* exists, it will update its label, otherwise it will create an edge between pair
|
||||
* of nodes with label provided or default label if no label provided.
|
||||
* Complexity: O(|nodes|).
|
||||
*
|
||||
* @argument nodes - list of nodes to be connected in series.
|
||||
* @argument label - value to set for each edge between pairs of nodes.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setPath(nodes: string[], label?: any): Graph;
|
||||
|
||||
/**
|
||||
* Return all nodes that are predecessors of the specified node or undefined if node v is not in
|
||||
* the graph. Behavior is undefined for undirected graphs - use neighbors instead. Takes O(|V|)
|
||||
* time.
|
||||
*/
|
||||
predecessors(node: string): string[];
|
||||
/**
|
||||
* Detects whether graph has a node with specified name or not.
|
||||
|
||||
*
|
||||
* @argument name - name of the node.
|
||||
* @returns true if graph has node with specified name, false - otherwise.
|
||||
*/
|
||||
hasNode(name: string): boolean;
|
||||
|
||||
/**
|
||||
* Return all nodes that are successors of the specified node or undefined if node v is not in
|
||||
* the graph. Behavior is undefined for undirected graphs - use neighbors instead. Takes O(|V|)
|
||||
* time.
|
||||
*/
|
||||
successors(node: string): string[];
|
||||
/**
|
||||
* Remove the node with the name from the graph or do nothing if the node is not in
|
||||
* the graph. If the node was removed this function also removes any incident
|
||||
* edges.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument name - name of the node.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
removeNode(name: string): Graph;
|
||||
|
||||
/**
|
||||
* Return all nodes that are predecessors or successors of the specified node or undefined if
|
||||
* node v is not in the graph. Takes O(|V|) time.
|
||||
*/
|
||||
neighbors(node: string): string[];
|
||||
/**
|
||||
* Gets all nodes of the graph. Note, the in case of compound graph subnodes are
|
||||
* not included in list.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @returns list of graph nodes.
|
||||
*/
|
||||
nodes(): string[];
|
||||
|
||||
isDirected(): boolean;
|
||||
isMultigraph(): boolean;
|
||||
isCompound(): boolean;
|
||||
/**
|
||||
* Gets the label of node with specified name.
|
||||
* Complexity: O(|V|).
|
||||
*
|
||||
* @returns label value of the node.
|
||||
*/
|
||||
node(name: string): any;
|
||||
|
||||
/** Sets the label for the graph to label. */
|
||||
setGraph(label: string): void;
|
||||
/**
|
||||
* Creates or updates the label for the edge (v, w) with the optionally supplied
|
||||
* name. If label is supplied it is set as the value for the edge. If label is not
|
||||
* supplied and the edge was created by this call then the default edge label will
|
||||
* be assigned. The name parameter is only useful with multigraphs.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument v - edge source node.
|
||||
* @argument w - edge sink node.
|
||||
* @argument label - value to associate with the edge.
|
||||
* @argument name - unique name of the edge in order to identify it in multigraph.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setEdge(v: string, w: string, label?: any, name?: string): Graph;
|
||||
|
||||
/**
|
||||
* Returns the currently assigned label for the graph. If no label has been assigned,
|
||||
* returns undefined.
|
||||
*/
|
||||
graph(): string;
|
||||
/**
|
||||
* Creates or updates the label for the specified edge. If label is supplied it is
|
||||
* set as the value for the edge. If label is not supplied and the edge was created
|
||||
* by this call then the default edge label will be assigned. The name parameter is
|
||||
* only useful with multigraphs.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument edge - edge descriptor.
|
||||
* @argument label - value to associate with the edge.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setEdge(edge: Edge, label?: any): Graph;
|
||||
|
||||
/**
|
||||
* Returns the number of nodes in the graph.
|
||||
*/
|
||||
nodeCount(): number;
|
||||
/**
|
||||
* Gets edges of the graph. In case of compound graph subgraphs are not considered.
|
||||
* Complexity: O(|E|).
|
||||
*
|
||||
* @return graph edges list.
|
||||
*/
|
||||
edges(): Edge[];
|
||||
|
||||
/**
|
||||
* Returns the number of edges in the graph.
|
||||
*/
|
||||
edgeCount(): number;
|
||||
/**
|
||||
* Gets the label for the specified edge.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument v - edge source node.
|
||||
* @argument w - edge sink node.
|
||||
* @argument name - name of the edge (actual for multigraph).
|
||||
* @returns value associated with specified edge.
|
||||
*/
|
||||
edge(v: string, w: string, name?: string): any;
|
||||
|
||||
/** Returns those nodes in the graph that have no in-edges. Takes O(|V|) time. */
|
||||
sources(): string[];
|
||||
/**
|
||||
* Gets the label for the specified edge.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument edge - edge descriptor.
|
||||
* @returns value associated with specified edge.
|
||||
*/
|
||||
edge(e: Edge): any;
|
||||
|
||||
/** Returns those nodes in the graph that have no out-edges. Takes O(|V|) time. */
|
||||
sinks(): string[];
|
||||
}
|
||||
/**
|
||||
* Detects whether the graph contains specified edge or not. No subgraphs are considered.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument v - edge source node.
|
||||
* @argument w - edge sink node.
|
||||
* @argument name - name of the edge (actual for multigraph).
|
||||
* @returns whether the graph contains the specified edge or not.
|
||||
*/
|
||||
hasEdge(v: string, w: string, name?: string): boolean;
|
||||
|
||||
export namespace json {
|
||||
/**
|
||||
* Creates a JSONrepresentation of the graph that can be serialized to a string with
|
||||
* JSON.stringify. The graph can later be restored using json.read.
|
||||
*/
|
||||
function write(g: Graph): Object;
|
||||
/**
|
||||
* Detects whether the graph contains specified edge or not. No subgraphs are considered.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument edge - edge descriptor.
|
||||
* @returns whether the graph contains the specified edge or not.
|
||||
*/
|
||||
hasEdge(edge: Edge): boolean;
|
||||
|
||||
/**
|
||||
* Takes JSON as input and returns the graph representation. For example, if we have
|
||||
* serialized the graph in json-write to a string named str, we can restore it to a
|
||||
* graph as follows:
|
||||
*
|
||||
* var g2 = graphlib.json.read(JSON.parse(str));
|
||||
* g2.nodes();
|
||||
* // ['a', 'b']
|
||||
* g2.edges()
|
||||
* // [ { v: 'a', w: 'b' } ]
|
||||
*/
|
||||
function read(json: Object): Graph;
|
||||
}
|
||||
/**
|
||||
* Removes the specified edge from the graph. No subgraphs are considered.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument edge - edge descriptor.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
removeEdge(edge: Edge): Graph;
|
||||
|
||||
export interface Path {
|
||||
distance: number;
|
||||
predecessor: string;
|
||||
}
|
||||
/**
|
||||
* Removes the specified edge from the graph. No subgraphs are considered.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @argument v - edge source node.
|
||||
* @argument w - edge sink node.
|
||||
* @argument name - name of the edge (actual for multigraph).
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
removeEdge(v: string, w: string, name?: string): Graph;
|
||||
|
||||
export namespace alg {
|
||||
/**
|
||||
* Finds all connected components in a graph and returns an array of these components.
|
||||
* Each component is itself an array that contains the ids of nodes in the component.
|
||||
* This function takes O(|V|) time.
|
||||
*/
|
||||
function components(g: Graph): string[][];
|
||||
/**
|
||||
* Return all edges that point to the node v. Optionally filters those edges down to just those
|
||||
* coming from node u. Behavior is undefined for undirected graphs - use nodeEdges instead.
|
||||
* Complexity: O(|E|).
|
||||
*
|
||||
* @argument v - edge sink node.
|
||||
* @argument w - edge source node.
|
||||
* @returns edges descriptors list if v is in the graph, or undefined otherwise.
|
||||
*/
|
||||
inEdges(v: string, w?: string): void | Edge[];
|
||||
|
||||
/**
|
||||
* This function is an implementation of Dijkstra's algorithm which finds the shortest
|
||||
* path from source to all other nodes in g. This function returns a map of
|
||||
* v -> { distance, predecessor }. The distance property holds the sum of the weights
|
||||
* from source to v along the shortest path or Number.POSITIVE_INFINITY if there is no path
|
||||
* from source. The predecessor property can be used to walk the individual elements of the
|
||||
* path from source to v in reverse order.
|
||||
*
|
||||
* It takes an optional weightFn(e) which returns the weight of the edge e. If no weightFn
|
||||
* is supplied then each edge is assumed to have a weight of 1. This function throws an
|
||||
* Error if any of the traversed edges have a negative edge weight.
|
||||
*
|
||||
* It takes an optional edgeFn(v) which returns the ids of all edges incident to the node v
|
||||
* for the purposes of shortest path traversal. By default this function uses the g.outEdges.
|
||||
*
|
||||
* It takes O((|E| + |V|) * log |V|) time.
|
||||
*/
|
||||
function dijkstra(
|
||||
graph: Graph,
|
||||
source: string,
|
||||
weightFn?: (e: Edge) => number,
|
||||
edgeFn?: (v: string) => Edge[]
|
||||
): {[node: string]: Path};
|
||||
/**
|
||||
* Return all edges that are pointed at by node v. Optionally filters those edges down to just
|
||||
* those point to w. Behavior is undefined for undirected graphs - use nodeEdges instead.
|
||||
* Complexity: O(|E|).
|
||||
*
|
||||
* @argument v - edge source node.
|
||||
* @argument w - edge sink node.
|
||||
* @returns edges descriptors list if v is in the graph, or undefined otherwise.
|
||||
*/
|
||||
outEdges(v: string, w?: string): void | Edge[];
|
||||
|
||||
/**
|
||||
* This function finds the shortest path from each node to every other reachable node in
|
||||
* the graph. It is similar to alg.dijkstra, but instead of returning a single-source
|
||||
* array, it returns a mapping of of source -> alg.dijksta(g, source, weightFn, edgeFn).
|
||||
*
|
||||
* This function takes an optional weightFn(e) which returns the weight of the edge e.
|
||||
* If no weightFn is supplied then each edge is assumed to have a weight of 1. This
|
||||
* function throws an Error if any of the traversed edges have a negative edge weight.
|
||||
*
|
||||
* This function takes an optional edgeFn(u) which returns the ids of all edges incident
|
||||
* to the node u for the purposes of shortest path traversal. By default this function
|
||||
* uses g.outEdges.
|
||||
*
|
||||
* This function takes O(|V| * (|E| + |V|) * log |V|) time.
|
||||
*/
|
||||
function dijkstraAll(
|
||||
graph: Graph,
|
||||
weightFn?: (e: Edge) => number,
|
||||
edgeFn?: (v: string) => Edge[]
|
||||
): {[source: string]: {[node: string]: Path}};
|
||||
/**
|
||||
* Returns all edges to or from node v regardless of direction. Optionally filters those edges
|
||||
* down to just those between nodes v and w regardless of direction.
|
||||
* Complexity: O(|E|).
|
||||
*
|
||||
* @argument v - edge adjacent node.
|
||||
* @argument w - edge adjacent node.
|
||||
* @returns edges descriptors list if v is in the graph, or undefined otherwise.
|
||||
*/
|
||||
nodeEdges(v: string, w?: string): void | Edge[];
|
||||
|
||||
/**
|
||||
* Given a Graph, g, this function returns all nodes that are part of a cycle. As there
|
||||
* may be more than one cycle in a graph this function return an array of these cycles,
|
||||
* where each cycle is itself represented by an array of ids for each node involved in
|
||||
* that cycle.
|
||||
*
|
||||
* alg.isAcyclic is more efficient if you only need to determine whether a graph has a
|
||||
* cycle or not.
|
||||
*/
|
||||
function findCycles(graph: Graph): string[][];
|
||||
/**
|
||||
* Return all nodes that are predecessors of the specified node or undefined if node v is not in
|
||||
* the graph. Behavior is undefined for undirected graphs - use neighbors instead.
|
||||
* Complexity: O(|V|).
|
||||
*
|
||||
* @argument v - node identifier.
|
||||
* @returns node identifiers list or undefined if v is not in the graph.
|
||||
*/
|
||||
predecessors(v: string): void | string[];
|
||||
|
||||
/**
|
||||
* This function is an implementation of the Floyd-Warshall algorithm, which finds the
|
||||
* shortest path from each node to every other reachable node in the graph. It is similar
|
||||
* to alg.dijkstraAll, but it handles negative edge weights and is more efficient for some types
|
||||
* of graphs. This function returns a map of source -> { target -> { distance, predecessor }.
|
||||
* The distance property holds the sum of the weights from source to target along the shortest
|
||||
* path of Number.POSITIVE_INFINITY if there is no path from source. The predecessor property
|
||||
* can be used to walk the individual elements of the path from source to target in reverse
|
||||
* order.
|
||||
*
|
||||
* This function takes an optional weightFn(e) which returns the weight of the edge e. If no
|
||||
* weightFunc is supplied then each edge is assumed to have a weight of 1.
|
||||
*
|
||||
* This function takes an optional edgeFn(v) which returns the ids of all edges incident to the
|
||||
* node v for the purposes of shortest path traversal. By default this function uses the
|
||||
* outEdges function on the supplied graph.
|
||||
*
|
||||
* This algorithm takes O(|V|^3) time.
|
||||
*/
|
||||
function floydWarshall(
|
||||
graph: Graph,
|
||||
weightFn?: (e: Edge) => number,
|
||||
edgeFn?: (v: string) => Edge[]
|
||||
): {[source: string]: {[node: string]: Path}};
|
||||
/**
|
||||
* Return all nodes that are successors of the specified node or undefined if node v is not in
|
||||
* the graph. Behavior is undefined for undirected graphs - use neighbors instead.
|
||||
* Complexity: O(|V|).
|
||||
*
|
||||
* @argument v - node identifier.
|
||||
* @returns node identifiers list or undefined if v is not in the graph.
|
||||
*/
|
||||
successors(v: string): void | string[];
|
||||
|
||||
/**
|
||||
* Given a Graph, g, this function returns true if the graph has no cycles and returns false if it
|
||||
* does. This algorithm returns as soon as it detects the first cycle. You can use alg.findCycles
|
||||
* to get the actual list of cycles in the graph.
|
||||
*/
|
||||
function isAcyclic(graph: Graph): boolean;
|
||||
/**
|
||||
* Return all nodes that are predecessors or successors of the specified node or undefined if
|
||||
* node v is not in the graph.
|
||||
* Complexity: O(|V|).
|
||||
*
|
||||
* @argument v - node identifier.
|
||||
* @returns node identifiers list or undefined if v is not in the graph.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prim's algorithm takes a connected undirected graph and generates a minimum spanning tree. This
|
||||
* function returns the minimum spanning tree as an undirected graph. This algorithm is derived
|
||||
* from the description in "Introduction to Algorithms", Third Edition, Cormen, et al., Pg 634.
|
||||
*
|
||||
* This function takes a weightFn(e) which returns the weight of the edge e. It throws an Error if
|
||||
* the graph is not connected.
|
||||
*
|
||||
* This function takes O(|E| log |V|) time.
|
||||
*/
|
||||
function prim(graph: Graph, weightFn: (e: Edge) => number): Graph;
|
||||
neighbors(v: string): void | string[];
|
||||
|
||||
/**
|
||||
* This function is an implementation of Tarjan's algorithm which finds all strongly connected
|
||||
* components in the directed graph g. Each strongly connected component is composed of nodes that
|
||||
* can reach all other nodes in the component via directed edges. A strongly connected component
|
||||
* can consist of a single node if that node cannot both reach and be reached by any other
|
||||
* specific node in the graph. Components of more than one node are guaranteed to have at least
|
||||
* one cycle.
|
||||
*
|
||||
* This function returns an array of components. Each component is itself an array that contains
|
||||
* the ids of all nodes in the component.
|
||||
*/
|
||||
function tarjan(graph: Graph): string[][];
|
||||
/**
|
||||
* Whether graph was created with 'directed' flag set to true or not.
|
||||
*
|
||||
* @returns whether the graph edges have an orientation.
|
||||
*/
|
||||
isDirected(): boolean;
|
||||
|
||||
/**
|
||||
* An implementation of topological sorting.
|
||||
*
|
||||
* Given a Graph g this function returns an array of nodes such that for each edge u -> v, u
|
||||
* appears before v in the array. If the graph has a cycle it is impossible to generate such a
|
||||
* list and CycleException is thrown.
|
||||
*
|
||||
* Takes O(|V| + |E|) time.
|
||||
*/
|
||||
function topsort(graph: Graph): string[];
|
||||
}
|
||||
/**
|
||||
* Whether graph was created with 'multigraph' flag set to true or not.
|
||||
*
|
||||
* @returns whether the pair of nodes of the graph can have multiple edges.
|
||||
*/
|
||||
isMultigraph(): boolean;
|
||||
|
||||
/**
|
||||
* Whether graph was created with 'compound' flag set to true or not.
|
||||
*
|
||||
* @returns whether a node of the graph can have subnodes.
|
||||
*/
|
||||
isCompound(): boolean;
|
||||
|
||||
/**
|
||||
* Sets the label of the graph.
|
||||
*
|
||||
* @argument label - label value.
|
||||
* @returns the graph, allowing this to be chained with other functions.
|
||||
*/
|
||||
setGraph(label: string): Graph;
|
||||
|
||||
/**
|
||||
* Gets the graph label.
|
||||
*
|
||||
* @returns currently assigned label for the graph or undefined if no label assigned.
|
||||
*/
|
||||
graph(): void | string;
|
||||
|
||||
/**
|
||||
* Gets the number of nodes in the graph.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @returns nodes count.
|
||||
*/
|
||||
nodeCount(): number;
|
||||
|
||||
/**
|
||||
* Gets the number of edges in the graph.
|
||||
* Complexity: O(1).
|
||||
*
|
||||
* @returns edges count.
|
||||
*/
|
||||
edgeCount(): number;
|
||||
|
||||
/**
|
||||
* Gets list of nodes without in-edges.
|
||||
* Complexity: O(|V|).
|
||||
*
|
||||
* @returns the graph source nodes.
|
||||
*/
|
||||
sources(): string[];
|
||||
|
||||
/**
|
||||
* Gets list of nodes without out-edges.
|
||||
* Complexity: O(|V|).
|
||||
*
|
||||
* @returns the graph source nodes.
|
||||
*/
|
||||
sinks(): string[];
|
||||
}
|
||||
|
||||
export namespace json {
|
||||
/**
|
||||
* Creates a JSON representation of the graph that can be serialized to a string with
|
||||
* JSON.stringify. The graph can later be restored using json.read.
|
||||
*
|
||||
* @argument graph - target to create JSON representation of.
|
||||
* @returns JSON serializable graph representation
|
||||
*/
|
||||
function write(graph: Graph): Object;
|
||||
|
||||
/**
|
||||
* Takes JSON as input and returns the graph representation.
|
||||
*
|
||||
* @example
|
||||
* var g2 = graphlib.json.read(JSON.parse(str));
|
||||
* g2.nodes();
|
||||
* // ['a', 'b']
|
||||
* g2.edges()
|
||||
* // [ { v: 'a', w: 'b' } ]
|
||||
*
|
||||
* @argument json - JSON serializable graph representation
|
||||
* @returns graph constructed acccording to specified representation
|
||||
*/
|
||||
function read(json: Object): Graph;
|
||||
}
|
||||
|
||||
export interface Path {
|
||||
distance: number;
|
||||
predecessor: string;
|
||||
}
|
||||
|
||||
export namespace alg {
|
||||
/**
|
||||
* Finds all connected components in a graph and returns an array of these components.
|
||||
* Each component is itself an array that contains the ids of nodes in the component.
|
||||
* Complexity: O(|V|).
|
||||
*
|
||||
* @argument graph - graph to find components in.
|
||||
* @returns array of nodes list representing components
|
||||
*/
|
||||
function components(graph: Graph): string[][];
|
||||
|
||||
/**
|
||||
* This function is an implementation of Dijkstra's algorithm which finds the shortest
|
||||
* path from source to all other nodes in graph. This function returns a map of
|
||||
* v -> { distance, predecessor }. The distance property holds the sum of the weights
|
||||
* from source to v along the shortest path or Number.POSITIVE_INFINITY if there is no path
|
||||
* from source. The predecessor property can be used to walk the individual elements of the
|
||||
* path from source to v in reverse order.
|
||||
* Complexity: O((|E| + |V|) * log |V|).
|
||||
*
|
||||
* @argument graph - graph where to search pathes.
|
||||
* @argument source - node to start pathes from.
|
||||
* @argument weightFn - function which takes edge e and returns the weight of it. If no weightFn
|
||||
* is supplied then each edge is assumed to have a weight of 1. This function throws an
|
||||
* Error if any of the traversed edges have a negative edge weight.
|
||||
* @argument edgeFn - function which takes a node v and returns the ids of all edges incident to it
|
||||
* for the purposes of shortest path traversal. By default this function uses the graph.outEdges.
|
||||
* @returns shortest pathes map that starts from node source
|
||||
*/
|
||||
function dijkstra(
|
||||
graph: Graph,
|
||||
source: string,
|
||||
weightFn?: (e: Edge) => number,
|
||||
edgeFn?: (v: string) => Edge[]
|
||||
): { [node: string]: Path };
|
||||
|
||||
/**
|
||||
* This function finds the shortest path from each node to every other reachable node in
|
||||
* the graph. It is similar to alg.dijkstra, but instead of returning a single-source
|
||||
* array, it returns a mapping of source -> alg.dijksta(g, source, weightFn, edgeFn).
|
||||
* Complexity: O(|V| * (|E| + |V|) * log |V|).
|
||||
*
|
||||
* @argument graph - graph where to search pathes.
|
||||
* @argument weightFn - function which takes edge e and returns the weight of it. If no weightFn
|
||||
* is supplied then each edge is assumed to have a weight of 1. This function throws an
|
||||
* Error if any of the traversed edges have a negative edge weight.
|
||||
* @argument edgeFn - function which takes a node v and returns the ids of all edges incident to it
|
||||
* for the purposes of shortest path traversal. By default this function uses the graph.outEdges.
|
||||
* @returns shortest pathes map.
|
||||
*/
|
||||
function dijkstraAll(
|
||||
graph: Graph,
|
||||
weightFn?: (e: Edge) => number,
|
||||
edgeFn?: (v: string) => Edge[]
|
||||
): { [source: string]: { [node: string]: Path } };
|
||||
|
||||
/**
|
||||
* Given a Graph, graph, this function returns all nodes that are part of a cycle. As there
|
||||
* may be more than one cycle in a graph this function return an array of these cycles,
|
||||
* where each cycle is itself represented by an array of ids for each node involved in
|
||||
* that cycle. Method alg.isAcyclic is more efficient if you only need to determine whether a graph has a
|
||||
* cycle or not.
|
||||
* Complexity: O(|V| + |E|).
|
||||
*
|
||||
* @argument graph - graph where to search cycles.
|
||||
* @returns cycles list.
|
||||
*/
|
||||
function findCycles(graph: Graph): string[][];
|
||||
|
||||
/**
|
||||
* Given a Graph, graph, this function returns true if the graph has no cycles and returns false if it
|
||||
* does. This algorithm returns as soon as it detects the first cycle. You can use alg.findCycles
|
||||
* to get the actual list of cycles in the graph.
|
||||
*
|
||||
* @argument graph - graph to detect whether it acyclic ot not.
|
||||
* @returns whether graph contain cycles or not.
|
||||
*/
|
||||
function isAcyclic(graph: Graph): boolean;
|
||||
|
||||
/**
|
||||
* This function is an implementation of the Floyd-Warshall algorithm, which finds the
|
||||
* shortest path from each node to every other reachable node in the graph. It is similar
|
||||
* to alg.dijkstraAll, but it handles negative edge weights and is more efficient for some types
|
||||
* of graphs. This function returns a map of source -> { target -> { distance, predecessor }.
|
||||
* The distance property holds the sum of the weights from source to target along the shortest
|
||||
* path of Number.POSITIVE_INFINITY if there is no path from source. The predecessor property
|
||||
* can be used to walk the individual elements of the path from source to target in reverse
|
||||
* order.
|
||||
* Complexity: O(|V|^3).
|
||||
*
|
||||
* @argument graph - graph where to search pathes.
|
||||
* @argument weightFn - function which takes edge e and returns the weight of it. If no weightFn
|
||||
* is supplied then each edge is assumed to have a weight of 1. This function throws an
|
||||
* Error if any of the traversed edges have a negative edge weight.
|
||||
* @argument edgeFn - function which takes a node v and returns the ids of all edges incident to it
|
||||
* for the purposes of shortest path traversal. By default this function uses the graph.outEdges.
|
||||
* @returns shortest pathes map.
|
||||
*/
|
||||
function floydWarshall(
|
||||
graph: Graph,
|
||||
weightFn?: (e: Edge) => number,
|
||||
edgeFn?: (v: string) => Edge[]
|
||||
): { [source: string]: { [node: string]: Path } };
|
||||
|
||||
/**
|
||||
* Prim's algorithm takes a connected undirected graph and generates a minimum spanning tree. This
|
||||
* function returns the minimum spanning tree as an undirected graph. This algorithm is derived
|
||||
* from the description in "Introduction to Algorithms", Third Edition, Cormen, et al., Pg 634.
|
||||
* Complexity: O(|E| * log |V|);
|
||||
*
|
||||
* @argument graph - graph to generate a minimum spanning tree of.
|
||||
* @argument weightFn - function which takes edge e and returns the weight of it. It throws an Error if
|
||||
* the graph is not connected.
|
||||
* @returns minimum spanning tree of graph.
|
||||
*/
|
||||
function prim(graph: Graph, weightFn: (e: Edge) => number): Graph;
|
||||
|
||||
/**
|
||||
* This function is an implementation of Tarjan's algorithm which finds all strongly connected
|
||||
* components in the directed graph g. Each strongly connected component is composed of nodes that
|
||||
* can reach all other nodes in the component via directed edges. A strongly connected component
|
||||
* can consist of a single node if that node cannot both reach and be reached by any other
|
||||
* specific node in the graph. Components of more than one node are guaranteed to have at least
|
||||
* one cycle.
|
||||
* Complexity: O(|V| + |E|).
|
||||
*
|
||||
* @argument graph - graph to find all strongly connected components of.
|
||||
* @return an array of components. Each component is itself an array that contains
|
||||
* the ids of all nodes in the component.
|
||||
*/
|
||||
function tarjan(graph: Graph): string[][];
|
||||
|
||||
/**
|
||||
* Given a Graph graph this function applies topological sorting to it.
|
||||
* If the graph has a cycle it is impossible to generate such a list and CycleException is thrown.
|
||||
* Complexity: O(|V| + |E|).
|
||||
*
|
||||
* @argument graph - graph to apply topological sorting to.
|
||||
* @returns an array of nodes such that for each edge u -> v, u appears before v in the array.
|
||||
*/
|
||||
function topsort(graph: Graph): string[];
|
||||
|
||||
/**
|
||||
* Performs pre-order depth first traversal on the input graph. If the graph is
|
||||
* undirected then this algorithm will navigate using neighbors. If the graph
|
||||
* is directed then this algorithm will navigate using successors.
|
||||
*
|
||||
* @argument graph - depth first traversal target.
|
||||
* @argument vs - nodes list to traverse.
|
||||
* @returns the nodes in the order they were visited as a list of their names.
|
||||
*/
|
||||
function preorder(graph: Graph, vs: string[]): string[]
|
||||
|
||||
/**
|
||||
* Performs post-order depth first traversal on the input graph. If the graph is
|
||||
* undirected then this algorithm will navigate using neighbors. If the graph
|
||||
* is directed then this algorithm will navigate using successors.
|
||||
*
|
||||
* @argument graph - depth first traversal target.
|
||||
* @argument vs - nodes list to traverse.
|
||||
* @returns the nodes in the order they were visited as a list of their names.
|
||||
*/
|
||||
function postorder(graph: Graph, vs: string[]): string[]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
// Type definitions for jfs 0.2
|
||||
// Project: http://github.com/flosse/json-file-store
|
||||
// Definitions by: Tomasz Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
declare const JsonFileStore: JsonFileStore.JsonFileStore;
|
||||
|
||||
declare namespace JsonFileStore {
|
||||
export interface Storable {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
type?: 'single' | 'memory';
|
||||
pretty?: boolean;
|
||||
saveId?: boolean | string;
|
||||
}
|
||||
|
||||
export interface JsonFileStore {
|
||||
new <T extends Storable>(name?: string, opts?: Options): Instance<T>;
|
||||
}
|
||||
|
||||
export interface Instance<T> {
|
||||
save<K extends keyof T, V extends T[K]>(id: K, o: V, cb?: (err?: Error, id?: K) => void): void;
|
||||
save<V extends T[keyof T]>(o: V, cb?: (err?: Error, id?: string) => void): void;
|
||||
|
||||
saveSync<K extends keyof T, V extends T[K]>(id: K, o: V): void;
|
||||
saveSync<V extends T[keyof T]>(o: V): void;
|
||||
|
||||
get<K extends keyof T, V extends T[K]>(id: K, cb?: (err?: Error, o?: V) => void): void;
|
||||
|
||||
getSync<K extends keyof T, V extends T[K]>(id: K): V | Error;
|
||||
|
||||
delete<K extends keyof T>(id: K, cb?: (err?: Error) => void): void;
|
||||
|
||||
deleteSync<K extends keyof T>(id: K): Error | void;
|
||||
|
||||
all(cb: (err?: Error, all?: T) => void): void;
|
||||
|
||||
allSync(): T;
|
||||
}
|
||||
}
|
||||
|
||||
export = JsonFileStore;
|
||||
@@ -0,0 +1,44 @@
|
||||
import * as Store from 'jfs';
|
||||
|
||||
interface TestStore {
|
||||
foo: string;
|
||||
bar: number;
|
||||
}
|
||||
|
||||
const db = new Store<TestStore>('data', {type: 'memory'});
|
||||
|
||||
// save with custom ID
|
||||
db.save('bar', 123, function(err, id) {
|
||||
// now the data is stored in the file data/anId.json
|
||||
});
|
||||
|
||||
// save with generated ID
|
||||
db.save(333, function(err, id) {
|
||||
// id is a unique ID
|
||||
});
|
||||
|
||||
// save synchronously
|
||||
db.saveSync('foo', 'test');
|
||||
|
||||
db.get('bar', function(err, obj) {
|
||||
// obj = { foo: ''bar' }
|
||||
});
|
||||
|
||||
// get synchronously
|
||||
const val = db.getSync('bar');
|
||||
|
||||
// get all available objects
|
||||
db.all(function(err, objs) {
|
||||
// objs is a map: ID => OBJECT
|
||||
});
|
||||
|
||||
// get all synchronously
|
||||
var objs = db.allSync();
|
||||
|
||||
// delete by ID
|
||||
db.delete('foo', function(err) {
|
||||
// the file data/myId.json was removed
|
||||
});
|
||||
|
||||
// delete synchronously
|
||||
db.deleteSync('bar');
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jfs-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Vendored
+1
@@ -284,6 +284,7 @@ interface JQueryFileUploadXhr {
|
||||
jqXHR: JQueryXHR;
|
||||
result: any;
|
||||
textStatus: string;
|
||||
headers: {[key: string]: any};
|
||||
}
|
||||
|
||||
interface JQueryFileUploadFilesObject {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for magnet-uri 5.1
|
||||
// Project: https://github.com/feross/magnet-uri
|
||||
// Definitions by: Tomasz Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare const MagnetUri: MagnetUri.MagnetUri;
|
||||
|
||||
declare namespace MagnetUri {
|
||||
export interface MagnetUri {
|
||||
(uri: string): Instance;
|
||||
decode(uri: string): Instance;
|
||||
encode(parsed: Instance): string;
|
||||
}
|
||||
|
||||
export interface Instance extends Object {
|
||||
dn?: string | string[];
|
||||
tr?: string | string[];
|
||||
xs?: string | string[];
|
||||
as?: string | string[];
|
||||
ws?: string | string[];
|
||||
kt?: string[];
|
||||
ix?: number | number[];
|
||||
xt?: string | string[];
|
||||
infoHash?: string;
|
||||
infoHashBuffer?: Buffer;
|
||||
name?: string | string[];
|
||||
keywords?: string | string[];
|
||||
announce?: string[];
|
||||
urlList?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
export = MagnetUri;
|
||||
@@ -0,0 +1,8 @@
|
||||
import * as magnet from 'magnet-uri';
|
||||
|
||||
// "Leaves of Grass" by Walt Whitman
|
||||
const uri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337';
|
||||
|
||||
const parsed = magnet.decode(uri);
|
||||
console.log(parsed);
|
||||
console.log(magnet.encode(parsed));
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"magnet-uri-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// Type definitions for mock-raf 1.0
|
||||
// Project: https://github.com/FormidableLabs/mock-raf
|
||||
// Definitions by: Daniel Pereira <https://github.com/djpereira>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace MockRaf {
|
||||
|
||||
interface Options {
|
||||
|
||||
/** The time that should pass during each requestAnimationFrame step in milliseconds. Default is roughly equivalent to default browser behavior. */
|
||||
time?: number;
|
||||
|
||||
/** The number of steps to take. */
|
||||
count?: number;
|
||||
}
|
||||
|
||||
/** Creates a mockRaf instance, exposing the functions you'll use to interact with the mock. */
|
||||
interface Creator {
|
||||
|
||||
/** Returns the current now value of the mock. Starts at 0 and increases with each step() taken. Useful for stubbing out performance.now() or a polyfill when using requestAnimationFrame with timers. */
|
||||
now(): number;
|
||||
|
||||
/** Replacement for requestAnimationFrame or a polyfill.Adds a callback to be fired on the next step. */
|
||||
raf(callback: FrameRequestCallback): number;
|
||||
|
||||
/** Replacement for cancelAnimationFrame or a polyfill.Removes all currently scheduled requestAnimationFrame callbacks from the queue. */
|
||||
cancel(handle: number): void;
|
||||
|
||||
/** Takes requestAnimationFrame steps. Fires currently queued callbacks for each step and increments now time for each step. The primary way to interact with a mockRaf instance for testing. */
|
||||
step(options?: Options): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare function MockRaf(): MockRaf.Creator;
|
||||
|
||||
export = MockRaf;
|
||||
@@ -0,0 +1,9 @@
|
||||
import * as createMockRaf from 'mock-raf';
|
||||
|
||||
const mockRaf = createMockRaf();
|
||||
const id = mockRaf.raf(() => {
|
||||
console.log('RAF!!!');
|
||||
});
|
||||
mockRaf.step({ count: 10 });
|
||||
mockRaf.cancel(id);
|
||||
console.log(mockRaf.now());
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mock-raf-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Vendored
+39
-3
@@ -3,7 +3,9 @@
|
||||
// Definitions by: Vincent Bortone <https://github.com/vbortone/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface NumeralJSLanguage {
|
||||
|
||||
// http://numeraljs.com/#locales
|
||||
interface NumeralJSLocale {
|
||||
delimiters: {
|
||||
thousands: string;
|
||||
decimal: string;
|
||||
@@ -20,12 +22,43 @@ interface NumeralJSLanguage {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// http://numeraljs.com/#custom-formats
|
||||
interface NumeralJsFormat {
|
||||
regexps: {
|
||||
format: RegExp,
|
||||
unformat: RegExp,
|
||||
},
|
||||
format: (value: any, format: string, roundingFunction: Function) => string,
|
||||
unformat: (value: string) => number
|
||||
}
|
||||
|
||||
type RegisterType = 'format' | 'locale';
|
||||
|
||||
// http://numeraljs.com/#use-it
|
||||
interface Numeral {
|
||||
(value?: any): Numeral;
|
||||
version: string;
|
||||
isNumeral: boolean;
|
||||
language(key?: string, values?: NumeralJSLanguage): Numeral | string;
|
||||
zeroFormat(format: string): string;
|
||||
|
||||
/**
|
||||
* This function sets the current locale. If no arguments are passed in,
|
||||
* it will simply return the current global locale key.
|
||||
*/
|
||||
locale(key?: string): string;
|
||||
|
||||
/**
|
||||
* Registers a language definition or a custom format definition.
|
||||
*
|
||||
* @param what Allowed values are: either 'format' or 'locale'
|
||||
* @param key The key of the registerd type, e.g. 'de' for a german locale definition
|
||||
* @param value The locale definition or the format definitiion
|
||||
*/
|
||||
register(what: RegisterType, key: string, value: NumeralJSLocale | NumeralJsFormat): NumeralJSLocale | NumeralJsFormat;
|
||||
|
||||
zeroFormat(format: string): void;
|
||||
nullFormat(format: string): void;
|
||||
defaultFormat(format: string): void;
|
||||
clone(): Numeral;
|
||||
format(inputString?: string): string;
|
||||
formatCurrency(inputString?: string): string;
|
||||
@@ -42,6 +75,9 @@ interface Numeral {
|
||||
|
||||
declare var numeral: Numeral;
|
||||
|
||||
/**
|
||||
* Usage: <code>import * as numeral from 'numeral'</code>
|
||||
*/
|
||||
declare module "numeral" {
|
||||
|
||||
export = numeral;
|
||||
|
||||
@@ -41,3 +41,49 @@ var bVal: number = b.value();
|
||||
// 1000
|
||||
var cVal: number = c.add(10).value();
|
||||
// 1010
|
||||
|
||||
|
||||
// Formats
|
||||
numeral.register('format', 'percentage', {
|
||||
regexps: {
|
||||
format: /(%)/,
|
||||
unformat: /(%)/
|
||||
},
|
||||
format: function(value, format, roundingFunction) {
|
||||
return 'foo';
|
||||
},
|
||||
unformat: function(string) {
|
||||
return 123;
|
||||
}
|
||||
});
|
||||
|
||||
var customFormatted = numeral().format('0%');
|
||||
|
||||
|
||||
// Locales
|
||||
// load a locale
|
||||
numeral.register('locale', 'fr', {
|
||||
delimiters: {
|
||||
thousands: ' ',
|
||||
decimal: ','
|
||||
},
|
||||
abbreviations: {
|
||||
thousand: 'k',
|
||||
million: 'm',
|
||||
billion: 'b',
|
||||
trillion: 't'
|
||||
},
|
||||
ordinal : function (number) {
|
||||
return number === 1 ? 'er' : 'ème';
|
||||
},
|
||||
currency: {
|
||||
symbol: '€'
|
||||
}
|
||||
});
|
||||
|
||||
// switch between locales
|
||||
numeral.locale('fr');
|
||||
|
||||
// return the current locale
|
||||
numeral.locale();
|
||||
// 'fr'
|
||||
|
||||
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
// Type definitions for parse-torrent-file 4.0
|
||||
// Project: https://github.com/feross/parse-torrent-file
|
||||
// Definitions by: Tomasz Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare const ParseTorrentFile: ParseTorrentFile.ParseTorrentFile;
|
||||
|
||||
declare namespace ParseTorrentFile {
|
||||
export interface TorrentInfo {
|
||||
'name.utf-8'?: string;
|
||||
name?: string;
|
||||
files?: File[];
|
||||
'piece length'?: number;
|
||||
pieces?: number;
|
||||
private?: boolean;
|
||||
}
|
||||
|
||||
export interface Torrent {
|
||||
info?: TorrentInfo;
|
||||
'creation date'?: number;
|
||||
'created by'?: string;
|
||||
comment?: Buffer;
|
||||
'announce-list'?: string[][];
|
||||
announce?: string;
|
||||
'url-list'?: Buffer;
|
||||
}
|
||||
|
||||
export interface ParseTorrentFile {
|
||||
(torrent: Buffer | Torrent): Instance;
|
||||
decode(torrent: Buffer | Torrent): Instance;
|
||||
encode(parsed: Instance): Buffer;
|
||||
}
|
||||
|
||||
export interface ParsedFile {
|
||||
path: string;
|
||||
name: string;
|
||||
length: number;
|
||||
offset: number;
|
||||
}
|
||||
|
||||
export interface Instance extends Object {
|
||||
info?: TorrentInfo;
|
||||
infoBuffer?: Buffer;
|
||||
infoHash?: string;
|
||||
infoHashBuffer?: Buffer;
|
||||
name?: string;
|
||||
private?: boolean;
|
||||
created?: Date;
|
||||
createdBy?: string;
|
||||
announce?: string[];
|
||||
urlList?: string[];
|
||||
pieceLength?: number;
|
||||
lastPieceLength?: number;
|
||||
pieces?: string[];
|
||||
length?: number;
|
||||
files?: ParsedFile[];
|
||||
}
|
||||
}
|
||||
|
||||
export = ParseTorrentFile;
|
||||
@@ -0,0 +1,12 @@
|
||||
import * as parseTorrentFile from 'parse-torrent-file';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const torrent = fs.readFileSync(__filename);
|
||||
try {
|
||||
const parsed = parseTorrentFile(torrent);
|
||||
console.log(parsed.name);
|
||||
} catch (e) {
|
||||
// the torrent file was corrupt
|
||||
console.error(e);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"parse-torrent-file-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Vendored
+24
-29
@@ -1,40 +1,35 @@
|
||||
// Type definitions for parse-torrent
|
||||
// Type definitions for parse-torrent 5.8
|
||||
// Project: https://github.com/feross/parse-torrent
|
||||
// Definitions by: Bazyli Brzóska <https://invent.life>
|
||||
// Definitions by: Bazyli Brzóska <https://github.com/niieani>, Tomasz Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare var ParseTorrent:ParseTorrent.StaticInstance;
|
||||
export = ParseTorrent;
|
||||
import * as MagnetUri from 'magnet-uri';
|
||||
import * as ParseTorrentFile from 'parse-torrent-file';
|
||||
|
||||
declare const ParseTorrent: ParseTorrent.ParseTorrent;
|
||||
|
||||
declare namespace ParseTorrent {
|
||||
export interface ParsedTorrent {
|
||||
infoHash:string;
|
||||
xt?:string;
|
||||
info?: { length:number, name:Buffer, 'piece length':number, pieces:Buffer };
|
||||
infoBuffer?:Buffer;
|
||||
name?:string;
|
||||
private?:boolean;
|
||||
created?:Date;
|
||||
comment?:string;
|
||||
announce?:Array<string>;
|
||||
urlList?:Array<string>;
|
||||
files?:Array<{path:string, name:string, length: number, offset:number}>;
|
||||
length?:number;
|
||||
pieceLength?:number;
|
||||
lastPieceLength?:number;
|
||||
pieces?:Array<string>;
|
||||
}
|
||||
|
||||
interface StaticInstance {
|
||||
(magnetUriOrInfoHash:string):ParsedTorrent;
|
||||
(torrentFileOrInfoHash:Buffer):{ info:ParsedTorrent };
|
||||
interface ParseTorrent {
|
||||
(torrent: string): MagnetUri.Instance;
|
||||
(torrent: Buffer): MagnetUri.Instance | ParseTorrentFile.Instance;
|
||||
(torrent: Instance | MagnetUri.Instance | ParseTorrentFile.Instance): Instance;
|
||||
|
||||
toMagnetURI(parsedTorrent:ParsedTorrent):string;
|
||||
toTorrentFile(parsedTorrent:{ info:ParsedTorrent }):Buffer;
|
||||
toMagnetURI: typeof MagnetUri.encode;
|
||||
toTorrentFile: typeof ParseTorrentFile.encode;
|
||||
|
||||
remote(torrent: string | Buffer | Instance | MagnetUri.Instance | ParseTorrentFile.Instance | Blob, cb?: (err: Error, torrent?: Instance) => void): void;
|
||||
}
|
||||
|
||||
export interface Instance extends MagnetUri.Instance, ParseTorrentFile.Instance {
|
||||
infoHash: string;
|
||||
name?: string;
|
||||
announce?: string[];
|
||||
urlList?: string[];
|
||||
}
|
||||
|
||||
remote(remoteURLorLocalTorrentPath:string, onTorrentCallback?:(err:Error, parsedTorrent:ParsedTorrent)=>void):void;
|
||||
remote(torrentBlob:Blob, onTorrentCallback?:(err:Error, parsedTorrent:ParsedTorrent)=>void):void;
|
||||
}
|
||||
}
|
||||
|
||||
export = ParseTorrent;
|
||||
|
||||
@@ -1,37 +1,35 @@
|
||||
|
||||
|
||||
import parseTorrent = require('parse-torrent');
|
||||
import * as parseTorrent from 'parse-torrent';
|
||||
import * as fs from 'fs';
|
||||
|
||||
// info hash (as a hex string)
|
||||
parseTorrent('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
|
||||
parseTorrent('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36');
|
||||
// { infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36' }
|
||||
|
||||
// info hash (as a Buffer)
|
||||
parseTorrent(new Buffer('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', 'hex'))
|
||||
parseTorrent(new Buffer('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', 'hex'));
|
||||
// { infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36' }
|
||||
|
||||
// magnet uri (as a utf8 string)
|
||||
parseTorrent('magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36')
|
||||
parseTorrent('magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36');
|
||||
// { xt: 'urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
|
||||
// infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36' }
|
||||
|
||||
// magnet uri with torrent name
|
||||
parseTorrent('magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves%20of%20Grass%20by%20Walt%20Whitman.epub')
|
||||
parseTorrent('magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves%20of%20Grass%20by%20Walt%20Whitman.epub');
|
||||
// { xt: 'urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
|
||||
// dn: 'Leaves of Grass by Walt Whitman.epub',
|
||||
// infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
|
||||
// name: 'Leaves of Grass by Walt Whitman.epub' }
|
||||
|
||||
// magnet uri with trackers
|
||||
parseTorrent('magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&tr=http%3A%2F%2Ftracker.example.com%2Fannounce')
|
||||
parseTorrent('magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&tr=http%3A%2F%2Ftracker.example.com%2Fannounce');
|
||||
// { xt: 'urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
|
||||
// tr: 'http://tracker.example.com/announce',
|
||||
// infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
|
||||
// announce: [ 'http://tracker.example.com/announce' ] }
|
||||
|
||||
// .torrent file (as a Buffer)
|
||||
parseTorrent(fs.readFileSync(__dirname + '/torrents/leaves.torrent'))
|
||||
parseTorrent(fs.readFileSync(__dirname + '/torrents/leaves.torrent'));
|
||||
// { info:
|
||||
// { length: 362017,
|
||||
// name: <Buffer 4c 65 61 76 65 73 20 6f 66 20 47 72 61 73 73 20 62 79 20 57 61 6c 74 20 57 68 69 74 6d 61 6e 2e 65 70 75 62>,
|
||||
@@ -80,18 +78,15 @@ parseTorrent(fs.readFileSync(__dirname + '/torrents/leaves.torrent'))
|
||||
// 'c698de9b0dad92980906c026d8c1408fa08fe4ec' ] }
|
||||
|
||||
var uri = parseTorrent.toMagnetURI({
|
||||
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
|
||||
})
|
||||
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
|
||||
});
|
||||
|
||||
var buf = parseTorrent.toTorrentFile({
|
||||
info: {
|
||||
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36'
|
||||
/* ... */
|
||||
}
|
||||
})
|
||||
infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
|
||||
});
|
||||
|
||||
parseTorrent.remote('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', function (err, parsedTorrent) {
|
||||
// if (err) throw err
|
||||
// console.log(parsedTorrent)
|
||||
})
|
||||
parseTorrent.remote('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', function(err, parsedTorrent) {
|
||||
// if (err) throw err
|
||||
// console.log(parsedTorrent)
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Vendored
+87
@@ -0,0 +1,87 @@
|
||||
// Type definitions for payment 2.1
|
||||
// Project: https://github.com/jessepollak/payment#readme
|
||||
// Definitions by: Alexandre Paré <https://github.com/apare>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface Fns {
|
||||
/**
|
||||
* Validates a card number:
|
||||
* * Validates numbers
|
||||
* * Validates Luhn algorithm
|
||||
* * Validates length
|
||||
*/
|
||||
validateCardNumber(cardNumber: string): boolean;
|
||||
/**
|
||||
* Validates a card expiry:
|
||||
* * Validates numbers
|
||||
* * Validates in the future
|
||||
* * Supports year shorthand
|
||||
* * Supports formatted as formatCardExpiry input value
|
||||
*/
|
||||
validateCardExpiry(monthYear: string, year?: string): boolean;
|
||||
/**
|
||||
* Validates a card CVC:
|
||||
* * Validates number
|
||||
* * Validates length to 4
|
||||
*/
|
||||
validateCardCVC(cvc: string, type: string): boolean;
|
||||
/**
|
||||
* Returns a card type. Either:
|
||||
* * visa
|
||||
* * mastercard
|
||||
* * discover
|
||||
* * amex
|
||||
* * jcb
|
||||
* * dinersclub
|
||||
* * maestro
|
||||
* * laser
|
||||
* * unionpay
|
||||
* * elo
|
||||
*
|
||||
* The function will return null if the card type can't be determined.
|
||||
*/
|
||||
cardType(cardNumber: string): string;
|
||||
/**
|
||||
* Parses a credit card expiry in the form of MM/YYYY, returning an object containing the `month` and `year`.
|
||||
* Shorthand years, such as `13` are also supported (and converted into the longhand, e.g. `2013`).
|
||||
*/
|
||||
cardExpiryVal(monthYear: string | HTMLInputElement): MonthYear;
|
||||
}
|
||||
|
||||
interface MonthYear {
|
||||
month: number;
|
||||
year: number;
|
||||
}
|
||||
|
||||
declare var Payment: {
|
||||
/**
|
||||
* Formats card numbers:
|
||||
* * Includes a space between every 4 digits
|
||||
* * Restricts input to numbers
|
||||
* * Limits to 16 numbers
|
||||
* * Supports American Express formatting
|
||||
* * Adds a class of the card type (e.g. 'visa') to the input
|
||||
*/
|
||||
formatCardNumber(elem: HTMLInputElement): HTMLInputElement;
|
||||
/**
|
||||
* Formats card expiry:
|
||||
* * Includes a / between the month and year
|
||||
* * Restricts input to numbers
|
||||
* * Restricts length
|
||||
*/
|
||||
formatCardExpiry(elem: HTMLInputElement): HTMLInputElement;
|
||||
/**
|
||||
* Formats card CVC:
|
||||
* * Restricts length to 4 numbers
|
||||
* * Restricts input to numbers
|
||||
*/
|
||||
formatCardCVC(elem: HTMLInputElement): HTMLInputElement;
|
||||
/**
|
||||
* General numeric input restriction.
|
||||
*/
|
||||
restrictNumeric(elem: HTMLInputElement): HTMLInputElement;
|
||||
|
||||
fns: Fns;
|
||||
};
|
||||
|
||||
export = Payment;
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as Payment from "payment";
|
||||
|
||||
var input = document.getElementById('input') as HTMLInputElement;
|
||||
|
||||
Payment.restrictNumeric(input);
|
||||
Payment.formatCardNumber(input);
|
||||
Payment.formatCardExpiry(input);
|
||||
Payment.formatCardCVC(input);
|
||||
|
||||
var card = "1234 5678 9012 3456";
|
||||
|
||||
var cardType = Payment.fns.cardType(card);
|
||||
Payment.fns.validateCardNumber(card);
|
||||
Payment.fns.validateCardExpiry("1 / 20");
|
||||
Payment.fns.validateCardExpiry("1", "20");
|
||||
Payment.fns.validateCardCVC("123", cardType);
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"payment-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
Vendored
+3
-3
@@ -9,7 +9,7 @@
|
||||
|
||||
import events = require("events");
|
||||
import stream = require("stream");
|
||||
import pgTypes = require("pg-types");
|
||||
import pgTypes = require("pg-types");
|
||||
|
||||
export declare function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void;
|
||||
export declare function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void;
|
||||
@@ -92,8 +92,8 @@ export declare class Client extends events.EventEmitter {
|
||||
constructor(connection: string);
|
||||
constructor(config: ClientConfig);
|
||||
|
||||
connect(callback?: (err:Error) => void): void;
|
||||
end(): void;
|
||||
connect(callback?: (err:Error) => void): void;
|
||||
end(callback?: (err: Error) => void): void;
|
||||
release(): void;
|
||||
|
||||
query(queryText: string): Promise<QueryResult>;
|
||||
|
||||
Vendored
+99
-100
@@ -1,142 +1,141 @@
|
||||
// Type definitions for RxJS v2.5.3
|
||||
// Type definitions for RxJS 7.0
|
||||
// Project: https://github.com/Reactive-Extensions/RxJS-DOM
|
||||
// Definitions by: oliver Weichhold <https://github.com/oliverw>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference types="rx" />
|
||||
import * as Rx from 'rx';
|
||||
|
||||
declare module Rx.DOM {
|
||||
export interface AjaxSettings {
|
||||
async?: boolean;
|
||||
body?: string;
|
||||
// This options does not seem to be used in the code yet
|
||||
// contentType?: string;
|
||||
crossDomain?: boolean;
|
||||
headers?: any;
|
||||
method?: string;
|
||||
password?: string;
|
||||
progressObserver?: Rx.Observer<any>;
|
||||
responseType?: string;
|
||||
url?: string;
|
||||
user?: string;
|
||||
declare module 'rx' {
|
||||
namespace DOM {
|
||||
interface AjaxSettings {
|
||||
async?: boolean;
|
||||
body?: string;
|
||||
// This options does not seem to be used in the code yet
|
||||
// contentType?: string;
|
||||
crossDomain?: boolean;
|
||||
headers?: any;
|
||||
method?: string;
|
||||
password?: string;
|
||||
progressObserver?: Rx.Observer<any>;
|
||||
responseType?: string;
|
||||
url?: string;
|
||||
user?: string;
|
||||
}
|
||||
|
||||
export interface AjaxSuccessResponse {
|
||||
response: any;
|
||||
status: number;
|
||||
responseType: string;
|
||||
xhr: XMLHttpRequest;
|
||||
originalEvent: Event;
|
||||
interface AjaxSuccessResponse {
|
||||
response: any;
|
||||
status: number;
|
||||
responseType: string;
|
||||
xhr: XMLHttpRequest;
|
||||
originalEvent: Event;
|
||||
}
|
||||
|
||||
export interface AjaxErrorResponse {
|
||||
type: string;
|
||||
status: number;
|
||||
xhr: XMLHttpRequest;
|
||||
originalEvent: Event;
|
||||
interface AjaxErrorResponse {
|
||||
type: string;
|
||||
status: number;
|
||||
xhr: XMLHttpRequest;
|
||||
originalEvent: Event;
|
||||
}
|
||||
|
||||
export interface JsonpSettings {
|
||||
async?: boolean;
|
||||
jsonp?: string;
|
||||
jsonpCallback?: string;
|
||||
url?: string;
|
||||
interface JsonpSettings {
|
||||
async?: boolean;
|
||||
jsonp?: string;
|
||||
jsonpCallback?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export interface JsonpSuccessResponse {
|
||||
response: any;
|
||||
status: number;
|
||||
responseType: string;
|
||||
originalEvent: Event;
|
||||
interface JsonpSuccessResponse {
|
||||
response: any;
|
||||
status: number;
|
||||
responseType: string;
|
||||
originalEvent: Event;
|
||||
}
|
||||
|
||||
export interface JsonpErrorResponse {
|
||||
type: string;
|
||||
status: number;
|
||||
originalEvent: Event;
|
||||
interface JsonpErrorResponse {
|
||||
type: string;
|
||||
status: number;
|
||||
originalEvent: Event;
|
||||
}
|
||||
|
||||
export interface GeolocationOptions {
|
||||
enableHighAccuracy?: boolean;
|
||||
timeout?: number;
|
||||
maximumAge?: number;
|
||||
interface GeolocationOptions {
|
||||
enableHighAccuracy?: boolean;
|
||||
timeout?: number;
|
||||
maximumAge?: number;
|
||||
}
|
||||
|
||||
// Events
|
||||
function fromEvent<T>(element:any, eventName:string, selector?:Function, useCapture?:boolean):Rx.Observable<T>;
|
||||
function fromEvent<T>(element: any, eventName: string, selector?: Function, useCapture?: boolean): Rx.Observable<T>;
|
||||
|
||||
function ready():Rx.Observable<any>;
|
||||
function ready(): Rx.Observable<any>;
|
||||
|
||||
// Event Shortcuts
|
||||
function blur(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<FocusEvent>;
|
||||
function change(element: Element, selector?:Function):Rx.Observable<Event>;
|
||||
function click(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function contextmenu(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function dblclick(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function error(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<Event>;
|
||||
function focus(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<FocusEvent>;
|
||||
function focusin(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function focusout(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function keydown(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<KeyboardEvent>;
|
||||
function keypress(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<KeyboardEvent>;
|
||||
function keyup(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<KeyboardEvent>;
|
||||
function load(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<UIEvent>;
|
||||
function mousedown(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function mouseenter(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function mouseleave(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function mousemove(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function mouseout(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function mouseover(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function mouseup(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<MouseEvent>;
|
||||
function resize(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<UIEvent>;
|
||||
function scroll(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<UIEvent>;
|
||||
function select(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<Event>;
|
||||
function submit(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<Event>;
|
||||
function unload(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<Event>;
|
||||
function blur(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<FocusEvent>;
|
||||
function change(element: Element, selector?: Function): Rx.Observable<Event>;
|
||||
function click(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function contextmenu(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function dblclick(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function error(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<Event>;
|
||||
function focus(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<FocusEvent>;
|
||||
function focusin(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function focusout(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function keydown(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<KeyboardEvent>;
|
||||
function keypress(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<KeyboardEvent>;
|
||||
function keyup(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<KeyboardEvent>;
|
||||
function load(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<UIEvent>;
|
||||
function mousedown(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function mouseenter(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function mouseleave(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function mousemove(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function mouseout(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function mouseover(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function mouseup(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<MouseEvent>;
|
||||
function resize(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<UIEvent>;
|
||||
function scroll(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<UIEvent>;
|
||||
function select(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<Event>;
|
||||
function submit(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<Event>;
|
||||
function unload(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<Event>;
|
||||
|
||||
// Pointer Events
|
||||
function pointerdown(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<PointerEvent>;
|
||||
function pointerenter(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<PointerEvent>;
|
||||
function pointerleave(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<PointerEvent>;
|
||||
function pointermove(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<PointerEvent>;
|
||||
function pointerout(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<PointerEvent>;
|
||||
function pointerover(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<PointerEvent>;
|
||||
function pointerup(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<PointerEvent>;
|
||||
function pointerdown(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<PointerEvent>;
|
||||
function pointerenter(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<PointerEvent>;
|
||||
function pointerleave(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<PointerEvent>;
|
||||
function pointermove(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<PointerEvent>;
|
||||
function pointerout(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<PointerEvent>;
|
||||
function pointerover(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<PointerEvent>;
|
||||
function pointerup(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<PointerEvent>;
|
||||
|
||||
// Touch Events
|
||||
function touchcancel(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<TouchEvent>;
|
||||
function touchend(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<TouchEvent>;
|
||||
function touchmove(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<TouchEvent>;
|
||||
function touchstart(element: Element, selector?:Function, useCapture?:boolean):Rx.Observable<TouchEvent>;
|
||||
function touchcancel(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<TouchEvent>;
|
||||
function touchend(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<TouchEvent>;
|
||||
function touchmove(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<TouchEvent>;
|
||||
function touchstart(element: Element, selector?: Function, useCapture?: boolean): Rx.Observable<TouchEvent>;
|
||||
|
||||
// Ajax
|
||||
function ajax(url:string):Rx.Observable<AjaxSuccessResponse>;
|
||||
function ajax(settings:AjaxSettings):Rx.Observable<AjaxSuccessResponse>;
|
||||
function get(url:string):Rx.Observable<AjaxSuccessResponse>;
|
||||
function getJSON(url:string):Rx.Observable<string>;
|
||||
function post(url:string, body:any):Rx.Observable<AjaxSuccessResponse>;
|
||||
function jsonpRequest(url:string):Rx.Observable<string>;
|
||||
function jsonpRequest(settings:JsonpSettings):Rx.Observable<JsonpSuccessResponse>;
|
||||
function ajax(settingsOrUrl: AjaxSettings | string): Rx.Observable<AjaxSuccessResponse>;
|
||||
function get(url: string): Rx.Observable<AjaxSuccessResponse>;
|
||||
function getJSON(url: string): Rx.Observable<string>;
|
||||
function post(url: string, body: any): Rx.Observable<AjaxSuccessResponse>;
|
||||
function jsonpRequest(url: string): Rx.Observable<string>;
|
||||
function jsonpRequest(settings: JsonpSettings): Rx.Observable<JsonpSuccessResponse>;
|
||||
|
||||
// Server-Sent Events
|
||||
function fromEventSource<T>(url:string, openObservable?:Rx.Observer<T>):Rx.Observable<T>;
|
||||
function fromEventSource<T>(url: string, openObservable?: Rx.Observer<T>): Rx.Observable<T>;
|
||||
|
||||
// Web Sockets
|
||||
function fromWebSocket(url:string, protocol:string, openObserver?:Rx.Observer<Event>, closingObserver?:Rx.Observer<CloseEvent>):Rx.Subject<MessageEvent>;
|
||||
function fromWebSocket(url: string, protocol: string, openObserver?: Rx.Observer<Event>, closingObserver?: Rx.Observer<CloseEvent>): Rx.Subject<MessageEvent>;
|
||||
|
||||
// Web Workers
|
||||
function fromWebWorker(url:string):Rx.Subject<string>;
|
||||
function fromWebWorker(url: string): Rx.Subject<string>;
|
||||
|
||||
// Mutation Observers
|
||||
function fromMutationObserver(target:Node, options:MutationObserverInit):Rx.Observable<MutationEvent>;
|
||||
function fromMutationObserver(target: Node, options: MutationObserverInit): Rx.Observable<MutationEvent>;
|
||||
|
||||
// Geolocation
|
||||
export module geolocation {
|
||||
function getCurrentPosition(geolocationOptions?:GeolocationOptions):Rx.Observable<Position>;
|
||||
function watchPosition(geolocationOptions?:GeolocationOptions):Rx.Observable<Position>;
|
||||
namespace geolocation {
|
||||
function getCurrentPosition(geolocationOptions?: GeolocationOptions): Rx.Observable<Position>;
|
||||
function watchPosition(geolocationOptions?: GeolocationOptions): Rx.Observable<Position>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "rx-dom" {
|
||||
export default Rx.DOM;
|
||||
}
|
||||
export = Rx;
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
import * as Rx from 'rx';
|
||||
import * as DOM from 'rx-dom';
|
||||
import * as DOM from 'rx-dom';
|
||||
|
||||
// Rx and DOM should both be the same reference
|
||||
// before rx-dom import, Rx will not contain the DOM namespace
|
||||
// after rx-dom import, Rx will contain the DOM namespace
|
||||
|
||||
// this is the standard approach for importing rx + rx-dom
|
||||
import { Observable, Subject, DOM as rxdom } from 'rx-dom';
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
// this package augments Rx with namespace level functions
|
||||
// it would be particualrly strange to type these functions differently
|
||||
"forbidden-types": false
|
||||
}
|
||||
}
|
||||
Vendored
+41
-42
@@ -1,4 +1,4 @@
|
||||
// Type definitions for sqlite3 2.2.3
|
||||
// Type definitions for sqlite3 2.2
|
||||
// Project: https://github.com/mapbox/node-sqlite3
|
||||
// Definitions by: Nick Malaguti <https://github.com/nmalaguti/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -23,67 +23,66 @@ export interface RunResult {
|
||||
}
|
||||
|
||||
export declare class Statement {
|
||||
public bind(callback?: (err: Error) => void): Statement;
|
||||
public bind(...params: any[]): Statement;
|
||||
bind(callback?: (err: Error) => void): Statement;
|
||||
bind(...params: any[]): Statement;
|
||||
|
||||
public reset(callback?: (err: Error) => void): Statement;
|
||||
reset(callback?: (err: Error) => void): Statement;
|
||||
|
||||
public finalize(callback?: (err: Error) => void): Statement;
|
||||
finalize(callback?: (err: Error) => void): Statement;
|
||||
|
||||
public run(callback?: (err: Error) => void): Statement;
|
||||
public run(params: any, callback?: (err: Error) => void): Statement;
|
||||
public run(...params: any[]): Statement;
|
||||
run(callback?: (err: Error) => void): Statement;
|
||||
run(params: any, callback?: (err: Error) => void): Statement;
|
||||
run(...params: any[]): Statement;
|
||||
|
||||
public get(callback?: (err: Error, row: any) => void): Statement;
|
||||
public get(params: any, callback?: (err: Error, row: any) => void): Statement;
|
||||
public get(...params: any[]): Statement;
|
||||
get(callback?: (err: Error, row: any) => void): Statement;
|
||||
get(params: any, callback?: (err: Error, row: any) => void): Statement;
|
||||
get(...params: any[]): Statement;
|
||||
|
||||
public all(callback?: (err: Error, rows: any[]) => void): Statement;
|
||||
public all(params: any, callback?: (err: Error, rows: any[]) => void): Statement;
|
||||
public all(...params: any[]): Statement;
|
||||
all(callback?: (err: Error, rows: any[]) => void): Statement;
|
||||
all(params: any, callback?: (err: Error, rows: any[]) => void): Statement;
|
||||
all(...params: any[]): Statement;
|
||||
|
||||
public each(callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement;
|
||||
public each(params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement;
|
||||
public each(...params: any[]): Statement;
|
||||
each(callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement;
|
||||
each(params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Statement;
|
||||
each(...params: any[]): Statement;
|
||||
}
|
||||
|
||||
export declare class Database extends events.EventEmitter {
|
||||
constructor(filename: string, callback?: (err: Error) => void);
|
||||
constructor(filename: string, mode?: number, callback?: (err: Error) => void);
|
||||
|
||||
public close(callback?: (err: Error) => void): void;
|
||||
close(callback?: (err: Error) => void): void;
|
||||
|
||||
public run(sql: string, callback?: (err: Error) => void): Database;
|
||||
public run(sql: string, params: any, callback?: (err: Error) => void): Database;
|
||||
public run(sql: string, ...params: any[]): Database;
|
||||
run(sql: string, callback?: (err: Error) => void): Database;
|
||||
run(sql: string, params: any, callback?: (err: Error) => void): Database;
|
||||
run(sql: string, ...params: any[]): Database;
|
||||
|
||||
public get(sql: string, callback?: (err: Error, row: any) => void): Database;
|
||||
public get(sql: string, params: any, callback?: (err: Error, row: any) => void): Database;
|
||||
public get(sql: string, ...params: any[]): Database;
|
||||
get(sql: string, callback?: (err: Error, row: any) => void): Database;
|
||||
get(sql: string, params: any, callback?: (err: Error, row: any) => void): Database;
|
||||
get(sql: string, ...params: any[]): Database;
|
||||
|
||||
public all(sql: string, callback?: (err: Error, rows: any[]) => void): Database;
|
||||
public all(sql: string, params: any, callback?: (err: Error, rows: any[]) => void): Database;
|
||||
public all(sql: string, ...params: any[]): Database;
|
||||
all(sql: string, callback?: (err: Error, rows: any[]) => void): Database;
|
||||
all(sql: string, params: any, callback?: (err: Error, rows: any[]) => void): Database;
|
||||
all(sql: string, ...params: any[]): Database;
|
||||
|
||||
public each(sql: string, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database;
|
||||
public each(sql: string, params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database;
|
||||
public each(sql: string, ...params: any[]): Database;
|
||||
each(sql: string, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database;
|
||||
each(sql: string, params: any, callback?: (err: Error, row: any) => void, complete?: (err: Error, count: number) => void): Database;
|
||||
each(sql: string, ...params: any[]): Database;
|
||||
|
||||
public exec(sql: string, callback?: (err: Error) => void): Database;
|
||||
exec(sql: string, callback?: (err: Error) => void): Database;
|
||||
|
||||
public prepare(sql: string, callback?: (err: Error) => void): Statement;
|
||||
public prepare(sql: string, params: any, callback?: (err: Error) => void): Statement;
|
||||
public prepare(sql: string, ...params: any[]): Statement;
|
||||
prepare(sql: string, callback?: (err: Error) => void): Statement;
|
||||
prepare(sql: string, params: any, callback?: (err: Error) => void): Statement;
|
||||
prepare(sql: string, ...params: any[]): Statement;
|
||||
|
||||
public serialize(callback?: () => void): void;
|
||||
public parallelize(callback?: () => void): void;
|
||||
serialize(callback?: () => void): void;
|
||||
parallelize(callback?: () => void): void;
|
||||
|
||||
public on(event: "trace", listener: (sql: string) => void): this;
|
||||
public on(event: "profile", listener: (sql: string, time: number) => void): this;
|
||||
public on(event: "error", listener: (err: Error) => void): this;
|
||||
public on(event: "open", listener: () => void): this;
|
||||
public on(event: "close", listener: () => void): this;
|
||||
public on(event: string, listener: Function): this;
|
||||
on(event: "trace", listener: (sql: string) => void): this;
|
||||
on(event: "profile", listener: (sql: string, time: number) => void): this;
|
||||
on(event: "error", listener: (err: Error) => void): this;
|
||||
on(event: "open" | "close", listener: () => void): this;
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
}
|
||||
|
||||
declare function verbose(): void;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import sqlite3 = require('sqlite3');
|
||||
sqlite3.verbose();
|
||||
|
||||
var db: sqlite3.Database;
|
||||
var db: sqlite3.Database = new sqlite3.Database('chain.sqlite3', () => {});
|
||||
|
||||
function createDb() {
|
||||
console.log("createDb chain");
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Vendored
+84
@@ -6,6 +6,89 @@
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare namespace UIkit {
|
||||
interface DropdownElement {
|
||||
/**
|
||||
* Show the dropdown
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* Hide the dropdown
|
||||
* @param {boolean} force
|
||||
*/
|
||||
hide(force?: boolean): void;
|
||||
}
|
||||
type DropdownPosition =
|
||||
'bottom-left' |
|
||||
'bottom-center' |
|
||||
'bottom-right' |
|
||||
'top-left' |
|
||||
'top-center' |
|
||||
'top-right' |
|
||||
'left-top' |
|
||||
'left-center' |
|
||||
'left-bottom' |
|
||||
'right-top' |
|
||||
'right-center' |
|
||||
'right-bottom';
|
||||
interface DropdownOptions {
|
||||
/**
|
||||
* Dropdown position
|
||||
* @default 'bottom-left'
|
||||
*/
|
||||
pos?: DropdownPosition;
|
||||
/**
|
||||
* Dropdown trigger behaviour
|
||||
* @default 'hover'
|
||||
*/
|
||||
mode?: 'hover'|'click';
|
||||
/**
|
||||
* Remain time before auto closing dropdown in hover mode
|
||||
* @default 800
|
||||
*/
|
||||
remaintime?: number;
|
||||
/**
|
||||
* Stretch dropdown width to a specified element
|
||||
* @default false
|
||||
*/
|
||||
justify?: string|JQuery|false;
|
||||
/**
|
||||
* Referenced element to keep dropdowns visibilty
|
||||
* @default window
|
||||
*/
|
||||
boundary?: string|JQuery|Window;
|
||||
/**
|
||||
* Delay time in hover mode before a dropdown is shown in ms
|
||||
* @default 0
|
||||
*/
|
||||
delay?: number;
|
||||
/**
|
||||
* Dropdown selector
|
||||
* @default '.uk-dropdown,.uk-dropdown-blank'
|
||||
*/
|
||||
dropdownSelector?: string|JQuery;
|
||||
/**
|
||||
* Is added to the delay time when hovering from one active dropdown to another dropdown (in ms)
|
||||
* @default 250
|
||||
*/
|
||||
hoverDelayIdle?: number;
|
||||
/**
|
||||
* Prevent automatic dropdown flip
|
||||
* Possible values: 'x', 'y', true, false
|
||||
* @default false
|
||||
*/
|
||||
preventflip?: 'x'|'y'|boolean;
|
||||
}
|
||||
/**
|
||||
* Create a toggleable dropdown with different styles
|
||||
* Documentation: {@link http://getuikit.org/docs/dropdown.html}
|
||||
*
|
||||
* Events:
|
||||
* Name Description
|
||||
* show.uk.dropdown Triggered on dropdown show
|
||||
* hide.uk.dropdown Triggered on dropdown hide
|
||||
* stack.uk.dropdown Triggered when a dropdown stacks to fit into screen
|
||||
*/
|
||||
type Dropdown = (selector: string|JQuery, options?: DropdownOptions) => DropdownElement;
|
||||
interface ModalElement {
|
||||
/**
|
||||
* Show the modal
|
||||
@@ -1347,6 +1430,7 @@ declare namespace UIkit {
|
||||
* </table>
|
||||
*/
|
||||
type Upload = (element: string|JQuery, options: UploadOptions) => any;
|
||||
var dropdown: Dropdown;
|
||||
var modal: Modal;
|
||||
var lightbox: LightBox;
|
||||
var offcanvas: OffCanvas;
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
function testDropdown() {
|
||||
UIkit.dropdown("#parent");
|
||||
UIkit.dropdown($("#parent"));
|
||||
|
||||
let options: UIkit.DropdownOptions = {
|
||||
pos: 'bottom-center',
|
||||
mode: 'click',
|
||||
remaintime: 150,
|
||||
justify: false,
|
||||
boundary: window,
|
||||
delay: 0,
|
||||
dropdownSelector: '.uk-dropdown,.uk-dropdown-blank',
|
||||
hoverDelayIdle: 200,
|
||||
preventflip: 'x'
|
||||
};
|
||||
var dropdown = UIkit.dropdown("$parent", options);
|
||||
|
||||
dropdown.show();
|
||||
dropdown.hide();
|
||||
dropdown.hide(true);
|
||||
dropdown.hide(false);
|
||||
}
|
||||
|
||||
function testModal() {
|
||||
UIkit.modal.alert("Attention!");
|
||||
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
// Type definitions for vkbeautify 0.99
|
||||
// Project: https://github.com/aabluedragon/vkbeautify
|
||||
// Definitions by: Tim Schraepen <https://github.com/sch3lp/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Original project: https://github.com/vkiryukhin/vkBeautify
|
||||
|
||||
// beautifying
|
||||
/**
|
||||
* Pretty print an xml string with the given number of whitespace, or with a given indentation pattern
|
||||
*/
|
||||
export function xml(text: string, amountOfWhitespaces?: number | string): string;
|
||||
|
||||
/**
|
||||
* Pretty print a json string with the given number of whitespace, or with a given indentation pattern
|
||||
*/
|
||||
export function json(text: string, amountOfWhitespaces?: number | string): string;
|
||||
|
||||
/**
|
||||
* Pretty print a css string with the given number of whitespace, or with a given indentation pattern
|
||||
*/
|
||||
export function css(text: string, amountOfWhitespaces?: number | string): string;
|
||||
|
||||
/**
|
||||
* Pretty print an sql string with the given number of whitespace, or with a given indentation pattern
|
||||
*/
|
||||
export function sql(text: string, amountOfWhitespaces?: number | string): string;
|
||||
|
||||
// minifying
|
||||
/**
|
||||
* Minifiy an xml string, and preserve or remove comments (default)
|
||||
*/
|
||||
export function xmlmin(text: string, preserveComments?: boolean): string;
|
||||
/**
|
||||
* Minifiy a json string
|
||||
*/
|
||||
export function jsonmin(text: string): string;
|
||||
/**
|
||||
* Minifiy a css string, and preserve or remove comments (default)
|
||||
*/
|
||||
export function cssmin(text: string, preserveComments?: boolean): string;
|
||||
/**
|
||||
* Minifiy an sql string
|
||||
*/
|
||||
export function sqlmin(text: string): string;
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"vkbeautify-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
@@ -0,0 +1,119 @@
|
||||
import VKBeautify from 'vkbeautify';
|
||||
|
||||
/*
|
||||
* Beautifying
|
||||
*
|
||||
* vkbeautify.xml(text [,indent_pattern]);
|
||||
* vkbeautify.json(text [,indent_pattern]);
|
||||
* vkbeautify.css(text [,indent_pattern]);
|
||||
* vkbeautify.sql(text [,indent_pattern]);
|
||||
*
|
||||
* @text - String; text to beatufy;
|
||||
* @indent_pattern - Integer | String;
|
||||
* Integer: number of white spaces;
|
||||
* String: character string to visualize indentation ( can also be a set of white spaces )
|
||||
*/
|
||||
|
||||
let exampleContent = "here-be-xml-json-css-or-sql-content-that-is-about-to-get-formatted";
|
||||
|
||||
//xml
|
||||
function xmlWithDefault() {
|
||||
VKBeautify.xml(exampleContent);
|
||||
}
|
||||
|
||||
function xmlWithNumberOfSpaces() {
|
||||
VKBeautify.xml(exampleContent, 3);
|
||||
}
|
||||
|
||||
function xmlWithStringPattern() {
|
||||
VKBeautify.xml(exampleContent, ' ');
|
||||
}
|
||||
|
||||
//json
|
||||
function jsonWithDefault() {
|
||||
VKBeautify.json(exampleContent);
|
||||
}
|
||||
|
||||
function jsonWithNumberOfSpaces() {
|
||||
VKBeautify.json(exampleContent, 3);
|
||||
}
|
||||
|
||||
function jsonWithStringPattern() {
|
||||
VKBeautify.json(exampleContent, ' ');
|
||||
}
|
||||
|
||||
//css
|
||||
function cssWithDefault() {
|
||||
VKBeautify.css(exampleContent);
|
||||
}
|
||||
|
||||
function cssWithNumberOfSpaces() {
|
||||
VKBeautify.css(exampleContent, 3);
|
||||
}
|
||||
|
||||
function cssWithStringPattern() {
|
||||
VKBeautify.css(exampleContent, ' ');
|
||||
}
|
||||
|
||||
//sql
|
||||
function sqlWithDefault() {
|
||||
VKBeautify.sql(exampleContent);
|
||||
}
|
||||
|
||||
function sqlWithNumberOfSpaces() {
|
||||
VKBeautify.sql(exampleContent, 3);
|
||||
}
|
||||
|
||||
function sqlWithStringPattern() {
|
||||
VKBeautify.sql(exampleContent, ' ');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Minifying
|
||||
*
|
||||
* vkbeautify.xmlmin(text [,preserve_comments]);
|
||||
* vkbeautify.jsonmin(text);
|
||||
* vkbeautify.cssmin(text [,preserve_comments]);
|
||||
* vkbeautify.sqlmin(text);
|
||||
*
|
||||
* @text - String; text to minify;
|
||||
* @preserve_comments - Bool; [optional];
|
||||
* Set this flag to true to prevent removing comments from @text ( minxml and mincss functions only. )
|
||||
*/
|
||||
|
||||
//xml
|
||||
function xmlminWithDefault() {
|
||||
VKBeautify.xmlmin(exampleContent);
|
||||
}
|
||||
|
||||
function xmlminWitPreserveComments() {
|
||||
VKBeautify.xmlmin(exampleContent, true);
|
||||
}
|
||||
|
||||
function xmlminAndRemoveComments() {
|
||||
VKBeautify.xmlmin(exampleContent, false);
|
||||
}
|
||||
|
||||
//json
|
||||
function jsonmin() {
|
||||
VKBeautify.jsonmin(exampleContent);
|
||||
}
|
||||
|
||||
//css
|
||||
function cssminWithDefault() {
|
||||
VKBeautify.cssmin(exampleContent);
|
||||
}
|
||||
|
||||
function cssminWitPreserveComments() {
|
||||
VKBeautify.cssmin(exampleContent, true);
|
||||
}
|
||||
|
||||
function cssminAndRemoveComments() {
|
||||
VKBeautify.cssmin(exampleContent, false);
|
||||
}
|
||||
|
||||
//sql
|
||||
function sqlmin() {
|
||||
VKBeautify.sqlmin(exampleContent);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
|
||||
Vendored
+2
-2
@@ -38,8 +38,8 @@ declare namespace WebTorrent {
|
||||
on(event: 'torrent', callback: (torrent: Torrent) => void): this;
|
||||
on(event: 'error', callback: (err: Error | string) => void): this;
|
||||
|
||||
add(torrent: string | Buffer | ParseTorrent.ParsedTorrent, opts?: TorrentOptions, cb?: (torrent: Torrent) => any): Torrent;
|
||||
add(torrent: string | Buffer | ParseTorrent.ParsedTorrent, cb?: (torrent: Torrent) => any): Torrent;
|
||||
add(torrent: string | Buffer | ParseTorrent.Instance, opts?: TorrentOptions, cb?: (torrent: Torrent) => any): Torrent;
|
||||
add(torrent: string | Buffer | ParseTorrent.Instance, cb?: (torrent: Torrent) => any): Torrent;
|
||||
|
||||
seed(input: string | string[] | File | File[] | FileList | Buffer | Buffer[] | NodeJS.ReadableStream | NodeJS.ReadableStream[], opts?: TorrentOptions, cb?: (torrent: Torrent) => any): Torrent;
|
||||
seed(input: string | string[] | File | File[] | FileList | Buffer | Buffer[] | NodeJS.ReadableStream | NodeJS.ReadableStream[], cb?: (torrent: Torrent) => any): Torrent;
|
||||
|
||||
Vendored
+110
-60
@@ -1,13 +1,9 @@
|
||||
// Type definitions for z-schema v3.16.0
|
||||
// Project: https://github.com/zaggino/z-schema
|
||||
// Definitions by: Adam Meadows <https://github.com/job13er>
|
||||
// Definitions by: pgonzal <https://github.com/pgonzal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = ZSchema.Validator;
|
||||
export as namespace ZSchema;
|
||||
|
||||
declare namespace ZSchema {
|
||||
|
||||
declare namespace Validator {
|
||||
export interface Options {
|
||||
asyncTimeout?: number;
|
||||
forceAdditional?: boolean;
|
||||
@@ -31,66 +27,120 @@ declare namespace ZSchema {
|
||||
ignoreUnknownFormats?: boolean;
|
||||
}
|
||||
|
||||
export interface SchemaError {
|
||||
code: string;
|
||||
description: string;
|
||||
export interface SchemaError extends Error {
|
||||
/**
|
||||
* Implements the Error.name contract. The value is always "z-schema validation error".
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* An identifier indicating the type of error.
|
||||
* Example: "JSON_OBJECT_VALIDATION_FAILED"
|
||||
*/
|
||||
message: string;
|
||||
params: string[];
|
||||
|
||||
/**
|
||||
* Returns details for each error that occurred during validation.
|
||||
* See Options.breakOnFirstError.
|
||||
*/
|
||||
details: SchemaErrorDetail[];
|
||||
}
|
||||
|
||||
export interface SchemaErrorDetail {
|
||||
/**
|
||||
* Example: "Expected type string but found type array"
|
||||
*/
|
||||
message: string;
|
||||
/**
|
||||
* An error identifier that can be used to format a custom error message.
|
||||
* Example: "INVALID_TYPE"
|
||||
*/
|
||||
code: string;
|
||||
/**
|
||||
* Format parameters that can be used to format a custom error message.
|
||||
* Example: ["string","array"]
|
||||
*/
|
||||
params: Array<string>;
|
||||
/**
|
||||
* A JSON path indicating the location of the error.
|
||||
* Example: "#/projects/1"
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* The schema rule description, which is included for certain errors where
|
||||
* this information is useful (e.g. to describe a constraint).
|
||||
*/
|
||||
description: string;
|
||||
|
||||
/**
|
||||
* Returns details for sub-schemas that failed to match. For example, if the schema
|
||||
* uses the "oneOf" constraint to accept several alternative possibilities, each
|
||||
* alternative will have its own inner detail object explaining why it failed to match.
|
||||
*/
|
||||
inner: SchemaErrorDetail[];
|
||||
}
|
||||
}
|
||||
|
||||
export class Validator {
|
||||
|
||||
/**
|
||||
* Register a custom format.
|
||||
*
|
||||
* @param name - name of the custom format
|
||||
* @param validatorFunction - custom format validator function.
|
||||
* Returns `true` if `value` matches the custom format.
|
||||
*/
|
||||
public static registerFormat(formatName: string, validatorFunction: (value: any) => boolean): void;
|
||||
declare class Validator {
|
||||
/**
|
||||
* Register a custom format.
|
||||
*
|
||||
* @param name - name of the custom format
|
||||
* @param validatorFunction - custom format validator function.
|
||||
* Returns `true` if `value` matches the custom format.
|
||||
*/
|
||||
public static registerFormat(formatName: string, validatorFunction: (value: any) => boolean): void;
|
||||
|
||||
/**
|
||||
* Unregister a format.
|
||||
*
|
||||
* @param name - name of the custom format
|
||||
*/
|
||||
public static unregisterFormat(name: string): void;
|
||||
|
||||
/**
|
||||
* Get the list of all registered formats.
|
||||
*
|
||||
* Both the names of the burned-in formats and the custom format names are
|
||||
* returned by this function.
|
||||
*
|
||||
* @returns {string[]} the list of all registered format names.
|
||||
*/
|
||||
public static getRegisteredFormats(): string[];
|
||||
|
||||
public static getDefaultOptions(): Options;
|
||||
|
||||
constructor(options: Options);
|
||||
/**
|
||||
* Unregister a format.
|
||||
*
|
||||
* @param name - name of the custom format
|
||||
*/
|
||||
public static unregisterFormat(name: string): void;
|
||||
|
||||
/**
|
||||
* @param schema - JSON object representing schema
|
||||
* @returns {boolean} true if schema is valid.
|
||||
*/
|
||||
validateSchema(schema: any): boolean;
|
||||
/**
|
||||
* Get the list of all registered formats.
|
||||
*
|
||||
* Both the names of the burned-in formats and the custom format names are
|
||||
* returned by this function.
|
||||
*
|
||||
* @returns {string[]} the list of all registered format names.
|
||||
*/
|
||||
public static getRegisteredFormats(): string[];
|
||||
|
||||
/**
|
||||
* @param json - either a JSON string or a parsed JSON object
|
||||
* @param schema - the JSON object representing the schema
|
||||
* @returns true if json matches schema
|
||||
*/
|
||||
validate(json: any, schema: any): boolean;
|
||||
public static getDefaultOptions(): Validator.Options;
|
||||
|
||||
/**
|
||||
* @param json - either a JSON string or a parsed JSON object
|
||||
* @param schema - the JSON object representing the schema
|
||||
*/
|
||||
validate(json: any, schema: any, callback: (err: any, valid: boolean) => void): void;
|
||||
constructor(options: Validator.Options);
|
||||
|
||||
getLastError(): SchemaError;
|
||||
getLastErrors(): SchemaError[];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param schema - JSON object representing schema
|
||||
* @returns {boolean} true if schema is valid.
|
||||
*/
|
||||
validateSchema(schema: any): boolean;
|
||||
|
||||
/**
|
||||
* @param json - either a JSON string or a parsed JSON object
|
||||
* @param schema - the JSON object representing the schema
|
||||
* @returns true if json matches schema
|
||||
*/
|
||||
validate(json: any, schema: any): boolean;
|
||||
|
||||
/**
|
||||
* @param json - either a JSON string or a parsed JSON object
|
||||
* @param schema - the JSON object representing the schema
|
||||
*/
|
||||
validate(json: any, schema: any, callback: (err: any, valid: boolean) => void): void;
|
||||
|
||||
/**
|
||||
* Returns an Error object for the most recent failed validation, or null if the validation was successful.
|
||||
*/
|
||||
getLastError(): Validator.SchemaError;
|
||||
|
||||
/**
|
||||
* Returns the error details for the most recent validation, or undefined if the validation was successful.
|
||||
* This is the same list as the SchemaError.details property.
|
||||
*/
|
||||
getLastErrors(): Validator.SchemaErrorDetail[];
|
||||
}
|
||||
|
||||
export = Validator;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
|
||||
import Validator = require('z-schema');
|
||||
|
||||
import ZSchema = require('z-schema');
|
||||
|
||||
var options = {
|
||||
var options: Validator.Options = {
|
||||
noTypeless: true,
|
||||
forceItems: true,
|
||||
};
|
||||
|
||||
var validator = new ZSchema(options);
|
||||
var validator: Validator = new Validator(options);
|
||||
var json: any = {
|
||||
foo: 'bar',
|
||||
};
|
||||
@@ -31,5 +30,5 @@ validator.validate(json, schema, function (err: any, valid: boolean) {
|
||||
}
|
||||
});
|
||||
|
||||
var error = validator.getLastError();
|
||||
var errors = validator.getLastErrors();
|
||||
var error: Validator.SchemaError = validator.getLastError();
|
||||
var errors: Validator.SchemaErrorDetail[] = validator.getLastErrors();
|
||||
|
||||
Reference in New Issue
Block a user