@nejs/basic-extensions 2.21.5 → 2.22.6

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 (266) hide show
  1. package/README.md +78 -4
  2. package/dist/@nejs/basic-extensions.bundle.2.22.6.js +25 -0
  3. package/dist/@nejs/basic-extensions.bundle.2.22.6.js.map +7 -0
  4. package/dist/cjs/classes/index.cjs +11129 -0
  5. package/dist/cjs/classes/index.cjs.map +7 -0
  6. package/dist/cjs/index.cjs +15191 -0
  7. package/dist/cjs/index.cjs.map +7 -0
  8. package/dist/cjs/utils/index.cjs +3954 -0
  9. package/dist/cjs/utils/index.cjs.map +7 -0
  10. package/dist/esm/basic-extensions.mjs +25 -0
  11. package/dist/esm/basic-extensions.mjs.map +7 -0
  12. package/package.json +16 -22
  13. package/repl.bootstrap.js +4 -7
  14. package/repl.history +26 -26
  15. package/src/classes/enumeration.js +466 -0
  16. package/src/classes/index.js +5 -1
  17. package/src/index.js +3 -1
  18. package/src/regular.expression.extensions.js +0 -35
  19. package/src/utils/toolkit.js +699 -516
  20. package/tests/arrayextensions.test.js +3 -3
  21. package/tests/index.test.js +3 -1
  22. package/tests/newClasses/asyncIterable.test.js +3 -3
  23. package/tests/newClasses/deferred.test.js +3 -3
  24. package/tests/newClasses/descriptor.test.js +3 -3
  25. package/tests/newClasses/iterable.test.js +3 -3
  26. package/tests/newClasses/refmap.test.js +3 -3
  27. package/tests/newClasses/refset.test.js +3 -3
  28. package/tests/objectextensions.test.js +3 -3
  29. package/tests/setextensions.test.js +3 -3
  30. package/tests/stringextensions.test.js +3 -2
  31. package/tests/utils/descriptor.utils.test.js +1 -1
  32. package/tests/utils/toolkit.test.js +429 -163
  33. package/.esdoc.json +0 -9
  34. package/.vscode/settings.json +0 -5
  35. package/bin/build +0 -27
  36. package/bin/clean +0 -14
  37. package/bin/esbuild +0 -91
  38. package/bin/fixup +0 -13
  39. package/bin/repl.basics.js +0 -584
  40. package/bin/repl.signature.js +0 -63
  41. package/bin/version +0 -100
  42. package/dist/@nejs/basic-extensions.bundle.2.21.5.js +0 -25
  43. package/dist/@nejs/basic-extensions.bundle.2.21.5.js.map +0 -7
  44. package/dist/cjs/array.extensions.d.ts +0 -39
  45. package/dist/cjs/array.extensions.js +0 -477
  46. package/dist/cjs/array.extensions.js.map +0 -1
  47. package/dist/cjs/big.int.extension.d.ts +0 -31
  48. package/dist/cjs/big.int.extension.js +0 -273
  49. package/dist/cjs/big.int.extension.js.map +0 -1
  50. package/dist/cjs/classes/asyncIterable.d.ts +0 -126
  51. package/dist/cjs/classes/asyncIterable.js +0 -209
  52. package/dist/cjs/classes/asyncIterable.js.map +0 -1
  53. package/dist/cjs/classes/deferred.d.ts +0 -146
  54. package/dist/cjs/classes/deferred.js +0 -291
  55. package/dist/cjs/classes/deferred.js.map +0 -1
  56. package/dist/cjs/classes/descriptor.d.ts +0 -334
  57. package/dist/cjs/classes/descriptor.js +0 -537
  58. package/dist/cjs/classes/descriptor.js.map +0 -1
  59. package/dist/cjs/classes/enum.d.ts +0 -50
  60. package/dist/cjs/classes/enum.js +0 -405
  61. package/dist/cjs/classes/enum.js.map +0 -1
  62. package/dist/cjs/classes/index.d.ts +0 -15
  63. package/dist/cjs/classes/index.js +0 -63
  64. package/dist/cjs/classes/index.js.map +0 -1
  65. package/dist/cjs/classes/introspector.d.ts +0 -20
  66. package/dist/cjs/classes/introspector.js +0 -130
  67. package/dist/cjs/classes/introspector.js.map +0 -1
  68. package/dist/cjs/classes/iterable.d.ts +0 -169
  69. package/dist/cjs/classes/iterable.js +0 -268
  70. package/dist/cjs/classes/iterable.js.map +0 -1
  71. package/dist/cjs/classes/param.parser.d.ts +0 -221
  72. package/dist/cjs/classes/param.parser.js +0 -242
  73. package/dist/cjs/classes/param.parser.js.map +0 -1
  74. package/dist/cjs/classes/pluggable.proxy.d.ts +0 -153
  75. package/dist/cjs/classes/pluggable.proxy.js +0 -444
  76. package/dist/cjs/classes/pluggable.proxy.js.map +0 -1
  77. package/dist/cjs/classes/property.d.ts +0 -79
  78. package/dist/cjs/classes/property.js +0 -284
  79. package/dist/cjs/classes/property.js.map +0 -1
  80. package/dist/cjs/classes/refmap.d.ts +0 -238
  81. package/dist/cjs/classes/refmap.js +0 -421
  82. package/dist/cjs/classes/refmap.js.map +0 -1
  83. package/dist/cjs/classes/refset.d.ts +0 -186
  84. package/dist/cjs/classes/refset.js +0 -370
  85. package/dist/cjs/classes/refset.js.map +0 -1
  86. package/dist/cjs/classes/symkeys.d.ts +0 -349
  87. package/dist/cjs/classes/symkeys.js +0 -510
  88. package/dist/cjs/classes/symkeys.js.map +0 -1
  89. package/dist/cjs/classes/type.d.ts +0 -56
  90. package/dist/cjs/classes/type.js +0 -405
  91. package/dist/cjs/classes/type.js.map +0 -1
  92. package/dist/cjs/function.extensions.d.ts +0 -12
  93. package/dist/cjs/function.extensions.js +0 -758
  94. package/dist/cjs/function.extensions.js.map +0 -1
  95. package/dist/cjs/global.this.d.ts +0 -2
  96. package/dist/cjs/global.this.js +0 -300
  97. package/dist/cjs/global.this.js.map +0 -1
  98. package/dist/cjs/index.d.ts +0 -31
  99. package/dist/cjs/index.js +0 -228
  100. package/dist/cjs/index.js.map +0 -1
  101. package/dist/cjs/json.extensions.d.ts +0 -2
  102. package/dist/cjs/json.extensions.js +0 -109
  103. package/dist/cjs/json.extensions.js.map +0 -1
  104. package/dist/cjs/map.extensions.d.ts +0 -3
  105. package/dist/cjs/map.extensions.js +0 -143
  106. package/dist/cjs/map.extensions.js.map +0 -1
  107. package/dist/cjs/math.extension.d.ts +0 -14
  108. package/dist/cjs/math.extension.js +0 -71
  109. package/dist/cjs/math.extension.js.map +0 -1
  110. package/dist/cjs/number.extension.d.ts +0 -44
  111. package/dist/cjs/number.extension.js +0 -278
  112. package/dist/cjs/number.extension.js.map +0 -1
  113. package/dist/cjs/object.extensions.d.ts +0 -33
  114. package/dist/cjs/object.extensions.js +0 -1091
  115. package/dist/cjs/object.extensions.js.map +0 -1
  116. package/dist/cjs/package.json +0 -3
  117. package/dist/cjs/proxy.extensions.d.ts +0 -2
  118. package/dist/cjs/proxy.extensions.js +0 -207
  119. package/dist/cjs/proxy.extensions.js.map +0 -1
  120. package/dist/cjs/reflect.extensions.d.ts +0 -14
  121. package/dist/cjs/reflect.extensions.js +0 -316
  122. package/dist/cjs/reflect.extensions.js.map +0 -1
  123. package/dist/cjs/regular.expression.extensions.d.ts +0 -2
  124. package/dist/cjs/regular.expression.extensions.js +0 -423
  125. package/dist/cjs/regular.expression.extensions.js.map +0 -1
  126. package/dist/cjs/set.extensions.d.ts +0 -40
  127. package/dist/cjs/set.extensions.js +0 -355
  128. package/dist/cjs/set.extensions.js.map +0 -1
  129. package/dist/cjs/string.extensions.d.ts +0 -23
  130. package/dist/cjs/string.extensions.js +0 -704
  131. package/dist/cjs/string.extensions.js.map +0 -1
  132. package/dist/cjs/symbol.extensions.d.ts +0 -11
  133. package/dist/cjs/symbol.extensions.js +0 -735
  134. package/dist/cjs/symbol.extensions.js.map +0 -1
  135. package/dist/cjs/utils/copy.object.d.ts +0 -408
  136. package/dist/cjs/utils/copy.object.js +0 -720
  137. package/dist/cjs/utils/copy.object.js.map +0 -1
  138. package/dist/cjs/utils/descriptor.utils.d.ts +0 -298
  139. package/dist/cjs/utils/descriptor.utils.js +0 -889
  140. package/dist/cjs/utils/descriptor.utils.js.map +0 -1
  141. package/dist/cjs/utils/index.d.ts +0 -75
  142. package/dist/cjs/utils/index.js +0 -61
  143. package/dist/cjs/utils/index.js.map +0 -1
  144. package/dist/cjs/utils/stdout.d.ts +0 -742
  145. package/dist/cjs/utils/stdout.js +0 -1042
  146. package/dist/cjs/utils/stdout.js.map +0 -1
  147. package/dist/cjs/utils/toolkit.d.ts +0 -1898
  148. package/dist/cjs/utils/toolkit.js +0 -1378
  149. package/dist/cjs/utils/toolkit.js.map +0 -1
  150. package/dist/cjs/weakref.extensions.d.ts +0 -2
  151. package/dist/cjs/weakref.extensions.js +0 -19
  152. package/dist/cjs/weakref.extensions.js.map +0 -1
  153. package/dist/mjs/array.extensions.d.ts +0 -39
  154. package/dist/mjs/array.extensions.js +0 -474
  155. package/dist/mjs/array.extensions.js.map +0 -1
  156. package/dist/mjs/big.int.extension.d.ts +0 -31
  157. package/dist/mjs/big.int.extension.js +0 -270
  158. package/dist/mjs/big.int.extension.js.map +0 -1
  159. package/dist/mjs/classes/asyncIterable.d.ts +0 -126
  160. package/dist/mjs/classes/asyncIterable.js +0 -204
  161. package/dist/mjs/classes/asyncIterable.js.map +0 -1
  162. package/dist/mjs/classes/deferred.d.ts +0 -146
  163. package/dist/mjs/classes/deferred.js +0 -287
  164. package/dist/mjs/classes/deferred.js.map +0 -1
  165. package/dist/mjs/classes/descriptor.d.ts +0 -334
  166. package/dist/mjs/classes/descriptor.js +0 -533
  167. package/dist/mjs/classes/descriptor.js.map +0 -1
  168. package/dist/mjs/classes/enum.d.ts +0 -50
  169. package/dist/mjs/classes/enum.js +0 -400
  170. package/dist/mjs/classes/enum.js.map +0 -1
  171. package/dist/mjs/classes/index.d.ts +0 -15
  172. package/dist/mjs/classes/index.js +0 -46
  173. package/dist/mjs/classes/index.js.map +0 -1
  174. package/dist/mjs/classes/introspector.d.ts +0 -20
  175. package/dist/mjs/classes/introspector.js +0 -126
  176. package/dist/mjs/classes/introspector.js.map +0 -1
  177. package/dist/mjs/classes/iterable.d.ts +0 -169
  178. package/dist/mjs/classes/iterable.js +0 -263
  179. package/dist/mjs/classes/iterable.js.map +0 -1
  180. package/dist/mjs/classes/param.parser.d.ts +0 -221
  181. package/dist/mjs/classes/param.parser.js +0 -238
  182. package/dist/mjs/classes/param.parser.js.map +0 -1
  183. package/dist/mjs/classes/pluggable.proxy.d.ts +0 -153
  184. package/dist/mjs/classes/pluggable.proxy.js +0 -438
  185. package/dist/mjs/classes/pluggable.proxy.js.map +0 -1
  186. package/dist/mjs/classes/property.d.ts +0 -79
  187. package/dist/mjs/classes/property.js +0 -280
  188. package/dist/mjs/classes/property.js.map +0 -1
  189. package/dist/mjs/classes/refmap.d.ts +0 -238
  190. package/dist/mjs/classes/refmap.js +0 -417
  191. package/dist/mjs/classes/refmap.js.map +0 -1
  192. package/dist/mjs/classes/refset.d.ts +0 -186
  193. package/dist/mjs/classes/refset.js +0 -366
  194. package/dist/mjs/classes/refset.js.map +0 -1
  195. package/dist/mjs/classes/symkeys.d.ts +0 -349
  196. package/dist/mjs/classes/symkeys.js +0 -506
  197. package/dist/mjs/classes/symkeys.js.map +0 -1
  198. package/dist/mjs/classes/type.d.ts +0 -56
  199. package/dist/mjs/classes/type.js +0 -401
  200. package/dist/mjs/classes/type.js.map +0 -1
  201. package/dist/mjs/function.extensions.d.ts +0 -12
  202. package/dist/mjs/function.extensions.js +0 -755
  203. package/dist/mjs/function.extensions.js.map +0 -1
  204. package/dist/mjs/global.this.d.ts +0 -2
  205. package/dist/mjs/global.this.js +0 -264
  206. package/dist/mjs/global.this.js.map +0 -1
  207. package/dist/mjs/index.d.ts +0 -31
  208. package/dist/mjs/index.js +0 -206
  209. package/dist/mjs/index.js.map +0 -1
  210. package/dist/mjs/json.extensions.d.ts +0 -2
  211. package/dist/mjs/json.extensions.js +0 -106
  212. package/dist/mjs/json.extensions.js.map +0 -1
  213. package/dist/mjs/map.extensions.d.ts +0 -3
  214. package/dist/mjs/map.extensions.js +0 -140
  215. package/dist/mjs/map.extensions.js.map +0 -1
  216. package/dist/mjs/math.extension.d.ts +0 -14
  217. package/dist/mjs/math.extension.js +0 -68
  218. package/dist/mjs/math.extension.js.map +0 -1
  219. package/dist/mjs/number.extension.d.ts +0 -44
  220. package/dist/mjs/number.extension.js +0 -275
  221. package/dist/mjs/number.extension.js.map +0 -1
  222. package/dist/mjs/object.extensions.d.ts +0 -33
  223. package/dist/mjs/object.extensions.js +0 -1088
  224. package/dist/mjs/object.extensions.js.map +0 -1
  225. package/dist/mjs/package.json +0 -3
  226. package/dist/mjs/proxy.extensions.d.ts +0 -2
  227. package/dist/mjs/proxy.extensions.js +0 -204
  228. package/dist/mjs/proxy.extensions.js.map +0 -1
  229. package/dist/mjs/reflect.extensions.d.ts +0 -14
  230. package/dist/mjs/reflect.extensions.js +0 -313
  231. package/dist/mjs/reflect.extensions.js.map +0 -1
  232. package/dist/mjs/regular.expression.extensions.d.ts +0 -2
  233. package/dist/mjs/regular.expression.extensions.js +0 -420
  234. package/dist/mjs/regular.expression.extensions.js.map +0 -1
  235. package/dist/mjs/set.extensions.d.ts +0 -40
  236. package/dist/mjs/set.extensions.js +0 -352
  237. package/dist/mjs/set.extensions.js.map +0 -1
  238. package/dist/mjs/string.extensions.d.ts +0 -23
  239. package/dist/mjs/string.extensions.js +0 -701
  240. package/dist/mjs/string.extensions.js.map +0 -1
  241. package/dist/mjs/symbol.extensions.d.ts +0 -11
  242. package/dist/mjs/symbol.extensions.js +0 -732
  243. package/dist/mjs/symbol.extensions.js.map +0 -1
  244. package/dist/mjs/utils/copy.object.d.ts +0 -408
  245. package/dist/mjs/utils/copy.object.js +0 -702
  246. package/dist/mjs/utils/copy.object.js.map +0 -1
  247. package/dist/mjs/utils/descriptor.utils.d.ts +0 -298
  248. package/dist/mjs/utils/descriptor.utils.js +0 -875
  249. package/dist/mjs/utils/descriptor.utils.js.map +0 -1
  250. package/dist/mjs/utils/index.d.ts +0 -75
  251. package/dist/mjs/utils/index.js +0 -45
  252. package/dist/mjs/utils/index.js.map +0 -1
  253. package/dist/mjs/utils/stdout.d.ts +0 -742
  254. package/dist/mjs/utils/stdout.js +0 -1037
  255. package/dist/mjs/utils/stdout.js.map +0 -1
  256. package/dist/mjs/utils/toolkit.d.ts +0 -1898
  257. package/dist/mjs/utils/toolkit.js +0 -1373
  258. package/dist/mjs/utils/toolkit.js.map +0 -1
  259. package/dist/mjs/weakref.extensions.d.ts +0 -2
  260. package/dist/mjs/weakref.extensions.js +0 -16
  261. package/dist/mjs/weakref.extensions.js.map +0 -1
  262. package/jsdoc-config.json +0 -31
  263. package/tsconfig.base.json +0 -28
  264. package/tsconfig.cjs.json +0 -8
  265. package/tsconfig.esm.json +0 -8
  266. package/vitest.config.js +0 -7
