From d3789893deeb3b17bc7738ee9943ffcdf15810f0 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 15 Nov 2015 12:02:50 -0800 Subject: [PATCH 01/49] Convert to typescript, make it executable --- .gitignore | 3 +- .vscode/launch.json | 41 + .vscode/tasks.json | 187 + bin/syncjs | 4 + src/classes/CLI.ts | 128 + src/classes/Config.ts | 53 + src/classes/SyncError.ts | 9 + src/sync.ts | 29 + tsconfig.json | 16 + typings/colors/colors.d.ts | 123 + typings/jsonplus/jsonplus.d.ts | 15 + typings/moment/moment-node.d.ts | 479 +++ typings/moment/moment.d.ts | 8 + typings/node/node.d.ts | 2088 ++++++++++ .../underscore.string/underscore.string.d.ts | 573 +++ typings/underscore/underscore.d.ts | 3413 +++++++++++++++++ 16 files changed, 7168 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 bin/syncjs create mode 100644 src/classes/CLI.ts create mode 100644 src/classes/Config.ts create mode 100644 src/classes/SyncError.ts create mode 100644 src/sync.ts create mode 100644 tsconfig.json create mode 100644 typings/colors/colors.d.ts create mode 100644 typings/jsonplus/jsonplus.d.ts create mode 100644 typings/moment/moment-node.d.ts create mode 100644 typings/moment/moment.d.ts create mode 100644 typings/node/node.d.ts create mode 100644 typings/underscore.string/underscore.string.d.ts create mode 100644 typings/underscore/underscore.d.ts diff --git a/.gitignore b/.gitignore index 7b859f7..0beea89 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ results node_modules npm-debug.log -config.json \ No newline at end of file +config.json +dist \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9339632 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,41 @@ +{ + "version": "0.1.0", + // List of configurations. Add new configurations or edit existing ones. + "configurations": [ + { + // Name of configuration; appears in the launch configuration drop down menu. + "name": "Launch sync.js", + // Type of configuration. + "type": "node", + // Workspace relative or absolute path to the program. + "program": "sync.js", + // Automatically stop program after launch. + "stopOnEntry": false, + // Command line arguments passed to the program. + "args": [], + // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. + "cwd": ".", + // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. + "runtimeExecutable": null, + // Optional arguments passed to the runtime executable. + "runtimeArgs": ["--nolazy"], + // Environment variables passed to the program. + "env": { + "NODE_ENV": "development" + }, + // Use JavaScript source maps (if they exist). + "sourceMaps": false, + // If JavaScript source maps are enabled, the generated code is expected in this directory. + "outDir": null + }, + { + "name": "Attach", + "type": "node", + // TCP/IP address. Default is "localhost". + "address": "localhost", + // Port to attach to. + "port": 5858, + "sourceMaps": false + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..2ccfef3 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,187 @@ +// Available variables which can be used inside of strings. +// ${workspaceRoot}: the root folder of the team +// ${file}: the current opened file +// ${fileBasename}: the current opened file's basename +// ${fileDirname}: the current opened file's dirname +// ${fileExtname}: the current opened file's extension +// ${cwd}: the current working directory of the spawned process + +// A task runner that calls the Typescript compiler (tsc) and +// Compiles a HelloWorld.ts program +{ + "version": "0.1.0", + + // The command is tsc. Assumes that tsc has been installed using npm install -g typescript + "command": "tsc", + + // The command is a shell script + "isShellCommand": true, + + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + + // use the standard tsc problem matcher to find compile problems + // in the output. + "problemMatcher": "$tsc" +} + +// A task runner that calls the Typescript compiler (tsc) and +// compiles based on a tsconfig.json file that is present in +// the root of the folder open in VSCode +/* +{ + "version": "0.1.0", + + // The command is tsc. Assumes that tsc has been installed using npm install -g typescript + "command": "tsc", + + // The command is a shell script + "isShellCommand": true, + + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + + // Tell the tsc compiler to use the tsconfig.json from the open folder. + "args": ["-p", "."], + + // use the standard tsc problem matcher to find compile problems + // in the output. + "problemMatcher": "$tsc" +} +*/ + +// A task runner configuration for gulp. Gulp provides a less task +// which compiles less to css. +/* +{ + "version": "0.1.0", + "command": "gulp", + "isShellCommand": true, + "tasks": [ + { + "taskName": "less", + // Make this the default build command. + "isBuildCommand": true, + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + // Use the standard less compilation problem matcher. + "problemMatcher": "$lessCompile" + } + ] +} +*/ + +// Uncomment the following section to use jake to build a workspace +// cloned from https://github.com/Microsoft/TypeScript.git +/* +{ + "version": "0.1.0", + // Task runner is jake + "command": "jake", + // Need to be executed in shell / cmd + "isShellCommand": true, + "showOutput": "silent", + "tasks": [ + { + // TS build command is local. + "taskName": "local", + // Make this the default build command. + "isBuildCommand": true, + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + // Use the redefined Typescript output problem matcher. + "problemMatcher": [ + "$tsc" + ] + } + ] +} +*/ + +// Uncomment the section below to use msbuild and generate problems +// for csc, cpp, tsc and vb. The configuration assumes that msbuild +// is available on the path and a solution file exists in the +// workspace folder root. +/* +{ + "version": "0.1.0", + "command": "msbuild", + "args": [ + // Ask msbuild to generate full paths for file names. + "/property:GenerateFullPaths=true" + ], + "taskSelector": "/t:", + "showOutput": "silent", + "tasks": [ + { + "taskName": "build", + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + // Use the standard MS compiler pattern to detect errors, warnings + // and infos in the output. + "problemMatcher": "$msCompile" + } + ] +} +*/ + +// Uncomment the following section to use msbuild which compiles Typescript +// and less files. +/* +{ + "version": "0.1.0", + "command": "msbuild", + "args": [ + // Ask msbuild to generate full paths for file names. + "/property:GenerateFullPaths=true" + ], + "taskSelector": "/t:", + "showOutput": "silent", + "tasks": [ + { + "taskName": "build", + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + // Use the standard MS compiler pattern to detect errors, warnings + // and infos in the output. + "problemMatcher": [ + "$msCompile", + "$lessCompile" + ] + } + ] +} +*/ +// A task runner example that defines a problemMatcher inline instead of using +// a predfined one. +/* +{ + "version": "0.1.0", + "command": "tsc", + "isShellCommand": true, + "args": ["HelloWorld.ts"], + "showOutput": "silent", + "problemMatcher": { + // The problem is owned by the typescript language service. Ensure that the problems + // are merged with problems produced by Visual Studio's language service. + "owner": "typescript", + // The file name for reported problems is relative to the current working directory. + "fileLocation": ["relative", "${cwd}"], + // The actual pattern to match problems in the output. + "pattern": { + // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. + "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", + // The match group that denotes the file containing the problem. + "file": 1, + // The match group that denotes the problem location. + "location": 2, + // The match group that denotes the problem's severity. Can be omitted. + "severity": 3, + // The match group that denotes the problem code. Can be omitted. + "code": 4, + // The match group that denotes the problem's message. + "message": 5 + } + } +} +*/ \ No newline at end of file diff --git a/bin/syncjs b/bin/syncjs new file mode 100644 index 0000000..bc0b47b --- /dev/null +++ b/bin/syncjs @@ -0,0 +1,4 @@ +#!/usr/bin/env node +var Sync = require('../dist/sync.js'); + +new Sync.default(); \ No newline at end of file diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts new file mode 100644 index 0000000..b0febdb --- /dev/null +++ b/src/classes/CLI.ts @@ -0,0 +1,128 @@ +import 'colors'; +import { sprintf, endsWith } from 'underscore.string'; +import readline = require('readline'); + +export default class CLI { + + private rline: readline.ReadLine; + private pdTime: NodeJS.Timer; + private lastRun: number; + private timeDiff: number; + + paused: boolean; + + constructor(public secondsInterval: number) { + try { + this.rline = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + } catch (e) { + this.write('You need to upgrade your nodejs'); + this.write('http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/'); + process.exit(1); + } + } + + write(msg: string): boolean { + return process.stdout.write.bind(process.stdout)(msg); + } + + + /** + * Start printing dots to screen, show script is working + */ + dotsStart() { + this.pdTime = setInterval(() => { + this.write('.'.yellow); + }, 200); + } + + /** + * Stop printing dots when process ends + */ + dotsStop() { + clearInterval(this.pdTime); + } + + printTitle() { + this.write('\n'.reset); + + if (this.paused) { + this.write(`Currently paused, type "${ 'resume'.green }" to start again.\n`); + } else { + this.write(`Started monitoring, checking every ${ this.secondsInterval } seconds.\n`); + } + + this.write(`Quit the script with CONTROL-C or type "${ 'exit'.green}".\n`); + this.write('-----------------------------------------------------------\n'.magenta); + this.showPrompt(); + } + + getHelp(command, text) { + return `${command.green}: ${text}\n`; + } + + showPrompt() { + this.rline.question(">>> ", answer => { + this.handleInput(answer); + // as soon as a command is run, show promt again just a like a real shell + this.showPrompt(); + }); + } + + handleInput(input) { + input = input.split(' '); + let cmd = input[0]; + let arg1 = input[1]; + switch (cmd) { + case "help": + let helpText = ""; + helpText += this.getHelp('pause', "Stops observing file changes"); + helpText += this.getHelp('resume', "Continue checking files"); + helpText += this.getHelp('resume -u', "Continue checking files and upload all the changed files while paused."); + helpText += this.getHelp('interval [s]', 'Sets the check interval duration. Example: "interval 2.5" check for every 2.5 seconds'); + helpText += this.getHelp('help', "Displays this text"); + helpText += this.getHelp('clear', "Clears the screen"); + helpText += this.getHelp('exit', "Exits the script"); + this.write(helpText); + break; + case "clear": + this.printTitle(); + break; + case "exit": + process.exit(0); + break; + case "pause": + this.paused = true; + this.printTitle(); + break; + case "resume": + if (this.paused) { + if (arg1 != "-u") { + this.lastRun = +(new Date()); + this.timeDiff = 0; + } + this.paused = false; + this.printTitle(); + if (arg1 == "-u") { + this.write('Finding all changed files while waiting.\n'); + } + // this.startChecking(); + } else { + this.write('Already running\n'); + } + break; + case "interval": + if (arg1) { + this.secondsInterval = parseFloat(arg1) || this.secondsInterval; + this.printTitle(); + } + this.write(`Check interval is ${ this.secondsInterval } Seconds\n`); + break; + case "": break; + default: + this.write(`Unknown command: ${ cmd }\nType "help" to see commands`.red); + } + } +} \ No newline at end of file diff --git a/src/classes/Config.ts b/src/classes/Config.ts new file mode 100644 index 0000000..0e29770 --- /dev/null +++ b/src/classes/Config.ts @@ -0,0 +1,53 @@ +import { parse } from 'jsonplus'; +import { readFileSync, existsSync } from 'fs'; +import { join as pathJoin } from 'path'; + +interface SyncConfig { + "host": string; + "intervalDuration": number; + "localPath": string; + "remotePath": string; +} + +const FILE_NAME = 'config_example.json'; + +export default class Config implements SyncConfig{ + private _filename: string; + private _config: SyncConfig; + + // properties + host: string; + intervalDuration: number; + localPath: string; + remotePath: string; + + constructor() { + this._filename = pathJoin(process.cwd(), FILE_NAME); + this._fetch(); + this._expand(); + } + + /** + * @TODO fail when file is not found + * @TODO fail when file cannot be parsed + */ + private _fetch() { + if (existsSync(this._filename)) { + let configraw; + if (configraw = readFileSync(this._filename)) { + this._config = parse(configraw.toString()); + } + } + } + + /** + * @TODO add checks on required values + * @TODO add defaults for optional values + */ + private _expand() { + this.host = this._config.host; + this.intervalDuration = this._config.intervalDuration; + this.localPath = this._config.localPath; + this.remotePath = this._config.remotePath; + } +} \ No newline at end of file diff --git a/src/classes/SyncError.ts b/src/classes/SyncError.ts new file mode 100644 index 0000000..eb031c1 --- /dev/null +++ b/src/classes/SyncError.ts @@ -0,0 +1,9 @@ +export default class SyncError { + constructor(public message: string) { + this.show(); + } + + show() { + console.error(this.message); + } +} diff --git a/src/sync.ts b/src/sync.ts new file mode 100644 index 0000000..8944fb2 --- /dev/null +++ b/src/sync.ts @@ -0,0 +1,29 @@ +import {exec} from 'child_process'; +import moment = require('moment'); +import SyncError from './classes/SyncError'; +import Config from './classes/Config'; +import CLI from './classes/CLI'; + +export default class Sync { + config: Config; + cli: CLI; + + constructor() { + this.config = new Config(); + this.cli = new CLI( + this.config.intervalDuration + ); + this.connect(); + } + + connect() { + // Test + this.cli.write('Connecting'); + this.cli.dotsStart(); + + setTimeout(() => { + this.cli.dotsStop(); + this.cli.printTitle(); + }, 5000); + } +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..e95bf58 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "sourceMap": true, + "noImplicitAny": false, + "rootDir": ".", + "outDir": "./dist" + }, + "buildOnSave": true, + "exclude": [ + "node_modules" + ] +} diff --git a/typings/colors/colors.d.ts b/typings/colors/colors.d.ts new file mode 100644 index 0000000..5aa2855 --- /dev/null +++ b/typings/colors/colors.d.ts @@ -0,0 +1,123 @@ +// Type definitions for Colors.js 0.6.0-1 +// Project: https://github.com/Marak/colors.js +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "colors" { + interface Color { + (text: string): string; + + black: Color; + red: Color; + green: Color; + yellow: Color; + blue: Color; + magenta: Color; + cyan: Color; + white: Color; + gray: Color; + grey: Color; + + bgBlack: Color; + bgRed: Color; + bgGreen: Color; + bgYellow: Color; + bgBlue: Color; + bgMagenta: Color; + bgCyan: Color; + bgWhite: Color; + + reset: Color; + bold: Color; + dim: Color; + italic: Color; + underline: Color; + inverse: Color; + hidden: Color; + strikethrough: Color; + + rainbow: Color; + zebra: Color; + america: Color; + trap: Color; + random: Color; + } + + module e { + export function setTheme(theme:any): void; + + export var black: Color; + export var red: Color; + export var green: Color; + export var yellow: Color; + export var blue: Color; + export var magenta: Color; + export var cyan: Color; + export var white: Color; + export var gray: Color; + export var grey: Color; + + export var bgBlack: Color; + export var bgRed: Color; + export var bgGreen: Color; + export var bgYellow: Color; + export var bgBlue: Color; + export var bgMagenta: Color; + export var bgCyan: Color; + export var bgWhite: Color; + + export var reset: Color; + export var bold: Color; + export var dim: Color; + export var italic: Color; + export var underline: Color; + export var inverse: Color; + export var hidden: Color; + export var strikethrough: Color; + + export var rainbow: Color; + export var zebra: Color; + export var america: Color; + export var trap: Color; + export var random: Color; + } + + export = e; +} + +interface String { + black: string; + red: string; + green: string; + yellow: string; + blue: string; + magenta: string; + cyan: string; + white: string; + gray: string; + grey: string; + + bgBlack: string; + bgRed: string; + bgGreen: string; + bgYellow: string; + bgBlue: string; + bgMagenta: string; + bgCyan: string; + bgWhite: string; + + reset: string; + bold: string; + dim: string; + italic: string; + underline: string; + inverse: string; + hidden: string; + strikethrough: string; + + rainbow: string; + zebra: string; + america: string; + trap: string; + random: string; +} diff --git a/typings/jsonplus/jsonplus.d.ts b/typings/jsonplus/jsonplus.d.ts new file mode 100644 index 0000000..f164d92 --- /dev/null +++ b/typings/jsonplus/jsonplus.d.ts @@ -0,0 +1,15 @@ +declare module "jsonplus" { + /** + * Takes a JSON string and returns back an object. + * In JSON String values you can use `@self` + * notation and reference the JSON itself. This will + * replace the value with reference + */ + function parse(jsonString: string): any; + + /** + * Resolves self references on an already parsed object + * self here is where references will be resolved against + */ + function resolve(object: any, self?: any): any; +} diff --git a/typings/moment/moment-node.d.ts b/typings/moment/moment-node.d.ts new file mode 100644 index 0000000..babde41 --- /dev/null +++ b/typings/moment/moment-node.d.ts @@ -0,0 +1,479 @@ +// Type definitions for Moment.js 2.8.0 +// Project: https://github.com/timrwood/moment +// Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module moment { + + interface MomentInput { + /** Year */ + years?: number; + /** Year */ + year?: number; + /** Year */ + y?: number; + + /** Month */ + months?: number; + /** Month */ + month?: number; + /** Month */ + M?: number; + + /** Week */ + weeks?: number; + /** Week */ + week?: number; + /** Week */ + w?: number; + + /** Day/Date */ + days?: number; + /** Day/Date */ + day?: number; + /** Day/Date */ + date?: number; + /** Day/Date */ + d?: number; + + /** Hour */ + hours?: number; + /** Hour */ + hour?: number; + /** Hour */ + h?: number; + + /** Minute */ + minutes?: number; + /** Minute */ + minute?: number; + /** Minute */ + m?: number; + + /** Second */ + seconds?: number; + /** Second */ + second?: number; + /** Second */ + s?: number; + + /** Millisecond */ + milliseconds?: number; + /** Millisecond */ + millisecond?: number; + /** Millisecond */ + ms?: number; + } + + interface Duration { + humanize(withSuffix?: boolean): string; + + as(units: string): number; + + milliseconds(): number; + asMilliseconds(): number; + + seconds(): number; + asSeconds(): number; + + minutes(): number; + asMinutes(): number; + + hours(): number; + asHours(): number; + + days(): number; + asDays(): number; + + months(): number; + asMonths(): number; + + years(): number; + asYears(): number; + + add(n: number, p: string): Duration; + add(n: number): Duration; + add(d: Duration): Duration; + + subtract(n: number, p: string): Duration; + subtract(n: number): Duration; + subtract(d: Duration): Duration; + + toISOString(): string; + toJSON(): string; + } + + interface Moment { + format(format: string): string; + format(): string; + + fromNow(withoutSuffix?: boolean): string; + + startOf(unitOfTime: string): Moment; + endOf(unitOfTime: string): Moment; + + /** + * Mutates the original moment by adding time. (deprecated in 2.8.0) + * + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + * @param amount the amount you want to add + */ + add(unitOfTime: string, amount: number): Moment; + /** + * Mutates the original moment by adding time. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + */ + add(amount: number, unitOfTime: string): Moment; + /** + * Mutates the original moment by adding time. Note that the order of arguments can be flipped. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) + */ + add(amount: string, unitOfTime: string): Moment; + /** + * Mutates the original moment by adding time. + * + * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} + */ + add(objectLiteral: MomentInput): Moment; + /** + * Mutates the original moment by adding time. + * + * @param duration a length of time + */ + add(duration: Duration): Moment; + + /** + * Mutates the original moment by subtracting time. (deprecated in 2.8.0) + * + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + * @param amount the amount you want to subtract + */ + subtract(unitOfTime: string, amount: number): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + * @param amount the amount you want to subtract + */ + subtract(amount: number, unitOfTime: string): Moment; + /** + * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. + * + * @param amount the amount you want to add + * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) + */ + subtract(amount: string, unitOfTime: string): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} + */ + subtract(objectLiteral: MomentInput): Moment; + /** + * Mutates the original moment by subtracting time. + * + * @param duration a length of time + */ + subtract(duration: Duration): Moment; + + calendar(): string; + calendar(start: Moment): string; + calendar(start: Moment, formats: MomentCalendar): string; + + clone(): Moment; + + /** + * @return Unix timestamp, or milliseconds since the epoch. + */ + valueOf(): number; + + local(): Moment; // current date/time in local mode + + utc(): Moment; // current date/time in UTC mode + + isValid(): boolean; + invalidAt(): number; + + year(y: number): Moment; + year(): number; + quarter(): number; + quarter(q: number): Moment; + month(M: number): Moment; + month(M: string): Moment; + month(): number; + day(d: number): Moment; + day(d: string): Moment; + day(): number; + date(d: number): Moment; + date(): number; + hour(h: number): Moment; + hour(): number; + hours(h: number): Moment; + hours(): number; + minute(m: number): Moment; + minute(): number; + minutes(m: number): Moment; + minutes(): number; + second(s: number): Moment; + second(): number; + seconds(s: number): Moment; + seconds(): number; + millisecond(ms: number): Moment; + millisecond(): number; + milliseconds(ms: number): Moment; + milliseconds(): number; + weekday(): number; + weekday(d: number): Moment; + isoWeekday(): number; + isoWeekday(d: number): Moment; + weekYear(): number; + weekYear(d: number): Moment; + isoWeekYear(): number; + isoWeekYear(d: number): Moment; + week(): number; + week(d: number): Moment; + weeks(): number; + weeks(d: number): Moment; + isoWeek(): number; + isoWeek(d: number): Moment; + isoWeeks(): number; + isoWeeks(d: number): Moment; + weeksInYear(): number; + isoWeeksInYear(): number; + dayOfYear(): number; + dayOfYear(d: number): Moment; + + from(f: Moment|string|number|Date|number[], suffix?: boolean): string; + to(f: Moment|string|number|Date|number[], suffix?: boolean): string; + toNow(withoutPrefix?: boolean): string; + + diff(b: Moment): number; + diff(b: Moment, unitOfTime: string): number; + diff(b: Moment, unitOfTime: string, round: boolean): number; + + toArray(): number[]; + toDate(): Date; + toISOString(): string; + toJSON(): string; + unix(): number; + + isLeapYear(): boolean; + zone(): number; + zone(b: number): Moment; + zone(b: string): Moment; + utcOffset(): number; + utcOffset(b: number): Moment; + utcOffset(b: string): Moment; + daysInMonth(): number; + isDST(): boolean; + + isBefore(): boolean; + isBefore(b: Moment|string|number|Date|number[], granularity?: string): boolean; + + isAfter(): boolean; + isAfter(b: Moment|string|number|Date|number[], granularity?: string): boolean; + + isSame(b: Moment|string|number|Date|number[], granularity?: string): boolean; + isBetween(a: Moment|string|number|Date|number[], b: Moment|string|number|Date|number[], granularity?: string): boolean; + + // Deprecated as of 2.8.0. + lang(language: string): Moment; + lang(reset: boolean): Moment; + lang(): MomentLanguage; + + locale(language: string): Moment; + locale(reset: boolean): Moment; + locale(): string; + + localeData(language: string): Moment; + localeData(reset: boolean): Moment; + localeData(): MomentLanguage; + + // Deprecated as of 2.7.0. + max(date: Moment|string|number|Date|any[]): Moment; + max(date: string, format: string): Moment; + + // Deprecated as of 2.7.0. + min(date: Moment|string|number|Date|any[]): Moment; + min(date: string, format: string): Moment; + + get(unit: string): number; + set(unit: string, value: number): Moment; + set(objectLiteral: MomentInput): Moment; + } + + type formatFunction = () => string; + + interface MomentCalendar { + lastDay?: string | formatFunction; + sameDay?: string | formatFunction; + nextDay?: string | formatFunction; + lastWeek?: string | formatFunction; + nextWeek?: string | formatFunction; + sameElse?: string | formatFunction; + } + + interface BaseMomentLanguage { + months ?: any; + monthsShort ?: any; + weekdays ?: any; + weekdaysShort ?: any; + weekdaysMin ?: any; + relativeTime ?: MomentRelativeTime; + meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string; + calendar ?: MomentCalendar; + ordinal ?: (num: number) => string; + } + + interface MomentLanguage extends BaseMomentLanguage { + longDateFormat?: MomentLongDateFormat; + } + + interface MomentLanguageData extends BaseMomentLanguage { + /** + * @param formatType should be L, LL, LLL, LLLL. + */ + longDateFormat(formatType: string): string; + } + + interface MomentLongDateFormat { + L: string; + LL: string; + LLL: string; + LLLL: string; + LT: string; + LTS: string; + l?: string; + ll?: string; + lll?: string; + llll?: string; + lt?: string; + lts?: string; + } + + interface MomentRelativeTime { + future: any; + past: any; + s: any; + m: any; + mm: any; + h: any; + hh: any; + d: any; + dd: any; + M: any; + MM: any; + y: any; + yy: any; + } + + interface MomentStatic { + version: string; + fn: Moment; + + (): Moment; + (date: number): Moment; + (date: number[]): Moment; + (date: string, format?: string, strict?: boolean): Moment; + (date: string, format?: string, language?: string, strict?: boolean): Moment; + (date: string, formats: string[], strict?: boolean): Moment; + (date: string, formats: string[], language?: string, strict?: boolean): Moment; + (date: string, specialFormat: () => void, strict?: boolean): Moment; + (date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment; + (date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment; + (date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment; + (date: Date): Moment; + (date: Moment): Moment; + (date: Object): Moment; + + utc(): Moment; + utc(date: number): Moment; + utc(date: number[]): Moment; + utc(date: string, format?: string, strict?: boolean): Moment; + utc(date: string, format?: string, language?: string, strict?: boolean): Moment; + utc(date: string, formats: string[], strict?: boolean): Moment; + utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; + utc(date: Date): Moment; + utc(date: Moment): Moment; + utc(date: Object): Moment; + + unix(timestamp: number): Moment; + + invalid(parsingFlags?: Object): Moment; + isMoment(): boolean; + isMoment(m: any): boolean; + isDate(m: any): boolean; + isDuration(): boolean; + isDuration(d: any): boolean; + + // Deprecated in 2.8.0. + lang(language?: string): string; + lang(language?: string, definition?: MomentLanguage): string; + + locale(language?: string): string; + locale(language?: string[]): string; + locale(language?: string, definition?: MomentLanguage): string; + + localeData(language?: string): MomentLanguageData; + + longDateFormat: any; + relativeTime: any; + meridiem: (hour: number, minute: number, isLowercase: boolean) => string; + calendar: any; + ordinal: (num: number) => string; + + duration(milliseconds: Number): Duration; + duration(num: Number, unitOfTime: string): Duration; + duration(input: MomentInput): Duration; + duration(object: any): Duration; + duration(): Duration; + + parseZone(date: string): Moment; + + months(): string[]; + months(index: number): string; + months(format: string): string[]; + months(format: string, index: number): string; + monthsShort(): string[]; + monthsShort(index: number): string; + monthsShort(format: string): string[]; + monthsShort(format: string, index: number): string; + + weekdays(): string[]; + weekdays(index: number): string; + weekdays(format: string): string[]; + weekdays(format: string, index: number): string; + weekdaysShort(): string[]; + weekdaysShort(index: number): string; + weekdaysShort(format: string): string[]; + weekdaysShort(format: string, index: number): string; + weekdaysMin(): string[]; + weekdaysMin(index: number): string; + weekdaysMin(format: string): string[]; + weekdaysMin(format: string, index: number): string; + + min(...moments: Moment[]): Moment; + max(...moments: Moment[]): Moment; + + normalizeUnits(unit: string): string; + relativeTimeThreshold(threshold: string): number|boolean; + relativeTimeThreshold(threshold: string, limit:number): boolean; + + /** + * Constant used to enable explicit ISO_8601 format parsing. + */ + ISO_8601(): void; + + defaultFormat: string; + } + +} + +declare module 'moment' { + var moment: moment.MomentStatic; + export = moment; +} diff --git a/typings/moment/moment.d.ts b/typings/moment/moment.d.ts new file mode 100644 index 0000000..78b0901 --- /dev/null +++ b/typings/moment/moment.d.ts @@ -0,0 +1,8 @@ +// Type definitions for Moment.js 2.8.0 +// Project: https://github.com/timrwood/moment +// Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare var moment: moment.MomentStatic; diff --git a/typings/node/node.d.ts b/typings/node/node.d.ts new file mode 100644 index 0000000..5a163f0 --- /dev/null +++ b/typings/node/node.d.ts @@ -0,0 +1,2088 @@ +// Type definitions for Node.js v4.x +// Project: http://nodejs.org/ +// Definitions by: Microsoft TypeScript , DefinitelyTyped +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/************************************************ +* * +* Node.js v4.x API * +* * +************************************************/ + +interface Error { + stack?: string; +} + + +// compat for TypeScript 1.5.3 +// if you use with --target es3 or --target es5 and use below definitions, +// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3. +interface MapConstructor {} +interface WeakMapConstructor {} +interface SetConstructor {} +interface WeakSetConstructor {} + +/************************************************ +* * +* GLOBAL * +* * +************************************************/ +declare var process: NodeJS.Process; +declare var global: NodeJS.Global; + +declare var __filename: string; +declare var __dirname: string; + +declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearTimeout(timeoutId: NodeJS.Timer): void; +declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearInterval(intervalId: NodeJS.Timer): void; +declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; +declare function clearImmediate(immediateId: any): void; + +interface NodeRequireFunction { + (id: string): any; +} + +interface NodeRequire extends NodeRequireFunction { + resolve(id:string): string; + cache: any; + extensions: any; + main: any; +} + +declare var require: NodeRequire; + +interface NodeModule { + exports: any; + require: NodeRequireFunction; + id: string; + filename: string; + loaded: boolean; + parent: any; + children: any[]; +} + +declare var module: NodeModule; + +// Same as module.exports +declare var exports: any; +declare var SlowBuffer: { + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (size: Uint8Array): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; + isBuffer(obj: any): boolean; + byteLength(string: string, encoding?: string): number; + concat(list: Buffer[], totalLength?: number): Buffer; +}; + + +// Buffer class +interface Buffer extends NodeBuffer {} + +/** + * Raw data is stored in instances of the Buffer class. + * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. + * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + */ +declare var Buffer: { + /** + * Allocates a new buffer containing the given {str}. + * + * @param str String to store in buffer. + * @param encoding encoding to use, optional. Default is 'utf8' + */ + new (str: string, encoding?: string): Buffer; + /** + * Allocates a new buffer of {size} octets. + * + * @param size count of octets to allocate. + */ + new (size: number): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + new (array: Uint8Array): Buffer; + /** + * Allocates a new buffer containing the given {array} of octets. + * + * @param array The octets to store. + */ + new (array: any[]): Buffer; + prototype: Buffer; + /** + * Returns true if {obj} is a Buffer + * + * @param obj object to test. + */ + isBuffer(obj: any): obj is Buffer; + /** + * Returns true if {encoding} is a valid encoding argument. + * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' + * + * @param encoding string to test. + */ + isEncoding(encoding: string): boolean; + /** + * Gives the actual byte length of a string. encoding defaults to 'utf8'. + * This is not the same as String.prototype.length since that returns the number of characters in a string. + * + * @param string string to test. + * @param encoding encoding used to evaluate (defaults to 'utf8') + */ + byteLength(string: string, encoding?: string): number; + /** + * Returns a buffer which is the result of concatenating all the buffers in the list together. + * + * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. + * If the list has exactly one item, then the first item of the list is returned. + * If the list has more than one item, then a new Buffer is created. + * + * @param list An array of Buffer objects to concatenate + * @param totalLength Total length of the buffers when concatenated. + * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. + */ + concat(list: Buffer[], totalLength?: number): Buffer; + /** + * The same as buf1.compare(buf2). + */ + compare(buf1: Buffer, buf2: Buffer): number; +}; + +/************************************************ +* * +* GLOBAL INTERFACES * +* * +************************************************/ +declare module NodeJS { + export interface ErrnoException extends Error { + errno?: number; + code?: string; + path?: string; + syscall?: string; + stack?: string; + } + + export interface EventEmitter { + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } + + export interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): string|Buffer; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: Buffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + } + + export interface WritableStream extends EventEmitter { + writable: boolean; + write(buffer: Buffer|string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } + + export interface ReadWriteStream extends ReadableStream, WritableStream {} + + export interface Process extends EventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: any; + exit(code?: number): void; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + openssl: string; + }; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid: number, signal?: string): void; + pid: number; + title: string; + arch: string; + platform: string; + memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; + nextTick(callback: Function): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?:number[]): number[]; + + // Worker + send?(message: any, sendHandle?: any): void; + } + + export interface Global { + Array: typeof Array; + ArrayBuffer: typeof ArrayBuffer; + Boolean: typeof Boolean; + Buffer: typeof Buffer; + DataView: typeof DataView; + Date: typeof Date; + Error: typeof Error; + EvalError: typeof EvalError; + Float32Array: typeof Float32Array; + Float64Array: typeof Float64Array; + Function: typeof Function; + GLOBAL: Global; + Infinity: typeof Infinity; + Int16Array: typeof Int16Array; + Int32Array: typeof Int32Array; + Int8Array: typeof Int8Array; + Intl: typeof Intl; + JSON: typeof JSON; + Map: MapConstructor; + Math: typeof Math; + NaN: typeof NaN; + Number: typeof Number; + Object: typeof Object; + Promise: Function; + RangeError: typeof RangeError; + ReferenceError: typeof ReferenceError; + RegExp: typeof RegExp; + Set: SetConstructor; + String: typeof String; + Symbol: Function; + SyntaxError: typeof SyntaxError; + TypeError: typeof TypeError; + URIError: typeof URIError; + Uint16Array: typeof Uint16Array; + Uint32Array: typeof Uint32Array; + Uint8Array: typeof Uint8Array; + Uint8ClampedArray: Function; + WeakMap: WeakMapConstructor; + WeakSet: WeakSetConstructor; + clearImmediate: (immediateId: any) => void; + clearInterval: (intervalId: NodeJS.Timer) => void; + clearTimeout: (timeoutId: NodeJS.Timer) => void; + console: typeof console; + decodeURI: typeof decodeURI; + decodeURIComponent: typeof decodeURIComponent; + encodeURI: typeof encodeURI; + encodeURIComponent: typeof encodeURIComponent; + escape: (str: string) => string; + eval: typeof eval; + global: Global; + isFinite: typeof isFinite; + isNaN: typeof isNaN; + parseFloat: typeof parseFloat; + parseInt: typeof parseInt; + process: Process; + root: Global; + setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; + setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; + undefined: typeof undefined; + unescape: (str: string) => string; + gc: () => void; + v8debug?: any; + } + + export interface Timer { + ref() : void; + unref() : void; + } +} + +/** + * @deprecated + */ +interface NodeBuffer { + [index: number]: number; + write(string: string, offset?: number, length?: number, encoding?: string): number; + toString(encoding?: string, start?: number, end?: number): string; + toJSON(): any; + length: number; + equals(otherBuffer: Buffer): boolean; + compare(otherBuffer: Buffer): number; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; + writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; + readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; + readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; + readUInt8(offset: number, noAsset?: boolean): number; + readUInt16LE(offset: number, noAssert?: boolean): number; + readUInt16BE(offset: number, noAssert?: boolean): number; + readUInt32LE(offset: number, noAssert?: boolean): number; + readUInt32BE(offset: number, noAssert?: boolean): number; + readInt8(offset: number, noAssert?: boolean): number; + readInt16LE(offset: number, noAssert?: boolean): number; + readInt16BE(offset: number, noAssert?: boolean): number; + readInt32LE(offset: number, noAssert?: boolean): number; + readInt32BE(offset: number, noAssert?: boolean): number; + readFloatLE(offset: number, noAssert?: boolean): number; + readFloatBE(offset: number, noAssert?: boolean): number; + readDoubleLE(offset: number, noAssert?: boolean): number; + readDoubleBE(offset: number, noAssert?: boolean): number; + writeUInt8(value: number, offset: number, noAssert?: boolean): number; + writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeInt8(value: number, offset: number, noAssert?: boolean): number; + writeInt16LE(value: number, offset: number, noAssert?: boolean): number; + writeInt16BE(value: number, offset: number, noAssert?: boolean): number; + writeInt32LE(value: number, offset: number, noAssert?: boolean): number; + writeInt32BE(value: number, offset: number, noAssert?: boolean): number; + writeFloatLE(value: number, offset: number, noAssert?: boolean): number; + writeFloatBE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; + writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; + fill(value: any, offset?: number, end?: number): Buffer; +} + +/************************************************ +* * +* MODULES * +* * +************************************************/ +declare module "buffer" { + export var INSPECT_MAX_BYTES: number; +} + +declare module "querystring" { + export function stringify(obj: any, sep?: string, eq?: string): string; + export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; + export function escape(str: string): string; + export function unescape(str: string): string; +} + +declare module "events" { + export class EventEmitter implements NodeJS.EventEmitter { + static listenerCount(emitter: EventEmitter, event: string): number; + + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } +} + +declare module "http" { + import * as events from "events"; + import * as net from "net"; + import * as stream from "stream"; + + export interface RequestOptions { + protocol?: string; + host?: string; + hostname?: string; + family?: number; + port?: number + localAddress?: string; + socketPath?: string; + method?: string; + path?: string; + headers?: { [key: string]: any }; + auth?: string; + agent?: Agent; + } + + export interface Server extends events.EventEmitter { + listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; + listen(port: number, hostname?: string, callback?: Function): Server; + listen(path: string, callback?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + close(cb?: any): Server; + address(): { port: number; family: string; address: string; }; + maxHeadersCount: number; + } + /** + * @deprecated Use IncomingMessage + */ + export interface ServerRequest extends IncomingMessage { + connection: net.Socket; + } + export interface ServerResponse extends events.EventEmitter, stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + writeContinue(): void; + writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; + writeHead(statusCode: number, headers?: any): void; + statusCode: number; + statusMessage: string; + setHeader(name: string, value: string): void; + sendDate: boolean; + getHeader(name: string): string; + removeHeader(name: string): void; + write(chunk: any, encoding?: string): any; + addTrailers(headers: any): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + export interface ClientRequest extends events.EventEmitter, stream.Writable { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + write(chunk: any, encoding?: string): void; + abort(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + export interface IncomingMessage extends events.EventEmitter, stream.Readable { + httpVersion: string; + headers: any; + rawHeaders: string[]; + trailers: any; + rawTrailers: any; + setTimeout(msecs: number, callback: Function): NodeJS.Timer; + /** + * Only valid for request obtained from http.Server. + */ + method?: string; + /** + * Only valid for request obtained from http.Server. + */ + url?: string; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusCode?: number; + /** + * Only valid for response obtained from http.ClientRequest. + */ + statusMessage?: string; + socket: net.Socket; + } + /** + * @deprecated Use IncomingMessage + */ + export interface ClientResponse extends IncomingMessage { } + + export interface AgentOptions { + /** + * Keep sockets around in a pool to be used by other requests in the future. Default = false + */ + keepAlive?: boolean; + /** + * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. + * Only relevant if keepAlive is set to true. + */ + keepAliveMsecs?: number; + /** + * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity + */ + maxSockets?: number; + /** + * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. + */ + maxFreeSockets?: number; + } + + export class Agent { + maxSockets: number; + sockets: any; + requests: any; + + constructor(opts?: AgentOptions); + + /** + * Destroy any sockets that are currently in use by the agent. + * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, + * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, + * sockets may hang open for quite a long time before the server terminates them. + */ + destroy(): void; + } + + export var METHODS: string[]; + + export var STATUS_CODES: { + [errorCode: number]: string; + [errorCode: string]: string; + }; + export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server; + export function createClient(port?: number, host?: string): any; + export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; + export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; + export var globalAgent: Agent; +} + +declare module "cluster" { + import * as child from "child_process"; + import * as events from "events"; + + export interface ClusterSettings { + exec?: string; + args?: string[]; + silent?: boolean; + } + + export class Worker extends events.EventEmitter { + id: string; + process: child.ChildProcess; + suicide: boolean; + send(message: any, sendHandle?: any): void; + kill(signal?: string): void; + destroy(signal?: string): void; + disconnect(): void; + } + + export var settings: ClusterSettings; + export var isMaster: boolean; + export var isWorker: boolean; + export function setupMaster(settings?: ClusterSettings): void; + export function fork(env?: any): Worker; + export function disconnect(callback?: Function): void; + export var worker: Worker; + export var workers: Worker[]; + + // Event emitter + export function addListener(event: string, listener: Function): void; + export function on(event: string, listener: Function): any; + export function once(event: string, listener: Function): void; + export function removeListener(event: string, listener: Function): void; + export function removeAllListeners(event?: string): void; + export function setMaxListeners(n: number): void; + export function listeners(event: string): Function[]; + export function emit(event: string, ...args: any[]): boolean; +} + +declare module "zlib" { + import * as stream from "stream"; + export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } + + export interface Gzip extends stream.Transform { } + export interface Gunzip extends stream.Transform { } + export interface Deflate extends stream.Transform { } + export interface Inflate extends stream.Transform { } + export interface DeflateRaw extends stream.Transform { } + export interface InflateRaw extends stream.Transform { } + export interface Unzip extends stream.Transform { } + + export function createGzip(options?: ZlibOptions): Gzip; + export function createGunzip(options?: ZlibOptions): Gunzip; + export function createDeflate(options?: ZlibOptions): Deflate; + export function createInflate(options?: ZlibOptions): Inflate; + export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; + export function createInflateRaw(options?: ZlibOptions): InflateRaw; + export function createUnzip(options?: ZlibOptions): Unzip; + + export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function deflateSync(buf: Buffer, options?: ZlibOptions): any; + export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any; + export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gzipSync(buf: Buffer, options?: ZlibOptions): any; + export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gunzipSync(buf: Buffer, options?: ZlibOptions): any; + export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflateSync(buf: Buffer, options?: ZlibOptions): any; + export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any; + export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function unzipSync(buf: Buffer, options?: ZlibOptions): any; + + // Constants + export var Z_NO_FLUSH: number; + export var Z_PARTIAL_FLUSH: number; + export var Z_SYNC_FLUSH: number; + export var Z_FULL_FLUSH: number; + export var Z_FINISH: number; + export var Z_BLOCK: number; + export var Z_TREES: number; + export var Z_OK: number; + export var Z_STREAM_END: number; + export var Z_NEED_DICT: number; + export var Z_ERRNO: number; + export var Z_STREAM_ERROR: number; + export var Z_DATA_ERROR: number; + export var Z_MEM_ERROR: number; + export var Z_BUF_ERROR: number; + export var Z_VERSION_ERROR: number; + export var Z_NO_COMPRESSION: number; + export var Z_BEST_SPEED: number; + export var Z_BEST_COMPRESSION: number; + export var Z_DEFAULT_COMPRESSION: number; + export var Z_FILTERED: number; + export var Z_HUFFMAN_ONLY: number; + export var Z_RLE: number; + export var Z_FIXED: number; + export var Z_DEFAULT_STRATEGY: number; + export var Z_BINARY: number; + export var Z_TEXT: number; + export var Z_ASCII: number; + export var Z_UNKNOWN: number; + export var Z_DEFLATED: number; + export var Z_NULL: number; +} + +declare module "os" { + export function tmpdir(): string; + export function hostname(): string; + export function type(): string; + export function platform(): string; + export function arch(): string; + export function release(): string; + export function uptime(): number; + export function loadavg(): number[]; + export function totalmem(): number; + export function freemem(): number; + export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[]; + export function networkInterfaces(): any; + export var EOL: string; +} + +declare module "https" { + import * as tls from "tls"; + import * as events from "events"; + import * as http from "http"; + + export interface ServerOptions { + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + crl?: any; + ciphers?: string; + honorCipherOrder?: boolean; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; + SNICallback?: (servername: string) => any; + } + + export interface RequestOptions extends http.RequestOptions{ + pfx?: any; + key?: any; + passphrase?: string; + cert?: any; + ca?: any; + ciphers?: string; + rejectUnauthorized?: boolean; + secureProtocol?: string; + } + + export interface Agent { + maxSockets: number; + sockets: any; + requests: any; + } + export var Agent: { + new (options?: RequestOptions): Agent; + }; + export interface Server extends tls.Server { } + export function createServer(options: ServerOptions, requestListener?: Function): Server; + export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; + export var globalAgent: Agent; +} + +declare module "punycode" { + export function decode(string: string): string; + export function encode(string: string): string; + export function toUnicode(domain: string): string; + export function toASCII(domain: string): string; + export var ucs2: ucs2; + interface ucs2 { + decode(string: string): number[]; + encode(codePoints: number[]): string; + } + export var version: any; +} + +declare module "repl" { + import * as stream from "stream"; + import * as events from "events"; + + export interface ReplOptions { + prompt?: string; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; + terminal?: boolean; + eval?: Function; + useColors?: boolean; + useGlobal?: boolean; + ignoreUndefined?: boolean; + writer?: Function; + } + export function start(options: ReplOptions): events.EventEmitter; +} + +declare module "readline" { + import * as events from "events"; + import * as stream from "stream"; + + export interface ReadLine extends events.EventEmitter { + setPrompt(prompt: string): void; + prompt(preserveCursor?: boolean): void; + question(query: string, callback: Function): void; + pause(): void; + resume(): void; + close(): void; + write(data: any, key?: any): void; + } + export interface ReadLineOptions { + input: NodeJS.ReadableStream; + output: NodeJS.WritableStream; + completer?: Function; + terminal?: boolean; + } + export function createInterface(options: ReadLineOptions): ReadLine; +} + +declare module "vm" { + export interface Context { } + export interface Script { + runInThisContext(): void; + runInNewContext(sandbox?: Context): void; + } + export function runInThisContext(code: string, filename?: string): void; + export function runInNewContext(code: string, sandbox?: Context, filename?: string): void; + export function runInContext(code: string, context: Context, filename?: string): void; + export function createContext(initSandbox?: Context): Context; + export function createScript(code: string, filename?: string): Script; +} + +declare module "child_process" { + import * as events from "events"; + import * as stream from "stream"; + + export interface ChildProcess extends events.EventEmitter { + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; + pid: number; + kill(signal?: string): void; + send(message: any, sendHandle?: any): void; + disconnect(): void; + unref(): void; + } + + export function spawn(command: string, args?: string[], options?: { + cwd?: string; + stdio?: any; + custom?: any; + env?: any; + detached?: boolean; + }): ChildProcess; + export function exec(command: string, options: { + cwd?: string; + stdio?: any; + customFds?: any; + env?: any; + encoding?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, + callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, args?: string[], + callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function execFile(file: string, args?: string[], options?: { + cwd?: string; + stdio?: any; + customFds?: any; + env?: any; + encoding?: string; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function fork(modulePath: string, args?: string[], options?: { + cwd?: string; + env?: any; + encoding?: string; + }): ChildProcess; + export function spawnSync(command: string, args?: string[], options?: { + cwd?: string; + input?: string | Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + encoding?: string; + }): { + pid: number; + output: string[]; + stdout: string | Buffer; + stderr: string | Buffer; + status: number; + signal: string; + error: Error; + }; + export function execSync(command: string, options?: { + cwd?: string; + input?: string|Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + encoding?: string; + }): string | Buffer; + export function execFileSync(command: string, args?: string[], options?: { + cwd?: string; + input?: string|Buffer; + stdio?: any; + env?: any; + uid?: number; + gid?: number; + timeout?: number; + maxBuffer?: number; + killSignal?: string; + encoding?: string; + }): string | Buffer; +} + +declare module "url" { + export interface Url { + href?: string; + protocol?: string; + auth?: string; + hostname?: string; + port?: string; + host?: string; + pathname?: string; + search?: string; + query?: any; // string | Object + slashes?: boolean; + hash?: string; + path?: string; + } + + export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; + export function format(url: Url): string; + export function resolve(from: string, to: string): string; +} + +declare module "dns" { + export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; + export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; + export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; + export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; +} + +declare module "net" { + import * as stream from "stream"; + + export interface Socket extends stream.Duplex { + // Extended base methods + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + + connect(port: number, host?: string, connectionListener?: Function): void; + connect(path: string, connectionListener?: Function): void; + bufferSize: number; + setEncoding(encoding?: string): void; + write(data: any, encoding?: string, callback?: Function): void; + destroy(): void; + pause(): void; + resume(): void; + setTimeout(timeout: number, callback?: Function): void; + setNoDelay(noDelay?: boolean): void; + setKeepAlive(enable?: boolean, initialDelay?: number): void; + address(): { port: number; family: string; address: string; }; + unref(): void; + ref(): void; + + remoteAddress: string; + remoteFamily: string; + remotePort: number; + localAddress: string; + localPort: number; + bytesRead: number; + bytesWritten: number; + + // Extended base methods + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + end(data?: any, encoding?: string): void; + } + + export var Socket: { + new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; + }; + + export interface Server extends Socket { + listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; + listen(path: string, listeningListener?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + close(callback?: Function): Server; + address(): { port: number; family: string; address: string; }; + maxConnections: number; + connections: number; + } + export function createServer(connectionListener?: (socket: Socket) =>void ): Server; + export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server; + export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function connect(port: number, host?: string, connectionListener?: Function): Socket; + export function connect(path: string, connectionListener?: Function): Socket; + export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; + export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; + export function createConnection(path: string, connectionListener?: Function): Socket; + export function isIP(input: string): number; + export function isIPv4(input: string): boolean; + export function isIPv6(input: string): boolean; +} + +declare module "dgram" { + import * as events from "events"; + + interface RemoteInfo { + address: string; + port: number; + size: number; + } + + interface AddressInfo { + address: string; + family: string; + port: number; + } + + export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; + + interface Socket extends events.EventEmitter { + send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; + bind(port: number, address?: string, callback?: () => void): void; + close(): void; + address(): AddressInfo; + setBroadcast(flag: boolean): void; + setMulticastTTL(ttl: number): void; + setMulticastLoopback(flag: boolean): void; + addMembership(multicastAddress: string, multicastInterface?: string): void; + dropMembership(multicastAddress: string, multicastInterface?: string): void; + } +} + +declare module "fs" { + import * as stream from "stream"; + import * as events from "events"; + + interface Stats { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; + atime: Date; + mtime: Date; + ctime: Date; + birthtime: Date; + } + + interface FSWatcher extends events.EventEmitter { + close(): void; + } + + export interface ReadStream extends stream.Readable { + close(): void; + } + export interface WriteStream extends stream.Writable { + close(): void; + bytesWritten: number; + } + + /** + * Asynchronous rename. + * @param oldPath + * @param newPath + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /** + * Synchronous rename + * @param oldPath + * @param newPath + */ + export function renameSync(oldPath: string, newPath: string): void; + export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncateSync(path: string, len?: number): void; + export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncateSync(fd: number, len?: number): void; + export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chownSync(path: string, uid: number, gid: number): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchownSync(fd: number, uid: number, gid: number): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchownSync(path: string, uid: number, gid: number): void; + export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmodSync(path: string, mode: number): void; + export function chmodSync(path: string, mode: string): void; + export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmodSync(fd: number, mode: number): void; + export function fchmodSync(fd: number, mode: string): void; + export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmodSync(path: string, mode: number): void; + export function lchmodSync(path: string, mode: string): void; + export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function statSync(path: string): Stats; + export function lstatSync(path: string): Stats; + export function fstatSync(fd: number): Stats; + export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function linkSync(srcpath: string, dstpath: string): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; + export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; + export function readlinkSync(path: string): string; + export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; + export function realpathSync(path: string, cache?: { [path: string]: string }): string; + /* + * Asynchronous unlink - deletes the file specified in {path} + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous unlink - deletes the file specified in {path} + * + * @param path + */ + export function unlinkSync(path: string): void; + /* + * Asynchronous rmdir - removes the directory specified in {path} + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous rmdir - removes the directory specified in {path} + * + * @param path + */ + export function rmdirSync(path: string): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + /* + * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdirSync(path: string, mode?: number): void; + /* + * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. + * + * @param path + * @param mode + * @param callback No arguments other than a possible exception are given to the completion callback. + */ + export function mkdirSync(path: string, mode?: string): void; + export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; + export function readdirSync(path: string): string[]; + export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function closeSync(fd: number): void; + export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function openSync(path: string, flags: string, mode?: number): number; + export function openSync(path: string, flags: string, mode?: string): number; + export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function utimesSync(path: string, atime: number, mtime: number): void; + export function utimesSync(path: string, atime: Date, mtime: Date): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function futimesSync(fd: number, atime: number, mtime: number): void; + export function futimesSync(fd: number, atime: Date, mtime: Date): void; + export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fsyncSync(fd: number): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; + export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param encoding + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + /* + * Asynchronous readFile - Asynchronously reads the entire contents of a file. + * + * @param fileName + * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. + */ + export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param encoding + */ + export function readFileSync(filename: string, encoding: string): string; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. + */ + export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; + /* + * Synchronous readFile - Synchronously reads the entire contents of a file. + * + * @param fileName + * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. + */ + export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; + export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; + export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; + export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; + export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; + export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; + export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; + export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; + export function exists(path: string, callback?: (exists: boolean) => void): void; + export function existsSync(path: string): boolean; + /** Constant for fs.access(). File is visible to the calling process. */ + export var F_OK: number; + /** Constant for fs.access(). File can be read by the calling process. */ + export var R_OK: number; + /** Constant for fs.access(). File can be written by the calling process. */ + export var W_OK: number; + /** Constant for fs.access(). File can be executed by the calling process. */ + export var X_OK: number; + /** Tests a user's permissions for the file specified by path. */ + export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void; + export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; + /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ + export function accessSync(path: string, mode ?: number): void; + export function createReadStream(path: string, options?: { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + }): ReadStream; + export function createWriteStream(path: string, options?: { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + }): WriteStream; +} + +declare module "path" { + + /** + * A parsed path object generated by path.parse() or consumed by path.format(). + */ + export interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } + + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param p string path to normalize. + */ + export function normalize(p: string): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: any[]): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: string[]): string; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} paramter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param pathSegments string paths to join. Non-string arguments are ignored. + */ + export function resolve(...pathSegments: any[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * @param path path to test. + */ + export function isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to}. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @param from + * @param to + */ + export function relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param p the path to evaluate. + */ + export function dirname(p: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param p the path to evaluate. + * @param ext optionally, an extension to remove from the result. + */ + export function basename(p: string, ext?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string + * + * @param p the path to evaluate. + */ + export function extname(p: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ + export var sep: string; + /** + * The platform-specific file delimiter. ';' or ':'. + */ + export var delimiter: string; + /** + * Returns an object from a path string - the opposite of format(). + * + * @param pathString path to evaluate. + */ + export function parse(pathString: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathString path to evaluate. + */ + export function format(pathObject: ParsedPath): string; + + export module posix { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } + + export module win32 { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } +} + +declare module "string_decoder" { + export interface NodeStringDecoder { + write(buffer: Buffer): string; + detectIncompleteChar(buffer: Buffer): number; + } + export var StringDecoder: { + new (encoding: string): NodeStringDecoder; + }; +} + +declare module "tls" { + import * as crypto from "crypto"; + import * as net from "net"; + import * as stream from "stream"; + + var CLIENT_RENEG_LIMIT: number; + var CLIENT_RENEG_WINDOW: number; + + export interface TlsOptions { + pfx?: any; //string or buffer + key?: any; //string or buffer + passphrase?: string; + cert?: any; + ca?: any; //string or buffer + crl?: any; //string or string array + ciphers?: string; + honorCipherOrder?: any; + requestCert?: boolean; + rejectUnauthorized?: boolean; + NPNProtocols?: any; //array or Buffer; + SNICallback?: (servername: string) => any; + } + + export interface ConnectionOptions { + host?: string; + port?: number; + socket?: net.Socket; + pfx?: any; //string | Buffer + key?: any; //string | Buffer + passphrase?: string; + cert?: any; //string | Buffer + ca?: any; //Array of string | Buffer + rejectUnauthorized?: boolean; + NPNProtocols?: any; //Array of string | Buffer + servername?: string; + } + + export interface Server extends net.Server { + // Extended base methods + listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; + listen(path: string, listeningListener?: Function): Server; + listen(handle: any, listeningListener?: Function): Server; + + listen(port: number, host?: string, callback?: Function): Server; + close(): Server; + address(): { port: number; family: string; address: string; }; + addContext(hostName: string, credentials: { + key: string; + cert: string; + ca: string; + }): void; + maxConnections: number; + connections: number; + } + + export interface ClearTextStream extends stream.Duplex { + authorized: boolean; + authorizationError: Error; + getPeerCertificate(): any; + getCipher: { + name: string; + version: string; + }; + address: { + port: number; + family: string; + address: string; + }; + remoteAddress: string; + remotePort: number; + } + + export interface SecurePair { + encrypted: any; + cleartext: any; + } + + export interface SecureContextOptions { + pfx?: any; //string | buffer + key?: any; //string | buffer + passphrase?: string; + cert?: any; // string | buffer + ca?: any; // string | buffer + crl?: any; // string | string[] + ciphers?: string; + honorCipherOrder?: boolean; + } + + export interface SecureContext { + context: any; + } + + export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; + export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; + export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; + export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; + export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; + export function createSecureContext(details: SecureContextOptions): SecureContext; +} + +declare module "crypto" { + export interface CredentialDetails { + pfx: string; + key: string; + passphrase: string; + cert: string; + ca: any; //string | string array + crl: any; //string | string array + ciphers: string; + } + export interface Credentials { context?: any; } + export function createCredentials(details: CredentialDetails): Credentials; + export function createHash(algorithm: string): Hash; + export function createHmac(algorithm: string, key: string): Hmac; + export function createHmac(algorithm: string, key: Buffer): Hmac; + interface Hash { + update(data: any, input_encoding?: string): Hash; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): any; + digest(): Buffer; + } + interface Hmac { + update(data: any, input_encoding?: string): Hmac; + digest(encoding: 'buffer'): Buffer; + digest(encoding: string): any; + digest(): Buffer; + } + export function createCipher(algorithm: string, password: any): Cipher; + export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; + interface Cipher { + update(data: Buffer): Buffer; + update(data: string, input_encoding?: string, output_encoding?: string): string; + final(): Buffer; + final(output_encoding: string): string; + setAutoPadding(auto_padding: boolean): void; + } + export function createDecipher(algorithm: string, password: any): Decipher; + export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; + interface Decipher { + update(data: Buffer): Buffer; + update(data: string, input_encoding?: string, output_encoding?: string): string; + final(): Buffer; + final(output_encoding: string): string; + setAutoPadding(auto_padding: boolean): void; + } + export function createSign(algorithm: string): Signer; + interface Signer extends NodeJS.WritableStream { + update(data: any): void; + sign(private_key: string, output_format: string): string; + } + export function createVerify(algorith: string): Verify; + interface Verify extends NodeJS.WritableStream { + update(data: any): void; + verify(object: string, signature: string, signature_format?: string): boolean; + } + export function createDiffieHellman(prime_length: number): DiffieHellman; + export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; + interface DiffieHellman { + generateKeys(encoding?: string): string; + computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; + getPrime(encoding?: string): string; + getGenerator(encoding: string): string; + getPublicKey(encoding?: string): string; + getPrivateKey(encoding?: string): string; + setPublicKey(public_key: string, encoding?: string): void; + setPrivateKey(public_key: string, encoding?: string): void; + } + export function getDiffieHellman(group_name: string): DiffieHellman; + export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; + export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; + export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer; + export function randomBytes(size: number): Buffer; + export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; + export function pseudoRandomBytes(size: number): Buffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; +} + +declare module "stream" { + import * as events from "events"; + + export interface Stream extends events.EventEmitter { + pipe(destination: T, options?: { end?: boolean; }): T; + } + + export interface ReadableOptions { + highWaterMark?: number; + encoding?: string; + objectMode?: boolean; + } + + export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { + readable: boolean; + constructor(opts?: ReadableOptions); + _read(size: number): void; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + } + + export interface WritableOptions { + highWaterMark?: number; + decodeStrings?: boolean; + objectMode?: boolean; + } + + export class Writable extends events.EventEmitter implements NodeJS.WritableStream { + writable: boolean; + constructor(opts?: WritableOptions); + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export interface DuplexOptions extends ReadableOptions, WritableOptions { + allowHalfOpen?: boolean; + } + + // Note: Duplex extends both Readable and Writable. + export class Duplex extends Readable implements NodeJS.ReadWriteStream { + writable: boolean; + constructor(opts?: DuplexOptions); + _write(chunk: any, encoding: string, callback: Function): void; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export interface TransformOptions extends ReadableOptions, WritableOptions {} + + // Note: Transform lacks the _read and _write methods of Readable/Writable. + export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { + readable: boolean; + writable: boolean; + constructor(opts?: TransformOptions); + _transform(chunk: any, encoding: string, callback: Function): void; + _flush(callback: Function): void; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: any): void; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; + push(chunk: any, encoding?: string): boolean; + write(chunk: any, cb?: Function): boolean; + write(chunk: any, encoding?: string, cb?: Function): boolean; + end(): void; + end(chunk: any, cb?: Function): void; + end(chunk: any, encoding?: string, cb?: Function): void; + } + + export class PassThrough extends Transform {} +} + +declare module "util" { + export interface InspectOptions { + showHidden?: boolean; + depth?: number; + colors?: boolean; + customInspect?: boolean; + } + + export function format(format: any, ...param: any[]): string; + export function debug(string: string): void; + export function error(...param: any[]): void; + export function puts(...param: any[]): void; + export function print(...param: any[]): void; + export function log(string: string): void; + export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; + export function inspect(object: any, options: InspectOptions): string; + export function isArray(object: any): boolean; + export function isRegExp(object: any): boolean; + export function isDate(object: any): boolean; + export function isError(object: any): boolean; + export function inherits(constructor: any, superConstructor: any): void; + export function debuglog(key:string): (msg:string,...param: any[])=>void; +} + +declare module "assert" { + function internal (value: any, message?: string): void; + module internal { + export class AssertionError implements Error { + name: string; + message: string; + actual: any; + expected: any; + operator: string; + generatedMessage: boolean; + + constructor(options?: {message?: string; actual?: any; expected?: any; + operator?: string; stackStartFunction?: Function}); + } + + export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; + export function ok(value: any, message?: string): void; + export function equal(actual: any, expected: any, message?: string): void; + export function notEqual(actual: any, expected: any, message?: string): void; + export function deepEqual(actual: any, expected: any, message?: string): void; + export function notDeepEqual(acutal: any, expected: any, message?: string): void; + export function strictEqual(actual: any, expected: any, message?: string): void; + export function notStrictEqual(actual: any, expected: any, message?: string): void; + export var throws: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export var doesNotThrow: { + (block: Function, message?: string): void; + (block: Function, error: Function, message?: string): void; + (block: Function, error: RegExp, message?: string): void; + (block: Function, error: (err: any) => boolean, message?: string): void; + }; + + export function ifError(value: any): void; + } + + export = internal; +} + +declare module "tty" { + import * as net from "net"; + + export function isatty(fd: number): boolean; + export interface ReadStream extends net.Socket { + isRaw: boolean; + setRawMode(mode: boolean): void; + } + export interface WriteStream extends net.Socket { + columns: number; + rows: number; + } +} + +declare module "domain" { + import * as events from "events"; + + export class Domain extends events.EventEmitter { + run(fn: Function): void; + add(emitter: events.EventEmitter): void; + remove(emitter: events.EventEmitter): void; + bind(cb: (err: Error, data: any) => any): any; + intercept(cb: (data: any) => any): any; + dispose(): void; + + addListener(event: string, listener: Function): Domain; + on(event: string, listener: Function): Domain; + once(event: string, listener: Function): Domain; + removeListener(event: string, listener: Function): Domain; + removeAllListeners(event?: string): Domain; + } + + export function create(): Domain; +} + +declare module "constants" { + export var E2BIG: number; + export var EACCES: number; + export var EADDRINUSE: number; + export var EADDRNOTAVAIL: number; + export var EAFNOSUPPORT: number; + export var EAGAIN: number; + export var EALREADY: number; + export var EBADF: number; + export var EBADMSG: number; + export var EBUSY: number; + export var ECANCELED: number; + export var ECHILD: number; + export var ECONNABORTED: number; + export var ECONNREFUSED: number; + export var ECONNRESET: number; + export var EDEADLK: number; + export var EDESTADDRREQ: number; + export var EDOM: number; + export var EEXIST: number; + export var EFAULT: number; + export var EFBIG: number; + export var EHOSTUNREACH: number; + export var EIDRM: number; + export var EILSEQ: number; + export var EINPROGRESS: number; + export var EINTR: number; + export var EINVAL: number; + export var EIO: number; + export var EISCONN: number; + export var EISDIR: number; + export var ELOOP: number; + export var EMFILE: number; + export var EMLINK: number; + export var EMSGSIZE: number; + export var ENAMETOOLONG: number; + export var ENETDOWN: number; + export var ENETRESET: number; + export var ENETUNREACH: number; + export var ENFILE: number; + export var ENOBUFS: number; + export var ENODATA: number; + export var ENODEV: number; + export var ENOENT: number; + export var ENOEXEC: number; + export var ENOLCK: number; + export var ENOLINK: number; + export var ENOMEM: number; + export var ENOMSG: number; + export var ENOPROTOOPT: number; + export var ENOSPC: number; + export var ENOSR: number; + export var ENOSTR: number; + export var ENOSYS: number; + export var ENOTCONN: number; + export var ENOTDIR: number; + export var ENOTEMPTY: number; + export var ENOTSOCK: number; + export var ENOTSUP: number; + export var ENOTTY: number; + export var ENXIO: number; + export var EOPNOTSUPP: number; + export var EOVERFLOW: number; + export var EPERM: number; + export var EPIPE: number; + export var EPROTO: number; + export var EPROTONOSUPPORT: number; + export var EPROTOTYPE: number; + export var ERANGE: number; + export var EROFS: number; + export var ESPIPE: number; + export var ESRCH: number; + export var ETIME: number; + export var ETIMEDOUT: number; + export var ETXTBSY: number; + export var EWOULDBLOCK: number; + export var EXDEV: number; + export var WSAEINTR: number; + export var WSAEBADF: number; + export var WSAEACCES: number; + export var WSAEFAULT: number; + export var WSAEINVAL: number; + export var WSAEMFILE: number; + export var WSAEWOULDBLOCK: number; + export var WSAEINPROGRESS: number; + export var WSAEALREADY: number; + export var WSAENOTSOCK: number; + export var WSAEDESTADDRREQ: number; + export var WSAEMSGSIZE: number; + export var WSAEPROTOTYPE: number; + export var WSAENOPROTOOPT: number; + export var WSAEPROTONOSUPPORT: number; + export var WSAESOCKTNOSUPPORT: number; + export var WSAEOPNOTSUPP: number; + export var WSAEPFNOSUPPORT: number; + export var WSAEAFNOSUPPORT: number; + export var WSAEADDRINUSE: number; + export var WSAEADDRNOTAVAIL: number; + export var WSAENETDOWN: number; + export var WSAENETUNREACH: number; + export var WSAENETRESET: number; + export var WSAECONNABORTED: number; + export var WSAECONNRESET: number; + export var WSAENOBUFS: number; + export var WSAEISCONN: number; + export var WSAENOTCONN: number; + export var WSAESHUTDOWN: number; + export var WSAETOOMANYREFS: number; + export var WSAETIMEDOUT: number; + export var WSAECONNREFUSED: number; + export var WSAELOOP: number; + export var WSAENAMETOOLONG: number; + export var WSAEHOSTDOWN: number; + export var WSAEHOSTUNREACH: number; + export var WSAENOTEMPTY: number; + export var WSAEPROCLIM: number; + export var WSAEUSERS: number; + export var WSAEDQUOT: number; + export var WSAESTALE: number; + export var WSAEREMOTE: number; + export var WSASYSNOTREADY: number; + export var WSAVERNOTSUPPORTED: number; + export var WSANOTINITIALISED: number; + export var WSAEDISCON: number; + export var WSAENOMORE: number; + export var WSAECANCELLED: number; + export var WSAEINVALIDPROCTABLE: number; + export var WSAEINVALIDPROVIDER: number; + export var WSAEPROVIDERFAILEDINIT: number; + export var WSASYSCALLFAILURE: number; + export var WSASERVICE_NOT_FOUND: number; + export var WSATYPE_NOT_FOUND: number; + export var WSA_E_NO_MORE: number; + export var WSA_E_CANCELLED: number; + export var WSAEREFUSED: number; + export var SIGHUP: number; + export var SIGINT: number; + export var SIGILL: number; + export var SIGABRT: number; + export var SIGFPE: number; + export var SIGKILL: number; + export var SIGSEGV: number; + export var SIGTERM: number; + export var SIGBREAK: number; + export var SIGWINCH: number; + export var SSL_OP_ALL: number; + export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; + export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; + export var SSL_OP_CISCO_ANYCONNECT: number; + export var SSL_OP_COOKIE_EXCHANGE: number; + export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; + export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; + export var SSL_OP_EPHEMERAL_RSA: number; + export var SSL_OP_LEGACY_SERVER_CONNECT: number; + export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; + export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; + export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; + export var SSL_OP_NETSCAPE_CA_DN_BUG: number; + export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; + export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; + export var SSL_OP_NO_COMPRESSION: number; + export var SSL_OP_NO_QUERY_MTU: number; + export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; + export var SSL_OP_NO_SSLv2: number; + export var SSL_OP_NO_SSLv3: number; + export var SSL_OP_NO_TICKET: number; + export var SSL_OP_NO_TLSv1: number; + export var SSL_OP_NO_TLSv1_1: number; + export var SSL_OP_NO_TLSv1_2: number; + export var SSL_OP_PKCS1_CHECK_1: number; + export var SSL_OP_PKCS1_CHECK_2: number; + export var SSL_OP_SINGLE_DH_USE: number; + export var SSL_OP_SINGLE_ECDH_USE: number; + export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; + export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; + export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; + export var SSL_OP_TLS_D5_BUG: number; + export var SSL_OP_TLS_ROLLBACK_BUG: number; + export var ENGINE_METHOD_DSA: number; + export var ENGINE_METHOD_DH: number; + export var ENGINE_METHOD_RAND: number; + export var ENGINE_METHOD_ECDH: number; + export var ENGINE_METHOD_ECDSA: number; + export var ENGINE_METHOD_CIPHERS: number; + export var ENGINE_METHOD_DIGESTS: number; + export var ENGINE_METHOD_STORE: number; + export var ENGINE_METHOD_PKEY_METHS: number; + export var ENGINE_METHOD_PKEY_ASN1_METHS: number; + export var ENGINE_METHOD_ALL: number; + export var ENGINE_METHOD_NONE: number; + export var DH_CHECK_P_NOT_SAFE_PRIME: number; + export var DH_CHECK_P_NOT_PRIME: number; + export var DH_UNABLE_TO_CHECK_GENERATOR: number; + export var DH_NOT_SUITABLE_GENERATOR: number; + export var NPN_ENABLED: number; + export var RSA_PKCS1_PADDING: number; + export var RSA_SSLV23_PADDING: number; + export var RSA_NO_PADDING: number; + export var RSA_PKCS1_OAEP_PADDING: number; + export var RSA_X931_PADDING: number; + export var RSA_PKCS1_PSS_PADDING: number; + export var POINT_CONVERSION_COMPRESSED: number; + export var POINT_CONVERSION_UNCOMPRESSED: number; + export var POINT_CONVERSION_HYBRID: number; + export var O_RDONLY: number; + export var O_WRONLY: number; + export var O_RDWR: number; + export var S_IFMT: number; + export var S_IFREG: number; + export var S_IFDIR: number; + export var S_IFCHR: number; + export var S_IFLNK: number; + export var O_CREAT: number; + export var O_EXCL: number; + export var O_TRUNC: number; + export var O_APPEND: number; + export var F_OK: number; + export var R_OK: number; + export var W_OK: number; + export var X_OK: number; + export var UV_UDP_REUSEADDR: number; +} diff --git a/typings/underscore.string/underscore.string.d.ts b/typings/underscore.string/underscore.string.d.ts new file mode 100644 index 0000000..1b08dcf --- /dev/null +++ b/typings/underscore.string/underscore.string.d.ts @@ -0,0 +1,573 @@ +// Type definitions for underscore.string +// Project: https://github.com/epeli/underscore.string +// Definitions by: Ry Racherbaumer +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface UnderscoreStatic { + str: UnderscoreStringStatic; + string: UnderscoreStringStatic; +} + +declare var s : UnderscoreStringStatic; + +interface UnderscoreStringStatic extends UnderscoreStringStaticExports { + /** + * Tests if string contains a substring. + * ('foobar', 'ob') => true + * @param str + * @param needle + */ + include(str: string, needle: string): boolean; + + /** + * Tests if string contains a substring. + * ('foobar', 'ob') => true + * @param str + * @param needle + */ + contains(str: string, needle: string): boolean; + + /** + * Return reversed string. + * ('foobar') => 'raboof' + * @param str + */ + reverse(str: string): string; +} + +/** + * Functions exported for mixing with underscore object. + * + * Usage: + * _.mixin(_.string.exports()); + * interface UnderscoreStatic extends UnderscoreStringStaticExports { } + */ +interface UnderscoreStringStaticExports { + + exports(): UnderscoreStringStaticExports; + + /** + * Determine if a string is 'blank.' + * @param str + */ + isBlank(str: string): boolean; + + /** + * Removes all html tags from string. + * @param str + */ + stripTags(str: string): string; + + /** + * Converts first letter of the string to uppercase. + * ('foo Bar') => 'Foo Bar' + * @param str + */ + capitalize(str: string): string; + + /** + * Chop a string into pieces. + * ('whitespace', 3) => ['whi','tes','pac','e'] + * @param str String to chop + * @param step Size of the pieces + */ + chop(str: string, step: number): any[]; + + /** + * Compress some whitespaces to one. + * (' foo bar ') => 'foo bar' + * @param str + */ + clean(str: string): string; + + /** + * Count occurences of a sub string. + * ('Hello world', 'l') => 3 + * @param str + * @param substr + */ + count(str: string, substr: string): number; + + /** + * Convert string to an array of characters. + * ('Hello') => ['H','e','l','l','o'] + * @param str + */ + chars(str: string): any[]; + + /** + * Returns a copy of the string in which all the case-based characters have had their case swapped. + * ('hELLO') => 'Hello' + * @param str + */ + swapCase(str: string): string; + + /** + * Converts HTML special characters to their entity equivalents. + * ('
Blah blah blah
') => '<div>Blah blah blah</div>' + * @param str + */ + escapeHTML(str: string): string; + + /** + * Converts entity characters to HTML equivalents. + * ('<div>Blah blah blah</div>') => '
Blah blah blah
' + * @param str + */ + unescapeHTML(str: string): string; + + /** + * Escape a string for use in a regular expression. + * @param str + */ + escapeRegExp(str: string): string; + + /** + * Splice a string like an array. + * @param str + * @param i + * @param howmany + * @param substr + */ + splice(str: string, i: number, howmany: number, substr?: string): string; + + /** + * Insert a string at index. + * @param str + * @param i + * @param substr + */ + insert(str: string, i: number, substr: string): string; + + /** + * Joins strings together with given separator. + * (' ', 'foo', 'bar') => 'foo bar' + * @param separator + * @param args + */ + join(separator: string, ...args: string[]): string; + + /** + * Split string by newlines character. + * ('Hello\nWorld') => ['Hello', 'World'] + * @param str + */ + lines(str: string): any[]; + + /** + * Checks if string starts with another string. + * ('image.gif', 'image') => true + * @param str + * @param starts + */ + startsWith(str: string, starts: string): boolean; + + /** + * Checks if string ends with another string. + * ('image.gif', 'gif') => true + * @param value + * @param starts + */ + endsWith(value: string, starts: string): boolean; + + /** + * Returns the successor to passed string. + * ('a') => 'b' + * @param str + */ + succ(str: string): string; + + /** + * Capitalize first letter of every word in the string. + * ('my name is epeli') => 'My Name Is Epeli' + * @param str + */ + titleize(str: string): string; + + /** + * Converts underscored or dasherized string to a camelized one. + * ('-moz-transform') => 'MozTransform' + * @param str + */ + camelize(str: string): string; + + /** + * Converts a camelized or dasherized string into an underscored one. + * ('MozTransform') => 'moz_transform' + * @param str + */ + underscored(str: string): string; + + /** + * Converts a underscored or camelized string into an dasherized one. + * ('MozTransform') => '-moz-transform' + * @param str + */ + dasherize(str: string): string; + + /** + * Converts string to camelized class name. + * ('some_class_name') => 'SomeClassName' + * @param str + */ + classify(str: string): string; + + /** + * Converts an underscored, camelized, or dasherized string into a humanized one. + * Also removes beginning and ending whitespace, and removes the postfix '_id'. + * (' capitalize dash-CamelCase_underscore trim ') => 'Capitalize dash camel case underscore trim' + * @param str + */ + humanize(str: string): string; + + /** + * Trims defined characters from begining and ending of the string. + * Defaults to whitespace characters. + * (' foobar ') => 'foobar' + * ('_-foobar-_', '_-') => 'foobar' + * @param str + * @param characters + */ + trim(str: string, characters?: string): string; + + /** + * Trims defined characters from begining and ending of the string. + * Defaults to whitespace characters. + * (' foobar ') => 'foobar' + * ('_-foobar-_', '_-') => 'foobar' + * @param str + * @param characters + */ + strip(str: string, characters?: string): string; + + /** + * Left trim. Similar to trim, but only for left side. + * @param str + * @param characters + */ + ltrim(str: string, characters?: string): string; + + /** + * Left trim. Similar to trim, but only for left side. + * @param str + * @param characters + */ + lstrip(str: string, characters?: string): string; + + /** + * Right trim. Similar to trim, but only for right side. + * @param str + * @param characters + */ + rtrim(str: string, characters?: string): string; + + /** + * Right trim. Similar to trim, but only for right side. + * @param str + * @param characters + */ + rstrip(str: string, characters?: string): string; + + /** + * Truncate string to specified length. + * ('Hello world').truncate(5) => 'Hello...' + * ('Hello').truncate(10) => 'Hello' + * @param str + * @param length + * @param truncateStr + */ + truncate(str: string, length: number, truncateStr?: string): string; + + /** + * Elegant version of truncate. + * Makes sure the pruned string does not exceed the original length. + * Avoid half-chopped words when truncating. + * ('Hello, cruel world', 15) => 'Hello, cruel...' + * @param str + * @param length + * @param pruneStr + */ + prune(str: string, length: number, pruneStr?: string): string; + + /** + * Split string by delimiter (String or RegExp). + * /\s+/ by default. + * (' I love you ') => ['I','love','you'] + * ('I_love_you', '_') => ['I','love','you'] + * @param str + * @param delimiter + */ + words(str: string): string[]; + + /** + * Split string by delimiter (String or RegExp). + * /\s+/ by default. + * (' I love you ') => ['I','love','you'] + * ('I_love_you', '_') => ['I','love','you'] + * @param str + * @param delimiter + */ + words(str: string, delimiter: string): string[]; + + /** + * Split string by delimiter (String or RegExp). + * /\s+/ by default. + * (' I love you ') => ['I','love','you'] + * ('I_love_you', '_') => ['I','love','you'] + * @param str + * @param delimiter + */ + words(str: string, delimiter: RegExp): string[]; + + /** + * Pads a string with characters until the total string length is equal to the passed length parameter. + * By default, pads on the left with the space char (' '). + * padStr is truncated to a single character if necessary. + * ('1', 8) => ' 1' + * ('1', 8, '0') => '00000001' + * ('1', 8, '0', 'right') => '10000000' + * ('1', 8, '0', 'both') => '00001000' + * ('1', 8, 'bleepblorp', 'both') => 'bbbb1bbb' + * @param str + * @param length + * @param padStr + * @param type + */ + pad(str: string, length: number, padStr?:string, type?: string): string; + + /** + * Left-pad a string. + * Alias for pad(str, length, padStr, 'left') + * ('1', 8, '0') => '00000001' + * @param str + * @param length + * @param padStr + */ + lpad(str: string, length: number, padStr?: string): string; + + /** + * Left-pad a string. + * Alias for pad(str, length, padStr, 'left') + * ('1', 8, '0') => '00000001' + * @param str + * @param length + * @param padStr + */ + rjust(str: string, length: number, padStr?: string): string; + + /** + * Right-pad a string. + * Alias for pad(str, length, padStr, 'right') + * ('1', 8, '0') => '10000000' + * @param str + * @param length + * @param padStr + */ + rpad(str: string, length: number, padStr?: string): string; + + /** + * Right-pad a string. + * Alias for pad(str, length, padStr, 'right') + * ('1', 8, '0') => '10000000' + * @param str + * @param length + * @param padStr + */ + ljust(str: string, length: number, padStr?: string): string; + + /** + * Left/right-pad a string. + * Alias for pad(str, length, padStr, 'both') + * ('1', 8, '0') => '00001000' + * @param str + * @param length + * @param padStr + */ + lrpad(str: string, length: number, padStr?: string): string; + + /** + * Left/right-pad a string. + * Alias for pad(str, length, padStr, 'both') + * ('1', 8, '0') => '00001000' + * @param str + * @param length + * @param padStr + */ + center(str: string, length: number, padStr?: string): string; + + /** + * C like string formatting. + * _.sprintf('%.1f', 1.17) => '1.2' + * @param format + * @param args + */ + sprintf(format: string, ...args: any[]): string; + + /** + * Parse string to number. + * Returns NaN if string can't be parsed to number. + * ('2.556').toNumber() => 3 + * ('2.556').toNumber(1) => 2.6 + * @param str + * @param decimals + */ + toNumber(str: string, decimals?: number): number; + + /** + * Formats the numbers. + * (1000, 2) => '1,000.00' + * (123456789.123, 5, '.', ',') => '123,456,789.12300' + * @param number + * @param dec + * @param dsep + * @param tsep + */ + numberFormat(number: number, dec?: number, dsep?: string, tsep?: string): string; + + /** + * Searches a string from left to right for a pattern. + * Returns a substring consisting of the characters in the string that are to the right of the pattern. + * If no match found, returns entire string. + * ('This_is_a_test_string').strRight('_') => 'is_a_test_string' + * @param str + * @param sep + */ + strRight(str: string, sep: string): string; + + /** + * Searches a string from right to left for a pattern. + * Returns a substring consisting of the characters in the string that are to the right of the pattern. + * If no match found, returns entire string. + * ('This_is_a_test_string').strRightBack('_') => 'string' + * @param str + * @param sep + */ + strRightBack(str: string, sep: string): string; + + /** + * Searches a string from left to right for a pattern. + * Returns a substring consisting of the characters in the string that are to the left of the pattern. + * If no match found, returns entire string. + * ('This_is_a_test_string').strLeft('_') => 'This' + * @param str + * @param sep + */ + strLeft(str: string, sep: string): string; + + /** + * Searches a string from right to left for a pattern. + * Returns a substring consisting of the characters in the string that are to the left of the pattern. + * If no match found, returns entire string. + * ('This_is_a_test_string').strLeftBack('_') => 'This_is_a_test' + * @param str + * @param sep + */ + strLeftBack(str: string, sep: string): string; + + /** + * Join an array into a human readable sentence. + * (['jQuery', 'Mootools', 'Prototype']) => 'jQuery, Mootools and Prototype' + * (['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ') => 'jQuery, Mootools unt Prototype' + * @param array + * @param separator + * @param lastSeparator + * @param serial + */ + toSentence(array: any[], separator?: string, lastSeparator?: string, serial?: boolean): string; + + /** + * The same as toSentence, but uses ', ' as default for lastSeparator. + * @param array + * @param separator + * @param lastSeparator + */ + toSentenceSerial(array: any[], separator?: string, lastSeparator?: string): string; + + /** + * Transform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash. + * ('Un éléphant à l'orée du bois') => 'un-elephant-a-loree-du-bois' + * @param str + */ + slugify(str: string): string; + + /** + * Surround a string with another string. + * ('foo', 'ab') => 'abfooab' + * @param str + * @param wrapper + */ + surround(str: string, wrapper: string): string; + + /** + * Quotes a string. + * quoteChar defaults to " + * ('foo') => '"foo"' + * @param str + */ + quote(str: string, quoteChar?: string): string; + + /** + * Quotes a string. + * quoteChar defaults to " + * ('foo') => '"foo"' + * @param str + */ + q(str: string, quoteChar?: string): string; + + /** + * Unquotes a string. + * quoteChar defaults to " + * ('"foo"') => 'foo' + * ("'foo'", "'") => 'foo' + * @param str + */ + unquote(str: string, quoteChar?: string): string; + + /** + * Repeat a string with an optional separator. + * ('foo', 3) => 'foofoofoo' + * ('foo', 3, 'bar') => 'foobarfoobarfoo' + * @param value + * @param count + * @param separator + */ + repeat(value: string, count: number, separator?:string): string; + + /** + * Naturally sort strings like humans would do. + * Caution: this function is charset dependent. + * @param str1 + * @param str2 + */ + naturalCmp(str1: string, str2: string): number; + + /** + * Calculates Levenshtein distance between two strings. + * ('kitten', 'kittah') => 2 + * @param str1 + * @param str2 + */ + levenshtein(str1: string, str2: string): number; + + /** + * Turn strings that can be commonly considered as booleans to real booleans. + * Such as "true", "false", "1" and "0". This function is case insensitive. + * ('true') => true + * ('FALSE') => false + * ('random') => undefined + * ('truthy', ['truthy'], ['falsy']) => true + * ('true only at start', [/^true/]) => true + * @param str + * @param trueValues + * @param falseValues + */ + toBoolean(str: string, trueValues?: any[], falseValues?: any[]): boolean; + +} +declare module 'underscore.string' { + var underscoreString: UnderscoreStringStatic; + export = underscoreString; +} +// TODO interface UnderscoreString extends Underscore diff --git a/typings/underscore/underscore.d.ts b/typings/underscore/underscore.d.ts new file mode 100644 index 0000000..7dea66a --- /dev/null +++ b/typings/underscore/underscore.d.ts @@ -0,0 +1,3413 @@ +// Type definitions for Underscore 1.7.0 +// Project: http://underscorejs.org/ +// Definitions by: Boris Yankov , Josh Baldwin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module _ { + /** + * underscore.js _.throttle options. + **/ + interface ThrottleSettings { + + /** + * If you'd like to disable the leading-edge call, pass this as false. + **/ + leading?: boolean; + + /** + * If you'd like to disable the execution on the trailing-edge, pass false. + **/ + trailing?: boolean; + } + + /** + * underscore.js template settings, set templateSettings or pass as an argument + * to 'template()' to override defaults. + **/ + interface TemplateSettings { + /** + * Default value is '/<%([\s\S]+?)%>/g'. + **/ + evaluate?: RegExp; + + /** + * Default value is '/<%=([\s\S]+?)%>/g'. + **/ + interpolate?: RegExp; + + /** + * Default value is '/<%-([\s\S]+?)%>/g'. + **/ + escape?: RegExp; + } + + interface Collection { } + + // Common interface between Arrays and jQuery objects + interface List extends Collection { + [index: number]: T; + length: number; + } + + interface Dictionary extends Collection { + [index: string]: T; + } + + interface ListIterator { + (value: T, index: number, list: List): TResult; + } + + interface ObjectIterator { + (element: T, key: string, list: Dictionary): TResult; + } + + interface MemoIterator { + (prev: TResult, curr: T, index: number, list: List): TResult; + } + + interface MemoObjectIterator { + (prev: TResult, curr: T, key: string, list: Dictionary): TResult; + } +} + +interface UnderscoreStatic { + /** + * Underscore OOP Wrapper, all Underscore functions that take an object + * as the first parameter can be invoked through this function. + * @param key First argument to Underscore object functions. + **/ + (value: Array): Underscore; + (value: T): Underscore; + + /* ************* + * Collections * + ************* */ + + /** + * Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is + * bound to the context object, if one is passed. Each invocation of iterator is called with three + * arguments: (element, index, list). If list is a JavaScript object, iterator's arguments will be + * (value, key, object). Delegates to the native forEach function if it exists. + * @param list Iterates over this list of elements. + * @param iterator Iterator function for each element `list`. + * @param context 'this' object in `iterator`, optional. + **/ + each( + list: _.List, + iterator: _.ListIterator, + context?: any): _.List; + + /** + * @see _.each + * @param object Iterates over properties of this object. + * @param iterator Iterator function for each property on `object`. + * @param context 'this' object in `iterator`, optional. + **/ + each( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): _.Dictionary; + + /** + * @see _.each + **/ + forEach( + list: _.List, + iterator: _.ListIterator, + context?: any): _.List; + + /** + * @see _.each + **/ + forEach( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): _.Dictionary; + + /** + * Produces a new array of values by mapping each value in list through a transformation function + * (iterator). If the native map method exists, it will be used instead. If list is a JavaScript + * object, iterator's arguments will be (value, key, object). + * @param list Maps the elements of this array. + * @param iterator Map iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return The mapped array result. + **/ + map( + list: _.List, + iterator: _.ListIterator, + context?: any): TResult[]; + + /** + * @see _.map + * @param object Maps the properties of this object. + * @param iterator Map iterator function for each property on `object`. + * @param context `this` object in `iterator`, optional. + * @return The mapped object result. + **/ + map( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): TResult[]; + + /** + * @see _.map + **/ + collect( + list: _.List, + iterator: _.ListIterator, + context?: any): TResult[]; + + /** + * @see _.map + **/ + collect( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): TResult[]; + + /** + * Also known as inject and foldl, reduce boils down a list of values into a single value. + * Memo is the initial state of the reduction, and each successive step of it should be + * returned by iterator. The iterator is passed four arguments: the memo, then the value + * and index (or key) of the iteration, and finally a reference to the entire list. + * @param list Reduces the elements of this array. + * @param iterator Reduce iterator function for each element in `list`. + * @param memo Initial reduce state. + * @param context `this` object in `iterator`, optional. + * @return Reduced object result. + **/ + reduce( + list: _.Collection, + iterator: _.MemoIterator, + memo?: TResult, + context?: any): TResult; + + reduce( + list: _.Dictionary, + iterator: _.MemoObjectIterator, + memo?: TResult, + context?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + list: _.Collection, + iterator: _.MemoIterator, + memo?: TResult, + context?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + list: _.Collection, + iterator: _.MemoIterator, + memo?: TResult, + context?: any): TResult; + + /** + * The right-associative version of reduce. Delegates to the JavaScript 1.8 version of + * reduceRight, if it exists. `foldr` is not as useful in JavaScript as it would be in a + * language with lazy evaluation. + * @param list Reduces the elements of this array. + * @param iterator Reduce iterator function for each element in `list`. + * @param memo Initial reduce state. + * @param context `this` object in `iterator`, optional. + * @return Reduced object result. + **/ + reduceRight( + list: _.Collection, + iterator: _.MemoIterator, + memo?: TResult, + context?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + list: _.Collection, + iterator: _.MemoIterator, + memo?: TResult, + context?: any): TResult; + + /** + * Looks through each value in the list, returning the first one that passes a truth + * test (iterator). The function returns as soon as it finds an acceptable element, + * and doesn't traverse the entire list. + * @param list Searches for a value in this list. + * @param iterator Search iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return The first acceptable found element in `list`, if nothing is found undefined/null is returned. + **/ + find( + list: _.List, + iterator: _.ListIterator, + context?: any): T; + + /** + * @see _.find + **/ + find( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): T; + + /** + * @see _.find + **/ + detect( + list: _.List, + iterator: _.ListIterator, + context?: any): T; + + /** + * @see _.find + **/ + detect( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): T; + + /** + * Looks through each value in the list, returning the index of the first one that passes a truth + * test (iterator). The function returns as soon as it finds an acceptable element, + * and doesn't traverse the entire list. + * @param list Searches for a value in this list. + * @param iterator Search iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned. + **/ + findIndex( + list: _.List, + iterator: _.ListIterator, + context?: any): number; + + + /** + * Looks through each value in the list, returning an array of all the values that pass a truth + * test (iterator). Delegates to the native filter method, if it exists. + * @param list Filter elements out of this list. + * @param iterator Filter iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return The filtered list of elements. + **/ + filter( + list: _.List, + iterator: _.ListIterator, + context?: any): T[]; + + /** + * @see _.filter + **/ + filter( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): T[]; + + /** + * @see _.filter + **/ + select( + list: _.List, + iterator: _.ListIterator, + context?: any): T[]; + + /** + * @see _.filter + **/ + select( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): T[]; + + /** + * Looks through each value in the list, returning an array of all the values that contain all + * of the key-value pairs listed in properties. + * @param list List to match elements again `properties`. + * @param properties The properties to check for on each element within `list`. + * @return The elements within `list` that contain the required `properties`. + **/ + where( + list: _.List, + properties: U): T[]; + + /** + * Looks through the list and returns the first value that matches all of the key-value pairs listed in properties. + * @param list Search through this list's elements for the first object with all `properties`. + * @param properties Properties to look for on the elements within `list`. + * @return The first element in `list` that has all `properties`. + **/ + findWhere( + list: _.List, + properties: U): T; + + /** + * Returns the values in list without the elements that the truth test (iterator) passes. + * The opposite of filter. + * Return all the elements for which a truth test fails. + * @param list Reject elements within this list. + * @param iterator Reject iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return The rejected list of elements. + **/ + reject( + list: _.List, + iterator: _.ListIterator, + context?: any): T[]; + + /** + * @see _.reject + **/ + reject( + object: _.Dictionary, + iterator: _.ObjectIterator, + context?: any): T[]; + + /** + * Returns true if all of the values in the list pass the iterator truth test. Delegates to the + * native method every, if present. + * @param list Truth test against all elements within this list. + * @param iterator Trust test iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return True if all elements passed the truth test, otherwise false. + **/ + every( + list: _.List, + iterator?: _.ListIterator, + context?: any): boolean; + + /** + * @see _.every + **/ + every( + list: _.Dictionary, + iterator?: _.ObjectIterator, + context?: any): boolean; + + /** + * @see _.every + **/ + all( + list: _.List, + iterator?: _.ListIterator, + context?: any): boolean; + + /** + * @see _.every + **/ + all( + list: _.Dictionary, + iterator?: _.ObjectIterator, + context?: any): boolean; + + /** + * Returns true if any of the values in the list pass the iterator truth test. Short-circuits and + * stops traversing the list if a true element is found. Delegates to the native method some, if present. + * @param list Truth test against all elements within this list. + * @param iterator Trust test iterator function for each element in `list`. + * @param context `this` object in `iterator`, optional. + * @return True if any elements passed the truth test, otherwise false. + **/ + some( + list: _.List, + iterator?: _.ListIterator, + context?: any): boolean; + + /** + * @see _.some + **/ + some( + object: _.Dictionary, + iterator?: _.ObjectIterator, + context?: any): boolean; + + /** + * @see _.some + **/ + any( + list: _.List, + iterator?: _.ListIterator, + context?: any): boolean; + + /** + * @see _.some + **/ + any( + object: _.Dictionary, + iterator?: _.ObjectIterator, + context?: any): boolean; + + /** + * Returns true if the value is present in the list. Uses indexOf internally, + * if list is an Array. + * @param list Checks each element to see if `value` is present. + * @param value The value to check for within `list`. + * @return True if `value` is present in `list`, otherwise false. + **/ + contains( + list: _.List, + value: T): boolean; + + /** + * @see _.contains + **/ + contains( + object: _.Dictionary, + value: T): boolean; + + /** + * @see _.contains + **/ + include( + list: _.Collection, + value: T): boolean; + + /** + * @see _.contains + **/ + include( + object: _.Dictionary, + value: T): boolean; + + /** + * Calls the method named by methodName on each value in the list. Any extra arguments passed to + * invoke will be forwarded on to the method invocation. + * @param list The element's in this list will each have the method `methodName` invoked. + * @param methodName The method's name to call on each element within `list`. + * @param arguments Additional arguments to pass to the method `methodName`. + **/ + invoke( + list: _.List, + methodName: string, + ...arguments: any[]): any; + + /** + * A convenient version of what is perhaps the most common use-case for map: extracting a list of + * property values. + * @param list The list to pluck elements out of that have the property `propertyName`. + * @param propertyName The property to look for on each element within `list`. + * @return The list of elements within `list` that have the property `propertyName`. + **/ + pluck( + list: _.List, + propertyName: string): any[]; + + /** + * Returns the maximum value in list. + * @param list Finds the maximum value in this list. + * @return Maximum value in `list`. + **/ + max(list: _.List): number; + + /** + * Returns the maximum value in list. If iterator is passed, it will be used on each value to generate + * the criterion by which the value is ranked. + * @param list Finds the maximum value in this list. + * @param iterator Compares each element in `list` to find the maximum value. + * @param context `this` object in `iterator`, optional. + * @return The maximum element within `list`. + **/ + max( + list: _.List, + iterator?: _.ListIterator, + context?: any): T; + + /** + * Returns the minimum value in list. + * @param list Finds the minimum value in this list. + * @return Minimum value in `list`. + **/ + min(list: _.List): number; + + /** + * Returns the minimum value in list. If iterator is passed, it will be used on each value to generate + * the criterion by which the value is ranked. + * @param list Finds the minimum value in this list. + * @param iterator Compares each element in `list` to find the minimum value. + * @param context `this` object in `iterator`, optional. + * @return The minimum element within `list`. + **/ + min( + list: _.List, + iterator?: _.ListIterator, + context?: any): T; + + /** + * Returns a sorted copy of list, ranked in ascending order by the results of running each value + * through iterator. Iterator may also be the string name of the property to sort by (eg. length). + * @param list Sorts this list. + * @param iterator Sort iterator for each element within `list`. + * @param context `this` object in `iterator`, optional. + * @return A sorted copy of `list`. + **/ + sortBy( + list: _.List, + iterator?: _.ListIterator, + context?: any): T[]; + + /** + * @see _.sortBy + * @param iterator Sort iterator for each element within `list`. + **/ + sortBy( + list: _.List, + iterator: string, + context?: any): T[]; + + /** + * Splits a collection into sets, grouped by the result of running each value through iterator. + * If iterator is a string instead of a function, groups by the property named by iterator on + * each of the values. + * @param list Groups this list. + * @param iterator Group iterator for each element within `list`, return the key to group the element by. + * @param context `this` object in `iterator`, optional. + * @return An object with the group names as properties where each property contains the grouped elements from `list`. + **/ + groupBy( + list: _.List, + iterator?: _.ListIterator, + context?: any): _.Dictionary; + + /** + * @see _.groupBy + * @param iterator Property on each object to group them by. + **/ + groupBy( + list: _.List, + iterator: string, + context?: any): _.Dictionary; + + /** + * Given a `list`, and an `iterator` function that returns a key for each element in the list (or a property name), + * returns an object with an index of each item. Just like _.groupBy, but for when you know your keys are unique. + **/ + indexBy( + list: _.List, + iterator: _.ListIterator, + context?: any): _.Dictionary; + + /** + * @see _.indexBy + * @param iterator Property on each object to index them by. + **/ + indexBy( + list: _.List, + iterator: string, + context?: any): _.Dictionary; + + /** + * Sorts a list into groups and returns a count for the number of objects in each group. Similar + * to groupBy, but instead of returning a list of values, returns a count for the number of values + * in that group. + * @param list Group elements in this list and then count the number of elements in each group. + * @param iterator Group iterator for each element within `list`, return the key to group the element by. + * @param context `this` object in `iterator`, optional. + * @return An object with the group names as properties where each property contains the number of elements in that group. + **/ + countBy( + list: _.List, + iterator?: _.ListIterator, + context?: any): _.Dictionary; + + /** + * @see _.countBy + * @param iterator Function name + **/ + countBy( + list: _.List, + iterator: string, + context?: any): _.Dictionary; + + /** + * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. + * @param list List to shuffle. + * @return Shuffled copy of `list`. + **/ + shuffle(list: _.Collection): T[]; + + /** + * Produce a random sample from the `list`. Pass a number to return `n` random elements from the list. Otherwise a single random item will be returned. + * @param list List to sample. + * @return Random sample of `n` elements in `list`. + **/ + sample(list: _.Collection, n: number): T[]; + + /** + * @see _.sample + **/ + sample(list: _.Collection): T; + + /** + * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting + * the arguments object. + * @param list object to transform into an array. + * @return `list` as an array. + **/ + toArray(list: _.Collection): T[]; + + /** + * Return the number of values in the list. + * @param list Count the number of values/elements in this list. + * @return Number of values in `list`. + **/ + size(list: _.Collection): number; + + /** + * Split array into two arrays: + * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate. + * @param array Array to split in two. + * @param iterator Filter iterator function for each element in `array`. + * @param context `this` object in `iterator`, optional. + * @return Array where Array[0] are the elements in `array` that satisfies the predicate, and Array[1] the elements that did not. + **/ + partition( + array: Array, + iterator: _.ListIterator, + context?: any): T[][]; + + /********* + * Arrays * + **********/ + + /** + * Returns the first element of an array. Passing n will return the first n elements of the array. + * @param array Retrieves the first element of this array. + * @return Returns the first element of `array`. + **/ + first(array: _.List): T; + + /** + * @see _.first + * @param n Return more than one element from `array`. + **/ + first( + array: _.List, + n: number): T[]; + + /** + * @see _.first + **/ + head(array: _.List): T; + + /** + * @see _.first + **/ + head( + array: _.List, + n: number): T[]; + + /** + * @see _.first + **/ + take(array: _.List): T; + + /** + * @see _.first + **/ + take( + array: _.List, + n: number): T[]; + + /** + * Returns everything but the last entry of the array. Especially useful on the arguments object. + * Pass n to exclude the last n elements from the result. + * @param array Retrieve all elements except the last `n`. + * @param n Leaves this many elements behind, optional. + * @return Returns everything but the last `n` elements of `array`. + **/ + initial( + array: _.List, + n?: number): T[]; + + /** + * Returns the last element of an array. Passing n will return the last n elements of the array. + * @param array Retrieves the last element of this array. + * @return Returns the last element of `array`. + **/ + last(array: _.List): T; + + /** + * @see _.last + * @param n Return more than one element from `array`. + **/ + last( + array: _.List, + n: number): T[]; + + /** + * Returns the rest of the elements in an array. Pass an index to return the values of the array + * from that index onward. + * @param array The array to retrieve all but the first `index` elements. + * @param n The index to start retrieving elements forward from, optional, default = 1. + * @return Returns the elements of `array` from `index` to the end of `array`. + **/ + rest( + array: _.List, + n?: number): T[]; + + /** + * @see _.rest + **/ + tail( + array: _.List, + n?: number): T[]; + + /** + * @see _.rest + **/ + drop( + array: _.List, + n?: number): T[]; + + /** + * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "", + * undefined and NaN are all falsy. + * @param array Array to compact. + * @return Copy of `array` without false values. + **/ + compact(array: _.List): T[]; + + /** + * Flattens a nested array (the nesting can be to any depth). If you pass shallow, the array will + * only be flattened a single level. + * @param array The array to flatten. + * @param shallow If true then only flatten one level, optional, default = false. + * @return `array` flattened. + **/ + flatten( + array: _.List, + shallow?: boolean): any[]; + + /** + * Returns a copy of the array with all instances of the values removed. + * @param array The array to remove `values` from. + * @param values The values to remove from `array`. + * @return Copy of `array` without `values`. + **/ + without( + array: _.List, + ...values: T[]): T[]; + + /** + * Computes the union of the passed-in arrays: the list of unique items, in order, that are + * present in one or more of the arrays. + * @param arrays Array of arrays to compute the union of. + * @return The union of elements within `arrays`. + **/ + union(...arrays: _.List[]): T[]; + + /** + * Computes the list of values that are the intersection of all the arrays. Each value in the result + * is present in each of the arrays. + * @param arrays Array of arrays to compute the intersection of. + * @return The intersection of elements within `arrays`. + **/ + intersection(...arrays: _.List[]): T[]; + + /** + * Similar to without, but returns the values from array that are not present in the other arrays. + * @param array Keeps values that are within `others`. + * @param others The values to keep within `array`. + * @return Copy of `array` with only `others` values. + **/ + difference( + array: _.List, + ...others: _.List[]): T[]; + + /** + * Produces a duplicate-free version of the array, using === to test object equality. If you know in + * advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If + * you want to compute unique items based on a transformation, pass an iterator function. + * @param array Array to remove duplicates from. + * @param isSorted True if `array` is already sorted, optional, default = false. + * @param iterator Transform the elements of `array` before comparisons for uniqueness. + * @param context 'this' object in `iterator`, optional. + * @return Copy of `array` where all elements are unique. + **/ + uniq( + array: _.List, + isSorted?: boolean, + iterator?: _.ListIterator, + context?: any): T[]; + + /** + * @see _.uniq + **/ + uniq( + array: _.List, + iterator?: _.ListIterator, + context?: any): T[]; + + /** + * @see _.uniq + **/ + unique( + array: _.List, + iterator?: _.ListIterator, + context?: any): T[]; + + /** + * @see _.uniq + **/ + unique( + array: _.List, + isSorted?: boolean, + iterator?: _.ListIterator, + context?: any): T[]; + + + /** + * Merges together the values of each of the arrays with the values at the corresponding position. + * Useful when you have separate data sources that are coordinated through matching array indexes. + * If you're working with a matrix of nested arrays, zip.apply can transpose the matrix in a similar fashion. + * @param arrays The arrays to merge/zip. + * @return Zipped version of `arrays`. + **/ + zip(...arrays: any[][]): any[][]; + + /** + * @see _.zip + **/ + zip(...arrays: any[]): any[]; + + /** + * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a + * list of keys, and a list of values. + * @param keys Key array. + * @param values Value array. + * @return An object containing the `keys` as properties and `values` as the property values. + **/ + object( + keys: _.List, + values: _.List): TResult; + + /** + * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a + * list of keys, and a list of values. + * @param keyValuePairs Array of [key, value] pairs. + * @return An object containing the `keys` as properties and `values` as the property values. + **/ + object(...keyValuePairs: any[][]): TResult; + + /** + * @see _.object + **/ + object( + list: _.List, + values?: any): TResult; + + /** + * Returns the index at which value can be found in the array, or -1 if value is not present in the array. + * Uses the native indexOf function unless it's missing. If you're working with a large array, and you know + * that the array is already sorted, pass true for isSorted to use a faster binary search ... or, pass a number + * as the third argument in order to look for the first matching value in the array after the given index. + * @param array The array to search for the index of `value`. + * @param value The value to search for within `array`. + * @param isSorted True if the array is already sorted, optional, default = false. + * @return The index of `value` within `array`. + **/ + indexOf( + array: _.List, + value: T, + isSorted?: boolean): number; + + /** + * @see _indexof + **/ + indexOf( + array: _.List, + value: T, + startFrom: number): number; + + /** + * Returns the index of the last occurrence of value in the array, or -1 if value is not present. Uses the + * native lastIndexOf function if possible. Pass fromIndex to start your search at a given index. + * @param array The array to search for the last index of `value`. + * @param value The value to search for within `array`. + * @param from The starting index for the search, optional. + * @return The index of the last occurrence of `value` within `array`. + **/ + lastIndexOf( + array: _.List, + value: T, + from?: number): number; + + /** + * Uses a binary search to determine the index at which the value should be inserted into the list in order + * to maintain the list's sorted order. If an iterator is passed, it will be used to compute the sort ranking + * of each value, including the value you pass. + * @param list The sorted list. + * @param value The value to determine its index within `list`. + * @param iterator Iterator to compute the sort ranking of each value, optional. + * @return The index where `value` should be inserted into `list`. + **/ + sortedIndex( + list: _.List, + value: T, + iterator?: (x: T) => TSort, context?: any): number; + + /** + * A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted, + * defaults to 0; step defaults to 1. Returns a list of integers from start to stop, incremented (or decremented) + * by step, exclusive. + * @param start Start here. + * @param stop Stop here. + * @param step The number to count up by each iteration, optional, default = 1. + * @return Array of numbers from `start` to `stop` with increments of `step`. + **/ + + range( + start: number, + stop: number, + step?: number): number[]; + + /** + * @see _.range + * @param stop Stop here. + * @return Array of numbers from 0 to `stop` with increments of 1. + * @note If start is not specified the implementation will never pull the step (step = arguments[2] || 0) + **/ + range(stop: number): number[]; + + /************* + * Functions * + *************/ + + /** + * Bind a function to an object, meaning that whenever the function is called, the value of this will + * be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application. + * @param func The function to bind `this` to `object`. + * @param context The `this` pointer whenever `fn` is called. + * @param arguments Additional arguments to pass to `fn` when called. + * @return `fn` with `this` bound to `object`. + **/ + bind( + func: Function, + context: any, + ...arguments: any[]): () => any; + + /** + * Binds a number of methods on the object, specified by methodNames, to be run in the context of that object + * whenever they are invoked. Very handy for binding functions that are going to be used as event handlers, + * which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the + * object's function properties will be bound to it. + * @param object The object to bind the methods `methodName` to. + * @param methodNames The methods to bind to `object`, optional and if not provided all of `object`'s + * methods are bound. + **/ + bindAll( + object: any, + ...methodNames: string[]): any; + + /** + * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. + * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be + * pre-filled, but left open to supply at call-time. + * @param fn Function to partially fill in arguments. + * @param arguments The partial arguments. + * @return `fn` with partially filled in arguments. + **/ + partial( + fn: Function, + ...arguments: any[]): Function; + + /** + * Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations. + * If passed an optional hashFunction, it will be used to compute the hash key for storing the result, based + * on the arguments to the original function. The default hashFunction just uses the first argument to the + * memoized function as the key. + * @param fn Computationally expensive function that will now memoized results. + * @param hashFn Hash function for storing the result of `fn`. + * @return Memoized version of `fn`. + **/ + memoize( + fn: Function, + hashFn?: (...args: any[]) => string): Function; + + /** + * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments, + * they will be forwarded on to the function when it is invoked. + * @param func Function to delay `waitMS` amount of ms. + * @param wait The amount of milliseconds to delay `fn`. + * @arguments Additional arguments to pass to `fn`. + **/ + delay( + func: Function, + wait: number, + ...arguments: any[]): any; + + /** + * @see _delay + **/ + delay( + func: Function, + ...arguments: any[]): any; + + /** + * Defers invoking the function until the current call stack has cleared, similar to using setTimeout + * with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without + * blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on + * to the function when it is invoked. + * @param fn The function to defer. + * @param arguments Additional arguments to pass to `fn`. + **/ + defer( + fn: Function, + ...arguments: any[]): void; + + /** + * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, + * will only actually call the original function at most once per every wait milliseconds. Useful for + * rate-limiting events that occur faster than you can keep up with. + * By default, throttle will execute the function as soon as you call it for the first time, and, + * if you call it again any number of times during the wait period, as soon as that period is over. + * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable + * the execution on the trailing-edge, pass {trailing: false}. + * @param func Function to throttle `waitMS` ms. + * @param wait The number of milliseconds to wait before `fn` can be invoked again. + * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. + * @return `fn` with a throttle of `wait`. + **/ + throttle( + func: T, + wait: number, + options?: _.ThrottleSettings): T; + + /** + * Creates and returns a new debounced version of the passed function that will postpone its execution + * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing + * behavior that should only happen after the input has stopped arriving. For example: rendering a preview + * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. + * + * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead + * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double + *-clicks on a "submit" button from firing a second time. + * @param fn Function to debounce `waitMS` ms. + * @param wait The number of milliseconds to wait before `fn` can be invoked again. + * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. + * @return Debounced version of `fn` that waits `wait` ms when invoked. + **/ + debounce( + fn: T, + wait: number, + immediate?: boolean): T; + + /** + * Creates a version of the function that can only be called one time. Repeated calls to the modified + * function will have no effect, returning the value from the original call. Useful for initialization + * functions, instead of having to set a boolean flag and then check it later. + * @param fn Function to only execute once. + * @return Copy of `fn` that can only be invoked once. + **/ + once(fn: T): T; + + /** + * Creates a version of the function that will only be run after first being called count times. Useful + * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, + * before proceeding. + * @param number count Number of times to be called before actually executing. + * @param Function fn The function to defer execution `count` times. + * @return Copy of `fn` that will not execute until it is invoked `count` times. + **/ + after( + count: number, + fn: Function): Function; + + /** + * Creates a version of the function that can be called no more than count times. The result of + * the last function call is memoized and returned when count has been reached. + * @param number count The maxmimum number of times the function can be called. + * @param Function fn The function to limit the number of times it can be called. + * @return Copy of `fn` that can only be called `count` times. + **/ + before( + count: number, + fn: Function): Function; + + /** + * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows + * the wrapper to execute code before and after the function runs, adjust the arguments, and execute it + * conditionally. + * @param fn Function to wrap. + * @param wrapper The function that will wrap `fn`. + * @return Wrapped version of `fn. + **/ + wrap( + fn: Function, + wrapper: (fn: Function, ...args: any[]) => any): Function; + + /** + * Returns a negated version of the pass-in predicate. + * @param Function predicate + * @return boolean + **/ + negate(predicate: Function): boolean; + + /** + * Returns the composition of a list of functions, where each function consumes the return value of the + * function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())). + * @param functions List of functions to compose. + * @return Composition of `functions`. + **/ + compose(...functions: Function[]): Function; + + /********** + * Objects * + ***********/ + + /** + * Retrieve all the names of the object's properties. + * @param object Retrieve the key or property names from this object. + * @return List of all the property names on `object`. + **/ + keys(object: any): string[]; + + /** + * Return all of the values of the object's properties. + * @param object Retrieve the values of all the properties on this object. + * @return List of all the values on `object`. + **/ + values(object: any): any[]; + + /** + * Like map, but for objects. Transform the value of each property in turn. + * @param object The object to transform + * @param iteratee The function that transforms property values + * @param context The optional context (value of `this`) to bind to + * @return a new _.Dictionary of property values + */ + mapObject(object: _.Dictionary, iteratee: (val: T, key: string, object: _.Dictionary) => U, context?: any): _.Dictionary; + + /** + * Like map, but for objects. Transform the value of each property in turn. + * @param object The object to transform + * @param iteratee The function that tranforms property values + * @param context The optional context (value of `this`) to bind to + */ + mapObject(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary; + + /** + * Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property + * @param object The object to transform + * @param iteratee The property name to retrieve + * @param context The optional context (value of `this`) to bind to + */ + mapObject(object: any, iteratee: string, context?: any): _.Dictionary; + + /** + * Convert an object into a list of [key, value] pairs. + * @param object Convert this object to a list of [key, value] pairs. + * @return List of [key, value] pairs on `object`. + **/ + pairs(object: any): any[][]; + + /** + * Returns a copy of the object where the keys have become the values and the values the keys. + * For this to work, all of your object's values should be unique and string serializable. + * @param object Object to invert key/value pairs. + * @return An inverted key/value paired version of `object`. + **/ + invert(object: any): any; + + /** + * Returns a sorted list of the names of every method in an object - that is to say, + * the name of every function property of the object. + * @param object Object to pluck all function property names from. + * @return List of all the function names on `object`. + **/ + functions(object: any): string[]; + + /** + * @see _functions + **/ + methods(object: any): string[]; + + /** + * Copy all of the properties in the source objects over to the destination object, and return + * the destination object. It's in-order, so the last source will override properties of the + * same name in previous arguments. + * @param destination Object to extend all the properties from `sources`. + * @param sources Extends `destination` with all properties from these source objects. + * @return `destination` extended with all the properties from the `sources` objects. + **/ + extend( + destination: any, + ...sources: any[]): any; + + /** + * Like extend, but only copies own properties over to the destination object. (alias: assign) + */ + extendOwn( + destination: any, + ...source: any[]): any; + + /** + * Like extend, but only copies own properties over to the destination object. (alias: extendOwn) + */ + assign( + destination: any, + ...source: any[]): any; + + /** + * Return a copy of the object, filtered to only have values for the whitelisted keys + * (or array of valid keys). + * @param object Object to strip unwanted key/value pairs. + * @keys The key/value pairs to keep on `object`. + * @return Copy of `object` with only the `keys` properties. + **/ + pick( + object: any, + ...keys: any[]): any; + + /** + * @see _.pick + **/ + pick( + object: any, + fn: (value: any, key: any, object: any) => any): any; + + /** + * Return a copy of the object, filtered to omit the blacklisted keys (or array of keys). + * @param object Object to strip unwanted key/value pairs. + * @param keys The key/value pairs to remove on `object`. + * @return Copy of `object` without the `keys` properties. + **/ + omit( + object: any, + ...keys: string[]): any; + + /** + * @see _.omit + **/ + omit( + object: any, + keys: string[]): any; + + /** + * @see _.omit + **/ + omit( + object: any, + iteratee: Function): any; + + /** + * Fill in null and undefined properties in object with values from the defaults objects, + * and return the object. As soon as the property is filled, further defaults will have no effect. + * @param object Fill this object with default values. + * @param defaults The default values to add to `object`. + * @return `object` with added `defaults` values. + **/ + defaults( + object: any, + ...defaults: any[]): any; + + /** + * Create a shallow-copied clone of the object. + * Any nested objects or arrays will be copied by reference, not duplicated. + * @param object Object to clone. + * @return Copy of `object`. + **/ + clone(object: T): T; + + /** + * Invokes interceptor with the object, and then returns object. The primary purpose of this method + * is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. + * @param object Argument to `interceptor`. + * @param intercepter The function to modify `object` before continuing the method chain. + * @return Modified `object`. + **/ + tap(object: T, intercepter: Function): T; + + /** + * Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe + * reference to the hasOwnProperty function, in case it's been overridden accidentally. + * @param object Object to check for `key`. + * @param key The key to check for on `object`. + * @return True if `key` is a property on `object`, otherwise false. + **/ + has(object: any, key: string): boolean; + + /** + * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs. + * @param attrs Object with key values pair + * @return Predicate function + **/ + matches(attrs: T): _.ListIterator; + + /** + * Returns a function that will itself return the key property of any passed-in object. + * @param key Property of the object. + * @return Function which accept an object an returns the value of key in that object. + **/ + property(key: string): (object: Object) => any; + + /** + * Performs an optimized deep comparison between the two objects, + * to determine if they should be considered equal. + * @param object Compare to `other`. + * @param other Compare to `object`. + * @return True if `object` is equal to `other`. + **/ + isEqual(object: any, other: any): boolean; + + /** + * Returns true if object contains no values. + * @param object Check if this object has no properties or values. + * @return True if `object` is empty. + **/ + isEmpty(object: any): boolean; + + /** + * Returns true if object is a DOM element. + * @param object Check if this object is a DOM element. + * @return True if `object` is a DOM element, otherwise false. + **/ + isElement(object: any): boolean; + + /** + * Returns true if object is an Array. + * @param object Check if this object is an Array. + * @return True if `object` is an Array, otherwise false. + **/ + isArray(object: any): boolean; + + /** + * Returns true if value is an Object. Note that JavaScript arrays and functions are objects, + * while (normal) strings and numbers are not. + * @param object Check if this object is an Object. + * @return True of `object` is an Object, otherwise false. + **/ + isObject(object: any): boolean; + + /** + * Returns true if object is an Arguments object. + * @param object Check if this object is an Arguments object. + * @return True if `object` is an Arguments object, otherwise false. + **/ + isArguments(object: any): boolean; + + /** + * Returns true if object is a Function. + * @param object Check if this object is a Function. + * @return True if `object` is a Function, otherwise false. + **/ + isFunction(object: any): boolean; + + /** + * Returns true if object is a String. + * @param object Check if this object is a String. + * @return True if `object` is a String, otherwise false. + **/ + isString(object: any): boolean; + + /** + * Returns true if object is a Number (including NaN). + * @param object Check if this object is a Number. + * @return True if `object` is a Number, otherwise false. + **/ + isNumber(object: any): boolean; + + /** + * Returns true if object is a finite Number. + * @param object Check if this object is a finite Number. + * @return True if `object` is a finite Number. + **/ + isFinite(object: any): boolean; + + /** + * Returns true if object is either true or false. + * @param object Check if this object is a bool. + * @return True if `object` is a bool, otherwise false. + **/ + isBoolean(object: any): boolean; + + /** + * Returns true if object is a Date. + * @param object Check if this object is a Date. + * @return True if `object` is a Date, otherwise false. + **/ + isDate(object: any): boolean; + + /** + * Returns true if object is a RegExp. + * @param object Check if this object is a RegExp. + * @return True if `object` is a RegExp, otherwise false. + **/ + isRegExp(object: any): boolean; + + /** + * Returns true if object is NaN. + * Note: this is not the same as the native isNaN function, + * which will also return true if the variable is undefined. + * @param object Check if this object is NaN. + * @return True if `object` is NaN, otherwise false. + **/ + isNaN(object: any): boolean; + + /** + * Returns true if the value of object is null. + * @param object Check if this object is null. + * @return True if `object` is null, otherwise false. + **/ + isNull(object: any): boolean; + + /** + * Returns true if value is undefined. + * @param object Check if this object is undefined. + * @return True if `object` is undefined, otherwise false. + **/ + isUndefined(value: any): boolean; + + /* ********* + * Utility * + ********** */ + + /** + * Give control of the "_" variable back to its previous owner. + * Returns a reference to the Underscore object. + * @return Underscore object reference. + **/ + noConflict(): any; + + /** + * Returns the same value that is used as the argument. In math: f(x) = x + * This function looks useless, but is used throughout Underscore as a default iterator. + * @param value Identity of this object. + * @return `value`. + **/ + identity(value: T): T; + + /** + * Creates a function that returns the same value that is used as the argument of _.constant + * @param value Identity of this object. + * @return Function that return value. + **/ + constant(value: T): () => T; + + /** + * Returns undefined irrespective of the arguments passed to it. Useful as the default + * for optional callback arguments. + * Note there is no way to indicate a 'undefined' return, so it is currently typed as void. + * @return undefined + **/ + noop(): void; + + /** + * Invokes the given iterator function n times. + * Each invocation of iterator is called with an index argument + * @param n Number of times to invoke `iterator`. + * @param iterator Function iterator to invoke `n` times. + * @param context `this` object in `iterator`, optional. + **/ + times(n: number, iterator: (n: number) => TResult, context?: any): TResult[]; + + /** + * Returns a random integer between min and max, inclusive. If you only pass one argument, + * it will return a number between 0 and that number. + * @param max The maximum random number. + * @return A random number between 0 and `max`. + **/ + random(max: number): number; + + /** + * @see _.random + * @param min The minimum random number. + * @return A random number between `min` and `max`. + **/ + random(min: number, max: number): number; + + /** + * Allows you to extend Underscore with your own utility functions. Pass a hash of + * {name: function} definitions to have your functions added to the Underscore object, + * as well as the OOP wrapper. + * @param object Mixin object containing key/function pairs to add to the Underscore object. + **/ + mixin(object: any): void; + + /** + * A mostly-internal function to generate callbacks that can be applied to each element + * in a collection, returning the desired result -- either identity, an arbitrary callback, + * a property matcher, or a propetery accessor. + * @param string|Function|Object value The value to iterate over, usually the key. + * @param any context + * @param number argCount + * @return Callback that can be applied to each element in a collection. + **/ + iteratee(value: string): Function; + iteratee(value: Function, context?: any, argCount?: number): Function; + iteratee(value: Object): Function; + + /** + * Generate a globally-unique id for client-side models or DOM elements that need one. + * If prefix is passed, the id will be appended to it. Without prefix, returns an integer. + * @param prefix A prefix string to start the unique ID with. + * @return Unique string ID beginning with `prefix`. + **/ + uniqueId(prefix: string): string; + + /** + * @see _.uniqueId + **/ + uniqueId(): number; + + /** + * Escapes a string for insertion into HTML, replacing &, <, >, ", ', and / characters. + * @param str Raw string to escape. + * @return `str` HTML escaped. + **/ + escape(str: string): string; + + /** + * The opposite of escape, replaces &, <, >, ", and ' with their unescaped counterparts. + * @param str HTML escaped string. + * @return `str` Raw string. + **/ + unescape(str: string): string; + + /** + * If the value of the named property is a function then invoke it; otherwise, return it. + * @param object Object to maybe invoke function `property` on. + * @param property The function by name to invoke on `object`. + * @return The result of invoking the function `property` on `object. + **/ + result(object: any, property: string): any; + + /** + * Compiles JavaScript templates into functions that can be evaluated for rendering. Useful + * for rendering complicated bits of HTML from JSON data sources. Template functions can both + * interpolate variables, using <%= ... %>, as well as execute arbitrary JavaScript code, with + * <% ... %>. If you wish to interpolate a value, and have it be HTML-escaped, use <%- ... %> When + * you evaluate a template function, pass in a data object that has properties corresponding to + * the template's free variables. If you're writing a one-off, you can pass the data object as + * the second parameter to template in order to render immediately instead of returning a template + * function. The settings argument should be a hash containing any _.templateSettings that should + * be overridden. + * @param templateString Underscore HTML template. + * @param data Data to use when compiling `templateString`. + * @param settings Settings to use while compiling. + * @return Returns the compiled Underscore HTML template. + **/ + template(templateString: string, settings?: _.TemplateSettings): (...data: any[]) => string; + + /** + * By default, Underscore uses ERB-style template delimiters, change the + * following template settings to use alternative delimiters. + **/ + templateSettings: _.TemplateSettings; + + /** + * Returns an integer timestamp for the current time, using the fastest method available in the runtime. Useful for implementing timing/animation functions. + **/ + now(): number; + + /* ********** + * Chaining * + *********** */ + + /** + * Returns a wrapped object. Calling methods on this object will continue to return wrapped objects + * until value() is used. + * @param obj Object to chain. + * @return Wrapped `obj`. + **/ + chain(obj: T[]): _Chain; + chain(obj: T): _Chain; +} + +interface Underscore { + + /* ************* + * Collections * + ************* */ + + /** + * Wrapped type `any[]`. + * @see _.each + **/ + each(iterator: _.ListIterator, context?: any): T[]; + + /** + * @see _.each + **/ + each(iterator: _.ObjectIterator, context?: any): T[]; + + /** + * @see _.each + **/ + forEach(iterator: _.ListIterator, context?: any): T[]; + + /** + * @see _.each + **/ + forEach(iterator: _.ObjectIterator, context?: any): T[]; + + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ListIterator, context?: any): TResult[]; + + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ObjectIterator, context?: any): TResult[]; + + /** + * @see _.map + **/ + collect(iterator: _.ListIterator, context?: any): TResult[]; + + /** + * @see _.map + **/ + collect(iterator: _.ObjectIterator, context?: any): TResult[]; + + /** + * Wrapped type `any[]`. + * @see _.reduce + **/ + reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; + + /** + * @see _.reduce + **/ + inject(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; + + /** + * @see _.reduce + **/ + foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; + + /** + * Wrapped type `any[]`. + * @see _.reduceRight + **/ + reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; + + /** + * Wrapped type `any[]`. + * @see _.find + **/ + find(iterator: _.ListIterator, context?: any): T; + + /** + * @see _.find + **/ + detect(iterator: _.ListIterator, context?: any): T; + + /** + * Wrapped type `any[]`. + * @see _.filter + **/ + filter(iterator: _.ListIterator, context?: any): T[]; + + /** + * @see _.filter + **/ + select(iterator: _.ListIterator, context?: any): T[]; + + /** + * Wrapped type `any[]`. + * @see _.where + **/ + where(properties: U): T[]; + + /** + * Wrapped type `any[]`. + * @see _.findWhere + **/ + findWhere(properties: U): T; + + /** + * Wrapped type `any[]`. + * @see _.reject + **/ + reject(iterator: _.ListIterator, context?: any): T[]; + + /** + * Wrapped type `any[]`. + * @see _.all + **/ + all(iterator?: _.ListIterator, context?: any): boolean; + + /** + * @see _.all + **/ + every(iterator?: _.ListIterator, context?: any): boolean; + + /** + * Wrapped type `any[]`. + * @see _.any + **/ + any(iterator?: _.ListIterator, context?: any): boolean; + + /** + * @see _.any + **/ + some(iterator?: _.ListIterator, context?: any): boolean; + + /** + * Wrapped type `any[]`. + * @see _.contains + **/ + contains(value: T): boolean; + + /** + * Alias for 'contains'. + * @see contains + **/ + include(value: T): boolean; + + /** + * Wrapped type `any[]`. + * @see _.invoke + **/ + invoke(methodName: string, ...arguments: any[]): any; + + /** + * Wrapped type `any[]`. + * @see _.pluck + **/ + pluck(propertyName: string): any[]; + + /** + * Wrapped type `number[]`. + * @see _.max + **/ + max(): number; + + /** + * Wrapped type `any[]`. + * @see _.max + **/ + max(iterator: _.ListIterator, context?: any): T; + + /** + * Wrapped type `any[]`. + * @see _.max + **/ + max(iterator?: _.ListIterator, context?: any): T; + + /** + * Wrapped type `number[]`. + * @see _.min + **/ + min(): number; + + /** + * Wrapped type `any[]`. + * @see _.min + **/ + min(iterator: _.ListIterator, context?: any): T; + + /** + * Wrapped type `any[]`. + * @see _.min + **/ + min(iterator?: _.ListIterator, context?: any): T; + + /** + * Wrapped type `any[]`. + * @see _.sortBy + **/ + sortBy(iterator?: _.ListIterator, context?: any): T[]; + + /** + * Wrapped type `any[]`. + * @see _.sortBy + **/ + sortBy(iterator: string, context?: any): T[]; + + /** + * Wrapped type `any[]`. + * @see _.groupBy + **/ + groupBy(iterator?: _.ListIterator, context?: any): _.Dictionary<_.List>; + + /** + * Wrapped type `any[]`. + * @see _.groupBy + **/ + groupBy(iterator: string, context?: any): _.Dictionary; + + /** + * Wrapped type `any[]`. + * @see _.indexBy + **/ + indexBy(iterator: _.ListIterator, context?: any): _.Dictionary; + + /** + * Wrapped type `any[]`. + * @see _.indexBy + **/ + indexBy(iterator: string, context?: any): _.Dictionary; + + /** + * Wrapped type `any[]`. + * @see _.countBy + **/ + countBy(iterator?: _.ListIterator, context?: any): _.Dictionary; + + /** + * Wrapped type `any[]`. + * @see _.countBy + **/ + countBy(iterator: string, context?: any): _.Dictionary; + + /** + * Wrapped type `any[]`. + * @see _.shuffle + **/ + shuffle(): T[]; + + /** + * Wrapped type `any[]`. + * @see _.sample + **/ + sample(n: number): T[]; + + /** + * @see _.sample + **/ + sample(): T; + + /** + * Wrapped type `any`. + * @see _.toArray + **/ + toArray(): T[]; + + /** + * Wrapped type `any`. + * @see _.size + **/ + size(): number; + + /********* + * Arrays * + **********/ + + /** + * Wrapped type `any[]`. + * @see _.first + **/ + first(): T; + + /** + * Wrapped type `any[]`. + * @see _.first + **/ + first(n: number): T[]; + + /** + * @see _.first + **/ + head(): T; + + /** + * @see _.first + **/ + head(n: number): T[]; + + /** + * @see _.first + **/ + take(): T; + + /** + * @see _.first + **/ + take(n: number): T[]; + + /** + * Wrapped type `any[]`. + * @see _.initial + **/ + initial(n?: number): T[]; + + /** + * Wrapped type `any[]`. + * @see _.last + **/ + last(): T; + + /** + * Wrapped type `any[]`. + * @see _.last + **/ + last(n: number): T[]; + + /** + * Wrapped type `any[]`. + * @see _.rest + **/ + rest(n?: number): T[]; + + /** + * @see _.rest + **/ + tail(n?: number): T[]; + + /** + * @see _.rest + **/ + drop(n?: number): T[]; + + /** + * Wrapped type `any[]`. + * @see _.compact + **/ + compact(): T[]; + + /** + * Wrapped type `any`. + * @see _.flatten + **/ + flatten(shallow?: boolean): any[]; + + /** + * Wrapped type `any[]`. + * @see _.without + **/ + without(...values: T[]): T[]; + + /** + * Wrapped type `any[]`. + * @see _.partition + **/ + partition(iterator: _.ListIterator, context?: any): T[][]; + + /** + * Wrapped type `any[][]`. + * @see _.union + **/ + union(...arrays: _.List[]): T[]; + + /** + * Wrapped type `any[][]`. + * @see _.intersection + **/ + intersection(...arrays: _.List[]): T[]; + + /** + * Wrapped type `any[]`. + * @see _.difference + **/ + difference(...others: _.List[]): T[]; + + /** + * Wrapped type `any[]`. + * @see _.uniq + **/ + uniq(isSorted?: boolean, iterator?: _.ListIterator): T[]; + + /** + * Wrapped type `any[]`. + * @see _.uniq + **/ + uniq(iterator?: _.ListIterator, context?: any): T[]; + + /** + * @see _.uniq + **/ + unique(isSorted?: boolean, iterator?: _.ListIterator): T[]; + + /** + * @see _.uniq + **/ + unique(iterator?: _.ListIterator, context?: any): T[]; + + /** + * Wrapped type `any[][]`. + * @see _.zip + **/ + zip(...arrays: any[][]): any[][]; + + /** + * Wrapped type `any[][]`. + * @see _.object + **/ + object(...keyValuePairs: any[][]): any; + + /** + * @see _.object + **/ + object(values?: any): any; + + /** + * Wrapped type `any[]`. + * @see _.indexOf + **/ + indexOf(value: T, isSorted?: boolean): number; + + /** + * @see _.indexOf + **/ + indexOf(value: T, startFrom: number): number; + + /** + * Wrapped type `any[]`. + * @see _.lastIndexOf + **/ + lastIndexOf(value: T, from?: number): number; + + /** + * Wrapped type `any[]`. + * @see _.sortedIndex + **/ + sortedIndex(value: T, iterator?: (x: T) => any, context?: any): number; + + /** + * Wrapped type `number`. + * @see _.range + **/ + range(stop: number, step?: number): number[]; + + /** + * Wrapped type `number`. + * @see _.range + **/ + range(): number[]; + + /* *********** + * Functions * + ************ */ + + /** + * Wrapped type `Function`. + * @see _.bind + **/ + bind(object: any, ...arguments: any[]): Function; + + /** + * Wrapped type `object`. + * @see _.bindAll + **/ + bindAll(...methodNames: string[]): any; + + /** + * Wrapped type `Function`. + * @see _.partial + **/ + partial(...arguments: any[]): Function; + + /** + * Wrapped type `Function`. + * @see _.memoize + **/ + memoize(hashFn?: (n: any) => string): Function; + + /** + * Wrapped type `Function`. + * @see _.defer + **/ + defer(...arguments: any[]): void; + + /** + * Wrapped type `Function`. + * @see _.delay + **/ + delay(wait: number, ...arguments: any[]): any; + + /** + * @see _.delay + **/ + delay(...arguments: any[]): any; + + /** + * Wrapped type `Function`. + * @see _.throttle + **/ + throttle(wait: number, options?: _.ThrottleSettings): Function; + + /** + * Wrapped type `Function`. + * @see _.debounce + **/ + debounce(wait: number, immediate?: boolean): Function; + + /** + * Wrapped type `Function`. + * @see _.once + **/ + once(): Function; + + /** + * Wrapped type `number`. + * @see _.after + **/ + after(fn: Function): Function; + + /** + * Wrapped type `number`. + * @see _.before + **/ + before(fn: Function): Function; + + /** + * Wrapped type `Function`. + * @see _.wrap + **/ + wrap(wrapper: Function): () => Function; + + /** + * Wrapped type `Function`. + * @see _.negate + **/ + negate(): boolean; + + /** + * Wrapped type `Function[]`. + * @see _.compose + **/ + compose(...functions: Function[]): Function; + + /********* * + * Objects * + ********** */ + + /** + * Wrapped type `object`. + * @see _.keys + **/ + keys(): string[]; + + /** + * Wrapped type `object`. + * @see _.values + **/ + values(): T[]; + + /** + * Wrapped type `object`. + * @see _.pairs + **/ + pairs(): any[][]; + + /** + * Wrapped type `object`. + * @see _.invert + **/ + invert(): any; + + /** + * Wrapped type `object`. + * @see _.functions + **/ + functions(): string[]; + + /** + * @see _.functions + **/ + methods(): string[]; + + /** + * Wrapped type `object`. + * @see _.extend + **/ + extend(...sources: any[]): any; + + /** + * Wrapped type `object`. + * @see _.pick + **/ + pick(...keys: any[]): any; + pick(keys: any[]): any; + pick(fn: (value: any, key: any, object: any) => any): any; + + /** + * Wrapped type `object`. + * @see _.omit + **/ + omit(...keys: string[]): any; + omit(keys: string[]): any; + omit(fn: Function): any; + + /** + * Wrapped type `object`. + * @see _.defaults + **/ + defaults(...defaults: any[]): any; + + /** + * Wrapped type `any[]`. + * @see _.clone + **/ + clone(): T; + + /** + * Wrapped type `object`. + * @see _.tap + **/ + tap(interceptor: (...as: any[]) => any): any; + + /** + * Wrapped type `object`. + * @see _.has + **/ + has(key: string): boolean; + + /** + * Wrapped type `any[]`. + * @see _.matches + **/ + matches(): _.ListIterator; + + /** + * Wrapped type `string`. + * @see _.property + **/ + property(): (object: Object) => any; + + /** + * Wrapped type `object`. + * @see _.isEqual + **/ + isEqual(other: any): boolean; + + /** + * Wrapped type `object`. + * @see _.isEmpty + **/ + isEmpty(): boolean; + + /** + * Wrapped type `object`. + * @see _.isElement + **/ + isElement(): boolean; + + /** + * Wrapped type `object`. + * @see _.isArray + **/ + isArray(): boolean; + + /** + * Wrapped type `object`. + * @see _.isObject + **/ + isObject(): boolean; + + /** + * Wrapped type `object`. + * @see _.isArguments + **/ + isArguments(): boolean; + + /** + * Wrapped type `object`. + * @see _.isFunction + **/ + isFunction(): boolean; + + /** + * Wrapped type `object`. + * @see _.isString + **/ + isString(): boolean; + + /** + * Wrapped type `object`. + * @see _.isNumber + **/ + isNumber(): boolean; + + /** + * Wrapped type `object`. + * @see _.isFinite + **/ + isFinite(): boolean; + + /** + * Wrapped type `object`. + * @see _.isBoolean + **/ + isBoolean(): boolean; + + /** + * Wrapped type `object`. + * @see _.isDate + **/ + isDate(): boolean; + + /** + * Wrapped type `object`. + * @see _.isRegExp + **/ + isRegExp(): boolean; + + /** + * Wrapped type `object`. + * @see _.isNaN + **/ + isNaN(): boolean; + + /** + * Wrapped type `object`. + * @see _.isNull + **/ + isNull(): boolean; + + /** + * Wrapped type `object`. + * @see _.isUndefined + **/ + isUndefined(): boolean; + + /********* * + * Utility * + ********** */ + + /** + * Wrapped type `any`. + * @see _.identity + **/ + identity(): any; + + /** + * Wrapped type `any`. + * @see _.constant + **/ + constant(): () => T; + + /** + * Wrapped type `any`. + * @see _.noop + **/ + noop(): void; + + /** + * Wrapped type `number`. + * @see _.times + **/ + times(iterator: (n: number) => TResult, context?: any): TResult[]; + + /** + * Wrapped type `number`. + * @see _.random + **/ + random(): number; + /** + * Wrapped type `number`. + * @see _.random + **/ + random(max: number): number; + + /** + * Wrapped type `object`. + * @see _.mixin + **/ + mixin(): void; + + /** + * Wrapped type `string|Function|Object`. + * @see _.iteratee + **/ + iteratee(context?: any, argCount?: number): Function; + + /** + * Wrapped type `string`. + * @see _.uniqueId + **/ + uniqueId(): string; + + /** + * Wrapped type `string`. + * @see _.escape + **/ + escape(): string; + + /** + * Wrapped type `string`. + * @see _.unescape + **/ + unescape(): string; + + /** + * Wrapped type `object`. + * @see _.result + **/ + result(property: string): any; + + /** + * Wrapped type `string`. + * @see _.template + **/ + template(settings?: _.TemplateSettings): (...data: any[]) => string; + + /********** * + * Chaining * + *********** */ + + /** + * Wrapped type `any`. + * @see _.chain + **/ + chain(): _Chain; + + /** + * Wrapped type `any`. + * Extracts the value of a wrapped object. + * @return Value of the wrapped object. + **/ + value(): TResult; +} + +interface _Chain { + + /* ************* + * Collections * + ************* */ + + /** + * Wrapped type `any[]`. + * @see _.each + **/ + each(iterator: _.ListIterator, context?: any): _Chain; + + /** + * @see _.each + **/ + each(iterator: _.ObjectIterator, context?: any): _Chain; + + /** + * @see _.each + **/ + forEach(iterator: _.ListIterator, context?: any): _Chain; + + /** + * @see _.each + **/ + forEach(iterator: _.ObjectIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ListIterator, context?: any): _ChainOfArrays; + + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; + + /** + * Wrapped type `any[]`. + * @see _.map + **/ + map(iterator: _.ObjectIterator, context?: any): _Chain; + + /** + * @see _.map + **/ + collect(iterator: _.ListIterator, context?: any): _Chain; + + /** + * @see _.map + **/ + collect(iterator: _.ObjectIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.reduce + **/ + reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; + + /** + * @see _.reduce + **/ + inject(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; + + /** + * @see _.reduce + **/ + foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.reduceRight + **/ + reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; + + /** + * @see _.reduceRight + **/ + foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.find + **/ + find(iterator: _.ListIterator, context?: any): _ChainSingle; + + /** + * @see _.find + **/ + detect(iterator: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.filter + **/ + filter(iterator: _.ListIterator, context?: any): _Chain; + + /** + * @see _.filter + **/ + select(iterator: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.where + **/ + where(properties: U): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.findWhere + **/ + findWhere(properties: U): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.reject + **/ + reject(iterator: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.all + **/ + all(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * @see _.all + **/ + every(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.any + **/ + any(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * @see _.any + **/ + some(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.contains + **/ + contains(value: T): _Chain; + + /** + * Alias for 'contains'. + * @see contains + **/ + include(value: T): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.invoke + **/ + invoke(methodName: string, ...arguments: any[]): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.pluck + **/ + pluck(propertyName: string): _Chain; + + /** + * Wrapped type `number[]`. + * @see _.max + **/ + max(): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.max + **/ + max(iterator: _.ListIterator, context?: any): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.max + **/ + max(iterator?: _.ListIterator, context?: any): _ChainSingle; + + /** + * Wrapped type `number[]`. + * @see _.min + **/ + min(): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.min + **/ + min(iterator: _.ListIterator, context?: any): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.min + **/ + min(iterator?: _.ListIterator, context?: any): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.sortBy + **/ + sortBy(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.sortBy + **/ + sortBy(iterator: string, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.groupBy + **/ + groupBy(iterator?: _.ListIterator, context?: any): _ChainOfArrays; + + /** + * Wrapped type `any[]`. + * @see _.groupBy + **/ + groupBy(iterator: string, context?: any): _ChainOfArrays; + + /** + * Wrapped type `any[]`. + * @see _.indexBy + **/ + indexBy(iterator: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.indexBy + **/ + indexBy(iterator: string, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.countBy + **/ + countBy(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.countBy + **/ + countBy(iterator: string, context?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.shuffle + **/ + shuffle(): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.sample + **/ + sample(n: number): _Chain; + + /** + * @see _.sample + **/ + sample(): _Chain; + + /** + * Wrapped type `any`. + * @see _.toArray + **/ + toArray(): _Chain; + + /** + * Wrapped type `any`. + * @see _.size + **/ + size(): _Chain; + + /********* + * Arrays * + **********/ + + /** + * Wrapped type `any[]`. + * @see _.first + **/ + first(): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.first + **/ + first(n: number): _Chain; + + /** + * @see _.first + **/ + head(): _Chain; + + /** + * @see _.first + **/ + head(n: number): _Chain; + + /** + * @see _.first + **/ + take(): _Chain; + + /** + * @see _.first + **/ + take(n: number): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.initial + **/ + initial(n?: number): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.last + **/ + last(): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.last + **/ + last(n: number): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.rest + **/ + rest(n?: number): _Chain; + + /** + * @see _.rest + **/ + tail(n?: number): _Chain; + + /** + * @see _.rest + **/ + drop(n?: number): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.compact + **/ + compact(): _Chain; + + /** + * Wrapped type `any`. + * @see _.flatten + **/ + flatten(shallow?: boolean): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.without + **/ + without(...values: T[]): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.partition + **/ + partition(iterator: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[][]`. + * @see _.union + **/ + union(...arrays: _.List[]): _Chain; + + /** + * Wrapped type `any[][]`. + * @see _.intersection + **/ + intersection(...arrays: _.List[]): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.difference + **/ + difference(...others: _.List[]): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.uniq + **/ + uniq(isSorted?: boolean, iterator?: _.ListIterator): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.uniq + **/ + uniq(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * @see _.uniq + **/ + unique(isSorted?: boolean, iterator?: _.ListIterator): _Chain; + + /** + * @see _.uniq + **/ + unique(iterator?: _.ListIterator, context?: any): _Chain; + + /** + * Wrapped type `any[][]`. + * @see _.zip + **/ + zip(...arrays: any[][]): _Chain; + + /** + * Wrapped type `any[][]`. + * @see _.object + **/ + object(...keyValuePairs: any[][]): _Chain; + + /** + * @see _.object + **/ + object(values?: any): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.indexOf + **/ + indexOf(value: T, isSorted?: boolean): _ChainSingle; + + /** + * @see _.indexOf + **/ + indexOf(value: T, startFrom: number): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.lastIndexOf + **/ + lastIndexOf(value: T, from?: number): _ChainSingle; + + /** + * Wrapped type `any[]`. + * @see _.sortedIndex + **/ + sortedIndex(value: T, iterator?: (x: T) => any, context?: any): _Chain; + + /** + * Wrapped type `number`. + * @see _.range + **/ + range(stop: number, step?: number): _Chain; + + /** + * Wrapped type `number`. + * @see _.range + **/ + range(): _Chain; + + /* *********** + * Functions * + ************ */ + + /** + * Wrapped type `Function`. + * @see _.bind + **/ + bind(object: any, ...arguments: any[]): _Chain; + + /** + * Wrapped type `object`. + * @see _.bindAll + **/ + bindAll(...methodNames: string[]): _Chain; + + /** + * Wrapped type `Function`. + * @see _.partial + **/ + partial(...arguments: any[]): _Chain; + + /** + * Wrapped type `Function`. + * @see _.memoize + **/ + memoize(hashFn?: (n: any) => string): _Chain; + + /** + * Wrapped type `Function`. + * @see _.defer + **/ + defer(...arguments: any[]): _Chain; + + /** + * Wrapped type `Function`. + * @see _.delay + **/ + delay(wait: number, ...arguments: any[]): _Chain; + + /** + * @see _.delay + **/ + delay(...arguments: any[]): _Chain; + + /** + * Wrapped type `Function`. + * @see _.throttle + **/ + throttle(wait: number, options?: _.ThrottleSettings): _Chain; + + /** + * Wrapped type `Function`. + * @see _.debounce + **/ + debounce(wait: number, immediate?: boolean): _Chain; + + /** + * Wrapped type `Function`. + * @see _.once + **/ + once(): _Chain; + + /** + * Wrapped type `number`. + * @see _.after + **/ + after(func: Function): _Chain; + + /** + * Wrapped type `number`. + * @see _.before + **/ + before(fn: Function): _Chain; + + /** + * Wrapped type `Function`. + * @see _.wrap + **/ + wrap(wrapper: Function): () => _Chain; + + /** + * Wrapped type `Function`. + * @see _.negate + **/ + negate(): _Chain; + + /** + * Wrapped type `Function[]`. + * @see _.compose + **/ + compose(...functions: Function[]): _Chain; + + /********* * + * Objects * + ********** */ + + /** + * Wrapped type `object`. + * @see _.keys + **/ + keys(): _Chain; + + /** + * Wrapped type `object`. + * @see _.values + **/ + values(): _Chain; + + /** + * Wrapped type `object`. + * @see _.pairs + **/ + pairs(): _Chain; + + /** + * Wrapped type `object`. + * @see _.invert + **/ + invert(): _Chain; + + /** + * Wrapped type `object`. + * @see _.functions + **/ + functions(): _Chain; + + /** + * @see _.functions + **/ + methods(): _Chain; + + /** + * Wrapped type `object`. + * @see _.extend + **/ + extend(...sources: any[]): _Chain; + + /** + * Wrapped type `object`. + * @see _.pick + **/ + pick(...keys: any[]): _Chain; + pick(keys: any[]): _Chain; + pick(fn: (value: any, key: any, object: any) => any): _Chain; + + /** + * Wrapped type `object`. + * @see _.omit + **/ + omit(...keys: string[]): _Chain; + omit(keys: string[]): _Chain; + omit(iteratee: Function): _Chain; + + /** + * Wrapped type `object`. + * @see _.defaults + **/ + defaults(...defaults: any[]): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.clone + **/ + clone(): _Chain; + + /** + * Wrapped type `object`. + * @see _.tap + **/ + tap(interceptor: (...as: any[]) => any): _Chain; + + /** + * Wrapped type `object`. + * @see _.has + **/ + has(key: string): _Chain; + + /** + * Wrapped type `any[]`. + * @see _.matches + **/ + matches(): _Chain; + + /** + * Wrapped type `string`. + * @see _.property + **/ + property(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isEqual + **/ + isEqual(other: any): _Chain; + + /** + * Wrapped type `object`. + * @see _.isEmpty + **/ + isEmpty(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isElement + **/ + isElement(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isArray + **/ + isArray(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isObject + **/ + isObject(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isArguments + **/ + isArguments(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isFunction + **/ + isFunction(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isString + **/ + isString(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isNumber + **/ + isNumber(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isFinite + **/ + isFinite(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isBoolean + **/ + isBoolean(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isDate + **/ + isDate(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isRegExp + **/ + isRegExp(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isNaN + **/ + isNaN(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isNull + **/ + isNull(): _Chain; + + /** + * Wrapped type `object`. + * @see _.isUndefined + **/ + isUndefined(): _Chain; + + /********* * + * Utility * + ********** */ + + /** + * Wrapped type `any`. + * @see _.identity + **/ + identity(): _Chain; + + /** + * Wrapped type `any`. + * @see _.constant + **/ + constant(): _Chain; + + /** + * Wrapped type `any`. + * @see _.noop + **/ + noop(): _Chain; + + /** + * Wrapped type `number`. + * @see _.times + **/ + times(iterator: (n: number) => TResult, context?: any): _Chain; + + /** + * Wrapped type `number`. + * @see _.random + **/ + random(): _Chain; + /** + * Wrapped type `number`. + * @see _.random + **/ + random(max: number): _Chain; + + /** + * Wrapped type `object`. + * @see _.mixin + **/ + mixin(): _Chain; + + /** + * Wrapped type `string|Function|Object`. + * @see _.iteratee + **/ + iteratee(context?: any, argCount?: number): _Chain; + + /** + * Wrapped type `string`. + * @see _.uniqueId + **/ + uniqueId(): _Chain; + + /** + * Wrapped type `string`. + * @see _.escape + **/ + escape(): _Chain; + + /** + * Wrapped type `string`. + * @see _.unescape + **/ + unescape(): _Chain; + + /** + * Wrapped type `object`. + * @see _.result + **/ + result(property: string): _Chain; + + /** + * Wrapped type `string`. + * @see _.template + **/ + template(settings?: _.TemplateSettings): (...data: any[]) => _Chain; + + /************* * + * Array proxy * + ************** */ + + /** + * Returns a new array comprised of the array on which it is called + * joined with the array(s) and/or value(s) provided as arguments. + * @param arr Arrays and/or values to concatenate into a new array. See the discussion below for details. + * @return A new array comprised of the array on which it is called + **/ + concat(...arr: Array): _Chain; + + /** + * Join all elements of an array into a string. + * @param separator Optional. Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma. + * @return The string conversions of all array elements joined into one string. + **/ + join(separator?: any): _ChainSingle; + + /** + * Removes the last element from an array and returns that element. + * @return Returns the popped element. + **/ + pop(): _ChainSingle; + + /** + * Adds one or more elements to the end of an array and returns the new length of the array. + * @param item The elements to add to the end of the array. + * @return The array with the element added to the end. + **/ + push(...item: Array): _Chain; + + /** + * Reverses an array in place. The first array element becomes the last and the last becomes the first. + * @return The reversed array. + **/ + reverse(): _Chain; + + /** + * Removes the first element from an array and returns that element. This method changes the length of the array. + * @return The shifted element. + **/ + shift(): _ChainSingle; + + /** + * Returns a shallow copy of a portion of an array into a new array object. + * @param start Zero-based index at which to begin extraction. + * @param end Optional. Zero-based index at which to end extraction. slice extracts up to but not including end. + * @return A shallow copy of a portion of an array into a new array object. + **/ + slice(start: number, end?: number): _Chain; + + /** + * Sorts the elements of an array in place and returns the array. The sort is not necessarily stable. The default sort order is according to string Unicode code points. + * @param compareFn Optional. Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element. + * @return The sorted array. + **/ + sort(compareFn: (a: T, b: T) => boolean): _Chain; + + /** + * Changes the content of an array by removing existing elements and/or adding new elements. + * @param index Index at which to start changing the array. If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end. + * @param quantity An integer indicating the number of old array elements to remove. If deleteCount is 0, no elements are removed. In this case, you should specify at least one new element. If deleteCount is greater than the number of elements left in the array starting at index, then all of the elements through the end of the array will be deleted. + * @param items The element to add to the array. If you don't specify any elements, splice will only remove elements from the array. + * @return An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned. + **/ + splice(index: number, quantity: number, ...items: Array): _Chain; + + /** + * A string representing the specified array and its elements. + * @return A string representing the specified array and its elements. + **/ + toString(): _ChainSingle; + + /** + * Adds one or more elements to the beginning of an array and returns the new length of the array. + * @param items The elements to add to the front of the array. + * @return The array with the element added to the beginning. + **/ + unshift(...items: Array): _Chain; + + /********** * + * Chaining * + *********** */ + + /** + * Wrapped type `any`. + * @see _.chain + **/ + chain(): _Chain; + + /** + * Wrapped type `any`. + * @see _.value + **/ + value(): T[]; +} +interface _ChainSingle { + value(): T; +} +interface _ChainOfArrays extends _Chain { + flatten(): _Chain; +} + +declare var _: UnderscoreStatic; + +declare module "underscore" { + export = _; +} From ca16b900497a56549966ae11d494980ef1d6bfec Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 16 Nov 2015 05:22:30 -0800 Subject: [PATCH 02/49] Add watcher, better index --- bin/syncjs | 2 +- package.json | 11 ++++--- src/{sync.ts => classes/Sync.ts} | 10 +++++-- src/classes/Watcher.ts | 46 ++++++++++++++++++++++++++++ src/index.ts | 4 +++ typings/chokidar/chokidar.d.ts | 51 ++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 8 deletions(-) rename src/{sync.ts => classes/Sync.ts} (74%) create mode 100644 src/classes/Watcher.ts create mode 100644 src/index.ts create mode 100644 typings/chokidar/chokidar.d.ts diff --git a/bin/syncjs b/bin/syncjs index bc0b47b..d2c38ec 100644 --- a/bin/syncjs +++ b/bin/syncjs @@ -1,4 +1,4 @@ #!/usr/bin/env node -var Sync = require('../dist/sync.js'); +var Sync = require('../dist/index.js'); new Sync.default(); \ No newline at end of file diff --git a/package.json b/package.json index a7428ea..3fed3dc 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,11 @@ "name": "sync.js", "version": "0.0.1", "dependencies": { - "moment": "latest", - "cli-color": "latest", - "underscore.string": "latest" + "chokidar": "^1.2.0", + "cli-color": "latest", + "colors": "^1.1.2", + "moment": "latest", + "scp2": "^0.2.2", + "underscore.string": "latest" } -} \ No newline at end of file +} diff --git a/src/sync.ts b/src/classes/Sync.ts similarity index 74% rename from src/sync.ts rename to src/classes/Sync.ts index 8944fb2..1472f65 100644 --- a/src/sync.ts +++ b/src/classes/Sync.ts @@ -1,11 +1,13 @@ import {exec} from 'child_process'; import moment = require('moment'); -import SyncError from './classes/SyncError'; -import Config from './classes/Config'; -import CLI from './classes/CLI'; +import SyncError from './SyncError'; +import Config from './Config'; +import CLI from './CLI'; +import Watcher from './Watcher'; export default class Sync { config: Config; + watch: Watcher; cli: CLI; constructor() { @@ -13,9 +15,11 @@ export default class Sync { this.cli = new CLI( this.config.intervalDuration ); + this.watch = new Watcher(); this.connect(); } + connect() { // Test this.cli.write('Connecting'); diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts new file mode 100644 index 0000000..5d6b99d --- /dev/null +++ b/src/classes/Watcher.ts @@ -0,0 +1,46 @@ +import chokidar = require('chokidar'); + + +export default class Watcher { + files: chokidar.FSWatcher; + + constructor( + private base: string = process.cwd(), + private ignores = [], + private noDefaultIgnores = false) { + + this.files = chokidar.watch(base, { + ignored: [/node_modules/, /.git/, /.svn/, /bower_components/].concat(this.ignores), + ignoreInitial: true + }); + + // Attach events + ['all', 'add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(method => { + this.files.on(method, this[method]); + }); + } + + all = (event:string, path:string) { + console.log(event, path); + } + + add = (path: string) => { + + } + + change = (path: string) => { + // console.log(`file changed ${path}`); + } + + unlink = (path: string) => { + + } + + addDir = (path: string) => { + + } + + unlinkDir = (path: string) => { + + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..3257c05 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,4 @@ +import Sync from './classes/Sync'; + +// Main Export +export default Sync; \ No newline at end of file diff --git a/typings/chokidar/chokidar.d.ts b/typings/chokidar/chokidar.d.ts new file mode 100644 index 0000000..663197f --- /dev/null +++ b/typings/chokidar/chokidar.d.ts @@ -0,0 +1,51 @@ +// Type definitions for chokidar 1.0.0 +// Project: https://github.com/paulmillr/chokidar +// Definitions by: Stefan Steinhart +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "fs" +{ + interface FSWatcher + { + add(fileDirOrGlob:string):void; + add(filesDirsOrGlobs:Array):void; + unwatch(fileDirOrGlob:string):void; + unwatch(filesDirsOrGlobs:Array):void; + } +} + +declare module "chokidar" +{ + interface WatchOptions + { + persistent?:boolean; + ignored?:any; + ignoreInitial?:boolean; + followSymlinks?:boolean; + cwd?:string; + usePolling?:boolean; + useFsEvents?:boolean; + alwaysStat?:boolean; + depth?:number; + interval?:number; + binaryInterval?:number; + ignorePermissionErrors?:boolean; + atomic?:boolean; + } + + import fs = require("fs"); + + interface FSWatcher extends fs.FSWatcher { + add(path:string); + add(paths:string[]); // (path / paths): Add files, directories, or glob patterns for tracking. Takes an array of strings or just one string. + on(event:string, callback:Function);// Listen for an FS event. Available events: add, addDir, change, unlink, unlinkDir, ready, raw, error. Additionally all is available which gets emitted with the underlying event name and path for every event other than ready, raw, and error. + unwatch(path:string); + unwatch(paths:string[]); // : Stop watching files, directories, or glob patterns. Takes an array of strings or just one string. + close(); //: Removes all listeners from watched files. + } + + function watch( fileDirOrGlob:string, options?:WatchOptions ): FSWatcher; + function watch( filesDirsOrGlobs:Array, options?:WatchOptions ): FSWatcher; +} From d3f1d043eb1cb02c9e7058ff06dd6fd4766a3d93 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 16 Nov 2015 05:38:11 -0800 Subject: [PATCH 03/49] fix compile error --- src/classes/Watcher.ts | 2 +- tsconfig.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index 5d6b99d..ecb77c7 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -20,7 +20,7 @@ export default class Watcher { }); } - all = (event:string, path:string) { + all = (event:string, path:string) => { console.log(event, path); } diff --git a/tsconfig.json b/tsconfig.json index e95bf58..5e89dc0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "experimentalDecorators": true, "emitDecoratorMetadata": true, "sourceMap": true, + "inlineSourceMap": true, "noImplicitAny": false, "rootDir": ".", "outDir": "./dist" From 8c707f6bec59edd24132513ff910c11e5849a73f Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 16 Nov 2015 06:22:43 -0800 Subject: [PATCH 04/49] Use promises --- config_example.json | 7 ++- package.json | 1 + src/classes/CLI.ts | 23 ++++----- src/classes/Sync.ts | 28 ++++++----- src/classes/Watcher.ts | 7 +++ src/index.ts | 1 + typings/es6-promise/es6-promise.d.ts | 73 ++++++++++++++++++++++++++++ 7 files changed, 114 insertions(+), 26 deletions(-) create mode 100644 typings/es6-promise/es6-promise.d.ts diff --git a/config_example.json b/config_example.json index 7a933ab..a1950c8 100644 --- a/config_example.json +++ b/config_example.json @@ -1,6 +1,5 @@ { - "host": "username@ssh.yourhost.com", - "interval_duration": 1.5, - "local_path": "/path/to/local/folder", - "remote_path": "/path/to/remote/folder" + "host": "username@ssh.example.com", + "localPath": "/path/to/local/folder", + "remotePath": "/path/to/remote/folder" } \ No newline at end of file diff --git a/package.json b/package.json index 3fed3dc..bed4c7a 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "chokidar": "^1.2.0", "cli-color": "latest", "colors": "^1.1.2", + "es6-promise": "^3.0.2", "moment": "latest", "scp2": "^0.2.2", "underscore.string": "latest" diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index b0febdb..0a8c175 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -9,7 +9,7 @@ export default class CLI { private lastRun: number; private timeDiff: number; - paused: boolean; + public paused: boolean; constructor(public secondsInterval: number) { try { @@ -29,10 +29,11 @@ export default class CLI { } + /** * Start printing dots to screen, show script is working */ - dotsStart() { + startProgress() { this.pdTime = setInterval(() => { this.write('.'.yellow); }, 200); @@ -41,11 +42,11 @@ export default class CLI { /** * Stop printing dots when process ends */ - dotsStop() { + stopProgress() { clearInterval(this.pdTime); } - printTitle() { + workspace() { this.write('\n'.reset); if (this.paused) { @@ -59,11 +60,11 @@ export default class CLI { this.showPrompt(); } - getHelp(command, text) { + private getHelp(command, text) { return `${command.green}: ${text}\n`; } - showPrompt() { + private showPrompt() { this.rline.question(">>> ", answer => { this.handleInput(answer); // as soon as a command is run, show promt again just a like a real shell @@ -71,7 +72,7 @@ export default class CLI { }); } - handleInput(input) { + private handleInput(input) { input = input.split(' '); let cmd = input[0]; let arg1 = input[1]; @@ -88,14 +89,14 @@ export default class CLI { this.write(helpText); break; case "clear": - this.printTitle(); + this.workspace(); break; case "exit": process.exit(0); break; case "pause": this.paused = true; - this.printTitle(); + this.workspace(); break; case "resume": if (this.paused) { @@ -104,7 +105,7 @@ export default class CLI { this.timeDiff = 0; } this.paused = false; - this.printTitle(); + this.workspace(); if (arg1 == "-u") { this.write('Finding all changed files while waiting.\n'); } @@ -116,7 +117,7 @@ export default class CLI { case "interval": if (arg1) { this.secondsInterval = parseFloat(arg1) || this.secondsInterval; - this.printTitle(); + this.workspace(); } this.write(`Check interval is ${ this.secondsInterval } Seconds\n`); break; diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index 1472f65..fe69801 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -11,23 +11,29 @@ export default class Sync { cli: CLI; constructor() { + this.config = new Config(); this.cli = new CLI( this.config.intervalDuration ); - this.watch = new Watcher(); - this.connect(); - } - - connect() { - // Test this.cli.write('Connecting'); - this.cli.dotsStart(); + this.cli.startProgress(); + + this.watch = new Watcher(); + this.watch.ready().then(() => { + return this.connect(); + }).then(() => { + this.cli.stopProgress(); + this.cli.workspace(); + }); + } - setTimeout(() => { - this.cli.dotsStop(); - this.cli.printTitle(); - }, 5000); + connect(): Promise { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve('connected'); + }, 5000); + }); } } \ No newline at end of file diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index ecb77c7..6c9f670 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -20,6 +20,13 @@ export default class Watcher { }); } + ready(): Promise { + let deferred = new Promise((resolve) => { + this.files.on('ready', resolve); + }); + return deferred + } + all = (event:string, path:string) => { console.log(event, path); } diff --git a/src/index.ts b/src/index.ts index 3257c05..4755ce7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import Sync from './classes/Sync'; +import 'es6-promise'; // Main Export export default Sync; \ No newline at end of file diff --git a/typings/es6-promise/es6-promise.d.ts b/typings/es6-promise/es6-promise.d.ts new file mode 100644 index 0000000..86c8227 --- /dev/null +++ b/typings/es6-promise/es6-promise.d.ts @@ -0,0 +1,73 @@ +// Type definitions for es6-promise +// Project: https://github.com/jakearchibald/ES6-Promise +// Definitions by: François de Campredon , vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface Thenable { + then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; + then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; +} + +declare class Promise implements Thenable { + /** + * If you call resolve in the body of the callback passed to the constructor, + * your promise is fulfilled with result object passed to resolve. + * If you call reject your promise is rejected with the object passed to resolve. + * For consistency and debugging (eg stack traces), obj should be an instanceof Error. + * Any errors thrown in the constructor callback will be implicitly passed to reject(). + */ + constructor(callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); + + /** + * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. + * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. + * Both callbacks have a single parameter , the fulfillment value or rejection reason. + * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. + * If an error is thrown in the callback, the returned promise rejects with that error. + * + * @param onFulfilled called when/if "promise" resolves + * @param onRejected called when/if "promise" rejects + */ + then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; + then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; + + /** + * Sugar for promise.then(undefined, onRejected) + * + * @param onRejected called when/if "promise" rejects + */ + catch(onRejected?: (error: any) => U | Thenable): Promise; +} + +declare module Promise { + /** + * Make a new promise from the thenable. + * A thenable is promise-like in as far as it has a "then" method. + */ + function resolve(value?: R | Thenable): Promise; + + /** + * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error + */ + function reject(error: any): Promise; + + /** + * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. + * the array passed to all can be a mixture of promise-like objects and other objects. + * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. + */ + function all(promises: (R | Thenable)[]): Promise; + + /** + * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. + */ + function race(promises: (R | Thenable)[]): Promise; +} + +declare module 'es6-promise' { + var foo: typeof Promise; // Temp variable to reference Promise in local context + module rsvp { + export var Promise: typeof foo; + } + export = rsvp; +} From 1af6f30c7c75ba8678f8819358e46b4464ffef90 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 16 Nov 2015 07:19:58 -0800 Subject: [PATCH 05/49] switch to chalk, remove unused dependencies --- .vscode/tasks.json | 3 + package.json | 6 +- src/classes/CLI.ts | 55 +- src/classes/Sync.ts | 6 +- tsconfig.json | 1 - typings/chalk/chalk.d.ts | 93 + typings/colors/colors.d.ts | 123 - .../underscore.string/underscore.string.d.ts | 573 --- typings/underscore/underscore.d.ts | 3413 ----------------- 9 files changed, 132 insertions(+), 4141 deletions(-) create mode 100644 typings/chalk/chalk.d.ts delete mode 100644 typings/colors/colors.d.ts delete mode 100644 typings/underscore.string/underscore.string.d.ts delete mode 100644 typings/underscore/underscore.d.ts diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 2ccfef3..1058306 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -20,6 +20,9 @@ // Show the output window only if unrecognized errors occur. "showOutput": "silent", + // Tell the tsc compiler to use the tsconfig.json from the open folder. + "args": ["-p", "."], + // use the standard tsc problem matcher to find compile problems // in the output. "problemMatcher": "$tsc" diff --git a/package.json b/package.json index bed4c7a..f226764 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,10 @@ "name": "sync.js", "version": "0.0.1", "dependencies": { + "chalk": "^1.1.1", "chokidar": "^1.2.0", - "cli-color": "latest", - "colors": "^1.1.2", "es6-promise": "^3.0.2", "moment": "latest", - "scp2": "^0.2.2", - "underscore.string": "latest" + "scp2": "^0.2.2" } } diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 0a8c175..5481aeb 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,5 +1,4 @@ -import 'colors'; -import { sprintf, endsWith } from 'underscore.string'; +import chalk = require('chalk'); import readline = require('readline'); export default class CLI { @@ -11,7 +10,7 @@ export default class CLI { public paused: boolean; - constructor(public secondsInterval: number) { + constructor() { try { this.rline = readline.createInterface({ input: process.stdin, @@ -24,18 +23,26 @@ export default class CLI { } } - write(msg: string): boolean { - return process.stdout.write.bind(process.stdout)(msg); + /** + * Clear the terminal + */ + clear() { + this.write(chalk.reset('\x1b[2J\x1b[0;0H')); } - + /** + * Write something to terminal + */ + write(msg: string | Chalk.ChalkChain): boolean { + return process.stdout.write.bind(process.stdout)(msg); + } /** * Start printing dots to screen, show script is working */ startProgress() { this.pdTime = setInterval(() => { - this.write('.'.yellow); + this.write(chalk.green('.')) }, 200); } @@ -46,24 +53,33 @@ export default class CLI { clearInterval(this.pdTime); } + /** + * Display the workspace for syncjs + */ workspace() { - this.write('\n'.reset); + this.clear(); if (this.paused) { - this.write(`Currently paused, type "${ 'resume'.green }" to start again.\n`); + this.write(`Currently paused, type "${ chalk.green('resume') }" to start again.\n`); } else { - this.write(`Started monitoring, checking every ${ this.secondsInterval } seconds.\n`); + this.write(`Started monitoring \n`); } - this.write(`Quit the script with CONTROL-C or type "${ 'exit'.green}".\n`); - this.write('-----------------------------------------------------------\n'.magenta); + this.write(`Quit the script with CONTROL-C or type "${ chalk.green('exit') }".\n`); + this.write(chalk.magenta('-----------------------------------------------------------\n')); this.showPrompt(); } + /** + * Shorthand command to print help text + */ private getHelp(command, text) { - return `${command.green}: ${text}\n`; + return `${ chalk.green(command) }: ${text}\n`; } + /** + * Display the prompt that asks for input + */ private showPrompt() { this.rline.question(">>> ", answer => { this.handleInput(answer); @@ -72,6 +88,9 @@ export default class CLI { }); } + /** + * Handle given input + */ private handleInput(input) { input = input.split(' '); let cmd = input[0]; @@ -82,7 +101,6 @@ export default class CLI { helpText += this.getHelp('pause', "Stops observing file changes"); helpText += this.getHelp('resume', "Continue checking files"); helpText += this.getHelp('resume -u', "Continue checking files and upload all the changed files while paused."); - helpText += this.getHelp('interval [s]', 'Sets the check interval duration. Example: "interval 2.5" check for every 2.5 seconds'); helpText += this.getHelp('help', "Displays this text"); helpText += this.getHelp('clear', "Clears the screen"); helpText += this.getHelp('exit', "Exits the script"); @@ -114,16 +132,9 @@ export default class CLI { this.write('Already running\n'); } break; - case "interval": - if (arg1) { - this.secondsInterval = parseFloat(arg1) || this.secondsInterval; - this.workspace(); - } - this.write(`Check interval is ${ this.secondsInterval } Seconds\n`); - break; case "": break; default: - this.write(`Unknown command: ${ cmd }\nType "help" to see commands`.red); + this.write(chalk.red(`Unknown command: ${ cmd }\nType "help" to see commands`)); } } } \ No newline at end of file diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index fe69801..de02892 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -1,5 +1,3 @@ -import {exec} from 'child_process'; -import moment = require('moment'); import SyncError from './SyncError'; import Config from './Config'; import CLI from './CLI'; @@ -13,9 +11,7 @@ export default class Sync { constructor() { this.config = new Config(); - this.cli = new CLI( - this.config.intervalDuration - ); + this.cli = new CLI(); this.cli.write('Connecting'); this.cli.startProgress(); diff --git a/tsconfig.json b/tsconfig.json index 5e89dc0..bbc4a66 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,6 @@ "target": "es5", "experimentalDecorators": true, "emitDecoratorMetadata": true, - "sourceMap": true, "inlineSourceMap": true, "noImplicitAny": false, "rootDir": ".", diff --git a/typings/chalk/chalk.d.ts b/typings/chalk/chalk.d.ts new file mode 100644 index 0000000..ede2947 --- /dev/null +++ b/typings/chalk/chalk.d.ts @@ -0,0 +1,93 @@ +// Type definitions for chalk v0.4.0 +// Project: https://github.com/sindresorhus/chalk +// Definitions by: Diullei Gomes , Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Chalk { + export interface ChalkModule extends ChalkStyle { + enabled: boolean; + supportsColor: boolean; + styles: ChalkStyleMap; + + stripColor(value: string): any; + hasColor(str: string): boolean; + } + + export interface ChalkChain extends ChalkStyle { + (...text: string[]): ChalkChain; + } + + export interface ChalkStyleElement { + open: string; + close: string; + } + + export interface ChalkStyle { + // General + reset: ChalkChain; + bold: ChalkChain; + italic: ChalkChain; + underline: ChalkChain; + inverse: ChalkChain; + strikethrough: ChalkChain; + + // Text colors + black: ChalkChain; + red: ChalkChain; + green: ChalkChain; + yellow: ChalkChain; + blue: ChalkChain; + magenta: ChalkChain; + cyan: ChalkChain; + white: ChalkChain; + gray: ChalkChain; + grey: ChalkChain; + + // Background colors + bgBlack: ChalkChain; + bgRed: ChalkChain; + bgGreen: ChalkChain; + bgYellow: ChalkChain; + bgBlue: ChalkChain; + bgMagenta: ChalkChain; + bgCyan: ChalkChain; + bgWhite: ChalkChain; + } + + export interface ChalkStyleMap { + // General + reset: ChalkStyleElement; + bold: ChalkStyleElement; + italic: ChalkStyleElement; + underline: ChalkStyleElement; + inverse: ChalkStyleElement; + strikethrough: ChalkStyleElement; + + // Text colors + black: ChalkStyleElement; + red: ChalkStyleElement; + green: ChalkStyleElement; + yellow: ChalkStyleElement; + blue: ChalkStyleElement; + magenta: ChalkStyleElement; + cyan: ChalkStyleElement; + white: ChalkStyleElement; + gray: ChalkStyleElement; + + // Background colors + bgBlack: ChalkStyleElement; + bgRed: ChalkStyleElement; + bgGreen: ChalkStyleElement; + bgYellow: ChalkStyleElement; + bgBlue: ChalkStyleElement; + bgMagenta: ChalkStyleElement; + bgCyan: ChalkStyleElement; + bgWhite: ChalkStyleElement; + } +} + +declare module "chalk" { + var ch: Chalk.ChalkModule; + export = ch; +} + diff --git a/typings/colors/colors.d.ts b/typings/colors/colors.d.ts deleted file mode 100644 index 5aa2855..0000000 --- a/typings/colors/colors.d.ts +++ /dev/null @@ -1,123 +0,0 @@ -// Type definitions for Colors.js 0.6.0-1 -// Project: https://github.com/Marak/colors.js -// Definitions by: Bart van der Schoor -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module "colors" { - interface Color { - (text: string): string; - - black: Color; - red: Color; - green: Color; - yellow: Color; - blue: Color; - magenta: Color; - cyan: Color; - white: Color; - gray: Color; - grey: Color; - - bgBlack: Color; - bgRed: Color; - bgGreen: Color; - bgYellow: Color; - bgBlue: Color; - bgMagenta: Color; - bgCyan: Color; - bgWhite: Color; - - reset: Color; - bold: Color; - dim: Color; - italic: Color; - underline: Color; - inverse: Color; - hidden: Color; - strikethrough: Color; - - rainbow: Color; - zebra: Color; - america: Color; - trap: Color; - random: Color; - } - - module e { - export function setTheme(theme:any): void; - - export var black: Color; - export var red: Color; - export var green: Color; - export var yellow: Color; - export var blue: Color; - export var magenta: Color; - export var cyan: Color; - export var white: Color; - export var gray: Color; - export var grey: Color; - - export var bgBlack: Color; - export var bgRed: Color; - export var bgGreen: Color; - export var bgYellow: Color; - export var bgBlue: Color; - export var bgMagenta: Color; - export var bgCyan: Color; - export var bgWhite: Color; - - export var reset: Color; - export var bold: Color; - export var dim: Color; - export var italic: Color; - export var underline: Color; - export var inverse: Color; - export var hidden: Color; - export var strikethrough: Color; - - export var rainbow: Color; - export var zebra: Color; - export var america: Color; - export var trap: Color; - export var random: Color; - } - - export = e; -} - -interface String { - black: string; - red: string; - green: string; - yellow: string; - blue: string; - magenta: string; - cyan: string; - white: string; - gray: string; - grey: string; - - bgBlack: string; - bgRed: string; - bgGreen: string; - bgYellow: string; - bgBlue: string; - bgMagenta: string; - bgCyan: string; - bgWhite: string; - - reset: string; - bold: string; - dim: string; - italic: string; - underline: string; - inverse: string; - hidden: string; - strikethrough: string; - - rainbow: string; - zebra: string; - america: string; - trap: string; - random: string; -} diff --git a/typings/underscore.string/underscore.string.d.ts b/typings/underscore.string/underscore.string.d.ts deleted file mode 100644 index 1b08dcf..0000000 --- a/typings/underscore.string/underscore.string.d.ts +++ /dev/null @@ -1,573 +0,0 @@ -// Type definitions for underscore.string -// Project: https://github.com/epeli/underscore.string -// Definitions by: Ry Racherbaumer -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -interface UnderscoreStatic { - str: UnderscoreStringStatic; - string: UnderscoreStringStatic; -} - -declare var s : UnderscoreStringStatic; - -interface UnderscoreStringStatic extends UnderscoreStringStaticExports { - /** - * Tests if string contains a substring. - * ('foobar', 'ob') => true - * @param str - * @param needle - */ - include(str: string, needle: string): boolean; - - /** - * Tests if string contains a substring. - * ('foobar', 'ob') => true - * @param str - * @param needle - */ - contains(str: string, needle: string): boolean; - - /** - * Return reversed string. - * ('foobar') => 'raboof' - * @param str - */ - reverse(str: string): string; -} - -/** - * Functions exported for mixing with underscore object. - * - * Usage: - * _.mixin(_.string.exports()); - * interface UnderscoreStatic extends UnderscoreStringStaticExports { } - */ -interface UnderscoreStringStaticExports { - - exports(): UnderscoreStringStaticExports; - - /** - * Determine if a string is 'blank.' - * @param str - */ - isBlank(str: string): boolean; - - /** - * Removes all html tags from string. - * @param str - */ - stripTags(str: string): string; - - /** - * Converts first letter of the string to uppercase. - * ('foo Bar') => 'Foo Bar' - * @param str - */ - capitalize(str: string): string; - - /** - * Chop a string into pieces. - * ('whitespace', 3) => ['whi','tes','pac','e'] - * @param str String to chop - * @param step Size of the pieces - */ - chop(str: string, step: number): any[]; - - /** - * Compress some whitespaces to one. - * (' foo bar ') => 'foo bar' - * @param str - */ - clean(str: string): string; - - /** - * Count occurences of a sub string. - * ('Hello world', 'l') => 3 - * @param str - * @param substr - */ - count(str: string, substr: string): number; - - /** - * Convert string to an array of characters. - * ('Hello') => ['H','e','l','l','o'] - * @param str - */ - chars(str: string): any[]; - - /** - * Returns a copy of the string in which all the case-based characters have had their case swapped. - * ('hELLO') => 'Hello' - * @param str - */ - swapCase(str: string): string; - - /** - * Converts HTML special characters to their entity equivalents. - * ('
Blah blah blah
') => '<div>Blah blah blah</div>' - * @param str - */ - escapeHTML(str: string): string; - - /** - * Converts entity characters to HTML equivalents. - * ('<div>Blah blah blah</div>') => '
Blah blah blah
' - * @param str - */ - unescapeHTML(str: string): string; - - /** - * Escape a string for use in a regular expression. - * @param str - */ - escapeRegExp(str: string): string; - - /** - * Splice a string like an array. - * @param str - * @param i - * @param howmany - * @param substr - */ - splice(str: string, i: number, howmany: number, substr?: string): string; - - /** - * Insert a string at index. - * @param str - * @param i - * @param substr - */ - insert(str: string, i: number, substr: string): string; - - /** - * Joins strings together with given separator. - * (' ', 'foo', 'bar') => 'foo bar' - * @param separator - * @param args - */ - join(separator: string, ...args: string[]): string; - - /** - * Split string by newlines character. - * ('Hello\nWorld') => ['Hello', 'World'] - * @param str - */ - lines(str: string): any[]; - - /** - * Checks if string starts with another string. - * ('image.gif', 'image') => true - * @param str - * @param starts - */ - startsWith(str: string, starts: string): boolean; - - /** - * Checks if string ends with another string. - * ('image.gif', 'gif') => true - * @param value - * @param starts - */ - endsWith(value: string, starts: string): boolean; - - /** - * Returns the successor to passed string. - * ('a') => 'b' - * @param str - */ - succ(str: string): string; - - /** - * Capitalize first letter of every word in the string. - * ('my name is epeli') => 'My Name Is Epeli' - * @param str - */ - titleize(str: string): string; - - /** - * Converts underscored or dasherized string to a camelized one. - * ('-moz-transform') => 'MozTransform' - * @param str - */ - camelize(str: string): string; - - /** - * Converts a camelized or dasherized string into an underscored one. - * ('MozTransform') => 'moz_transform' - * @param str - */ - underscored(str: string): string; - - /** - * Converts a underscored or camelized string into an dasherized one. - * ('MozTransform') => '-moz-transform' - * @param str - */ - dasherize(str: string): string; - - /** - * Converts string to camelized class name. - * ('some_class_name') => 'SomeClassName' - * @param str - */ - classify(str: string): string; - - /** - * Converts an underscored, camelized, or dasherized string into a humanized one. - * Also removes beginning and ending whitespace, and removes the postfix '_id'. - * (' capitalize dash-CamelCase_underscore trim ') => 'Capitalize dash camel case underscore trim' - * @param str - */ - humanize(str: string): string; - - /** - * Trims defined characters from begining and ending of the string. - * Defaults to whitespace characters. - * (' foobar ') => 'foobar' - * ('_-foobar-_', '_-') => 'foobar' - * @param str - * @param characters - */ - trim(str: string, characters?: string): string; - - /** - * Trims defined characters from begining and ending of the string. - * Defaults to whitespace characters. - * (' foobar ') => 'foobar' - * ('_-foobar-_', '_-') => 'foobar' - * @param str - * @param characters - */ - strip(str: string, characters?: string): string; - - /** - * Left trim. Similar to trim, but only for left side. - * @param str - * @param characters - */ - ltrim(str: string, characters?: string): string; - - /** - * Left trim. Similar to trim, but only for left side. - * @param str - * @param characters - */ - lstrip(str: string, characters?: string): string; - - /** - * Right trim. Similar to trim, but only for right side. - * @param str - * @param characters - */ - rtrim(str: string, characters?: string): string; - - /** - * Right trim. Similar to trim, but only for right side. - * @param str - * @param characters - */ - rstrip(str: string, characters?: string): string; - - /** - * Truncate string to specified length. - * ('Hello world').truncate(5) => 'Hello...' - * ('Hello').truncate(10) => 'Hello' - * @param str - * @param length - * @param truncateStr - */ - truncate(str: string, length: number, truncateStr?: string): string; - - /** - * Elegant version of truncate. - * Makes sure the pruned string does not exceed the original length. - * Avoid half-chopped words when truncating. - * ('Hello, cruel world', 15) => 'Hello, cruel...' - * @param str - * @param length - * @param pruneStr - */ - prune(str: string, length: number, pruneStr?: string): string; - - /** - * Split string by delimiter (String or RegExp). - * /\s+/ by default. - * (' I love you ') => ['I','love','you'] - * ('I_love_you', '_') => ['I','love','you'] - * @param str - * @param delimiter - */ - words(str: string): string[]; - - /** - * Split string by delimiter (String or RegExp). - * /\s+/ by default. - * (' I love you ') => ['I','love','you'] - * ('I_love_you', '_') => ['I','love','you'] - * @param str - * @param delimiter - */ - words(str: string, delimiter: string): string[]; - - /** - * Split string by delimiter (String or RegExp). - * /\s+/ by default. - * (' I love you ') => ['I','love','you'] - * ('I_love_you', '_') => ['I','love','you'] - * @param str - * @param delimiter - */ - words(str: string, delimiter: RegExp): string[]; - - /** - * Pads a string with characters until the total string length is equal to the passed length parameter. - * By default, pads on the left with the space char (' '). - * padStr is truncated to a single character if necessary. - * ('1', 8) => ' 1' - * ('1', 8, '0') => '00000001' - * ('1', 8, '0', 'right') => '10000000' - * ('1', 8, '0', 'both') => '00001000' - * ('1', 8, 'bleepblorp', 'both') => 'bbbb1bbb' - * @param str - * @param length - * @param padStr - * @param type - */ - pad(str: string, length: number, padStr?:string, type?: string): string; - - /** - * Left-pad a string. - * Alias for pad(str, length, padStr, 'left') - * ('1', 8, '0') => '00000001' - * @param str - * @param length - * @param padStr - */ - lpad(str: string, length: number, padStr?: string): string; - - /** - * Left-pad a string. - * Alias for pad(str, length, padStr, 'left') - * ('1', 8, '0') => '00000001' - * @param str - * @param length - * @param padStr - */ - rjust(str: string, length: number, padStr?: string): string; - - /** - * Right-pad a string. - * Alias for pad(str, length, padStr, 'right') - * ('1', 8, '0') => '10000000' - * @param str - * @param length - * @param padStr - */ - rpad(str: string, length: number, padStr?: string): string; - - /** - * Right-pad a string. - * Alias for pad(str, length, padStr, 'right') - * ('1', 8, '0') => '10000000' - * @param str - * @param length - * @param padStr - */ - ljust(str: string, length: number, padStr?: string): string; - - /** - * Left/right-pad a string. - * Alias for pad(str, length, padStr, 'both') - * ('1', 8, '0') => '00001000' - * @param str - * @param length - * @param padStr - */ - lrpad(str: string, length: number, padStr?: string): string; - - /** - * Left/right-pad a string. - * Alias for pad(str, length, padStr, 'both') - * ('1', 8, '0') => '00001000' - * @param str - * @param length - * @param padStr - */ - center(str: string, length: number, padStr?: string): string; - - /** - * C like string formatting. - * _.sprintf('%.1f', 1.17) => '1.2' - * @param format - * @param args - */ - sprintf(format: string, ...args: any[]): string; - - /** - * Parse string to number. - * Returns NaN if string can't be parsed to number. - * ('2.556').toNumber() => 3 - * ('2.556').toNumber(1) => 2.6 - * @param str - * @param decimals - */ - toNumber(str: string, decimals?: number): number; - - /** - * Formats the numbers. - * (1000, 2) => '1,000.00' - * (123456789.123, 5, '.', ',') => '123,456,789.12300' - * @param number - * @param dec - * @param dsep - * @param tsep - */ - numberFormat(number: number, dec?: number, dsep?: string, tsep?: string): string; - - /** - * Searches a string from left to right for a pattern. - * Returns a substring consisting of the characters in the string that are to the right of the pattern. - * If no match found, returns entire string. - * ('This_is_a_test_string').strRight('_') => 'is_a_test_string' - * @param str - * @param sep - */ - strRight(str: string, sep: string): string; - - /** - * Searches a string from right to left for a pattern. - * Returns a substring consisting of the characters in the string that are to the right of the pattern. - * If no match found, returns entire string. - * ('This_is_a_test_string').strRightBack('_') => 'string' - * @param str - * @param sep - */ - strRightBack(str: string, sep: string): string; - - /** - * Searches a string from left to right for a pattern. - * Returns a substring consisting of the characters in the string that are to the left of the pattern. - * If no match found, returns entire string. - * ('This_is_a_test_string').strLeft('_') => 'This' - * @param str - * @param sep - */ - strLeft(str: string, sep: string): string; - - /** - * Searches a string from right to left for a pattern. - * Returns a substring consisting of the characters in the string that are to the left of the pattern. - * If no match found, returns entire string. - * ('This_is_a_test_string').strLeftBack('_') => 'This_is_a_test' - * @param str - * @param sep - */ - strLeftBack(str: string, sep: string): string; - - /** - * Join an array into a human readable sentence. - * (['jQuery', 'Mootools', 'Prototype']) => 'jQuery, Mootools and Prototype' - * (['jQuery', 'Mootools', 'Prototype'], ', ', ' unt ') => 'jQuery, Mootools unt Prototype' - * @param array - * @param separator - * @param lastSeparator - * @param serial - */ - toSentence(array: any[], separator?: string, lastSeparator?: string, serial?: boolean): string; - - /** - * The same as toSentence, but uses ', ' as default for lastSeparator. - * @param array - * @param separator - * @param lastSeparator - */ - toSentenceSerial(array: any[], separator?: string, lastSeparator?: string): string; - - /** - * Transform text into a URL slug. Replaces whitespaces, accentuated, and special characters with a dash. - * ('Un éléphant à l'orée du bois') => 'un-elephant-a-loree-du-bois' - * @param str - */ - slugify(str: string): string; - - /** - * Surround a string with another string. - * ('foo', 'ab') => 'abfooab' - * @param str - * @param wrapper - */ - surround(str: string, wrapper: string): string; - - /** - * Quotes a string. - * quoteChar defaults to " - * ('foo') => '"foo"' - * @param str - */ - quote(str: string, quoteChar?: string): string; - - /** - * Quotes a string. - * quoteChar defaults to " - * ('foo') => '"foo"' - * @param str - */ - q(str: string, quoteChar?: string): string; - - /** - * Unquotes a string. - * quoteChar defaults to " - * ('"foo"') => 'foo' - * ("'foo'", "'") => 'foo' - * @param str - */ - unquote(str: string, quoteChar?: string): string; - - /** - * Repeat a string with an optional separator. - * ('foo', 3) => 'foofoofoo' - * ('foo', 3, 'bar') => 'foobarfoobarfoo' - * @param value - * @param count - * @param separator - */ - repeat(value: string, count: number, separator?:string): string; - - /** - * Naturally sort strings like humans would do. - * Caution: this function is charset dependent. - * @param str1 - * @param str2 - */ - naturalCmp(str1: string, str2: string): number; - - /** - * Calculates Levenshtein distance between two strings. - * ('kitten', 'kittah') => 2 - * @param str1 - * @param str2 - */ - levenshtein(str1: string, str2: string): number; - - /** - * Turn strings that can be commonly considered as booleans to real booleans. - * Such as "true", "false", "1" and "0". This function is case insensitive. - * ('true') => true - * ('FALSE') => false - * ('random') => undefined - * ('truthy', ['truthy'], ['falsy']) => true - * ('true only at start', [/^true/]) => true - * @param str - * @param trueValues - * @param falseValues - */ - toBoolean(str: string, trueValues?: any[], falseValues?: any[]): boolean; - -} -declare module 'underscore.string' { - var underscoreString: UnderscoreStringStatic; - export = underscoreString; -} -// TODO interface UnderscoreString extends Underscore diff --git a/typings/underscore/underscore.d.ts b/typings/underscore/underscore.d.ts deleted file mode 100644 index 7dea66a..0000000 --- a/typings/underscore/underscore.d.ts +++ /dev/null @@ -1,3413 +0,0 @@ -// Type definitions for Underscore 1.7.0 -// Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module _ { - /** - * underscore.js _.throttle options. - **/ - interface ThrottleSettings { - - /** - * If you'd like to disable the leading-edge call, pass this as false. - **/ - leading?: boolean; - - /** - * If you'd like to disable the execution on the trailing-edge, pass false. - **/ - trailing?: boolean; - } - - /** - * underscore.js template settings, set templateSettings or pass as an argument - * to 'template()' to override defaults. - **/ - interface TemplateSettings { - /** - * Default value is '/<%([\s\S]+?)%>/g'. - **/ - evaluate?: RegExp; - - /** - * Default value is '/<%=([\s\S]+?)%>/g'. - **/ - interpolate?: RegExp; - - /** - * Default value is '/<%-([\s\S]+?)%>/g'. - **/ - escape?: RegExp; - } - - interface Collection { } - - // Common interface between Arrays and jQuery objects - interface List extends Collection { - [index: number]: T; - length: number; - } - - interface Dictionary extends Collection { - [index: string]: T; - } - - interface ListIterator { - (value: T, index: number, list: List): TResult; - } - - interface ObjectIterator { - (element: T, key: string, list: Dictionary): TResult; - } - - interface MemoIterator { - (prev: TResult, curr: T, index: number, list: List): TResult; - } - - interface MemoObjectIterator { - (prev: TResult, curr: T, key: string, list: Dictionary): TResult; - } -} - -interface UnderscoreStatic { - /** - * Underscore OOP Wrapper, all Underscore functions that take an object - * as the first parameter can be invoked through this function. - * @param key First argument to Underscore object functions. - **/ - (value: Array): Underscore; - (value: T): Underscore; - - /* ************* - * Collections * - ************* */ - - /** - * Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is - * bound to the context object, if one is passed. Each invocation of iterator is called with three - * arguments: (element, index, list). If list is a JavaScript object, iterator's arguments will be - * (value, key, object). Delegates to the native forEach function if it exists. - * @param list Iterates over this list of elements. - * @param iterator Iterator function for each element `list`. - * @param context 'this' object in `iterator`, optional. - **/ - each( - list: _.List, - iterator: _.ListIterator, - context?: any): _.List; - - /** - * @see _.each - * @param object Iterates over properties of this object. - * @param iterator Iterator function for each property on `object`. - * @param context 'this' object in `iterator`, optional. - **/ - each( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): _.Dictionary; - - /** - * @see _.each - **/ - forEach( - list: _.List, - iterator: _.ListIterator, - context?: any): _.List; - - /** - * @see _.each - **/ - forEach( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): _.Dictionary; - - /** - * Produces a new array of values by mapping each value in list through a transformation function - * (iterator). If the native map method exists, it will be used instead. If list is a JavaScript - * object, iterator's arguments will be (value, key, object). - * @param list Maps the elements of this array. - * @param iterator Map iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The mapped array result. - **/ - map( - list: _.List, - iterator: _.ListIterator, - context?: any): TResult[]; - - /** - * @see _.map - * @param object Maps the properties of this object. - * @param iterator Map iterator function for each property on `object`. - * @param context `this` object in `iterator`, optional. - * @return The mapped object result. - **/ - map( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): TResult[]; - - /** - * @see _.map - **/ - collect( - list: _.List, - iterator: _.ListIterator, - context?: any): TResult[]; - - /** - * @see _.map - **/ - collect( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): TResult[]; - - /** - * Also known as inject and foldl, reduce boils down a list of values into a single value. - * Memo is the initial state of the reduction, and each successive step of it should be - * returned by iterator. The iterator is passed four arguments: the memo, then the value - * and index (or key) of the iteration, and finally a reference to the entire list. - * @param list Reduces the elements of this array. - * @param iterator Reduce iterator function for each element in `list`. - * @param memo Initial reduce state. - * @param context `this` object in `iterator`, optional. - * @return Reduced object result. - **/ - reduce( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - reduce( - list: _.Dictionary, - iterator: _.MemoObjectIterator, - memo?: TResult, - context?: any): TResult; - - /** - * @see _.reduce - **/ - inject( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * @see _.reduce - **/ - foldl( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * The right-associative version of reduce. Delegates to the JavaScript 1.8 version of - * reduceRight, if it exists. `foldr` is not as useful in JavaScript as it would be in a - * language with lazy evaluation. - * @param list Reduces the elements of this array. - * @param iterator Reduce iterator function for each element in `list`. - * @param memo Initial reduce state. - * @param context `this` object in `iterator`, optional. - * @return Reduced object result. - **/ - reduceRight( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * @see _.reduceRight - **/ - foldr( - list: _.Collection, - iterator: _.MemoIterator, - memo?: TResult, - context?: any): TResult; - - /** - * Looks through each value in the list, returning the first one that passes a truth - * test (iterator). The function returns as soon as it finds an acceptable element, - * and doesn't traverse the entire list. - * @param list Searches for a value in this list. - * @param iterator Search iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The first acceptable found element in `list`, if nothing is found undefined/null is returned. - **/ - find( - list: _.List, - iterator: _.ListIterator, - context?: any): T; - - /** - * @see _.find - **/ - find( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T; - - /** - * @see _.find - **/ - detect( - list: _.List, - iterator: _.ListIterator, - context?: any): T; - - /** - * @see _.find - **/ - detect( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T; - - /** - * Looks through each value in the list, returning the index of the first one that passes a truth - * test (iterator). The function returns as soon as it finds an acceptable element, - * and doesn't traverse the entire list. - * @param list Searches for a value in this list. - * @param iterator Search iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The index of the first acceptable found element in `list`, if nothing is found -1 is returned. - **/ - findIndex( - list: _.List, - iterator: _.ListIterator, - context?: any): number; - - - /** - * Looks through each value in the list, returning an array of all the values that pass a truth - * test (iterator). Delegates to the native filter method, if it exists. - * @param list Filter elements out of this list. - * @param iterator Filter iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The filtered list of elements. - **/ - filter( - list: _.List, - iterator: _.ListIterator, - context?: any): T[]; - - /** - * @see _.filter - **/ - filter( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T[]; - - /** - * @see _.filter - **/ - select( - list: _.List, - iterator: _.ListIterator, - context?: any): T[]; - - /** - * @see _.filter - **/ - select( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T[]; - - /** - * Looks through each value in the list, returning an array of all the values that contain all - * of the key-value pairs listed in properties. - * @param list List to match elements again `properties`. - * @param properties The properties to check for on each element within `list`. - * @return The elements within `list` that contain the required `properties`. - **/ - where( - list: _.List, - properties: U): T[]; - - /** - * Looks through the list and returns the first value that matches all of the key-value pairs listed in properties. - * @param list Search through this list's elements for the first object with all `properties`. - * @param properties Properties to look for on the elements within `list`. - * @return The first element in `list` that has all `properties`. - **/ - findWhere( - list: _.List, - properties: U): T; - - /** - * Returns the values in list without the elements that the truth test (iterator) passes. - * The opposite of filter. - * Return all the elements for which a truth test fails. - * @param list Reject elements within this list. - * @param iterator Reject iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return The rejected list of elements. - **/ - reject( - list: _.List, - iterator: _.ListIterator, - context?: any): T[]; - - /** - * @see _.reject - **/ - reject( - object: _.Dictionary, - iterator: _.ObjectIterator, - context?: any): T[]; - - /** - * Returns true if all of the values in the list pass the iterator truth test. Delegates to the - * native method every, if present. - * @param list Truth test against all elements within this list. - * @param iterator Trust test iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return True if all elements passed the truth test, otherwise false. - **/ - every( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.every - **/ - every( - list: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - /** - * @see _.every - **/ - all( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.every - **/ - all( - list: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - /** - * Returns true if any of the values in the list pass the iterator truth test. Short-circuits and - * stops traversing the list if a true element is found. Delegates to the native method some, if present. - * @param list Truth test against all elements within this list. - * @param iterator Trust test iterator function for each element in `list`. - * @param context `this` object in `iterator`, optional. - * @return True if any elements passed the truth test, otherwise false. - **/ - some( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.some - **/ - some( - object: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - /** - * @see _.some - **/ - any( - list: _.List, - iterator?: _.ListIterator, - context?: any): boolean; - - /** - * @see _.some - **/ - any( - object: _.Dictionary, - iterator?: _.ObjectIterator, - context?: any): boolean; - - /** - * Returns true if the value is present in the list. Uses indexOf internally, - * if list is an Array. - * @param list Checks each element to see if `value` is present. - * @param value The value to check for within `list`. - * @return True if `value` is present in `list`, otherwise false. - **/ - contains( - list: _.List, - value: T): boolean; - - /** - * @see _.contains - **/ - contains( - object: _.Dictionary, - value: T): boolean; - - /** - * @see _.contains - **/ - include( - list: _.Collection, - value: T): boolean; - - /** - * @see _.contains - **/ - include( - object: _.Dictionary, - value: T): boolean; - - /** - * Calls the method named by methodName on each value in the list. Any extra arguments passed to - * invoke will be forwarded on to the method invocation. - * @param list The element's in this list will each have the method `methodName` invoked. - * @param methodName The method's name to call on each element within `list`. - * @param arguments Additional arguments to pass to the method `methodName`. - **/ - invoke( - list: _.List, - methodName: string, - ...arguments: any[]): any; - - /** - * A convenient version of what is perhaps the most common use-case for map: extracting a list of - * property values. - * @param list The list to pluck elements out of that have the property `propertyName`. - * @param propertyName The property to look for on each element within `list`. - * @return The list of elements within `list` that have the property `propertyName`. - **/ - pluck( - list: _.List, - propertyName: string): any[]; - - /** - * Returns the maximum value in list. - * @param list Finds the maximum value in this list. - * @return Maximum value in `list`. - **/ - max(list: _.List): number; - - /** - * Returns the maximum value in list. If iterator is passed, it will be used on each value to generate - * the criterion by which the value is ranked. - * @param list Finds the maximum value in this list. - * @param iterator Compares each element in `list` to find the maximum value. - * @param context `this` object in `iterator`, optional. - * @return The maximum element within `list`. - **/ - max( - list: _.List, - iterator?: _.ListIterator, - context?: any): T; - - /** - * Returns the minimum value in list. - * @param list Finds the minimum value in this list. - * @return Minimum value in `list`. - **/ - min(list: _.List): number; - - /** - * Returns the minimum value in list. If iterator is passed, it will be used on each value to generate - * the criterion by which the value is ranked. - * @param list Finds the minimum value in this list. - * @param iterator Compares each element in `list` to find the minimum value. - * @param context `this` object in `iterator`, optional. - * @return The minimum element within `list`. - **/ - min( - list: _.List, - iterator?: _.ListIterator, - context?: any): T; - - /** - * Returns a sorted copy of list, ranked in ascending order by the results of running each value - * through iterator. Iterator may also be the string name of the property to sort by (eg. length). - * @param list Sorts this list. - * @param iterator Sort iterator for each element within `list`. - * @param context `this` object in `iterator`, optional. - * @return A sorted copy of `list`. - **/ - sortBy( - list: _.List, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.sortBy - * @param iterator Sort iterator for each element within `list`. - **/ - sortBy( - list: _.List, - iterator: string, - context?: any): T[]; - - /** - * Splits a collection into sets, grouped by the result of running each value through iterator. - * If iterator is a string instead of a function, groups by the property named by iterator on - * each of the values. - * @param list Groups this list. - * @param iterator Group iterator for each element within `list`, return the key to group the element by. - * @param context `this` object in `iterator`, optional. - * @return An object with the group names as properties where each property contains the grouped elements from `list`. - **/ - groupBy( - list: _.List, - iterator?: _.ListIterator, - context?: any): _.Dictionary; - - /** - * @see _.groupBy - * @param iterator Property on each object to group them by. - **/ - groupBy( - list: _.List, - iterator: string, - context?: any): _.Dictionary; - - /** - * Given a `list`, and an `iterator` function that returns a key for each element in the list (or a property name), - * returns an object with an index of each item. Just like _.groupBy, but for when you know your keys are unique. - **/ - indexBy( - list: _.List, - iterator: _.ListIterator, - context?: any): _.Dictionary; - - /** - * @see _.indexBy - * @param iterator Property on each object to index them by. - **/ - indexBy( - list: _.List, - iterator: string, - context?: any): _.Dictionary; - - /** - * Sorts a list into groups and returns a count for the number of objects in each group. Similar - * to groupBy, but instead of returning a list of values, returns a count for the number of values - * in that group. - * @param list Group elements in this list and then count the number of elements in each group. - * @param iterator Group iterator for each element within `list`, return the key to group the element by. - * @param context `this` object in `iterator`, optional. - * @return An object with the group names as properties where each property contains the number of elements in that group. - **/ - countBy( - list: _.List, - iterator?: _.ListIterator, - context?: any): _.Dictionary; - - /** - * @see _.countBy - * @param iterator Function name - **/ - countBy( - list: _.List, - iterator: string, - context?: any): _.Dictionary; - - /** - * Returns a shuffled copy of the list, using a version of the Fisher-Yates shuffle. - * @param list List to shuffle. - * @return Shuffled copy of `list`. - **/ - shuffle(list: _.Collection): T[]; - - /** - * Produce a random sample from the `list`. Pass a number to return `n` random elements from the list. Otherwise a single random item will be returned. - * @param list List to sample. - * @return Random sample of `n` elements in `list`. - **/ - sample(list: _.Collection, n: number): T[]; - - /** - * @see _.sample - **/ - sample(list: _.Collection): T; - - /** - * Converts the list (anything that can be iterated over), into a real Array. Useful for transmuting - * the arguments object. - * @param list object to transform into an array. - * @return `list` as an array. - **/ - toArray(list: _.Collection): T[]; - - /** - * Return the number of values in the list. - * @param list Count the number of values/elements in this list. - * @return Number of values in `list`. - **/ - size(list: _.Collection): number; - - /** - * Split array into two arrays: - * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate. - * @param array Array to split in two. - * @param iterator Filter iterator function for each element in `array`. - * @param context `this` object in `iterator`, optional. - * @return Array where Array[0] are the elements in `array` that satisfies the predicate, and Array[1] the elements that did not. - **/ - partition( - array: Array, - iterator: _.ListIterator, - context?: any): T[][]; - - /********* - * Arrays * - **********/ - - /** - * Returns the first element of an array. Passing n will return the first n elements of the array. - * @param array Retrieves the first element of this array. - * @return Returns the first element of `array`. - **/ - first(array: _.List): T; - - /** - * @see _.first - * @param n Return more than one element from `array`. - **/ - first( - array: _.List, - n: number): T[]; - - /** - * @see _.first - **/ - head(array: _.List): T; - - /** - * @see _.first - **/ - head( - array: _.List, - n: number): T[]; - - /** - * @see _.first - **/ - take(array: _.List): T; - - /** - * @see _.first - **/ - take( - array: _.List, - n: number): T[]; - - /** - * Returns everything but the last entry of the array. Especially useful on the arguments object. - * Pass n to exclude the last n elements from the result. - * @param array Retrieve all elements except the last `n`. - * @param n Leaves this many elements behind, optional. - * @return Returns everything but the last `n` elements of `array`. - **/ - initial( - array: _.List, - n?: number): T[]; - - /** - * Returns the last element of an array. Passing n will return the last n elements of the array. - * @param array Retrieves the last element of this array. - * @return Returns the last element of `array`. - **/ - last(array: _.List): T; - - /** - * @see _.last - * @param n Return more than one element from `array`. - **/ - last( - array: _.List, - n: number): T[]; - - /** - * Returns the rest of the elements in an array. Pass an index to return the values of the array - * from that index onward. - * @param array The array to retrieve all but the first `index` elements. - * @param n The index to start retrieving elements forward from, optional, default = 1. - * @return Returns the elements of `array` from `index` to the end of `array`. - **/ - rest( - array: _.List, - n?: number): T[]; - - /** - * @see _.rest - **/ - tail( - array: _.List, - n?: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: _.List, - n?: number): T[]; - - /** - * Returns a copy of the array with all falsy values removed. In JavaScript, false, null, 0, "", - * undefined and NaN are all falsy. - * @param array Array to compact. - * @return Copy of `array` without false values. - **/ - compact(array: _.List): T[]; - - /** - * Flattens a nested array (the nesting can be to any depth). If you pass shallow, the array will - * only be flattened a single level. - * @param array The array to flatten. - * @param shallow If true then only flatten one level, optional, default = false. - * @return `array` flattened. - **/ - flatten( - array: _.List, - shallow?: boolean): any[]; - - /** - * Returns a copy of the array with all instances of the values removed. - * @param array The array to remove `values` from. - * @param values The values to remove from `array`. - * @return Copy of `array` without `values`. - **/ - without( - array: _.List, - ...values: T[]): T[]; - - /** - * Computes the union of the passed-in arrays: the list of unique items, in order, that are - * present in one or more of the arrays. - * @param arrays Array of arrays to compute the union of. - * @return The union of elements within `arrays`. - **/ - union(...arrays: _.List[]): T[]; - - /** - * Computes the list of values that are the intersection of all the arrays. Each value in the result - * is present in each of the arrays. - * @param arrays Array of arrays to compute the intersection of. - * @return The intersection of elements within `arrays`. - **/ - intersection(...arrays: _.List[]): T[]; - - /** - * Similar to without, but returns the values from array that are not present in the other arrays. - * @param array Keeps values that are within `others`. - * @param others The values to keep within `array`. - * @return Copy of `array` with only `others` values. - **/ - difference( - array: _.List, - ...others: _.List[]): T[]; - - /** - * Produces a duplicate-free version of the array, using === to test object equality. If you know in - * advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If - * you want to compute unique items based on a transformation, pass an iterator function. - * @param array Array to remove duplicates from. - * @param isSorted True if `array` is already sorted, optional, default = false. - * @param iterator Transform the elements of `array` before comparisons for uniqueness. - * @param context 'this' object in `iterator`, optional. - * @return Copy of `array` where all elements are unique. - **/ - uniq( - array: _.List, - isSorted?: boolean, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.uniq - **/ - uniq( - array: _.List, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.uniq - **/ - unique( - array: _.List, - iterator?: _.ListIterator, - context?: any): T[]; - - /** - * @see _.uniq - **/ - unique( - array: _.List, - isSorted?: boolean, - iterator?: _.ListIterator, - context?: any): T[]; - - - /** - * Merges together the values of each of the arrays with the values at the corresponding position. - * Useful when you have separate data sources that are coordinated through matching array indexes. - * If you're working with a matrix of nested arrays, zip.apply can transpose the matrix in a similar fashion. - * @param arrays The arrays to merge/zip. - * @return Zipped version of `arrays`. - **/ - zip(...arrays: any[][]): any[][]; - - /** - * @see _.zip - **/ - zip(...arrays: any[]): any[]; - - /** - * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a - * list of keys, and a list of values. - * @param keys Key array. - * @param values Value array. - * @return An object containing the `keys` as properties and `values` as the property values. - **/ - object( - keys: _.List, - values: _.List): TResult; - - /** - * Converts arrays into objects. Pass either a single list of [key, value] pairs, or a - * list of keys, and a list of values. - * @param keyValuePairs Array of [key, value] pairs. - * @return An object containing the `keys` as properties and `values` as the property values. - **/ - object(...keyValuePairs: any[][]): TResult; - - /** - * @see _.object - **/ - object( - list: _.List, - values?: any): TResult; - - /** - * Returns the index at which value can be found in the array, or -1 if value is not present in the array. - * Uses the native indexOf function unless it's missing. If you're working with a large array, and you know - * that the array is already sorted, pass true for isSorted to use a faster binary search ... or, pass a number - * as the third argument in order to look for the first matching value in the array after the given index. - * @param array The array to search for the index of `value`. - * @param value The value to search for within `array`. - * @param isSorted True if the array is already sorted, optional, default = false. - * @return The index of `value` within `array`. - **/ - indexOf( - array: _.List, - value: T, - isSorted?: boolean): number; - - /** - * @see _indexof - **/ - indexOf( - array: _.List, - value: T, - startFrom: number): number; - - /** - * Returns the index of the last occurrence of value in the array, or -1 if value is not present. Uses the - * native lastIndexOf function if possible. Pass fromIndex to start your search at a given index. - * @param array The array to search for the last index of `value`. - * @param value The value to search for within `array`. - * @param from The starting index for the search, optional. - * @return The index of the last occurrence of `value` within `array`. - **/ - lastIndexOf( - array: _.List, - value: T, - from?: number): number; - - /** - * Uses a binary search to determine the index at which the value should be inserted into the list in order - * to maintain the list's sorted order. If an iterator is passed, it will be used to compute the sort ranking - * of each value, including the value you pass. - * @param list The sorted list. - * @param value The value to determine its index within `list`. - * @param iterator Iterator to compute the sort ranking of each value, optional. - * @return The index where `value` should be inserted into `list`. - **/ - sortedIndex( - list: _.List, - value: T, - iterator?: (x: T) => TSort, context?: any): number; - - /** - * A function to create flexibly-numbered lists of integers, handy for each and map loops. start, if omitted, - * defaults to 0; step defaults to 1. Returns a list of integers from start to stop, incremented (or decremented) - * by step, exclusive. - * @param start Start here. - * @param stop Stop here. - * @param step The number to count up by each iteration, optional, default = 1. - * @return Array of numbers from `start` to `stop` with increments of `step`. - **/ - - range( - start: number, - stop: number, - step?: number): number[]; - - /** - * @see _.range - * @param stop Stop here. - * @return Array of numbers from 0 to `stop` with increments of 1. - * @note If start is not specified the implementation will never pull the step (step = arguments[2] || 0) - **/ - range(stop: number): number[]; - - /************* - * Functions * - *************/ - - /** - * Bind a function to an object, meaning that whenever the function is called, the value of this will - * be the object. Optionally, bind arguments to the function to pre-fill them, also known as partial application. - * @param func The function to bind `this` to `object`. - * @param context The `this` pointer whenever `fn` is called. - * @param arguments Additional arguments to pass to `fn` when called. - * @return `fn` with `this` bound to `object`. - **/ - bind( - func: Function, - context: any, - ...arguments: any[]): () => any; - - /** - * Binds a number of methods on the object, specified by methodNames, to be run in the context of that object - * whenever they are invoked. Very handy for binding functions that are going to be used as event handlers, - * which would otherwise be invoked with a fairly useless this. If no methodNames are provided, all of the - * object's function properties will be bound to it. - * @param object The object to bind the methods `methodName` to. - * @param methodNames The methods to bind to `object`, optional and if not provided all of `object`'s - * methods are bound. - **/ - bindAll( - object: any, - ...methodNames: string[]): any; - - /** - * Partially apply a function by filling in any number of its arguments, without changing its dynamic this value. - * A close cousin of bind. You may pass _ in your list of arguments to specify an argument that should not be - * pre-filled, but left open to supply at call-time. - * @param fn Function to partially fill in arguments. - * @param arguments The partial arguments. - * @return `fn` with partially filled in arguments. - **/ - partial( - fn: Function, - ...arguments: any[]): Function; - - /** - * Memoizes a given function by caching the computed result. Useful for speeding up slow-running computations. - * If passed an optional hashFunction, it will be used to compute the hash key for storing the result, based - * on the arguments to the original function. The default hashFunction just uses the first argument to the - * memoized function as the key. - * @param fn Computationally expensive function that will now memoized results. - * @param hashFn Hash function for storing the result of `fn`. - * @return Memoized version of `fn`. - **/ - memoize( - fn: Function, - hashFn?: (...args: any[]) => string): Function; - - /** - * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments, - * they will be forwarded on to the function when it is invoked. - * @param func Function to delay `waitMS` amount of ms. - * @param wait The amount of milliseconds to delay `fn`. - * @arguments Additional arguments to pass to `fn`. - **/ - delay( - func: Function, - wait: number, - ...arguments: any[]): any; - - /** - * @see _delay - **/ - delay( - func: Function, - ...arguments: any[]): any; - - /** - * Defers invoking the function until the current call stack has cleared, similar to using setTimeout - * with a delay of 0. Useful for performing expensive computations or HTML rendering in chunks without - * blocking the UI thread from updating. If you pass the optional arguments, they will be forwarded on - * to the function when it is invoked. - * @param fn The function to defer. - * @param arguments Additional arguments to pass to `fn`. - **/ - defer( - fn: Function, - ...arguments: any[]): void; - - /** - * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, - * will only actually call the original function at most once per every wait milliseconds. Useful for - * rate-limiting events that occur faster than you can keep up with. - * By default, throttle will execute the function as soon as you call it for the first time, and, - * if you call it again any number of times during the wait period, as soon as that period is over. - * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable - * the execution on the trailing-edge, pass {trailing: false}. - * @param func Function to throttle `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. - * @return `fn` with a throttle of `wait`. - **/ - throttle( - func: T, - wait: number, - options?: _.ThrottleSettings): T; - - /** - * Creates and returns a new debounced version of the passed function that will postpone its execution - * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing - * behavior that should only happen after the input has stopped arriving. For example: rendering a preview - * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. - * - * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead - * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double - *-clicks on a "submit" button from firing a second time. - * @param fn Function to debounce `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. - * @return Debounced version of `fn` that waits `wait` ms when invoked. - **/ - debounce( - fn: T, - wait: number, - immediate?: boolean): T; - - /** - * Creates a version of the function that can only be called one time. Repeated calls to the modified - * function will have no effect, returning the value from the original call. Useful for initialization - * functions, instead of having to set a boolean flag and then check it later. - * @param fn Function to only execute once. - * @return Copy of `fn` that can only be invoked once. - **/ - once(fn: T): T; - - /** - * Creates a version of the function that will only be run after first being called count times. Useful - * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, - * before proceeding. - * @param number count Number of times to be called before actually executing. - * @param Function fn The function to defer execution `count` times. - * @return Copy of `fn` that will not execute until it is invoked `count` times. - **/ - after( - count: number, - fn: Function): Function; - - /** - * Creates a version of the function that can be called no more than count times. The result of - * the last function call is memoized and returned when count has been reached. - * @param number count The maxmimum number of times the function can be called. - * @param Function fn The function to limit the number of times it can be called. - * @return Copy of `fn` that can only be called `count` times. - **/ - before( - count: number, - fn: Function): Function; - - /** - * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows - * the wrapper to execute code before and after the function runs, adjust the arguments, and execute it - * conditionally. - * @param fn Function to wrap. - * @param wrapper The function that will wrap `fn`. - * @return Wrapped version of `fn. - **/ - wrap( - fn: Function, - wrapper: (fn: Function, ...args: any[]) => any): Function; - - /** - * Returns a negated version of the pass-in predicate. - * @param Function predicate - * @return boolean - **/ - negate(predicate: Function): boolean; - - /** - * Returns the composition of a list of functions, where each function consumes the return value of the - * function that follows. In math terms, composing the functions f(), g(), and h() produces f(g(h())). - * @param functions List of functions to compose. - * @return Composition of `functions`. - **/ - compose(...functions: Function[]): Function; - - /********** - * Objects * - ***********/ - - /** - * Retrieve all the names of the object's properties. - * @param object Retrieve the key or property names from this object. - * @return List of all the property names on `object`. - **/ - keys(object: any): string[]; - - /** - * Return all of the values of the object's properties. - * @param object Retrieve the values of all the properties on this object. - * @return List of all the values on `object`. - **/ - values(object: any): any[]; - - /** - * Like map, but for objects. Transform the value of each property in turn. - * @param object The object to transform - * @param iteratee The function that transforms property values - * @param context The optional context (value of `this`) to bind to - * @return a new _.Dictionary of property values - */ - mapObject(object: _.Dictionary, iteratee: (val: T, key: string, object: _.Dictionary) => U, context?: any): _.Dictionary; - - /** - * Like map, but for objects. Transform the value of each property in turn. - * @param object The object to transform - * @param iteratee The function that tranforms property values - * @param context The optional context (value of `this`) to bind to - */ - mapObject(object: any, iteratee: (val: any, key: string, object: any) => T, context?: any): _.Dictionary; - - /** - * Like map, but for objects. Retrieves a property from each entry in the object, as if by _.property - * @param object The object to transform - * @param iteratee The property name to retrieve - * @param context The optional context (value of `this`) to bind to - */ - mapObject(object: any, iteratee: string, context?: any): _.Dictionary; - - /** - * Convert an object into a list of [key, value] pairs. - * @param object Convert this object to a list of [key, value] pairs. - * @return List of [key, value] pairs on `object`. - **/ - pairs(object: any): any[][]; - - /** - * Returns a copy of the object where the keys have become the values and the values the keys. - * For this to work, all of your object's values should be unique and string serializable. - * @param object Object to invert key/value pairs. - * @return An inverted key/value paired version of `object`. - **/ - invert(object: any): any; - - /** - * Returns a sorted list of the names of every method in an object - that is to say, - * the name of every function property of the object. - * @param object Object to pluck all function property names from. - * @return List of all the function names on `object`. - **/ - functions(object: any): string[]; - - /** - * @see _functions - **/ - methods(object: any): string[]; - - /** - * Copy all of the properties in the source objects over to the destination object, and return - * the destination object. It's in-order, so the last source will override properties of the - * same name in previous arguments. - * @param destination Object to extend all the properties from `sources`. - * @param sources Extends `destination` with all properties from these source objects. - * @return `destination` extended with all the properties from the `sources` objects. - **/ - extend( - destination: any, - ...sources: any[]): any; - - /** - * Like extend, but only copies own properties over to the destination object. (alias: assign) - */ - extendOwn( - destination: any, - ...source: any[]): any; - - /** - * Like extend, but only copies own properties over to the destination object. (alias: extendOwn) - */ - assign( - destination: any, - ...source: any[]): any; - - /** - * Return a copy of the object, filtered to only have values for the whitelisted keys - * (or array of valid keys). - * @param object Object to strip unwanted key/value pairs. - * @keys The key/value pairs to keep on `object`. - * @return Copy of `object` with only the `keys` properties. - **/ - pick( - object: any, - ...keys: any[]): any; - - /** - * @see _.pick - **/ - pick( - object: any, - fn: (value: any, key: any, object: any) => any): any; - - /** - * Return a copy of the object, filtered to omit the blacklisted keys (or array of keys). - * @param object Object to strip unwanted key/value pairs. - * @param keys The key/value pairs to remove on `object`. - * @return Copy of `object` without the `keys` properties. - **/ - omit( - object: any, - ...keys: string[]): any; - - /** - * @see _.omit - **/ - omit( - object: any, - keys: string[]): any; - - /** - * @see _.omit - **/ - omit( - object: any, - iteratee: Function): any; - - /** - * Fill in null and undefined properties in object with values from the defaults objects, - * and return the object. As soon as the property is filled, further defaults will have no effect. - * @param object Fill this object with default values. - * @param defaults The default values to add to `object`. - * @return `object` with added `defaults` values. - **/ - defaults( - object: any, - ...defaults: any[]): any; - - /** - * Create a shallow-copied clone of the object. - * Any nested objects or arrays will be copied by reference, not duplicated. - * @param object Object to clone. - * @return Copy of `object`. - **/ - clone(object: T): T; - - /** - * Invokes interceptor with the object, and then returns object. The primary purpose of this method - * is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. - * @param object Argument to `interceptor`. - * @param intercepter The function to modify `object` before continuing the method chain. - * @return Modified `object`. - **/ - tap(object: T, intercepter: Function): T; - - /** - * Does the object contain the given key? Identical to object.hasOwnProperty(key), but uses a safe - * reference to the hasOwnProperty function, in case it's been overridden accidentally. - * @param object Object to check for `key`. - * @param key The key to check for on `object`. - * @return True if `key` is a property on `object`, otherwise false. - **/ - has(object: any, key: string): boolean; - - /** - * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs. - * @param attrs Object with key values pair - * @return Predicate function - **/ - matches(attrs: T): _.ListIterator; - - /** - * Returns a function that will itself return the key property of any passed-in object. - * @param key Property of the object. - * @return Function which accept an object an returns the value of key in that object. - **/ - property(key: string): (object: Object) => any; - - /** - * Performs an optimized deep comparison between the two objects, - * to determine if they should be considered equal. - * @param object Compare to `other`. - * @param other Compare to `object`. - * @return True if `object` is equal to `other`. - **/ - isEqual(object: any, other: any): boolean; - - /** - * Returns true if object contains no values. - * @param object Check if this object has no properties or values. - * @return True if `object` is empty. - **/ - isEmpty(object: any): boolean; - - /** - * Returns true if object is a DOM element. - * @param object Check if this object is a DOM element. - * @return True if `object` is a DOM element, otherwise false. - **/ - isElement(object: any): boolean; - - /** - * Returns true if object is an Array. - * @param object Check if this object is an Array. - * @return True if `object` is an Array, otherwise false. - **/ - isArray(object: any): boolean; - - /** - * Returns true if value is an Object. Note that JavaScript arrays and functions are objects, - * while (normal) strings and numbers are not. - * @param object Check if this object is an Object. - * @return True of `object` is an Object, otherwise false. - **/ - isObject(object: any): boolean; - - /** - * Returns true if object is an Arguments object. - * @param object Check if this object is an Arguments object. - * @return True if `object` is an Arguments object, otherwise false. - **/ - isArguments(object: any): boolean; - - /** - * Returns true if object is a Function. - * @param object Check if this object is a Function. - * @return True if `object` is a Function, otherwise false. - **/ - isFunction(object: any): boolean; - - /** - * Returns true if object is a String. - * @param object Check if this object is a String. - * @return True if `object` is a String, otherwise false. - **/ - isString(object: any): boolean; - - /** - * Returns true if object is a Number (including NaN). - * @param object Check if this object is a Number. - * @return True if `object` is a Number, otherwise false. - **/ - isNumber(object: any): boolean; - - /** - * Returns true if object is a finite Number. - * @param object Check if this object is a finite Number. - * @return True if `object` is a finite Number. - **/ - isFinite(object: any): boolean; - - /** - * Returns true if object is either true or false. - * @param object Check if this object is a bool. - * @return True if `object` is a bool, otherwise false. - **/ - isBoolean(object: any): boolean; - - /** - * Returns true if object is a Date. - * @param object Check if this object is a Date. - * @return True if `object` is a Date, otherwise false. - **/ - isDate(object: any): boolean; - - /** - * Returns true if object is a RegExp. - * @param object Check if this object is a RegExp. - * @return True if `object` is a RegExp, otherwise false. - **/ - isRegExp(object: any): boolean; - - /** - * Returns true if object is NaN. - * Note: this is not the same as the native isNaN function, - * which will also return true if the variable is undefined. - * @param object Check if this object is NaN. - * @return True if `object` is NaN, otherwise false. - **/ - isNaN(object: any): boolean; - - /** - * Returns true if the value of object is null. - * @param object Check if this object is null. - * @return True if `object` is null, otherwise false. - **/ - isNull(object: any): boolean; - - /** - * Returns true if value is undefined. - * @param object Check if this object is undefined. - * @return True if `object` is undefined, otherwise false. - **/ - isUndefined(value: any): boolean; - - /* ********* - * Utility * - ********** */ - - /** - * Give control of the "_" variable back to its previous owner. - * Returns a reference to the Underscore object. - * @return Underscore object reference. - **/ - noConflict(): any; - - /** - * Returns the same value that is used as the argument. In math: f(x) = x - * This function looks useless, but is used throughout Underscore as a default iterator. - * @param value Identity of this object. - * @return `value`. - **/ - identity(value: T): T; - - /** - * Creates a function that returns the same value that is used as the argument of _.constant - * @param value Identity of this object. - * @return Function that return value. - **/ - constant(value: T): () => T; - - /** - * Returns undefined irrespective of the arguments passed to it. Useful as the default - * for optional callback arguments. - * Note there is no way to indicate a 'undefined' return, so it is currently typed as void. - * @return undefined - **/ - noop(): void; - - /** - * Invokes the given iterator function n times. - * Each invocation of iterator is called with an index argument - * @param n Number of times to invoke `iterator`. - * @param iterator Function iterator to invoke `n` times. - * @param context `this` object in `iterator`, optional. - **/ - times(n: number, iterator: (n: number) => TResult, context?: any): TResult[]; - - /** - * Returns a random integer between min and max, inclusive. If you only pass one argument, - * it will return a number between 0 and that number. - * @param max The maximum random number. - * @return A random number between 0 and `max`. - **/ - random(max: number): number; - - /** - * @see _.random - * @param min The minimum random number. - * @return A random number between `min` and `max`. - **/ - random(min: number, max: number): number; - - /** - * Allows you to extend Underscore with your own utility functions. Pass a hash of - * {name: function} definitions to have your functions added to the Underscore object, - * as well as the OOP wrapper. - * @param object Mixin object containing key/function pairs to add to the Underscore object. - **/ - mixin(object: any): void; - - /** - * A mostly-internal function to generate callbacks that can be applied to each element - * in a collection, returning the desired result -- either identity, an arbitrary callback, - * a property matcher, or a propetery accessor. - * @param string|Function|Object value The value to iterate over, usually the key. - * @param any context - * @param number argCount - * @return Callback that can be applied to each element in a collection. - **/ - iteratee(value: string): Function; - iteratee(value: Function, context?: any, argCount?: number): Function; - iteratee(value: Object): Function; - - /** - * Generate a globally-unique id for client-side models or DOM elements that need one. - * If prefix is passed, the id will be appended to it. Without prefix, returns an integer. - * @param prefix A prefix string to start the unique ID with. - * @return Unique string ID beginning with `prefix`. - **/ - uniqueId(prefix: string): string; - - /** - * @see _.uniqueId - **/ - uniqueId(): number; - - /** - * Escapes a string for insertion into HTML, replacing &, <, >, ", ', and / characters. - * @param str Raw string to escape. - * @return `str` HTML escaped. - **/ - escape(str: string): string; - - /** - * The opposite of escape, replaces &, <, >, ", and ' with their unescaped counterparts. - * @param str HTML escaped string. - * @return `str` Raw string. - **/ - unescape(str: string): string; - - /** - * If the value of the named property is a function then invoke it; otherwise, return it. - * @param object Object to maybe invoke function `property` on. - * @param property The function by name to invoke on `object`. - * @return The result of invoking the function `property` on `object. - **/ - result(object: any, property: string): any; - - /** - * Compiles JavaScript templates into functions that can be evaluated for rendering. Useful - * for rendering complicated bits of HTML from JSON data sources. Template functions can both - * interpolate variables, using <%= ... %>, as well as execute arbitrary JavaScript code, with - * <% ... %>. If you wish to interpolate a value, and have it be HTML-escaped, use <%- ... %> When - * you evaluate a template function, pass in a data object that has properties corresponding to - * the template's free variables. If you're writing a one-off, you can pass the data object as - * the second parameter to template in order to render immediately instead of returning a template - * function. The settings argument should be a hash containing any _.templateSettings that should - * be overridden. - * @param templateString Underscore HTML template. - * @param data Data to use when compiling `templateString`. - * @param settings Settings to use while compiling. - * @return Returns the compiled Underscore HTML template. - **/ - template(templateString: string, settings?: _.TemplateSettings): (...data: any[]) => string; - - /** - * By default, Underscore uses ERB-style template delimiters, change the - * following template settings to use alternative delimiters. - **/ - templateSettings: _.TemplateSettings; - - /** - * Returns an integer timestamp for the current time, using the fastest method available in the runtime. Useful for implementing timing/animation functions. - **/ - now(): number; - - /* ********** - * Chaining * - *********** */ - - /** - * Returns a wrapped object. Calling methods on this object will continue to return wrapped objects - * until value() is used. - * @param obj Object to chain. - * @return Wrapped `obj`. - **/ - chain(obj: T[]): _Chain; - chain(obj: T): _Chain; -} - -interface Underscore { - - /* ************* - * Collections * - ************* */ - - /** - * Wrapped type `any[]`. - * @see _.each - **/ - each(iterator: _.ListIterator, context?: any): T[]; - - /** - * @see _.each - **/ - each(iterator: _.ObjectIterator, context?: any): T[]; - - /** - * @see _.each - **/ - forEach(iterator: _.ListIterator, context?: any): T[]; - - /** - * @see _.each - **/ - forEach(iterator: _.ObjectIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ListIterator, context?: any): TResult[]; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ObjectIterator, context?: any): TResult[]; - - /** - * @see _.map - **/ - collect(iterator: _.ListIterator, context?: any): TResult[]; - - /** - * @see _.map - **/ - collect(iterator: _.ObjectIterator, context?: any): TResult[]; - - /** - * Wrapped type `any[]`. - * @see _.reduce - **/ - reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * @see _.reduce - **/ - inject(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * @see _.reduce - **/ - foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * Wrapped type `any[]`. - * @see _.reduceRight - **/ - reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * @see _.reduceRight - **/ - foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): TResult; - - /** - * Wrapped type `any[]`. - * @see _.find - **/ - find(iterator: _.ListIterator, context?: any): T; - - /** - * @see _.find - **/ - detect(iterator: _.ListIterator, context?: any): T; - - /** - * Wrapped type `any[]`. - * @see _.filter - **/ - filter(iterator: _.ListIterator, context?: any): T[]; - - /** - * @see _.filter - **/ - select(iterator: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.where - **/ - where(properties: U): T[]; - - /** - * Wrapped type `any[]`. - * @see _.findWhere - **/ - findWhere(properties: U): T; - - /** - * Wrapped type `any[]`. - * @see _.reject - **/ - reject(iterator: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.all - **/ - all(iterator?: _.ListIterator, context?: any): boolean; - - /** - * @see _.all - **/ - every(iterator?: _.ListIterator, context?: any): boolean; - - /** - * Wrapped type `any[]`. - * @see _.any - **/ - any(iterator?: _.ListIterator, context?: any): boolean; - - /** - * @see _.any - **/ - some(iterator?: _.ListIterator, context?: any): boolean; - - /** - * Wrapped type `any[]`. - * @see _.contains - **/ - contains(value: T): boolean; - - /** - * Alias for 'contains'. - * @see contains - **/ - include(value: T): boolean; - - /** - * Wrapped type `any[]`. - * @see _.invoke - **/ - invoke(methodName: string, ...arguments: any[]): any; - - /** - * Wrapped type `any[]`. - * @see _.pluck - **/ - pluck(propertyName: string): any[]; - - /** - * Wrapped type `number[]`. - * @see _.max - **/ - max(): number; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator: _.ListIterator, context?: any): T; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator?: _.ListIterator, context?: any): T; - - /** - * Wrapped type `number[]`. - * @see _.min - **/ - min(): number; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator: _.ListIterator, context?: any): T; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator?: _.ListIterator, context?: any): T; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator?: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator: string, context?: any): T[]; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator?: _.ListIterator, context?: any): _.Dictionary<_.List>; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator: string, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: _.ListIterator, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: string, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator?: _.ListIterator, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator: string, context?: any): _.Dictionary; - - /** - * Wrapped type `any[]`. - * @see _.shuffle - **/ - shuffle(): T[]; - - /** - * Wrapped type `any[]`. - * @see _.sample - **/ - sample(n: number): T[]; - - /** - * @see _.sample - **/ - sample(): T; - - /** - * Wrapped type `any`. - * @see _.toArray - **/ - toArray(): T[]; - - /** - * Wrapped type `any`. - * @see _.size - **/ - size(): number; - - /********* - * Arrays * - **********/ - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(): T; - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(n: number): T[]; - - /** - * @see _.first - **/ - head(): T; - - /** - * @see _.first - **/ - head(n: number): T[]; - - /** - * @see _.first - **/ - take(): T; - - /** - * @see _.first - **/ - take(n: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.initial - **/ - initial(n?: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(): T; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(n: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.rest - **/ - rest(n?: number): T[]; - - /** - * @see _.rest - **/ - tail(n?: number): T[]; - - /** - * @see _.rest - **/ - drop(n?: number): T[]; - - /** - * Wrapped type `any[]`. - * @see _.compact - **/ - compact(): T[]; - - /** - * Wrapped type `any`. - * @see _.flatten - **/ - flatten(shallow?: boolean): any[]; - - /** - * Wrapped type `any[]`. - * @see _.without - **/ - without(...values: T[]): T[]; - - /** - * Wrapped type `any[]`. - * @see _.partition - **/ - partition(iterator: _.ListIterator, context?: any): T[][]; - - /** - * Wrapped type `any[][]`. - * @see _.union - **/ - union(...arrays: _.List[]): T[]; - - /** - * Wrapped type `any[][]`. - * @see _.intersection - **/ - intersection(...arrays: _.List[]): T[]; - - /** - * Wrapped type `any[]`. - * @see _.difference - **/ - difference(...others: _.List[]): T[]; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(isSorted?: boolean, iterator?: _.ListIterator): T[]; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(iterator?: _.ListIterator, context?: any): T[]; - - /** - * @see _.uniq - **/ - unique(isSorted?: boolean, iterator?: _.ListIterator): T[]; - - /** - * @see _.uniq - **/ - unique(iterator?: _.ListIterator, context?: any): T[]; - - /** - * Wrapped type `any[][]`. - * @see _.zip - **/ - zip(...arrays: any[][]): any[][]; - - /** - * Wrapped type `any[][]`. - * @see _.object - **/ - object(...keyValuePairs: any[][]): any; - - /** - * @see _.object - **/ - object(values?: any): any; - - /** - * Wrapped type `any[]`. - * @see _.indexOf - **/ - indexOf(value: T, isSorted?: boolean): number; - - /** - * @see _.indexOf - **/ - indexOf(value: T, startFrom: number): number; - - /** - * Wrapped type `any[]`. - * @see _.lastIndexOf - **/ - lastIndexOf(value: T, from?: number): number; - - /** - * Wrapped type `any[]`. - * @see _.sortedIndex - **/ - sortedIndex(value: T, iterator?: (x: T) => any, context?: any): number; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(stop: number, step?: number): number[]; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(): number[]; - - /* *********** - * Functions * - ************ */ - - /** - * Wrapped type `Function`. - * @see _.bind - **/ - bind(object: any, ...arguments: any[]): Function; - - /** - * Wrapped type `object`. - * @see _.bindAll - **/ - bindAll(...methodNames: string[]): any; - - /** - * Wrapped type `Function`. - * @see _.partial - **/ - partial(...arguments: any[]): Function; - - /** - * Wrapped type `Function`. - * @see _.memoize - **/ - memoize(hashFn?: (n: any) => string): Function; - - /** - * Wrapped type `Function`. - * @see _.defer - **/ - defer(...arguments: any[]): void; - - /** - * Wrapped type `Function`. - * @see _.delay - **/ - delay(wait: number, ...arguments: any[]): any; - - /** - * @see _.delay - **/ - delay(...arguments: any[]): any; - - /** - * Wrapped type `Function`. - * @see _.throttle - **/ - throttle(wait: number, options?: _.ThrottleSettings): Function; - - /** - * Wrapped type `Function`. - * @see _.debounce - **/ - debounce(wait: number, immediate?: boolean): Function; - - /** - * Wrapped type `Function`. - * @see _.once - **/ - once(): Function; - - /** - * Wrapped type `number`. - * @see _.after - **/ - after(fn: Function): Function; - - /** - * Wrapped type `number`. - * @see _.before - **/ - before(fn: Function): Function; - - /** - * Wrapped type `Function`. - * @see _.wrap - **/ - wrap(wrapper: Function): () => Function; - - /** - * Wrapped type `Function`. - * @see _.negate - **/ - negate(): boolean; - - /** - * Wrapped type `Function[]`. - * @see _.compose - **/ - compose(...functions: Function[]): Function; - - /********* * - * Objects * - ********** */ - - /** - * Wrapped type `object`. - * @see _.keys - **/ - keys(): string[]; - - /** - * Wrapped type `object`. - * @see _.values - **/ - values(): T[]; - - /** - * Wrapped type `object`. - * @see _.pairs - **/ - pairs(): any[][]; - - /** - * Wrapped type `object`. - * @see _.invert - **/ - invert(): any; - - /** - * Wrapped type `object`. - * @see _.functions - **/ - functions(): string[]; - - /** - * @see _.functions - **/ - methods(): string[]; - - /** - * Wrapped type `object`. - * @see _.extend - **/ - extend(...sources: any[]): any; - - /** - * Wrapped type `object`. - * @see _.pick - **/ - pick(...keys: any[]): any; - pick(keys: any[]): any; - pick(fn: (value: any, key: any, object: any) => any): any; - - /** - * Wrapped type `object`. - * @see _.omit - **/ - omit(...keys: string[]): any; - omit(keys: string[]): any; - omit(fn: Function): any; - - /** - * Wrapped type `object`. - * @see _.defaults - **/ - defaults(...defaults: any[]): any; - - /** - * Wrapped type `any[]`. - * @see _.clone - **/ - clone(): T; - - /** - * Wrapped type `object`. - * @see _.tap - **/ - tap(interceptor: (...as: any[]) => any): any; - - /** - * Wrapped type `object`. - * @see _.has - **/ - has(key: string): boolean; - - /** - * Wrapped type `any[]`. - * @see _.matches - **/ - matches(): _.ListIterator; - - /** - * Wrapped type `string`. - * @see _.property - **/ - property(): (object: Object) => any; - - /** - * Wrapped type `object`. - * @see _.isEqual - **/ - isEqual(other: any): boolean; - - /** - * Wrapped type `object`. - * @see _.isEmpty - **/ - isEmpty(): boolean; - - /** - * Wrapped type `object`. - * @see _.isElement - **/ - isElement(): boolean; - - /** - * Wrapped type `object`. - * @see _.isArray - **/ - isArray(): boolean; - - /** - * Wrapped type `object`. - * @see _.isObject - **/ - isObject(): boolean; - - /** - * Wrapped type `object`. - * @see _.isArguments - **/ - isArguments(): boolean; - - /** - * Wrapped type `object`. - * @see _.isFunction - **/ - isFunction(): boolean; - - /** - * Wrapped type `object`. - * @see _.isString - **/ - isString(): boolean; - - /** - * Wrapped type `object`. - * @see _.isNumber - **/ - isNumber(): boolean; - - /** - * Wrapped type `object`. - * @see _.isFinite - **/ - isFinite(): boolean; - - /** - * Wrapped type `object`. - * @see _.isBoolean - **/ - isBoolean(): boolean; - - /** - * Wrapped type `object`. - * @see _.isDate - **/ - isDate(): boolean; - - /** - * Wrapped type `object`. - * @see _.isRegExp - **/ - isRegExp(): boolean; - - /** - * Wrapped type `object`. - * @see _.isNaN - **/ - isNaN(): boolean; - - /** - * Wrapped type `object`. - * @see _.isNull - **/ - isNull(): boolean; - - /** - * Wrapped type `object`. - * @see _.isUndefined - **/ - isUndefined(): boolean; - - /********* * - * Utility * - ********** */ - - /** - * Wrapped type `any`. - * @see _.identity - **/ - identity(): any; - - /** - * Wrapped type `any`. - * @see _.constant - **/ - constant(): () => T; - - /** - * Wrapped type `any`. - * @see _.noop - **/ - noop(): void; - - /** - * Wrapped type `number`. - * @see _.times - **/ - times(iterator: (n: number) => TResult, context?: any): TResult[]; - - /** - * Wrapped type `number`. - * @see _.random - **/ - random(): number; - /** - * Wrapped type `number`. - * @see _.random - **/ - random(max: number): number; - - /** - * Wrapped type `object`. - * @see _.mixin - **/ - mixin(): void; - - /** - * Wrapped type `string|Function|Object`. - * @see _.iteratee - **/ - iteratee(context?: any, argCount?: number): Function; - - /** - * Wrapped type `string`. - * @see _.uniqueId - **/ - uniqueId(): string; - - /** - * Wrapped type `string`. - * @see _.escape - **/ - escape(): string; - - /** - * Wrapped type `string`. - * @see _.unescape - **/ - unescape(): string; - - /** - * Wrapped type `object`. - * @see _.result - **/ - result(property: string): any; - - /** - * Wrapped type `string`. - * @see _.template - **/ - template(settings?: _.TemplateSettings): (...data: any[]) => string; - - /********** * - * Chaining * - *********** */ - - /** - * Wrapped type `any`. - * @see _.chain - **/ - chain(): _Chain; - - /** - * Wrapped type `any`. - * Extracts the value of a wrapped object. - * @return Value of the wrapped object. - **/ - value(): TResult; -} - -interface _Chain { - - /* ************* - * Collections * - ************* */ - - /** - * Wrapped type `any[]`. - * @see _.each - **/ - each(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.each - **/ - each(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * @see _.each - **/ - forEach(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.each - **/ - forEach(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ListIterator, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.map - **/ - map(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * @see _.map - **/ - collect(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.map - **/ - collect(iterator: _.ObjectIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.reduce - **/ - reduce(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * @see _.reduce - **/ - inject(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * @see _.reduce - **/ - foldl(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.reduceRight - **/ - reduceRight(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * @see _.reduceRight - **/ - foldr(iterator: _.MemoIterator, memo?: TResult, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.find - **/ - find(iterator: _.ListIterator, context?: any): _ChainSingle; - - /** - * @see _.find - **/ - detect(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.filter - **/ - filter(iterator: _.ListIterator, context?: any): _Chain; - - /** - * @see _.filter - **/ - select(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.where - **/ - where(properties: U): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.findWhere - **/ - findWhere(properties: U): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.reject - **/ - reject(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.all - **/ - all(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * @see _.all - **/ - every(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.any - **/ - any(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * @see _.any - **/ - some(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.contains - **/ - contains(value: T): _Chain; - - /** - * Alias for 'contains'. - * @see contains - **/ - include(value: T): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.invoke - **/ - invoke(methodName: string, ...arguments: any[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.pluck - **/ - pluck(propertyName: string): _Chain; - - /** - * Wrapped type `number[]`. - * @see _.max - **/ - max(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.max - **/ - max(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `number[]`. - * @see _.min - **/ - min(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.min - **/ - min(iterator?: _.ListIterator, context?: any): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.sortBy - **/ - sortBy(iterator: string, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator?: _.ListIterator, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.groupBy - **/ - groupBy(iterator: string, context?: any): _ChainOfArrays; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.indexBy - **/ - indexBy(iterator: string, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.countBy - **/ - countBy(iterator: string, context?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.shuffle - **/ - shuffle(): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.sample - **/ - sample(n: number): _Chain; - - /** - * @see _.sample - **/ - sample(): _Chain; - - /** - * Wrapped type `any`. - * @see _.toArray - **/ - toArray(): _Chain; - - /** - * Wrapped type `any`. - * @see _.size - **/ - size(): _Chain; - - /********* - * Arrays * - **********/ - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.first - **/ - first(n: number): _Chain; - - /** - * @see _.first - **/ - head(): _Chain; - - /** - * @see _.first - **/ - head(n: number): _Chain; - - /** - * @see _.first - **/ - take(): _Chain; - - /** - * @see _.first - **/ - take(n: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.initial - **/ - initial(n?: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.last - **/ - last(n: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.rest - **/ - rest(n?: number): _Chain; - - /** - * @see _.rest - **/ - tail(n?: number): _Chain; - - /** - * @see _.rest - **/ - drop(n?: number): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.compact - **/ - compact(): _Chain; - - /** - * Wrapped type `any`. - * @see _.flatten - **/ - flatten(shallow?: boolean): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.without - **/ - without(...values: T[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.partition - **/ - partition(iterator: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.union - **/ - union(...arrays: _.List[]): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.intersection - **/ - intersection(...arrays: _.List[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.difference - **/ - difference(...others: _.List[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(isSorted?: boolean, iterator?: _.ListIterator): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.uniq - **/ - uniq(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * @see _.uniq - **/ - unique(isSorted?: boolean, iterator?: _.ListIterator): _Chain; - - /** - * @see _.uniq - **/ - unique(iterator?: _.ListIterator, context?: any): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.zip - **/ - zip(...arrays: any[][]): _Chain; - - /** - * Wrapped type `any[][]`. - * @see _.object - **/ - object(...keyValuePairs: any[][]): _Chain; - - /** - * @see _.object - **/ - object(values?: any): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.indexOf - **/ - indexOf(value: T, isSorted?: boolean): _ChainSingle; - - /** - * @see _.indexOf - **/ - indexOf(value: T, startFrom: number): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.lastIndexOf - **/ - lastIndexOf(value: T, from?: number): _ChainSingle; - - /** - * Wrapped type `any[]`. - * @see _.sortedIndex - **/ - sortedIndex(value: T, iterator?: (x: T) => any, context?: any): _Chain; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(stop: number, step?: number): _Chain; - - /** - * Wrapped type `number`. - * @see _.range - **/ - range(): _Chain; - - /* *********** - * Functions * - ************ */ - - /** - * Wrapped type `Function`. - * @see _.bind - **/ - bind(object: any, ...arguments: any[]): _Chain; - - /** - * Wrapped type `object`. - * @see _.bindAll - **/ - bindAll(...methodNames: string[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.partial - **/ - partial(...arguments: any[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.memoize - **/ - memoize(hashFn?: (n: any) => string): _Chain; - - /** - * Wrapped type `Function`. - * @see _.defer - **/ - defer(...arguments: any[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.delay - **/ - delay(wait: number, ...arguments: any[]): _Chain; - - /** - * @see _.delay - **/ - delay(...arguments: any[]): _Chain; - - /** - * Wrapped type `Function`. - * @see _.throttle - **/ - throttle(wait: number, options?: _.ThrottleSettings): _Chain; - - /** - * Wrapped type `Function`. - * @see _.debounce - **/ - debounce(wait: number, immediate?: boolean): _Chain; - - /** - * Wrapped type `Function`. - * @see _.once - **/ - once(): _Chain; - - /** - * Wrapped type `number`. - * @see _.after - **/ - after(func: Function): _Chain; - - /** - * Wrapped type `number`. - * @see _.before - **/ - before(fn: Function): _Chain; - - /** - * Wrapped type `Function`. - * @see _.wrap - **/ - wrap(wrapper: Function): () => _Chain; - - /** - * Wrapped type `Function`. - * @see _.negate - **/ - negate(): _Chain; - - /** - * Wrapped type `Function[]`. - * @see _.compose - **/ - compose(...functions: Function[]): _Chain; - - /********* * - * Objects * - ********** */ - - /** - * Wrapped type `object`. - * @see _.keys - **/ - keys(): _Chain; - - /** - * Wrapped type `object`. - * @see _.values - **/ - values(): _Chain; - - /** - * Wrapped type `object`. - * @see _.pairs - **/ - pairs(): _Chain; - - /** - * Wrapped type `object`. - * @see _.invert - **/ - invert(): _Chain; - - /** - * Wrapped type `object`. - * @see _.functions - **/ - functions(): _Chain; - - /** - * @see _.functions - **/ - methods(): _Chain; - - /** - * Wrapped type `object`. - * @see _.extend - **/ - extend(...sources: any[]): _Chain; - - /** - * Wrapped type `object`. - * @see _.pick - **/ - pick(...keys: any[]): _Chain; - pick(keys: any[]): _Chain; - pick(fn: (value: any, key: any, object: any) => any): _Chain; - - /** - * Wrapped type `object`. - * @see _.omit - **/ - omit(...keys: string[]): _Chain; - omit(keys: string[]): _Chain; - omit(iteratee: Function): _Chain; - - /** - * Wrapped type `object`. - * @see _.defaults - **/ - defaults(...defaults: any[]): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.clone - **/ - clone(): _Chain; - - /** - * Wrapped type `object`. - * @see _.tap - **/ - tap(interceptor: (...as: any[]) => any): _Chain; - - /** - * Wrapped type `object`. - * @see _.has - **/ - has(key: string): _Chain; - - /** - * Wrapped type `any[]`. - * @see _.matches - **/ - matches(): _Chain; - - /** - * Wrapped type `string`. - * @see _.property - **/ - property(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isEqual - **/ - isEqual(other: any): _Chain; - - /** - * Wrapped type `object`. - * @see _.isEmpty - **/ - isEmpty(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isElement - **/ - isElement(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isArray - **/ - isArray(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isObject - **/ - isObject(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isArguments - **/ - isArguments(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isFunction - **/ - isFunction(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isString - **/ - isString(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isNumber - **/ - isNumber(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isFinite - **/ - isFinite(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isBoolean - **/ - isBoolean(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isDate - **/ - isDate(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isRegExp - **/ - isRegExp(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isNaN - **/ - isNaN(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isNull - **/ - isNull(): _Chain; - - /** - * Wrapped type `object`. - * @see _.isUndefined - **/ - isUndefined(): _Chain; - - /********* * - * Utility * - ********** */ - - /** - * Wrapped type `any`. - * @see _.identity - **/ - identity(): _Chain; - - /** - * Wrapped type `any`. - * @see _.constant - **/ - constant(): _Chain; - - /** - * Wrapped type `any`. - * @see _.noop - **/ - noop(): _Chain; - - /** - * Wrapped type `number`. - * @see _.times - **/ - times(iterator: (n: number) => TResult, context?: any): _Chain; - - /** - * Wrapped type `number`. - * @see _.random - **/ - random(): _Chain; - /** - * Wrapped type `number`. - * @see _.random - **/ - random(max: number): _Chain; - - /** - * Wrapped type `object`. - * @see _.mixin - **/ - mixin(): _Chain; - - /** - * Wrapped type `string|Function|Object`. - * @see _.iteratee - **/ - iteratee(context?: any, argCount?: number): _Chain; - - /** - * Wrapped type `string`. - * @see _.uniqueId - **/ - uniqueId(): _Chain; - - /** - * Wrapped type `string`. - * @see _.escape - **/ - escape(): _Chain; - - /** - * Wrapped type `string`. - * @see _.unescape - **/ - unescape(): _Chain; - - /** - * Wrapped type `object`. - * @see _.result - **/ - result(property: string): _Chain; - - /** - * Wrapped type `string`. - * @see _.template - **/ - template(settings?: _.TemplateSettings): (...data: any[]) => _Chain; - - /************* * - * Array proxy * - ************** */ - - /** - * Returns a new array comprised of the array on which it is called - * joined with the array(s) and/or value(s) provided as arguments. - * @param arr Arrays and/or values to concatenate into a new array. See the discussion below for details. - * @return A new array comprised of the array on which it is called - **/ - concat(...arr: Array): _Chain; - - /** - * Join all elements of an array into a string. - * @param separator Optional. Specifies a string to separate each element of the array. The separator is converted to a string if necessary. If omitted, the array elements are separated with a comma. - * @return The string conversions of all array elements joined into one string. - **/ - join(separator?: any): _ChainSingle; - - /** - * Removes the last element from an array and returns that element. - * @return Returns the popped element. - **/ - pop(): _ChainSingle; - - /** - * Adds one or more elements to the end of an array and returns the new length of the array. - * @param item The elements to add to the end of the array. - * @return The array with the element added to the end. - **/ - push(...item: Array): _Chain; - - /** - * Reverses an array in place. The first array element becomes the last and the last becomes the first. - * @return The reversed array. - **/ - reverse(): _Chain; - - /** - * Removes the first element from an array and returns that element. This method changes the length of the array. - * @return The shifted element. - **/ - shift(): _ChainSingle; - - /** - * Returns a shallow copy of a portion of an array into a new array object. - * @param start Zero-based index at which to begin extraction. - * @param end Optional. Zero-based index at which to end extraction. slice extracts up to but not including end. - * @return A shallow copy of a portion of an array into a new array object. - **/ - slice(start: number, end?: number): _Chain; - - /** - * Sorts the elements of an array in place and returns the array. The sort is not necessarily stable. The default sort order is according to string Unicode code points. - * @param compareFn Optional. Specifies a function that defines the sort order. If omitted, the array is sorted according to each character's Unicode code point value, according to the string conversion of each element. - * @return The sorted array. - **/ - sort(compareFn: (a: T, b: T) => boolean): _Chain; - - /** - * Changes the content of an array by removing existing elements and/or adding new elements. - * @param index Index at which to start changing the array. If greater than the length of the array, actual starting index will be set to the length of the array. If negative, will begin that many elements from the end. - * @param quantity An integer indicating the number of old array elements to remove. If deleteCount is 0, no elements are removed. In this case, you should specify at least one new element. If deleteCount is greater than the number of elements left in the array starting at index, then all of the elements through the end of the array will be deleted. - * @param items The element to add to the array. If you don't specify any elements, splice will only remove elements from the array. - * @return An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned. - **/ - splice(index: number, quantity: number, ...items: Array): _Chain; - - /** - * A string representing the specified array and its elements. - * @return A string representing the specified array and its elements. - **/ - toString(): _ChainSingle; - - /** - * Adds one or more elements to the beginning of an array and returns the new length of the array. - * @param items The elements to add to the front of the array. - * @return The array with the element added to the beginning. - **/ - unshift(...items: Array): _Chain; - - /********** * - * Chaining * - *********** */ - - /** - * Wrapped type `any`. - * @see _.chain - **/ - chain(): _Chain; - - /** - * Wrapped type `any`. - * @see _.value - **/ - value(): T[]; -} -interface _ChainSingle { - value(): T; -} -interface _ChainOfArrays extends _Chain { - flatten(): _Chain; -} - -declare var _: UnderscoreStatic; - -declare module "underscore" { - export = _; -} From 2054af1c8db9896193fde838e5dd529feb53491b Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 18 Nov 2015 13:16:28 -0800 Subject: [PATCH 06/49] Uploader is added --- .vscode/launch.json | 6 +++--- config_example.json | 8 ++++--- src/classes/CLI.ts | 36 +++++++++++++++---------------- src/classes/Config.ts | 28 +++++++++++++++--------- src/classes/Sync.ts | 36 ++++++++++++++++--------------- src/classes/Uploader.ts | 38 +++++++++++++++++++++++++++++++++ src/classes/Watcher.ts | 44 ++++++++++++++++++++------------------ src/index.ts | 4 ++-- typings/scp2/scp2.d.ts | 47 +++++++++++++++++++++++++++++++++++++++++ 9 files changed, 174 insertions(+), 73 deletions(-) create mode 100644 src/classes/Uploader.ts create mode 100644 typings/scp2/scp2.d.ts diff --git a/.vscode/launch.json b/.vscode/launch.json index 9339632..b6a8b53 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ // Type of configuration. "type": "node", // Workspace relative or absolute path to the program. - "program": "sync.js", + "program": "bin/syncjs", // Automatically stop program after launch. "stopOnEntry": false, // Command line arguments passed to the program. @@ -24,9 +24,9 @@ "NODE_ENV": "development" }, // Use JavaScript source maps (if they exist). - "sourceMaps": false, + "sourceMaps": true, // If JavaScript source maps are enabled, the generated code is expected in this directory. - "outDir": null + "outDir": "dist/" }, { "name": "Attach", diff --git a/config_example.json b/config_example.json index a1950c8..4c71923 100644 --- a/config_example.json +++ b/config_example.json @@ -1,5 +1,7 @@ { - "host": "username@ssh.example.com", - "localPath": "/path/to/local/folder", - "remotePath": "/path/to/remote/folder" + "username": "ubuntu", + "host": "ec2-54-214-239-76.us-west-2.compute.amazonaws.com", + "localPath": "C:\\Users\\serka\\Projects\\sync", + "remotePath": "/home/ubuntu/src/sync", + "privateKey": "C:\\Users\\serka\\Dropbox\\serkan.io.pem" } \ No newline at end of file diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 5481aeb..db988a6 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,5 +1,5 @@ -import chalk = require('chalk'); -import readline = require('readline'); +import chalk = require("chalk"); +import readline = require("readline"); export default class CLI { @@ -17,8 +17,8 @@ export default class CLI { output: process.stdout }); } catch (e) { - this.write('You need to upgrade your nodejs'); - this.write('http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/'); + this.write("You need to upgrade your nodejs"); + this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/"); process.exit(1); } } @@ -27,7 +27,7 @@ export default class CLI { * Clear the terminal */ clear() { - this.write(chalk.reset('\x1b[2J\x1b[0;0H')); + this.write(chalk.reset("\x1b[2J\x1b[0;0H")); } /** @@ -42,7 +42,7 @@ export default class CLI { */ startProgress() { this.pdTime = setInterval(() => { - this.write(chalk.green('.')) + this.write(chalk.green(".")); }, 200); } @@ -60,13 +60,13 @@ export default class CLI { this.clear(); if (this.paused) { - this.write(`Currently paused, type "${ chalk.green('resume') }" to start again.\n`); + this.write(`Currently paused, type "${ chalk.green("resume") }" to start again.\n`); } else { this.write(`Started monitoring \n`); } - this.write(`Quit the script with CONTROL-C or type "${ chalk.green('exit') }".\n`); - this.write(chalk.magenta('-----------------------------------------------------------\n')); + this.write(`Quit the script with CONTROL-C or type "${ chalk.green("exit") }".\n`); + this.write(chalk.magenta("-----------------------------------------------------------\n")); this.showPrompt(); } @@ -92,18 +92,18 @@ export default class CLI { * Handle given input */ private handleInput(input) { - input = input.split(' '); + input = input.split(" "); let cmd = input[0]; let arg1 = input[1]; switch (cmd) { case "help": let helpText = ""; - helpText += this.getHelp('pause', "Stops observing file changes"); - helpText += this.getHelp('resume', "Continue checking files"); - helpText += this.getHelp('resume -u', "Continue checking files and upload all the changed files while paused."); - helpText += this.getHelp('help', "Displays this text"); - helpText += this.getHelp('clear', "Clears the screen"); - helpText += this.getHelp('exit', "Exits the script"); + helpText += this.getHelp("pause", "Stops observing file changes"); + helpText += this.getHelp("resume", "Continue checking files"); + helpText += this.getHelp("resume -u", "Continue checking files and upload all the changed files while paused."); + helpText += this.getHelp("help", "Displays this text"); + helpText += this.getHelp("clear", "Clears the screen"); + helpText += this.getHelp("exit", "Exits the script"); this.write(helpText); break; case "clear": @@ -125,11 +125,11 @@ export default class CLI { this.paused = false; this.workspace(); if (arg1 == "-u") { - this.write('Finding all changed files while waiting.\n'); + this.write("Finding all changed files while waiting.\n"); } // this.startChecking(); } else { - this.write('Already running\n'); + this.write("Already running\n"); } break; case "": break; diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 0e29770..9cd2270 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -1,15 +1,19 @@ -import { parse } from 'jsonplus'; -import { readFileSync, existsSync } from 'fs'; -import { join as pathJoin } from 'path'; +import { parse } from "jsonplus"; +import { readFileSync, existsSync } from "fs"; +import { join as pathJoin } from "path"; interface SyncConfig { + "username"?: string; + "password"?: string; + "port"?: number; "host": string; - "intervalDuration": number; "localPath": string; "remotePath": string; + "privateKey"?: string; + "ignores"?: Array; } -const FILE_NAME = 'config_example.json'; +const FILE_NAME = "config_example.json"; export default class Config implements SyncConfig{ private _filename: string; @@ -17,9 +21,13 @@ export default class Config implements SyncConfig{ // properties host: string; - intervalDuration: number; + username: string; + password: string; + port: number; localPath: string; remotePath: string; + privateKey: string; + ignores: Array; constructor() { this._filename = pathJoin(process.cwd(), FILE_NAME); @@ -45,9 +53,9 @@ export default class Config implements SyncConfig{ * @TODO add defaults for optional values */ private _expand() { - this.host = this._config.host; - this.intervalDuration = this._config.intervalDuration; - this.localPath = this._config.localPath; - this.remotePath = this._config.remotePath; + ["host", "port", "username", "password", + "localPath", "remotePath", "ignores", "privateKey"].forEach(prop => { + this[prop] = this._config[prop]; + }); } } \ No newline at end of file diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index de02892..f590ad9 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -1,35 +1,37 @@ -import SyncError from './SyncError'; -import Config from './Config'; -import CLI from './CLI'; -import Watcher from './Watcher'; +import SyncError from "./SyncError"; +import Config from "./Config"; +import CLI from "./CLI"; +import Watcher from "./Watcher"; +import Uploader from "./Uploader"; export default class Sync { config: Config; watch: Watcher; cli: CLI; + uploader: Uploader; constructor() { - + // Get config this.config = new Config(); - this.cli = new CLI(); - this.cli.write('Connecting'); + // Get Command line interface + this.cli = new CLI(); + this.cli.write("Connecting"); this.cli.startProgress(); - this.watch = new Watcher(); + // Setup the uploader + this.uploader = new Uploader(this.config); + + // Initiate file watch + this.watch = new Watcher(this.uploader, this.config); + + // When files are found start connection this.watch.ready().then(() => { - return this.connect(); + return this.uploader.connect(); }).then(() => { + // All done, stop indicator and show workspace this.cli.stopProgress(); this.cli.workspace(); }); } - - connect(): Promise { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve('connected'); - }, 5000); - }); - } } \ No newline at end of file diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts new file mode 100644 index 0000000..44c07de --- /dev/null +++ b/src/classes/Uploader.ts @@ -0,0 +1,38 @@ +import { Client } from "scp2"; +import Config from "./Config"; + +export default class Uploader { + constructor(private config: Config) {} + + connect(): Promise { + + let client = new Client({ + port: this.config.port, + host: this.config.host, + username: this.config.username, + password: this.config.password, + privateKey: require("fs").readFileSync(this.config.privateKey), + debug: true + }); + client.sftp((err, sftp) => { + if (err) { + console.log("There was a problem with connection"); + } + }); + + return new Promise((resolve, reject) => { + client.on("ready", () => { + resolve("connected"); + }); + }); + } + + uploadFile(fileName: string) { + let remote:string; + + remote = fileName.replace(this.config.localPath, this.config.remotePath); + + console.log(`local ${fileName} => remote ${remote}`); + + } +} diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index 6c9f670..f135952 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -1,53 +1,57 @@ -import chokidar = require('chokidar'); - +import chokidar = require("chokidar"); +import Uploader from "./Uploader"; +import Config from "./Config"; export default class Watcher { files: chokidar.FSWatcher; constructor( - private base: string = process.cwd(), - private ignores = [], - private noDefaultIgnores = false) { + private uploader: Uploader, + private config: Config, + private base: string = process.cwd() + ) { + + let defaultIgnores:Array = [/node_modules/, /.git/, /.svn/, /bower_components/]; this.files = chokidar.watch(base, { - ignored: [/node_modules/, /.git/, /.svn/, /bower_components/].concat(this.ignores), + ignored: defaultIgnores.concat(this.config.ignores), ignoreInitial: true }); // Attach events - ['all', 'add', 'change', 'unlink', 'addDir', 'unlinkDir'].forEach(method => { + ["all", "add", "change", "unlink", "addDir", "unlinkDir"].forEach(method => { this.files.on(method, this[method]); }); } ready(): Promise { let deferred = new Promise((resolve) => { - this.files.on('ready', resolve); + this.files.on("ready", resolve); }); - return deferred + return deferred; } all = (event:string, path:string) => { console.log(event, path); - } + }; add = (path: string) => { - - } + console.log("add", path); + }; change = (path: string) => { - // console.log(`file changed ${path}`); - } + this.uploader.uploadFile(path); + }; unlink = (path: string) => { - - } + console.log("unlink", path); + }; addDir = (path: string) => { - - } + console.log("addDir", path); + }; unlinkDir = (path: string) => { - - } + console.log("unlinkDir", path); + }; } diff --git a/src/index.ts b/src/index.ts index 4755ce7..a130015 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import Sync from './classes/Sync'; -import 'es6-promise'; +import Sync from "./classes/Sync"; +import "es6-promise"; // Main Export export default Sync; \ No newline at end of file diff --git a/typings/scp2/scp2.d.ts b/typings/scp2/scp2.d.ts new file mode 100644 index 0000000..8887f23 --- /dev/null +++ b/typings/scp2/scp2.d.ts @@ -0,0 +1,47 @@ + +declare module "scp2" { + + interface ScpOptions { + port?: number; + host?: string; + username?: string; + password?: string; + paths?: string; + privateKey?: string; + debug?: boolean; + } + + interface attrs { + size: number; + uid: number; + gid: number; + mode: number | string; + atime: number; + mtime: number; + } + + interface writeOptions { + destination: string; + content: string; + attrs: attrs; + source: string; + } + + export class Client { + constructor(options: ScpOptions); + sftp(callback: (err: string, sftp: Client) => void); + close(): void; + mkdir(dir: string, attrs: attrs, callback: (err: string) => void); + write(options: writeOptions, callback: (err: string) => void); + upload(src: string, destination: string, callback: (err: string) => void); + download(src: string, destination: string, callback: (err: string) => void); + on(eventName: string, callback: () => void); + } + + export interface client { + defaults(options: ScpOptions); + scp(fileName: string, options: ScpOptions | string, errCallback?: (err: string) => void); + scp(fileName: string, options: ScpOptions | string, glob: string, errCallback?: (err: string) => void); + Client: Client; + } +} \ No newline at end of file From d003b14c324074d85abee065a5463fcb1f37d005 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Thu, 19 Nov 2015 01:31:24 -0800 Subject: [PATCH 07/49] first upload --- package.json | 3 +- src/classes/Config.ts | 7 +- src/classes/SyncError.ts | 1 + src/classes/Uploader.ts | 44 +++++-- src/classes/Watcher.ts | 16 ++- typings/scp2/scp2.d.ts | 19 ++-- typings/upath/upath.d.ts | 239 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 303 insertions(+), 26 deletions(-) create mode 100644 typings/upath/upath.d.ts diff --git a/package.json b/package.json index f226764..df77b6e 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "chokidar": "^1.2.0", "es6-promise": "^3.0.2", "moment": "latest", - "scp2": "^0.2.2" + "scp2": "^0.2.2", + "upath": "^0.1.6" } } diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 9cd2270..29d0315 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -11,6 +11,7 @@ interface SyncConfig { "remotePath": string; "privateKey"?: string; "ignores"?: Array; + "pathMode": string; } const FILE_NAME = "config_example.json"; @@ -28,6 +29,7 @@ export default class Config implements SyncConfig{ remotePath: string; privateKey: string; ignores: Array; + pathMode: string = "0755"; constructor() { this._filename = pathJoin(process.cwd(), FILE_NAME); @@ -50,12 +52,11 @@ export default class Config implements SyncConfig{ /** * @TODO add checks on required values - * @TODO add defaults for optional values */ private _expand() { - ["host", "port", "username", "password", + ["host", "port", "username", "password", "pathMode", "localPath", "remotePath", "ignores", "privateKey"].forEach(prop => { - this[prop] = this._config[prop]; + this[prop] = this._config[prop] || this[prop]; }); } } \ No newline at end of file diff --git a/src/classes/SyncError.ts b/src/classes/SyncError.ts index eb031c1..397457b 100644 --- a/src/classes/SyncError.ts +++ b/src/classes/SyncError.ts @@ -7,3 +7,4 @@ export default class SyncError { console.error(this.message); } } + diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 44c07de..9df1213 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -1,12 +1,15 @@ import { Client } from "scp2"; import Config from "./Config"; +import upath = require("upath"); export default class Uploader { + client: Client; + constructor(private config: Config) {} connect(): Promise { - let client = new Client({ + this.client = new Client({ port: this.config.port, host: this.config.host, username: this.config.username, @@ -14,25 +17,52 @@ export default class Uploader { privateKey: require("fs").readFileSync(this.config.privateKey), debug: true }); - client.sftp((err, sftp) => { + + this.client.sftp((err, sftp) => { if (err) { console.log("There was a problem with connection"); } }); return new Promise((resolve, reject) => { - client.on("ready", () => { + this.client.on("ready", () => { resolve("connected"); }); }); } - uploadFile(fileName: string) { - let remote:string; - remote = fileName.replace(this.config.localPath, this.config.remotePath); + getRemotePath(path: string): string { + let normalPath = upath.normalizeSafe(path); + let normalLocalPath = upath.normalizeSafe(this.config.localPath); + let remotePath = normalPath.replace(normalLocalPath, this.config.remotePath); + return upath.normalizeSafe(remotePath); + } + + uploadFile(fileName: string): Promise { + let defer = new Promise((resolve, reject) => { + let remote = this.getRemotePath(fileName); - console.log(`local ${fileName} => remote ${remote}`); + // Client upload also creates the folder but creates it using local mode + // in windows it might mean we won't have permissons to save the fileName + // So I create the folder manually here to solve that issue. + // Mode we set can be configured from the config file + this.client.mkdir(upath.dirname(remote), {mode: this.config.pathMode}, err => { + if(err) { + reject(err); + } else { + // Uplad the file + this.client.upload(fileName, remote, err => { + if (err) { + reject(err); + } else { + resolve(remote); + } + }); + } + }); + }); + return defer; } } diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index f135952..272642d 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -32,26 +32,30 @@ export default class Watcher { } all = (event:string, path:string) => { - console.log(event, path); + console.log(event,": ", path); }; add = (path: string) => { - console.log("add", path); + //console.log("add", path); }; change = (path: string) => { - this.uploader.uploadFile(path); + this.uploader.uploadFile(path).then(remote => { + console.log(`File uploaded ${remote}`); + }).catch((err) => { + console.error("Could not upload", err); + }); }; unlink = (path: string) => { - console.log("unlink", path); + //console.log("unlink", path); }; addDir = (path: string) => { - console.log("addDir", path); + // console.log("addDir", path); }; unlinkDir = (path: string) => { - console.log("unlinkDir", path); + //console.log("unlinkDir", path); }; } diff --git a/typings/scp2/scp2.d.ts b/typings/scp2/scp2.d.ts index 8887f23..8605631 100644 --- a/typings/scp2/scp2.d.ts +++ b/typings/scp2/scp2.d.ts @@ -12,19 +12,19 @@ declare module "scp2" { } interface attrs { - size: number; - uid: number; - gid: number; - mode: number | string; - atime: number; - mtime: number; + size?: number; + uid?: number; + gid?: number; + mode?: number | string; + atime?: number; + mtime?: number; } interface writeOptions { destination: string; - content: string; - attrs: attrs; - source: string; + content?: string; + attrs?: attrs; + source?: string; } export class Client { @@ -32,6 +32,7 @@ declare module "scp2" { sftp(callback: (err: string, sftp: Client) => void); close(): void; mkdir(dir: string, attrs: attrs, callback: (err: string) => void); + mkdir(dir: string, callback: (err: string) => void); write(options: writeOptions, callback: (err: string) => void); upload(src: string, destination: string, callback: (err: string) => void); download(src: string, destination: string, callback: (err: string) => void); diff --git a/typings/upath/upath.d.ts b/typings/upath/upath.d.ts new file mode 100644 index 0000000..2aabc73 --- /dev/null +++ b/typings/upath/upath.d.ts @@ -0,0 +1,239 @@ +declare module "upath" { + + /** + * A parsed path object generated by path.parse() or consumed by path.format(). + */ + export interface ParsedPath { + /** + * The root of the path such as '/' or 'c:\' + */ + root: string; + /** + * The full directory path such as '/home/user/dir' or 'c:\path\dir' + */ + dir: string; + /** + * The file name including extension (if any) such as 'index.html' + */ + base: string; + /** + * The file extension (if any) such as '.html' + */ + ext: string; + /** + * The file name without extension (if any) such as 'index' + */ + name: string; + } + + /** + * Version of the library + */ + export var VERSION: string; + + /** + * Just converts all `to/` and consolidates duplicates, without performing any normalization. + * + * @param p string path to convert to unix. + */ + export function toUnix(p: string): string; + + /** + * Exactly like path.normalize(path), but it keeps the first meaningful ./. + * + * Note that the unix / is returned everywhere, so windows \ is always converted to unix /. + * + * @param p string path to normalize. + */ + export function normalizeSafe(p: string): string; + + /** + * Exactly like path.normalizeSafe(path), but it trims any useless ending /. + * + * @param p string path to normalize + */ + export function normalizeTrim(p: string): string; + + /** + * Exactly like path.join(), but it keeps the first meaningful ./. + * + * Note that the unix / is returned everywhere, so windows \ is always converted to unix /. + * + * @param paths string paths to join + */ + export function joinSafe(...p: any[]): string; + + /** + * Adds .ext to filename, but only if it doesn't already have the exact extension. + * + * @param file string filename to add extension to + * @param ext string extension to add + */ + export function addExt(file: string, ext: string): string; + + /** + * Trims a filename's extension. + * + * Extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7). + * + * An Array of ignoreExts (eg ['.min']) prevents these from being considered as extension, thus are not trimmed. + * + * @param filename string filename to trim it's extension + * @param ignoreExts array extensions to ignore + * @param maxSize number max length of the extension + */ + export function trimExt(filename: string, ignoreExts?: string[], maxSize?: number): string; + + /** + * Removes the specific ext extension from filename, if it has it. Otherwise it leaves it as is. As in all upath functions, it be .ext or ext. + * + * @param file string filename to remove extension to + * @param ext string extension to remove + */ + export function removeExt(filename: string, ext: string): string; + + /** + * Changes a filename's extension to ext. If it has no (valid) extension, it adds it. + * + * Valid extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7). + * + * An Array of ignoreExts (eg ['.min']) prevents these from being considered as extension, thus are not changed - the new extension is added instead. + * + * @param filename string filename to change it's extension + * @param ext string extension to change to + * @param ignoreExts array extensions to ignore + * @param maxSize number max length of the extension + */ + export function changeExt(filename: string, ext: string, ignoreExts?: string[], maxSize?: number): string; + + /** + * Adds .ext to filename, only if it doesn't already have any old extension. + * + * (Old) extensions are considered to be up to maxSize chars long, counting the dot (defaults to 7). + * + * An Array of ignoreExts (eg ['.min']) will force adding default .ext even if one of these is present. + * + * @param filename string filename to default to it's extension + * @param ext string extension to default to + * @param ignoreExts array extensions to ignore + * @param maxSize number max length of the extension + */ + export function defaultExt(filename: string, ext: string, ignoreExts?: string[], maxSize?: number): string; + + /** + * Normalize a string path, reducing '..' and '.' parts. + * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. + * + * @param p string path to normalize. + */ + export function normalize(p: string): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: any[]): string; + /** + * Join all arguments together and normalize the resulting path. + * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. + * + * @param paths string paths to join. + */ + export function join(...paths: string[]): string; + /** + * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. + * + * Starting from leftmost {from} paramter, resolves {to} to an absolute path. + * + * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. + * + * @param pathSegments string paths to join. Non-string arguments are ignored. + */ + export function resolve(...pathSegments: any[]): string; + /** + * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. + * + * @param path path to test. + */ + export function isAbsolute(path: string): boolean; + /** + * Solve the relative path from {from} to {to}. + * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. + * + * @param from + * @param to + */ + export function relative(from: string, to: string): string; + /** + * Return the directory name of a path. Similar to the Unix dirname command. + * + * @param p the path to evaluate. + */ + export function dirname(p: string): string; + /** + * Return the last portion of a path. Similar to the Unix basename command. + * Often used to extract the file name from a fully qualified path. + * + * @param p the path to evaluate. + * @param ext optionally, an extension to remove from the result. + */ + export function basename(p: string, ext?: string): string; + /** + * Return the extension of the path, from the last '.' to end of string in the last portion of the path. + * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string + * + * @param p the path to evaluate. + */ + export function extname(p: string): string; + /** + * The platform-specific file separator. '\\' or '/'. + */ + export var sep: string; + /** + * The platform-specific file delimiter. ';' or ':'. + */ + export var delimiter: string; + /** + * Returns an object from a path string - the opposite of format(). + * + * @param pathString path to evaluate. + */ + export function parse(pathString: string): ParsedPath; + /** + * Returns a path string from an object - the opposite of parse(). + * + * @param pathString path to evaluate. + */ + export function format(pathObject: ParsedPath): string; + + export module posix { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } + + export module win32 { + export function normalize(p: string): string; + export function join(...paths: any[]): string; + export function resolve(...pathSegments: any[]): string; + export function isAbsolute(p: string): boolean; + export function relative(from: string, to: string): string; + export function dirname(p: string): string; + export function basename(p: string, ext?: string): string; + export function extname(p: string): string; + export var sep: string; + export var delimiter: string; + export function parse(p: string): ParsedPath; + export function format(pP: ParsedPath): string; + } +} \ No newline at end of file From 12f98f9d641cd929e86e1b61a8a87c9e92a2e9bf Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Thu, 19 Nov 2015 01:47:28 -0800 Subject: [PATCH 08/49] better error handling --- src/classes/Uploader.ts | 10 ++++++++-- src/classes/Watcher.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 9df1213..284e167 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -49,12 +49,18 @@ export default class Uploader { // Mode we set can be configured from the config file this.client.mkdir(upath.dirname(remote), {mode: this.config.pathMode}, err => { if(err) { - reject(err); + reject({ + message: `Could not create ${ upath.dirname(remote) }`, + error: err + }); } else { // Uplad the file this.client.upload(fileName, remote, err => { if (err) { - reject(err); + reject({ + message: `Could not upload ${ remote }`, + error: err + }); } else { resolve(remote); } diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index 272642d..e7ecd33 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -43,7 +43,7 @@ export default class Watcher { this.uploader.uploadFile(path).then(remote => { console.log(`File uploaded ${remote}`); }).catch((err) => { - console.error("Could not upload", err); + console.error(err.message, err.error); }); }; From 0a2e7be998a1f8063c76cd1703f0d9985592769a Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Fri, 4 Dec 2015 21:41:52 -0800 Subject: [PATCH 09/49] Fix permissons --- bin/syncjs | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/syncjs diff --git a/bin/syncjs b/bin/syncjs old mode 100644 new mode 100755 From 2a4124bec91848c6b1784c6efa755e065986b3f1 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Fri, 11 Dec 2015 12:21:02 -0800 Subject: [PATCH 10/49] make installable --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index df77b6e..0f4d737 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,11 @@ { "name": "sync.js", "version": "0.0.1", + "main": "dist/main.js", + "preferGlobal": true, + "bin": { + "syncjs": "bin/syncjs" + }, "dependencies": { "chalk": "^1.1.1", "chokidar": "^1.2.0", From ad12916b817c70d043bea31bece7968f5cafea35 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Fri, 11 Dec 2015 12:23:24 -0800 Subject: [PATCH 11/49] fix imports --- src/classes/CLI.ts | 4 ++-- src/classes/SyncError.ts | 1 - src/classes/Watcher.ts | 13 ++++--------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index db988a6..82112f5 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,5 +1,5 @@ -import chalk = require("chalk"); -import readline = require("readline"); +import * as chalk from "chalk"; +import * as readline from "readline"; export default class CLI { diff --git a/src/classes/SyncError.ts b/src/classes/SyncError.ts index 397457b..eb031c1 100644 --- a/src/classes/SyncError.ts +++ b/src/classes/SyncError.ts @@ -7,4 +7,3 @@ export default class SyncError { console.error(this.message); } } - diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index e7ecd33..a66a743 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -1,4 +1,4 @@ -import chokidar = require("chokidar"); +import * as chokidar from "chokidar"; import Uploader from "./Uploader"; import Config from "./Config"; @@ -19,16 +19,15 @@ export default class Watcher { }); // Attach events - ["all", "add", "change", "unlink", "addDir", "unlinkDir"].forEach(method => { + ["all", "add", "change", "unlink", "unlinkDir"].forEach(method => { this.files.on(method, this[method]); }); } ready(): Promise { - let deferred = new Promise((resolve) => { - this.files.on("ready", resolve); + return new Promise((resolve) => { + this.files.on("ready", ()=>{}); }); - return deferred; } all = (event:string, path:string) => { @@ -51,10 +50,6 @@ export default class Watcher { //console.log("unlink", path); }; - addDir = (path: string) => { - // console.log("addDir", path); - }; - unlinkDir = (path: string) => { //console.log("unlinkDir", path); }; From 6e1f01c701656fcbaba1152972e8af6e86dbdfc1 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Fri, 11 Dec 2015 12:25:23 -0800 Subject: [PATCH 12/49] minor fixes --- src/classes/Config.ts | 2 +- src/classes/SyncError.ts | 9 --------- src/classes/Uploader.ts | 4 +--- 3 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 src/classes/SyncError.ts diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 29d0315..e61a536 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -14,7 +14,7 @@ interface SyncConfig { "pathMode": string; } -const FILE_NAME = "config_example.json"; +const FILE_NAME = "sync-config.json"; export default class Config implements SyncConfig{ private _filename: string; diff --git a/src/classes/SyncError.ts b/src/classes/SyncError.ts deleted file mode 100644 index eb031c1..0000000 --- a/src/classes/SyncError.ts +++ /dev/null @@ -1,9 +0,0 @@ -export default class SyncError { - constructor(public message: string) { - this.show(); - } - - show() { - console.error(this.message); - } -} diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 284e167..fee5692 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -40,7 +40,7 @@ export default class Uploader { } uploadFile(fileName: string): Promise { - let defer = new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { let remote = this.getRemotePath(fileName); // Client upload also creates the folder but creates it using local mode @@ -68,7 +68,5 @@ export default class Uploader { } }); }); - - return defer; } } From 8ff7388d09b822dfad87a6fb36bad4b32e7ae945 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Fri, 11 Dec 2015 13:41:52 -0800 Subject: [PATCH 13/49] make sure npm install -g works --- bin/syncjs | 5 +++-- package.json | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/syncjs b/bin/syncjs index d2c38ec..ef06531 100755 --- a/bin/syncjs +++ b/bin/syncjs @@ -1,4 +1,5 @@ #!/usr/bin/env node -var Sync = require('../dist/index.js'); +var path = require('path'); +var Sync = require(path.resolve(__dirname, '../dist/src/index.js')).default; -new Sync.default(); \ No newline at end of file +new Sync(); \ No newline at end of file diff --git a/package.json b/package.json index 0f4d737..9fda549 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "version": "0.0.1", "main": "dist/main.js", "preferGlobal": true, + "scripts": { + "postinstall": "./node_modules/.bin/tsc" + }, "bin": { "syncjs": "bin/syncjs" }, @@ -10,8 +13,10 @@ "chalk": "^1.1.1", "chokidar": "^1.2.0", "es6-promise": "^3.0.2", + "jsonplus": "^1.2.1", "moment": "latest", "scp2": "^0.2.2", + "typescript": "^1.7.3", "upath": "^0.1.6" } } From 245d130e1fbfdcaf8d890912c344732fadab0d20 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Fri, 11 Dec 2015 13:42:04 -0800 Subject: [PATCH 14/49] Proper error handling --- src/classes/CLI.ts | 18 ++++++++++++++++-- src/classes/Config.ts | 17 +++++++++++------ src/classes/Sync.ts | 6 +++--- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 82112f5..6b86ab2 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,6 +1,11 @@ import * as chalk from "chalk"; import * as readline from "readline"; +export const EXIT_NORMAL = 0; +export const EXIT_RUNTIME_FAILURE = 7; +export const EXIT_PARSE_ERROR = 3; +export const EXIT_INVALID_ARGUMENT = 9; + export default class CLI { private rline: readline.ReadLine; @@ -17,8 +22,8 @@ export default class CLI { output: process.stdout }); } catch (e) { - this.write("You need to upgrade your nodejs"); - this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/"); + this.write("You need to upgrade your nodejs\n"); + this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); process.exit(1); } } @@ -70,6 +75,15 @@ export default class CLI { this.showPrompt(); } + usage(message: string = null, code: number = 0): void { + if (message) { + this.write(chalk.red(message) + '\n\n'); + } + this.write(chalk.green.underline('USAGE:\n')); + this.write('TODO\n'); + process.exit(code); + } + /** * Shorthand command to print help text */ diff --git a/src/classes/Config.ts b/src/classes/Config.ts index e61a536..63b1c72 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -1,6 +1,7 @@ import { parse } from "jsonplus"; import { readFileSync, existsSync } from "fs"; import { join as pathJoin } from "path"; +import CLI, { EXIT_INVALID_ARGUMENT, EXIT_PARSE_ERROR } from './CLI'; interface SyncConfig { "username"?: string; @@ -31,22 +32,26 @@ export default class Config implements SyncConfig{ ignores: Array; pathMode: string = "0755"; - constructor() { + constructor(private cli: CLI) { this._filename = pathJoin(process.cwd(), FILE_NAME); this._fetch(); this._expand(); } - /** - * @TODO fail when file is not found - * @TODO fail when file cannot be parsed - */ private _fetch() { if (existsSync(this._filename)) { let configraw; if (configraw = readFileSync(this._filename)) { - this._config = parse(configraw.toString()); + try { + this._config = parse(configraw.toString()); + } catch(e) { + this.cli.usage('Could not parse DB file. Make sure JSON is correct', EXIT_PARSE_ERROR); + } + } else { + this.cli.usage('Cannot read config file. Make sure you have permissions', EXIT_INVALID_ARGUMENT); } + } else { + this.cli.usage('Config file not found', EXIT_INVALID_ARGUMENT); } } diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index f590ad9..25fe6f0 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -1,4 +1,3 @@ -import SyncError from "./SyncError"; import Config from "./Config"; import CLI from "./CLI"; import Watcher from "./Watcher"; @@ -11,11 +10,12 @@ export default class Sync { uploader: Uploader; constructor() { + this.cli = new CLI(); + // Get config - this.config = new Config(); + this.config = new Config(this.cli); // Get Command line interface - this.cli = new CLI(); this.cli.write("Connecting"); this.cli.startProgress(); From 0a8bb7fc92f1b1cfddc3c868c30263065641c444 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sat, 12 Dec 2015 15:59:15 -0800 Subject: [PATCH 15/49] Get definitions in order --- package.json | 1 + src/classes/Watcher.ts | 3 ++- tsd.json | 30 ++++++++++++++++++++++ typings/chokidar/chokidar.d.ts | 13 ++-------- typings/es6-promise/es6-promise.d.ts | 2 +- typings/jsonplus/jsonplus.d.ts | 15 ----------- typings/minimist/minimist.d.ts | 38 ++++++++++++++++++++++++++++ typings/node/node.d.ts | 32 ++++++++++++++++++++--- typings/tsd.d.ts | 8 ++++++ 9 files changed, 110 insertions(+), 32 deletions(-) create mode 100644 tsd.json delete mode 100644 typings/jsonplus/jsonplus.d.ts create mode 100644 typings/minimist/minimist.d.ts create mode 100644 typings/tsd.d.ts diff --git a/package.json b/package.json index 9fda549..f3f1a25 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "chokidar": "^1.2.0", "es6-promise": "^3.0.2", "jsonplus": "^1.2.1", + "minimist": "^1.2.0", "moment": "latest", "scp2": "^0.2.2", "typescript": "^1.7.3", diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index a66a743..2d54090 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -1,9 +1,10 @@ import * as chokidar from "chokidar"; import Uploader from "./Uploader"; import Config from "./Config"; +import { FSWatcher } from "fs"; export default class Watcher { - files: chokidar.FSWatcher; + files: FSWatcher; constructor( private uploader: Uploader, diff --git a/tsd.json b/tsd.json new file mode 100644 index 0000000..0ddf0d8 --- /dev/null +++ b/tsd.json @@ -0,0 +1,30 @@ +{ + "version": "v4", + "repo": "borisyankov/DefinitelyTyped", + "ref": "master", + "path": "typings", + "bundle": "typings/tsd.d.ts", + "installed": { + "minimist/minimist.d.ts": { + "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" + }, + "chalk/chalk.d.ts": { + "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" + }, + "chokidar/chokidar.d.ts": { + "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" + }, + "node/node.d.ts": { + "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" + }, + "es6-promise/es6-promise.d.ts": { + "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" + }, + "moment/moment.d.ts": { + "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" + }, + "moment/moment-node.d.ts": { + "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" + } + } +} diff --git a/typings/chokidar/chokidar.d.ts b/typings/chokidar/chokidar.d.ts index 663197f..6a417ca 100644 --- a/typings/chokidar/chokidar.d.ts +++ b/typings/chokidar/chokidar.d.ts @@ -37,15 +37,6 @@ declare module "chokidar" import fs = require("fs"); - interface FSWatcher extends fs.FSWatcher { - add(path:string); - add(paths:string[]); // (path / paths): Add files, directories, or glob patterns for tracking. Takes an array of strings or just one string. - on(event:string, callback:Function);// Listen for an FS event. Available events: add, addDir, change, unlink, unlinkDir, ready, raw, error. Additionally all is available which gets emitted with the underlying event name and path for every event other than ready, raw, and error. - unwatch(path:string); - unwatch(paths:string[]); // : Stop watching files, directories, or glob patterns. Takes an array of strings or just one string. - close(); //: Removes all listeners from watched files. - } - - function watch( fileDirOrGlob:string, options?:WatchOptions ): FSWatcher; - function watch( filesDirsOrGlobs:Array, options?:WatchOptions ): FSWatcher; + function watch( fileDirOrGlob:string, options?:WatchOptions ):fs.FSWatcher; + function watch( filesDirsOrGlobs:Array, options?:WatchOptions ):fs.FSWatcher; } diff --git a/typings/es6-promise/es6-promise.d.ts b/typings/es6-promise/es6-promise.d.ts index 86c8227..daf7134 100644 --- a/typings/es6-promise/es6-promise.d.ts +++ b/typings/es6-promise/es6-promise.d.ts @@ -12,7 +12,7 @@ declare class Promise implements Thenable { /** * If you call resolve in the body of the callback passed to the constructor, * your promise is fulfilled with result object passed to resolve. - * If you call reject your promise is rejected with the object passed to resolve. + * If you call reject your promise is rejected with the object passed to reject. * For consistency and debugging (eg stack traces), obj should be an instanceof Error. * Any errors thrown in the constructor callback will be implicitly passed to reject(). */ diff --git a/typings/jsonplus/jsonplus.d.ts b/typings/jsonplus/jsonplus.d.ts deleted file mode 100644 index f164d92..0000000 --- a/typings/jsonplus/jsonplus.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -declare module "jsonplus" { - /** - * Takes a JSON string and returns back an object. - * In JSON String values you can use `@self` - * notation and reference the JSON itself. This will - * replace the value with reference - */ - function parse(jsonString: string): any; - - /** - * Resolves self references on an already parsed object - * self here is where references will be resolved against - */ - function resolve(object: any, self?: any): any; -} diff --git a/typings/minimist/minimist.d.ts b/typings/minimist/minimist.d.ts new file mode 100644 index 0000000..abbc5f0 --- /dev/null +++ b/typings/minimist/minimist.d.ts @@ -0,0 +1,38 @@ +// Type definitions for minimist 1.1.3 +// Project: https://github.com/substack/minimist +// Definitions by: Bart van der Schoor , Necroskillz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'minimist' { + function minimist(args?: string[], opts?: minimist.Opts): minimist.ParsedArgs; + + module minimist { + export interface Opts { + // a string or array of strings argument names to always treat as strings + // string?: string; + string?: string|string[]; + // a string or array of strings to always treat as booleans + // boolean?: string; + boolean?: boolean|string|string[]; + // an object mapping string names to strings or arrays of string argument names to use + // alias?: {[key:string]: string}; + alias?: {[key:string]: string[]}; + // an object mapping string argument names to default values + default?: {[key:string]: any}; + // when true, populate argv._ with everything after the first non-option + stopEarly?: boolean; + // a function which is invoked with a command line parameter not defined in the opts configuration object. + // If the function returns false, the unknown option is not added to argv + unknown?: (arg: string) => boolean; + // when true, populate argv._ with everything before the -- and argv['--'] with everything after the -- + '--'?: boolean; + } + + export interface ParsedArgs { + [arg: string]: any; + _: string[]; + } + } + + export = minimist; +} diff --git a/typings/node/node.d.ts b/typings/node/node.d.ts index 5a163f0..06c4bb9 100644 --- a/typings/node/node.d.ts +++ b/typings/node/node.d.ts @@ -430,7 +430,7 @@ declare module "http" { import * as events from "events"; import * as net from "net"; import * as stream from "stream"; - + export interface RequestOptions { protocol?: string; host?: string; @@ -698,7 +698,29 @@ declare module "zlib" { } declare module "os" { + export interface CpuInfo { + model: string; + speed: number; + times: { + user: number; + nice: number; + sys: number; + idle: number; + irq: number; + } + } + + export interface NetworkInterfaceInfo { + address: string; + netmask: string; + family: string; + mac: string; + internal: boolean; + } + export function tmpdir(): string; + export function homedir(): string; + export function endianness(): string; export function hostname(): string; export function type(): string; export function platform(): string; @@ -708,8 +730,8 @@ declare module "os" { export function loadavg(): number[]; export function totalmem(): number; export function freemem(): number; - export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[]; - export function networkInterfaces(): any; + export function cpus(): CpuInfo[]; + export function networkInterfaces(): {[index: string]: NetworkInterfaceInfo[]}; export var EOL: string; } @@ -1675,7 +1697,7 @@ declare module "crypto" { declare module "stream" { import * as events from "events"; - export interface Stream extends events.EventEmitter { + export class Stream extends events.EventEmitter { pipe(destination: T, options?: { end?: boolean; }): T; } @@ -1808,6 +1830,8 @@ declare module "assert" { export function notDeepEqual(acutal: any, expected: any, message?: string): void; export function strictEqual(actual: any, expected: any, message?: string): void; export function notStrictEqual(actual: any, expected: any, message?: string): void; + export function deepStrictEqual(actual: any, expected: any, message?: string): void; + export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; export var throws: { (block: Function, message?: string): void; (block: Function, error: Function, message?: string): void; diff --git a/typings/tsd.d.ts b/typings/tsd.d.ts new file mode 100644 index 0000000..5c85b09 --- /dev/null +++ b/typings/tsd.d.ts @@ -0,0 +1,8 @@ +/// +/// +/// +/// +/// +/// +/// +/// From ac54b441f8adcc65e7ef0ffe905f8953061ab478 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sat, 12 Dec 2015 17:38:29 -0800 Subject: [PATCH 16/49] Accept arguments --- bin/syncjs | 2 +- src/classes/CLI.ts | 40 +++++++++++++++++++++++++++++++++++----- src/classes/Config.ts | 10 +++++----- src/classes/Sync.ts | 42 ++++++++++++++++++++++++------------------ 4 files changed, 65 insertions(+), 29 deletions(-) diff --git a/bin/syncjs b/bin/syncjs index ef06531..74e6c50 100755 --- a/bin/syncjs +++ b/bin/syncjs @@ -1,5 +1,5 @@ #!/usr/bin/env node var path = require('path'); -var Sync = require(path.resolve(__dirname, '../dist/src/index.js')).default; +var Sync = require(path.resolve(__dirname, '../dist/index.js')).default; new Sync(); \ No newline at end of file diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 6b86ab2..78224d9 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,5 +1,6 @@ import * as chalk from "chalk"; import * as readline from "readline"; +import * as minimist from "minimist"; export const EXIT_NORMAL = 0; export const EXIT_RUNTIME_FAILURE = 7; @@ -12,10 +13,15 @@ export default class CLI { private pdTime: NodeJS.Timer; private lastRun: number; private timeDiff: number; + private args: minimist.ParsedArgs; public paused: boolean; constructor() { + + // Parse arguments + this.args = minimist(process.argv.slice(2)); + try { this.rline = readline.createInterface({ input: process.stdin, @@ -24,10 +30,34 @@ export default class CLI { } catch (e) { this.write("You need to upgrade your nodejs\n"); this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); - process.exit(1); + process.exit(EXIT_RUNTIME_FAILURE); } } + /** + * Checks if a command has been passed or not + * @param command string name of the command + */ + hasStartupCommand(command: string): boolean { + return this.args._.filter( n => n === command ).length > 0; + } + + /** + * Gets requested argument + * @param name string name of the argument + */ + getArgument(name: string, defaultValue: any = null): any { + let value = null; + + if (name in this.args) { + value = this.args[name]; + } else if (name[0] in this.args) { + value = this.args[name[0]]; + } + + return value !== null? value : defaultValue; + } + /** * Clear the terminal */ @@ -77,10 +107,10 @@ export default class CLI { usage(message: string = null, code: number = 0): void { if (message) { - this.write(chalk.red(message) + '\n\n'); + this.write(chalk.red(message) + "n\n"); } - this.write(chalk.green.underline('USAGE:\n')); - this.write('TODO\n'); + this.write(chalk.green.underline("USAGE:\n")); + this.write("TODO\n"); process.exit(code); } @@ -124,7 +154,7 @@ export default class CLI { this.workspace(); break; case "exit": - process.exit(0); + process.exit(EXIT_NORMAL); break; case "pause": this.paused = true; diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 63b1c72..f546d50 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -1,7 +1,7 @@ import { parse } from "jsonplus"; import { readFileSync, existsSync } from "fs"; import { join as pathJoin } from "path"; -import CLI, { EXIT_INVALID_ARGUMENT, EXIT_PARSE_ERROR } from './CLI'; +import CLI, { EXIT_INVALID_ARGUMENT, EXIT_PARSE_ERROR } from "./CLI"; interface SyncConfig { "username"?: string; @@ -33,7 +33,7 @@ export default class Config implements SyncConfig{ pathMode: string = "0755"; constructor(private cli: CLI) { - this._filename = pathJoin(process.cwd(), FILE_NAME); + this._filename = pathJoin(process.cwd(), this.cli.getArgument("config", FILE_NAME)); this._fetch(); this._expand(); } @@ -45,13 +45,13 @@ export default class Config implements SyncConfig{ try { this._config = parse(configraw.toString()); } catch(e) { - this.cli.usage('Could not parse DB file. Make sure JSON is correct', EXIT_PARSE_ERROR); + this.cli.usage("Could not parse DB file. Make sure JSON is correct", EXIT_PARSE_ERROR); } } else { - this.cli.usage('Cannot read config file. Make sure you have permissions', EXIT_INVALID_ARGUMENT); + this.cli.usage("Cannot read config file. Make sure you have permissions", EXIT_INVALID_ARGUMENT); } } else { - this.cli.usage('Config file not found', EXIT_INVALID_ARGUMENT); + this.cli.usage("Config file not found", EXIT_INVALID_ARGUMENT); } } diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index 25fe6f0..3d431b5 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -1,5 +1,5 @@ import Config from "./Config"; -import CLI from "./CLI"; +import CLI, { EXIT_NORMAL } from "./CLI"; import Watcher from "./Watcher"; import Uploader from "./Uploader"; @@ -12,26 +12,32 @@ export default class Sync { constructor() { this.cli = new CLI(); - // Get config - this.config = new Config(this.cli); + if (this.cli.hasStartupCommand("init")) { + this.cli.write("TODO: generate a config file"); - // Get Command line interface - this.cli.write("Connecting"); - this.cli.startProgress(); + process.exit(EXIT_NORMAL); + } else { + // Get config + this.config = new Config(this.cli); - // Setup the uploader - this.uploader = new Uploader(this.config); + // Get Command line interface + this.cli.write("Connecting"); + this.cli.startProgress(); - // Initiate file watch - this.watch = new Watcher(this.uploader, this.config); + // Setup the uploader + this.uploader = new Uploader(this.config); - // When files are found start connection - this.watch.ready().then(() => { - return this.uploader.connect(); - }).then(() => { - // All done, stop indicator and show workspace - this.cli.stopProgress(); - this.cli.workspace(); - }); + // Initiate file watch + this.watch = new Watcher(this.uploader, this.config); + + // When files are found start connection + this.watch.ready().then(() => { + return this.uploader.connect(); + }).then(() => { + // All done, stop indicator and show workspace + this.cli.stopProgress(); + this.cli.workspace(); + }); + } } } \ No newline at end of file From bb7f35e3b166e17b4a8d80ce9f134c02df391211 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 13 Dec 2015 01:18:26 -0800 Subject: [PATCH 17/49] Config creator --- src/classes/CLI.ts | 6 ++++ src/classes/Config.ts | 8 ++--- src/classes/InitConfig.ts | 74 +++++++++++++++++++++++++++++++++++++++ src/classes/Sync.ts | 7 ++-- src/classes/Uploader.ts | 2 +- 5 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 src/classes/InitConfig.ts diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 78224d9..5a6ee4f 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -72,6 +72,12 @@ export default class CLI { return process.stdout.write.bind(process.stdout)(msg); } + read(question: string): Promise { + return new Promise((resolve) => { + this.rline.question(`${question}:\n>>> `, resolve); + }); + } + /** * Start printing dots to screen, show script is working */ diff --git a/src/classes/Config.ts b/src/classes/Config.ts index f546d50..219bf6d 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -3,7 +3,7 @@ import { readFileSync, existsSync } from "fs"; import { join as pathJoin } from "path"; import CLI, { EXIT_INVALID_ARGUMENT, EXIT_PARSE_ERROR } from "./CLI"; -interface SyncConfig { +export interface SyncConfig { "username"?: string; "password"?: string; "port"?: number; @@ -12,10 +12,10 @@ interface SyncConfig { "remotePath": string; "privateKey"?: string; "ignores"?: Array; - "pathMode": string; + "pathMode"?: string; } -const FILE_NAME = "sync-config.json"; +export const CONFIG_FILE_NAME = "sync-config.json"; export default class Config implements SyncConfig{ private _filename: string; @@ -33,7 +33,7 @@ export default class Config implements SyncConfig{ pathMode: string = "0755"; constructor(private cli: CLI) { - this._filename = pathJoin(process.cwd(), this.cli.getArgument("config", FILE_NAME)); + this._filename = pathJoin(process.cwd(), this.cli.getArgument("config", CONFIG_FILE_NAME)); this._fetch(); this._expand(); } diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts new file mode 100644 index 0000000..a2a33db --- /dev/null +++ b/src/classes/InitConfig.ts @@ -0,0 +1,74 @@ +import CLI, {EXIT_NORMAL} from "./CLI"; +import { SyncConfig, CONFIG_FILE_NAME } from './Config'; +import * as chalk from "chalk"; +import * as upath from "upath"; +import { writeFileSync } from 'fs'; + +export default class InitConfig { + + constructor(private cli: CLI) { + this.collectInformation(); + } + + collectInformation () { + let newConfig: SyncConfig = { localPath: null, remotePath: null, host: null }; + let leaveEmpty = chalk.gray("[hit enter to leave empty]"); + let useDefault = chalk.gray("[hit enter to use default]"); + let required = chalk.red("[required]"); + + this.cli.read(`${chalk.green("Username to connect")} ${leaveEmpty}`).then(answer => { + if (answer) { + newConfig.username = answer; + } + return this.cli.read(`${chalk.green("Password to connect")} ${leaveEmpty}`); + }).then(answer => { + if (answer) { + newConfig.password = answer; + } + return this.cli.read(`${chalk.green("Port number to connect")} ${leaveEmpty}`); + }) + .then(answer => { + if (Number(answer)) { + newConfig.port = Number(answer); + } + return this.cli.read(`${chalk.green("Domain or ip address to connect")} ${required}`); + }) + .then(answer => { + if (answer) { + newConfig.host = answer; + } + return this.cli.read(`${chalk.green("Local Path:")} [${process.cwd()}] ${useDefault}`); + }) + .then(answer => { + if (answer) { + newConfig.localPath = upath.normalizeSafe(answer); + } else { + newConfig.localPath = upath.normalizeSafe(process.cwd()); + } + return this.cli.read(`${chalk.green("Remote Path")} ${required}`); + }) + .then(answer => { + if (answer) { + newConfig.remotePath = answer; + } + return this.cli.read(`${chalk.green("Path to privateKey if any")} ${leaveEmpty}`); + }) + .then(answer => { + if (answer) { + newConfig.privateKey = upath.normalizeSafe(answer); + } + return this.cli.read(`${chalk.green("Does this look good?")} + \n${JSON.stringify(newConfig, null, 4)} + \n${chalk.green("Say [yes] or [no]")}`); + }).then((answer) => { + if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') { + writeFileSync(CONFIG_FILE_NAME, JSON.stringify(newConfig, null, 4), 'utf8'); + this.cli.write(`${CONFIG_FILE_NAME} is saved.\n`); + } else { + this.cli.write("Operation cancelled. Exiting..."); + } + + process.exit(EXIT_NORMAL); + }); + } +} \ No newline at end of file diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index 3d431b5..6c901ef 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -1,7 +1,8 @@ import Config from "./Config"; -import CLI, { EXIT_NORMAL } from "./CLI"; +import CLI from "./CLI"; import Watcher from "./Watcher"; import Uploader from "./Uploader"; +import InitConfig from './InitConfig'; export default class Sync { config: Config; @@ -13,9 +14,7 @@ export default class Sync { this.cli = new CLI(); if (this.cli.hasStartupCommand("init")) { - this.cli.write("TODO: generate a config file"); - - process.exit(EXIT_NORMAL); + new InitConfig(this.cli); } else { // Get config this.config = new Config(this.cli); diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index fee5692..21e16ca 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -1,6 +1,6 @@ +import * as upath from "upath"; import { Client } from "scp2"; import Config from "./Config"; -import upath = require("upath"); export default class Uploader { client: Client; From 3ce2a9910ce68d628b1659f35565f87c1e959c5f Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 13 Dec 2015 01:41:54 -0800 Subject: [PATCH 18/49] Use Enum instead of const for error codes --- src/classes/CLI.ts | 29 +++++++++++++++++++++++------ src/classes/Config.ts | 8 ++++---- src/classes/InitConfig.ts | 6 +++--- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 5a6ee4f..ec78ad9 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -2,10 +2,27 @@ import * as chalk from "chalk"; import * as readline from "readline"; import * as minimist from "minimist"; -export const EXIT_NORMAL = 0; -export const EXIT_RUNTIME_FAILURE = 7; -export const EXIT_PARSE_ERROR = 3; -export const EXIT_INVALID_ARGUMENT = 9; +export enum EXIT_CODE { + /** + * Exit normally + */ + NORMAL = 0, + + /** + * Any kind exit with error + */ + RUNTIME_FAILURE = 1, + + /** + * If user terminates with ctrl-c use this + */ + TERMINATED = 130, + + /** + * Tell user that arguments were wrong + */ + INVALID_ARGUMENT = 128 +} export default class CLI { @@ -30,7 +47,7 @@ export default class CLI { } catch (e) { this.write("You need to upgrade your nodejs\n"); this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); - process.exit(EXIT_RUNTIME_FAILURE); + process.exit(EXIT_CODE.RUNTIME_FAILURE); } } @@ -160,7 +177,7 @@ export default class CLI { this.workspace(); break; case "exit": - process.exit(EXIT_NORMAL); + process.exit(EXIT_CODE.NORMAL); break; case "pause": this.paused = true; diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 219bf6d..8e2a553 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -1,7 +1,7 @@ import { parse } from "jsonplus"; import { readFileSync, existsSync } from "fs"; import { join as pathJoin } from "path"; -import CLI, { EXIT_INVALID_ARGUMENT, EXIT_PARSE_ERROR } from "./CLI"; +import CLI, { EXIT_CODE } from "./CLI"; export interface SyncConfig { "username"?: string; @@ -45,13 +45,13 @@ export default class Config implements SyncConfig{ try { this._config = parse(configraw.toString()); } catch(e) { - this.cli.usage("Could not parse DB file. Make sure JSON is correct", EXIT_PARSE_ERROR); + this.cli.usage("Could not parse DB file. Make sure JSON is correct", EXIT_CODE.RUNTIME_FAILURE); } } else { - this.cli.usage("Cannot read config file. Make sure you have permissions", EXIT_INVALID_ARGUMENT); + this.cli.usage("Cannot read config file. Make sure you have permissions", EXIT_CODE.INVALID_ARGUMENT); } } else { - this.cli.usage("Config file not found", EXIT_INVALID_ARGUMENT); + this.cli.usage("Config file not found", EXIT_CODE.INVALID_ARGUMENT); } } diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index a2a33db..5284ac2 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -1,8 +1,8 @@ -import CLI, {EXIT_NORMAL} from "./CLI"; -import { SyncConfig, CONFIG_FILE_NAME } from './Config'; import * as chalk from "chalk"; import * as upath from "upath"; import { writeFileSync } from 'fs'; +import CLI, { EXIT_CODE } from "./CLI"; +import { SyncConfig, CONFIG_FILE_NAME } from './Config'; export default class InitConfig { @@ -68,7 +68,7 @@ export default class InitConfig { this.cli.write("Operation cancelled. Exiting..."); } - process.exit(EXIT_NORMAL); + process.exit(EXIT_CODE.NORMAL); }); } } \ No newline at end of file From fbd4fdee3a8fd5701ade17dc3dc58c5a3523d75c Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 13 Dec 2015 01:53:24 -0800 Subject: [PATCH 19/49] whitespace fixes --- src/classes/InitConfig.ts | 15 +++++---------- src/classes/Uploader.ts | 3 ++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index 5284ac2..ae121ee 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -26,34 +26,29 @@ export default class InitConfig { newConfig.password = answer; } return this.cli.read(`${chalk.green("Port number to connect")} ${leaveEmpty}`); - }) - .then(answer => { + }).then(answer => { if (Number(answer)) { newConfig.port = Number(answer); } return this.cli.read(`${chalk.green("Domain or ip address to connect")} ${required}`); - }) - .then(answer => { + }).then(answer => { if (answer) { newConfig.host = answer; } return this.cli.read(`${chalk.green("Local Path:")} [${process.cwd()}] ${useDefault}`); - }) - .then(answer => { + }).then(answer => { if (answer) { newConfig.localPath = upath.normalizeSafe(answer); } else { newConfig.localPath = upath.normalizeSafe(process.cwd()); } return this.cli.read(`${chalk.green("Remote Path")} ${required}`); - }) - .then(answer => { + }).then(answer => { if (answer) { newConfig.remotePath = answer; } return this.cli.read(`${chalk.green("Path to privateKey if any")} ${leaveEmpty}`); - }) - .then(answer => { + }).then(answer => { if (answer) { newConfig.privateKey = upath.normalizeSafe(answer); } diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 21e16ca..2ad5720 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -1,4 +1,5 @@ import * as upath from "upath"; +import { readFileSync } from "fs"; import { Client } from "scp2"; import Config from "./Config"; @@ -14,7 +15,7 @@ export default class Uploader { host: this.config.host, username: this.config.username, password: this.config.password, - privateKey: require("fs").readFileSync(this.config.privateKey), + privateKey: readFileSync(this.config.privateKey).toString(), debug: true }); From 3c00fac2ac704bff78e87d53a8f345c1eb5956a0 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 13 Dec 2015 02:13:25 -0800 Subject: [PATCH 20/49] Add unlink file method --- src/classes/Uploader.ts | 24 +++++++++++++++++++++++- src/classes/Watcher.ts | 14 +++++++++++--- typings/scp2/scp2.d.ts | 2 +- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 2ad5720..0bd243a 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -32,7 +32,6 @@ export default class Uploader { }); } - getRemotePath(path: string): string { let normalPath = upath.normalizeSafe(path); let normalLocalPath = upath.normalizeSafe(this.config.localPath); @@ -40,6 +39,29 @@ export default class Uploader { return upath.normalizeSafe(remotePath); } + unlinkFile(fileName: string): Promise { + return new Promise((resolve, reject) => { + let remote = this.getRemotePath(fileName); + + this.client.sftp((err, sftp) => { + if (err) { + reject('SFTP cannot be created'); + } else { + sftp.ready(()=> { + console.log('connection established'); + sftp.unlink(remote, (err) => { + if (err) { + reject('File could not be deleted'); + } else { + resolve(remote); + } + }); + }); + } + }); + }); + } + uploadFile(fileName: string): Promise { return new Promise((resolve, reject) => { let remote = this.getRemotePath(fileName); diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index 2d54090..9eb501d 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -32,11 +32,15 @@ export default class Watcher { } all = (event:string, path:string) => { - console.log(event,": ", path); + // console.log(event,": ", path); }; add = (path: string) => { - //console.log("add", path); + this.uploader.uploadFile(path).then(remote => { + console.log(`File uploaded ${remote}`); + }).catch((err) => { + console.error(err.message, err.error); + }); }; change = (path: string) => { @@ -48,7 +52,11 @@ export default class Watcher { }; unlink = (path: string) => { - //console.log("unlink", path); + this.uploader.unlinkFile(path).then(remote => { + console.log(`File deleted ${remote}`); + }).catch((err) => { + console.log(`Error deleting file ${err}`); + }); }; unlinkDir = (path: string) => { diff --git a/typings/scp2/scp2.d.ts b/typings/scp2/scp2.d.ts index 8605631..247b966 100644 --- a/typings/scp2/scp2.d.ts +++ b/typings/scp2/scp2.d.ts @@ -29,7 +29,7 @@ declare module "scp2" { export class Client { constructor(options: ScpOptions); - sftp(callback: (err: string, sftp: Client) => void); + sftp(callback: (err: string, sftp: any) => void); close(): void; mkdir(dir: string, attrs: attrs, callback: (err: string) => void); mkdir(dir: string, callback: (err: string) => void); From 8fa58a0ae5487968548120e7206744ca44e69924 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 13 Dec 2015 02:46:08 -0800 Subject: [PATCH 21/49] Fix connection problems and implement folder and file delete --- src/classes/Sync.ts | 4 ++-- src/classes/Uploader.ts | 42 ++++++++++++++++++++++++++++------------- src/classes/Watcher.ts | 12 +++++++++--- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index 6c901ef..f65e1a4 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -24,10 +24,10 @@ export default class Sync { this.cli.startProgress(); // Setup the uploader - this.uploader = new Uploader(this.config); + this.uploader = new Uploader(this.config, this.cli); // Initiate file watch - this.watch = new Watcher(this.uploader, this.config); + this.watch = new Watcher(this.uploader, this.config, this.cli); // When files are found start connection this.watch.ready().then(() => { diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 0bd243a..81a02c1 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -2,23 +2,24 @@ import * as upath from "upath"; import { readFileSync } from "fs"; import { Client } from "scp2"; import Config from "./Config"; +import CLI from "./CLI"; export default class Uploader { client: Client; - constructor(private config: Config) {} + constructor(private config: Config, private cli: CLI) {} connect(): Promise { - this.client = new Client({ port: this.config.port, host: this.config.host, username: this.config.username, password: this.config.password, - privateKey: readFileSync(this.config.privateKey).toString(), - debug: true + privateKey: this.config.privateKey? readFileSync(this.config.privateKey).toString() : undefined, + // debug: true }); + // Triggers the initial connection this.client.sftp((err, sftp) => { if (err) { console.log("There was a problem with connection"); @@ -42,20 +43,35 @@ export default class Uploader { unlinkFile(fileName: string): Promise { return new Promise((resolve, reject) => { let remote = this.getRemotePath(fileName); + this.client.sftp((err, sftp) => { + if (err) { + reject('SFTP cannot be created'); + } else { + sftp.unlink(remote, (err) => { + if (err) { + reject('File could not be deleted'); + } else { + resolve(remote); + } + }); + } + }); + }); + } + unlinkFolder(folderPath: string): Promise { + return new Promise((resolve, reject) => { + let remote = this.getRemotePath(folderPath); this.client.sftp((err, sftp) => { if (err) { reject('SFTP cannot be created'); } else { - sftp.ready(()=> { - console.log('connection established'); - sftp.unlink(remote, (err) => { - if (err) { - reject('File could not be deleted'); - } else { - resolve(remote); - } - }); + sftp.rmdir(remote, (err) => { + if (err) { + reject('Folder could not be deleted'); + } else { + resolve(remote); + } }); } }); diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index 9eb501d..4496fbb 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -1,7 +1,8 @@ import * as chokidar from "chokidar"; +import { FSWatcher } from "fs"; import Uploader from "./Uploader"; import Config from "./Config"; -import { FSWatcher } from "fs"; +import CLI from "./CLI"; export default class Watcher { files: FSWatcher; @@ -9,6 +10,7 @@ export default class Watcher { constructor( private uploader: Uploader, private config: Config, + private cli: CLI, private base: string = process.cwd() ) { @@ -27,7 +29,7 @@ export default class Watcher { ready(): Promise { return new Promise((resolve) => { - this.files.on("ready", ()=>{}); + this.files.on("ready", resolve); }); } @@ -60,6 +62,10 @@ export default class Watcher { }; unlinkDir = (path: string) => { - //console.log("unlinkDir", path); + this.uploader.unlinkFolder(path).then(remote => { + console.log(`Folder deleted ${remote}`); + }).catch((err) => { + console.log(`Error deleting folder ${err}`); + }); }; } From 226dc71d59949bb5db6822c3f9bffc79ee566c5c Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 13 Dec 2015 23:40:54 -0800 Subject: [PATCH 22/49] Fix debugger, clean up some code --- .vscode/launch.json | 8 +-- .vscode/tasks.json | 171 -------------------------------------------- package.json | 31 +++++++- 3 files changed, 32 insertions(+), 178 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index b6a8b53..bdcc350 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,11 +8,11 @@ // Type of configuration. "type": "node", // Workspace relative or absolute path to the program. - "program": "bin/syncjs", + "program": "./bin/syncjs", // Automatically stop program after launch. "stopOnEntry": false, // Command line arguments passed to the program. - "args": [], + "args": ["-c", "config_example.json", "--no-color"], // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. "cwd": ".", // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. @@ -32,10 +32,10 @@ "name": "Attach", "type": "node", // TCP/IP address. Default is "localhost". - "address": "localhost", + // "address": "localhost", // Port to attach to. "port": 5858, - "sourceMaps": false + "sourceMaps": true } ] } diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1058306..b4437d0 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,13 +1,3 @@ -// Available variables which can be used inside of strings. -// ${workspaceRoot}: the root folder of the team -// ${file}: the current opened file -// ${fileBasename}: the current opened file's basename -// ${fileDirname}: the current opened file's dirname -// ${fileExtname}: the current opened file's extension -// ${cwd}: the current working directory of the spawned process - -// A task runner that calls the Typescript compiler (tsc) and -// Compiles a HelloWorld.ts program { "version": "0.1.0", @@ -27,164 +17,3 @@ // in the output. "problemMatcher": "$tsc" } - -// A task runner that calls the Typescript compiler (tsc) and -// compiles based on a tsconfig.json file that is present in -// the root of the folder open in VSCode -/* -{ - "version": "0.1.0", - - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript - "command": "tsc", - - // The command is a shell script - "isShellCommand": true, - - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - - // Tell the tsc compiler to use the tsconfig.json from the open folder. - "args": ["-p", "."], - - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc" -} -*/ - -// A task runner configuration for gulp. Gulp provides a less task -// which compiles less to css. -/* -{ - "version": "0.1.0", - "command": "gulp", - "isShellCommand": true, - "tasks": [ - { - "taskName": "less", - // Make this the default build command. - "isBuildCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the standard less compilation problem matcher. - "problemMatcher": "$lessCompile" - } - ] -} -*/ - -// Uncomment the following section to use jake to build a workspace -// cloned from https://github.com/Microsoft/TypeScript.git -/* -{ - "version": "0.1.0", - // Task runner is jake - "command": "jake", - // Need to be executed in shell / cmd - "isShellCommand": true, - "showOutput": "silent", - "tasks": [ - { - // TS build command is local. - "taskName": "local", - // Make this the default build command. - "isBuildCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the redefined Typescript output problem matcher. - "problemMatcher": [ - "$tsc" - ] - } - ] -} -*/ - -// Uncomment the section below to use msbuild and generate problems -// for csc, cpp, tsc and vb. The configuration assumes that msbuild -// is available on the path and a solution file exists in the -// workspace folder root. -/* -{ - "version": "0.1.0", - "command": "msbuild", - "args": [ - // Ask msbuild to generate full paths for file names. - "/property:GenerateFullPaths=true" - ], - "taskSelector": "/t:", - "showOutput": "silent", - "tasks": [ - { - "taskName": "build", - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the standard MS compiler pattern to detect errors, warnings - // and infos in the output. - "problemMatcher": "$msCompile" - } - ] -} -*/ - -// Uncomment the following section to use msbuild which compiles Typescript -// and less files. -/* -{ - "version": "0.1.0", - "command": "msbuild", - "args": [ - // Ask msbuild to generate full paths for file names. - "/property:GenerateFullPaths=true" - ], - "taskSelector": "/t:", - "showOutput": "silent", - "tasks": [ - { - "taskName": "build", - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the standard MS compiler pattern to detect errors, warnings - // and infos in the output. - "problemMatcher": [ - "$msCompile", - "$lessCompile" - ] - } - ] -} -*/ -// A task runner example that defines a problemMatcher inline instead of using -// a predfined one. -/* -{ - "version": "0.1.0", - "command": "tsc", - "isShellCommand": true, - "args": ["HelloWorld.ts"], - "showOutput": "silent", - "problemMatcher": { - // The problem is owned by the typescript language service. Ensure that the problems - // are merged with problems produced by Visual Studio's language service. - "owner": "typescript", - // The file name for reported problems is relative to the current working directory. - "fileLocation": ["relative", "${cwd}"], - // The actual pattern to match problems in the output. - "pattern": { - // The regular expression. Matches HelloWorld.ts(2,10): error TS2339: Property 'logg' does not exist on type 'Console'. - "regexp": "^([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\):\\s+(error|warning|info)\\s+(TS\\d+)\\s*:\\s*(.*)$", - // The match group that denotes the file containing the problem. - "file": 1, - // The match group that denotes the problem location. - "location": 2, - // The match group that denotes the problem's severity. Can be omitted. - "severity": 3, - // The match group that denotes the problem code. Can be omitted. - "code": 4, - // The match group that denotes the problem's message. - "message": 5 - } - } -} -*/ \ No newline at end of file diff --git a/package.json b/package.json index f3f1a25..2f035b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sync.js", - "version": "0.0.1", + "version": "2.0.0", "main": "dist/main.js", "preferGlobal": true, "scripts": { @@ -17,7 +17,32 @@ "minimist": "^1.2.0", "moment": "latest", "scp2": "^0.2.2", - "typescript": "^1.7.3", + "typescript": "1.6.2", "upath": "^0.1.6" - } + }, + "description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.", + "devDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/serkanyersen/sync.git" + }, + "keywords": [ + "SFTP", + "sync", + "rsync", + "scp", + "ftp", + "upload", + "project", + "typescript", + "developer", + "tools", + "tooling" + ], + "author": "Serkan Yersen", + "license": "MIT", + "bugs": { + "url": "https://github.com/serkanyersen/sync/issues" + }, + "homepage": "https://github.com/serkanyersen/sync#readme" } From 1ae3d8d5a661e696714c155ba33401b107237ff9 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 13 Dec 2015 23:43:30 -0800 Subject: [PATCH 23/49] fix missing keys --- .vscode/launch.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index bdcc350..02da322 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -3,6 +3,7 @@ // List of configurations. Add new configurations or edit existing ones. "configurations": [ { + "request": "launch", // Name of configuration; appears in the launch configuration drop down menu. "name": "Launch sync.js", // Type of configuration. @@ -29,6 +30,7 @@ "outDir": "dist/" }, { + "request": "attach", "name": "Attach", "type": "node", // TCP/IP address. Default is "localhost". From 11c81fb8ef2cd63dfd10b22706905e01b54ce667 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 14 Dec 2015 00:06:24 -0800 Subject: [PATCH 24/49] Fixes a bug with progress and displays better output --- src/classes/CLI.ts | 8 ++++---- src/classes/Watcher.ts | 33 +++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index ec78ad9..b12daea 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -27,7 +27,7 @@ export enum EXIT_CODE { export default class CLI { private rline: readline.ReadLine; - private pdTime: NodeJS.Timer; + private pdTime: Array = []; private lastRun: number; private timeDiff: number; private args: minimist.ParsedArgs; @@ -99,16 +99,16 @@ export default class CLI { * Start printing dots to screen, show script is working */ startProgress() { - this.pdTime = setInterval(() => { + this.pdTime.push(setInterval(() => { this.write(chalk.green(".")); - }, 200); + }, 200)); } /** * Stop printing dots when process ends */ stopProgress() { - clearInterval(this.pdTime); + clearInterval(this.pdTime.pop()); } /** diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index 4496fbb..a3bb9c5 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -1,4 +1,5 @@ -import * as chokidar from "chokidar"; +import * as chokidar from "chokidar" +import * as chalk from "chalk"; import { FSWatcher } from "fs"; import Uploader from "./Uploader"; import Config from "./Config"; @@ -34,37 +35,57 @@ export default class Watcher { } all = (event:string, path:string) => { - // console.log(event,": ", path); + + let eventToWord = { + add: chalk.green("ADDED"), + change: chalk.green("CHANGED"), + unlink: chalk.red("DELETED"), + unlinkDir: chalk.red("DELETED") + } + + if (event in eventToWord) { + this.cli.workspace(); + this.cli.write(`\n${eventToWord[event]} ${path}`); + this.cli.startProgress(); + } }; add = (path: string) => { this.uploader.uploadFile(path).then(remote => { - console.log(`File uploaded ${remote}`); + this.cli.stopProgress(); + this.cli.write(`\nSAVED ${remote}`); }).catch((err) => { + this.cli.stopProgress(); console.error(err.message, err.error); }); }; change = (path: string) => { this.uploader.uploadFile(path).then(remote => { - console.log(`File uploaded ${remote}`); + this.cli.stopProgress(); + this.cli.write(`\nSAVED ${remote}`); }).catch((err) => { + this.cli.stopProgress(); console.error(err.message, err.error); }); }; unlink = (path: string) => { this.uploader.unlinkFile(path).then(remote => { - console.log(`File deleted ${remote}`); + this.cli.stopProgress(); + this.cli.write(`\nSAVED ${remote}`); }).catch((err) => { + this.cli.stopProgress(); console.log(`Error deleting file ${err}`); }); }; unlinkDir = (path: string) => { this.uploader.unlinkFolder(path).then(remote => { - console.log(`Folder deleted ${remote}`); + this.cli.stopProgress(); + this.cli.write(`\nSAVED ${remote}`); }).catch((err) => { + this.cli.stopProgress(); console.log(`Error deleting folder ${err}`); }); }; From d54b395ad2949c2d653b8942d4dbb5f7ecd80082 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 14 Dec 2015 11:56:52 -0800 Subject: [PATCH 25/49] Resolve password issue --- package.json | 1 + src/classes/CLI.ts | 33 ++++++++++++++++----------- src/classes/Config.ts | 19 ++++++++++++++-- src/classes/InitConfig.ts | 48 +++++++++++++++++++++++++++++---------- src/classes/Sync.ts | 20 ++++++++-------- 5 files changed, 85 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 2f035b6..82cd4ae 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "latest", + "readline-sync": "^1.2.21", "scp2": "^0.2.2", "typescript": "1.6.2", "upath": "^0.1.6" diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index b12daea..6f77893 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,6 +1,7 @@ import * as chalk from "chalk"; import * as readline from "readline"; import * as minimist from "minimist"; +var readlineSync = require("readline-sync"); export enum EXIT_CODE { /** @@ -24,6 +25,11 @@ export enum EXIT_CODE { INVALID_ARGUMENT = 128 } +interface ReadLineOptions{ + follow?: string; + hideEchoBack?: boolean +} + export default class CLI { private rline: readline.ReadLine; @@ -39,16 +45,16 @@ export default class CLI { // Parse arguments this.args = minimist(process.argv.slice(2)); - try { - this.rline = readline.createInterface({ - input: process.stdin, - output: process.stdout - }); - } catch (e) { - this.write("You need to upgrade your nodejs\n"); - this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); - process.exit(EXIT_CODE.RUNTIME_FAILURE); - } + // try { + // this.rline = readline.createInterface({ + // input: process.stdin, + // output: process.stdout + // }); + // } catch (e) { + // this.write("You need to upgrade your nodejs\n"); + // this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); + // process.exit(EXIT_CODE.RUNTIME_FAILURE); + // } } /** @@ -89,9 +95,10 @@ export default class CLI { return process.stdout.write.bind(process.stdout)(msg); } - read(question: string): Promise { + read(question: string, password=false): Promise { return new Promise((resolve) => { - this.rline.question(`${question}:\n>>> `, resolve); + let answer = readlineSync.question(question, {hideEchoBack: password}); + resolve(answer); }); } @@ -148,7 +155,7 @@ export default class CLI { * Display the prompt that asks for input */ private showPrompt() { - this.rline.question(">>> ", answer => { + this.read(">>> ").then(answer => { this.handleInput(answer); // as soon as a command is run, show promt again just a like a real shell this.showPrompt(); diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 8e2a553..6c1f78f 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -34,8 +34,23 @@ export default class Config implements SyncConfig{ constructor(private cli: CLI) { this._filename = pathJoin(process.cwd(), this.cli.getArgument("config", CONFIG_FILE_NAME)); - this._fetch(); - this._expand(); + } + + ready(): Promise{ + return new Promise((resolve) => { + this._fetch(); + this._expand(); + + // Temporary + if (!this.password && !this.privateKey) { + this.cli.read('Password: ', true).then(answer => { + this.password = this._config.password = answer; + resolve(); + }); + } else { + resolve(); + } + }); } private _fetch() { diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index ae121ee..8de433f 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -4,57 +4,81 @@ import { writeFileSync } from 'fs'; import CLI, { EXIT_CODE } from "./CLI"; import { SyncConfig, CONFIG_FILE_NAME } from './Config'; +interface PromptOptions { + leaveEmpty?: boolean; + useDefault?: boolean; + required?: boolean; +} + export default class InitConfig { constructor(private cli: CLI) { this.collectInformation(); } + private getPrompt(question:string, options:PromptOptions = {}): string { + let leaveEmpty = chalk.gray(" [hit enter to leave empty]"); + let useDefault = chalk.gray(" [hit enter to use default]"); + let required = chalk.red(" [required]"); + let marker = ""; + + if (options.leaveEmpty) { + marker += leaveEmpty; + } + + if (options.useDefault) { + marker += useDefault; + } + + if (options.required) { + marker += required; + } + + return `${chalk.green("Username to connect")}${marker}:\n>>> `; + } + collectInformation () { let newConfig: SyncConfig = { localPath: null, remotePath: null, host: null }; - let leaveEmpty = chalk.gray("[hit enter to leave empty]"); - let useDefault = chalk.gray("[hit enter to use default]"); - let required = chalk.red("[required]"); - this.cli.read(`${chalk.green("Username to connect")} ${leaveEmpty}`).then(answer => { + this.cli.read(this.getPrompt("Username to connect", {leaveEmpty: true})).then(answer => { if (answer) { newConfig.username = answer; } - return this.cli.read(`${chalk.green("Password to connect")} ${leaveEmpty}`); + return this.cli.read(this.getPrompt("Password to connect", {leaveEmpty: true})); }).then(answer => { if (answer) { newConfig.password = answer; } - return this.cli.read(`${chalk.green("Port number to connect")} ${leaveEmpty}`); + return this.cli.read(this.getPrompt("Port number to connect", {leaveEmpty: true})); }).then(answer => { if (Number(answer)) { newConfig.port = Number(answer); } - return this.cli.read(`${chalk.green("Domain or ip address to connect")} ${required}`); + return this.cli.read(this.getPrompt("Domain or ip address to connect", {required: true})); }).then(answer => { if (answer) { newConfig.host = answer; } - return this.cli.read(`${chalk.green("Local Path:")} [${process.cwd()}] ${useDefault}`); + return this.cli.read(this.getPrompt(`Local Path: [${process.cwd()}]`, {useDefault: true})); }).then(answer => { if (answer) { newConfig.localPath = upath.normalizeSafe(answer); } else { newConfig.localPath = upath.normalizeSafe(process.cwd()); } - return this.cli.read(`${chalk.green("Remote Path")} ${required}`); + return this.cli.read(this.getPrompt("Remote Path", {required: true})); }).then(answer => { if (answer) { newConfig.remotePath = answer; } - return this.cli.read(`${chalk.green("Path to privateKey if any")} ${leaveEmpty}`); + return this.cli.read(this.getPrompt("Path to privateKey if any", {leaveEmpty: true})); }).then(answer => { if (answer) { newConfig.privateKey = upath.normalizeSafe(answer); } - return this.cli.read(`${chalk.green("Does this look good?")} + return this.cli.read(this.getPrompt(`Does this look good?" \n${JSON.stringify(newConfig, null, 4)} - \n${chalk.green("Say [yes] or [no]")}`); + \n${chalk.green("Say [yes] or [no]")}`)); }).then((answer) => { if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') { writeFileSync(CONFIG_FILE_NAME, JSON.stringify(newConfig, null, 4), 'utf8'); diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index f65e1a4..b04a07b 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -19,18 +19,20 @@ export default class Sync { // Get config this.config = new Config(this.cli); - // Get Command line interface - this.cli.write("Connecting"); - this.cli.startProgress(); + this.config.ready().then(() => { + // Get Command line interface + this.cli.write("Connecting"); + this.cli.startProgress(); - // Setup the uploader - this.uploader = new Uploader(this.config, this.cli); + // Setup the uploader + this.uploader = new Uploader(this.config, this.cli); - // Initiate file watch - this.watch = new Watcher(this.uploader, this.config, this.cli); + // Initiate file watch + this.watch = new Watcher(this.uploader, this.config, this.cli); - // When files are found start connection - this.watch.ready().then(() => { + // When files are found start connection + return this.watch.ready(); + }).then(() => { return this.uploader.connect(); }).then(() => { // All done, stop indicator and show workspace From 32c097c2c63bbd6e39ad356d3fd6d51857820a70 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 14 Dec 2015 12:46:41 -0800 Subject: [PATCH 26/49] fix questions --- src/classes/InitConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index 8de433f..0a3d212 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -34,7 +34,7 @@ export default class InitConfig { marker += required; } - return `${chalk.green("Username to connect")}${marker}:\n>>> `; + return `${question}${marker}:\n>>> `; } collectInformation () { From e387e5a649d7191849e5eea2ef71bdd37c23e0c2 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 14 Dec 2015 13:41:45 -0800 Subject: [PATCH 27/49] Whitespace fixes --- src/classes/CLI.ts | 10 +++++----- src/classes/Config.ts | 16 ++++++++-------- src/classes/InitConfig.ts | 22 +++++++++++----------- src/classes/Uploader.ts | 8 ++++---- src/classes/Watcher.ts | 6 +++--- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 6f77893..5c6cc2d 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -25,7 +25,7 @@ export enum EXIT_CODE { INVALID_ARGUMENT = 128 } -interface ReadLineOptions{ +interface ReadLineOptions { follow?: string; hideEchoBack?: boolean } @@ -62,7 +62,7 @@ export default class CLI { * @param command string name of the command */ hasStartupCommand(command: string): boolean { - return this.args._.filter( n => n === command ).length > 0; + return this.args._.filter(n => n === command).length > 0; } /** @@ -78,7 +78,7 @@ export default class CLI { value = this.args[name[0]]; } - return value !== null? value : defaultValue; + return value !== null ? value : defaultValue; } /** @@ -95,9 +95,9 @@ export default class CLI { return process.stdout.write.bind(process.stdout)(msg); } - read(question: string, password=false): Promise { + read(question: string, password = false): Promise { return new Promise((resolve) => { - let answer = readlineSync.question(question, {hideEchoBack: password}); + let answer = readlineSync.question(question, { hideEchoBack: password }); resolve(answer); }); } diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 6c1f78f..36565c1 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -11,13 +11,13 @@ export interface SyncConfig { "localPath": string; "remotePath": string; "privateKey"?: string; - "ignores"?: Array; + "ignores"?: Array; "pathMode"?: string; } export const CONFIG_FILE_NAME = "sync-config.json"; -export default class Config implements SyncConfig{ +export default class Config implements SyncConfig { private _filename: string; private _config: SyncConfig; @@ -29,14 +29,14 @@ export default class Config implements SyncConfig{ localPath: string; remotePath: string; privateKey: string; - ignores: Array; + ignores: Array; pathMode: string = "0755"; constructor(private cli: CLI) { this._filename = pathJoin(process.cwd(), this.cli.getArgument("config", CONFIG_FILE_NAME)); } - ready(): Promise{ + ready(): Promise { return new Promise((resolve) => { this._fetch(); this._expand(); @@ -59,7 +59,7 @@ export default class Config implements SyncConfig{ if (configraw = readFileSync(this._filename)) { try { this._config = parse(configraw.toString()); - } catch(e) { + } catch (e) { this.cli.usage("Could not parse DB file. Make sure JSON is correct", EXIT_CODE.RUNTIME_FAILURE); } } else { @@ -75,8 +75,8 @@ export default class Config implements SyncConfig{ */ private _expand() { ["host", "port", "username", "password", "pathMode", - "localPath", "remotePath", "ignores", "privateKey"].forEach(prop => { - this[prop] = this._config[prop] || this[prop]; - }); + "localPath", "remotePath", "ignores", "privateKey"].forEach(prop => { + this[prop] = this._config[prop] || this[prop]; + }); } } \ No newline at end of file diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index 0a3d212..816b1dd 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -16,7 +16,7 @@ export default class InitConfig { this.collectInformation(); } - private getPrompt(question:string, options:PromptOptions = {}): string { + private getPrompt(question: string, options: PromptOptions = {}): string { let leaveEmpty = chalk.gray(" [hit enter to leave empty]"); let useDefault = chalk.gray(" [hit enter to use default]"); let required = chalk.red(" [required]"); @@ -37,48 +37,48 @@ export default class InitConfig { return `${question}${marker}:\n>>> `; } - collectInformation () { + collectInformation(): void { let newConfig: SyncConfig = { localPath: null, remotePath: null, host: null }; - this.cli.read(this.getPrompt("Username to connect", {leaveEmpty: true})).then(answer => { + this.cli.read(this.getPrompt("Username to connect", { leaveEmpty: true })).then(answer => { if (answer) { newConfig.username = answer; } - return this.cli.read(this.getPrompt("Password to connect", {leaveEmpty: true})); + return this.cli.read(this.getPrompt("Password to connect", { leaveEmpty: true })); }).then(answer => { if (answer) { newConfig.password = answer; } - return this.cli.read(this.getPrompt("Port number to connect", {leaveEmpty: true})); + return this.cli.read(this.getPrompt("Port number to connect", { leaveEmpty: true })); }).then(answer => { if (Number(answer)) { newConfig.port = Number(answer); } - return this.cli.read(this.getPrompt("Domain or ip address to connect", {required: true})); + return this.cli.read(this.getPrompt("Domain or ip address to connect", { required: true })); }).then(answer => { if (answer) { newConfig.host = answer; } - return this.cli.read(this.getPrompt(`Local Path: [${process.cwd()}]`, {useDefault: true})); + return this.cli.read(this.getPrompt(`Local Path: [${process.cwd() }]`, { useDefault: true })); }).then(answer => { if (answer) { newConfig.localPath = upath.normalizeSafe(answer); } else { newConfig.localPath = upath.normalizeSafe(process.cwd()); } - return this.cli.read(this.getPrompt("Remote Path", {required: true})); + return this.cli.read(this.getPrompt("Remote Path", { required: true })); }).then(answer => { if (answer) { newConfig.remotePath = answer; } - return this.cli.read(this.getPrompt("Path to privateKey if any", {leaveEmpty: true})); + return this.cli.read(this.getPrompt("Path to privateKey if any", { leaveEmpty: true })); }).then(answer => { if (answer) { newConfig.privateKey = upath.normalizeSafe(answer); } return this.cli.read(this.getPrompt(`Does this look good?" - \n${JSON.stringify(newConfig, null, 4)} - \n${chalk.green("Say [yes] or [no]")}`)); + \n${JSON.stringify(newConfig, null, 4) } + \n${chalk.green("Say [yes] or [no]") }`)); }).then((answer) => { if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') { writeFileSync(CONFIG_FILE_NAME, JSON.stringify(newConfig, null, 4), 'utf8'); diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 81a02c1..539ee8a 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -7,7 +7,7 @@ import CLI from "./CLI"; export default class Uploader { client: Client; - constructor(private config: Config, private cli: CLI) {} + constructor(private config: Config, private cli: CLI) { } connect(): Promise { this.client = new Client({ @@ -15,7 +15,7 @@ export default class Uploader { host: this.config.host, username: this.config.username, password: this.config.password, - privateKey: this.config.privateKey? readFileSync(this.config.privateKey).toString() : undefined, + privateKey: this.config.privateKey ? readFileSync(this.config.privateKey).toString() : undefined, // debug: true }); @@ -86,8 +86,8 @@ export default class Uploader { // in windows it might mean we won't have permissons to save the fileName // So I create the folder manually here to solve that issue. // Mode we set can be configured from the config file - this.client.mkdir(upath.dirname(remote), {mode: this.config.pathMode}, err => { - if(err) { + this.client.mkdir(upath.dirname(remote), { mode: this.config.pathMode }, err => { + if (err) { reject({ message: `Could not create ${ upath.dirname(remote) }`, error: err diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index a3bb9c5..c4e0789 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -13,9 +13,9 @@ export default class Watcher { private config: Config, private cli: CLI, private base: string = process.cwd() - ) { + ) { - let defaultIgnores:Array = [/node_modules/, /.git/, /.svn/, /bower_components/]; + let defaultIgnores: Array = [/node_modules/, /.git/, /.svn/, /bower_components/]; this.files = chokidar.watch(base, { ignored: defaultIgnores.concat(this.config.ignores), @@ -34,7 +34,7 @@ export default class Watcher { }); } - all = (event:string, path:string) => { + all = (event: string, path: string) => { let eventToWord = { add: chalk.green("ADDED"), From fab24767369767b2b5c3edcc8ab93fef875aee6f Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 14 Dec 2015 13:42:37 -0800 Subject: [PATCH 28/49] green questions --- src/classes/InitConfig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index 816b1dd..31c5adb 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -34,7 +34,7 @@ export default class InitConfig { marker += required; } - return `${question}${marker}:\n>>> `; + return `${chalk.green(question)}${marker}:\n>>> `; } collectInformation(): void { From 1ee12d082b1721ba4df97af66f3344fcf719abe6 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 14 Dec 2015 13:43:39 -0800 Subject: [PATCH 29/49] fix file watcher --- src/classes/Watcher.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index c4e0789..b5913be 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -12,7 +12,7 @@ export default class Watcher { private uploader: Uploader, private config: Config, private cli: CLI, - private base: string = process.cwd() + private base: string = config.localPath ) { let defaultIgnores: Array = [/node_modules/, /.git/, /.svn/, /bower_components/]; From 90c3981af292b455815f53f4bb1c414dd7dd1544 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 14 Dec 2015 13:44:35 -0800 Subject: [PATCH 30/49] remove commented code --- src/classes/CLI.ts | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 5c6cc2d..579bd65 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -41,20 +41,8 @@ export default class CLI { public paused: boolean; constructor() { - // Parse arguments this.args = minimist(process.argv.slice(2)); - - // try { - // this.rline = readline.createInterface({ - // input: process.stdin, - // output: process.stdout - // }); - // } catch (e) { - // this.write("You need to upgrade your nodejs\n"); - // this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); - // process.exit(EXIT_CODE.RUNTIME_FAILURE); - // } } /** From 64ca4c962e850cbd67d1ac0d8136785dcc8ea369 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 20 Dec 2015 12:18:28 -0800 Subject: [PATCH 31/49] TypeScript 1.7 upgrade --- .gitignore | 2 ++ bin/syncjs | 2 +- package.json | 4 +-- src/classes/Watcher.ts | 82 +++++++++++++++++++++++++++++++++++------- 4 files changed, 74 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 0beea89..5ce6d57 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ lib-cov *.pid *.gz +.idea + pids logs results diff --git a/bin/syncjs b/bin/syncjs index 74e6c50..ef06531 100755 --- a/bin/syncjs +++ b/bin/syncjs @@ -1,5 +1,5 @@ #!/usr/bin/env node var path = require('path'); -var Sync = require(path.resolve(__dirname, '../dist/index.js')).default; +var Sync = require(path.resolve(__dirname, '../dist/src/index.js')).default; new Sync(); \ No newline at end of file diff --git a/package.json b/package.json index 82cd4ae..3b75ccf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sync.js", "version": "2.0.0", - "main": "dist/main.js", + "main": "dist/src/index.js", "preferGlobal": true, "scripts": { "postinstall": "./node_modules/.bin/tsc" @@ -18,7 +18,7 @@ "moment": "latest", "readline-sync": "^1.2.21", "scp2": "^0.2.2", - "typescript": "1.6.2", + "typescript": "^1.7.*", "upath": "^0.1.6" }, "description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.", diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index b5913be..c8b5211 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -5,8 +5,15 @@ import Uploader from "./Uploader"; import Config from "./Config"; import CLI from "./CLI"; +interface PausedChanges { + event: string; + path: string; +} + export default class Watcher { files: FSWatcher; + private paused = false; + private changes: PausedChanges[] = []; constructor( private uploader: Uploader, @@ -24,7 +31,7 @@ export default class Watcher { // Attach events ["all", "add", "change", "unlink", "unlinkDir"].forEach(method => { - this.files.on(method, this[method]); + this.files.on(method, this.pauseHandler(method)); }); } @@ -34,23 +41,72 @@ export default class Watcher { }); } - all = (event: string, path: string) => { + pause() { + this.paused = true; + } - let eventToWord = { - add: chalk.green("ADDED"), - change: chalk.green("CHANGED"), - unlink: chalk.red("DELETED"), - unlinkDir: chalk.red("DELETED") + resume(): Promise { + return new Promise((resolve, reject) => { + this.cli.write(`${ this.changes.length } files had changed while paused.`); + this.changes.forEach((change) => { + this.cli.write(`${ this.eventToWord[change.event] }: ${ change.path } `); + this.cli.read('Do you want to make these uploads? [Y/N] ').then((answer) => { + if (answer[0].toUpperCase() === 'Y') { + this.cli.write('Uploading.'); + resolve(); + } else { + reject(); + this.cli.write('Resuming.'); + } + // Set pause false the last thing. Even if changes happen + // during this prompt is on screen. They are still caught + this.paused = false; + }); + }); + }); + } + + eventToWord = { + add: chalk.green("ADDED"), + change: chalk.green("CHANGED"), + unlink: chalk.red("DELETED"), + unlinkDir: chalk.red("DELETED") + }; + + + private pauseHandler(method: string): Function { + return (...args: string[]) => { + let path: string, + event = method; + + // Handle argument difference + if (method === 'all') { + path = args[1]; + event = args[0] + } else { + path = args[0]; + } + + // If paused store the values + if (this.paused ) { + this.changes.push({ event, path }); + } else { + // If not, continue as ususal + this[method](...args); + } } + } + - if (event in eventToWord) { + private all = (event:string, path:string) => { + if (event in this.eventToWord) { this.cli.workspace(); - this.cli.write(`\n${eventToWord[event]} ${path}`); + this.cli.write(`\n${ this.eventToWord[event]} ${path}`); this.cli.startProgress(); } }; - add = (path: string) => { + private add = (path: string) => { this.uploader.uploadFile(path).then(remote => { this.cli.stopProgress(); this.cli.write(`\nSAVED ${remote}`); @@ -60,7 +116,7 @@ export default class Watcher { }); }; - change = (path: string) => { + private change = (path: string) => { this.uploader.uploadFile(path).then(remote => { this.cli.stopProgress(); this.cli.write(`\nSAVED ${remote}`); @@ -70,7 +126,7 @@ export default class Watcher { }); }; - unlink = (path: string) => { + private unlink = (path: string) => { this.uploader.unlinkFile(path).then(remote => { this.cli.stopProgress(); this.cli.write(`\nSAVED ${remote}`); @@ -80,7 +136,7 @@ export default class Watcher { }); }; - unlinkDir = (path: string) => { + private unlinkDir = (path: string) => { this.uploader.unlinkFolder(path).then(remote => { this.cli.stopProgress(); this.cli.write(`\nSAVED ${remote}`); From 83b7b52e3003d2a2f8515423c4caeabcc1baa142 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Sun, 20 Dec 2015 21:38:51 -0800 Subject: [PATCH 32/49] editor settings --- .vscode/settings.json | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4038d3c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +// Place your settings in this file to overwrite default and user settings. +{ + "javascript.validate.lint.newOnLowercaseFunctions": "ignore" +} \ No newline at end of file From 46c0ee10ec5862aa0dd901c09db280b92ce8e344 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Tue, 22 Dec 2015 23:58:00 -0800 Subject: [PATCH 33/49] switch to gulp and babel for better es6 support. fix readline problem --- .vscode/tasks.json | 53 ++++++++++++++------ bin/syncjs | 2 +- gulpfile.js | 16 ++++++ package.json | 11 +++-- src/classes/CLI.ts | 20 +++++--- src/index.ts | 1 - tsconfig.json | 2 +- tsd.json | 3 -- typings/es6-promise/es6-promise.d.ts | 73 ---------------------------- typings/tsd.d.ts | 1 - 10 files changed, 76 insertions(+), 106 deletions(-) create mode 100644 gulpfile.js delete mode 100644 typings/es6-promise/es6-promise.d.ts diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b4437d0..a637823 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,19 +1,44 @@ -{ - "version": "0.1.0", +// Available variables which can be used inside of strings. +// ${workspaceRoot}: the root folder of the team +// ${file}: the current opened file +// ${fileBasename}: the current opened file's basename +// ${fileDirname}: the current opened file's dirname +// ${fileExtname}: the current opened file's extension +// ${cwd}: the current working directory of the spawned process - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript - "command": "tsc", +// { +// "version": "0.1.0", - // The command is a shell script - "isShellCommand": true, +// // The command is tsc. Assumes that tsc has been installed using npm install -g typescript +// "command": "tsc", + +// // The command is a shell script +// "isShellCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", +// // Show the output window only if unrecognized errors occur. +// "showOutput": "silent", - // Tell the tsc compiler to use the tsconfig.json from the open folder. - "args": ["-p", "."], +// // Tell the tsc compiler to use the tsconfig.json from the open folder. +// "args": ["-p", "."], - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc" -} +// // use the standard tsc problem matcher to find compile problems +// // in the output. +// "problemMatcher": "$tsc" +// } + +{ + "version": "0.1.0", + "command": "gulp", + "isShellCommand": true, + "tasks": [ + { + "taskName": "default", + // Make this the default build command. + "isBuildCommand": true, + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", + // Use the standard less compilation problem matcher. + "problemMatcher": "$tsc" + } + ] +} \ No newline at end of file diff --git a/bin/syncjs b/bin/syncjs index ef06531..74e6c50 100755 --- a/bin/syncjs +++ b/bin/syncjs @@ -1,5 +1,5 @@ #!/usr/bin/env node var path = require('path'); -var Sync = require(path.resolve(__dirname, '../dist/src/index.js')).default; +var Sync = require(path.resolve(__dirname, '../dist/index.js')).default; new Sync(); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..71a00d1 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,16 @@ +var gulp = require('gulp'); +var ts = require('gulp-typescript'); +var babel = require('gulp-babel'); + +var tsProject = ts.createProject('./tsconfig.json', { + typescript: require('typescript') +}); + +gulp.task('default', function() { + return gulp.src(['src/**/*.ts', 'typings/**/*.ts']) + .pipe(ts(tsProject)) + .pipe(babel({ + presets: ['es2015'] + })) + .pipe(gulp.dest('dist')); +}); \ No newline at end of file diff --git a/package.json b/package.json index 3b75ccf..8c4d562 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,27 @@ { "name": "sync.js", "version": "2.0.0", - "main": "dist/src/index.js", + "main": "dist/index.js", "preferGlobal": true, "scripts": { - "postinstall": "./node_modules/.bin/tsc" + "postinstall": "./node_modules/.bin/gulp" }, "bin": { "syncjs": "bin/syncjs" }, "dependencies": { + "babel-preset-es2015": "^6.3.13", "chalk": "^1.1.1", "chokidar": "^1.2.0", - "es6-promise": "^3.0.2", + "gulp": "^3.9.0", + "gulp-babel": "^6.1.1", + "gulp-typescript": "^2.10.0", "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "latest", "readline-sync": "^1.2.21", "scp2": "^0.2.2", - "typescript": "^1.7.*", + "typescript": "^1.8.0-dev.20151222", "upath": "^0.1.6" }, "description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.", diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 579bd65..b9ce368 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,7 +1,6 @@ import * as chalk from "chalk"; import * as readline from "readline"; import * as minimist from "minimist"; -var readlineSync = require("readline-sync"); export enum EXIT_CODE { /** @@ -25,11 +24,6 @@ export enum EXIT_CODE { INVALID_ARGUMENT = 128 } -interface ReadLineOptions { - follow?: string; - hideEchoBack?: boolean -} - export default class CLI { private rline: readline.ReadLine; @@ -43,6 +37,17 @@ export default class CLI { constructor() { // Parse arguments this.args = minimist(process.argv.slice(2)); + + try { + this.rline = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + } catch (e) { + this.write("You need to upgrade your nodejs\n"); + this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); + process.exit(EXIT_CODE.RUNTIME_FAILURE); + } } /** @@ -85,8 +90,7 @@ export default class CLI { read(question: string, password = false): Promise { return new Promise((resolve) => { - let answer = readlineSync.question(question, { hideEchoBack: password }); - resolve(answer); + this.rline.question(question, resolve); }); } diff --git a/src/index.ts b/src/index.ts index a130015..db8febd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ import Sync from "./classes/Sync"; -import "es6-promise"; // Main Export export default Sync; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index bbc4a66..8cf6204 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "module": "commonjs", - "target": "es5", + "target": "es6", "experimentalDecorators": true, "emitDecoratorMetadata": true, "inlineSourceMap": true, diff --git a/tsd.json b/tsd.json index 0ddf0d8..6a68bd8 100644 --- a/tsd.json +++ b/tsd.json @@ -17,9 +17,6 @@ "node/node.d.ts": { "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" }, - "es6-promise/es6-promise.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - }, "moment/moment.d.ts": { "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" }, diff --git a/typings/es6-promise/es6-promise.d.ts b/typings/es6-promise/es6-promise.d.ts deleted file mode 100644 index daf7134..0000000 --- a/typings/es6-promise/es6-promise.d.ts +++ /dev/null @@ -1,73 +0,0 @@ -// Type definitions for es6-promise -// Project: https://github.com/jakearchibald/ES6-Promise -// Definitions by: François de Campredon , vvakame -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -interface Thenable { - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Thenable; -} - -declare class Promise implements Thenable { - /** - * If you call resolve in the body of the callback passed to the constructor, - * your promise is fulfilled with result object passed to resolve. - * If you call reject your promise is rejected with the object passed to reject. - * For consistency and debugging (eg stack traces), obj should be an instanceof Error. - * Any errors thrown in the constructor callback will be implicitly passed to reject(). - */ - constructor(callback: (resolve : (value?: R | Thenable) => void, reject: (error?: any) => void) => void); - - /** - * onFulfilled is called when/if "promise" resolves. onRejected is called when/if "promise" rejects. - * Both are optional, if either/both are omitted the next onFulfilled/onRejected in the chain is called. - * Both callbacks have a single parameter , the fulfillment value or rejection reason. - * "then" returns a new promise equivalent to the value you return from onFulfilled/onRejected after being passed through Promise.resolve. - * If an error is thrown in the callback, the returned promise rejects with that error. - * - * @param onFulfilled called when/if "promise" resolves - * @param onRejected called when/if "promise" rejects - */ - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Promise; - then(onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => void): Promise; - - /** - * Sugar for promise.then(undefined, onRejected) - * - * @param onRejected called when/if "promise" rejects - */ - catch(onRejected?: (error: any) => U | Thenable): Promise; -} - -declare module Promise { - /** - * Make a new promise from the thenable. - * A thenable is promise-like in as far as it has a "then" method. - */ - function resolve(value?: R | Thenable): Promise; - - /** - * Make a promise that rejects to obj. For consistency and debugging (eg stack traces), obj should be an instanceof Error - */ - function reject(error: any): Promise; - - /** - * Make a promise that fulfills when every item in the array fulfills, and rejects if (and when) any item rejects. - * the array passed to all can be a mixture of promise-like objects and other objects. - * The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value. - */ - function all(promises: (R | Thenable)[]): Promise; - - /** - * Make a Promise that fulfills when any item fulfills, and rejects if any item rejects. - */ - function race(promises: (R | Thenable)[]): Promise; -} - -declare module 'es6-promise' { - var foo: typeof Promise; // Temp variable to reference Promise in local context - module rsvp { - export var Promise: typeof foo; - } - export = rsvp; -} diff --git a/typings/tsd.d.ts b/typings/tsd.d.ts index 5c85b09..d24a0b6 100644 --- a/typings/tsd.d.ts +++ b/typings/tsd.d.ts @@ -2,7 +2,6 @@ /// /// /// -/// /// /// /// From 51bec09c6360cc54ad24badac88ed293c1ba8de4 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Tue, 22 Dec 2015 23:59:02 -0800 Subject: [PATCH 34/49] no more readline sync --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index 8c4d562..6d2ec4b 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "latest", - "readline-sync": "^1.2.21", "scp2": "^0.2.2", "typescript": "^1.8.0-dev.20151222", "upath": "^0.1.6" From 871a8ba0303c5f8fd90a4504688cb45784972436 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 23 Dec 2015 02:07:05 -0800 Subject: [PATCH 35/49] don't use gulp, instead use npm to build. it's faster --- .babelrc | 5 ++++ .vscode/tasks.json | 60 +++++++++++++++++++++++----------------------- gulpfile.js | 16 ------------- package.json | 6 ++--- tsconfig.json | 2 +- 5 files changed, 38 insertions(+), 51 deletions(-) create mode 100644 .babelrc delete mode 100644 gulpfile.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..bc5b4b4 --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": ["es2015"], + "compact": true, + "comments": false +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a637823..aaece6e 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,39 +6,39 @@ // ${fileExtname}: the current opened file's extension // ${cwd}: the current working directory of the spawned process -// { -// "version": "0.1.0", +{ + "version": "0.1.0", -// // The command is tsc. Assumes that tsc has been installed using npm install -g typescript -// "command": "tsc", + // The command is tsc. Assumes that tsc has been installed using npm install -g typescript + "command": "npm", -// // The command is a shell script -// "isShellCommand": true, + // The command is a shell script + "isShellCommand": true, -// // Show the output window only if unrecognized errors occur. -// "showOutput": "silent", + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", -// // Tell the tsc compiler to use the tsconfig.json from the open folder. -// "args": ["-p", "."], + // Tell the tsc compiler to use the tsconfig.json from the open folder. + "args": ["run", "postinstall"], -// // use the standard tsc problem matcher to find compile problems -// // in the output. -// "problemMatcher": "$tsc" -// } + // use the standard tsc problem matcher to find compile problems + // in the output. + "problemMatcher": "$tsc" +} -{ - "version": "0.1.0", - "command": "gulp", - "isShellCommand": true, - "tasks": [ - { - "taskName": "default", - // Make this the default build command. - "isBuildCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - // Use the standard less compilation problem matcher. - "problemMatcher": "$tsc" - } - ] -} \ No newline at end of file +// { +// "version": "0.1.0", +// "command": "gulp", +// "isShellCommand": true, +// "tasks": [ +// { +// "taskName": "default", +// // Make this the default build command. +// "isBuildCommand": true, +// // Show the output window only if unrecognized errors occur. +// "showOutput": "silent", +// // Use the standard less compilation problem matcher. +// "problemMatcher": "$tsc" +// } +// ] +// } \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 71a00d1..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,16 +0,0 @@ -var gulp = require('gulp'); -var ts = require('gulp-typescript'); -var babel = require('gulp-babel'); - -var tsProject = ts.createProject('./tsconfig.json', { - typescript: require('typescript') -}); - -gulp.task('default', function() { - return gulp.src(['src/**/*.ts', 'typings/**/*.ts']) - .pipe(ts(tsProject)) - .pipe(babel({ - presets: ['es2015'] - })) - .pipe(gulp.dest('dist')); -}); \ No newline at end of file diff --git a/package.json b/package.json index 6d2ec4b..1cce6f4 100644 --- a/package.json +++ b/package.json @@ -4,18 +4,16 @@ "main": "dist/index.js", "preferGlobal": true, "scripts": { - "postinstall": "./node_modules/.bin/gulp" + "postinstall": "tsc && babel dist -d dist" }, "bin": { "syncjs": "bin/syncjs" }, "dependencies": { + "babel-cli": "^6.3.17", "babel-preset-es2015": "^6.3.13", "chalk": "^1.1.1", "chokidar": "^1.2.0", - "gulp": "^3.9.0", - "gulp-babel": "^6.1.1", - "gulp-typescript": "^2.10.0", "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "latest", diff --git a/tsconfig.json b/tsconfig.json index 8cf6204..95f86d6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "emitDecoratorMetadata": true, "inlineSourceMap": true, "noImplicitAny": false, - "rootDir": ".", + "rootDir": "./src", "outDir": "./dist" }, "buildOnSave": true, From 092d964f103003b55355bd1bea14e599d5307106 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 27 Jul 2016 15:59:29 -0700 Subject: [PATCH 36/49] Little update on packages --- .vscode/launch.json | 6 +++--- .vscode/settings.json | 2 +- .vscode/tasks.json | 22 +++++++++++----------- package.json | 16 ++++++++-------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 02da322..c390531 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,13 +9,13 @@ // Type of configuration. "type": "node", // Workspace relative or absolute path to the program. - "program": "./bin/syncjs", + "program": "${workspaceRoot}/bin/syncjs", // Automatically stop program after launch. "stopOnEntry": false, // Command line arguments passed to the program. "args": ["-c", "config_example.json", "--no-color"], // Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace. - "cwd": ".", + "cwd": "${workspaceRoot}", // Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH. "runtimeExecutable": null, // Optional arguments passed to the runtime executable. @@ -27,7 +27,7 @@ // Use JavaScript source maps (if they exist). "sourceMaps": true, // If JavaScript source maps are enabled, the generated code is expected in this directory. - "outDir": "dist/" + "outDir": "${workspaceRoot}/dist/" }, { "request": "attach", diff --git a/.vscode/settings.json b/.vscode/settings.json index 4038d3c..01b59ef 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ // Place your settings in this file to overwrite default and user settings. { - "javascript.validate.lint.newOnLowercaseFunctions": "ignore" + "javascript.validate.lint.newOnLowercaseFunctions": "ignore" } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index aaece6e..ce501cb 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -7,23 +7,23 @@ // ${cwd}: the current working directory of the spawned process { - "version": "0.1.0", + "version": "0.1.0", - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript - "command": "npm", + // The command is tsc. Assumes that tsc has been installed using npm install -g typescript + "command": "npm", - // The command is a shell script - "isShellCommand": true, + // The command is a shell script + "isShellCommand": true, - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", + // Show the output window only if unrecognized errors occur. + "showOutput": "silent", // Tell the tsc compiler to use the tsconfig.json from the open folder. - "args": ["run", "postinstall"], + "args": ["run", "postinstall"], - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc" + // use the standard tsc problem matcher to find compile problems + // in the output. + "problemMatcher": "$tsc" } // { diff --git a/package.json b/package.json index 1cce6f4..e5385d6 100644 --- a/package.json +++ b/package.json @@ -10,16 +10,16 @@ "syncjs": "bin/syncjs" }, "dependencies": { - "babel-cli": "^6.3.17", - "babel-preset-es2015": "^6.3.13", - "chalk": "^1.1.1", - "chokidar": "^1.2.0", + "babel-cli": "^6.11.4", + "babel-preset-es2015": "^6.9.0", + "chalk": "^1.1.3", + "chokidar": "^1.6.0", "jsonplus": "^1.2.1", "minimist": "^1.2.0", - "moment": "latest", - "scp2": "^0.2.2", - "typescript": "^1.8.0-dev.20151222", - "upath": "^0.1.6" + "moment": "2.14.1", + "scp2": "^0.5.0", + "typescript": "^1.8.10", + "upath": "^0.2.0" }, "description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.", "devDependencies": {}, From 50bbdafc87dc630c6672f236fa7d38bda17b368e Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 3 Aug 2016 17:14:46 -0700 Subject: [PATCH 37/49] add gulp build --- .babelrc | 2 +- .vscode/settings.json | 14 +++++++++- .vscode/tasks.json | 61 +++++++++++++++--------------------------- gulpfile.js | 21 +++++++++++++++ package.json | 19 +++++++++---- typings/scp2/scp2.d.ts | 2 ++ typings/tsd.d.ts | 2 ++ 7 files changed, 74 insertions(+), 47 deletions(-) create mode 100644 gulpfile.js diff --git a/.babelrc b/.babelrc index bc5b4b4..426d1b3 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,5 @@ { "presets": ["es2015"], - "compact": true, + "compact": false, "comments": false } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 01b59ef..9f81489 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,16 @@ // Place your settings in this file to overwrite default and user settings. { - "javascript.validate.lint.newOnLowercaseFunctions": "ignore" + "files.trimTrailingWhitespace": true, + "search.exclude": { + "**/node_modules": true, + "**/bower_components": true, + "**/dist": true, + "**/typings": true + }, + "files.exclude": { + "**/.git": true, + "**/.svn": true, + "**/.DS_Store": true, + "**/dist/*": true + } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ce501cb..53eaaba 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,44 +1,25 @@ -// Available variables which can be used inside of strings. -// ${workspaceRoot}: the root folder of the team -// ${file}: the current opened file -// ${fileBasename}: the current opened file's basename -// ${fileDirname}: the current opened file's dirname -// ${fileExtname}: the current opened file's extension -// ${cwd}: the current working directory of the spawned process - { + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format "version": "0.1.0", - - // The command is tsc. Assumes that tsc has been installed using npm install -g typescript "command": "npm", - - // The command is a shell script "isShellCommand": true, - - // Show the output window only if unrecognized errors occur. - "showOutput": "silent", - - // Tell the tsc compiler to use the tsconfig.json from the open folder. - "args": ["run", "postinstall"], - - // use the standard tsc problem matcher to find compile problems - // in the output. - "problemMatcher": "$tsc" -} - -// { -// "version": "0.1.0", -// "command": "gulp", -// "isShellCommand": true, -// "tasks": [ -// { -// "taskName": "default", -// // Make this the default build command. -// "isBuildCommand": true, -// // Show the output window only if unrecognized errors occur. -// "showOutput": "silent", -// // Use the standard less compilation problem matcher. -// "problemMatcher": "$tsc" -// } -// ] -// } \ No newline at end of file + "showOutput": "always", + "suppressTaskName": true, + "tasks": [ + { + "taskName": "install", + "args": ["install"] + }, + { + "taskName": "build", + "args": ["run", "build"], + "isWatching": true, + "isBuildCommand": true + }, + { + "taskName": "test", + "args": ["run", "test"] + } + ] +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..e875026 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,21 @@ +var gulp = require("gulp"); +var ts = require("gulp-typescript"); +var babel = require("gulp-babel"); +var rename = require("gulp-rename"); + +gulp.task("build", function () { + var tsProject = ts.createProject(__dirname + "/tsconfig.json"); + return tsProject.src() + .pipe(ts(tsProject)) + .pipe(babel()) + .pipe(rename(function (path) { + path.extname = ".js"; + })) + .pipe(gulp.dest("./dist")); +}); + +gulp.task("watch", function() { + gulp.watch("./src/**/*.ts", ["build"]); +}); + +gulp.task("default", ["build", "watch"]) \ No newline at end of file diff --git a/package.json b/package.json index e5385d6..d77118d 100644 --- a/package.json +++ b/package.json @@ -4,25 +4,34 @@ "main": "dist/index.js", "preferGlobal": true, "scripts": { - "postinstall": "tsc && babel dist -d dist" + "start": "gulp", + "build": "gulp build", + "postinstall": "gulp build" }, "bin": { "syncjs": "bin/syncjs" }, "dependencies": { - "babel-cli": "^6.11.4", - "babel-preset-es2015": "^6.9.0", + "chalk": "^1.1.3", "chokidar": "^1.6.0", "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "2.14.1", "scp2": "^0.5.0", - "typescript": "^1.8.10", "upath": "^0.2.0" }, "description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.", - "devDependencies": {}, + "devDependencies": { + "typescript": "^1.8.10", + "babel-cli": "^6.11.4", + "babel-preset-es2015": "^6.9.0", + "babel-runtime": "^6.11.6", + "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", + "gulp-rename": "^1.2.2", + "gulp-typescript": "^2.13.6" + }, "repository": { "type": "git", "url": "git+https://github.com/serkanyersen/sync.git" diff --git a/typings/scp2/scp2.d.ts b/typings/scp2/scp2.d.ts index 247b966..31ecb0d 100644 --- a/typings/scp2/scp2.d.ts +++ b/typings/scp2/scp2.d.ts @@ -8,6 +8,8 @@ declare module "scp2" { password?: string; paths?: string; privateKey?: string; + agentForward?: boolean; + agent?: string; debug?: boolean; } diff --git a/typings/tsd.d.ts b/typings/tsd.d.ts index d24a0b6..e211e5b 100644 --- a/typings/tsd.d.ts +++ b/typings/tsd.d.ts @@ -5,3 +5,5 @@ /// /// /// +/// +/// From 1b65dec50f1ae6f21591353e5884932dffc115db Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Thu, 11 Aug 2016 16:34:44 -0700 Subject: [PATCH 38/49] make input better --- .gitignore | 4 +- package.json | 3 +- src/classes/CLI.ts | 28 +- src/classes/Config.ts | 2 +- src/classes/InitConfig.ts | 189 ++++++---- src/classes/Sync.ts | 2 +- src/classes/Uploader.ts | 1 + typings/inquirer/inquirer.d.ts | 300 ++++++++++++++++ typings/rx/rx-lite.d.ts | 635 +++++++++++++++++++++++++++++++++ typings/through/through.d.ts | 24 ++ 10 files changed, 1092 insertions(+), 96 deletions(-) create mode 100644 typings/inquirer/inquirer.d.ts create mode 100644 typings/rx/rx-lite.d.ts create mode 100644 typings/through/through.d.ts diff --git a/.gitignore b/.gitignore index 5ce6d57..e43ab00 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,6 @@ node_modules npm-debug.log config.json -dist \ No newline at end of file +dist + +sync-config.json \ No newline at end of file diff --git a/package.json b/package.json index d77118d..2feb2f5 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,13 @@ "syncjs": "bin/syncjs" }, "dependencies": { - "chalk": "^1.1.3", "chokidar": "^1.6.0", + "inquirer": "^1.1.2", "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "2.14.1", + "prompt": "^1.0.0", "scp2": "^0.5.0", "upath": "^0.2.0" }, diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index b9ce368..37cb5c8 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -1,6 +1,6 @@ import * as chalk from "chalk"; -import * as readline from "readline"; import * as minimist from "minimist"; +import inquirer = require("inquirer"); export enum EXIT_CODE { /** @@ -26,7 +26,6 @@ export enum EXIT_CODE { export default class CLI { - private rline: readline.ReadLine; private pdTime: Array = []; private lastRun: number; private timeDiff: number; @@ -37,17 +36,6 @@ export default class CLI { constructor() { // Parse arguments this.args = minimist(process.argv.slice(2)); - - try { - this.rline = readline.createInterface({ - input: process.stdin, - output: process.stdout - }); - } catch (e) { - this.write("You need to upgrade your nodejs\n"); - this.write("http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/\n"); - process.exit(EXIT_CODE.RUNTIME_FAILURE); - } } /** @@ -88,9 +76,17 @@ export default class CLI { return process.stdout.write.bind(process.stdout)(msg); } - read(question: string, password = false): Promise { - return new Promise((resolve) => { - this.rline.question(question, resolve); + read(question: any, hidden = false): Promise { + return new Promise((resolve, reject) => { + let scheme = { + type: hidden? "password" : "input", + message: question, + name: "response" + }; + + inquirer.prompt(scheme).then((answer) => { + resolve(answer.response); + }); }); } diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 36565c1..5f525ed 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -43,7 +43,7 @@ export default class Config implements SyncConfig { // Temporary if (!this.password && !this.privateKey) { - this.cli.read('Password: ', true).then(answer => { + this.cli.read("Enter password to connect", true).then(answer => { this.password = this._config.password = answer; resolve(); }); diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index 31c5adb..3ae3465 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -3,91 +3,128 @@ import * as upath from "upath"; import { writeFileSync } from 'fs'; import CLI, { EXIT_CODE } from "./CLI"; import { SyncConfig, CONFIG_FILE_NAME } from './Config'; +import inquirer = require("inquirer"); -interface PromptOptions { - leaveEmpty?: boolean; - useDefault?: boolean; - required?: boolean; -} - -export default class InitConfig { - - constructor(private cli: CLI) { - this.collectInformation(); - } +export default class InitConfig2 { - private getPrompt(question: string, options: PromptOptions = {}): string { - let leaveEmpty = chalk.gray(" [hit enter to leave empty]"); - let useDefault = chalk.gray(" [hit enter to use default]"); - let required = chalk.red(" [required]"); - let marker = ""; + constructor() { - if (options.leaveEmpty) { - marker += leaveEmpty; - } + let currentConf = {}; - if (options.useDefault) { - marker += useDefault; - } + try { + currentConf = require(upath.resolve(process.cwd(), CONFIG_FILE_NAME)); + console.log("Existing config found."); + } catch(e) {} - if (options.required) { - marker += required; - } + let questions: inquirer.Questions = [ + { + type: "input", + name: "username", + message: "Username to connect:", + validate: (answer) => { + if (!answer) { + return "Username is required"; + } + return true; + }, + default: currentConf.username + }, + { + type: "list", + name: "authType", + message: "How do you want to authenticate:", + choices: [ + "Password in config", + "Ask password during connection", + "Private key" + ] + }, + { + type: "password", + name: "password", + message: "Enter your password:", + when: (answers: any) => answers.authType === "Password in config" + }, + { + type: "input", + name: "privateKey", + message: "Path to private key:", + default: currentConf.privateKey, + when: (answers: any) => answers.authType === "Private key", + filter: (answer) => { + return upath.normalizeSafe(answer); + } + }, + { + type: "input", + name: "host", + default: currentConf.host, + message: "Hostname or IP to connect", + validate: (answer) => { + if (!answer) { + return "Hostname is required"; + } + return true; + } + }, + { + type: "input", + name: "port", + message: "Port to conenct:", + default: currentConf.port || "use default" + }, + { + type: "input", + name: "localPath", + message: "Local Path", + filter: (answer) => { + return upath.normalizeSafe(answer); + }, + default: currentConf.localPath || process.cwd() + }, + { + type: "input", + name: "remotePath", + message: "Remote Path", + default: currentConf.remotePath, + validate: (answer) => { + if (!answer) { + return "Remote Path is required"; + } + return true; + } + } + ]; - return `${chalk.green(question)}${marker}:\n>>> `; - } + inquirer.prompt(questions).then((answers) => { + let pass; + // if default, don't put it in config + if (answers.port == "use default") { + delete answers.port; + } - collectInformation(): void { - let newConfig: SyncConfig = { localPath: null, remotePath: null, host: null }; + // no need this in the config + delete answers.authType; - this.cli.read(this.getPrompt("Username to connect", { leaveEmpty: true })).then(answer => { - if (answer) { - newConfig.username = answer; - } - return this.cli.read(this.getPrompt("Password to connect", { leaveEmpty: true })); - }).then(answer => { - if (answer) { - newConfig.password = answer; - } - return this.cli.read(this.getPrompt("Port number to connect", { leaveEmpty: true })); - }).then(answer => { - if (Number(answer)) { - newConfig.port = Number(answer); - } - return this.cli.read(this.getPrompt("Domain or ip address to connect", { required: true })); - }).then(answer => { - if (answer) { - newConfig.host = answer; - } - return this.cli.read(this.getPrompt(`Local Path: [${process.cwd() }]`, { useDefault: true })); - }).then(answer => { - if (answer) { - newConfig.localPath = upath.normalizeSafe(answer); - } else { - newConfig.localPath = upath.normalizeSafe(process.cwd()); - } - return this.cli.read(this.getPrompt("Remote Path", { required: true })); - }).then(answer => { - if (answer) { - newConfig.remotePath = answer; - } - return this.cli.read(this.getPrompt("Path to privateKey if any", { leaveEmpty: true })); - }).then(answer => { - if (answer) { - newConfig.privateKey = upath.normalizeSafe(answer); - } - return this.cli.read(this.getPrompt(`Does this look good?" - \n${JSON.stringify(newConfig, null, 4) } - \n${chalk.green("Say [yes] or [no]") }`)); - }).then((answer) => { - if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') { - writeFileSync(CONFIG_FILE_NAME, JSON.stringify(newConfig, null, 4), 'utf8'); - this.cli.write(`${CONFIG_FILE_NAME} is saved.\n`); - } else { - this.cli.write("Operation cancelled. Exiting..."); + if (answers.password) { + pass = answers.password; + answers.password = "****"; } - process.exit(EXIT_CODE.NORMAL); + inquirer.prompt({ + type: "confirm", + name: "yes", + message: `${JSON.stringify(answers, null, 4)}\nDoes this look good?` + }).then((answer) => { + if (answer.yes) { + if (pass) { + answers.password = pass; + } + writeFileSync(CONFIG_FILE_NAME, JSON.stringify(answers, null, 4), 'utf8'); + } else { + console.log("No config was saved."); + } + }) }); } -} \ No newline at end of file +} diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index b04a07b..b25def1 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -14,7 +14,7 @@ export default class Sync { this.cli = new CLI(); if (this.cli.hasStartupCommand("init")) { - new InitConfig(this.cli); + new InitConfig(); } else { // Get config this.config = new Config(this.cli); diff --git a/src/classes/Uploader.ts b/src/classes/Uploader.ts index 539ee8a..41b32a2 100644 --- a/src/classes/Uploader.ts +++ b/src/classes/Uploader.ts @@ -15,6 +15,7 @@ export default class Uploader { host: this.config.host, username: this.config.username, password: this.config.password, + // agentForward: true, privateKey: this.config.privateKey ? readFileSync(this.config.privateKey).toString() : undefined, // debug: true }); diff --git a/typings/inquirer/inquirer.d.ts b/typings/inquirer/inquirer.d.ts new file mode 100644 index 0000000..caba259 --- /dev/null +++ b/typings/inquirer/inquirer.d.ts @@ -0,0 +1,300 @@ +// Type definitions for Inquirer.js +// Project: https://github.com/SBoudrias/Inquirer.js +// Definitions by: Qubo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "inquirer" { + import through = require('through'); + + namespace inquirer { + type Prompts = { [name: string]: PromptModule }; + type ChoiceType = string|objects.ChoiceOption|objects.Separator; + type Questions = Question|Question[]|Rx.Observable; + + interface Inquirer { + restoreDefaultPrompts(): void; + /** + * Expose helper functions on the top level for easiest usage by common users + * @param name + * @param prompt + */ + registerPrompt(name: string, prompt: PromptModule): void; + /** + * Create a new self-contained prompt module. + */ + createPromptModule(): PromptModule; + /** + * Public CLI helper interface + * @param questions Questions settings array + * @param cb Callback being passed the user answers + * @return + */ + prompt(questions: Questions, cb?: (answers: Answers) => any): ui.Prompt; + prompts: Prompts; + Separator: objects.SeparatorStatic; + ui: { + BottomBar: ui.BottomBar; + Prompt: ui.Prompt; + } + } + + interface PromptModule { + (questions: Questions, cb: (answers: Answers) => any): ui.Prompt; + /** + * Register a prompt type + * @param name Prompt type name + * @param prompt Prompt constructor + */ + registerPrompt(name: string, prompt: PromptModule): ui.Prompt; + /** + * Register the defaults provider prompts + */ + restoreDefaultPrompts(): void; + } + + interface Question { + /** + * Type of the prompt. + * Possible values: + *
    + *
  • input
  • + *
  • confirm
  • + *
  • list
  • + *
  • rawlist
  • + *
  • password
  • + *
+ * @defaults: 'input' + */ + type?: string; + /** + * The name to use when storing the answer in the anwers hash. + */ + name?: string; + /** + * The question to print. If defined as a function, + * the first parameter will be the current inquirer session answers. + */ + message?: string|((answers: Answers) => string); + /** + * Default value(s) to use if nothing is entered, or a function that returns the default value(s). + * If defined as a function, the first parameter will be the current inquirer session answers. + */ + default?: any|((answers: Answers) => any); + /** + * Choices array or a function returning a choices array. If defined as a function, + * the first parameter will be the current inquirer session answers. + * Array values can be simple strings, or objects containing a name (to display) and a value properties + * (to save in the answers hash). Values can also be a Separator. + */ + choices?: ChoiceType[]|((answers: Answers) => ChoiceType[]); + /** + * Receive the user input and should return true if the value is valid, and an error message (String) + * otherwise. If false is returned, a default error message is provided. + */ + validate?(input: string): boolean|string; + /** + * Receive the user input and return the filtered value to be used inside the program. + * The value returned will be added to the Answers hash. + */ + filter?(input: string): string; + /** + * Receive the current user answers hash and should return true or false depending on whether or + * not this question should be asked. The value can also be a simple boolean. + */ + when?: boolean|((answers: Answers) => boolean); + paginated?: boolean; + } + + /** + * A key/value hash containing the client answers in each prompt. + */ + interface Answers { + [key: string]: string|boolean; + } + + namespace ui { + /** + * Base interface class other can inherits from + */ + interface Prompt extends BaseUI { + new(promptModule: Prompts): Prompt; + /** + * Once all prompt are over + */ + onCompletion(): void; + processQuestion(question: Question): any; + fetchAnswer(question: Question): any; + setDefaultType(question: Question): any; + filterIfRunnable(question: Question): any; + then(cb:any): any + } + + /** + * Sticky bottom bar user interface + */ + interface BottomBar extends BaseUI { + new(opt?: BottomBarOption): BottomBar; + /** + * Render the prompt to screen + * @return self + */ + render(): BottomBar; + /** + * Update the bottom bar content and rerender + * @param bottomBar Bottom bar content + * @return self + */ + updateBottomBar(bottomBar: string): BottomBar; + /** + * Rerender the prompt + * @return self + */ + writeLog(data: any): BottomBar; + /** + * Make sure line end on a line feed + * @param str Input string + * @return The input string with a final line feed + */ + enforceLF(str: string): string; + /** + * Helper for writing message in Prompt + * @param message The message to be output + */ + write(message: string): void; + log: through.ThroughStream; + } + + interface BottomBarOption { + bottomBar?: string; + } + /** + * Base interface class other can inherits from + */ + interface BaseUI { + new(opt: TOpt): void; + /** + * Handle the ^C exit + * @return {null} + */ + onForceClose(): void; + /** + * Close the interface and cleanup listeners + */ + close(): void; + /** + * Handle and propagate keypress events + */ + onKeypress(s: string, key: Key): void; + } + + interface Key { + sequence: string; + name: string; + meta: boolean; + shift: boolean; + ctrl: boolean; + } + } + + namespace objects { + /** + * Choice object + * Normalize input as choice object + * @constructor + * @param {String|Object} val Choice value. If an object is passed, it should contains + * at least one of `value` or `name` property + */ + interface Choice { + new(str: string): Choice; + new(separator: Separator): Choice; + new(option: ChoiceOption): Choice; + } + + interface ChoiceOption { + name?: string; + value?: string; + type?: string; + extra?: any; + key?: string; + checked?: boolean; + disabled?: string|((answers: Answers) => any); + } + + /** + * Choices collection + * Collection of multiple `choice` object + * @constructor + * @param choices All `choice` to keep in the collection + */ + interface Choices { + new(choices: (string|Separator|ChoiceOption)[], answers?: Answers): Choices; + choices: Choice[]; + realChoices: Choice[]; + length: number; + realLength: number; + /** + * Get a valid choice from the collection + * @param selector The selected choice index + * @return Return the matched choice or undefined + */ + getChoice(selector: number): Choice; + /** + * Get a raw element from the collection + * @param selector The selected index value + * @return Return the matched choice or undefined + */ + get(selector: number): Choice; + /** + * Match the valid choices against a where clause + * @param whereClause Lodash `where` clause + * @return Matching choices or empty array + */ + where(whereClause: U): Choice[]; + /** + * Pluck a particular key from the choices + * @param propertyName Property name to select + * @return Selected properties + */ + pluck(propertyName: string): any[]; + forEach(application: (choice: Choice) => T): T[]; + } + + interface SeparatorStatic { + /** + * @param line Separation line content (facultative) + */ + new(line?: string): Separator; + /** + * Helper function returning false if object is a separator + * @param obj object to test against + * @return `false` if object is a separator + */ + exclude(obj: any): boolean; + } + + /** + * Separator object + * Used to space/separate choices group + * @constructor + * @param {String} line Separation line content (facultative) + */ + interface Separator { + type: string; + line: string; + /** + * Stringify separator + * @return {String} the separator display string + */ + toString(): string; + } + } + } + + var inquirer: inquirer.Inquirer; + + export = inquirer; +} + diff --git a/typings/rx/rx-lite.d.ts b/typings/rx/rx-lite.d.ts new file mode 100644 index 0000000..f159979 --- /dev/null +++ b/typings/rx/rx-lite.d.ts @@ -0,0 +1,635 @@ +// DefinitelyTyped: partial + +// This file contains common part of defintions for rx.d.ts and rx.lite.d.ts +// Do not include the file separately. + +declare namespace Rx { + export module internals { + function isEqual(left: any, right: any): boolean; + function addRef(xs: Observable, r: { getDisposable(): IDisposable; }): Observable; + + // Priority Queue for Scheduling + export class PriorityQueue { + constructor(capacity: number); + + length: number; + + isHigherPriority(left: number, right: number): boolean; + percolate(index: number): void; + heapify(index: number): void; + peek(): ScheduledItem; + removeAt(index: number): void; + dequeue(): ScheduledItem; + enqueue(item: ScheduledItem): void; + remove(item: ScheduledItem): boolean; + + static count: number; + } + + export class ScheduledItem { + constructor(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: (x: TTime, y: TTime) => number); + + scheduler: IScheduler; + state: TTime; + action: (scheduler: IScheduler, state: any) => IDisposable; + dueTime: TTime; + comparer: (x: TTime, y: TTime) => number; + disposable: SingleAssignmentDisposable; + + invoke(): void; + compareTo(other: ScheduledItem): number; + isCancelled(): boolean; + invokeCore(): IDisposable; + } + } + + export module config { + export var Promise: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }; + } + + export module helpers { + function noop(): void; + function notDefined(value: any): boolean; + function identity(value: T): T; + function defaultNow(): number; + function defaultComparer(left: any, right: any): boolean; + function defaultSubComparer(left: any, right: any): number; + function defaultKeySerializer(key: any): string; + function defaultError(err: any): void; + function isPromise(p: any): boolean; + function asArray(...args: T[]): T[]; + function not(value: any): boolean; + function isFunction(value: any): boolean; + } + + export interface IDisposable { + dispose(): void; + } + + export class CompositeDisposable implements IDisposable { + constructor (...disposables: IDisposable[]); + constructor (disposables: IDisposable[]); + + isDisposed: boolean; + length: number; + + dispose(): void; + add(item: IDisposable): void; + remove(item: IDisposable): boolean; + toArray(): IDisposable[]; + } + + export class Disposable implements IDisposable { + constructor(action: () => void); + + static create(action: () => void): IDisposable; + static empty: IDisposable; + + dispose(): void; + } + + // Single assignment + export class SingleAssignmentDisposable implements IDisposable { + constructor(); + + isDisposed: boolean; + current: IDisposable; + + dispose(): void ; + getDisposable(): IDisposable; + setDisposable(value: IDisposable): void ; + } + + // SerialDisposable it's an alias of SingleAssignmentDisposable + export class SerialDisposable extends SingleAssignmentDisposable { + constructor(); + } + + export class RefCountDisposable implements IDisposable { + constructor(disposable: IDisposable); + + dispose(): void; + + isDisposed: boolean; + getDisposable(): IDisposable; + } + + export interface IScheduler { + now(): number; + isScheduler(value: any): boolean; + + schedule(action: () => void): IDisposable; + scheduleWithState(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; + scheduleWithAbsolute(dueTime: number, action: () => void): IDisposable; + scheduleWithAbsoluteAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable; + scheduleWithRelative(dueTime: number, action: () => void): IDisposable; + scheduleWithRelativeAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable; + + scheduleRecursive(action: (action: () =>void ) =>void ): IDisposable; + scheduleRecursiveWithState(state: TState, action: (state: TState, action: (state: TState) =>void ) =>void ): IDisposable; + scheduleRecursiveWithAbsolute(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable; + scheduleRecursiveWithAbsoluteAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable; + scheduleRecursiveWithRelative(dueTime: number, action: (action: (dueTime: number) =>void ) =>void ): IDisposable; + scheduleRecursiveWithRelativeAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) =>void ) =>void ): IDisposable; + + schedulePeriodic(period: number, action: () => void): IDisposable; + schedulePeriodicWithState(state: TState, period: number, action: (state: TState) => TState): IDisposable; + } + + export interface Scheduler extends IScheduler { + } + + export interface SchedulerStatic { + new ( + now: () => number, + schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, + scheduleRelative: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, + scheduleAbsolute: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable): Scheduler; + + normalize(timeSpan: number): number; + + immediate: IScheduler; + currentThread: ICurrentThreadScheduler; + default: IScheduler; // alias for Scheduler.timeout + timeout: IScheduler; + } + + export var Scheduler: SchedulerStatic; + + // Current Thread IScheduler + interface ICurrentThreadScheduler extends IScheduler { + scheduleRequired(): boolean; + } + + // Notifications + export class Notification { + accept(observer: IObserver): void; + accept(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult; + toObservable(scheduler?: IScheduler): Observable; + hasValue: boolean; + equals(other: Notification): boolean; + kind: string; + value: T; + exception: any; + + static createOnNext(value: T): Notification; + static createOnError(exception: any): Notification; + static createOnCompleted(): Notification; + } + + /** + * Promise A+ + */ + export interface IPromise { + then(onFulfilled: (value: T) => IPromise, onRejected: (reason: any) => IPromise): IPromise; + then(onFulfilled: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise; + then(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise): IPromise; + then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise; + } + + // Observer + export interface IObserver { + onNext(value: T): void; + onError(exception: any): void; + onCompleted(): void; + } + + export interface Observer extends IObserver { + toNotifier(): (notification: Notification) => void; + asObserver(): Observer; + } + + interface ObserverStatic { + create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer; + fromNotifier(handler: (notification: Notification, thisArg?: any) => void): Observer; + } + + export var Observer: ObserverStatic; + + export interface IObservable { + subscribe(observer: Observer): IDisposable; + subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; + + subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable; + subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable; + subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable; + } + + export interface Observable extends IObservable { + forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe + toArray(): Observable; + + catch(handler: (exception: any) => Observable): Observable; + catchException(handler: (exception: any) => Observable): Observable; // alias for catch + catch(handler: (exception: any) => IPromise): Observable; + catchException(handler: (exception: any) => IPromise): Observable; // alias for catch + catch(second: Observable): Observable; + catchException(second: Observable): Observable; // alias for catch + combineLatest(second: Observable|IPromise): Observable<[T, T2]>; + combineLatest(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; + combineLatest(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; + combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; + combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + combineLatest(souces: (Observable|IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; + withLatestFrom(second: Observable|IPromise): Observable<[T, T2]>; + withLatestFrom(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; + withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; + withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; + withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + withLatestFrom(souces: (Observable|IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; + concat(...sources: (Observable|IPromise)[]): Observable; + concat(sources: (Observable|IPromise)[]): Observable; + concatAll(): Observable; + concatObservable(): Observable; // alias for concatAll + concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat + concatMap(selector: (value: T, index: number) => R[]): Observable; // alias for selectConcat + concatMap(sequence: Observable): Observable; // alias for selectConcat + concatMap(sequence: R[]): Observable; // alias for selectConcat + merge(maxConcurrent: number): T; + merge(other: Observable): Observable; + merge(other: IPromise): Observable; + mergeAll(): Observable; + mergeObservable(): Observable; // alias for mergeAll + skipUntil(other: Observable): Observable; + skipUntil(other: IPromise): Observable; + switch(): Observable; + switchLatest(): Observable; // alias for switch + takeUntil(other: Observable): Observable; + takeUntil(other: IPromise): Observable; + zip(second: Observable|IPromise): Observable<[T, T2]>; + zip(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + zip(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; + zip(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; + zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; + zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + zip(second: (Observable|IPromise)[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; + + asObservable(): Observable; + dematerialize(): Observable; + distinctUntilChanged(skipParameter: boolean, comparer: (x: T, y: T) => boolean): Observable; + distinctUntilChanged(keySelector?: (value: T) => TValue, comparer?: (x: TValue, y: TValue) => boolean): Observable; + do(observer: Observer): Observable; + doAction(observer: Observer): Observable; // alias for do + tap(observer: Observer): Observable; // alias for do + do(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; + doAction(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do + tap(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do + + doOnNext(onNext: (value: T) => void, thisArg?: any): Observable; + doOnError(onError: (exception: any) => void, thisArg?: any): Observable; + doOnCompleted(onCompleted: () => void, thisArg?: any): Observable; + tapOnNext(onNext: (value: T) => void, thisArg?: any): Observable; + tapOnError(onError: (exception: any) => void, thisArg?: any): Observable; + tapOnCompleted(onCompleted: () => void, thisArg?: any): Observable; + + finally(action: () => void): Observable; + finallyAction(action: () => void): Observable; // alias for finally + ignoreElements(): Observable; + materialize(): Observable>; + repeat(repeatCount?: number): Observable; + retry(retryCount?: number): Observable; + retryWhen(notifier: (errors: Observable) => Observable): Observable; + + /** + * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. + * For aggregation behavior with no intermediate results, see Observable.aggregate. + * @example + * var res = source.scan(function (acc, x) { return acc + x; }); + * var res = source.scan(function (acc, x) { return acc + x; }, 0); + * @param accumulator An accumulator function to be invoked on each element. + * @param seed The initial accumulator value. + * @returns An observable sequence containing the accumulated values. + */ + scan(accumulator: (acc: TAcc, value: T, index?: number, source?: Observable) => TAcc, seed: TAcc): Observable; + scan(accumulator: (acc: T, value: T, index?: number, source?: Observable) => T): Observable; + + skipLast(count: number): Observable; + startWith(...values: T[]): Observable; + startWith(scheduler: IScheduler, ...values: T[]): Observable; + takeLast(count: number): Observable; + takeLastBuffer(count: number): Observable; + + select(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; + map(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for select + pluck(prop: string): Observable; + selectMany(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; + selectMany(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; + selectMany(selector: (value: T) => Observable): Observable; + selectMany(selector: (value: T) => IPromise): Observable; + selectMany(other: Observable): Observable; + selectMany(other: IPromise): Observable; + selectMany(selector: (value: T) => TResult[]): Observable; // alias for selectMany + flatMap(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany + flatMap(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany + flatMap(selector: (value: T) => Observable): Observable; // alias for selectMany + flatMap(selector: (value: T) => IPromise): Observable; // alias for selectMany + flatMap(other: Observable): Observable; // alias for selectMany + flatMap(other: IPromise): Observable; // alias for selectMany + flatMap(selector: (value: T) => TResult[]): Observable; // alias for selectMany + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + selectManyObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; + + /** + * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. + * @param {Function} onError A transform function to apply when an error occurs in the source sequence. + * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. + * @param {Any} [thisArg] An optional "this" to use to invoke each transform. + * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. + */ + flatMapObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; + + selectConcat(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; + selectConcat(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; + selectConcat(selector: (value: T, index: number) => Observable): Observable; + selectConcat(selector: (value: T, index: number) => IPromise): Observable; + selectConcat(sequence: Observable): Observable; + + /** + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param [thisArg] Object to use as this when executing callback. + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + selectSwitch(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; + /** + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param [thisArg] Object to use as this when executing callback. + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + flatMapLatest(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; // alias for selectSwitch + /** + * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then + * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + * @param [thisArg] Object to use as this when executing callback. + * @since 2.2.28 + * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences + * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + switchMap(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for selectSwitch + + skip(count: number): Observable; + skipWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + take(count: number, scheduler?: IScheduler): Observable; + takeWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + where(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; + filter(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; // alias for where + + /** + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * @param promiseCtor The constructor of the promise. + * @returns An ES6 compatible promise with the last value from the observable sequence. + */ + toPromise>(promiseCtor: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): TPromise; }): TPromise; + /** + * Converts an existing observable sequence to an ES6 Compatible Promise + * @example + * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); + * + * // With config + * Rx.config.Promise = RSVP.Promise; + * var promise = Rx.Observable.return(42).toPromise(); + * @param [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. + * @returns An ES6 compatible promise with the last value from the observable sequence. + */ + toPromise(promiseCtor?: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }): IPromise; + + // Experimental Flattening + + /** + * Performs a exclusive waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * Can be applied on `Observable>` or `Observable>`. + * @since 2.2.28 + * @returns A exclusive observable with only the results that happen when subscribed. + */ + exclusive(): Observable; + + /** + * Performs a exclusive map waiting for the first to finish before subscribing to another observable. + * Observables that come in between subscriptions will be dropped on the floor. + * Can be applied on `Observable>` or `Observable>`. + * @since 2.2.28 + * @param selector Selector to invoke for every item in the current subscription. + * @param [thisArg] An optional context to invoke with the selector parameter. + * @returns {An exclusive observable with only the results that happen when subscribed. + */ + exclusiveMap(selector: (value: I, index: number, source: Observable) => R, thisArg?: any): Observable; + } + + interface ObservableStatic { + create(subscribe: (observer: Observer) => IDisposable): Observable; + create(subscribe: (observer: Observer) => () => void): Observable; + create(subscribe: (observer: Observer) => void): Observable; + createWithDisposable(subscribe: (observer: Observer) => IDisposable): Observable; + defer(observableFactory: () => Observable): Observable; + defer(observableFactory: () => IPromise): Observable; + empty(scheduler?: IScheduler): Observable; + + /** + * This method creates a new Observable sequence from an array object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param mapFn Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: T[], mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; + /** + * This method creates a new Observable sequence from an array object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param [mapFn] Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: T[], mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; + + /** + * This method creates a new Observable sequence from an array-like object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param mapFn Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: { length: number;[index: number]: T; }, mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; + /** + * This method creates a new Observable sequence from an array-like object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param [mapFn] Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(array: { length: number;[index: number]: T; }, mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; + + /** + * This method creates a new Observable sequence from an array-like or iterable object. + * @param array An array-like or iterable object to convert to an Observable sequence. + * @param [mapFn] Map function to call on every element of the array. + * @param [thisArg] The context to use calling the mapFn if provided. + * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. + */ + from(iterable: any, mapFn?: (value: any, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; + + fromArray(array: T[], scheduler?: IScheduler): Observable; + fromArray(array: { length: number;[index: number]: T; }, scheduler?: IScheduler): Observable; + + generate(initialState: TState, condition: (state: TState) => boolean, iterate: (state: TState) => TState, resultSelector: (state: TState) => TResult, scheduler?: IScheduler): Observable; + never(): Observable; + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * + * @example + * var res = Rx.Observable.of(1, 2, 3); + * @since 2.2.28 + * @returns The observable sequence whose elements are pulled from the given arguments. + */ + of(...values: T[]): Observable; + + /** + * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. + * @example + * var res = Rx.Observable.ofWithScheduler(Rx.Scheduler.timeout, 1, 2, 3); + * @since 2.2.28 + * @param [scheduler] A scheduler to use for scheduling the arguments. + * @returns The observable sequence whose elements are pulled from the given arguments. + */ + ofWithScheduler(scheduler?: IScheduler, ...values: T[]): Observable; + range(start: number, count: number, scheduler?: IScheduler): Observable; + repeat(value: T, repeatCount?: number, scheduler?: IScheduler): Observable; + return(value: T, scheduler?: IScheduler): Observable; + /** + * @since 2.2.28 + */ + just(value: T, scheduler?: IScheduler): Observable; // alias for return + returnValue(value: T, scheduler?: IScheduler): Observable; // alias for return + throw(exception: Error, scheduler?: IScheduler): Observable; + throw(exception: any, scheduler?: IScheduler): Observable; + throwException(exception: Error, scheduler?: IScheduler): Observable; // alias for throw + throwException(exception: any, scheduler?: IScheduler): Observable; // alias for throw + throwError(error: Error, scheduler?: IScheduler): Observable; // alias for throw + throwError(error: any, scheduler?: IScheduler): Observable; // alias for throw + + catch(sources: Observable[]): Observable; + catch(sources: IPromise[]): Observable; + catchException(sources: Observable[]): Observable; // alias for catch + catchException(sources: IPromise[]): Observable; // alias for catch + catchError(sources: Observable[]): Observable; // alias for catch + catchError(sources: IPromise[]): Observable; // alias for catch + catch(...sources: Observable[]): Observable; + catch(...sources: IPromise[]): Observable; + catchException(...sources: Observable[]): Observable; // alias for catch + catchException(...sources: IPromise[]): Observable; // alias for catch + catchError(...sources: Observable[]): Observable; // alias for catch + catchError(...sources: IPromise[]): Observable; // alias for catch + + combineLatest(first: Observable|IPromise, second: Observable|IPromise): Observable<[T, T2]>; + combineLatest(first: Observable|IPromise, second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; + combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; + combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; + combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + combineLatest(sources: (Observable|IPromise)[]): Observable; + combineLatest(sources: (Observable|IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise): Observable<[T, T2]>; + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; + withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + withLatestFrom(souces: (Observable|IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + + concat(...sources: Observable[]): Observable; + concat(...sources: IPromise[]): Observable; + concat(sources: Observable[]): Observable; + concat(sources: IPromise[]): Observable; + merge(...sources: Observable[]): Observable; + merge(...sources: IPromise[]): Observable; + merge(sources: Observable[]): Observable; + merge(sources: IPromise[]): Observable; + merge(scheduler: IScheduler, ...sources: Observable[]): Observable; + merge(scheduler: IScheduler, ...sources: IPromise[]): Observable; + merge(scheduler: IScheduler, sources: Observable[]): Observable; + merge(scheduler: IScheduler, sources: IPromise[]): Observable; + + pairs(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>; + + zip(first: Observable|IPromise, sources: (Observable|IPromise)[]): Observable<[T1, T2]>; + zip(first: Observable|IPromise, sources: (Observable|IPromise)[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; + zip(source1: Observable|IPromise, source2: Observable|IPromise): Observable<[T1, T2]>; + zip(source1: Observable|IPromise, source2: Observable|IPromise, resultSelector: (item1: T1, item2: T2) => TResult): Observable; + zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise): Observable<[T1, T2, T3]>; + zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; + zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise): Observable<[T1, T2, T3, T4]>; + zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, source5: Observable|IPromise): Observable<[T1, T2, T3, T4, T5]>; + zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, source5: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TResult): Observable; + zipArray(...sources: (Observable|IPromise)[]): Observable; + zipArray(sources: (Observable|IPromise)[]): Observable; + + /** + * Converts a Promise to an Observable sequence + * @param promise An ES6 Compliant promise. + * @returns An Observable sequence which wraps the existing promise success and failure. + */ + fromPromise(promise: IPromise): Observable; + + prototype: any; + } + + export var Observable: ObservableStatic; + + interface ISubject extends Observable, Observer, IDisposable { + hasObservers(): boolean; + } + + export interface Subject extends ISubject { + } + + interface SubjectStatic { + new (): Subject; + create(observer?: Observer, observable?: Observable): ISubject; + } + + export var Subject: SubjectStatic; + + export interface AsyncSubject extends Subject { + } + + interface AsyncSubjectStatic { + new (): AsyncSubject; + } + + export var AsyncSubject: AsyncSubjectStatic; +} diff --git a/typings/through/through.d.ts b/typings/through/through.d.ts new file mode 100644 index 0000000..b0d49fc --- /dev/null +++ b/typings/through/through.d.ts @@ -0,0 +1,24 @@ +// Type definitions for through +// Project: https://github.com/dominictarr/through +// Definitions by: Andrew Gaspar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "through" { + import stream = require("stream"); + + function through(write?: (data: any) => void, + end?: () => void, + opts?: { + autoDestroy: boolean; + }): through.ThroughStream; + + namespace through { + export interface ThroughStream extends stream.Transform { + autoDestroy: boolean; + } + } + + export = through; +} From f914eec10fd5953322d8dc1a9c0e375c224d25ba Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Mon, 15 Aug 2016 12:06:19 -0700 Subject: [PATCH 39/49] save point --- src/classes/CLI.ts | 22 ++++++++++++++++++++-- src/classes/Config.ts | 2 +- src/classes/Watcher.ts | 18 ++++++++++++------ 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 37cb5c8..830b9d6 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -30,12 +30,15 @@ export default class CLI { private lastRun: number; private timeDiff: number; private args: minimist.ParsedArgs; + // private ui: inquirer.ui.BottomBar; + private activePrompt; public paused: boolean; constructor() { // Parse arguments this.args = minimist(process.argv.slice(2)); + // this.ui = new inquirer.ui.BottomBar(); } /** @@ -76,6 +79,11 @@ export default class CLI { return process.stdout.write.bind(process.stdout)(msg); } + log(message: string) { + // this.ui.updateBottomBar(message); + console.log(message); + } + read(question: any, hidden = false): Promise { return new Promise((resolve, reject) => { let scheme = { @@ -84,7 +92,7 @@ export default class CLI { name: "response" }; - inquirer.prompt(scheme).then((answer) => { + this.ui.prompt(scheme).then((answer) => { resolve(answer.response); }); }); @@ -143,8 +151,18 @@ export default class CLI { * Display the prompt that asks for input */ private showPrompt() { - this.read(">>> ").then(answer => { + if (this.activePrompt) { + // this.ui.close(); + //console.log(this.activePrompt); + //this.activePrompt.ui.rl.emit("serkan") + return true; + } + + + this.activePrompt = this.read(">>> "); + this.activePrompt.then(answer => { this.handleInput(answer); + this.activePrompt = false; // as soon as a command is run, show promt again just a like a real shell this.showPrompt(); }); diff --git a/src/classes/Config.ts b/src/classes/Config.ts index 5f525ed..c969c34 100644 --- a/src/classes/Config.ts +++ b/src/classes/Config.ts @@ -43,7 +43,7 @@ export default class Config implements SyncConfig { // Temporary if (!this.password && !this.privateKey) { - this.cli.read("Enter password to connect", true).then(answer => { + this.cli.read("Enter password to connect:", true).then(answer => { this.password = this._config.password = answer; resolve(); }); diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index c8b5211..d1f7253 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -100,8 +100,8 @@ export default class Watcher { private all = (event:string, path:string) => { if (event in this.eventToWord) { - this.cli.workspace(); - this.cli.write(`\n${ this.eventToWord[event]} ${path}`); + // this.cli.workspace(); + this.cli.log(`\n${ this.eventToWord[event]} ${path.replace(this.config.localPath, "").replace(this.config.remotePath, "")}`); this.cli.startProgress(); } }; @@ -109,7 +109,7 @@ export default class Watcher { private add = (path: string) => { this.uploader.uploadFile(path).then(remote => { this.cli.stopProgress(); - this.cli.write(`\nSAVED ${remote}`); + // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); }).catch((err) => { this.cli.stopProgress(); console.error(err.message, err.error); @@ -119,30 +119,36 @@ export default class Watcher { private change = (path: string) => { this.uploader.uploadFile(path).then(remote => { this.cli.stopProgress(); - this.cli.write(`\nSAVED ${remote}`); + // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); + // this.cli.workspace(); }).catch((err) => { this.cli.stopProgress(); console.error(err.message, err.error); + // this.cli.workspace(); }); }; private unlink = (path: string) => { this.uploader.unlinkFile(path).then(remote => { this.cli.stopProgress(); - this.cli.write(`\nSAVED ${remote}`); + // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); + // this.cli.workspace(); }).catch((err) => { this.cli.stopProgress(); console.log(`Error deleting file ${err}`); + // this.cli.workspace(); }); }; private unlinkDir = (path: string) => { this.uploader.unlinkFolder(path).then(remote => { this.cli.stopProgress(); - this.cli.write(`\nSAVED ${remote}`); + // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); + // this.cli.workspace(); }).catch((err) => { this.cli.stopProgress(); console.log(`Error deleting folder ${err}`); + // this.cli.workspace(); }); }; } From 1687f155b365204563deb5e645027acfa8f1865d Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Tue, 16 Aug 2016 14:42:17 -0700 Subject: [PATCH 40/49] Remove complexity --- src/classes/CLI.ts | 71 ++++++++++++++++++++++--------------- src/classes/Sync.ts | 15 ++++++-- src/classes/Watcher.ts | 80 +++++++++--------------------------------- 3 files changed, 71 insertions(+), 95 deletions(-) diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index 830b9d6..e3efb49 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -30,9 +30,9 @@ export default class CLI { private lastRun: number; private timeDiff: number; private args: minimist.ParsedArgs; - // private ui: inquirer.ui.BottomBar; + private ui: inquirer.ui.Prompt[] = []; private activePrompt; - + private pauseEvents: Function[] = []; public paused: boolean; constructor() { @@ -65,6 +65,10 @@ export default class CLI { return value !== null ? value : defaultValue; } + onPaused(event) { + this.pauseEvents.push(event); + } + /** * Clear the terminal */ @@ -82,19 +86,33 @@ export default class CLI { log(message: string) { // this.ui.updateBottomBar(message); console.log(message); + // this.showPrompt(); } read(question: any, hidden = false): Promise { - return new Promise((resolve, reject) => { - let scheme = { - type: hidden? "password" : "input", - message: question, - name: "response" - }; - - this.ui.prompt(scheme).then((answer) => { - resolve(answer.response); - }); + let scheme = { + type: hidden? "password" : "input", + message: question, + name: "response" + }; + + let promise = inquirer.prompt(scheme); + this.ui.push(promise['ui']); + + return promise.then((answer) => { + return answer.response; + }); + } + + closePrompts() { + this.ui.map((ui) => { + if (!ui['closed']) { + ui.close(); + ui['closed'] = true; + //console.log("closed now") + } else { + //console.log("closed Already") + } }); } @@ -118,17 +136,12 @@ export default class CLI { * Display the workspace for syncjs */ workspace() { - this.clear(); - - if (this.paused) { - this.write(`Currently paused, type "${ chalk.green("resume") }" to start again.\n`); - } else { - this.write(`Started monitoring \n`); - } + // this.clear(); - this.write(`Quit the script with CONTROL-C or type "${ chalk.green("exit") }".\n`); + this.write(`Started monitoring \n`); + this.write(`Quit the script with CONTROL-C".\n`); this.write(chalk.magenta("-----------------------------------------------------------\n")); - this.showPrompt(); + // this.showPrompt(); } usage(message: string = null, code: number = 0): void { @@ -152,13 +165,9 @@ export default class CLI { */ private showPrompt() { if (this.activePrompt) { - // this.ui.close(); - //console.log(this.activePrompt); - //this.activePrompt.ui.rl.emit("serkan") - return true; + this.closePrompts(); } - this.activePrompt = this.read(">>> "); this.activePrompt.then(answer => { this.handleInput(answer); @@ -194,6 +203,9 @@ export default class CLI { break; case "pause": this.paused = true; + this.pauseEvents.map((ev) => { + ev(this.paused); + }); this.workspace(); break; case "resume": @@ -207,7 +219,9 @@ export default class CLI { if (arg1 == "-u") { this.write("Finding all changed files while waiting.\n"); } - // this.startChecking(); + this.pauseEvents.map((ev) => { + ev(this.paused); + }); } else { this.write("Already running\n"); } @@ -217,4 +231,5 @@ export default class CLI { this.write(chalk.red(`Unknown command: ${ cmd }\nType "help" to see commands`)); } } -} \ No newline at end of file +} + diff --git a/src/classes/Sync.ts b/src/classes/Sync.ts index b25def1..5439d60 100644 --- a/src/classes/Sync.ts +++ b/src/classes/Sync.ts @@ -3,26 +3,32 @@ import CLI from "./CLI"; import Watcher from "./Watcher"; import Uploader from "./Uploader"; import InitConfig from './InitConfig'; +const observatory = require("observatory"); export default class Sync { config: Config; watch: Watcher; cli: CLI; uploader: Uploader; + task: any; constructor() { this.cli = new CLI(); + this.task = observatory.add("Initializing..."); + if (this.cli.hasStartupCommand("init")) { new InitConfig(); } else { // Get config this.config = new Config(this.cli); + this.task.status("reading config"); this.config.ready().then(() => { // Get Command line interface - this.cli.write("Connecting"); - this.cli.startProgress(); + //this.cli.write("Connecting"); + //this.cli.startProgress(); + this.task.status("watching files"); // Setup the uploader this.uploader = new Uploader(this.config, this.cli); @@ -31,12 +37,15 @@ export default class Sync { this.watch = new Watcher(this.uploader, this.config, this.cli); // When files are found start connection + return this.watch.ready(); }).then(() => { + this.task.status("connecting server"); return this.uploader.connect(); }).then(() => { // All done, stop indicator and show workspace - this.cli.stopProgress(); + // this.cli.stopProgress(); + this.task.done("Connected").details(this.config.host); this.cli.workspace(); }); } diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index d1f7253..ced339a 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -4,16 +4,11 @@ import { FSWatcher } from "fs"; import Uploader from "./Uploader"; import Config from "./Config"; import CLI from "./CLI"; - -interface PausedChanges { - event: string; - path: string; -} +const observatory = require("observatory"); export default class Watcher { files: FSWatcher; - private paused = false; - private changes: PausedChanges[] = []; + private tasks = {}; constructor( private uploader: Uploader, @@ -31,7 +26,7 @@ export default class Watcher { // Attach events ["all", "add", "change", "unlink", "unlinkDir"].forEach(method => { - this.files.on(method, this.pauseHandler(method)); + this.files.on(method, this.handler(method)); }); } @@ -41,31 +36,6 @@ export default class Watcher { }); } - pause() { - this.paused = true; - } - - resume(): Promise { - return new Promise((resolve, reject) => { - this.cli.write(`${ this.changes.length } files had changed while paused.`); - this.changes.forEach((change) => { - this.cli.write(`${ this.eventToWord[change.event] }: ${ change.path } `); - this.cli.read('Do you want to make these uploads? [Y/N] ').then((answer) => { - if (answer[0].toUpperCase() === 'Y') { - this.cli.write('Uploading.'); - resolve(); - } else { - reject(); - this.cli.write('Resuming.'); - } - // Set pause false the last thing. Even if changes happen - // during this prompt is on screen. They are still caught - this.paused = false; - }); - }); - }); - } - eventToWord = { add: chalk.green("ADDED"), change: chalk.green("CHANGED"), @@ -73,8 +43,7 @@ export default class Watcher { unlinkDir: chalk.red("DELETED") }; - - private pauseHandler(method: string): Function { + private handler(method: string): Function { return (...args: string[]) => { let path: string, event = method; @@ -87,68 +56,51 @@ export default class Watcher { path = args[0]; } - // If paused store the values - if (this.paused ) { - this.changes.push({ event, path }); - } else { - // If not, continue as ususal - this[method](...args); - } + // If not, continue as ususal + this[method](...args); } } - private all = (event:string, path:string) => { if (event in this.eventToWord) { - // this.cli.workspace(); - this.cli.log(`\n${ this.eventToWord[event]} ${path.replace(this.config.localPath, "").replace(this.config.remotePath, "")}`); - this.cli.startProgress(); + this.tasks[path] = observatory.add(this.eventToWord[event]); + this.tasks[path].status("Uploading").details(path.replace(this.config.localPath, "")); } }; private add = (path: string) => { this.uploader.uploadFile(path).then(remote => { - this.cli.stopProgress(); - // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); + this.tasks[path].done("Done"); }).catch((err) => { - this.cli.stopProgress(); + this.tasks[path].fail("Fail"); console.error(err.message, err.error); }); }; private change = (path: string) => { this.uploader.uploadFile(path).then(remote => { - this.cli.stopProgress(); - // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); - // this.cli.workspace(); + this.tasks[path].done("Done"); }).catch((err) => { - this.cli.stopProgress(); + this.tasks[path].fail("Fail"); console.error(err.message, err.error); - // this.cli.workspace(); }); }; private unlink = (path: string) => { this.uploader.unlinkFile(path).then(remote => { - this.cli.stopProgress(); - // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); - // this.cli.workspace(); + this.tasks[path].done("Done"); }).catch((err) => { - this.cli.stopProgress(); + this.tasks[path].fail("Fail"); console.log(`Error deleting file ${err}`); - // this.cli.workspace(); }); }; private unlinkDir = (path: string) => { this.uploader.unlinkFolder(path).then(remote => { - this.cli.stopProgress(); - // this.cli.log(`\nSAVED ${remote.replace(this.config.remotePath, "")}`); - // this.cli.workspace(); + this.tasks[path].done("Done"); }).catch((err) => { - this.cli.stopProgress(); + this.tasks[path].fail("Fail"); console.log(`Error deleting folder ${err}`); - // this.cli.workspace(); }); }; } From decec203f73d9d173506149ae297a870c1fbff75 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Tue, 16 Aug 2016 14:49:12 -0700 Subject: [PATCH 41/49] better message --- src/classes/Watcher.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index ced339a..bc44838 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -63,8 +63,8 @@ export default class Watcher { private all = (event:string, path:string) => { if (event in this.eventToWord) { - this.tasks[path] = observatory.add(this.eventToWord[event]); - this.tasks[path].status("Uploading").details(path.replace(this.config.localPath, "")); + this.tasks[path] = observatory.add(this.eventToWord[event] + " " + path.replace(this.config.localPath, "")); + this.tasks[path].status("Uploading"); } }; From eb436143275a2685b6a27040f38974d8c869cc3f Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Tue, 16 Aug 2016 14:52:20 -0700 Subject: [PATCH 42/49] add errors in details --- src/classes/Watcher.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/classes/Watcher.ts b/src/classes/Watcher.ts index bc44838..5f10668 100644 --- a/src/classes/Watcher.ts +++ b/src/classes/Watcher.ts @@ -72,8 +72,7 @@ export default class Watcher { this.uploader.uploadFile(path).then(remote => { this.tasks[path].done("Done"); }).catch((err) => { - this.tasks[path].fail("Fail"); - console.error(err.message, err.error); + this.tasks[path].fail("Fail").details(err.message); }); }; @@ -81,8 +80,7 @@ export default class Watcher { this.uploader.uploadFile(path).then(remote => { this.tasks[path].done("Done"); }).catch((err) => { - this.tasks[path].fail("Fail"); - console.error(err.message, err.error); + this.tasks[path].fail("Fail").details(err.message); }); }; @@ -90,8 +88,7 @@ export default class Watcher { this.uploader.unlinkFile(path).then(remote => { this.tasks[path].done("Done"); }).catch((err) => { - this.tasks[path].fail("Fail"); - console.log(`Error deleting file ${err}`); + this.tasks[path].fail("Fail").details(`Error deleting file ${err}`); }); }; @@ -99,8 +96,7 @@ export default class Watcher { this.uploader.unlinkFolder(path).then(remote => { this.tasks[path].done("Done"); }).catch((err) => { - this.tasks[path].fail("Fail"); - console.log(`Error deleting folder ${err}`); + this.tasks[path].fail("Fail").details(`Error deleting folder ${err}`); }); }; } From a38345796f069d7e8471822ce3604632929f265d Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 12 Oct 2016 15:27:46 -0700 Subject: [PATCH 43/49] missing package --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 2feb2f5..5619743 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "jsonplus": "^1.2.1", "minimist": "^1.2.0", "moment": "2.14.1", + "observatory": "^1.0.0", "prompt": "^1.0.0", "scp2": "^0.5.0", "upath": "^0.2.0" From b28aef05aead09ec2ac2c3fc3aa510980c4a2bc6 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 2 Nov 2016 14:51:11 -0700 Subject: [PATCH 44/49] upgrade part 1 --- .jshintrc | 14 - .vscode/settings.json | 2 + config_example.json | 7 - gulpfile.js | 2 +- package.json | 21 +- sync.js | 435 ------- yarn.lock | 2877 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 2894 insertions(+), 464 deletions(-) delete mode 100644 .jshintrc delete mode 100644 config_example.json delete mode 100755 sync.js create mode 100644 yarn.lock diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 03f2b63..0000000 --- a/.jshintrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "boss": true, - "undef": false, - "white": false, - "eqeqeq": false, - "browser": true, - "devel": true, - "bitwise": false, - "quotmark": false, - "camelcase": false, - "strict": false, - "trailing": true, - "node": true -} diff --git a/.vscode/settings.json b/.vscode/settings.json index 9f81489..8327f06 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,4 +13,6 @@ "**/.DS_Store": true, "**/dist/*": true } +, +"typescript.tsdk": "./node_modules/typescript/lib" } \ No newline at end of file diff --git a/config_example.json b/config_example.json deleted file mode 100644 index 4c71923..0000000 --- a/config_example.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "username": "ubuntu", - "host": "ec2-54-214-239-76.us-west-2.compute.amazonaws.com", - "localPath": "C:\\Users\\serka\\Projects\\sync", - "remotePath": "/home/ubuntu/src/sync", - "privateKey": "C:\\Users\\serka\\Dropbox\\serkan.io.pem" -} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index e875026..b6a90b6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,7 +6,7 @@ var rename = require("gulp-rename"); gulp.task("build", function () { var tsProject = ts.createProject(__dirname + "/tsconfig.json"); return tsProject.src() - .pipe(ts(tsProject)) + .pipe(tsProject()) .pipe(babel()) .pipe(rename(function (path) { path.extname = ".js"; diff --git a/package.json b/package.json index 5619743..59f3c86 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,19 @@ "syncjs": "bin/syncjs" }, "dependencies": { + "@types/chalk": "^0.4.31", + "@types/chokidar": "^1.4.29", + "@types/inquirer": "^0.0.30", + "@types/minimist": "^1.1.29", + "@types/node": "^6.0.46", + "@types/rx": "^2.5.33", + "@types/through": "^0.0.28", "chalk": "^1.1.3", - "chokidar": "^1.6.0", + "chokidar": "^1.6.1", "inquirer": "^1.1.2", "jsonplus": "^1.2.1", "minimist": "^1.2.0", - "moment": "2.14.1", + "moment": "2.15.2", "observatory": "^1.0.0", "prompt": "^1.0.0", "scp2": "^0.5.0", @@ -25,14 +32,14 @@ }, "description": "sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command.", "devDependencies": { - "typescript": "^1.8.10", - "babel-cli": "^6.11.4", - "babel-preset-es2015": "^6.9.0", - "babel-runtime": "^6.11.6", + "babel-cli": "^6.18.0", + "babel-preset-es2015": "^6.18.0", + "babel-runtime": "^6.18.0", "gulp": "^3.9.1", "gulp-babel": "^6.1.2", "gulp-rename": "^1.2.2", - "gulp-typescript": "^2.13.6" + "gulp-typescript": "^3.1.2", + "typescript": "^2.0.6" }, "repository": { "type": "git", diff --git a/sync.js b/sync.js deleted file mode 100755 index 09051e9..0000000 --- a/sync.js +++ /dev/null @@ -1,435 +0,0 @@ -#!/usr/bin/env node -'use strict'; -/** - * a nifty tool to sync your local folder with remote folder - * -------------------------------------------------------------- - * INSTALLATION, just clone this to any place on your computer - * and cd to sync folder, then run: `npm install` and run server - * by calling `nodejs sync.js` - * -------------------------------------------------------------- - * For best usage, create a config file as ~/.ssh/config - * and put this inside ----------- ~/.ssh/config ------------------ -Host * - ControlMaster auto - ControlPath ~/.ssh/master-%r@%h:%p - -Host dev - HostName {HOST URL OR IP} - User {YOUR USERNAME} -------------------------------------------- - * so script can maintain a persistent SSH connection and be faster - */ -var sync = { - // for colored and powerful command line - clc: require('cli-color'), - // shortcut to write to console - write: process.stdout.write.bind(process.stdout), - // execute a child process - exec: require('child_process').exec, - // Date Time parsing easy way - moment: require('moment'), - // self explanatory sprintf method - sprintf: require('underscore.string').sprintf, - // Check if string ends with given substring - endsWith: require('underscore.string').endsWith, - // read users input, for command line - readline: require('readline'), - // when was the last time script checked changes - lastRun: +(new Date()), - // how many seconds it took to start checking again - timeDiff: 0, - // if true, stop checking changes - paused: false, - // time handler for print dots functions - pdTime: 0, - /** - * Read config file and check it's existance - */ - getConfig: function(){ - // Check the existance of the config file - try{ - this.config = require("./config.json"); - }catch(e){ - console.log(this.clc.red('Please create a config file by copying the config_example.json')); - process.exit(1); - } - // Make sure remote path ends with slash - if(!this.endsWith(this.config.remote_path, '/')){ - this.config.remote_path += '/'; - } - }, - /** - * Start read line process, and check if installed nodejs compatible with it - * @return {[type]} [description] - */ - initReadline: function(){ - // Ubuntu uses the old version of node.js and it doesn't have support for readline features - // So check here for errors and warn user about node upgrade - try{ - this.rl = this.readline.createInterface({ - input: process.stdin, - output: process.stdout - }); - }catch(e){ - console.log('You need to upgrade your nodejs'); - console.log('http://slopjong.de/2012/10/31/how-to-install-the-latest-nodejs-in-ubuntu/'); - process.exit(1); - } - }, - /** - * Start printing dots to screen, show script is working - */ - dotsStart: function(){ - var self = this; - this.pdTime = setInterval(function(){ - self.write(self.clc.yellow('.')); - }, 200); - }, - /** - * Stop printing dots when process ends - */ - dotsStop: function(){ - clearInterval(this.pdTime); - }, - /** - * Convert date time string to unix time - */ - getSecondsOf: function (time) { - var t = this.moment(new Date(time)); - if (t !== null) { - return t.unix(); - } - return 0; - }, - /** - * Generate a find command for both OSX and Ubuntu - * ubuntu should cover most linux versions - */ - generateFindCMD: function(){ - // ls command powered with find to get recently changed files - // Command to get changed files - if (process.platform === 'darwin'){ - // for mac os x - this.cmd = 'ls -1CloTtr $( find . -type f -mtime -5m -print ) | grep -v \'.git/\' | awk \'{ print $5, $6, $7, $8, "-", $9 }\''; - }else{ - // for linux - this.cmd = 'ls -1Clotr --time-style=+\'%d-%b-%Y %T\' $( find . -type f -mmin -5 -print ) | grep -v \'.git/\' | awk \'{ print $5, $6, "-", $7 }\''; - } - }, - /** - * Upload given file to server then call given callback - */ - uploadFile: function (line, callback, i){ - var self = this; - // notify user that upload has started - this.write( this.clc.magenta(i) + ' ' + this.clc.yellow(this.sprintf('Uploading file: %s ', line[0]))); - // create scp command - var scp = this.sprintf('scp %s %s:%s', line[0], this.host, line[1]); - // start printing dots - this.dotsStart(); - //execute command - this.exec(scp, function(e){ - // command completed, stop dots - self.dotsStop(); - // if there is an error during upload, print it otherwise give user success message - if (e !== null) { - self.write(self.clc.red(self.sprintf('ERROR on: %s Message: %s\n', line[1], e))); - }else{ - self.write(self.clc.green(' Saved.\n')); - self.showNotification('File uploaded'); - } - // call callback no matter what - callback(); - }); - }, - /** - * Returns a list of changed files - */ - getChangedFiles: function (lines){ - var self = this; - // an empty array to fill changed files - var changedFiles = []; - // create a unix time right before our last check - var anIntervalAgo = this.moment().unix() - this.timeDiff; - // loop all returned files - lines.forEach(function(line){ - // split the file list so that we can have the file name and changed date - var details = line.split(' - '); - // Convert date to seconds, so we can compare it unix time of now - var fileSeconds = self.getSecondsOf(details[0]); - // merge rest of the details to re-genrate the file name - details.shift(); - var filename = details.join(''); - - // if file changed at least an interval ago, then it is a recent change - if (fileSeconds > anIntervalAgo) { - // create remote file name and add to the array - var remoteFile = filename.replace('./', self.remotePath); - if(!self.endsWith(filename, '.swp') && - !self.endsWith(filename, '.pyc') && - !self.endsWith(filename, '.DS_Store')){ - changedFiles.push([filename, remoteFile]); - } - } - }); - - return changedFiles; - }, - /** - * Keep the script explanation at the top of the page - */ - printTitle: function(){ - this.write(this.clc.reset + '\n'); - if(this.paused){ - this.write('Currently paused, type "'+ this.clc.green('resume') + '" to start again.\n'); - }else{ - this.write(this.sprintf('Started monitoring, checking every %s seconds.\n', this.secondsInterval)); - } - this.write('Quit the script with CONTROL-C or type "'+this.clc.green('exit')+'".\n'); - this.write(this.clc.magenta('-----------------------------------------------------------\n')); - this.showPrompt(); - }, - /** - * Show prompt line so user can run commands - */ - showPrompt: function(){ - var self = this; - this.rl.question(">>> ", function(answer) { - self.handleInput(answer); - // as soon as a command is run, show promt again just a like a real shell - self.showPrompt(); - }); - }, - /** - * Short cut to generate a help text - */ - getHelp: function(command, text){ - return this.sprintf("%s: %s\n", this.clc.green(command), text); - }, - /** - * a little command line interface to control the script - */ - handleInput: function(input){ - input = input.split(' '); - var cmd = input[0]; - var arg1 = input[1]; - switch(cmd){ - case "help": - var helpText = ""; - helpText += this.getHelp('pause', "Stops observing file changes"); - helpText += this.getHelp('resume', "Continue checking files"); - helpText += this.getHelp('resume -u', "Continue checking files and upload all the changed files while paused."); - helpText += this.getHelp('interval [s]', 'Sets the check interval duration. Example: "interval 2.5" check for every 2.5 seconds'); - helpText += this.getHelp('help', "Displays this text"); - helpText += this.getHelp('clear', "Clears the screen"); - helpText += this.getHelp('exit', "Exits the script"); - this.write(helpText); - break; - case "clear": - this.printTitle(); - break; - case "exit": - process.exit(0); - break; - case "pause": - this.paused = true; - break; - case "resume": - if(this.paused){ - if(arg1 != "-u"){ - this.lastRun = +(new Date()); - this.timeDiff = 0; - } - this.paused = false; - this.printTitle(); - if(arg1 == "-u"){ - this.write('Finding all changed files while waiting.\n'); - } - this.startChecking(); - }else{ - this.write('Already running\n'); - } - break; - case "interval": - if(arg1){ - this.secondsInterval = parseFloat(arg1) || this.secondsInterval; - this.printTitle(); - } - this.write('Check interval is '+this.secondsInterval+' Seconds\n'); - break; - case "":break; - default: - console.log(this.clc.red('Unknown command: "'+cmd+'"\nType "help" to see commands')); - } - }, - /** - * Creates a master SSH connection, keeps the connection open - * so `scp` commands work faster by sharing the same persisten connection - */ - createMasterConection: function(){ - var self = this; - // Show starting text - this.write('Connecting.'); - this.dotsStart(); - - // Keep a connection open to make scp commands faster - this.ssh = this.exec('ssh -Mv '+this.host, function(){ - self.write(self.clc.red('\nSSH connection failed.\n')); - // stop showing dots - self.dotsStop(); - process.exit(1); - }); - - // Wait for SSH connection to be connected - this.ssh.stderr.on('data', function (data) { - // if asks for password, stop printing dots - if(data.toString().indexOf('Next authentication method: password') != -1){ - self.dotsStop(); - } - // SSH initially throws an exception, when first executed from node. - // just ignoring that message is enough - if(data.toString().indexOf('Entering interactive session') != -1){ - // stop showing dots - self.dotsStop(); - - // Let user know what's happening - self.printTitle(); - - // Start Checking changes - self.startChecking(); - } - }); - }, - /** - * Start checking changes, since we don't use setInterval - * this function is called for starting each loop - */ - startChecking: function(){ - // calculate the last time it run, so we can check back to that point and get the changes while file was uploaded - this.timeDiff = (+(new Date()) - this.lastRun) / 1000; - this.lastRun = +(new Date()); - if (this.paused){ - this.printTitle(); - return false; - } - // start again - setTimeout(this.checkChanges.bind(this), this.secondsInterval * 1000); - }, - /** - * Show a notification using mac os x notification center - * @param {[type]} message Message to show - */ - showNotification: function(message) { - if (this.config.showNotification) { - this.exec("osascript -e 'display notification \""+message+"\" with title \"Sync.js\"'"); - } - if (this.config.useTerminalNotifier) { - var bin = 'terminal-notifier '; - this.exec(bin + ["-title 'Sync.js'", - "-message '" + message + "'", - "-group 'Sync.js'", - "-activate " + this.config.terminalNotifierSenderID, - "-sender " + this.config.terminalNotifierSenderID].join(' ')); - } - }, - /** - * Execude find command and upload any changed file - * @return {[type]} [description] - */ - checkChanges: function(){ - // Execute the find command and get all recently changed files - this.exec(this.cmd, this.onFindComplete.bind(this)); // EO exec - }, - /** - * When find command is completed, check for changed files and upload them - * if necessary - */ - onFindComplete: function(error, stdout, stderr) { - //console.log(stdout); - //console.log(error, stderr); - // if there is an error, print and exit - if (error !== null) { - this.write(this.clc.red('exec error: ' + error) + '\n'); - this.showNotification('exec error: ' + error); - }else{ - // Get all the lines from the output - var lines = stdout.split(/\n/); - // run only if there is an output - if(lines.length > 0){ - // an index to gradually step changed files list - this.cfIndex = 0; - // Get only the files that are changed from the last time we checked - this.cf = this.getChangedFiles(lines); - // If there are changed files - if(this.cf.length > 0){ - // Clear the screen - this.printTitle(); - if(this.config.visorSupport){ - this.exec("osascript -e 'set prev_ to name of (info for (path to frontmost application))' " + - "-e 'tell application \"Terminal\" to activate' " + - "-e 'delay 1' " + - "-e 'tell application prev_ to activate'"); - } - // Display how many files were changed - var message = this.cf.length + ' file'+(this.cf.length>1? 's':'')+' changed.' + '\n'; - this.write(message); - this.showNotification(message); - - // Start uploading files as soon as function is created - this.uploadAll(); - }else{ - this.startChecking(); // if no changed file found, start checking again - } - }else{ - this.startChecking(); // if no file returned, start checking again - } - } - }, - /** - * Instead of looping changed files list, create a callback loop - * so each iteration will start after the previous one is completed - * this is needed to prevent creating too many connections with `scp` - */ - uploadAll: function(){ - var self = this; - // while index is less than changed files length - if(this.cfIndex < this.cf.length){ - // Upload the current file, and when it's finished - // switch to next one - this.uploadFile(this.cf[this.cfIndex], function(){ - self.uploadAll(++self.cfIndex); - }, this.cf.length>1? this.sprintf('[%s - %s]', this.cfIndex+1, this.cf.length) : '>'); // [1 - 25] like string to show the status of the upload - }else{ - if(this.cf.length > 1){ - this.write('All files are uploaded.\n'); - this.showNotification('All files are uploaded'); - } - this.showPrompt(); - this.startChecking(); - } - }, - /** - * Initiate the script - */ - init: function(){ - // initiate moment - this.moment().format(); - this.getConfig(); - this.initReadline(); - - // How many seconds should script wait for each interval? - this.secondsInterval = this.config.interval_duration || 1.5; - // Path names to sync - this.localPath = this.config.local_path; - this.remotePath = this.config.remote_path; - this.generateFindCMD(); - this.host = this.config.host; - // switch to project path to run commands relatively - process.chdir(this.localPath); - - this.createMasterConection(); - } -}; -// Let the games begin!!! -sync.init(); diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..5849095 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,2877 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 +"@types/chalk": + version "0.4.31" + resolved "https://registry.yarnpkg.com/@types/chalk/-/chalk-0.4.31.tgz#a31d74241a6b1edbb973cf36d97a2896834a51f9" + +"@types/chokidar": + version "1.4.29" + resolved "https://registry.yarnpkg.com/@types/chokidar/-/chokidar-1.4.29.tgz#31efd569930cf6799b20941c86bc6bff7c2e230a" + dependencies: + "@types/node" "*" + +"@types/inquirer": + version "0.0.30" + resolved "https://registry.yarnpkg.com/@types/inquirer/-/inquirer-0.0.30.tgz#2e30a40ff188c9830ec0d4c71f99ee65972de5b7" + dependencies: + "@types/rx" "*" + "@types/through" "*" + +"@types/minimist": + version "1.1.29" + resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.1.29.tgz#91cd01c4f28c18c8a4e621aad803a3608d81cfea" + +"@types/node", "@types/node@*": + version "6.0.46" + resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.46.tgz#8d9e48572831f05b11cc4c793754d43437219d62" + +"@types/rx", "@types/rx@*": + version "2.5.33" + resolved "https://registry.yarnpkg.com/@types/rx/-/rx-2.5.33.tgz#1867f4ac98e57428fe82b284d1a80c9c1f611bb7" + +"@types/through", "@types/through@*": + version "0.0.28" + resolved "https://registry.yarnpkg.com/@types/through/-/through-0.0.28.tgz#1effa9a6d00fb48572b4cc9f44df25b0100db7fc" + dependencies: + "@types/node" "*" + +abbrev@1: + version "1.0.9" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" + +ansi-escapes@^1.1.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + +ansi-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.0.0.tgz#c5061b6e0ef8a81775e50f5d66151bf6bf371107" + +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + +anymatch@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + dependencies: + arrify "^1.0.0" + micromatch "^2.1.5" + +aproba@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.0.4.tgz#2713680775e7614c8ba186c065d4e2e52d1072c0" + +archy@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" + +are-we-there-yet@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz#80e470e95a084794fe1899262c5667c6e88de1b3" + dependencies: + delegates "^1.0.0" + readable-stream "^2.0.0 || ^1.1.13" + +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + +arr-flatten@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.1.tgz#e5ffe54d45e19f32f216e91eb99c8ce892bb604b" + +array-differ@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-1.0.0.tgz#eff52e3758249d33be402b8bb8e564bb2b5d4031" + +array-find-index@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1" + +array-uniq@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" + +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + +arrify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" + +asn1@~0.2.0, asn1@~0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.3.tgz#dac8787713c9966849fc8180777ebe9c1ddf3b86" + +assert-plus@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" + +assert-plus@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525" + +async-each@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.1.tgz#19d386a1d9edc6e7c1c85d388aedbcc56d33602d" + +async@~0.9.0: + version "0.9.2" + resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" + +async@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/async/-/async-1.0.0.tgz#f8fc04ca3a13784ade9e1641af98578cfbd647a9" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + +aws-sign2@~0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" + +aws4@^1.2.1: + version "1.5.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.5.0.tgz#0a29ffb79c31c9e712eeb087e8e7a64b4a56d755" + +babel-cli@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.18.0.tgz#92117f341add9dead90f6fa7d0a97c0cc08ec186" + dependencies: + babel-core "^6.18.0" + babel-polyfill "^6.16.0" + babel-register "^6.18.0" + babel-runtime "^6.9.0" + commander "^2.8.1" + convert-source-map "^1.1.0" + fs-readdir-recursive "^1.0.0" + glob "^5.0.5" + lodash "^4.2.0" + output-file-sync "^1.1.0" + path-is-absolute "^1.0.0" + slash "^1.0.0" + source-map "^0.5.0" + v8flags "^2.0.10" + optionalDependencies: + chokidar "^1.0.0" + +babel-code-frame@^6.16.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.16.0.tgz#f90e60da0862909d3ce098733b5d3987c97cb8de" + dependencies: + chalk "^1.1.0" + esutils "^2.0.2" + js-tokens "^2.0.0" + +babel-core@^6.0.2, babel-core@^6.18.0: + version "6.18.2" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.18.2.tgz#d8bb14dd6986fa4f3566a26ceda3964fa0e04e5b" + dependencies: + babel-code-frame "^6.16.0" + babel-generator "^6.18.0" + babel-helpers "^6.16.0" + babel-messages "^6.8.0" + babel-register "^6.18.0" + babel-runtime "^6.9.1" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + babylon "^6.11.0" + convert-source-map "^1.1.0" + debug "^2.1.1" + json5 "^0.5.0" + lodash "^4.2.0" + minimatch "^3.0.2" + path-is-absolute "^1.0.0" + private "^0.1.6" + slash "^1.0.0" + source-map "^0.5.0" + +babel-generator@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.18.0.tgz#e4f104cb3063996d9850556a45aae4a022060a07" + dependencies: + babel-messages "^6.8.0" + babel-runtime "^6.9.0" + babel-types "^6.18.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.2.0" + source-map "^0.5.0" + +babel-helper-call-delegate@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.18.0.tgz#05b14aafa430884b034097ef29e9f067ea4133bd" + dependencies: + babel-helper-hoist-variables "^6.18.0" + babel-runtime "^6.0.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helper-define-map@^6.18.0, babel-helper-define-map@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.18.0.tgz#8d6c85dc7fbb4c19be3de40474d18e97c3676ec2" + dependencies: + babel-helper-function-name "^6.18.0" + babel-runtime "^6.9.0" + babel-types "^6.18.0" + lodash "^4.2.0" + +babel-helper-function-name@^6.18.0, babel-helper-function-name@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.18.0.tgz#68ec71aeba1f3e28b2a6f0730190b754a9bf30e6" + dependencies: + babel-helper-get-function-arity "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helper-get-function-arity@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.18.0.tgz#a5b19695fd3f9cdfc328398b47dafcd7094f9f24" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-hoist-variables@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.18.0.tgz#a835b5ab8b46d6de9babefae4d98ea41e866b82a" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-optimise-call-expression@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.18.0.tgz#9261d0299ee1a4f08a6dd28b7b7c777348fd8f0f" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-helper-regex@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.18.0.tgz#ae0ebfd77de86cb2f1af258e2cc20b5fe893ecc6" + dependencies: + babel-runtime "^6.9.0" + babel-types "^6.18.0" + lodash "^4.2.0" + +babel-helper-replace-supers@^6.18.0, babel-helper-replace-supers@^6.8.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.18.0.tgz#28ec69877be4144dbd64f4cc3a337e89f29a924e" + dependencies: + babel-helper-optimise-call-expression "^6.18.0" + babel-messages "^6.8.0" + babel-runtime "^6.0.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-helpers@^6.16.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.16.0.tgz#1095ec10d99279460553e67eb3eee9973d3867e3" + dependencies: + babel-runtime "^6.0.0" + babel-template "^6.16.0" + +babel-messages@^6.8.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.8.0.tgz#bf504736ca967e6d65ef0adb5a2a5f947c8e0eb9" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-check-es2015-constants@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.8.0.tgz#dbf024c32ed37bfda8dee1e76da02386a8d26fe7" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-arrow-functions@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.8.0.tgz#5b63afc3181bdc9a8c4d481b5a4f3f7d7fef3d9d" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.8.0.tgz#ed95d629c4b5a71ae29682b998f70d9833eb366d" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-block-scoping@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.18.0.tgz#3bfdcfec318d46df22525cdea88f1978813653af" + dependencies: + babel-runtime "^6.9.0" + babel-template "^6.15.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + lodash "^4.2.0" + +babel-plugin-transform-es2015-classes@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.18.0.tgz#ffe7a17321bf83e494dcda0ae3fc72df48ffd1d9" + dependencies: + babel-helper-define-map "^6.18.0" + babel-helper-function-name "^6.18.0" + babel-helper-optimise-call-expression "^6.18.0" + babel-helper-replace-supers "^6.18.0" + babel-messages "^6.8.0" + babel-runtime "^6.9.0" + babel-template "^6.14.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-computed-properties@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.8.0.tgz#f51010fd61b3bd7b6b60a5fdfd307bb7a5279870" + dependencies: + babel-helper-define-map "^6.8.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-destructuring@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.18.0.tgz#a08fb89415ab82058649558bedb7bf8dafa76ba5" + dependencies: + babel-runtime "^6.9.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.6.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.8.0.tgz#fd8f7f7171fc108cc1c70c3164b9f15a81c25f7d" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.8.0" + +babel-plugin-transform-es2015-for-of@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.18.0.tgz#4c517504db64bf8cfc119a6b8f177211f2028a70" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-function-name@^6.9.0: + version "6.9.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.9.0.tgz#8c135b17dbd064e5bba56ec511baaee2fca82719" + dependencies: + babel-helper-function-name "^6.8.0" + babel-runtime "^6.9.0" + babel-types "^6.9.0" + +babel-plugin-transform-es2015-literals@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.8.0.tgz#50aa2e5c7958fc2ab25d74ec117e0cc98f046468" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-modules-amd@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.18.0.tgz#49a054cbb762bdf9ae2d8a807076cfade6141e40" + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-modules-commonjs@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.18.0.tgz#c15ae5bb11b32a0abdcc98a5837baa4ee8d67bcc" + dependencies: + babel-plugin-transform-strict-mode "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.16.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.18.0.tgz#f09294707163edae4d3b3e8bfacecd01d920b7ad" + dependencies: + babel-helper-hoist-variables "^6.18.0" + babel-runtime "^6.11.6" + babel-template "^6.14.0" + +babel-plugin-transform-es2015-modules-umd@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.18.0.tgz#23351770ece5c1f8e83ed67cb1d7992884491e50" + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.18.0" + babel-runtime "^6.0.0" + babel-template "^6.8.0" + +babel-plugin-transform-es2015-object-super@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.8.0.tgz#1b858740a5a4400887c23dcff6f4d56eea4a24c5" + dependencies: + babel-helper-replace-supers "^6.8.0" + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-parameters@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.18.0.tgz#9b2cfe238c549f1635ba27fc1daa858be70608b1" + dependencies: + babel-helper-call-delegate "^6.18.0" + babel-helper-get-function-arity "^6.18.0" + babel-runtime "^6.9.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-shorthand-properties@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.18.0.tgz#e2ede3b7df47bf980151926534d1dd0cbea58f43" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-plugin-transform-es2015-spread@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.8.0.tgz#0217f737e3b821fa5a669f187c6ed59205f05e9c" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-sticky-regex@^6.3.13: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.8.0.tgz#e73d300a440a35d5c64f5c2a344dc236e3df47be" + dependencies: + babel-helper-regex "^6.8.0" + babel-runtime "^6.0.0" + babel-types "^6.8.0" + +babel-plugin-transform-es2015-template-literals@^6.6.0: + version "6.8.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.8.0.tgz#86eb876d0a2c635da4ec048b4f7de9dfc897e66b" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.18.0.tgz#0b14c48629c90ff47a0650077f6aa699bee35798" + dependencies: + babel-runtime "^6.0.0" + +babel-plugin-transform-es2015-unicode-regex@^6.3.13: + version "6.11.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.11.0.tgz#6298ceabaad88d50a3f4f392d8de997260f6ef2c" + dependencies: + babel-helper-regex "^6.8.0" + babel-runtime "^6.0.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-regenerator@^6.16.0: + version "6.16.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.16.1.tgz#a75de6b048a14154aae14b0122756c5bed392f59" + dependencies: + babel-runtime "^6.9.0" + babel-types "^6.16.0" + private "~0.1.5" + +babel-plugin-transform-strict-mode@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.18.0.tgz#df7cf2991fe046f44163dcd110d5ca43bc652b9d" + dependencies: + babel-runtime "^6.0.0" + babel-types "^6.18.0" + +babel-polyfill@^6.16.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.16.0.tgz#2d45021df87e26a374b6d4d1a9c65964d17f2422" + dependencies: + babel-runtime "^6.9.1" + core-js "^2.4.0" + regenerator-runtime "^0.9.5" + +babel-preset-es2015@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-preset-es2015/-/babel-preset-es2015-6.18.0.tgz#b8c70df84ec948c43dcf2bf770e988eb7da88312" + dependencies: + babel-plugin-check-es2015-constants "^6.3.13" + babel-plugin-transform-es2015-arrow-functions "^6.3.13" + babel-plugin-transform-es2015-block-scoped-functions "^6.3.13" + babel-plugin-transform-es2015-block-scoping "^6.18.0" + babel-plugin-transform-es2015-classes "^6.18.0" + babel-plugin-transform-es2015-computed-properties "^6.3.13" + babel-plugin-transform-es2015-destructuring "^6.18.0" + babel-plugin-transform-es2015-duplicate-keys "^6.6.0" + babel-plugin-transform-es2015-for-of "^6.18.0" + babel-plugin-transform-es2015-function-name "^6.9.0" + babel-plugin-transform-es2015-literals "^6.3.13" + babel-plugin-transform-es2015-modules-amd "^6.18.0" + babel-plugin-transform-es2015-modules-commonjs "^6.18.0" + babel-plugin-transform-es2015-modules-systemjs "^6.18.0" + babel-plugin-transform-es2015-modules-umd "^6.18.0" + babel-plugin-transform-es2015-object-super "^6.3.13" + babel-plugin-transform-es2015-parameters "^6.18.0" + babel-plugin-transform-es2015-shorthand-properties "^6.18.0" + babel-plugin-transform-es2015-spread "^6.3.13" + babel-plugin-transform-es2015-sticky-regex "^6.3.13" + babel-plugin-transform-es2015-template-literals "^6.6.0" + babel-plugin-transform-es2015-typeof-symbol "^6.18.0" + babel-plugin-transform-es2015-unicode-regex "^6.3.13" + babel-plugin-transform-regenerator "^6.16.0" + +babel-register@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.18.0.tgz#892e2e03865078dd90ad2c715111ec4449b32a68" + dependencies: + babel-core "^6.18.0" + babel-runtime "^6.11.6" + core-js "^2.4.0" + home-or-tmp "^2.0.0" + lodash "^4.2.0" + mkdirp "^0.5.1" + source-map-support "^0.4.2" + +babel-runtime@^6.0.0, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.9.0, babel-runtime@^6.9.1: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.18.0.tgz#0f4177ffd98492ef13b9f823e9994a02584c9078" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.9.5" + +babel-template@^6.14.0, babel-template@^6.15.0, babel-template@^6.16.0, babel-template@^6.8.0: + version "6.16.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.16.0.tgz#e149dd1a9f03a35f817ddbc4d0481988e7ebc8ca" + dependencies: + babel-runtime "^6.9.0" + babel-traverse "^6.16.0" + babel-types "^6.16.0" + babylon "^6.11.0" + lodash "^4.2.0" + +babel-traverse@^6.16.0, babel-traverse@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.18.0.tgz#5aeaa980baed2a07c8c47329cd90c3b90c80f05e" + dependencies: + babel-code-frame "^6.16.0" + babel-messages "^6.8.0" + babel-runtime "^6.9.0" + babel-types "^6.18.0" + babylon "^6.11.0" + debug "^2.2.0" + globals "^9.0.0" + invariant "^2.2.0" + lodash "^4.2.0" + +babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.8.0, babel-types@^6.9.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.18.0.tgz#1f7d5a73474c59eb9151b2417bbff4e4fce7c3f8" + dependencies: + babel-runtime "^6.9.1" + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^1.0.1" + +babylon@^6.11.0: + version "6.13.1" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.13.1.tgz#adca350e088f0467647157652bafead6ddb8dfdb" + +balanced-match@^0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" + +bcrypt-pbkdf@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.0.tgz#3ca76b85241c7170bf7d9703e7b9aa74630040d4" + dependencies: + tweetnacl "^0.14.3" + +beeper@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.0.tgz#9ee6fc1ce7f54feaace7ce73588b056037866a2c" + +binary-extensions@^1.0.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.7.0.tgz#6c1610db163abfb34edfe42fa423343a1e01185d" + +block-stream@*: + version "0.0.9" + resolved "https://registry.yarnpkg.com/block-stream/-/block-stream-0.0.9.tgz#13ebfe778a03205cfe03751481ebb4b3300c126a" + dependencies: + inherits "~2.0.0" + +boom@2.x.x: + version "2.10.1" + resolved "https://registry.yarnpkg.com/boom/-/boom-2.10.1.tgz#39c8918ceff5799f83f9492a848f625add0c766f" + dependencies: + hoek "2.x.x" + +brace-expansion@^1.0.0: + version "1.1.6" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.6.tgz#7197d7eaa9b87e648390ea61fc66c84427420df9" + dependencies: + balanced-match "^0.4.1" + concat-map "0.0.1" + +braces@^1.8.2: + version "1.8.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + +buffer-shims@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-shims/-/buffer-shims-1.0.0.tgz#9978ce317388c649ad8793028c3477ef044a8b51" + +builtin-modules@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" + +camelcase-keys@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/camelcase-keys/-/camelcase-keys-2.1.0.tgz#308beeaffdf28119051efa1d932213c91b8f92e7" + dependencies: + camelcase "^2.0.0" + map-obj "^1.0.0" + +camelcase@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" + +caseless@~0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" + +chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + +chokidar@^1.0.0, chokidar@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + +cli-cursor@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" + dependencies: + restore-cursor "^1.0.1" + +cli-width@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.1.0.tgz#b234ca209b29ef66fc518d9b98d5847b00edf00a" + +clone-stats@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/clone-stats/-/clone-stats-0.0.1.tgz#b88f94a82cf38b8791d58046ea4029ad88ca99d1" + +clone@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/clone/-/clone-0.2.0.tgz#c6126a90ad4f72dbf5acdb243cc37724fe93fc1f" + +clone@^1.0.0, clone@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.2.tgz#260b7a99ebb1edfe247538175f783243cb19d149" + +code-point-at@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.0.1.tgz#1104cd34f9b5b45d3eba88f1babc1924e1ce35fb" + dependencies: + number-is-nan "^1.0.0" + +colors@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" + +colors@1.0.x: + version "1.0.3" + resolved "https://registry.yarnpkg.com/colors/-/colors-1.0.3.tgz#0433f44d809680fdeb60ed260f1b0c262e82a40b" + +combined-stream@^1.0.5, combined-stream@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + dependencies: + delayed-stream "~1.0.0" + +commander@^2.8.1, commander@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" + dependencies: + graceful-readlink ">= 1.0.0" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + +concat-stream@^1.4.7: + version "1.5.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.5.2.tgz#708978624d856af41a5a741defdd261da752c266" + dependencies: + inherits "~2.0.1" + readable-stream "~2.0.0" + typedarray "~0.0.5" + +console-control-strings@^1.0.0, console-control-strings@~1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + +convert-source-map@^1.1.0, convert-source-map@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.3.0.tgz#e9f3e9c6e2728efc2676696a70eb382f73106a67" + +core-js@^2.4.0: + version "2.4.1" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + +cryptiles@2.x.x: + version "2.0.5" + resolved "https://registry.yarnpkg.com/cryptiles/-/cryptiles-2.0.5.tgz#3bdfecdc608147c1c67202fa291e7dca59eaa3b8" + dependencies: + boom "2.x.x" + +currently-unhandled@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea" + dependencies: + array-find-index "^1.0.1" + +cycle@1.0.x: + version "1.0.3" + resolved "https://registry.yarnpkg.com/cycle/-/cycle-1.0.3.tgz#21e80b2be8580f98b468f379430662b046c34ad2" + +dashdash@^1.12.0: + version "1.14.0" + resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.0.tgz#29e486c5418bf0f356034a993d51686a33e84141" + dependencies: + assert-plus "^1.0.0" + +dateformat@^1.0.11: + version "1.0.12" + resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-1.0.12.tgz#9f124b67594c937ff706932e4a642cca8dbbfee9" + dependencies: + get-stdin "^4.0.1" + meow "^3.3.0" + +debug@^2.1.1, debug@^2.2.0, debug@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.2.0.tgz#f87057e995b1a1f6ae6a4960664137bc56f039da" + dependencies: + ms "0.7.1" + +decamelize@^1.1.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + +deep-equal@~0.2.1: + version "0.2.2" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-0.2.2.tgz#84b745896f34c684e98f2ce0e42abaf43bba017d" + +deep-extend@~0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + +defaults@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/defaults/-/defaults-1.0.3.tgz#c656051e9817d9ff08ed881477f3fe4019f3ef7d" + dependencies: + clone "^1.0.2" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + +delegates@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" + +deprecated@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/deprecated/-/deprecated-0.0.1.tgz#f9c9af5464afa1e7a971458a8bdef2aa94d5bb19" + +detect-file@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-0.1.0.tgz#4935dedfd9488648e006b0129566e9386711ea63" + dependencies: + fs-exists-sync "^0.1.0" + +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + +duplexer2@0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.0.2.tgz#c614dcf67e2fb14995a91711e5a617e8a60a31db" + dependencies: + readable-stream "~1.1.9" + +duplexify@^3.2.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.0.tgz#1aa773002e1578457e9d9d4a50b0ccaaebcbd604" + dependencies: + end-of-stream "1.0.0" + inherits "^2.0.1" + readable-stream "^2.0.0" + stream-shift "^1.0.0" + +ecc-jsbn@~0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz#0fc73a9ed5f0d53c38193398523ef7e543777505" + dependencies: + jsbn "~0.1.0" + +end-of-stream@~0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-0.1.5.tgz#8e177206c3c80837d85632e8b9359dfe8b2f6eaf" + dependencies: + once "~1.3.0" + +end-of-stream@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.0.0.tgz#d4596e702734a93e40e9af864319eabd99ff2f0e" + dependencies: + once "~1.3.0" + +error-ex@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.0.tgz#e67b43f3e82c96ea3a584ffee0b9fc3325d802d9" + dependencies: + is-arrayish "^0.2.1" + +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + +esutils@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.2.tgz#0abf4f1caa5bcb1f7a9d8acc6dea4faaa04bac9b" + +exit-hook@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" + +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + +expand-tilde@^1.2.1, expand-tilde@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-1.2.2.tgz#0b81eba897e5a3d31d1c3d102f8f01441e559449" + dependencies: + os-homedir "^1.0.1" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + dependencies: + is-extendable "^0.1.0" + +extend@^3.0.0, extend@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.0.tgz#5a474353b9f3353ddd8176dfd37b91c83a46f1d4" + +external-editor@^1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-1.1.1.tgz#12d7b0db850f7ff7e7081baf4005700060c4600b" + dependencies: + extend "^3.0.0" + spawn-sync "^1.0.15" + tmp "^0.0.29" + +extglob@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + +extsprintf@1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" + +eyes@0.1.x: + version "0.1.8" + resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0" + +fancy-log@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/fancy-log/-/fancy-log-1.2.0.tgz#d5a51b53e9ab22ca07d558f2b67ae55fdb5fcbd8" + dependencies: + chalk "^1.1.1" + time-stamp "^1.0.0" + +figures@^1.3.5: + version "1.7.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" + dependencies: + escape-string-regexp "^1.0.5" + object-assign "^4.1.0" + +filename-regex@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + +fill-range@^2.1.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.3.tgz#50b77dfd7e469bc7492470963699fe7a8485a723" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^1.1.3" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + +find-index@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4" + +find-up@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f" + dependencies: + path-exists "^2.0.0" + pinkie-promise "^2.0.0" + +findup-sync@^0.4.2: + version "0.4.3" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.4.3.tgz#40043929e7bc60adf0b7f4827c4c6e75a0deca12" + dependencies: + detect-file "^0.1.0" + is-glob "^2.0.1" + micromatch "^2.3.7" + resolve-dir "^0.1.0" + +fined@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/fined/-/fined-1.0.2.tgz#5b28424b760d7598960b7ef8480dff8ad3660e97" + dependencies: + expand-tilde "^1.2.1" + lodash.assignwith "^4.0.7" + lodash.isempty "^4.2.1" + lodash.isplainobject "^4.0.4" + lodash.isstring "^4.0.1" + lodash.pick "^4.2.1" + parse-filepath "^1.0.1" + +first-chunk-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/first-chunk-stream/-/first-chunk-stream-1.0.0.tgz#59bfb50cd905f60d7c394cd3d9acaab4e6ad934e" + +flagged-respawn@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/flagged-respawn/-/flagged-respawn-0.3.2.tgz#ff191eddcd7088a675b2610fffc976be9b8074b5" + +for-in@^0.1.5: + version "0.1.6" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8" + +for-own@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.4.tgz#0149b41a39088c7515f51ebe1c1386d45f935072" + dependencies: + for-in "^0.1.5" + +forever-agent@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" + +form-data@~2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.1.tgz#4adf0342e1a79afa1e84c8c320a9ffc82392a1f3" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + +fs-exists-sync@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" + +fs-readdir-recursive@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + +fsevents@^1.0.0: + version "1.0.14" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.0.14.tgz#558e8cc38643d8ef40fe45158486d0d25758eee4" + dependencies: + nan "^2.3.0" + node-pre-gyp "^0.6.29" + +fstream-ignore@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/fstream-ignore/-/fstream-ignore-1.0.5.tgz#9c31dae34767018fe1d249b24dada67d092da105" + dependencies: + fstream "^1.0.0" + inherits "2" + minimatch "^3.0.0" + +fstream@^1.0.0, fstream@^1.0.2, fstream@~1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.10.tgz#604e8a92fe26ffd9f6fae30399d4984e1ab22822" + dependencies: + graceful-fs "^4.1.2" + inherits "~2.0.0" + mkdirp ">=0.5 0" + rimraf "2" + +gauge@~2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.6.0.tgz#d35301ad18e96902b4751dcbbe40f4218b942a46" + dependencies: + aproba "^1.0.3" + console-control-strings "^1.0.0" + has-color "^0.1.7" + has-unicode "^2.0.0" + object-assign "^4.1.0" + signal-exit "^3.0.0" + string-width "^1.0.1" + strip-ansi "^3.0.1" + wide-align "^1.1.0" + +gaze@^0.5.1: + version "0.5.2" + resolved "https://registry.yarnpkg.com/gaze/-/gaze-0.5.2.tgz#40b709537d24d1d45767db5a908689dfe69ac44f" + dependencies: + globule "~0.1.0" + +generate-function@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.0.0.tgz#6858fe7c0969b7d4e9093337647ac79f60dfbe74" + +generate-object-property@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/generate-object-property/-/generate-object-property-1.2.0.tgz#9c0e1c40308ce804f4783618b937fa88f99d50d0" + dependencies: + is-property "^1.0.0" + +get-stdin@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" + +getpass@^0.1.1: + version "0.1.6" + resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.6.tgz#283ffd9fc1256840875311c1b60e8c40187110e6" + dependencies: + assert-plus "^1.0.0" + +glob-base@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + +glob-parent@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.0.1.tgz#60021327cc963ddc3b5f085764f500479ecd82ff" + dependencies: + is-glob "^3.1.0" + path-dirname "^1.0.0" + +glob-stream@^3.1.5: + version "3.1.18" + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-3.1.18.tgz#9170a5f12b790306fdfe598f313f8f7954fd143b" + dependencies: + glob "^4.3.1" + glob2base "^0.0.12" + minimatch "^2.0.1" + ordered-read-streams "^0.1.0" + through2 "^0.6.1" + unique-stream "^1.0.0" + +glob-stream@^5.3.2: + version "5.3.5" + resolved "https://registry.yarnpkg.com/glob-stream/-/glob-stream-5.3.5.tgz#a55665a9a8ccdc41915a87c701e32d4e016fad22" + dependencies: + extend "^3.0.0" + glob "^5.0.3" + glob-parent "^3.0.0" + micromatch "^2.3.7" + ordered-read-streams "^0.3.0" + through2 "^0.6.0" + to-absolute-glob "^0.1.1" + unique-stream "^2.0.2" + +glob-watcher@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/glob-watcher/-/glob-watcher-0.0.6.tgz#b95b4a8df74b39c83298b0c05c978b4d9a3b710b" + dependencies: + gaze "^0.5.1" + +glob@^4.3.1: + version "4.5.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-4.5.3.tgz#c6cb73d3226c1efef04de3c56d012f03377ee15f" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "^2.0.1" + once "^1.3.0" + +glob@^5.0.3, glob@^5.0.5: + version "5.0.15" + resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" + dependencies: + inflight "^1.0.4" + inherits "2" + minimatch "2 || 3" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@^7.0.5: + version "7.1.1" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob@~3.1.21: + version "3.1.21" + resolved "https://registry.yarnpkg.com/glob/-/glob-3.1.21.tgz#d29e0a055dea5138f4d07ed40e8982e83c2066cd" + dependencies: + graceful-fs "~1.2.0" + inherits "1" + minimatch "~0.2.11" + +glob@~7.0.3: + version "7.0.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.0.6.tgz#211bafaf49e525b8cd93260d14ab136152b3f57a" + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.2" + once "^1.3.0" + path-is-absolute "^1.0.0" + +glob2base@^0.0.12: + version "0.0.12" + resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56" + dependencies: + find-index "^0.1.1" + +global-modules@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-0.2.3.tgz#ea5a3bed42c6d6ce995a4f8a1269b5dae223828d" + dependencies: + global-prefix "^0.1.4" + is-windows "^0.2.0" + +global-prefix@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-0.1.4.tgz#05158db1cde2dd491b455e290eb3ab8bfc45c6e1" + dependencies: + ini "^1.3.4" + is-windows "^0.2.0" + osenv "^0.1.3" + which "^1.2.10" + +globals@^9.0.0: + version "9.12.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.12.0.tgz#992ce90828c3a55fa8f16fada177adb64664cf9d" + +globule@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/globule/-/globule-0.1.0.tgz#d9c8edde1da79d125a151b79533b978676346ae5" + dependencies: + glob "~3.1.21" + lodash "~1.0.1" + minimatch "~0.2.11" + +glogg@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/glogg/-/glogg-1.0.0.tgz#7fe0f199f57ac906cf512feead8f90ee4a284fc5" + dependencies: + sparkles "^1.0.0" + +graceful-fs@^3.0.0: + version "3.0.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" + dependencies: + natives "^1.1.0" + +graceful-fs@^4.0.0, graceful-fs@^4.1.2, graceful-fs@^4.1.4: + version "4.1.9" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.9.tgz#baacba37d19d11f9d146d3578bc99958c3787e29" + +graceful-fs@~1.2.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" + +"graceful-readlink@>= 1.0.0": + version "1.0.1" + resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" + +gulp-babel@^6.1.2: + version "6.1.2" + resolved "https://registry.yarnpkg.com/gulp-babel/-/gulp-babel-6.1.2.tgz#7c0176e4ba3f244c60588a0c4b320a45d1adefce" + dependencies: + babel-core "^6.0.2" + gulp-util "^3.0.0" + object-assign "^4.0.1" + replace-ext "0.0.1" + through2 "^2.0.0" + vinyl-sourcemaps-apply "^0.2.0" + +gulp-rename@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/gulp-rename/-/gulp-rename-1.2.2.tgz#3ad4428763f05e2764dec1c67d868db275687817" + +gulp-sourcemaps@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/gulp-sourcemaps/-/gulp-sourcemaps-1.6.0.tgz#b86ff349d801ceb56e1d9e7dc7bbcb4b7dee600c" + dependencies: + convert-source-map "^1.1.1" + graceful-fs "^4.1.2" + strip-bom "^2.0.0" + through2 "^2.0.0" + vinyl "^1.0.0" + +gulp-typescript@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/gulp-typescript/-/gulp-typescript-3.1.2.tgz#faf748991208efaf33c62010e2dce9e261117abd" + dependencies: + gulp-util "~3.0.7" + source-map "~0.5.3" + through2 "~2.0.1" + vinyl-fs "~2.4.3" + +gulp-util@^3.0.0, gulp-util@~3.0.7: + version "3.0.7" + resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.7.tgz#78925c4b8f8b49005ac01a011c557e6218941cbb" + dependencies: + array-differ "^1.0.0" + array-uniq "^1.0.2" + beeper "^1.0.0" + chalk "^1.0.0" + dateformat "^1.0.11" + fancy-log "^1.1.0" + gulplog "^1.0.0" + has-gulplog "^0.1.0" + lodash._reescape "^3.0.0" + lodash._reevaluate "^3.0.0" + lodash._reinterpolate "^3.0.0" + lodash.template "^3.0.0" + minimist "^1.1.0" + multipipe "^0.1.2" + object-assign "^3.0.0" + replace-ext "0.0.1" + through2 "^2.0.0" + vinyl "^0.5.0" + +gulp@^3.9.1: + version "3.9.1" + resolved "https://registry.yarnpkg.com/gulp/-/gulp-3.9.1.tgz#571ce45928dd40af6514fc4011866016c13845b4" + dependencies: + archy "^1.0.0" + chalk "^1.0.0" + deprecated "^0.0.1" + gulp-util "^3.0.0" + interpret "^1.0.0" + liftoff "^2.1.0" + minimist "^1.1.0" + orchestrator "^0.3.0" + pretty-hrtime "^1.0.0" + semver "^4.1.0" + tildify "^1.0.0" + v8flags "^2.0.2" + vinyl-fs "^0.3.0" + +gulplog@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/gulplog/-/gulplog-1.0.0.tgz#e28c4d45d05ecbbed818363ce8f9c5926229ffe5" + dependencies: + glogg "^1.0.0" + +har-validator@~2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" + dependencies: + chalk "^1.1.1" + commander "^2.9.0" + is-my-json-valid "^2.12.4" + pinkie-promise "^2.0.0" + +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + dependencies: + ansi-regex "^2.0.0" + +has-color@^0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/has-color/-/has-color-0.1.7.tgz#67144a5260c34fc3cca677d041daf52fe7b78b2f" + +has-gulplog@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" + dependencies: + sparkles "^1.0.0" + +has-unicode@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" + +hawk@~3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4" + dependencies: + boom "2.x.x" + cryptiles "2.x.x" + hoek "2.x.x" + sntp "1.x.x" + +hoek@2.x.x: + version "2.16.3" + resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed" + +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + +hosted-git-info@^2.1.4: + version "2.1.5" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.1.5.tgz#0ba81d90da2e25ab34a332e6ec77936e1598118b" + +http-signature@~1.1.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/http-signature/-/http-signature-1.1.1.tgz#df72e267066cd0ac67fb76adf8e134a8fbcf91bf" + dependencies: + assert-plus "^0.2.0" + jsprim "^1.2.2" + sshpk "^1.7.0" + +i@0.3.x: + version "0.3.5" + resolved "https://registry.yarnpkg.com/i/-/i-0.3.5.tgz#1d2b854158ec8169113c6cb7f6b6801e99e211d5" + +indent-string@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" + dependencies: + repeating "^2.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@^2.0.1, inherits@~2.0.0, inherits@~2.0.1, inherits@2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + +inherits@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-1.0.2.tgz#ca4309dadee6b54cc0b8d247e8d7c7a0975bdc9b" + +ini@^1.3.4, ini@~1.3.0: + version "1.3.4" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" + +inquirer@^1.1.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-1.2.2.tgz#f725c1316f0020e7f3d538c8c5ad0c2732c1c451" + dependencies: + ansi-escapes "^1.1.0" + chalk "^1.0.0" + cli-cursor "^1.0.1" + cli-width "^2.0.0" + external-editor "^1.1.0" + figures "^1.3.5" + lodash "^4.3.0" + mute-stream "0.0.6" + pinkie-promise "^2.0.0" + run-async "^2.2.0" + rx "^4.1.0" + string-width "^1.0.1" + strip-ansi "^3.0.0" + through "^2.3.6" + +interpret@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c" + +invariant@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.1.tgz#b097010547668c7e337028ebe816ebe36c8a8d54" + dependencies: + loose-envify "^1.0.0" + +is-absolute@^0.2.3: + version "0.2.6" + resolved "https://registry.yarnpkg.com/is-absolute/-/is-absolute-0.2.6.tgz#20de69f3db942ef2d87b9c2da36f172235b1b5eb" + dependencies: + is-relative "^0.2.1" + is-windows "^0.2.0" + +is-arrayish@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.0.2: + version "1.1.4" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.4.tgz#cfc86ccd5dc5a52fa80489111c6920c457e2d98b" + +is-builtin-module@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-builtin-module/-/is-builtin-module-1.0.0.tgz#540572d34f7ac3119f8f76c30cbc1b1e037affbe" + dependencies: + builtin-modules "^1.0.0" + +is-dotfile@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + +is-extglob@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.0.tgz#33411a482b046bf95e6b0cb27ee2711af4cf15ad" + +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + +is-fullwidth-code-point@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" + dependencies: + number-is-nan "^1.0.0" + +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + dependencies: + is-extglob "^2.1.0" + +is-my-json-valid@^2.12.4: + version "2.15.0" + resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.15.0.tgz#936edda3ca3c211fd98f3b2d3e08da43f7b2915b" + dependencies: + generate-function "^2.0.0" + generate-object-property "^1.1.0" + jsonpointer "^4.0.0" + xtend "^4.0.0" + +is-number@^2.0.2, is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + +is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + +is-property@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" + +is-relative@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-relative/-/is-relative-0.2.1.tgz#d27f4c7d516d175fb610db84bbeef23c3bc97aa5" + dependencies: + is-unc-path "^0.1.1" + +is-stream@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + +is-typedarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" + +is-unc-path@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-unc-path/-/is-unc-path-0.1.1.tgz#ab2533d77ad733561124c3dc0f5cd8b90054c86b" + dependencies: + unc-path-regex "^0.1.0" + +is-utf8@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72" + +is-valid-glob@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/is-valid-glob/-/is-valid-glob-0.3.0.tgz#d4b55c69f51886f9b65c70d6c2622d37e29f48fe" + +is-windows@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-0.2.0.tgz#de1aa6d63ea29dd248737b69f1ff8b8002d2108c" + +isarray@~1.0.0, isarray@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + +isarray@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" + +isexe@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-1.1.2.tgz#36f3e22e60750920f5e7241a476a8c6a42275ad0" + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + dependencies: + isarray "1.0.0" + +isstream@~0.1.2, isstream@0.1.x: + version "0.1.2" + resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" + +jodid25519@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" + dependencies: + jsbn "~0.1.0" + +js-tokens@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-2.0.0.tgz#79903f5563ee778cc1162e6dcf1a0027c97f9cb5" + +jsbn@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.0.tgz#650987da0dd74f4ebf5a11377a2aa2d273e97dfd" + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + +json-schema@0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" + +json-stable-stringify@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" + dependencies: + jsonify "~0.0.0" + +json-stringify-safe@~5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" + +json5@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.0.tgz#9b20715b026cbe3778fd769edccd822d8332a5b2" + +jsonify@~0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" + +jsonplus@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/jsonplus/-/jsonplus-1.2.1.tgz#f77ea4fc95b8bc929be673f19245e9ba1dc69296" + dependencies: + lodash "^3.10.1" + strip-json-comments "^1.0.4" + +jsonpointer@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.0.tgz#6661e161d2fc445f19f98430231343722e1fcbd5" + +jsprim@^1.2.2: + version "1.3.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.3.1.tgz#2a7256f70412a29ee3670aaca625994c4dcff252" + dependencies: + extsprintf "1.0.2" + json-schema "0.2.3" + verror "1.3.6" + +kind-of@^3.0.2: + version "3.0.4" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.0.4.tgz#7b8ecf18a4e17f8269d73b501c9f232c96887a74" + dependencies: + is-buffer "^1.0.2" + +lazystream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lazystream/-/lazystream-1.0.0.tgz#f6995fe0f820392f61396be89462407bb77168e4" + dependencies: + readable-stream "^2.0.5" + +liftoff@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.3.0.tgz#a98f2ff67183d8ba7cfaca10548bd7ff0550b385" + dependencies: + extend "^3.0.0" + findup-sync "^0.4.2" + fined "^1.0.1" + flagged-respawn "^0.3.2" + lodash.isplainobject "^4.0.4" + lodash.isstring "^4.0.1" + lodash.mapvalues "^4.4.0" + rechoir "^0.6.2" + resolve "^1.1.7" + +load-json-file@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" + dependencies: + graceful-fs "^4.1.2" + parse-json "^2.2.0" + pify "^2.0.0" + pinkie-promise "^2.0.0" + strip-bom "^2.0.0" + +lodash._basecopy@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz#8da0e6a876cf344c0ad8a54882111dd3c5c7ca36" + +lodash._basetostring@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz#d1861d877f824a52f669832dcaf3ee15566a07d5" + +lodash._basevalues@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._basevalues/-/lodash._basevalues-3.0.0.tgz#5b775762802bde3d3297503e26300820fdf661b7" + +lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + +lodash._isiterateecall@^3.0.0: + version "3.0.9" + resolved "https://registry.yarnpkg.com/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz#5203ad7ba425fae842460e696db9cf3e6aac057c" + +lodash._reescape@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reescape/-/lodash._reescape-3.0.0.tgz#2b1d6f5dfe07c8a355753e5f27fac7f1cde1616a" + +lodash._reevaluate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reevaluate/-/lodash._reevaluate-3.0.0.tgz#58bc74c40664953ae0b124d806996daca431e2ed" + +lodash._reinterpolate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + +lodash._root@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" + +lodash.assignwith@^4.0.7: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.assignwith/-/lodash.assignwith-4.2.0.tgz#127a97f02adc41751a954d24b0de17e100e038eb" + +lodash.escape@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/lodash.escape/-/lodash.escape-3.2.0.tgz#995ee0dc18c1b48cc92effae71a10aab5b487698" + dependencies: + lodash._root "^3.0.0" + +lodash.isarguments@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" + +lodash.isarray@^3.0.0: + version "3.0.4" + resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" + +lodash.isempty@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e" + +lodash.isequal@^4.0.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.4.0.tgz#6295768e98e14dc15ce8d362ef6340db82852031" + +lodash.isplainobject@^4.0.4: + version "4.0.6" + resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" + +lodash.isstring@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" + +lodash.keys@^3.0.0: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" + dependencies: + lodash._getnative "^3.0.0" + lodash.isarguments "^3.0.0" + lodash.isarray "^3.0.0" + +lodash.mapvalues@^4.4.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.mapvalues/-/lodash.mapvalues-4.6.0.tgz#1bafa5005de9dd6f4f26668c30ca37230cc9689c" + +lodash.pick@^4.2.1: + version "4.4.0" + resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" + +lodash.restparam@^3.0.0: + version "3.6.1" + resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" + +lodash.template@^3.0.0: + version "3.6.2" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-3.6.2.tgz#f8cdecc6169a255be9098ae8b0c53d378931d14f" + dependencies: + lodash._basecopy "^3.0.0" + lodash._basetostring "^3.0.0" + lodash._basevalues "^3.0.0" + lodash._isiterateecall "^3.0.0" + lodash._reinterpolate "^3.0.0" + lodash.escape "^3.0.0" + lodash.keys "^3.0.0" + lodash.restparam "^3.0.0" + lodash.templatesettings "^3.0.0" + +lodash.templatesettings@^3.0.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-3.1.1.tgz#fb307844753b66b9f1afa54e262c745307dba8e5" + dependencies: + lodash._reinterpolate "^3.0.0" + lodash.escape "^3.0.0" + +lodash@^3.10.1, lodash@3.x: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + +lodash@^4.2.0, lodash@^4.3.0: + version "4.16.6" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.16.6.tgz#d22c9ac660288f3843e16ba7d2b5d06cca27d777" + +lodash@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" + +lodash@~4.11.1: + version "4.11.2" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.11.2.tgz#d6b4338b110a58e21dae5cebcfdbbfd2bc4cdb3b" + +loose-envify@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.0.tgz#6b26248c42f6d4fa4b0d8542f78edfcde35642a8" + dependencies: + js-tokens "^2.0.0" + +loud-rejection@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/loud-rejection/-/loud-rejection-1.6.0.tgz#5b46f80147edee578870f086d04821cf998e551f" + dependencies: + currently-unhandled "^0.4.1" + signal-exit "^3.0.0" + +lru-cache@2: + version "2.7.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952" + +map-cache@^0.2.0: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + +map-obj@^1.0.0, map-obj@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" + +meow@^3.3.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/meow/-/meow-3.7.0.tgz#72cb668b425228290abbfa856892587308a801fb" + dependencies: + camelcase-keys "^2.0.0" + decamelize "^1.1.2" + loud-rejection "^1.0.0" + map-obj "^1.0.1" + minimist "^1.1.3" + normalize-package-data "^2.3.4" + object-assign "^4.0.1" + read-pkg-up "^1.0.1" + redent "^1.0.0" + trim-newlines "^1.0.0" + +merge-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-1.0.0.tgz#9cfd156fef35421e2b5403ce11dc6eb1962b026e" + dependencies: + readable-stream "^2.0.1" + +micromatch@^2.1.5, micromatch@^2.3.7: + version "2.3.11" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + +mime-db@~1.24.0: + version "1.24.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.24.0.tgz#e2d13f939f0016c6e4e9ad25a8652f126c467f0c" + +mime-types@^2.1.12, mime-types@~2.1.7: + version "2.1.12" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.12.tgz#152ba256777020dd4663f54c2e7bc26381e71729" + dependencies: + mime-db "~1.24.0" + +minimatch@^2.0.1: + version "2.0.10" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-2.0.10.tgz#8d087c39c6b38c001b97fca7ce6d0e1e80afbac7" + dependencies: + brace-expansion "^1.0.0" + +minimatch@^3.0.0, minimatch@^3.0.2, "minimatch@2 || 3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" + dependencies: + brace-expansion "^1.0.0" + +minimatch@~0.2.11: + version "0.2.14" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-0.2.14.tgz#c74e780574f63c6f9a090e90efbe6ef53a6a756a" + dependencies: + lru-cache "2" + sigmund "~1.0.0" + +minimist@^1.1.0, minimist@^1.1.3, minimist@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" + +minimist@0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d" + +mkdirp@^0.5.0, mkdirp@^0.5.1, "mkdirp@>=0.5 0", mkdirp@~0.5.1, mkdirp@0.x.x: + version "0.5.1" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" + dependencies: + minimist "0.0.8" + +moment@2.15.2: + version "2.15.2" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.15.2.tgz#1bfdedf6a6e345f322fe956d5df5bd08a8ce84dc" + +ms@0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" + +multipipe@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/multipipe/-/multipipe-0.1.2.tgz#2a8f2ddf70eed564dff2d57f1e1a137d9f05078b" + dependencies: + duplexer2 "0.0.2" + +mute-stream@~0.0.4, mute-stream@0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.6.tgz#48962b19e169fd1dfc240b3f1e7317627bbc47db" + +nan@^2.3.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.4.0.tgz#fb3c59d45fe4effe215f0b890f8adf6eb32d2232" + +natives@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.0.tgz#e9ff841418a6b2ec7a495e939984f78f163e6e31" + +ncp@1.0.x: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ncp/-/ncp-1.0.1.tgz#d15367e5cb87432ba117d2bf80fdf45aecfb4246" + +node-pre-gyp@^0.6.29: + version "0.6.31" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.31.tgz#d8a00ddaa301a940615dbcc8caad4024d58f6017" + dependencies: + mkdirp "~0.5.1" + nopt "~3.0.6" + npmlog "^4.0.0" + rc "~1.1.6" + request "^2.75.0" + rimraf "~2.5.4" + semver "~5.3.0" + tar "~2.2.1" + tar-pack "~3.3.0" + +node-uuid@~1.4.7: + version "1.4.7" + resolved "https://registry.yarnpkg.com/node-uuid/-/node-uuid-1.4.7.tgz#6da5a17668c4b3dd59623bda11cf7fa4c1f60a6f" + +nopt@~3.0.6: + version "3.0.6" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + dependencies: + abbrev "1" + +normalize-package-data@^2.3.2, normalize-package-data@^2.3.4: + version "2.3.5" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.5.tgz#8d924f142960e1777e7ffe170543631cc7cb02df" + dependencies: + hosted-git-info "^2.1.4" + is-builtin-module "^1.0.0" + semver "2 || 3 || 4 || 5" + validate-npm-package-license "^3.0.1" + +normalize-path@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.0.1.tgz#47886ac1662760d4261b7d979d241709d3ce3f7a" + +npmlog@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.0.tgz#e094503961c70c1774eb76692080e8d578a9f88f" + dependencies: + are-we-there-yet "~1.1.2" + console-control-strings "~1.1.0" + gauge "~2.6.0" + set-blocking "~2.0.0" + +number-is-nan@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d" + +oauth-sign@~0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43" + +object-assign@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-3.0.0.tgz#9bedd5ca0897949bca47e7ff408062d549f587f2" + +object-assign@^4.0.0, object-assign@^4.0.1, object-assign@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.0.tgz#7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0" + +object.omit@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + +observatory@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/observatory/-/observatory-1.0.0.tgz#2baa606e8299e6866914ec9c8a4db6a41136e59b" + dependencies: + ansi-escapes "^1.1.0" + chalk "^1.1.1" + lodash "^3.10.1" + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + dependencies: + wrappy "1" + +once@~1.3.0, once@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/once/-/once-1.3.3.tgz#b2e261557ce4c314ec8304f3fa82663e4297ca20" + dependencies: + wrappy "1" + +onetime@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" + +orchestrator@^0.3.0: + version "0.3.7" + resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.7.tgz#c45064e22c5a2a7b99734f409a95ffedc7d3c3df" + dependencies: + end-of-stream "~0.1.5" + sequencify "~0.0.7" + stream-consume "~0.1.0" + +ordered-read-streams@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.1.0.tgz#fd565a9af8eb4473ba69b6ed8a34352cb552f126" + +ordered-read-streams@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/ordered-read-streams/-/ordered-read-streams-0.3.0.tgz#7137e69b3298bb342247a1bbee3881c80e2fd78b" + dependencies: + is-stream "^1.0.1" + readable-stream "^2.0.1" + +os-homedir@^1.0.0, os-homedir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + +os-shim@^0.1.2: + version "0.1.3" + resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917" + +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + +osenv@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.3.tgz#83cf05c6d6458fc4d5ac6362ea325d92f2754217" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.0" + +output-file-sync@^1.1.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" + dependencies: + graceful-fs "^4.1.4" + mkdirp "^0.5.1" + object-assign "^4.1.0" + +parse-filepath@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/parse-filepath/-/parse-filepath-1.0.1.tgz#159d6155d43904d16c10ef698911da1e91969b73" + dependencies: + is-absolute "^0.2.3" + map-cache "^0.2.0" + path-root "^0.1.1" + +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + +parse-json@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" + dependencies: + error-ex "^1.2.0" + +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" + +path-exists@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-2.1.0.tgz#0feb6c64f0fc518d9a754dd5efb62c7022761f4b" + dependencies: + pinkie-promise "^2.0.0" + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + +path-root-regex@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/path-root-regex/-/path-root-regex-0.1.2.tgz#bfccdc8df5b12dc52c8b43ec38d18d72c04ba96d" + +path-root@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/path-root/-/path-root-0.1.1.tgz#9a4a6814cac1c0cd73360a95f32083c8ea4745b7" + dependencies: + path-root-regex "^0.1.0" + +path-type@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" + dependencies: + graceful-fs "^4.1.2" + pify "^2.0.0" + pinkie-promise "^2.0.0" + +pify@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c" + +pinkie-promise@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pinkie-promise/-/pinkie-promise-2.0.1.tgz#2135d6dfa7a358c069ac9b178776288228450ffa" + dependencies: + pinkie "^2.0.0" + +pinkie@^2.0.0: + version "2.0.4" + resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870" + +pkginfo@0.3.x: + version "0.3.1" + resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21" + +pkginfo@0.x.x: + version "0.4.0" + resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.0.tgz#349dbb7ffd38081fcadc0853df687f0c7744cd65" + +preserve@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + +pretty-hrtime@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/pretty-hrtime/-/pretty-hrtime-1.0.2.tgz#70ca96f4d0628a443b918758f79416a9a7bc9fa8" + +private@^0.1.6, private@~0.1.5: + version "0.1.6" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.6.tgz#55c6a976d0f9bafb9924851350fe47b9b5fbb7c1" + +process-nextick-args@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" + +prompt@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prompt/-/prompt-1.0.0.tgz#8e57123c396ab988897fb327fd3aedc3e735e4fe" + dependencies: + colors "^1.1.2" + pkginfo "0.x.x" + read "1.0.x" + revalidator "0.1.x" + utile "0.3.x" + winston "2.1.x" + +punycode@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + +qs@~6.3.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442" + +randomatic@^1.1.3: + version "1.1.5" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.5.tgz#5e9ef5f2d573c67bd2b8124ae90b5156e457840b" + dependencies: + is-number "^2.0.2" + kind-of "^3.0.2" + +rc@~1.1.6: + version "1.1.6" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.1.6.tgz#43651b76b6ae53b5c802f1151fa3fc3b059969c9" + dependencies: + deep-extend "~0.4.0" + ini "~1.3.0" + minimist "^1.2.0" + strip-json-comments "~1.0.4" + +read-pkg-up@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" + dependencies: + find-up "^1.0.0" + read-pkg "^1.0.0" + +read-pkg@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" + dependencies: + load-json-file "^1.0.0" + normalize-package-data "^2.3.2" + path-type "^1.0.0" + +read@1.0.x: + version "1.0.7" + resolved "https://registry.yarnpkg.com/read/-/read-1.0.7.tgz#b3da19bd052431a97671d44a42634adf710b40c4" + dependencies: + mute-stream "~0.0.4" + +readable-stream@^2.0.0, "readable-stream@^2.0.0 || ^1.1.13", readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.4, readable-stream@^2.0.5, readable-stream@~2.1.4: + version "2.1.5" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.1.5.tgz#66fa8b720e1438b364681f2ad1a63c618448c9d0" + dependencies: + buffer-shims "^1.0.0" + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.0: + version "1.0.34" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@~1.1.9: + version "1.1.14" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "0.0.1" + string_decoder "~0.10.x" + +readable-stream@~2.0.0: + version "2.0.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + +readdirp@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78" + dependencies: + graceful-fs "^4.1.2" + minimatch "^3.0.2" + readable-stream "^2.0.2" + set-immediate-shim "^1.0.1" + +rechoir@^0.6.2: + version "0.6.2" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.6.2.tgz#85204b54dba82d5742e28c96756ef43af50e3384" + dependencies: + resolve "^1.1.6" + +redent@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" + dependencies: + indent-string "^2.1.0" + strip-indent "^1.0.1" + +regenerate@^1.2.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.1.tgz#0300203a5d2fdcf89116dce84275d011f5903f33" + +regenerator-runtime@^0.9.5: + version "0.9.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.9.5.tgz#403d6d40a4bdff9c330dd9392dcbb2d9a8bba1fc" + +regex-cache@^0.4.2: + version "0.4.3" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + dependencies: + is-equal-shallow "^0.1.3" + is-primitive "^2.0.0" + +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + dependencies: + jsesc "~0.5.0" + +repeat-element@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" + +repeat-string@^1.5.2: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + +replace-ext@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" + +request@^2.75.0: + version "2.76.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.76.0.tgz#be44505afef70360a0436955106be3945d95560e" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.11.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~2.0.6" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + node-uuid "~1.4.7" + oauth-sign "~0.8.1" + qs "~6.3.0" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "~0.4.1" + +resolve-dir@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-0.1.1.tgz#b219259a5602fac5c5c496ad894a6e8cc430261e" + dependencies: + expand-tilde "^1.2.2" + global-modules "^0.2.3" + +resolve@^1.1.6, resolve@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + +restore-cursor@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" + dependencies: + exit-hook "^1.0.0" + onetime "^1.0.0" + +revalidator@0.1.x: + version "0.1.8" + resolved "https://registry.yarnpkg.com/revalidator/-/revalidator-0.1.8.tgz#fece61bfa0c1b52a206bd6b18198184bdd523a3b" + +rimraf@~2.5.1, rimraf@~2.5.4, rimraf@2, rimraf@2.x.x: + version "2.5.4" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.5.4.tgz#96800093cbf1a0c86bd95b4625467535c29dfa04" + dependencies: + glob "^7.0.5" + +run-async@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.2.0.tgz#8783abd83c7bb86f41ee0602fc82404b3bd6e8b9" + dependencies: + is-promise "^2.1.0" + pinkie-promise "^2.0.0" + +rx@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" + +scp2@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/scp2/-/scp2-0.5.0.tgz#64ee74bc3685f3a4c6290f2da8c1e3b4eef92e8d" + dependencies: + async "~0.9.0" + glob "~7.0.3" + lodash "~4.11.1" + ssh2 "~0.4.10" + +semver@^4.1.0: + version "4.3.6" + resolved "https://registry.yarnpkg.com/semver/-/semver-4.3.6.tgz#300bc6e0e86374f7ba61068b5b1ecd57fc6532da" + +semver@~5.3.0, "semver@2 || 3 || 4 || 5": + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + +sequencify@~0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/sequencify/-/sequencify-0.0.7.tgz#90cff19d02e07027fd767f5ead3e7b95d1e7380c" + +set-blocking@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + +set-immediate-shim@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" + +sigmund@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590" + +signal-exit@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.1.tgz#5a4c884992b63a7acd9badb7894c3ee9cfccad81" + +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + +sntp@1.x.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" + dependencies: + hoek "2.x.x" + +source-map-support@^0.4.2: + version "0.4.6" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.6.tgz#32552aa64b458392a85eab3b0b5ee61527167aeb" + dependencies: + source-map "^0.5.3" + +source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@~0.5.3: + version "0.5.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + +sparkles@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" + +spawn-sync@^1.0.15: + version "1.0.15" + resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476" + dependencies: + concat-stream "^1.4.7" + os-shim "^0.1.2" + +spdx-correct@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" + dependencies: + spdx-license-ids "^1.0.2" + +spdx-expression-parse@~1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" + +spdx-license-ids@^1.0.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" + +ssh2-streams@~0.0.22: + version "0.0.23" + resolved "https://registry.yarnpkg.com/ssh2-streams/-/ssh2-streams-0.0.23.tgz#aeef30831bb5fc4af6aa3f6d0a261a413531612b" + dependencies: + asn1 "~0.2.0" + readable-stream "~1.0.0" + streamsearch "~0.1.2" + +ssh2@~0.4.10: + version "0.4.15" + resolved "https://registry.yarnpkg.com/ssh2/-/ssh2-0.4.15.tgz#07c6f4106d9f7b6ea6e4df636c6c53f1f9817ff8" + dependencies: + readable-stream "~1.0.0" + ssh2-streams "~0.0.22" + +sshpk@^1.7.0: + version "1.10.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.10.1.tgz#30e1a5d329244974a1af61511339d595af6638b0" + dependencies: + asn1 "~0.2.3" + assert-plus "^1.0.0" + dashdash "^1.12.0" + getpass "^0.1.1" + optionalDependencies: + bcrypt-pbkdf "^1.0.0" + ecc-jsbn "~0.1.1" + jodid25519 "^1.0.0" + jsbn "~0.1.0" + tweetnacl "~0.14.0" + +stack-trace@0.0.x: + version "0.0.9" + resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.9.tgz#a8f6eaeca90674c333e7c43953f275b451510695" + +stream-consume@~0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/stream-consume/-/stream-consume-0.1.0.tgz#a41ead1a6d6081ceb79f65b061901b6d8f3d1d0f" + +stream-shift@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" + +streamsearch@~0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/streamsearch/-/streamsearch-0.1.2.tgz#808b9d0e56fc273d809ba57338e929919a1a9f1a" + +string_decoder@~0.10.x: + version "0.10.31" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" + +string-width@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3" + dependencies: + code-point-at "^1.0.0" + is-fullwidth-code-point "^1.0.0" + strip-ansi "^3.0.0" + +stringstream@~0.0.4: + version "0.0.5" + resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878" + +strip-ansi@^3.0.0, strip-ansi@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + dependencies: + ansi-regex "^2.0.0" + +strip-bom-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-bom-stream/-/strip-bom-stream-1.0.0.tgz#e7144398577d51a6bed0fa1994fa05f43fd988ee" + dependencies: + first-chunk-stream "^1.0.0" + strip-bom "^2.0.0" + +strip-bom@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-1.0.0.tgz#85b8862f3844b5a6d5ec8467a93598173a36f794" + dependencies: + first-chunk-stream "^1.0.0" + is-utf8 "^0.2.0" + +strip-bom@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" + dependencies: + is-utf8 "^0.2.0" + +strip-indent@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/strip-indent/-/strip-indent-1.0.1.tgz#0c7962a6adefa7bbd4ac366460a638552ae1a0a2" + dependencies: + get-stdin "^4.0.1" + +strip-json-comments@^1.0.4, strip-json-comments@~1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" + +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + +tar-pack@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.3.0.tgz#30931816418f55afc4d21775afdd6720cee45dae" + dependencies: + debug "~2.2.0" + fstream "~1.0.10" + fstream-ignore "~1.0.5" + once "~1.3.3" + readable-stream "~2.1.4" + rimraf "~2.5.1" + tar "~2.2.1" + uid-number "~0.0.6" + +tar@~2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-2.2.1.tgz#8e4d2a256c0e2185c6b18ad694aec968b83cb1d1" + dependencies: + block-stream "*" + fstream "^1.0.2" + inherits "2" + +through@^2.3.6: + version "2.3.8" + resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" + +through2-filter@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/through2-filter/-/through2-filter-2.0.0.tgz#60bc55a0dacb76085db1f9dae99ab43f83d622ec" + dependencies: + through2 "~2.0.0" + xtend "~4.0.0" + +through2@^0.6.0, through2@^0.6.1: + version "0.6.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" + dependencies: + readable-stream ">=1.0.33-1 <1.1.0-0" + xtend ">=4.0.0 <4.1.0-0" + +through2@^2.0.0, through2@~2.0.0, through2@~2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.1.tgz#384e75314d49f32de12eebb8136b8eb6b5d59da9" + dependencies: + readable-stream "~2.0.0" + xtend "~4.0.0" + +tildify@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/tildify/-/tildify-1.2.0.tgz#dcec03f55dca9b7aa3e5b04f21817eb56e63588a" + dependencies: + os-homedir "^1.0.0" + +time-stamp@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-1.0.1.tgz#9f4bd23559c9365966f3302dbba2b07c6b99b151" + +tmp@^0.0.29: + version "0.0.29" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.29.tgz#f25125ff0dd9da3ccb0c2dd371ee1288bb9128c0" + dependencies: + os-tmpdir "~1.0.1" + +to-absolute-glob@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/to-absolute-glob/-/to-absolute-glob-0.1.1.tgz#1cdfa472a9ef50c239ee66999b662ca0eb39937f" + dependencies: + extend-shallow "^2.0.1" + +to-fast-properties@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" + +tough-cookie@~2.3.0: + version "2.3.2" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + dependencies: + punycode "^1.4.1" + +trim-newlines@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/trim-newlines/-/trim-newlines-1.0.0.tgz#5887966bb582a4503a41eb524f7d35011815a613" + +tunnel-agent@~0.4.1: + version "0.4.3" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" + +tweetnacl@^0.14.3, tweetnacl@~0.14.0: + version "0.14.3" + resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-0.14.3.tgz#3da382f670f25ded78d7b3d1792119bca0b7132d" + +typedarray@~0.0.5: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + +typescript@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.0.6.tgz#5385499ac9811508c2c43e0ea07a1ddca435e111" + +uid-number@~0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81" + +unc-path-regex@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" + +underscore.string@2.3.x: + version "2.3.3" + resolved "https://registry.yarnpkg.com/underscore.string/-/underscore.string-2.3.3.tgz#71c08bf6b428b1133f37e78fa3a21c82f7329b0d" + +unique-stream@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-1.0.0.tgz#d59a4a75427447d9aa6c91e70263f8d26a4b104b" + +unique-stream@^2.0.2: + version "2.2.1" + resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.2.1.tgz#5aa003cfbe94c5ff866c4e7d668bb1c4dbadb369" + dependencies: + json-stable-stringify "^1.0.0" + through2-filter "^2.0.0" + +upath@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/upath/-/upath-0.2.0.tgz#bdbad0f2c60afea165f8127dbb1b5bdee500ad81" + dependencies: + lodash "3.x" + underscore.string "2.3.x" + +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + +util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + +utile@0.3.x: + version "0.3.0" + resolved "https://registry.yarnpkg.com/utile/-/utile-0.3.0.tgz#1352c340eb820e4d8ddba039a4fbfaa32ed4ef3a" + dependencies: + async "~0.9.0" + deep-equal "~0.2.1" + i "0.3.x" + mkdirp "0.x.x" + ncp "1.0.x" + rimraf "2.x.x" + +v8flags@^2.0.10, v8flags@^2.0.2: + version "2.0.11" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881" + dependencies: + user-home "^1.1.1" + +vali-date@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/vali-date/-/vali-date-1.0.0.tgz#1b904a59609fb328ef078138420934f6b86709a6" + +validate-npm-package-license@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + dependencies: + spdx-correct "~1.0.0" + spdx-expression-parse "~1.0.0" + +verror@1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" + dependencies: + extsprintf "1.0.2" + +vinyl-fs@^0.3.0: + version "0.3.14" + resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-0.3.14.tgz#9a6851ce1cac1c1cea5fe86c0931d620c2cfa9e6" + dependencies: + defaults "^1.0.0" + glob-stream "^3.1.5" + glob-watcher "^0.0.6" + graceful-fs "^3.0.0" + mkdirp "^0.5.0" + strip-bom "^1.0.0" + through2 "^0.6.1" + vinyl "^0.4.0" + +vinyl-fs@~2.4.3: + version "2.4.4" + resolved "https://registry.yarnpkg.com/vinyl-fs/-/vinyl-fs-2.4.4.tgz#be6ff3270cb55dfd7d3063640de81f25d7532239" + dependencies: + duplexify "^3.2.0" + glob-stream "^5.3.2" + graceful-fs "^4.0.0" + gulp-sourcemaps "1.6.0" + is-valid-glob "^0.3.0" + lazystream "^1.0.0" + lodash.isequal "^4.0.0" + merge-stream "^1.0.0" + mkdirp "^0.5.0" + object-assign "^4.0.0" + readable-stream "^2.0.4" + strip-bom "^2.0.0" + strip-bom-stream "^1.0.0" + through2 "^2.0.0" + through2-filter "^2.0.0" + vali-date "^1.0.0" + vinyl "^1.0.0" + +vinyl-sourcemaps-apply@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705" + dependencies: + source-map "^0.5.1" + +vinyl@^0.4.0: + version "0.4.6" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.4.6.tgz#2f356c87a550a255461f36bbeb2a5ba8bf784847" + dependencies: + clone "^0.2.0" + clone-stats "^0.0.1" + +vinyl@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-0.5.3.tgz#b0455b38fc5e0cf30d4325132e461970c2091cde" + dependencies: + clone "^1.0.0" + clone-stats "^0.0.1" + replace-ext "0.0.1" + +vinyl@^1.0.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-1.2.0.tgz#5c88036cf565e5df05558bfc911f8656df218884" + dependencies: + clone "^1.0.0" + clone-stats "^0.0.1" + replace-ext "0.0.1" + +which@^1.2.10: + version "1.2.11" + resolved "https://registry.yarnpkg.com/which/-/which-1.2.11.tgz#c8b2eeea6b8c1659fa7c1dd4fdaabe9533dc5e8b" + dependencies: + isexe "^1.1.1" + +wide-align@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + dependencies: + string-width "^1.0.1" + +winston@2.1.x: + version "2.1.1" + resolved "https://registry.yarnpkg.com/winston/-/winston-2.1.1.tgz#3c9349d196207fd1bdff9d4bc43ef72510e3a12e" + dependencies: + async "~1.0.0" + colors "1.0.x" + cycle "1.0.x" + eyes "0.1.x" + isstream "0.1.x" + pkginfo "0.3.x" + stack-trace "0.0.x" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + +xtend@^4.0.0, "xtend@>=4.0.0 <4.1.0-0", xtend@~4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af" + From 6879adc008d7801c06c1815db4d98dda0ec27a58 Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 2 Nov 2016 15:06:11 -0700 Subject: [PATCH 45/49] clean old types --- src/classes/CLI.ts | 5 +- src/classes/InitConfig.ts | 4 +- typings/chalk/chalk.d.ts | 93 -- typings/chokidar/chokidar.d.ts | 42 - typings/inquirer/inquirer.d.ts | 300 ----- typings/minimist/minimist.d.ts | 38 - typings/moment/moment-node.d.ts | 479 ------- typings/moment/moment.d.ts | 8 - typings/node/node.d.ts | 2112 ------------------------------- typings/rx/rx-lite.d.ts | 635 ---------- typings/through/through.d.ts | 24 - typings/tsd.d.ts | 6 - 12 files changed, 5 insertions(+), 3741 deletions(-) delete mode 100644 typings/chalk/chalk.d.ts delete mode 100644 typings/chokidar/chokidar.d.ts delete mode 100644 typings/inquirer/inquirer.d.ts delete mode 100644 typings/minimist/minimist.d.ts delete mode 100644 typings/moment/moment-node.d.ts delete mode 100644 typings/moment/moment.d.ts delete mode 100644 typings/node/node.d.ts delete mode 100644 typings/rx/rx-lite.d.ts delete mode 100644 typings/through/through.d.ts diff --git a/src/classes/CLI.ts b/src/classes/CLI.ts index e3efb49..3baf588 100644 --- a/src/classes/CLI.ts +++ b/src/classes/CLI.ts @@ -79,7 +79,7 @@ export default class CLI { /** * Write something to terminal */ - write(msg: string | Chalk.ChalkChain): boolean { + write(msg: string | chalk.ChalkChain): boolean { return process.stdout.write.bind(process.stdout)(msg); } @@ -96,7 +96,8 @@ export default class CLI { name: "response" }; - let promise = inquirer.prompt(scheme); + // Bad type definition + let promise = inquirer.prompt(scheme); this.ui.push(promise['ui']); return promise.then((answer) => { diff --git a/src/classes/InitConfig.ts b/src/classes/InitConfig.ts index 3ae3465..7813ed1 100644 --- a/src/classes/InitConfig.ts +++ b/src/classes/InitConfig.ts @@ -96,7 +96,7 @@ export default class InitConfig2 { } ]; - inquirer.prompt(questions).then((answers) => { + inquirer.prompt(questions)['then']((answers) => { let pass; // if default, don't put it in config if (answers.port == "use default") { @@ -115,7 +115,7 @@ export default class InitConfig2 { type: "confirm", name: "yes", message: `${JSON.stringify(answers, null, 4)}\nDoes this look good?` - }).then((answer) => { + })['then']((answer) => { if (answer.yes) { if (pass) { answers.password = pass; diff --git a/typings/chalk/chalk.d.ts b/typings/chalk/chalk.d.ts deleted file mode 100644 index ede2947..0000000 --- a/typings/chalk/chalk.d.ts +++ /dev/null @@ -1,93 +0,0 @@ -// Type definitions for chalk v0.4.0 -// Project: https://github.com/sindresorhus/chalk -// Definitions by: Diullei Gomes , Bart van der Schoor -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module Chalk { - export interface ChalkModule extends ChalkStyle { - enabled: boolean; - supportsColor: boolean; - styles: ChalkStyleMap; - - stripColor(value: string): any; - hasColor(str: string): boolean; - } - - export interface ChalkChain extends ChalkStyle { - (...text: string[]): ChalkChain; - } - - export interface ChalkStyleElement { - open: string; - close: string; - } - - export interface ChalkStyle { - // General - reset: ChalkChain; - bold: ChalkChain; - italic: ChalkChain; - underline: ChalkChain; - inverse: ChalkChain; - strikethrough: ChalkChain; - - // Text colors - black: ChalkChain; - red: ChalkChain; - green: ChalkChain; - yellow: ChalkChain; - blue: ChalkChain; - magenta: ChalkChain; - cyan: ChalkChain; - white: ChalkChain; - gray: ChalkChain; - grey: ChalkChain; - - // Background colors - bgBlack: ChalkChain; - bgRed: ChalkChain; - bgGreen: ChalkChain; - bgYellow: ChalkChain; - bgBlue: ChalkChain; - bgMagenta: ChalkChain; - bgCyan: ChalkChain; - bgWhite: ChalkChain; - } - - export interface ChalkStyleMap { - // General - reset: ChalkStyleElement; - bold: ChalkStyleElement; - italic: ChalkStyleElement; - underline: ChalkStyleElement; - inverse: ChalkStyleElement; - strikethrough: ChalkStyleElement; - - // Text colors - black: ChalkStyleElement; - red: ChalkStyleElement; - green: ChalkStyleElement; - yellow: ChalkStyleElement; - blue: ChalkStyleElement; - magenta: ChalkStyleElement; - cyan: ChalkStyleElement; - white: ChalkStyleElement; - gray: ChalkStyleElement; - - // Background colors - bgBlack: ChalkStyleElement; - bgRed: ChalkStyleElement; - bgGreen: ChalkStyleElement; - bgYellow: ChalkStyleElement; - bgBlue: ChalkStyleElement; - bgMagenta: ChalkStyleElement; - bgCyan: ChalkStyleElement; - bgWhite: ChalkStyleElement; - } -} - -declare module "chalk" { - var ch: Chalk.ChalkModule; - export = ch; -} - diff --git a/typings/chokidar/chokidar.d.ts b/typings/chokidar/chokidar.d.ts deleted file mode 100644 index 6a417ca..0000000 --- a/typings/chokidar/chokidar.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Type definitions for chokidar 1.0.0 -// Project: https://github.com/paulmillr/chokidar -// Definitions by: Stefan Steinhart -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare module "fs" -{ - interface FSWatcher - { - add(fileDirOrGlob:string):void; - add(filesDirsOrGlobs:Array):void; - unwatch(fileDirOrGlob:string):void; - unwatch(filesDirsOrGlobs:Array):void; - } -} - -declare module "chokidar" -{ - interface WatchOptions - { - persistent?:boolean; - ignored?:any; - ignoreInitial?:boolean; - followSymlinks?:boolean; - cwd?:string; - usePolling?:boolean; - useFsEvents?:boolean; - alwaysStat?:boolean; - depth?:number; - interval?:number; - binaryInterval?:number; - ignorePermissionErrors?:boolean; - atomic?:boolean; - } - - import fs = require("fs"); - - function watch( fileDirOrGlob:string, options?:WatchOptions ):fs.FSWatcher; - function watch( filesDirsOrGlobs:Array, options?:WatchOptions ):fs.FSWatcher; -} diff --git a/typings/inquirer/inquirer.d.ts b/typings/inquirer/inquirer.d.ts deleted file mode 100644 index caba259..0000000 --- a/typings/inquirer/inquirer.d.ts +++ /dev/null @@ -1,300 +0,0 @@ -// Type definitions for Inquirer.js -// Project: https://github.com/SBoudrias/Inquirer.js -// Definitions by: Qubo -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// -/// - -declare module "inquirer" { - import through = require('through'); - - namespace inquirer { - type Prompts = { [name: string]: PromptModule }; - type ChoiceType = string|objects.ChoiceOption|objects.Separator; - type Questions = Question|Question[]|Rx.Observable; - - interface Inquirer { - restoreDefaultPrompts(): void; - /** - * Expose helper functions on the top level for easiest usage by common users - * @param name - * @param prompt - */ - registerPrompt(name: string, prompt: PromptModule): void; - /** - * Create a new self-contained prompt module. - */ - createPromptModule(): PromptModule; - /** - * Public CLI helper interface - * @param questions Questions settings array - * @param cb Callback being passed the user answers - * @return - */ - prompt(questions: Questions, cb?: (answers: Answers) => any): ui.Prompt; - prompts: Prompts; - Separator: objects.SeparatorStatic; - ui: { - BottomBar: ui.BottomBar; - Prompt: ui.Prompt; - } - } - - interface PromptModule { - (questions: Questions, cb: (answers: Answers) => any): ui.Prompt; - /** - * Register a prompt type - * @param name Prompt type name - * @param prompt Prompt constructor - */ - registerPrompt(name: string, prompt: PromptModule): ui.Prompt; - /** - * Register the defaults provider prompts - */ - restoreDefaultPrompts(): void; - } - - interface Question { - /** - * Type of the prompt. - * Possible values: - *
    - *
  • input
  • - *
  • confirm
  • - *
  • list
  • - *
  • rawlist
  • - *
  • password
  • - *
- * @defaults: 'input' - */ - type?: string; - /** - * The name to use when storing the answer in the anwers hash. - */ - name?: string; - /** - * The question to print. If defined as a function, - * the first parameter will be the current inquirer session answers. - */ - message?: string|((answers: Answers) => string); - /** - * Default value(s) to use if nothing is entered, or a function that returns the default value(s). - * If defined as a function, the first parameter will be the current inquirer session answers. - */ - default?: any|((answers: Answers) => any); - /** - * Choices array or a function returning a choices array. If defined as a function, - * the first parameter will be the current inquirer session answers. - * Array values can be simple strings, or objects containing a name (to display) and a value properties - * (to save in the answers hash). Values can also be a Separator. - */ - choices?: ChoiceType[]|((answers: Answers) => ChoiceType[]); - /** - * Receive the user input and should return true if the value is valid, and an error message (String) - * otherwise. If false is returned, a default error message is provided. - */ - validate?(input: string): boolean|string; - /** - * Receive the user input and return the filtered value to be used inside the program. - * The value returned will be added to the Answers hash. - */ - filter?(input: string): string; - /** - * Receive the current user answers hash and should return true or false depending on whether or - * not this question should be asked. The value can also be a simple boolean. - */ - when?: boolean|((answers: Answers) => boolean); - paginated?: boolean; - } - - /** - * A key/value hash containing the client answers in each prompt. - */ - interface Answers { - [key: string]: string|boolean; - } - - namespace ui { - /** - * Base interface class other can inherits from - */ - interface Prompt extends BaseUI { - new(promptModule: Prompts): Prompt; - /** - * Once all prompt are over - */ - onCompletion(): void; - processQuestion(question: Question): any; - fetchAnswer(question: Question): any; - setDefaultType(question: Question): any; - filterIfRunnable(question: Question): any; - then(cb:any): any - } - - /** - * Sticky bottom bar user interface - */ - interface BottomBar extends BaseUI { - new(opt?: BottomBarOption): BottomBar; - /** - * Render the prompt to screen - * @return self - */ - render(): BottomBar; - /** - * Update the bottom bar content and rerender - * @param bottomBar Bottom bar content - * @return self - */ - updateBottomBar(bottomBar: string): BottomBar; - /** - * Rerender the prompt - * @return self - */ - writeLog(data: any): BottomBar; - /** - * Make sure line end on a line feed - * @param str Input string - * @return The input string with a final line feed - */ - enforceLF(str: string): string; - /** - * Helper for writing message in Prompt - * @param message The message to be output - */ - write(message: string): void; - log: through.ThroughStream; - } - - interface BottomBarOption { - bottomBar?: string; - } - /** - * Base interface class other can inherits from - */ - interface BaseUI { - new(opt: TOpt): void; - /** - * Handle the ^C exit - * @return {null} - */ - onForceClose(): void; - /** - * Close the interface and cleanup listeners - */ - close(): void; - /** - * Handle and propagate keypress events - */ - onKeypress(s: string, key: Key): void; - } - - interface Key { - sequence: string; - name: string; - meta: boolean; - shift: boolean; - ctrl: boolean; - } - } - - namespace objects { - /** - * Choice object - * Normalize input as choice object - * @constructor - * @param {String|Object} val Choice value. If an object is passed, it should contains - * at least one of `value` or `name` property - */ - interface Choice { - new(str: string): Choice; - new(separator: Separator): Choice; - new(option: ChoiceOption): Choice; - } - - interface ChoiceOption { - name?: string; - value?: string; - type?: string; - extra?: any; - key?: string; - checked?: boolean; - disabled?: string|((answers: Answers) => any); - } - - /** - * Choices collection - * Collection of multiple `choice` object - * @constructor - * @param choices All `choice` to keep in the collection - */ - interface Choices { - new(choices: (string|Separator|ChoiceOption)[], answers?: Answers): Choices; - choices: Choice[]; - realChoices: Choice[]; - length: number; - realLength: number; - /** - * Get a valid choice from the collection - * @param selector The selected choice index - * @return Return the matched choice or undefined - */ - getChoice(selector: number): Choice; - /** - * Get a raw element from the collection - * @param selector The selected index value - * @return Return the matched choice or undefined - */ - get(selector: number): Choice; - /** - * Match the valid choices against a where clause - * @param whereClause Lodash `where` clause - * @return Matching choices or empty array - */ - where(whereClause: U): Choice[]; - /** - * Pluck a particular key from the choices - * @param propertyName Property name to select - * @return Selected properties - */ - pluck(propertyName: string): any[]; - forEach(application: (choice: Choice) => T): T[]; - } - - interface SeparatorStatic { - /** - * @param line Separation line content (facultative) - */ - new(line?: string): Separator; - /** - * Helper function returning false if object is a separator - * @param obj object to test against - * @return `false` if object is a separator - */ - exclude(obj: any): boolean; - } - - /** - * Separator object - * Used to space/separate choices group - * @constructor - * @param {String} line Separation line content (facultative) - */ - interface Separator { - type: string; - line: string; - /** - * Stringify separator - * @return {String} the separator display string - */ - toString(): string; - } - } - } - - var inquirer: inquirer.Inquirer; - - export = inquirer; -} - diff --git a/typings/minimist/minimist.d.ts b/typings/minimist/minimist.d.ts deleted file mode 100644 index abbc5f0..0000000 --- a/typings/minimist/minimist.d.ts +++ /dev/null @@ -1,38 +0,0 @@ -// Type definitions for minimist 1.1.3 -// Project: https://github.com/substack/minimist -// Definitions by: Bart van der Schoor , Necroskillz -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module 'minimist' { - function minimist(args?: string[], opts?: minimist.Opts): minimist.ParsedArgs; - - module minimist { - export interface Opts { - // a string or array of strings argument names to always treat as strings - // string?: string; - string?: string|string[]; - // a string or array of strings to always treat as booleans - // boolean?: string; - boolean?: boolean|string|string[]; - // an object mapping string names to strings or arrays of string argument names to use - // alias?: {[key:string]: string}; - alias?: {[key:string]: string[]}; - // an object mapping string argument names to default values - default?: {[key:string]: any}; - // when true, populate argv._ with everything after the first non-option - stopEarly?: boolean; - // a function which is invoked with a command line parameter not defined in the opts configuration object. - // If the function returns false, the unknown option is not added to argv - unknown?: (arg: string) => boolean; - // when true, populate argv._ with everything before the -- and argv['--'] with everything after the -- - '--'?: boolean; - } - - export interface ParsedArgs { - [arg: string]: any; - _: string[]; - } - } - - export = minimist; -} diff --git a/typings/moment/moment-node.d.ts b/typings/moment/moment-node.d.ts deleted file mode 100644 index babde41..0000000 --- a/typings/moment/moment-node.d.ts +++ /dev/null @@ -1,479 +0,0 @@ -// Type definitions for Moment.js 2.8.0 -// Project: https://github.com/timrwood/moment -// Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -declare module moment { - - interface MomentInput { - /** Year */ - years?: number; - /** Year */ - year?: number; - /** Year */ - y?: number; - - /** Month */ - months?: number; - /** Month */ - month?: number; - /** Month */ - M?: number; - - /** Week */ - weeks?: number; - /** Week */ - week?: number; - /** Week */ - w?: number; - - /** Day/Date */ - days?: number; - /** Day/Date */ - day?: number; - /** Day/Date */ - date?: number; - /** Day/Date */ - d?: number; - - /** Hour */ - hours?: number; - /** Hour */ - hour?: number; - /** Hour */ - h?: number; - - /** Minute */ - minutes?: number; - /** Minute */ - minute?: number; - /** Minute */ - m?: number; - - /** Second */ - seconds?: number; - /** Second */ - second?: number; - /** Second */ - s?: number; - - /** Millisecond */ - milliseconds?: number; - /** Millisecond */ - millisecond?: number; - /** Millisecond */ - ms?: number; - } - - interface Duration { - humanize(withSuffix?: boolean): string; - - as(units: string): number; - - milliseconds(): number; - asMilliseconds(): number; - - seconds(): number; - asSeconds(): number; - - minutes(): number; - asMinutes(): number; - - hours(): number; - asHours(): number; - - days(): number; - asDays(): number; - - months(): number; - asMonths(): number; - - years(): number; - asYears(): number; - - add(n: number, p: string): Duration; - add(n: number): Duration; - add(d: Duration): Duration; - - subtract(n: number, p: string): Duration; - subtract(n: number): Duration; - subtract(d: Duration): Duration; - - toISOString(): string; - toJSON(): string; - } - - interface Moment { - format(format: string): string; - format(): string; - - fromNow(withoutSuffix?: boolean): string; - - startOf(unitOfTime: string): Moment; - endOf(unitOfTime: string): Moment; - - /** - * Mutates the original moment by adding time. (deprecated in 2.8.0) - * - * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) - * @param amount the amount you want to add - */ - add(unitOfTime: string, amount: number): Moment; - /** - * Mutates the original moment by adding time. - * - * @param amount the amount you want to add - * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) - */ - add(amount: number, unitOfTime: string): Moment; - /** - * Mutates the original moment by adding time. Note that the order of arguments can be flipped. - * - * @param amount the amount you want to add - * @param unitOfTime the unit of time you want to add (eg "years" / "hours" etc) - */ - add(amount: string, unitOfTime: string): Moment; - /** - * Mutates the original moment by adding time. - * - * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} - */ - add(objectLiteral: MomentInput): Moment; - /** - * Mutates the original moment by adding time. - * - * @param duration a length of time - */ - add(duration: Duration): Moment; - - /** - * Mutates the original moment by subtracting time. (deprecated in 2.8.0) - * - * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) - * @param amount the amount you want to subtract - */ - subtract(unitOfTime: string, amount: number): Moment; - /** - * Mutates the original moment by subtracting time. - * - * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) - * @param amount the amount you want to subtract - */ - subtract(amount: number, unitOfTime: string): Moment; - /** - * Mutates the original moment by subtracting time. Note that the order of arguments can be flipped. - * - * @param amount the amount you want to add - * @param unitOfTime the unit of time you want to subtract (eg "years" / "hours" etc) - */ - subtract(amount: string, unitOfTime: string): Moment; - /** - * Mutates the original moment by subtracting time. - * - * @param objectLiteral an object literal that describes multiple time units {days:7,months:1} - */ - subtract(objectLiteral: MomentInput): Moment; - /** - * Mutates the original moment by subtracting time. - * - * @param duration a length of time - */ - subtract(duration: Duration): Moment; - - calendar(): string; - calendar(start: Moment): string; - calendar(start: Moment, formats: MomentCalendar): string; - - clone(): Moment; - - /** - * @return Unix timestamp, or milliseconds since the epoch. - */ - valueOf(): number; - - local(): Moment; // current date/time in local mode - - utc(): Moment; // current date/time in UTC mode - - isValid(): boolean; - invalidAt(): number; - - year(y: number): Moment; - year(): number; - quarter(): number; - quarter(q: number): Moment; - month(M: number): Moment; - month(M: string): Moment; - month(): number; - day(d: number): Moment; - day(d: string): Moment; - day(): number; - date(d: number): Moment; - date(): number; - hour(h: number): Moment; - hour(): number; - hours(h: number): Moment; - hours(): number; - minute(m: number): Moment; - minute(): number; - minutes(m: number): Moment; - minutes(): number; - second(s: number): Moment; - second(): number; - seconds(s: number): Moment; - seconds(): number; - millisecond(ms: number): Moment; - millisecond(): number; - milliseconds(ms: number): Moment; - milliseconds(): number; - weekday(): number; - weekday(d: number): Moment; - isoWeekday(): number; - isoWeekday(d: number): Moment; - weekYear(): number; - weekYear(d: number): Moment; - isoWeekYear(): number; - isoWeekYear(d: number): Moment; - week(): number; - week(d: number): Moment; - weeks(): number; - weeks(d: number): Moment; - isoWeek(): number; - isoWeek(d: number): Moment; - isoWeeks(): number; - isoWeeks(d: number): Moment; - weeksInYear(): number; - isoWeeksInYear(): number; - dayOfYear(): number; - dayOfYear(d: number): Moment; - - from(f: Moment|string|number|Date|number[], suffix?: boolean): string; - to(f: Moment|string|number|Date|number[], suffix?: boolean): string; - toNow(withoutPrefix?: boolean): string; - - diff(b: Moment): number; - diff(b: Moment, unitOfTime: string): number; - diff(b: Moment, unitOfTime: string, round: boolean): number; - - toArray(): number[]; - toDate(): Date; - toISOString(): string; - toJSON(): string; - unix(): number; - - isLeapYear(): boolean; - zone(): number; - zone(b: number): Moment; - zone(b: string): Moment; - utcOffset(): number; - utcOffset(b: number): Moment; - utcOffset(b: string): Moment; - daysInMonth(): number; - isDST(): boolean; - - isBefore(): boolean; - isBefore(b: Moment|string|number|Date|number[], granularity?: string): boolean; - - isAfter(): boolean; - isAfter(b: Moment|string|number|Date|number[], granularity?: string): boolean; - - isSame(b: Moment|string|number|Date|number[], granularity?: string): boolean; - isBetween(a: Moment|string|number|Date|number[], b: Moment|string|number|Date|number[], granularity?: string): boolean; - - // Deprecated as of 2.8.0. - lang(language: string): Moment; - lang(reset: boolean): Moment; - lang(): MomentLanguage; - - locale(language: string): Moment; - locale(reset: boolean): Moment; - locale(): string; - - localeData(language: string): Moment; - localeData(reset: boolean): Moment; - localeData(): MomentLanguage; - - // Deprecated as of 2.7.0. - max(date: Moment|string|number|Date|any[]): Moment; - max(date: string, format: string): Moment; - - // Deprecated as of 2.7.0. - min(date: Moment|string|number|Date|any[]): Moment; - min(date: string, format: string): Moment; - - get(unit: string): number; - set(unit: string, value: number): Moment; - set(objectLiteral: MomentInput): Moment; - } - - type formatFunction = () => string; - - interface MomentCalendar { - lastDay?: string | formatFunction; - sameDay?: string | formatFunction; - nextDay?: string | formatFunction; - lastWeek?: string | formatFunction; - nextWeek?: string | formatFunction; - sameElse?: string | formatFunction; - } - - interface BaseMomentLanguage { - months ?: any; - monthsShort ?: any; - weekdays ?: any; - weekdaysShort ?: any; - weekdaysMin ?: any; - relativeTime ?: MomentRelativeTime; - meridiem ?: (hour: number, minute: number, isLowercase: boolean) => string; - calendar ?: MomentCalendar; - ordinal ?: (num: number) => string; - } - - interface MomentLanguage extends BaseMomentLanguage { - longDateFormat?: MomentLongDateFormat; - } - - interface MomentLanguageData extends BaseMomentLanguage { - /** - * @param formatType should be L, LL, LLL, LLLL. - */ - longDateFormat(formatType: string): string; - } - - interface MomentLongDateFormat { - L: string; - LL: string; - LLL: string; - LLLL: string; - LT: string; - LTS: string; - l?: string; - ll?: string; - lll?: string; - llll?: string; - lt?: string; - lts?: string; - } - - interface MomentRelativeTime { - future: any; - past: any; - s: any; - m: any; - mm: any; - h: any; - hh: any; - d: any; - dd: any; - M: any; - MM: any; - y: any; - yy: any; - } - - interface MomentStatic { - version: string; - fn: Moment; - - (): Moment; - (date: number): Moment; - (date: number[]): Moment; - (date: string, format?: string, strict?: boolean): Moment; - (date: string, format?: string, language?: string, strict?: boolean): Moment; - (date: string, formats: string[], strict?: boolean): Moment; - (date: string, formats: string[], language?: string, strict?: boolean): Moment; - (date: string, specialFormat: () => void, strict?: boolean): Moment; - (date: string, specialFormat: () => void, language?: string, strict?: boolean): Moment; - (date: string, formatsIncludingSpecial: any[], strict?: boolean): Moment; - (date: string, formatsIncludingSpecial: any[], language?: string, strict?: boolean): Moment; - (date: Date): Moment; - (date: Moment): Moment; - (date: Object): Moment; - - utc(): Moment; - utc(date: number): Moment; - utc(date: number[]): Moment; - utc(date: string, format?: string, strict?: boolean): Moment; - utc(date: string, format?: string, language?: string, strict?: boolean): Moment; - utc(date: string, formats: string[], strict?: boolean): Moment; - utc(date: string, formats: string[], language?: string, strict?: boolean): Moment; - utc(date: Date): Moment; - utc(date: Moment): Moment; - utc(date: Object): Moment; - - unix(timestamp: number): Moment; - - invalid(parsingFlags?: Object): Moment; - isMoment(): boolean; - isMoment(m: any): boolean; - isDate(m: any): boolean; - isDuration(): boolean; - isDuration(d: any): boolean; - - // Deprecated in 2.8.0. - lang(language?: string): string; - lang(language?: string, definition?: MomentLanguage): string; - - locale(language?: string): string; - locale(language?: string[]): string; - locale(language?: string, definition?: MomentLanguage): string; - - localeData(language?: string): MomentLanguageData; - - longDateFormat: any; - relativeTime: any; - meridiem: (hour: number, minute: number, isLowercase: boolean) => string; - calendar: any; - ordinal: (num: number) => string; - - duration(milliseconds: Number): Duration; - duration(num: Number, unitOfTime: string): Duration; - duration(input: MomentInput): Duration; - duration(object: any): Duration; - duration(): Duration; - - parseZone(date: string): Moment; - - months(): string[]; - months(index: number): string; - months(format: string): string[]; - months(format: string, index: number): string; - monthsShort(): string[]; - monthsShort(index: number): string; - monthsShort(format: string): string[]; - monthsShort(format: string, index: number): string; - - weekdays(): string[]; - weekdays(index: number): string; - weekdays(format: string): string[]; - weekdays(format: string, index: number): string; - weekdaysShort(): string[]; - weekdaysShort(index: number): string; - weekdaysShort(format: string): string[]; - weekdaysShort(format: string, index: number): string; - weekdaysMin(): string[]; - weekdaysMin(index: number): string; - weekdaysMin(format: string): string[]; - weekdaysMin(format: string, index: number): string; - - min(...moments: Moment[]): Moment; - max(...moments: Moment[]): Moment; - - normalizeUnits(unit: string): string; - relativeTimeThreshold(threshold: string): number|boolean; - relativeTimeThreshold(threshold: string, limit:number): boolean; - - /** - * Constant used to enable explicit ISO_8601 format parsing. - */ - ISO_8601(): void; - - defaultFormat: string; - } - -} - -declare module 'moment' { - var moment: moment.MomentStatic; - export = moment; -} diff --git a/typings/moment/moment.d.ts b/typings/moment/moment.d.ts deleted file mode 100644 index 78b0901..0000000 --- a/typings/moment/moment.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Type definitions for Moment.js 2.8.0 -// Project: https://github.com/timrwood/moment -// Definitions by: Michael Lakerveld , Aaron King , Hiroki Horiuchi , Dick van den Brink , Adi Dahiya , Matt Brooks -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/// - -declare var moment: moment.MomentStatic; diff --git a/typings/node/node.d.ts b/typings/node/node.d.ts deleted file mode 100644 index 06c4bb9..0000000 --- a/typings/node/node.d.ts +++ /dev/null @@ -1,2112 +0,0 @@ -// Type definitions for Node.js v4.x -// Project: http://nodejs.org/ -// Definitions by: Microsoft TypeScript , DefinitelyTyped -// Definitions: https://github.com/borisyankov/DefinitelyTyped - -/************************************************ -* * -* Node.js v4.x API * -* * -************************************************/ - -interface Error { - stack?: string; -} - - -// compat for TypeScript 1.5.3 -// if you use with --target es3 or --target es5 and use below definitions, -// use the lib.es6.d.ts that is bundled with TypeScript 1.5.3. -interface MapConstructor {} -interface WeakMapConstructor {} -interface SetConstructor {} -interface WeakSetConstructor {} - -/************************************************ -* * -* GLOBAL * -* * -************************************************/ -declare var process: NodeJS.Process; -declare var global: NodeJS.Global; - -declare var __filename: string; -declare var __dirname: string; - -declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearTimeout(timeoutId: NodeJS.Timer): void; -declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; -declare function clearInterval(intervalId: NodeJS.Timer): void; -declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; -declare function clearImmediate(immediateId: any): void; - -interface NodeRequireFunction { - (id: string): any; -} - -interface NodeRequire extends NodeRequireFunction { - resolve(id:string): string; - cache: any; - extensions: any; - main: any; -} - -declare var require: NodeRequire; - -interface NodeModule { - exports: any; - require: NodeRequireFunction; - id: string; - filename: string; - loaded: boolean; - parent: any; - children: any[]; -} - -declare var module: NodeModule; - -// Same as module.exports -declare var exports: any; -declare var SlowBuffer: { - new (str: string, encoding?: string): Buffer; - new (size: number): Buffer; - new (size: Uint8Array): Buffer; - new (array: any[]): Buffer; - prototype: Buffer; - isBuffer(obj: any): boolean; - byteLength(string: string, encoding?: string): number; - concat(list: Buffer[], totalLength?: number): Buffer; -}; - - -// Buffer class -interface Buffer extends NodeBuffer {} - -/** - * Raw data is stored in instances of the Buffer class. - * A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized. - * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - */ -declare var Buffer: { - /** - * Allocates a new buffer containing the given {str}. - * - * @param str String to store in buffer. - * @param encoding encoding to use, optional. Default is 'utf8' - */ - new (str: string, encoding?: string): Buffer; - /** - * Allocates a new buffer of {size} octets. - * - * @param size count of octets to allocate. - */ - new (size: number): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: Uint8Array): Buffer; - /** - * Allocates a new buffer containing the given {array} of octets. - * - * @param array The octets to store. - */ - new (array: any[]): Buffer; - prototype: Buffer; - /** - * Returns true if {obj} is a Buffer - * - * @param obj object to test. - */ - isBuffer(obj: any): obj is Buffer; - /** - * Returns true if {encoding} is a valid encoding argument. - * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' - * - * @param encoding string to test. - */ - isEncoding(encoding: string): boolean; - /** - * Gives the actual byte length of a string. encoding defaults to 'utf8'. - * This is not the same as String.prototype.length since that returns the number of characters in a string. - * - * @param string string to test. - * @param encoding encoding used to evaluate (defaults to 'utf8') - */ - byteLength(string: string, encoding?: string): number; - /** - * Returns a buffer which is the result of concatenating all the buffers in the list together. - * - * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. - * If the list has exactly one item, then the first item of the list is returned. - * If the list has more than one item, then a new Buffer is created. - * - * @param list An array of Buffer objects to concatenate - * @param totalLength Total length of the buffers when concatenated. - * If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly. - */ - concat(list: Buffer[], totalLength?: number): Buffer; - /** - * The same as buf1.compare(buf2). - */ - compare(buf1: Buffer, buf2: Buffer): number; -}; - -/************************************************ -* * -* GLOBAL INTERFACES * -* * -************************************************/ -declare module NodeJS { - export interface ErrnoException extends Error { - errno?: number; - code?: string; - path?: string; - syscall?: string; - stack?: string; - } - - export interface EventEmitter { - addListener(event: string, listener: Function): EventEmitter; - on(event: string, listener: Function): EventEmitter; - once(event: string, listener: Function): EventEmitter; - removeListener(event: string, listener: Function): EventEmitter; - removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - } - - export interface ReadableStream extends EventEmitter { - readable: boolean; - read(size?: number): string|Buffer; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; - } - - export interface WritableStream extends EventEmitter { - writable: boolean; - write(buffer: Buffer|string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - } - - export interface ReadWriteStream extends ReadableStream, WritableStream {} - - export interface Process extends EventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; - argv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: { - http_parser: string; - node: string; - v8: string; - ares: string; - uv: string; - zlib: string; - openssl: string; - }; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; - }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid: number, signal?: string): void; - pid: number; - title: string; - arch: string; - platform: string; - memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; - nextTick(callback: Function): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?:number[]): number[]; - - // Worker - send?(message: any, sendHandle?: any): void; - } - - export interface Global { - Array: typeof Array; - ArrayBuffer: typeof ArrayBuffer; - Boolean: typeof Boolean; - Buffer: typeof Buffer; - DataView: typeof DataView; - Date: typeof Date; - Error: typeof Error; - EvalError: typeof EvalError; - Float32Array: typeof Float32Array; - Float64Array: typeof Float64Array; - Function: typeof Function; - GLOBAL: Global; - Infinity: typeof Infinity; - Int16Array: typeof Int16Array; - Int32Array: typeof Int32Array; - Int8Array: typeof Int8Array; - Intl: typeof Intl; - JSON: typeof JSON; - Map: MapConstructor; - Math: typeof Math; - NaN: typeof NaN; - Number: typeof Number; - Object: typeof Object; - Promise: Function; - RangeError: typeof RangeError; - ReferenceError: typeof ReferenceError; - RegExp: typeof RegExp; - Set: SetConstructor; - String: typeof String; - Symbol: Function; - SyntaxError: typeof SyntaxError; - TypeError: typeof TypeError; - URIError: typeof URIError; - Uint16Array: typeof Uint16Array; - Uint32Array: typeof Uint32Array; - Uint8Array: typeof Uint8Array; - Uint8ClampedArray: Function; - WeakMap: WeakMapConstructor; - WeakSet: WeakSetConstructor; - clearImmediate: (immediateId: any) => void; - clearInterval: (intervalId: NodeJS.Timer) => void; - clearTimeout: (timeoutId: NodeJS.Timer) => void; - console: typeof console; - decodeURI: typeof decodeURI; - decodeURIComponent: typeof decodeURIComponent; - encodeURI: typeof encodeURI; - encodeURIComponent: typeof encodeURIComponent; - escape: (str: string) => string; - eval: typeof eval; - global: Global; - isFinite: typeof isFinite; - isNaN: typeof isNaN; - parseFloat: typeof parseFloat; - parseInt: typeof parseInt; - process: Process; - root: Global; - setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; - setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; - undefined: typeof undefined; - unescape: (str: string) => string; - gc: () => void; - v8debug?: any; - } - - export interface Timer { - ref() : void; - unref() : void; - } -} - -/** - * @deprecated - */ -interface NodeBuffer { - [index: number]: number; - write(string: string, offset?: number, length?: number, encoding?: string): number; - toString(encoding?: string, start?: number, end?: number): string; - toJSON(): any; - length: number; - equals(otherBuffer: Buffer): boolean; - compare(otherBuffer: Buffer): number; - copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): Buffer; - writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; - readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; - readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; - readUInt8(offset: number, noAsset?: boolean): number; - readUInt16LE(offset: number, noAssert?: boolean): number; - readUInt16BE(offset: number, noAssert?: boolean): number; - readUInt32LE(offset: number, noAssert?: boolean): number; - readUInt32BE(offset: number, noAssert?: boolean): number; - readInt8(offset: number, noAssert?: boolean): number; - readInt16LE(offset: number, noAssert?: boolean): number; - readInt16BE(offset: number, noAssert?: boolean): number; - readInt32LE(offset: number, noAssert?: boolean): number; - readInt32BE(offset: number, noAssert?: boolean): number; - readFloatLE(offset: number, noAssert?: boolean): number; - readFloatBE(offset: number, noAssert?: boolean): number; - readDoubleLE(offset: number, noAssert?: boolean): number; - readDoubleBE(offset: number, noAssert?: boolean): number; - writeUInt8(value: number, offset: number, noAssert?: boolean): number; - writeUInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeUInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeInt8(value: number, offset: number, noAssert?: boolean): number; - writeInt16LE(value: number, offset: number, noAssert?: boolean): number; - writeInt16BE(value: number, offset: number, noAssert?: boolean): number; - writeInt32LE(value: number, offset: number, noAssert?: boolean): number; - writeInt32BE(value: number, offset: number, noAssert?: boolean): number; - writeFloatLE(value: number, offset: number, noAssert?: boolean): number; - writeFloatBE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleLE(value: number, offset: number, noAssert?: boolean): number; - writeDoubleBE(value: number, offset: number, noAssert?: boolean): number; - fill(value: any, offset?: number, end?: number): Buffer; -} - -/************************************************ -* * -* MODULES * -* * -************************************************/ -declare module "buffer" { - export var INSPECT_MAX_BYTES: number; -} - -declare module "querystring" { - export function stringify(obj: any, sep?: string, eq?: string): string; - export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; - export function escape(str: string): string; - export function unescape(str: string): string; -} - -declare module "events" { - export class EventEmitter implements NodeJS.EventEmitter { - static listenerCount(emitter: EventEmitter, event: string): number; - - addListener(event: string, listener: Function): EventEmitter; - on(event: string, listener: Function): EventEmitter; - once(event: string, listener: Function): EventEmitter; - removeListener(event: string, listener: Function): EventEmitter; - removeAllListeners(event?: string): EventEmitter; - setMaxListeners(n: number): void; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; - } -} - -declare module "http" { - import * as events from "events"; - import * as net from "net"; - import * as stream from "stream"; - - export interface RequestOptions { - protocol?: string; - host?: string; - hostname?: string; - family?: number; - port?: number - localAddress?: string; - socketPath?: string; - method?: string; - path?: string; - headers?: { [key: string]: any }; - auth?: string; - agent?: Agent; - } - - export interface Server extends events.EventEmitter { - listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; - listen(port: number, hostname?: string, callback?: Function): Server; - listen(path: string, callback?: Function): Server; - listen(handle: any, listeningListener?: Function): Server; - close(cb?: any): Server; - address(): { port: number; family: string; address: string; }; - maxHeadersCount: number; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ServerRequest extends IncomingMessage { - connection: net.Socket; - } - export interface ServerResponse extends events.EventEmitter, stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - writeContinue(): void; - writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; - writeHead(statusCode: number, headers?: any): void; - statusCode: number; - statusMessage: string; - setHeader(name: string, value: string): void; - sendDate: boolean; - getHeader(name: string): string; - removeHeader(name: string): void; - write(chunk: any, encoding?: string): any; - addTrailers(headers: any): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface ClientRequest extends events.EventEmitter, stream.Writable { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - write(chunk: any, encoding?: string): void; - abort(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - export interface IncomingMessage extends events.EventEmitter, stream.Readable { - httpVersion: string; - headers: any; - rawHeaders: string[]; - trailers: any; - rawTrailers: any; - setTimeout(msecs: number, callback: Function): NodeJS.Timer; - /** - * Only valid for request obtained from http.Server. - */ - method?: string; - /** - * Only valid for request obtained from http.Server. - */ - url?: string; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusCode?: number; - /** - * Only valid for response obtained from http.ClientRequest. - */ - statusMessage?: string; - socket: net.Socket; - } - /** - * @deprecated Use IncomingMessage - */ - export interface ClientResponse extends IncomingMessage { } - - export interface AgentOptions { - /** - * Keep sockets around in a pool to be used by other requests in the future. Default = false - */ - keepAlive?: boolean; - /** - * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. - * Only relevant if keepAlive is set to true. - */ - keepAliveMsecs?: number; - /** - * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity - */ - maxSockets?: number; - /** - * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. - */ - maxFreeSockets?: number; - } - - export class Agent { - maxSockets: number; - sockets: any; - requests: any; - - constructor(opts?: AgentOptions); - - /** - * Destroy any sockets that are currently in use by the agent. - * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, - * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, - * sockets may hang open for quite a long time before the server terminates them. - */ - destroy(): void; - } - - export var METHODS: string[]; - - export var STATUS_CODES: { - [errorCode: number]: string; - [errorCode: string]: string; - }; - export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server; - export function createClient(port?: number, host?: string): any; - export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest; - export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; - export var globalAgent: Agent; -} - -declare module "cluster" { - import * as child from "child_process"; - import * as events from "events"; - - export interface ClusterSettings { - exec?: string; - args?: string[]; - silent?: boolean; - } - - export class Worker extends events.EventEmitter { - id: string; - process: child.ChildProcess; - suicide: boolean; - send(message: any, sendHandle?: any): void; - kill(signal?: string): void; - destroy(signal?: string): void; - disconnect(): void; - } - - export var settings: ClusterSettings; - export var isMaster: boolean; - export var isWorker: boolean; - export function setupMaster(settings?: ClusterSettings): void; - export function fork(env?: any): Worker; - export function disconnect(callback?: Function): void; - export var worker: Worker; - export var workers: Worker[]; - - // Event emitter - export function addListener(event: string, listener: Function): void; - export function on(event: string, listener: Function): any; - export function once(event: string, listener: Function): void; - export function removeListener(event: string, listener: Function): void; - export function removeAllListeners(event?: string): void; - export function setMaxListeners(n: number): void; - export function listeners(event: string): Function[]; - export function emit(event: string, ...args: any[]): boolean; -} - -declare module "zlib" { - import * as stream from "stream"; - export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } - - export interface Gzip extends stream.Transform { } - export interface Gunzip extends stream.Transform { } - export interface Deflate extends stream.Transform { } - export interface Inflate extends stream.Transform { } - export interface DeflateRaw extends stream.Transform { } - export interface InflateRaw extends stream.Transform { } - export interface Unzip extends stream.Transform { } - - export function createGzip(options?: ZlibOptions): Gzip; - export function createGunzip(options?: ZlibOptions): Gunzip; - export function createDeflate(options?: ZlibOptions): Deflate; - export function createInflate(options?: ZlibOptions): Inflate; - export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; - export function createInflateRaw(options?: ZlibOptions): InflateRaw; - export function createUnzip(options?: ZlibOptions): Unzip; - - export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function deflateSync(buf: Buffer, options?: ZlibOptions): any; - export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any; - export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function gzipSync(buf: Buffer, options?: ZlibOptions): any; - export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function gunzipSync(buf: Buffer, options?: ZlibOptions): any; - export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function inflateSync(buf: Buffer, options?: ZlibOptions): any; - export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any; - export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; - export function unzipSync(buf: Buffer, options?: ZlibOptions): any; - - // Constants - export var Z_NO_FLUSH: number; - export var Z_PARTIAL_FLUSH: number; - export var Z_SYNC_FLUSH: number; - export var Z_FULL_FLUSH: number; - export var Z_FINISH: number; - export var Z_BLOCK: number; - export var Z_TREES: number; - export var Z_OK: number; - export var Z_STREAM_END: number; - export var Z_NEED_DICT: number; - export var Z_ERRNO: number; - export var Z_STREAM_ERROR: number; - export var Z_DATA_ERROR: number; - export var Z_MEM_ERROR: number; - export var Z_BUF_ERROR: number; - export var Z_VERSION_ERROR: number; - export var Z_NO_COMPRESSION: number; - export var Z_BEST_SPEED: number; - export var Z_BEST_COMPRESSION: number; - export var Z_DEFAULT_COMPRESSION: number; - export var Z_FILTERED: number; - export var Z_HUFFMAN_ONLY: number; - export var Z_RLE: number; - export var Z_FIXED: number; - export var Z_DEFAULT_STRATEGY: number; - export var Z_BINARY: number; - export var Z_TEXT: number; - export var Z_ASCII: number; - export var Z_UNKNOWN: number; - export var Z_DEFLATED: number; - export var Z_NULL: number; -} - -declare module "os" { - export interface CpuInfo { - model: string; - speed: number; - times: { - user: number; - nice: number; - sys: number; - idle: number; - irq: number; - } - } - - export interface NetworkInterfaceInfo { - address: string; - netmask: string; - family: string; - mac: string; - internal: boolean; - } - - export function tmpdir(): string; - export function homedir(): string; - export function endianness(): string; - export function hostname(): string; - export function type(): string; - export function platform(): string; - export function arch(): string; - export function release(): string; - export function uptime(): number; - export function loadavg(): number[]; - export function totalmem(): number; - export function freemem(): number; - export function cpus(): CpuInfo[]; - export function networkInterfaces(): {[index: string]: NetworkInterfaceInfo[]}; - export var EOL: string; -} - -declare module "https" { - import * as tls from "tls"; - import * as events from "events"; - import * as http from "http"; - - export interface ServerOptions { - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - crl?: any; - ciphers?: string; - honorCipherOrder?: boolean; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; - SNICallback?: (servername: string) => any; - } - - export interface RequestOptions extends http.RequestOptions{ - pfx?: any; - key?: any; - passphrase?: string; - cert?: any; - ca?: any; - ciphers?: string; - rejectUnauthorized?: boolean; - secureProtocol?: string; - } - - export interface Agent { - maxSockets: number; - sockets: any; - requests: any; - } - export var Agent: { - new (options?: RequestOptions): Agent; - }; - export interface Server extends tls.Server { } - export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; - export var globalAgent: Agent; -} - -declare module "punycode" { - export function decode(string: string): string; - export function encode(string: string): string; - export function toUnicode(domain: string): string; - export function toASCII(domain: string): string; - export var ucs2: ucs2; - interface ucs2 { - decode(string: string): number[]; - encode(codePoints: number[]): string; - } - export var version: any; -} - -declare module "repl" { - import * as stream from "stream"; - import * as events from "events"; - - export interface ReplOptions { - prompt?: string; - input?: NodeJS.ReadableStream; - output?: NodeJS.WritableStream; - terminal?: boolean; - eval?: Function; - useColors?: boolean; - useGlobal?: boolean; - ignoreUndefined?: boolean; - writer?: Function; - } - export function start(options: ReplOptions): events.EventEmitter; -} - -declare module "readline" { - import * as events from "events"; - import * as stream from "stream"; - - export interface ReadLine extends events.EventEmitter { - setPrompt(prompt: string): void; - prompt(preserveCursor?: boolean): void; - question(query: string, callback: Function): void; - pause(): void; - resume(): void; - close(): void; - write(data: any, key?: any): void; - } - export interface ReadLineOptions { - input: NodeJS.ReadableStream; - output: NodeJS.WritableStream; - completer?: Function; - terminal?: boolean; - } - export function createInterface(options: ReadLineOptions): ReadLine; -} - -declare module "vm" { - export interface Context { } - export interface Script { - runInThisContext(): void; - runInNewContext(sandbox?: Context): void; - } - export function runInThisContext(code: string, filename?: string): void; - export function runInNewContext(code: string, sandbox?: Context, filename?: string): void; - export function runInContext(code: string, context: Context, filename?: string): void; - export function createContext(initSandbox?: Context): Context; - export function createScript(code: string, filename?: string): Script; -} - -declare module "child_process" { - import * as events from "events"; - import * as stream from "stream"; - - export interface ChildProcess extends events.EventEmitter { - stdin: stream.Writable; - stdout: stream.Readable; - stderr: stream.Readable; - pid: number; - kill(signal?: string): void; - send(message: any, sendHandle?: any): void; - disconnect(): void; - unref(): void; - } - - export function spawn(command: string, args?: string[], options?: { - cwd?: string; - stdio?: any; - custom?: any; - env?: any; - detached?: boolean; - }): ChildProcess; - export function exec(command: string, options: { - cwd?: string; - stdio?: any; - customFds?: any; - env?: any; - encoding?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, - callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], - callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function execFile(file: string, args?: string[], options?: { - cwd?: string; - stdio?: any; - customFds?: any; - env?: any; - encoding?: string; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; - export function fork(modulePath: string, args?: string[], options?: { - cwd?: string; - env?: any; - encoding?: string; - }): ChildProcess; - export function spawnSync(command: string, args?: string[], options?: { - cwd?: string; - input?: string | Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - encoding?: string; - }): { - pid: number; - output: string[]; - stdout: string | Buffer; - stderr: string | Buffer; - status: number; - signal: string; - error: Error; - }; - export function execSync(command: string, options?: { - cwd?: string; - input?: string|Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - encoding?: string; - }): string | Buffer; - export function execFileSync(command: string, args?: string[], options?: { - cwd?: string; - input?: string|Buffer; - stdio?: any; - env?: any; - uid?: number; - gid?: number; - timeout?: number; - maxBuffer?: number; - killSignal?: string; - encoding?: string; - }): string | Buffer; -} - -declare module "url" { - export interface Url { - href?: string; - protocol?: string; - auth?: string; - hostname?: string; - port?: string; - host?: string; - pathname?: string; - search?: string; - query?: any; // string | Object - slashes?: boolean; - hash?: string; - path?: string; - } - - export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; - export function format(url: Url): string; - export function resolve(from: string, to: string): string; -} - -declare module "dns" { - export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; - export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; - export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; - export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; -} - -declare module "net" { - import * as stream from "stream"; - - export interface Socket extends stream.Duplex { - // Extended base methods - write(buffer: Buffer): boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - write(str: string, encoding?: string, fd?: string): boolean; - - connect(port: number, host?: string, connectionListener?: Function): void; - connect(path: string, connectionListener?: Function): void; - bufferSize: number; - setEncoding(encoding?: string): void; - write(data: any, encoding?: string, callback?: Function): void; - destroy(): void; - pause(): void; - resume(): void; - setTimeout(timeout: number, callback?: Function): void; - setNoDelay(noDelay?: boolean): void; - setKeepAlive(enable?: boolean, initialDelay?: number): void; - address(): { port: number; family: string; address: string; }; - unref(): void; - ref(): void; - - remoteAddress: string; - remoteFamily: string; - remotePort: number; - localAddress: string; - localPort: number; - bytesRead: number; - bytesWritten: number; - - // Extended base methods - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; - end(data?: any, encoding?: string): void; - } - - export var Socket: { - new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; - }; - - export interface Server extends Socket { - listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; - listen(path: string, listeningListener?: Function): Server; - listen(handle: any, listeningListener?: Function): Server; - close(callback?: Function): Server; - address(): { port: number; family: string; address: string; }; - maxConnections: number; - connections: number; - } - export function createServer(connectionListener?: (socket: Socket) =>void ): Server; - export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server; - export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function connect(port: number, host?: string, connectionListener?: Function): Socket; - export function connect(path: string, connectionListener?: Function): Socket; - export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; - export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; - export function createConnection(path: string, connectionListener?: Function): Socket; - export function isIP(input: string): number; - export function isIPv4(input: string): boolean; - export function isIPv6(input: string): boolean; -} - -declare module "dgram" { - import * as events from "events"; - - interface RemoteInfo { - address: string; - port: number; - size: number; - } - - interface AddressInfo { - address: string; - family: string; - port: number; - } - - export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; - - interface Socket extends events.EventEmitter { - send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; - bind(port: number, address?: string, callback?: () => void): void; - close(): void; - address(): AddressInfo; - setBroadcast(flag: boolean): void; - setMulticastTTL(ttl: number): void; - setMulticastLoopback(flag: boolean): void; - addMembership(multicastAddress: string, multicastInterface?: string): void; - dropMembership(multicastAddress: string, multicastInterface?: string): void; - } -} - -declare module "fs" { - import * as stream from "stream"; - import * as events from "events"; - - interface Stats { - isFile(): boolean; - isDirectory(): boolean; - isBlockDevice(): boolean; - isCharacterDevice(): boolean; - isSymbolicLink(): boolean; - isFIFO(): boolean; - isSocket(): boolean; - dev: number; - ino: number; - mode: number; - nlink: number; - uid: number; - gid: number; - rdev: number; - size: number; - blksize: number; - blocks: number; - atime: Date; - mtime: Date; - ctime: Date; - birthtime: Date; - } - - interface FSWatcher extends events.EventEmitter { - close(): void; - } - - export interface ReadStream extends stream.Readable { - close(): void; - } - export interface WriteStream extends stream.Writable { - close(): void; - bytesWritten: number; - } - - /** - * Asynchronous rename. - * @param oldPath - * @param newPath - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /** - * Synchronous rename - * @param oldPath - * @param newPath - */ - export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function truncateSync(path: string, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function chmodSync(path: string, mode: number): void; - export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fchmodSync(fd: number, mode: number): void; - export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function lchmodSync(path: string, mode: number): void; - export function lchmodSync(path: string, mode: string): void; - export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; - export function statSync(path: string): Stats; - export function lstatSync(path: string): Stats; - export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; - export function readlinkSync(path: string): string; - export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; - export function realpathSync(path: string, cache?: { [path: string]: string }): string; - /* - * Asynchronous unlink - deletes the file specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous unlink - deletes the file specified in {path} - * - * @param path - */ - export function unlinkSync(path: string): void; - /* - * Asynchronous rmdir - removes the directory specified in {path} - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous rmdir - removes the directory specified in {path} - * - * @param path - */ - export function rmdirSync(path: string): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string, mode?: number): void; - /* - * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. - * - * @param path - * @param mode - * @param callback No arguments other than a possible exception are given to the completion callback. - */ - export function mkdirSync(path: string, mode?: string): void; - export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; - export function readdirSync(path: string): string[]; - export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function closeSync(fd: number): void; - export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; - export function openSync(path: string, flags: string, mode?: number): number; - export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function utimesSync(path: string, atime: number, mtime: number): void; - export function utimesSync(path: string, atime: Date, mtime: Date): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function futimesSync(fd: number, atime: number, mtime: number): void; - export function futimesSync(fd: number, atime: Date, mtime: Date): void; - export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; - export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; - export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; - export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; - export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Asynchronous readFile - Asynchronously reads the entire contents of a file. - * - * @param fileName - * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. - */ - export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param encoding - */ - export function readFileSync(filename: string, encoding: string): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - /* - * Synchronous readFile - Synchronously reads the entire contents of a file. - * - * @param fileName - * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. - */ - export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; - export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; - export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; - export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; - export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; - export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; - export function exists(path: string, callback?: (exists: boolean) => void): void; - export function existsSync(path: string): boolean; - /** Constant for fs.access(). File is visible to the calling process. */ - export var F_OK: number; - /** Constant for fs.access(). File can be read by the calling process. */ - export var R_OK: number; - /** Constant for fs.access(). File can be written by the calling process. */ - export var W_OK: number; - /** Constant for fs.access(). File can be executed by the calling process. */ - export var X_OK: number; - /** Tests a user's permissions for the file specified by path. */ - export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void; - export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; - /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ - export function accessSync(path: string, mode ?: number): void; - export function createReadStream(path: string, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - autoClose?: boolean; - }): ReadStream; - export function createWriteStream(path: string, options?: { - flags?: string; - encoding?: string; - fd?: number; - mode?: number; - }): WriteStream; -} - -declare module "path" { - - /** - * A parsed path object generated by path.parse() or consumed by path.format(). - */ - export interface ParsedPath { - /** - * The root of the path such as '/' or 'c:\' - */ - root: string; - /** - * The full directory path such as '/home/user/dir' or 'c:\path\dir' - */ - dir: string; - /** - * The file name including extension (if any) such as 'index.html' - */ - base: string; - /** - * The file extension (if any) such as '.html' - */ - ext: string; - /** - * The file name without extension (if any) such as 'index' - */ - name: string; - } - - /** - * Normalize a string path, reducing '..' and '.' parts. - * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. - * - * @param p string path to normalize. - */ - export function normalize(p: string): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths string paths to join. - */ - export function join(...paths: any[]): string; - /** - * Join all arguments together and normalize the resulting path. - * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. - * - * @param paths string paths to join. - */ - export function join(...paths: string[]): string; - /** - * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. - * - * Starting from leftmost {from} paramter, resolves {to} to an absolute path. - * - * If {to} isn't already absolute, {from} arguments are prepended in right to left order, until an absolute path is found. If after using all {from} paths still no absolute path is found, the current working directory is used as well. The resulting path is normalized, and trailing slashes are removed unless the path gets resolved to the root directory. - * - * @param pathSegments string paths to join. Non-string arguments are ignored. - */ - export function resolve(...pathSegments: any[]): string; - /** - * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. - * - * @param path path to test. - */ - export function isAbsolute(path: string): boolean; - /** - * Solve the relative path from {from} to {to}. - * At times we have two absolute paths, and we need to derive the relative path from one to the other. This is actually the reverse transform of path.resolve. - * - * @param from - * @param to - */ - export function relative(from: string, to: string): string; - /** - * Return the directory name of a path. Similar to the Unix dirname command. - * - * @param p the path to evaluate. - */ - export function dirname(p: string): string; - /** - * Return the last portion of a path. Similar to the Unix basename command. - * Often used to extract the file name from a fully qualified path. - * - * @param p the path to evaluate. - * @param ext optionally, an extension to remove from the result. - */ - export function basename(p: string, ext?: string): string; - /** - * Return the extension of the path, from the last '.' to end of string in the last portion of the path. - * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string - * - * @param p the path to evaluate. - */ - export function extname(p: string): string; - /** - * The platform-specific file separator. '\\' or '/'. - */ - export var sep: string; - /** - * The platform-specific file delimiter. ';' or ':'. - */ - export var delimiter: string; - /** - * Returns an object from a path string - the opposite of format(). - * - * @param pathString path to evaluate. - */ - export function parse(pathString: string): ParsedPath; - /** - * Returns a path string from an object - the opposite of parse(). - * - * @param pathString path to evaluate. - */ - export function format(pathObject: ParsedPath): string; - - export module posix { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } - - export module win32 { - export function normalize(p: string): string; - export function join(...paths: any[]): string; - export function resolve(...pathSegments: any[]): string; - export function isAbsolute(p: string): boolean; - export function relative(from: string, to: string): string; - export function dirname(p: string): string; - export function basename(p: string, ext?: string): string; - export function extname(p: string): string; - export var sep: string; - export var delimiter: string; - export function parse(p: string): ParsedPath; - export function format(pP: ParsedPath): string; - } -} - -declare module "string_decoder" { - export interface NodeStringDecoder { - write(buffer: Buffer): string; - detectIncompleteChar(buffer: Buffer): number; - } - export var StringDecoder: { - new (encoding: string): NodeStringDecoder; - }; -} - -declare module "tls" { - import * as crypto from "crypto"; - import * as net from "net"; - import * as stream from "stream"; - - var CLIENT_RENEG_LIMIT: number; - var CLIENT_RENEG_WINDOW: number; - - export interface TlsOptions { - pfx?: any; //string or buffer - key?: any; //string or buffer - passphrase?: string; - cert?: any; - ca?: any; //string or buffer - crl?: any; //string or string array - ciphers?: string; - honorCipherOrder?: any; - requestCert?: boolean; - rejectUnauthorized?: boolean; - NPNProtocols?: any; //array or Buffer; - SNICallback?: (servername: string) => any; - } - - export interface ConnectionOptions { - host?: string; - port?: number; - socket?: net.Socket; - pfx?: any; //string | Buffer - key?: any; //string | Buffer - passphrase?: string; - cert?: any; //string | Buffer - ca?: any; //Array of string | Buffer - rejectUnauthorized?: boolean; - NPNProtocols?: any; //Array of string | Buffer - servername?: string; - } - - export interface Server extends net.Server { - // Extended base methods - listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; - listen(path: string, listeningListener?: Function): Server; - listen(handle: any, listeningListener?: Function): Server; - - listen(port: number, host?: string, callback?: Function): Server; - close(): Server; - address(): { port: number; family: string; address: string; }; - addContext(hostName: string, credentials: { - key: string; - cert: string; - ca: string; - }): void; - maxConnections: number; - connections: number; - } - - export interface ClearTextStream extends stream.Duplex { - authorized: boolean; - authorizationError: Error; - getPeerCertificate(): any; - getCipher: { - name: string; - version: string; - }; - address: { - port: number; - family: string; - address: string; - }; - remoteAddress: string; - remotePort: number; - } - - export interface SecurePair { - encrypted: any; - cleartext: any; - } - - export interface SecureContextOptions { - pfx?: any; //string | buffer - key?: any; //string | buffer - passphrase?: string; - cert?: any; // string | buffer - ca?: any; // string | buffer - crl?: any; // string | string[] - ciphers?: string; - honorCipherOrder?: boolean; - } - - export interface SecureContext { - context: any; - } - - export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; - export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; - export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; - export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; - export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; - export function createSecureContext(details: SecureContextOptions): SecureContext; -} - -declare module "crypto" { - export interface CredentialDetails { - pfx: string; - key: string; - passphrase: string; - cert: string; - ca: any; //string | string array - crl: any; //string | string array - ciphers: string; - } - export interface Credentials { context?: any; } - export function createCredentials(details: CredentialDetails): Credentials; - export function createHash(algorithm: string): Hash; - export function createHmac(algorithm: string, key: string): Hmac; - export function createHmac(algorithm: string, key: Buffer): Hmac; - interface Hash { - update(data: any, input_encoding?: string): Hash; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): any; - digest(): Buffer; - } - interface Hmac { - update(data: any, input_encoding?: string): Hmac; - digest(encoding: 'buffer'): Buffer; - digest(encoding: string): any; - digest(): Buffer; - } - export function createCipher(algorithm: string, password: any): Cipher; - export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; - interface Cipher { - update(data: Buffer): Buffer; - update(data: string, input_encoding?: string, output_encoding?: string): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding: boolean): void; - } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; - interface Decipher { - update(data: Buffer): Buffer; - update(data: string, input_encoding?: string, output_encoding?: string): string; - final(): Buffer; - final(output_encoding: string): string; - setAutoPadding(auto_padding: boolean): void; - } - export function createSign(algorithm: string): Signer; - interface Signer extends NodeJS.WritableStream { - update(data: any): void; - sign(private_key: string, output_format: string): string; - } - export function createVerify(algorith: string): Verify; - interface Verify extends NodeJS.WritableStream { - update(data: any): void; - verify(object: string, signature: string, signature_format?: string): boolean; - } - export function createDiffieHellman(prime_length: number): DiffieHellman; - export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; - interface DiffieHellman { - generateKeys(encoding?: string): string; - computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; - getPrime(encoding?: string): string; - getGenerator(encoding: string): string; - getPublicKey(encoding?: string): string; - getPrivateKey(encoding?: string): string; - setPublicKey(public_key: string, encoding?: string): void; - setPrivateKey(public_key: string, encoding?: string): void; - } - export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer; - export function randomBytes(size: number): Buffer; - export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; - export function pseudoRandomBytes(size: number): Buffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; -} - -declare module "stream" { - import * as events from "events"; - - export class Stream extends events.EventEmitter { - pipe(destination: T, options?: { end?: boolean; }): T; - } - - export interface ReadableOptions { - highWaterMark?: number; - encoding?: string; - objectMode?: boolean; - } - - export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { - readable: boolean; - constructor(opts?: ReadableOptions); - _read(size: number): void; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - } - - export interface WritableOptions { - highWaterMark?: number; - decodeStrings?: boolean; - objectMode?: boolean; - } - - export class Writable extends events.EventEmitter implements NodeJS.WritableStream { - writable: boolean; - constructor(opts?: WritableOptions); - _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export interface DuplexOptions extends ReadableOptions, WritableOptions { - allowHalfOpen?: boolean; - } - - // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeJS.ReadWriteStream { - writable: boolean; - constructor(opts?: DuplexOptions); - _write(chunk: any, encoding: string, callback: Function): void; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export interface TransformOptions extends ReadableOptions, WritableOptions {} - - // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { - readable: boolean; - writable: boolean; - constructor(opts?: TransformOptions); - _transform(chunk: any, encoding: string, callback: Function): void; - _flush(callback: Function): void; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: any): void; - wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; - push(chunk: any, encoding?: string): boolean; - write(chunk: any, cb?: Function): boolean; - write(chunk: any, encoding?: string, cb?: Function): boolean; - end(): void; - end(chunk: any, cb?: Function): void; - end(chunk: any, encoding?: string, cb?: Function): void; - } - - export class PassThrough extends Transform {} -} - -declare module "util" { - export interface InspectOptions { - showHidden?: boolean; - depth?: number; - colors?: boolean; - customInspect?: boolean; - } - - export function format(format: any, ...param: any[]): string; - export function debug(string: string): void; - export function error(...param: any[]): void; - export function puts(...param: any[]): void; - export function print(...param: any[]): void; - export function log(string: string): void; - export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; - export function inspect(object: any, options: InspectOptions): string; - export function isArray(object: any): boolean; - export function isRegExp(object: any): boolean; - export function isDate(object: any): boolean; - export function isError(object: any): boolean; - export function inherits(constructor: any, superConstructor: any): void; - export function debuglog(key:string): (msg:string,...param: any[])=>void; -} - -declare module "assert" { - function internal (value: any, message?: string): void; - module internal { - export class AssertionError implements Error { - name: string; - message: string; - actual: any; - expected: any; - operator: string; - generatedMessage: boolean; - - constructor(options?: {message?: string; actual?: any; expected?: any; - operator?: string; stackStartFunction?: Function}); - } - - export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; - export function ok(value: any, message?: string): void; - export function equal(actual: any, expected: any, message?: string): void; - export function notEqual(actual: any, expected: any, message?: string): void; - export function deepEqual(actual: any, expected: any, message?: string): void; - export function notDeepEqual(acutal: any, expected: any, message?: string): void; - export function strictEqual(actual: any, expected: any, message?: string): void; - export function notStrictEqual(actual: any, expected: any, message?: string): void; - export function deepStrictEqual(actual: any, expected: any, message?: string): void; - export function notDeepStrictEqual(actual: any, expected: any, message?: string): void; - export var throws: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export var doesNotThrow: { - (block: Function, message?: string): void; - (block: Function, error: Function, message?: string): void; - (block: Function, error: RegExp, message?: string): void; - (block: Function, error: (err: any) => boolean, message?: string): void; - }; - - export function ifError(value: any): void; - } - - export = internal; -} - -declare module "tty" { - import * as net from "net"; - - export function isatty(fd: number): boolean; - export interface ReadStream extends net.Socket { - isRaw: boolean; - setRawMode(mode: boolean): void; - } - export interface WriteStream extends net.Socket { - columns: number; - rows: number; - } -} - -declare module "domain" { - import * as events from "events"; - - export class Domain extends events.EventEmitter { - run(fn: Function): void; - add(emitter: events.EventEmitter): void; - remove(emitter: events.EventEmitter): void; - bind(cb: (err: Error, data: any) => any): any; - intercept(cb: (data: any) => any): any; - dispose(): void; - - addListener(event: string, listener: Function): Domain; - on(event: string, listener: Function): Domain; - once(event: string, listener: Function): Domain; - removeListener(event: string, listener: Function): Domain; - removeAllListeners(event?: string): Domain; - } - - export function create(): Domain; -} - -declare module "constants" { - export var E2BIG: number; - export var EACCES: number; - export var EADDRINUSE: number; - export var EADDRNOTAVAIL: number; - export var EAFNOSUPPORT: number; - export var EAGAIN: number; - export var EALREADY: number; - export var EBADF: number; - export var EBADMSG: number; - export var EBUSY: number; - export var ECANCELED: number; - export var ECHILD: number; - export var ECONNABORTED: number; - export var ECONNREFUSED: number; - export var ECONNRESET: number; - export var EDEADLK: number; - export var EDESTADDRREQ: number; - export var EDOM: number; - export var EEXIST: number; - export var EFAULT: number; - export var EFBIG: number; - export var EHOSTUNREACH: number; - export var EIDRM: number; - export var EILSEQ: number; - export var EINPROGRESS: number; - export var EINTR: number; - export var EINVAL: number; - export var EIO: number; - export var EISCONN: number; - export var EISDIR: number; - export var ELOOP: number; - export var EMFILE: number; - export var EMLINK: number; - export var EMSGSIZE: number; - export var ENAMETOOLONG: number; - export var ENETDOWN: number; - export var ENETRESET: number; - export var ENETUNREACH: number; - export var ENFILE: number; - export var ENOBUFS: number; - export var ENODATA: number; - export var ENODEV: number; - export var ENOENT: number; - export var ENOEXEC: number; - export var ENOLCK: number; - export var ENOLINK: number; - export var ENOMEM: number; - export var ENOMSG: number; - export var ENOPROTOOPT: number; - export var ENOSPC: number; - export var ENOSR: number; - export var ENOSTR: number; - export var ENOSYS: number; - export var ENOTCONN: number; - export var ENOTDIR: number; - export var ENOTEMPTY: number; - export var ENOTSOCK: number; - export var ENOTSUP: number; - export var ENOTTY: number; - export var ENXIO: number; - export var EOPNOTSUPP: number; - export var EOVERFLOW: number; - export var EPERM: number; - export var EPIPE: number; - export var EPROTO: number; - export var EPROTONOSUPPORT: number; - export var EPROTOTYPE: number; - export var ERANGE: number; - export var EROFS: number; - export var ESPIPE: number; - export var ESRCH: number; - export var ETIME: number; - export var ETIMEDOUT: number; - export var ETXTBSY: number; - export var EWOULDBLOCK: number; - export var EXDEV: number; - export var WSAEINTR: number; - export var WSAEBADF: number; - export var WSAEACCES: number; - export var WSAEFAULT: number; - export var WSAEINVAL: number; - export var WSAEMFILE: number; - export var WSAEWOULDBLOCK: number; - export var WSAEINPROGRESS: number; - export var WSAEALREADY: number; - export var WSAENOTSOCK: number; - export var WSAEDESTADDRREQ: number; - export var WSAEMSGSIZE: number; - export var WSAEPROTOTYPE: number; - export var WSAENOPROTOOPT: number; - export var WSAEPROTONOSUPPORT: number; - export var WSAESOCKTNOSUPPORT: number; - export var WSAEOPNOTSUPP: number; - export var WSAEPFNOSUPPORT: number; - export var WSAEAFNOSUPPORT: number; - export var WSAEADDRINUSE: number; - export var WSAEADDRNOTAVAIL: number; - export var WSAENETDOWN: number; - export var WSAENETUNREACH: number; - export var WSAENETRESET: number; - export var WSAECONNABORTED: number; - export var WSAECONNRESET: number; - export var WSAENOBUFS: number; - export var WSAEISCONN: number; - export var WSAENOTCONN: number; - export var WSAESHUTDOWN: number; - export var WSAETOOMANYREFS: number; - export var WSAETIMEDOUT: number; - export var WSAECONNREFUSED: number; - export var WSAELOOP: number; - export var WSAENAMETOOLONG: number; - export var WSAEHOSTDOWN: number; - export var WSAEHOSTUNREACH: number; - export var WSAENOTEMPTY: number; - export var WSAEPROCLIM: number; - export var WSAEUSERS: number; - export var WSAEDQUOT: number; - export var WSAESTALE: number; - export var WSAEREMOTE: number; - export var WSASYSNOTREADY: number; - export var WSAVERNOTSUPPORTED: number; - export var WSANOTINITIALISED: number; - export var WSAEDISCON: number; - export var WSAENOMORE: number; - export var WSAECANCELLED: number; - export var WSAEINVALIDPROCTABLE: number; - export var WSAEINVALIDPROVIDER: number; - export var WSAEPROVIDERFAILEDINIT: number; - export var WSASYSCALLFAILURE: number; - export var WSASERVICE_NOT_FOUND: number; - export var WSATYPE_NOT_FOUND: number; - export var WSA_E_NO_MORE: number; - export var WSA_E_CANCELLED: number; - export var WSAEREFUSED: number; - export var SIGHUP: number; - export var SIGINT: number; - export var SIGILL: number; - export var SIGABRT: number; - export var SIGFPE: number; - export var SIGKILL: number; - export var SIGSEGV: number; - export var SIGTERM: number; - export var SIGBREAK: number; - export var SIGWINCH: number; - export var SSL_OP_ALL: number; - export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; - export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; - export var SSL_OP_CISCO_ANYCONNECT: number; - export var SSL_OP_COOKIE_EXCHANGE: number; - export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; - export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; - export var SSL_OP_EPHEMERAL_RSA: number; - export var SSL_OP_LEGACY_SERVER_CONNECT: number; - export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; - export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; - export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; - export var SSL_OP_NETSCAPE_CA_DN_BUG: number; - export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; - export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; - export var SSL_OP_NO_COMPRESSION: number; - export var SSL_OP_NO_QUERY_MTU: number; - export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; - export var SSL_OP_NO_SSLv2: number; - export var SSL_OP_NO_SSLv3: number; - export var SSL_OP_NO_TICKET: number; - export var SSL_OP_NO_TLSv1: number; - export var SSL_OP_NO_TLSv1_1: number; - export var SSL_OP_NO_TLSv1_2: number; - export var SSL_OP_PKCS1_CHECK_1: number; - export var SSL_OP_PKCS1_CHECK_2: number; - export var SSL_OP_SINGLE_DH_USE: number; - export var SSL_OP_SINGLE_ECDH_USE: number; - export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; - export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; - export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; - export var SSL_OP_TLS_D5_BUG: number; - export var SSL_OP_TLS_ROLLBACK_BUG: number; - export var ENGINE_METHOD_DSA: number; - export var ENGINE_METHOD_DH: number; - export var ENGINE_METHOD_RAND: number; - export var ENGINE_METHOD_ECDH: number; - export var ENGINE_METHOD_ECDSA: number; - export var ENGINE_METHOD_CIPHERS: number; - export var ENGINE_METHOD_DIGESTS: number; - export var ENGINE_METHOD_STORE: number; - export var ENGINE_METHOD_PKEY_METHS: number; - export var ENGINE_METHOD_PKEY_ASN1_METHS: number; - export var ENGINE_METHOD_ALL: number; - export var ENGINE_METHOD_NONE: number; - export var DH_CHECK_P_NOT_SAFE_PRIME: number; - export var DH_CHECK_P_NOT_PRIME: number; - export var DH_UNABLE_TO_CHECK_GENERATOR: number; - export var DH_NOT_SUITABLE_GENERATOR: number; - export var NPN_ENABLED: number; - export var RSA_PKCS1_PADDING: number; - export var RSA_SSLV23_PADDING: number; - export var RSA_NO_PADDING: number; - export var RSA_PKCS1_OAEP_PADDING: number; - export var RSA_X931_PADDING: number; - export var RSA_PKCS1_PSS_PADDING: number; - export var POINT_CONVERSION_COMPRESSED: number; - export var POINT_CONVERSION_UNCOMPRESSED: number; - export var POINT_CONVERSION_HYBRID: number; - export var O_RDONLY: number; - export var O_WRONLY: number; - export var O_RDWR: number; - export var S_IFMT: number; - export var S_IFREG: number; - export var S_IFDIR: number; - export var S_IFCHR: number; - export var S_IFLNK: number; - export var O_CREAT: number; - export var O_EXCL: number; - export var O_TRUNC: number; - export var O_APPEND: number; - export var F_OK: number; - export var R_OK: number; - export var W_OK: number; - export var X_OK: number; - export var UV_UDP_REUSEADDR: number; -} diff --git a/typings/rx/rx-lite.d.ts b/typings/rx/rx-lite.d.ts deleted file mode 100644 index f159979..0000000 --- a/typings/rx/rx-lite.d.ts +++ /dev/null @@ -1,635 +0,0 @@ -// DefinitelyTyped: partial - -// This file contains common part of defintions for rx.d.ts and rx.lite.d.ts -// Do not include the file separately. - -declare namespace Rx { - export module internals { - function isEqual(left: any, right: any): boolean; - function addRef(xs: Observable, r: { getDisposable(): IDisposable; }): Observable; - - // Priority Queue for Scheduling - export class PriorityQueue { - constructor(capacity: number); - - length: number; - - isHigherPriority(left: number, right: number): boolean; - percolate(index: number): void; - heapify(index: number): void; - peek(): ScheduledItem; - removeAt(index: number): void; - dequeue(): ScheduledItem; - enqueue(item: ScheduledItem): void; - remove(item: ScheduledItem): boolean; - - static count: number; - } - - export class ScheduledItem { - constructor(scheduler: IScheduler, state: any, action: (scheduler: IScheduler, state: any) => IDisposable, dueTime: TTime, comparer?: (x: TTime, y: TTime) => number); - - scheduler: IScheduler; - state: TTime; - action: (scheduler: IScheduler, state: any) => IDisposable; - dueTime: TTime; - comparer: (x: TTime, y: TTime) => number; - disposable: SingleAssignmentDisposable; - - invoke(): void; - compareTo(other: ScheduledItem): number; - isCancelled(): boolean; - invokeCore(): IDisposable; - } - } - - export module config { - export var Promise: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }; - } - - export module helpers { - function noop(): void; - function notDefined(value: any): boolean; - function identity(value: T): T; - function defaultNow(): number; - function defaultComparer(left: any, right: any): boolean; - function defaultSubComparer(left: any, right: any): number; - function defaultKeySerializer(key: any): string; - function defaultError(err: any): void; - function isPromise(p: any): boolean; - function asArray(...args: T[]): T[]; - function not(value: any): boolean; - function isFunction(value: any): boolean; - } - - export interface IDisposable { - dispose(): void; - } - - export class CompositeDisposable implements IDisposable { - constructor (...disposables: IDisposable[]); - constructor (disposables: IDisposable[]); - - isDisposed: boolean; - length: number; - - dispose(): void; - add(item: IDisposable): void; - remove(item: IDisposable): boolean; - toArray(): IDisposable[]; - } - - export class Disposable implements IDisposable { - constructor(action: () => void); - - static create(action: () => void): IDisposable; - static empty: IDisposable; - - dispose(): void; - } - - // Single assignment - export class SingleAssignmentDisposable implements IDisposable { - constructor(); - - isDisposed: boolean; - current: IDisposable; - - dispose(): void ; - getDisposable(): IDisposable; - setDisposable(value: IDisposable): void ; - } - - // SerialDisposable it's an alias of SingleAssignmentDisposable - export class SerialDisposable extends SingleAssignmentDisposable { - constructor(); - } - - export class RefCountDisposable implements IDisposable { - constructor(disposable: IDisposable); - - dispose(): void; - - isDisposed: boolean; - getDisposable(): IDisposable; - } - - export interface IScheduler { - now(): number; - isScheduler(value: any): boolean; - - schedule(action: () => void): IDisposable; - scheduleWithState(state: TState, action: (scheduler: IScheduler, state: TState) => IDisposable): IDisposable; - scheduleWithAbsolute(dueTime: number, action: () => void): IDisposable; - scheduleWithAbsoluteAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable; - scheduleWithRelative(dueTime: number, action: () => void): IDisposable; - scheduleWithRelativeAndState(state: TState, dueTime: number, action: (scheduler: IScheduler, state: TState) =>IDisposable): IDisposable; - - scheduleRecursive(action: (action: () =>void ) =>void ): IDisposable; - scheduleRecursiveWithState(state: TState, action: (state: TState, action: (state: TState) =>void ) =>void ): IDisposable; - scheduleRecursiveWithAbsolute(dueTime: number, action: (action: (dueTime: number) => void) => void): IDisposable; - scheduleRecursiveWithAbsoluteAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) => void) => void): IDisposable; - scheduleRecursiveWithRelative(dueTime: number, action: (action: (dueTime: number) =>void ) =>void ): IDisposable; - scheduleRecursiveWithRelativeAndState(state: TState, dueTime: number, action: (state: TState, action: (state: TState, dueTime: number) =>void ) =>void ): IDisposable; - - schedulePeriodic(period: number, action: () => void): IDisposable; - schedulePeriodicWithState(state: TState, period: number, action: (state: TState) => TState): IDisposable; - } - - export interface Scheduler extends IScheduler { - } - - export interface SchedulerStatic { - new ( - now: () => number, - schedule: (state: any, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, - scheduleRelative: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable, - scheduleAbsolute: (state: any, dueTime: number, action: (scheduler: IScheduler, state: any) => IDisposable) => IDisposable): Scheduler; - - normalize(timeSpan: number): number; - - immediate: IScheduler; - currentThread: ICurrentThreadScheduler; - default: IScheduler; // alias for Scheduler.timeout - timeout: IScheduler; - } - - export var Scheduler: SchedulerStatic; - - // Current Thread IScheduler - interface ICurrentThreadScheduler extends IScheduler { - scheduleRequired(): boolean; - } - - // Notifications - export class Notification { - accept(observer: IObserver): void; - accept(onNext: (value: T) => TResult, onError?: (exception: any) => TResult, onCompleted?: () => TResult): TResult; - toObservable(scheduler?: IScheduler): Observable; - hasValue: boolean; - equals(other: Notification): boolean; - kind: string; - value: T; - exception: any; - - static createOnNext(value: T): Notification; - static createOnError(exception: any): Notification; - static createOnCompleted(): Notification; - } - - /** - * Promise A+ - */ - export interface IPromise { - then(onFulfilled: (value: T) => IPromise, onRejected: (reason: any) => IPromise): IPromise; - then(onFulfilled: (value: T) => IPromise, onRejected?: (reason: any) => R): IPromise; - then(onFulfilled: (value: T) => R, onRejected: (reason: any) => IPromise): IPromise; - then(onFulfilled?: (value: T) => R, onRejected?: (reason: any) => R): IPromise; - } - - // Observer - export interface IObserver { - onNext(value: T): void; - onError(exception: any): void; - onCompleted(): void; - } - - export interface Observer extends IObserver { - toNotifier(): (notification: Notification) => void; - asObserver(): Observer; - } - - interface ObserverStatic { - create(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observer; - fromNotifier(handler: (notification: Notification, thisArg?: any) => void): Observer; - } - - export var Observer: ObserverStatic; - - export interface IObservable { - subscribe(observer: Observer): IDisposable; - subscribe(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; - - subscribeOnNext(onNext: (value: T) => void, thisArg?: any): IDisposable; - subscribeOnError(onError: (exception: any) => void, thisArg?: any): IDisposable; - subscribeOnCompleted(onCompleted: () => void, thisArg?: any): IDisposable; - } - - export interface Observable extends IObservable { - forEach(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): IDisposable; // alias for subscribe - toArray(): Observable; - - catch(handler: (exception: any) => Observable): Observable; - catchException(handler: (exception: any) => Observable): Observable; // alias for catch - catch(handler: (exception: any) => IPromise): Observable; - catchException(handler: (exception: any) => IPromise): Observable; // alias for catch - catch(second: Observable): Observable; - catchException(second: Observable): Observable; // alias for catch - combineLatest(second: Observable|IPromise): Observable<[T, T2]>; - combineLatest(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - combineLatest(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - combineLatest(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - combineLatest(souces: (Observable|IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; - withLatestFrom(second: Observable|IPromise): Observable<[T, T2]>; - withLatestFrom(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - withLatestFrom(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - withLatestFrom(souces: (Observable|IPromise)[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; - concat(...sources: (Observable|IPromise)[]): Observable; - concat(sources: (Observable|IPromise)[]): Observable; - concatAll(): Observable; - concatObservable(): Observable; // alias for concatAll - concatMap(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => Observable): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => IPromise): Observable; // alias for selectConcat - concatMap(selector: (value: T, index: number) => R[]): Observable; // alias for selectConcat - concatMap(sequence: Observable): Observable; // alias for selectConcat - concatMap(sequence: R[]): Observable; // alias for selectConcat - merge(maxConcurrent: number): T; - merge(other: Observable): Observable; - merge(other: IPromise): Observable; - mergeAll(): Observable; - mergeObservable(): Observable; // alias for mergeAll - skipUntil(other: Observable): Observable; - skipUntil(other: IPromise): Observable; - switch(): Observable; - switchLatest(): Observable; // alias for switch - takeUntil(other: Observable): Observable; - takeUntil(other: IPromise): Observable; - zip(second: Observable|IPromise): Observable<[T, T2]>; - zip(second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - zip(second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - zip(second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - zip(second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - zip(second: (Observable|IPromise)[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; - - asObservable(): Observable; - dematerialize(): Observable; - distinctUntilChanged(skipParameter: boolean, comparer: (x: T, y: T) => boolean): Observable; - distinctUntilChanged(keySelector?: (value: T) => TValue, comparer?: (x: TValue, y: TValue) => boolean): Observable; - do(observer: Observer): Observable; - doAction(observer: Observer): Observable; // alias for do - tap(observer: Observer): Observable; // alias for do - do(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; - doAction(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do - tap(onNext?: (value: T) => void, onError?: (exception: any) => void, onCompleted?: () => void): Observable; // alias for do - - doOnNext(onNext: (value: T) => void, thisArg?: any): Observable; - doOnError(onError: (exception: any) => void, thisArg?: any): Observable; - doOnCompleted(onCompleted: () => void, thisArg?: any): Observable; - tapOnNext(onNext: (value: T) => void, thisArg?: any): Observable; - tapOnError(onError: (exception: any) => void, thisArg?: any): Observable; - tapOnCompleted(onCompleted: () => void, thisArg?: any): Observable; - - finally(action: () => void): Observable; - finallyAction(action: () => void): Observable; // alias for finally - ignoreElements(): Observable; - materialize(): Observable>; - repeat(repeatCount?: number): Observable; - retry(retryCount?: number): Observable; - retryWhen(notifier: (errors: Observable) => Observable): Observable; - - /** - * Applies an accumulator function over an observable sequence and returns each intermediate result. The optional seed value is used as the initial accumulator value. - * For aggregation behavior with no intermediate results, see Observable.aggregate. - * @example - * var res = source.scan(function (acc, x) { return acc + x; }); - * var res = source.scan(function (acc, x) { return acc + x; }, 0); - * @param accumulator An accumulator function to be invoked on each element. - * @param seed The initial accumulator value. - * @returns An observable sequence containing the accumulated values. - */ - scan(accumulator: (acc: TAcc, value: T, index?: number, source?: Observable) => TAcc, seed: TAcc): Observable; - scan(accumulator: (acc: T, value: T, index?: number, source?: Observable) => T): Observable; - - skipLast(count: number): Observable; - startWith(...values: T[]): Observable; - startWith(scheduler: IScheduler, ...values: T[]): Observable; - takeLast(count: number): Observable; - takeLastBuffer(count: number): Observable; - - select(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; - map(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for select - pluck(prop: string): Observable; - selectMany(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; - selectMany(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; - selectMany(selector: (value: T) => Observable): Observable; - selectMany(selector: (value: T) => IPromise): Observable; - selectMany(other: Observable): Observable; - selectMany(other: IPromise): Observable; - selectMany(selector: (value: T) => TResult[]): Observable; // alias for selectMany - flatMap(selector: (value: T) => Observable, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany - flatMap(selector: (value: T) => IPromise, resultSelector: (item: T, other: TOther) => TResult): Observable; // alias for selectMany - flatMap(selector: (value: T) => Observable): Observable; // alias for selectMany - flatMap(selector: (value: T) => IPromise): Observable; // alias for selectMany - flatMap(other: Observable): Observable; // alias for selectMany - flatMap(other: IPromise): Observable; // alias for selectMany - flatMap(selector: (value: T) => TResult[]): Observable; // alias for selectMany - - /** - * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. - * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. - * @param {Function} onError A transform function to apply when an error occurs in the source sequence. - * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. - * @param {Any} [thisArg] An optional "this" to use to invoke each transform. - * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. - */ - selectManyObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; - - /** - * Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. - * @param {Function} onNext A transform function to apply to each element; the second parameter of the function represents the index of the source element. - * @param {Function} onError A transform function to apply when an error occurs in the source sequence. - * @param {Function} onCompleted A transform function to apply when the end of the source sequence is reached. - * @param {Any} [thisArg] An optional "this" to use to invoke each transform. - * @returns {Observable} An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence. - */ - flatMapObserver(onNext: (value: T, index: number) => Observable, onError: (exception: any) => Observable, onCompleted: () => Observable, thisArg?: any): Observable; - - selectConcat(selector: (value: T, index: number) => Observable, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; - selectConcat(selector: (value: T, index: number) => IPromise, resultSelector: (value1: T, value2: T2, index: number) => R): Observable; - selectConcat(selector: (value: T, index: number) => Observable): Observable; - selectConcat(selector: (value: T, index: number) => IPromise): Observable; - selectConcat(sequence: Observable): Observable; - - /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then - * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. - * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - * @param [thisArg] Object to use as this when executing callback. - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences - * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. - */ - selectSwitch(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; - /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then - * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. - * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - * @param [thisArg] Object to use as this when executing callback. - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences - * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. - */ - flatMapLatest(selector: (value: T, index: number, source: Observable) => Observable, thisArg?: any): Observable; // alias for selectSwitch - /** - * Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then - * transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. - * @param selector A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - * @param [thisArg] Object to use as this when executing callback. - * @since 2.2.28 - * @returns An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences - * and that at any point in time produces the elements of the most recent inner observable sequence that has been received. - */ - switchMap(selector: (value: T, index: number, source: Observable) => TResult, thisArg?: any): Observable; // alias for selectSwitch - - skip(count: number): Observable; - skipWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - take(count: number, scheduler?: IScheduler): Observable; - takeWhile(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - where(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; - filter(predicate: (value: T, index: number, source: Observable) => boolean, thisArg?: any): Observable; // alias for where - - /** - * Converts an existing observable sequence to an ES6 Compatible Promise - * @example - * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); - * @param promiseCtor The constructor of the promise. - * @returns An ES6 compatible promise with the last value from the observable sequence. - */ - toPromise>(promiseCtor: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): TPromise; }): TPromise; - /** - * Converts an existing observable sequence to an ES6 Compatible Promise - * @example - * var promise = Rx.Observable.return(42).toPromise(RSVP.Promise); - * - * // With config - * Rx.config.Promise = RSVP.Promise; - * var promise = Rx.Observable.return(42).toPromise(); - * @param [promiseCtor] The constructor of the promise. If not provided, it looks for it in Rx.config.Promise. - * @returns An ES6 compatible promise with the last value from the observable sequence. - */ - toPromise(promiseCtor?: { new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): IPromise; }): IPromise; - - // Experimental Flattening - - /** - * Performs a exclusive waiting for the first to finish before subscribing to another observable. - * Observables that come in between subscriptions will be dropped on the floor. - * Can be applied on `Observable>` or `Observable>`. - * @since 2.2.28 - * @returns A exclusive observable with only the results that happen when subscribed. - */ - exclusive(): Observable; - - /** - * Performs a exclusive map waiting for the first to finish before subscribing to another observable. - * Observables that come in between subscriptions will be dropped on the floor. - * Can be applied on `Observable>` or `Observable>`. - * @since 2.2.28 - * @param selector Selector to invoke for every item in the current subscription. - * @param [thisArg] An optional context to invoke with the selector parameter. - * @returns {An exclusive observable with only the results that happen when subscribed. - */ - exclusiveMap(selector: (value: I, index: number, source: Observable) => R, thisArg?: any): Observable; - } - - interface ObservableStatic { - create(subscribe: (observer: Observer) => IDisposable): Observable; - create(subscribe: (observer: Observer) => () => void): Observable; - create(subscribe: (observer: Observer) => void): Observable; - createWithDisposable(subscribe: (observer: Observer) => IDisposable): Observable; - defer(observableFactory: () => Observable): Observable; - defer(observableFactory: () => IPromise): Observable; - empty(scheduler?: IScheduler): Observable; - - /** - * This method creates a new Observable sequence from an array object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param mapFn Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: T[], mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; - /** - * This method creates a new Observable sequence from an array object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param [mapFn] Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: T[], mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; - - /** - * This method creates a new Observable sequence from an array-like object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param mapFn Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: { length: number;[index: number]: T; }, mapFn: (value: T, index: number) => TResult, thisArg?: any, scheduler?: IScheduler): Observable; - /** - * This method creates a new Observable sequence from an array-like object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param [mapFn] Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(array: { length: number;[index: number]: T; }, mapFn?: (value: T, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; - - /** - * This method creates a new Observable sequence from an array-like or iterable object. - * @param array An array-like or iterable object to convert to an Observable sequence. - * @param [mapFn] Map function to call on every element of the array. - * @param [thisArg] The context to use calling the mapFn if provided. - * @param [scheduler] Optional scheduler to use for scheduling. If not provided, defaults to Scheduler.currentThread. - */ - from(iterable: any, mapFn?: (value: any, index: number) => T, thisArg?: any, scheduler?: IScheduler): Observable; - - fromArray(array: T[], scheduler?: IScheduler): Observable; - fromArray(array: { length: number;[index: number]: T; }, scheduler?: IScheduler): Observable; - - generate(initialState: TState, condition: (state: TState) => boolean, iterate: (state: TState) => TState, resultSelector: (state: TState) => TResult, scheduler?: IScheduler): Observable; - never(): Observable; - - /** - * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. - * - * @example - * var res = Rx.Observable.of(1, 2, 3); - * @since 2.2.28 - * @returns The observable sequence whose elements are pulled from the given arguments. - */ - of(...values: T[]): Observable; - - /** - * This method creates a new Observable instance with a variable number of arguments, regardless of number or type of the arguments. - * @example - * var res = Rx.Observable.ofWithScheduler(Rx.Scheduler.timeout, 1, 2, 3); - * @since 2.2.28 - * @param [scheduler] A scheduler to use for scheduling the arguments. - * @returns The observable sequence whose elements are pulled from the given arguments. - */ - ofWithScheduler(scheduler?: IScheduler, ...values: T[]): Observable; - range(start: number, count: number, scheduler?: IScheduler): Observable; - repeat(value: T, repeatCount?: number, scheduler?: IScheduler): Observable; - return(value: T, scheduler?: IScheduler): Observable; - /** - * @since 2.2.28 - */ - just(value: T, scheduler?: IScheduler): Observable; // alias for return - returnValue(value: T, scheduler?: IScheduler): Observable; // alias for return - throw(exception: Error, scheduler?: IScheduler): Observable; - throw(exception: any, scheduler?: IScheduler): Observable; - throwException(exception: Error, scheduler?: IScheduler): Observable; // alias for throw - throwException(exception: any, scheduler?: IScheduler): Observable; // alias for throw - throwError(error: Error, scheduler?: IScheduler): Observable; // alias for throw - throwError(error: any, scheduler?: IScheduler): Observable; // alias for throw - - catch(sources: Observable[]): Observable; - catch(sources: IPromise[]): Observable; - catchException(sources: Observable[]): Observable; // alias for catch - catchException(sources: IPromise[]): Observable; // alias for catch - catchError(sources: Observable[]): Observable; // alias for catch - catchError(sources: IPromise[]): Observable; // alias for catch - catch(...sources: Observable[]): Observable; - catch(...sources: IPromise[]): Observable; - catchException(...sources: Observable[]): Observable; // alias for catch - catchException(...sources: IPromise[]): Observable; // alias for catch - catchError(...sources: Observable[]): Observable; // alias for catch - catchError(...sources: IPromise[]): Observable; // alias for catch - - combineLatest(first: Observable|IPromise, second: Observable|IPromise): Observable<[T, T2]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - combineLatest(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - combineLatest(sources: (Observable|IPromise)[]): Observable; - combineLatest(sources: (Observable|IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; - - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise): Observable<[T, T2]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise): Observable<[T, T2, T3]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise): Observable<[T, T2, T3, T4]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise): Observable<[T, T2, T3, T4, T5]>; - withLatestFrom(first: Observable|IPromise, second: Observable|IPromise, third: Observable|IPromise, fourth: Observable|IPromise, fifth: Observable|IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - withLatestFrom(souces: (Observable|IPromise)[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; - - concat(...sources: Observable[]): Observable; - concat(...sources: IPromise[]): Observable; - concat(sources: Observable[]): Observable; - concat(sources: IPromise[]): Observable; - merge(...sources: Observable[]): Observable; - merge(...sources: IPromise[]): Observable; - merge(sources: Observable[]): Observable; - merge(sources: IPromise[]): Observable; - merge(scheduler: IScheduler, ...sources: Observable[]): Observable; - merge(scheduler: IScheduler, ...sources: IPromise[]): Observable; - merge(scheduler: IScheduler, sources: Observable[]): Observable; - merge(scheduler: IScheduler, sources: IPromise[]): Observable; - - pairs(obj: { [key: string]: T }, scheduler?: IScheduler): Observable<[string, T]>; - - zip(first: Observable|IPromise, sources: (Observable|IPromise)[]): Observable<[T1, T2]>; - zip(first: Observable|IPromise, sources: (Observable|IPromise)[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise): Observable<[T1, T2]>; - zip(source1: Observable|IPromise, source2: Observable|IPromise, resultSelector: (item1: T1, item2: T2) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise): Observable<[T1, T2, T3]>; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise): Observable<[T1, T2, T3, T4]>; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, source5: Observable|IPromise): Observable<[T1, T2, T3, T4, T5]>; - zip(source1: Observable|IPromise, source2: Observable|IPromise, source3: Observable|IPromise, source4: Observable|IPromise, source5: Observable|IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TResult): Observable; - zipArray(...sources: (Observable|IPromise)[]): Observable; - zipArray(sources: (Observable|IPromise)[]): Observable; - - /** - * Converts a Promise to an Observable sequence - * @param promise An ES6 Compliant promise. - * @returns An Observable sequence which wraps the existing promise success and failure. - */ - fromPromise(promise: IPromise): Observable; - - prototype: any; - } - - export var Observable: ObservableStatic; - - interface ISubject extends Observable, Observer, IDisposable { - hasObservers(): boolean; - } - - export interface Subject extends ISubject { - } - - interface SubjectStatic { - new (): Subject; - create(observer?: Observer, observable?: Observable): ISubject; - } - - export var Subject: SubjectStatic; - - export interface AsyncSubject extends Subject { - } - - interface AsyncSubjectStatic { - new (): AsyncSubject; - } - - export var AsyncSubject: AsyncSubjectStatic; -} diff --git a/typings/through/through.d.ts b/typings/through/through.d.ts deleted file mode 100644 index b0d49fc..0000000 --- a/typings/through/through.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -// Type definitions for through -// Project: https://github.com/dominictarr/through -// Definitions by: Andrew Gaspar -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/// - -declare module "through" { - import stream = require("stream"); - - function through(write?: (data: any) => void, - end?: () => void, - opts?: { - autoDestroy: boolean; - }): through.ThroughStream; - - namespace through { - export interface ThroughStream extends stream.Transform { - autoDestroy: boolean; - } - } - - export = through; -} diff --git a/typings/tsd.d.ts b/typings/tsd.d.ts index e211e5b..2125321 100644 --- a/typings/tsd.d.ts +++ b/typings/tsd.d.ts @@ -1,9 +1,3 @@ -/// -/// -/// -/// -/// -/// /// /// /// From c1b425ac668921fca46eff4fbf8c30920810053d Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 2 Nov 2016 15:09:35 -0700 Subject: [PATCH 46/49] Fix dependencies --- package.json | 17 +++++++---------- tsd.json | 27 --------------------------- 2 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 tsd.json diff --git a/package.json b/package.json index 59f3c86..c98b053 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "sync.js", + "name": "syncjs", "version": "2.0.0", "main": "dist/index.js", "preferGlobal": true, @@ -12,19 +12,11 @@ "syncjs": "bin/syncjs" }, "dependencies": { - "@types/chalk": "^0.4.31", - "@types/chokidar": "^1.4.29", - "@types/inquirer": "^0.0.30", - "@types/minimist": "^1.1.29", - "@types/node": "^6.0.46", - "@types/rx": "^2.5.33", - "@types/through": "^0.0.28", "chalk": "^1.1.3", "chokidar": "^1.6.1", "inquirer": "^1.1.2", "jsonplus": "^1.2.1", "minimist": "^1.2.0", - "moment": "2.15.2", "observatory": "^1.0.0", "prompt": "^1.0.0", "scp2": "^0.5.0", @@ -39,7 +31,12 @@ "gulp-babel": "^6.1.2", "gulp-rename": "^1.2.2", "gulp-typescript": "^3.1.2", - "typescript": "^2.0.6" + "typescript": "^2.0.6", + "@types/chalk": "^0.4.31", + "@types/chokidar": "^1.4.29", + "@types/inquirer": "^0.0.30", + "@types/minimist": "^1.1.29", + "@types/node": "^6.0.46" }, "repository": { "type": "git", diff --git a/tsd.json b/tsd.json deleted file mode 100644 index 6a68bd8..0000000 --- a/tsd.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "version": "v4", - "repo": "borisyankov/DefinitelyTyped", - "ref": "master", - "path": "typings", - "bundle": "typings/tsd.d.ts", - "installed": { - "minimist/minimist.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - }, - "chalk/chalk.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - }, - "chokidar/chokidar.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - }, - "node/node.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - }, - "moment/moment.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - }, - "moment/moment-node.d.ts": { - "commit": "5a8fc5ee71701431e4fdbb80c506e3c13f85a9ff" - } - } -} From 885f4f1844e8381d2ee83ef90468cd59340f242a Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 2 Nov 2016 15:21:48 -0700 Subject: [PATCH 47/49] updated yarn.lock file --- yarn.lock | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 5849095..ba1a6ad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -25,11 +25,11 @@ version "6.0.46" resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.46.tgz#8d9e48572831f05b11cc4c793754d43437219d62" -"@types/rx", "@types/rx@*": +"@types/rx@*": version "2.5.33" resolved "https://registry.yarnpkg.com/@types/rx/-/rx-2.5.33.tgz#1867f4ac98e57428fe82b284d1a80c9c1f611bb7" -"@types/through", "@types/through@*": +"@types/through@*": version "0.0.28" resolved "https://registry.yarnpkg.com/@types/through/-/through-0.0.28.tgz#1effa9a6d00fb48572b4cc9f44df25b0100db7fc" dependencies: @@ -1929,10 +1929,6 @@ mkdirp@^0.5.0, mkdirp@^0.5.1, "mkdirp@>=0.5 0", mkdirp@~0.5.1, mkdirp@0.x.x: dependencies: minimist "0.0.8" -moment@2.15.2: - version "2.15.2" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.15.2.tgz#1bfdedf6a6e345f322fe956d5df5bd08a8ce84dc" - ms@0.7.1: version "0.7.1" resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.1.tgz#9cd13c03adbff25b65effde7ce864ee952017098" From 0813413170927b0c54a0e3f3881c195ca45ffcff Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 2 Nov 2016 16:41:15 -0700 Subject: [PATCH 48/49] new README --- README.md | 95 ++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index a37e73b..f3e54a1 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,60 @@ -## Sync.js - Upload changed local files to remote server -sync.js let's you keep your remote files in sync with your local copy. Whenever you make a change on your local project, sync.js uploads the changed files to remote server using `scp` command. +Syncjs - Upload changed local files to remote server +---------------------------------------------------- -When configured correctly, it works really fast because sync.js leverages [openSSH master connection settings](http://protempore.net/~calvins/howto/ssh-connection-sharing/). That means instead of creating new connections for each upload, sync.js keeps one connection open and uses it for all uploads. +Syncjs is an easy to use command line tool for uploading your local changes to a remote server. -![How it works](http://i.imgur.com/weaaKqh.gif "How it works") +It's useful in situations where your application needs to be on a remote server to run (dev machines, pubdev environments, etc.) but you still want to use your local environment for development. You can simply map you local copy of the project to the remote version and syncjs will do the rest. -### Why did I do this? Aren't there already tools doing the same exact thing? -Yes there are. However, none of them fulfills my needs. I use Sublime Text 2 and occasionally VIM. ST2 has `SFTP` plugin -~~but it doesn't have ST3 support yet~~, also it doesn't upload files when they changed via other editors. +![Syncjs](http://i.imgur.com/rLNUErv.gif, "syncjs") -I tried `unison` but it kills the CPU and syncs remote to local too. Configuration was too complex and it was not really customizable. As soon as I started `unison` it filled my computer with all the compressed scripts and tmp files from the server. +This example shows usage with Visual Studio Code but since it's an external script, you can use it with any editor you want. -Other options were mostly either not working or doing so many other things that I don't need. I only want to upload files to remote server when they are changed. That's it. +Features +-------- + - Easy to setup + - Fast and reliable + - Runs independently from your toolchain so you can use it with anyting + - Runs on windows, osx and linux + - detects and handles changes on folders + - can run multiple instances at the same time -### Features -- Fast and reliable change detection -- Very light weight, doesn't use excessive CPU power -- Internal command line to control the script while it's working -- Doesn't depend on any editor, so you can use it with any application -- It's very simplistic and customizable, you can alter the script however you like -- Colorful and interactive output. -- And many more +Installation +------------ -### Installation -Just clone this repository `anywhere` on your computer +Syncjs is easy to install, just execute the following ``` -git clone git@github.com:serkanyersen/sync.git +npm install -g syncjs ``` -Go inside `sync ` folder and install dependencies -``` -cd sync -npm install -``` -Create a config file using the example file - -``` -cp config_example.json config.json -``` -The config file is very self explanatory, just open it and add your own information - -```json -{ - "host": "username@ssh.yourhost.com", - "interval_duration": 1.5, - "local_path": "/path/to/local/folder", - "remote_path": "/path/to/remote/folder" -} -``` -To leverage the openSSH master connection feature, just open `~/.ssh/config` file -and put the following in it (unless you don't have it already): - -``` -Host * - ControlMaster auto - ControlPath ~/.ssh/master-%r@%h:%p -``` -Now you are ready to go, start the script by calling sync.js with either `./sync.js` or `nodejs sync.js` +After this you'll have `syncjs` binary available to you. -That's it. +Configuration +------------- -### Bonus -If you are on OSX and using `iTerm` or any other terminal other than the default `Terminal.app`, you can install [TotalTerminal](http://totalterminal.binaryage.com/) formerly known as `Visor` and start `sync.js` from it. And if you add this line to `config.json` +Syncjs comes with an init script and sets itself up for you. All you need to do is to `cd` into your projects directory and run `syncjs init` it will ask few simple questions and create the config file called `sync-config.json` make sure you include this file in your `.gitignore` because this file might contain passwords or secrets depending on your preferences. ``` -"visorSupport": true +cd /my/project/folder +syncjs init ``` -sync.js will pop visor terminal on the screen for a second and hide it again, so that you'll understand script is currently uploading your change. +![Configuration](http://i.imgur.com/3VnNDc5.gif, "syncjs init") -It works better when you place the visor at the bottom of the screen and reduce the row count. +### Questions on config + - **Username**: your username that you use to connect to remote machine + - **Auth method**: + - **Password in config**: This the least secure version of auth. It will keep your password in the config file **as plain text** do not use this please + - **Ask during connect**: This option will ask your password again every time you start `syncjs` your password will not be stored anywhere. + - **Private Key**: Most secure option, just provide the path for your key file and syncjs will do the rest + - **Hostname or IP of the server**: Tell syncjs where to connect + - **Port to connect**: defaults to `22` this usually is what you want + - **Local path**: syncjs will automatically detect this as the root of your project, but if you only want to sync one specific folder, **provide it here as full path** + - **Remote path**: This is where copy of your local folder lives in the remote server. Make sure you type full path here as well. -## License -MIT, Go Crazy +License +------- +MIT \ No newline at end of file From f22c301925e25a35e3d1a28224138df8159c57de Mon Sep 17 00:00:00 2001 From: Serkan Yersen Date: Wed, 2 Nov 2016 16:58:24 -0700 Subject: [PATCH 49/49] Add more example gifs --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3e54a1..e2203c5 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,12 @@ Syncjs is an easy to use command line tool for uploading your local changes to a It's useful in situations where your application needs to be on a remote server to run (dev machines, pubdev environments, etc.) but you still want to use your local environment for development. You can simply map you local copy of the project to the remote version and syncjs will do the rest. -![Syncjs](http://i.imgur.com/rLNUErv.gif, "syncjs") +![Syncjs in use](http://i.imgur.com/rLNUErv.gif, "syncjs") This example shows usage with Visual Studio Code but since it's an external script, you can use it with any editor you want. +![Vim Example](http://i.imgur.com/drnEET1.gif, "syncjs") + Features -------- - Easy to setup