
연속적인 async 함수의 호출을 함수형으로 처리하기 위해 async한 pipe 함수를 다음과 같이 구현할 수 있다. (async function main() { const results = await pipeAsync( getTargetAsync, pickAlias, getInfoAsync, getFriendsAsync )("injuk"); console.log(results); /* 실행 결과 [ { id: '222', name: 'two', bf: 'ingnoh' }, { id: '333', name: 'three', bf: 'ingnoh' }, { id: '444', name: 'four', bf: 'ingnoh' } ] */ })(); function pipeAsync(...asyncFun) {..
JS를 사용하다보면 함수 내부에서 this 참조가 원하지 않는 객체를 참조하거나 아예 유실되어버리는는 경우가 종종 발생한다. 이러한 경우에 사용할 수 있도록 JS에서는 Function.prototype의 call, apply, bind를 제공하고있으며, 세 메소드는 모두 함수에 this 참조를 연결한다는 공통점을 갖지만 사용법 측면에서 다음과 같은 소소한 차이가 있다. Function.prototype.call: 함수 내부에서 참조할 this와 매개 변수 목록을 하나씩 나열하여 전달하는 식으로 함수를 호출한다. Function.prototype.apply: 함수 내부에서 참조할 this와 매개 변수 목록을 배열로 전달하는 식으로 함수를 호출한다. Function.prototype.bind: 함수 내부에서..
환경 | MacBook Pro(2019), Ventura 13.0 Rust를 처음 배울 때, rustc 를 활용한 Hello World 애플리케이션의 컴파일이 다음과 같이 실패할 수 있다. error: linking with `cc` failed: exit status: 1 | = note: "cc" "-arch" "x86_64" "-m64" ... 중략 ... = note: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun error: aborting due to previous err..
백만년만에 Vault를 사용하다보니, 로컬에 저장된 버전이 최신 버전인 1.12에 비해 1.8.4로 너무 낮았다. 업그레이드 방법을 한참 찾았는데, 알고보니 그냥 인스톨하면 되는거였다... [~] brew tap hashicorp/tap [~] brew install hashicorp/tap/vault [~] vault -v Vault v1.12.0, built 2022-10-10T18:14:33Z 참고 Install | Vault | HashiCorp Developer Explore Vault product documentation, tutorials, and examples. developer.hashicorp.com
다음과 같이 getter에 async 키워드를 작성할 경우에는 Syntax Error가 발생한다. SyntaxError: Unexpected identifier class MyClass { #props = { hello: 'world' }; async get result() { // SyntaxError: Unexpected identifier return this.#props; } } (async function main() { const myInstance = new MyClass(); const result = await myInstance.result; console.log(result); })(); 이 경우, 그냥 Promise를 반환하면 간단하게 async getter를 구현할 수 있다. cl..

일반적으로 falsy한 값의 체크는 다음과 같이 확인한다. function isFalsy(value) { return !value ? true : false; } console.log(isFalsy(undefined)); // true console.log(isFalsy(null)); // true console.log(isFalsy(0)); // true console.log(isFalsy('')); // true console.log(isFalsy([])); // false console.log(isFalsy({})); // false /* 요런 특징을 이용해서 if(value) 또는 if(!value)로 활용하곤 한다. */ 그러나 0과 빈 문자열은 검증하지 않고, 오로지 null 또는 undefi..
String.prototype.localeCompare()를 배열의 sort()와 함께 사용하여 다음과 같이 코드를 작성할 수 있다. String.prototype.localeCompare() - JavaScript | MDN The localeCompare() method returns a number indicating whether a reference string comes before, or after, or is the same as the given string in sort order. developer.mozilla.org const arr = [ { name: 'folder_1' }, { name: 'folder_2' }, { name: 'folder_3' }, { name: 'fold..
- Total
- Today
- Yesterday
- mysql
- JEST
- jQuery
- etc
- Puppeteer
- Spring Cloud Config
- Database
- Java
- hashicorp
- postgresql
- kotlin
- eureka
- Node.js
- react
- Git
- 코딩테스트
- pgloader
- Vault
- RancherDesktop
- AWS IoT
- javascript
- JPA
- Linux
- IntelliJ
- AWS
- spring boot
- shell
- terraform
- Gradle
- Docker
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 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 |