@visulima/object 1.0.1 → 1.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 CHANGED
@@ -1,3 +1,25 @@
1
+ ## @visulima/object [1.0.3](https://github.com/visulima/visulima/compare/@visulima/object@1.0.2...@visulima/object@1.0.3) (2024-09-07)
2
+
3
+ ### Bug Fixes
4
+
5
+ * fixed broken chunk splitting from packem ([1aaf277](https://github.com/visulima/visulima/commit/1aaf27779292d637923c5f8a220e18606e78caa2))
6
+
7
+ ## @visulima/object [1.0.2](https://github.com/visulima/visulima/compare/@visulima/object@1.0.1...@visulima/object@1.0.2) (2024-09-07)
8
+
9
+ ### Bug Fixes
10
+
11
+ * added types support for node10 ([604583f](https://github.com/visulima/visulima/commit/604583fa3c24b950fafad45d17e7a1333040fd76))
12
+
13
+ ### Styles
14
+
15
+ * cs fixes ([f5c4af7](https://github.com/visulima/visulima/commit/f5c4af7cfa9fc79b6d3fa60c1e48d88bffab5a08))
16
+
17
+ ### Miscellaneous Chores
18
+
19
+ * update dev dependencies ([0738f98](https://github.com/visulima/visulima/commit/0738f9810478bb215ce4b2571dc8874c4c503089))
20
+ * updated dev dependencies ([45c2a76](https://github.com/visulima/visulima/commit/45c2a76bc974ecb2c6b172c3af03373d4cc6a5ce))
21
+ * updated dev dependencies ([da46d8e](https://github.com/visulima/visulima/commit/da46d8ef8a964c086060944172f1bd931b7bde9a))
22
+
1
23
  ## @visulima/object [1.0.1](https://github.com/visulima/visulima/compare/@visulima/object@1.0.0...@visulima/object@1.0.1) (2024-08-01)
2
24
 
3
25
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -40,13 +40,13 @@ By: Sindre Sorhus
40
40
  Repository: sindresorhus/dot-prop
41
41
 
42
42
  > MIT License
43
- >
43
+ >
44
44
  > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
45
- >
45
+ >
46
46
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
47
- >
47
+ >
48
48
  > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
49
- >
49
+ >
50
50
  > 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.
51
51
 
52
52
  ---------------------------------------
@@ -57,13 +57,13 @@ By: Sindre Sorhus
57
57
  Repository: sindresorhus/is-plain-obj
58
58
 
59
59
  > MIT License
60
- >
60
+ >
61
61
  > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
62
- >
62
+ >
63
63
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
64
- >
64
+ >
65
65
  > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66
- >
66
+ >
67
67
  > 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.
68
68
 
69
69
  <!-- DEPENDENCIES -->
@@ -88,13 +88,13 @@ By: Sindre Sorhus
88
88
  Repository: sindresorhus/dot-prop
89
89
 
90
90
  > MIT License
91
- >
91
+ >
92
92
  > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
93
- >
93
+ >
94
94
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
95
- >
95
+ >
96
96
  > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
97
- >
97
+ >
98
98
  > 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
99
 
100
100
  ---------------------------------------
@@ -105,13 +105,13 @@ By: Sindre Sorhus
105
105
  Repository: sindresorhus/is-plain-obj
106
106
 
107
107
  > MIT License
108
- >
108
+ >
109
109
  > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
110
- >
110
+ >
111
111
  > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
112
- >
112
+ >
113
113
  > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
114
- >
114
+ >
115
115
  > 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.
116
116
 
117
117
  ---------------------------------------
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var M=Object.defineProperty;var u=(e,r)=>M(e,"name",{value:r,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function w(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}u(w,"isPlainObject");var F=Object.defineProperty,L=u((e,r)=>F(e,"name",{value:r,configurable:!0}),"n$1");const S=L((e,r)=>{const t=r.split(".");return e.split(".").reduce((n,a,o)=>{const l=t[o]==="*"?"*":a;return n.push(l),n},[]).join(".")===r},"pathsAreEqual");var q=Object.defineProperty,R=u((e,r)=>q(e,"name",{value:r,configurable:!0}),"m$2");const k=R((e,r,t="")=>w(e)?Object.entries(e).reduce((n,[a,o])=>{let l=t;return l&&(l+="."),l+=a,r.some(g=>S(l,g))?n:w(o)?(n[a]=k(e[a],r,l),n):(n[a]=o,n)},{}):e,"recursiveOmit");var B=Object.defineProperty,D=u((e,r)=>B(e,"name",{value:r,configurable:!0}),"r");const K=D(e=>Array.isArray(e)&&e.length>0,"isFullArray"),W=D((e,r)=>K(r)?k(e,r):e,"omit"),C=W;var G=Object.defineProperty,z=u((e,r)=>G(e,"name",{value:r,configurable:!0}),"h");const T=z((e,r,t="")=>w(e)?Object.entries(e).reduce((n,[a,o])=>{let l=t;if(l&&(l+="."),l+=a,r.length>0){let g=!1;if(r.forEach(O=>{const _=l.split(".").length,x=O.split(".").length,m=O.split(".").slice(0,_).join("."),A=l.split(".").slice(0,x).join(".");S(A,m)&&(g=!0)}),!g)return n}return w(o)?(n[a]=T(e[a],r,l),n):(n[a]=o,n)},{}):e,"recursivePick");var H=Object.defineProperty,$=u((e,r)=>H(e,"name",{value:r,configurable:!0}),"t");const J=$(e=>Array.isArray(e)&&e.length>0,"isFullArray"),Q=$((e,r)=>J(r)?T(e,r):{},"pick"),U=Q;var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},E={},y={};Object.defineProperty(y,"__esModule",{value:!0});y.isDocumentToRecurOn=y.flatten=y.unique=void 0;function V(e){return[...new Set(e)]}u(V,"unique");y.unique=V;function X(e){return[].concat(...e)}u(X,"flatten");y.flatten=X;function Y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length}u(Y,"isDocumentToRecurOn");y.isDocumentToRecurOn=Y;var N={};Object.defineProperty(N,"__esModule",{value:!0});(function(e){var r=p&&p.__createBinding||(Object.create?function(s,i,f,d){d===void 0&&(d=f);var c=Object.getOwnPropertyDescriptor(i,f);(!c||("get"in c?!i.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:u(function(){return i[f]},"get")}),Object.defineProperty(s,d,c)}:function(s,i,f,d){d===void 0&&(d=f),s[d]=i[f]}),t=p&&p.__setModuleDefault||(Object.create?function(s,i){Object.defineProperty(s,"default",{enumerable:!0,value:i})}:function(s,i){s.default=i}),n=p&&p.__importStar||function(s){if(s&&s.__esModule)return s;var i={};if(s!=null)for(var f in s)f!=="default"&&Object.prototype.hasOwnProperty.call(s,f)&&r(i,s,f);return t(i,s),i},a=p&&p.__exportStar||function(s,i){for(var f in s)f!=="default"&&!Object.prototype.hasOwnProperty.call(i,f)&&r(i,s,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.deepKeysFromList=e.deepKeys=void 0;const o=n(y);a(N,e);function l(s,i){const f=A(i);return typeof s=="object"&&s!==null?O("",s,f):[]}u(l,"deepKeys"),e.deepKeys=l;function g(s,i){const f=A(i);return s.map(d=>typeof d=="object"&&d!==null?l(d,f):[])}u(g,"deepKeysFromList"),e.deepKeysFromList=g;function O(s,i,f){const d=Object.keys(i).map(c=>{const b=m(s,x(c,f));return f.expandNestedObjects&&o.isDocumentToRecurOn(i[c])||f.arrayIndexesAsKeys&&Array.isArray(i[c])&&i[c].length?O(b,i[c],f):f.expandArrayObjects&&Array.isArray(i[c])?_(i[c],b,f):f.ignoreEmptyArrays&&Array.isArray(i[c])&&!i[c].length?[]:b});return o.flatten(d)}u(O,"generateDeepKeysList");function _(s,i,f){let d=g(s,f);return s.length?s.length&&o.flatten(d).length===0?[i]:(d=d.map(c=>Array.isArray(c)&&c.length===0?[i]:c.map(b=>m(i,x(b,f)))),o.unique(o.flatten(d))):f.ignoreEmptyArraysWhenExpanding?[]:[i]}u(_,"processArrayKeys");function x(s,i){return i.escapeNestedDots?s.replace(/\./g,"\\."):s}u(x,"escapeNestedDotsIfSpecified");function m(s,i){return s?s+"."+i:i}u(m,"buildKeyName");function A(s){return{arrayIndexesAsKeys:!1,expandNestedObjects:!0,expandArrayObjects:!1,ignoreEmptyArraysWhenExpanding:!1,escapeNestedDots:!1,ignoreEmptyArrays:!1,...s??{}}}u(A,"mergeOptions")})(E);const h=u(e=>{const r=typeof e;return e!==null&&(r==="object"||r==="function")},"isObject"),P=new Set(["__proto__","prototype","constructor"]),Z=new Set("0123456789");function v(e){const r=[];let t="",n="start",a=!1;for(const o of e)switch(o){case"\\":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");a&&(t+=o),n="property",a=!a;break}case".":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="property";break}if(a){a=!1,t+=o;break}if(P.has(t))return[];r.push(t),t="",n="property";break}case"[":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="index";break}if(a){a=!1,t+=o;break}if(n==="property"){if(P.has(t))return[];r.push(t),t=""}n="index";break}case"]":{if(n==="index"){r.push(Number.parseInt(t,10)),t="",n="indexEnd";break}if(n==="indexEnd")throw new Error("Invalid character after an index")}default:{if(n==="index"&&!Z.has(o))throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");n==="start"&&(n="property"),a&&(a=!1,t+="\\"),t+=o}}switch(a&&(t+="\\"),n){case"property":{if(P.has(t))return[];r.push(t);break}case"index":throw new Error("Index was not closed");case"start":{r.push("");break}}return r}u(v,"getPathSegments");function I(e,r){if(typeof r!="number"&&Array.isArray(e)){const t=Number.parseInt(r,10);return Number.isInteger(t)&&e[t]===e[r]}return!1}u(I,"isStringIndex");function j(e,r){if(I(e,r))throw new Error("Cannot use string index")}u(j,"assertNotStringIndex");function ee(e,r,t){if(!h(e)||typeof r!="string")return t===void 0?e:t;const n=v(r);if(n.length===0)return t;for(let a=0;a<n.length;a++){const o=n[a];if(I(e,o)?e=a===n.length-1?void 0:null:e=e[o],e==null){if(a!==n.length-1)return t;break}}return e===void 0?t:e}u(ee,"getProperty");function re(e,r,t){if(!h(e)||typeof r!="string")return e;const n=e,a=v(r);for(let o=0;o<a.length;o++){const l=a[o];j(e,l),o===a.length-1?e[l]=t:h(e[l])||(e[l]=typeof a[o+1]=="number"?[]:{}),e=e[l]}return n}u(re,"setProperty");function ne(e,r){if(!h(e)||typeof r!="string")return!1;const t=v(r);for(let n=0;n<t.length;n++){const a=t[n];if(j(e,a),n===t.length-1)return delete e[a],!0;if(e=e[a],!h(e))return!1}}u(ne,"deleteProperty");function te(e,r){if(!h(e)||typeof r!="string")return!1;const t=v(r);if(t.length===0)return!1;for(const n of t){if(!h(e)||!(n in e)||I(e,n))return!1;e=e[n]}return!0}u(te,"hasProperty");function ie(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replaceAll(/[\\.[]/g,"\\$&")}u(ie,"escapePath");exports.deepKeys=E.deepKeys;exports.deepKeysFromList=E.deepKeysFromList;exports.deleteProperty=ne;exports.escapePath=ie;exports.getProperty=ee;exports.hasProperty=te;exports.isPlainObject=w;exports.omit=C;exports.pick=U;exports.setProperty=re;
1
+ "use strict";var D=Object.defineProperty;var u=(s,p)=>D(s,"name",{value:p,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./shared/omit-Cwc8rJUb.cjs"),q=require("./shared/pick-CkwC0jUm.cjs"),c=require("./shared/getProperty-D34HTBAJ.cjs"),M=require("./shared/isPlainObject-BTLAczOE.cjs");var o=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},y={},a={};Object.defineProperty(a,"__esModule",{value:!0});a.isDocumentToRecurOn=a.flatten=a.unique=void 0;function S(s){return[...new Set(s)]}u(S,"unique");a.unique=S;function T(s){return[].concat(...s)}u(T,"flatten");a.flatten=T;function E(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)&&Object.keys(s).length}u(E,"isDocumentToRecurOn");a.isDocumentToRecurOn=E;var P={};Object.defineProperty(P,"__esModule",{value:!0});(function(s){var p=o&&o.__createBinding||(Object.create?function(r,e,t,i){i===void 0&&(i=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:u(function(){return e[t]},"get")}),Object.defineProperty(r,i,n)}:function(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}),A=o&&o.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),v=o&&o.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&p(e,r,t);return A(e,r),e},m=o&&o.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&p(e,r,t)};Object.defineProperty(s,"__esModule",{value:!0}),s.deepKeysFromList=s.deepKeys=void 0;const f=v(a);m(P,s);function d(r,e){const t=j(e);return typeof r=="object"&&r!==null?b("",r,t):[]}u(d,"deepKeys"),s.deepKeys=d;function g(r,e){const t=j(e);return r.map(i=>typeof i=="object"&&i!==null?d(i,t):[])}u(g,"deepKeysFromList"),s.deepKeysFromList=g;function b(r,e,t){const i=Object.keys(e).map(n=>{const l=_(r,O(n,t));return t.expandNestedObjects&&f.isDocumentToRecurOn(e[n])||t.arrayIndexesAsKeys&&Array.isArray(e[n])&&e[n].length?b(l,e[n],t):t.expandArrayObjects&&Array.isArray(e[n])?h(e[n],l,t):t.ignoreEmptyArrays&&Array.isArray(e[n])&&!e[n].length?[]:l});return f.flatten(i)}u(b,"generateDeepKeysList");function h(r,e,t){let i=g(r,t);return r.length?r.length&&f.flatten(i).length===0?[e]:(i=i.map(n=>Array.isArray(n)&&n.length===0?[e]:n.map(l=>_(e,O(l,t)))),f.unique(f.flatten(i))):t.ignoreEmptyArraysWhenExpanding?[]:[e]}u(h,"processArrayKeys");function O(r,e){return e.escapeNestedDots?r.replace(/\./g,"\\."):r}u(O,"escapeNestedDotsIfSpecified");function _(r,e){return r?r+"."+e:e}u(_,"buildKeyName");function j(r){return{arrayIndexesAsKeys:!1,expandNestedObjects:!0,expandArrayObjects:!1,ignoreEmptyArraysWhenExpanding:!1,escapeNestedDots:!1,ignoreEmptyArrays:!1,...r??{}}}u(j,"mergeOptions")})(y);exports.omit=w;exports.pick=q;exports.deleteProperty=c.deleteProperty;exports.escapePath=c.escapePath;exports.getProperty=c.getProperty;exports.hasProperty=c.hasProperty;exports.setProperty=c.setProperty;exports.isPlainObject=M;exports.deepKeys=y.deepKeys;exports.deepKeysFromList=y.deepKeysFromList;
package/dist/index.d.cts CHANGED
@@ -785,6 +785,33 @@ NumberAbsolute<NegativeInfinity>
785
785
  */
786
786
  type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
787
787
 
788
+ /**
789
+ Check whether the given type is a number or a number string.
790
+
791
+ Supports floating-point as a string.
792
+
793
+ @example
794
+ ```
795
+ type A = IsNumberLike<'1'>;
796
+ //=> true
797
+
798
+ type B = IsNumberLike<'-1.1'>;
799
+ //=> true
800
+
801
+ type C = IsNumberLike<1>;
802
+ //=> true
803
+
804
+ type D = IsNumberLike<'a'>;
805
+ //=> false
806
+ */
807
+ type IsNumberLike<N> =
808
+ N extends number ? true
809
+ : N extends `${number}`
810
+ ? true
811
+ : N extends `${number}.${number}`
812
+ ? true
813
+ : false;
814
+
788
815
  /**
789
816
  Returns the minimum number in the given union of numbers.
790
817
 
@@ -1166,6 +1193,44 @@ type PathsOptions = {
1166
1193
  @default 10
1167
1194
  */
1168
1195
  maxRecursionDepth?: number;
1196
+
1197
+ /**
1198
+ Use bracket notation for array indices and numeric object keys.
1199
+
1200
+ @default false
1201
+
1202
+ @example
1203
+ ```
1204
+ type ArrayExample = {
1205
+ array: ['foo'];
1206
+ };
1207
+
1208
+ type A = Paths<ArrayExample, {bracketNotation: false}>;
1209
+ //=> 'array' | 'array.0'
1210
+
1211
+ type B = Paths<ArrayExample, {bracketNotation: true}>;
1212
+ //=> 'array' | 'array[0]'
1213
+ ```
1214
+
1215
+ @example
1216
+ ```
1217
+ type NumberKeyExample = {
1218
+ 1: ['foo'];
1219
+ };
1220
+
1221
+ type A = Paths<NumberKeyExample, {bracketNotation: false}>;
1222
+ //=> 1 | '1' | '1.0'
1223
+
1224
+ type B = Paths<NumberKeyExample, {bracketNotation: true}>;
1225
+ //=> '[1]' | '[1][0]'
1226
+ ```
1227
+ */
1228
+ bracketNotation?: boolean;
1229
+ };
1230
+
1231
+ type DefaultPathsOptions = {
1232
+ maxRecursionDepth: 10;
1233
+ bracketNotation: false;
1169
1234
  };
1170
1235
 
1171
1236
  /**
@@ -1209,7 +1274,14 @@ open('listB.1'); // TypeError. Because listB only has one element.
1209
1274
  @category Object
1210
1275
  @category Array
1211
1276
  */
1212
- type Paths<T, Options extends PathsOptions = {}> =
1277
+ type Paths<T, Options extends PathsOptions = {}> = _Paths<T, {
1278
+ // Set default maxRecursionDepth to 10
1279
+ maxRecursionDepth: Options['maxRecursionDepth'] extends number ? Options['maxRecursionDepth'] : DefaultPathsOptions['maxRecursionDepth'];
1280
+ // Set default bracketNotation to false
1281
+ bracketNotation: Options['bracketNotation'] extends boolean ? Options['bracketNotation'] : DefaultPathsOptions['bracketNotation'];
1282
+ }>;
1283
+
1284
+ type _Paths<T, Options extends Required<PathsOptions>> =
1213
1285
  T extends NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>
1214
1286
  ? never
1215
1287
  : IsAny<T> extends true
@@ -1224,25 +1296,50 @@ type Paths<T, Options extends PathsOptions = {}> =
1224
1296
  ? InternalPaths<T, Options>
1225
1297
  : never;
1226
1298
 
1227
- type InternalPaths<T, Options extends PathsOptions = {}> =
1228
- (Options['maxRecursionDepth'] extends number ? Options['maxRecursionDepth'] : 10) extends infer MaxDepth extends number
1299
+ type InternalPaths<T, Options extends Required<PathsOptions>> =
1300
+ Options['maxRecursionDepth'] extends infer MaxDepth extends number
1229
1301
  ? Required<T> extends infer T
1230
1302
  ? T extends EmptyObject | readonly []
1231
1303
  ? never
1232
1304
  : {
1233
1305
  [Key in keyof T]:
1234
1306
  Key extends string | number // Limit `Key` to string or number.
1235
- // If `Key` is a number, return `Key | `${Key}``, because both `array[0]` and `array['0']` work.
1236
- ?
1237
- | Key
1238
- | ToString<Key>
1239
- | (
1240
- GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1241
- ? IsNever<Paths<T[Key], {maxRecursionDepth: Subtract<MaxDepth, 1>}>> extends false
1242
- ? `${Key}.${Paths<T[Key], {maxRecursionDepth: Subtract<MaxDepth, 1>}>}`
1243
- : never
1307
+ ? (
1308
+ Options['bracketNotation'] extends true
1309
+ ? IsNumberLike<Key> extends true
1310
+ ? `[${Key}]`
1311
+ : (Key | ToString<Key>)
1244
1312
  : never
1245
- )
1313
+ |
1314
+ Options['bracketNotation'] extends false
1315
+ // If `Key` is a number, return `Key | `${Key}``, because both `array[0]` and `array['0']` work.
1316
+ ? (Key | ToString<Key>)
1317
+ : never
1318
+ ) extends infer TranformedKey extends string | number ?
1319
+ // 1. If style is 'a[0].b' and 'Key' is a numberlike value like 3 or '3', transform 'Key' to `[${Key}]`, else to `${Key}` | Key
1320
+ // 2. If style is 'a.0.b', transform 'Key' to `${Key}` | Key
1321
+ | TranformedKey
1322
+ | (
1323
+ // Recursively generate paths for the current key
1324
+ GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1325
+ ? _Paths<T[Key], {bracketNotation: Options['bracketNotation']; maxRecursionDepth: Subtract<MaxDepth, 1>}> extends infer SubPath
1326
+ ? SubPath extends string | number
1327
+ ? (
1328
+ Options['bracketNotation'] extends true
1329
+ ? SubPath extends `[${any}]` | `[${any}]${string}`
1330
+ ? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
1331
+ : `${TranformedKey}.${SubPath}`
1332
+ : never
1333
+ ) | (
1334
+ Options['bracketNotation'] extends false
1335
+ ? `${TranformedKey}.${SubPath}`
1336
+ : never
1337
+ )
1338
+ : never
1339
+ : never
1340
+ : never
1341
+ )
1342
+ : never
1246
1343
  : never
1247
1344
  }[keyof T & (T extends UnknownArray ? number : unknown)]
1248
1345
  : never
@@ -1546,6 +1643,8 @@ type ArraySplice<
1546
1643
  : never // Should never happen
1547
1644
  : never; // Should never happen
1548
1645
 
1646
+ type LiteralStringUnion<T> = LiteralUnion<T, string>;
1647
+
1549
1648
  /**
1550
1649
  Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
1551
1650
 
@@ -1774,6 +1873,25 @@ type UsefulInfo = OmitDeep<Info, 'userInfo.uselessInfo'>;
1774
1873
  // userInfo: {
1775
1874
  // name: string;
1776
1875
  // };
1876
+ // };
1877
+
1878
+ // Supports removing multiple paths
1879
+ type Info1 = {
1880
+ userInfo: {
1881
+ name: string;
1882
+ uselessField: string;
1883
+ uselessInfo: {
1884
+ foo: string;
1885
+ };
1886
+ };
1887
+ };
1888
+
1889
+ type UsefulInfo1 = OmitDeep<Info1, 'userInfo.uselessInfo' | 'userInfo.uselessField'>;
1890
+ // type UsefulInfo1 = {
1891
+ // userInfo: {
1892
+ // name: string;
1893
+ // };
1894
+ // };
1777
1895
 
1778
1896
  // Supports array
1779
1897
  type A = OmitDeep<[1, 'foo', 2], 1>;
@@ -1946,7 +2064,7 @@ type GetOptions = {
1946
2064
  /**
1947
2065
  Like the `Get` type but receives an array of strings as a path parameter.
1948
2066
  */
1949
- type GetWithPath<BaseType, Keys extends readonly string[], Options extends GetOptions = {}> =
2067
+ type GetWithPath<BaseType, Keys, Options extends GetOptions = {}> =
1950
2068
  Keys extends readonly []
1951
2069
  ? BaseType
1952
2070
  : Keys extends readonly [infer Head, ...infer Tail]
@@ -2117,8 +2235,13 @@ Get<Record<string, string>, 'foo', {strict: true}> // => string
2117
2235
  @category Array
2118
2236
  @category Template literal
2119
2237
  */
2120
- type Get<BaseType, Path extends string | readonly string[], Options extends GetOptions = {}> =
2121
- GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
2238
+ type Get<
2239
+ BaseType,
2240
+ Path extends
2241
+ | readonly string[]
2242
+ | LiteralStringUnion<ToString<Paths<BaseType, {bracketNotation: false}> | Paths<BaseType, {bracketNotation: true}>>>,
2243
+ Options extends GetOptions = {}> =
2244
+ GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
2122
2245
 
2123
2246
  declare const omit: <T extends { [key in string]: unknown; }, K extends string>(object: T, keys: Paths<T>[]) => OmitDeep<T, K>;
2124
2247
 
package/dist/index.d.mts CHANGED
@@ -785,6 +785,33 @@ NumberAbsolute<NegativeInfinity>
785
785
  */
786
786
  type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
787
787
 
788
+ /**
789
+ Check whether the given type is a number or a number string.
790
+
791
+ Supports floating-point as a string.
792
+
793
+ @example
794
+ ```
795
+ type A = IsNumberLike<'1'>;
796
+ //=> true
797
+
798
+ type B = IsNumberLike<'-1.1'>;
799
+ //=> true
800
+
801
+ type C = IsNumberLike<1>;
802
+ //=> true
803
+
804
+ type D = IsNumberLike<'a'>;
805
+ //=> false
806
+ */
807
+ type IsNumberLike<N> =
808
+ N extends number ? true
809
+ : N extends `${number}`
810
+ ? true
811
+ : N extends `${number}.${number}`
812
+ ? true
813
+ : false;
814
+
788
815
  /**
789
816
  Returns the minimum number in the given union of numbers.
790
817
 
@@ -1166,6 +1193,44 @@ type PathsOptions = {
1166
1193
  @default 10
1167
1194
  */
1168
1195
  maxRecursionDepth?: number;
1196
+
1197
+ /**
1198
+ Use bracket notation for array indices and numeric object keys.
1199
+
1200
+ @default false
1201
+
1202
+ @example
1203
+ ```
1204
+ type ArrayExample = {
1205
+ array: ['foo'];
1206
+ };
1207
+
1208
+ type A = Paths<ArrayExample, {bracketNotation: false}>;
1209
+ //=> 'array' | 'array.0'
1210
+
1211
+ type B = Paths<ArrayExample, {bracketNotation: true}>;
1212
+ //=> 'array' | 'array[0]'
1213
+ ```
1214
+
1215
+ @example
1216
+ ```
1217
+ type NumberKeyExample = {
1218
+ 1: ['foo'];
1219
+ };
1220
+
1221
+ type A = Paths<NumberKeyExample, {bracketNotation: false}>;
1222
+ //=> 1 | '1' | '1.0'
1223
+
1224
+ type B = Paths<NumberKeyExample, {bracketNotation: true}>;
1225
+ //=> '[1]' | '[1][0]'
1226
+ ```
1227
+ */
1228
+ bracketNotation?: boolean;
1229
+ };
1230
+
1231
+ type DefaultPathsOptions = {
1232
+ maxRecursionDepth: 10;
1233
+ bracketNotation: false;
1169
1234
  };
1170
1235
 
1171
1236
  /**
@@ -1209,7 +1274,14 @@ open('listB.1'); // TypeError. Because listB only has one element.
1209
1274
  @category Object
1210
1275
  @category Array
1211
1276
  */
1212
- type Paths<T, Options extends PathsOptions = {}> =
1277
+ type Paths<T, Options extends PathsOptions = {}> = _Paths<T, {
1278
+ // Set default maxRecursionDepth to 10
1279
+ maxRecursionDepth: Options['maxRecursionDepth'] extends number ? Options['maxRecursionDepth'] : DefaultPathsOptions['maxRecursionDepth'];
1280
+ // Set default bracketNotation to false
1281
+ bracketNotation: Options['bracketNotation'] extends boolean ? Options['bracketNotation'] : DefaultPathsOptions['bracketNotation'];
1282
+ }>;
1283
+
1284
+ type _Paths<T, Options extends Required<PathsOptions>> =
1213
1285
  T extends NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>
1214
1286
  ? never
1215
1287
  : IsAny<T> extends true
@@ -1224,25 +1296,50 @@ type Paths<T, Options extends PathsOptions = {}> =
1224
1296
  ? InternalPaths<T, Options>
1225
1297
  : never;
1226
1298
 
1227
- type InternalPaths<T, Options extends PathsOptions = {}> =
1228
- (Options['maxRecursionDepth'] extends number ? Options['maxRecursionDepth'] : 10) extends infer MaxDepth extends number
1299
+ type InternalPaths<T, Options extends Required<PathsOptions>> =
1300
+ Options['maxRecursionDepth'] extends infer MaxDepth extends number
1229
1301
  ? Required<T> extends infer T
1230
1302
  ? T extends EmptyObject | readonly []
1231
1303
  ? never
1232
1304
  : {
1233
1305
  [Key in keyof T]:
1234
1306
  Key extends string | number // Limit `Key` to string or number.
1235
- // If `Key` is a number, return `Key | `${Key}``, because both `array[0]` and `array['0']` work.
1236
- ?
1237
- | Key
1238
- | ToString<Key>
1239
- | (
1240
- GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1241
- ? IsNever<Paths<T[Key], {maxRecursionDepth: Subtract<MaxDepth, 1>}>> extends false
1242
- ? `${Key}.${Paths<T[Key], {maxRecursionDepth: Subtract<MaxDepth, 1>}>}`
1243
- : never
1307
+ ? (
1308
+ Options['bracketNotation'] extends true
1309
+ ? IsNumberLike<Key> extends true
1310
+ ? `[${Key}]`
1311
+ : (Key | ToString<Key>)
1244
1312
  : never
1245
- )
1313
+ |
1314
+ Options['bracketNotation'] extends false
1315
+ // If `Key` is a number, return `Key | `${Key}``, because both `array[0]` and `array['0']` work.
1316
+ ? (Key | ToString<Key>)
1317
+ : never
1318
+ ) extends infer TranformedKey extends string | number ?
1319
+ // 1. If style is 'a[0].b' and 'Key' is a numberlike value like 3 or '3', transform 'Key' to `[${Key}]`, else to `${Key}` | Key
1320
+ // 2. If style is 'a.0.b', transform 'Key' to `${Key}` | Key
1321
+ | TranformedKey
1322
+ | (
1323
+ // Recursively generate paths for the current key
1324
+ GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1325
+ ? _Paths<T[Key], {bracketNotation: Options['bracketNotation']; maxRecursionDepth: Subtract<MaxDepth, 1>}> extends infer SubPath
1326
+ ? SubPath extends string | number
1327
+ ? (
1328
+ Options['bracketNotation'] extends true
1329
+ ? SubPath extends `[${any}]` | `[${any}]${string}`
1330
+ ? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
1331
+ : `${TranformedKey}.${SubPath}`
1332
+ : never
1333
+ ) | (
1334
+ Options['bracketNotation'] extends false
1335
+ ? `${TranformedKey}.${SubPath}`
1336
+ : never
1337
+ )
1338
+ : never
1339
+ : never
1340
+ : never
1341
+ )
1342
+ : never
1246
1343
  : never
1247
1344
  }[keyof T & (T extends UnknownArray ? number : unknown)]
1248
1345
  : never
@@ -1546,6 +1643,8 @@ type ArraySplice<
1546
1643
  : never // Should never happen
1547
1644
  : never; // Should never happen
1548
1645
 
1646
+ type LiteralStringUnion<T> = LiteralUnion<T, string>;
1647
+
1549
1648
  /**
1550
1649
  Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
1551
1650
 
@@ -1774,6 +1873,25 @@ type UsefulInfo = OmitDeep<Info, 'userInfo.uselessInfo'>;
1774
1873
  // userInfo: {
1775
1874
  // name: string;
1776
1875
  // };
1876
+ // };
1877
+
1878
+ // Supports removing multiple paths
1879
+ type Info1 = {
1880
+ userInfo: {
1881
+ name: string;
1882
+ uselessField: string;
1883
+ uselessInfo: {
1884
+ foo: string;
1885
+ };
1886
+ };
1887
+ };
1888
+
1889
+ type UsefulInfo1 = OmitDeep<Info1, 'userInfo.uselessInfo' | 'userInfo.uselessField'>;
1890
+ // type UsefulInfo1 = {
1891
+ // userInfo: {
1892
+ // name: string;
1893
+ // };
1894
+ // };
1777
1895
 
1778
1896
  // Supports array
1779
1897
  type A = OmitDeep<[1, 'foo', 2], 1>;
@@ -1946,7 +2064,7 @@ type GetOptions = {
1946
2064
  /**
1947
2065
  Like the `Get` type but receives an array of strings as a path parameter.
1948
2066
  */
1949
- type GetWithPath<BaseType, Keys extends readonly string[], Options extends GetOptions = {}> =
2067
+ type GetWithPath<BaseType, Keys, Options extends GetOptions = {}> =
1950
2068
  Keys extends readonly []
1951
2069
  ? BaseType
1952
2070
  : Keys extends readonly [infer Head, ...infer Tail]
@@ -2117,8 +2235,13 @@ Get<Record<string, string>, 'foo', {strict: true}> // => string
2117
2235
  @category Array
2118
2236
  @category Template literal
2119
2237
  */
2120
- type Get<BaseType, Path extends string | readonly string[], Options extends GetOptions = {}> =
2121
- GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
2238
+ type Get<
2239
+ BaseType,
2240
+ Path extends
2241
+ | readonly string[]
2242
+ | LiteralStringUnion<ToString<Paths<BaseType, {bracketNotation: false}> | Paths<BaseType, {bracketNotation: true}>>>,
2243
+ Options extends GetOptions = {}> =
2244
+ GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
2122
2245
 
2123
2246
  declare const omit: <T extends { [key in string]: unknown; }, K extends string>(object: T, keys: Paths<T>[]) => OmitDeep<T, K>;
2124
2247
 
package/dist/index.d.ts CHANGED
@@ -785,6 +785,33 @@ NumberAbsolute<NegativeInfinity>
785
785
  */
786
786
  type NumberAbsolute<N extends number> = `${N}` extends `-${infer StringPositiveN}` ? StringToNumber<StringPositiveN> : N;
787
787
 
788
+ /**
789
+ Check whether the given type is a number or a number string.
790
+
791
+ Supports floating-point as a string.
792
+
793
+ @example
794
+ ```
795
+ type A = IsNumberLike<'1'>;
796
+ //=> true
797
+
798
+ type B = IsNumberLike<'-1.1'>;
799
+ //=> true
800
+
801
+ type C = IsNumberLike<1>;
802
+ //=> true
803
+
804
+ type D = IsNumberLike<'a'>;
805
+ //=> false
806
+ */
807
+ type IsNumberLike<N> =
808
+ N extends number ? true
809
+ : N extends `${number}`
810
+ ? true
811
+ : N extends `${number}.${number}`
812
+ ? true
813
+ : false;
814
+
788
815
  /**
789
816
  Returns the minimum number in the given union of numbers.
790
817
 
@@ -1166,6 +1193,44 @@ type PathsOptions = {
1166
1193
  @default 10
1167
1194
  */
1168
1195
  maxRecursionDepth?: number;
1196
+
1197
+ /**
1198
+ Use bracket notation for array indices and numeric object keys.
1199
+
1200
+ @default false
1201
+
1202
+ @example
1203
+ ```
1204
+ type ArrayExample = {
1205
+ array: ['foo'];
1206
+ };
1207
+
1208
+ type A = Paths<ArrayExample, {bracketNotation: false}>;
1209
+ //=> 'array' | 'array.0'
1210
+
1211
+ type B = Paths<ArrayExample, {bracketNotation: true}>;
1212
+ //=> 'array' | 'array[0]'
1213
+ ```
1214
+
1215
+ @example
1216
+ ```
1217
+ type NumberKeyExample = {
1218
+ 1: ['foo'];
1219
+ };
1220
+
1221
+ type A = Paths<NumberKeyExample, {bracketNotation: false}>;
1222
+ //=> 1 | '1' | '1.0'
1223
+
1224
+ type B = Paths<NumberKeyExample, {bracketNotation: true}>;
1225
+ //=> '[1]' | '[1][0]'
1226
+ ```
1227
+ */
1228
+ bracketNotation?: boolean;
1229
+ };
1230
+
1231
+ type DefaultPathsOptions = {
1232
+ maxRecursionDepth: 10;
1233
+ bracketNotation: false;
1169
1234
  };
1170
1235
 
1171
1236
  /**
@@ -1209,7 +1274,14 @@ open('listB.1'); // TypeError. Because listB only has one element.
1209
1274
  @category Object
1210
1275
  @category Array
1211
1276
  */
1212
- type Paths<T, Options extends PathsOptions = {}> =
1277
+ type Paths<T, Options extends PathsOptions = {}> = _Paths<T, {
1278
+ // Set default maxRecursionDepth to 10
1279
+ maxRecursionDepth: Options['maxRecursionDepth'] extends number ? Options['maxRecursionDepth'] : DefaultPathsOptions['maxRecursionDepth'];
1280
+ // Set default bracketNotation to false
1281
+ bracketNotation: Options['bracketNotation'] extends boolean ? Options['bracketNotation'] : DefaultPathsOptions['bracketNotation'];
1282
+ }>;
1283
+
1284
+ type _Paths<T, Options extends Required<PathsOptions>> =
1213
1285
  T extends NonRecursiveType | ReadonlyMap<unknown, unknown> | ReadonlySet<unknown>
1214
1286
  ? never
1215
1287
  : IsAny<T> extends true
@@ -1224,25 +1296,50 @@ type Paths<T, Options extends PathsOptions = {}> =
1224
1296
  ? InternalPaths<T, Options>
1225
1297
  : never;
1226
1298
 
1227
- type InternalPaths<T, Options extends PathsOptions = {}> =
1228
- (Options['maxRecursionDepth'] extends number ? Options['maxRecursionDepth'] : 10) extends infer MaxDepth extends number
1299
+ type InternalPaths<T, Options extends Required<PathsOptions>> =
1300
+ Options['maxRecursionDepth'] extends infer MaxDepth extends number
1229
1301
  ? Required<T> extends infer T
1230
1302
  ? T extends EmptyObject | readonly []
1231
1303
  ? never
1232
1304
  : {
1233
1305
  [Key in keyof T]:
1234
1306
  Key extends string | number // Limit `Key` to string or number.
1235
- // If `Key` is a number, return `Key | `${Key}``, because both `array[0]` and `array['0']` work.
1236
- ?
1237
- | Key
1238
- | ToString<Key>
1239
- | (
1240
- GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1241
- ? IsNever<Paths<T[Key], {maxRecursionDepth: Subtract<MaxDepth, 1>}>> extends false
1242
- ? `${Key}.${Paths<T[Key], {maxRecursionDepth: Subtract<MaxDepth, 1>}>}`
1243
- : never
1307
+ ? (
1308
+ Options['bracketNotation'] extends true
1309
+ ? IsNumberLike<Key> extends true
1310
+ ? `[${Key}]`
1311
+ : (Key | ToString<Key>)
1244
1312
  : never
1245
- )
1313
+ |
1314
+ Options['bracketNotation'] extends false
1315
+ // If `Key` is a number, return `Key | `${Key}``, because both `array[0]` and `array['0']` work.
1316
+ ? (Key | ToString<Key>)
1317
+ : never
1318
+ ) extends infer TranformedKey extends string | number ?
1319
+ // 1. If style is 'a[0].b' and 'Key' is a numberlike value like 3 or '3', transform 'Key' to `[${Key}]`, else to `${Key}` | Key
1320
+ // 2. If style is 'a.0.b', transform 'Key' to `${Key}` | Key
1321
+ | TranformedKey
1322
+ | (
1323
+ // Recursively generate paths for the current key
1324
+ GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
1325
+ ? _Paths<T[Key], {bracketNotation: Options['bracketNotation']; maxRecursionDepth: Subtract<MaxDepth, 1>}> extends infer SubPath
1326
+ ? SubPath extends string | number
1327
+ ? (
1328
+ Options['bracketNotation'] extends true
1329
+ ? SubPath extends `[${any}]` | `[${any}]${string}`
1330
+ ? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
1331
+ : `${TranformedKey}.${SubPath}`
1332
+ : never
1333
+ ) | (
1334
+ Options['bracketNotation'] extends false
1335
+ ? `${TranformedKey}.${SubPath}`
1336
+ : never
1337
+ )
1338
+ : never
1339
+ : never
1340
+ : never
1341
+ )
1342
+ : never
1246
1343
  : never
1247
1344
  }[keyof T & (T extends UnknownArray ? number : unknown)]
1248
1345
  : never
@@ -1546,6 +1643,8 @@ type ArraySplice<
1546
1643
  : never // Should never happen
1547
1644
  : never; // Should never happen
1548
1645
 
1646
+ type LiteralStringUnion<T> = LiteralUnion<T, string>;
1647
+
1549
1648
  /**
1550
1649
  Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
1551
1650
 
@@ -1774,6 +1873,25 @@ type UsefulInfo = OmitDeep<Info, 'userInfo.uselessInfo'>;
1774
1873
  // userInfo: {
1775
1874
  // name: string;
1776
1875
  // };
1876
+ // };
1877
+
1878
+ // Supports removing multiple paths
1879
+ type Info1 = {
1880
+ userInfo: {
1881
+ name: string;
1882
+ uselessField: string;
1883
+ uselessInfo: {
1884
+ foo: string;
1885
+ };
1886
+ };
1887
+ };
1888
+
1889
+ type UsefulInfo1 = OmitDeep<Info1, 'userInfo.uselessInfo' | 'userInfo.uselessField'>;
1890
+ // type UsefulInfo1 = {
1891
+ // userInfo: {
1892
+ // name: string;
1893
+ // };
1894
+ // };
1777
1895
 
1778
1896
  // Supports array
1779
1897
  type A = OmitDeep<[1, 'foo', 2], 1>;
@@ -1946,7 +2064,7 @@ type GetOptions = {
1946
2064
  /**
1947
2065
  Like the `Get` type but receives an array of strings as a path parameter.
1948
2066
  */
1949
- type GetWithPath<BaseType, Keys extends readonly string[], Options extends GetOptions = {}> =
2067
+ type GetWithPath<BaseType, Keys, Options extends GetOptions = {}> =
1950
2068
  Keys extends readonly []
1951
2069
  ? BaseType
1952
2070
  : Keys extends readonly [infer Head, ...infer Tail]
@@ -2117,8 +2235,13 @@ Get<Record<string, string>, 'foo', {strict: true}> // => string
2117
2235
  @category Array
2118
2236
  @category Template literal
2119
2237
  */
2120
- type Get<BaseType, Path extends string | readonly string[], Options extends GetOptions = {}> =
2121
- GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
2238
+ type Get<
2239
+ BaseType,
2240
+ Path extends
2241
+ | readonly string[]
2242
+ | LiteralStringUnion<ToString<Paths<BaseType, {bracketNotation: false}> | Paths<BaseType, {bracketNotation: true}>>>,
2243
+ Options extends GetOptions = {}> =
2244
+ GetWithPath<BaseType, Path extends string ? ToPath<Path> : Path, Options>;
2122
2245
 
2123
2246
  declare const omit: <T extends { [key in string]: unknown; }, K extends string>(object: T, keys: Paths<T>[]) => OmitDeep<T, K>;
2124
2247
 
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var M=Object.defineProperty;var u=(e,r)=>M(e,"name",{value:r,configurable:!0});function m(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}u(m,"isPlainObject");var j=Object.defineProperty,L=u((e,r)=>j(e,"name",{value:r,configurable:!0}),"n$1");const S=L((e,r)=>{const t=r.split(".");return e.split(".").reduce((n,a,o)=>{const l=t[o]==="*"?"*":a;return n.push(l),n},[]).join(".")===r},"pathsAreEqual");var q=Object.defineProperty,R=u((e,r)=>q(e,"name",{value:r,configurable:!0}),"m$2");const k=R((e,r,t="")=>m(e)?Object.entries(e).reduce((n,[a,o])=>{let l=t;return l&&(l+="."),l+=a,r.some(g=>S(l,g))?n:m(o)?(n[a]=k(e[a],r,l),n):(n[a]=o,n)},{}):e,"recursiveOmit");var B=Object.defineProperty,D=u((e,r)=>B(e,"name",{value:r,configurable:!0}),"r");const K=D(e=>Array.isArray(e)&&e.length>0,"isFullArray"),W=D((e,r)=>K(r)?k(e,r):e,"omit"),Z=W;var C=Object.defineProperty,G=u((e,r)=>C(e,"name",{value:r,configurable:!0}),"h");const $=G((e,r,t="")=>m(e)?Object.entries(e).reduce((n,[a,o])=>{let l=t;if(l&&(l+="."),l+=a,r.length>0){let g=!1;if(r.forEach(O=>{const _=l.split(".").length,x=O.split(".").length,b=O.split(".").slice(0,_).join("."),A=l.split(".").slice(0,x).join(".");S(A,b)&&(g=!0)}),!g)return n}return m(o)?(n[a]=$(e[a],r,l),n):(n[a]=o,n)},{}):e,"recursivePick");var z=Object.defineProperty,N=u((e,r)=>z(e,"name",{value:r,configurable:!0}),"t");const H=N(e=>Array.isArray(e)&&e.length>0,"isFullArray"),J=N((e,r)=>H(r)?$(e,r):{},"pick"),ee=J;var p=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},P={},y={};Object.defineProperty(y,"__esModule",{value:!0});y.isDocumentToRecurOn=y.flatten=y.unique=void 0;function Q(e){return[...new Set(e)]}u(Q,"unique");y.unique=Q;function U(e){return[].concat(...e)}u(U,"flatten");y.flatten=U;function V(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length}u(V,"isDocumentToRecurOn");y.isDocumentToRecurOn=V;var T={};Object.defineProperty(T,"__esModule",{value:!0});(function(e){var r=p&&p.__createBinding||(Object.create?function(s,i,f,d){d===void 0&&(d=f);var c=Object.getOwnPropertyDescriptor(i,f);(!c||("get"in c?!i.__esModule:c.writable||c.configurable))&&(c={enumerable:!0,get:u(function(){return i[f]},"get")}),Object.defineProperty(s,d,c)}:function(s,i,f,d){d===void 0&&(d=f),s[d]=i[f]}),t=p&&p.__setModuleDefault||(Object.create?function(s,i){Object.defineProperty(s,"default",{enumerable:!0,value:i})}:function(s,i){s.default=i}),n=p&&p.__importStar||function(s){if(s&&s.__esModule)return s;var i={};if(s!=null)for(var f in s)f!=="default"&&Object.prototype.hasOwnProperty.call(s,f)&&r(i,s,f);return t(i,s),i},a=p&&p.__exportStar||function(s,i){for(var f in s)f!=="default"&&!Object.prototype.hasOwnProperty.call(i,f)&&r(i,s,f)};Object.defineProperty(e,"__esModule",{value:!0}),e.deepKeysFromList=e.deepKeys=void 0;const o=n(y);a(T,e);function l(s,i){const f=A(i);return typeof s=="object"&&s!==null?O("",s,f):[]}u(l,"deepKeys"),e.deepKeys=l;function g(s,i){const f=A(i);return s.map(d=>typeof d=="object"&&d!==null?l(d,f):[])}u(g,"deepKeysFromList"),e.deepKeysFromList=g;function O(s,i,f){const d=Object.keys(i).map(c=>{const w=b(s,x(c,f));return f.expandNestedObjects&&o.isDocumentToRecurOn(i[c])||f.arrayIndexesAsKeys&&Array.isArray(i[c])&&i[c].length?O(w,i[c],f):f.expandArrayObjects&&Array.isArray(i[c])?_(i[c],w,f):f.ignoreEmptyArrays&&Array.isArray(i[c])&&!i[c].length?[]:w});return o.flatten(d)}u(O,"generateDeepKeysList");function _(s,i,f){let d=g(s,f);return s.length?s.length&&o.flatten(d).length===0?[i]:(d=d.map(c=>Array.isArray(c)&&c.length===0?[i]:c.map(w=>b(i,x(w,f)))),o.unique(o.flatten(d))):f.ignoreEmptyArraysWhenExpanding?[]:[i]}u(_,"processArrayKeys");function x(s,i){return i.escapeNestedDots?s.replace(/\./g,"\\."):s}u(x,"escapeNestedDotsIfSpecified");function b(s,i){return s?s+"."+i:i}u(b,"buildKeyName");function A(s){return{arrayIndexesAsKeys:!1,expandNestedObjects:!0,expandArrayObjects:!1,ignoreEmptyArraysWhenExpanding:!1,escapeNestedDots:!1,ignoreEmptyArrays:!1,...s??{}}}u(A,"mergeOptions")})(P);const h=u(e=>{const r=typeof e;return e!==null&&(r==="object"||r==="function")},"isObject"),E=new Set(["__proto__","prototype","constructor"]),X=new Set("0123456789");function v(e){const r=[];let t="",n="start",a=!1;for(const o of e)switch(o){case"\\":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");a&&(t+=o),n="property",a=!a;break}case".":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="property";break}if(a){a=!1,t+=o;break}if(E.has(t))return[];r.push(t),t="",n="property";break}case"[":{if(n==="index")throw new Error("Invalid character in an index");if(n==="indexEnd"){n="index";break}if(a){a=!1,t+=o;break}if(n==="property"){if(E.has(t))return[];r.push(t),t=""}n="index";break}case"]":{if(n==="index"){r.push(Number.parseInt(t,10)),t="",n="indexEnd";break}if(n==="indexEnd")throw new Error("Invalid character after an index")}default:{if(n==="index"&&!X.has(o))throw new Error("Invalid character in an index");if(n==="indexEnd")throw new Error("Invalid character after an index");n==="start"&&(n="property"),a&&(a=!1,t+="\\"),t+=o}}switch(a&&(t+="\\"),n){case"property":{if(E.has(t))return[];r.push(t);break}case"index":throw new Error("Index was not closed");case"start":{r.push("");break}}return r}u(v,"getPathSegments");function I(e,r){if(typeof r!="number"&&Array.isArray(e)){const t=Number.parseInt(r,10);return Number.isInteger(t)&&e[t]===e[r]}return!1}u(I,"isStringIndex");function F(e,r){if(I(e,r))throw new Error("Cannot use string index")}u(F,"assertNotStringIndex");function re(e,r,t){if(!h(e)||typeof r!="string")return t===void 0?e:t;const n=v(r);if(n.length===0)return t;for(let a=0;a<n.length;a++){const o=n[a];if(I(e,o)?e=a===n.length-1?void 0:null:e=e[o],e==null){if(a!==n.length-1)return t;break}}return e===void 0?t:e}u(re,"getProperty");function ne(e,r,t){if(!h(e)||typeof r!="string")return e;const n=e,a=v(r);for(let o=0;o<a.length;o++){const l=a[o];F(e,l),o===a.length-1?e[l]=t:h(e[l])||(e[l]=typeof a[o+1]=="number"?[]:{}),e=e[l]}return n}u(ne,"setProperty");function te(e,r){if(!h(e)||typeof r!="string")return!1;const t=v(r);for(let n=0;n<t.length;n++){const a=t[n];if(F(e,a),n===t.length-1)return delete e[a],!0;if(e=e[a],!h(e))return!1}}u(te,"deleteProperty");function ie(e,r){if(!h(e)||typeof r!="string")return!1;const t=v(r);if(t.length===0)return!1;for(const n of t){if(!h(e)||!(n in e)||I(e,n))return!1;e=e[n]}return!0}u(ie,"hasProperty");function ae(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replaceAll(/[\\.[]/g,"\\$&")}u(ae,"escapePath");const se=P.deepKeys,fe=P.deepKeysFromList;export{se as deepKeys,fe as deepKeysFromList,te as deleteProperty,ae as escapePath,re as getProperty,ie as hasProperty,m as isPlainObject,Z as omit,ee as pick,ne as setProperty};
1
+ var P=Object.defineProperty;var u=(s,c)=>P(s,"name",{value:c,configurable:!0});import{default as F}from"./shared/omit-Df-0bpNu.mjs";import{default as q}from"./shared/pick-CS1_JC9v.mjs";import{deleteProperty as I,escapePath as B,getProperty as W,hasProperty as G,setProperty as K}from"./shared/getProperty-C5Q_YpVO.mjs";import{default as z}from"./shared/isPlainObject-CFPUbgRS.mjs";var f=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},p={},o={};Object.defineProperty(o,"__esModule",{value:!0});o.isDocumentToRecurOn=o.flatten=o.unique=void 0;function h(s){return[...new Set(s)]}u(h,"unique");o.unique=h;function w(s){return[].concat(...s)}u(w,"flatten");o.flatten=w;function x(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)&&Object.keys(s).length}u(x,"isDocumentToRecurOn");o.isDocumentToRecurOn=x;var j={};Object.defineProperty(j,"__esModule",{value:!0});(function(s){var c=f&&f.__createBinding||(Object.create?function(r,e,t,i){i===void 0&&(i=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:u(function(){return e[t]},"get")}),Object.defineProperty(r,i,n)}:function(r,e,t,i){i===void 0&&(i=t),r[i]=e[t]}),A=f&&f.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e})}:function(r,e){r.default=e}),m=f&&f.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&c(e,r,t);return A(e,r),e},v=f&&f.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&c(e,r,t)};Object.defineProperty(s,"__esModule",{value:!0}),s.deepKeysFromList=s.deepKeys=void 0;const a=m(o);v(j,s);function d(r,e){const t=_(e);return typeof r=="object"&&r!==null?b("",r,t):[]}u(d,"deepKeys"),s.deepKeys=d;function y(r,e){const t=_(e);return r.map(i=>typeof i=="object"&&i!==null?d(i,t):[])}u(y,"deepKeysFromList"),s.deepKeysFromList=y;function b(r,e,t){const i=Object.keys(e).map(n=>{const l=O(r,g(n,t));return t.expandNestedObjects&&a.isDocumentToRecurOn(e[n])||t.arrayIndexesAsKeys&&Array.isArray(e[n])&&e[n].length?b(l,e[n],t):t.expandArrayObjects&&Array.isArray(e[n])?D(e[n],l,t):t.ignoreEmptyArrays&&Array.isArray(e[n])&&!e[n].length?[]:l});return a.flatten(i)}u(b,"generateDeepKeysList");function D(r,e,t){let i=y(r,t);return r.length?r.length&&a.flatten(i).length===0?[e]:(i=i.map(n=>Array.isArray(n)&&n.length===0?[e]:n.map(l=>O(e,g(l,t)))),a.unique(a.flatten(i))):t.ignoreEmptyArraysWhenExpanding?[]:[e]}u(D,"processArrayKeys");function g(r,e){return e.escapeNestedDots?r.replace(/\./g,"\\."):r}u(g,"escapeNestedDotsIfSpecified");function O(r,e){return r?r+"."+e:e}u(O,"buildKeyName");function _(r){return{arrayIndexesAsKeys:!1,expandNestedObjects:!0,expandArrayObjects:!1,ignoreEmptyArraysWhenExpanding:!1,escapeNestedDots:!1,ignoreEmptyArrays:!1,...r??{}}}u(_,"mergeOptions")})(p);const E=p.deepKeys,L=p.deepKeysFromList;export{E as deepKeys,L as deepKeysFromList,I as deleteProperty,B as escapePath,W as getProperty,G as hasProperty,z as isPlainObject,F as omit,q as pick,K as setProperty};
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var s=(r,n)=>c(r,"name",{value:n,configurable:!0});const a=s(r=>{const n=typeof r;return r!==null&&(n==="object"||n==="function")},"isObject"),x=s(r=>a(r)&&Object.keys(r).length===0,"isEmptyObject"),u=new Set(["__proto__","prototype","constructor"]),g=new Set("0123456789");function d(r){const n=[];let t="",e="start",i=!1;for(const f of r)switch(f){case"\\":{if(e==="index")throw new Error("Invalid character in an index");if(e==="indexEnd")throw new Error("Invalid character after an index");i&&(t+=f),e="property",i=!i;break}case".":{if(e==="index")throw new Error("Invalid character in an index");if(e==="indexEnd"){e="property";break}if(i){i=!1,t+=f;break}if(u.has(t))return[];n.push(t),t="",e="property";break}case"[":{if(e==="index")throw new Error("Invalid character in an index");if(e==="indexEnd"){e="index";break}if(i){i=!1,t+=f;break}if(e==="property"){if(u.has(t))return[];n.push(t),t=""}e="index";break}case"]":{if(e==="index"){n.push(Number.parseInt(t,10)),t="",e="indexEnd";break}if(e==="indexEnd")throw new Error("Invalid character after an index")}default:{if(e==="index"&&!g.has(f))throw new Error("Invalid character in an index");if(e==="indexEnd")throw new Error("Invalid character after an index");e==="start"&&(e="property"),i&&(i=!1,t+="\\"),t+=f}}switch(i&&(t+="\\"),e){case"property":{if(u.has(t))return[];n.push(t);break}case"index":throw new Error("Index was not closed");case"start":{n.push("");break}}return n}s(d,"getPathSegments");function l(r,n){if(typeof n!="number"&&Array.isArray(r)){const t=Number.parseInt(n,10);return Number.isInteger(t)&&r[t]===r[n]}return!1}s(l,"isStringIndex");function p(r,n){if(l(r,n))throw new Error("Cannot use string index")}s(p,"assertNotStringIndex");function I(r,n,t){if(!a(r)||typeof n!="string")return t===void 0?r:t;const e=d(n);if(e.length===0)return t;for(let i=0;i<e.length;i++){const f=e[i];if(l(r,f)?r=i===e.length-1?void 0:null:r=r[f],r==null){if(i!==e.length-1)return t;break}}return r===void 0?t:r}s(I,"getProperty");function m(r,n,t){if(!a(r)||typeof n!="string")return r;const e=r,i=d(n);for(let f=0;f<i.length;f++){const o=i[f];p(r,o),f===i.length-1?r[o]=t:a(r[o])||(r[o]=typeof i[f+1]=="number"?[]:{}),r=r[o]}return e}s(m,"setProperty");function A(r,n){if(!a(r)||typeof n!="string")return!1;const t=d(n);for(let e=0;e<t.length;e++){const i=t[e];if(p(r,i),e===t.length-1)return delete r[i],!0;if(r=r[i],!a(r))return!1}}s(A,"deleteProperty");function P(r,n){if(!a(r)||typeof n!="string")return!1;const t=d(n);if(t.length===0)return!1;for(const e of t){if(!a(r)||!(e in r)||l(r,e))return!1;r=r[e]}return!0}s(P,"hasProperty");function w(r){if(typeof r!="string")throw new TypeError("Expected a string");return r.replaceAll(/[\\.[]/g,"\\$&")}s(w,"escapePath");function h(r){const n=Object.entries(r);return Array.isArray(r)?n.map(([t,e])=>[Number(t),e]):n}s(h,"entries");function E(r){let n="";for(let[t,e]of h(r))typeof e=="number"?n+=`[${e}]`:(e=w(e),n+=t===0?e:`.${e}`);return n}s(E,"stringifyPath");function*y(r,n=[]){if(!a(r)||x(r)){n.length>0&&(yield E(n));return}for(const[t,e]of h(r))yield*y(e,[...n,t])}s(y,"deepKeysIterator");function S(r){return[...y(r)]}s(S,"deepKeys");export{S as deepKeys,A as deleteProperty,w as escapePath,I as getProperty,P as hasProperty,m as setProperty};
@@ -0,0 +1 @@
1
+ "use strict";var g=Object.defineProperty;var f=(r,n)=>g(r,"name",{value:n,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=f(r=>{const n=typeof r;return r!==null&&(n==="object"||n==="function")},"isObject"),x=f(r=>a(r)&&Object.keys(r).length===0,"isEmptyObject"),u=new Set(["__proto__","prototype","constructor"]),w=new Set("0123456789");function d(r){const n=[];let t="",e="start",i=!1;for(const s of r)switch(s){case"\\":{if(e==="index")throw new Error("Invalid character in an index");if(e==="indexEnd")throw new Error("Invalid character after an index");i&&(t+=s),e="property",i=!i;break}case".":{if(e==="index")throw new Error("Invalid character in an index");if(e==="indexEnd"){e="property";break}if(i){i=!1,t+=s;break}if(u.has(t))return[];n.push(t),t="",e="property";break}case"[":{if(e==="index")throw new Error("Invalid character in an index");if(e==="indexEnd"){e="index";break}if(i){i=!1,t+=s;break}if(e==="property"){if(u.has(t))return[];n.push(t),t=""}e="index";break}case"]":{if(e==="index"){n.push(Number.parseInt(t,10)),t="",e="indexEnd";break}if(e==="indexEnd")throw new Error("Invalid character after an index")}default:{if(e==="index"&&!w.has(s))throw new Error("Invalid character in an index");if(e==="indexEnd")throw new Error("Invalid character after an index");e==="start"&&(e="property"),i&&(i=!1,t+="\\"),t+=s}}switch(i&&(t+="\\"),e){case"property":{if(u.has(t))return[];n.push(t);break}case"index":throw new Error("Index was not closed");case"start":{n.push("");break}}return n}f(d,"getPathSegments");function l(r,n){if(typeof n!="number"&&Array.isArray(r)){const t=Number.parseInt(n,10);return Number.isInteger(t)&&r[t]===r[n]}return!1}f(l,"isStringIndex");function p(r,n){if(l(r,n))throw new Error("Cannot use string index")}f(p,"assertNotStringIndex");function E(r,n,t){if(!a(r)||typeof n!="string")return t===void 0?r:t;const e=d(n);if(e.length===0)return t;for(let i=0;i<e.length;i++){const s=e[i];if(l(r,s)?r=i===e.length-1?void 0:null:r=r[s],r==null){if(i!==e.length-1)return t;break}}return r===void 0?t:r}f(E,"getProperty");function k(r,n,t){if(!a(r)||typeof n!="string")return r;const e=r,i=d(n);for(let s=0;s<i.length;s++){const o=i[s];p(r,o),s===i.length-1?r[o]=t:a(r[o])||(r[o]=typeof i[s+1]=="number"?[]:{}),r=r[o]}return e}f(k,"setProperty");function I(r,n){if(!a(r)||typeof n!="string")return!1;const t=d(n);for(let e=0;e<t.length;e++){const i=t[e];if(p(r,i),e===t.length-1)return delete r[i],!0;if(r=r[i],!a(r))return!1}}f(I,"deleteProperty");function m(r,n){if(!a(r)||typeof n!="string")return!1;const t=d(n);if(t.length===0)return!1;for(const e of t){if(!a(r)||!(e in r)||l(r,e))return!1;r=r[e]}return!0}f(m,"hasProperty");function y(r){if(typeof r!="string")throw new TypeError("Expected a string");return r.replaceAll(/[\\.[]/g,"\\$&")}f(y,"escapePath");function h(r){const n=Object.entries(r);return Array.isArray(r)?n.map(([t,e])=>[Number(t),e]):n}f(h,"entries");function P(r){let n="";for(let[t,e]of h(r))typeof e=="number"?n+=`[${e}]`:(e=y(e),n+=t===0?e:`.${e}`);return n}f(P,"stringifyPath");function*c(r,n=[]){if(!a(r)||x(r)){n.length>0&&(yield P(n));return}for(const[t,e]of h(r))yield*c(e,[...n,t])}f(c,"deepKeysIterator");function A(r){return[...c(r)]}f(A,"deepKeys");exports.deepKeys=A;exports.deleteProperty=I;exports.escapePath=y;exports.getProperty=E;exports.hasProperty=m;exports.setProperty=k;
@@ -0,0 +1 @@
1
+ "use strict";var r=Object.defineProperty;var e=(t,o)=>r(t,"name",{value:o,configurable:!0});function n(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)}e(n,"isPlainObject");module.exports=n;
@@ -0,0 +1 @@
1
+ var n=Object.defineProperty;var e=(t,o)=>n(t,"name",{value:o,configurable:!0});function i(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)}e(i,"isPlainObject");export{i as default};
@@ -0,0 +1 @@
1
+ "use strict";var v=Object.defineProperty;var t=(r,e)=>v(r,"name",{value:e,configurable:!0});const s=require("./isPlainObject-BTLAczOE.cjs"),b=require("./paths-are-equal-D8teV-Y-.cjs");var f=Object.defineProperty,y=t((r,e)=>f(r,"name",{value:e,configurable:!0}),"m$1");const u=y((r,e,l="")=>s(r)?Object.entries(r).reduce((a,[n,c])=>{let i=l;return i&&(i+="."),i+=n,e.some(m=>b.c(i,m))?a:s(c)?(a[n]=u(r[n],e,i),a):(a[n]=c,a)},{}):r,"recursiveOmit");var O=Object.defineProperty,o=t((r,e)=>O(r,"name",{value:e,configurable:!0}),"r");const j=o(r=>Array.isArray(r)&&r.length>0,"isFullArray"),p=o((r,e)=>j(e)?u(r,e):r,"omit");module.exports=p;
@@ -0,0 +1 @@
1
+ var s=Object.defineProperty;var o=(r,e)=>s(r,"name",{value:e,configurable:!0});import c from"./isPlainObject-CFPUbgRS.mjs";import{c as v}from"./paths-are-equal-BgwMgI_D.mjs";var b=Object.defineProperty,p=o((r,e)=>b(r,"name",{value:e,configurable:!0}),"m$1");const m=p((r,e,u="")=>c(r)?Object.entries(r).reduce((a,[n,t])=>{let i=u;return i&&(i+="."),i+=n,e.some(f=>v(i,f))?a:c(t)?(a[n]=m(r[n],e,i),a):(a[n]=t,a)},{}):r,"recursiveOmit");var y=Object.defineProperty,l=o((r,e)=>y(r,"name",{value:e,configurable:!0}),"r");const O=l(r=>Array.isArray(r)&&r.length>0,"isFullArray"),A=l((r,e)=>O(e)?m(r,e):r,"omit");export{A as default};
@@ -0,0 +1 @@
1
+ var u=Object.defineProperty;var t=(r,e)=>u(r,"name",{value:e,configurable:!0});var p=Object.defineProperty,l=t((r,e)=>p(r,"name",{value:e,configurable:!0}),"n");const d=l((r,e)=>{const o=e.split(".");return r.split(".").reduce((n,a,c)=>{const s=o[c]==="*"?"*":a;return n.push(s),n},[]).join(".")===e},"pathsAreEqual");export{d as c};
@@ -0,0 +1 @@
1
+ "use strict";var o=Object.defineProperty;var n=(r,e)=>o(r,"name",{value:e,configurable:!0});var i=Object.defineProperty,l=n((r,e)=>i(r,"name",{value:e,configurable:!0}),"n");const p=l((r,e)=>{const c=e.split(".");return r.split(".").reduce((t,s,u)=>{const a=c[u]==="*"?"*":s;return t.push(a),t},[]).join(".")===e},"pathsAreEqual");exports.c=p;
@@ -0,0 +1 @@
1
+ var j=Object.defineProperty;var a=(e,r)=>j(e,"name",{value:r,configurable:!0});import s from"./isPlainObject-CFPUbgRS.mjs";import{c as m}from"./paths-are-equal-BgwMgI_D.mjs";var d=Object.defineProperty,y=a((e,r)=>d(e,"name",{value:r,configurable:!0}),"h");const p=y((e,r,f="")=>s(e)?Object.entries(e).reduce((i,[l,c])=>{let t=f;if(t&&(t+="."),t+=l,r.length>0){let n=!1;if(r.forEach(o=>{const v=t.split(".").length,b=o.split(".").length,g=o.split(".").slice(0,v).join("."),h=t.split(".").slice(0,b).join(".");m(h,g)&&(n=!0)}),!n)return i}return s(c)?(i[l]=p(e[l],r,t),i):(i[l]=c,i)},{}):e,"recursivePick");var P=Object.defineProperty,u=a((e,r)=>P(e,"name",{value:r,configurable:!0}),"t");const O=u(e=>Array.isArray(e)&&e.length>0,"isFullArray"),x=u((e,r)=>O(r)?p(e,r):{},"pick");export{x as default};
@@ -0,0 +1 @@
1
+ "use strict";var j=Object.defineProperty;var l=(e,r)=>j(e,"name",{value:r,configurable:!0});const u=require("./isPlainObject-BTLAczOE.cjs"),y=require("./paths-are-equal-D8teV-Y-.cjs");var P=Object.defineProperty,d=l((e,r)=>P(e,"name",{value:r,configurable:!0}),"h");const o=d((e,r,f="")=>u(e)?Object.entries(e).reduce((i,[c,a])=>{let t=f;if(t&&(t+="."),t+=c,r.length>0){let n=!1;if(r.forEach(s=>{const h=t.split(".").length,v=s.split(".").length,b=s.split(".").slice(0,h).join("."),g=t.split(".").slice(0,v).join(".");y.c(g,b)&&(n=!0)}),!n)return i}return u(a)?(i[c]=o(e[c],r,t),i):(i[c]=a,i)},{}):e,"recursivePick");var A=Object.defineProperty,p=l((e,r)=>A(e,"name",{value:r,configurable:!0}),"t");const O=p(e=>Array.isArray(e)&&e.length>0,"isFullArray"),q=p((e,r)=>O(r)?o(e,r):{},"pick");module.exports=q;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/object",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Helper functions for working with objects and arrays.",
5
5
  "keywords": [
6
6
  "visulima",
@@ -64,6 +64,13 @@
64
64
  "module": "dist/index.mjs",
65
65
  "browser": "./dist/index.mjs",
66
66
  "types": "dist/index.d.ts",
67
+ "typesVersions": {
68
+ "*": {
69
+ "*": [
70
+ "./dist/index.d.ts"
71
+ ]
72
+ }
73
+ },
67
74
  "files": [
68
75
  "dist",
69
76
  "README.md",
@@ -74,19 +81,20 @@
74
81
  "@anolilab/prettier-config": "^5.0.14",
75
82
  "@anolilab/semantic-release-pnpm": "1.1.3",
76
83
  "@anolilab/semantic-release-preset": "^9.0.0",
84
+ "@arethetypeswrong/cli": "^0.15.4",
77
85
  "@babel/core": "^7.25.2",
78
86
  "@rushstack/eslint-plugin-security": "^0.8.2",
79
87
  "@secretlint/secretlint-rule-preset-recommend": "^8.2.4",
80
- "@total-typescript/ts-reset": "^0.5.1",
88
+ "@total-typescript/ts-reset": "^0.6.1",
81
89
  "@types/node": "18.19.39",
82
- "@visulima/packem": "^1.0.0-alpha.60",
90
+ "@visulima/packem": "^1.0.0-alpha.95",
83
91
  "@vitest/coverage-v8": "^2.0.5",
84
92
  "@vitest/ui": "^2.0.5",
85
93
  "conventional-changelog-conventionalcommits": "8.0.0",
86
94
  "cross-env": "^7.0.3",
87
95
  "deeks": "^3.1.1",
88
96
  "dot-prop": "^9.0.0",
89
- "esbuild": "^0.23.0",
97
+ "esbuild": "^0.23.1",
90
98
  "eslint": "8.57.0",
91
99
  "eslint-plugin-deprecation": "^3.0.0",
92
100
  "eslint-plugin-etc": "^2.0.3",
@@ -99,8 +107,8 @@
99
107
  "prettier": "^3.3.3",
100
108
  "rimraf": "5.0.9",
101
109
  "secretlint": "8.2.4",
102
- "semantic-release": "^24.0.0",
103
- "type-fest": "^4.23.0",
110
+ "semantic-release": "^24.1.0",
111
+ "type-fest": "^4.26.0",
104
112
  "typescript": "5.5.4",
105
113
  "vitest": "^2.0.5"
106
114
  },
@@ -129,6 +137,7 @@
129
137
  "build:prod": "cross-env NODE_ENV=production packem build",
130
138
  "clean": "rimraf node_modules dist .eslintcache",
131
139
  "dev": "pnpm run build --watch",
140
+ "lint:attw": "attw --pack",
132
141
  "lint:eslint": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs",
133
142
  "lint:eslint:fix": "eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix",
134
143
  "lint:package-json": "publint --strict",