├── .gitignore ├── .rapignore ├── .travis.yml ├── README.md ├── examples └── device-information │ ├── README.md │ ├── app.json │ ├── package.json │ ├── src │ └── index.js │ ├── static │ └── style.css │ └── views │ └── index.html ├── mime.json ├── package.json ├── src ├── index.ts └── test │ └── static-files-test.ts ├── test ├── static │ ├── 1.html │ ├── 2.unknown │ └── 3.js.gz ├── test.js └── views │ └── index.html ├── tsconfig.json └── typings ├── assertion-error └── assertion-error.d.ts ├── chai-as-promised └── chai-as-promised.d.ts ├── chai └── chai.d.ts ├── fetch.d.ts ├── node └── node.d.ts ├── promises-a-plus └── promises-a-plus.d.ts └── references.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | /.vscode/ 2 | /.ruff/ 3 | 4 | /src/debug/ 5 | node_modules/ 6 | ruff_modules/ 7 | /bld/ 8 | 9 | /examples/*/ruff_box.json 10 | -------------------------------------------------------------------------------- /.rapignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | coverage/** 3 | src/** 4 | bld/test/** 5 | bld/debug/** 6 | test/** 7 | typings/** 8 | examples/** 9 | 10 | .* 11 | 12 | *.zip 13 | *.tar 14 | 15 | tsconfig.json 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '6' 4 | before_script: 5 | - npm run install-sdk 6 | - npm run install-rap-dependencies 7 | - npm run build 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/vilic/ruff-home.svg)](https://travis-ci.org/vilic/ruff-home) 2 | 3 | # Home (Web Framework) for Ruff 4 | 5 | GitHub 6 | 7 | ## Install 8 | 9 | ```sh 10 | rap install home 11 | ``` 12 | 13 | ## Usage 14 | 15 | Here's a simple example (code available [here](./examples/device-information)): 16 | 17 | **src/index.js** 18 | 19 | ```js 20 | 'use strict'; 21 | 22 | var Path = require('path'); 23 | var Server = require('home').Server; 24 | 25 | var server = new Server(); 26 | 27 | server.use('/', Server.static('static')); 28 | 29 | server.get('/', function (req) { 30 | return { 31 | sn: process.ruff.sn, 32 | time: Date.now() 33 | }; 34 | }); 35 | 36 | server.listen(80); 37 | ``` 38 | 39 | **views/index.html** 40 | 41 | ```html 42 | 43 | 44 | 45 | 46 | Device Information 47 | 48 | 49 | 50 |

Device Information

51 | 55 | 56 | 57 | ``` 58 | 59 | **static/style.css** 60 | 61 | ```css 62 | body { 63 | font-family: sans-serif; 64 | color: #666; 65 | } 66 | 67 | h1 { 68 | font-weight: normal; 69 | color: #333; 70 | } 71 | ``` 72 | 73 | ## API References 74 | 75 | Home provides a simple middleware mechanism based on promise: 76 | 77 | ```js 78 | // Matches all request with path `/*`. 79 | server.use('/', function (req) { 80 | // ... 81 | 82 | // If `req` (or a promise with it as value) is returned, 83 | // otherwise the request stops here. 84 | return req; 85 | }); 86 | ``` 87 | 88 | ### Hosting Static Files 89 | 90 | Just like Express, Home provides a built-in (but tiny) `static` middleware for hosting static files: 91 | 92 | ```js 93 | server.use('/', Server.static('static')); 94 | ``` 95 | 96 | The first `'/'` means that we will try to find a static file for request that matches `/*`, and `'static'` means we are going to find that file under `static` folder (it could also be an absolute path). 97 | 98 | ### Handling Requests 99 | 100 | By returning an object or a promise with an object as its value, Home will response with the correspondent JSON. 101 | 102 | ```js 103 | // Matches GET requests with path `/`. 104 | server.get('/', function (req) { 105 | return { 106 | value: 123 107 | }; 108 | }); 109 | ``` 110 | 111 | But if a view file is found for the request path, Home will render the view instead: 112 | 113 | * For `/foo/bar`, it will look for `${viewsDir}/foo/bar.html`. 114 | * For `/`, it will look for `${viewsDir}/index.html`. 115 | 116 | Home also provides an `ExpectedError` class with a `statusCode` property. 117 | When an error of this class is thrown, Home will update the response status code according to the error. 118 | 119 | Error views should be named after the status code and put into `${viewsDir}/${errorViewsFolder}`. 120 | 121 | ### Response 122 | 123 | If you want to handle the response yourself, you can either process the `res` object directly (following `req` parameter) or create a concrete class of `Response` and implement method `applyTo(res: ServerResponse): void`. 124 | If you are going to handle `res` object directly, make sure headers get sent before the function returns. 125 | 126 | ## License 127 | 128 | MIT License. 129 | -------------------------------------------------------------------------------- /examples/device-information/README.md: -------------------------------------------------------------------------------- 1 | # Device Information Application 2 | 3 | ## Install & Layout 4 | 5 | ```sh 6 | # Install dependencies. 7 | rap install 8 | 9 | # Layout `ruff_box.json`. 10 | rap layout 11 | ``` 12 | 13 | ## Deploy & Start 14 | 15 | ```sh 16 | # Select a device to deploy, and keep its IP address. 17 | rap scan 18 | 19 | # Deploy and start application. 20 | rap deploy -s 21 | ``` 22 | 23 | ## Visit Home Page 24 | 25 | This application listens on port 80, visit the home page by visiting `http://`. 26 | 27 | ## License 28 | 29 | MIT License. 30 | -------------------------------------------------------------------------------- /examples/device-information/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "board": "ruff-mbd-v1", 3 | "devices": [] 4 | } -------------------------------------------------------------------------------- /examples/device-information/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "device-information", 3 | "version": "0.1.0", 4 | "description": "A home page for device information.", 5 | "author": "vilicvane", 6 | "main": "src/index.js", 7 | "ruff": { 8 | "dependencies": { 9 | "ruff-mbd-v1": "^2.0.3", 10 | "home": "^0.1.1" 11 | }, 12 | "devDependencies": {} 13 | } 14 | } -------------------------------------------------------------------------------- /examples/device-information/src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Path = require('path'); 4 | var Server = require('home').Server; 5 | 6 | var server = new Server(); 7 | 8 | server.use('/', Server.static('static')); 9 | 10 | server.get('/', function (req) { 11 | return { 12 | sn: process.ruff.sn, 13 | time: Date.now() 14 | }; 15 | }); 16 | 17 | server.listen(80); 18 | -------------------------------------------------------------------------------- /examples/device-information/static/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: sans-serif; 3 | color: #666; 4 | } 5 | 6 | h1 { 7 | font-weight: normal; 8 | color: #333; 9 | } 10 | -------------------------------------------------------------------------------- /examples/device-information/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Device Information 6 | 7 | 8 | 9 |

Device Information

10 | 14 | 15 | -------------------------------------------------------------------------------- /mime.json: -------------------------------------------------------------------------------- 1 | { 2 | ".txt": "text/plain", 3 | ".text": "text/plain", 4 | ".htm": "text/html", 5 | ".html": "text/html", 6 | ".png": "image/png", 7 | ".jpg": "image/jpeg", 8 | ".jpeg": "image/jpeg", 9 | ".gif": "image/gif", 10 | ".js": "text/javascript", 11 | ".css": "text/css" 12 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "home", 3 | "version": "0.1.8", 4 | "description": "Home (Web Framework) for Ruff.", 5 | "author": "vilicvane", 6 | "license": "MIT", 7 | "main": "bld/index.js", 8 | "typings": "bld/index.d.ts", 9 | "scripts": { 10 | "install-sdk": "rvm install --local", 11 | "install-rap-dependencies": "rap install", 12 | "build": "tsc", 13 | "test": "ruff test/test.js" 14 | }, 15 | "engines": { 16 | "ruff": "^1.3.0" 17 | }, 18 | "devDependencies": { 19 | "rvm": "^0.3.2", 20 | "typescript": "^2.0.3" 21 | }, 22 | "ruff": { 23 | "dependencies": { 24 | "promise": "^0.1.2" 25 | }, 26 | "devDependencies": { 27 | "t": "^0.1.7", 28 | "chai": "npm:^3.5.0", 29 | "chai-as-promised": "npm:^6.0.0", 30 | "fetch": "^0.1.2" 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Home (Web Framework) for Ruff. 3 | * A tiny web framework. 4 | * 5 | * https://github.com/vilic/ruff-home 6 | * 7 | * MIT License 8 | */ 9 | 10 | import 'promise'; 11 | 12 | import * as FS from 'fs'; 13 | import * as HTTP from 'http'; 14 | import { IncomingMessage, ServerResponse } from 'http'; 15 | import * as Path from 'path'; 16 | import * as QueryString from 'querystring'; 17 | import * as URL from 'url'; 18 | 19 | export type HTTPMethod = 'GET' | 'POST'; 20 | 21 | export interface Dictionary { 22 | [key: string]: T; 23 | } 24 | 25 | export type Resolvable = Promise | T; 26 | 27 | export interface Request extends IncomingMessage { 28 | path: string; 29 | query: Dictionary; 30 | } 31 | 32 | export interface Middleware { 33 | (req: Request, res: ServerResponse): Resolvable; 34 | } 35 | 36 | export interface RouteOptions { 37 | method: string | undefined; 38 | path: string; 39 | extendable: boolean; 40 | middleware: Middleware; 41 | } 42 | 43 | export interface Route extends RouteOptions { 44 | pathWithEndingSlash: string; 45 | } 46 | 47 | export abstract class Response { 48 | abstract applyTo(req: ServerResponse): void; 49 | } 50 | 51 | export class ExpectedError { 52 | constructor( 53 | public message: string, 54 | public statusCode = 500 55 | ) { } 56 | } 57 | 58 | export class NotFoundError extends ExpectedError { 59 | constructor( 60 | message: string, 61 | public path: string 62 | ) { 63 | super(message, 404); 64 | } 65 | } 66 | 67 | const hop = Object.prototype.hasOwnProperty; 68 | 69 | let mimeMap = require('../mime.json'); 70 | 71 | let voidPromise = Promise.resolve(); 72 | 73 | export class Server { 74 | server = HTTP.createServer(); 75 | routes: Route[] = []; 76 | 77 | views: string; 78 | errorViewsFolder: string; 79 | 80 | private _templateCache: Dictionary = {}; 81 | 82 | constructor({ 83 | views = Path.resolve('views'), 84 | errorViewsFolder = 'error' 85 | } = {}) { 86 | this.views = views; 87 | this.errorViewsFolder = errorViewsFolder; 88 | 89 | this.server.on('request', (req: IncomingMessage, res: ServerResponse) => { 90 | this._handleRequest(req as Request, res); 91 | }); 92 | } 93 | 94 | private _handleRequest(req: Request, res: ServerResponse): void { 95 | let urlStr = req.url; 96 | let { pathname, query: queryStr } = URL.parse(urlStr!); 97 | 98 | req.query = QueryString.parse(queryStr); 99 | 100 | let routes = this.routes; 101 | let index = 0; 102 | 103 | let next = () => { 104 | let route = routes[index++]; 105 | 106 | if (!route) { 107 | this._handleError(pathname, res, new NotFoundError('Page Not Found', pathname)); 108 | return; 109 | } 110 | 111 | let method = route.method; 112 | 113 | if ( 114 | (method && method !== req.method) || ( 115 | pathname !== route.path && 116 | (!route.extendable || pathname.indexOf(route.pathWithEndingSlash) !== 0) 117 | ) 118 | ) { 119 | next(); 120 | return; 121 | } 122 | 123 | req.path = route.extendable && route.path !== '/' ? 124 | pathname.substr(route.path.length) : pathname; 125 | 126 | let resultResolvable: Resolvable; 127 | 128 | try { 129 | resultResolvable = route.middleware(req, res); 130 | } catch (error) { 131 | this._handleError(pathname, res, error); 132 | return; 133 | } 134 | 135 | // Performance reason. 136 | if (resultResolvable === req) { 137 | next(); 138 | } else { 139 | Promise 140 | .resolve(resultResolvable) 141 | .then(result => { 142 | if (result === req) { 143 | next(); 144 | } else { 145 | this._handleResult(pathname, res, result); 146 | } 147 | }, reason => { 148 | this._handleError(pathname, res, reason); 149 | }); 150 | } 151 | }; 152 | 153 | next(); 154 | } 155 | 156 | add(options: RouteOptions): void { 157 | let route = options as Route; 158 | let path = options.path; 159 | 160 | if (path === '/') { 161 | route.path = path; 162 | route.pathWithEndingSlash = path; 163 | } else if (/\/$/.test(path)) { 164 | route.path = path.substr(0, path.length - 1); 165 | route.pathWithEndingSlash = path; 166 | } else { 167 | route.path = path; 168 | route.pathWithEndingSlash = path + '/'; 169 | } 170 | 171 | this.routes.push(route); 172 | } 173 | 174 | use(path: string, middleware: Middleware): void { 175 | this.add({ 176 | method: undefined, 177 | path, 178 | extendable: true, 179 | middleware 180 | }); 181 | } 182 | 183 | get(path: string, middleware: Middleware): void { 184 | this.add({ 185 | method: 'GET', 186 | path, 187 | extendable: false, 188 | middleware 189 | }); 190 | } 191 | 192 | post(path: string, middleware: Middleware): void { 193 | this.add({ 194 | method: 'POST', 195 | path, 196 | extendable: false, 197 | middleware 198 | }); 199 | } 200 | 201 | listen(port: number, hostname?: string): Promise { 202 | return new Promise((resolve, reject) => { 203 | this.server.listen(port, hostname, (error: Error) => { 204 | if (error) { 205 | reject(error); 206 | } else { 207 | resolve(); 208 | } 209 | }); 210 | }); 211 | } 212 | 213 | private _handleResult(path: string, res: ServerResponse, result: Response | Object | void): void { 214 | if ((res)._headerSent) { 215 | return; 216 | } 217 | 218 | if (result instanceof Response) { 219 | result.applyTo(res); 220 | } else { 221 | // Ideally, we should convert result into an instance of response and apply it later. 222 | // But as it's running on board, that step is skipped for performance reason. 223 | 224 | let html = this._render(path, result); 225 | 226 | if (html === undefined) { 227 | let json = JSON.stringify(result); 228 | 229 | if (json) { 230 | res.setHeader('Content-Type', 'application/json'); 231 | res.write(json); 232 | } 233 | 234 | res.end(); 235 | } else { 236 | res.setHeader('Content-Type', 'text/html'); 237 | res.write(html); 238 | res.end(); 239 | } 240 | } 241 | } 242 | 243 | private _handleError(path: string, res: ServerResponse, error: ExpectedError | Error | Object): void { 244 | if ((res)._headerSent) { 245 | return; 246 | } 247 | 248 | let html: string; 249 | let statusCode: number; 250 | 251 | if (error instanceof ExpectedError) { 252 | statusCode = error.statusCode; 253 | html = this._render(`${this.errorViewsFolder}/${statusCode}`, error) || 254 | error.message; 255 | } else { 256 | statusCode = 500; 257 | html = 'Server Error'; 258 | } 259 | 260 | res.statusCode = statusCode; 261 | res.setHeader('Content-Type', 'text/html'); 262 | 263 | res.write(html); 264 | res.end(); 265 | 266 | console.error(error); 267 | } 268 | 269 | private _render(view: string, data: any): string | undefined { 270 | if (view === '/') { 271 | view += 'index'; 272 | } 273 | 274 | let template: string | undefined; 275 | 276 | if (hop.call(this._templateCache, view)) { 277 | template = this._templateCache[view]; 278 | 279 | if (!template) { 280 | return undefined; 281 | } 282 | } else { 283 | let viewPath = Path.join(this.views, view + '.html'); 284 | 285 | if (FS.existsSync(viewPath)) { 286 | template = FS.readFileSync(viewPath, 'utf-8'); 287 | this._templateCache[view] = template; 288 | } else { 289 | this._templateCache[view] = undefined; 290 | return undefined; 291 | } 292 | } 293 | 294 | data = data || Object.create(null); 295 | 296 | return template.replace(/\{([$\w\d.-]+)\}/g, (text: string, expression: string) => { 297 | let keys = expression.split('.'); 298 | 299 | let node = data; 300 | 301 | for (let key of keys) { 302 | node = node[key]; 303 | 304 | if (node === undefined) { 305 | return text; 306 | } 307 | } 308 | 309 | return node; 310 | }); 311 | } 312 | 313 | static static(path: string, defaultPath = '/index.html'): Middleware { 314 | return (req, res) => { 315 | return new Promise((resolve, reject) => { 316 | if (defaultPath && defaultPath[0] !== '/') { 317 | defaultPath = '/' + defaultPath; 318 | } 319 | 320 | let urlPath = req.path === '/' ? defaultPath : req.path; 321 | let filePath: string | undefined = Path.join(path, urlPath); 322 | 323 | let candidates = [ 324 | { 325 | path: `${filePath}.gz`, 326 | gzipped: true 327 | }, 328 | { 329 | path: filePath, 330 | gzipped: false 331 | } 332 | ] 333 | 334 | let target = findAndMerge(candidates, candidate => { 335 | try { 336 | let stats = FS.statSync(candidate.path); 337 | return stats.isFile() ? 338 | { size: stats.size } : undefined; 339 | } catch (error) { 340 | return undefined; 341 | } 342 | }); 343 | 344 | if (!target) { 345 | resolve(req); 346 | return; 347 | } 348 | 349 | if (target.gzipped) { 350 | res.setHeader('Content-Encoding', 'gzip'); 351 | } 352 | 353 | res.setHeader('Content-Length', target.size.toString()); 354 | 355 | let extname = Path.extname(filePath); 356 | 357 | res.setHeader( 358 | 'Content-Type', 359 | hop.call(mimeMap, extname) ? 360 | mimeMap[extname] : 'application/octet-stream' 361 | ); 362 | 363 | try { 364 | let stream = FS.createReadStream(target.path); 365 | 366 | stream.pipe(res); 367 | 368 | stream.on('error', reject); 369 | res.on('error', reject); 370 | 371 | res.on('end', () => resolve()); 372 | } catch (error) { 373 | reject(error); 374 | } 375 | }); 376 | }; 377 | } 378 | } 379 | 380 | export default Server; 381 | 382 | type FindAndMergeFilter = (item: T) => U | undefined; 383 | 384 | function findAndMerge(items: T[], filter: FindAndMergeFilter): T & U | undefined { 385 | for (let item of items) { 386 | let ret = filter(item); 387 | 388 | if (ret) { 389 | return assign(item, ret); 390 | } 391 | } 392 | 393 | return undefined; 394 | } 395 | 396 | function assign(target: T, source: U): T & U { 397 | for (let key of Object.keys(source)) { 398 | if (!(key in target)) { 399 | (target)[key] = (source)[key]; 400 | } 401 | } 402 | 403 | return target as T & U; 404 | } 405 | -------------------------------------------------------------------------------- /src/test/static-files-test.ts: -------------------------------------------------------------------------------- 1 | import * as Path from 'path'; 2 | 3 | import fetch from 'fetch'; 4 | import { Server } from '../'; 5 | 6 | import 't'; 7 | 8 | const port = 8088; 9 | const baseUrl = `http://127.0.0.1:${port}`; 10 | 11 | describe('Static files', () => { 12 | let server: Server; 13 | 14 | before(() => { 15 | server = new Server(); 16 | server.use('/', Server.static(Path.join(__dirname, '../../test/static'))); 17 | return server.listen(port); 18 | }); 19 | 20 | after(() => { 21 | return new Promise((resolve, reject) => { 22 | server.server.close((error: any) => error ? reject(error) : resolve()); 23 | }); 24 | }) 25 | 26 | it('Should handle files with configured content type', () => { 27 | return fetch(`${baseUrl}/1.html`) 28 | .then(response => response.text()) 29 | .then(text => { 30 | text.trim().should.equal('text/html'); 31 | }); 32 | }); 33 | 34 | it('Should handle files with unknown content type', () => { 35 | return fetch(`${baseUrl}/2.unknown`) 36 | .then(response => response.text()) 37 | .then(text => { 38 | text.trim().should.equal('application/octet-stream'); 39 | }); 40 | }); 41 | 42 | it('Should handle pre-gzipped files', () => { 43 | return fetch(`${baseUrl}/3.js`) 44 | .then(response => { 45 | response.headers['content-encoding'].should.equal('gzip'); 46 | return response.buffer(); 47 | }) 48 | .then(buffer => { 49 | buffer.length.should.be.greaterThan(0); 50 | }); 51 | }); 52 | }); 53 | 54 | describe('Static files under specified path', () => { 55 | let server: Server; 56 | 57 | before(() => { 58 | server = new Server({ 59 | views: Path.join(__dirname, '../../test/views') 60 | }); 61 | 62 | server.use('/build', Server.static(Path.join(__dirname, '../../test/static'))); 63 | 64 | server.get('/', () => { 65 | return { 66 | foo: 'abc' 67 | }; 68 | }); 69 | 70 | return server.listen(port); 71 | }); 72 | 73 | after(() => { 74 | return new Promise((resolve, reject) => { 75 | server.server.close((error: any) => error ? reject(error) : resolve()); 76 | }); 77 | }) 78 | 79 | it('Should handle files with configured content type', () => { 80 | return fetch(`${baseUrl}/build/1.html`) 81 | .then(response => response.text()) 82 | .then(text => { 83 | text.trim().should.equal('text/html'); 84 | }); 85 | }); 86 | 87 | it('Should handle files with unknown content type', () => { 88 | return fetch(`${baseUrl}/build/2.unknown`) 89 | .then(response => response.text()) 90 | .then(text => { 91 | text.trim().should.equal('application/octet-stream'); 92 | }); 93 | }); 94 | 95 | it('Should handle pre-gzipped files', () => { 96 | return fetch(`${baseUrl}/build/3.js`) 97 | .then(response => { 98 | response.headers['content-encoding'].should.equal('gzip'); 99 | return response.buffer(); 100 | }) 101 | .then(buffer => { 102 | buffer.length.should.be.greaterThan(0); 103 | }); 104 | }); 105 | 106 | it('Should not break views path', () => { 107 | return fetch(baseUrl) 108 | .then(response => response.text()) 109 | .then(text => { 110 | text.trim().should.equal('abc'); 111 | }); 112 | }); 113 | }); 114 | -------------------------------------------------------------------------------- /test/static/1.html: -------------------------------------------------------------------------------- 1 | text/html 2 | -------------------------------------------------------------------------------- /test/static/2.unknown: -------------------------------------------------------------------------------- 1 | application/octet-stream 2 | -------------------------------------------------------------------------------- /test/static/3.js.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vilicvane/ruff-home/f6c5e914834eeff673b065b5a12352a3f9e2f88b/test/static/3.js.gz -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Chai = require('chai'); 4 | 5 | Chai.should(); 6 | Chai.use(require('chai-as-promised')); 7 | 8 | require('../bld/test/static-files-test'); 9 | -------------------------------------------------------------------------------- /test/views/index.html: -------------------------------------------------------------------------------- 1 | {foo} 2 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "noLib": true, 6 | "noEmitOnError": true, 7 | "noImplicitAny": true, 8 | "noImplicitReturns": true, 9 | "noImplicitThis": true, 10 | "strictNullChecks": true, 11 | "preserveConstEnums": true, 12 | "removeComments": true, 13 | "declaration": true, 14 | "sourceMap": true, 15 | "newLine": "LF", 16 | "outDir": "bld" 17 | }, 18 | "exclude": [ 19 | "node_modules", 20 | "ruff_modules" 21 | ] 22 | } -------------------------------------------------------------------------------- /typings/assertion-error/assertion-error.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for assertion-error 1.0.0 2 | // Project: https://github.com/chaijs/assertion-error 3 | // Definitions by: Bart van der Schoor 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | declare module 'assertion-error' { 7 | class AssertionError implements Error { 8 | constructor(message: string, props?: any, ssf?: Function); 9 | name: string; 10 | message: string; 11 | showDiff: boolean; 12 | stack: string; 13 | } 14 | export = AssertionError; 15 | } 16 | -------------------------------------------------------------------------------- /typings/chai-as-promised/chai-as-promised.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for chai-as-promised 2 | // Project: https://github.com/domenic/chai-as-promised/ 3 | // Definitions by: jt000 , Yuki Kokubun 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | /// 7 | /// 8 | 9 | declare module 'chai-as-promised' { 10 | function chaiAsPromised(chai: any, utils: any): void; 11 | namespace chaiAsPromised {} 12 | export = chaiAsPromised; 13 | } 14 | 15 | declare namespace Chai { 16 | 17 | // For BDD API 18 | interface Assertion extends LanguageChains, NumericComparison, TypeComparison { 19 | eventually: PromisedAssertion; 20 | become(expected: any): PromisedAssertion; 21 | fulfilled: PromisedAssertion; 22 | rejected: PromisedAssertion; 23 | rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; 24 | notify(fn: Function): PromisedAssertion; 25 | } 26 | 27 | // Eventually does not have .then(), but PromisedAssertion have. 28 | interface Eventually extends PromisedLanguageChains, PromisedNumericComparison, PromisedTypeComparison { 29 | // From chai-as-promised 30 | become(expected: PromisesAPlus.Thenable): PromisedAssertion; 31 | fulfilled: PromisedAssertion; 32 | rejected: PromisedAssertion; 33 | rejectedWith(expected: any, message?: string | RegExp): PromisedAssertion; 34 | notify(fn: Function): PromisedAssertion; 35 | 36 | // From chai 37 | not: PromisedAssertion; 38 | deep: PromisedDeep; 39 | a: PromisedTypeComparison; 40 | an: PromisedTypeComparison; 41 | include: PromisedInclude; 42 | contain: PromisedInclude; 43 | ok: PromisedAssertion; 44 | true: PromisedAssertion; 45 | false: PromisedAssertion; 46 | null: PromisedAssertion; 47 | undefined: PromisedAssertion; 48 | exist: PromisedAssertion; 49 | empty: PromisedAssertion; 50 | arguments: PromisedAssertion; 51 | Arguments: PromisedAssertion; 52 | equal: PromisedEqual; 53 | equals: PromisedEqual; 54 | eq: PromisedEqual; 55 | eql: PromisedEqual; 56 | eqls: PromisedEqual; 57 | property: PromisedProperty; 58 | ownProperty: PromisedOwnProperty; 59 | haveOwnProperty: PromisedOwnProperty; 60 | length: PromisedLength; 61 | lengthOf: PromisedLength; 62 | match(regexp: RegExp|string, message?: string): PromisedAssertion; 63 | string(string: string, message?: string): PromisedAssertion; 64 | keys: PromisedKeys; 65 | key(string: string): PromisedAssertion; 66 | throw: PromisedThrow; 67 | throws: PromisedThrow; 68 | Throw: PromisedThrow; 69 | respondTo(method: string, message?: string): PromisedAssertion; 70 | itself: PromisedAssertion; 71 | satisfy(matcher: Function, message?: string): PromisedAssertion; 72 | closeTo(expected: number, delta: number, message?: string): PromisedAssertion; 73 | members: PromisedMembers; 74 | } 75 | 76 | interface PromisedAssertion extends Eventually, PromisesAPlus.Thenable { 77 | } 78 | 79 | interface PromisedLanguageChains { 80 | eventually: Eventually; 81 | 82 | // From chai 83 | to: PromisedAssertion; 84 | be: PromisedAssertion; 85 | been: PromisedAssertion; 86 | is: PromisedAssertion; 87 | that: PromisedAssertion; 88 | which: PromisedAssertion; 89 | and: PromisedAssertion; 90 | has: PromisedAssertion; 91 | have: PromisedAssertion; 92 | with: PromisedAssertion; 93 | at: PromisedAssertion; 94 | of: PromisedAssertion; 95 | same: PromisedAssertion; 96 | } 97 | 98 | interface PromisedNumericComparison { 99 | above: PromisedNumberComparer; 100 | gt: PromisedNumberComparer; 101 | greaterThan: PromisedNumberComparer; 102 | least: PromisedNumberComparer; 103 | gte: PromisedNumberComparer; 104 | below: PromisedNumberComparer; 105 | lt: PromisedNumberComparer; 106 | lessThan: PromisedNumberComparer; 107 | most: PromisedNumberComparer; 108 | lte: PromisedNumberComparer; 109 | within(start: number, finish: number, message?: string): PromisedAssertion; 110 | } 111 | 112 | interface PromisedNumberComparer { 113 | (value: number, message?: string): PromisedAssertion; 114 | } 115 | 116 | interface PromisedTypeComparison { 117 | (type: string, message?: string): PromisedAssertion; 118 | instanceof: PromisedInstanceOf; 119 | instanceOf: PromisedInstanceOf; 120 | } 121 | 122 | interface PromisedInstanceOf { 123 | (constructor: Object, message?: string): PromisedAssertion; 124 | } 125 | 126 | interface PromisedDeep { 127 | equal: PromisedEqual; 128 | include: PromisedInclude; 129 | property: PromisedProperty; 130 | } 131 | 132 | interface PromisedEqual { 133 | (value: any, message?: string): PromisedAssertion; 134 | } 135 | 136 | interface PromisedProperty { 137 | (name: string, value?: any, message?: string): PromisedAssertion; 138 | } 139 | 140 | interface PromisedOwnProperty { 141 | (name: string, message?: string): PromisedAssertion; 142 | } 143 | 144 | interface PromisedLength extends PromisedLanguageChains, PromisedNumericComparison { 145 | (length: number, message?: string): PromisedAssertion; 146 | } 147 | 148 | interface PromisedInclude { 149 | (value: Object, message?: string): PromisedAssertion; 150 | (value: string, message?: string): PromisedAssertion; 151 | (value: number, message?: string): PromisedAssertion; 152 | keys: PromisedKeys; 153 | members: PromisedMembers; 154 | } 155 | 156 | interface PromisedKeys { 157 | (...keys: string[]): PromisedAssertion; 158 | (keys: any[]): PromisedAssertion; 159 | } 160 | 161 | interface PromisedThrow { 162 | (): PromisedAssertion; 163 | (expected: string, message?: string): PromisedAssertion; 164 | (expected: RegExp, message?: string): PromisedAssertion; 165 | (constructor: Error, expected?: string, message?: string): PromisedAssertion; 166 | (constructor: Error, expected?: RegExp, message?: string): PromisedAssertion; 167 | (constructor: Function, expected?: string, message?: string): PromisedAssertion; 168 | (constructor: Function, expected?: RegExp, message?: string): PromisedAssertion; 169 | } 170 | 171 | interface PromisedMembers { 172 | (set: any[], message?: string): PromisedAssertion; 173 | } 174 | 175 | // For Assert API 176 | interface Assert { 177 | eventually: PromisedAssert; 178 | isFulfilled(promise: PromisesAPlus.Thenable, message?: string): PromisesAPlus.Thenable; 179 | becomes(promise: PromisesAPlus.Thenable, expected: any, message?: string): PromisesAPlus.Thenable; 180 | doesNotBecome(promise: PromisesAPlus.Thenable, expected: any, message?: string): PromisesAPlus.Thenable; 181 | isRejected(promise: PromisesAPlus.Thenable, message?: string): PromisesAPlus.Thenable; 182 | isRejected(promise: PromisesAPlus.Thenable, expected: any, message?: string): PromisesAPlus.Thenable; 183 | isRejected(promise: PromisesAPlus.Thenable, match: RegExp, message?: string): PromisesAPlus.Thenable; 184 | notify(fn: Function): PromisesAPlus.Thenable; 185 | } 186 | 187 | export interface PromisedAssert { 188 | fail(actual?: any, expected?: any, msg?: string, operator?: string): PromisesAPlus.Thenable; 189 | 190 | ok(val: any, msg?: string): PromisesAPlus.Thenable; 191 | notOk(val: any, msg?: string): PromisesAPlus.Thenable; 192 | 193 | equal(act: any, exp: any, msg?: string): PromisesAPlus.Thenable; 194 | notEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable; 195 | 196 | strictEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable; 197 | notStrictEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable; 198 | 199 | deepEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable; 200 | notDeepEqual(act: any, exp: any, msg?: string): PromisesAPlus.Thenable; 201 | 202 | isTrue(val: any, msg?: string): PromisesAPlus.Thenable; 203 | isFalse(val: any, msg?: string): PromisesAPlus.Thenable; 204 | 205 | isNull(val: any, msg?: string): PromisesAPlus.Thenable; 206 | isNotNull(val: any, msg?: string): PromisesAPlus.Thenable; 207 | 208 | isUndefined(val: any, msg?: string): PromisesAPlus.Thenable; 209 | isDefined(val: any, msg?: string): PromisesAPlus.Thenable; 210 | 211 | isFunction(val: any, msg?: string): PromisesAPlus.Thenable; 212 | isNotFunction(val: any, msg?: string): PromisesAPlus.Thenable; 213 | 214 | isObject(val: any, msg?: string): PromisesAPlus.Thenable; 215 | isNotObject(val: any, msg?: string): PromisesAPlus.Thenable; 216 | 217 | isArray(val: any, msg?: string): PromisesAPlus.Thenable; 218 | isNotArray(val: any, msg?: string): PromisesAPlus.Thenable; 219 | 220 | isString(val: any, msg?: string): PromisesAPlus.Thenable; 221 | isNotString(val: any, msg?: string): PromisesAPlus.Thenable; 222 | 223 | isNumber(val: any, msg?: string): PromisesAPlus.Thenable; 224 | isNotNumber(val: any, msg?: string): PromisesAPlus.Thenable; 225 | 226 | isBoolean(val: any, msg?: string): PromisesAPlus.Thenable; 227 | isNotBoolean(val: any, msg?: string): PromisesAPlus.Thenable; 228 | 229 | typeOf(val: any, type: string, msg?: string): PromisesAPlus.Thenable; 230 | notTypeOf(val: any, type: string, msg?: string): PromisesAPlus.Thenable; 231 | 232 | instanceOf(val: any, type: Function, msg?: string): PromisesAPlus.Thenable; 233 | notInstanceOf(val: any, type: Function, msg?: string): PromisesAPlus.Thenable; 234 | 235 | include(exp: string, inc: any, msg?: string): PromisesAPlus.Thenable; 236 | include(exp: any[], inc: any, msg?: string): PromisesAPlus.Thenable; 237 | 238 | notInclude(exp: string, inc: any, msg?: string): PromisesAPlus.Thenable; 239 | notInclude(exp: any[], inc: any, msg?: string): PromisesAPlus.Thenable; 240 | 241 | match(exp: any, re: RegExp, msg?: string): PromisesAPlus.Thenable; 242 | notMatch(exp: any, re: RegExp, msg?: string): PromisesAPlus.Thenable; 243 | 244 | property(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable; 245 | notProperty(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable; 246 | deepProperty(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable; 247 | notDeepProperty(obj: Object, prop: string, msg?: string): PromisesAPlus.Thenable; 248 | 249 | propertyVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable; 250 | propertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable; 251 | 252 | deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable; 253 | deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): PromisesAPlus.Thenable; 254 | 255 | lengthOf(exp: any, len: number, msg?: string): PromisesAPlus.Thenable; 256 | //alias frenzy 257 | throw(fn: Function, msg?: string): PromisesAPlus.Thenable; 258 | throw(fn: Function, regExp: RegExp): PromisesAPlus.Thenable; 259 | throw(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable; 260 | throw(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable; 261 | 262 | throws(fn: Function, msg?: string): PromisesAPlus.Thenable; 263 | throws(fn: Function, regExp: RegExp): PromisesAPlus.Thenable; 264 | throws(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable; 265 | throws(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable; 266 | 267 | Throw(fn: Function, msg?: string): PromisesAPlus.Thenable; 268 | Throw(fn: Function, regExp: RegExp): PromisesAPlus.Thenable; 269 | Throw(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable; 270 | Throw(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable; 271 | 272 | doesNotThrow(fn: Function, msg?: string): PromisesAPlus.Thenable; 273 | doesNotThrow(fn: Function, regExp: RegExp): PromisesAPlus.Thenable; 274 | doesNotThrow(fn: Function, errType: Function, msg?: string): PromisesAPlus.Thenable; 275 | doesNotThrow(fn: Function, errType: Function, regExp: RegExp): PromisesAPlus.Thenable; 276 | 277 | operator(val: any, operator: string, val2: any, msg?: string): PromisesAPlus.Thenable; 278 | closeTo(act: number, exp: number, delta: number, msg?: string): PromisesAPlus.Thenable; 279 | 280 | sameMembers(set1: any[], set2: any[], msg?: string): PromisesAPlus.Thenable; 281 | includeMembers(set1: any[], set2: any[], msg?: string): PromisesAPlus.Thenable; 282 | 283 | ifError(val: any, msg?: string): PromisesAPlus.Thenable; 284 | } 285 | } 286 | -------------------------------------------------------------------------------- /typings/chai/chai.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for chai 3.4.0 2 | // Project: http://chaijs.com/ 3 | // Definitions by: Jed Mao , 4 | // Bart van der Schoor , 5 | // Andrew Brown , 6 | // Olivier Chevet , 7 | // Matt Wistrand 8 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 9 | 10 | // 11 | 12 | declare namespace Chai { 13 | 14 | interface ChaiStatic { 15 | expect: ExpectStatic; 16 | should(): Should; 17 | /** 18 | * Provides a way to extend the internals of Chai 19 | */ 20 | use(fn: (chai: any, utils: any) => void): ChaiStatic; 21 | assert: AssertStatic; 22 | config: Config; 23 | AssertionError: typeof AssertionError; 24 | } 25 | 26 | export interface ExpectStatic extends AssertionStatic { 27 | fail(actual?: any, expected?: any, message?: string, operator?: string): void; 28 | } 29 | 30 | export interface AssertStatic extends Assert { 31 | } 32 | 33 | export interface AssertionStatic { 34 | (target: any, message?: string): Assertion; 35 | } 36 | 37 | interface ShouldAssertion { 38 | equal(value1: any, value2: any, message?: string): void; 39 | Throw: ShouldThrow; 40 | throw: ShouldThrow; 41 | exist(value: any, message?: string): void; 42 | } 43 | 44 | interface Should extends ShouldAssertion { 45 | not: ShouldAssertion; 46 | fail(actual: any, expected: any, message?: string, operator?: string): void; 47 | } 48 | 49 | interface ShouldThrow { 50 | (actual: Function): void; 51 | (actual: Function, expected: string|RegExp, message?: string): void; 52 | (actual: Function, constructor: Error|Function, expected?: string|RegExp, message?: string): void; 53 | } 54 | 55 | interface Assertion extends LanguageChains, NumericComparison, TypeComparison { 56 | not: Assertion; 57 | deep: Deep; 58 | any: KeyFilter; 59 | all: KeyFilter; 60 | a: TypeComparison; 61 | an: TypeComparison; 62 | include: Include; 63 | includes: Include; 64 | contain: Include; 65 | contains: Include; 66 | ok: Assertion; 67 | true: Assertion; 68 | false: Assertion; 69 | null: Assertion; 70 | undefined: Assertion; 71 | NaN: Assertion; 72 | exist: Assertion; 73 | empty: Assertion; 74 | arguments: Assertion; 75 | Arguments: Assertion; 76 | equal: Equal; 77 | equals: Equal; 78 | eq: Equal; 79 | eql: Equal; 80 | eqls: Equal; 81 | property: Property; 82 | ownProperty: OwnProperty; 83 | haveOwnProperty: OwnProperty; 84 | ownPropertyDescriptor: OwnPropertyDescriptor; 85 | haveOwnPropertyDescriptor: OwnPropertyDescriptor; 86 | length: Length; 87 | lengthOf: Length; 88 | match: Match; 89 | matches: Match; 90 | string(string: string, message?: string): Assertion; 91 | keys: Keys; 92 | key(string: string): Assertion; 93 | throw: Throw; 94 | throws: Throw; 95 | Throw: Throw; 96 | respondTo: RespondTo; 97 | respondsTo: RespondTo; 98 | itself: Assertion; 99 | satisfy: Satisfy; 100 | satisfies: Satisfy; 101 | closeTo: CloseTo; 102 | approximately: CloseTo; 103 | members: Members; 104 | increase: PropertyChange; 105 | increases: PropertyChange; 106 | decrease: PropertyChange; 107 | decreases: PropertyChange; 108 | change: PropertyChange; 109 | changes: PropertyChange; 110 | extensible: Assertion; 111 | sealed: Assertion; 112 | frozen: Assertion; 113 | oneOf(list: any[], message?: string): Assertion; 114 | } 115 | 116 | interface LanguageChains { 117 | to: Assertion; 118 | be: Assertion; 119 | been: Assertion; 120 | is: Assertion; 121 | that: Assertion; 122 | which: Assertion; 123 | and: Assertion; 124 | has: Assertion; 125 | have: Assertion; 126 | with: Assertion; 127 | at: Assertion; 128 | of: Assertion; 129 | same: Assertion; 130 | } 131 | 132 | interface NumericComparison { 133 | above: NumberComparer; 134 | gt: NumberComparer; 135 | greaterThan: NumberComparer; 136 | least: NumberComparer; 137 | gte: NumberComparer; 138 | below: NumberComparer; 139 | lt: NumberComparer; 140 | lessThan: NumberComparer; 141 | most: NumberComparer; 142 | lte: NumberComparer; 143 | within(start: number, finish: number, message?: string): Assertion; 144 | } 145 | 146 | interface NumberComparer { 147 | (value: number, message?: string): Assertion; 148 | } 149 | 150 | interface TypeComparison { 151 | (type: string, message?: string): Assertion; 152 | instanceof: InstanceOf; 153 | instanceOf: InstanceOf; 154 | } 155 | 156 | interface InstanceOf { 157 | (constructor: Object, message?: string): Assertion; 158 | } 159 | 160 | interface CloseTo { 161 | (expected: number, delta: number, message?: string): Assertion; 162 | } 163 | 164 | interface Deep { 165 | equal: Equal; 166 | include: Include; 167 | property: Property; 168 | members: Members; 169 | } 170 | 171 | interface KeyFilter { 172 | keys: Keys; 173 | } 174 | 175 | interface Equal { 176 | (value: any, message?: string): Assertion; 177 | } 178 | 179 | interface Property { 180 | (name: string, value?: any, message?: string): Assertion; 181 | } 182 | 183 | interface OwnProperty { 184 | (name: string, message?: string): Assertion; 185 | } 186 | 187 | interface OwnPropertyDescriptor { 188 | (name: string, descriptor: PropertyDescriptor, message?: string): Assertion; 189 | (name: string, message?: string): Assertion; 190 | } 191 | 192 | interface Length extends LanguageChains, NumericComparison { 193 | (length: number, message?: string): Assertion; 194 | } 195 | 196 | interface Include { 197 | (value: Object, message?: string): Assertion; 198 | (value: string, message?: string): Assertion; 199 | (value: number, message?: string): Assertion; 200 | keys: Keys; 201 | members: Members; 202 | any: KeyFilter; 203 | all: KeyFilter; 204 | } 205 | 206 | interface Match { 207 | (regexp: RegExp|string, message?: string): Assertion; 208 | } 209 | 210 | interface Keys { 211 | (...keys: string[]): Assertion; 212 | (keys: any[]): Assertion; 213 | (keys: Object): Assertion; 214 | } 215 | 216 | interface Throw { 217 | (): Assertion; 218 | (expected: string, message?: string): Assertion; 219 | (expected: RegExp, message?: string): Assertion; 220 | (constructor: Error, expected?: string, message?: string): Assertion; 221 | (constructor: Error, expected?: RegExp, message?: string): Assertion; 222 | (constructor: Function, expected?: string, message?: string): Assertion; 223 | (constructor: Function, expected?: RegExp, message?: string): Assertion; 224 | } 225 | 226 | interface RespondTo { 227 | (method: string, message?: string): Assertion; 228 | } 229 | 230 | interface Satisfy { 231 | (matcher: Function, message?: string): Assertion; 232 | } 233 | 234 | interface Members { 235 | (set: any[], message?: string): Assertion; 236 | } 237 | 238 | interface PropertyChange { 239 | (object: Object, prop: string, msg?: string): Assertion; 240 | } 241 | 242 | export interface Assert { 243 | /** 244 | * @param expression Expression to test for truthiness. 245 | * @param message Message to display on error. 246 | */ 247 | (expression: any, message?: string): void; 248 | 249 | fail(actual?: any, expected?: any, msg?: string, operator?: string): void; 250 | 251 | ok(val: any, msg?: string): void; 252 | isOk(val: any, msg?: string): void; 253 | notOk(val: any, msg?: string): void; 254 | isNotOk(val: any, msg?: string): void; 255 | 256 | equal(act: any, exp: any, msg?: string): void; 257 | notEqual(act: any, exp: any, msg?: string): void; 258 | 259 | strictEqual(act: any, exp: any, msg?: string): void; 260 | notStrictEqual(act: any, exp: any, msg?: string): void; 261 | 262 | deepEqual(act: any, exp: any, msg?: string): void; 263 | notDeepEqual(act: any, exp: any, msg?: string): void; 264 | 265 | isTrue(val: any, msg?: string): void; 266 | isFalse(val: any, msg?: string): void; 267 | 268 | isNotTrue(val: any, msg?: string): void; 269 | isNotFalse(val: any, msg?: string): void; 270 | 271 | isNull(val: any, msg?: string): void; 272 | isNotNull(val: any, msg?: string): void; 273 | 274 | isUndefined(val: any, msg?: string): void; 275 | isDefined(val: any, msg?: string): void; 276 | 277 | isNaN(val: any, msg?: string): void; 278 | isNotNaN(val: any, msg?: string): void; 279 | 280 | isAbove(val: number, abv: number, msg?: string): void; 281 | isBelow(val: number, blw: number, msg?: string): void; 282 | 283 | isAtLeast(val: number, atlst: number, msg?: string): void; 284 | isAtMost(val: number, atmst: number, msg?: string): void; 285 | 286 | isFunction(val: any, msg?: string): void; 287 | isNotFunction(val: any, msg?: string): void; 288 | 289 | isObject(val: any, msg?: string): void; 290 | isNotObject(val: any, msg?: string): void; 291 | 292 | isArray(val: any, msg?: string): void; 293 | isNotArray(val: any, msg?: string): void; 294 | 295 | isString(val: any, msg?: string): void; 296 | isNotString(val: any, msg?: string): void; 297 | 298 | isNumber(val: any, msg?: string): void; 299 | isNotNumber(val: any, msg?: string): void; 300 | 301 | isBoolean(val: any, msg?: string): void; 302 | isNotBoolean(val: any, msg?: string): void; 303 | 304 | typeOf(val: any, type: string, msg?: string): void; 305 | notTypeOf(val: any, type: string, msg?: string): void; 306 | 307 | instanceOf(val: any, type: Function, msg?: string): void; 308 | notInstanceOf(val: any, type: Function, msg?: string): void; 309 | 310 | include(exp: string, inc: any, msg?: string): void; 311 | include(exp: any[], inc: any, msg?: string): void; 312 | 313 | notInclude(exp: string, inc: any, msg?: string): void; 314 | notInclude(exp: any[], inc: any, msg?: string): void; 315 | 316 | match(exp: any, re: RegExp, msg?: string): void; 317 | notMatch(exp: any, re: RegExp, msg?: string): void; 318 | 319 | property(obj: Object, prop: string, msg?: string): void; 320 | notProperty(obj: Object, prop: string, msg?: string): void; 321 | deepProperty(obj: Object, prop: string, msg?: string): void; 322 | notDeepProperty(obj: Object, prop: string, msg?: string): void; 323 | 324 | propertyVal(obj: Object, prop: string, val: any, msg?: string): void; 325 | propertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; 326 | 327 | deepPropertyVal(obj: Object, prop: string, val: any, msg?: string): void; 328 | deepPropertyNotVal(obj: Object, prop: string, val: any, msg?: string): void; 329 | 330 | lengthOf(exp: any, len: number, msg?: string): void; 331 | //alias frenzy 332 | throw(fn: Function, msg?: string): void; 333 | throw(fn: Function, regExp: RegExp): void; 334 | throw(fn: Function, errType: Function, msg?: string): void; 335 | throw(fn: Function, errType: Function, regExp: RegExp): void; 336 | 337 | throws(fn: Function, msg?: string): void; 338 | throws(fn: Function, regExp: RegExp): void; 339 | throws(fn: Function, errType: Function, msg?: string): void; 340 | throws(fn: Function, errType: Function, regExp: RegExp): void; 341 | 342 | Throw(fn: Function, msg?: string): void; 343 | Throw(fn: Function, regExp: RegExp): void; 344 | Throw(fn: Function, errType: Function, msg?: string): void; 345 | Throw(fn: Function, errType: Function, regExp: RegExp): void; 346 | 347 | doesNotThrow(fn: Function, msg?: string): void; 348 | doesNotThrow(fn: Function, regExp: RegExp): void; 349 | doesNotThrow(fn: Function, errType: Function, msg?: string): void; 350 | doesNotThrow(fn: Function, errType: Function, regExp: RegExp): void; 351 | 352 | operator(val: any, operator: string, val2: any, msg?: string): void; 353 | closeTo(act: number, exp: number, delta: number, msg?: string): void; 354 | approximately(act: number, exp: number, delta: number, msg?: string): void; 355 | 356 | sameMembers(set1: any[], set2: any[], msg?: string): void; 357 | sameDeepMembers(set1: any[], set2: any[], msg?: string): void; 358 | includeMembers(superset: any[], subset: any[], msg?: string): void; 359 | 360 | ifError(val: any, msg?: string): void; 361 | 362 | isExtensible(obj: {}, msg?: string): void; 363 | extensible(obj: {}, msg?: string): void; 364 | isNotExtensible(obj: {}, msg?: string): void; 365 | notExtensible(obj: {}, msg?: string): void; 366 | 367 | isSealed(obj: {}, msg?: string): void; 368 | sealed(obj: {}, msg?: string): void; 369 | isNotSealed(obj: {}, msg?: string): void; 370 | notSealed(obj: {}, msg?: string): void; 371 | 372 | isFrozen(obj: Object, msg?: string): void; 373 | frozen(obj: Object, msg?: string): void; 374 | isNotFrozen(obj: Object, msg?: string): void; 375 | notFrozen(obj: Object, msg?: string): void; 376 | 377 | oneOf(inList: any, list: any[], msg?: string): void; 378 | } 379 | 380 | export interface Config { 381 | includeStack: boolean; 382 | } 383 | 384 | export class AssertionError { 385 | constructor(message: string, _props?: any, ssf?: Function); 386 | name: string; 387 | message: string; 388 | showDiff: boolean; 389 | stack: string; 390 | } 391 | } 392 | 393 | declare var chai: Chai.ChaiStatic; 394 | 395 | declare module "chai" { 396 | export = chai; 397 | } 398 | 399 | interface Object { 400 | should: Chai.Assertion; 401 | } 402 | -------------------------------------------------------------------------------- /typings/fetch.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'fetch' { 2 | import * as HTTP from 'http'; 3 | export interface HashTable { 4 | [key: string]: T; 5 | } 6 | export type HttpMethod = 'GET' | 'POST'; 7 | export interface InitOptions { 8 | method?: HttpMethod; 9 | headers?: HashTable; 10 | body?: string | Buffer; 11 | referrer?: string; 12 | } 13 | export default function fetch(url: string, {method, headers, body, referrer}?: InitOptions): Promise; 14 | export class Response { 15 | private _res; 16 | private _headers; 17 | private _bufferPromise; 18 | constructor(res: HTTP.IncomingMessage); 19 | ok: boolean; 20 | status: number; 21 | statusText: string; 22 | headers: HashTable; 23 | bodyUsed: boolean; 24 | buffer(): Promise; 25 | text(): Promise; 26 | json(): Promise; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /typings/node/node.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for Node.js v0.12.0 2 | // Project: http://nodejs.org/ 3 | // Definitions by: Microsoft TypeScript , DefinitelyTyped 4 | // Definitions: https://github.com/borisyankov/DefinitelyTyped 5 | 6 | /************************************************ 7 | * * 8 | * Node.js v0.12.0 API * 9 | * * 10 | ************************************************/ 11 | 12 | // compat for TypeScript 1.5.3 13 | // if you use with --target es3 or --target es5 and use below definitions, 14 | // use the lib.es6.d.ts that is bundled with TypeScript 1.5.3. 15 | interface MapConstructor {} 16 | interface WeakMapConstructor {} 17 | interface SetConstructor {} 18 | interface WeakSetConstructor {} 19 | 20 | /************************************************ 21 | * * 22 | * GLOBAL * 23 | * * 24 | ************************************************/ 25 | declare var process: NodeJS.Process; 26 | declare var global: NodeJS.Global; 27 | 28 | declare var __filename: string; 29 | declare var __dirname: string; 30 | 31 | declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; 32 | declare function clearTimeout(timeoutId: NodeJS.Timer): void; 33 | declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; 34 | declare function clearInterval(intervalId: NodeJS.Timer): void; 35 | declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; 36 | declare function clearImmediate(immediateId: any): void; 37 | 38 | interface NodeRequireFunction { 39 | (id: string): any; 40 | } 41 | 42 | interface NodeRequire extends NodeRequireFunction { 43 | resolve(id:string): string; 44 | cache: any; 45 | extensions: any; 46 | main: any; 47 | } 48 | 49 | declare var require: NodeRequire; 50 | 51 | interface NodeModule { 52 | exports: any; 53 | require: NodeRequireFunction; 54 | id: string; 55 | filename: string; 56 | loaded: boolean; 57 | parent: any; 58 | children: any[]; 59 | } 60 | 61 | declare var module: NodeModule; 62 | 63 | // Same as module.exports 64 | declare var exports: any; 65 | declare var SlowBuffer: { 66 | new (str: string, encoding?: string): Buffer; 67 | new (size: number): Buffer; 68 | new (size: Uint8Array): Buffer; 69 | new (array: any[]): Buffer; 70 | prototype: Buffer; 71 | isBuffer(obj: any): boolean; 72 | byteLength(string: string, encoding?: string): number; 73 | concat(list: Buffer[], totalLength?: number): Buffer; 74 | }; 75 | 76 | 77 | // Buffer class 78 | interface Buffer extends NodeBuffer {} 79 | 80 | /** 81 | * Raw data is stored in instances of the Buffer class. 82 | * 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. 83 | * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' 84 | */ 85 | declare var Buffer: { 86 | /** 87 | * Allocates a new buffer containing the given {str}. 88 | * 89 | * @param str String to store in buffer. 90 | * @param encoding encoding to use, optional. Default is 'utf8' 91 | */ 92 | new (str: string, encoding?: string): Buffer; 93 | /** 94 | * Allocates a new buffer of {size} octets. 95 | * 96 | * @param size count of octets to allocate. 97 | */ 98 | new (size: number): Buffer; 99 | /** 100 | * Allocates a new buffer containing the given {array} of octets. 101 | * 102 | * @param array The octets to store. 103 | */ 104 | new (array: Uint8Array): Buffer; 105 | /** 106 | * Allocates a new buffer containing the given {array} of octets. 107 | * 108 | * @param array The octets to store. 109 | */ 110 | new (array: any[]): Buffer; 111 | prototype: Buffer; 112 | /** 113 | * Returns true if {obj} is a Buffer 114 | * 115 | * @param obj object to test. 116 | */ 117 | isBuffer(obj: any): boolean; 118 | /** 119 | * Returns true if {encoding} is a valid encoding argument. 120 | * Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex' 121 | * 122 | * @param encoding string to test. 123 | */ 124 | isEncoding(encoding: string): boolean; 125 | /** 126 | * Gives the actual byte length of a string. encoding defaults to 'utf8'. 127 | * This is not the same as String.prototype.length since that returns the number of characters in a string. 128 | * 129 | * @param string string to test. 130 | * @param encoding encoding used to evaluate (defaults to 'utf8') 131 | */ 132 | byteLength(string: string, encoding?: string): number; 133 | /** 134 | * Returns a buffer which is the result of concatenating all the buffers in the list together. 135 | * 136 | * If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer. 137 | * If the list has exactly one item, then the first item of the list is returned. 138 | * If the list has more than one item, then a new Buffer is created. 139 | * 140 | * @param list An array of Buffer objects to concatenate 141 | * @param totalLength Total length of the buffers when concatenated. 142 | * 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. 143 | */ 144 | concat(list: Buffer[], totalLength?: number): Buffer; 145 | /** 146 | * The same as buf1.compare(buf2). 147 | */ 148 | compare(buf1: Buffer, buf2: Buffer): number; 149 | }; 150 | 151 | /************************************************ 152 | * * 153 | * GLOBAL INTERFACES * 154 | * * 155 | ************************************************/ 156 | declare module NodeJS { 157 | export interface ErrnoException extends Error { 158 | errno?: number; 159 | code?: string; 160 | path?: string; 161 | syscall?: string; 162 | stack?: string; 163 | } 164 | 165 | export interface EventEmitter { 166 | addListener(event: string, listener: Function): EventEmitter; 167 | on(event: string, listener: Function): EventEmitter; 168 | once(event: string, listener: Function): EventEmitter; 169 | removeListener(event: string, listener: Function): EventEmitter; 170 | removeAllListeners(event?: string): EventEmitter; 171 | setMaxListeners(n: number): void; 172 | listeners(event: string): Function[]; 173 | emit(event: string, ...args: any[]): boolean; 174 | } 175 | 176 | export interface ReadableStream extends EventEmitter { 177 | readable: boolean; 178 | read(size?: number): string|Buffer; 179 | setEncoding(encoding: string): void; 180 | pause(): void; 181 | resume(): void; 182 | pipe(destination: T, options?: { end?: boolean; }): T; 183 | unpipe(destination?: T): void; 184 | unshift(chunk: string): void; 185 | unshift(chunk: Buffer): void; 186 | wrap(oldStream: ReadableStream): ReadableStream; 187 | } 188 | 189 | export interface WritableStream extends EventEmitter { 190 | writable: boolean; 191 | write(buffer: Buffer, cb?: Function): boolean; 192 | write(str: string, cb?: Function): boolean; 193 | write(str: string, encoding?: string, cb?: Function): boolean; 194 | end(): void; 195 | end(buffer: Buffer, cb?: Function): void; 196 | end(str: string, cb?: Function): void; 197 | end(str: string, encoding?: string, cb?: Function): void; 198 | } 199 | 200 | export interface ReadWriteStream extends ReadableStream, WritableStream {} 201 | 202 | export interface Process extends EventEmitter { 203 | stdout: WritableStream; 204 | stderr: WritableStream; 205 | stdin: ReadableStream; 206 | argv: string[]; 207 | execPath: string; 208 | abort(): void; 209 | chdir(directory: string): void; 210 | cwd(): string; 211 | env: any; 212 | exit(code?: number): void; 213 | getgid(): number; 214 | setgid(id: number): void; 215 | setgid(id: string): void; 216 | getuid(): number; 217 | setuid(id: number): void; 218 | setuid(id: string): void; 219 | version: string; 220 | versions: { 221 | http_parser: string; 222 | node: string; 223 | v8: string; 224 | ares: string; 225 | uv: string; 226 | zlib: string; 227 | openssl: string; 228 | }; 229 | config: { 230 | target_defaults: { 231 | cflags: any[]; 232 | default_configuration: string; 233 | defines: string[]; 234 | include_dirs: string[]; 235 | libraries: string[]; 236 | }; 237 | variables: { 238 | clang: number; 239 | host_arch: string; 240 | node_install_npm: boolean; 241 | node_install_waf: boolean; 242 | node_prefix: string; 243 | node_shared_openssl: boolean; 244 | node_shared_v8: boolean; 245 | node_shared_zlib: boolean; 246 | node_use_dtrace: boolean; 247 | node_use_etw: boolean; 248 | node_use_openssl: boolean; 249 | target_arch: string; 250 | v8_no_strict_aliasing: number; 251 | v8_use_snapshot: boolean; 252 | visibility: string; 253 | }; 254 | }; 255 | kill(pid: number, signal?: string): void; 256 | pid: number; 257 | title: string; 258 | arch: string; 259 | platform: string; 260 | memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; 261 | nextTick(callback: Function): void; 262 | umask(mask?: number): number; 263 | uptime(): number; 264 | hrtime(time?:number[]): number[]; 265 | 266 | // Worker 267 | send?(message: any, sendHandle?: any): void; 268 | } 269 | 270 | export interface Global { 271 | Array: typeof Array; 272 | ArrayBuffer: typeof ArrayBuffer; 273 | Boolean: typeof Boolean; 274 | Buffer: typeof Buffer; 275 | DataView: typeof DataView; 276 | Date: typeof Date; 277 | Error: typeof Error; 278 | EvalError: typeof EvalError; 279 | Float32Array: typeof Float32Array; 280 | Float64Array: typeof Float64Array; 281 | Function: typeof Function; 282 | GLOBAL: Global; 283 | Infinity: typeof Infinity; 284 | Int16Array: typeof Int16Array; 285 | Int32Array: typeof Int32Array; 286 | Int8Array: typeof Int8Array; 287 | Intl: typeof Intl; 288 | JSON: typeof JSON; 289 | Map: MapConstructor; 290 | Math: typeof Math; 291 | NaN: typeof NaN; 292 | Number: typeof Number; 293 | Object: typeof Object; 294 | Promise: Function; 295 | RangeError: typeof RangeError; 296 | ReferenceError: typeof ReferenceError; 297 | RegExp: typeof RegExp; 298 | Set: SetConstructor; 299 | String: typeof String; 300 | Symbol: Function; 301 | SyntaxError: typeof SyntaxError; 302 | TypeError: typeof TypeError; 303 | URIError: typeof URIError; 304 | Uint16Array: typeof Uint16Array; 305 | Uint32Array: typeof Uint32Array; 306 | Uint8Array: typeof Uint8Array; 307 | Uint8ClampedArray: Function; 308 | WeakMap: WeakMapConstructor; 309 | WeakSet: WeakSetConstructor; 310 | clearImmediate: (immediateId: any) => void; 311 | clearInterval: (intervalId: NodeJS.Timer) => void; 312 | clearTimeout: (timeoutId: NodeJS.Timer) => void; 313 | console: typeof console; 314 | decodeURI: typeof decodeURI; 315 | decodeURIComponent: typeof decodeURIComponent; 316 | encodeURI: typeof encodeURI; 317 | encodeURIComponent: typeof encodeURIComponent; 318 | escape: (str: string) => string; 319 | eval: typeof eval; 320 | global: Global; 321 | isFinite: typeof isFinite; 322 | isNaN: typeof isNaN; 323 | parseFloat: typeof parseFloat; 324 | parseInt: typeof parseInt; 325 | process: Process; 326 | root: Global; 327 | setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => any; 328 | setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; 329 | setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => NodeJS.Timer; 330 | undefined: typeof undefined; 331 | unescape: (str: string) => string; 332 | gc: () => void; 333 | } 334 | 335 | export interface Timer { 336 | ref() : void; 337 | unref() : void; 338 | } 339 | } 340 | 341 | /** 342 | * @deprecated 343 | */ 344 | interface NodeBuffer { 345 | [index: number]: number; 346 | write(string: string, offset?: number, length?: number, encoding?: string): number; 347 | toString(encoding?: string, start?: number, end?: number): string; 348 | toJSON(): any; 349 | length: number; 350 | equals(otherBuffer: Buffer): boolean; 351 | compare(otherBuffer: Buffer): number; 352 | copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; 353 | slice(start?: number, end?: number): Buffer; 354 | writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; 355 | writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; 356 | writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; 357 | writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number; 358 | readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number; 359 | readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number; 360 | readIntLE(offset: number, byteLength: number, noAssert?: boolean): number; 361 | readIntBE(offset: number, byteLength: number, noAssert?: boolean): number; 362 | readUInt8(offset: number, noAsset?: boolean): number; 363 | readUInt16LE(offset: number, noAssert?: boolean): number; 364 | readUInt16BE(offset: number, noAssert?: boolean): number; 365 | readUInt32LE(offset: number, noAssert?: boolean): number; 366 | readUInt32BE(offset: number, noAssert?: boolean): number; 367 | readInt8(offset: number, noAssert?: boolean): number; 368 | readInt16LE(offset: number, noAssert?: boolean): number; 369 | readInt16BE(offset: number, noAssert?: boolean): number; 370 | readInt32LE(offset: number, noAssert?: boolean): number; 371 | readInt32BE(offset: number, noAssert?: boolean): number; 372 | readFloatLE(offset: number, noAssert?: boolean): number; 373 | readFloatBE(offset: number, noAssert?: boolean): number; 374 | readDoubleLE(offset: number, noAssert?: boolean): number; 375 | readDoubleBE(offset: number, noAssert?: boolean): number; 376 | writeUInt8(value: number, offset: number, noAssert?: boolean): void; 377 | writeUInt16LE(value: number, offset: number, noAssert?: boolean): void; 378 | writeUInt16BE(value: number, offset: number, noAssert?: boolean): void; 379 | writeUInt32LE(value: number, offset: number, noAssert?: boolean): void; 380 | writeUInt32BE(value: number, offset: number, noAssert?: boolean): void; 381 | writeInt8(value: number, offset: number, noAssert?: boolean): void; 382 | writeInt16LE(value: number, offset: number, noAssert?: boolean): void; 383 | writeInt16BE(value: number, offset: number, noAssert?: boolean): void; 384 | writeInt32LE(value: number, offset: number, noAssert?: boolean): void; 385 | writeInt32BE(value: number, offset: number, noAssert?: boolean): void; 386 | writeFloatLE(value: number, offset: number, noAssert?: boolean): void; 387 | writeFloatBE(value: number, offset: number, noAssert?: boolean): void; 388 | writeDoubleLE(value: number, offset: number, noAssert?: boolean): void; 389 | writeDoubleBE(value: number, offset: number, noAssert?: boolean): void; 390 | fill(value: any, offset?: number, end?: number): void; 391 | } 392 | 393 | /************************************************ 394 | * * 395 | * MODULES * 396 | * * 397 | ************************************************/ 398 | declare module "buffer" { 399 | export var INSPECT_MAX_BYTES: number; 400 | } 401 | 402 | declare module "querystring" { 403 | export function stringify(obj: any, sep?: string, eq?: string): string; 404 | export function parse(str: string, sep?: string, eq?: string, options?: { maxKeys?: number; }): any; 405 | export function escape(str: string): string; 406 | export function unescape(str: string): string; 407 | } 408 | 409 | declare module "events" { 410 | export class EventEmitter implements NodeJS.EventEmitter { 411 | static listenerCount(emitter: EventEmitter, event: string): number; 412 | 413 | addListener(event: string, listener: Function): EventEmitter; 414 | on(event: string, listener: Function): EventEmitter; 415 | once(event: string, listener: Function): EventEmitter; 416 | removeListener(event: string, listener: Function): EventEmitter; 417 | removeAllListeners(event?: string): EventEmitter; 418 | setMaxListeners(n: number): void; 419 | listeners(event: string): Function[]; 420 | emit(event: string, ...args: any[]): boolean; 421 | } 422 | } 423 | 424 | declare module "http" { 425 | import events = require("events"); 426 | import net = require("net"); 427 | import stream = require("stream"); 428 | 429 | export interface Server extends events.EventEmitter { 430 | listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; 431 | listen(port: number, hostname?: string, callback?: Function): Server; 432 | listen(path: string, callback?: Function): Server; 433 | listen(handle: any, listeningListener?: Function): Server; 434 | close(cb?: any): Server; 435 | address(): { port: number; family: string; address: string; }; 436 | maxHeadersCount: number; 437 | } 438 | /** 439 | * @deprecated Use IncomingMessage 440 | */ 441 | export interface ServerRequest extends IncomingMessage { 442 | connection: net.Socket; 443 | } 444 | export interface ServerResponse extends events.EventEmitter, stream.Writable { 445 | // Extended base methods 446 | write(buffer: Buffer): boolean; 447 | write(buffer: Buffer, cb?: Function): boolean; 448 | write(str: string, cb?: Function): boolean; 449 | write(str: string, encoding?: string, cb?: Function): boolean; 450 | write(str: string, encoding?: string, fd?: string): boolean; 451 | 452 | writeContinue(): void; 453 | writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; 454 | writeHead(statusCode: number, headers?: any): void; 455 | statusCode: number; 456 | setHeader(name: string, value: string): void; 457 | sendDate: boolean; 458 | getHeader(name: string): string; 459 | removeHeader(name: string): void; 460 | write(chunk: any, encoding?: string): any; 461 | addTrailers(headers: any): void; 462 | 463 | // Extended base methods 464 | end(): void; 465 | end(buffer: Buffer, cb?: Function): void; 466 | end(str: string, cb?: Function): void; 467 | end(str: string, encoding?: string, cb?: Function): void; 468 | end(data?: any, encoding?: string): void; 469 | } 470 | export interface ClientRequest extends events.EventEmitter, stream.Writable { 471 | // Extended base methods 472 | write(buffer: Buffer): boolean; 473 | write(buffer: Buffer, cb?: Function): boolean; 474 | write(str: string, cb?: Function): boolean; 475 | write(str: string, encoding?: string, cb?: Function): boolean; 476 | write(str: string, encoding?: string, fd?: string): boolean; 477 | 478 | write(chunk: any, encoding?: string): void; 479 | abort(): void; 480 | setTimeout(timeout: number, callback?: Function): void; 481 | setNoDelay(noDelay?: boolean): void; 482 | setSocketKeepAlive(enable?: boolean, initialDelay?: number): void; 483 | 484 | // Extended base methods 485 | end(): void; 486 | end(buffer: Buffer, cb?: Function): void; 487 | end(str: string, cb?: Function): void; 488 | end(str: string, encoding?: string, cb?: Function): void; 489 | end(data?: any, encoding?: string): void; 490 | } 491 | export interface IncomingMessage extends events.EventEmitter, stream.Readable { 492 | httpVersion: string; 493 | headers: any; 494 | rawHeaders: string[]; 495 | trailers: any; 496 | rawTrailers: any; 497 | setTimeout(msecs: number, callback: Function): NodeJS.Timer; 498 | /** 499 | * Only valid for request obtained from http.Server. 500 | */ 501 | method?: string; 502 | /** 503 | * Only valid for request obtained from http.Server. 504 | */ 505 | url?: string; 506 | /** 507 | * Only valid for response obtained from http.ClientRequest. 508 | */ 509 | statusCode?: number; 510 | /** 511 | * Only valid for response obtained from http.ClientRequest. 512 | */ 513 | statusMessage?: string; 514 | socket: net.Socket; 515 | } 516 | /** 517 | * @deprecated Use IncomingMessage 518 | */ 519 | export interface ClientResponse extends IncomingMessage { } 520 | 521 | export interface AgentOptions { 522 | /** 523 | * Keep sockets around in a pool to be used by other requests in the future. Default = false 524 | */ 525 | keepAlive?: boolean; 526 | /** 527 | * When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000. 528 | * Only relevant if keepAlive is set to true. 529 | */ 530 | keepAliveMsecs?: number; 531 | /** 532 | * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity 533 | */ 534 | maxSockets?: number; 535 | /** 536 | * Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256. 537 | */ 538 | maxFreeSockets?: number; 539 | } 540 | 541 | export class Agent { 542 | maxSockets: number; 543 | sockets: any; 544 | requests: any; 545 | 546 | constructor(opts?: AgentOptions); 547 | 548 | /** 549 | * Destroy any sockets that are currently in use by the agent. 550 | * It is usually not necessary to do this. However, if you are using an agent with KeepAlive enabled, 551 | * then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, 552 | * sockets may hang open for quite a long time before the server terminates them. 553 | */ 554 | destroy(): void; 555 | } 556 | 557 | export var METHODS: string[]; 558 | 559 | export var STATUS_CODES: { 560 | [errorCode: number]: string; 561 | [errorCode: string]: string; 562 | }; 563 | export function createServer(requestListener?: (request: IncomingMessage, response: ServerResponse) =>void ): Server; 564 | export function createClient(port?: number, host?: string): any; 565 | export function request(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; 566 | export function get(options: any, callback?: (res: IncomingMessage) => void): ClientRequest; 567 | export var globalAgent: Agent; 568 | } 569 | 570 | declare module "cluster" { 571 | import child = require("child_process"); 572 | import events = require("events"); 573 | 574 | export interface ClusterSettings { 575 | exec?: string; 576 | args?: string[]; 577 | silent?: boolean; 578 | } 579 | 580 | export class Worker extends events.EventEmitter { 581 | id: string; 582 | process: child.ChildProcess; 583 | suicide: boolean; 584 | send(message: any, sendHandle?: any): void; 585 | kill(signal?: string): void; 586 | destroy(signal?: string): void; 587 | disconnect(): void; 588 | } 589 | 590 | export var settings: ClusterSettings; 591 | export var isMaster: boolean; 592 | export var isWorker: boolean; 593 | export function setupMaster(settings?: ClusterSettings): void; 594 | export function fork(env?: any): Worker; 595 | export function disconnect(callback?: Function): void; 596 | export var worker: Worker; 597 | export var workers: Worker[]; 598 | 599 | // Event emitter 600 | export function addListener(event: string, listener: Function): void; 601 | export function on(event: string, listener: Function): any; 602 | export function once(event: string, listener: Function): void; 603 | export function removeListener(event: string, listener: Function): void; 604 | export function removeAllListeners(event?: string): void; 605 | export function setMaxListeners(n: number): void; 606 | export function listeners(event: string): Function[]; 607 | export function emit(event: string, ...args: any[]): boolean; 608 | } 609 | 610 | declare module "zlib" { 611 | import stream = require("stream"); 612 | export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } 613 | 614 | export interface Gzip extends stream.Transform { } 615 | export interface Gunzip extends stream.Transform { } 616 | export interface Deflate extends stream.Transform { } 617 | export interface Inflate extends stream.Transform { } 618 | export interface DeflateRaw extends stream.Transform { } 619 | export interface InflateRaw extends stream.Transform { } 620 | export interface Unzip extends stream.Transform { } 621 | 622 | export function createGzip(options?: ZlibOptions): Gzip; 623 | export function createGunzip(options?: ZlibOptions): Gunzip; 624 | export function createDeflate(options?: ZlibOptions): Deflate; 625 | export function createInflate(options?: ZlibOptions): Inflate; 626 | export function createDeflateRaw(options?: ZlibOptions): DeflateRaw; 627 | export function createInflateRaw(options?: ZlibOptions): InflateRaw; 628 | export function createUnzip(options?: ZlibOptions): Unzip; 629 | 630 | export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 631 | export function deflateSync(buf: Buffer, options?: ZlibOptions): any; 632 | export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 633 | export function deflateRawSync(buf: Buffer, options?: ZlibOptions): any; 634 | export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 635 | export function gzipSync(buf: Buffer, options?: ZlibOptions): any; 636 | export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 637 | export function gunzipSync(buf: Buffer, options?: ZlibOptions): any; 638 | export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 639 | export function inflateSync(buf: Buffer, options?: ZlibOptions): any; 640 | export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 641 | export function inflateRawSync(buf: Buffer, options?: ZlibOptions): any; 642 | export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; 643 | export function unzipSync(buf: Buffer, options?: ZlibOptions): any; 644 | 645 | // Constants 646 | export var Z_NO_FLUSH: number; 647 | export var Z_PARTIAL_FLUSH: number; 648 | export var Z_SYNC_FLUSH: number; 649 | export var Z_FULL_FLUSH: number; 650 | export var Z_FINISH: number; 651 | export var Z_BLOCK: number; 652 | export var Z_TREES: number; 653 | export var Z_OK: number; 654 | export var Z_STREAM_END: number; 655 | export var Z_NEED_DICT: number; 656 | export var Z_ERRNO: number; 657 | export var Z_STREAM_ERROR: number; 658 | export var Z_DATA_ERROR: number; 659 | export var Z_MEM_ERROR: number; 660 | export var Z_BUF_ERROR: number; 661 | export var Z_VERSION_ERROR: number; 662 | export var Z_NO_COMPRESSION: number; 663 | export var Z_BEST_SPEED: number; 664 | export var Z_BEST_COMPRESSION: number; 665 | export var Z_DEFAULT_COMPRESSION: number; 666 | export var Z_FILTERED: number; 667 | export var Z_HUFFMAN_ONLY: number; 668 | export var Z_RLE: number; 669 | export var Z_FIXED: number; 670 | export var Z_DEFAULT_STRATEGY: number; 671 | export var Z_BINARY: number; 672 | export var Z_TEXT: number; 673 | export var Z_ASCII: number; 674 | export var Z_UNKNOWN: number; 675 | export var Z_DEFLATED: number; 676 | export var Z_NULL: number; 677 | } 678 | 679 | declare module "os" { 680 | export function tmpdir(): string; 681 | export function hostname(): string; 682 | export function type(): string; 683 | export function platform(): string; 684 | export function arch(): string; 685 | export function release(): string; 686 | export function uptime(): number; 687 | export function loadavg(): number[]; 688 | export function totalmem(): number; 689 | export function freemem(): number; 690 | export function cpus(): { model: string; speed: number; times: { user: number; nice: number; sys: number; idle: number; irq: number; }; }[]; 691 | export function networkInterfaces(): any; 692 | export var EOL: string; 693 | } 694 | 695 | declare module "https" { 696 | import tls = require("tls"); 697 | import events = require("events"); 698 | import http = require("http"); 699 | 700 | export interface ServerOptions { 701 | pfx?: any; 702 | key?: any; 703 | passphrase?: string; 704 | cert?: any; 705 | ca?: any; 706 | crl?: any; 707 | ciphers?: string; 708 | honorCipherOrder?: boolean; 709 | requestCert?: boolean; 710 | rejectUnauthorized?: boolean; 711 | NPNProtocols?: any; 712 | SNICallback?: (servername: string) => any; 713 | } 714 | 715 | export interface RequestOptions { 716 | host?: string; 717 | hostname?: string; 718 | port?: number; 719 | path?: string; 720 | method?: string; 721 | headers?: any; 722 | auth?: string; 723 | agent?: any; 724 | pfx?: any; 725 | key?: any; 726 | passphrase?: string; 727 | cert?: any; 728 | ca?: any; 729 | ciphers?: string; 730 | rejectUnauthorized?: boolean; 731 | } 732 | 733 | export interface Agent { 734 | maxSockets: number; 735 | sockets: any; 736 | requests: any; 737 | } 738 | export var Agent: { 739 | new (options?: RequestOptions): Agent; 740 | }; 741 | export interface Server extends tls.Server { } 742 | export function createServer(options: ServerOptions, requestListener?: Function): Server; 743 | export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; 744 | export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) =>void ): http.ClientRequest; 745 | export var globalAgent: Agent; 746 | } 747 | 748 | declare module "punycode" { 749 | export function decode(string: string): string; 750 | export function encode(string: string): string; 751 | export function toUnicode(domain: string): string; 752 | export function toASCII(domain: string): string; 753 | export var ucs2: ucs2; 754 | interface ucs2 { 755 | decode(string: string): string; 756 | encode(codePoints: number[]): string; 757 | } 758 | export var version: any; 759 | } 760 | 761 | declare module "repl" { 762 | import stream = require("stream"); 763 | import events = require("events"); 764 | 765 | export interface ReplOptions { 766 | prompt?: string; 767 | input?: NodeJS.ReadableStream; 768 | output?: NodeJS.WritableStream; 769 | terminal?: boolean; 770 | eval?: Function; 771 | useColors?: boolean; 772 | useGlobal?: boolean; 773 | ignoreUndefined?: boolean; 774 | writer?: Function; 775 | } 776 | export function start(options: ReplOptions): events.EventEmitter; 777 | } 778 | 779 | declare module "readline" { 780 | import events = require("events"); 781 | import stream = require("stream"); 782 | 783 | export interface ReadLine extends events.EventEmitter { 784 | setPrompt(prompt: string, length: number): void; 785 | prompt(preserveCursor?: boolean): void; 786 | question(query: string, callback: Function): void; 787 | pause(): void; 788 | resume(): void; 789 | close(): void; 790 | write(data: any, key?: any): void; 791 | } 792 | export interface ReadLineOptions { 793 | input: NodeJS.ReadableStream; 794 | output: NodeJS.WritableStream; 795 | completer?: Function; 796 | terminal?: boolean; 797 | } 798 | export function createInterface(options: ReadLineOptions): ReadLine; 799 | } 800 | 801 | declare module "vm" { 802 | export interface Context { } 803 | export interface Script { 804 | runInThisContext(): void; 805 | runInNewContext(sandbox?: Context): void; 806 | } 807 | export function runInThisContext(code: string, filename?: string): void; 808 | export function runInNewContext(code: string, sandbox?: Context, filename?: string): void; 809 | export function runInContext(code: string, context: Context, filename?: string): void; 810 | export function createContext(initSandbox?: Context): Context; 811 | export function createScript(code: string, filename?: string): Script; 812 | } 813 | 814 | declare module "child_process" { 815 | import events = require("events"); 816 | import stream = require("stream"); 817 | 818 | export interface ChildProcess extends events.EventEmitter { 819 | stdin: stream.Writable; 820 | stdout: stream.Readable; 821 | stderr: stream.Readable; 822 | pid: number; 823 | kill(signal?: string): void; 824 | send(message: any, sendHandle?: any): void; 825 | disconnect(): void; 826 | } 827 | 828 | export function spawn(command: string, args?: string[], options?: { 829 | cwd?: string; 830 | stdio?: any; 831 | custom?: any; 832 | env?: any; 833 | detached?: boolean; 834 | }): ChildProcess; 835 | export function exec(command: string, options: { 836 | cwd?: string; 837 | stdio?: any; 838 | customFds?: any; 839 | env?: any; 840 | encoding?: string; 841 | timeout?: number; 842 | maxBuffer?: number; 843 | killSignal?: string; 844 | }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 845 | export function exec(command: string, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 846 | export function execFile(file: string, 847 | callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 848 | export function execFile(file: string, args?: string[], 849 | callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 850 | export function execFile(file: string, args?: string[], options?: { 851 | cwd?: string; 852 | stdio?: any; 853 | customFds?: any; 854 | env?: any; 855 | encoding?: string; 856 | timeout?: number; 857 | maxBuffer?: string; 858 | killSignal?: string; 859 | }, callback?: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; 860 | export function fork(modulePath: string, args?: string[], options?: { 861 | cwd?: string; 862 | env?: any; 863 | encoding?: string; 864 | }): ChildProcess; 865 | export function execSync(command: string, options?: { 866 | cwd?: string; 867 | input?: string|Buffer; 868 | stdio?: any; 869 | env?: any; 870 | uid?: number; 871 | gid?: number; 872 | timeout?: number; 873 | maxBuffer?: number; 874 | killSignal?: string; 875 | encoding?: string; 876 | }): ChildProcess; 877 | export function execFileSync(command: string, args?: string[], options?: { 878 | cwd?: string; 879 | input?: string|Buffer; 880 | stdio?: any; 881 | env?: any; 882 | uid?: number; 883 | gid?: number; 884 | timeout?: number; 885 | maxBuffer?: number; 886 | killSignal?: string; 887 | encoding?: string; 888 | }): ChildProcess; 889 | } 890 | 891 | declare module "url" { 892 | export interface Url { 893 | href: string; 894 | protocol: string; 895 | auth: string; 896 | hostname: string; 897 | port: string; 898 | host: string; 899 | pathname: string; 900 | search: string; 901 | query: any; // string | Object 902 | slashes: boolean; 903 | hash?: string; 904 | path?: string; 905 | } 906 | 907 | export interface UrlOptions { 908 | protocol?: string; 909 | auth?: string; 910 | hostname?: string; 911 | port?: string; 912 | host?: string; 913 | pathname?: string; 914 | search?: string; 915 | query?: any; 916 | hash?: string; 917 | path?: string; 918 | } 919 | 920 | export function parse(urlStr: string, parseQueryString?: boolean , slashesDenoteHost?: boolean ): Url; 921 | export function format(url: UrlOptions): string; 922 | export function resolve(from: string, to: string): string; 923 | } 924 | 925 | declare module "dns" { 926 | export function lookup(domain: string, family: number, callback: (err: Error, address: string, family: number) =>void ): string; 927 | export function lookup(domain: string, callback: (err: Error, address: string, family: number) =>void ): string; 928 | export function resolve(domain: string, rrtype: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 929 | export function resolve(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 930 | export function resolve4(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 931 | export function resolve6(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 932 | export function resolveMx(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 933 | export function resolveTxt(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 934 | export function resolveSrv(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 935 | export function resolveNs(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 936 | export function resolveCname(domain: string, callback: (err: Error, addresses: string[]) =>void ): string[]; 937 | export function reverse(ip: string, callback: (err: Error, domains: string[]) =>void ): string[]; 938 | } 939 | 940 | declare module "net" { 941 | import stream = require("stream"); 942 | 943 | export interface Socket extends stream.Duplex { 944 | // Extended base methods 945 | write(buffer: Buffer): boolean; 946 | write(buffer: Buffer, cb?: Function): boolean; 947 | write(str: string, cb?: Function): boolean; 948 | write(str: string, encoding?: string, cb?: Function): boolean; 949 | write(str: string, encoding?: string, fd?: string): boolean; 950 | 951 | connect(port: number, host?: string, connectionListener?: Function): void; 952 | connect(path: string, connectionListener?: Function): void; 953 | bufferSize: number; 954 | setEncoding(encoding?: string): void; 955 | write(data: any, encoding?: string, callback?: Function): void; 956 | destroy(): void; 957 | pause(): void; 958 | resume(): void; 959 | setTimeout(timeout: number, callback?: Function): void; 960 | setNoDelay(noDelay?: boolean): void; 961 | setKeepAlive(enable?: boolean, initialDelay?: number): void; 962 | address(): { port: number; family: string; address: string; }; 963 | unref(): void; 964 | ref(): void; 965 | 966 | remoteAddress: string; 967 | remoteFamily: string; 968 | remotePort: number; 969 | localAddress: string; 970 | localPort: number; 971 | bytesRead: number; 972 | bytesWritten: number; 973 | 974 | // Extended base methods 975 | end(): void; 976 | end(buffer: Buffer, cb?: Function): void; 977 | end(str: string, cb?: Function): void; 978 | end(str: string, encoding?: string, cb?: Function): void; 979 | end(data?: any, encoding?: string): void; 980 | } 981 | 982 | export var Socket: { 983 | new (options?: { fd?: string; type?: string; allowHalfOpen?: boolean; }): Socket; 984 | }; 985 | 986 | export interface Server extends Socket { 987 | listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; 988 | listen(path: string, listeningListener?: Function): Server; 989 | listen(handle: any, listeningListener?: Function): Server; 990 | close(callback?: Function): Server; 991 | address(): { port: number; family: string; address: string; }; 992 | maxConnections: number; 993 | connections: number; 994 | } 995 | export function createServer(connectionListener?: (socket: Socket) =>void ): Server; 996 | export function createServer(options?: { allowHalfOpen?: boolean; }, connectionListener?: (socket: Socket) =>void ): Server; 997 | export function connect(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; 998 | export function connect(port: number, host?: string, connectionListener?: Function): Socket; 999 | export function connect(path: string, connectionListener?: Function): Socket; 1000 | export function createConnection(options: { allowHalfOpen?: boolean; }, connectionListener?: Function): Socket; 1001 | export function createConnection(port: number, host?: string, connectionListener?: Function): Socket; 1002 | export function createConnection(path: string, connectionListener?: Function): Socket; 1003 | export function isIP(input: string): number; 1004 | export function isIPv4(input: string): boolean; 1005 | export function isIPv6(input: string): boolean; 1006 | } 1007 | 1008 | declare module "dgram" { 1009 | import events = require("events"); 1010 | 1011 | interface RemoteInfo { 1012 | address: string; 1013 | port: number; 1014 | size: number; 1015 | } 1016 | 1017 | interface AddressInfo { 1018 | address: string; 1019 | family: string; 1020 | port: number; 1021 | } 1022 | 1023 | export function createSocket(type: string, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket; 1024 | 1025 | interface Socket extends events.EventEmitter { 1026 | send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: (error: Error, bytes: number) => void): void; 1027 | bind(port: number, address?: string, callback?: () => void): void; 1028 | close(): void; 1029 | address(): AddressInfo; 1030 | setBroadcast(flag: boolean): void; 1031 | setMulticastTTL(ttl: number): void; 1032 | setMulticastLoopback(flag: boolean): void; 1033 | addMembership(multicastAddress: string, multicastInterface?: string): void; 1034 | dropMembership(multicastAddress: string, multicastInterface?: string): void; 1035 | } 1036 | } 1037 | 1038 | declare module "fs" { 1039 | import stream = require("stream"); 1040 | import events = require("events"); 1041 | 1042 | interface Stats { 1043 | isFile(): boolean; 1044 | isDirectory(): boolean; 1045 | isBlockDevice(): boolean; 1046 | isCharacterDevice(): boolean; 1047 | isSymbolicLink(): boolean; 1048 | isFIFO(): boolean; 1049 | isSocket(): boolean; 1050 | dev: number; 1051 | ino: number; 1052 | mode: number; 1053 | nlink: number; 1054 | uid: number; 1055 | gid: number; 1056 | rdev: number; 1057 | size: number; 1058 | blksize: number; 1059 | blocks: number; 1060 | atime: Date; 1061 | mtime: Date; 1062 | ctime: Date; 1063 | } 1064 | 1065 | interface FSWatcher extends events.EventEmitter { 1066 | close(): void; 1067 | } 1068 | 1069 | export interface ReadStream extends stream.Readable { 1070 | close(): void; 1071 | } 1072 | export interface WriteStream extends stream.Writable { 1073 | close(): void; 1074 | bytesWritten: number; 1075 | } 1076 | 1077 | /** 1078 | * Asynchronous rename. 1079 | * @param oldPath 1080 | * @param newPath 1081 | * @param callback No arguments other than a possible exception are given to the completion callback. 1082 | */ 1083 | export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1084 | /** 1085 | * Synchronous rename 1086 | * @param oldPath 1087 | * @param newPath 1088 | */ 1089 | export function renameSync(oldPath: string, newPath: string): void; 1090 | export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1091 | export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1092 | export function truncateSync(path: string, len?: number): void; 1093 | export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1094 | export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1095 | export function ftruncateSync(fd: number, len?: number): void; 1096 | export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1097 | export function chownSync(path: string, uid: number, gid: number): void; 1098 | export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1099 | export function fchownSync(fd: number, uid: number, gid: number): void; 1100 | export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1101 | export function lchownSync(path: string, uid: number, gid: number): void; 1102 | export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1103 | export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1104 | export function chmodSync(path: string, mode: number): void; 1105 | export function chmodSync(path: string, mode: string): void; 1106 | export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1107 | export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1108 | export function fchmodSync(fd: number, mode: number): void; 1109 | export function fchmodSync(fd: number, mode: string): void; 1110 | export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1111 | export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1112 | export function lchmodSync(path: string, mode: number): void; 1113 | export function lchmodSync(path: string, mode: string): void; 1114 | export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; 1115 | export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; 1116 | export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; 1117 | export function statSync(path: string): Stats; 1118 | export function lstatSync(path: string): Stats; 1119 | export function fstatSync(fd: number): Stats; 1120 | export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1121 | export function linkSync(srcpath: string, dstpath: string): void; 1122 | export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1123 | export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; 1124 | export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; 1125 | export function readlinkSync(path: string): string; 1126 | export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; 1127 | export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; 1128 | export function realpathSync(path: string, cache?: { [path: string]: string }): string; 1129 | /* 1130 | * Asynchronous unlink - deletes the file specified in {path} 1131 | * 1132 | * @param path 1133 | * @param callback No arguments other than a possible exception are given to the completion callback. 1134 | */ 1135 | export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1136 | /* 1137 | * Synchronous unlink - deletes the file specified in {path} 1138 | * 1139 | * @param path 1140 | */ 1141 | export function unlinkSync(path: string): void; 1142 | /* 1143 | * Asynchronous rmdir - removes the directory specified in {path} 1144 | * 1145 | * @param path 1146 | * @param callback No arguments other than a possible exception are given to the completion callback. 1147 | */ 1148 | export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1149 | /* 1150 | * Synchronous rmdir - removes the directory specified in {path} 1151 | * 1152 | * @param path 1153 | */ 1154 | export function rmdirSync(path: string): void; 1155 | /* 1156 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. 1157 | * 1158 | * @param path 1159 | * @param callback No arguments other than a possible exception are given to the completion callback. 1160 | */ 1161 | export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1162 | /* 1163 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. 1164 | * 1165 | * @param path 1166 | * @param mode 1167 | * @param callback No arguments other than a possible exception are given to the completion callback. 1168 | */ 1169 | export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1170 | /* 1171 | * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. 1172 | * 1173 | * @param path 1174 | * @param mode 1175 | * @param callback No arguments other than a possible exception are given to the completion callback. 1176 | */ 1177 | export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; 1178 | /* 1179 | * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. 1180 | * 1181 | * @param path 1182 | * @param mode 1183 | * @param callback No arguments other than a possible exception are given to the completion callback. 1184 | */ 1185 | export function mkdirSync(path: string, mode?: number): void; 1186 | /* 1187 | * Synchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. 1188 | * 1189 | * @param path 1190 | * @param mode 1191 | * @param callback No arguments other than a possible exception are given to the completion callback. 1192 | */ 1193 | export function mkdirSync(path: string, mode?: string): void; 1194 | export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; 1195 | export function readdirSync(path: string): string[]; 1196 | export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1197 | export function closeSync(fd: number): void; 1198 | export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; 1199 | export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; 1200 | export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; 1201 | export function openSync(path: string, flags: string, mode?: number): number; 1202 | export function openSync(path: string, flags: string, mode?: string): number; 1203 | export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1204 | export function utimes(path: string, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; 1205 | export function utimesSync(path: string, atime: number, mtime: number): void; 1206 | export function utimesSync(path: string, atime: Date, mtime: Date): void; 1207 | export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1208 | export function futimes(fd: number, atime: Date, mtime: Date, callback?: (err?: NodeJS.ErrnoException) => void): void; 1209 | export function futimesSync(fd: number, atime: number, mtime: number): void; 1210 | export function futimesSync(fd: number, atime: Date, mtime: Date): void; 1211 | export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; 1212 | export function fsyncSync(fd: number): void; 1213 | export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; 1214 | export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; 1215 | export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; 1216 | export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; 1217 | /* 1218 | * Asynchronous readFile - Asynchronously reads the entire contents of a file. 1219 | * 1220 | * @param fileName 1221 | * @param encoding 1222 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. 1223 | */ 1224 | export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; 1225 | /* 1226 | * Asynchronous readFile - Asynchronously reads the entire contents of a file. 1227 | * 1228 | * @param fileName 1229 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. 1230 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. 1231 | */ 1232 | export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; 1233 | /* 1234 | * Asynchronous readFile - Asynchronously reads the entire contents of a file. 1235 | * 1236 | * @param fileName 1237 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFile returns a string; otherwise it returns a Buffer. 1238 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. 1239 | */ 1240 | export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; 1241 | /* 1242 | * Asynchronous readFile - Asynchronously reads the entire contents of a file. 1243 | * 1244 | * @param fileName 1245 | * @param callback - The callback is passed two arguments (err, data), where data is the contents of the file. 1246 | */ 1247 | export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; 1248 | /* 1249 | * Synchronous readFile - Synchronously reads the entire contents of a file. 1250 | * 1251 | * @param fileName 1252 | * @param encoding 1253 | */ 1254 | export function readFileSync(filename: string, encoding: string): string; 1255 | /* 1256 | * Synchronous readFile - Synchronously reads the entire contents of a file. 1257 | * 1258 | * @param fileName 1259 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. 1260 | */ 1261 | export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; 1262 | /* 1263 | * Synchronous readFile - Synchronously reads the entire contents of a file. 1264 | * 1265 | * @param fileName 1266 | * @param options An object with optional {encoding} and {flag} properties. If {encoding} is specified, readFileSync returns a string; otherwise it returns a Buffer. 1267 | */ 1268 | export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; 1269 | export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; 1270 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 1271 | export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 1272 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; 1273 | export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; 1274 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 1275 | export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; 1276 | export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; 1277 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; 1278 | export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; 1279 | export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; 1280 | export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: (curr: Stats, prev: Stats) => void): void; 1281 | export function unwatchFile(filename: string, listener?: (curr: Stats, prev: Stats) => void): void; 1282 | export function watch(filename: string, listener?: (event: string, filename: string) => any): FSWatcher; 1283 | export function watch(filename: string, options: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; 1284 | export function exists(path: string, callback?: (exists: boolean) => void): void; 1285 | export function existsSync(path: string): boolean; 1286 | /** Constant for fs.access(). File is visible to the calling process. */ 1287 | export var F_OK: number; 1288 | /** Constant for fs.access(). File can be read by the calling process. */ 1289 | export var R_OK: number; 1290 | /** Constant for fs.access(). File can be written by the calling process. */ 1291 | export var W_OK: number; 1292 | /** Constant for fs.access(). File can be executed by the calling process. */ 1293 | export var X_OK: number; 1294 | /** Tests a user's permissions for the file specified by path. */ 1295 | export function access(path: string, callback: (err: NodeJS.ErrnoException) => void): void; 1296 | export function access(path: string, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; 1297 | /** Synchronous version of fs.access. This throws if any accessibility checks fail, and does nothing otherwise. */ 1298 | export function accessSync(path: string, mode ?: number): void; 1299 | export function createReadStream(path: string, options?: { 1300 | flags?: string; 1301 | encoding?: string; 1302 | fd?: string; 1303 | mode?: number; 1304 | bufferSize?: number; 1305 | }): ReadStream; 1306 | export function createReadStream(path: string, options?: { 1307 | flags?: string; 1308 | encoding?: string; 1309 | fd?: string; 1310 | mode?: string; 1311 | bufferSize?: number; 1312 | }): ReadStream; 1313 | export function createWriteStream(path: string, options?: { 1314 | flags?: string; 1315 | encoding?: string; 1316 | string?: string; 1317 | }): WriteStream; 1318 | } 1319 | 1320 | declare module "path" { 1321 | 1322 | /** 1323 | * A parsed path object generated by path.parse() or consumed by path.format(). 1324 | */ 1325 | export interface ParsedPath { 1326 | /** 1327 | * The root of the path such as '/' or 'c:\' 1328 | */ 1329 | root: string; 1330 | /** 1331 | * The full directory path such as '/home/user/dir' or 'c:\path\dir' 1332 | */ 1333 | dir: string; 1334 | /** 1335 | * The file name including extension (if any) such as 'index.html' 1336 | */ 1337 | base: string; 1338 | /** 1339 | * The file extension (if any) such as '.html' 1340 | */ 1341 | ext: string; 1342 | /** 1343 | * The file name without extension (if any) such as 'index' 1344 | */ 1345 | name: string; 1346 | } 1347 | 1348 | /** 1349 | * Normalize a string path, reducing '..' and '.' parts. 1350 | * 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. 1351 | * 1352 | * @param p string path to normalize. 1353 | */ 1354 | export function normalize(p: string): string; 1355 | /** 1356 | * Join all arguments together and normalize the resulting path. 1357 | * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. 1358 | * 1359 | * @param paths string paths to join. 1360 | */ 1361 | export function join(...paths: any[]): string; 1362 | /** 1363 | * Join all arguments together and normalize the resulting path. 1364 | * Arguments must be strings. In v0.8, non-string arguments were silently ignored. In v0.10 and up, an exception is thrown. 1365 | * 1366 | * @param paths string paths to join. 1367 | */ 1368 | export function join(...paths: string[]): string; 1369 | /** 1370 | * The right-most parameter is considered {to}. Other parameters are considered an array of {from}. 1371 | * 1372 | * Starting from leftmost {from} paramter, resolves {to} to an absolute path. 1373 | * 1374 | * 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. 1375 | * 1376 | * @param pathSegments string paths to join. Non-string arguments are ignored. 1377 | */ 1378 | export function resolve(...pathSegments: any[]): string; 1379 | /** 1380 | * Determines whether {path} is an absolute path. An absolute path will always resolve to the same location, regardless of the working directory. 1381 | * 1382 | * @param path path to test. 1383 | */ 1384 | export function isAbsolute(path: string): boolean; 1385 | /** 1386 | * Solve the relative path from {from} to {to}. 1387 | * 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. 1388 | * 1389 | * @param from 1390 | * @param to 1391 | */ 1392 | export function relative(from: string, to: string): string; 1393 | /** 1394 | * Return the directory name of a path. Similar to the Unix dirname command. 1395 | * 1396 | * @param p the path to evaluate. 1397 | */ 1398 | export function dirname(p: string): string; 1399 | /** 1400 | * Return the last portion of a path. Similar to the Unix basename command. 1401 | * Often used to extract the file name from a fully qualified path. 1402 | * 1403 | * @param p the path to evaluate. 1404 | * @param ext optionally, an extension to remove from the result. 1405 | */ 1406 | export function basename(p: string, ext?: string): string; 1407 | /** 1408 | * Return the extension of the path, from the last '.' to end of string in the last portion of the path. 1409 | * If there is no '.' in the last portion of the path or the first character of it is '.', then it returns an empty string 1410 | * 1411 | * @param p the path to evaluate. 1412 | */ 1413 | export function extname(p: string): string; 1414 | /** 1415 | * The platform-specific file separator. '\\' or '/'. 1416 | */ 1417 | export var sep: string; 1418 | /** 1419 | * The platform-specific file delimiter. ';' or ':'. 1420 | */ 1421 | export var delimiter: string; 1422 | /** 1423 | * Returns an object from a path string - the opposite of format(). 1424 | * 1425 | * @param pathString path to evaluate. 1426 | */ 1427 | export function parse(pathString: string): ParsedPath; 1428 | /** 1429 | * Returns a path string from an object - the opposite of parse(). 1430 | * 1431 | * @param pathString path to evaluate. 1432 | */ 1433 | export function format(pathObject: ParsedPath): string; 1434 | 1435 | export module posix { 1436 | export function normalize(p: string): string; 1437 | export function join(...paths: any[]): string; 1438 | export function resolve(...pathSegments: any[]): string; 1439 | export function isAbsolute(p: string): boolean; 1440 | export function relative(from: string, to: string): string; 1441 | export function dirname(p: string): string; 1442 | export function basename(p: string, ext?: string): string; 1443 | export function extname(p: string): string; 1444 | export var sep: string; 1445 | export var delimiter: string; 1446 | export function parse(p: string): ParsedPath; 1447 | export function format(pP: ParsedPath): string; 1448 | } 1449 | 1450 | export module win32 { 1451 | export function normalize(p: string): string; 1452 | export function join(...paths: any[]): string; 1453 | export function resolve(...pathSegments: any[]): string; 1454 | export function isAbsolute(p: string): boolean; 1455 | export function relative(from: string, to: string): string; 1456 | export function dirname(p: string): string; 1457 | export function basename(p: string, ext?: string): string; 1458 | export function extname(p: string): string; 1459 | export var sep: string; 1460 | export var delimiter: string; 1461 | export function parse(p: string): ParsedPath; 1462 | export function format(pP: ParsedPath): string; 1463 | } 1464 | } 1465 | 1466 | declare module "string_decoder" { 1467 | export interface NodeStringDecoder { 1468 | write(buffer: Buffer): string; 1469 | detectIncompleteChar(buffer: Buffer): number; 1470 | } 1471 | export var StringDecoder: { 1472 | new (encoding: string): NodeStringDecoder; 1473 | }; 1474 | } 1475 | 1476 | declare module "tls" { 1477 | import crypto = require("crypto"); 1478 | import net = require("net"); 1479 | import stream = require("stream"); 1480 | 1481 | var CLIENT_RENEG_LIMIT: number; 1482 | var CLIENT_RENEG_WINDOW: number; 1483 | 1484 | export interface TlsOptions { 1485 | pfx?: any; //string or buffer 1486 | key?: any; //string or buffer 1487 | passphrase?: string; 1488 | cert?: any; 1489 | ca?: any; //string or buffer 1490 | crl?: any; //string or string array 1491 | ciphers?: string; 1492 | honorCipherOrder?: any; 1493 | requestCert?: boolean; 1494 | rejectUnauthorized?: boolean; 1495 | NPNProtocols?: any; //array or Buffer; 1496 | SNICallback?: (servername: string) => any; 1497 | } 1498 | 1499 | export interface ConnectionOptions { 1500 | host?: string; 1501 | port?: number; 1502 | socket?: net.Socket; 1503 | pfx?: any; //string | Buffer 1504 | key?: any; //string | Buffer 1505 | passphrase?: string; 1506 | cert?: any; //string | Buffer 1507 | ca?: any; //Array of string | Buffer 1508 | rejectUnauthorized?: boolean; 1509 | NPNProtocols?: any; //Array of string | Buffer 1510 | servername?: string; 1511 | } 1512 | 1513 | export interface Server extends net.Server { 1514 | // Extended base methods 1515 | listen(port: number, host?: string, backlog?: number, listeningListener?: Function): Server; 1516 | listen(path: string, listeningListener?: Function): Server; 1517 | listen(handle: any, listeningListener?: Function): Server; 1518 | 1519 | listen(port: number, host?: string, callback?: Function): Server; 1520 | close(): Server; 1521 | address(): { port: number; family: string; address: string; }; 1522 | addContext(hostName: string, credentials: { 1523 | key: string; 1524 | cert: string; 1525 | ca: string; 1526 | }): void; 1527 | maxConnections: number; 1528 | connections: number; 1529 | } 1530 | 1531 | export interface ClearTextStream extends stream.Duplex { 1532 | authorized: boolean; 1533 | authorizationError: Error; 1534 | getPeerCertificate(): any; 1535 | getCipher: { 1536 | name: string; 1537 | version: string; 1538 | }; 1539 | address: { 1540 | port: number; 1541 | family: string; 1542 | address: string; 1543 | }; 1544 | remoteAddress: string; 1545 | remotePort: number; 1546 | } 1547 | 1548 | export interface SecurePair { 1549 | encrypted: any; 1550 | cleartext: any; 1551 | } 1552 | 1553 | export interface SecureContextOptions { 1554 | pfx?: any; //string | buffer 1555 | key?: any; //string | buffer 1556 | passphrase?: string; 1557 | cert?: any; // string | buffer 1558 | ca?: any; // string | buffer 1559 | crl?: any; // string | string[] 1560 | ciphers?: string; 1561 | honorCipherOrder?: boolean; 1562 | } 1563 | 1564 | export interface SecureContext { 1565 | context: any; 1566 | } 1567 | 1568 | export function createServer(options: TlsOptions, secureConnectionListener?: (cleartextStream: ClearTextStream) =>void ): Server; 1569 | export function connect(options: TlsOptions, secureConnectionListener?: () =>void ): ClearTextStream; 1570 | export function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; 1571 | export function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () =>void ): ClearTextStream; 1572 | export function createSecurePair(credentials?: crypto.Credentials, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair; 1573 | export function createSecureContext(details: SecureContextOptions): SecureContext; 1574 | } 1575 | 1576 | declare module "crypto" { 1577 | export interface CredentialDetails { 1578 | pfx: string; 1579 | key: string; 1580 | passphrase: string; 1581 | cert: string; 1582 | ca: any; //string | string array 1583 | crl: any; //string | string array 1584 | ciphers: string; 1585 | } 1586 | export interface Credentials { context?: any; } 1587 | export function createCredentials(details: CredentialDetails): Credentials; 1588 | export function createHash(algorithm: string): Hash; 1589 | export function createHmac(algorithm: string, key: string): Hmac; 1590 | export function createHmac(algorithm: string, key: Buffer): Hmac; 1591 | interface Hash { 1592 | update(data: any, input_encoding?: string): Hash; 1593 | digest(encoding: 'buffer'): Buffer; 1594 | digest(encoding: string): any; 1595 | digest(): Buffer; 1596 | } 1597 | interface Hmac { 1598 | update(data: any, input_encoding?: string): Hmac; 1599 | digest(encoding: 'buffer'): Buffer; 1600 | digest(encoding: string): any; 1601 | digest(): Buffer; 1602 | } 1603 | export function createCipher(algorithm: string, password: any): Cipher; 1604 | export function createCipheriv(algorithm: string, key: any, iv: any): Cipher; 1605 | interface Cipher { 1606 | update(data: Buffer): Buffer; 1607 | update(data: string, input_encoding?: string, output_encoding?: string): string; 1608 | final(): Buffer; 1609 | final(output_encoding: string): string; 1610 | setAutoPadding(auto_padding: boolean): void; 1611 | } 1612 | export function createDecipher(algorithm: string, password: any): Decipher; 1613 | export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; 1614 | interface Decipher { 1615 | update(data: Buffer): Buffer; 1616 | update(data: string, input_encoding?: string, output_encoding?: string): string; 1617 | final(): Buffer; 1618 | final(output_encoding: string): string; 1619 | setAutoPadding(auto_padding: boolean): void; 1620 | } 1621 | export function createSign(algorithm: string): Signer; 1622 | interface Signer { 1623 | update(data: any): void; 1624 | sign(private_key: string, output_format: string): string; 1625 | } 1626 | export function createVerify(algorith: string): Verify; 1627 | interface Verify { 1628 | update(data: any): void; 1629 | verify(object: string, signature: string, signature_format?: string): boolean; 1630 | } 1631 | export function createDiffieHellman(prime_length: number): DiffieHellman; 1632 | export function createDiffieHellman(prime: number, encoding?: string): DiffieHellman; 1633 | interface DiffieHellman { 1634 | generateKeys(encoding?: string): string; 1635 | computeSecret(other_public_key: string, input_encoding?: string, output_encoding?: string): string; 1636 | getPrime(encoding?: string): string; 1637 | getGenerator(encoding: string): string; 1638 | getPublicKey(encoding?: string): string; 1639 | getPrivateKey(encoding?: string): string; 1640 | setPublicKey(public_key: string, encoding?: string): void; 1641 | setPrivateKey(public_key: string, encoding?: string): void; 1642 | } 1643 | export function getDiffieHellman(group_name: string): DiffieHellman; 1644 | export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; 1645 | export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, digest: string, callback: (err: Error, derivedKey: Buffer) => any): void; 1646 | export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; 1647 | export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number, digest: string) : Buffer; 1648 | export function randomBytes(size: number): Buffer; 1649 | export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; 1650 | export function pseudoRandomBytes(size: number): Buffer; 1651 | export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; 1652 | } 1653 | 1654 | declare module "stream" { 1655 | import events = require("events"); 1656 | 1657 | export interface Stream extends events.EventEmitter { 1658 | pipe(destination: T, options?: { end?: boolean; }): T; 1659 | } 1660 | 1661 | export interface ReadableOptions { 1662 | highWaterMark?: number; 1663 | encoding?: string; 1664 | objectMode?: boolean; 1665 | } 1666 | 1667 | export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { 1668 | readable: boolean; 1669 | constructor(opts?: ReadableOptions); 1670 | _read(size: number): void; 1671 | read(size?: number): string|Buffer; 1672 | setEncoding(encoding: string): void; 1673 | pause(): void; 1674 | resume(): void; 1675 | pipe(destination: T, options?: { end?: boolean; }): T; 1676 | unpipe(destination?: T): void; 1677 | unshift(chunk: string): void; 1678 | unshift(chunk: Buffer): void; 1679 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; 1680 | push(chunk: any, encoding?: string): boolean; 1681 | } 1682 | 1683 | export interface WritableOptions { 1684 | highWaterMark?: number; 1685 | decodeStrings?: boolean; 1686 | } 1687 | 1688 | export class Writable extends events.EventEmitter implements NodeJS.WritableStream { 1689 | writable: boolean; 1690 | constructor(opts?: WritableOptions); 1691 | _write(data: Buffer, encoding: string, callback: Function): void; 1692 | _write(data: string, encoding: string, callback: Function): void; 1693 | write(buffer: Buffer, cb?: Function): boolean; 1694 | write(str: string, cb?: Function): boolean; 1695 | write(str: string, encoding?: string, cb?: Function): boolean; 1696 | end(): void; 1697 | end(buffer: Buffer, cb?: Function): void; 1698 | end(str: string, cb?: Function): void; 1699 | end(str: string, encoding?: string, cb?: Function): void; 1700 | } 1701 | 1702 | export interface DuplexOptions extends ReadableOptions, WritableOptions { 1703 | allowHalfOpen?: boolean; 1704 | } 1705 | 1706 | // Note: Duplex extends both Readable and Writable. 1707 | export class Duplex extends Readable implements NodeJS.ReadWriteStream { 1708 | writable: boolean; 1709 | constructor(opts?: DuplexOptions); 1710 | _write(data: Buffer, encoding: string, callback: Function): void; 1711 | _write(data: string, encoding: string, callback: Function): void; 1712 | write(buffer: Buffer, cb?: Function): boolean; 1713 | write(str: string, cb?: Function): boolean; 1714 | write(str: string, encoding?: string, cb?: Function): boolean; 1715 | end(): void; 1716 | end(buffer: Buffer, cb?: Function): void; 1717 | end(str: string, cb?: Function): void; 1718 | end(str: string, encoding?: string, cb?: Function): void; 1719 | } 1720 | 1721 | export interface TransformOptions extends ReadableOptions, WritableOptions {} 1722 | 1723 | // Note: Transform lacks the _read and _write methods of Readable/Writable. 1724 | export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { 1725 | readable: boolean; 1726 | writable: boolean; 1727 | constructor(opts?: TransformOptions); 1728 | _transform(chunk: Buffer, encoding: string, callback: Function): void; 1729 | _transform(chunk: string, encoding: string, callback: Function): void; 1730 | _flush(callback: Function): void; 1731 | read(size?: number): any; 1732 | setEncoding(encoding: string): void; 1733 | pause(): void; 1734 | resume(): void; 1735 | pipe(destination: T, options?: { end?: boolean; }): T; 1736 | unpipe(destination?: T): void; 1737 | unshift(chunk: string): void; 1738 | unshift(chunk: Buffer): void; 1739 | wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; 1740 | push(chunk: any, encoding?: string): boolean; 1741 | write(buffer: Buffer, cb?: Function): boolean; 1742 | write(str: string, cb?: Function): boolean; 1743 | write(str: string, encoding?: string, cb?: Function): boolean; 1744 | end(): void; 1745 | end(buffer: Buffer, cb?: Function): void; 1746 | end(str: string, cb?: Function): void; 1747 | end(str: string, encoding?: string, cb?: Function): void; 1748 | } 1749 | 1750 | export class PassThrough extends Transform {} 1751 | } 1752 | 1753 | declare module "util" { 1754 | export interface InspectOptions { 1755 | showHidden?: boolean; 1756 | depth?: number; 1757 | colors?: boolean; 1758 | customInspect?: boolean; 1759 | } 1760 | 1761 | export function format(format: any, ...param: any[]): string; 1762 | export function debug(string: string): void; 1763 | export function error(...param: any[]): void; 1764 | export function puts(...param: any[]): void; 1765 | export function print(...param: any[]): void; 1766 | export function log(string: string): void; 1767 | export function inspect(object: any, showHidden?: boolean, depth?: number, color?: boolean): string; 1768 | export function inspect(object: any, options: InspectOptions): string; 1769 | export function isArray(object: any): boolean; 1770 | export function isRegExp(object: any): boolean; 1771 | export function isDate(object: any): boolean; 1772 | export function isError(object: any): boolean; 1773 | export function inherits(constructor: any, superConstructor: any): void; 1774 | } 1775 | 1776 | declare module "assert" { 1777 | function internal (value: any, message?: string): void; 1778 | module internal { 1779 | export class AssertionError implements Error { 1780 | name: string; 1781 | message: string; 1782 | actual: any; 1783 | expected: any; 1784 | operator: string; 1785 | generatedMessage: boolean; 1786 | 1787 | constructor(options?: {message?: string; actual?: any; expected?: any; 1788 | operator?: string; stackStartFunction?: Function}); 1789 | } 1790 | 1791 | export function fail(actual?: any, expected?: any, message?: string, operator?: string): void; 1792 | export function ok(value: any, message?: string): void; 1793 | export function equal(actual: any, expected: any, message?: string): void; 1794 | export function notEqual(actual: any, expected: any, message?: string): void; 1795 | export function deepEqual(actual: any, expected: any, message?: string): void; 1796 | export function notDeepEqual(acutal: any, expected: any, message?: string): void; 1797 | export function strictEqual(actual: any, expected: any, message?: string): void; 1798 | export function notStrictEqual(actual: any, expected: any, message?: string): void; 1799 | export var throws: { 1800 | (block: Function, message?: string): void; 1801 | (block: Function, error: Function, message?: string): void; 1802 | (block: Function, error: RegExp, message?: string): void; 1803 | (block: Function, error: (err: any) => boolean, message?: string): void; 1804 | }; 1805 | 1806 | export var doesNotThrow: { 1807 | (block: Function, message?: string): void; 1808 | (block: Function, error: Function, message?: string): void; 1809 | (block: Function, error: RegExp, message?: string): void; 1810 | (block: Function, error: (err: any) => boolean, message?: string): void; 1811 | }; 1812 | 1813 | export function ifError(value: any): void; 1814 | } 1815 | 1816 | export = internal; 1817 | } 1818 | 1819 | declare module "tty" { 1820 | import net = require("net"); 1821 | 1822 | export function isatty(fd: number): boolean; 1823 | export interface ReadStream extends net.Socket { 1824 | isRaw: boolean; 1825 | setRawMode(mode: boolean): void; 1826 | } 1827 | export interface WriteStream extends net.Socket { 1828 | columns: number; 1829 | rows: number; 1830 | } 1831 | } 1832 | 1833 | declare module "domain" { 1834 | import events = require("events"); 1835 | 1836 | export class Domain extends events.EventEmitter { 1837 | run(fn: Function): void; 1838 | add(emitter: events.EventEmitter): void; 1839 | remove(emitter: events.EventEmitter): void; 1840 | bind(cb: (err: Error, data: any) => any): any; 1841 | intercept(cb: (data: any) => any): any; 1842 | dispose(): void; 1843 | 1844 | addListener(event: string, listener: Function): Domain; 1845 | on(event: string, listener: Function): Domain; 1846 | once(event: string, listener: Function): Domain; 1847 | removeListener(event: string, listener: Function): Domain; 1848 | removeAllListeners(event?: string): Domain; 1849 | } 1850 | 1851 | export function create(): Domain; 1852 | } 1853 | 1854 | declare module "constants" { 1855 | export var E2BIG: number; 1856 | export var EACCES: number; 1857 | export var EADDRINUSE: number; 1858 | export var EADDRNOTAVAIL: number; 1859 | export var EAFNOSUPPORT: number; 1860 | export var EAGAIN: number; 1861 | export var EALREADY: number; 1862 | export var EBADF: number; 1863 | export var EBADMSG: number; 1864 | export var EBUSY: number; 1865 | export var ECANCELED: number; 1866 | export var ECHILD: number; 1867 | export var ECONNABORTED: number; 1868 | export var ECONNREFUSED: number; 1869 | export var ECONNRESET: number; 1870 | export var EDEADLK: number; 1871 | export var EDESTADDRREQ: number; 1872 | export var EDOM: number; 1873 | export var EEXIST: number; 1874 | export var EFAULT: number; 1875 | export var EFBIG: number; 1876 | export var EHOSTUNREACH: number; 1877 | export var EIDRM: number; 1878 | export var EILSEQ: number; 1879 | export var EINPROGRESS: number; 1880 | export var EINTR: number; 1881 | export var EINVAL: number; 1882 | export var EIO: number; 1883 | export var EISCONN: number; 1884 | export var EISDIR: number; 1885 | export var ELOOP: number; 1886 | export var EMFILE: number; 1887 | export var EMLINK: number; 1888 | export var EMSGSIZE: number; 1889 | export var ENAMETOOLONG: number; 1890 | export var ENETDOWN: number; 1891 | export var ENETRESET: number; 1892 | export var ENETUNREACH: number; 1893 | export var ENFILE: number; 1894 | export var ENOBUFS: number; 1895 | export var ENODATA: number; 1896 | export var ENODEV: number; 1897 | export var ENOENT: number; 1898 | export var ENOEXEC: number; 1899 | export var ENOLCK: number; 1900 | export var ENOLINK: number; 1901 | export var ENOMEM: number; 1902 | export var ENOMSG: number; 1903 | export var ENOPROTOOPT: number; 1904 | export var ENOSPC: number; 1905 | export var ENOSR: number; 1906 | export var ENOSTR: number; 1907 | export var ENOSYS: number; 1908 | export var ENOTCONN: number; 1909 | export var ENOTDIR: number; 1910 | export var ENOTEMPTY: number; 1911 | export var ENOTSOCK: number; 1912 | export var ENOTSUP: number; 1913 | export var ENOTTY: number; 1914 | export var ENXIO: number; 1915 | export var EOPNOTSUPP: number; 1916 | export var EOVERFLOW: number; 1917 | export var EPERM: number; 1918 | export var EPIPE: number; 1919 | export var EPROTO: number; 1920 | export var EPROTONOSUPPORT: number; 1921 | export var EPROTOTYPE: number; 1922 | export var ERANGE: number; 1923 | export var EROFS: number; 1924 | export var ESPIPE: number; 1925 | export var ESRCH: number; 1926 | export var ETIME: number; 1927 | export var ETIMEDOUT: number; 1928 | export var ETXTBSY: number; 1929 | export var EWOULDBLOCK: number; 1930 | export var EXDEV: number; 1931 | export var WSAEINTR: number; 1932 | export var WSAEBADF: number; 1933 | export var WSAEACCES: number; 1934 | export var WSAEFAULT: number; 1935 | export var WSAEINVAL: number; 1936 | export var WSAEMFILE: number; 1937 | export var WSAEWOULDBLOCK: number; 1938 | export var WSAEINPROGRESS: number; 1939 | export var WSAEALREADY: number; 1940 | export var WSAENOTSOCK: number; 1941 | export var WSAEDESTADDRREQ: number; 1942 | export var WSAEMSGSIZE: number; 1943 | export var WSAEPROTOTYPE: number; 1944 | export var WSAENOPROTOOPT: number; 1945 | export var WSAEPROTONOSUPPORT: number; 1946 | export var WSAESOCKTNOSUPPORT: number; 1947 | export var WSAEOPNOTSUPP: number; 1948 | export var WSAEPFNOSUPPORT: number; 1949 | export var WSAEAFNOSUPPORT: number; 1950 | export var WSAEADDRINUSE: number; 1951 | export var WSAEADDRNOTAVAIL: number; 1952 | export var WSAENETDOWN: number; 1953 | export var WSAENETUNREACH: number; 1954 | export var WSAENETRESET: number; 1955 | export var WSAECONNABORTED: number; 1956 | export var WSAECONNRESET: number; 1957 | export var WSAENOBUFS: number; 1958 | export var WSAEISCONN: number; 1959 | export var WSAENOTCONN: number; 1960 | export var WSAESHUTDOWN: number; 1961 | export var WSAETOOMANYREFS: number; 1962 | export var WSAETIMEDOUT: number; 1963 | export var WSAECONNREFUSED: number; 1964 | export var WSAELOOP: number; 1965 | export var WSAENAMETOOLONG: number; 1966 | export var WSAEHOSTDOWN: number; 1967 | export var WSAEHOSTUNREACH: number; 1968 | export var WSAENOTEMPTY: number; 1969 | export var WSAEPROCLIM: number; 1970 | export var WSAEUSERS: number; 1971 | export var WSAEDQUOT: number; 1972 | export var WSAESTALE: number; 1973 | export var WSAEREMOTE: number; 1974 | export var WSASYSNOTREADY: number; 1975 | export var WSAVERNOTSUPPORTED: number; 1976 | export var WSANOTINITIALISED: number; 1977 | export var WSAEDISCON: number; 1978 | export var WSAENOMORE: number; 1979 | export var WSAECANCELLED: number; 1980 | export var WSAEINVALIDPROCTABLE: number; 1981 | export var WSAEINVALIDPROVIDER: number; 1982 | export var WSAEPROVIDERFAILEDINIT: number; 1983 | export var WSASYSCALLFAILURE: number; 1984 | export var WSASERVICE_NOT_FOUND: number; 1985 | export var WSATYPE_NOT_FOUND: number; 1986 | export var WSA_E_NO_MORE: number; 1987 | export var WSA_E_CANCELLED: number; 1988 | export var WSAEREFUSED: number; 1989 | export var SIGHUP: number; 1990 | export var SIGINT: number; 1991 | export var SIGILL: number; 1992 | export var SIGABRT: number; 1993 | export var SIGFPE: number; 1994 | export var SIGKILL: number; 1995 | export var SIGSEGV: number; 1996 | export var SIGTERM: number; 1997 | export var SIGBREAK: number; 1998 | export var SIGWINCH: number; 1999 | export var SSL_OP_ALL: number; 2000 | export var SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION: number; 2001 | export var SSL_OP_CIPHER_SERVER_PREFERENCE: number; 2002 | export var SSL_OP_CISCO_ANYCONNECT: number; 2003 | export var SSL_OP_COOKIE_EXCHANGE: number; 2004 | export var SSL_OP_CRYPTOPRO_TLSEXT_BUG: number; 2005 | export var SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS: number; 2006 | export var SSL_OP_EPHEMERAL_RSA: number; 2007 | export var SSL_OP_LEGACY_SERVER_CONNECT: number; 2008 | export var SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER: number; 2009 | export var SSL_OP_MICROSOFT_SESS_ID_BUG: number; 2010 | export var SSL_OP_MSIE_SSLV2_RSA_PADDING: number; 2011 | export var SSL_OP_NETSCAPE_CA_DN_BUG: number; 2012 | export var SSL_OP_NETSCAPE_CHALLENGE_BUG: number; 2013 | export var SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG: number; 2014 | export var SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG: number; 2015 | export var SSL_OP_NO_COMPRESSION: number; 2016 | export var SSL_OP_NO_QUERY_MTU: number; 2017 | export var SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION: number; 2018 | export var SSL_OP_NO_SSLv2: number; 2019 | export var SSL_OP_NO_SSLv3: number; 2020 | export var SSL_OP_NO_TICKET: number; 2021 | export var SSL_OP_NO_TLSv1: number; 2022 | export var SSL_OP_NO_TLSv1_1: number; 2023 | export var SSL_OP_NO_TLSv1_2: number; 2024 | export var SSL_OP_PKCS1_CHECK_1: number; 2025 | export var SSL_OP_PKCS1_CHECK_2: number; 2026 | export var SSL_OP_SINGLE_DH_USE: number; 2027 | export var SSL_OP_SINGLE_ECDH_USE: number; 2028 | export var SSL_OP_SSLEAY_080_CLIENT_DH_BUG: number; 2029 | export var SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG: number; 2030 | export var SSL_OP_TLS_BLOCK_PADDING_BUG: number; 2031 | export var SSL_OP_TLS_D5_BUG: number; 2032 | export var SSL_OP_TLS_ROLLBACK_BUG: number; 2033 | export var ENGINE_METHOD_DSA: number; 2034 | export var ENGINE_METHOD_DH: number; 2035 | export var ENGINE_METHOD_RAND: number; 2036 | export var ENGINE_METHOD_ECDH: number; 2037 | export var ENGINE_METHOD_ECDSA: number; 2038 | export var ENGINE_METHOD_CIPHERS: number; 2039 | export var ENGINE_METHOD_DIGESTS: number; 2040 | export var ENGINE_METHOD_STORE: number; 2041 | export var ENGINE_METHOD_PKEY_METHS: number; 2042 | export var ENGINE_METHOD_PKEY_ASN1_METHS: number; 2043 | export var ENGINE_METHOD_ALL: number; 2044 | export var ENGINE_METHOD_NONE: number; 2045 | export var DH_CHECK_P_NOT_SAFE_PRIME: number; 2046 | export var DH_CHECK_P_NOT_PRIME: number; 2047 | export var DH_UNABLE_TO_CHECK_GENERATOR: number; 2048 | export var DH_NOT_SUITABLE_GENERATOR: number; 2049 | export var NPN_ENABLED: number; 2050 | export var RSA_PKCS1_PADDING: number; 2051 | export var RSA_SSLV23_PADDING: number; 2052 | export var RSA_NO_PADDING: number; 2053 | export var RSA_PKCS1_OAEP_PADDING: number; 2054 | export var RSA_X931_PADDING: number; 2055 | export var RSA_PKCS1_PSS_PADDING: number; 2056 | export var POINT_CONVERSION_COMPRESSED: number; 2057 | export var POINT_CONVERSION_UNCOMPRESSED: number; 2058 | export var POINT_CONVERSION_HYBRID: number; 2059 | export var O_RDONLY: number; 2060 | export var O_WRONLY: number; 2061 | export var O_RDWR: number; 2062 | export var S_IFMT: number; 2063 | export var S_IFREG: number; 2064 | export var S_IFDIR: number; 2065 | export var S_IFCHR: number; 2066 | export var S_IFLNK: number; 2067 | export var O_CREAT: number; 2068 | export var O_EXCL: number; 2069 | export var O_TRUNC: number; 2070 | export var O_APPEND: number; 2071 | export var F_OK: number; 2072 | export var R_OK: number; 2073 | export var W_OK: number; 2074 | export var X_OK: number; 2075 | export var UV_UDP_REUSEADDR: number; 2076 | } 2077 | -------------------------------------------------------------------------------- /typings/promises-a-plus/promises-a-plus.d.ts: -------------------------------------------------------------------------------- 1 | // Type definitions for promises-a-plus 2 | // Project: http://promisesaplus.com/ 3 | // Definitions by: Igor Oleinikov 4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped 5 | 6 | declare namespace PromisesAPlus { 7 | interface PromiseCtor { 8 | (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; 9 | } 10 | 11 | interface PromiseImpl { 12 | new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; 13 | } 14 | 15 | interface Thenable { 16 | then(onFulfill?: (value: T) => Thenable|R, onReject?: (error: any) => Thenable|R): Thenable; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typings/references.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | --------------------------------------------------------------------------------