- Permission 문제 해결:
- System Node 로 설치되있으면:
npm install -g typescript했을 때 permission 에러 (sudo 써야)- 해결 하려면 (sudo 안쓰려면): /usr/local/??? 등의 폴더들에게 permission 줘야
- 사용자가 늘면 group permission 도 하고
- ... 으아!
- System Node 로 설치되있으면:
- NVM 으로 node 설치하면
| async function withErrorHandler( | |
| run: () => Promise<HTTPResponseType>, | |
| options?: { | |
| }, | |
| ) { | |
| try { | |
| return run(); | |
| } catch (e) { | |
| // handle error here. |
| { | |
| "extends": "tslint-microsoft-contrib", | |
| "rules": { | |
| "completed-docs": false, | |
| "trailing-comma": [ | |
| true, | |
| { | |
| "multiline": "always", | |
| "singleline": { | |
| "functions": "ignore", |
| function* generateRandomNumber() { | |
| let count = 1; | |
| // tslint:disable | |
| while (true) { | |
| count++; | |
| console.log(count); | |
| yield Math.random(); | |
| } | |
| } |
| // yarn add ramda @types-ramda | |
| import { | |
| curry, | |
| } from 'ramda'; | |
| function test(a: string, b: number, c: boolean) { | |
| // ... | |
| } | |
| const curried1 = curry(test); |
| // temporary fix for any 3rd party lib. without TS definition | |
| declare module 'any-module' { | |
| const a: any | { | |
| default: any | |
| }; | |
| export = a; | |
| } |
| new Promise((resolve, reject) => reject(1)) | |
| .catch((result) => { | |
| console.log(result); | |
| return new Promise((resolve, reject) => resolve(2)) | |
| }) | |
| .then((result) => console.log(result)) | |
| // result: 1, 2 |
| // NOT MINE - FROM SOMEONE @ INTERNET | |
| // same as scala's stripMargin | |
| export function stripMargin(template: TemplateStringsArray, ...expressions: any[]) { | |
| let result = template.reduce((accumulator, part, i) => { | |
| return accumulator + expressions[i - 1] + part | |
| }) | |
| return result.replace(/\r?(\n)\s*\|/g, '$1'); | |
| } |