Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
ãã®promiseãªãã¸ã§ã¯ãã¯ãresolveããã®ã§ã.then ã®ç¬¬ä¸å¼æ°ã§æå®ããonFulfilled ã³ã¼ã«ããã¯ã« true ã¨ããå¤ã渡ãããã«ãªã£ã¦ã¾ãã ä»ã¾ã§ã®ãã¹ãã®æ¸ãæ¹ ãã®getSuccessPromiseã 1.18.0ãã以åã¯ä»¥ä¸ã®ããã«æ¸ããã¨ã§ãã¹ãããã¦ãã¾ããã it("should manually handling test...", function (done) { getSuccessPromise().then(function (value) { assert(value); done(); }).catch(done); // <= ãã®catchãä»åã®å¤æ´ã§ã®ç¦ç¹ }); getSuccessPromise()ã®è¿ãå¤ã§ããpromiseãªãã¸ã§ã¯ããresolveããã㨠value ã« true ãå ¥ã£ã¦ assert(t
Node.js ã®ã³ã¢ã« util.promisify ã追å ãããã github.com ä»å㯠util.promisify ãæã¤å½¹å²ãä¸å¿ã« Node.js ã«ããã Promise ã®ç«å ´ã«ã¤ãã¦ã話ãã¦ãããã¨ããã¨æãã util.promisify ã¨ã¯ èªãã§åã®ãã¨ãé¢æ°ã Promise ã«å¤æãã¦ãããã¦ã¼ãã£ãªãã£ã¡ã½ããã ä¸è¨ã®ãããªè¦é ã§å¤æã§ããã const util = require('util'); const fs = require('fs'); const stat = util.promisify(fs.stat); stat('.').then((stats) => { console.log(stats); }).catch((error) => { console.error(error); }); async-awaitã使ããã
æè¿èªåã§éåæåæã®ãã©ã°ã¤ã³æ¸ãã¨ãã¯Thenableãªæãã§æ¸ãã¦ããã¨ãå¤ãã Thenableã£ã¦ã®ã¯ã©ããããã¨ãã¨ããã¨ãtypescirptã®es6-promises ã§ã¯æ¬¡ã®ããã«å®ç¾©ãã¦ããã interface Thenable<R> { then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>; then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>; then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenab
ãã¦ã Node.js ã®ã¨ã©ã¼ãã³ããªã³ã°ã¯é£ããã¨è¨ããã¦ã¾ããã 2016å¹´ç¾å¨ãã¤ã¾ãNodeã® v4 ã¨ã v6 ã主æµã«ãªãã Promise ãåºæ¬çãªå¦çã¨ãã¦æ¡ç¨ããã¦ããç¶æ³ã§ã¯ã©ãã§ãããããã¡ãã£ã¨èãã¦ã¿ã¾ãã ä¸å¿ããã®è£è¶³ã§ãã qiita.com TL;DR æªã ã«é£ããããã ãã Promise ã§æ¹åããã¦ãããasync-await ã zone ã¾ã§æ¥ããããªã楽ã«ãªãã ãã¨ã unhandledRejection ã uncaughtException ãããé ·ããã¨ã«ãªããªãã®ã§ã大åãã·ã«ãªã£ã¦ããã Node.js ã®ã¨ã©ã¼ãã³ããªã³ã°ã®é£ãã ã¾ã JavaScript ã«ã¯åæã¨éåæã®ã¨ã©ã¼ãã³ããªã³ã°ã®ããæ¹ãããã¾ããåè ã¯æè¬ try-catch ã«ããæ¹æ³ãå¾è 㯠callback ã使ã£ã¦ç¬¬ä¸å¼æ°ã§å®ç¾ããæ¹æ³ã emit(
Promise Cancellation Is Dead â Long Live Promise Cancellation! Not very long ago Domenic Denicola (worth a follow, a very smart guy) withdrew his proposal for promise cancellation from the TC39. A lot of people might think that means that promise cancellation isnât coming to JavaScript. Those people would be right, if you couldnât already cancel a promise via very similar means to what was propose
ç®æ¬¡ 1. ã¯ããã« 2. Promiseã®æ¦å¿µãç解ãã å¹éï¼è¡åãå«ããªå¥³ã®å 2.1 Promiseã¨ã¯ä½ãï¼ å¹éï¼å®è¡é åº 2.2 Promiseã¨ä¸¦è¡å¦ç å¹éï¼å¼ã®æ½è±¡å 3. Promiseã®ãããããç解ãã 3.1. Promiseã§å¼ãé åºä»ããã 3.2. æå°éã®Promiseå®è¡ 4.Promiseã¨ã¨ã©ã¼å¦ç å¹éï¼è¨ç®å¤±æã®å ´å 4.1. ã¨ã©ã¼ãPromiseã§å¦çãã 4.2. Promiseã®å¤±æã®ä¼æ 5. Promiseã®çµå 5.1. Promiseã確å®çã«çµåãã 5.2. Promiseãé確å®çã«çµåãã 6. Promiseã®å®ç¨çãªç解 6.1. ECMAScript Promiseã®å°å ¥ 6.2. .then ã®åæ 7. Promiseã¨ã¯ç¸æ§ãæªãã±ã¼ã¹ã¨ã¯ï¼ 8. ã¾ã¨ã åèæç® è¿½å è³æ è³æã¨ã©ã¤ãã©ãª 1. ã¯ããã«
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}