@nejs/basic-extensions 1.6.1 → 1.7.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.
Files changed (139) hide show
  1. package/.esdoc.json +9 -0
  2. package/README.md +2025 -11
  3. package/bin/clean +6 -0
  4. package/dist/@nejs/basic-extensions.bundle.1.6.1.js +4 -0
  5. package/dist/@nejs/basic-extensions.bundle.1.6.1.js.map +7 -0
  6. package/dist/cjs/arrayextensions.js +1 -0
  7. package/dist/cjs/arrayextensions.js.map +1 -0
  8. package/dist/cjs/functionextensions.js +1 -0
  9. package/dist/cjs/functionextensions.js.map +1 -0
  10. package/dist/cjs/globals.js +2 -1
  11. package/dist/cjs/globals.js.map +1 -0
  12. package/dist/cjs/index.d.ts +10 -19
  13. package/dist/cjs/index.js +69 -76
  14. package/dist/cjs/index.js.map +1 -0
  15. package/dist/cjs/mapextensions.d.ts +2 -0
  16. package/dist/cjs/mapextensions.js +30 -0
  17. package/dist/cjs/mapextensions.js.map +1 -0
  18. package/dist/cjs/newClasses/asyncIterable.d.ts +123 -0
  19. package/dist/cjs/{asyncIterable.js → newClasses/asyncIterable.js} +7 -4
  20. package/dist/cjs/newClasses/asyncIterable.js.map +1 -0
  21. package/dist/cjs/newClasses/descriptor.d.ts +401 -0
  22. package/dist/cjs/{descriptor.js → newClasses/descriptor.js} +150 -80
  23. package/dist/cjs/newClasses/descriptor.js.map +1 -0
  24. package/dist/cjs/newClasses/iterable.d.ts +125 -0
  25. package/dist/cjs/{iterable.js → newClasses/iterable.js} +36 -10
  26. package/dist/cjs/newClasses/iterable.js.map +1 -0
  27. package/dist/cjs/newClasses/refmap.d.ts +238 -0
  28. package/dist/cjs/newClasses/refmap.js +433 -0
  29. package/dist/cjs/newClasses/refmap.js.map +1 -0
  30. package/dist/cjs/newClasses/refset.d.ts +186 -0
  31. package/dist/cjs/{refset.js → newClasses/refset.js} +4 -2
  32. package/dist/cjs/newClasses/refset.js.map +1 -0
  33. package/dist/cjs/objectextensions.d.ts +7 -6
  34. package/dist/cjs/objectextensions.js +85 -43
  35. package/dist/cjs/objectextensions.js.map +1 -0
  36. package/dist/cjs/reflectextensions.js +16 -12
  37. package/dist/cjs/reflectextensions.js.map +1 -0
  38. package/dist/cjs/stringextensions.js +1 -0
  39. package/dist/cjs/stringextensions.js.map +1 -0
  40. package/dist/cjs/symbolextensions.js +3 -1
  41. package/dist/cjs/symbolextensions.js.map +1 -0
  42. package/dist/cjs/weakrefextensions.js +1 -0
  43. package/dist/cjs/weakrefextensions.js.map +1 -0
  44. package/dist/mjs/arrayextensions.js +1 -0
  45. package/dist/mjs/arrayextensions.js.map +1 -0
  46. package/dist/mjs/functionextensions.js +1 -0
  47. package/dist/mjs/functionextensions.js.map +1 -0
  48. package/dist/mjs/globals.js +2 -1
  49. package/dist/mjs/globals.js.map +1 -0
  50. package/dist/mjs/index.d.ts +10 -19
  51. package/dist/mjs/index.js +67 -60
  52. package/dist/mjs/index.js.map +1 -0
  53. package/dist/mjs/mapextensions.d.ts +2 -0
  54. package/dist/mjs/mapextensions.js +27 -0
  55. package/dist/mjs/mapextensions.js.map +1 -0
  56. package/dist/mjs/newClasses/asyncIterable.d.ts +123 -0
  57. package/dist/mjs/{asyncIterable.js → newClasses/asyncIterable.js} +106 -105
  58. package/dist/mjs/newClasses/asyncIterable.js.map +1 -0
  59. package/dist/mjs/newClasses/descriptor.d.ts +401 -0
  60. package/dist/mjs/{descriptor.js → newClasses/descriptor.js} +129 -67
  61. package/dist/mjs/newClasses/descriptor.js.map +1 -0
  62. package/dist/mjs/newClasses/iterable.d.ts +125 -0
  63. package/dist/mjs/newClasses/iterable.js +199 -0
  64. package/dist/mjs/newClasses/iterable.js.map +1 -0
  65. package/dist/mjs/newClasses/refmap.d.ts +238 -0
  66. package/dist/mjs/newClasses/refmap.js +417 -0
  67. package/dist/mjs/newClasses/refmap.js.map +1 -0
  68. package/dist/mjs/newClasses/refset.d.ts +186 -0
  69. package/dist/mjs/{refset.js → newClasses/refset.js} +3 -2
  70. package/dist/mjs/newClasses/refset.js.map +1 -0
  71. package/dist/mjs/objectextensions.d.ts +7 -6
  72. package/dist/mjs/objectextensions.js +84 -42
  73. package/dist/mjs/objectextensions.js.map +1 -0
  74. package/dist/mjs/reflectextensions.js +16 -12
  75. package/dist/mjs/reflectextensions.js.map +1 -0
  76. package/dist/mjs/stringextensions.js +1 -0
  77. package/dist/mjs/stringextensions.js.map +1 -0
  78. package/dist/mjs/symbolextensions.js +3 -1
  79. package/dist/mjs/symbolextensions.js.map +1 -0
  80. package/dist/mjs/weakrefextensions.js +1 -0
  81. package/dist/mjs/weakrefextensions.js.map +1 -0
  82. package/docs/assets/anchor.js +350 -0
  83. package/docs/assets/bass-addons.css +12 -0
  84. package/docs/assets/bass.css +544 -0
  85. package/docs/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
  86. package/docs/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
  87. package/docs/assets/fonts/LICENSE.txt +93 -0
  88. package/docs/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
  89. package/docs/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
  90. package/docs/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
  91. package/docs/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
  92. package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
  93. package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
  94. package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
  95. package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
  96. package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
  97. package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
  98. package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
  99. package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
  100. package/docs/assets/fonts/source-code-pro.css +23 -0
  101. package/docs/assets/github.css +123 -0
  102. package/docs/assets/site.js +168 -0
  103. package/docs/assets/split.css +15 -0
  104. package/docs/assets/split.js +782 -0
  105. package/docs/assets/style.css +147 -0
  106. package/docs/index.html +13060 -0
  107. package/jsdoc-config.json +31 -0
  108. package/package.json +12 -3
  109. package/src/globals.js +1 -1
  110. package/src/index.js +75 -82
  111. package/src/mapextensions.js +30 -0
  112. package/src/{asyncIterable.js → newClasses/asyncIterable.js} +117 -117
  113. package/src/{descriptor.js → newClasses/descriptor.js} +137 -74
  114. package/src/newClasses/iterable.js +221 -0
  115. package/src/newClasses/refmap.js +483 -0
  116. package/src/{refset.js → newClasses/refset.js} +2 -2
  117. package/src/objectextensions.js +97 -46
  118. package/src/reflectextensions.js +16 -14
  119. package/src/symbolextensions.js +2 -1
  120. package/tests/index.test.js +1 -1
  121. package/tests/{asyncIterable.test.js → newClasses/asyncIterable.test.js} +3 -4
  122. package/tests/newClasses/descriptor.test.js +252 -0
  123. package/tests/{iterable.test.js → newClasses/iterable.test.js} +2 -4
  124. package/tests/newClasses/refmap.test.js +69 -0
  125. package/tests/{refset.test.js → newClasses/refset.test.js} +2 -4
  126. package/tests/objectextensions.test.js +128 -0
  127. package/tsconfig.base.json +2 -1
  128. package/dist/@nejs/basic-extensions.bundle.1.6.0.js +0 -2
  129. package/dist/@nejs/basic-extensions.bundle.1.6.0.js.map +0 -7
  130. package/dist/cjs/asyncIterable.d.ts +0 -3
  131. package/dist/cjs/descriptor.d.ts +0 -2
  132. package/dist/cjs/iterable.d.ts +0 -3
  133. package/dist/cjs/refset.d.ts +0 -2
  134. package/dist/mjs/asyncIterable.d.ts +0 -3
  135. package/dist/mjs/descriptor.d.ts +0 -2
  136. package/dist/mjs/iterable.d.ts +0 -3
  137. package/dist/mjs/iterable.js +0 -184
  138. package/dist/mjs/refset.d.ts +0 -2
  139. package/src/iterable.js +0 -203
