├── .gitignore ├── README.md ├── tourheroes_js ├── app │ ├── app.component.js │ └── main.js ├── index.html ├── package.json └── styles.css └── tourheroes_ts ├── app ├── app.component.css ├── app.component.js ├── app.component.js.map ├── app.component.ts ├── app.routes.js ├── app.routes.js.map ├── app.routes.ts ├── dashboard.component.css ├── dashboard.component.html ├── dashboard.component.js ├── dashboard.component.js.map ├── dashboard.component.ts ├── hero-detail.component.css ├── hero-detail.component.html ├── hero-detail.component.js ├── hero-detail.component.js.map ├── hero-detail.component.ts ├── hero.js ├── hero.js.map ├── hero.service.js ├── hero.service.js.map ├── hero.service.ts ├── hero.ts ├── heroes ├── heroes.component.css ├── heroes.component.html ├── heroes.component.js ├── heroes.component.js.map ├── heroes.component.ts ├── in-memory-data.service.js ├── in-memory-data.service.js.map ├── in-memory-data.service.ts ├── main.js ├── main.js.map └── main.ts ├── gh.html ├── index.html ├── package.json ├── sample.css ├── styles.css ├── systemjs.config.js ├── tsconfig.json ├── typings.json └── typings ├── globals ├── core-js │ ├── index.d.ts │ └── typings.json ├── jasmine │ ├── index.d.ts │ └── typings.json └── node │ ├── index.d.ts │ └── typings.json └── index.d.ts /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | npm-debug.log -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 1. O que é isso? 2 | 3 | Minha implementação pro [tutorial oficial do Angular2](https://angular.io/docs/ts/latest/tutorial/) 4 | * [Live demo com Typescript](https://tonylampada.github.io/borangular2/tourheroes_ts/gh.html) (Tour of heroes) 5 | * [Live demo com Javascript](https://tonylampada.github.io/borangular2/tourheroes_js/) (Quickstart) 6 | 7 | # 2. O que vc achou do Angular2? 8 | 9 | Antes de ouvir minha opinião, devo dizer que ainda sei muito pouco sobre o Angular2 - a gente só deu uns amassos e pra conhecer um framework de verdade, não tem jeito - só casando. 10 | 11 | Dito isso, eu gostei do que vi até agora. Ele "amarra" um pouco mais a estrutura do projeto, mas isso "força" uma adoção das boas práticas que a gente aprendeu trabalhando com Angular 1.x. Por exemplo: tudo é modular e componentizado. Você até consegue "sair do trilho" e fazer alguma gambiarra, mas é muito mais fácil aceitar as decisões que o framework já tomou e "andar na linha". 12 | 13 | Apesar disso, eu ainda não acho que ele está bom o suficiente pra ser usado em produção, num projeto crítico que precisa ir pro ar amanhã. Mas meu sentimento é que estamos chegando lá. 14 | 15 | # 3. O que aprendeu fazendo esse tutorial? 16 | 17 | Rapaz, um monte de coisa. Vou fazer uma lista delas abaixo. 18 | 19 | * Você pode usar mais de uma linguagem (Javascript, Dart, Typescript) pra trabalhar com o framework. 20 | * Typescript é um superset do javascript. Ou seja, [typescript = javascript + sintaxes adicionais], sendo que essas sintaxes adicionais permitem fazer coisas que JS não faz, como criar variáveis com tipo, classes, funções lambda, etc. Mas dentro de um arquivo .ts vc pode escrever código js normalmente que também funciona. 21 | * Typescript é claramente o "favorito" (do Google). Tanto é que se vc procurar o [tutorial pra Javascript](https://angular.io/docs/js/latest/tutorial/index.html), veja o que diz: `This chapter is not yet available in JavaScript. We recommend reading the TypeScript version.`, isso aih pra mim é "joguinho sujo" pra estimular a adoção do Typescript. Ô GOOGLE, EU NÃO NASCI ONTEM NÃO VIU! SEU SAFADO! 22 | * Uma aplicação Angular2 é uma árvore de componentes, que pode ter rotas. 23 | * Exemplo da estrutura de componentes e rotas do "Tour of Heroes" em typescript: 24 | 25 | ``` 26 | 1 (C) AppComponent 27 | -- 1.1 (R) heroes = (C) HeroesComponent //listar heroes 28 | ---- 1.1.1 (C) HeroDetailComponent //Formulario pra criar um Hero 29 | -- 1.2 (R) dashboard = (C) DashboardComponent //"home" de heroes 30 | -- 1.3 (R) detail/:id = (C) HeroDetailComponent //Formulario pra editar um hero 31 | ``` 32 | 33 | * Um componente é um pedaço de tela que o usuário pode interagir. Um componente Angular2: 34 | * Tem um **template** html (view) 35 | * Pode ter um conjunto de estilos (css) que valem apenas pro componente 36 | * Tem uma **classe** que implementa o comportamento do componente (model) 37 | * Pode depender de outros componentes e também de serviços externos que o Angular injeta (na **classe** do componente) 38 | * Se parece um pouco com a estrutura [diretiva + serviço-modelo] que a gente viu no ng-masters (e que eu vivo recomendando pra galera implementar no ANgular 1.x), só que sem um controller ou um $scope no meio. 39 | * Aliás, o conceito de $scope já era. Foi pro saco. 40 | * Uma **rota** deve ser associada diretamente a um componente. Essa é uma diferença conceitual importante pro Angular 1.x, onde rotas são associadas a *templates* 41 | * Um componente pode ser roteado ou não. Por exemplo, o componente *HeroDetailComponent* (que permite editar uma entidade "Hero") pode "receber um Hero" pra editar através da rota (caso 1.3 na árvore acima); ou pode receber um Hero através do componente pai (caso 1.1.1) 42 | * No Angular2 existem **classes injetáveis**, que fazem mais ou menos o papel dos **serviços** que a gente cria no Angular1.x (usando o método .factory() ou .service()) 43 | * O ciclo de vida das instâncias dessas classes injetáveis **depende da estrutura da árvore onde se encaixam os componentes aonde essas instâncias são injetadas**. Isso é *completamente diferente* (e mais complicado) do que acontece com os serviços do Angular 1.x, onde tudo é singleton. 44 | * O CSS dos componentes, por padrão fica junto do código do componente, que nem eu faço no [djangular3](https://github.com/tonylampada/djangular3) ;-) 45 | * O Angular2 vem com o **in-memory-web-api** que é um jeito mais "nativo" de fazer um implementação mockada do seu backend, muito parecido com o mock-api que aparece no [djangular3](https://github.com/tonylampada/djangular3) 46 | 47 | # 4. O que falta aprender. 48 | 49 | * Qual o melhor jeito de empacotar uma aplicação Angular2 pra produção (budle, minify, tals) 50 | * Qual o melhor jeito de colocar o sass dentro da build do projeto. 51 | * Typescript. É outra linguagem, negão. Tem que aprender - ou então caga e vai programar com JS mesmo, que também pode ser uma opção 52 | * System.js. No tutorial ele recomenda usar esse cara que é um "carregador de arquivos js" pra sua página. Meu entendimento de como usar e como ele funciona ainda tá muito meia boca. 53 | * Entender melhor como usar o "in-memory-web-api" pra fazer mocks de chamadas http 54 | * Testes - qual o melhor caminho pra fazer testes unitários 55 | * Migração do Angular 1.x - parece muito dolorido. Existe alguma luz no fim do túnel? 56 | -------------------------------------------------------------------------------- /tourheroes_js/app/app.component.js: -------------------------------------------------------------------------------- 1 | (function(app) { 2 | app.AppComponent = 3 | ng.core.Component({ 4 | selector: 'my-app', 5 | template: '

My First Angular 2 Appz

' 6 | }) 7 | .Class({ 8 | constructor: function() {} 9 | }); 10 | })(window.app || (window.app = {})); 11 | -------------------------------------------------------------------------------- /tourheroes_js/app/main.js: -------------------------------------------------------------------------------- 1 | (function(app) { 2 | document.addEventListener('DOMContentLoaded', function() { 3 | ng.platformBrowserDynamic.bootstrap(app.AppComponent); 4 | }); 5 | })(window.app || (window.app = {})); 6 | -------------------------------------------------------------------------------- /tourheroes_js/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Angular 2 QuickStart JS 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Loading... 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /tourheroes_js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular2-quickstart", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "start": "npm run lite", 6 | "lite": "lite-server" 7 | }, 8 | "license": "ISC", 9 | "dependencies": { 10 | "@angular/common": "2.0.0-rc.4", 11 | "@angular/compiler": "2.0.0-rc.4", 12 | "@angular/core": "2.0.0-rc.4", 13 | "@angular/forms": "0.2.0", 14 | "@angular/http": "2.0.0-rc.4", 15 | "@angular/platform-browser": "2.0.0-rc.4", 16 | "@angular/platform-browser-dynamic": "2.0.0-rc.4", 17 | "@angular/router": "3.0.0-beta.1", 18 | "@angular/router-deprecated": "2.0.0-rc.2", 19 | "@angular/upgrade": "2.0.0-rc.4", 20 | 21 | "core-js": "^2.4.0", 22 | "reflect-metadata": "0.1.3", 23 | "rxjs": "5.0.0-beta.6", 24 | "zone.js": "0.6.12", 25 | 26 | "angular2-in-memory-web-api": "0.0.14", 27 | "bootstrap": "^3.3.6" 28 | }, 29 | "devDependencies": { 30 | "concurrently": "^2.0.0", 31 | "lite-server": "^2.2.0" 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tourheroes_js/styles.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color: #369; 3 | font-family: Arial, Helvetica, sans-serif; 4 | font-size: 250%; 5 | } 6 | body { 7 | margin: 2em; 8 | } 9 | 10 | /* 11 | * See https://github.com/angular/angular.io/blob/master/public/docs/_examples/styles.css 12 | * for the full set of master styles used by the documentation samples 13 | */ 14 | -------------------------------------------------------------------------------- /tourheroes_ts/app/app.component.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | font-size: 1.2em; 3 | color: #999; 4 | margin-bottom: 0; 5 | } 6 | h2 { 7 | font-size: 2em; 8 | margin-top: 0; 9 | padding-top: 0; 10 | } 11 | nav a { 12 | padding: 5px 10px; 13 | text-decoration: none; 14 | margin-top: 10px; 15 | display: inline-block; 16 | background-color: #eee; 17 | border-radius: 4px; 18 | } 19 | nav a:visited, a:link { 20 | color: #607D8B; 21 | } 22 | nav a:hover { 23 | color: #039be5; 24 | background-color: #CFD8DC; 25 | } 26 | nav a.active { 27 | color: #039be5; 28 | } 29 | -------------------------------------------------------------------------------- /tourheroes_ts/app/app.component.js: -------------------------------------------------------------------------------- 1 | System.register(['@angular/core', './hero.service', '@angular/router'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 5 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 6 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 7 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 8 | return c > 3 && r && Object.defineProperty(target, key, r), r; 9 | }; 10 | var __metadata = (this && this.__metadata) || function (k, v) { 11 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 12 | }; 13 | var core_1, hero_service_1, router_1; 14 | var AppComponent; 15 | return { 16 | setters:[ 17 | function (core_1_1) { 18 | core_1 = core_1_1; 19 | }, 20 | function (hero_service_1_1) { 21 | hero_service_1 = hero_service_1_1; 22 | }, 23 | function (router_1_1) { 24 | router_1 = router_1_1; 25 | }], 26 | execute: function() { 27 | AppComponent = (function () { 28 | function AppComponent() { 29 | this.title = 'Tour of Heroes'; 30 | } 31 | AppComponent = __decorate([ 32 | core_1.Component({ 33 | selector: 'my-app', 34 | template: "\n

{{title}}

\n \n \n ", 35 | styleUrls: ['app/app.component.css'], 36 | directives: [router_1.ROUTER_DIRECTIVES], 37 | providers: [hero_service_1.HeroService] 38 | }), 39 | __metadata('design:paramtypes', []) 40 | ], AppComponent); 41 | return AppComponent; 42 | }()); 43 | exports_1("AppComponent", AppComponent); 44 | } 45 | } 46 | }); 47 | //# sourceMappingURL=app.component.js.map -------------------------------------------------------------------------------- /tourheroes_ts/app/app.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.component.js","sourceRoot":"","sources":["app.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAkBA;gBAAA;oBACE,UAAK,GAAG,gBAAgB,CAAC;gBAC3B,CAAC;gBAhBD;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,QAAQ;wBAClB,QAAQ,EAAE,gQAOT;wBACD,SAAS,EAAE,CAAC,uBAAuB,CAAC;wBACpC,UAAU,EAAE,CAAC,0BAAiB,CAAC;wBAC/B,SAAS,EAAE,CAAC,0BAAW,CAAC;qBACzB,CAAC;;gCAAA;gBAGF,mBAAC;YAAD,CAAC,AAFD,IAEC;YAFD,uCAEC,CAAA"} -------------------------------------------------------------------------------- /tourheroes_ts/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { HeroService } from './hero.service'; 3 | import { HeroesComponent } from './heroes.component'; 4 | import { ROUTER_DIRECTIVES } from '@angular/router'; 5 | @Component({ 6 | selector: 'my-app', 7 | template: ` 8 |

{{title}}

9 | 13 | 14 | `, 15 | styleUrls: ['app/app.component.css'], 16 | directives: [ROUTER_DIRECTIVES], 17 | providers: [HeroService] 18 | }) 19 | export class AppComponent { 20 | title = 'Tour of Heroes'; 21 | } -------------------------------------------------------------------------------- /tourheroes_ts/app/app.routes.js: -------------------------------------------------------------------------------- 1 | System.register(['@angular/router', './heroes.component', './dashboard.component', './hero-detail.component'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var router_1, heroes_component_1, dashboard_component_1, hero_detail_component_1; 5 | var routes, APP_ROUTER_PROVIDERS; 6 | return { 7 | setters:[ 8 | function (router_1_1) { 9 | router_1 = router_1_1; 10 | }, 11 | function (heroes_component_1_1) { 12 | heroes_component_1 = heroes_component_1_1; 13 | }, 14 | function (dashboard_component_1_1) { 15 | dashboard_component_1 = dashboard_component_1_1; 16 | }, 17 | function (hero_detail_component_1_1) { 18 | hero_detail_component_1 = hero_detail_component_1_1; 19 | }], 20 | execute: function() { 21 | routes = [ 22 | { 23 | path: 'heroes', 24 | component: heroes_component_1.HeroesComponent 25 | }, 26 | { 27 | path: 'dashboard', 28 | component: dashboard_component_1.DashboardComponent 29 | }, 30 | { 31 | path: 'detail/:id', 32 | component: hero_detail_component_1.HeroDetailComponent 33 | }, 34 | { 35 | path: '**', 36 | redirectTo: '/dashboard', 37 | pathMatch: 'full' 38 | }, 39 | ]; 40 | exports_1("APP_ROUTER_PROVIDERS", APP_ROUTER_PROVIDERS = [ 41 | router_1.provideRouter(routes) 42 | ]); 43 | } 44 | } 45 | }); 46 | //# sourceMappingURL=app.routes.js.map -------------------------------------------------------------------------------- /tourheroes_ts/app/app.routes.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.routes.js","sourceRoot":"","sources":["app.routes.ts"],"names":[],"mappings":";;;;QAKM,MAAM,EAoBC,oBAAoB;;;;;;;;;;;;;;;;YApB3B,MAAM,GAAiB;gBACzB;oBACI,IAAI,EAAE,QAAQ;oBACd,SAAS,EAAE,kCAAe;iBAC7B;gBACD;oBACI,IAAI,EAAE,WAAW;oBACjB,SAAS,EAAE,wCAAkB;iBAChC;gBACD;oBACI,IAAI,EAAE,YAAY;oBAClB,SAAS,EAAE,2CAAmB;iBACjC;gBACD;oBACI,IAAI,EAAE,IAAI;oBACV,UAAU,EAAE,YAAY;oBACxB,SAAS,EAAE,MAAM;iBACpB;aACJ,CAAC;YAEW,kCAAA,oBAAoB,GAAG;gBAClC,sBAAa,CAAC,MAAM,CAAC;aACtB,CAAA,CAAC"} -------------------------------------------------------------------------------- /tourheroes_ts/app/app.routes.ts: -------------------------------------------------------------------------------- 1 | import { provideRouter, RouterConfig } from '@angular/router'; 2 | import { HeroesComponent } from './heroes.component'; 3 | import { DashboardComponent } from './dashboard.component'; 4 | import { HeroDetailComponent } from './hero-detail.component'; 5 | 6 | const routes: RouterConfig = [ 7 | { 8 | path: 'heroes', 9 | component: HeroesComponent 10 | }, 11 | { 12 | path: 'dashboard', 13 | component: DashboardComponent 14 | }, 15 | { 16 | path: 'detail/:id', 17 | component: HeroDetailComponent 18 | }, 19 | { 20 | path: '**', 21 | redirectTo: '/dashboard', 22 | pathMatch: 'full' 23 | }, 24 | ]; 25 | 26 | export const APP_ROUTER_PROVIDERS = [ 27 | provideRouter(routes) 28 | ]; 29 | -------------------------------------------------------------------------------- /tourheroes_ts/app/dashboard.component.css: -------------------------------------------------------------------------------- 1 | [class*='col-'] { 2 | float: left; 3 | } 4 | *, *:after, *:before { 5 | -webkit-box-sizing: border-box; 6 | -moz-box-sizing: border-box; 7 | box-sizing: border-box; 8 | } 9 | h3 { 10 | text-align: center; margin-bottom: 0; 11 | } 12 | [class*='col-'] { 13 | padding-right: 20px; 14 | padding-bottom: 20px; 15 | } 16 | [class*='col-']:last-of-type { 17 | padding-right: 0; 18 | } 19 | .grid { 20 | margin: 0; 21 | } 22 | .col-1-4 { 23 | width: 25%; 24 | } 25 | .module { 26 | padding: 20px; 27 | text-align: center; 28 | color: #eee; 29 | max-height: 120px; 30 | min-width: 120px; 31 | background-color: #607D8B; 32 | border-radius: 2px; 33 | } 34 | h4 { 35 | position: relative; 36 | } 37 | .module:hover { 38 | background-color: #EEE; 39 | cursor: pointer; 40 | color: #607d8b; 41 | } 42 | .grid-pad { 43 | padding: 10px 0; 44 | } 45 | .grid-pad > [class*='col-']:last-of-type { 46 | padding-right: 20px; 47 | } 48 | @media (max-width: 600px) { 49 | .module { 50 | font-size: 10px; 51 | max-height: 75px; } 52 | } 53 | @media (max-width: 1024px) { 54 | .grid { 55 | margin: 0; 56 | } 57 | .module { 58 | min-width: 60px; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /tourheroes_ts/app/dashboard.component.html: -------------------------------------------------------------------------------- 1 |

Top Heroes

2 |
3 |
4 |
5 |

{{hero.name}}

6 |
7 |
8 |
9 | -------------------------------------------------------------------------------- /tourheroes_ts/app/dashboard.component.js: -------------------------------------------------------------------------------- 1 | System.register(['@angular/core', './hero.service', '@angular/router'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 5 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 6 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 7 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 8 | return c > 3 && r && Object.defineProperty(target, key, r), r; 9 | }; 10 | var __metadata = (this && this.__metadata) || function (k, v) { 11 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 12 | }; 13 | var core_1, hero_service_1, router_1; 14 | var DashboardComponent; 15 | return { 16 | setters:[ 17 | function (core_1_1) { 18 | core_1 = core_1_1; 19 | }, 20 | function (hero_service_1_1) { 21 | hero_service_1 = hero_service_1_1; 22 | }, 23 | function (router_1_1) { 24 | router_1 = router_1_1; 25 | }], 26 | execute: function() { 27 | DashboardComponent = (function () { 28 | function DashboardComponent(heroService, router) { 29 | this.heroService = heroService; 30 | this.router = router; 31 | this.heroes = []; 32 | } 33 | ; 34 | DashboardComponent.prototype.ngOnInit = function () { 35 | var _this = this; 36 | this.heroService.getHeroes().then(function (heroes) { return _this.heroes = heroes.slice(1, 5); }); 37 | }; 38 | DashboardComponent.prototype.gotoDetail = function (hero) { 39 | this.router.navigate(['/detail', hero.id]); 40 | }; 41 | DashboardComponent = __decorate([ 42 | core_1.Component({ 43 | selector: 'my-dashboard', 44 | templateUrl: 'app/dashboard.component.html', 45 | styleUrls: ['app/dashboard.component.css'], 46 | }), 47 | __metadata('design:paramtypes', [hero_service_1.HeroService, router_1.Router]) 48 | ], DashboardComponent); 49 | return DashboardComponent; 50 | }()); 51 | exports_1("DashboardComponent", DashboardComponent); 52 | } 53 | } 54 | }); 55 | //# sourceMappingURL=dashboard.component.js.map -------------------------------------------------------------------------------- /tourheroes_ts/app/dashboard.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"dashboard.component.js","sourceRoot":"","sources":["dashboard.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;YAUA;gBAGI,4BACY,WAAwB,EACxB,MAAc;oBADd,gBAAW,GAAX,WAAW,CAAa;oBACxB,WAAM,GAAN,MAAM,CAAQ;oBAJ1B,WAAM,GAAW,EAAE,CAAC;gBAIU,CAAC;;gBAE/B,qCAAQ,GAAR;oBAAA,iBAEC;oBADG,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAhC,CAAgC,CAAC,CAAC;gBAClF,CAAC;gBACD,uCAAU,GAAV,UAAW,IAAU;oBACjB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC/C,CAAC;gBAjBL;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,cAAc;wBACxB,WAAW,EAAE,8BAA8B;wBAC3C,SAAS,EAAE,CAAC,6BAA6B,CAAC;qBAC3C,CAAC;;sCAAA;gBAcF,yBAAC;YAAD,CAAC,AAbD,IAaC;YAbD,mDAaC,CAAA"} -------------------------------------------------------------------------------- /tourheroes_ts/app/dashboard.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { HeroService } from './hero.service'; 3 | import { Hero } from './hero'; 4 | import { Router } from '@angular/router'; 5 | 6 | @Component({ 7 | selector: 'my-dashboard', 8 | templateUrl: 'app/dashboard.component.html', 9 | styleUrls: ['app/dashboard.component.css'], 10 | }) 11 | export class DashboardComponent implements OnInit { 12 | heroes: Hero[] = []; 13 | 14 | constructor( 15 | private heroService: HeroService, 16 | private router: Router) { }; 17 | 18 | ngOnInit() { 19 | this.heroService.getHeroes().then(heroes => this.heroes = heroes.slice(1, 5)); 20 | } 21 | gotoDetail(hero: Hero) { 22 | this.router.navigate(['/detail', hero.id]); 23 | } 24 | } -------------------------------------------------------------------------------- /tourheroes_ts/app/hero-detail.component.css: -------------------------------------------------------------------------------- 1 | label { 2 | display: inline-block; 3 | width: 3em; 4 | margin: .5em 0; 5 | color: #607D8B; 6 | font-weight: bold; 7 | } 8 | input { 9 | height: 2em; 10 | font-size: 1em; 11 | padding-left: .4em; 12 | } 13 | button { 14 | margin-top: 20px; 15 | font-family: Arial; 16 | background-color: #eee; 17 | border: none; 18 | padding: 5px 10px; 19 | border-radius: 4px; 20 | cursor: pointer; cursor: hand; 21 | } 22 | button:hover { 23 | background-color: #cfd8dc; 24 | } 25 | button:disabled { 26 | background-color: #eee; 27 | color: #ccc; 28 | cursor: auto; 29 | } 30 | -------------------------------------------------------------------------------- /tourheroes_ts/app/hero-detail.component.html: -------------------------------------------------------------------------------- 1 |
2 |

