@visulima/object 3.0.0 → 3.1.1

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## @visulima/object [3.1.1](https://github.com/visulima/visulima/compare/%40visulima%2Fobject%403.1.0...%40visulima%2Fobject%403.1.1) (2026-08-17)
2
+
3
+ ## @visulima/object [3.1.0](https://github.com/visulima/visulima/compare/%40visulima%2Fobject%403.0.0...%40visulima%2Fobject%403.1.0) (2026-08-02)
4
+
1
5
  ## @visulima/object [3.0.0](https://github.com/visulima/visulima/compare/@visulima/object@2.0.4...@visulima/object@3.0.0) (2026-07-03)
2
6
 
3
7
  ### ⚠ BREAKING CHANGES
package/dist/index.d.ts CHANGED
@@ -1,54 +1,54 @@
1
1
  import { Paths, OmitDeep, PickDeep, Get } from 'type-fest';
2
2
  export type { OmitDeep, Paths, PickDeep, Split } from 'type-fest';
3
3
  /**
4
- * Omit returns a new object without the props you omit.
5
- *
6
- * Supports dot-notation for nested props (e.g. `nested.prop`), `*` wildcard
7
- * segments (e.g. `items.*.secret`), array traversal (e.g. `users.0.password`
8
- * or `users.*.password`), and backslash-escaped dots for keys that literally
9
- * contain a `.` (e.g. `a\\.b`). Symbol-keyed properties are always preserved.
10
- * @template T
11
- * @template K
12
- * @param object the target object to omit props from
13
- * @param keys the prop names you want to omit
14
- * @returns a new object without the omitted props
15
- * @example
16
- * ```js
17
- * omit({ id: "1", name: "n", secret: "x" }, ["secret"]);
18
- * // => { id: "1", name: "n" }
19
- *
20
- * omit({ users: [{ name: "a", password: "p" }] }, ["users.*.password"]);
21
- * // => { users: [{ name: "a" }] }
22
- * ```
23
- */
24
- declare const omit: <T extends { [key in string]: unknown }, const K extends Paths<T>>(object: T, keys: ReadonlyArray<K>) => OmitDeep<T, K>;
4
+ * Omit returns a new object without the props you omit.
5
+ *
6
+ * Supports dot-notation for nested props (e.g. `nested.prop`), `*` wildcard
7
+ * segments (e.g. `items.*.secret`), array traversal (e.g. `users.0.password`
8
+ * or `users.*.password`), and backslash-escaped dots for keys that literally
9
+ * contain a `.` (e.g. `a\\.b`). Symbol-keyed properties are always preserved.
10
+ * @template T
11
+ * @template K
12
+ * @param object the target object to omit props from
13
+ * @param keys the prop names you want to omit
14
+ * @returns a new object without the omitted props
15
+ * @example
16
+ * ```js
17
+ * omit({ id: "1", name: "n", secret: "x" }, ["secret"]);
18
+ * // => { id: "1", name: "n" }
19
+ *
20
+ * omit({ users: [{ name: "a", password: "p" }] }, ["users.*.password"]);
21
+ * // => { users: [{ name: "a" }] }
22
+ * ```
23
+ */
24
+ declare const omit: <T extends { [key in string]: unknown; }, const K extends Paths<T>>(object: T, keys: ReadonlyArray<K>) => OmitDeep<T, K>;
25
25
  /**
26
- * Pick returns a new object with only the props you pick.
27
- *
28
- * Supports dot-notation for nested props (e.g. `nested.prop` keeps just
29
- * `{ nested: { prop: 1 } }`), `*` wildcard segments (e.g. `items.*.id`), array
30
- * traversal (e.g. `users.0.name` or `users.*.name`), and backslash-escaped
31
- * dots for keys that literally contain a `.` (e.g. `a\\.b`).
32
- * @template T
33
- * @template K
34
- * @param object the target object to pick props from
35
- * @param keys an array of prop names you want to keep
36
- * @returns a new object with just the picked props
37
- * @example
38
- * ```js
39
- * pick({ id: "1", name: "n", secret: "x" }, ["id", "name"]);
40
- * // => { id: "1", name: "n" }
41
- *
42
- * pick({ users: [{ name: "a", password: "p" }] }, ["users.*.name"]);
43
- * // => { users: [{ name: "a" }] }
44
- * ```
45
- */
46
- declare const pick: <T extends { [key in string]: unknown }, const K extends Paths<T>>(object: T, keys: ReadonlyArray<K>) => PickDeep<T, K>;
26
+ * Pick returns a new object with only the props you pick.
27
+ *
28
+ * Supports dot-notation for nested props (e.g. `nested.prop` keeps just
29
+ * `{ nested: { prop: 1 } }`), `*` wildcard segments (e.g. `items.*.id`), array
30
+ * traversal (e.g. `users.0.name` or `users.*.name`), and backslash-escaped
31
+ * dots for keys that literally contain a `.` (e.g. `a\\.b`).
32
+ * @template T
33
+ * @template K
34
+ * @param object the target object to pick props from
35
+ * @param keys an array of prop names you want to keep
36
+ * @returns a new object with just the picked props
37
+ * @example
38
+ * ```js
39
+ * pick({ id: "1", name: "n", secret: "x" }, ["id", "name"]);
40
+ * // => { id: "1", name: "n" }
41
+ *
42
+ * pick({ users: [{ name: "a", password: "p" }] }, ["users.*.name"]);
43
+ * // => { users: [{ name: "a" }] }
44
+ * ```
45
+ */
46
+ declare const pick: <T extends { [key in string]: unknown; }, const K extends Paths<T>>(object: T, keys: ReadonlyArray<K>) => PickDeep<T, K>;
47
47
  /**
48
- * Determines whether a value is a plain object (i.e. created from `{}` or `Object.create(null)`).
49
- * @param value Value to inspect.
50
- * @returns `true` if the value is a plain object, otherwise `false`.
51
- */
48
+ * Determines whether a value is a plain object (i.e. created from `{}` or `Object.create(null)`).
49
+ * @param value Value to inspect.
50
+ * @returns `true` if the value is a plain object, otherwise `false`.
51
+ */
52
52
  declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
