@nejs/basic-extensions 2.21.0 → 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 (270) hide show
  1. package/.idea/markdown.xml +8 -0
  2. package/.idea/modules.xml +8 -0
  3. package/.idea/ne-basic-extensions.iml +8 -0
  4. package/.idea/vcs.xml +6 -0
  5. package/CODE_STYLE.md +393 -0
  6. package/CODING_PHILOSOPHY.md +36 -0
  7. package/DOCUMENTATION_GUIDELINES.md +221 -0
  8. package/README.md +78 -4
  9. package/dist/@nejs/basic-extensions.bundle.2.22.6.js +25 -0
  10. package/dist/@nejs/basic-extensions.bundle.2.22.6.js.map +7 -0
  11. package/dist/cjs/classes/index.cjs +11129 -0
  12. package/dist/cjs/classes/index.cjs.map +7 -0
  13. package/dist/cjs/index.cjs +15191 -0
  14. package/dist/cjs/index.cjs.map +7 -0
  15. package/dist/cjs/utils/index.cjs +3954 -0
  16. package/dist/cjs/utils/index.cjs.map +7 -0
  17. package/dist/esm/basic-extensions.mjs +25 -0
  18. package/dist/esm/basic-extensions.mjs.map +7 -0
  19. package/package.json +16 -22
  20. package/repl.bootstrap.js +4 -7
  21. package/repl.history +30 -30
  22. package/src/big.int.extension.js +171 -45
  23. package/src/classes/enumeration.js +466 -0
  24. package/src/classes/index.js +5 -1
  25. package/src/index.js +5 -1
  26. package/src/math.extension.js +73 -0
  27. package/src/number.extension.js +18 -0
  28. package/src/regular.expression.extensions.js +0 -35
  29. package/src/utils/toolkit.js +699 -516
  30. package/tests/arrayextensions.test.js +3 -3
  31. package/tests/index.test.js +3 -1
  32. package/tests/newClasses/asyncIterable.test.js +3 -3
  33. package/tests/newClasses/deferred.test.js +3 -3
  34. package/tests/newClasses/descriptor.test.js +3 -3
  35. package/tests/newClasses/iterable.test.js +3 -3
  36. package/tests/newClasses/refmap.test.js +3 -3
  37. package/tests/newClasses/refset.test.js +3 -3
  38. package/tests/objectextensions.test.js +3 -3
  39. package/tests/setextensions.test.js +3 -3
  40. package/tests/stringextensions.test.js +3 -2
  41. package/tests/utils/descriptor.utils.test.js +1 -1
  42. package/tests/utils/toolkit.test.js +429 -163
  43. package/.esdoc.json +0 -9
  44. package/.vscode/settings.json +0 -5
  45. package/bin/build +0 -27
  46. package/bin/clean +0 -14
  47. package/bin/esbuild +0 -91
  48. package/bin/fixup +0 -13
  49. package/bin/repl.basics.js +0 -584
  50. package/bin/repl.signature.js +0 -63
  51. package/bin/version +0 -100
  52. package/dist/@nejs/basic-extensions.bundle.2.21.0.js +0 -25
  53. package/dist/@nejs/basic-extensions.bundle.2.21.0.js.map +0 -7
  54. package/dist/cjs/array.extensions.d.ts +0 -39
  55. package/dist/cjs/array.extensions.js +0 -477
  56. package/dist/cjs/array.extensions.js.map +0 -1
  57. package/dist/cjs/big.int.extension.d.ts +0 -31
  58. package/dist/cjs/big.int.extension.js +0 -165
  59. package/dist/cjs/big.int.extension.js.map +0 -1
  60. package/dist/cjs/classes/asyncIterable.d.ts +0 -126
  61. package/dist/cjs/classes/asyncIterable.js +0 -209
  62. package/dist/cjs/classes/asyncIterable.js.map +0 -1
  63. package/dist/cjs/classes/deferred.d.ts +0 -146
  64. package/dist/cjs/classes/deferred.js +0 -291
  65. package/dist/cjs/classes/deferred.js.map +0 -1
  66. package/dist/cjs/classes/descriptor.d.ts +0 -334
  67. package/dist/cjs/classes/descriptor.js +0 -537
  68. package/dist/cjs/classes/descriptor.js.map +0 -1
  69. package/dist/cjs/classes/enum.d.ts +0 -50
  70. package/dist/cjs/classes/enum.js +0 -405
  71. package/dist/cjs/classes/enum.js.map +0 -1
  72. package/dist/cjs/classes/index.d.ts +0 -15
  73. package/dist/cjs/classes/index.js +0 -63
  74. package/dist/cjs/classes/index.js.map +0 -1
  75. package/dist/cjs/classes/introspector.d.ts +0 -20
  76. package/dist/cjs/classes/introspector.js +0 -130
  77. package/dist/cjs/classes/introspector.js.map +0 -1
  78. package/dist/cjs/classes/iterable.d.ts +0 -169
  79. package/dist/cjs/classes/iterable.js +0 -268
  80. package/dist/cjs/classes/iterable.js.map +0 -1
  81. package/dist/cjs/classes/param.parser.d.ts +0 -221
  82. package/dist/cjs/classes/param.parser.js +0 -242
  83. package/dist/cjs/classes/param.parser.js.map +0 -1
  84. package/dist/cjs/classes/pluggable.proxy.d.ts +0 -153
  85. package/dist/cjs/classes/pluggable.proxy.js +0 -444
  86. package/dist/cjs/classes/pluggable.proxy.js.map +0 -1
  87. package/dist/cjs/classes/property.d.ts +0 -79
  88. package/dist/cjs/classes/property.js +0 -284
  89. package/dist/cjs/classes/property.js.map +0 -1
  90. package/dist/cjs/classes/refmap.d.ts +0 -238
  91. package/dist/cjs/classes/refmap.js +0 -421
  92. package/dist/cjs/classes/refmap.js.map +0 -1
  93. package/dist/cjs/classes/refset.d.ts +0 -186
  94. package/dist/cjs/classes/refset.js +0 -370
  95. package/dist/cjs/classes/refset.js.map +0 -1
  96. package/dist/cjs/classes/symkeys.d.ts +0 -349
  97. package/dist/cjs/classes/symkeys.js +0 -510
  98. package/dist/cjs/classes/symkeys.js.map +0 -1
  99. package/dist/cjs/classes/type.d.ts +0 -56
  100. package/dist/cjs/classes/type.js +0 -405
  101. package/dist/cjs/classes/type.js.map +0 -1
  102. package/dist/cjs/function.extensions.d.ts +0 -12
  103. package/dist/cjs/function.extensions.js +0 -758
  104. package/dist/cjs/function.extensions.js.map +0 -1
  105. package/dist/cjs/global.this.d.ts +0 -2
  106. package/dist/cjs/global.this.js +0 -300
  107. package/dist/cjs/global.this.js.map +0 -1
  108. package/dist/cjs/index.d.ts +0 -31
  109. package/dist/cjs/index.js +0 -226
  110. package/dist/cjs/index.js.map +0 -1
  111. package/dist/cjs/json.extensions.d.ts +0 -2
  112. package/dist/cjs/json.extensions.js +0 -109
  113. package/dist/cjs/json.extensions.js.map +0 -1
  114. package/dist/cjs/map.extensions.d.ts +0 -3
  115. package/dist/cjs/map.extensions.js +0 -143
  116. package/dist/cjs/map.extensions.js.map +0 -1
  117. package/dist/cjs/number.extension.d.ts +0 -44
  118. package/dist/cjs/number.extension.js +0 -261
  119. package/dist/cjs/number.extension.js.map +0 -1
  120. package/dist/cjs/object.extensions.d.ts +0 -33
  121. package/dist/cjs/object.extensions.js +0 -1091
  122. package/dist/cjs/object.extensions.js.map +0 -1
  123. package/dist/cjs/package.json +0 -3
  124. package/dist/cjs/proxy.extensions.d.ts +0 -2
  125. package/dist/cjs/proxy.extensions.js +0 -207
  126. package/dist/cjs/proxy.extensions.js.map +0 -1
  127. package/dist/cjs/reflect.extensions.d.ts +0 -14
  128. package/dist/cjs/reflect.extensions.js +0 -316
  129. package/dist/cjs/reflect.extensions.js.map +0 -1
  130. package/dist/cjs/regular.expression.extensions.d.ts +0 -2
  131. package/dist/cjs/regular.expression.extensions.js +0 -423
  132. package/dist/cjs/regular.expression.extensions.js.map +0 -1
  133. package/dist/cjs/set.extensions.d.ts +0 -40
  134. package/dist/cjs/set.extensions.js +0 -355
  135. package/dist/cjs/set.extensions.js.map +0 -1
  136. package/dist/cjs/string.extensions.d.ts +0 -23
  137. package/dist/cjs/string.extensions.js +0 -704
  138. package/dist/cjs/string.extensions.js.map +0 -1
  139. package/dist/cjs/symbol.extensions.d.ts +0 -11
  140. package/dist/cjs/symbol.extensions.js +0 -735
  141. package/dist/cjs/symbol.extensions.js.map +0 -1
  142. package/dist/cjs/utils/copy.object.d.ts +0 -408
  143. package/dist/cjs/utils/copy.object.js +0 -720
  144. package/dist/cjs/utils/copy.object.js.map +0 -1
  145. package/dist/cjs/utils/descriptor.utils.d.ts +0 -298
  146. package/dist/cjs/utils/descriptor.utils.js +0 -889
  147. package/dist/cjs/utils/descriptor.utils.js.map +0 -1
  148. package/dist/cjs/utils/index.d.ts +0 -75
  149. package/dist/cjs/utils/index.js +0 -61
  150. package/dist/cjs/utils/index.js.map +0 -1
  151. package/dist/cjs/utils/stdout.d.ts +0 -742
  152. package/dist/cjs/utils/stdout.js +0 -1042
  153. package/dist/cjs/utils/stdout.js.map +0 -1
  154. package/dist/cjs/utils/toolkit.d.ts +0 -1898
  155. package/dist/cjs/utils/toolkit.js +0 -1378
  156. package/dist/cjs/utils/toolkit.js.map +0 -1
  157. package/dist/cjs/weakref.extensions.d.ts +0 -2
  158. package/dist/cjs/weakref.extensions.js +0 -19
  159. package/dist/cjs/weakref.extensions.js.map +0 -1
  160. package/dist/mjs/array.extensions.d.ts +0 -39
  161. package/dist/mjs/array.extensions.js +0 -474
  162. package/dist/mjs/array.extensions.js.map +0 -1
  163. package/dist/mjs/big.int.extension.d.ts +0 -31
  164. package/dist/mjs/big.int.extension.js +0 -162
  165. package/dist/mjs/big.int.extension.js.map +0 -1
  166. package/dist/mjs/classes/asyncIterable.d.ts +0 -126
  167. package/dist/mjs/classes/asyncIterable.js +0 -204
  168. package/dist/mjs/classes/asyncIterable.js.map +0 -1
  169. package/dist/mjs/classes/deferred.d.ts +0 -146
  170. package/dist/mjs/classes/deferred.js +0 -287
  171. package/dist/mjs/classes/deferred.js.map +0 -1
  172. package/dist/mjs/classes/descriptor.d.ts +0 -334
  173. package/dist/mjs/classes/descriptor.js +0 -533
  174. package/dist/mjs/classes/descriptor.js.map +0 -1
  175. package/dist/mjs/classes/enum.d.ts +0 -50
  176. package/dist/mjs/classes/enum.js +0 -400
  177. package/dist/mjs/classes/enum.js.map +0 -1
  178. package/dist/mjs/classes/index.d.ts +0 -15
  179. package/dist/mjs/classes/index.js +0 -46
  180. package/dist/mjs/classes/index.js.map +0 -1
  181. package/dist/mjs/classes/introspector.d.ts +0 -20
  182. package/dist/mjs/classes/introspector.js +0 -126
  183. package/dist/mjs/classes/introspector.js.map +0 -1
  184. package/dist/mjs/classes/iterable.d.ts +0 -169
  185. package/dist/mjs/classes/iterable.js +0 -263
  186. package/dist/mjs/classes/iterable.js.map +0 -1
  187. package/dist/mjs/classes/param.parser.d.ts +0 -221
  188. package/dist/mjs/classes/param.parser.js +0 -238
  189. package/dist/mjs/classes/param.parser.js.map +0 -1
  190. package/dist/mjs/classes/pluggable.proxy.d.ts +0 -153
  191. package/dist/mjs/classes/pluggable.proxy.js +0 -438
  192. package/dist/mjs/classes/pluggable.proxy.js.map +0 -1
  193. package/dist/mjs/classes/property.d.ts +0 -79
  194. package/dist/mjs/classes/property.js +0 -280
  195. package/dist/mjs/classes/property.js.map +0 -1
  196. package/dist/mjs/classes/refmap.d.ts +0 -238
  197. package/dist/mjs/classes/refmap.js +0 -417
  198. package/dist/mjs/classes/refmap.js.map +0 -1
  199. package/dist/mjs/classes/refset.d.ts +0 -186
  200. package/dist/mjs/classes/refset.js +0 -366
  201. package/dist/mjs/classes/refset.js.map +0 -1
  202. package/dist/mjs/classes/symkeys.d.ts +0 -349
  203. package/dist/mjs/classes/symkeys.js +0 -506
  204. package/dist/mjs/classes/symkeys.js.map +0 -1
  205. package/dist/mjs/classes/type.d.ts +0 -56
  206. package/dist/mjs/classes/type.js +0 -401
  207. package/dist/mjs/classes/type.js.map +0 -1
  208. package/dist/mjs/function.extensions.d.ts +0 -12
  209. package/dist/mjs/function.extensions.js +0 -755
  210. package/dist/mjs/function.extensions.js.map +0 -1
  211. package/dist/mjs/global.this.d.ts +0 -2
  212. package/dist/mjs/global.this.js +0 -264
  213. package/dist/mjs/global.this.js.map +0 -1
  214. package/dist/mjs/index.d.ts +0 -31
  215. package/dist/mjs/index.js +0 -204
  216. package/dist/mjs/index.js.map +0 -1
  217. package/dist/mjs/json.extensions.d.ts +0 -2
  218. package/dist/mjs/json.extensions.js +0 -106
  219. package/dist/mjs/json.extensions.js.map +0 -1
  220. package/dist/mjs/map.extensions.d.ts +0 -3
  221. package/dist/mjs/map.extensions.js +0 -140
  222. package/dist/mjs/map.extensions.js.map +0 -1
  223. package/dist/mjs/number.extension.d.ts +0 -44
  224. package/dist/mjs/number.extension.js +0 -258
  225. package/dist/mjs/number.extension.js.map +0 -1
  226. package/dist/mjs/object.extensions.d.ts +0 -33
  227. package/dist/mjs/object.extensions.js +0 -1088
  228. package/dist/mjs/object.extensions.js.map +0 -1
  229. package/dist/mjs/package.json +0 -3
  230. package/dist/mjs/proxy.extensions.d.ts +0 -2
  231. package/dist/mjs/proxy.extensions.js +0 -204
  232. package/dist/mjs/proxy.extensions.js.map +0 -1
  233. package/dist/mjs/reflect.extensions.d.ts +0 -14
  234. package/dist/mjs/reflect.extensions.js +0 -313
  235. package/dist/mjs/reflect.extensions.js.map +0 -1
  236. package/dist/mjs/regular.expression.extensions.d.ts +0 -2
  237. package/dist/mjs/regular.expression.extensions.js +0 -420
  238. package/dist/mjs/regular.expression.extensions.js.map +0 -1
  239. package/dist/mjs/set.extensions.d.ts +0 -40
  240. package/dist/mjs/set.extensions.js +0 -352
  241. package/dist/mjs/set.extensions.js.map +0 -1
  242. package/dist/mjs/string.extensions.d.ts +0 -23
  243. package/dist/mjs/string.extensions.js +0 -701
  244. package/dist/mjs/string.extensions.js.map +0 -1
  245. package/dist/mjs/symbol.extensions.d.ts +0 -11
  246. package/dist/mjs/symbol.extensions.js +0 -732
  247. package/dist/mjs/symbol.extensions.js.map +0 -1
  248. package/dist/mjs/utils/copy.object.d.ts +0 -408
  249. package/dist/mjs/utils/copy.object.js +0 -702
  250. package/dist/mjs/utils/copy.object.js.map +0 -1
  251. package/dist/mjs/utils/descriptor.utils.d.ts +0 -298
  252. package/dist/mjs/utils/descriptor.utils.js +0 -875
  253. package/dist/mjs/utils/descriptor.utils.js.map +0 -1
  254. package/dist/mjs/utils/index.d.ts +0 -75
  255. package/dist/mjs/utils/index.js +0 -45
  256. package/dist/mjs/utils/index.js.map +0 -1
  257. package/dist/mjs/utils/stdout.d.ts +0 -742
  258. package/dist/mjs/utils/stdout.js +0 -1037
  259. package/dist/mjs/utils/stdout.js.map +0 -1
  260. package/dist/mjs/utils/toolkit.d.ts +0 -1898
  261. package/dist/mjs/utils/toolkit.js +0 -1373
  262. package/dist/mjs/utils/toolkit.js.map +0 -1
  263. package/dist/mjs/weakref.extensions.d.ts +0 -2
  264. package/dist/mjs/weakref.extensions.js +0 -16
  265. package/dist/mjs/weakref.extensions.js.map +0 -1
  266. package/jsdoc-config.json +0 -31
  267. package/tsconfig.base.json +0 -28
  268. package/tsconfig.cjs.json +0 -8
  269. package/tsconfig.esm.json +0 -8
  270. 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';