@byloth/core 2.0.1 → 2.0.2
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/README.md +1 -0
- package/dist/core.js +18 -8
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +1 -1
- package/dist/core.umd.cjs.map +1 -1
- package/package.json +10 -8
- package/src/core/types.ts +43 -10
- package/src/index.ts +3 -2
- package/src/models/aggregators/aggregated-async-iterator.ts +5 -0
- package/src/models/aggregators/aggregated-iterator.ts +5 -0
- package/src/models/aggregators/reduced-iterator.ts +18 -5
- package/src/models/aggregators/types.ts +35 -0
- package/src/models/callbacks/callable-object.ts +7 -0
- package/src/models/callbacks/publisher.ts +12 -8
- package/src/models/callbacks/switchable-callback.ts +9 -1
- package/src/models/callbacks/types.ts +32 -0
- package/src/models/exceptions/core.ts +9 -0
- package/src/models/exceptions/index.ts +40 -1
- package/src/models/iterators/smart-async-iterator.ts +5 -0
- package/src/models/iterators/smart-iterator.ts +5 -0
- package/src/models/iterators/types.ts +79 -1
- package/src/models/json/json-storage.ts +3 -0
- package/src/models/json/types.ts +1 -1
- package/src/models/promises/deferred-promise.ts +5 -0
- package/src/models/promises/smart-promise.ts +5 -0
- package/src/models/promises/timed-promise.ts +5 -0
- package/src/models/promises/types.ts +30 -0
- package/src/models/timers/clock.ts +3 -0
- package/src/models/timers/countdown.ts +5 -0
- package/src/models/timers/game-loop.ts +3 -0
- package/src/models/types.ts +1 -1
- package/src/utils/async.ts +15 -0
- package/src/utils/curve.ts +1 -1
- package/src/utils/date.ts +36 -6
- package/src/utils/dom.ts +5 -0
- package/src/utils/iterator.ts +40 -0
- package/src/utils/math.ts +15 -0
- package/src/utils/random.ts +4 -0
- package/src/utils/string.ts +5 -0
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/Byloth/core/actions/workflows/release-npm.yml)
|
|
4
4
|
[](https://github.com/Byloth/core/actions/workflows/release-gpr.yml)
|
|
5
|
+
[](https://codecov.io/gh/Byloth/core)
|
|
5
6
|
|
|
6
7
|
An unopinionated collection of useful functions and classes that I use widely in all my projects.
|
|
7
8
|
|
package/dist/core.js
CHANGED
|
@@ -1240,7 +1240,9 @@ const p = class p {
|
|
|
1240
1240
|
*
|
|
1241
1241
|
* console.log(results.toObject()); // { even: [0, 2, 6, 8] }
|
|
1242
1242
|
* ```
|
|
1243
|
-
*
|
|
1243
|
+
*
|
|
1244
|
+
* ---
|
|
1245
|
+
*
|
|
1244
1246
|
* @param count The number of elements to drop.
|
|
1245
1247
|
*
|
|
1246
1248
|
* @returns A new {@link ReducedIterator} containing the remaining elements.
|
|
@@ -1407,7 +1409,7 @@ const p = class p {
|
|
|
1407
1409
|
* const reduced = new SmartIterator<number>([-3, -1, 0, 2, 3, 5, 6, 8])
|
|
1408
1410
|
* .groupBy((value) => value % 2 === 0 ? "even" : "odd")
|
|
1409
1411
|
* .reduce((key, accumulator, value) => accumulator + value);
|
|
1410
|
-
*
|
|
1412
|
+
*
|
|
1411
1413
|
* reduced.forEach((key, value, index) =>
|
|
1412
1414
|
* {
|
|
1413
1415
|
* console.log(`#${index} - ${key}: ${value}`); // "#0 - odd: 4", "#1 - even: 16"
|
|
@@ -3828,7 +3830,9 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3828
3830
|
* window.addEventListener("pointerdown", () => { onPointerMove.enable(); });
|
|
3829
3831
|
* window.addEventListener("pointermove", onPointerMove);
|
|
3830
3832
|
* ```
|
|
3831
|
-
*
|
|
3833
|
+
*
|
|
3834
|
+
* ---
|
|
3835
|
+
*
|
|
3832
3836
|
* @param key
|
|
3833
3837
|
* The key that is associated with the implementation to enable. Default is the currently selected implementation.
|
|
3834
3838
|
*/
|
|
@@ -3938,7 +3942,7 @@ class it extends (ve = Ge, ge = Symbol.toStringTag, ve) {
|
|
|
3938
3942
|
switch(e) {
|
|
3939
3943
|
if (!this._callbacks.has(e))
|
|
3940
3944
|
throw new _(`The key '${e}' doesn't yet have any associated callback.`);
|
|
3941
|
-
this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e));
|
|
3945
|
+
this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
|
|
3942
3946
|
}
|
|
3943
3947
|
}
|
|
3944
3948
|
var ke;
|
|
@@ -4504,11 +4508,11 @@ function lt(i, t, e = 864e5) {
|
|
|
4504
4508
|
return i = new Date(i), t = new Date(t), i < t ? n = Math.floor : n = Math.ceil, n((t.getTime() - i.getTime()) / e);
|
|
4505
4509
|
}
|
|
4506
4510
|
function ct(i, t, e = 864e5) {
|
|
4507
|
-
if (i >= t)
|
|
4511
|
+
if (i = new Date(i), t = new Date(t), i >= t)
|
|
4508
4512
|
throw new b("The end date must be greater than the start date.");
|
|
4509
4513
|
return new c(function* () {
|
|
4510
|
-
const n =
|
|
4511
|
-
let s =
|
|
4514
|
+
const n = t.getTime();
|
|
4515
|
+
let s = i.getTime();
|
|
4512
4516
|
for (; s < n; )
|
|
4513
4517
|
yield new Date(s), s += e;
|
|
4514
4518
|
});
|
|
@@ -4864,6 +4868,8 @@ class ft extends (Ie = qe, je = Symbol.toStringTag, Ie) {
|
|
|
4864
4868
|
* The internal method actually responsible for stopping the
|
|
4865
4869
|
* countdown and resolving or rejecting the {@link Countdown._deferrer} promise.
|
|
4866
4870
|
*
|
|
4871
|
+
* ---
|
|
4872
|
+
*
|
|
4867
4873
|
* @param reason
|
|
4868
4874
|
* The reason why the countdown has stopped.
|
|
4869
4875
|
*
|
|
@@ -5095,6 +5101,8 @@ const F = class F {
|
|
|
5095
5101
|
/**
|
|
5096
5102
|
* Picks a random valid index from a given array of elements.
|
|
5097
5103
|
*
|
|
5104
|
+
* ---
|
|
5105
|
+
*
|
|
5098
5106
|
* @template T The type of the elements in the array.
|
|
5099
5107
|
*
|
|
5100
5108
|
* @param elements
|
|
@@ -5112,6 +5120,8 @@ const F = class F {
|
|
|
5112
5120
|
/**
|
|
5113
5121
|
* Picks a random element from a given array of elements.
|
|
5114
5122
|
*
|
|
5123
|
+
* ---
|
|
5124
|
+
*
|
|
5115
5125
|
* @template T The type of the elements in the array.
|
|
5116
5126
|
*
|
|
5117
5127
|
* @param elements
|
|
@@ -5240,7 +5250,7 @@ function Et(i) {
|
|
|
5240
5250
|
function Mt(i) {
|
|
5241
5251
|
return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
|
|
5242
5252
|
}
|
|
5243
|
-
const Rt = "2.0.
|
|
5253
|
+
const Rt = "2.0.2";
|
|
5244
5254
|
export {
|
|
5245
5255
|
T as AggregatedAsyncIterator,
|
|
5246
5256
|
g as AggregatedIterator,
|