53
53
  interface DeeksOptions {
54
54
  /** @default false */
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{default as U}from"./packem_shared/omit-DUxizCOe.js";import{default as C}from"./packem_shared/pick-L4PJlDoB.js";import{default as H}from"./packem_shared/isPlainObject-DqcjswLg.js";import{deleteProperty as Q,escapePath as V,getProperty as X,hasProperty as Y,setProperty as Z}from"./packem_shared/deleteProperty-y5ClNSkn.js";var o={},c={},x;function L(){if(x)return c;x=1,Object.defineProperty(c,"__esModule",{value:!0}),c.isDocumentToRecurOn=c.flatten=c.unique=void 0;function y(u){return[...new Set(u)]}c.unique=y;function h(u){return[].concat(...u)}c.flatten=h;function m(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.keys(u).length}return c.isDocumentToRecurOn=m,c}var _={},q;function N(){return q||(q=1,Object.defineProperty(_,"__esModule",{value:!0})),_}var S;function T(){return S||(S=1,(function(y){var h=o&&o.__createBinding||(Object.create?(function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]})),m=o&&o.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),u=o&&o.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&h(t,e,r);return m(t,e),t},E=o&&o.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&h(t,e,r)};Object.defineProperty(y,"__esModule",{value:!0}),y.deepKeysFromList=y.deepKeys=void 0;const b=u(L());E(N(),y);function M(e,t){const r=k(t);return typeof e=="object"&&e!==null?v("",e,r,new WeakSet):[]}y.deepKeys=M;function A(e,t,r){const n=k(t),s=r??new WeakSet;return e.map(i=>typeof i=="object"&&i!==null?s.has(i)?[]:v("",i,n,s):[])}y.deepKeysFromList=A;function v(e,t,r,n){const s=[],i=Object.keys(t);n.add(t);const f=[{obj:t,keys:i,i:0,basePath:e}];for(;f.length;){const p=f[f.length-1];if(p.i>=p.keys.length){f.pop();continue}const K=p.keys[p.i++],a=p.obj[K],g=O(p.basePath,P(K,r));if(r.expandNestedObjects&&b.isDocumentToRecurOn(a)||r.arrayIndexesAsKeys&&Array.isArray(a)&&a.length)if(r.arrayIndexesAsKeys&&Array.isArray(a)){const j=a;for(let d=j.length-1;d>=0;d--){const l=j[d],D=O(g,String(d));typeof l=="object"&&l!==null&&!Array.isArray(l)?n.has(l)||(n.add(l),f.push({obj:l,keys:Object.keys(l),i:0,basePath:D})):s.push(D)}}else n.has(a)||(n.add(a),f.push({obj:a,keys:Object.keys(a),i:0,basePath:g}));else if(r.expandArrayObjects&&Array.isArray(a)){const j=R(a,g,r,n);for(const d of j)s.push(d)}else{if(r.ignoreEmptyArrays&&Array.isArray(a)&&!a.length)continue;s.push(g)}}return b.unique(s)}function R(e,t,r,n){let s=A(e,r,n);return e.length?e.length&&b.flatten(s).length===0?[t]:(s=s.map(i=>Array.isArray(i)&&i.length===0?[t]:i.map(f=>O(t,P(f,r)))),b.unique(b.flatten(s))):r.ignoreEmptyArraysWhenExpanding?[]:[t]}function P(e,t){return t.escapeNestedDots?e.replace(/\./g,"\\."):e}function O(e,t){return e?e+"."+t:t}function k(e){return{arrayIndexesAsKeys:!1,expandNestedObjects:!0,expandArrayObjects:!1,ignoreEmptyArraysWhenExpanding:!1,escapeNestedDots:!1,ignoreEmptyArrays:!1,...e??{}}}})(o)),o}var w=T();const F=w.deepKeys,I=w.deepKeysFromList;export{F as deepKeys,I as deepKeysFromList,Q as deleteProperty,V as escapePath,X as getProperty,Y as hasProperty,H as isPlainObject,U as omit,C as pick,Z as setProperty};
1
+ import{default as U}from"./packem_shared/omit-7v36zCOc.js";import{default as z}from"./packem_shared/pick-1aTP8kw5.js";import{default as G}from"./packem_shared/isPlainObject-CV4RFPv0.js";import{deleteProperty as J,escapePath as Q,getProperty as X,hasProperty as Y,setProperty as Z}from"./packem_shared/deleteProperty-Cn6yDusY.js";var u={},f={},q;function L(){if(q)return f;q=1,Object.defineProperty(f,"__esModule",{value:!0}),f.isDocumentToRecurOn=f.flatten=f.unique=void 0;function c(i){return[...new Set(i)]}f.unique=c;function h(i){return[].concat(...i)}f.flatten=h;function _(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)&&Object.keys(i).length}return f.isDocumentToRecurOn=_,f}var A={},k;function T(){return k||(k=1,Object.defineProperty(A,"__esModule",{value:!0})),A}var S;function F(){return S||(S=1,(function(c){var h=u&&u.__createBinding||(Object.create?(function(e,r,t,n){n===void 0&&(n=t);var s=Object.getOwnPropertyDescriptor(r,t);(!s||("get"in s?!r.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,s)}):(function(e,r,t,n){n===void 0&&(n=t),e[n]=r[t]})),_=u&&u.__setModuleDefault||(Object.create?(function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}):function(e,r){e.default=r}),i=u&&u.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var t in e)t!=="default"&&Object.prototype.hasOwnProperty.call(e,t)&&h(r,e,t);return _(r,e),r},E=u&&u.__exportStar||function(e,r){for(var t in e)t!=="default"&&!Object.prototype.hasOwnProperty.call(r,t)&&h(r,e,t)};Object.defineProperty(c,"__esModule",{value:!0}),c.deepKeysFromList=c.deepKeys=void 0;const b=i(L());E(T(),c);function M(e,r){const t=D(r),n=new WeakSet;return typeof e=="object"&&e!==null?P("",e,t,n):[]}c.deepKeys=M;function v(e,r,t){const n=D(r),s=t??new WeakSet;return e.map(o=>typeof o=="object"&&o!==null?s.has(o)?[]:P("",o,n,s):[])}c.deepKeysFromList=v;function P(e,r,t,n){const s=[],o=Object.keys(r);n.add(r);const l=[{obj:r,keys:o,i:0,basePath:e}];for(;l.length;){const p=l[l.length-1];if(p.i>=p.keys.length){l.pop();continue}const K=p.keys[p.i++],a=p.obj[K],O=j(p.basePath,m(K,t));if(t.expandNestedObjects&&b.isDocumentToRecurOn(a)||t.arrayIndexesAsKeys&&Array.isArray(a)&&a.length)if(t.arrayIndexesAsKeys&&Array.isArray(a)){const g=a;for(let d=g.length-1;d>=0;d--){const y=g[d],x=j(O,String(d));typeof y=="object"&&y!==null&&!Array.isArray(y)?n.has(y)||(n.add(y),l.push({obj:y,keys:Object.keys(y),i:0,basePath:x})):s.push(x)}}else n.has(a)||(n.add(a),l.push({obj:a,keys:Object.keys(a),i:0,basePath:O}));else if(t.expandArrayObjects&&Array.isArray(a)){const g=R(a,O,t,n);for(const d of g)s.push(d)}else{if(t.ignoreEmptyArrays&&Array.isArray(a)&&!a.length)continue;s.push(O)}}return b.unique(s)}function R(e,r,t,n){let s=v(e,t,n);return e.length?e.length&&b.flatten(s).length===0?[r]:(s=s.map(o=>Array.isArray(o)&&o.length===0?[r]:o.map(l=>j(r,m(l,t)))),b.unique(b.flatten(s))):t.ignoreEmptyArraysWhenExpanding?[]:[r]}function m(e,r){return r.escapeNestedDots?e.replace(/\./g,"\\."):e}function j(e,r){return e?e+"."+r:r}function D(e){return{arrayIndexesAsKeys:!1,expandNestedObjects:!0,expandArrayObjects:!1,ignoreEmptyArraysWhenExpanding:!1,escapeNestedDots:!1,ignoreEmptyArrays:!1,...e??{}}}})(u)),u}var w=F();const N=w.deepKeys,I=w.deepKeysFromList;export{N as deepKeys,I as deepKeysFromList,J as deleteProperty,Q as escapePath,X as getProperty,Y as hasProperty,G as isPlainObject,U as omit,z as pick,Z as setProperty};
@@ -0,0 +1 @@
1
+ const u=r=>{const e=typeof r;return r!==null&&(e==="object"||e==="function")},d=new Set(["__proto__","prototype","constructor"]),m=Math.max(...[...d].map(r=>r.length)),E=1e6,A=r=>r>="0"&&r<="9";function l(r){if(r==="0")return!0;if(/^[1-9]\d*$/.test(r)){const e=Number.parseInt(r,10);return e<=Number.MAX_SAFE_INTEGER&&e<=E}return!1}function h(r,e){return d.has(r)?!1:(r&&l(r)?e.push(Number.parseInt(r,10)):e.push(r),!0)}function I(r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);const e=[];let n="",t="",o=!1,i="start",s=!1,f=0;for(const a of r){if(f++,s){n+=a,s=!1;continue}if(a==="\\"){if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${f}`);if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${f}`);s=!0,i=i==="start"?"property":i;continue}switch(a){case".":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${f}`);if(i==="indexEnd"){i="property";break}if(!h(n,e))return[];n="",i="property";break}case"[":{if(i==="index")throw new Error(`Invalid character '${a}' in an index at position ${f}`);if(i==="indexEnd"){i="index";break}if(i==="property"&&n.length<=m&&d.has(n))return[];o=i==="property",i="index";break}case"]":{if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${f}`);if(i!=="index"){i==="start"&&(i="property"),n+=a;break}if(t===""){n+="[]",i="property";break}if((n!==""||o)&&!h(n,e))return[];n="",o=!1;const p=Number.parseInt(t,10),c=p<=E&&t===String(p);e.push(c?p:t),t="",i="indexEnd";break}default:{if(i==="index"){if(!A(a))throw new Error(`Invalid character '${a}' in an index at position ${f}`);t+=a;break}if(i==="indexEnd")throw new Error(`Invalid character '${a}' after an index at position ${f}`);i==="start"&&(i="property"),n+=a}}}switch(s&&(n+="\\"),i){case"property":{if(!h(n,e))return[];break}case"index":throw new Error("Index was not closed");case"start":{e.push("");break}}return e}function y(r){if(typeof r=="string")return I(r);if(Array.isArray(r)){const e=[];for(const[n,t]of r.entries()){if(typeof t!="string"&&typeof t!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof t}`);if(typeof t=="number"&&!Number.isFinite(t))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${t}`);if(d.has(t))return[];typeof t=="string"&&l(t)?e.push(Number.parseInt(t,10)):e.push(t)}return e}return[]}function b(r,e,n){if(!u(r)||typeof e!="string"&&!Array.isArray(e))return n===void 0?r:n;const t=y(e);if(t.length===0)return n;for(let o=0;o<t.length;o++){const i=t[o];if(r=r[i],r==null){if(o!==t.length-1)return n;break}}return r===void 0?n:r}function k(r,e,n){if(!u(r)||typeof e!="string"&&!Array.isArray(e))return r;const t=r,o=y(e);if(o.length===0)return r;for(let i=0;i<o.length;i++){const s=o[i];if(i===o.length-1){r[s]=n;continue}const f=r[s];if(u(f)){r=f;continue}const p=typeof o[i+1]=="number";r[s]=p?[]:{},r=r[s]}return t}function P(r,e){if(!u(r)||typeof e!="string"&&!Array.isArray(e))return!1;const n=y(e);if(n.length===0)return!1;for(let t=0;t<n.length;t++){const o=n[t];if(t===n.length-1)return Object.hasOwn(r,o)?(delete r[o],!0):!1;const i=r[o];if(!u(i))return!1;r=i}}function S(r,e){if(!u(r)||typeof e!="string"&&!Array.isArray(e))return!1;const n=y(e);if(n.length===0)return!1;for(const t of n){if(!u(r)||!(t in r))return!1;r=r[t]}return!0}function g(r){if(typeof r!="string")throw new TypeError(`Expected a string, got ${typeof r}`);return r.replaceAll(/[\\.[]/g,String.raw`\$&`)}function w(r){const e=Object.entries(r);return Array.isArray(r)?e.map(([n,t])=>[l(n)?Number.parseInt(n,10):n,t]):e}function $(r,e,n,t){const o=!e&&(t||n);if(typeof r=="number"){if(!Number.isInteger(r)||r<0){const s=g(String(r));return e?s:`.${s}`}return o?`.${r}`:`[${r}]`}if(r==="")return e?"":".";if(l(r)){const s=Number.parseInt(r,10);return o?`.${s}`:`[${s}]`}const i=g(r);return e?i:`.${i}`}function K(r,e={}){if(!Array.isArray(r))throw new TypeError(`Expected an array, got ${typeof r}`);const{preferDotForIndices:n=!1}=e,t=[];let o=!0;for(const[i,s]of r.entries()){if(typeof s!="string"&&typeof s!="number")throw new TypeError(`Expected a string or number for path segment at index ${i}, got ${typeof s}`);const f=$(s,i===0,o,n);t.push(f),f!==""&&(o=!1)}return t.join("")}function*N(r){if(!u(r))return;const e=w(r);if(e.length===0)return;const n=new Set([r]),t=[{iterator:e[Symbol.iterator](),prefix:"",object:r}];for(;t.length>0;){const o=t.at(-1),{value:i,done:s}=o.iterator.next();if(s){n.delete(t.pop().object);continue}const[f,a]=i,{prefix:p}=o,c=p+$(f,t.length===1,p==="",!1);if(u(a)){if(n.has(a))continue;const x=w(a);if(x.length>0){n.add(a),t.push({iterator:x[Symbol.iterator](),prefix:c,object:a});continue}}yield c}}function T(r){return[...N(r)]}function _(r){const e={};if(!u(r))return e;for(const[n,t]of Object.entries(r))k(e,n,t);return e}export{T as deepKeys,P as deleteProperty,g as escapePath,b as getProperty,S as hasProperty,I as parsePath,k as setProperty,K as stringifyPath,_ as unflatten};
@@ -0,0 +1 @@
1
+ const e=t=>{if(typeof t!="object"||t===null)return!1;const o=Object.getPrototypeOf(t);return(o===null||o===Object.prototype||Object.getPrototypeOf(o)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};export{e as default};
@@ -0,0 +1 @@
1
+ import{n as a,s as f,c as l,a as m}from"./split-path-0wTzUYQI.js";import p from"./isPlainObject-CV4RFPv0.js";const y=(t,r)=>{const s=[];for(const[n,e]of t.entries()){const o=a(r,String(n));o.some(i=>i.length===0)||s.push(c(e,o))}return s},h=(t,r)=>{const s={};for(const[n,e]of Object.entries(t)){const o=a(r,n);o.some(i=>i.length===0)||f(s,n,c(e,o))}return l(t,s),s},c=(t,r)=>Array.isArray(t)?y(t,r):p(t)?h(t,r):t,u=(t,r)=>c(t,r),g=(t,r)=>{const s=r.map(n=>m(n));return u(t,s)};export{g as default};
@@ -0,0 +1 @@
1
+ import{s as h,c as u,n as p,a as m}from"./split-path-0wTzUYQI.js";import a from"./isPlainObject-CV4RFPv0.js";const e=Symbol("nothing"),f=r=>{if(Array.isArray(r))return r.map(t=>f(t));if(!a(r))return r;const n={};for(const[t,s]of Object.entries(r))h(n,t,f(s));return u(r,n),n},d=(r,n)=>{const t=[];for(const[s,o]of r.entries()){const c=p(n,String(s));if(c.length===0)continue;const i=l(o,c);i!==e&&t.push(i)}return t.length>0?t:e},g=(r,n)=>{const t={};let s=!1;for(const[o,c]of Object.entries(r)){const i=p(n,o);if(i.length===0)continue;const y=l(c,i);y!==e&&(h(t,o,y),s=!0)}return s?t:e},l=(r,n)=>n.some(t=>t.length===0)?f(r):Array.isArray(r)?d(r,n):a(r)?g(r,n):e,A=(r,n)=>{const t=l(r,n);return t!==e?t:a(r)||Array.isArray(r)?{}:r},w=(r,n)=>{if(n.length===0)return{};const t=n.map(s=>m(s));return A(r,t)};export{w as default};
@@ -0,0 +1 @@
1
+ const n=(r,e)=>{for(const t of Object.getOwnPropertySymbols(r))Object.getOwnPropertyDescriptor(r,t)?.enumerable&&(e[t]=r[t])},c=(r,e)=>{const t=[];for(const s of r){const[o]=s;(o==="*"||o===e)&&t.push(s.slice(1))}return t},i=(r,e,t)=>{if(e==="__proto__"){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:t,writable:!0});return}r[e]=t},f=r=>{const e=[];let t="",s=!1;for(const o of r){if(s){t+=o==="."||o==="\\"?o:`\\${o}`,s=!1;continue}if(o==="\\"){s=!0;continue}if(o==="."){e.push(t),t="";continue}t+=o}return s&&(t+="\\"),e.push(t),e};export{f as a,n as c,c as n,i as s};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/object",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "description": "Helper functions for working with objects and arrays.",
5
5
  "keywords": [
6
6
  "access",
@@ -58,7 +58,7 @@
58
58
  "CHANGELOG.md"
59
59
  ],
