In this article, I would like to share final features in ECMAScript by the awsome article.
π― Asynchronous Iteration
- Detail Description
- Outline
- Support data that is delivered asynchronously
- Use case
- Lines of text, read asynchronously from a file or an HTTP connection
Sample code:
If you want to call asynchronously API multiple time, you could execute in parallel using Promise.all
and execute as follows:
(async() => { |
But if you use a lot of API, it is difficult to manage the code. You could rewrite this by using Asynchronous Iteration:
(async() => { |
π Rest/Spread Properties
- Detail
- Outline
- The rest operator
...
in object destructuring - The spread operator (β¦) in object literals
- The rest operator
// Rest Properties |
π RegExp: named capture groups
It is about identifying capture groups via name in RegExp:
const RE_DATE = /(? |
π RegExp: Unicode property escapes
In the Unicode standard, each character has properties - metadata descripbing it.
We can use the Unicode properties in JavaScript RegExp:
const re = /^\p{General_Category=Decimal_Number}+$/u; |
π RegExp: lookbehind assetions
(?<= ...)< code> indicates lookbehind assetions:=>
// Before ES2018 |
π RegExp: s (dotAll) flag for regular expressions
If you add flag /s
to a regular expression, .
matches line terminator character:
/^.$/s.test('\n') |
π Promise.prototype.finally()
Promise.prototype.finally()
works as follows:
promise |
finally()
callbac is always executed. Compare:
then()
callback is only executed if promise if fulfilledcathc()
callback is only executed:- If promise is rejected
- If thenβs callback throws an exception
- returns a rejected Promise.
π³ Special Thanks
- https://qiita.com/shisama/items/f7029822a5848592cbc2#async-iteration
- https://qiita.com/nabepon/items/b59e959809060158be8b
- https://qiita.com/uhyo/items/13e8bd7e616f83a463e5
π₯ Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!