xjs-common 13.0.2 → 13.0.3

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.
@@ -41,7 +41,7 @@ var DType;
41
41
  DType.required = required;
42
42
  /**
43
43
  * express array.
44
- * @param elmDesc {@link TypeDesc} or class constructor type.
44
+ * @param elmDesc {@link TypeDesc} or {@link Ctor|class constructor type}.
45
45
  */
46
46
  function array(elmDesc = {}) {
47
47
  return (target, propKey) => setDesc(target, propKey, (td) => u_type_1.UType.isFunction(elmDesc) ? td.ary = { cls: elmDesc } : td.ary = elmDesc);
@@ -49,7 +49,7 @@ var DType;
49
49
  DType.array = array;
50
50
  /**
51
51
  * express record object. note that this may allow array type because array is essentialy object type has properties.
52
- * @param elmDesc {@link TypeDesc} or class constructor type.
52
+ * @param elmDesc {@link TypeDesc} or {@link Ctor|class constructor type}.
53
53
  */
54
54
  function record(elmDesc = {}) {
55
55
  return (target, propKey) => setDesc(target, propKey, (td) => u_type_1.UType.isFunction(elmDesc) ? td.rcd = { cls: elmDesc } : td.rcd = elmDesc);
@@ -57,7 +57,7 @@ var DType;
57
57
  DType.record = record;
58
58
  /**
59
59
  * express an object which has properties that specified class express with {@link DType}.
60
- * @param ctor class constructor type.
60
+ * @param ctor {@link Ctor|class constructor type}.
61
61
  */
62
62
  function object(ctor) {
63
63
  return (target, propKey) => setDesc(target, propKey, (td) => td.cls = ctor);
@@ -5,7 +5,7 @@ const xjs_err_1 = require("../../obj/xjs-err");
5
5
  const u_1 = require("../u");
6
6
  const s_errCode = 100;
7
7
  /**
8
- * applies transation to the method. note that the method must return a Promise.
8
+ * applies transation to the method. **note that the method must return a `Promise`**.
9
9
  * @param op.timeoutSec default is `30`.
10
10
  */
11
11
  function transaction(op) {
@@ -71,4 +71,13 @@ var UObj;
71
71
  return o;
72
72
  }
73
73
  UObj.manipulateProperties = manipulateProperties;
74
+ /**
75
+ * generate a record object which contains spedified keys with values generated from value generator.
76
+ * @param keys keys contained in the object.
77
+ * @param vgen value generator.
78
+ */
79
+ function generateRecord(keys, vgen) {
80
+ return keys.reduce((o, k) => { o[k] = vgen(k); return o; }, {});
81
+ }
82
+ UObj.generateRecord = generateRecord;
74
83
  })(UObj || (exports.UObj = UObj = {}));
@@ -55,17 +55,17 @@ export declare namespace DType {
55
55
  function required(target: Object, propKey: string): void;
56
56
  /**
57
57
  * express array.
58
- * @param elmDesc {@link TypeDesc} or class constructor type.
58
+ * @param elmDesc {@link TypeDesc} or {@link Ctor|class constructor type}.
59
59
  */
60
60
  function array(elmDesc?: AnyTypeDesc | Ctor): (target: Object, propKey: string) => void;
61
61
  /**
62
62
  * express record object. note that this may allow array type because array is essentialy object type has properties.
63
- * @param elmDesc {@link TypeDesc} or class constructor type.
63
+ * @param elmDesc {@link TypeDesc} or {@link Ctor|class constructor type}.
64
64
  */
65
65
  function record(elmDesc?: AnyTypeDesc | Ctor): (target: Object, propKey: string) => void;
66
66
  /**
67
67
  * express an object which has properties that specified class express with {@link DType}.
68
- * @param ctor class constructor type.
68
+ * @param ctor {@link Ctor|class constructor type}.
69
69
  */
70
70
  function object(ctor: Ctor): (target: Object, propKey: string) => void;
71
71
  function keep(target: Object, propKey: string): void;
@@ -38,7 +38,7 @@ export var DType;
38
38
  DType.required = required;
39
39
  /**
40
40
  * express array.
41
- * @param elmDesc {@link TypeDesc} or class constructor type.
41
+ * @param elmDesc {@link TypeDesc} or {@link Ctor|class constructor type}.
42
42
  */
43
43
  function array(elmDesc = {}) {
44
44
  return (target, propKey) => setDesc(target, propKey, (td) => UType.isFunction(elmDesc) ? td.ary = { cls: elmDesc } : td.ary = elmDesc);
@@ -46,7 +46,7 @@ export var DType;
46
46
  DType.array = array;
47
47
  /**
48
48
  * express record object. note that this may allow array type because array is essentialy object type has properties.
49
- * @param elmDesc {@link TypeDesc} or class constructor type.
49
+ * @param elmDesc {@link TypeDesc} or {@link Ctor|class constructor type}.
50
50
  */
51
51
  function record(elmDesc = {}) {
52
52
  return (target, propKey) => setDesc(target, propKey, (td) => UType.isFunction(elmDesc) ? td.rcd = { cls: elmDesc } : td.rcd = elmDesc);
@@ -54,7 +54,7 @@ export var DType;
54
54
  DType.record = record;
55
55
  /**
56
56
  * express an object which has properties that specified class express with {@link DType}.
57
- * @param ctor class constructor type.
57
+ * @param ctor {@link Ctor|class constructor type}.
58
58
  */
59
59
  function object(ctor) {
60
60
  return (target, propKey) => setDesc(target, propKey, (td) => td.cls = ctor);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * applies transation to the method. note that the method must return a Promise.
2
+ * applies transation to the method. **note that the method must return a `Promise`**.
3
3
  * @param op.timeoutSec default is `30`.
4
4
  */
5
5
  export declare function transaction(op?: {
@@ -2,7 +2,7 @@ import { XjsErr } from "../../obj/xjs-err";
2
2
  import { delay } from "../u";
3
3
  const s_errCode = 100;
4
4
  /**
5
- * applies transation to the method. note that the method must return a Promise.
5
+ * applies transation to the method. **note that the method must return a `Promise`**.
6
6
  * @param op.timeoutSec default is `30`.
7
7
  */
8
8
  export function transaction(op) {
@@ -1,4 +1,4 @@
1
- import { Ctor, MaybeArray, NonObject, NormalRecord, Type } from "../const/types";
1
+ import { Ctor, IndexSignature, MaybeArray, NonObject, NormalRecord, Type } from "../const/types";
2
2
  export declare namespace UObj {
3
3
  /**
4
4
  * assign properties to the object with specified property keys.
@@ -36,4 +36,10 @@ export declare namespace UObj {
36
36
  recursive?: boolean;
37
37
  targetType?: MaybeArray<Exclude<Type, "object" | "null" | "undefined">>;
38
38
  }): T;
39
+ /**
40
+ * generate a record object which contains spedified keys with values generated from value generator.
41
+ * @param keys keys contained in the object.
42
+ * @param vgen value generator.
43
+ */
44
+ function generateRecord<K extends IndexSignature, V>(keys: K[], vgen: (k: K) => V): Record<K, V>;
39
45
  }
@@ -68,4 +68,13 @@ export var UObj;
68
68
  return o;
69
69
  }
70
70
  UObj.manipulateProperties = manipulateProperties;
71
+ /**
72
+ * generate a record object which contains spedified keys with values generated from value generator.
73
+ * @param keys keys contained in the object.
74
+ * @param vgen value generator.
75
+ */
76
+ function generateRecord(keys, vgen) {
77
+ return keys.reduce((o, k) => { o[k] = vgen(k); return o; }, {});
78
+ }
79
+ UObj.generateRecord = generateRecord;
71
80
  })(UObj || (UObj = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xjs-common",
3
- "version": "13.0.2",
3
+ "version": "13.0.3",
4
4
  "description": "library modules for typescript that bundled general-purpose implementations.",
5
5
  "repository": {
6
6
  "type": "git",