@@ -1,349 +0,0 @@
1
- /**
2
- * Represents a secure container for storing and retrieving unique symbols
3
- * associated with data. This class provides methods to add new symbols to
4
- * the Symkeys and to retrieve data associated with a particular symbol.
5
- *
6
- * @example
7
- * // Create a new Symkeys instance
8
- * const symkeys = new Symkeys();
9
- *
10
- * // Add a symbol with associated data to the Symkeys
11
- * const mySymbol = Symkeys.add('myIdentifier', { foo: 'bar' });
12
- *
13
- * // Retrieve the data using the symbol
14
- * const myData = Symkeys.dataFor(mySymbol);
15
- * console.log(myData); // Output: { foo: 'bar' }
16
- */
17
- export class Symkeys {
18
- /**
19
- * Checks if a given value is a Symkey.
20
- *
21
- * This method checks if the provided value is a Symkey. A Symkey is a
22
- * symbol that matches a specific pattern. The pattern is defined as a
23
- * symbol that starts with '@', followed by any characters, a space, a '#',
24
- * and ends with one or more word characters.
25
- *
26
- * @param {Symbol} value - The value to check.
27
- * @returns {boolean} Returns true if the value is a Symkey, false otherwise.
28
- *
29
- * @example
30
- * // Check if a symbol is a Symkey:
31
- * const sym = Symbol('@nejs.prototype #rwiy2o905d');
32
- * console.log(Symkeys.isSymkey(sym)); // Outputs: true
33
- */
34
- static isSymkey(value: Symbol): boolean;
35
- /**
36
- * Generates a random token string.
37
- *
38
- * This method creates a pseudo-random token that can be used for various
39
- * purposes within the library, such as generating unique identifiers or
40
- * keys. The token is generated using a base 36 encoding, which includes
41
- * numbers and lowercase letters.
42
- *
43
- * @returns A random token string.
44
- *
45
- * @example
46
- * // Example of getting a random token:
47
- * const token = MyClass.token;
48
- * console.log(token); // Outputs a string like 'qg6k1zr0is'
49
- */
50
- static get token(): string;
51
- /**
52
- * Reusable publicly static key for identifying where data is stored.
53
- */
54
- static get kDataKey(): symbol;
55
- /**
56
- * Reusable publicly static key for identifying where data is stored.
57
- */
58
- static get kPrototype(): symbol;
59
- /**
60
- * A static getter that returns a unique, reusable symbol for 'symkeys.domain'.
61
- *
62
- * This getter is used to create a unique symbol that can be used as a key
63
- * for storing and retrieving domain-specific data in the Symkeys. The symbol
64
- * is created using the `Symbol.for` method, which ensures that the same
65
- * symbol is returned for a given key, in this case 'symkeys.domain'.
66
- *
67
- * @returns {Symbol} A unique symbol for 'symkeys.domain'.
68
- *
69
- * @example
70
- * // Retrieve the 'symkeys.domain' symbol
71
- * const domainSymbol = Symkeys.kDomain;
72
- * console.log(domainSymbol); // Outputs: Symbol(symkeys.domain)
73
- */
74
- static get kDomain(): Symbol;
75
- /**
76
- * A static getter that returns a unique, reusable symbol for 'symkeys.separator'.
77
- *
78
- * This getter is used to create a unique symbol that can be used as a key
79
- * for storing and retrieving separator-specific data in the Symkeys. The symbol
80
- * is created using the `Symbol.for` method, which ensures that the same
81
- * symbol is returned for a given key, in this case 'symkeys.separator'.
82
- *
83
- * @returns {Symbol} A unique symbol for 'symkeys.separator'.
84
- *
85
- * @example
86
- * // Retrieve the 'symkeys.separator' symbol
87
- * const separatorSymbol = Symkeys.kSeparator;
88
- * console.log(separatorSymbol); // Outputs: Symbol(symkeys.separator)
89
- */
90
- static get kSeparator(): Symbol;
91
- /**
92
- * Constructs a new instance of the Symkeys, setting up a proxy to
93
- * intercept and manage access to properties.
94
- *
95
- * This constructor initializes the Symkeys with a proxy that
96
- * overrides the default behavior for property access, checking, and
97
- * enumeration. It allows the Symkeys to behave like a map for its
98
- * own properties, while also maintaining the prototype chain.
99
- *
100
- * @param {string} domain an optional prefix string, to which the
101
- * `separator` parameter value will be guaranteed to have in between
102
- * the domain (if truthy) and the name of the added key.
103
- * @param {string} separator defaults to a period. So if your domain
104
- * is 'symkeys.internal' then calling {@link add()} with a name of
105
- * `"feature"` will result in the full name being
106
- * `"symkeys.internal.feature"`
107
- *
108
- * @example
109
- * const Symkeys = new Symkeys();
110
- * Symkeys[Symbol.for('myProperty')] = 'myValue';
111
- * console.log(Symkeys[Symbol.for('myProperty')]); // 'myValue'
112
- */
113
- constructor(domain?: string, separator?: string);
114
- /**
115
- * Adds a new symbol to the Symkeys instance with the given name and
116
- * associated data.
117
- *
118
- * This method generates a unique symbol based on the provided name,
119
- * optional domain, separator, and token. It also allows embedding
120
- * additional data into the symbol's name.
121
- *
122
- * @param {string} named - The base name for the new symbol.
123
- * @param {Object} options - Additional options for the symbol.
124
- * @param {*} [options.associate={}] - Data to associate with the symbol.
125
- * @param {Object} [options.embed] - Optional data to embed in the symbol.
126
- * @param {string} [options.useDomain] - Optional domain to include in the
127
- * symbol's name.
128
- * @param {string} [options.useSeparator] - Optional separator to use in
129
- * the symbol's name.
130
- * @param {string} [options.useToken] - Optional token to use for the
131
- * symbol. If not provided, a random token is generated.
132
- * @returns {Symbol} The newly created symbol.
133
- *
134
- * @example
135
- * // Add a symbol with associated data
136
- * const mySymbol = symkeys.add('myIdentifier', {
137
- * associate: { foo: 'bar' },
138
- * embed: { baz: 'qux' },
139
- * useDomain: 'exampleDomain',
140
- * useSeparator: '-',
141
- * useToken: 'customToken',
142
- * })
143
- * console.log(mySymbol)
144
- * // Symbol(@exampleDomain-myIdentifier {"baz":"qux"} #customToken)
145
- */
146
- add(named: string, { associate, embed, useDomain, useSeparator, useToken, }: {
147
- associate?: any;
148
- embed?: Object | undefined;
149
- useDomain?: string | undefined;
150
- useSeparator?: string | undefined;
151
- useToken?: string | undefined;
152
- }): Symbol;
153
- /**
154
- * Creates or retrieves a shared symbol key with the given name and
155
- * optional associated data.
156
- *
157
- * This method generates a shared symbol key using the provided name
158
- * and optional parameters. If the symbol already exists in the
159
- * Symkeys's internal map, it updates the associated data if provided.
160
- * Otherwise, it creates a new symbol with the specified parameters.
161
- *
162
- * @param {string} named - The name to use for the shared symbol key.
163
- * @param {Object} options - Optional parameters for the shared symbol key.
164
- * @param {Object} [options.associate] - Data to associate with the symbol.
165
- * @param {Object} [options.embed] - Data to embed in the symbol's name.
166
- * @param {string} [options.useDomain] - Domain to include in the symbol's name.
167
- * @param {string} [options.useSeparator] - Separator to use in the symbol's name.
168
- * @returns {Symbol} The shared symbol key.
169
- *
170
- * @example
171
- * // Create or retrieve a shared symbol key with associated data
172
- * const sharedSymbol = symkeys.sharedKey('mySharedKey', {
173
- * associate: { foo: 'bar' },
174
- * embed: { baz: 'qux' },
175
- * useDomain: 'exampleDomain',
176
- * useSeparator: '-',
177
- * })
178
- * console.log(sharedSymbol)
179
- * // Symbol(@exampleDomain-mySharedKey {"baz":"qux"} #shared)
180
- */
181
- sharedKey(named: string, { associate, embed, useDomain, useSeparator }: {
182
- associate?: Object | undefined;
183
- embed?: Object | undefined;
184
- useDomain?: string | undefined;
185
- useSeparator?: string | undefined;
186
- }): Symbol;
187
- /**
188
- * Retrieves the data associated with a given symbol from the Symkeys.
189
- *
190
- * This method allows access to the data that has been associated with a
191
- * particular symbol in the Symkeys. It is useful for retrieving stored
192
- * information when only the symbol is known.
193
- *
194
- * @param symbol - The symbol whose associated data is to be
195
- * retrieved.
196
- * @returns The data associated with the symbol, or undefined if
197
- * the symbol is not found in the Symkeys.
198
- *
199
- * @example
200
- * // Assuming 'mySymbol' is a symbol that has been added to the Symkeys
201
- * // with associated data
202
- * const data = Symkeys.dataFor(mySymbol);
203
- * console.log(data); // Output: The data associated with 'mySymbol'
204
- */
205
- data(forSymbol: any): any;
206
- /**
207
- * Deletes the data associated with a given symbol from the Symkeys.
208
- *
209
- * This method allows removal of the data that has been associated with a
210
- * particular symbol in the Symkeys. It is useful when you want to clean up
211
- * or remove stored information associated with a symbol.
212
- *
213
- * @param {Symbol} forSymbol - The symbol whose associated data is to be
214
- * deleted.
215
- * @param {*} replaceWith - Optionally, if `replaceWith` is not `undefined`,
216
- * a new value can be set after the original is deleted
217
- * @returns {boolean} - Returns true if an element in the Symkeys existed and
218
- * has been removed, or false if the element does not exist
219
- *
220
- * @example
221
- * // Assuming 'mySymbol' is a symbol that has been added to the Symkeys
222
- * // with associated data
223
- * const isDeleted = Symkeys.deleteData(mySymbol);
224
- * console.log(isDeleted); // Output: true if data was deleted, false otherwise
225
- */
226
- deleteData(forSymbol: Symbol, replaceWith?: any): boolean;
227
- /**
228
- * Checks if the Symkeys instance has data associated with a given symbol.
229
- *
230
- * This method checks if the Symkeys instance has any data associated with
231
- * the provided symbol. It is useful when you need to verify if data exists
232
- * for a particular symbol before attempting to retrieve or manipulate it.
233
- *
234
- * @param {Symbol} forSymbol - The symbol to check for associated data.
235
- * @returns {boolean} Returns true if data exists for the symbol, false otherwise.
236
- *
237
- * @example
238
- * // Assuming 'mySymbol' is a symbol that has been added to the Symkeys
239
- * // with associated data
240
- * const hasData = Symkeys.hasData(mySymbol);
241
- * console.log(hasData); // Output: true if data exists, false otherwise
242
- */
243
- hasData(forSymbol: Symbol): boolean;
244
- /**
245
- * Sets the data associated with a given symbol in the Symkeys.
246
- *
247
- * This method allows you to associate data with a particular symbol in the
248
- * Symkeys. It is useful when you want to store information that can be
249
- * retrieved later using the symbol.
250
- *
251
- * Note that setting only succeeds if the Symkey symbol has already been
252
- * added via {@link Symkeys.add}
253
- *
254
- * @param {Symbol} forSymbol - The symbol with which the data is to be
255
- * associated.
256
- * @param {*} value - The data to be associated with the symbol.
257
- * @returns {boolean} true if the value has been set, false if the key
258
- * has not yet been added via {@link Symkeys.add}
259
- *
260
- * @example
261
- * // Assuming 'mySymbol' is a symbol that has been added to the Symkeys
262
- * // and 'myData' is the data to be associated with 'mySymbol'
263
- * Symkeys.setData(mySymbol, myData);
264
- */
265
- setData(forSymbol: Symbol, value: any): boolean;
266
- /**
267
- * Extracts the token part from a symbol created by the `add` method.
268
- *
269
- * This method parses the string representation of a symbol to retrieve
270
- * the unique token that was appended to the symbol's name upon creation.
271
- * It is useful for debugging or for operations that require knowledge of
272
- * the token associated with a symbol.
273
- *
274
- * @param symbol - The symbol whose token is to be extracted.
275
- * @returns The extracted token or undefined if the
276
- * token cannot be extracted.
277
- *
278
- * @example
279
- * // Assuming 'mySymbol' is a symbol created with the name 'myEntry'
280
- * // and a token 'agftofxob6f'
281
- * const token = Symkeys.tokenFor(mySymbol);
282
- * console.log(token); // Output: 'agftofxob6f'
283
- */
284
- token(forSymbol: any): any;
285
- /**
286
- * Retrieves the separator used in the Symkeys instance.
287
- *
288
- * This getter method allows access to the separator that is used to
289
- * distinguish between different parts of a symbol in the Symkeys instance.
290
- * It is useful when you need to know the separator for parsing symbols or
291
- * constructing new ones.
292
- *
293
- * @returns {string} The separator used in the Symkeys instance.
294
- *
295
- * @example
296
- * // Assuming the Symkeys instance has a separator '.'
297
- * const separator = Symkeys.separator;
298
- * console.log(separator); // Output: '.'
299
- */
300
- get separator(): string;
301
- /**
302
- * Retrieves an iterator for the symbols stored in the Symkeys.
303
- *
304
- * This method provides access to the symbols that have been stored in
305
- * the Symkeys. It returns an iterator which can be used to loop over
306
- * all the symbols. This is particularly useful for iterating through
307
- * all stored data without knowing the individual symbols in advance.
308
- *
309
- * @returns An iterator that yields all the symbols
310
- * stored in the Symkeys.
311
- *
312
- * @example
313
- * // Assuming the Symkeys has symbols stored
314
- * for (const symbol of Symkeys.symbols()) {
315
- * console.log(symbol);
316
- * }
317
- */
318
- symbols(): any;
319
- /**
320
- * Calculates a name by combining a provided name, domain, and separator.
321
- *
322
- * This method takes a provided name, domain, and separator as input and
323
- * constructs a new name by combining these elements. If the domain or
324
- * separator are not provided, it uses the default domain and separator
325
- * stored in the Symkeys instance. If the provided name starts with the
326
- * separator, it removes the leading separator from the name.
327
- *
328
- * If the domain ends with the separator, it removes the trailing separator
329
- * from the domain. If the domain is empty, it sets the separator to an
330
- * empty string.
331
- *
332
- * @param {string} providedName - The name to be used in the calculation.
333
- * @param {string} [useDomain] - The domain to be used in the calculation.
334
- * If not provided, the default domain of the Symkeys instance is used.
335
- * @param {string} [useSeparator] - The separator to be used in the
336
- * calculation. If not provided, the default separator of the Symkeys
337
- * instance is used.
338
- * @returns {string} The calculated name.
339
- *
340
- * @example
341
- * // Assuming the Symkeys instance has a domain 'symkeys.internal'
342
- * // and a separator '.'
343
- * const name = Symkeys.calculateName('feature', 'symkeys.public', '/');
344
- * console.log(name); // Output: 'symkeys.public/feature'
345
- */
346
- calculateName(providedName: string, useDomain?: string, useSeparator?: string): string;
347
- }
348
- export const SymkeysExtension: Extension;
349
- import { Extension } from '@nejs/extension';