@visulima/object 2.0.2 → 2.0.3
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 +13 -0
- package/LICENSE.md +7 -2
- package/dist/index.d.ts +7 -216
- package/dist/index.js +1 -1
- package/dist/omit.d.ts +18 -0
- package/dist/pick.d.ts +18 -0
- package/dist/utils/paths-are-equal.d.ts +15 -0
- package/dist/utils/recursive-omit.d.ts +3 -0
- package/dist/utils/recursive-pick.d.ts +3 -0
- package/package.json +1 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## @visulima/object [2.0.3](https://github.com/visulima/visulima/compare/@visulima/object@2.0.2...@visulima/object@2.0.3) (2025-11-12)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **deps:** update type-fest dependency across multiple packages ([93e13be](https://github.com/visulima/visulima/commit/93e13be5248207968a96303710db2a0604d16b9b))
|
|
6
|
+
* update package configurations and TypeScript definitions ([b59aa59](https://github.com/visulima/visulima/commit/b59aa59dac1508216b944f4b917fb4a7ab1f70a4))
|
|
7
|
+
|
|
8
|
+
### Miscellaneous Chores
|
|
9
|
+
|
|
10
|
+
* Add jsr file to all packages for release ([#565](https://github.com/visulima/visulima/issues/565)) ([ec91652](https://github.com/visulima/visulima/commit/ec91652b4e4112adf14ba152c1239a7703ba425a))
|
|
11
|
+
* update license files and clean up TypeScript definitions ([fe668cc](https://github.com/visulima/visulima/commit/fe668cc26de23591d4df54a0954455ebbe31b22d))
|
|
12
|
+
* update npm and pnpm configurations for monorepo optimization ([#564](https://github.com/visulima/visulima/issues/564)) ([5512b42](https://github.com/visulima/visulima/commit/5512b42f672c216b6a3c9e39035199a4ebd9a4b8))
|
|
13
|
+
|
|
1
14
|
## @visulima/object [2.0.2](https://github.com/visulima/visulima/compare/@visulima/object@2.0.1...@visulima/object@2.0.2) (2025-11-05)
|
|
2
15
|
|
|
3
16
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -71,18 +71,22 @@ Repository: sindresorhus/is-plain-obj
|
|
|
71
71
|
<!-- TYPE_DEPENDENCIES -->
|
|
72
72
|
|
|
73
73
|
# Licenses of bundled types
|
|
74
|
+
|
|
74
75
|
The published @visulima/object artifact additionally contains code with the following licenses:
|
|
75
76
|
MIT
|
|
76
77
|
|
|
77
78
|
# Bundled types:
|
|
79
|
+
|
|
78
80
|
## deeks
|
|
81
|
+
|
|
79
82
|
License: MIT
|
|
80
83
|
By: mrodrig
|
|
81
84
|
Repository: git+https://github.com/mrodrig/deeks.git
|
|
82
85
|
|
|
83
|
-
|
|
86
|
+
---
|
|
84
87
|
|
|
85
88
|
## dot-prop
|
|
89
|
+
|
|
86
90
|
License: MIT
|
|
87
91
|
By: Sindre Sorhus
|
|
88
92
|
Repository: sindresorhus/dot-prop
|
|
@@ -97,9 +101,10 @@ Repository: sindresorhus/dot-prop
|
|
|
97
101
|
>
|
|
98
102
|
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
99
103
|
|
|
100
|
-
|
|
104
|
+
---
|
|
101
105
|
|
|
102
106
|
## is-plain-obj
|
|
107
|
+
|
|
103
108
|
License: MIT
|
|
104
109
|
By: Sindre Sorhus
|
|
105
110
|
Repository: sindresorhus/is-plain-obj
|
package/dist/index.d.ts
CHANGED
|
@@ -1,216 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
interface DeeksOptions {
|
|
9
|
-
/** @default false */
|
|
10
|
-
arrayIndexesAsKeys?: boolean;
|
|
11
|
-
/** @default true */
|
|
12
|
-
expandNestedObjects?: boolean;
|
|
13
|
-
/** @default false */
|
|
14
|
-
expandArrayObjects?: boolean;
|
|
15
|
-
/** @default false */
|
|
16
|
-
ignoreEmptyArraysWhenExpanding?: boolean;
|
|
17
|
-
/** @default false */
|
|
18
|
-
escapeNestedDots?: boolean;
|
|
19
|
-
/** @default false */
|
|
20
|
-
ignoreEmptyArrays?: boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Return the deep keys list for a single document
|
|
25
|
-
* @param object
|
|
26
|
-
* @param options
|
|
27
|
-
* @returns {Array}
|
|
28
|
-
*/
|
|
29
|
-
declare function deepKeys(object: object, options?: DeeksOptions): string[];
|
|
30
|
-
/**
|
|
31
|
-
* Return the deep keys list for all documents in the provided list
|
|
32
|
-
* @param list
|
|
33
|
-
* @param options
|
|
34
|
-
* @returns Array[Array[String]]
|
|
35
|
-
*/
|
|
36
|
-
declare function deepKeysFromList(list: object[], options?: DeeksOptions): string[][];
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
Get the value of the property at the given path.
|
|
40
|
-
|
|
41
|
-
@param object - Object or array to get the `path` value.
|
|
42
|
-
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key. Array indices can be accessed using bracket notation (`'users[0].name'`) or dot notation (`'users.0.name'`). Both syntaxes are equivalent and will create arrays when setting values. Numeric strings in dot notation (like `'users.0.name'`) are automatically coerced to numbers. When using array paths, numeric strings are normalized to numbers for simplicity (treating `['users', '0']` the same as `['users', 0]`).
|
|
43
|
-
@param defaultValue - Default value.
|
|
44
|
-
|
|
45
|
-
@example
|
|
46
|
-
```
|
|
47
|
-
import {getProperty} from 'dot-prop';
|
|
48
|
-
|
|
49
|
-
getProperty({foo: {bar: 'unicorn'}}, 'foo.bar');
|
|
50
|
-
//=> 'unicorn'
|
|
51
|
-
|
|
52
|
-
getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep');
|
|
53
|
-
//=> undefined
|
|
54
|
-
|
|
55
|
-
getProperty({foo: {bar: 'a'}}, 'foo.notDefined.deep', 'default value');
|
|
56
|
-
//=> 'default value'
|
|
57
|
-
|
|
58
|
-
getProperty({foo: {'dot.dot': 'unicorn'}}, 'foo.dot\\.dot');
|
|
59
|
-
//=> 'unicorn'
|
|
60
|
-
|
|
61
|
-
getProperty({foo: [{bar: 'unicorn'}]}, 'foo[0].bar');
|
|
62
|
-
//=> 'unicorn'
|
|
63
|
-
|
|
64
|
-
getProperty({foo: [{bar: 'unicorn'}]}, 'foo.0.bar');
|
|
65
|
-
//=> 'unicorn'
|
|
66
|
-
```
|
|
67
|
-
*/
|
|
68
|
-
declare function getProperty<ObjectType, PathType extends string, DefaultValue = undefined>(
|
|
69
|
-
object: ObjectType,
|
|
70
|
-
path: PathType | ReadonlyArray<string | number>,
|
|
71
|
-
defaultValue?: DefaultValue
|
|
72
|
-
): ObjectType extends Record<string, unknown> | unknown[]
|
|
73
|
-
? (unknown extends Get<ObjectType, PathType> ? DefaultValue : Get<ObjectType, PathType>)
|
|
74
|
-
: DefaultValue extends undefined ? unknown : DefaultValue;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
Set the property at the given path to the given value.
|
|
78
|
-
|
|
79
|
-
@param object - Object or array to set the `path` value.
|
|
80
|
-
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key. Array indices can be accessed using bracket notation (`'users[0].name'`) or dot notation (`'users.0.name'`). Both syntaxes are equivalent and will create arrays when setting values. Numeric strings in dot notation (like `'users.0.name'`) are automatically coerced to numbers. When using array paths, numeric strings are normalized to numbers for simplicity (treating `['users', '0']` the same as `['users', 0]`).
|
|
81
|
-
@param value - Value to set at `path`.
|
|
82
|
-
@returns The object.
|
|
83
|
-
|
|
84
|
-
@example
|
|
85
|
-
```
|
|
86
|
-
import {setProperty} from 'dot-prop';
|
|
87
|
-
|
|
88
|
-
const object = {foo: {bar: 'a'}};
|
|
89
|
-
setProperty(object, 'foo.bar', 'b');
|
|
90
|
-
console.log(object);
|
|
91
|
-
//=> {foo: {bar: 'b'}}
|
|
92
|
-
|
|
93
|
-
const foo = setProperty({}, 'foo.bar', 'c');
|
|
94
|
-
console.log(foo);
|
|
95
|
-
//=> {foo: {bar: 'c'}}
|
|
96
|
-
|
|
97
|
-
setProperty(object, 'foo.baz', 'x');
|
|
98
|
-
console.log(object);
|
|
99
|
-
//=> {foo: {bar: 'b', baz: 'x'}}
|
|
100
|
-
|
|
101
|
-
setProperty(object, 'foo.biz[0]', 'a');
|
|
102
|
-
console.log(object);
|
|
103
|
-
//=> {foo: {bar: 'b', baz: 'x', biz: ['a']}}
|
|
104
|
-
|
|
105
|
-
setProperty(object, 'foo.items.0', 'first');
|
|
106
|
-
console.log(object);
|
|
107
|
-
//=> {foo: {bar: 'b', baz: 'x', biz: ['a'], items: ['first']}}
|
|
108
|
-
```
|
|
109
|
-
*/
|
|
110
|
-
declare function setProperty<ObjectType extends (Record<string, any> | unknown[])>(
|
|
111
|
-
object: ObjectType,
|
|
112
|
-
path: string | ReadonlyArray<string | number>,
|
|
113
|
-
value: unknown
|
|
114
|
-
): ObjectType;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
Check whether the property at the given path exists.
|
|
118
|
-
|
|
119
|
-
@param object - Object or array to test the `path` value.
|
|
120
|
-
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key. Array indices can be accessed using bracket notation (`'users[0].name'`) or dot notation (`'users.0.name'`). Both syntaxes are equivalent and will create arrays when setting values. Numeric strings in dot notation (like `'users.0.name'`) are automatically coerced to numbers. When using array paths, numeric strings are normalized to numbers for simplicity (treating `['users', '0']` the same as `['users', 0]`).
|
|
121
|
-
|
|
122
|
-
@example
|
|
123
|
-
```
|
|
124
|
-
import {hasProperty} from 'dot-prop';
|
|
125
|
-
|
|
126
|
-
hasProperty({foo: {bar: 'unicorn'}}, 'foo.bar');
|
|
127
|
-
//=> true
|
|
128
|
-
```
|
|
129
|
-
*/
|
|
130
|
-
declare function hasProperty(object: Record<string, any> | unknown[] | undefined, path: string | ReadonlyArray<string | number>): boolean;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
Delete the property at the given path.
|
|
134
|
-
|
|
135
|
-
@param object - Object or array to delete the `path` value.
|
|
136
|
-
@param path - Path of the property in the object, using `.` to separate each nested key. Use `\\.` if you have a `.` in the key. Array indices can be accessed using bracket notation (`'users[0].name'`) or dot notation (`'users.0.name'`). Both syntaxes are equivalent and will create arrays when setting values. Numeric strings in dot notation (like `'users.0.name'`) are automatically coerced to numbers. When using array paths, numeric strings are normalized to numbers for simplicity (treating `['users', '0']` the same as `['users', 0]`).
|
|
137
|
-
@returns A boolean of whether the property existed before being deleted.
|
|
138
|
-
|
|
139
|
-
@example
|
|
140
|
-
```
|
|
141
|
-
import {deleteProperty} from 'dot-prop';
|
|
142
|
-
|
|
143
|
-
const object = {foo: {bar: 'a'}};
|
|
144
|
-
deleteProperty(object, 'foo.bar');
|
|
145
|
-
console.log(object);
|
|
146
|
-
//=> {foo: {}}
|
|
147
|
-
|
|
148
|
-
object.foo.bar = {x: 'y', y: 'x'};
|
|
149
|
-
deleteProperty(object, 'foo.bar.x');
|
|
150
|
-
console.log(object);
|
|
151
|
-
//=> {foo: {bar: {y: 'x'}}}
|
|
152
|
-
```
|
|
153
|
-
*/
|
|
154
|
-
declare function deleteProperty(object: Record<string, any> | unknown[], path: string | ReadonlyArray<string | number>): boolean;
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
Escape special characters in a path. Useful for sanitizing user input.
|
|
158
|
-
|
|
159
|
-
@param path - The dot path to sanitize.
|
|
160
|
-
|
|
161
|
-
@example
|
|
162
|
-
```
|
|
163
|
-
import {getProperty, escapePath} from 'dot-prop';
|
|
164
|
-
|
|
165
|
-
const object = {
|
|
166
|
-
foo: {
|
|
167
|
-
bar: '👸🏻 You found me Mario!',
|
|
168
|
-
},
|
|
169
|
-
'foo.bar' : '🍄 The princess is in another castle!',
|
|
170
|
-
};
|
|
171
|
-
const escapedPath = escapePath('foo.bar');
|
|
172
|
-
|
|
173
|
-
console.log(getProperty(object, escapedPath));
|
|
174
|
-
//=> '🍄 The princess is in another castle!'
|
|
175
|
-
```
|
|
176
|
-
*/
|
|
177
|
-
declare function escapePath(path: string): string;
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
Check if a value is a plain object.
|
|
181
|
-
|
|
182
|
-
An object is plain if it's created by either `{}`, `new Object()`, or `Object.create(null)`.
|
|
183
|
-
|
|
184
|
-
@example
|
|
185
|
-
```
|
|
186
|
-
import isPlainObject from 'is-plain-obj';
|
|
187
|
-
import {runInNewContext} from 'node:vm';
|
|
188
|
-
|
|
189
|
-
isPlainObject({foo: 'bar'});
|
|
190
|
-
//=> true
|
|
191
|
-
|
|
192
|
-
isPlainObject(new Object());
|
|
193
|
-
//=> true
|
|
194
|
-
|
|
195
|
-
isPlainObject(Object.create(null));
|
|
196
|
-
//=> true
|
|
197
|
-
|
|
198
|
-
// This works across realms
|
|
199
|
-
isPlainObject(runInNewContext('({})'));
|
|
200
|
-
//=> true
|
|
201
|
-
|
|
202
|
-
isPlainObject([1, 2, 3]);
|
|
203
|
-
//=> false
|
|
204
|
-
|
|
205
|
-
class Unicorn {}
|
|
206
|
-
isPlainObject(new Unicorn());
|
|
207
|
-
//=> false
|
|
208
|
-
|
|
209
|
-
isPlainObject(Math);
|
|
210
|
-
//=> false
|
|
211
|
-
```
|
|
212
|
-
*/
|
|
213
|
-
declare function isPlainObject<Value>(value: unknown): value is Record<PropertyKey, Value>;
|
|
214
|
-
|
|
215
|
-
export { deepKeys, deepKeysFromList, deleteProperty, escapePath, getProperty, hasProperty, isPlainObject, omit, pick, setProperty };
|
|
216
|
-
export type { DeeksOptions as DeepKeysOptions };
|
|
1
|
+
export { default as omit } from "./omit.d.ts";
|
|
2
|
+
export { default as pick } from "./pick.d.ts";
|
|
3
|
+
export type { DeeksOptions as DeepKeysOptions } from "deeks";
|
|
4
|
+
export { deepKeys, deepKeysFromList } from "deeks";
|
|
5
|
+
export { deleteProperty, escapePath, getProperty, hasProperty, setProperty } from "dot-prop";
|
|
6
|
+
export { default as isPlainObject } from "is-plain-obj";
|
|
7
|
+
export type { OmitDeep, Paths, PickDeep, Split } from "type-fest";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var F=Object.defineProperty;var s=(y,d)=>F(y,"name",{value:d,configurable:!0});import{default as J}from"./packem_shared/omit-BfV-sPAM.js";import{default as V}from"./packem_shared/pick-CT4qE7de.js";import{deleteProperty as Y,escapePath as Z,getProperty as $,hasProperty as ee,setProperty as te}from"./packem_shared/getProperty-DPNB_aKG.js";import{default as ne}from"./packem_shared/isPlainObject-CLTs8VdF.js";var c={},p={},w;function I(){if(w)return p;w=1;var y=Object.defineProperty,d=s((u,K)=>y(u,"name",{value:K,configurable:!0}),"t");Object.defineProperty(p,"__esModule",{value:!0}),p.isDocumentToRecurOn=p.flatten=p.unique=void 0;function i(u){return[...new Set(u)]}s(i,"unique"),d(i,"unique"),p.unique=i;function m(u){return[].concat(...u)}s(m,"flatten"),d(m,"flatten"),p.flatten=m;function j(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.keys(u).length}return s(j,"isDocumentToRecurOn"),d(j,"isDocumentToRecurOn"),p.isDocumentToRecurOn=j,p}s(I,"requireUtils");var x={},E;function W(){return E||(E=1,Object.defineProperty(x,"__esModule",{value:!0})),x}s(W,"requireTypes");var M;function B(){return M||(M=1,(function(y){var d=Object.defineProperty,i=s((e,t)=>d(e,"name",{value:t,configurable:!0}),"u"),m=c&&c.__createBinding||(Object.create?(function(e,t,r,n){n===void 0&&(n=r);var a=Object.getOwnPropertyDescriptor(t,r);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:i(function(){return t[r]},"get")}),Object.defineProperty(e,n,a)}):(function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]})),j=c&&c.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),u=c&&c.__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)&&m(t,e,r);return j(t,e),t},K=c&&c.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&m(t,e,r)};Object.defineProperty(y,"__esModule",{value:!0}),y.deepKeysFromList=y.deepKeys=void 0;const O=u(I());K(W(),y);function S(e,t){const r=q(t);return typeof e=="object"&&e!==null?k("",e,r,new WeakSet):[]}s(S,"deepKeys"),i(S,"deepKeys"),y.deepKeys=S;function P(e,t,r){const n=q(t),a=r??new WeakSet;return e.map(f=>typeof f=="object"&&f!==null?a.has(f)?[]:k("",f,n,a):[])}s(P,"deepKeysFromList"),i(P,"deepKeysFromList"),y.deepKeysFromList=P;function k(e,t,r,n){const a=[],f=Object.keys(t);n.add(t);const l=[{obj:t,keys:f,i:0,basePath:e}];for(;l.length;){const g=l[l.length-1];if(g.i>=g.keys.length){l.pop();continue}const N=g.keys[g.i++],o=g.obj[N],_=v(g.basePath,D(N,r));if(r.expandNestedObjects&&O.isDocumentToRecurOn(o)||r.arrayIndexesAsKeys&&Array.isArray(o)&&o.length)if(r.arrayIndexesAsKeys&&Array.isArray(o)){const A=o;for(let h=A.length-1;h>=0;h--){const b=A[h],R=v(_,String(h));typeof b=="object"&&b!==null&&!Array.isArray(b)?n.has(b)||(n.add(b),l.push({obj:b,keys:Object.keys(b),i:0,basePath:R})):a.push(R)}}else n.has(o)||(n.add(o),l.push({obj:o,keys:Object.keys(o),i:0,basePath:_}));else if(r.expandArrayObjects&&Array.isArray(o)){const A=L(o,_,r,n);for(const h of A)a.push(h)}else{if(r.ignoreEmptyArrays&&Array.isArray(o)&&!o.length)continue;a.push(_)}}return O.unique(a)}s(k,"generateDeepKeysList"),i(k,"generateDeepKeysList");function L(e,t,r,n){let a=P(e,r,n);return e.length?e.length&&O.flatten(a).length===0?[t]:(a=a.map(f=>Array.isArray(f)&&f.length===0?[t]:f.map(l=>v(t,D(l,r)))),O.unique(O.flatten(a))):r.ignoreEmptyArraysWhenExpanding?[]:[t]}s(L,"processArrayKeys"),i(L,"processArrayKeys");function D(e,t){return t.escapeNestedDots?e.replace(/\./g,"\\."):e}s(D,"escapeNestedDotsIfSpecified"),i(D,"escapeNestedDotsIfSpecified");function v(e,t){return e?e+"."+t:t}s(v,"buildKeyName"),i(v,"buildKeyName");function q(e){return{arrayIndexesAsKeys:!1,expandNestedObjects:!0,expandArrayObjects:!1,ignoreEmptyArraysWhenExpanding:!1,escapeNestedDots:!1,ignoreEmptyArrays:!1,...e??{}}}s(q,"mergeOptions"),i(q,"mergeOptions")})(c)),c}s(B,"requireDeeks");var T=B();const z=T.deepKeys,C=T.deepKeysFromList;export{z as deepKeys,C as deepKeysFromList,Y as deleteProperty,Z as escapePath,$ as getProperty,ee as hasProperty,ne as isPlainObject,J as omit,V as pick,te as setProperty};
|
package/dist/omit.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modified copy of https://github.com/mesqueeb/filter-anything/blob/main/src/index.ts
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2018 Luca Ban - Mesqueeb
|
|
7
|
+
*/
|
|
8
|
+
import type { OmitDeep, Paths } from "type-fest";
|
|
9
|
+
/**
|
|
10
|
+
* Omit returns a new object without the props you omit.
|
|
11
|
+
* @template T
|
|
12
|
+
* @template K
|
|
13
|
+
* @param object the target object to omit props from
|
|
14
|
+
* @param keys the prop names you want to omit
|
|
15
|
+
* @returns a new object without the omitted props
|
|
16
|
+
*/
|
|
17
|
+
declare const omit: <T extends { [key in string]: unknown; }, K extends string>(object: T, keys: Paths<T>[]) => OmitDeep<T, K>;
|
|
18
|
+
export default omit;
|
package/dist/pick.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modified copy of https://github.com/mesqueeb/filter-anything/blob/main/src/index.ts
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2018 Luca Ban - Mesqueeb
|
|
7
|
+
*/
|
|
8
|
+
import type { Paths, PickDeep } from "type-fest";
|
|
9
|
+
/**
|
|
10
|
+
* Pick returns a new object with only the props you pick.
|
|
11
|
+
* @template T
|
|
12
|
+
* @template K
|
|
13
|
+
* @param object the target object to pick props from
|
|
14
|
+
* @param keys an array of prop names you want to keep - allows dot-notation for nested props, eg. `nested.prop` will keep just `{ nested: { prop: 1 } }`
|
|
15
|
+
* @returns a new object with just the picked props
|
|
16
|
+
*/
|
|
17
|
+
declare const pick: <T extends { [key in string]: unknown; }, K extends Paths<T>>(object: T, keys: Paths<T>[]) => PickDeep<T, K>;
|
|
18
|
+
export default pick;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Modified copy of https://github.com/mesqueeb/filter-anything/blob/main/src/pathsAreEqual.ts
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2018 Luca Ban - Mesqueeb
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* PathsAreEqual returns true if the path and wildcardPath are equal.
|
|
10
|
+
* @param path The path to compare
|
|
11
|
+
* @param wildcardPath The wildcard path to compare
|
|
12
|
+
* @returns True if the path and wildcardPath are equal, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
declare const pathsAreEqual: (path: string, wildcardPath: string) => boolean;
|
|
15
|
+
export default pathsAreEqual;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/object",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Helper functions for working with objects and arrays.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -59,9 +59,6 @@
|
|
|
59
59
|
"README.md",
|
|
60
60
|
"CHANGELOG.md"
|
|
61
61
|
],
|
|
62
|
-
"dependencies": {
|
|
63
|
-
"type-fest": "^5.2.0"
|
|
64
|
-
},
|
|
65
62
|
"engines": {
|
|
66
63
|
"node": ">=20.19 <=25.x"
|
|
67
64
|
},
|