@oscarpalmer/atoms 0.211.0 → 0.213.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.
@@ -1,70 +0,0 @@
1
- import { GENERATOR_NAME_ASYNC, GENERATOR_NAME_SYNC, PLAN_SYMBOL, PLAN_TYPE_PLAN_ASYNC, PLAN_TYPE_PLAN_SYNC } from "./models/plan.model.mjs";
2
- //#region src/internal/plan.ts
3
- /**
4
- * Create an immediately failing generator
5
- *
6
- * @param reason Failure reason
7
- * @returns Failing generator
8
- */
9
- function fail(reason) {
10
- return (function* () {
11
- yield;
12
- throw reason;
13
- })();
14
- }
15
- /**
16
- * Is the value an asynchronous generator function?
17
- *
18
- * @param value Value to check
19
- * @returns `true` if the value is an asynchronous generator function, otherwise `false`
20
- */
21
- function isAsyncGenerator(value) {
22
- return isGeneratorInstance(GENERATOR_NAME_ASYNC, value);
23
- }
24
- /**
25
- * Is the value an asynchronous plan?
26
- *
27
- * @param value Value to check
28
- * @returns `true` if the value is an asynchronous plan, otherwise `false`
29
- */
30
- function isAsyncPlan(value) {
31
- return isPlanInstance(PLAN_TYPE_PLAN_ASYNC, value);
32
- }
33
- /**
34
- * Is the value a generator function?
35
- *
36
- * @param value Value to check
37
- * @returns `true` if the value is a generator function, otherwise `false`
38
- */
39
- function isGenerator(value) {
40
- return isGeneratorInstance(GENERATOR_NAME_SYNC, value);
41
- }
42
- function isGeneratorInstance(name, value) {
43
- return typeof value === "function" && value !== null && value.constructor.name === name && typeof value.prototype.next === "function" && typeof value.prototype.return === "function" && typeof value.prototype.throw === "function";
44
- }
45
- /**
46
- * Is the value a plan?
47
- *
48
- * @param value Value to check
49
- * @returns `true` if the value is a plan, otherwise `false`
50
- */
51
- function isPlan(value) {
52
- return isPlanInstance(PLAN_TYPE_PLAN_SYNC, value);
53
- }
54
- function isPlanInstance(type, value) {
55
- return typeof value === "object" && value !== null && PLAN_SYMBOL in value && value[PLAN_SYMBOL].type === type;
56
- }
57
- /**
58
- * Create an immediately succeeding generator
59
- *
60
- * @param value Success value
61
- * @returns Succeeding generator
62
- */
63
- function succeed(value) {
64
- return (function* () {
65
- yield;
66
- return value;
67
- })();
68
- }
69
- //#endregion
70
- export { fail, isAsyncGenerator, isAsyncPlan, isGenerator, isPlan, succeed };