{{hero.name}} details!

3 |
4 | {{hero.id}}
5 |
6 | 7 | 8 |
9 | 10 | 11 |
12 | -------------------------------------------------------------------------------- /tourheroes_ts/app/hero-detail.component.js: -------------------------------------------------------------------------------- 1 | System.register(['@angular/core', './hero', '@angular/router', './hero.service'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 5 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 6 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 7 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 8 | return c > 3 && r && Object.defineProperty(target, key, r), r; 9 | }; 10 | var __metadata = (this && this.__metadata) || function (k, v) { 11 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 12 | }; 13 | var core_1, hero_1, router_1, hero_service_1; 14 | var HeroDetailComponent; 15 | return { 16 | setters:[ 17 | function (core_1_1) { 18 | core_1 = core_1_1; 19 | }, 20 | function (hero_1_1) { 21 | hero_1 = hero_1_1; 22 | }, 23 | function (router_1_1) { 24 | router_1 = router_1_1; 25 | }, 26 | function (hero_service_1_1) { 27 | hero_service_1 = hero_service_1_1; 28 | }], 29 | execute: function() { 30 | HeroDetailComponent = (function () { 31 | function HeroDetailComponent(heroService, route) { 32 | this.heroService = heroService; 33 | this.route = route; 34 | this.close = new core_1.EventEmitter(); 35 | this.navigated = false; // true if navigated here 36 | } 37 | HeroDetailComponent.prototype.save = function () { 38 | var _this = this; 39 | this.heroService 40 | .save(this.hero) 41 | .then(function (hero) { 42 | _this.hero = hero; // saved hero, w/ id if new 43 | _this.goBack(hero); 44 | }) 45 | .catch(function (error) { return _this.error = error; }); // TODO: Display error message 46 | }; 47 | HeroDetailComponent.prototype.ngOnInit = function () { 48 | var _this = this; 49 | this.sub = this.route.params.subscribe(function (params) { 50 | if (params['id'] !== undefined) { 51 | var id = +params['id']; 52 | _this.navigated = true; 53 | _this.heroService.getHero(id) 54 | .then(function (hero) { return _this.hero = hero; }); 55 | } 56 | else { 57 | _this.navigated = false; 58 | _this.hero = new hero_1.Hero(); 59 | } 60 | }); 61 | }; 62 | HeroDetailComponent.prototype.ngOnDestroy = function () { 63 | this.sub.unsubscribe(); 64 | }; 65 | HeroDetailComponent.prototype.goBack = function (savedHero) { 66 | if (savedHero === void 0) { savedHero = null; } 67 | this.close.emit(savedHero); 68 | if (this.navigated) { 69 | window.history.back(); 70 | } 71 | }; 72 | __decorate([ 73 | core_1.Input(), 74 | __metadata('design:type', hero_1.Hero) 75 | ], HeroDetailComponent.prototype, "hero", void 0); 76 | __decorate([ 77 | core_1.Output(), 78 | __metadata('design:type', Object) 79 | ], HeroDetailComponent.prototype, "close", void 0); 80 | HeroDetailComponent = __decorate([ 81 | core_1.Component({ 82 | selector: 'my-hero-detail', 83 | templateUrl: 'app/hero-detail.component.html', 84 | styleUrls: ['app/hero-detail.component.css'] 85 | }), 86 | __metadata('design:paramtypes', [hero_service_1.HeroService, router_1.ActivatedRoute]) 87 | ], HeroDetailComponent); 88 | return HeroDetailComponent; 89 | }()); 90 | exports_1("HeroDetailComponent", HeroDetailComponent); 91 | } 92 | } 93 | }); 94 | //# sourceMappingURL=hero-detail.component.js.map -------------------------------------------------------------------------------- /tourheroes_ts/app/hero-detail.component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"hero-detail.component.js","sourceRoot":"","sources":["hero-detail.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAUA;gBAQE,6BACU,WAAwB,EACxB,KAAqB;oBADrB,gBAAW,GAAX,WAAW,CAAa;oBACxB,UAAK,GAAL,KAAK,CAAgB;oBAPrB,UAAK,GAAG,IAAI,mBAAY,EAAE,CAAC;oBAGrC,cAAS,GAAG,KAAK,CAAC,CAAC,yBAAyB;gBAK5C,CAAC;gBAED,kCAAI,GAAJ;oBAAA,iBAQC;oBAPC,IAAI,CAAC,WAAW;yBACX,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;yBACf,IAAI,CAAC,UAAA,IAAI;wBACR,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,2BAA2B;wBAC7C,KAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;oBACpB,CAAC,CAAC;yBACD,KAAK,CAAC,UAAA,KAAK,IAAI,OAAA,KAAI,CAAC,KAAK,GAAG,KAAK,EAAlB,CAAkB,CAAC,CAAC,CAAC,8BAA8B;gBACzE,CAAC;gBACD,sCAAQ,GAAR;oBAAA,iBAYC;oBAXC,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,UAAA,MAAM;wBAC3C,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC;4BAC/B,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;4BACvB,KAAI,CAAC,SAAS,GAAG,IAAI,CAAC;4BACtB,KAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;iCACvB,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,KAAI,CAAC,IAAI,GAAG,IAAI,EAAhB,CAAgB,CAAC,CAAC;wBACtC,CAAC;wBAAC,IAAI,CAAC,CAAC;4BACN,KAAI,CAAC,SAAS,GAAG,KAAK,CAAC;4BACvB,KAAI,CAAC,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;wBACzB,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;gBACD,yCAAW,GAAX;oBACE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACzB,CAAC;gBACD,oCAAM,GAAN,UAAO,SAAsB;oBAAtB,yBAAsB,GAAtB,gBAAsB;oBAC3B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC3B,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;wBACnB,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;oBACxB,CAAC;gBACH,CAAC;gBAzCF;oBAAC,YAAK,EAAE;;iEAAA;gBACP;oBAAC,aAAM,EAAE;;kEAAA;gBARX;oBAAC,gBAAS,CAAC;wBACT,QAAQ,EAAE,gBAAgB;wBAC1B,WAAW,EAAE,gCAAgC;wBAC7C,SAAS,EAAE,CAAC,+BAA+B,CAAC;qBAC7C,CAAC;;uCAAA;gBA6CF,0BAAC;YAAD,CAAC,AA5CD,IA4CC;YA5CD,qDA4CC,CAAA"} -------------------------------------------------------------------------------- /tourheroes_ts/app/hero-detail.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input, Output, OnInit, OnDestroy, EventEmitter } from '@angular/core'; 2 | import { Hero } from './hero'; 3 | import { ActivatedRoute } from '@angular/router'; 4 | import { HeroService } from './hero.service'; 5 | 6 | @Component({ 7 | selector: 'my-hero-detail', 8 | templateUrl: 'app/hero-detail.component.html', 9 | styleUrls: ['app/hero-detail.component.css'] 10 | }) 11 | export class HeroDetailComponent implements OnInit, OnDestroy { 12 | 13 | @Input() hero: Hero; 14 | @Output() close = new EventEmitter(); 15 | error: any; 16 | sub: any; 17 | navigated = false; // true if navigated here 18 | 19 | constructor( 20 | private heroService: HeroService, 21 | private route: ActivatedRoute) { 22 | } 23 | 24 | save() { 25 | this.heroService 26 | .save(this.hero) 27 | .then(hero => { 28 | this.hero = hero; // saved hero, w/ id if new 29 | this.goBack(hero); 30 | }) 31 | .catch(error => this.error = error); // TODO: Display error message 32 | } 33 | ngOnInit() { 34 | this.sub = this.route.params.subscribe(params => { 35 | if (params['id'] !== undefined) { 36 | let id = +params['id']; 37 | this.navigated = true; 38 | this.heroService.getHero(id) 39 | .then(hero => this.hero = hero); 40 | } else { 41 | this.navigated = false; 42 | this.hero = new Hero(); 43 | } 44 | }); 45 | } 46 | ngOnDestroy() { 47 | this.sub.unsubscribe(); 48 | } 49 | goBack(savedHero: Hero = null) { 50 | this.close.emit(savedHero); 51 | if (this.navigated) { 52 | window.history.back(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /tourheroes_ts/app/hero.js: -------------------------------------------------------------------------------- 1 | System.register([], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var Hero; 5 | return { 6 | setters:[], 7 | execute: function() { 8 | Hero = (function () { 9 | function Hero() { 10 | } 11 | return Hero; 12 | }()); 13 | exports_1("Hero", Hero); 14 | } 15 | } 16 | }); 17 | //# sourceMappingURL=hero.js.map -------------------------------------------------------------------------------- /tourheroes_ts/app/hero.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"hero.js","sourceRoot":"","sources":["hero.ts"],"names":[],"mappings":";;;;;;;YAAA;gBAAA;gBAGA,CAAC;gBAAD,WAAC;YAAD,CAAC,AAHD,IAGC;YAHD,uBAGC,CAAA"} -------------------------------------------------------------------------------- /tourheroes_ts/app/hero.service.js: -------------------------------------------------------------------------------- 1 | System.register(['@angular/core', '@angular/http', 'rxjs/add/operator/toPromise'], function(exports_1, context_1) { 2 | "use strict"; 3 | var __moduleName = context_1 && context_1.id; 4 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { 5 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 6 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 7 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 8 | return c > 3 && r && Object.defineProperty(target, key, r), r; 9 | }; 10 | var __metadata = (this && this.__metadata) || function (k, v) { 11 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); 12 | }; 13 | var core_1, http_1; 14 | var HeroService; 15 | return { 16 | setters:[ 17 | function (core_1_1) { 18 | core_1 = core_1_1; 19 | }, 20 | function (http_1_1) { 21 | http_1 = http_1_1; 22 | }, 23 | function (_1) {}], 24 | execute: function() { 25 | HeroService = (function () { 26 | function HeroService(http) { 27 | this.http = http; 28 | this.heroesUrl = 'app/heroes'; // URL to web api 29 | console.log('new service'); 30 | } 31 | ; 32 | HeroService.prototype.getHeroes = function () { 33 | return this.http.get(this.heroesUrl) 34 | .toPromise() 35 | .then(function (response) { return response.json().data; }) 36 | .catch(this.handleError); 37 | }; 38 | HeroService.prototype.getHero = function (id) { 39 | return this.getHeroes() 40 | .then(function (heroes) { return heroes.filter(function (hero) { return hero.id === id; })[0]; }); 41 | }; 42 | HeroService.prototype.delete = function (hero) { 43 | var headers = new http_1.Headers(); 44 | headers.append('Content-Type', 'application/json'); 45 | var url = this.heroesUrl + "/" + hero.id; 46 | return this.http 47 | .delete(url, headers) 48 | .toPromise() 49 | .catch(this.handleError); 50 | }; 51 | HeroService.prototype.save = function (hero) { 52 | if (hero.id) { 53 | return this.put(hero); 54 | } 55 | return this.post(hero); 56 | }; 57 | HeroService.prototype.handleError = function (error) { 58 | console.error('An error occurred', error); 59 | return Promise.reject(error.message || error); 60 | }; 61 | HeroService.prototype.post = function (hero) { 62 | var headers = new http_1.Headers({ 63 | 'Content-Type': 'application/json' }); 64 | return this.http 65 | .post(this.heroesUrl, JSON.stringify(hero), { headers: headers }) 66 | .toPromise() 67 | .then(function (res) { return res.json().data; }) 68 | .catch(this.handleError); 69 | }; 70 | HeroService.prototype.put = function (hero) { 71 | var headers = new http_1.Headers(); 72 | headers.append('Content-Type', 'application/json'); 73 | var url = this.heroesUrl + "/" + hero.id; 74 | return this.http 75 | .put(url, JSON.stringify(hero), { headers: headers }) 76 | .toPromise() 77 | .then(function () { return hero; }) 78 | .catch(this.handleError); 79 | }; 80 | HeroService = __decorate([ 81 | core_1.Injectable(), 82 | __metadata('design:paramtypes', [http_1.Http]) 83 | ], HeroService); 84 | return HeroService; 85 | }()); 86 | exports_1("HeroService", HeroService); 87 | } 88 | } 89 | }); 90 | //# sourceMappingURL=hero.service.js.map -------------------------------------------------------------------------------- /tourheroes_ts/app/hero.service.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"hero.service.js","sourceRoot":"","sources":["hero.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;YAMA;gBAEI,qBAAoB,IAAU;oBAAV,SAAI,GAAJ,IAAI,CAAM;oBADtB,cAAS,GAAG,YAAY,CAAC,CAAE,iBAAiB;oBAEhD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAC/B,CAAC;;gBACD,+BAAS,GAAT;oBACI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;yBACxB,SAAS,EAAE;yBACX,IAAI,CAAC,UAAA,QAAQ,IAAI,OAAA,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAApB,CAAoB,CAAC;yBACtC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACxC,CAAC;gBACD,6BAAO,GAAP,UAAQ,EAAU;oBACd,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE;yBACX,IAAI,CAAC,UAAA,MAAM,IAAI,OAAA,MAAM,CAAC,MAAM,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,EAAE,KAAK,EAAE,EAAd,CAAc,CAAC,CAAC,CAAC,CAAC,EAAxC,CAAwC,CAAC,CAAC;gBACzE,CAAC;gBACD,4BAAM,GAAN,UAAO,IAAU;oBACf,IAAI,OAAO,GAAG,IAAI,cAAO,EAAE,CAAC;oBAC5B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;oBAEnD,IAAI,GAAG,GAAM,IAAI,CAAC,SAAS,SAAI,IAAI,CAAC,EAAI,CAAC;oBAEzC,MAAM,CAAC,IAAI,CAAC,IAAI;yBACJ,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC;yBACpB,SAAS,EAAE;yBACX,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACtC,CAAC;gBACD,0BAAI,GAAJ,UAAK,IAAU;oBACb,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;wBACZ,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;oBACxB,CAAC;oBACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACzB,CAAC;gBACO,iCAAW,GAAnB,UAAoB,KAAU;oBAC1B,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC;oBAC1C,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;gBAClD,CAAC;gBACO,0BAAI,GAAZ,UAAa,IAAU;oBACrB,IAAI,OAAO,GAAG,IAAI,cAAO,CAAC;wBACxB,cAAc,EAAE,kBAAkB,EAAC,CAAC,CAAC;oBAEvC,MAAM,CAAC,IAAI,CAAC,IAAI;yBACJ,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC;yBAC9D,SAAS,EAAE;yBACX,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAf,CAAe,CAAC;yBAC5B,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACtC,CAAC;gBAEO,yBAAG,GAAX,UAAY,IAAU;oBACpB,IAAI,OAAO,GAAG,IAAI,cAAO,EAAE,CAAC;oBAC5B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;oBAEnD,IAAI,GAAG,GAAM,IAAI,CAAC,SAAS,SAAI,IAAI,CAAC,EAAI,CAAC;oBAEzC,MAAM,CAAC,IAAI,CAAC,IAAI;yBACJ,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,EAAC,OAAO,EAAE,OAAO,EAAC,CAAC;yBAClD,SAAS,EAAE;yBACX,IAAI,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;yBAChB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACtC,CAAC;gBA3DL;oBAAC,iBAAU,EAAE;;+BAAA;gBA4Db,kBAAC;YAAD,CAAC,AA3DD,IA2DC;YA3DD,qCA2DC,CAAA"} -------------------------------------------------------------------------------- /tourheroes_ts/app/hero.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Hero } from './hero'; 3 | import { Headers, Http } from '@angular/http'; 4 | import 'rxjs/add/operator/toPromise'; 5 | 6 | @Injectable() 7 | export class HeroService { 8 | private heroesUrl = 'app/heroes'; // URL to web api 9 | constructor(private http: Http) { 10 | console.log('new service'); 11 | }; 12 | getHeroes(): Promise { 13 | return this.http.get(this.heroesUrl) 14 | .toPromise() 15 | .then(response => response.json().data) 16 | .catch(this.handleError); 17 | } 18 | getHero(id: number) { 19 | return this.getHeroes() 20 | .then(heroes => heroes.filter(hero => hero.id === id)[0]); 21 | } 22 | delete(hero: Hero) { 23 | let headers = new Headers(); 24 | headers.append('Content-Type', 'application/json'); 25 | 26 | let url = `${this.heroesUrl}/${hero.id}`; 27 | 28 | return this.http 29 | .delete(url, headers) 30 | .toPromise() 31 | .catch(this.handleError); 32 | } 33 | save(hero: Hero): Promise { 34 | if (hero.id) { 35 | return this.put(hero); 36 | } 37 | return this.post(hero); 38 | } 39 | private handleError(error: any) { 40 | console.error('An error occurred', error); 41 | return Promise.reject(error.message || error); 42 | } 43 | private post(hero: Hero): Promise { // add new hero 44 | let headers = new Headers({ 45 | 'Content-Type': 'application/json'}); 46 | 47 | return this.http 48 | .post(this.heroesUrl, JSON.stringify(hero), {headers: headers}) 49 | .toPromise() 50 | .then(res => res.json().data) 51 | .catch(this.handleError); 52 | } 53 | 54 | private put(hero: Hero) { // Update existing Hero 55 | let headers = new Headers(); 56 | headers.append('Content-Type', 'application/json'); 57 | 58 | let url = `${this.heroesUrl}/${hero.id}`; 59 | 60 | return this.http 61 | .put(url, JSON.stringify(hero), {headers: headers}) 62 | .toPromise() 63 | .then(() => hero) 64 | .catch(this.handleError); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /tourheroes_ts/app/hero.ts: -------------------------------------------------------------------------------- 1 | export class Hero { 2 | id: number; 3 | name: string; 4 | } 5 | -------------------------------------------------------------------------------- /tourheroes_ts/app/heroes: -------------------------------------------------------------------------------- 1 | {"data": [ 2 | { 3 | "id": 11, 4 | "name": "Mr. Nice" 5 | }, 6 | { 7 | "id": 12, 8 | "name": "Narco" 9 | }, 10 | { 11 | "id": 13, 12 | "name": "Bombasto" 13 | }, 14 | { 15 | "id": 14, 16 | "name": "Celeritas" 17 | }, 18 | { 19 | "id": 15, 20 | "name": "Magneta" 21 | }, 22 | { 23 | "id": 16, 24 | "name": "RubberMan" 25 | }, 26 | { 27 | "id": 17, 28 | "name": "Dynama" 29 | }, 30 | { 31 | "id": 18, 32 | "name": "Dr IQ" 33 | }, 34 | { 35 | "id": 19, 36 | "name": "Magma" 37 | }, 38 | { 39 | "id": 20, 40 | "name": "Tornado" 41 | } 42 | ]} -------------------------------------------------------------------------------- /tourheroes_ts/app/heroes.component.css: -------------------------------------------------------------------------------- 1 | .selected { 2 | background-color: #CFD8DC !important; 3 | color: white; 4 | } 5 | .heroes { 6 | margin: 0 0 2em 0; 7 | list-style-type: none; 8 | padding: 0; 9 | width: 15em; 10 | } 11 | .heroes li { 12 | cursor: pointer; 13 | position: relative; 14 | left: 0; 15 | background-color: #EEE; 16 | margin: .5em; 17 | padding: .3em 0; 18 | height: 1.6em; 19 | border-radius: 4px; 20 | } 21 | .heroes li.selected:hover { 22 | background-color: #BBD8DC !important; 23 | color: white; 24 | } 25 | .heroes li:hover { 26 | color: #607D8B; 27 | background-color: #DDD; 28 | left: .1em; 29 | } 30 | .heroes .text { 31 | position: relative; 32 | top: -3px; 33 | } 34 | .heroes .badge { 35 | display: inline-block; 36 | font-size: small; 37 | color: white; 38 | padding: 0.8em 0.7em 0 0.7em; 39 | background-color: #607D8B; 40 | line-height: 1em; 41 | position: relative; 42 | left: -1px; 43 | top: -4px; 44 | height: 1.8em; 45 | margin-right: .8em; 46 | border-radius: 4px 0 0 4px; 47 | } 48 | -------------------------------------------------------------------------------- /tourheroes_ts/app/heroes.component.html: -------------------------------------------------------------------------------- 1 |

My Heroes

2 |
    3 |
  • 4 | 5 | {{hero.id}} {{hero.name}} 6 | 7 | 8 |
  • 9 |
10 |
{{error}}
11 | 12 |
13 | 14 |
15 |
16 |

17 | {{selectedHero.name | uppercase}} is my hero 18 |

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