@@ -1,19 +1,10 @@
1
- export function enableAll(owners: any): void;
2
- export function enableNetNew(): void;
3
- export function disableAll(owners: any): void;
4
- export function disableNetNew(): void;
5
- export const all: {};
6
- import { ObjectExtensions } from './objectextensions.js';
7
- import { FunctionExtensions } from './functionextensions.js';
8
- import { ReflectExtensions } from './reflectextensions.js';
9
- import { StringExtensions } from './stringextensions.js';
10
- import { SymbolExtensions } from './symbolextensions.js';
11
- import { ArrayPrototypeExtensions } from './arrayextensions.js';
12
- import { GlobalFunctionsAndProps } from './globals.js';
13
- import { DescriptorExtensions } from './descriptor.js';
14
- import { AsyncIterableExtensions } from './asyncIterable.js';
15
- import { AsyncIteratorExtensions } from './asyncIterable.js';
16
- import { IterableExtensions } from './iterable.js';
17
- import { IteratorExtensions } from './iterable.js';
18
- import { RefSetExtensions } from './refset.js';
19
- export { ObjectExtensions, FunctionExtensions, ReflectExtensions, StringExtensions, SymbolExtensions, ArrayPrototypeExtensions, GlobalFunctionsAndProps, DescriptorExtensions, AsyncIterableExtensions, AsyncIteratorExtensions, IterableExtensions, IteratorExtensions, RefSetExtensions };
1
+ export const all: any;
2
+ export default results;
3
+ declare namespace results {
4
+ export { Extensions as extensions };
5
+ export { Patches as patches };
6
+ export { all };
7
+ }
8
+ export const Extensions: {};
9
+ export const Patches: Map<Object, import("@nejs/extension").Patch>;
10
+ export const Controls: {};
package/dist/mjs/index.js CHANGED
@@ -1,76 +1,83 @@
1
1
  import { FunctionExtensions } from './functionextensions.js';
