@visulima/object 3.0.0 → 3.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.
- package/CHANGELOG.md +2 -0
- package/dist/index.d.ts +46 -46
- package/dist/index.js +1 -1
- package/dist/packem_shared/omit-BVHtDcCP.js +1 -0
- package/dist/packem_shared/pick-Fkm4vY-x.js +1 -0
- package/dist/packem_shared/split-path-DEreWCls.js +1 -0
- package/package.json +1 -1
- package/dist/packem_shared/omit-DUxizCOe.js +0 -1
- package/dist/packem_shared/pick-L4PJlDoB.js +0 -1
- package/dist/packem_shared/safe-assign-Dy7OR5kT.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
## @visulima/object [3.1.0](https://github.com/visulima/visulima/compare/%40visulima%2Fobject%403.0.0...%40visulima%2Fobject%403.1.0) (2026-08-02)
|
|
2
|
+
|
|
1
3
|
## @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
4
|
|
|
3
5
|
### ⚠ 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-
|
|
1
|
+
import{default as U}from"./packem_shared/omit-BVHtDcCP.js";import{default as C}from"./packem_shared/pick-Fkm4vY-x.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as a,t as i,a as m,i as u}from"./split-path-DEreWCls.js";import p from"./isPlainObject-DqcjswLg.js";const g=(t,o)=>{const s=[];for(const[r,n]of t.entries()){const e=a(o,String(r));e.some(c=>c.length===0)||s.push(f(n,e))}return s},h=(t,o)=>{const s={};for(const[r,n]of Object.entries(t)){const e=a(o,r);e.some(c=>c.length===0)||i(s,r,f(n,e))}return m(t,s),s},f=(t,o)=>Array.isArray(t)?g(t,o):p(t)?h(t,o):t,l=(t,o)=>f(t,o),b=(t,o)=>{const s=o.map(r=>u(r));return l(t,s)};export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as g,a as y,e as m,i as h}from"./split-path-DEreWCls.js";import a from"./isPlainObject-DqcjswLg.js";const s=Symbol("nothing"),f=t=>{if(Array.isArray(t))return t.map(r=>f(r));if(!a(t))return t;const e={};for(const[r,o]of Object.entries(t))g(e,r,f(o));return y(t,e),e},p=(t,e)=>{const r=[];for(const[o,c]of t.entries()){const i=m(e,String(o));if(i.length===0)continue;const n=u(c,i);n!==s&&r.push(n)}return r.length>0?r:s},A=(t,e)=>{const r={};let o=!1;for(const[c,i]of Object.entries(t)){const n=m(e,c);if(n.length===0)continue;const l=u(i,n);l!==s&&(g(r,c,l),o=!0)}return o?r:s},u=(t,e)=>e.some(r=>r.length===0)?f(t):Array.isArray(t)?p(t,e):a(t)?A(t,e):s,b=(t,e)=>{const r=u(t,e);return r!==s?r:a(t)||Array.isArray(t)?{}:t},S=(t,e)=>{if(e.length===0)return{};const r=e.map(o=>h(o));return b(t,r)};export{S as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const s=(r,t)=>{for(const e of Object.getOwnPropertySymbols(r))Object.getOwnPropertyDescriptor(r,e)?.enumerable&&(t[e]=r[e])},c=(r,t)=>{const e=[];for(const n of r){const[o]=n;(o==="*"||o===t)&&e.push(n.slice(1))}return e},u=(r,t,e)=>{if(t==="__proto__"){Object.defineProperty(r,t,{configurable:!0,enumerable:!0,value:e,writable:!0});return}r[t]=e},f=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};export{s as a,c as e,f as i,u as t};
|
package/package.json
CHANGED
|
@@ -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};
|