Programming/openGL2020. 4. 3. 23:21

예전에 줄을 그어가면서 열심히 읽었구나...

그런데 놓친게 왜이리 많았지? 그래서 이해를 못했던 건가? 이런 생각이 많이 드네

 

아무튼 다시 공부 시작해보자.. 틈틈히

Posted by 구차니
Programming/node.js2020. 2. 1. 18:29

숫자라고 숫자로 인식하는게 아니라서 정렬 순서가 엉망으로 보일수 있음

그렇기에 숫자라면 sort() 함수에 sort용 함수를 넣어주어야 한다.

 

[링크 : http://dudmy.net/javascript/2015/11/16/javascript-sort/]

'Programming > node.js' 카테고리의 다른 글

웹소켓  (0) 2022.03.25
broadway / jsmpeg  (0) 2020.09.16
node.js postgresql transaction  (0) 2020.01.31
for 에서 async, await  (0) 2020.01.30
es6 전개문구 (...)  (0) 2020.01.29
Posted by 구차니
Programming/node.js2020. 1. 31. 01:20

async와 await를 이용해서 순차적으로 실행하여 트랜잭션을 구현한 예제

[링크 : https://node-postgres.com/features/transactions]

'Programming > node.js' 카테고리의 다른 글

broadway / jsmpeg  (0) 2020.09.16
node.js array.sort() 주의사항  (0) 2020.02.01
for 에서 async, await  (0) 2020.01.30
es6 전개문구 (...)  (0) 2020.01.29
node.js 객체 합치기  (0) 2020.01.29
Posted by 구차니
Programming/node.js2020. 1. 30. 22:25

for문을 돌리는데 비동기로 돌아버려서

그걸 강제로 동기로 돌리는 방법 찾는중

루프를 async - await new Promise()로 하는게 일단 작동하는걸 확인함

(async function loop() {
    for (let i = 0; i < 10; i++) {
        await new Promise(resolve => setTimeout(resolve, Math.random() * 1000));
        console.log(i);
    }
})();

[링크 : https://stackoverflow.com/questions/40328932/javascript-es6-promise-for-loop/40329190]

'Programming > node.js' 카테고리의 다른 글

node.js array.sort() 주의사항  (0) 2020.02.01
node.js postgresql transaction  (0) 2020.01.31
es6 전개문구 (...)  (0) 2020.01.29
node.js 객체 합치기  (0) 2020.01.29
unserscore 라이브러리  (0) 2020.01.29
Posted by 구차니
Programming/node.js2020. 1. 29. 17:45

... 은 es6부터 추가된 문법으로

배열을 풀어서 인자로 만들어 주는 듯

 

function sum(x, y, z) {
  return x + y + z;
}

const numbers = [1, 2, 3];

console.log(sum(...numbers));
// expected output: 6

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Spread_syntax]

[링크 : https://2ality.com/2015/01/es6-set-operations.html]

'Programming > node.js' 카테고리의 다른 글

node.js postgresql transaction  (0) 2020.01.31
for 에서 async, await  (0) 2020.01.30
node.js 객체 합치기  (0) 2020.01.29
unserscore 라이브러리  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
Posted by 구차니
Programming/node.js2020. 1. 29. 17:05

assign()을 쓰면 가능은 한데..

동일 이름일 경우에는 어떻게 해야할까?

 

[링크 : https://4urdev.tistory.com/22]

+

키 이름을 미리 바꾸고 합치면 되려나?

[링크 : https://www.freecodecamp.org/news/30-seconds-of-code-rename-many-object-keys-in-javascript-268f279c7bfa/]

'Programming > node.js' 카테고리의 다른 글

for 에서 async, await  (0) 2020.01.30
es6 전개문구 (...)  (0) 2020.01.29
unserscore 라이브러리  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
node.js promise  (0) 2020.01.20
Posted by 구차니
Programming/node.js2020. 1. 29. 13:29

node.js 에서 사용할수 있는 라이브러리.

객체등을 uniq하게 정렬해줄수 있다는데

정작해보니.. 키에 따라서 정리만 해주는 정도?

 

[링크 : https://ddalpange.github.io/2017/10/10/js-not-duplicated-object-array/]

[링크 : http://underscorejs.org/]

[링크 : https://harrythegreat.tistory.com/entry/언더스코어-정리]

 

+

함수로 정리하는 내용

[링크 : https://gamblecoder.tistory.com/29]

 

'Programming > node.js' 카테고리의 다른 글

es6 전개문구 (...)  (0) 2020.01.29
node.js 객체 합치기  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
node.js promise  (0) 2020.01.20
node.js cookie 관련 함수들  (0) 2020.01.19
Posted by 구차니
Programming/node.js2020. 1. 23. 19:32

array와 set을 통해서 집합 연산을 할 수 있다.

단.. 2개의 집합에 대해서는 용이한데 3개의 집합에 대한 교집합 은 쉽지 않고

객체에 대해서 하려면 이래저래 손이 많이 갈 듯..

 

3개의 집합에 대해서 항목별로 계산하려면

최소 7가지 정보가 필요한데

 

[링크 : https://zetawiki.com/wiki/JavaScript_합집합,_교집합,_차집합,_대칭차]

'Programming > node.js' 카테고리의 다른 글

node.js 객체 합치기  (0) 2020.01.29
unserscore 라이브러리  (0) 2020.01.29
node.js promise  (0) 2020.01.20
node.js cookie 관련 함수들  (0) 2020.01.19
node.js crypto 모듈  (0) 2020.01.19
Posted by 구차니
Programming/node.js2020. 1. 20. 16:10

promise는 비동기 작업을 동기작업으로 바꿀수(?)있는 마법의 키워드 이다.

아래와 같이 new promise를 통해서 만들어 주고

return new promise((resolve, reject) => {

// 비동기 작업

// 비동기 작업의 리턴값 (정상)

   resolve(value);

// 비동기 작업 비정상 종료시 리턴값

   reject(value);

})

 

3개의 비동기 작업이 모두 종료되고 그 값을 이용해 무언가를 하려면

promise.all로 구현을 해주고 값을 하나로 합쳐주면 된다.

Promise.all([worker1, worker2, worker3])

.then([value1, value2, value3]) => {

return ({value1, value2, value3})

 

 

[링크 : https://programmingsummaries.tistory.com/325]

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Promise/all]

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Promise]

 

구조 분해 할당

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment]

'Programming > node.js' 카테고리의 다른 글

unserscore 라이브러리  (0) 2020.01.29
node.js 집합연산  (0) 2020.01.23
node.js cookie 관련 함수들  (0) 2020.01.19
node.js crypto 모듈  (0) 2020.01.19
node.js xpath 그리고 boolean  (0) 2019.12.17
Posted by 구차니
Programming/node.js2020. 1. 19. 17:17

쿠키를 삭제한다. 단 삭제만 하고 어떠한 응답을 주는것이 아니기에

redirection 등을 추가로 해주어야 클라이언트에서 작동을 인식한다.

res.clearCookie(name [, options])
Clears the cookie specified by name. For details about the options object, see res.cookie().

Web browsers and other compliant clients will only clear the cookie if the given options is identical to those given to res.cookie(), excluding expires and maxAge.

res.cookie('name', 'tobi', { path: '/admin' })
res.clearCookie('name', { path: '/admin' })

[링크 : https://expressjs.com/ko/api.html]

[링크 : https://victorydntmd.tistory.com/35]

 

 

아래 블로그의 path는 optional 이기에 굳이 넣어주지 않아도 된다.

app.get('/logout', function(req,res) {
    res.clearCookie(key);
});

 

app.get('/logout', function(req,res) {
    res.clearCookie(key, {path:'/path'});
});

[링크 : https://kwanghyuk.tistory.com/90]

'Programming > node.js' 카테고리의 다른 글

node.js 집합연산  (0) 2020.01.23
node.js promise  (0) 2020.01.20
node.js crypto 모듈  (0) 2020.01.19
node.js xpath 그리고 boolean  (0) 2019.12.17
node.js JWT with refresh token  (0) 2019.12.10
Posted by 구차니