2
- import { ObjectExtensions } from './objectextensions.js';
2
+ import { ObjectExtensions, ObjectPrototypeExtensions } from './objectextensions.js';
3
+ import { MapPrototypeExtensions } from './mapextensions.js';
3
4
  import { ReflectExtensions } from './reflectextensions.js';
4
5
  import { StringExtensions } from './stringextensions.js';
5
6
  import { SymbolExtensions } from './symbolextensions.js';
6
7
  import { ArrayPrototypeExtensions } from './arrayextensions.js';
7
- import { DescriptorExtensions } from './descriptor.js';
8
+ import { DescriptorExtensions, Descriptor } from './newClasses/descriptor.js';
8
9
  import { GlobalFunctionsAndProps } from './globals.js';
9
- import { RefSetExtensions } from './refset.js';
10
- import { AsyncIteratorExtensions, AsyncIterableExtensions } from './asyncIterable.js';
11
- import { IteratorExtensions, IterableExtensions } from './iterable.js';
12
- import { Patch } from '@nejs/extension';
13
- const Owners = [
14
- Object,
15
- Function,
16
- Reflect,
17
- String,
18
- Symbol,
19
- Array.prototype,
20
- ];
21
- const NetNew = [
22
- GlobalFunctionsAndProps,
23
- DescriptorExtensions,
24
- AsyncIterableExtensions,
25
- AsyncIteratorExtensions,
26
- IterableExtensions,
27
- IteratorExtensions,
28
- RefSetExtensions,
29
- ];
30
- export function enableAll(owners) {
31
- const list = owners || Owners;
32
- if (!list) {
33
- throw new Error('Unable to enable features without owners list');
34
- }
35
- list.forEach(owner => {
36
- Patch.enableFor(owner);
37
- });
38
- enableNetNew();
39
- }
40
- export function enableNetNew() {
41
- NetNew.forEach(extension => { extension.apply(); });
42
- }
43
- export function disableAll(owners) {
44
- const list = owners || Owners;
45
- if (!list) {
46
- throw new Error('Unable to disable features without owners list');
47
- }
48
- list.forEach(owner => {
49
- Patch.disableFor(owner);
50
- });
51
- disableNetNew();
52
- }
53
- export function disableNetNew() {
54
- NetNew.forEach(extension => { extension.revert(); });
55
- }
10
+ import { RefSetExtensions } from './newClasses/refset.js';
11
+ import { RefMapExtensions } from './newClasses/refmap.js';
12
+ import { AsyncIteratorExtensions, AsyncIterableExtensions } from './newClasses/asyncIterable.js';
13
+ import { IteratorExtensions, IterableExtensions } from './newClasses/iterable.js';
14
+ const Patches = new Map([
15
+ [Object, ObjectExtensions],
16
+ [Function, FunctionExtensions],
17
+ [Reflect, ReflectExtensions],
18
+ [String, StringExtensions],
19
+ [Symbol, SymbolExtensions],
20
+ [Object.prototype, ObjectPrototypeExtensions],
21
+ [Array.prototype, ArrayPrototypeExtensions],
22
+ [Map.prototype, MapPrototypeExtensions],
23
+ [globalThis, GlobalFunctionsAndProps],
24
+ ]);
25
+ const Extensions = {
26
+ [DescriptorExtensions.key]: DescriptorExtensions,
27
+ [AsyncIterableExtensions.key]: AsyncIterableExtensions,
28
+ [AsyncIteratorExtensions.key]: AsyncIteratorExtensions,
29
+ [IterableExtensions.key]: IterableExtensions,
30
+ [IteratorExtensions.key]: IteratorExtensions,
31
+ [RefSetExtensions.key]: RefSetExtensions,
32
+ [RefMapExtensions.key]: RefMapExtensions,
33
+ };
34
+ const Controls = {};
35
+ Object.assign(Controls, {
36
+ enableAll() {
37
+ Controls.enablePatches();
38
+ Controls.enableExtensions();
39
+ },
40
+ enablePatches() {
41
+ Patches.forEach((extension) => { extension.apply(); });
42
+ },
43
+ enableExtensions() {
44
+ Object.values(Extensions).forEach((extension) => { extension.apply(); });
45
+ },
46
+ disableAll(owners) {
47
+ Controls.disablePatches();
48
+ Controls.disableExtensions();
49
+ },
50
+ disablePatches() {
51
+ Patches.forEach((extension) => { extension.revert(); });
52
+ },
53
+ disableExtensions() {
54
+ Object.values(Extensions).forEach((extension) => { extension.revert(); });
55
+ },
56
+ });
56
57
  export const all = (() => {
57
- let extensions = [
58
- ObjectExtensions,
59
- FunctionExtensions,
60
- ReflectExtensions,
61
- StringExtensions,
62
- SymbolExtensions,
63
- ArrayPrototypeExtensions,
64
- GlobalFunctionsAndProps,
65
- DescriptorExtensions,
58
+ const extensions = [
59
+ ...Array.from(Patches.values()),
60
+ ...Array.from(Object.values(Extensions)),
66
61
  ];
67
62
  const dest = extensions.reduce((accumulator, extension) => {
68
63
  Reflect.ownKeys(extension.patchEntries).reduce((_, key) => {
69
- accumulator[key] = extension.patchEntries[key].computed;
64
+ const entry = extension.patchEntries[key];
65
+ if (entry.isAccessor)
66
+ accumulator[key] = new Descriptor(entry.descriptor);
67
+ else
68
+ accumulator[key] = entry.computed;
70
69
  return accumulator;
71
70
  }, accumulator);
72
71
  return accumulator;
73
72
  }, {});
74
73
  return dest;
75
74
  })();
76
- export { ObjectExtensions, FunctionExtensions, ReflectExtensions, StringExtensions, SymbolExtensions, ArrayPrototypeExtensions, GlobalFunctionsAndProps, DescriptorExtensions, AsyncIterableExtensions, AsyncIteratorExtensions, IterableExtensions, IteratorExtensions, RefSetExtensions, };
75
+ const results = {
76
+ ...Controls,
77
+ extensions: Extensions,
78
+ patches: Patches,
79
+ all,
80
+ };
81
+ export default results;
82
+ export { Extensions, Patches, Controls, };
83
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAA;AAC/D,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,+BAA+B,CAAA;AAEtC,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,0BAA0B,CAAA;AAEjC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC;IACtB,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAC1B,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAC9B,CAAC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CAAA;AACb,CAAC,CAAC,EAAE,CAAA;AAEJ,MAAM,OAAO,GAAG;IACd,GAAG,QAAQ;IACX,UAAU,EAAE,UAAU;IACtB,OAAO,EAAE,OAAO;IAChB,GAAG;CACJ,CAAA;AAED,eAAe,OAAO,CAAA;AAEtB,OAAO,EACL,UAAU,EACV,OAAO,EACP,QAAQ,GACT,CAAA"}
@@ -0,0 +1,2 @@
1
+ export const MapPrototypeExtensions: Patch;
2
+ import { Patch } from '@nejs/extension';
@@ -0,0 +1,27 @@
1
+ import { Patch } from '@nejs/extension';
2
+ export const MapPrototypeExtensions = new Patch(Map.prototype, {
3
+ /**
4
+ * The function `getKey` returns the key associated with a given value
5
+ * in a map.
6
+ *
7
+ * @param {any} value - The value parameter is the value that you want to
8
+ * find the corresponding key for in the map.
9
+ * @param [strict=true] - The "strict" parameter is a boolean value that
10
+ * determines whether strict equality (===) or loose equality (==) should
11
+ * be used when comparing the "value" parameter with the values in the
12
+ * entries of the object. If "strict" is set to true, strict equality will
13
+ * be used.
14
+ * @returns the key associated with the given value. If a matching key is
15
+ * found, it is returned. If no matching key is found, null is returned.
16
+ */
17
+ getKey(value, strict = true) {
18
+ for (const [key, entryValue] of this) {
19
+ if ((strict && value === entryValue) &&
20
+ (!strict && value == entryValue)) {
21
+ return key;
22
+ }
23
+ return null;
24
+ }
25
+ },
26
+ });
27
+ //# sourceMappingURL=mapextensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapextensions.js","sourceRoot":"","sources":["../../src/mapextensions.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE;IAC7D;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;QACzB,KAAK,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,IAAI,EAAE,CAAC;YACrC,IACE,CAAC,MAAM,IAAI,KAAK,KAAK,UAAU,CAAC;gBAChC,CAAC,CAAC,MAAM,IAAI,KAAK,IAAI,UAAU,CAAC,EAChC,CAAC;gBACD,OAAO,GAAG,CAAA;YACZ,CAAC;YAED,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;CACF,CAAC,CAAA"}
@@ -0,0 +1,123 @@
1
+ /**
2
+ * The AsyncIterable class extends the concept of Iterable to asynchronous
3
+ * operations. It allows creating iterable objects where each element can be
4
+ * an asynchronous entity, like a Promise. This class is particularly useful
5
+ * when dealing with asynchronous data sources, such as API responses, file
6
+ * reading in chunks, or any other data that is not immediately available but
7
+ * arrives over time.
8
+ */
9
+ export class AsyncIterable {
10
+ /**
11
+ * Checks if a given value is an async iterable. This method determines if
12
+ * the provided value has a `Symbol.asyncIterator` property that is an async
13
+ * generator function. It's a precise way to identify if the value conforms
14
+ * to the async iterable protocol using an async generator function.
15
+ *
16
+ * Note: This method specifically checks for async generator functions. Some
17
+ * async iterables might use regular async functions that return an async
18
+ * iterator, which this method won't identify.
19
+ *
20
+ * @param {*} value - The value to be checked for async iterability.
21
+ * @returns {boolean} - Returns true if the value is an async iterable
22
+ * implemented using an async generator function, false otherwise.
23
+ */
24
+ static isAsyncIterable(value: any): boolean;
25
+ /**
26
+ * Constructs an instance of AsyncIterable. Similar to Iterable, it can be
27
+ * initialized with either an iterable object or individual elements. The
28
+ * elements can be promises, direct values, or a mix of both. If the first
29
+ * argument is an iterable, the instance is initialized with the elements
30
+ * from the iterable, followed by any additional arguments. If the first
31
+ * argument is not an iterable, all arguments are treated as individual
32
+ * elements.
33
+ *
34
+ * @param {Iterable|Promise|*} elementsOrFirstElement - An iterable object,
35
+ * a Promise, or the first element.
36
+ * @param {...Promise|*} moreElements - Additional elements if the first
37
+ * argument is not an iterable.
38
+ */
39
+ constructor(elementsOrFirstElement: Iterable<any> | Promise<any> | any, ...moreElements: (Promise<any> | any)[]);
40
+ /**
41
+ * Implements the async iterable protocol. When an instance of AsyncIterable
42
+ * is used in a `for await...of` loop, this async generator function is
43
+ * invoked. It yields each element as a Promise, allowing asynchronous
44
+ * iteration. Elements that are not Promises are automatically wrapped in
45
+ * a resolved Promise to ensure consistency.
46
+ *
47
+ * @returns {AsyncGenerator} An async generator that yields each element as
48
+ * a Promise.
49
+ */
50
+ [Symbol.asyncIterator](): AsyncGenerator;
51
+ /**
52
+ * Ensures that the constructor of this object instance's name
53
+ * is returned if the string tag for this instance is queried
54
+ *
55
+ * @returns {string} the name of the class
56
+ */
57
+ get [Symbol.toStringTag](): string;
58
+ #private;
59
+ }
60
+ /**
61
+ * Being able to create a compliant `AsyncIterator` around any type of
62
+ * iterable object. This can be wrapped around any type of object that
63
+ * has a `[Symbol.asyncIterator]` property assigned to a generator
64
+ * function.
65
+ */
66
+ export class AsyncIterator {
67
+ /**
68
+ * Creates a new `AsyncIterator` object instance.
69
+ *
70
+ * @param {object} asyncIterable any object that has a
71
+ * `[Symbol.asyncIterable]` property assigned to a generator function.
72
+ */
73
+ constructor(asyncIterable: object);
74
+ /**
75
+ * Returns a new `Array` derived from the iterable this object
76
+ * wraps.
77
+ *
78
+ * @returns {array} a new `Array` generated from the wrapped
79
+ * iterable. The method is generated from using an async for of
80
+ * loop.
81
+ */
82
+ asArray(): any[];
83
+ /**
84
+ * Returns the actual iterable object passed to the constructor that
85
+ * created this instance.
86
+ *
87
+ * @returns {object} the object containing the `[Symbol.iterator]`
88
+ */
89
+ get asyncIterable(): object;
90
+ /**
91
+ * The function retrieves the next value in the iterator. If the
92
+ * the iterator has run its course, `reset()` can be invoked to
93
+ * reset the pointer to the beginning of the iteration.
94
+ *
95
+ * @returns {any} the next value
96
+ */
97
+ next(): any;
98
+ /**
99
+ * Resets the async iterator to the beginning allowing it to be
100
+ * iterated over again.
101
+ */
102
+ reset(): Promise<void>;
103
+ /**
104
+ * The existence of this symbol on the object instances, indicates that
105
+ * it can be used in `for(.. of ..)` loops and its values can be
106
+ * extracted from calls to `Array.from()`
107
+ *
108
+ * @returns {AsyncIterable} this is returned since this object is already
109
+ * conforming to the expected JavaScript AsyncIterator interface
110
+ */
111
+ [Symbol.asyncIterator](): AsyncIterable;
112
+ /**
113
+ * Ensures that the constructor of this object instance's name
114
+ * is returned if the string tag for this instance is queried
115
+ *
116
+ * @returns {string} the name of the class
117
+ */
118
+ get [Symbol.toStringTag](): string;
119
+ #private;
120
+ }
121
+ export const AsyncIterableExtensions: Extension;
122
+ export const AsyncIteratorExtensions: Extension;
123
+ import { Extension } from '@nejs/extension';
@@ -7,7 +7,7 @@ import { Extension } from '@nejs/extension';
7
7
  * reading in chunks, or any other data that is not immediately available but
8
8
  * arrives over time.
9
9
  */
10
- class AsyncIterable {
10
+ export class AsyncIterable {
11
11
  /**
12
12
  * Private field to store the elements of the async iterable.
13
13
  * @private
@@ -62,109 +62,6 @@ class AsyncIterable {
62
62
  get [Symbol.toStringTag]() {
63
63
  return this.constructor.name;
64
64
  }
65
- /**
66
- * Being able to create a compliant `AsyncIterator` around any type of
67
- * iterable object. This can be wrapped around any type of object that
68
- * has a `[Symbol.asyncIterator]` property assigned to a generator
69
- * function.
70
- */
71
- static AsyncIterator = class AsyncIterator {
72
- /**
73
- * Creates a new `AsyncIterator` object instance.
74
- *
75
- * @param {object} asyncIterable any object that has a
76
- * `[Symbol.asyncIterable]` property assigned to a generator function.
77
- */
78
- constructor(asyncIterable) {
79
- if (!asyncIterable || !Reflect.has(asyncIterable, Symbol.asyncIterator)) {
80
- throw new TypeError('Value used to instantiate AsyncIterator is not an async iterable');
81
- }
82
- this.#asyncIterable = asyncIterable;
83
- this.#asyncIterator = asyncIterable[Symbol.asyncIterator]();
84
- }
85
- /**
86
- * Returns a new `Array` derived from the iterable this object
87
- * wraps.
88
- *
89
- * @returns {array} a new `Array` generated from the wrapped
90
- * iterable. The method is generated from using an async for of
91
- * loop.
92
- */
93
- async asArray() {
94
- const array = [];
95
- for await (const value of this) {
96
- array.push(value);
97
- }
98
- return array;
99
- }
100
- /**
101
- * Returns the actual iterable object passed to the constructor that
102
- * created this instance.
103
- *
104
- * @returns {object} the object containing the `[Symbol.iterator]`
105
- */
106
- get asyncIterable() {
107
- return this.#asyncIterable;
108
- }
109
- /**
110
- * The function retrieves the next value in the iterator. If the
111
- * the iterator has run its course, `reset()` can be invoked to
112
- * reset the pointer to the beginning of the iteration.
113
- *
114
- * @returns {any} the next value
115
- */
116
- async next() {
117
- const result = await this.#asyncIterator.next();
118
- if (result.done) {
119
- return { value: undefined, done: true };
120
- }
121
- else {
122
- return { value: result.value, done: false };
123
- }
124
- }
125
- /**
126
- * Resets the async iterator to the beginning allowing it to be
127
- * iterated over again.
128
- */
129
- async reset() {
130
- this.#asyncIterator = this.#asyncIterable[Symbol.asyncIterator]();
131
- }
132
- /**
133
- * The existence of this symbol on the object instances, indicates that
134
- * it can be used in `for(.. of ..)` loops and its values can be
135
- * extracted from calls to `Array.from()`
136
- *
137
- * @returns {AsyncIterable} this is returned since this object is already
138
- * conforming to the expected JavaScript AsyncIterator interface
139
- */
140
- [Symbol.asyncIterator]() {
141
- return this;
142
- }
143
- /**
144
- * Ensures that the constructor of this object instance's name
145
- * is returned if the string tag for this instance is queried
146
- *
147
- * @returns {string} the name of the class
148
- */
149
- get [Symbol.toStringTag]() {
150
- return this.constructor.name;
151
- }
152
- /**
153
- * The object from which its iterator functionality is derived.
154
- *
155
- * @type {object}
156
- * @private
157
- */
158
- #asyncIterable = null;
159
- /**
160
- * The results of a call to the iterable's `[Symbol.asyncIterator]`
161
- * generator function.
162
- *
163
- * @type {object}
164
- * @private
165
- */
166
- #asyncIterator = null;
167
- };
168
65
  /**
169
66
  * Checks if a given value is an async iterable. This method determines if
170
67
  * the provided value has a `Symbol.asyncIterator` property that is an async
@@ -184,5 +81,109 @@ class AsyncIterable {
184
81
  return type === '[object AsyncGeneratorFunction]';
185
82
  }
186
83
  }
84
+ /**
85
+ * Being able to create a compliant `AsyncIterator` around any type of
86
+ * iterable object. This can be wrapped around any type of object that
87
+ * has a `[Symbol.asyncIterator]` property assigned to a generator
88
+ * function.
89
+ */
90
+ export class AsyncIterator {
91
+ /**
92
+ * Creates a new `AsyncIterator` object instance.
93
+ *
94
+ * @param {object} asyncIterable any object that has a
95
+ * `[Symbol.asyncIterable]` property assigned to a generator function.
96
+ */
97
+ constructor(asyncIterable) {
98
+ if (!asyncIterable || !Reflect.has(asyncIterable, Symbol.asyncIterator)) {
99
+ throw new TypeError('Value used to instantiate AsyncIterator is not an async iterable');
100
+ }
101
+ this.#asyncIterable = asyncIterable;
102
+ this.#asyncIterator = asyncIterable[Symbol.asyncIterator]();
103
+ }
104
+ /**
105
+ * Returns a new `Array` derived from the iterable this object
106
+ * wraps.
107
+ *
108
+ * @returns {array} a new `Array` generated from the wrapped
109
+ * iterable. The method is generated from using an async for of
110
+ * loop.
111
+ */
112
+ async asArray() {
113
+ const array = [];
114
+ for await (const value of this) {
115
+ array.push(value);
116
+ }
117
+ return array;
118
+ }
119
+ /**
120
+ * Returns the actual iterable object passed to the constructor that
121
+ * created this instance.
122
+ *
123
+ * @returns {object} the object containing the `[Symbol.iterator]`
124
+ */
125
+ get asyncIterable() {
126
+ return this.#asyncIterable;
127
+ }
128
+ /**
129
+ * The function retrieves the next value in the iterator. If the
130
+ * the iterator has run its course, `reset()` can be invoked to
131
+ * reset the pointer to the beginning of the iteration.
132
+ *
133
+ * @returns {any} the next value
134
+ */
135
+ async next() {
136
+ const result = await this.#asyncIterator.next();
137
+ if (result.done) {
138
+ return { value: undefined, done: true };
139
+ }
140
+ else {
141
+ return { value: result.value, done: false };
142
+ }
143
+ }
144
+ /**
145
+ * Resets the async iterator to the beginning allowing it to be
146
+ * iterated over again.
147
+ */
148
+ async reset() {
149
+ this.#asyncIterator = this.#asyncIterable[Symbol.asyncIterator]();
150
+ }
151
+ /**
152
+ * The existence of this symbol on the object instances, indicates that
153
+ * it can be used in `for(.. of ..)` loops and its values can be
154
+ * extracted from calls to `Array.from()`
155
+ *
156
+ * @returns {AsyncIterable} this is returned since this object is already
157
+ * conforming to the expected JavaScript AsyncIterator interface
158
+ */
159
+ [Symbol.asyncIterator]() {
160
+ return this;
161
+ }
162
+ /**
163
+ * Ensures that the constructor of this object instance's name
164
+ * is returned if the string tag for this instance is queried
165
+ *
166
+ * @returns {string} the name of the class
167
+ */
168
+ get [Symbol.toStringTag]() {
169
+ return this.constructor.name;
170
+ }
171
+ /**
172
+ * The object from which its iterator functionality is derived.
173
+ *
174
+ * @type {object}
175
+ * @private
176
+ */
177
+ #asyncIterable = null;
178
+ /**
179
+ * The results of a call to the iterable's `[Symbol.asyncIterator]`
180
+ * generator function.
181
+ *
182
+ * @type {object}
183
+ * @private
184
+ */
185
+ #asyncIterator = null;
186
+ }
187
187
  export const AsyncIterableExtensions = new Extension(AsyncIterable);
188
- export const AsyncIteratorExtensions = new Extension(AsyncIterable.AsyncIterator);
188
+ export const AsyncIteratorExtensions = new Extension(AsyncIterator);
189
+ //# sourceMappingURL=asyncIterable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncIterable.js","sourceRoot":"","sources":["../../../src/newClasses/asyncIterable.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACxB;;;OAGG;IACH,SAAS,GAAG,EAAE,CAAC;IAEf;;;;;;;;;;;;;OAaG;IACH,YAAY,sBAAsB,EAAE,GAAG,YAAY;QACjD,IACE,sBAAsB,IAAI,IAAI;YAC9B,OAAO,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,UAAU,EAC7D,CAAC;YACD,IAAI,CAAC,SAAS,GAAG,CAAC,GAAG,sBAAsB,EAAE,GAAG,YAAY,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,GAAG,CAAC,sBAAsB,EAAE,GAAG,YAAY,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED;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