├── .npmrc ├── hosting.json ├── typings ├── tsd.d.ts └── node │ └── node.d.ts ├── .babelrc ├── README.md ├── jsconfig.json ├── wwwroot ├── favicon.ico ├── web.config └── app.jsx ├── Views ├── _ViewImports.cshtml ├── Shared │ └── Error.cshtml └── Home │ └── Index.cshtml ├── appsettings.json ├── tsd.json ├── package.json ├── Controllers └── HomeController.cs ├── project.json ├── Helpers └── WebpackHelper.cs ├── webpack.config.babel.js ├── Startup.cs └── .gitignore /.npmrc: -------------------------------------------------------------------------------- 1 | save-exact=true -------------------------------------------------------------------------------- /hosting.json: -------------------------------------------------------------------------------- 1 | { 2 | "webroot": "build" 3 | } -------------------------------------------------------------------------------- /typings/tsd.d.ts: -------------------------------------------------------------------------------- 1 | 2 | /// 3 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "es2015", 4 | "react" 5 | ] 6 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### Setup Instructions 2 | 1. dnu restore 3 | 2. npm run build 4 | 3. dnx web -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "ES6" 5 | } 6 | } -------------------------------------------------------------------------------- /wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scottaddie/webpack-aspnet5/HEAD/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using webpack_aspnet5 2 | @addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers" 3 | -------------------------------------------------------------------------------- /Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Error"; 3 | } 4 | 5 |

Error.

6 |

An error occurred while processing your request.

7 | -------------------------------------------------------------------------------- /appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "IncludeScopes": false, 4 | "LogLevel": { 5 | "Default": "Verbose", 6 | "System": "Information", 7 | "Microsoft": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /tsd.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "v4", 3 | "repo": "borisyankov/DefinitelyTyped", 4 | "ref": "master", 5 | "path": "typings", 6 | "bundle": "typings/tsd.d.ts", 7 | "installed": { 8 | "node/node.d.ts": { 9 | "commit": "16134c168d021351acb1673ee9659644fc58c424" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /wwwroot/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Webpack/ASP.NET 5 Sample App 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /wwwroot/app.jsx: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('file?name=favicon.ico!./favicon.ico'); 4 | 5 | import React from 'react'; 6 | import { render } from 'react-dom'; 7 | 8 | const { string } = React.PropTypes; 9 | 10 | class App extends React.Component { 11 | constructor() { 12 | super(); 13 | } 14 | 15 | render() { 16 | return ( 17 |
18 |

Hello, {this.props.firstName}{' '}{this.props.lastName}!

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