@quenty/promise 10.5.0 → 10.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [10.6.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.5.0...@quenty/promise@10.6.0) (2024-10-04)
7
+
8
+
9
+ ### Performance Improvements
10
+
11
+ * Use coroutine.running() for promise yielding ([658de34](https://github.com/Quenty/NevermoreEngine/commit/658de34e1bff418a5076065c07f7ddb4300db514))
12
+
13
+
14
+
15
+
16
+
6
17
  # [10.5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/promise@10.4.0...@quenty/promise@10.5.0) (2024-09-25)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/promise
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/promise",
3
- "version": "10.5.0",
3
+ "version": "10.6.0",
4
4
  "description": "Promise implementation for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,11 +26,11 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "@quenty/deferred": "^2.2.0",
29
- "@quenty/loader": "^10.5.0",
30
- "@quenty/maid": "^3.3.0"
29
+ "@quenty/loader": "^10.6.0",
30
+ "@quenty/maid": "^3.4.0"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "41715b15e2b48b2d22ff4f5277a8d4b7a0d32ef3"
35
+ "gitHead": "035abfa088c854a73e1c65b350267eaa17669646"
36
36
  }
@@ -182,16 +182,15 @@ function Promise:Wait()
182
182
  elseif self._rejected then
183
183
  return error(tostring(self._rejected[1]), 2)
184
184
  else
185
- local bindable = Instance.new("BindableEvent")
185
+ local waitingCoroutine = coroutine.running()
186
186
 
187
187
  self:Then(function()
188
- bindable:Fire()
188
+ task.spawn(waitingCoroutine)
189
189
  end, function()
190
- bindable:Fire()
190
+ task.spawn(waitingCoroutine)
191
191
  end)
192
192
 
193
- bindable.Event:Wait()
194
- bindable:Destroy()
193
+ coroutine.yield()
195
194
 
196
195
  if self._rejected then
197
196
  return error(tostring(self._rejected[1]), 2)
@@ -215,21 +214,22 @@ function Promise:Yield()
215
214
  elseif self._rejected then
216
215
  return false, unpack(self._rejected, 1, self._valuesLength)
217
216
  else
218
- local bindable = Instance.new("BindableEvent")
217
+ local waitingCoroutine = coroutine.running()
219
218
 
220
219
  self:Then(function()
221
- bindable:Fire()
220
+ task.spawn(waitingCoroutine)
222
221
  end, function()
223
- bindable:Fire()
222
+ task.spawn(waitingCoroutine)
224
223
  end)
225
224
 
226
- bindable.Event:Wait()
227
- bindable:Destroy()
225
+ coroutine.yield()
228
226
 
229
227
  if self._fulfilled then
230
228
  return true, unpack(self._fulfilled, 1, self._valuesLength)
231
229
  elseif self._rejected then
232
230
  return false, unpack(self._rejected, 1, self._valuesLength)
231
+ else
232
+ error("Bad state")
233
233
  end
234
234
  end
235
235
  end