Apply new lint rules to even more files (#15445)

This commit is contained in:
Andy 2017-03-28 10:56:00 -07:00 committed by GitHub
parent 668a4e35eb
commit e5ed4fc916
73 changed files with 594 additions and 697 deletions

View File

@ -11,7 +11,7 @@ import { Url } from "url";
declare function parseurl(req: IncomingMessage): Url | undefined;
declare namespace parseurl {
export function original(req: IncomingMessage): Url | undefined;
function original(req: IncomingMessage): Url | undefined;
}
export = parseurl;

View File

@ -14,20 +14,18 @@ declare const MaskedInput: MaskedInput;
type MaskedInput = ComponentClass<MaskedInput.MaskedInputProps>;
declare namespace MaskedInput {
export interface FormatCharacter {
interface FormatCharacter {
validate(char: string): string;
transform?(char: string): string;
}
export interface CharsFormatters {
interface CharsFormatters {
[char: string]: FormatCharacter;
}
export interface MaskedInputProps extends HTMLAttributes<any> {
interface MaskedInputProps extends HTMLAttributes<any> {
mask: string;
formatCharacter?: CharsFormatters;
placeholderChar?: string;
}
}

View File

@ -11,7 +11,7 @@ export as namespace ReactModal;
export = ReactModal;
declare namespace ReactModal {
export interface Styles {
interface Styles {
content?: {
[key: string]: any;
};
@ -20,7 +20,7 @@ declare namespace ReactModal {
};
}
export interface Props {
interface Props {
/* Boolean describing if the modal should be shown or not. Defaults to false. */
isOpen: boolean;
/* Object indicating styles to be used for the modal, divided into overlay and content styles. */

View File

@ -3,9 +3,9 @@ import * as ReactModal from 'react-modal';
class ExampleOfUsingReactModal extends React.Component<{}, {}> {
render() {
var onAfterOpenFn = () => { };
var onRequestCloseFn = () => { };
var customStyle = {
const onAfterOpenFn = () => { };
const onRequestCloseFn = () => { };
const customStyle = {
overlay: {
position: 'fixed',
top: 0,
@ -27,7 +27,6 @@ class ExampleOfUsingReactModal extends React.Component<{}, {}> {
borderRadius: '4px',
outline: 'none',
padding: '20px'
}
};
return (

View File

@ -15,26 +15,24 @@ export = Notifications;
declare class Notifications extends Component<Notifications.NotificationsProps, any> {}
declare namespace Notifications {
type NotificationsState = Notification[];
export type NotificationsState = Notification[];
type NotificationLevel = "error" | "warning" | "info" | "success";
export type NotificationLevel = "error" | "warning" | "info" | "success";
type NotificationsReducer<A extends Action> = (state: NotificationsState, action: A) => NotificationsState;
export type NotificationsReducer<A extends Action> = (state: NotificationsState, action: A) => NotificationsState;
type NotificationShow = (opts?: Notification) => Action;
export type NotificationShow = (opts?: Notification) => Action;
export interface NotificationsProps extends Attributes {
interface NotificationsProps extends Attributes {
notifications?: Notification[];
}
export const reducer: NotificationsReducer<any>;
const reducer: NotificationsReducer<any>;
export const show: (opts?: Notification, level?: NotificationLevel) => Action;
export const error: NotificationShow;
export const hide: (opts?: Notification | string | number) => Action;
export const info: NotificationShow;
export const success: NotificationShow;
export const warning: NotificationShow;
function show(opts?: Notification, level?: NotificationLevel): Action;
const error: NotificationShow;
function hide(opts?: Notification | string | number): Action;
const info: NotificationShow;
const success: NotificationShow;
const warning: NotificationShow;
}

View File

@ -5,7 +5,6 @@ import * as Notifications from "react-notification-system-redux";
import { reducer, show, hide, info, error, warning, success, NotificationLevel } from "react-notification-system-redux";
class Test extends React.Component<any, any> {
private test() {
const notification: Notification = {
message : "Test"
@ -27,7 +26,6 @@ class Test extends React.Component<any, any> {
const notifications: Notification[] = [];
return (<Notifications notifications={ notifications } />);
}
}
const store: Store<any> = createStore(reducer);

View File

@ -1,6 +1,10 @@
// Type definitions for react-router-redux 4.0
// Project: https://github.com/rackt/react-router-redux
// Definitions by: Isman Usoh <http://github.com/isman-usoh>, Noah Shipley <https://github.com/noah79>, Dimitri Rosenberg <https://github.com/rosendi>, Karol Janyst <https://github.com/LKay>, Dovydas Navickas <https://github.com/DovydasNavickas>
// Definitions by: Isman Usoh <http://github.com/isman-usoh>
// Noah Shipley <https://github.com/noah79>
// Dimitri Rosenberg <https://github.com/rosendi>
// Karol Janyst <https://github.com/LKay>
// Dovydas Navickas <https://github.com/DovydasNavickas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1

View File

@ -6,22 +6,17 @@
import * as React from "react";
declare module "react-sticky" {
export var StickyContainer: React.ComponentClass<React.HTMLAttributes<HTMLDivElement>>;
export interface StickyProps {
isActive?: boolean;
className?: string;
style?: any;
stickyClassName?: string;
stickyStyle?: any;
topOffset?: number;
bottomOffset?: number;
onStickyStateChange?: (isSticky: boolean) => void;
}
export var Sticky: React.ComponentClass<StickyProps>;
export const StickyContainer: React.ComponentClass<React.HTMLAttributes<HTMLDivElement>>;
export interface StickyProps {
isActive?: boolean;
className?: string;
style?: any;
stickyClassName?: string;
stickyStyle?: any;
topOffset?: number;
bottomOffset?: number;
onStickyStateChange?: (isSticky: boolean) => void;
}
export const Sticky: React.ComponentClass<StickyProps>;

View File

@ -5,194 +5,186 @@
// TypeScript Version: 2.2
import * as React from 'react';
declare module 'react-svg-pan-zoom' {
// String constants:
export const MODE_IDLE = 'idle';
export const MODE_PANNING = 'panning';
export const MODE_ZOOMING = 'zooming';
// String constants:
const MODE_IDLE = 'idle';
const MODE_PANNING = 'panning';
const MODE_ZOOMING = 'zooming';
export const TOOL_AUTO = 'auto';
export const TOOL_NONE = 'none';
export const TOOL_PAN = 'pan';
export const TOOL_ZOOM_IN = 'zoom-in';
export const TOOL_ZOOM_OUT = 'zoom-out';
export const TOOL_AUTO = 'auto';
export const TOOL_NONE = 'none';
export const TOOL_PAN = 'pan';
export const TOOL_ZOOM_IN = 'zoom-in';
export const TOOL_ZOOM_OUT = 'zoom-out';
export const POSITION_NONE = 'none';
export const POSITION_TOP = 'top';
export const POSITION_RIGHT = 'right';
export const POSITION_BOTTOM = 'bottom';
export const POSITION_LEFT = 'left';
export const POSITION_NONE = 'none';
export const POSITION_TOP = 'top';
export const POSITION_RIGHT = 'right';
export const POSITION_BOTTOM = 'bottom';
export const POSITION_LEFT = 'left';
export type Mode = typeof MODE_IDLE | typeof MODE_PANNING | typeof MODE_ZOOMING;
export type Mode = typeof MODE_IDLE | typeof MODE_PANNING | typeof MODE_ZOOMING;
export interface Value {
version: 2,
mode: Mode,
focus: boolean,
a: number,
b: number,
c: number,
d: number,
e: number,
f: number,
viewerWidth: number,
viewerHeight: number,
SVGWidth: number,
SVGHeight: number,
startX?: number | null,
startY?: number | null,
endX?: number | null,
endY?: number | null,
}
export type Tool = typeof TOOL_AUTO | typeof TOOL_NONE | typeof TOOL_PAN |
typeof TOOL_ZOOM_IN | typeof TOOL_ZOOM_OUT
export type ToolbarPosition = typeof POSITION_NONE | typeof POSITION_TOP | typeof POSITION_RIGHT |
typeof POSITION_BOTTOM | typeof POSITION_LEFT
export interface OptionalProps {
//background of the viewer
background: React.CSSProperties,
//background of the svg
SVGBackground: string,
//value of the viewer (current point of view)
value: Value | null,
//CSS style of the Viewer
style: object,
//className of the Viewer
className: string,
//detect zoom operation performed trough pinch gesture or mouse scroll
detectWheel: boolean,
//perform PAN if the mouse is on viewer border
detectAutoPan: boolean,
//toolbar position
toolbarPosition: ToolbarPosition,
//handler something changed
onChangeValue: (value: Value) => void,
//handler tool changed
onChangeTool: (tool: Tool) => void,
// Note: The `T` type parameter is the type of the `target` of the event:
//handler click
onClick: <T>(event: ViewerMouseEvent<T>) => void,
//handler double click
onDoubleClick: <T>(event: ViewerMouseEvent<T>) => void,
//handler mouseup
onMouseUp: <T>(event: ViewerMouseEvent<T>) => void,
//handler mousemove
onMouseMove: <T>(event: ViewerMouseEvent<T>) => void,
//handler mousedown
onMouseDown: <T>(event: ViewerMouseEvent<T>) => void,
//if disabled the user can move the image outside the viewer
preventPanOutside: boolean,
//how much scale in or out
scaleFactor: number,
//current active tool (TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT)
tool: Tool,
//modifier keys //https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState
modifierKeys: string[],
//override default toolbar component
// TODO: specify function type more clearly
customToolbar: React.Component<any, any> | React.StatelessComponent<any>,
// How about touch events? They are in README but not in `propTypes`.
}
export interface RequiredProps {
//width of the viewer displayed on screen
width: number,
//height of the viewer displayed on screen
height: number,
//accept only one node SVG
// TODO: Figure out how to constrain `children` or maybe just leave it commented out
// because `children` is already implicit props
// children: () => any
}
export type Props = RequiredProps & Partial<OptionalProps>
class ReactSVGPanZoom extends React.Component<Props, {}> {
pan(SVGDeltaX: number, SVGDeltaY: number): void
zoom(SVGPointX: number, SVGPointY: number, scaleFactor: number): void
fitSelection(selectionSVGPointX: number, selectionSVGPointY: number, selectionWidth: number, selectionHeight: number): void
fitToViewer(): void
setPointOnViewerCenter(SVGPointX: number, SVGPointY: number, zoomLevel: number): void
reset(): void
zoomOnViewerCenter(scaleFactor: number): void
getValue(): Value
setValue(value: Value): void
getTool(): Tool
setTool(tool: Tool): void
}
export interface Point {
x: number,
y: number,
}
export interface ViewerMouseEvent<T>{
originalEvent: React.MouseEvent<T>,
SVGViewer: SVGSVGElement,
point: Point,
x: number,
y: number,
scaleFactor: number,
translationX: number,
translationY: number,
preventDefault(): void
stopPropagation(): void
}
export interface ViewerTouchEvent<T> {
originalEvent: React.TouchEvent<T>,
SVGViewer: SVGSVGElement,
points: Point[],
changedPoints: Point[],
scaleFactor: number,
translationX: number,
translationY: number,
preventDefault(): void
stopPropagation(): void
}
// Utility functions exposed:
export function pan(value: Value, SVGDeltaX: number, SVGDeltaY: number, panLimit?: number): Value
export function zoom(value: Value, SVGPointX: number, SVGPointY: number, scaleFactor: number): Value
export function fitSelection(
value: Value, selectionSVGPointX: number, selectionSVGPointY: number, selectionWidth: number, selectionHeight: number): Value
export function fitToViewer(value: Value): Value
export function zoomOnViewerCenter(value: Value, scaleFactor: number): Value
export function setPointOnViewerCenter(value: Value, SVGPointX: number, SVGPointY: number, zoomLevel: number): Value
export function reset(value: Value): Value
export interface Value {
version: 2;
mode: Mode;
focus: boolean;
a: number;
b: number;
c: number;
d: number;
e: number;
f: number;
viewerWidth: number;
viewerHeight: number;
SVGWidth: number;
SVGHeight: number;
startX?: number | null;
startY?: number | null;
endX?: number | null;
endY?: number | null;
}
export type Tool = typeof TOOL_AUTO | typeof TOOL_NONE | typeof TOOL_PAN |
typeof TOOL_ZOOM_IN | typeof TOOL_ZOOM_OUT;
export type ToolbarPosition = typeof POSITION_NONE | typeof POSITION_TOP | typeof POSITION_RIGHT |
typeof POSITION_BOTTOM | typeof POSITION_LEFT;
export interface OptionalProps {
// background of the viewer
background: React.CSSProperties;
// background of the svg
SVGBackground: string;
// value of the viewer (current point of view)
value: Value | null;
// CSS style of the Viewer
style: object;
// className of the Viewer
className: string;
// detect zoom operation performed trough pinch gesture or mouse scroll
detectWheel: boolean;
// perform PAN if the mouse is on viewer border
detectAutoPan: boolean;
// toolbar position
toolbarPosition: ToolbarPosition;
// handler something changed
onChangeValue(value: Value): void;
// handler tool changed
onChangeTool(tool: Tool): void;
// Note: The `T` type parameter is the type of the `target` of the event:
// handler click
onClick<T>(event: ViewerMouseEvent<T>): void;
// handler double click
onDoubleClick<T>(event: ViewerMouseEvent<T>): void;
// handler mouseup
onMouseUp<T>(event: ViewerMouseEvent<T>): void;
// handler mousemove
onMouseMove<T>(event: ViewerMouseEvent<T>): void;
// handler mousedown
onMouseDown<T>(event: ViewerMouseEvent<T>): void;
// if disabled the user can move the image outside the viewer
preventPanOutside: boolean;
// how much scale in or out
scaleFactor: number;
// current active tool (TOOL_NONE, TOOL_PAN, TOOL_ZOOM_IN, TOOL_ZOOM_OUT)
tool: Tool;
// modifier keys //https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState
modifierKeys: string[];
// override default toolbar component
// TODO: specify function type more clearly
customToolbar: React.Component<any, any> | React.StatelessComponent<any>;
// How about touch events? They are in README but not in `propTypes`.
}
export interface RequiredProps {
// width of the viewer displayed on screen
width: number;
// height of the viewer displayed on screen
height: number;
// accept only one node SVG
// TODO: Figure out how to constrain `children` or maybe just leave it commented out
// because `children` is already implicit props
// children: () => any;
}
export type Props = RequiredProps & Partial<OptionalProps>;
export class ReactSVGPanZoom extends React.Component<Props, {}> {
pan(SVGDeltaX: number, SVGDeltaY: number): void;
zoom(SVGPointX: number, SVGPointY: number, scaleFactor: number): void;
fitSelection(selectionSVGPointX: number, selectionSVGPointY: number, selectionWidth: number, selectionHeight: number): void;
fitToViewer(): void;
setPointOnViewerCenter(SVGPointX: number, SVGPointY: number, zoomLevel: number): void;
reset(): void;
zoomOnViewerCenter(scaleFactor: number): void;
getValue(): Value;
setValue(value: Value): void;
getTool(): Tool;
setTool(tool: Tool): void;
}
export interface Point {
x: number;
y: number;
}
export interface ViewerMouseEvent<T>{
originalEvent: React.MouseEvent<T>;
SVGViewer: SVGSVGElement;
point: Point;
x: number;
y: number;
scaleFactor: number;
translationX: number;
translationY: number;
preventDefault(): void;
stopPropagation(): void;
}
export interface ViewerTouchEvent<T> {
originalEvent: React.TouchEvent<T>;
SVGViewer: SVGSVGElement;
points: Point[];
changedPoints: Point[];
scaleFactor: number;
translationX: number;
translationY: number;
preventDefault(): void;
stopPropagation(): void;
}
// Utility functions exposed:
export function pan(value: Value, SVGDeltaX: number, SVGDeltaY: number, panLimit?: number): Value;
export function zoom(value: Value, SVGPointX: number, SVGPointY: number, scaleFactor: number): Value;
export function fitSelection(
value: Value, selectionSVGPointX: number, selectionSVGPointY: number, selectionWidth: number, selectionHeight: number): Value;
export function fitToViewer(value: Value): Value;
export function zoomOnViewerCenter(value: Value, scaleFactor: number): Value;
export function setPointOnViewerCenter(value: Value, SVGPointX: number, SVGPointY: number, zoomLevel: number): Value;
export function reset(value: Value): Value;

View File

@ -7,9 +7,8 @@ import {
ViewerMouseEvent
} from 'react-svg-pan-zoom';
class Example1 extends React.Component<{}, {}> {
Viewer: ReactSVGPanZoom
Viewer: ReactSVGPanZoom;
constructor(props: Props) {
super(props);
}

View File

@ -13,13 +13,13 @@ import * as Tether from 'tether';
declare class TetherComponent extends React.Component<ReactTether.TetherComponentProps, null> { }
declare namespace ReactTether {
export interface TetherComponentProps extends React.Props<TetherComponent>, Tether.ITetherOptions {
interface TetherComponentProps extends React.Props<TetherComponent>, Tether.ITetherOptions {
renderElementTag?: string;
renderElementTo?: string | {appendChild: (element: HTMLElement) => void};
renderElementTo?: string | { appendChild(element: HTMLElement): void };
id?: string;
className?: string;
style?: React.CSSProperties;
onUpdate?: () => void;
onRepositioned?: () => void;
onUpdate?(): void;
onRepositioned?(): void;
}
}

View File

@ -13,4 +13,4 @@ const ReactTetherAllOptions: JSX.Element =
/>;
const ReactTetherRequiredOptions: JSX.Element =
<TetherComponent attachment="bottom middle" />;
<TetherComponent attachment="bottom middle" />;

View File

@ -9,13 +9,13 @@ declare namespace Realm {
* PropertyType
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.html#~PropertyType }
*/
export type PropertyType = string | 'bool' | 'int' | 'float' | 'double' | 'string' | 'data' | 'date' | 'list';
type PropertyType = string | 'bool' | 'int' | 'float' | 'double' | 'string' | 'data' | 'date' | 'list';
/**
* ObjectSchemaProperty
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.html#~ObjectSchemaProperty }
*/
export interface ObjectSchemaProperty {
interface ObjectSchemaProperty {
type: PropertyType;
objectType?: string;
default?: any;
@ -24,7 +24,7 @@ declare namespace Realm {
}
// properties types
export interface PropertiesTypes {
interface PropertiesTypes {
[keys: string]: PropertyType | ObjectSchemaProperty;
}
@ -32,7 +32,7 @@ declare namespace Realm {
* ObjectSchema
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.html#~ObjectSchema }
*/
export interface ObjectSchema {
interface ObjectSchema {
name: string;
primaryKey?: string;
properties: PropertiesTypes;
@ -42,7 +42,7 @@ declare namespace Realm {
* ObjectClass
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.html#~ObjectClass }
*/
export interface ObjectClass {
interface ObjectClass {
schema: ObjectSchema;
}
@ -50,7 +50,7 @@ declare namespace Realm {
* ObjectType
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.html#~ObjectType }
*/
export interface ObjectType {
interface ObjectType {
type: ObjectClass;
}
@ -63,7 +63,7 @@ declare namespace Realm {
* realm configuration
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.html#~Configuration }
*/
export interface Configuration {
interface Configuration {
encryptionKey?: any;
migration?: any;
path?: string;
@ -74,7 +74,7 @@ declare namespace Realm {
}
// object props type
export interface ObjectPropsType {
interface ObjectPropsType {
[keys: string]: any;
}
@ -82,18 +82,18 @@ declare namespace Realm {
* SortDescriptor
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Collection.html#~SortDescriptor }
*/
export type SortDescriptor = string | [string, boolean] | any[];
type SortDescriptor = string | [string, boolean] | any[];
/**
* Iterator
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Collection.html#~Iterator }
*/
export interface IteratorResult<T> {
interface IteratorResult<T> {
done: boolean;
value?: T;
}
export interface Iterator<T> {
interface Iterator<T> {
next(done: boolean, value?: any): IteratorResult<T>;
[Symbol.iterator](): any;
}
@ -102,7 +102,7 @@ declare namespace Realm {
* Collection
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Collection.html }
*/
export interface Collection<T> {
interface Collection<T> {
readonly length: number;
/**
@ -240,7 +240,7 @@ declare namespace Realm {
* Object
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Object.html }
*/
export interface Object {
interface Object {
/**
* @returns boolean
*/
@ -251,7 +251,7 @@ declare namespace Realm {
* List
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.List.html }
*/
export interface List<T> extends Collection<T> {
interface List<T> extends Collection<T> {
/**
* @returns T
*/
@ -287,13 +287,13 @@ declare namespace Realm {
* Results
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Results.html }
*/
export type Results<T> = Collection<T>;
type Results<T> = Collection<T>;
/**
* User
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Sync.User.html }
*/
export interface User {
interface User {
all: any;
current: User;
readonly identity: string;
@ -313,7 +313,7 @@ declare namespace Realm {
* Session
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Sync.Session.html }
*/
export interface Session {
interface Session {
readonly config: any;
readonly state: string;
readonly url: string;
@ -324,7 +324,7 @@ declare namespace Realm {
* AuthError
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Sync.AuthError.html }
*/
export interface AuthError {
interface AuthError {
readonly code: number;
readonly type: string;
}
@ -333,7 +333,7 @@ declare namespace Realm {
* ChangeEvent
* @see { @link https://realm.io/docs/javascript/latest/api/Realm.Sync.ChangeEvent.html }
*/
export interface ChangeEvent {
interface ChangeEvent {
readonly changes: any;
readonly oldRealm: Realm;
readonly path: string;

View File

@ -67,7 +67,6 @@ const currentVersion = Realm.schemaVersion(Realm.defaultPath);
Realm.Sync.User.register('http://localhost:9080', 'username@example.com', 'p@s$w0rd', (error, user) => { /* ... */ });
Realm.Sync.User.login('http://localhost.com:9080', 'username@example.com', 'p@s$w0rd', (error, user) => {
const todoSchema = {
name: 'Todo',
primaryKey: 'id',

View File

@ -5,9 +5,9 @@ import {
import reduceReducers from 'reduce-reducers';
interface TestStore {
a: number,
b: string
a: number;
b: string;
}
let firstReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a;
let secondReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a
let finalReducer: (state: TestStore, action: Action) => TestStore = reduceReducers(firstReducer, secondReducer);
const firstReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a;
const secondReducer: (state: TestStore, action: Action) => TestStore = (a, b) => a;
const finalReducer: (state: TestStore, action: Action) => TestStore = reduceReducers(firstReducer, secondReducer);

View File

@ -1,13 +1,12 @@
import Reflux = require("reflux");
var syncActions = Reflux.createActions([
const syncActions = Reflux.createActions([
"statusUpdate",
"statusEdited",
"statusAdded"
]);
var asyncActions = Reflux.createActions({
const asyncActions = Reflux.createActions({
fireBall: {asyncResult: true}
});
@ -16,10 +15,8 @@ asyncActions.fireBall.listen(function() {
setTimeout(() => this.completed(true), 1000);
});
// Creates a DataStore
var statusStore = Reflux.createStore({
const statusStore = Reflux.createStore({
// Initial setup
init() {
// Register statusUpdate action
@ -27,7 +24,7 @@ var statusStore = Reflux.createStore({
},
// Callback
onFireBall(flag: boolean) {
var status = flag ? 'ONLINE' : 'OFFLINE';
const status = flag ? 'ONLINE' : 'OFFLINE';
// Pass on to listeners
this.trigger(status);
@ -38,11 +35,11 @@ Reflux.createAction({
children: ["progressed", "completed", "failed"]
});
var action = Reflux.createAction();
const action = Reflux.createAction();
var actions = Reflux.createActions(["fireBall", "magicMissile"]);
const actions = Reflux.createActions(["fireBall", "magicMissile"]);
var Store = Reflux.createStore({
const Store = Reflux.createStore({
init() {
this.listenToMany(actions);
},
@ -54,6 +51,6 @@ var Store = Reflux.createStore({
}
});
var ReactComponent = {
const ReactComponent = {
mixins: [Reflux.ListenerMixin]
};
};

View File

@ -6,14 +6,18 @@
// This project is licensed under the MIT license.
// Copyrights are respective of each contributor listed at the beginning of each definition file.
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
export interface CombineValidatorsOptions {
serializeValues?: (values: any) => any;
serializeValues?(values: any): any;
}
export interface Config {

View File

@ -3,7 +3,7 @@ import r = require("revalidate");
const isValidEmail = r.createValidator(
message => value => {
if (value && !/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(value)) {
return message
return message;
}
},
'Invalid email address'
@ -12,7 +12,7 @@ const isValidEmail = r.createValidator(
const isGreaterThan = (n: any) => r.createValidator(
message => value => {
if (value && Number(value) <= n) {
return message
return message;
}
},
field => `${field} must be greater than ${n}`

View File

@ -13,12 +13,11 @@ export = RRule;
// For CommonJS it must be imported as `require("rrule").RRule`.
import RRuleAlias = RRule;
declare module "rrule" {
export type RRule = RRuleAlias;
export const RRule: typeof RRuleAlias;
type RRule = RRuleAlias;
const RRule: typeof RRuleAlias;
}
declare namespace RRule {
/**
* see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
@ -52,11 +51,9 @@ declare namespace RRule {
getJsWeekday(): number;
}
}
declare class RRule {
/**
* @param {Object?} options - see <http://labix.org/python-dateutil/#head-cf004ee9a75592797e076752b2a889c10f445418>
* The only required option is `freq`, one of RRule.YEARLY, RRule.MONTHLY, ...
@ -123,11 +120,9 @@ declare class RRule {
isFullyConvertibleToText(): boolean;
clone(): RRule;
}
declare namespace RRule {
const FREQUENCIES: "YEARLY" | "MONTHLY" | "WEEKLY" | "DAILY" | "HOURLY" | "MINUTELY" | "SECONDLY";
enum Frequency {

View File

@ -30,7 +30,6 @@ y.push(rule.toText());
// including the default and inferred ones.
y.push(RRule.optionsToString(rule.options));
// Cherry-pick only some options from an rrule:
y.push(RRule.optionsToString({
freq: rule.options.freq,
@ -42,7 +41,7 @@ rule = RRule.fromString("FREQ=WEEKLY;DTSTART=20120201T093000Z");
// This is equivalent
rule = new RRule(RRule.parseString("FREQ=WEEKLY;DTSTART=20120201T093000Z"));
var options = RRule.parseString('FREQ=DAILY;INTERVAL=6');
let options = RRule.parseString('FREQ=DAILY;INTERVAL=6');
options.dtstart = new Date(2000, 1, 1);
rule = new RRule(options);

View File

@ -10,7 +10,7 @@ declare namespace Rx {
hasObservers(): boolean;
}
export interface Subject<T> extends ISubject<T> {
interface Subject<T> extends ISubject<T> {
}
interface SubjectStatic {
@ -18,18 +18,18 @@ declare namespace Rx {
create<T>(observer?: Observer<T>, observable?: Observable<T>): ISubject<T>;
}
export var Subject: SubjectStatic;
const Subject: SubjectStatic;
export interface AsyncSubject<T> extends Subject<T> {
interface AsyncSubject<T> extends Subject<T> {
}
interface AsyncSubjectStatic {
new <T>(): AsyncSubject<T>;
}
export var AsyncSubject: AsyncSubjectStatic;
const AsyncSubject: AsyncSubjectStatic;
export interface BehaviorSubject<T> extends Subject<T> {
interface BehaviorSubject<T> extends Subject<T> {
getValue(): T;
}
@ -37,16 +37,16 @@ declare namespace Rx {
new <T>(initialValue: T): BehaviorSubject<T>;
}
export var BehaviorSubject: BehaviorSubjectStatic;
const BehaviorSubject: BehaviorSubjectStatic;
export interface ReplaySubject<T> extends Subject<T> {
interface ReplaySubject<T> extends Subject<T> {
}
interface ReplaySubjectStatic {
new <T>(bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject<T>;
}
export var ReplaySubject: ReplaySubjectStatic;
const ReplaySubject: ReplaySubjectStatic;
interface ConnectableObservable<T> extends Observable<T> {
connect(): IDisposable;
@ -57,9 +57,9 @@ declare namespace Rx {
new <T>(): ConnectableObservable<T>;
}
export var ConnectableObservable: ConnectableObservableStatic;
const ConnectableObservable: ConnectableObservableStatic;
export interface Observable<T> {
interface Observable<T> {
multicast(subject: Observable<T>): ConnectableObservable<T>;
multicast<TResult>(subjectSelector: () => ISubject<T>, selector: (source: ConnectableObservable<T>) => Observable<T>): Observable<T>;
publish(): ConnectableObservable<T>;

View File

@ -7,24 +7,24 @@ declare namespace Rx {
/**
* Promise A+
*/
export interface IPromise<T> {
interface IPromise<T> {
then<R>(onFulfilled: (value: T) => IPromise<R>, onRejected: (reason: any) => IPromise<R>): IPromise<R>;
then<R>(onFulfilled: (value: T) => IPromise<R>, onRejected?: (reason: any) => R): IPromise<R>;
then<R>(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise<R>): IPromise<R>;
then<R>(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise<R>;
}
export interface IDisposable {
interface IDisposable {
dispose(): void;
}
export interface IScheduler {
interface IScheduler {
catch(handler: (exception: any) => boolean): IScheduler;
catchException(handler: (exception: any) => boolean): IScheduler;
}
// Observer
export interface Observer<T> {
interface Observer<T> {
checked(): Observer<any>;
}
@ -37,7 +37,7 @@ declare namespace Rx {
notifyOn<T>(scheduler: IScheduler): Observer<T>;
}
export interface Observable<T> {
interface Observable<T> {
observeOn(scheduler: IScheduler): Observable<T>;
subscribeOn(scheduler: IScheduler): Observable<T>;

View File

@ -6,7 +6,7 @@
///<reference types="rx-lite" />
declare namespace Rx {
export interface Observable<T> {
interface Observable<T> {
finalValue(): Observable<T>;
aggregate(accumulator: (acc: T, value: T) => T): Observable<T>;
aggregate<TAcc>(seed: TAcc, accumulator: (acc: TAcc, value: T) => TAcc): Observable<TAcc>;

View File

@ -6,7 +6,7 @@
///<reference types="rx-lite"/>
declare namespace Rx {
export interface Observable<T> {
interface Observable<T> {
/**
* Pauses the underlying observable sequence based upon the observable sequence which yields true/false.
* @example
@ -37,11 +37,11 @@ declare namespace Rx {
controlled(enableQueue?: boolean): ControlledObservable<T>;
}
export interface ControlledObservable<T> extends Observable<T> {
interface ControlledObservable<T> extends Observable<T> {
request(numberOfItems?: number): IDisposable;
}
export interface PausableObservable<T> extends Observable<T> {
interface PausableObservable<T> extends Observable<T> {
pause(): void;
resume(): void;
}

View File

@ -2,18 +2,18 @@
// Tests by Igor Oleinikov <https://github.com/Igorbek>
function testPausable() {
var o: Rx.Observable<string> = {} as any;
const o: Rx.Observable<string> = {} as any;
var pauser = new Rx.Subject<boolean>();
const pauser = new Rx.Subject<boolean>();
var p = o.pausable(pauser);
let p = o.pausable(pauser);
p = o.pausableBuffered(pauser);
}
function testControlled() {
var o: Rx.Observable<string> = {} as any;
var c = o.controlled();
const o: Rx.Observable<string> = {} as any;
const c = o.controlled();
var d: Rx.IDisposable = c.request();
let d: Rx.IDisposable = c.request();
d = c.request(5);
}

View File

@ -6,7 +6,7 @@
/// <reference types="rx-lite-virtualtime" />
declare namespace Rx {
export interface TestScheduler extends VirtualTimeScheduler<number, number> {
interface TestScheduler extends VirtualTimeScheduler<number, number> {
createColdObservable<T>(...records: Recorded[]): Observable<T>;
createHotObservable<T>(...records: Recorded[]): Observable<T>;
createObserver<T>(): MockObserver<T>;
@ -16,11 +16,11 @@ declare namespace Rx {
startWithCreate<T>(create: () => Observable<T>): MockObserver<T>;
}
export var TestScheduler: {
const TestScheduler: {
new (): TestScheduler;
};
export class Recorded {
class Recorded {
constructor(time: number, value: any, equalityComparer?: (x: any, y: any) => boolean);
equals(other: Recorded): boolean;
toString(): string;
@ -28,7 +28,7 @@ declare namespace Rx {
value: any;
}
export var ReactiveTest: {
const ReactiveTest: {
created: number;
subscribed: number;
disposed: number;
@ -40,12 +40,12 @@ declare namespace Rx {
subscribe(subscribeAt: number, unsubscribeAt?: number): Subscription;
};
export class Subscription {
class Subscription {
constructor(subscribeAt: number, unsubscribeAt?: number);
equals(other: Subscription): boolean;
}
export interface MockObserver<T> extends Observer<T> {
interface MockObserver<T> extends Observer<T> {
messages: Recorded[];
}
@ -53,7 +53,7 @@ declare namespace Rx {
new <T>(scheduler: IScheduler): MockObserver<T>;
}
export var MockObserver: MockObserverStatic;
const MockObserver: MockObserverStatic;
}
declare module "rx-lite-testing" {

View File

@ -6,7 +6,7 @@
///<reference types="rx-lite" />
declare namespace Rx {
export interface Observable<T> {
interface Observable<T> {
delaySubscription(dueTime: number, scheduler?: IScheduler): Observable<T>;
delayWithSelector(delayDurationSelector: (item: T) => number): Observable<T>;
delayWithSelector(subscriptionDelay: number, delayDurationSelector: (item: T) => number): Observable<T>;

View File

@ -6,7 +6,7 @@
///<reference types="rx-lite" />
declare namespace Rx {
export interface VirtualTimeScheduler<TAbsolute, TRelative> extends Scheduler {
interface VirtualTimeScheduler<TAbsolute, TRelative> extends Scheduler {
// protected constructor(initialClock: TAbsolute, comparer: (first: TAbsolute, second: TAbsolute) => number);
advanceBy(time: TRelative): void;
@ -28,10 +28,10 @@ declare namespace Rx {
/* protected */ getNext(): internals.ScheduledItem<TAbsolute>;
}
export interface HistoricalScheduler extends VirtualTimeScheduler<number, number> {
interface HistoricalScheduler extends VirtualTimeScheduler<number, number> {
}
export var HistoricalScheduler: {
const HistoricalScheduler: {
new (initialClock: number, comparer: (first: number, second: number) => number): HistoricalScheduler;
};
}

View File

@ -7,12 +7,12 @@
/// <reference types="rx-core-binding" />
declare namespace Rx {
export namespace internals {
namespace internals {
function isEqual(left: any, right: any): boolean;
function addRef<T>(xs: Observable<T>, r: { getDisposable(): IDisposable; }): Observable<T>;
// Priority Queue for Scheduling
export class PriorityQueue<TTime> {
class PriorityQueue<TTime> {
constructor(capacity: number);
length: number;
@ -29,7 +29,7 @@ declare namespace Rx {
static count: number;
}
export class ScheduledItem<TTime> {
class ScheduledItem<TTime> {
constructor(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: (x: TTime, y: TTime) => number);
scheduler: IScheduler;
@ -46,11 +46,11 @@ declare namespace Rx {
}
}
export namespace config {
export var Promise: { new <T>(resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise<T>; };
namespace config {
let Promise: { new <T>(resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise<T>; };
}
export namespace helpers {
namespace helpers {
function noop(): void;
function notDefined(value: any): boolean;
function identity<T>(value: T): T;
@ -65,7 +65,7 @@ declare namespace Rx {
function isFunction(value: any): boolean;
}
export class CompositeDisposable implements IDisposable {
class CompositeDisposable implements IDisposable {
constructor(...disposables: IDisposable[]);
constructor(disposables: IDisposable[]);
@ -78,7 +78,7 @@ declare namespace Rx {
toArray(): IDisposable[];
}
export class Disposable implements IDisposable {
class Disposable implements IDisposable {
constructor(action: () => void);
static create(action: () => void): IDisposable;
@ -88,7 +88,7 @@ declare namespace Rx {
}
// Single assignment
export class SingleAssignmentDisposable implements IDisposable {
class SingleAssignmentDisposable implements IDisposable {
constructor();
isDisposed: boolean;
@ -100,11 +100,11 @@ declare namespace Rx {
}
// SerialDisposable it's an alias of SingleAssignmentDisposable
export class SerialDisposable extends SingleAssignmentDisposable {
class SerialDisposable extends SingleAssignmentDisposable {
constructor();
}
export class RefCountDisposable implements IDisposable {
class RefCountDisposable implements IDisposable {
constructor(disposable: IDisposable);
dispose(): void;
@ -113,7 +113,7 @@ declare namespace Rx {
getDisposable(): IDisposable;
}
export interface IScheduler {
interface IScheduler {
now(): number;
isScheduler(value: any): boolean;
@ -135,10 +135,10 @@ declare namespace Rx {
schedulePeriodicWithState<TState>(state: TState, period: number, action: (state: TState) => TState): IDisposable;
}
export interface Scheduler extends IScheduler {
interface Scheduler extends IScheduler {
}
export interface SchedulerStatic {
interface SchedulerStatic {
new (
now: () => number,
schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable,
@ -153,7 +153,7 @@ declare namespace Rx {
timeout: IScheduler;
}
export var Scheduler: SchedulerStatic;
const Scheduler: SchedulerStatic;
// Current Thread IScheduler
interface ICurrentThreadScheduler extends IScheduler {
@ -161,7 +161,7 @@ declare namespace Rx {
}
// Notifications
export class Notification<T> {
class Notification<T> {
accept(observer: IObserver<T>): void;
accept<TResult>(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult;
toObservable(scheduler?: IScheduler): Observable<T>;
@ -177,13 +177,13 @@ declare namespace Rx {
}
// Observer
export interface IObserver<T> {
interface IObserver<T> {
onNext(value: T): void;
onError(exception: any): void;
onCompleted(): void;
}
export interface Observer<T> extends IObserver<T> {
interface Observer<T> extends IObserver<T> {
toNotifier(): (notification: Notification<T>) => void;
asObserver(): Observer<T>;
}
@ -193,9 +193,9 @@ declare namespace Rx {
fromNotifier<T>(handler: (notification: Notification<T>, thisArg?: any) => void): Observer<T>;
}
export var Observer: ObserverStatic;
const Observer: ObserverStatic;
export interface IObservable<T> {
interface IObservable<T> {
subscribe(observer: Observer<T>): IDisposable;
subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable;
@ -204,7 +204,7 @@ declare namespace Rx {
subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable;
}
export interface Observable<T> extends IObservable<T> {
interface Observable<T> extends IObservable<T> {
forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe
toArray(): Observable<T[]>;
@ -591,17 +591,17 @@ declare namespace Rx {
prototype: any;
}
export var Observable: ObservableStatic;
const Observable: ObservableStatic;
}
// Async
declare namespace Rx {
export namespace config {
namespace config {
/**
* Configuration option to determine whether to use native events only
*/
export var useNativeEvents: boolean;
const useNativeEvents: boolean;
}
interface ObservableStatic {
@ -655,12 +655,12 @@ declare namespace Rx {
}
interface NodeEventTarget {
addListener: (name: string, cb: (e: any) => any) => void;
addListener(name: string, cb: (e: any) => any): void;
}
interface NativeEventTarget {
on: (name: string, cb: (e: any) => any) => void;
off: (name: string, cb: (e: any) => any) => void;
on(name: string, cb: (e: any) => any): void;
off(name: string, cb: (e: any) => any): void;
}
interface DOMEventTarget {
@ -669,29 +669,28 @@ declare namespace Rx {
}
}
// time
declare namespace Rx {
export interface TimeInterval<T> {
interface TimeInterval<T> {
value: T;
interval: number;
}
export interface Timestamp<T> {
interface Timestamp<T> {
value: T;
timestamp: number;
}
export interface Observable<T> {
interface Observable<T> {
delay(dueTime: Date, scheduler?: IScheduler): Observable<T>;
delay(dueTime: number, scheduler?: IScheduler): Observable<T>;
debounce(dueTime: number, scheduler?: IScheduler): Observable<T>;
throttleWithTimeout(dueTime: number, scheduler?: IScheduler): Observable<T>;
/**
* @deprecated use #debounce or #throttleWithTimeout instead.
*/
* @deprecated use #debounce or #throttleWithTimeout instead.
*/
throttle(dueTime: number, scheduler?: IScheduler): Observable<T>;
timeInterval(scheduler?: IScheduler): Observable<TimeInterval<T>>;

View File

@ -1,53 +1,51 @@
import * as Rx from 'rx-lite';
namespace Tests.Async {
var obsNum: Rx.Observable<number>;
var obsStr: Rx.Observable<string>;
var sch: Rx.IScheduler;
let obsNum: Rx.Observable<number>;
let obsStr: Rx.Observable<string>;
function fromCallback() {
// 0 arguments
var func0: (cb: (result: number) => void) => void = () => { };
const func0: (cb: (result: number) => void) => void = () => { };
obsNum = Rx.Observable.fromCallback(func0)();
obsNum = Rx.Observable.fromCallback(func0, obsStr)();
obsNum = Rx.Observable.fromCallback(func0, obsStr, (results: number[]) => results[0])();
// 1 argument
var func1: (a: string, cb: (result: number) => void) => number = () => 0;
const func1: (a: string, cb: (result: number) => void) => number = () => 0;
obsNum = Rx.Observable.fromCallback(func1)("");
obsNum = Rx.Observable.fromCallback(func1, {})("");
obsNum = Rx.Observable.fromCallback(func1, {}, (results: number[]) => results[0])("");
// 2 arguments
var func2: (a: number, b: string, cb: (result: string) => number) => Date = () => new Date();
const func2: (a: number, b: string, cb: (result: string) => number) => Date = () => new Date();
obsStr = Rx.Observable.fromCallback(func2)(1, "");
obsStr = Rx.Observable.fromCallback(func2, {})(1, "");
obsStr = Rx.Observable.fromCallback(func2, {}, (results: string[]) => results[0])(1, "");
// 3 arguments
var func3: (a: number, b: string, c: boolean, cb: (result: string) => number) => Date = () => new Date();
const func3: (a: number, b: string, c: boolean, cb: (result: string) => number) => Date = () => new Date();
obsStr = Rx.Observable.fromCallback(func3)(1, "", true);
obsStr = Rx.Observable.fromCallback(func3, {})(1, "", true);
obsStr = Rx.Observable.fromCallback(func3, {}, (results: string[]) => results[0])(1, "", true);
// multiple results
var func0m: (cb: (result1: number, result2: number, result3: number) => void) => void = () => { };
const func0m: (cb: (result1: number, result2: number, result3: number) => void) => void = () => { };
obsNum = Rx.Observable.fromCallback(func0m, obsStr, (results: number[]) => results[0])();
var func1m: (a: string, cb: (result1: number, result2: number, result3: number) => void) => void = () => { };
const func1m: (a: string, cb: (result1: number, result2: number, result3: number) => void) => void = () => { };
obsNum = Rx.Observable.fromCallback(func1m, obsStr, (results: number[]) => results[0])("");
var func2m: (a: string, b: number, cb: (result1: string, result2: string, result3: string) => void) => void = () => { };
const func2m: (a: string, b: number, cb: (result1: string, result2: string, result3: string) => void) => void = () => { };
obsStr = Rx.Observable.fromCallback(func2m, obsStr, (results: string[]) => results[0])("", 10);
}
function toPromise() {
var promiseImpl: {
const promiseImpl: {
new <T>(resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Rx.IPromise<T>;
} = undefined as any;
Rx.config.Promise = promiseImpl;
var p: Rx.IPromise<number> = obsNum.toPromise(promiseImpl);
let p: Rx.IPromise<number> = obsNum.toPromise(promiseImpl);
p = obsNum.toPromise();
@ -56,14 +54,13 @@ namespace Tests.Async {
p = p.then(undefined, reason => 10);
// p = p.then(undefined, reason => p);
var ps: Rx.IPromise<string> = p.then(undefined, reason => "error");
let ps: Rx.IPromise<string> = p.then(undefined, reason => "error");
ps = p.then(x => "");
ps = p.then(x => ps);
}
}
function test_scan() {
/* Without a seed */
const source1: Rx.Observable<number> = Rx.Observable.range(1, 3)
.scan((acc, x, i, source) => acc + x);
@ -71,16 +68,15 @@ function test_scan() {
/* With a seed */
const source2: Rx.Observable<string> = Rx.Observable.range(1, 3)
.scan((acc, x, i, source) => acc + x, '...');
}
function test_concatAll() {
/* concatAll Example */
var source = Rx.Observable.range(0, 3)
const source = Rx.Observable.range(0, 3)
.map(x => Rx.Observable.range(x, 3))
.concatAll();
var subscription = source.subscribe(
const subscription = source.subscribe(
x => {
console.log('Next: %s', x);
},
@ -94,11 +90,11 @@ function test_concatAll() {
function test_mergeAll() {
/* mergeAll example */
var source = Rx.Observable.range(0, 3)
const source = Rx.Observable.range(0, 3)
.map(x => Rx.Observable.range(x, 3))
.mergeAll();
var subscription = source.subscribe(
const subscription = source.subscribe(
x => {
console.log('Next: %s', x);
},
@ -108,25 +104,24 @@ function test_mergeAll() {
() => {
console.log('Completed');
});
}
// from https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/publish.md
function test_publish() {
var interval = Rx.Observable.interval(1000);
const interval = Rx.Observable.interval(1000);
var source = interval
const source = interval
.take(2)
.doAction(x => {
console.log('Side effect');
});
var published = source.publish();
const published = source.publish();
published.subscribe(createObserver('SourceA'));
published.subscribe(createObserver('SourceB'));
var connection = published.connect();
const connection = published.connect();
function createObserver(tag: string) {
return Rx.Observer.create(

View File

@ -5,18 +5,15 @@
/// <reference types="express-session" />
export = FileStore;
declare namespace FileStore {
/**
* FileStore Options
*
* @interface Options
*/
interface Options {
/**
* The directory where the session files will be stored. Defaults to `./sessions`
*
@ -111,7 +108,7 @@ declare namespace FileStore {
* @type {Function}
* @memberOf Options
*/
logFn?: (...args: any[]) => void;
logFn?(...args: any[]): void;
/**
* Returns fallback session object after all failed retries. No defaults
@ -119,7 +116,7 @@ declare namespace FileStore {
* @type {Function}
* @memberOf Options
*/
fallbackSessionFn?: (...args: any[]) => void;
fallbackSessionFn?(...args: any[]): void;
/**
* Object-to-text text encoding. Can be null. Defaults to `'utf8'`
@ -135,7 +132,7 @@ declare namespace FileStore {
* @type {Function}
* @memberOf Options
*/
encoder?: (...args: any[]) => void;
encoder?(...args: any[]): void;
/**
* Decoding function. Takes encoded data, returns object. Defaults to `JSON.parse`
@ -143,7 +140,7 @@ declare namespace FileStore {
* @type {Function}
* @memberOf Options
*/
decoder?: (...args: any[]) => void;
decoder?(...args: any[]): void;
/**
* If secret string is specified then enables encryption of the session before
@ -185,7 +182,7 @@ declare namespace FileStore {
*
* @memberOf Options
*/
keyFunction?: (secret: string, sessionId: string) => string;
keyFunction?(secret: string, sessionId: string): string;
}
}
@ -196,7 +193,6 @@ declare namespace FileStore {
* @class FileStore
*/
declare class FileStore {
/**
* Creates an instance of FileStore.
* @param {FileStore.Options} options
@ -283,5 +279,4 @@ declare class FileStore {
* @memberOf FileStore
*/
expired(sessionId: string, callback: (errr: any, isExpired: boolean) => void): void;
}

View File

@ -8,6 +8,4 @@ const options: FileStore.Options = {
const sessionStore = new FileStore(options);
sessionStore.list((err: any, file: Array<string>) => {
});
sessionStore.list((err: any, file: string[]) => {});

View File

@ -4,7 +4,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace sheetify {
export function getPrefix(css: string): string;
function getPrefix(css: string): string;
}
declare function sheetify(src: string | TemplateStringsArray, filename?: string, options?: {[prop: string]: any}, done?: (err: Error, css: string, prefix: string) => void): string;

View File

@ -17,4 +17,4 @@ const test8 = sheetify`
}
`;
const prefix = sheetify.getPrefix('boop');
const prefix = sheetify.getPrefix('boop');

View File

@ -10,7 +10,7 @@ import * as stream from 'stream';
declare const SimplePeer: SimplePeer.SimplePeer;
declare namespace SimplePeer {
export interface Options {
interface Options {
initiator?: boolean; // set to true if this is the initiating peer
channelConfig?: {}; // custom webrtc data channel configuration (used by createDataChannel)
channelName?: string; // custom webrtc data channel name
@ -19,14 +19,14 @@ declare namespace SimplePeer {
offerConstraints?: {}; // custom offer constraints (used by createOffer method)
answerConstraints?: {}; // custom answer constraints (used by createAnswer method)
reconnectTimer?: boolean | number; // wait __ milliseconds after ICE 'disconnect' for reconnect attempt before emitting 'close'
sdpTransform?: <T extends any>(sdp: T) => T; // function to transform the generated SDP signaling data (for advanced users)
sdpTransform?<T extends any>(sdp: T): T; // function to transform the generated SDP signaling data (for advanced users)
stream?: boolean; // if video/voice is desired, pass stream returned from getUserMedia
trickle?: boolean; // set to false to disable trickle ICE and get a single 'signal' event (slower)
wrtc?: {}; // RTCPeerConnection/RTCSessionDescription/RTCIceCandidate
}
// https://github.com/feross/simple-peer/tree/v6.1.5#peer--new-simplepeeropts
export interface SimplePeer {
interface SimplePeer {
new (opts?: Options): Instance;
(opts?: Options): Instance;
@ -34,17 +34,16 @@ declare namespace SimplePeer {
readonly WEBRTC_SUPPORT: boolean;
}
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
export type SimplePeerData = string | Buffer | TypedArray | ArrayBuffer | Blob;
type SimplePeerData = string | Buffer | TypedArray | ArrayBuffer | Blob;
export interface SignalData {
interface SignalData {
sdp?: any;
candidate?: any;
}
export interface Instance extends stream.Duplex {
interface Instance extends stream.Duplex {
// https://github.com/feross/simple-peer/tree/v6.1.5#peersignaldata
signal(data: string | SignalData): void;

View File

@ -3,7 +3,7 @@
// Definitions by: Kir Dergachev <https://github.com/decyrus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare interface SIP {
interface SIP {
UA: {
new (configuration?: sipjs.ConfigurationParameters): sipjs.UA;
};
@ -18,7 +18,6 @@ declare interface SIP {
}
declare namespace sipjs {
interface URI {
scheme?: string;
user?: string;
@ -164,7 +163,6 @@ declare namespace sipjs {
}
namespace WebRTC {
interface Options {
stunServers?: string | string[];
turnServers?: TurnServer | TurnServer[];
@ -211,7 +209,7 @@ declare namespace sipjs {
log?: {
builtinEnabled?: boolean;
level?: number | string;
connector?: (level: string, category: string, label: string, content: string) => void;
connector?(level: string, category: string, label: string, content: string): void;
};
mediaHandlerFactory?: WebRTC.MediaHandlerFactory;
noAnswerTimeout?: number;

View File

@ -88,12 +88,8 @@ ua.on('registered', () => { });
ua.on('unregistered', (args: sipjs.UA.EventArgs.UnregisteredArgs) => { });
ua.on('registrationFailed', (args: sipjs.UA.EventArgs.RegistrationFailedArgs) => { });
ua.on('invite', (session: sipjs.Session) => {
session.on('progress', (response) => {
});
session.on('accepted', (response) => {
});
session.on('rejected', (response) => {
});
session.on('progress', (response) => {});
session.on('accepted', (response) => {});
session.on('rejected', (response) => {});
});
ua.on('message', (message: sipjs.Message) => { });

View File

@ -7,10 +7,10 @@ declare var sitemap2: Sitemap;
export = sitemap2;
declare interface Sitemap {
interface Sitemap {
new (conf?: SitemapConfig): Sitemap;
addUrl(urlData: UrlData | UrlData[] | string | string[]): this
addUrl(urlData: UrlData | UrlData[] | string | string[]): this;
addSitemap(sm: Sitemap): this;
toXML(): SitemapXml[];
@ -21,7 +21,7 @@ declare interface Sitemap {
childrens: Sitemap[];
}
declare interface SitemapConfig {
interface SitemapConfig {
hostName?: string;
fileName?: string;
limit?: number;
@ -31,7 +31,7 @@ declare interface SitemapConfig {
childrens?: Sitemap[];
}
declare interface UrlData {
interface UrlData {
url: string;
chengefreq?: string;
priority?: number | string;
@ -43,10 +43,10 @@ declare interface UrlData {
description: string;
thumbnail_loc: string;
content_loc: string;
}
};
}
declare interface SitemapXml {
interface SitemapXml {
fileName: string;
xml: string;
}

View File

@ -1,6 +1,6 @@
import Sitemap = require('sitemap2');
let sitemap = new Sitemap({
const sitemap = new Sitemap({
hostName: ('https://example.com/'),
fileName: 'sitemap.xml',
limit: 50000,
@ -43,9 +43,9 @@ sitemap.addUrl([
}
]);
let sitemap2 = new Sitemap();
const sitemap2 = new Sitemap();
sitemap.addSitemap(sitemap2);
const xmlList = sitemap.toXML();
var str = xmlList[0].fileName;
var str = xmlList[0].xml;
let str = xmlList[0].fileName;
str = xmlList[0].xml;

View File

@ -1 +1,6 @@
{ "extends": "../tslint.json" }
{
"extends": "../tslint.json",
"rules": {
"no-misused-new": false
}
}

View File

@ -23,7 +23,7 @@ interface SpeakingURLOptions {
declare function getSlug(input: string, options?: SpeakingURLOptions|string): string;
declare namespace getSlug {
export function createSlug(options: SpeakingURLOptions): (input: string) => string;
function createSlug(options: SpeakingURLOptions): (input: string) => string;
}
export = getSlug;

View File

@ -91,4 +91,4 @@ const options = {
};
const mySlug = getSlug.createSlug(options);
slug = mySlug('welcome to the jungle');
slug = mySlug('welcome to the jungle');

View File

@ -5,14 +5,13 @@
/// <reference types="node" />
import events = require("events");
export declare var OPEN_READONLY: number;
export declare var OPEN_READWRITE: number;
export declare var OPEN_CREATE: number;
export const OPEN_READONLY: number;
export const OPEN_READWRITE: number;
export const OPEN_CREATE: number;
export declare var cached: {
export const cached: {
Database(filename: string, callback?: (err: Error) => void): Database;
Database(filename: string, mode?: number, callback?: (err: Error) => void): Database;
};
@ -22,7 +21,7 @@ export interface RunResult {
changes: number;
}
export declare class Statement {
export class Statement {
bind(callback?: (err: Error) => void): Statement;
bind(...params: any[]): Statement;
@ -47,7 +46,7 @@ export declare class Statement {
each(...params: any[]): Statement;
}
export declare class Database extends events.EventEmitter {
export class Database extends events.EventEmitter {
constructor(filename: string, callback?: (err: Error) => void);
constructor(filename: string, mode?: number, callback?: (err: Error) => void);
@ -85,4 +84,4 @@ export declare class Database extends events.EventEmitter {
on(event: string, listener: (...args: any[]) => void): this;
}
declare function verbose(): void;
export function verbose(): void;

View File

@ -1,8 +1,7 @@
import sqlite3 = require('sqlite3');
sqlite3.verbose();
var db: sqlite3.Database = new sqlite3.Database('chain.sqlite3', () => {});
let db: sqlite3.Database = new sqlite3.Database('chain.sqlite3', () => {});
function createDb() {
console.log("createDb chain");
@ -16,9 +15,9 @@ function createTable() {
function insertRows() {
console.log("insertRows Ipsum i");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
const stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) {
for (let i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
@ -56,8 +55,8 @@ runChainExample();
db.serialize(() => {
db.run("CREATE TABLE lorem (info TEXT)");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) {
const stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (let i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();

View File

@ -4,24 +4,24 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Stamplay {
export function init(appId: string): void;
export function User(): StamplayObject;
export function Cobject(object: string): StamplayObject;
function init(appId: string): void;
function User(): StamplayObject;
function Cobject(object: string): StamplayObject;
export interface Model {
interface Model {
signup({}): Promise<any>;
new(): Model; // This is suspicious, but tests show model instances being constructable...
get(property: string): any;
set(property: string, value: any): void;
unset(property: string) : void;
fetch(id: any) : Promise<any>;
unset(property: string): void;
fetch(id: any): Promise<any>;
destroy(): Promise<any>;
save({}?): Promise<any>;
upVote(): Promise<any>;
}
export interface StamplayObject {
interface StamplayObject {
Model: Model;
Collection : any;
Collection: any;
}
}

View File

@ -1,12 +1,11 @@
Stamplay.init('sample');
var userFn = Stamplay.User();
var user = new userFn.Model;
var colTags = Stamplay.Cobject('tag');
var tags = new colTags.Collection();
const userFn = Stamplay.User();
const user = new userFn.Model();
const colTags = Stamplay.Cobject('tag');
const tags = new colTags.Collection();
// Signing up
var registrationData = {
const registrationData = {
email : 'user@provider.com',
password: 'mySecret'
};
@ -15,20 +14,19 @@ user.signup(registrationData).then(() => {
user.set('phoneNumber', '020 123 4567' );
return user.save();
}).then(() => {
var number = user.get('phoneNumber');
const number = user.get('phoneNumber');
console.log(number); // number value is 020 123 4567
});
// Action
var colFoo = Stamplay.Cobject('foo');
var fooMod = new colFoo.Model();
const colFoo = Stamplay.Cobject('foo');
const fooMod = new colFoo.Model();
fooMod.fetch(5)
.then(() => fooMod.upVote())
.then(
() => {
//success callback
// success callback
}, (err: any) => {
//error callback
// error callback
}
)
);

View File

@ -1 +1,6 @@
{ "extends": "../tslint.json" }
{
"extends": "../tslint.json",
"rules": {
"no-misused-new": false
}
}

View File

@ -25,9 +25,9 @@ declare namespace steed {
length(): number;
kill(): void;
concurrency: number;
drain: () => any;
empty: () => any;
saturated: () => any;
drain(): any;
empty(): any;
saturated(): any;
}
interface Steed {

View File

@ -2,8 +2,8 @@
import steed = require('steed');
declare var path: {
exists: (path: string, callback?: (error: Error, exists: boolean) => any) => void;
declare const path: {
exists(path: string, callback?: (error: Error, exists: boolean) => any): void;
};
function funcStringCbErrBoolean(v: string, cb: (error: Error, res: boolean) => void) { }
@ -19,15 +19,15 @@ steed.series([
() => {}
]);
var data: any[] = [];
const data: any[] = [];
function steedProcess(item: any, callback: (error: Error, result: any) => void) { }
steed.map(data, steedProcess, (error, results) => {
console.log(results);
});
var openFiles = ['file1', 'file2'];
const openFiles = ['file1', 'file2'];
var saveFile = (file: string, cb: (error: Error) => void) => {};
const saveFile = (file: string, cb: (error: Error) => void) => {};
steed.each(openFiles, saveFile, (error: Error) => {});
steed.eachSeries(openFiles, saveFile, (error: Error) => {});
@ -109,7 +109,6 @@ steed.parallel<string, Error>([
],
(error, results) => {});
steed.parallel({
one(callback) {
setTimeout(() => {
@ -144,7 +143,7 @@ function whileFn(callback: any) {
}
function whileTest() { return count < 5; }
var count = 0;
let count = 0;
steed.waterfall([
(callback: any) => {
@ -158,13 +157,11 @@ steed.waterfall([
}
], (error, result) => {});
var q = steed.queue<any, Error>((task: any, callback: () => void) => {
const q = steed.queue<any, Error>((task: any, callback: () => void) => {
console.log('hello ' + task.name);
callback();
}, 2);
q.drain = () => {
console.log('all items have been processed');
};
@ -189,8 +186,8 @@ q.unshift([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], (error: Error) =>
console.log('finished processing bar');
});
var qLength: number = q.length();
var qIsIdle: boolean = q.idle();
const qLength: number = q.length();
const qIsIdle: boolean = q.idle();
q.saturated = () => {
console.log('queue is saturated.');
@ -209,7 +206,7 @@ q.resume();
q.kill();
// tests for strongly typed tasks
var q2 = steed.queue<string, Error>((task: string, callback: () => void) => {
const q2 = steed.queue<string, Error>((task: string, callback: () => void) => {
console.log('Task: ' + task);
callback();
}, 1);
@ -251,38 +248,24 @@ steed.each<number, Error>({
a: 1,
b: 2
}, (val: number, next: steed.ErrorCallback<Error>): void => {
setTimeout((): void => {
console.log(`steed.each: ${val}`);
next();
}, 500);
}, (err?: Error): void => {
console.log("steed.each: done.");
});
steed.eachSeries<number, Error>({
a: 1,
b: 2
}, (val: number, next: steed.ErrorCallback<Error>): void => {
setTimeout((): void => {
console.log(`steed.eachSeries: ${val}`);
next();
}, 500);
}, (err?: Error): void => {
console.log("steed.eachSeries: done.");
});
// map
@ -292,19 +275,12 @@ steed.map<number, string, Error>({
b: 2,
c: 3
}, (val: number, next: steed.SteedResultCallback<string, Error>): void => {
setTimeout((): void => {
console.log(`steed.map: ${val}`);
next(undefined as any, val.toString());
}, 500);
}, (error: Error, results: string[]): void => {
console.log("steed.map: done with results", results);
});
steed.mapSeries<number, string, Error>({
@ -312,17 +288,10 @@ steed.mapSeries<number, string, Error>({
b: 2,
c: 3
}, (val: number, next: steed.SteedResultCallback<string, Error>): void => {
setTimeout((): void => {
console.log(`steed.mapSeries: ${val}`);
next(undefined as any, val.toString());
}, 500);
}, (error: Error, results: string[]): void => {
console.log("steed.mapSeries: done with results", results);
});

View File

@ -11,7 +11,7 @@ export interface WritableStreamBufferOptions extends stream.WritableOptions {
incrementAmount?: number;
}
export declare class WritableStreamBuffer extends stream.Writable {
export class WritableStreamBuffer extends stream.Writable {
constructor(options?: WritableStreamBufferOptions);
size(): number;
maxSize(): number;
@ -26,7 +26,7 @@ export interface ReadableStreamBufferOptions extends stream.ReadableOptions {
incrementAmount?: number;
}
export declare class ReadableStreamBuffer extends stream.Readable {
export class ReadableStreamBuffer extends stream.Readable {
constructor(options?: ReadableStreamBufferOptions);
put(data: string | Buffer, encoding?: string): void;
stop(): void;
@ -34,7 +34,7 @@ export declare class ReadableStreamBuffer extends stream.Readable {
maxSize(): number;
}
export declare const DEFAULT_INITIAL_SIZE: number;
export declare const DEFAULT_INCREMENT_AMOUNT: number;
export declare const DEFAULT_FREQUENCY: number;
export declare const DEFAULT_CHUNK_SIZE: number;
export const DEFAULT_INITIAL_SIZE: number;
export const DEFAULT_INCREMENT_AMOUNT: number;
export const DEFAULT_FREQUENCY: number;
export const DEFAULT_CHUNK_SIZE: number;

View File

@ -3,15 +3,15 @@ import * as streamBuffers from 'stream-buffers';
// The following are examples from README.md
// https://github.com/samcday/node-stream-buffer
var myWritableStreamBuffer = new streamBuffers.WritableStreamBuffer({
const myWritableStreamBuffer = new streamBuffers.WritableStreamBuffer({
initialSize: (100 * 1024), // start at 100 kilobytes.
incrementAmount: (10 * 1024) // grow by 10 kilobytes each time buffer overflows.
});
var a = streamBuffers.DEFAULT_INITIAL_SIZE; // (8 * 1024)
var b = streamBuffers.DEFAULT_INCREMENT_AMOUNT; // (8 * 1024)
var c = streamBuffers.DEFAULT_CHUNK_SIZE; // (1024)
var d = streamBuffers.DEFAULT_FREQUENCY; // (1)
const a = streamBuffers.DEFAULT_INITIAL_SIZE; // (8 * 1024)
const b = streamBuffers.DEFAULT_INCREMENT_AMOUNT; // (8 * 1024)
const c = streamBuffers.DEFAULT_CHUNK_SIZE; // (1024)
const d = streamBuffers.DEFAULT_FREQUENCY; // (1)
const buffer = new Buffer('ASDF');
myWritableStreamBuffer.write('ASDF');
@ -31,7 +31,7 @@ myWritableStreamBuffer.getContents(5);
// Gets first 5 bytes as a utf8 string.
myWritableStreamBuffer.getContentsAsString('utf8', 5);
var myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
const myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
frequency: 10, // in milliseconds.
chunkSize: 2048 // in bytes.
});

View File

@ -7,7 +7,7 @@
declare namespace StrongClusterControl {
type pid = number;
export interface StartOptions {
interface StartOptions {
size?: number;
env?: {};
shutdownTimeout?: number;
@ -15,17 +15,17 @@ declare namespace StrongClusterControl {
throttleDelay?: number;
}
export interface ClusterMaster {
interface ClusterMaster {
pid: number;
setSize?: number;
startTime: number;
}
export interface ClusterWorker extends ClusterMaster {
interface ClusterWorker extends ClusterMaster {
id: number;
}
export interface ClusterStatus {
interface ClusterStatus {
master: ClusterMaster;
workers: ClusterWorker[];
}
@ -34,7 +34,7 @@ declare namespace StrongClusterControl {
SHUTDOWN: "CLUSTER_CONTROL_shutdown";
}
export interface Control extends NodeJS.EventEmitter {
interface Control extends NodeJS.EventEmitter {
readonly cmd: CMD;
readonly CPUS: number;
readonly options: StartOptions;

View File

@ -26,14 +26,13 @@ declare namespace SwaggerHook {
* @see {@link http://sailsjs.com/documentation/concepts/extending-sails/hooks/hook-specification|Sails Hook Docs}
* @see {@link http://sailsjs.com/documentation/anatomy/api/hooks/my-hook/index-js|Sails Hook Example}
*/
export interface SailsHook {
interface SailsHook {
/**
* Perform startup tasks.
* All Sails configuration is guaranteed to be completed before a hooks initialize function runs.
* @param {Function} done - called when `swagger-sails-hook`'s startup tasks have finished.
*/
initialize: (done: () => any) => void;
initialize(done: () => any): void;
/**
* `swagger-sails-hook` specific route bound to a Sails app at load time.
@ -48,7 +47,7 @@ declare namespace SwaggerHook {
* This route will match any routes that aren't bound in the app via a custom route configuration
* or a blueprint.
*/
"/*": (req: any, res: any, next: () => any) => any
"/*"(req: any, res: any, next: () => any): any
}
};
}

View File

@ -1,7 +1,6 @@
import swaggerSailsHook = require("swagger-sails-hook");
import * as express from "express";
const mockSailsApp = {
models: {},
conf: {},

View File

@ -132,7 +132,7 @@ interface BaseSchema {
uniqueItems?: boolean;
maxProperties?: number;
minProperties?: number;
enum?: (string|boolean|number|{})[];
enum?: Array<string | boolean | number | {}>;
type?: string;
items?: Schema|Schema[];
}

View File

@ -12,7 +12,7 @@ declare namespace tcp {
/**
* Extends Tedious Connection with release function
*/
export class PooledConnection extends tedious.Connection {
class PooledConnection extends tedious.Connection {
/**
* If the connection is issued from a connection pool returns the connection to the pool.
*/
@ -24,12 +24,12 @@ declare namespace tcp {
* @param err error if any
* @param connection issued from the pool
*/
export type ConnectionCallback = (err: Error, connection: PooledConnection) => void;
type ConnectionCallback = (err: Error, connection: PooledConnection) => void;
/**
* Pool Configuration interface
*/
export interface PoolConfig {
interface PoolConfig {
/**
* Minimum concurrent connections
*/

View File

@ -1,7 +1,7 @@
import ConnectionPool = require("tedious-connection-pool");
import tedious = require("tedious");
var config: tedious.ConnectionConfig = {
const config: tedious.ConnectionConfig = {
userName: "rogier",
password: "rogiers password",
server: "127.0.0.1",
@ -11,12 +11,12 @@ var config: tedious.ConnectionConfig = {
}
};
var poolConfig : ConnectionPool.PoolConfig = {
const poolConfig: ConnectionPool.PoolConfig = {
min: 1,
max: 4
};
var pool: ConnectionPool = new ConnectionPool(poolConfig, config);
const pool: ConnectionPool = new ConnectionPool(poolConfig, config);
pool.on('error', (err: Error) => {
console.error(err);
@ -34,8 +34,7 @@ pool.acquire((err: Error, connection: ConnectionPool.PooledConnection) => {
connection.rollbackTransaction((error: Error): void => {});
connection.commitTransaction((error: Error): void => {});
var request = new tedious.Request("SELECT * FROM foo", (error: Error, rowCount: number): void => {
const request = new tedious.Request("SELECT * FROM foo", (error: Error, rowCount: number): void => {
});
request.on("row", (row: tedious.ColumnValue[]): void => {
});
@ -43,11 +42,5 @@ pool.acquire((err: Error, connection: ConnectionPool.PooledConnection) => {
connection.release();
pool.drain();
});

View File

@ -2,7 +2,7 @@
import * as t from 'transducers-js';
var map = t.map,
const map = t.map,
filter = t.filter,
comp = t.comp,
into = t.into;
@ -11,119 +11,119 @@ var map = t.map,
function inc(n: number) { return n + 1; };
function isEven(n: number) { return n % 2 === 0; };
var xf = comp(map(inc), filter(isEven));
let xf = comp(map(inc), filter(isEven));
into([], xf, [0, 1, 2, 3, 4]); // [2, 4]
// integration
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
apush = (arr: number[], x: number) => { arr.push(x); return arr; },
xf = comp(map(inc), filter(isEven)),
toFn = t.toFn;
const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const apush = (arr: number[], x: number) => { arr.push(x); return arr; };
xf = comp(map(inc), filter(isEven));
const toFn = t.toFn;
arr.reduce(toFn(xf, apush), []); // native
// source examples
function mapExample() {
var xf = t.map(inc);
const xf = t.map(inc);
t.into([], xf, [1, 2, 3]); // [2, 3, 4]
}
function filterExample() {
var xf = t.filter(isEven);
const xf = t.filter(isEven);
t.into([], xf, [0, 1, 2, 3, 4]); // [0, 2, 4];
}
function removeExample() {
var xf = t.remove(isEven);
const xf = t.remove(isEven);
t.into([], xf, [0, 1, 2, 3, 4]); // [1, 3];
}
function complementExample() {
var isOdd = t.complement(isEven);
const isOdd = t.complement(isEven);
}
function keepIndexedExample() {
var xf = t.keepIndexed((i: number, x: string|number) => { if (typeof x === "string") return "cool"; });
const xf = t.keepIndexed((i: number, x: string|number) => { if (typeof x === "string") return "cool"; });
t.into([], xf, [0, 1, "foo", 3, 4, "bar"]); // ["foo", "bar"]
}
function takeExample() {
var xf = t.take(3);
const xf = t.take(3);
t.into([], xf, [0, 1, 2, 3, 4, 5]); // [0, 1, 2];
}
function takeWhileExample() {
var xf = t.takeWhile(n => n < 3);
const xf = t.takeWhile(n => n < 3);
t.into([], xf, [0, 1, 2, 3, 4, 5]); // [0, 1, 2];
}
function intoExample() {
var xf = t.comp(t.map(inc), t.filter(isEven));
const xf = t.comp(t.map(inc), t.filter(isEven));
t.into([], xf, [1, 2, 3, 4]); // [2, 4]
}
function toFnExample() {
var arr = [0, 1, 2, 3, 4, 5];
var xf = t.comp(t.map(inc), t.filter(isEven));
const arr = [0, 1, 2, 3, 4, 5];
const xf = t.comp(t.map(inc), t.filter(isEven));
arr.reduce(t.toFn(xf, apush), []); // [2, 4, 6]
}
function takeNthExample() {
var xf = t.takeNth(3);
const xf = t.takeNth(3);
t.into([], xf, [0, 1, 2, 3, 4, 5]); // [2, 5];
}
function dropExample() {
var xf = t.drop(3);
const xf = t.drop(3);
t.into([], xf, [0, 1, 2, 3, 4, 5]); // [3, 4, 5];
}
function dropWhileExample() {
var xf = t.dropWhile(n => n < 3);
const xf = t.dropWhile(n => n < 3);
t.into([], xf, [0, 1, 2, 3, 4, 5]); // [3, 4, 5];
}
function partitionByExample() {
var xf = t.partitionBy((x: string|number) => typeof x === "string");
const xf = t.partitionBy((x: string|number) => typeof x === "string");
t.into([], xf, [0, 1, "foo", "bar", 2, 3, "bar", "baz"]); // [[0, 1], ["foo", "bar"], [2, 3], ["bar", "baz"]];
}
function partitionAllExample() {
var xf = t.partitionAll(3);
const xf = t.partitionAll(3);
t.into([], xf, [0, 1, 2, 3, 4, 5]); // [[0, 1, 2], [3, 4, 5]]
}
function wrapExample() {
var arrayPush = t.wrap((arr: number[], x: number) => { arr.push(x); return arr; });
const arrayPush = t.wrap((arr: number[], x: number) => { arr.push(x); return arr; });
}
function ensureReducedExample() {
var x = t.ensureReduced(1);
var y = t.ensureReduced(x);
const x = t.ensureReduced(1);
const y = t.ensureReduced(x);
x === y; // true
}
function unreducedExample() {
var x = t.reduced(1);
const x = t.reduced(1);
t.unreduced(x); // 1
t.unreduced(t.unreduced(x)); // 1
}
function reverse(arr: number[]) {
var arr: number[] = Array.prototype.slice.call(arr, 0);
arr = Array.prototype.slice.call(arr, 0);
arr.reverse();
return arr;
}
function catExample() {
var xf = t.comp(t.map(reverse), t.cat);
const xf = t.comp(t.map(reverse), t.cat);
t.into([], xf, [[3, 2, 1], [6, 5, 4]]); // [1, 2, 3, 4, 5, 6]
}
function mapcatExample() {
var xf = t.mapcat(reverse);
const xf = t.mapcat(reverse);
t.into([], xf, [[3, 2, 1], [6, 5, 4]]); // [1, 2, 3, 4, 5, 6]
}

View File

@ -8,9 +8,7 @@
import * as angular from 'angular';
declare module 'angular' {
export namespace ui {
namespace ui {
/*
* $deepStateRedirect
*/
@ -64,7 +62,6 @@ declare module 'angular' {
* Previous state service
*/
interface IPreviousStateService {
/**
* Get a previous state
* @param memoName Memo name
@ -117,18 +114,17 @@ declare module 'angular' {
/*
* Function (injectable). Called when a sticky state is navigated away from (inactivated).
*/
onInactivate?: (...args: any[]) => void;
onInactivate?(...args: any[]): void;
/*
* Function (injectable). Called when an inactive sticky state is navigated to (reactivated).
*/
onReactivate?: (...args: any[]) => void;
onReactivate?(...args: any[]): void;
/*
* Note: named views are mandatory when using sticky states!
*/
views?: { [name: string]: angular.ui.IState };
}
/**
* Sticky state service
*/
@ -150,9 +146,7 @@ declare module 'angular' {
state(name: string, config: IStickyState): IStateProvider;
}
interface IFutureStateProvider {
/**
* Registers a `FutureState` object as a placeholder for a full UI-Router `state` or `state` tree.
*/
@ -164,31 +158,28 @@ declare module 'angular' {
stateFactory(type: string, stateFactory: IFutureStateFactory): void;
/**
* Adds a resolve function.
* `$futureStateProvider` won't reject any state transitions or routes until all resolveFunction promises have been resolved.
* Adds a resolve function.
* `$futureStateProvider` won't reject any state transitions or routes until all resolveFunction promises have been resolved.
* Resolves may be used to defer routing until the states have been loaded via $http, for instance.
*/
addResolve(resolveFn: IResolveFunction): void;
}
interface IFutureStateService {
}
interface IFutureStateService {}
/**
* A `FutureState` object is a placeholder for full a UI-Router `state`
*/
interface IFutureState {
/**
* The placeholder state name (fully qualified).
* The placeholder state name (fully qualified).
* Attempted transitions to this state (or any substates) will trigger a lazy load of the full UI-Router `state` represented by this FutureState.
*/
stateName: string;
/**
* The placeholder url path fragment (the fragment is the URL prefix which the state will be accessed on, not the URL of the state's source code).
* Attempted navigations to a URL starting with this fragment will trigger a lazy load of the full UI-Router `state` represented by this FutureState.
* The placeholder url path fragment (the fragment is the URL prefix which the state will be accessed on, not the URL of the state's source code).
* Attempted navigations to a URL starting with this fragment will trigger a lazy load of the full UI-Router `state` represented by this FutureState.
*/
url: string;

View File

@ -1,8 +1,7 @@
{
"extends": "../tslint.json",
"rules": {
"interface-name": [
false
]
"interface-name": false,
"no-empty-interface": false
}
}

View File

@ -1,23 +1,20 @@
import * as angular from 'angular';
var myApp = angular.module('testModule')
const myApp = angular.module('testModule');
myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: angular.ui.IStickyStateProvider) => {
var state: angular.ui.IStickyState = {
const state: angular.ui.IStickyState = {
name: 'test',
sticky: true,
dsr: {
default: 'substate',
params: ['param1', 'param2'],
fn: ($dsr$) => {
return $dsr$.to;
}
fn: ($dsr$) => $dsr$.to,
},
onInactivate: ($state: angular.ui.IState) => {
var iAmInjectedByInjector = $state;
const iAmInjectedByInjector = $state;
},
onReactivate: ($state: angular.ui.IState) => {
var iAmInjectedByInjector = $state;
const iAmInjectedByInjector = $state;
},
controller: ($previousState: angular.ui.IPreviousStateService, $deepstateRedirect: angular.ui.IDeepStateRedirectService) => {
$previousState.memo('test-memo1');
@ -37,7 +34,7 @@ myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: a
});
},
views: {
//named views are mandatory
// named views are mandatory
'name1': {}
}
};
@ -51,16 +48,13 @@ myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: a
dsr: {
default: 'substate',
params: ['param1', 'param2'],
fn: ($dsr$) => {
return $dsr$.to;
}
fn: $dsr$ => $dsr$.to,
},
onInactivate: ($state: angular.ui.IState) => {
var iAmInjectedByInjector = $state;
const iAmInjectedByInjector = $state;
},
onReactivate: ($state: angular.ui.IState) => {
var iAmInjectedByInjector = $state;
const iAmInjectedByInjector = $state;
},
controller: ($previousState: angular.ui.IPreviousStateService, $deepstateRedirect: angular.ui.IDeepStateRedirectService) => {
$previousState.memo('test-memo1');
@ -80,7 +74,7 @@ myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: a
});
},
views: {
//named views are mandatory
// named views are mandatory
'name1': {}
}
});
@ -91,16 +85,13 @@ myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: a
dsr: {
default: 'substate',
params: ['param1', 'param2'],
fn: ($dsr$) => {
return $dsr$.to;
}
fn: $dsr$ => $dsr$.to,
},
onInactivate: ($state: angular.ui.IState) => {
var iAmInjectedByInjector = $state;
const iAmInjectedByInjector = $state;
},
onReactivate: ($state: angular.ui.IState) => {
var iAmInjectedByInjector = $state;
const iAmInjectedByInjector = $state;
},
controller: ($previousState: angular.ui.IPreviousStateService, $deepstateRedirect: angular.ui.IDeepStateRedirectService) => {
$previousState.memo('test-memo1');
@ -120,44 +111,43 @@ myApp.config(($stateProvider: angular.ui.IStateProvider, $stickyStateProvider: a
});
},
views: {
//named views are mandatory
// named views are mandatory
'name1': {}
}
});
});
var templateLoadStateFactory: ng.ui.IFutureStateFactory = ($q: ng.IQService, $timeout: ng.ITimeoutService, futureState: ng.ui.IFutureState) => {
var d = $q.defer();
const templateLoadStateFactory: ng.ui.IFutureStateFactory = ($q: ng.IQService, $timeout: ng.ITimeoutService, futureState: ng.ui.IFutureState) => {
const d = $q.defer();
$timeout(() => {
var fullUiRouterState = {
const fullUiRouterState = {
name: futureState.stateName,
url: futureState.url,
template: '<h1>Template</h1>'
}
};
d.resolve(fullUiRouterState); // Async resolve of ui-router state promise
}, 1000);
return d.promise; // ui-router state promise returned
}
};
myApp.config(($futureStateProvider: ng.ui.IFutureStateProvider) => {
$futureStateProvider.addResolve(($q: ng.IQService, $timeout: ng.ITimeoutService) => {
var d = $q.defer();
const d = $q.defer();
$timeout(() => {
d.resolve("When this resolves, future state provider will re-sync the state/url");
}, 1000);
return d.promise;
});
var futureState = { type: 'ngload', stateName: 'foo', url: '/foo', src: 'foo.js' };
const futureState = { type: 'ngload', stateName: 'foo', url: '/foo', src: 'foo.js' };
$futureStateProvider.futureState(futureState);
$futureStateProvider.stateFactory('ngload', templateLoadStateFactory);
});
var adminModuleFutureState: ng.ui.IFutureState = {
const adminModuleFutureState: ng.ui.IFutureState = {
stateName: 'app.admin',
url: '/admin',
type: 'ngload',
src: 'js/modules/admin.js' // example custom attr
}
};

View File

@ -39,7 +39,7 @@ export interface ActionContext extends Context {
*/
export interface Route<C, R> {
path: string;
action: (ctx: ActionContext & C, params: Params) => R | Promise<R> | void;
action(ctx: ActionContext & C, params: Params): R | Promise<R> | void;
children?: Routes<C, R>;
}

View File

@ -26,7 +26,6 @@ const routes2 = [
resolve(routes2, { path: "/hello/john" })
.then(result => console.log(result));
// Test 3
const routes3 = [
{
@ -38,7 +37,6 @@ const routes3 = [
resolve(routes3, { path: "/hello/john" })
.then(result => console.log(result));
// Test 4
const routes4 = [
{

View File

@ -6,7 +6,7 @@
/**
* A smooth 3D tilt javascript library forked from Tilt.js (jQuery version).
*/
export declare namespace VanillaTilt {
export namespace VanillaTilt {
/**
* Options which configures the tilting
*/
@ -49,7 +49,7 @@ export declare namespace VanillaTilt {
easing?: string;
}
export interface TiltValues {
interface TiltValues {
/**
* The current tilt on the X axis
*/
@ -68,15 +68,15 @@ export declare namespace VanillaTilt {
percentageY: number;
}
export interface HTMLVanillaTiltElement extends HTMLElement {
vanillaTilt: VanillaTilt
interface HTMLVanillaTiltElement extends HTMLElement {
vanillaTilt: VanillaTilt;
}
}
/**
* A smooth 3D tilt javascript library forked from Tilt.js (jQuery version).
*/
export declare class VanillaTilt {
export class VanillaTilt {
/**
* Creates a new instance of a VanillaTilt element.
* @param element The element, which should be a VanillaTilt element

View File

@ -1,6 +1,6 @@
import { VanillaTilt } from './index.d';
import { VanillaTilt } from 'vanilla-tilt';
let element: VanillaTilt = new VanillaTilt(document.createElement('a'), {
const element: VanillaTilt = new VanillaTilt(document.createElement('a'), {
axis: 'y',
easing: 'cubic-besizer(0.9, 0.9, 0.9)',
max: 2,
@ -21,8 +21,7 @@ VanillaTilt.init([document.createElement('a')], {
axis: null
});
let values: VanillaTilt.TiltValues = element.getValues();
const values: VanillaTilt.TiltValues = element.getValues();
values.percentageX;
values.percentageY;
values.tiltX;

View File

@ -1,10 +1,10 @@
import v = require('voca');
var str: string;
var num: number;
var bool: boolean;
var strAry: string[];
var numAry: number[];
let str: string;
let num: number;
let bool: boolean;
let strAry: string[];
let numAry: number[];
// Case
str = v.camelCase();
@ -222,18 +222,18 @@ str = v.splice('new year', 0, 3, 'happy');
str = v.tr();
str = v.tr('hello', 'el', 'ip');
str = v.tr('Yes. The fire rises.', {
'Yes': 'Awesome',
'fire': 'flame'
})
Yes: 'Awesome',
fire: 'flame'
});
str = v('hello').tr('el', 'ip').value();
str = v('Yes. The fire rises.').tr({
'Yes': 'Awesome',
'fire': 'flame'
Yes: 'Awesome',
fire: 'flame'
}).value();
str = v.chain('hello').tr('el', 'ip').value();
str = v.chain('Yes. The fire rises.').tr({
'Yes': 'Awesome',
'fire': 'flame'
Yes: 'Awesome',
fire: 'flame'
}).value();
str = v.trim();
@ -349,5 +349,5 @@ str = v.stripTags('<span><i>Winter</i> is <b>cold</b></span>', ['b', 'i']);
str = v.stripTags('Sun<br/>set', '', '-');
// Util
var voca: v.VocaStatic = v.noConflict();
var version: string = v.version;
const voca: v.VocaStatic = v.noConflict();
const version: string = v.version;

View File

@ -12,7 +12,7 @@ interface Navigator {
}
declare namespace WebMidi {
export interface MIDIOptions {
interface MIDIOptions {
/**
* This member informs the system whether the ability to send and receive system
* exclusive messages is requested or allowed on a given MIDIAccess object.
@ -24,15 +24,15 @@ declare namespace WebMidi {
* This is a maplike interface whose value is a MIDIInput instance and key is its
* ID.
*/
export type MIDIInputMap = Map<string, MIDIInput>;
type MIDIInputMap = Map<string, MIDIInput>;
/**
* This is a maplike interface whose value is a MIDIOutput instance and key is its
* ID.
*/
export type MIDIOutputMap = Map<string, MIDIOutput>;
type MIDIOutputMap = Map<string, MIDIOutput>;
export interface MIDIAccess extends EventTarget {
interface MIDIAccess extends EventTarget {
/**
* The MIDI input ports available to the system.
*/
@ -47,7 +47,7 @@ declare namespace WebMidi {
* The handler called when a new port is connected or an existing port changes the
* state attribute.
*/
onstatechange: (e: MIDIConnectionEvent) => void;
onstatechange(e: MIDIConnectionEvent): void;
/**
* This attribute informs the user whether system exclusive support is enabled on
@ -56,13 +56,13 @@ declare namespace WebMidi {
sysexEnabled: boolean;
}
export type MIDIPortType = "input" | "output";
type MIDIPortType = "input" | "output";
export type MIDIPortDeviceState = "disconnected" | "connected";
type MIDIPortDeviceState = "disconnected" | "connected";
export type MIDIPortConnectionState = "open" | "closed" | "pending";
type MIDIPortConnectionState = "open" | "closed" | "pending";
export interface MIDIPort extends EventTarget {
interface MIDIPort extends EventTarget {
/**
* A unique ID of the port. This can be used by developers to remember ports the
* user has chosen for their application.
@ -104,7 +104,7 @@ declare namespace WebMidi {
* The handler called when an existing port changes its state or connection
* attributes.
*/
onstatechange: (e: MIDIConnectionEvent) => void;
onstatechange(e: MIDIConnectionEvent): void;
/**
* Makes the MIDI device corresponding to the MIDIPort explicitly available. Note
@ -133,11 +133,11 @@ declare namespace WebMidi {
close(): Promise<MIDIPort>;
}
export interface MIDIInput extends MIDIPort {
onmidimessage: (e: MIDIMessageEvent) => void;
interface MIDIInput extends MIDIPort {
onmidimessage(e: MIDIMessageEvent): void;
}
export interface MIDIOutput extends MIDIPort {
interface MIDIOutput extends MIDIPort {
/**
* Enqueues the message to be sent to the corresponding MIDI port.
* @param data The data to be enqueued, with each sequence entry representing a single byte of data.
@ -156,7 +156,7 @@ declare namespace WebMidi {
clear(): void;
}
export interface MIDIMessageEvent extends Event {
interface MIDIMessageEvent extends Event {
/**
* A timestamp specifying when the event occurred.
*/
@ -168,7 +168,7 @@ declare namespace WebMidi {
data: Uint8Array;
}
export interface MIDIMessageEventInit extends EventInit {
interface MIDIMessageEventInit extends EventInit {
/**
* A timestamp specifying when the event occurred.
*/
@ -180,14 +180,14 @@ declare namespace WebMidi {
data: Uint8Array;
}
export interface MIDIConnectionEvent extends Event {
interface MIDIConnectionEvent extends Event {
/**
* The port that has been connected or disconnected.
*/
port: MIDIPort;
}
export interface MIDIConnectionEventInit extends EventInit {
interface MIDIConnectionEventInit extends EventInit {
/**
* The port that has been connected or disconnected.
*/

View File

@ -1,6 +1,4 @@
var onFulfilled = (item: WebMidi.MIDIAccess) => {
const onFulfilled = (item: WebMidi.MIDIAccess) => {
this._midiPort = item;
item.onstatechange = (event: WebMidi.MIDIConnectionEvent) => {
@ -11,14 +9,14 @@ var onFulfilled = (item: WebMidi.MIDIAccess) => {
console.log("sysexenabled");
console.log(item.sysexEnabled);
var inputs = this._midiPort.inputs.values();
const inputs = this._midiPort.inputs.values();
for (const o of inputs) {
this._inputs.push(o);
console.log(o);
}
var outputs = item.outputs.values();
const outputs = item.outputs.values();
for (const op of outputs) {
this._outputs.push(op);
op.send([ 0x90, 0x45, 0x7f ] );
@ -31,7 +29,7 @@ var onFulfilled = (item: WebMidi.MIDIAccess) => {
}
};
var onRejected = (e: Error) => { console.error(e); };
const onRejected = (e: Error) => { console.error(e); };
if (navigator.requestMIDIAccess !== undefined) {
navigator.requestMIDIAccess().then(onFulfilled, onRejected);

View File

@ -13,12 +13,12 @@ import { Wire } from 'bittorrent-protocol';
declare const WebTorrent: WebTorrent.WebTorrent;
declare namespace WebTorrent {
export interface WebTorrent {
interface WebTorrent {
new (config?: Options): Instance;
(config?: Options): Instance;
WEBRTC_SUPPORT: boolean;
}
export interface Options {
interface Options {
maxConns?: number;
nodeId?: string | Buffer;
peerId?: string | Buffer;
@ -27,16 +27,16 @@ declare namespace WebTorrent {
webSeeds?: boolean;
}
export interface TorrentOptions {
interface TorrentOptions {
announce?: any[];
getAnnounceOpts?: () => void;
getAnnounceOpts?(): void;
maxWebConns?: number;
path?: string;
store?: (chunkLength: number, storeOpts: { length: number, files: File[], torrent: Torrent, }) => any;
store?(chunkLength: number, storeOpts: { length: number, files: File[], torrent: Torrent, }): any;
name?: string;
}
export interface Instance extends NodeJS.EventEmitter {
interface Instance extends NodeJS.EventEmitter {
on(event: 'torrent', callback: (torrent: Torrent) => void): this;
on(event: 'error', callback: (err: Error | string) => void): this;
@ -63,7 +63,7 @@ declare namespace WebTorrent {
readonly ratio: number;
}
export interface Torrent extends NodeJS.EventEmitter {
interface Torrent extends NodeJS.EventEmitter {
readonly infoHash: string;
readonly magnetURI: string;
@ -127,7 +127,7 @@ declare namespace WebTorrent {
on(event: 'noPeers', callback: (announceType: 'tracker' | 'dht') => void): this;
}
export interface TorrentFile extends NodeJS.EventEmitter {
interface TorrentFile extends NodeJS.EventEmitter {
readonly name: string;
readonly path: string;

View File

@ -1,8 +1,8 @@
import * as WebTorrent from 'webtorrent';
import * as fs from 'fs';
var client = new WebTorrent();
var magnetURI = '...';
const client = new WebTorrent();
const magnetURI = '...';
client.add(magnetURI, {}, torrent => {
// Got torrent metadata!
@ -25,7 +25,7 @@ client.add(magnetURI, {}, torrent => {
file.getBlobURL((err, url) => {
if (err) throw err;
var a = document.createElement('a');
const a = document.createElement('a');
// a.download = file.name
if (url) {
a.href = url;
@ -61,7 +61,7 @@ client.seed('./file.txt', {}, torrent => {
client.add(magnetURI, torrent => {
// create HTTP server for this torrent
var server = torrent.createServer();
const server = torrent.createServer();
server.listen(1234); // start the server listening to a port
// visit http://localhost:<port>/ to see a list of files

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

@ -7,7 +7,7 @@ declare namespace Wu {
type Consumer<T> = (t: T) => void;
type Filter<T> = (t: T) => boolean;
export interface WuStatic {
interface WuStatic {
<T>(iterable: Iterable<T>): WuIterable<T>;
// only static
chain<T>(...iters: Array<Iterable<T>>): WuIterable<T>;
@ -62,7 +62,7 @@ declare namespace Wu {
tee<T>(iter: Iterable<T>): Array<WuIterable<T>>;
tee<T>(n: number, iter: Iterable<T>): Array<WuIterable<T>>;
}
export interface WuIterable<T> extends IterableIterator<T> {
interface WuIterable<T> extends IterableIterator<T> {
// generated from section "copied to WuIterable" above via
// sed -r 's/(, )?iter: Iterable<\w+>//' |
// sed -r 's/^(\s+\w+)<T>/\1/' |

View File

@ -18,7 +18,7 @@ assert.iterable = (thing: any) => {
// iterator are in the |expected| set.
assert.eqSet = (expected: any, actual: any) => {
assert.iterable(actual);
for (var x of actual) {
for (const x of actual) {
assert.ok(expected.has(x));
expected.delete(x);
}
@ -96,23 +96,23 @@ describe("wu.count", () => {
});
describe("wu.curryable", () => {
it("should wait until its given enough arguments", () => {
var f = wu.curryable((a, b) => a + b);
const f = wu.curryable((a, b) => a + b);
var f0 = f()()()()();
const f0 = f()()()()();
assert.equal(typeof f0, "function");
var f1 = f(1);
const f1 = f(1);
assert.equal(typeof f1, "function");
assert.equal(f1(2), 3);
});
it("should just call the function when given enough arguments", () => {
var f = wu.curryable((a, b) => a + b);
const f = wu.curryable((a, b) => a + b);
assert.equal(f(1, 2), 3);
});
it("should expect the number of arguments we tell it to", () => {
var f = wu.curryable((...args) => 5, 5);
const f = wu.curryable((...args) => 5, 5);
assert.equal(typeof f(1, 2, 3, 4), "function");
assert.equal(f(1, 2, 3, 4, 5), 5);
});

View File

@ -85,7 +85,6 @@ generator.runInstall('installer', 'pkg', {});
generator.runInstall('installer', 'pkg', { 'custom-option': 3 }, () => {});
generator.runInstall('installer', 'pkg', {}, () => {}, {});
const composed1: Base = generator.composeWith('bootstrap', { sass: true });
const composed2: Base = generator.composeWith(require.resolve('generator-bootstrap/app/main.js'), { sass: true });