@bemoje/object 0.2.5 → 0.2.7
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/package.json +2 -3
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
- package/src/index.js.map +1 -1
- package/src/lib/objClonePrimitiveProperties.d.ts +7 -0
- package/src/lib/objClonePrimitiveProperties.js +19 -0
- package/src/lib/objClonePrimitiveProperties.js.map +1 -0
- package/src/types/TPrimitive.d.ts +1 -0
- package/src/types/TPrimitive.js +3 -0
- package/src/types/TPrimitive.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/object",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Object related tools/util.",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"scripts": {},
|
|
@@ -29,6 +29,5 @@
|
|
|
29
29
|
"homepage": "https://github.com/bemoje/tsmono",
|
|
30
30
|
"type": "commonjs",
|
|
31
31
|
"typings": "./src/index.d.ts",
|
|
32
|
-
"devDependencies": {}
|
|
33
|
-
"types": "./src/index.d.ts"
|
|
32
|
+
"devDependencies": {}
|
|
34
33
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './lib/getConstructor';
|
|
|
3
3
|
export * from './lib/inheritStaticMembers';
|
|
4
4
|
export * from './lib/iterableFirstElement';
|
|
5
5
|
export * from './lib/iteratePrototypeChain';
|
|
6
|
+
export * from './lib/objClonePrimitiveProperties';
|
|
6
7
|
export * from './lib/objDeepFreeze';
|
|
7
8
|
export * from './lib/objDelete';
|
|
8
9
|
export * from './lib/objEntries';
|
|
@@ -41,3 +42,4 @@ export * from './lib/toJson';
|
|
|
41
42
|
export * from './types/Constructor';
|
|
42
43
|
export * from './types/ConstructorOf';
|
|
43
44
|
export * from './types/ObjectKey';
|
|
45
|
+
export * from './types/TPrimitive';
|
package/src/index.js
CHANGED
|
@@ -6,6 +6,7 @@ tslib_1.__exportStar(require("./lib/getConstructor"), exports);
|
|
|
6
6
|
tslib_1.__exportStar(require("./lib/inheritStaticMembers"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./lib/iterableFirstElement"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./lib/iteratePrototypeChain"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./lib/objClonePrimitiveProperties"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./lib/objDeepFreeze"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./lib/objDelete"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./lib/objEntries"), exports);
|
|
@@ -44,4 +45,5 @@ tslib_1.__exportStar(require("./lib/toJson"), exports);
|
|
|
44
45
|
tslib_1.__exportStar(require("./types/Constructor"), exports);
|
|
45
46
|
tslib_1.__exportStar(require("./types/ConstructorOf"), exports);
|
|
46
47
|
tslib_1.__exportStar(require("./types/ObjectKey"), exports);
|
|
48
|
+
tslib_1.__exportStar(require("./types/TPrimitive"), exports);
|
|
47
49
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/object/src/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyC;AACzC,+DAAoC;AACpC,qEAA0C;AAC1C,qEAA0C;AAC1C,sEAA2C;AAC3C,8DAAmC;AACnC,0DAA+B;AAC/B,2DAAgC;AAChC,gEAAqC;AACrC,0DAA+B;AAC/B,2DAAgC;AAChC,uDAA4B;AAC5B,6DAAkC;AAClC,uDAA4B;AAC5B,2DAAgC;AAChC,wDAA6B;AAC7B,6DAAkC;AAClC,uDAA4B;AAC5B,2DAAgC;AAChC,8DAAmC;AACnC,4DAAiC;AACjC,mEAAwC;AACxC,yEAA8C;AAC9C,0DAA+B;AAC/B,2DAAgC;AAChC,uDAA4B;AAC5B,wDAA6B;AAC7B,4DAAiC;AACjC,yDAA8B;AAC9B,0DAA+B;AAC/B,6EAAkD;AAClD,0DAA+B;AAC/B,+DAAoC;AACpC,wDAA6B;AAC7B,8DAAmC;AACnC,mEAAwC;AACxC,iEAAsC;AACtC,+DAAoC;AACpC,4DAAiC;AACjC,uDAA4B;AAC5B,8DAAmC;AACnC,gEAAqC;AACrC,4DAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/object/src/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyC;AACzC,+DAAoC;AACpC,qEAA0C;AAC1C,qEAA0C;AAC1C,sEAA2C;AAC3C,4EAAiD;AACjD,8DAAmC;AACnC,0DAA+B;AAC/B,2DAAgC;AAChC,gEAAqC;AACrC,0DAA+B;AAC/B,2DAAgC;AAChC,uDAA4B;AAC5B,6DAAkC;AAClC,uDAA4B;AAC5B,2DAAgC;AAChC,wDAA6B;AAC7B,6DAAkC;AAClC,uDAA4B;AAC5B,2DAAgC;AAChC,8DAAmC;AACnC,4DAAiC;AACjC,mEAAwC;AACxC,yEAA8C;AAC9C,0DAA+B;AAC/B,2DAAgC;AAChC,uDAA4B;AAC5B,wDAA6B;AAC7B,4DAAiC;AACjC,yDAA8B;AAC9B,0DAA+B;AAC/B,6EAAkD;AAClD,0DAA+B;AAC/B,+DAAoC;AACpC,wDAA6B;AAC7B,8DAAmC;AACnC,mEAAwC;AACxC,iEAAsC;AACtC,+DAAoC;AACpC,4DAAiC;AACjC,uDAA4B;AAC5B,8DAAmC;AACnC,gEAAqC;AACrC,4DAAiC;AACjC,6DAAkC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ObjectKey } from '../types/ObjectKey';
|
|
2
|
+
import { TPrimitive } from '../types/TPrimitive';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a shallow clone of an object, but replaces all non-primitive values with a string representation of the value's type.
|
|
5
|
+
* @param o - The object to clone.
|
|
6
|
+
*/
|
|
7
|
+
export declare function objClonePrimitiveProperties(o: Record<ObjectKey, unknown>): Record<ObjectKey, TPrimitive>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objClonePrimitiveProperties = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a shallow clone of an object, but replaces all non-primitive values with a string representation of the value's type.
|
|
6
|
+
* @param o - The object to clone.
|
|
7
|
+
*/
|
|
8
|
+
function objClonePrimitiveProperties(o) {
|
|
9
|
+
const clone = {};
|
|
10
|
+
for (const [key, value] of Object.entries(o)) {
|
|
11
|
+
clone[key] = isPrimitive(value) ? value : `[${Object.getPrototypeOf(value).constructor.name}]`;
|
|
12
|
+
}
|
|
13
|
+
return clone;
|
|
14
|
+
}
|
|
15
|
+
exports.objClonePrimitiveProperties = objClonePrimitiveProperties;
|
|
16
|
+
function isPrimitive(value) {
|
|
17
|
+
return (typeof value !== 'object' && typeof value !== 'function') || value === null;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=objClonePrimitiveProperties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objClonePrimitiveProperties.js","sourceRoot":"","sources":["../../../../../packages/object/src/lib/objClonePrimitiveProperties.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,CAA6B;IACvE,MAAM,KAAK,GAAkC,EAAE,CAAA;IAC/C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC5C,KAAK,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,IAAI,GAAG,CAAA;KAC/F;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAND,kEAMC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,IAAI,KAAK,KAAK,IAAI,CAAA;AACrF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type TPrimitive = null | undefined | bigint | boolean | number | string | symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TPrimitive.js","sourceRoot":"","sources":["../../../../../packages/object/src/types/TPrimitive.ts"],"names":[],"mappings":""}
|