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 f9 = pipe( | |
a => ({ status: a }), | |
a => Promise.reject('reject!'), | |
).exception(e => e && e.status == 10) ( | |
e => console.log('e 10') | |
).error( | |
e => console.log(e) | |
).nullable( | |
e => console.log('nullable~') | |
); |
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 isNagativeNumber = a => a < 0; | |
const f7 = pipe( | |
a => a - 10, | |
a => a + 100 | |
).exception(isNagativeNumber) ( | |
_ => console.log('์ค๊ฐ์ ๋น ์ ธ๋์ด') | |
); | |
console.log( f7(10) ); // 100 |
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 f4 = pipe( | |
a => a + 10, | |
a => asdasd123asdasd, | |
a => a + 100 // <-- ์ค์ง ์์ต๋๋ค. | |
).error(log); // ReferenceError: asdasd123asdasd is not defined | |
log(f4(1)); // undefined ๋ฆฌํด๋๊ณ , error๋ก ๊ฐ์ ์๋ฌ ์ถ๋ ฅ | |
const f5 = pipe( | |
a => a + 10, |
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 f0 = pipe( | |
a => a + 10, // <--- null ์จ ๊ฒฝ์ฐ ์คํ๋์ง ์์ | |
a => a + 100 // <--- null ์จ ๊ฒฝ์ฐ ์คํ๋์ง ์์ | |
).nullable(); | |
console.log( f0(1) ); // 111 | |
console.log( f0(null) ); // null | |
const f1 = pipe( | |
a => a + 10, // <--- null ์จ ๊ฒฝ์ฐ ์คํ๋์ง ์์ |
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
// ๋์์ users์ posts ์ถ๋ฐ | |
const res1 = awiat concurrency({ | |
users: _=> query(...), | |
posts: _=> query(...) | |
}); | |
//{ | |
// users: [row, row, row, ...] | |
// posts: [row, row, row, ...] | |
//} |
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
some(pipe(get, isBlah), [{ ... }, { ... }, { ... }]); | |
// - ํ๋์ฉ ์๋ | |
// - ๋ง์ผ ์ฒซ ๋ฒ์งธ์์ ์ฐธ์ ๋ง๋ค๋ฉด ๋ค์ 2๊ฐ๋ ๋๋น ์์ฒญ์ ํ์ง ์์ | |
someC(pipe(get, isBlah), [{ ... }, { ... }, { ... }]); | |
// - ๋์์ 3๊ฐ ๋ชจ๋ ๋๋น ์์ฒญ | |
// - ๋จผ์ ์จ ๊ฒฐ๊ณผ๋ฅผ ํตํด ์ฐธ์ ๋ง๋ค๋ฉด ๋๋จธ์ง ๊ฒฐ๊ณผ๋ฅผ ๋ ๊ธฐ๋ค๋ฆฌ์ง ์๊ณ ๋ค์์ผ๋ก ๋์ด๊ฐ |
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
go([0, 0, 3000, 5000, 6000, 1000, 5000], | |
someC(a => new Promise(function (resolve) { | |
setTimeout(function() { resolve(a); }, a); | |
})), | |
b => console.log(b, '<----------- 1์ด ๋ค')); | |
// true <----------- 1์ด ๋ค | |
// - ๋ชจ๋ ๊ฐ์ ํด๋นํ๋ ํจ์ ํ๊ฐ | |
// - 1000์ด ๊ฐ์ฅ ๋จผ์ ๊ฒฐ๊ณผ๋ฅผ ๋ง๋ค์ด์ 1์ด ๋ค ๊ฒฐ๊ณผ๋ฅผ ์ฆ์ ๋ฆฌํดํ๊ณ , ๋๋จธ์ง๋ ๊ธฐ๋ค๋ฆฌ์ง ์์ |
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
go([0, 0, 3000, 5000, 6000, 1000, 5000], | |
some(a => new Promise(function (resolve) { | |
setTimeout(function() { resolve(a); }, a); | |
})), | |
b => console.log(b, '<---------- 3์ด ์ ๋ ๋ค')); | |
// true <------ 3์ด ์ ๋ ๋ค | |
// - 0, 0, 3000์ ํด๋นํ๋ ํจ์๋ง ํ๊ฐ |
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
(async function() { | |
const list = [1, 2, 3, 4]; | |
const result = await map(async function(val) { | |
return await add2(val); | |
}, list); | |
console.log(result, 'async/await 3'); | |
// [3, 4, 5, 6] async/await 3 | |
}) (); |
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
(async function() { | |
const list = [1, 2, 3, 4]; | |
const result = await list.map(async function(val) { | |
return await add2(val); | |
}); | |
console.log(result, 'async/await 2'); | |
// [Promise, Promise, Promise, Promise] async/await 2 | |
}) (); |