You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/11-async/05-promise-api/article.md
+3-17Lines changed: 3 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -193,11 +193,7 @@ if(!Promise.allSettled) {
193
193
194
194
في هذا الرمز ، يأخذ `promises.map` قيم الإدخال ، ويحولها إلى وعود (فقط في حالة تمرير عدم الوعد) مع` p => Promise.resolve (p) `، ثم يضيف معالج` .then` إلى كل واحد.
195
195
196
-
<<<<<<< HEAD
197
-
يحول هذا المعالج نتيجة "القيمة" الناجحة إلى "{state:" الوفاء "و value}` والخطأ "reason" إلى "{state: "رفض"، reason} `. هذا هو بالضبط تنسيق `Promise.allSettled`.
198
-
=======
199
-
That handler turns a successful result `value` into `{status:'fulfilled', value}`, and an error `reason` into `{status:'rejected', reason}`. That's exactly the format of `Promise.allSettled`.
200
-
>>>>>>> e4e6a50b5762dd5dc4c0f0c58f870c64be39dcfa
196
+
يحول هذا المعالج نتيجة `القيمة` الناجحة إلى `{status:'fulfilled', value}` والخطأ `reason` إلى `{status:'rejected', reason}`. هذا هو بالضبط تنسيق `Promise.allSettled`.
201
197
202
198
الآن يمكننا استخدام "Promise.allSettled" للحصول على نتائج * جميع * الوعود المعطاة ، حتى لو رفض بعضها.
203
199
@@ -281,22 +277,12 @@ let promise = new Promise((resolve, reject) => reject(error));
281
277
282
278
هناك 5 طرق ثابتة لفئة `Promise`:
283
279
284
-
<<<<<<< HEAD
285
280
1. "Promise.all (الوعود)" - تنتظر جميع الوعود لحل وإرجاع مجموعة من نتائجها. إذا تم رفض أي من الوعود المعطاة ، يصبح خطأ "Promise.all" ، ويتم تجاهل جميع النتائج الأخرى.
286
281
2. "Promise.allSettled (الوعود)" (الطريقة المضافة حديثًا) - تنتظر جميع الوعود بتسوية نتائجها وإعادتها كمجموعة من الأشياء مع:
4. "Promise.resolve (القيمة)" - يقدم وعدًا ثابتًا بقيمة معينة.
291
286
5. "Promise.reject (خطأ)" - يقدم وعدًا مرفوضًا مع الخطأ المحدد.
292
-
=======
293
-
1. `Promise.all(promises)` -- waits for all promises to resolve and returns an array of their results. If any of the given promises rejects, it becomes the error of `Promise.all`, and all other results are ignored.
294
-
2. `Promise.allSettled(promises)` (recently added method) -- waits for all promises to settle and returns their results as an array of objects with:
295
-
- `status`: `"fulfilled"` or `"rejected"`
296
-
- `value` (if fulfilled) or `reason` (if rejected).
297
-
3. `Promise.race(promises)` -- waits for the first promise to settle, and its result/error becomes the outcome.
298
-
4. `Promise.resolve(value)` -- makes a resolved promise with the given value.
299
-
5. `Promise.reject(error)` -- makes a rejected promise with the given error.
300
-
>>>>>>> e4e6a50b5762dd5dc4c0f0c58f870c64be39dcfa
301
-
302
-
من بين هذه العناصر الخمسة ، يعد "Promise.all" الأكثر شيوعًا في الممارسة.
287
+
288
+
من بين هذه العناصر الخمسة ، يعد "Promise.all" الأكثر شيوعًا في الممارسة.
0 commit comments