60
60
  "dependencies": {
61
- "type-fest": "5.7.0"
61
+ "type-fest": "5.8.0"
62
62
  },
63
63
  "engines": {
64
64
  "node": "^22.14.0 || >=24.10.0"
@@ -1 +0,0 @@
1
- const f=e=>{const r=typeof e;return e!==null&&(r==="object"||r==="function")},g=e=>{if(!f(e))return!1;for(const r in e)if(Object.hasOwn(e,r))return!1;return!0},y=new Set(["__proto__","prototype","constructor"]),d=1e6,w=e=>e>="0"&&e<="9";function u(e){if(e==="0")return!0;if(/^[1-9]\d*$/.test(e)){const r=Number.parseInt(e,10);return r<=Number.MAX_SAFE_INTEGER&&r<=d}return!1}function c(e,r){return y.has(e)?!1:(e&&u(e)?r.push(Number.parseInt(e,10)):r.push(e),!0)}function b(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);const r=[];let n="",t="start",o=!1,i=0;for(const s of e){if(i++,o){n+=s,o=!1;continue}if(s==="\\"){if(t==="index")throw new Error(`Invalid character '${s}' in an index at position ${i}`);if(t==="indexEnd")throw new Error(`Invalid character '${s}' after an index at position ${i}`);o=!0,t=t==="start"?"property":t;continue}switch(s){case".":{if(t==="index")throw new Error(`Invalid character '${s}' in an index at position ${i}`);if(t==="indexEnd"){t="property";break}if(!c(n,r))return[];n="",t="property";break}case"[":{if(t==="index")throw new Error(`Invalid character '${s}' in an index at position ${i}`);if(t==="indexEnd"){t="index";break}if(t==="property"||t==="start"){if((n||t==="property")&&!c(n,r))return[];n=""}t="index";break}case"]":{if(t==="index"){if(n==="")n=(r.pop()||"")+"[]",t="property";else{const a=Number.parseInt(n,10);!Number.isNaN(a)&&Number.isFinite(a)&&a>=0&&a<=Number.MAX_SAFE_INTEGER&&a<=d&&n===String(a)?r.push(a):r.push(n),n="",t="indexEnd"}break}if(t==="indexEnd")throw new Error(`Invalid character '${s}' after an index at position ${i}`);n+=s;break}default:{if(t==="index"&&!w(s))throw new Error(`Invalid character '${s}' in an index at position ${i}`);if(t==="indexEnd")throw new Error(`Invalid character '${s}' after an index at position ${i}`);t==="start"&&(t="property"),n+=s}}}switch(o&&(n+="\\"),t){case"property":{if(!c(n,r))return[];break}case"index":throw new Error("Index was not closed");case"start":{r.push("");break}}return r}function p(e){if(typeof e=="string")return b(e);if(Array.isArray(e)){const r=[];for(const[n,t]of e.entries()){if(typeof t!="string"&&typeof t!="number")throw new TypeError(`Expected a string or number for path segment at index ${n}, got ${typeof t}`);if(typeof t=="number"&&!Number.isFinite(t))throw new TypeError(`Path segment at index ${n} must be a finite number, got ${t}`);if(y.has(t))return[];typeof t=="string"&&u(t)?r.push(Number.parseInt(t,10)):r.push(t)}return r}return[]}function m(e,r,n){if(!f(e)||typeof r!="string"&&!Array.isArray(r))return n===void 0?e:n;const t=p(r);if(t.length===0)return n;for(let o=0;o<t.length;o++){const i=t[o];if(e=e[i],e==null){if(o!==t.length-1)return n;break}}return e===void 0?n:e}function x(e,r,n){if(!f(e)||typeof r!="string"&&!Array.isArray(r))return e;const t=e,o=p(r);if(o.length===0)return e;for(let i=0;i<o.length;i++){const s=o[i];if(i===o.length-1)e[s]=n;else if(!f(e[s])){const a=typeof o[i+1]=="number";e[s]=a?[]:{}}e=e[s]}return t}function A(e,r){if(!f(e)||typeof r!="string"&&!Array.isArray(r))return!1;const n=p(r);if(n.length===0)return!1;for(let t=0;t<n.length;t++){const o=n[t];if(t===n.length-1)return Object.hasOwn(e,o)?(delete e[o],!0):!1;if(e=e[o],!f(e))return!1}}function I(e,r){if(!f(e)||typeof r!="string"&&!Array.isArray(r))return!1;const n=p(r);if(n.length===0)return!1;for(const t of n){if(!f(e)||!(t in e))return!1;e=e[t]}return!0}function h(e){if(typeof e!="string")throw new TypeError(`Expected a string, got ${typeof e}`);return e.replaceAll(/[\\.[]/g,String.raw`\$&`)}function E(e){const r=Object.entries(e);return Array.isArray(e)?r.map(([n,t])=>[u(n)?Number.parseInt(n,10):n,t]):r}function $(e,r={}){if(!Array.isArray(e))throw new TypeError(`Expected an array, got ${typeof e}`);const{preferDotForIndices:n=!1}=r,t=[];for(const[o,i]of e.entries()){if(typeof i!="string"&&typeof i!="number")throw new TypeError(`Expected a string or number for path segment at index ${o}, got ${typeof i}`);if(typeof i=="number")if(!Number.isInteger(i)||i<0){const s=h(String(i));t.push(o===0?s:`.${s}`)}else n&&o>0?t.push(`.${i}`):t.push(`[${i}]`);else if(typeof i=="string")if(i==="")o===0||t.push(".");else if(u(i)){const s=Number.parseInt(i,10);n&&o>0?t.push(`.${s}`):t.push(`[${s}]`)}else{const s=h(i);t.push(o===0?s:`.${s}`)}}return t.join("")}function*l(e,r=[],n=new Set){if(!f(e)||g(e)){r.length>0&&(yield $(r));return}if(!n.has(e)){n.add(e);for(const[t,o]of E(e))r.push(t),yield*l(o,r,n),r.pop();n.delete(e)}}function N(e){return[...l(e)]}function k(e){const r={};if(!f(e))return r;for(const[n,t]of Object.entries(e))x(r,n,t);return r}export{N as deepKeys,A as deleteProperty,h as escapePath,m as getProperty,I as hasProperty,b as parsePath,x as setProperty,$ as stringifyPath,k as unflatten};
@@ -1 +0,0 @@
1
- const o=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)};export{o as default};
@@ -1 +0,0 @@
1
- import a from"./isPlainObject-DqcjswLg.js";import{o as m,t as u,i as y}from"./safe-assign-Dy7OR5kT.js";const b=(t,o)=>{for(const r of Object.getOwnPropertySymbols(t))Object.getOwnPropertyDescriptor(t,r)?.enumerable&&(o[r]=t[r])},i=(t,o,r)=>{if(Array.isArray(t)){const s=[];for(const[f,c]of t.entries()){const n=[...r,String(f)];o.some(p=>m(n,p))||s.push(i(c,o,n))}return s}if(!a(t))return t;const e={};for(const[s,f]of Object.entries(t)){const c=[...r,s];o.some(n=>m(c,n))||u(e,s,i(f,o,c))}return b(t,e),e},O=(t,o)=>i(t,o,[]),l=(t,o)=>{const r=o.map(e=>y(e));return O(t,r)};export{l as default};
@@ -1 +0,0 @@
1
- import m from"./isPlainObject-DqcjswLg.js";import{t as u,o as a,i as h}from"./safe-assign-Dy7OR5kT.js";const l=(o,t)=>t.some(e=>{const r=Math.min(o.length,e.length);return a(o.slice(0,r),e.slice(0,r))}),c=(o,t,e)=>{if(Array.isArray(o)){const n=[];for(const[i,s]of o.entries()){const f=[...e,String(i)];t.length>0&&!l(f,t)||n.push(c(s,t,f))}return n}if(!m(o))return o;const r={};for(const[n,i]of Object.entries(o)){const s=[...e,n];t.length>0&&!l(s,t)||u(r,n,c(i,t,s))}return r},g=(o,t)=>c(o,t,[]),A=(o,t)=>{if(t.length===0)return{};const e=t.map(r=>h(r));return g(o,e)};export{A as default};
@@ -1 +0,0 @@
1
- const u=r=>{const t=[];let e="",n=!1;for(const o of r){if(n){e+=o==="."||o==="\\"?o:`\\${o}`,n=!1;continue}if(o==="\\"){n=!0;continue}if(o==="."){t.push(e),e="";continue}e+=o}return n&&(e+="\\"),t.push(e),t},f=(r,t)=>{if(r.length!==t.length)return!1;for(const[e,n]of t.entries())if(n!=="*"&&n!==r[e])return!1;return!0},i=(r,t,e)=>{if(t==="__proto__"){Object.defineProperty(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0});return}r[t]=e};export{u as i,f as o,i as t};