├── .gitignore
├── README.md
├── app
├── app.ts
├── index.html
├── notification.ts
└── second.html
├── build
├── angular2.js
├── angular2.js.map
├── app.js
├── app.js.map
├── common.js
└── common.js.map
├── index.js
├── package.json
├── tsconfig.json
├── typings.json
├── typings
├── globals
│ ├── core-js
│ │ ├── index.d.ts
│ │ └── typings.json
│ ├── github-electron
│ │ ├── index.d.ts
│ │ └── typings.json
│ ├── jasmine
│ │ ├── index.d.ts
│ │ └── typings.json
│ └── node
│ │ ├── index.d.ts
│ │ └── typings.json
└── index.d.ts
└── webpack.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | build/
3 | typings/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #angular2-desktop-menus
2 | A simple application demonstrating how to design menus in desktop apps created using Angular 2 and electron.
3 |
4 | For further details - http://tphangout.com/?p=339
5 |
--------------------------------------------------------------------------------
/app/app.ts:
--------------------------------------------------------------------------------
1 |
2 | import {bootstrap} from '@angular/platform-browser-dynamic';
3 | import {Component} from '@angular/core';
4 |
5 | import {remote, ipcRenderer} from 'electron';
6 |
7 | let {dialog} = remote;
8 |
9 | @Component({
10 | selector: 'myapp',
11 | template: '
Angular 2 app inside a desktop app
'
12 | })
13 |
14 | export class AppComponent {
15 |
16 | constructor() {
17 | var menu = remote.Menu.buildFromTemplate([{
18 | label: 'Raja',
19 | submenu: [
20 | {
21 | label: 'open',
22 | click: function(){
23 | dialog.showOpenDialog((cb) => {
24 |
25 | })
26 | }
27 | },
28 | {
29 | label: 'opencustom',
30 | click: function(){
31 | ipcRenderer.send('open-custom');
32 | let notification = new Notification('Customdialog', {
33 | body: 'This is a custom window created by us'
34 | })
35 |
36 | }
37 | }
38 | ]
39 | }])
40 | remote.Menu.setApplicationMenu(menu);
41 | }
42 |
43 | }
44 |
45 | bootstrap(AppComponent);
46 |
47 |
--------------------------------------------------------------------------------
/app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | First App
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/notification.ts:
--------------------------------------------------------------------------------
1 | declare class Notification {
2 | constructor(title: string, options?: Object)
3 | }
--------------------------------------------------------------------------------
/app/second.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello, This is second window
4 |
5 |
--------------------------------------------------------------------------------
/build/common.js:
--------------------------------------------------------------------------------
1 | /******/ (function(modules) { // webpackBootstrap
2 | /******/ // install a JSONP callback for chunk loading
3 | /******/ var parentJsonpFunction = window["webpackJsonp"];
4 | /******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules) {
5 | /******/ // add "moreModules" to the modules object,
6 | /******/ // then flag all "chunkIds" as loaded and fire callback
7 | /******/ var moduleId, chunkId, i = 0, callbacks = [];
8 | /******/ for(;i < chunkIds.length; i++) {
9 | /******/ chunkId = chunkIds[i];
10 | /******/ if(installedChunks[chunkId])
11 | /******/ callbacks.push.apply(callbacks, installedChunks[chunkId]);
12 | /******/ installedChunks[chunkId] = 0;
13 | /******/ }
14 | /******/ for(moduleId in moreModules) {
15 | /******/ modules[moduleId] = moreModules[moduleId];
16 | /******/ }
17 | /******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);
18 | /******/ while(callbacks.length)
19 | /******/ callbacks.shift().call(null, __webpack_require__);
20 | /******/ if(moreModules[0]) {
21 | /******/ installedModules[0] = 0;
22 | /******/ return __webpack_require__(0);
23 | /******/ }
24 | /******/ };
25 | /******/
26 | /******/ // The module cache
27 | /******/ var installedModules = {};
28 | /******/
29 | /******/ // object to store loaded and loading chunks
30 | /******/ // "0" means "already loaded"
31 | /******/ // Array means "loading", array contains callbacks
32 | /******/ var installedChunks = {
33 | /******/ 2:0
34 | /******/ };
35 | /******/
36 | /******/ // The require function
37 | /******/ function __webpack_require__(moduleId) {
38 | /******/
39 | /******/ // Check if module is in cache
40 | /******/ if(installedModules[moduleId])
41 | /******/ return installedModules[moduleId].exports;
42 | /******/
43 | /******/ // Create a new module (and put it into the cache)
44 | /******/ var module = installedModules[moduleId] = {
45 | /******/ exports: {},
46 | /******/ id: moduleId,
47 | /******/ loaded: false
48 | /******/ };
49 | /******/
50 | /******/ // Execute the module function
51 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
52 | /******/
53 | /******/ // Flag the module as loaded
54 | /******/ module.loaded = true;
55 | /******/
56 | /******/ // Return the exports of the module
57 | /******/ return module.exports;
58 | /******/ }
59 | /******/
60 | /******/ // This file contains only the entry chunk.
61 | /******/ // The chunk loading function for additional chunks
62 | /******/ __webpack_require__.e = function requireEnsure(chunkId, callback) {
63 | /******/ // "0" is the signal for "already loaded"
64 | /******/ if(installedChunks[chunkId] === 0)
65 | /******/ return callback.call(null, __webpack_require__);
66 | /******/
67 | /******/ // an array means "currently loading".
68 | /******/ if(installedChunks[chunkId] !== undefined) {
69 | /******/ installedChunks[chunkId].push(callback);
70 | /******/ } else {
71 | /******/ // start chunk loading
72 | /******/ installedChunks[chunkId] = [callback];
73 | /******/ var head = document.getElementsByTagName('head')[0];
74 | /******/ var script = document.createElement('script');
75 | /******/ script.type = 'text/javascript';
76 | /******/ script.charset = 'utf-8';
77 | /******/ script.async = true;
78 | /******/
79 | /******/ script.src = __webpack_require__.p + "" + chunkId + ".chunk.js";
80 | /******/ head.appendChild(script);
81 | /******/ }
82 | /******/ };
83 | /******/
84 | /******/ // expose the modules object (__webpack_modules__)
85 | /******/ __webpack_require__.m = modules;
86 | /******/
87 | /******/ // expose the module cache
88 | /******/ __webpack_require__.c = installedModules;
89 | /******/
90 | /******/ // __webpack_public_path__
91 | /******/ __webpack_require__.p = "build/";
92 | /******/ })
93 | /************************************************************************/
94 | /******/ ([]);
95 | //# sourceMappingURL=common.js.map
--------------------------------------------------------------------------------
/build/common.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["webpack:///webpack/bootstrap 2946bad86cd649249795"],"names":[],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA,gBAAQ,oBAAoB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA,YAAI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA","file":"common.js","sourcesContent":[" \t// install a JSONP callback for chunk loading\n \tvar parentJsonpFunction = window[\"webpackJsonp\"];\n \twindow[\"webpackJsonp\"] = function webpackJsonpCallback(chunkIds, moreModules) {\n \t\t// add \"moreModules\" to the modules object,\n \t\t// then flag all \"chunkIds\" as loaded and fire callback\n \t\tvar moduleId, chunkId, i = 0, callbacks = [];\n \t\tfor(;i < chunkIds.length; i++) {\n \t\t\tchunkId = chunkIds[i];\n \t\t\tif(installedChunks[chunkId])\n \t\t\t\tcallbacks.push.apply(callbacks, installedChunks[chunkId]);\n \t\t\tinstalledChunks[chunkId] = 0;\n \t\t}\n \t\tfor(moduleId in moreModules) {\n \t\t\tmodules[moduleId] = moreModules[moduleId];\n \t\t}\n \t\tif(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules);\n \t\twhile(callbacks.length)\n \t\t\tcallbacks.shift().call(null, __webpack_require__);\n \t\tif(moreModules[0]) {\n \t\t\tinstalledModules[0] = 0;\n \t\t\treturn __webpack_require__(0);\n \t\t}\n \t};\n\n \t// The module cache\n \tvar installedModules = {};\n\n \t// object to store loaded and loading chunks\n \t// \"0\" means \"already loaded\"\n \t// Array means \"loading\", array contains callbacks\n \tvar installedChunks = {\n \t\t2:0\n \t};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n \t// This file contains only the entry chunk.\n \t// The chunk loading function for additional chunks\n \t__webpack_require__.e = function requireEnsure(chunkId, callback) {\n \t\t// \"0\" is the signal for \"already loaded\"\n \t\tif(installedChunks[chunkId] === 0)\n \t\t\treturn callback.call(null, __webpack_require__);\n\n \t\t// an array means \"currently loading\".\n \t\tif(installedChunks[chunkId] !== undefined) {\n \t\t\tinstalledChunks[chunkId].push(callback);\n \t\t} else {\n \t\t\t// start chunk loading\n \t\t\tinstalledChunks[chunkId] = [callback];\n \t\t\tvar head = document.getElementsByTagName('head')[0];\n \t\t\tvar script = document.createElement('script');\n \t\t\tscript.type = 'text/javascript';\n \t\t\tscript.charset = 'utf-8';\n \t\t\tscript.async = true;\n\n \t\t\tscript.src = __webpack_require__.p + \"\" + chunkId + \".chunk.js\";\n \t\t\thead.appendChild(script);\n \t\t}\n \t};\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"build/\";\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap 2946bad86cd649249795\n **/"],"sourceRoot":""}
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var electron = require('electron');
2 | var app = electron.app;
3 | var BrowserWindow = electron.BrowserWindow;
4 | var ipc = electron.ipcMain;
5 |
6 |
7 | app.on('ready', ()=>{
8 | var mainWindow = new BrowserWindow({
9 | width: 1280,
10 | height: 720
11 | })
12 | mainWindow.loadURL('file://' + __dirname + '/app/index.html');
13 |
14 | var secondWindow = new BrowserWindow({
15 | width: 800,
16 | height: 600,
17 | show: false
18 | })
19 | secondWindow.loadURL('file://' + __dirname + '/app/second.html');
20 |
21 | ipc.on('open-custom' ,() => {
22 | secondWindow.show();
23 | })
24 |
25 | });
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "angular2desk",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "build": "webpack --progress --profile --colors --display-error-details --display-cached",
8 | "postinstall": "typings install",
9 | "start": "electron ."
10 | },
11 | "author": "Rajayogan",
12 | "license": "MIT",
13 | "devDependencies": {
14 | "electron-prebuilt": "^1.2.2",
15 | "es6-shim": "^0.34.0",
16 | "ts-loader": "^0.7.2",
17 | "typescript": "^1.7.3",
18 | "webpack": "^1.12.9",
19 | "webpack-dev-server": "^1.14.0"
20 | },
21 | "dependencies": {
22 | "@angular/common": "2.0.0-rc.1",
23 | "@angular/compiler": "2.0.0-rc.1",
24 | "@angular/core": "2.0.0-rc.1",
25 | "@angular/http": "2.0.0-rc.1",
26 | "@angular/platform-browser": "2.0.0-rc.1",
27 | "@angular/platform-browser-dynamic": "2.0.0-rc.1",
28 | "@angular/router": "2.0.0-rc.1",
29 | "angular2-in-memory-web-api": "0.0.10",
30 | "es6-shim": "^0.35.0",
31 | "reflect-metadata": "0.1.2",
32 | "rxjs": "5.0.0-beta.6",
33 | "zone.js": "^0.6.12"
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES5",
4 | "module": "commonjs",
5 | "removeComments": true,
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "sourceMap": true
9 | },
10 | "exclude": [
11 | "node_modules",
12 | "typings/main",
13 | "typings/main.d.ts"
14 | ]
15 | }
--------------------------------------------------------------------------------
/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "globalDependencies": {
3 | "core-js": "registry:dt/core-js#0.0.0+20160317120654",
4 | "jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
5 | "node": "registry:dt/node#4.0.0+20160509154515",
6 | "github-electron": "registry:dt/github-electron#0.37.6+20160417155838"
7 | }
8 | }
--------------------------------------------------------------------------------
/typings/globals/core-js/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/core-js/core-js.d.ts",
5 | "raw": "registry:dt/core-js#0.0.0+20160317120654",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/7de6c3dd94feaeb21f20054b9f30d5dabc5efabd/core-js/core-js.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/typings/globals/github-electron/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/cba323eec13cbabcde5b5926156b3f04cfb44496/github-electron/github-electron.d.ts",
5 | "raw": "registry:dt/github-electron#0.37.6+20160417155838",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/cba323eec13cbabcde5b5926156b3f04cfb44496/github-electron/github-electron.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/typings/globals/jasmine/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/36a1be34dbe202c665b3ddafd50824f78c09eea3/jasmine/jasmine.d.ts
3 | declare function describe(description: string, specDefinitions: () => void): void;
4 | declare function fdescribe(description: string, specDefinitions: () => void): void;
5 | declare function xdescribe(description: string, specDefinitions: () => void): void;
6 |
7 | declare function it(expectation: string, assertion?: () => void, timeout?: number): void;
8 | declare function it(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
9 | declare function fit(expectation: string, assertion?: () => void, timeout?: number): void;
10 | declare function fit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
11 | declare function xit(expectation: string, assertion?: () => void, timeout?: number): void;
12 | declare function xit(expectation: string, assertion?: (done: DoneFn) => void, timeout?: number): void;
13 |
14 | /** If you call the function pending anywhere in the spec body, no matter the expectations, the spec will be marked pending. */
15 | declare function pending(reason?: string): void;
16 |
17 | declare function beforeEach(action: () => void, timeout?: number): void;
18 | declare function beforeEach(action: (done: DoneFn) => void, timeout?: number): void;
19 | declare function afterEach(action: () => void, timeout?: number): void;
20 | declare function afterEach(action: (done: DoneFn) => void, timeout?: number): void;
21 |
22 | declare function beforeAll(action: () => void, timeout?: number): void;
23 | declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void;
24 | declare function afterAll(action: () => void, timeout?: number): void;
25 | declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void;
26 |
27 | declare function expect(spy: Function): jasmine.Matchers;
28 | declare function expect(actual: any): jasmine.Matchers;
29 |
30 | declare function fail(e?: any): void;
31 | /** Action method that should be called when the async work is complete */
32 | interface DoneFn extends Function {
33 | (): void;
34 |
35 | /** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */
36 | fail: (message?: Error|string) => void;
37 | }
38 |
39 | declare function spyOn(object: any, method: string): jasmine.Spy;
40 |
41 | declare function runs(asyncMethod: Function): void;
42 | declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, timeout?: number): void;
43 | declare function waits(timeout?: number): void;
44 |
45 | declare namespace jasmine {
46 |
47 | var clock: () => Clock;
48 |
49 | function any(aclass: any): Any;
50 | function anything(): Any;
51 | function arrayContaining(sample: any[]): ArrayContaining;
52 | function objectContaining(sample: any): ObjectContaining;
53 | function createSpy(name: string, originalFn?: Function): Spy;
54 | function createSpyObj(baseName: string, methodNames: any[]): any;
55 | function createSpyObj(baseName: string, methodNames: any[]): T;
56 | function pp(value: any): string;
57 | function getEnv(): Env;
58 | function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
59 | function addMatchers(matchers: CustomMatcherFactories): void;
60 | function stringMatching(str: string): Any;
61 | function stringMatching(str: RegExp): Any;
62 |
63 | interface Any {
64 |
65 | new (expectedClass: any): any;
66 |
67 | jasmineMatches(other: any): boolean;
68 | jasmineToString(): string;
69 | }
70 |
71 | // taken from TypeScript lib.core.es6.d.ts, applicable to CustomMatchers.contains()
72 | interface ArrayLike {
73 | length: number;
74 | [n: number]: T;
75 | }
76 |
77 | interface ArrayContaining {
78 | new (sample: any[]): any;
79 |
80 | asymmetricMatch(other: any): boolean;
81 | jasmineToString(): string;
82 | }
83 |
84 | interface ObjectContaining {
85 | new (sample: any): any;
86 |
87 | jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
88 | jasmineToString(): string;
89 | }
90 |
91 | interface Block {
92 |
93 | new (env: Env, func: SpecFunction, spec: Spec): any;
94 |
95 | execute(onComplete: () => void): void;
96 | }
97 |
98 | interface WaitsBlock extends Block {
99 | new (env: Env, timeout: number, spec: Spec): any;
100 | }
101 |
102 | interface WaitsForBlock extends Block {
103 | new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
104 | }
105 |
106 | interface Clock {
107 | install(): void;
108 | uninstall(): void;
109 | /** Calls to any registered callback are triggered when the clock is ticked forward via the jasmine.clock().tick function, which takes a number of milliseconds. */
110 | tick(ms: number): void;
111 | mockDate(date?: Date): void;
112 | }
113 |
114 | interface CustomEqualityTester {
115 | (first: any, second: any): boolean;
116 | }
117 |
118 | interface CustomMatcher {
119 | compare(actual: T, expected: T): CustomMatcherResult;
120 | compare(actual: any, expected: any): CustomMatcherResult;
121 | }
122 |
123 | interface CustomMatcherFactory {
124 | (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher;
125 | }
126 |
127 | interface CustomMatcherFactories {
128 | [index: string]: CustomMatcherFactory;
129 | }
130 |
131 | interface CustomMatcherResult {
132 | pass: boolean;
133 | message?: string;
134 | }
135 |
136 | interface MatchersUtil {
137 | equals(a: any, b: any, customTesters?: Array): boolean;
138 | contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean;
139 | buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string;
140 | }
141 |
142 | interface Env {
143 | setTimeout: any;
144 | clearTimeout: void;
145 | setInterval: any;
146 | clearInterval: void;
147 | updateInterval: number;
148 |
149 | currentSpec: Spec;
150 |
151 | matchersClass: Matchers;
152 |
153 | version(): any;
154 | versionString(): string;
155 | nextSpecId(): number;
156 | addReporter(reporter: Reporter): void;
157 | execute(): void;
158 | describe(description: string, specDefinitions: () => void): Suite;
159 | // ddescribe(description: string, specDefinitions: () => void): Suite; Not a part of jasmine. Angular team adds these
160 | beforeEach(beforeEachFunction: () => void): void;
161 | beforeAll(beforeAllFunction: () => void): void;
162 | currentRunner(): Runner;
163 | afterEach(afterEachFunction: () => void): void;
164 | afterAll(afterAllFunction: () => void): void;
165 | xdescribe(desc: string, specDefinitions: () => void): XSuite;
166 | it(description: string, func: () => void): Spec;
167 | // iit(description: string, func: () => void): Spec; Not a part of jasmine. Angular team adds these
168 | xit(desc: string, func: () => void): XSpec;
169 | compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
170 | compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
171 | equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
172 | contains_(haystack: any, needle: any): boolean;
173 | addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
174 | addMatchers(matchers: CustomMatcherFactories): void;
175 | specFilter(spec: Spec): boolean;
176 | }
177 |
178 | interface FakeTimer {
179 |
180 | new (): any;
181 |
182 | reset(): void;
183 | tick(millis: number): void;
184 | runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
185 | scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
186 | }
187 |
188 | interface HtmlReporter {
189 | new (): any;
190 | }
191 |
192 | interface HtmlSpecFilter {
193 | new (): any;
194 | }
195 |
196 | interface Result {
197 | type: string;
198 | }
199 |
200 | interface NestedResults extends Result {
201 | description: string;
202 |
203 | totalCount: number;
204 | passedCount: number;
205 | failedCount: number;
206 |
207 | skipped: boolean;
208 |
209 | rollupCounts(result: NestedResults): void;
210 | log(values: any): void;
211 | getItems(): Result[];
212 | addResult(result: Result): void;
213 | passed(): boolean;
214 | }
215 |
216 | interface MessageResult extends Result {
217 | values: any;
218 | trace: Trace;
219 | }
220 |
221 | interface ExpectationResult extends Result {
222 | matcherName: string;
223 | passed(): boolean;
224 | expected: any;
225 | actual: any;
226 | message: string;
227 | trace: Trace;
228 | }
229 |
230 | interface Trace {
231 | name: string;
232 | message: string;
233 | stack: any;
234 | }
235 |
236 | interface PrettyPrinter {
237 |
238 | new (): any;
239 |
240 | format(value: any): void;
241 | iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
242 | emitScalar(value: any): void;
243 | emitString(value: string): void;
244 | emitArray(array: any[]): void;
245 | emitObject(obj: any): void;
246 | append(value: any): void;
247 | }
248 |
249 | interface StringPrettyPrinter extends PrettyPrinter {
250 | }
251 |
252 | interface Queue {
253 |
254 | new (env: any): any;
255 |
256 | env: Env;
257 | ensured: boolean[];
258 | blocks: Block[];
259 | running: boolean;
260 | index: number;
261 | offset: number;
262 | abort: boolean;
263 |
264 | addBefore(block: Block, ensure?: boolean): void;
265 | add(block: any, ensure?: boolean): void;
266 | insertNext(block: any, ensure?: boolean): void;
267 | start(onComplete?: () => void): void;
268 | isRunning(): boolean;
269 | next_(): void;
270 | results(): NestedResults;
271 | }
272 |
273 | interface Matchers {
274 |
275 | new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
276 |
277 | env: Env;
278 | actual: any;
279 | spec: Env;
280 | isNot?: boolean;
281 | message(): any;
282 |
283 | toBe(expected: any, expectationFailOutput?: any): boolean;
284 | toEqual(expected: any, expectationFailOutput?: any): boolean;
285 | toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean;
286 | toBeDefined(expectationFailOutput?: any): boolean;
287 | toBeUndefined(expectationFailOutput?: any): boolean;
288 | toBeNull(expectationFailOutput?: any): boolean;
289 | toBeNaN(): boolean;
290 | toBeTruthy(expectationFailOutput?: any): boolean;
291 | toBeFalsy(expectationFailOutput?: any): boolean;
292 | toHaveBeenCalled(): boolean;
293 | toHaveBeenCalledWith(...params: any[]): boolean;
294 | toHaveBeenCalledTimes(expected: number): boolean;
295 | toContain(expected: any, expectationFailOutput?: any): boolean;
296 | toBeLessThan(expected: number, expectationFailOutput?: any): boolean;
297 | toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean;
298 | toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean;
299 | toThrow(expected?: any): boolean;
300 | toThrowError(message?: string | RegExp): boolean;
301 | toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean;
302 | not: Matchers;
303 |
304 | Any: Any;
305 | }
306 |
307 | interface Reporter {
308 | reportRunnerStarting(runner: Runner): void;
309 | reportRunnerResults(runner: Runner): void;
310 | reportSuiteResults(suite: Suite): void;
311 | reportSpecStarting(spec: Spec): void;
312 | reportSpecResults(spec: Spec): void;
313 | log(str: string): void;
314 | }
315 |
316 | interface MultiReporter extends Reporter {
317 | addReporter(reporter: Reporter): void;
318 | }
319 |
320 | interface Runner {
321 |
322 | new (env: Env): any;
323 |
324 | execute(): void;
325 | beforeEach(beforeEachFunction: SpecFunction): void;
326 | afterEach(afterEachFunction: SpecFunction): void;
327 | beforeAll(beforeAllFunction: SpecFunction): void;
328 | afterAll(afterAllFunction: SpecFunction): void;
329 | finishCallback(): void;
330 | addSuite(suite: Suite): void;
331 | add(block: Block): void;
332 | specs(): Spec[];
333 | suites(): Suite[];
334 | topLevelSuites(): Suite[];
335 | results(): NestedResults;
336 | }
337 |
338 | interface SpecFunction {
339 | (spec?: Spec): void;
340 | }
341 |
342 | interface SuiteOrSpec {
343 | id: number;
344 | env: Env;
345 | description: string;
346 | queue: Queue;
347 | }
348 |
349 | interface Spec extends SuiteOrSpec {
350 |
351 | new (env: Env, suite: Suite, description: string): any;
352 |
353 | suite: Suite;
354 |
355 | afterCallbacks: SpecFunction[];
356 | spies_: Spy[];
357 |
358 | results_: NestedResults;
359 | matchersClass: Matchers;
360 |
361 | getFullName(): string;
362 | results(): NestedResults;
363 | log(arguments: any): any;
364 | runs(func: SpecFunction): Spec;
365 | addToQueue(block: Block): void;
366 | addMatcherResult(result: Result): void;
367 | expect(actual: any): any;
368 | waits(timeout: number): Spec;
369 | waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
370 | fail(e?: any): void;
371 | getMatchersClass_(): Matchers;
372 | addMatchers(matchersPrototype: CustomMatcherFactories): void;
373 | finishCallback(): void;
374 | finish(onComplete?: () => void): void;
375 | after(doAfter: SpecFunction): void;
376 | execute(onComplete?: () => void): any;
377 | addBeforesAndAftersToQueue(): void;
378 | explodes(): void;
379 | spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
380 | removeAllSpies(): void;
381 | }
382 |
383 | interface XSpec {
384 | id: number;
385 | runs(): void;
386 | }
387 |
388 | interface Suite extends SuiteOrSpec {
389 |
390 | new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
391 |
392 | parentSuite: Suite;
393 |
394 | getFullName(): string;
395 | finish(onComplete?: () => void): void;
396 | beforeEach(beforeEachFunction: SpecFunction): void;
397 | afterEach(afterEachFunction: SpecFunction): void;
398 | beforeAll(beforeAllFunction: SpecFunction): void;
399 | afterAll(afterAllFunction: SpecFunction): void;
400 | results(): NestedResults;
401 | add(suiteOrSpec: SuiteOrSpec): void;
402 | specs(): Spec[];
403 | suites(): Suite[];
404 | children(): any[];
405 | execute(onComplete?: () => void): void;
406 | }
407 |
408 | interface XSuite {
409 | execute(): void;
410 | }
411 |
412 | interface Spy {
413 | (...params: any[]): any;
414 |
415 | identity: string;
416 | and: SpyAnd;
417 | calls: Calls;
418 | mostRecentCall: { args: any[]; };
419 | argsForCall: any[];
420 | wasCalled: boolean;
421 | }
422 |
423 | interface SpyAnd {
424 | /** By chaining the spy with and.callThrough, the spy will still track all calls to it but in addition it will delegate to the actual implementation. */
425 | callThrough(): Spy;
426 | /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */
427 | returnValue(val: any): Spy;
428 | /** By chaining the spy with and.returnValues, all calls to the function will return specific values in order until it reaches the end of the return values list. */
429 | returnValues(...values: any[]): Spy;
430 | /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */
431 | callFake(fn: Function): Spy;
432 | /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */
433 | throwError(msg: string): Spy;
434 | /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */
435 | stub(): Spy;
436 | }
437 |
438 | interface Calls {
439 | /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/
440 | any(): boolean;
441 | /** By chaining the spy with calls.count(), will return the number of times the spy was called **/
442 | count(): number;
443 | /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/
444 | argsFor(index: number): any[];
445 | /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/
446 | allArgs(): any[];
447 | /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/
448 | all(): CallInfo[];
449 | /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/
450 | mostRecent(): CallInfo;
451 | /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/
452 | first(): CallInfo;
453 | /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/
454 | reset(): void;
455 | }
456 |
457 | interface CallInfo {
458 | /** The context (the this) for the call */
459 | object: any;
460 | /** All arguments passed to the call */
461 | args: any[];
462 | /** The return value of the call */
463 | returnValue: any;
464 | }
465 |
466 | interface Util {
467 | inherit(childClass: Function, parentClass: Function): any;
468 | formatException(e: any): any;
469 | htmlEscape(str: string): string;
470 | argsToArray(args: any): any;
471 | extend(destination: any, source: any): any;
472 | }
473 |
474 | interface JsApiReporter extends Reporter {
475 |
476 | started: boolean;
477 | finished: boolean;
478 | result: any;
479 | messages: any;
480 |
481 | new (): any;
482 |
483 | suites(): Suite[];
484 | summarize_(suiteOrSpec: SuiteOrSpec): any;
485 | results(): any;
486 | resultsForSpec(specId: any): any;
487 | log(str: any): any;
488 | resultsForSpecs(specIds: any): any;
489 | summarizeResult_(result: any): any;
490 | }
491 |
492 | interface Jasmine {
493 | Spec: Spec;
494 | clock: Clock;
495 | util: Util;
496 | }
497 |
498 | export var HtmlReporter: HtmlReporter;
499 | export var HtmlSpecFilter: HtmlSpecFilter;
500 | export var DEFAULT_TIMEOUT_INTERVAL: number;
501 | }
--------------------------------------------------------------------------------
/typings/globals/jasmine/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/36a1be34dbe202c665b3ddafd50824f78c09eea3/jasmine/jasmine.d.ts",
5 | "raw": "registry:dt/jasmine#2.2.0+20160505161446",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/36a1be34dbe202c665b3ddafd50824f78c09eea3/jasmine/jasmine.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/typings/globals/node/index.d.ts:
--------------------------------------------------------------------------------
1 | // Generated by typings
2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6d0e826824da52204c1c93f92cecbc961ac84fa9/node/node.d.ts
3 | interface Error {
4 | stack?: string;
5 | }
6 |
7 |
8 | // compat for TypeScript 1.8
9 | // if you use with --target es3 or --target es5 and use below definitions,
10 | // use the lib.es6.d.ts that is bundled with TypeScript 1.8.
11 | interface MapConstructor {}
12 | interface WeakMapConstructor {}
13 | interface SetConstructor {}
14 | interface WeakSetConstructor {}
15 |
16 | /************************************************
17 | * *
18 | * GLOBAL *
19 | * *
20 | ************************************************/
21 | declare var process: NodeJS.Process;
22 | declare var global: NodeJS.Global;
23 |
24 | declare var __filename: string;
25 | declare var __dirname: string;
26 |
27 | declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
28 | declare function clearTimeout(timeoutId: NodeJS.Timer): void;
29 | declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer;
30 | declare function clearInterval(intervalId: NodeJS.Timer): void;
31 | declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any;
32 | declare function clearImmediate(immediateId: any): void;
33 |
34 | interface NodeRequireFunction {
35 | (id: string): any;
36 | }
37 |
38 | interface NodeRequire extends NodeRequireFunction {
39 | resolve(id:string): string;
40 | cache: any;
41 | extensions: any;
42 | main: any;
43 | }
44 |
45 | declare var require: NodeRequire;
46 |
47 | interface NodeModule {
48 | exports: any;
49 | require: NodeRequireFunction;
50 | id: string;
51 | filename: string;
52 | loaded: boolean;
53 | parent: any;
54 | children: any[];
55 | }
56 |
57 | declare var module: NodeModule;
58 |
59 | // Same as module.exports
60 | declare var exports: any;
61 | declare var SlowBuffer: {
62 | new (str: string, encoding?: string): Buffer;
63 | new (size: number): Buffer;
64 | new (size: Uint8Array): Buffer;
65 | new (array: any[]): Buffer;
66 | prototype: Buffer;
67 | isBuffer(obj: any): boolean;
68 | byteLength(string: string, encoding?: string): number;
69 | concat(list: Buffer[], totalLength?: number): Buffer;
70 | };
71 |
72 |
73 | // Buffer class
74 | type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "binary" | "hex";
75 | interface Buffer extends NodeBuffer {}
76 |
77 | /**
78 | * Raw data is stored in instances of the Buffer class.
79 | * 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.
80 | * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
81 | */
82 | declare var Buffer: {
83 | /**
84 | * Allocates a new buffer containing the given {str}.
85 | *
86 | * @param str String to store in buffer.
87 | * @param encoding encoding to use, optional. Default is 'utf8'
88 | */
89 | new (str: string, encoding?: string): Buffer;
90 | /**
91 | * Allocates a new buffer of {size} octets.
92 | *
93 | * @param size count of octets to allocate.
94 | */
95 | new (size: number): Buffer;
96 | /**
97 | * Allocates a new buffer containing the given {array} of octets.
98 | *
99 | * @param array The octets to store.
100 | */
101 | new (array: Uint8Array): Buffer;
102 | /**
103 | * Produces a Buffer backed by the same allocated memory as
104 | * the given {ArrayBuffer}.
105 | *
106 | *
107 | * @param arrayBuffer The ArrayBuffer with which to share memory.
108 | */
109 | new (arrayBuffer: ArrayBuffer): Buffer;
110 | /**
111 | * Allocates a new buffer containing the given {array} of octets.
112 | *
113 | * @param array The octets to store.
114 | */
115 | new (array: any[]): Buffer;
116 | /**
117 | * Copies the passed {buffer} data onto a new {Buffer} instance.
118 | *
119 | * @param buffer The buffer to copy.
120 | */
121 | new (buffer: Buffer): Buffer;
122 | prototype: Buffer;
123 | /**
124 | * Allocates a new Buffer using an {array} of octets.
125 | *
126 | * @param array
127 | */
128 | from(array: any[]): Buffer;
129 | /**
130 | * When passed a reference to the .buffer property of a TypedArray instance,
131 | * the newly created Buffer will share the same allocated memory as the TypedArray.
132 | * The optional {byteOffset} and {length} arguments specify a memory range
133 | * within the {arrayBuffer} that will be shared by the Buffer.
134 | *
135 | * @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
136 | * @param byteOffset
137 | * @param length
138 | */
139 | from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?:number): Buffer;
140 | /**
141 | * Copies the passed {buffer} data onto a new Buffer instance.
142 | *
143 | * @param buffer
144 | */
145 | from(buffer: Buffer): Buffer;
146 | /**
147 | * Creates a new Buffer containing the given JavaScript string {str}.
148 | * If provided, the {encoding} parameter identifies the character encoding.
149 | * If not provided, {encoding} defaults to 'utf8'.
150 | *
151 | * @param str
152 | */
153 | from(str: string, encoding?: string): Buffer;
154 | /**
155 | * Returns true if {obj} is a Buffer
156 | *
157 | * @param obj object to test.
158 | */
159 | isBuffer(obj: any): obj is Buffer;
160 | /**
161 | * Returns true if {encoding} is a valid encoding argument.
162 | * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
163 | *
164 | * @param encoding string to test.
165 | */
166 | isEncoding(encoding: string): boolean;
167 | /**
168 | * Gives the actual byte length of a string. encoding defaults to 'utf8'.
169 | * This is not the same as String.prototype.length since that returns the number of characters in a string.
170 | *
171 | * @param string string to test.
172 | * @param encoding encoding used to evaluate (defaults to 'utf8')
173 | */
174 | byteLength(string: string, encoding?: string): number;
175 | /**
176 | * Returns a buffer which is the result of concatenating all the buffers in the list together.
177 | *
178 | * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
179 | * If the list has exactly one item, then the first item of the list is returned.
180 | * If the list has more than one item, then a new Buffer is created.
181 | *
182 | * @param list An array of Buffer objects to concatenate
183 | * @param totalLength Total length of the buffers when concatenated.
184 | * 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.
185 | */
186 | concat(list: Buffer[], totalLength?: number): Buffer;
187 | /**
188 | * The same as buf1.compare(buf2).
189 | */
190 | compare(buf1: Buffer, buf2: Buffer): number;
191 | };
192 |
193 | /************************************************
194 | * *
195 | * GLOBAL INTERFACES *
196 | * *
197 | ************************************************/
198 | declare namespace NodeJS {
199 | export interface ErrnoException extends Error {
200 | errno?: number;
201 | code?: string;
202 | path?: string;
203 | syscall?: string;
204 | stack?: string;
205 | }
206 |
207 | export interface EventEmitter {
208 | addListener(event: string, listener: Function): this;
209 | on(event: string, listener: Function): this;
210 | once(event: string, listener: Function): this;
211 | removeListener(event: string, listener: Function): this;
212 | removeAllListeners(event?: string): this;
213 | setMaxListeners(n: number): this;
214 | getMaxListeners(): number;
215 | listeners(event: string): Function[];
216 | emit(event: string, ...args: any[]): boolean;
217 | listenerCount(type: string): number;
218 | }
219 |
220 | export interface ReadableStream extends EventEmitter {
221 | readable: boolean;
222 | read(size?: number): string|Buffer;
223 | setEncoding(encoding: string): void;
224 | pause(): void;
225 | resume(): void;
226 | pipe(destination: T, options?: { end?: boolean; }): T;
227 | unpipe(destination?: T): void;
228 | unshift(chunk: string): void;
229 | unshift(chunk: Buffer): void;
230 | wrap(oldStream: ReadableStream): ReadableStream;
231 | }
232 |
233 | export interface WritableStream extends EventEmitter {
234 | writable: boolean;
235 | write(buffer: Buffer|string, cb?: Function): boolean;
236 | write(str: string, encoding?: string, cb?: Function): boolean;
237 | end(): void;
238 | end(buffer: Buffer, cb?: Function): void;
239 | end(str: string, cb?: Function): void;
240 | end(str: string, encoding?: string, cb?: Function): void;
241 | }
242 |
243 | export interface ReadWriteStream extends ReadableStream, WritableStream {}
244 |
245 | export interface Events extends EventEmitter { }
246 |
247 | export interface Domain extends Events {
248 | run(fn: Function): void;
249 | add(emitter: Events): void;
250 | remove(emitter: Events): void;
251 | bind(cb: (err: Error, data: any) => any): any;
252 | intercept(cb: (data: any) => any): any;
253 | dispose(): void;
254 |
255 | addListener(event: string, listener: Function): this;
256 | on(event: string, listener: Function): this;
257 | once(event: string, listener: Function): this;
258 | removeListener(event: string, listener: Function): this;
259 | removeAllListeners(event?: string): this;
260 | }
261 |
262 | export interface MemoryUsage {
263 | rss: number;
264 | heapTotal: number;
265 | heapUsed: number;
266 | }
267 |
268 | export interface Process extends EventEmitter {
269 | stdout: WritableStream;
270 | stderr: WritableStream;
271 | stdin: ReadableStream;
272 | argv: string[];
273 | execArgv: string[];
274 | execPath: string;
275 | abort(): void;
276 | chdir(directory: string): void;
277 | cwd(): string;
278 | env: any;
279 | exit(code?: number): void;
280 | getgid(): number;
281 | setgid(id: number): void;
282 | setgid(id: string): void;
283 | getuid(): number;
284 | setuid(id: number): void;
285 | setuid(id: string): void;
286 | version: string;
287 | versions: {
288 | http_parser: string;
289 | node: string;
290 | v8: string;
291 | ares: string;
292 | uv: string;
293 | zlib: string;
294 | openssl: string;
295 | };
296 | config: {
297 | target_defaults: {
298 | cflags: any[];
299 | default_configuration: string;
300 | defines: string[];
301 | include_dirs: string[];
302 | libraries: string[];
303 | };
304 | variables: {
305 | clang: number;
306 | host_arch: string;
307 | node_install_npm: boolean;
308 | node_install_waf: boolean;
309 | node_prefix: string;
310 | node_shared_openssl: boolean;
311 | node_shared_v8: boolean;
312 | node_shared_zlib: boolean;
313 | node_use_dtrace: boolean;
314 | node_use_etw: boolean;
315 | node_use_openssl: boolean;
316 | target_arch: string;
317 | v8_no_strict_aliasing: number;
318 | v8_use_snapshot: boolean;
319 | visibility: string;
320 | };
321 | };
322 | kill(pid:number, signal?: string|number): void;
323 | pid: number;
324 | title: string;
325 | arch: string;
326 | platform: string;
327 | memoryUsage(): MemoryUsage;
328 | nextTick(callback: Function): void;
329 | umask(mask?: number): number;
330 | uptime(): number;
331 | hrtime(time?:number[]): number[];
332 | domain: Domain;
333 |
334 | // Worker
335 | send?(message: any, sendHandle?: any): void;
336 | disconnect(): void;
337 | connected: boolean;
338 | }
339 |
340 | export interface Global {
341 | Array: typeof Array;
342 | ArrayBuffer: typeof ArrayBuffer;
343 | Boolean: typeof Boolean;
344 | Buffer: typeof Buffer;
345 | DataView: typeof DataView;
346 | Date: typeof Date;
347 | Error: typeof Error;
348 | EvalError: typeof EvalError;
349 | Float32Array: typeof Float32Array;
350 | Float64Array: typeof Float64Array;
351 | Function: typeof Function;
352 | GLOBAL: Global;
353 | Infinity: typeof Infinity;
354 | Int16Array: typeof Int16Array;
355 | Int32Array: typeof Int32Array;
356 | Int8Array: typeof Int8Array;
357 | Intl: typeof Intl;
358 | JSON: typeof JSON;
359 | Map: MapConstructor;
360 | Math: typeof Math;
361 | NaN: typeof NaN;
362 | Number: typeof Number;
363 | Object: typeof Object;
364 | Promise: Function;
365 | RangeError: typeof RangeError;
366 | ReferenceError: typeof ReferenceError;
367 | RegExp: typeof RegExp;
368 | Set: SetConstructor;
369 | String: typeof String;
370 | Symbol: Function;
371 | SyntaxError: typeof SyntaxError;
372 | TypeError: typeof TypeError;
373 | URIError: typeof URIError;
374 | Uint16Array: typeof Uint16Array;
375 | Uint32Array: typeof Uint32Array;
376 | Uint8Array: typeof Uint8Array;
377 | Uint8ClampedArray: Function;
378 | WeakMap: WeakMapConstructor;
379 | WeakSet: WeakSetConstructor;
380 | clearImmediate: (immediateId: any) => void;
381 | clearInterval: (intervalId: NodeJS.Timer) => void;
382 | clearTimeout: (timeoutId: NodeJS.Timer) => void;
383 | console: typeof console;
384 | decodeURI: typeof decodeURI;
385 | decodeURIComponent: typeof decodeURIComponent;
386 | encodeURI: typeof encodeURI;
387 | encodeURIComponent: typeof encodeURIComponent;
388 | escape: (str: string) => string;
389 | eval: typeof eval;
390 | global: Global;
391 | isFinite: typeof isFinite;
392 | isNaN: typeof isNaN;
393 | parseFloat: typeof parseFloat;
394 | parseInt: typeof parseInt;
395 | process: Process;
396 | root: Global;
397 | setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any;
398 | setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
399 | setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer;
400 | undefined: typeof undefined;
401 | unescape: (str: string) => string;
402 | gc: () => void;
403 | v8debug?: any;
404 | }
405 |
406 | export interface Timer {
407 | ref() : void;
408 | unref() : void;
409 | }
410 | }
411 |
412 | /**
413 | * @deprecated
414 | */
415 | interface NodeBuffer extends Uint8Array {
416 | write(string: string, offset?: number, length?: number, encoding?: string): number;
417 | toString(encoding?: string, start?: number, end?: number): string;
418 | toJSON(): any;
419 | equals(otherBuffer: Buffer): boolean;
420 | compare(otherBuffer: Buffer): number;
421 | copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
422 | slice(start?: number, end?: number): Buffer;
423 | writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
424 | writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
425 | writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
426 | writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
427 | readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
428 | readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
429 | readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
430 | readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
431 | readUInt8(offset: number, noAssert?: boolean): number;
432 | readUInt16LE(offset: number, noAssert?: boolean): number;
433 | readUInt16BE(offset: number, noAssert?: boolean): number;
434 | readUInt32LE(offset: number, noAssert?: boolean): number;
435 | readUInt32BE(offset: number, noAssert?: boolean): number;
436 | readInt8(offset: number, noAssert?: boolean): number;
437 | readInt16LE(offset: number, noAssert?: boolean): number;
438 | readInt16BE(offset: number, noAssert?: boolean): number;
439 | readInt32LE(offset: number, noAssert?: boolean): number;
440 | readInt32BE(offset: number, noAssert?: boolean): number;
441 | readFloatLE(offset: number, noAssert?: boolean): number;
442 | readFloatBE(offset: number, noAssert?: boolean): number;
443 | readDoubleLE(offset: number, noAssert?: boolean): number;
444 | readDoubleBE(offset: number, noAssert?: boolean): number;
445 | writeUInt8(value: number, offset: number, noAssert?: boolean): number;
446 | writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
447 | writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
448 | writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
449 | writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
450 | writeInt8(value: number, offset: number, noAssert?: boolean): number;
451 | writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
452 | writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
453 | writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
454 | writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
455 | writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
456 | writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
457 | writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
458 | writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
459 | fill(value: any, offset?: number, end?: number): Buffer;
460 | // TODO: encoding param
461 | indexOf(value: string | number | Buffer, byteOffset?: number): number;
462 | // TODO: entries
463 | // TODO: includes
464 | // TODO: keys
465 | // TODO: values
466 | }
467 |
468 | /************************************************
469 | * *
470 | * MODULES *
471 | * *
472 | ************************************************/
473 | declare module "buffer" {
474 | export var INSPECT_MAX_BYTES: number;
475 | var BuffType: typeof Buffer;
476 | var SlowBuffType: typeof SlowBuffer;
477 | export { BuffType as Buffer, SlowBuffType as SlowBuffer };
478 | }
479 |
480 | declare module "querystring" {
481 | export interface StringifyOptions {
482 | encodeURIComponent?: Function;
483 | }
484 |
485 | export interface ParseOptions {
486 | maxKeys?: number;
487 | decodeURIComponent?: Function;
488 | }
489 |
490 | export function stringify(obj: T, sep?: string, eq?: string, options?: StringifyOptions): string;
491 | export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): any;
492 | export function parse(str: string, sep?: string, eq?: string, options?: ParseOptions): T;
493 | export function escape(str: string): string;
494 | export function unescape(str: string): string;
495 | }
496 |
497 | declare module "events" {
498 | export class EventEmitter implements NodeJS.EventEmitter {
499 | static EventEmitter: EventEmitter;
500 | static listenerCount(emitter: EventEmitter, event: string): number; // deprecated
501 | static defaultMaxListeners: number;
502 |
503 | addListener(event: string, listener: Function): this;
504 | on(event: string, listener: Function): this;
505 | once(event: string, listener: Function): this;
506 | removeListener(event: string, listener: Function): this;
507 | removeAllListeners(event?: string): this;
508 | setMaxListeners(n: number): this;
509 | getMaxListeners(): number;
510 | listeners(event: string): Function[];
511 | emit(event: string, ...args: any[]): boolean;
512 | listenerCount(type: string): number;
513 | }
514 | }
515 |
516 | declare module "http" {
517 | import * as events from "events";
518 | import * as net from "net";
519 | import * as stream from "stream";
520 |
521 | export interface RequestOptions {
522 | protocol?: string;
523 | host?: string;
524 | hostname?: string;
525 | family?: number;
526 | port?: number;
527 | localAddress?: string;
528 | socketPath?: string;
529 | method?: string;
530 | path?: string;
531 | headers?: { [key: string]: any };
532 | auth?: string;
533 | agent?: Agent|boolean;
534 | }
535 |
536 | export interface Server extends events.EventEmitter, net.Server {
537 | setTimeout(msecs: number, callback: Function): void;
538 | maxHeadersCount: number;
539 | timeout: number;
540 | }
541 | /**
542 | * @deprecated Use IncomingMessage
543 | */
544 | export interface ServerRequest extends IncomingMessage {
545 | connection: net.Socket;
546 | }
547 | export interface ServerResponse extends events.EventEmitter, stream.Writable {
548 | // Extended base methods
549 | write(buffer: Buffer): boolean;
550 | write(buffer: Buffer, cb?: Function): boolean;
551 | write(str: string, cb?: Function): boolean;
552 | write(str: string, encoding?: string, cb?: Function): boolean;
553 | write(str: string, encoding?: string, fd?: string): boolean;
554 |
555 | writeContinue(): void;
556 | writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void;
557 | writeHead(statusCode: number, headers?: any): void;
558 | statusCode: number;
559 | statusMessage: string;
560 | headersSent: boolean;
561 | setHeader(name: string, value: string | string[]): void;
562 | sendDate: boolean;
563 | getHeader(name: string): string;
564 | removeHeader(name: string): void;
565 | write(chunk: any, encoding?: string): any;
566 | addTrailers(headers: any): void;
567 |
568 | // Extended base methods
569 | end(): void;
570 | end(buffer: Buffer, cb?: Function): void;
571 | end(str: string, cb?: Function): void;
572 | end(str: string, encoding?: string, cb?: Function): void;
573 | end(data?: any, encoding?: string): void;
574 | }
575 | export interface ClientRequest extends events.EventEmitter, stream.Writable {
576 | // Extended base methods
577 | write(buffer: Buffer): boolean;
578 | write(buffer: Buffer, cb?: Function): boolean;
579 | write(str: string, cb?: Function): boolean;
580 | write(str: string, encoding?: string, cb?: Function): boolean;
581 | write(str: string, encoding?: string, fd?: string): boolean;
582 |
583 | write(chunk: any, encoding?: string): void;
584 | abort(): void;
585 | setTimeout(timeout: number, callback?: Function): void;
586 | setNoDelay(noDelay?: boolean): void;
587 | setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
588 |
589 | setHeader(name: string, value: string | string[]): void;
590 | getHeader(name: string): string;
591 | removeHeader(name: string): void;
592 | addTrailers(headers: any): void;
593 |
594 | // Extended base methods
595 | end(): void;
596 | end(buffer: Buffer, cb?: Function): void;
597 | end(str: string, cb?: Function): void;
598 | end(str: string, encoding?: string, cb?: Function): void;
599 | end(data?: any, encoding?: string): void;
600 | }
601 | export interface IncomingMessage extends events.EventEmitter, stream.Readable {
602 | httpVersion: string;
603 | headers: any;
604 | rawHeaders: string[];
605 | trailers: any;
606 | rawTrailers: any;
607 | setTimeout(msecs: number, callback: Function): NodeJS.Timer;
608 | /**
609 | * Only valid for request obtained from http.Server.
610 | */
611 | method?: string;
612 | /**
613 | * Only valid for request obtained from http.Server.
614 | */
615 | url?: string;
616 | /**
617 | * Only valid for response obtained from http.ClientRequest.
618 | */
619 | statusCode?: number;
620 | /**
621 | * Only valid for response obtained from http.ClientRequest.
622 | */
623 | statusMessage?: string;
624 | socket: net.Socket;
625 | }
626 | /**
627 | * @deprecated Use IncomingMessage
628 | */
629 | export interface ClientResponse extends IncomingMessage { }
630 |
631 | export interface AgentOptions {
632 | /**
633 | * Keep sockets around in a pool to be used by other requests in the future. Default = false
634 | */
635 | keepAlive?: boolean;
636 | /**
637 | * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
638 | * Only relevant if keepAlive is set to true.
639 | */
640 | keepAliveMsecs?: number;
641 | /**
642 | * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
643 | */
644 | maxSockets?: number;
645 | /**
646 | * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
647 | */
648 | maxFreeSockets?: number;
649 | }
650 |
651 | export class Agent {
652 | maxSockets: number;
653 | sockets: any;
654 | requests: any;
655 |
656 | constructor(opts?: AgentOptions);
657 |
658 | /**
659 | * Destroy any sockets that are currently in use by the agent.
660 | * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled,
661 | * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise,
662 | * sockets may hang open for quite a long time before the server terminates them.
663 | */
664 | destroy(): void;
665 | }
666 |
667 | export var METHODS: string[];
668 |
669 | export var STATUS_CODES: {
670 | [errorCode: number]: string;
671 | [errorCode: string]: string;
672 | };
673 | export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server;
674 | export function createClient(port?: number, host?: string): any;
675 | export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
676 | export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest;
677 | export var globalAgent: Agent;
678 | }
679 |
680 | declare module "cluster" {
681 | import * as child from "child_process";
682 | import * as events from "events";
683 |
684 | export interface ClusterSettings {
685 | exec?: string;
686 | args?: string[];
687 | silent?: boolean;
688 | }
689 |
690 | export interface Address {
691 | address: string;
692 | port: number;
693 | addressType: string;
694 | }
695 |
696 | export class Worker extends events.EventEmitter {
697 | id: string;
698 | process: child.ChildProcess;
699 | suicide: boolean;
700 | send(message: any, sendHandle?: any): void;
701 | kill(signal?: string): void;
702 | destroy(signal?: string): void;
703 | disconnect(): void;
704 | isConnected(): boolean;
705 | isDead(): boolean;
706 | }
707 |
708 | export var settings: ClusterSettings;
709 | export var isMaster: boolean;
710 | export var isWorker: boolean;
711 | export function setupMaster(settings?: ClusterSettings): void;
712 | export function fork(env?: any): Worker;
713 | export function disconnect(callback?: Function): void;
714 | export var worker: Worker;
715 | export var workers: {
716 | [index: string]: Worker
717 | };
718 |
719 | // Event emitter
720 | export function addListener(event: string, listener: Function): void;
721 | export function on(event: "disconnect", listener: (worker: Worker) => void): void;
722 | export function on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): void;
723 | export function on(event: "fork", listener: (worker: Worker) => void): void;
724 | export function on(event: "listening", listener: (worker: Worker, address: any) => void): void;
725 | export function on(event: "message", listener: (worker: Worker, message: any) => void): void;
726 | export function on(event: "online", listener: (worker: Worker) => void): void;
727 | export function on(event: "setup", listener: (settings: any) => void): void;
728 | export function on(event: string, listener: Function): any;
729 | export function once(event: string, listener: Function): void;
730 | export function removeListener(event: string, listener: Function): void;
731 | export function removeAllListeners(event?: string): void;
732 | export function setMaxListeners(n: number): void;
733 | export function listeners(event: string): Function[];
734 | export function emit(event: string, ...args: any[]): boolean;
735 | }
736 |
737 | declare module "zlib" {
738 | import * as stream from "stream";
739 | export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; }
740 |
741 | export interface Gzip extends stream.Transform { }
742 | export interface Gunzip extends stream.Transform { }
743 | export interface Deflate extends stream.Transform { }
744 | export interface Inflate extends stream.Transform { }
745 | export interface DeflateRaw extends stream.Transform { }
746 | export interface InflateRaw extends stream.Transform { }
747 | export interface Unzip extends stream.Transform { }
748 |
749 | export function createGzip(options?: ZlibOptions): Gzip;
750 | export function createGunzip(options?: ZlibOptions): Gunzip;
751 | export function createDeflate(options?: ZlibOptions): Deflate;
752 | export function createInflate(options?: ZlibOptions): Inflate;
753 | export function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
754 | export function createInflateRaw(options?: ZlibOptions): InflateRaw;
755 | export function createUnzip(options?: ZlibOptions): Unzip;
756 |
757 | export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
758 | export function deflateSync(buf: Buffer, options?: ZlibOptions): any;
759 | export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
760 | export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any;
761 | export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
762 | export function gzipSync(buf: Buffer, options?: ZlibOptions): any;
763 | export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
764 | export function gunzipSync(buf: Buffer, options?: ZlibOptions): any;
765 | export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
766 | export function inflateSync(buf: Buffer, options?: ZlibOptions): any;
767 | export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
768 | export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any;
769 | export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void;
770 | export function unzipSync(buf: Buffer, options?: ZlibOptions): any;
771 |
772 | // Constants
773 | export var Z_NO_FLUSH: number;
774 | export var Z_PARTIAL_FLUSH: number;
775 | export var Z_SYNC_FLUSH: number;
776 | export var Z_FULL_FLUSH: number;
777 | export var Z_FINISH: number;
778 | export var Z_BLOCK: number;
779 | export var Z_TREES: number;
780 | export var Z_OK: number;
781 | export var Z_STREAM_END: number;
782 | export var Z_NEED_DICT: number;
783 | export var Z_ERRNO: number;
784 | export var Z_STREAM_ERROR: number;
785 | export var Z_DATA_ERROR: number;
786 | export var Z_MEM_ERROR: number;
787 | export var Z_BUF_ERROR: number;
788 | export var Z_VERSION_ERROR: number;
789 | export var Z_NO_COMPRESSION: number;
790 | export var Z_BEST_SPEED: number;
791 | export var Z_BEST_COMPRESSION: number;
792 | export var Z_DEFAULT_COMPRESSION: number;
793 | export var Z_FILTERED: number;
794 | export var Z_HUFFMAN_ONLY: number;
795 | export var Z_RLE: number;
796 | export var Z_FIXED: number;
797 | export var Z_DEFAULT_STRATEGY: number;
798 | export var Z_BINARY: number;
799 | export var Z_TEXT: number;
800 | export var Z_ASCII: number;
801 | export var Z_UNKNOWN: number;
802 | export var Z_DEFLATED: number;
803 | export var Z_NULL: number;
804 | }
805 |
806 | declare module "os" {
807 | export interface CpuInfo {
808 | model: string;
809 | speed: number;
810 | times: {
811 | user: number;
812 | nice: number;
813 | sys: number;
814 | idle: number;
815 | irq: number;
816 | };
817 | }
818 |
819 | export interface NetworkInterfaceInfo {
820 | address: string;
821 | netmask: string;
822 | family: string;
823 | mac: string;
824 | internal: boolean;
825 | }
826 |
827 | export function tmpdir(): string;
828 | export function homedir(): string;
829 | export function endianness(): string;
830 | export function hostname(): string;
831 | export function type(): string;
832 | export function platform(): string;
833 | export function arch(): string;
834 | export function release(): string;
835 | export function uptime(): number;
836 | export function loadavg(): number[];
837 | export function totalmem(): number;
838 | export function freemem(): number;
839 | export function cpus(): CpuInfo[];
840 | export function networkInterfaces(): {[index: string]: NetworkInterfaceInfo[]};
841 | export var EOL: string;
842 | }
843 |
844 | declare module "https" {
845 | import * as tls from "tls";
846 | import * as events from "events";
847 | import * as http from "http";
848 |
849 | export interface ServerOptions {
850 | pfx?: any;
851 | key?: any;
852 | passphrase?: string;
853 | cert?: any;
854 | ca?: any;
855 | crl?: any;
856 | ciphers?: string;
857 | honorCipherOrder?: boolean;
858 | requestCert?: boolean;
859 | rejectUnauthorized?: boolean;
860 | NPNProtocols?: any;
861 | SNICallback?: (servername: string) => any;
862 | }
863 |
864 | export interface RequestOptions extends http.RequestOptions {
865 | pfx?: any;
866 | key?: any;
867 | passphrase?: string;
868 | cert?: any;
869 | ca?: any;
870 | ciphers?: string;
871 | rejectUnauthorized?: boolean;
872 | secureProtocol?: string;
873 | }
874 |
875 | export interface Agent extends http.Agent { }
876 |
877 | export interface AgentOptions extends http.AgentOptions {
878 | maxCachedSessions?: number;
879 | }
880 |
881 | export var Agent: {
882 | new (options?: AgentOptions): Agent;
883 | };
884 | export interface Server extends tls.Server { }
885 | export function createServer(options: ServerOptions, requestListener?: Function): Server;
886 | export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest;
887 | export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest;
888 | export var globalAgent: Agent;
889 | }
890 |
891 | declare module "punycode" {
892 | export function decode(string: string): string;
893 | export function encode(string: string): string;
894 | export function toUnicode(domain: string): string;
895 | export function toASCII(domain: string): string;
896 | export var ucs2: ucs2;
897 | interface ucs2 {
898 | decode(string: string): number[];
899 | encode(codePoints: number[]): string;
900 | }
901 | export var version: any;
902 | }
903 |
904 | declare module "repl" {
905 | import * as stream from "stream";
906 | import * as events from "events";
907 |
908 | export interface ReplOptions {
909 | prompt?: string;
910 | input?: NodeJS.ReadableStream;
911 | output?: NodeJS.WritableStream;
912 | terminal?: boolean;
913 | eval?: Function;
914 | useColors?: boolean;
915 | useGlobal?: boolean;
916 | ignoreUndefined?: boolean;
917 | writer?: Function;
918 | }
919 | export function start(options: ReplOptions): events.EventEmitter;
920 | }
921 |
922 | declare module "readline" {
923 | import * as events from "events";
924 | import * as stream from "stream";
925 |
926 | export interface Key {
927 | sequence?: string;
928 | name?: string;
929 | ctrl?: boolean;
930 | meta?: boolean;
931 | shift?: boolean;
932 | }
933 |
934 | export interface ReadLine extends events.EventEmitter {
935 | setPrompt(prompt: string): void;
936 | prompt(preserveCursor?: boolean): void;
937 | question(query: string, callback: (answer: string) => void): void;
938 | pause(): ReadLine;
939 | resume(): ReadLine;
940 | close(): void;
941 | write(data: string|Buffer, key?: Key): void;
942 | }
943 |
944 | export interface Completer {
945 | (line: string): CompleterResult;
946 | (line: string, callback: (err: any, result: CompleterResult) => void): any;
947 | }
948 |
949 | export interface CompleterResult {
950 | completions: string[];
951 | line: string;
952 | }
953 |
954 | export interface ReadLineOptions {
955 | input: NodeJS.ReadableStream;
956 | output?: NodeJS.WritableStream;
957 | completer?: Completer;
958 | terminal?: boolean;
959 | historySize?: number;
960 | }
961 |
962 | export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer, terminal?: boolean): ReadLine;
963 | export function createInterface(options: ReadLineOptions): ReadLine;
964 |
965 | export function cursorTo(stream: NodeJS.WritableStream, x: number, y: number): void;
966 | export function moveCursor(stream: NodeJS.WritableStream, dx: number|string, dy: number|string): void;
967 | export function clearLine(stream: NodeJS.WritableStream, dir: number): void;
968 | export function clearScreenDown(stream: NodeJS.WritableStream): void;
969 | }
970 |
971 | declare module "vm" {
972 | export interface Context { }
973 | export interface ScriptOptions {
974 | filename?: string;
975 | lineOffset?: number;
976 | columnOffset?: number;
977 | displayErrors?: boolean;
978 | timeout?: number;
979 | cachedData?: Buffer;
980 | produceCachedData?: boolean;
981 | }
982 | export interface RunningScriptOptions {
983 | filename?: string;
984 | lineOffset?: number;
985 | columnOffset?: number;
986 | displayErrors?: boolean;
987 | timeout?: number;
988 | }
989 | export class Script {
990 | constructor(code: string, options?: ScriptOptions);
991 | runInContext(contextifiedSandbox: Context, options?: RunningScriptOptions): any;
992 | runInNewContext(sandbox?: Context, options?: RunningScriptOptions): any;
993 | runInThisContext(options?: RunningScriptOptions): any;
994 | }
995 | export function createContext(sandbox?: Context): Context;
996 | export function isContext(sandbox: Context): boolean;
997 | export function runInContext(code: string, contextifiedSandbox: Context, options?: RunningScriptOptions): any;
998 | export function runInDebugContext(code: string): any;
999 | export function runInNewContext(code: string, sandbox?: Context, options?: RunningScriptOptions): any;
1000 | export function runInThisContext(code: string, options?: RunningScriptOptions): any;
1001 | }
1002 |
1003 | declare module "child_process" {
1004 | import * as events from "events";
1005 | import * as stream from "stream";
1006 |
1007 | export interface ChildProcess extends events.EventEmitter {
1008 | stdin: stream.Writable;
1009 | stdout: stream.Readable;
1010 | stderr: stream.Readable;
1011 | stdio: [stream.Writable, stream.Readable, stream.Readable];
1012 | pid: number;
1013 | kill(signal?: string): void;
1014 | send(message: any, sendHandle?: any): void;
1015 | disconnect(): void;
1016 | unref(): void;
1017 | }
1018 |
1019 | export interface SpawnOptions {
1020 | cwd?: string;
1021 | env?: any;
1022 | stdio?: any;
1023 | detached?: boolean;
1024 | uid?: number;
1025 | gid?: number;
1026 | shell?: boolean | string;
1027 | }
1028 | export function spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
1029 |
1030 | export interface ExecOptions {
1031 | cwd?: string;
1032 | env?: any;
1033 | shell?: string;
1034 | timeout?: number;
1035 | maxBuffer?: number;
1036 | killSignal?: string;
1037 | uid?: number;
1038 | gid?: number;
1039 | }
1040 | export interface ExecOptionsWithStringEncoding extends ExecOptions {
1041 | encoding: BufferEncoding;
1042 | }
1043 | export interface ExecOptionsWithBufferEncoding extends ExecOptions {
1044 | encoding: string; // specify `null`.
1045 | }
1046 | export function exec(command: string, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1047 | export function exec(command: string, options: ExecOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1048 | // usage. child_process.exec("tsc", {encoding: null as string}, (err, stdout, stderr) => {});
1049 | export function exec(command: string, options: ExecOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
1050 | export function exec(command: string, options: ExecOptions, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1051 |
1052 | export interface ExecFileOptions {
1053 | cwd?: string;
1054 | env?: any;
1055 | timeout?: number;
1056 | maxBuffer?: number;
1057 | killSignal?: string;
1058 | uid?: number;
1059 | gid?: number;
1060 | }
1061 | export interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
1062 | encoding: BufferEncoding;
1063 | }
1064 | export interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
1065 | encoding: string; // specify `null`.
1066 | }
1067 | export function execFile(file: string, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1068 | export function execFile(file: string, options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1069 | // usage. child_process.execFile("file.sh", {encoding: null as string}, (err, stdout, stderr) => {});
1070 | export function execFile(file: string, options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
1071 | export function execFile(file: string, options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1072 | export function execFile(file: string, args?: string[], callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1073 | export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithStringEncoding, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1074 | // usage. child_process.execFile("file.sh", ["foo"], {encoding: null as string}, (err, stdout, stderr) => {});
1075 | export function execFile(file: string, args?: string[], options?: ExecFileOptionsWithBufferEncoding, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess;
1076 | export function execFile(file: string, args?: string[], options?: ExecFileOptions, callback?: (error: Error, stdout: string, stderr: string) =>void ): ChildProcess;
1077 |
1078 | export interface ForkOptions {
1079 | cwd?: string;
1080 | env?: any;
1081 | execPath?: string;
1082 | execArgv?: string[];
1083 | silent?: boolean;
1084 | uid?: number;
1085 | gid?: number;
1086 | }
1087 | export function fork(modulePath: string, args?: string[], options?: ForkOptions): ChildProcess;
1088 |
1089 | export interface SpawnSyncOptions {
1090 | cwd?: string;
1091 | input?: string | Buffer;
1092 | stdio?: any;
1093 | env?: any;
1094 | uid?: number;
1095 | gid?: number;
1096 | timeout?: number;
1097 | killSignal?: string;
1098 | maxBuffer?: number;
1099 | encoding?: string;
1100 | shell?: boolean | string;
1101 | }
1102 | export interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
1103 | encoding: BufferEncoding;
1104 | }
1105 | export interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
1106 | encoding: string; // specify `null`.
1107 | }
1108 | export interface SpawnSyncReturns {
1109 | pid: number;
1110 | output: string[];
1111 | stdout: T;
1112 | stderr: T;
1113 | status: number;
1114 | signal: string;
1115 | error: Error;
1116 | }
1117 | export function spawnSync(command: string): SpawnSyncReturns;
1118 | export function spawnSync(command: string, options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns;
1119 | export function spawnSync(command: string, options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns;
1120 | export function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns;
1121 | export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns;
1122 | export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns;
1123 | export function spawnSync(command: string, args?: string[], options?: SpawnSyncOptions): SpawnSyncReturns;
1124 |
1125 | export interface ExecSyncOptions {
1126 | cwd?: string;
1127 | input?: string | Buffer;
1128 | stdio?: any;
1129 | env?: any;
1130 | shell?: string;
1131 | uid?: number;
1132 | gid?: number;
1133 | timeout?: number;
1134 | killSignal?: string;
1135 | maxBuffer?: number;
1136 | encoding?: string;
1137 | }
1138 | export interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
1139 | encoding: BufferEncoding;
1140 | }
1141 | export interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
1142 | encoding: string; // specify `null`.
1143 | }
1144 | export function execSync(command: string): Buffer;
1145 | export function execSync(command: string, options?: ExecSyncOptionsWithStringEncoding): string;
1146 | export function execSync(command: string, options?: ExecSyncOptionsWithBufferEncoding): Buffer;
1147 | export function execSync(command: string, options?: ExecSyncOptions): Buffer;
1148 |
1149 | export interface ExecFileSyncOptions {
1150 | cwd?: string;
1151 | input?: string | Buffer;
1152 | stdio?: any;
1153 | env?: any;
1154 | uid?: number;
1155 | gid?: number;
1156 | timeout?: number;
1157 | killSignal?: string;
1158 | maxBuffer?: number;
1159 | encoding?: string;
1160 | }
1161 | export interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
1162 | encoding: BufferEncoding;
1163 | }
1164 | export interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
1165 | encoding: string; // specify `null`.
1166 | }
1167 | export function execFileSync(command: string): Buffer;
1168 | export function execFileSync(command: string, options?: ExecFileSyncOptionsWithStringEncoding): string;
1169 | export function execFileSync(command: string, options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1170 | export function execFileSync(command: string, options?: ExecFileSyncOptions): Buffer;
1171 | export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithStringEncoding): string;
1172 | export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptionsWithBufferEncoding): Buffer;
1173 | export function execFileSync(command: string, args?: string[], options?: ExecFileSyncOptions): Buffer;
1174 | }
1175 |
1176 | declare module "url" {
1177 | export interface Url {
1178 | href?: string;
1179 | protocol?: string;
1180 | auth?: string;
1181 | hostname?: string;
1182 | port?: string;
1183 | host?: string;
1184 | pathname?: string;
1185 | search?: string;
1186 | query?: string | any;
1187 | slashes?: boolean;
1188 | hash?: string;
1189 | path?: string;
1190 | }
1191 |
1192 | export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url;
1193 | export function format(url: Url): string;
1194 | export function resolve(from: string, to: string): string;
1195 | }
1196 |
1197 | declare module "dns" {
1198 | export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string;
1199 | export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string;
1200 | export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1201 | export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1202 | export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1203 | export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1204 | export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1205 | export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1206 | export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1207 | export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1208 | export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[];
1209 | export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[];
1210 | }
1211 |
1212 | declare module "net" {
1213 | import * as stream from "stream";
1214 |
1215 | export interface Socket extends stream.Duplex {
1216 | // Extended base methods
1217 | write(buffer: Buffer): boolean;
1218 | write(buffer: Buffer, cb?: Function): boolean;
1219 | write(str: string, cb?: Function): boolean;
1220 | write(str: string, encoding?: string, cb?: Function): boolean;
1221 | write(str: string, encoding?: string, fd?: string): boolean;
1222 |
1223 | connect(port: number, host?: string, connectionListener?: Function): void;
1224 | connect(path: string, connectionListener?: Function): void;
1225 | bufferSize: number;
1226 | setEncoding(encoding?: string): void;
1227 | write(data: any, encoding?: string, callback?: Function): void;
1228 | destroy(): void;
1229 | pause(): void;
1230 | resume(): void;
1231 | setTimeout(timeout: number, callback?: Function): void;
1232 | setNoDelay(noDelay?: boolean): void;
1233 | setKeepAlive(enable?: boolean, initialDelay?: number): void;
1234 | address(): { port: number; family: string; address: string; };
1235 | unref(): void;
1236 | ref(): void;
1237 |
1238 | remoteAddress: string;
1239 | remoteFamily: string;
1240 | remotePort: number;
1241 | localAddress: string;
1242 | localPort: number;
1243 | bytesRead: number;
1244 | bytesWritten: number;
1245 |
1246 | // Extended base methods
1247 | end(): void;
1248 | end(buffer: Buffer, cb?: Function): void;
1249 | end(str: string, cb?: Function): void;
1250 | end(str: string, encoding?: string, cb?: Function): void;
1251 | end(data?: any, encoding?: string): void;
1252 | }
1253 |
1254 | export var Socket: {
1255 | new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket;
1256 | };
1257 |
1258 | export interface ListenOptions {
1259 | port?: number;
1260 | host?: string;
1261 | backlog?: number;
1262 | path?: string;
1263 | exclusive?: boolean;
1264 | }
1265 |
1266 | export interface Server extends Socket {
1267 | listen(port: number, hostname?: string, backlog?: number, listeningListener?: Function): Server;
1268 | listen(port: number, hostname?: string, listeningListener?: Function): Server;
1269 | listen(port: number, backlog?: number, listeningListener?: Function): Server;
1270 | listen(port: number, listeningListener?: Function): Server;
1271 | listen(path: string, backlog?: number, listeningListener?: Function): Server;
1272 | listen(path: string, listeningListener?: Function): Server;
1273 | listen(handle: any, backlog?: number, listeningListener?: Function): Server;
1274 | listen(handle: any, listeningListener?: Function): Server;
1275 | listen(options: ListenOptions, listeningListener?: Function): Server;
1276 | close(callback?: Function): Server;
1277 | address(): { port: number; family: string; address: string; };
1278 | getConnections(cb: (error: Error, count: number) => void): void;
1279 | ref(): Server;
1280 | unref(): Server;
1281 | maxConnections: number;
1282 | connections: number;
1283 | }
1284 | export function createServer(connectionListener?: (socket: Socket) =>void ): Server;
1285 | export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server;
1286 | export function connect(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1287 | export function connect(port: number, host?: string, connectionListener?: Function): Socket;
1288 | export function connect(path: string, connectionListener?: Function): Socket;
1289 | export function createConnection(options: { port: number, host?: string, localAddress? : string, localPort? : string, family? : number, allowHalfOpen?: boolean; }, connectionListener?: Function): Socket;
1290 | export function createConnection(port: number, host?: string, connectionListener?: Function): Socket;
1291 | export function createConnection(path: string, connectionListener?: Function): Socket;
1292 | export function isIP(input: string): number;
1293 | export function isIPv4(input: string): boolean;
1294 | export function isIPv6(input: string): boolean;
1295 | }
1296 |
1297 | declare module "dgram" {
1298 | import * as events from "events";
1299 |
1300 | interface RemoteInfo {
1301 | address: string;
1302 | port: number;
1303 | size: number;
1304 | }
1305 |
1306 | interface AddressInfo {
1307 | address: string;
1308 | family: string;
1309 | port: number;
1310 | }
1311 |
1312 | export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
1313 |
1314 | interface Socket extends events.EventEmitter {
1315 | send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void;
1316 | bind(port: number, address?: string, callback?: () => void): void;
1317 | close(): void;
1318 | address(): AddressInfo;
1319 | setBroadcast(flag: boolean): void;
1320 | setMulticastTTL(ttl: number): void;
1321 | setMulticastLoopback(flag: boolean): void;
1322 | addMembership(multicastAddress: string, multicastInterface?: string): void;
1323 | dropMembership(multicastAddress: string, multicastInterface?: string): void;
1324 | }
1325 | }
1326 |
1327 | declare module "fs" {
1328 | import * as stream from "stream";
1329 | import * as events from "events";
1330 |
1331 | interface Stats {
1332 | isFile(): boolean;
1333 | isDirectory(): boolean;
1334 | isBlockDevice(): boolean;
1335 | isCharacterDevice(): boolean;
1336 | isSymbolicLink(): boolean;
1337 | isFIFO(): boolean;
1338 | isSocket(): boolean;
1339 | dev: number;
1340 | ino: number;
1341 | mode: number;
1342 | nlink: number;
1343 | uid: number;
1344 | gid: number;
1345 | rdev: number;
1346 | size: number;
1347 | blksize: number;
1348 | blocks: number;
1349 | atime: Date;
1350 | mtime: Date;
1351 | ctime: Date;
1352 | birthtime: Date;
1353 | }
1354 |
1355 | interface FSWatcher extends events.EventEmitter {
1356 | close(): void;
1357 | }
1358 |
1359 | export interface ReadStream extends stream.Readable {
1360 | close(): void;
1361 | }
1362 | export interface WriteStream extends stream.Writable {
1363 | close(): void;
1364 | bytesWritten: number;
1365 | }
1366 |
1367 | /**
1368 | * Asynchronous rename.
1369 | * @param oldPath
1370 | * @param newPath
1371 | * @param callback No arguments other than a possible exception are given to the completion callback.
1372 | */
1373 | export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1374 | /**
1375 | * Synchronous rename
1376 | * @param oldPath
1377 | * @param newPath
1378 | */
1379 | export function renameSync(oldPath: string, newPath: string): void;
1380 | export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1381 | export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1382 | export function truncateSync(path: string, len?: number): void;
1383 | export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1384 | export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1385 | export function ftruncateSync(fd: number, len?: number): void;
1386 | export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1387 | export function chownSync(path: string, uid: number, gid: number): void;
1388 | export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1389 | export function fchownSync(fd: number, uid: number, gid: number): void;
1390 | export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1391 | export function lchownSync(path: string, uid: number, gid: number): void;
1392 | export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1393 | export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1394 | export function chmodSync(path: string, mode: number): void;
1395 | export function chmodSync(path: string, mode: string): void;
1396 | export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1397 | export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1398 | export function fchmodSync(fd: number, mode: number): void;
1399 | export function fchmodSync(fd: number, mode: string): void;
1400 | export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1401 | export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1402 | export function lchmodSync(path: string, mode: number): void;
1403 | export function lchmodSync(path: string, mode: string): void;
1404 | export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1405 | export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1406 | export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
1407 | export function statSync(path: string): Stats;
1408 | export function lstatSync(path: string): Stats;
1409 | export function fstatSync(fd: number): Stats;
1410 | export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1411 | export function linkSync(srcpath: string, dstpath: string): void;
1412 | export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1413 | export function symlinkSync(srcpath: string, dstpath: string, type?: string): void;
1414 | export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void;
1415 | export function readlinkSync(path: string): string;
1416 | export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void;
1417 | export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void;
1418 | export function realpathSync(path: string, cache?: { [path: string]: string }): string;
1419 | /*
1420 | * Asynchronous unlink - deletes the file specified in {path}
1421 | *
1422 | * @param path
1423 | * @param callback No arguments other than a possible exception are given to the completion callback.
1424 | */
1425 | export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1426 | /*
1427 | * Synchronous unlink - deletes the file specified in {path}
1428 | *
1429 | * @param path
1430 | */
1431 | export function unlinkSync(path: string): void;
1432 | /*
1433 | * Asynchronous rmdir - removes the directory specified in {path}
1434 | *
1435 | * @param path
1436 | * @param callback No arguments other than a possible exception are given to the completion callback.
1437 | */
1438 | export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1439 | /*
1440 | * Synchronous rmdir - removes the directory specified in {path}
1441 | *
1442 | * @param path
1443 | */
1444 | export function rmdirSync(path: string): void;
1445 | /*
1446 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1447 | *
1448 | * @param path
1449 | * @param callback No arguments other than a possible exception are given to the completion callback.
1450 | */
1451 | export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1452 | /*
1453 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1454 | *
1455 | * @param path
1456 | * @param mode
1457 | * @param callback No arguments other than a possible exception are given to the completion callback.
1458 | */
1459 | export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1460 | /*
1461 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1462 | *
1463 | * @param path
1464 | * @param mode
1465 | * @param callback No arguments other than a possible exception are given to the completion callback.
1466 | */
1467 | export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
1468 | /*
1469 | * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1470 | *
1471 | * @param path
1472 | * @param mode
1473 | * @param callback No arguments other than a possible exception are given to the completion callback.
1474 | */
1475 | export function mkdirSync(path: string, mode?: number): void;
1476 | /*
1477 | * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777.
1478 | *
1479 | * @param path
1480 | * @param mode
1481 | * @param callback No arguments other than a possible exception are given to the completion callback.
1482 | */
1483 | export function mkdirSync(path: string, mode?: string): void;
1484 | /*
1485 | * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1486 | *
1487 | * @param prefix
1488 | * @param callback The created folder path is passed as a string to the callback's second parameter.
1489 | */
1490 | export function mkdtemp(prefix: string, callback?: (err: NodeJS.ErrnoException, folder: string) => void): void;
1491 | /*
1492 | * Synchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory.
1493 | *
1494 | * @param prefix
1495 | * @returns Returns the created folder path.
1496 | */
1497 | export function mkdtempSync(prefix: string): string;
1498 | export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void;
1499 | export function readdirSync(path: string): string[];
1500 | export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1501 | export function closeSync(fd: number): void;
1502 | export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
1503 | export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
1504 | export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void;
1505 | export function openSync(path: string, flags: string, mode?: number): number;
1506 | export function openSync(path: string, flags: string, mode?: string): number;
1507 | export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1508 | export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
1509 | export function utimesSync(path: string, atime: number, mtime: number): void;
1510 | export function utimesSync(path: string, atime: Date, mtime: Date): void;
1511 | export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1512 | export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void;
1513 | export function futimesSync(fd: number, atime: number, mtime: number): void;
1514 | export function futimesSync(fd: number, atime: Date, mtime: Date): void;
1515 | export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void;
1516 | export function fsyncSync(fd: number): void;
1517 | export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
1518 | export function write(fd: number, buffer: Buffer, offset: number, length: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void;
1519 | export function write(fd: number, data: any, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1520 | export function write(fd: number, data: any, offset: number, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1521 | export function write(fd: number, data: any, offset: number, encoding: string, callback?: (err: NodeJS.ErrnoException, written: number, str: string) => void): void;
1522 | export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position?: number): number;
1523 | export function writeSync(fd: number, data: any, position?: number, enconding?: string): number;
1524 | export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void;
1525 | export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number;
1526 | /*
1527 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1528 | *
1529 | * @param fileName
1530 | * @param encoding
1531 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1532 | */
1533 | export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
1534 | /*
1535 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1536 | *
1537 | * @param fileName
1538 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
1539 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1540 | */
1541 | export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void;
1542 | /*
1543 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1544 | *
1545 | * @param fileName
1546 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer.
1547 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1548 | */
1549 | export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
1550 | /*
1551 | * Asynchronous readFile - Asynchronously reads the entire contents of a file.
1552 | *
1553 | * @param fileName
1554 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file.
1555 | */
1556 | export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void;
1557 | /*
1558 | * Synchronous readFile - Synchronously reads the entire contents of a file.
1559 | *
1560 | * @param fileName
1561 | * @param encoding
1562 | */
1563 | export function readFileSync(filename: string, encoding: string): string;
1564 | /*
1565 | * Synchronous readFile - Synchronously reads the entire contents of a file.
1566 | *
1567 | * @param fileName
1568 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
1569 | */
1570 | export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string;
1571 | /*
1572 | * Synchronous readFile - Synchronously reads the entire contents of a file.
1573 | *
1574 | * @param fileName
1575 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer.
1576 | */
1577 | export function readFileSync(filename: string, options?: { flag?: string; }): Buffer;
1578 | export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
1579 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1580 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1581 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
1582 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
1583 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1584 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void;
1585 | export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void;
1586 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void;
1587 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void;
1588 | export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void;
1589 | export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void;
1590 | export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void;
1591 | export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher;
1592 | export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher;
1593 | export function exists(path: string, callback?: (exists: boolean) => void): void;
1594 | export function existsSync(path: string): boolean;
1595 | /** Constant for fs.access(). File is visible to the calling process. */
1596 | export var F_OK: number;
1597 | /** Constant for fs.access(). File can be read by the calling process. */
1598 | export var R_OK: number;
1599 | /** Constant for fs.access(). File can be written by the calling process. */
1600 | export var W_OK: number;
1601 | /** Constant for fs.access(). File can be executed by the calling process. */
1602 | export var X_OK: number;
1603 | /** Tests a user's permissions for the file specified by path. */
1604 | export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void;
1605 | export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void;
1606 | /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */
1607 | export function accessSync(path: string, mode ?: number): void;
1608 | export function createReadStream(path: string, options?: {
1609 | flags?: string;
1610 | encoding?: string;
1611 | fd?: number;
1612 | mode?: number;
1613 | autoClose?: boolean;
1614 | }): ReadStream;
1615 | export function createWriteStream(path: string, options?: {
1616 | flags?: string;
1617 | encoding?: string;
1618 | fd?: number;
1619 | mode?: number;
1620 | }): WriteStream;
1621 | }
1622 |
1623 | declare module "path" {
1624 |
1625 | /**
1626 | * A parsed path object generated by path.parse() or consumed by path.format().
1627 | */
1628 | export interface ParsedPath {
1629 | /**
1630 | * The root of the path such as '/' or 'c:\'
1631 | */
1632 | root: string;
1633 | /**
1634 | * The full directory path such as '/home/user/dir' or 'c:\path\dir'
1635 | */
1636 | dir: string;
1637 | /**
1638 | * The file name including extension (if any) such as 'index.html'
1639 | */
1640 | base: string;
1641 | /**
1642 | * The file extension (if any) such as '.html'
1643 | */
1644 | ext: string;
1645 | /**
1646 | * The file name without extension (if any) such as 'index'
1647 | */
1648 | name: string;
1649 | }
1650 |
1651 | /**
1652 | * Normalize a string path, reducing '..' and '.' parts.
1653 | * 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.
1654 | *
1655 | * @param p string path to normalize.
1656 | */
1657 | export function normalize(p: string): string;
1658 | /**
1659 | * Join all arguments together and normalize the resulting path.
1660 | * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
1661 | *
1662 | * @param paths string paths to join.
1663 | */
1664 | export function join(...paths: any[]): string;
1665 | /**
1666 | * Join all arguments together and normalize the resulting path.
1667 | * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown.
1668 | *
1669 | * @param paths string paths to join.
1670 | */
1671 | export function join(...paths: string[]): string;
1672 | /**
1673 | * The right-most parameter is considered {to}. Other parameters are considered an array of {from}.
1674 | *
1675 | * Starting from leftmost {from} paramter, resolves {to} to an absolute path.
1676 | *
1677 | * 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.
1678 | *
1679 | * @param pathSegments string paths to join. Non-string arguments are ignored.
1680 | */
1681 | export function resolve(...pathSegments: any[]): string;
1682 | /**
1683 | * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory.
1684 | *
1685 | * @param path path to test.
1686 | */
1687 | export function isAbsolute(path: string): boolean;
1688 | /**
1689 | * Solve the relative path from {from} to {to}.
1690 | * 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.
1691 | *
1692 | * @param from
1693 | * @param to
1694 | */
1695 | export function relative(from: string, to: string): string;
1696 | /**
1697 | * Return the directory name of a path. Similar to the Unix dirname command.
1698 | *
1699 | * @param p the path to evaluate.
1700 | */
1701 | export function dirname(p: string): string;
1702 | /**
1703 | * Return the last portion of a path. Similar to the Unix basename command.
1704 | * Often used to extract the file name from a fully qualified path.
1705 | *
1706 | * @param p the path to evaluate.
1707 | * @param ext optionally, an extension to remove from the result.
1708 | */
1709 | export function basename(p: string, ext?: string): string;
1710 | /**
1711 | * Return the extension of the path, from the last '.' to end of string in the last portion of the path.
1712 | * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string
1713 | *
1714 | * @param p the path to evaluate.
1715 | */
1716 | export function extname(p: string): string;
1717 | /**
1718 | * The platform-specific file separator. '\\' or '/'.
1719 | */
1720 | export var sep: string;
1721 | /**
1722 | * The platform-specific file delimiter. ';' or ':'.
1723 | */
1724 | export var delimiter: string;
1725 | /**
1726 | * Returns an object from a path string - the opposite of format().
1727 | *
1728 | * @param pathString path to evaluate.
1729 | */
1730 | export function parse(pathString: string): ParsedPath;
1731 | /**
1732 | * Returns a path string from an object - the opposite of parse().
1733 | *
1734 | * @param pathString path to evaluate.
1735 | */
1736 | export function format(pathObject: ParsedPath): string;
1737 |
1738 | export module posix {
1739 | export function normalize(p: string): string;
1740 | export function join(...paths: any[]): string;
1741 | export function resolve(...pathSegments: any[]): string;
1742 | export function isAbsolute(p: string): boolean;
1743 | export function relative(from: string, to: string): string;
1744 | export function dirname(p: string): string;
1745 | export function basename(p: string, ext?: string): string;
1746 | export function extname(p: string): string;
1747 | export var sep: string;
1748 | export var delimiter: string;
1749 | export function parse(p: string): ParsedPath;
1750 | export function format(pP: ParsedPath): string;
1751 | }
1752 |
1753 | export module win32 {
1754 | export function normalize(p: string): string;
1755 | export function join(...paths: any[]): string;
1756 | export function resolve(...pathSegments: any[]): string;
1757 | export function isAbsolute(p: string): boolean;
1758 | export function relative(from: string, to: string): string;
1759 | export function dirname(p: string): string;
1760 | export function basename(p: string, ext?: string): string;
1761 | export function extname(p: string): string;
1762 | export var sep: string;
1763 | export var delimiter: string;
1764 | export function parse(p: string): ParsedPath;
1765 | export function format(pP: ParsedPath): string;
1766 | }
1767 | }
1768 |
1769 | declare module "string_decoder" {
1770 | export interface NodeStringDecoder {
1771 | write(buffer: Buffer): string;
1772 | detectIncompleteChar(buffer: Buffer): number;
1773 | }
1774 | export var StringDecoder: {
1775 | new (encoding: string): NodeStringDecoder;
1776 | };
1777 | }
1778 |
1779 | declare module "tls" {
1780 | import * as crypto from "crypto";
1781 | import * as net from "net";
1782 | import * as stream from "stream";
1783 |
1784 | var CLIENT_RENEG_LIMIT: number;
1785 | var CLIENT_RENEG_WINDOW: number;
1786 |
1787 | export interface TlsOptions {
1788 | host?: string;
1789 | port?: number;
1790 | pfx?: any; //string or buffer
1791 | key?: any; //string or buffer
1792 | passphrase?: string;
1793 | cert?: any;
1794 | ca?: any; //string or buffer
1795 | crl?: any; //string or string array
1796 | ciphers?: string;
1797 | honorCipherOrder?: any;
1798 | requestCert?: boolean;
1799 | rejectUnauthorized?: boolean;
1800 | NPNProtocols?: any; //array or Buffer;
1801 | SNICallback?: (servername: string) => any;
1802 | }
1803 |
1804 | export interface ConnectionOptions {
1805 | host?: string;
1806 | port?: number;
1807 | socket?: net.Socket;
1808 | pfx?: string | Buffer
1809 | key?: string | Buffer
1810 | passphrase?: string;
1811 | cert?: string | Buffer
1812 | ca?: (string | Buffer)[];
1813 | rejectUnauthorized?: boolean;
1814 | NPNProtocols?: (string | Buffer)[];
1815 | servername?: string;
1816 | }
1817 |
1818 | export interface Server extends net.Server {
1819 | close(): Server;
1820 | address(): { port: number; family: string; address: string; };
1821 | addContext(hostName: string, credentials: {
1822 | key: string;
1823 | cert: string;
1824 | ca: string;
1825 | }): void;
1826 | maxConnections: number;
1827 | connections: number;
1828 | }
1829 |
1830 | export interface ClearTextStream extends stream.Duplex {
1831 | authorized: boolean;
1832 | authorizationError: Error;
1833 | getPeerCertificate(): any;
1834 | getCipher: {
1835 | name: string;
1836 | version: string;
1837 | };
1838 | address: {
1839 | port: number;
1840 | family: string;
1841 | address: string;
1842 | };
1843 | remoteAddress: string;
1844 | remotePort: number;
1845 | }
1846 |
1847 | export interface SecurePair {
1848 | encrypted: any;
1849 | cleartext: any;
1850 | }
1851 |
1852 | export interface SecureContextOptions {
1853 | pfx?: string | Buffer;
1854 | key?: string | Buffer;
1855 | passphrase?: string;
1856 | cert?: string | Buffer;
1857 | ca?: string | Buffer;
1858 | crl?: string | string[]
1859 | ciphers?: string;
1860 | honorCipherOrder?: boolean;
1861 | }
1862 |
1863 | export interface SecureContext {
1864 | context: any;
1865 | }
1866 |
1867 | export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server;
1868 | export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream;
1869 | export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
1870 | export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream;
1871 | export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
1872 | export function createSecureContext(details: SecureContextOptions): SecureContext;
1873 | }
1874 |
1875 | declare module "crypto" {
1876 | export interface CredentialDetails {
1877 | pfx: string;
1878 | key: string;
1879 | passphrase: string;
1880 | cert: string;
1881 | ca: string | string[];
1882 | crl: string | string[];
1883 | ciphers: string;
1884 | }
1885 | export interface Credentials { context?: any; }
1886 | export function createCredentials(details: CredentialDetails): Credentials;
1887 | export function createHash(algorithm: string): Hash;
1888 | export function createHmac(algorithm: string, key: string): Hmac;
1889 | export function createHmac(algorithm: string, key: Buffer): Hmac;
1890 | export interface Hash {
1891 | update(data: any, input_encoding?: string): Hash;
1892 | digest(encoding: 'buffer'): Buffer;
1893 | digest(encoding: string): any;
1894 | digest(): Buffer;
1895 | }
1896 | export interface Hmac extends NodeJS.ReadWriteStream {
1897 | update(data: any, input_encoding?: string): Hmac;
1898 | digest(encoding: 'buffer'): Buffer;
1899 | digest(encoding: string): any;
1900 | digest(): Buffer;
1901 | }
1902 | export function createCipher(algorithm: string, password: any): Cipher;
1903 | export function createCipheriv(algorithm: string, key: any, iv: any): Cipher;
1904 | export interface Cipher extends NodeJS.ReadWriteStream {
1905 | update(data: Buffer): Buffer;
1906 | update(data: string, input_encoding: "utf8"|"ascii"|"binary"): Buffer;
1907 | update(data: Buffer, input_encoding: any, output_encoding: "binary"|"base64"|"hex"): string;
1908 | update(data: string, input_encoding: "utf8"|"ascii"|"binary", output_encoding: "binary"|"base64"|"hex"): string;
1909 | final(): Buffer;
1910 | final(output_encoding: string): string;
1911 | setAutoPadding(auto_padding: boolean): void;
1912 | getAuthTag(): Buffer;
1913 | }
1914 | export function createDecipher(algorithm: string, password: any): Decipher;
1915 | export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher;
1916 | export interface Decipher extends NodeJS.ReadWriteStream {
1917 | update(data: Buffer): Buffer;
1918 | update(data: string, input_encoding: "binary"|"base64"|"hex"): Buffer;
1919 | update(data: Buffer, input_encoding: any, output_encoding: "utf8"|"ascii"|"binary"): string;
1920 | update(data: string, input_encoding: "binary"|"base64"|"hex", output_encoding: "utf8"|"ascii"|"binary"): string;
1921 | final(): Buffer;
1922 | final(output_encoding: string): string;
1923 | setAutoPadding(auto_padding: boolean): void;
1924 | setAuthTag(tag: Buffer): void;
1925 | }
1926 | export function createSign(algorithm: string): Signer;
1927 | export interface Signer extends NodeJS.WritableStream {
1928 | update(data: any): void;
1929 | sign(private_key: string, output_format: string): string;
1930 | }
1931 | export function createVerify(algorith: string): Verify;
1932 | export interface Verify extends NodeJS.WritableStream {
1933 | update(data: any): void;
1934 | verify(object: string, signature: string, signature_format?: string): boolean;
1935 | }
1936 | export function createDiffieHellman(prime_length: number): DiffieHellman;
1937 | export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman;
1938 | export interface DiffieHellman {
1939 | generateKeys(encoding?: string): string;
1940 | computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string;
1941 | getPrime(encoding?: string): string;
1942 | getGenerator(encoding: string): string;
1943 | getPublicKey(encoding?: string): string;
1944 | getPrivateKey(encoding?: string): string;
1945 | setPublicKey(public_key: string, encoding?: string): void;
1946 | setPrivateKey(public_key: string, encoding?: string): void;
1947 | }
1948 | export function getDiffieHellman(group_name: string): DiffieHellman;
1949 | export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void;
1950 | export function pbkdf2(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void;
1951 | export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number) : Buffer;
1952 | export function pbkdf2Sync(password: string|Buffer, salt: string|Buffer, iterations: number, keylen: number, digest: string) : Buffer;
1953 | export function randomBytes(size: number): Buffer;
1954 | export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
1955 | export function pseudoRandomBytes(size: number): Buffer;
1956 | export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void;
1957 | export interface RsaPublicKey {
1958 | key: string;
1959 | padding?: any;
1960 | }
1961 | export interface RsaPrivateKey {
1962 | key: string;
1963 | passphrase?: string,
1964 | padding?: any;
1965 | }
1966 | export function publicEncrypt(public_key: string|RsaPublicKey, buffer: Buffer): Buffer
1967 | export function privateDecrypt(private_key: string|RsaPrivateKey, buffer: Buffer): Buffer
1968 | }
1969 |
1970 | declare module "stream" {
1971 | import * as events from "events";
1972 |
1973 | export class Stream extends events.EventEmitter {
1974 | pipe(destination: T, options?: { end?: boolean; }): T;
1975 | }
1976 |
1977 | export interface ReadableOptions {
1978 | highWaterMark?: number;
1979 | encoding?: string;
1980 | objectMode?: boolean;
1981 | }
1982 |
1983 | export class Readable extends events.EventEmitter implements NodeJS.ReadableStream {
1984 | readable: boolean;
1985 | constructor(opts?: ReadableOptions);
1986 | _read(size: number): void;
1987 | read(size?: number): any;
1988 | setEncoding(encoding: string): void;
1989 | pause(): void;
1990 | resume(): void;
1991 | pipe(destination: T, options?: { end?: boolean; }): T;
1992 | unpipe(destination?: T): void;
1993 | unshift(chunk: any): void;
1994 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
1995 | push(chunk: any, encoding?: string): boolean;
1996 | }
1997 |
1998 | export interface WritableOptions {
1999 | highWaterMark?: number;
2000 | decodeStrings?: boolean;
2001 | objectMode?: boolean;
2002 | }
2003 |
2004 | export class Writable extends events.EventEmitter implements NodeJS.WritableStream {
2005 | writable: boolean;
2006 | constructor(opts?: WritableOptions);
2007 | _write(chunk: any, encoding: string, callback: Function): void;
2008 | write(chunk: any, cb?: Function): boolean;
2009 | write(chunk: any, encoding?: string, cb?: Function): boolean;
2010 | end(): void;
2011 | end(chunk: any, cb?: Function): void;
2012 | end(chunk: any, encoding?: string, cb?: Function): void;
2013 | }
2014 |
2015 | export interface DuplexOptions extends ReadableOptions, WritableOptions {
2016 | allowHalfOpen?: boolean;
2017 | }
2018 |
2019 | // Note: Duplex extends both Readable and Writable.
2020 | export class Duplex extends Readable implements NodeJS.ReadWriteStream {
2021 | writable: boolean;
2022 | constructor(opts?: DuplexOptions);
2023 | _write(chunk: any, encoding: string, callback: Function): void;
2024 | write(chunk: any, cb?: Function): boolean;
2025 | write(chunk: any, encoding?: string, cb?: Function): boolean;
2026 | end(): void;
2027 | end(chunk: any, cb?: Function): void;
2028 | end(chunk: any, encoding?: string, cb?: Function): void;
2029 | }
2030 |
2031 | export interface TransformOptions extends ReadableOptions, WritableOptions {}
2032 |
2033 | // Note: Transform lacks the _read and _write methods of Readable/Writable.
2034 | export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream {
2035 | readable: boolean;
2036 | writable: boolean;
2037 | constructor(opts?: TransformOptions);
2038 | _transform(chunk: any, encoding: string, callback: Function): void;
2039 | _flush(callback: Function): void;
2040 | read(size?: number): any;
2041 | setEncoding(encoding: string): void;
2042 | pause(): void;
2043 | resume(): void;
2044 | pipe(destination: T, options?: { end?: boolean; }): T;
2045 | unpipe(destination?: T): void;
2046 | unshift(chunk: any): void;
2047 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream;
2048 | push(chunk: any, encoding?: string): boolean;
2049 | write(chunk: any, cb?: Function): boolean;
2050 | write(chunk: any, encoding?: string, cb?: Function): boolean;
2051 | end(): void;
2052 | end(chunk: any, cb?: Function): void;
2053 | end(chunk: any, encoding?: string, cb?: Function): void;
2054 | }
2055 |
2056 | export class PassThrough extends Transform {}
2057 | }
2058 |
2059 | declare module "util" {
2060 | export interface InspectOptions {
2061 | showHidden?: boolean;
2062 | depth?: number;
2063 | colors?: boolean;
2064 | customInspect?: boolean;
2065 | }
2066 |
2067 | export function format(format: any, ...param: any[]): string;
2068 | export function debug(string: string): void;
2069 | export function error(...param: any[]): void;
2070 | export function puts(...param: any[]): void;
2071 | export function print(...param: any[]): void;
2072 | export function log(string: string): void;
2073 | export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string;
2074 | export function inspect(object: any, options: InspectOptions): string;
2075 | export function isArray(object: any): boolean;
2076 | export function isRegExp(object: any): boolean;
2077 | export function isDate(object: any): boolean;
2078 | export function isError(object: any): boolean;
2079 | export function inherits(constructor: any, superConstructor: any): void;
2080 | export function debuglog(key:string): (msg:string,...param: any[])=>void;
2081 | }
2082 |
2083 | declare module "assert" {
2084 | function internal (value: any, message?: string): void;
2085 | namespace internal {
2086 | export class AssertionError implements Error {
2087 | name: string;
2088 | message: string;
2089 | actual: any;
2090 | expected: any;
2091 | operator: string;
2092 | generatedMessage: boolean;
2093 |
2094 | constructor(options?: {message?: string; actual?: any; expected?: any;
2095 | operator?: string; stackStartFunction?: Function});
2096 | }
2097 |
2098 | export function fail(actual?: any, expected?: any, message?: string, operator?: string): void;
2099 | export function ok(value: any, message?: string): void;
2100 | export function equal(actual: any, expected: any, message?: string): void;
2101 | export function notEqual(actual: any, expected: any, message?: string): void;
2102 | export function deepEqual(actual: any, expected: any, message?: string): void;
2103 | export function notDeepEqual(acutal: any, expected: any, message?: string): void;
2104 | export function strictEqual(actual: any, expected: any, message?: string): void;
2105 | export function notStrictEqual(actual: any, expected: any, message?: string): void;
2106 | export function deepStrictEqual(actual: any, expected: any, message?: string): void;
2107 | export function notDeepStrictEqual(actual: any, expected: any, message?: string): void;
2108 | export var throws: {
2109 | (block: Function, message?: string): void;
2110 | (block: Function, error: Function, message?: string): void;
2111 | (block: Function, error: RegExp, message?: string): void;
2112 | (block: Function, error: (err: any) => boolean, message?: string): void;
2113 | };
2114 |
2115 | export var doesNotThrow: {
2116 | (block: Function, message?: string): void;
2117 | (block: Function, error: Function, message?: string): void;
2118 | (block: Function, error: RegExp, message?: string): void;
2119 | (block: Function, error: (err: any) => boolean, message?: string): void;
2120 | };
2121 |
2122 | export function ifError(value: any): void;
2123 | }
2124 |
2125 | export = internal;
2126 | }
2127 |
2128 | declare module "tty" {
2129 | import * as net from "net";
2130 |
2131 | export function isatty(fd: number): boolean;
2132 | export interface ReadStream extends net.Socket {
2133 | isRaw: boolean;
2134 | setRawMode(mode: boolean): void;
2135 | isTTY: boolean;
2136 | }
2137 | export interface WriteStream extends net.Socket {
2138 | columns: number;
2139 | rows: number;
2140 | isTTY: boolean;
2141 | }
2142 | }
2143 |
2144 | declare module "domain" {
2145 | import * as events from "events";
2146 |
2147 | export class Domain extends events.EventEmitter implements NodeJS.Domain {
2148 | run(fn: Function): void;
2149 | add(emitter: events.EventEmitter): void;
2150 | remove(emitter: events.EventEmitter): void;
2151 | bind(cb: (err: Error, data: any) => any): any;
2152 | intercept(cb: (data: any) => any): any;
2153 | dispose(): void;
2154 | }
2155 |
2156 | export function create(): Domain;
2157 | }
2158 |
2159 | declare module "constants" {
2160 | export var E2BIG: number;
2161 | export var EACCES: number;
2162 | export var EADDRINUSE: number;
2163 | export var EADDRNOTAVAIL: number;
2164 | export var EAFNOSUPPORT: number;
2165 | export var EAGAIN: number;
2166 | export var EALREADY: number;
2167 | export var EBADF: number;
2168 | export var EBADMSG: number;
2169 | export var EBUSY: number;
2170 | export var ECANCELED: number;
2171 | export var ECHILD: number;
2172 | export var ECONNABORTED: number;
2173 | export var ECONNREFUSED: number;
2174 | export var ECONNRESET: number;
2175 | export var EDEADLK: number;
2176 | export var EDESTADDRREQ: number;
2177 | export var EDOM: number;
2178 | export var EEXIST: number;
2179 | export var EFAULT: number;
2180 | export var EFBIG: number;
2181 | export var EHOSTUNREACH: number;
2182 | export var EIDRM: number;
2183 | export var EILSEQ: number;
2184 | export var EINPROGRESS: number;
2185 | export var EINTR: number;
2186 | export var EINVAL: number;
2187 | export var EIO: number;
2188 | export var EISCONN: number;
2189 | export var EISDIR: number;
2190 | export var ELOOP: number;
2191 | export var EMFILE: number;
2192 | export var EMLINK: number;
2193 | export var EMSGSIZE: number;
2194 | export var ENAMETOOLONG: number;
2195 | export var ENETDOWN: number;
2196 | export var ENETRESET: number;
2197 | export var ENETUNREACH: number;
2198 | export var ENFILE: number;
2199 | export var ENOBUFS: number;
2200 | export var ENODATA: number;
2201 | export var ENODEV: number;
2202 | export var ENOENT: number;
2203 | export var ENOEXEC: number;
2204 | export var ENOLCK: number;
2205 | export var ENOLINK: number;
2206 | export var ENOMEM: number;
2207 | export var ENOMSG: number;
2208 | export var ENOPROTOOPT: number;
2209 | export var ENOSPC: number;
2210 | export var ENOSR: number;
2211 | export var ENOSTR: number;
2212 | export var ENOSYS: number;
2213 | export var ENOTCONN: number;
2214 | export var ENOTDIR: number;
2215 | export var ENOTEMPTY: number;
2216 | export var ENOTSOCK: number;
2217 | export var ENOTSUP: number;
2218 | export var ENOTTY: number;
2219 | export var ENXIO: number;
2220 | export var EOPNOTSUPP: number;
2221 | export var EOVERFLOW: number;
2222 | export var EPERM: number;
2223 | export var EPIPE: number;
2224 | export var EPROTO: number;
2225 | export var EPROTONOSUPPORT: number;
2226 | export var EPROTOTYPE: number;
2227 | export var ERANGE: number;
2228 | export var EROFS: number;
2229 | export var ESPIPE: number;
2230 | export var ESRCH: number;
2231 | export var ETIME: number;
2232 | export var ETIMEDOUT: number;
2233 | export var ETXTBSY: number;
2234 | export var EWOULDBLOCK: number;
2235 | export var EXDEV: number;
2236 | export var WSAEINTR: number;
2237 | export var WSAEBADF: number;
2238 | export var WSAEACCES: number;
2239 | export var WSAEFAULT: number;
2240 | export var WSAEINVAL: number;
2241 | export var WSAEMFILE: number;
2242 | export var WSAEWOULDBLOCK: number;
2243 | export var WSAEINPROGRESS: number;
2244 | export var WSAEALREADY: number;
2245 | export var WSAENOTSOCK: number;
2246 | export var WSAEDESTADDRREQ: number;
2247 | export var WSAEMSGSIZE: number;
2248 | export var WSAEPROTOTYPE: number;
2249 | export var WSAENOPROTOOPT: number;
2250 | export var WSAEPROTONOSUPPORT: number;
2251 | export var WSAESOCKTNOSUPPORT: number;
2252 | export var WSAEOPNOTSUPP: number;
2253 | export var WSAEPFNOSUPPORT: number;
2254 | export var WSAEAFNOSUPPORT: number;
2255 | export var WSAEADDRINUSE: number;
2256 | export var WSAEADDRNOTAVAIL: number;
2257 | export var WSAENETDOWN: number;
2258 | export var WSAENETUNREACH: number;
2259 | export var WSAENETRESET: number;
2260 | export var WSAECONNABORTED: number;
2261 | export var WSAECONNRESET: number;
2262 | export var WSAENOBUFS: number;
2263 | export var WSAEISCONN: number;
2264 | export var WSAENOTCONN: number;
2265 | export var WSAESHUTDOWN: number;
2266 | export var WSAETOOMANYREFS: number;
2267 | export var WSAETIMEDOUT: number;
2268 | export var WSAECONNREFUSED: number;
2269 | export var WSAELOOP: number;
2270 | export var WSAENAMETOOLONG: number;
2271 | export var WSAEHOSTDOWN: number;
2272 | export var WSAEHOSTUNREACH: number;
2273 | export var WSAENOTEMPTY: number;
2274 | export var WSAEPROCLIM: number;
2275 | export var WSAEUSERS: number;
2276 | export var WSAEDQUOT: number;
2277 | export var WSAESTALE: number;
2278 | export var WSAEREMOTE: number;
2279 | export var WSASYSNOTREADY: number;
2280 | export var WSAVERNOTSUPPORTED: number;
2281 | export var WSANOTINITIALISED: number;
2282 | export var WSAEDISCON: number;
2283 | export var WSAENOMORE: number;
2284 | export var WSAECANCELLED: number;
2285 | export var WSAEINVALIDPROCTABLE: number;
2286 | export var WSAEINVALIDPROVIDER: number;
2287 | export var WSAEPROVIDERFAILEDINIT: number;
2288 | export var WSASYSCALLFAILURE: number;
2289 | export var WSASERVICE_NOT_FOUND: number;
2290 | export var WSATYPE_NOT_FOUND: number;
2291 | export var WSA_E_NO_MORE: number;
2292 | export var WSA_E_CANCELLED: number;
2293 | export var WSAEREFUSED: number;
2294 | export var SIGHUP: number;
2295 | export var SIGINT: number;
2296 | export var SIGILL: number;
2297 | export var SIGABRT: number;
2298 | export var SIGFPE: number;
2299 | export var SIGKILL: number;
2300 | export var SIGSEGV: number;
2301 | export var SIGTERM: number;
2302 | export var SIGBREAK: number;
2303 | export var SIGWINCH: number;
2304 | export var SSL_OP_ALL: number;
2305 | export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number;
2306 | export var SSL_OP_CIPHER_SERVER_PREFERENCE: number;
2307 | export var SSL_OP_CISCO_ANYCONNECT: number;
2308 | export var SSL_OP_COOKIE_EXCHANGE: number;
2309 | export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number;
2310 | export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number;
2311 | export var SSL_OP_EPHEMERAL_RSA: number;
2312 | export var SSL_OP_LEGACY_SERVER_CONNECT: number;
2313 | export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number;
2314 | export var SSL_OP_MICROSOFT_SESS_ID_BUG: number;
2315 | export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number;
2316 | export var SSL_OP_NETSCAPE_CA_DN_BUG: number;
2317 | export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number;
2318 | export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number;
2319 | export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number;
2320 | export var SSL_OP_NO_COMPRESSION: number;
2321 | export var SSL_OP_NO_QUERY_MTU: number;
2322 | export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number;
2323 | export var SSL_OP_NO_SSLv2: number;
2324 | export var SSL_OP_NO_SSLv3: number;
2325 | export var SSL_OP_NO_TICKET: number;
2326 | export var SSL_OP_NO_TLSv1: number;
2327 | export var SSL_OP_NO_TLSv1_1: number;
2328 | export var SSL_OP_NO_TLSv1_2: number;
2329 | export var SSL_OP_PKCS1_CHECK_1: number;
2330 | export var SSL_OP_PKCS1_CHECK_2: number;
2331 | export var SSL_OP_SINGLE_DH_USE: number;
2332 | export var SSL_OP_SINGLE_ECDH_USE: number;
2333 | export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number;
2334 | export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number;
2335 | export var SSL_OP_TLS_BLOCK_PADDING_BUG: number;
2336 | export var SSL_OP_TLS_D5_BUG: number;
2337 | export var SSL_OP_TLS_ROLLBACK_BUG: number;
2338 | export var ENGINE_METHOD_DSA: number;
2339 | export var ENGINE_METHOD_DH: number;
2340 | export var ENGINE_METHOD_RAND: number;
2341 | export var ENGINE_METHOD_ECDH: number;
2342 | export var ENGINE_METHOD_ECDSA: number;
2343 | export var ENGINE_METHOD_CIPHERS: number;
2344 | export var ENGINE_METHOD_DIGESTS: number;
2345 | export var ENGINE_METHOD_STORE: number;
2346 | export var ENGINE_METHOD_PKEY_METHS: number;
2347 | export var ENGINE_METHOD_PKEY_ASN1_METHS: number;
2348 | export var ENGINE_METHOD_ALL: number;
2349 | export var ENGINE_METHOD_NONE: number;
2350 | export var DH_CHECK_P_NOT_SAFE_PRIME: number;
2351 | export var DH_CHECK_P_NOT_PRIME: number;
2352 | export var DH_UNABLE_TO_CHECK_GENERATOR: number;
2353 | export var DH_NOT_SUITABLE_GENERATOR: number;
2354 | export var NPN_ENABLED: number;
2355 | export var RSA_PKCS1_PADDING: number;
2356 | export var RSA_SSLV23_PADDING: number;
2357 | export var RSA_NO_PADDING: number;
2358 | export var RSA_PKCS1_OAEP_PADDING: number;
2359 | export var RSA_X931_PADDING: number;
2360 | export var RSA_PKCS1_PSS_PADDING: number;
2361 | export var POINT_CONVERSION_COMPRESSED: number;
2362 | export var POINT_CONVERSION_UNCOMPRESSED: number;
2363 | export var POINT_CONVERSION_HYBRID: number;
2364 | export var O_RDONLY: number;
2365 | export var O_WRONLY: number;
2366 | export var O_RDWR: number;
2367 | export var S_IFMT: number;
2368 | export var S_IFREG: number;
2369 | export var S_IFDIR: number;
2370 | export var S_IFCHR: number;
2371 | export var S_IFLNK: number;
2372 | export var O_CREAT: number;
2373 | export var O_EXCL: number;
2374 | export var O_TRUNC: number;
2375 | export var O_APPEND: number;
2376 | export var F_OK: number;
2377 | export var R_OK: number;
2378 | export var W_OK: number;
2379 | export var X_OK: number;
2380 | export var UV_UDP_REUSEADDR: number;
2381 | }
--------------------------------------------------------------------------------
/typings/globals/node/typings.json:
--------------------------------------------------------------------------------
1 | {
2 | "resolution": "main",
3 | "tree": {
4 | "src": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6d0e826824da52204c1c93f92cecbc961ac84fa9/node/node.d.ts",
5 | "raw": "registry:dt/node#4.0.0+20160509154515",
6 | "typings": "https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/6d0e826824da52204c1c93f92cecbc961ac84fa9/node/node.d.ts"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/typings/index.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 | ///
4 | ///
5 |
--------------------------------------------------------------------------------
/webpack.config.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var webpack = require('webpack');
3 | var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
4 |
5 | module.exports = {
6 | devtool: 'source-map',
7 | debug: true,
8 |
9 | entry: {
10 | 'angular2': [
11 | 'rxjs',
12 | 'reflect-metadata',
13 | 'zone.js',
14 | '@angular/core',
15 | '@angular/router',
16 | '@angular/http'
17 | ],
18 | 'app': './app/app'
19 | },
20 |
21 | output: {
22 | path: __dirname + '/build/',
23 | publicPath: 'build/',
24 | filename: '[name].js',
25 | sourceMapFilename: '[name].js.map',
26 | chunkFilename: '[id].chunk.js'
27 | },
28 |
29 | resolve: {
30 | extensions: ['','.ts','.js','.json', '.css', '.html']
31 | },
32 |
33 | module: {
34 | loaders: [
35 | {
36 | test: /\.ts$/,
37 | loader: 'ts',
38 | exclude: [ /node_modules/ ]
39 | }
40 | ]
41 | },
42 |
43 | plugins: [
44 | new CommonsChunkPlugin({ name: 'angular2', filename: 'angular2.js', minChunks: Infinity }),
45 | new CommonsChunkPlugin({ name: 'common', filename: 'common.js' })
46 | ],
47 | target: 'electron-renderer'
48 | };
--------------------------------------------------------------------------------