grofc_utils 1.2.1 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grofc_utils",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/object.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import { throwIfIsNotPlainObject, throwIfKeyMissing } from "./guard";
2
-
3
- export function makeReadOnlyProperty(obj, name) {
2
+ /**
3
+ * 将对象的指定属性设置为只读
4
+ * @param {Object} obj - 需要修改的对象
5
+ * @param {string} name - 需要设为只读的属性名
6
+ * @throws {TypeError} 当obj不是普通对象或name不是字符串时会抛出类型错误
7
+ * @throws {Error} 当对象中找不到指定属性时会抛出错误
8
+ */
9
+ export function makePropertyReadOnly(obj, name) {
4
10
  throwIfIsNotPlainObject(obj);
5
11
  throwIfKeyMissing(obj, name, "obj");
6
12
  const descriptor = Object.getOwnPropertyDescriptor(obj, name);
@@ -1 +1,8 @@
1
- export function makeReadOnlyProperty(obj: any, name: any): void;
1
+ /**
2
+ * 将对象的指定属性设置为只读
3
+ * @param {Object} obj - 需要修改的对象
4
+ * @param {string} name - 需要设为只读的属性名
5
+ * @throws {TypeError} 当obj不是普通对象或name不是字符串时会抛出类型错误
6
+ * @throws {Error} 当对象中找不到指定属性时会抛出错误
7
+ */
8
+ export function makePropertyReadOnly(obj: Object, name: string): void;