@oxog/utils 1.0.0 → 1.1.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 (43) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +101 -43
  3. package/dist/chunk-25WW2FCA.js +34 -0
  4. package/dist/chunk-25WW2FCA.js.map +1 -0
  5. package/dist/chunk-DEVWOLUI.cjs +112 -0
  6. package/dist/chunk-DEVWOLUI.cjs.map +1 -0
  7. package/dist/chunk-IUDFQZIP.js +99 -0
  8. package/dist/chunk-IUDFQZIP.js.map +1 -0
  9. package/dist/chunk-PZ5AY32C.js +9 -0
  10. package/dist/chunk-PZ5AY32C.js.map +1 -0
  11. package/dist/chunk-Q7SFCCGT.cjs +11 -0
  12. package/dist/chunk-Q7SFCCGT.cjs.map +1 -0
  13. package/dist/chunk-SWG777R6.cjs +40 -0
  14. package/dist/chunk-SWG777R6.cjs.map +1 -0
  15. package/dist/index.cjs +482 -191
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +288 -15
  18. package/dist/index.d.ts +288 -15
  19. package/dist/index.js +428 -186
  20. package/dist/index.js.map +1 -1
  21. package/dist/plugins/async.cjs +90 -107
  22. package/dist/plugins/async.cjs.map +1 -1
  23. package/dist/plugins/async.d.cts +19 -6
  24. package/dist/plugins/async.d.ts +19 -6
  25. package/dist/plugins/async.js +89 -106
  26. package/dist/plugins/async.js.map +1 -1
  27. package/dist/plugins/deep.cjs +183 -59
  28. package/dist/plugins/deep.cjs.map +1 -1
  29. package/dist/plugins/deep.d.cts +25 -7
  30. package/dist/plugins/deep.d.ts +25 -7
  31. package/dist/plugins/deep.js +183 -59
  32. package/dist/plugins/deep.js.map +1 -1
  33. package/dist/plugins/guard.cjs +2 -0
  34. package/dist/plugins/guard.cjs.map +1 -1
  35. package/dist/plugins/guard.js +2 -0
  36. package/dist/plugins/guard.js.map +1 -1
  37. package/dist/plugins/transform.cjs +6 -3
  38. package/dist/plugins/transform.cjs.map +1 -1
  39. package/dist/plugins/transform.js +6 -3
  40. package/dist/plugins/transform.js.map +1 -1
  41. package/dist/{types-XmRC5wYO.d.cts → types-B-i5UbJo.d.cts} +24 -7
  42. package/dist/{types-XmRC5wYO.d.ts → types-B-i5UbJo.d.ts} +24 -7
  43. package/package.json +15 -10
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ // src/internal.ts
4
+ var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
5
+ var hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
6
+ function assignOwn(obj, key, value) {
7
+ if (key === "__proto__") {
8
+ Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ }
13
+ function parsePath(path) {
14
+ const segments = [];
15
+ const source = String(path);
16
+ const pattern = /\[\s*(?:'([^']*)'|"([^"]*)"|([^\]]*?))\s*\]|([^.[\]]+)/g;
17
+ let match;
18
+ while ((match = pattern.exec(source)) !== null) {
19
+ const [, single, double, bare, dotted] = match;
20
+ if (dotted !== void 0) {
21
+ segments.push({ key: dotted, index: false });
22
+ } else {
23
+ const key = single ?? double ?? bare ?? "";
24
+ if (key === "") continue;
25
+ segments.push({ key, index: single === void 0 && double === void 0 && /^\d+$/.test(key) });
26
+ }
27
+ }
28
+ return segments;
29
+ }
30
+ function hasUnsafeSegment(segments) {
31
+ return segments.some((segment) => UNSAFE_KEYS.has(segment.key));
32
+ }
33
+
34
+ exports.UNSAFE_KEYS = UNSAFE_KEYS;
35
+ exports.assignOwn = assignOwn;
36
+ exports.hasOwn = hasOwn;
37
+ exports.hasUnsafeSegment = hasUnsafeSegment;
38
+ exports.parsePath = parsePath;
39
+ //# sourceMappingURL=chunk-SWG777R6.cjs.map
40
+ //# sourceMappingURL=chunk-SWG777R6.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal.ts"],"names":[],"mappings":";;;A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AAa,MAAA,KAAW,MAAA,IAAa,OAAA,CAAQ,IAAA,CAAK,GAAG,CAAA,EAAG,CAAA;AAAA,IACjG;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;AAGO,SAAS,iBAAiB,QAAA,EAA2C;AAC1E,EAAA,OAAO,QAAA,CAAS,KAAK,CAAC,OAAA,KAAY,YAAY,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAC,CAAA;AAChE","file":"chunk-SWG777R6.cjs","sourcesContent":["/**\n * Internal helpers shared by the public modules. Not part of the public API.\n * @internal\n */\n\n/** Keys that can reach or replace an object's prototype. */\nexport const UNSAFE_KEYS: ReadonlySet<string> = new Set(['__proto__', 'constructor', 'prototype']);\n\nexport const hasOwn = (obj: object, key: PropertyKey): boolean =>\n Object.prototype.hasOwnProperty.call(obj, key);\n\n/**\n * Assign `obj[key] = value` as an own data property.\n *\n * Plain assignment of `\"__proto__\"` would replace the prototype of `obj`\n * instead of storing a value; this helper always stores data.\n */\nexport function assignOwn(obj: any, key: PropertyKey, value: unknown): void {\n if (key === '__proto__') {\n Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });\n } else {\n obj[key] = value;\n }\n}\n\n/** One segment of a parsed property path. */\nexport interface PathSegment {\n key: string;\n /** True when the segment was written as a numeric bracket index (`[0]`). */\n index: boolean;\n}\n\n/**\n * Parse a property path such as `a.b[0].c` or `a['b'].c`.\n *\n * Empty segments are ignored, so `a..b` is the same as `a.b`.\n */\nexport function parsePath(path: string | number): PathSegment[] {\n const segments: PathSegment[] = [];\n const source = String(path);\n const pattern = /\\[\\s*(?:'([^']*)'|\"([^\"]*)\"|([^\\]]*?))\\s*\\]|([^.[\\]]+)/g;\n let match: RegExpExecArray | null;\n while ((match = pattern.exec(source)) !== null) {\n const [, single, double, bare, dotted] = match;\n if (dotted !== undefined) {\n segments.push({ key: dotted, index: false });\n } else {\n const key = single ?? double ?? bare ?? '';\n if (key === '') continue;\n segments.push({ key, index: single === undefined && double === undefined && /^\\d+$/.test(key) });\n }\n }\n return segments;\n}\n\n/** True when any segment of the path is `__proto__`, `constructor` or `prototype`. */\nexport function hasUnsafeSegment(segments: readonly PathSegment[]): boolean {\n return segments.some((segment) => UNSAFE_KEYS.has(segment.key));\n}\n"]}