This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| MicrosoftのTranslator APIを使ってText-to-Textの翻訳をするサンプル。 | |
| https://www.microsoft.com/en-us/translator | |
| es2015形式でJSにトランスパイルした後、babel-nodeで実行すると簡単です。 | |
| Dependencies: request, xml2js, babel-polyfill | |
| */ | |
| import 'babel-polyfill'; // async/awaitを書くなら必要。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {BaseException} from '@angular/core'; | |
| import {getTestInjector} from '@angular/core/testing'; | |
| declare var Zone: any; | |
| let _FakeAsyncTestZoneSpecType = (Zone as any /** TODO #9100 */)['FakeAsyncTestZoneSpec']; | |
| /** | |
| * Wraps a function to be executed in the fakeAsync zone: | |
| * - microtasks are manually executed by calling `flushMicrotasks()`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function asyncPower(asyncFunction: () => Promise<void>): Function { | |
| return function (done) { | |
| asyncFunction() | |
| .then(() => done()) | |
| .catch(e => done.fail(e.message)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Copy *.ts and *.d.ts files from ./jspm_packages/npm/ to ./node_modules/@types/ | |
| This tool is for TypeScript 2.0. | |
| */ | |
| const lodash = require('lodash'); | |
| const fs = require('fs-extra'); | |
| const path = require('path'); | |
| const root = path.resolve(); | |
| require('./jspm_packages/system.src'); // SystemJS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| System.config({ | |
| // baseURL: '/', // あるとないとでどう変わるかよくわからない。 | |
| // defaultJSExtensions: true, // 拡張子.jsを省略する。 | |
| transpiler: false, // on the flyでトランスパイルするときに設定する。 | |
| paths: { | |
| '*': 'node_modules/*', // import {...} from 'hoge' と書くと node_modules/hoge を参照するようになる。 | |
| 'root:*': '/*', | |
| }, | |
| packageConfigPaths: [ // package.jsonのmainプロパティがあればjsファイルを自動で参照する。 | |
| '*/package.json', // ./node_modules/*/package.json と書くのと同じ。lodash等のマッピングに使われる。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Hapi = require('hapi'); | |
| const Inert = require('inert'); | |
| const Vision = require('vision'); | |
| const Joi = require('joi'); | |
| const HapiSwagger = require('hapi-swagger'); | |
| const Pack = require('./package.json'); | |
| const server = new Hapi.Server(); | |
| server.connection({ | |
| host: 'localhost', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import chokidar from 'chokidar'; // @types/chokidar | |
| import parse from 'csv-parse'; // @types/csv-parse | |
| import fs from 'fs'; // @types/node | |
| chokidar.watch('S:/chokidar', { ignored: /[\/\\]\./ }).on('all', (event: string, path: string) => { | |
| if (event === 'add' || event === 'change') { | |
| if (new RegExp(/\.(csv|txt)$/).test(path)) { | |
| console.log(event, path); | |
| fs.readFile(path, 'utf8', (err, data: string) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'babel-polyfill'; | |
| import 'zone.js/dist/zone-node'; | |
| declare const Zone: any; | |
| Zone.current.fork({}).run(async () => { | |
| // (async () => { | |
| const obj = { | |
| increment: Promise.resolve({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'core-js'; | |
| import { Observable, Subject, BehaviorSubject } from 'rxjs'; | |
| type Action = { | |
| key: string; | |
| value: any; | |
| } | |
| type State = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require('setimmediate') | |
| const asap = require('asap') as (func: Function) => void | |
| const cloneDeep = require('lodash.clonedeep') as <T>(obj: T) => T | |
| import { createStore, applyMiddleware, Store } from 'redux' | |
| import { Observable } from 'rxjs/Observable' | |
| import { Subject } from 'rxjs/Subject' | |
| import { BehaviorSubject } from 'rxjs/BehaviorSubject' | |
| import 'rxjs/add/observable/of' | |
| import 'rxjs/add/observable/from' |