@zoodogood/utils 1.2.0-change.1444 → 1.2.3-change.1466

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.
@@ -38,6 +38,7 @@ declare class CapturedContent {
38
38
  content: TCaptureValue;
39
39
  context?: CliParserRunContext;
40
40
  constructor(content: TCaptureValue);
41
+ isFlagMatchArray(): boolean;
41
42
  setContextInstance(context: CapturedContent["context"]): this;
42
43
  isRegexMatchArray(): boolean;
43
44
  isString(): boolean;
@@ -51,15 +51,16 @@ class FlagsManager {
51
51
  captureFlags(flags, context) {
52
52
  for (const { name, capture, expectValue } of flags) {
53
53
  for (const flag of capture) {
54
- const regex = `(?<=^|\\s)${flag}${expectValue ? "(?:(?:\\s+|=)(?<value>[^\\s]+))" : ""}`;
54
+ const regex = `(?<=^|\\s)${flag}${expectValue ? "(?:(?:\\s+(?!-)|=)(?<value>[^\\s]+))" : ""}`;
55
55
  const { parser } = context;
56
56
  const captureName = name || flag;
57
57
  const match = parser.replaceByMatch(RegExp(regex, "i"));
58
58
  if (!match) {
59
- context.captures.set(`${captureName}`, null);
59
+ !context.captures.has(`${captureName}`) &&
60
+ context.captures.set(`${captureName}`, null);
60
61
  continue;
61
62
  }
62
- context.captures.set(`${captureName}`, new CapturedContent(match).setContextInstance(context));
63
+ context.captures.set(`${captureName}`, new CapturedContentFlagMatchArray(match).setContextInstance(context));
63
64
  }
64
65
  }
65
66
  return this;
@@ -69,6 +70,9 @@ class CapturedContent {
69
70
  constructor(content) {
70
71
  this.content = content;
71
72
  }
73
+ isFlagMatchArray() {
74
+ return this instanceof CapturedContentFlagMatchArray;
75
+ }
72
76
  setContextInstance(context) {
73
77
  this.context = context;
74
78
  return this;
@@ -140,7 +144,7 @@ class CapturedContent {
140
144
  content = this.regexArrayOrStringToString(content);
141
145
  }
142
146
  if (context && this.contentIsBracketGroupStamp(content, context)) {
143
- return ((_a = this.contentToGroupElement(content, context)) === null || _a === void 0 ? void 0 : _a.full) || content;
147
+ return ((_a = this.contentToGroupElement(content, context)) === null || _a === void 0 ? void 0 : _a.content) || content;
144
148
  }
145
149
  return content;
146
150
  })(content);
@@ -150,6 +154,12 @@ class CapturedContent {
150
154
  return value;
151
155
  }
152
156
  }
157
+ class CapturedContentFlagMatchArray extends CapturedContent {
158
+ valueOfFlag() {
159
+ var _a;
160
+ return ((_a = this.content.groups) === null || _a === void 0 ? void 0 : _a.value) || null;
161
+ }
162
+ }
153
163
  class CliParserRunContext {
154
164
  constructor(parser) {
155
165
  this.input = "";
@@ -178,7 +188,7 @@ export class CliParser {
178
188
  const { context: bracketsContext, indexes } = context.brackets.parseSafe(context.input);
179
189
  const groups = context.brackets.findPrimaryGroups(bracketsContext);
180
190
  let offset = 0;
181
- for (const index in groups) {
191
+ for (let index = 0; index < groups.length; index++) {
182
192
  const group = groups[index];
183
193
  const replacement = context.brackets.toStringGroup(indexes[index]);
184
194
  const length = group.length;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zoodogood/utils",
3
3
  "type": "module",
4
- "version": "1.2.0-change.1444",
4
+ "version": "1.2.3-change.1466",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
package/readme.md CHANGED
@@ -3,6 +3,9 @@ A set of utilities in different directions for primitive data types.
3
3
  # Docs:
4
4
  https://zoodogood.github.io/utils/public
5
5
 
6
+ > [!IMPORTANT]
7
+ > If you are using this library, please contact me urgently. As long as I am the only user of my library, I allow myself to change its components on the fly, breaking backwards compatibility.
8
+
6
9
  ```js
7
10
  export { ending } from '@zoodogood/utils/primitives';
8
11
  ```