@bemoje/object 0.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/LICENSE +21 -0
- package/dist/index.cjs.js +6 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.esm.js +6 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/createObjectFactory.d.ts +14 -0
- package/dist/types/lib/createObjectFactory.d.ts.map +1 -0
- package/dist/types/lib/getConstructor.d.ts +14 -0
- package/dist/types/lib/getConstructor.d.ts.map +1 -0
- package/dist/types/lib/inheritStaticMembers.d.ts +26 -0
- package/dist/types/lib/inheritStaticMembers.d.ts.map +1 -0
- package/dist/types/lib/iterableFirstElement.d.ts +12 -0
- package/dist/types/lib/iterableFirstElement.d.ts.map +1 -0
- package/dist/types/lib/iteratePrototypeChain.d.ts +23 -0
- package/dist/types/lib/iteratePrototypeChain.d.ts.map +1 -0
- package/dist/types/lib/objDeepFreeze.d.ts +30 -0
- package/dist/types/lib/objDeepFreeze.d.ts.map +1 -0
- package/dist/types/lib/objDelete.d.ts +15 -0
- package/dist/types/lib/objDelete.d.ts.map +1 -0
- package/dist/types/lib/objEntries.d.ts +16 -0
- package/dist/types/lib/objEntries.d.ts.map +1 -0
- package/dist/types/lib/objEntriesArray.d.ts +16 -0
- package/dist/types/lib/objEntriesArray.d.ts.map +1 -0
- package/dist/types/lib/objFilter.d.ts +16 -0
- package/dist/types/lib/objFilter.d.ts.map +1 -0
- package/dist/types/lib/objForEach.d.ts +17 -0
- package/dist/types/lib/objForEach.d.ts.map +1 -0
- package/dist/types/lib/objGet.d.ts +19 -0
- package/dist/types/lib/objGet.d.ts.map +1 -0
- package/dist/types/lib/objGetOrElse.d.ts +16 -0
- package/dist/types/lib/objGetOrElse.d.ts.map +1 -0
- package/dist/types/lib/objHas.d.ts +17 -0
- package/dist/types/lib/objHas.d.ts.map +1 -0
- package/dist/types/lib/objIsEmpty.d.ts +18 -0
- package/dist/types/lib/objIsEmpty.d.ts.map +1 -0
- package/dist/types/lib/objKeys.d.ts +17 -0
- package/dist/types/lib/objKeys.d.ts.map +1 -0
- package/dist/types/lib/objKeysArray.d.ts +15 -0
- package/dist/types/lib/objKeysArray.d.ts.map +1 -0
- package/dist/types/lib/objMap.d.ts +16 -0
- package/dist/types/lib/objMap.d.ts.map +1 -0
- package/dist/types/lib/objMapKeys.d.ts +17 -0
- package/dist/types/lib/objMapKeys.d.ts.map +1 -0
- package/dist/types/lib/objMapMutable.d.ts +17 -0
- package/dist/types/lib/objMapMutable.d.ts.map +1 -0
- package/dist/types/lib/objOmitKeys.d.ts +15 -0
- package/dist/types/lib/objOmitKeys.d.ts.map +1 -0
- package/dist/types/lib/objOmitKeysMutable.d.ts +14 -0
- package/dist/types/lib/objOmitKeysMutable.d.ts.map +1 -0
- package/dist/types/lib/objPropertyValueToGetter.d.ts +23 -0
- package/dist/types/lib/objPropertyValueToGetter.d.ts.map +1 -0
- package/dist/types/lib/objReduce.d.ts +19 -0
- package/dist/types/lib/objReduce.d.ts.map +1 -0
- package/dist/types/lib/objReverse.d.ts +14 -0
- package/dist/types/lib/objReverse.d.ts.map +1 -0
- package/dist/types/lib/objSet.d.ts +16 -0
- package/dist/types/lib/objSet.d.ts.map +1 -0
- package/dist/types/lib/objSize.d.ts +14 -0
- package/dist/types/lib/objSize.d.ts.map +1 -0
- package/dist/types/lib/objSortKeys.d.ts +15 -0
- package/dist/types/lib/objSortKeys.d.ts.map +1 -0
- package/dist/types/lib/objToMap.d.ts +18 -0
- package/dist/types/lib/objToMap.d.ts.map +1 -0
- package/dist/types/lib/objUpdate.d.ts +15 -0
- package/dist/types/lib/objUpdate.d.ts.map +1 -0
- package/dist/types/lib/objUpdatePropertyDescriptors.d.ts +17 -0
- package/dist/types/lib/objUpdatePropertyDescriptors.d.ts.map +1 -0
- package/dist/types/lib/objValues.d.ts +21 -0
- package/dist/types/lib/objValues.d.ts.map +1 -0
- package/dist/types/lib/objValuesArray.d.ts +15 -0
- package/dist/types/lib/objValuesArray.d.ts.map +1 -0
- package/dist/types/lib/objWalk.d.ts +19 -0
- package/dist/types/lib/objWalk.d.ts.map +1 -0
- package/dist/types/lib/setEnumerable.d.ts +19 -0
- package/dist/types/lib/setEnumerable.d.ts.map +1 -0
- package/dist/types/lib/setNonConfigurable.d.ts +21 -0
- package/dist/types/lib/setNonConfigurable.d.ts.map +1 -0
- package/dist/types/lib/setNonEnumerable.d.ts +16 -0
- package/dist/types/lib/setNonEnumerable.d.ts.map +1 -0
- package/dist/types/lib/setNonWritable.d.ts +22 -0
- package/dist/types/lib/setNonWritable.d.ts.map +1 -0
- package/dist/types/lib/setWritable.d.ts +17 -0
- package/dist/types/lib/setWritable.d.ts.map +1 -0
- package/dist/types/lib/toJson.d.ts +13 -0
- package/dist/types/lib/toJson.d.ts.map +1 -0
- package/dist/types/types/Constructor.d.ts +8 -0
- package/dist/types/types/Constructor.d.ts.map +1 -0
- package/dist/types/types/ConstructorOf.d.ts +5 -0
- package/dist/types/types/ConstructorOf.d.ts.map +1 -0
- package/dist/types/types/ObjectKey.d.ts +2 -0
- package/dist/types/types/ObjectKey.d.ts.map +1 -0
- package/package.json +35 -0
- package/project.json +8 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ObjectKey } from '../types/ObjectKey';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the specified properties of an object to be non-writable.
|
|
4
|
+
* @template T - The type of the object.
|
|
5
|
+
* @param object The object whose properties are to be made non-writable.
|
|
6
|
+
* @param properties The names of the properties to be made non-writable.
|
|
7
|
+
* @throws Will throw an error if any of the specified properties do not exist on the object.
|
|
8
|
+
* @example ```ts
|
|
9
|
+
* const obj = { a: 1, b: 2, c: 3 };
|
|
10
|
+
* setNonWritable(obj, 'a', 'b');
|
|
11
|
+
* obj;;
|
|
12
|
+
* //=> { a: 1, b: 2, c: 3 }
|
|
13
|
+
* obj.a = 10;;
|
|
14
|
+
* //=> Throws an error
|
|
15
|
+
* obj.b = 20;;
|
|
16
|
+
* //=> Throws an error
|
|
17
|
+
* obj.c = 30;;
|
|
18
|
+
* //=> Works fine
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function setNonWritable(object: Record<ObjectKey, any>, ...properties: string[]): void;
|
|
22
|
+
//# sourceMappingURL=setNonWritable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setNonWritable.d.ts","sourceRoot":"","sources":["../../../src/lib/setNonWritable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAK5F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ObjectKey } from '../types/ObjectKey';
|
|
2
|
+
/**
|
|
3
|
+
* Sets the specified properties of an object to be writable.
|
|
4
|
+
* @template T - The type of the object.
|
|
5
|
+
* @param object The object whose properties are to be made writable.
|
|
6
|
+
* @param propertyNames The names of the properties to be made writable.
|
|
7
|
+
* @throws Will throw an error if any of the specified properties do not exist on the object.
|
|
8
|
+
* @example ```ts
|
|
9
|
+
* setWritable({ a: 1, b: 2 }, 'a', 'b').a = 3;;
|
|
10
|
+
* //=> 3
|
|
11
|
+
* setWritable({ a: 1, b: 2 }, 'a', 'b').b = 4;;
|
|
12
|
+
* //=> 4
|
|
13
|
+
* ```
|
|
14
|
+
* @returns void
|
|
15
|
+
*/
|
|
16
|
+
export declare function setWritable(object: Record<ObjectKey, any>, ...properties: string[]): void;
|
|
17
|
+
//# sourceMappingURL=setWritable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setWritable.d.ts","sourceRoot":"","sources":["../../../src/lib/setWritable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,UAAU,EAAE,MAAM,EAAE,GAAG,IAAI,CAKzF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts the given data to a JSON string.
|
|
3
|
+
* @template T - The type of the data to be converted to JSON.
|
|
4
|
+
* @param data The data to be converted to JSON.
|
|
5
|
+
* @param pretty Optional parameter that determines whether the resulting JSON string should be pretty-printed. Default is `false`.
|
|
6
|
+
* @returns The JSON string representation of the given data.
|
|
7
|
+
* @example ```ts
|
|
8
|
+
* toJson({ name: 'John', age: 30 }, true);;
|
|
9
|
+
* //=> "{\n "name": "John",\n "age": 30\n}"
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function toJson<T>(data: T, pretty?: boolean): string;
|
|
13
|
+
//# sourceMappingURL=toJson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toJson.d.ts","sourceRoot":"","sources":["../../../src/lib/toJson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,UAAQ,GAAG,MAAM,CAEzD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This type represents a constructor function. It is a function that can be called with the `new` keyword to create an instance of a certain type.
|
|
3
|
+
* @template T - The type of the object that the constructor will create. Defaults to a record with string keys and any type values.
|
|
4
|
+
* @param {...any[]} args - The arguments to pass to the constructor function.
|
|
5
|
+
* @returns {T} - The created object.
|
|
6
|
+
*/
|
|
7
|
+
export type Constructor<T = Record<string, any>> = new (...args: any[]) => T;
|
|
8
|
+
//# sourceMappingURL=Constructor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Constructor.d.ts","sourceRoot":"","sources":["../../../src/types/Constructor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConstructorOf.d.ts","sourceRoot":"","sources":["../../../src/types/ConstructorOf.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObjectKey.d.ts","sourceRoot":"","sources":["../../../src/types/ObjectKey.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bemoje/object",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Object related tools/util.",
|
|
5
|
+
"main": "dist/index.cjs.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/types/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"lint": "eslint \"*/**/*.{ts,js,json}\" --fix",
|
|
10
|
+
"test": "jest --preset ts-jest",
|
|
11
|
+
"build": "rimraf dist && rollup --config ./rollup.config.js --bundleConfigAsCjs",
|
|
12
|
+
"docs": "rimraf ../../docs/object && typedoc --out ../../docs/object --entryPoints src/index.ts",
|
|
13
|
+
"prepub": "npm run lint && npm run build && npm run test && npm run docs"
|
|
14
|
+
},
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Benjamin Møller Jensen",
|
|
17
|
+
"email": "bemoje@bemoje.net",
|
|
18
|
+
"url": "https://github.com/bemoje/"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"keywords": [],
|
|
22
|
+
"dependencies": {},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/bemoje/tsmono.git"
|
|
26
|
+
},
|
|
27
|
+
"funding": {
|
|
28
|
+
"type": "patreon",
|
|
29
|
+
"url": "https://www.patreon.com/user?u=40752770"
|
|
30
|
+
},
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/bemoje/tsmono/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/bemoje/tsmono"
|
|
35
|
+
}
|