@visulima/object 1.0.9 → 1.0.11
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 +26 -0
- package/README.md +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.d.cts +7 -2464
- package/dist/index.d.mts +7 -2464
- package/dist/index.d.ts +7 -2464
- package/dist/index.mjs +9 -9
- package/dist/omit.d.cts +20 -0
- package/dist/omit.d.mts +20 -0
- package/dist/omit.d.ts +20 -0
- package/dist/packem_shared/{getProperty-BuSUBWTY.cjs → getProperty-W4y1P_8H.cjs} +4 -4
- package/dist/packem_shared/{getProperty-CqSBQFGO.mjs → getProperty-uiEqCe4m.mjs} +4 -4
- package/dist/pick.d.cts +20 -0
- package/dist/pick.d.mts +20 -0
- package/dist/pick.d.ts +20 -0
- package/dist/utils/paths-are-equal.d.cts +9 -0
- package/dist/utils/paths-are-equal.d.mts +9 -0
- package/dist/utils/paths-are-equal.d.ts +9 -0
- package/dist/utils/recursive-omit.d.cts +3 -0
- package/dist/utils/recursive-omit.d.mts +3 -0
- package/dist/utils/recursive-omit.d.ts +3 -0
- package/dist/utils/recursive-pick.d.cts +3 -0
- package/dist/utils/recursive-pick.d.mts +3 -0
- package/dist/utils/recursive-pick.d.ts +3 -0
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { default as omit } from './packem_shared/omit-Bz46-jv-.mjs';
|
|
2
2
|
export { default as pick } from './packem_shared/pick-C9-E3eDJ.mjs';
|
|
3
|
-
export { deleteProperty, escapePath, getProperty, hasProperty, setProperty } from './packem_shared/getProperty-
|
|
3
|
+
export { deleteProperty, escapePath, getProperty, hasProperty, setProperty } from './packem_shared/getProperty-uiEqCe4m.mjs';
|
|
4
4
|
export { default as isPlainObject } from './packem_shared/isPlainObject-BEp1xndO.mjs';
|
|
5
5
|
|
|
6
6
|
var deeks = {};
|
|
@@ -15,7 +15,7 @@ function requireUtils () {
|
|
|
15
15
|
var __defProp = Object.defineProperty;
|
|
16
16
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
17
|
Object.defineProperty(utils, "__esModule", { value: true });
|
|
18
|
-
utils.isDocumentToRecurOn = utils.flatten = utils.unique =
|
|
18
|
+
utils.isDocumentToRecurOn = utils.flatten = utils.unique = void 0;
|
|
19
19
|
function unique(array) {
|
|
20
20
|
return [...new Set(array)];
|
|
21
21
|
}
|
|
@@ -53,8 +53,8 @@ function requireDeeks () {
|
|
|
53
53
|
(function (exports) {
|
|
54
54
|
var __defProp = Object.defineProperty;
|
|
55
55
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
56
|
-
var __createBinding = deeks.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
57
|
-
if (k2 ===
|
|
56
|
+
var __createBinding = deeks && deeks.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
57
|
+
if (k2 === void 0) k2 = k;
|
|
58
58
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
59
59
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
60
60
|
desc = { enumerable: true, get: /* @__PURE__ */ __name(function() {
|
|
@@ -63,15 +63,15 @@ function requireDeeks () {
|
|
|
63
63
|
}
|
|
64
64
|
Object.defineProperty(o, k2, desc);
|
|
65
65
|
} : function(o, m, k, k2) {
|
|
66
|
-
if (k2 ===
|
|
66
|
+
if (k2 === void 0) k2 = k;
|
|
67
67
|
o[k2] = m[k];
|
|
68
68
|
});
|
|
69
|
-
var __setModuleDefault = deeks.__setModuleDefault || (Object.create ? function(o, v) {
|
|
69
|
+
var __setModuleDefault = deeks && deeks.__setModuleDefault || (Object.create ? function(o, v) {
|
|
70
70
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
71
71
|
} : function(o, v) {
|
|
72
72
|
o["default"] = v;
|
|
73
73
|
});
|
|
74
|
-
var __importStar = deeks.__importStar || function(mod) {
|
|
74
|
+
var __importStar = deeks && deeks.__importStar || function(mod) {
|
|
75
75
|
if (mod && mod.__esModule) return mod;
|
|
76
76
|
var result = {};
|
|
77
77
|
if (mod != null) {
|
|
@@ -80,11 +80,11 @@ function requireDeeks () {
|
|
|
80
80
|
__setModuleDefault(result, mod);
|
|
81
81
|
return result;
|
|
82
82
|
};
|
|
83
|
-
var __exportStar = deeks.__exportStar || function(m, exports2) {
|
|
83
|
+
var __exportStar = deeks && deeks.__exportStar || function(m, exports2) {
|
|
84
84
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
85
85
|
};
|
|
86
86
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
87
|
-
exports.deepKeysFromList = exports.deepKeys =
|
|
87
|
+
exports.deepKeysFromList = exports.deepKeys = void 0;
|
|
88
88
|
const utils = __importStar(requireUtils());
|
|
89
89
|
__exportStar(requireTypes(), exports);
|
|
90
90
|
function deepKeys(object, options) {
|
package/dist/omit.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @template T
|
|
14
|
+
* @template K
|
|
15
|
+
* @param {T} object the target object to omit props from
|
|
16
|
+
* @param {K[]} keys the prop names you want to omit
|
|
17
|
+
* @returns {OmitDeep<T, K>} a new object without the omitted props
|
|
18
|
+
*/
|
|
19
|
+
declare const omit: <T extends { [key in string]: unknown; }, K extends string>(object: T, keys: Paths<T>[]) => OmitDeep<T, K>;
|
|
20
|
+
export = omit;
|
package/dist/omit.d.mts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @template T
|
|
14
|
+
* @template K
|
|
15
|
+
* @param {T} object the target object to omit props from
|
|
16
|
+
* @param {K[]} keys the prop names you want to omit
|
|
17
|
+
* @returns {OmitDeep<T, K>} a new object without the omitted props
|
|
18
|
+
*/
|
|
19
|
+
declare const omit: <T extends { [key in string]: unknown; }, K extends string>(object: T, keys: Paths<T>[]) => OmitDeep<T, K>;
|
|
20
|
+
export default omit;
|
package/dist/omit.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*
|
|
12
|
+
* @export
|
|
13
|
+
* @template T
|
|
14
|
+
* @template K
|
|
15
|
+
* @param {T} object the target object to omit props from
|
|
16
|
+
* @param {K[]} keys the prop names you want to omit
|
|
17
|
+
* @returns {OmitDeep<T, K>} a new object without the omitted props
|
|
18
|
+
*/
|
|
19
|
+
declare const omit: <T extends { [key in string]: unknown; }, K extends string>(object: T, keys: Paths<T>[]) => OmitDeep<T, K>;
|
|
20
|
+
export = omit;
|
|
@@ -147,7 +147,7 @@ function assertNotStringIndex(object, key) {
|
|
|
147
147
|
__name(assertNotStringIndex, "assertNotStringIndex");
|
|
148
148
|
function getProperty(object, path, value) {
|
|
149
149
|
if (!isObject(object) || typeof path !== "string") {
|
|
150
|
-
return value ===
|
|
150
|
+
return value === void 0 ? object : value;
|
|
151
151
|
}
|
|
152
152
|
const pathArray = getPathSegments(path);
|
|
153
153
|
if (pathArray.length === 0) {
|
|
@@ -156,18 +156,18 @@ function getProperty(object, path, value) {
|
|
|
156
156
|
for (let index = 0; index < pathArray.length; index++) {
|
|
157
157
|
const key = pathArray[index];
|
|
158
158
|
if (isStringIndex(object, key)) {
|
|
159
|
-
object = index === pathArray.length - 1 ?
|
|
159
|
+
object = index === pathArray.length - 1 ? void 0 : null;
|
|
160
160
|
} else {
|
|
161
161
|
object = object[key];
|
|
162
162
|
}
|
|
163
|
-
if (object ===
|
|
163
|
+
if (object === void 0 || object === null) {
|
|
164
164
|
if (index !== pathArray.length - 1) {
|
|
165
165
|
return value;
|
|
166
166
|
}
|
|
167
167
|
break;
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
return object ===
|
|
170
|
+
return object === void 0 ? value : object;
|
|
171
171
|
}
|
|
172
172
|
__name(getProperty, "getProperty");
|
|
173
173
|
function setProperty(object, path, value) {
|
|
@@ -143,7 +143,7 @@ function assertNotStringIndex(object, key) {
|
|
|
143
143
|
__name(assertNotStringIndex, "assertNotStringIndex");
|
|
144
144
|
function getProperty(object, path, value) {
|
|
145
145
|
if (!isObject(object) || typeof path !== "string") {
|
|
146
|
-
return value ===
|
|
146
|
+
return value === void 0 ? object : value;
|
|
147
147
|
}
|
|
148
148
|
const pathArray = getPathSegments(path);
|
|
149
149
|
if (pathArray.length === 0) {
|
|
@@ -152,18 +152,18 @@ function getProperty(object, path, value) {
|
|
|
152
152
|
for (let index = 0; index < pathArray.length; index++) {
|
|
153
153
|
const key = pathArray[index];
|
|
154
154
|
if (isStringIndex(object, key)) {
|
|
155
|
-
object = index === pathArray.length - 1 ?
|
|
155
|
+
object = index === pathArray.length - 1 ? void 0 : null;
|
|
156
156
|
} else {
|
|
157
157
|
object = object[key];
|
|
158
158
|
}
|
|
159
|
-
if (object ===
|
|
159
|
+
if (object === void 0 || object === null) {
|
|
160
160
|
if (index !== pathArray.length - 1) {
|
|
161
161
|
return value;
|
|
162
162
|
}
|
|
163
163
|
break;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
return object ===
|
|
166
|
+
return object === void 0 ? value : object;
|
|
167
167
|
}
|
|
168
168
|
__name(getProperty, "getProperty");
|
|
169
169
|
function setProperty(object, path, value) {
|
package/dist/pick.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*
|
|
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
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*
|
|
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
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
*
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/object",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "Helper functions for working with objects and arrays.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visulima",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"main": "dist/index.cjs",
|
|
64
64
|
"module": "dist/index.mjs",
|
|
65
|
-
"browser": "
|
|
65
|
+
"browser": "dist/index.mjs",
|
|
66
66
|
"types": "dist/index.d.ts",
|
|
67
67
|
"typesVersions": {
|
|
68
68
|
">=5.0": {
|