@visulima/object 1.0.12 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/LICENSE.md +2 -131
- package/dist/index.d.ts +216 -7
- package/dist/index.js +1 -0
- package/dist/packem_shared/getProperty-DPNB_aKG.js +1 -0
- package/dist/packem_shared/isPlainObject-CLTs8VdF.js +1 -0
- package/dist/packem_shared/omit-BfV-sPAM.js +1 -0
- package/dist/packem_shared/paths-are-equal-BYur8Hqc.js +1 -0
- package/dist/packem_shared/pick-CT4qE7de.js +1 -0
- package/package.json +7 -21
- package/dist/index.cjs +0 -187
- package/dist/index.d.cts +0 -7
- package/dist/index.d.mts +0 -7
- package/dist/index.mjs +0 -176
- package/dist/omit.d.cts +0 -20
- package/dist/omit.d.mts +0 -20
- package/dist/omit.d.ts +0 -20
- package/dist/packem_shared/getProperty-W4y1P_8H.cjs +0 -278
- package/dist/packem_shared/getProperty-uiEqCe4m.mjs +0 -269
- package/dist/packem_shared/isPlainObject-BEp1xndO.mjs +0 -12
- package/dist/packem_shared/isPlainObject-D2hOGcuW.cjs +0 -14
- package/dist/packem_shared/omit-Bz46-jv-.mjs +0 -38
- package/dist/packem_shared/omit-DSwyUtN2.cjs +0 -40
- package/dist/packem_shared/paths-are-equal-BvHTDEDJ.cjs +0 -15
- package/dist/packem_shared/paths-are-equal-DY1QWTwZ.mjs +0 -13
- package/dist/packem_shared/pick-BX11mP2m.cjs +0 -52
- package/dist/packem_shared/pick-C9-E3eDJ.mjs +0 -50
- package/dist/pick.d.cts +0 -20
- package/dist/pick.d.mts +0 -20
- package/dist/pick.d.ts +0 -20
- package/dist/utils/paths-are-equal.d.cts +0 -9
- package/dist/utils/paths-are-equal.d.mts +0 -9
- package/dist/utils/paths-are-equal.d.ts +0 -9
- package/dist/utils/recursive-omit.d.cts +0 -3
- package/dist/utils/recursive-omit.d.mts +0 -3
- package/dist/utils/recursive-omit.d.ts +0 -3
- package/dist/utils/recursive-pick.d.cts +0 -3
- package/dist/utils/recursive-pick.d.mts +0 -3
- package/dist/utils/recursive-pick.d.ts +0 -3
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const isPlainObject = require('./isPlainObject-D2hOGcuW.cjs');
|
|
4
|
-
const pathsAreEqual = require('./paths-are-equal-BvHTDEDJ.cjs');
|
|
5
|
-
|
|
6
|
-
var __defProp$1 = Object.defineProperty;
|
|
7
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
8
|
-
const recursivePick = /* @__PURE__ */ __name$1((object, pickedKeys, pathUntilNow = "") => {
|
|
9
|
-
if (!isPlainObject(object)) {
|
|
10
|
-
return object;
|
|
11
|
-
}
|
|
12
|
-
return Object.entries(object).reduce((carry, [key, value]) => {
|
|
13
|
-
let path = pathUntilNow;
|
|
14
|
-
if (path) {
|
|
15
|
-
path += ".";
|
|
16
|
-
}
|
|
17
|
-
path += key;
|
|
18
|
-
if (pickedKeys.length > 0) {
|
|
19
|
-
let passed = false;
|
|
20
|
-
pickedKeys.forEach((pickedKey) => {
|
|
21
|
-
const pathDepth = path.split(".").length;
|
|
22
|
-
const pickedKeyDepth = pickedKey.split(".").length;
|
|
23
|
-
const pickedKeyUpToNow = pickedKey.split(".").slice(0, pathDepth).join(".");
|
|
24
|
-
const pathUpToPickedKeyDepth = path.split(".").slice(0, pickedKeyDepth).join(".");
|
|
25
|
-
if (pathsAreEqual.pathsAreEqual(pathUpToPickedKeyDepth, pickedKeyUpToNow)) {
|
|
26
|
-
passed = true;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
if (!passed) {
|
|
30
|
-
return carry;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (!isPlainObject(value)) {
|
|
34
|
-
carry[key] = value;
|
|
35
|
-
return carry;
|
|
36
|
-
}
|
|
37
|
-
carry[key] = recursivePick(object[key], pickedKeys, path);
|
|
38
|
-
return carry;
|
|
39
|
-
}, {});
|
|
40
|
-
}, "recursivePick");
|
|
41
|
-
|
|
42
|
-
var __defProp = Object.defineProperty;
|
|
43
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
44
|
-
const isFullArray = /* @__PURE__ */ __name((input) => Array.isArray(input) && input.length > 0, "isFullArray");
|
|
45
|
-
const pick = /* @__PURE__ */ __name((object, keys) => {
|
|
46
|
-
if (!isFullArray(keys)) {
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
return recursivePick(object, keys);
|
|
50
|
-
}, "pick");
|
|
51
|
-
|
|
52
|
-
module.exports = pick;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import isPlainObject from './isPlainObject-BEp1xndO.mjs';
|
|
2
|
-
import { p as pathsAreEqual } from './paths-are-equal-DY1QWTwZ.mjs';
|
|
3
|
-
|
|
4
|
-
var __defProp$1 = Object.defineProperty;
|
|
5
|
-
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
6
|
-
const recursivePick = /* @__PURE__ */ __name$1((object, pickedKeys, pathUntilNow = "") => {
|
|
7
|
-
if (!isPlainObject(object)) {
|
|
8
|
-
return object;
|
|
9
|
-
}
|
|
10
|
-
return Object.entries(object).reduce((carry, [key, value]) => {
|
|
11
|
-
let path = pathUntilNow;
|
|
12
|
-
if (path) {
|
|
13
|
-
path += ".";
|
|
14
|
-
}
|
|
15
|
-
path += key;
|
|
16
|
-
if (pickedKeys.length > 0) {
|
|
17
|
-
let passed = false;
|
|
18
|
-
pickedKeys.forEach((pickedKey) => {
|
|
19
|
-
const pathDepth = path.split(".").length;
|
|
20
|
-
const pickedKeyDepth = pickedKey.split(".").length;
|
|
21
|
-
const pickedKeyUpToNow = pickedKey.split(".").slice(0, pathDepth).join(".");
|
|
22
|
-
const pathUpToPickedKeyDepth = path.split(".").slice(0, pickedKeyDepth).join(".");
|
|
23
|
-
if (pathsAreEqual(pathUpToPickedKeyDepth, pickedKeyUpToNow)) {
|
|
24
|
-
passed = true;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
if (!passed) {
|
|
28
|
-
return carry;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (!isPlainObject(value)) {
|
|
32
|
-
carry[key] = value;
|
|
33
|
-
return carry;
|
|
34
|
-
}
|
|
35
|
-
carry[key] = recursivePick(object[key], pickedKeys, path);
|
|
36
|
-
return carry;
|
|
37
|
-
}, {});
|
|
38
|
-
}, "recursivePick");
|
|
39
|
-
|
|
40
|
-
var __defProp = Object.defineProperty;
|
|
41
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
42
|
-
const isFullArray = /* @__PURE__ */ __name((input) => Array.isArray(input) && input.length > 0, "isFullArray");
|
|
43
|
-
const pick = /* @__PURE__ */ __name((object, keys) => {
|
|
44
|
-
if (!isFullArray(keys)) {
|
|
45
|
-
return {};
|
|
46
|
-
}
|
|
47
|
-
return recursivePick(object, keys);
|
|
48
|
-
}, "pick");
|
|
49
|
-
|
|
50
|
-
export { pick as default };
|
package/dist/pick.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 ".//index.d.d.cts";
|
|
9
|
-
/**
|
|
10
|
-
* pick returns a new object with only the props you pick
|
|
11
|
-
*
|
|
12
|
-
* @export
|
|
13
|
-
* @template T
|
|
14
|
-
* @template K
|
|
15
|
-
* @param {T} object the target object to pick props from
|
|
16
|
-
* @param {K[]} 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 } }`
|
|
17
|
-
* @returns {PickDeep<T, K>} a new object with just the picked props
|
|
18
|
-
*/
|
|
19
|
-
declare const pick: <T extends { [key in string]: unknown; }, K extends Paths<T>>(object: T, keys: Paths<T>[]) => PickDeep<T, K>;
|
|
20
|
-
export = pick;
|
package/dist/pick.d.mts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 ".//index.d.d.mts";
|
|
9
|
-
/**
|
|
10
|
-
* pick returns a new object with only the props you pick
|
|
11
|
-
*
|
|
12
|
-
* @export
|
|
13
|
-
* @template T
|
|
14
|
-
* @template K
|
|
15
|
-
* @param {T} object the target object to pick props from
|
|
16
|
-
* @param {K[]} 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 } }`
|
|
17
|
-
* @returns {PickDeep<T, K>} a new object with just the picked props
|
|
18
|
-
*/
|
|
19
|
-
declare const pick: <T extends { [key in string]: unknown; }, K extends Paths<T>>(object: T, keys: Paths<T>[]) => PickDeep<T, K>;
|
|
20
|
-
export default pick;
|
package/dist/pick.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 ".//index.d.d.ts";
|
|
9
|
-
/**
|
|
10
|
-
* pick returns a new object with only the props you pick
|
|
11
|
-
*
|
|
12
|
-
* @export
|
|
13
|
-
* @template T
|
|
14
|
-
* @template K
|
|
15
|
-
* @param {T} object the target object to pick props from
|
|
16
|
-
* @param {K[]} 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 } }`
|
|
17
|
-
* @returns {PickDeep<T, K>} a new object with just the picked props
|
|
18
|
-
*/
|
|
19
|
-
declare const pick: <T extends { [key in string]: unknown; }, K extends Paths<T>>(object: T, keys: Paths<T>[]) => PickDeep<T, K>;
|
|
20
|
-
export = pick;
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
declare const pathsAreEqual: (path: string, wildcardPath: string) => boolean;
|
|
9
|
-
export = pathsAreEqual;
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
declare const pathsAreEqual: (path: string, wildcardPath: string) => boolean;
|
|
9
|
-
export default pathsAreEqual;
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
declare const pathsAreEqual: (path: string, wildcardPath: string) => boolean;
|
|
9
|
-
export = pathsAreEqual;
|