@zwa73/utils 1.0.166 → 1.0.168

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/dist/UtilClass.js CHANGED
@@ -210,11 +210,10 @@ class Hbs {
210
210
  return '';
211
211
  });
212
212
  this.hbs.registerHelper('defli', (name, options) => {
213
- const rawvalue = options.fn();
213
+ const rawvalue = options.fn(this.context);
214
214
  const values = rawvalue
215
215
  .split('[[br]]')
216
- .map(value => value.trim())
217
- .map(value => this.hbs.compile(value)(this.context));
216
+ .map(value => value.trim());
218
217
  this.context[name] = values;
219
218
  return '';
220
219
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.166",
3
+ "version": "1.0.168",
4
4
  "description": "my utils",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/UtilClass.ts CHANGED
@@ -67,7 +67,7 @@ export class Stream<T> implements Iterable<T>{
67
67
  //轮询平均分
68
68
  'average':()=>{
69
69
  for (let i = 0; i < count; i++) {
70
- const clist = [];
70
+ const clist:T[] = [];
71
71
  for (let j = i; j < size; j += count)
72
72
  clist.push(this._list[j]);
73
73
  result.push(clist);
@@ -218,12 +218,11 @@ export class Hbs<T extends Record<Keyable,any> = Record<Keyable,any>>{
218
218
  });
219
219
 
220
220
  this.hbs.registerHelper('defli', (name,options)=> {
221
- const rawvalue = options.fn() as string;
221
+ const rawvalue = options.fn(this.context) as string;
222
222
 
223
223
  const values = rawvalue
224
224
  .split('[[br]]')
225
- .map(value => value.trim())
226
- .map(value => this.hbs.compile(value)(this.context));
225
+ .map(value => value.trim());
227
226
  (this.context as any)[name] = values;
228
227
  return '';
229
228
  });
package/dist/backup.d.ts DELETED
@@ -1,32 +0,0 @@
1
- /**类组合
2
- * 将mixinList每个成员的字段混入base
3
- * @param base - 基础类
4
- * @param mixinList - 目标类
5
- * @returns - 混合完成的类
6
- */
7
- export declare function composeClassFull<Base extends object, MixinList extends object[]>(base: Base, ...mixinList: MixinList): ComposedFullClassMult<Base, MixinList>;
8
- /**组合的类
9
- * @template Base - 基类
10
- * @template Mixin - 待混入的类
11
- */
12
- export type ComposedFullClass<Base extends object, Mixin extends object> = Base & Mixin;
13
- /**组合的类 多组合变体
14
- * @template Base - 基类
15
- * @template MixinList- 待混入的类型数组
16
- */
17
- export type ComposedFullClassMult<Base extends object, MixinList extends object[]> = MixinList extends [infer Mixin, ...infer Rest] ? Mixin extends object ? Rest extends object[] ? ComposedFullClassMult<ComposedFullClass<Base, Mixin>, Rest> : Base : Base : Base;
18
- /**将一个类型的所有方法的 `this` 参数改为 `T` 类型
19
- * @template Methods - 待更改的函数表
20
- * @template T - 目标this类型
21
- */
22
- export type MethodsThisAs<Methods, T> = {
23
- [K in keyof Methods]: Methods[K] extends (...args: infer A) => infer R ? (this: T, ...args: A) => R : Methods[K];
24
- };
25
- /**尝试断言一个类的原型
26
- * 其所有函数的 this 都必须为某个类型
27
- * assignThisAs<Self,T>(Self.prototype);
28
- * @template Self - 类的类型
29
- * @template T - 目标this类型
30
- * @param prototype - 类的原型
31
- */
32
- export declare function assertThisAs<Self, T>(prototype: MethodsThisAs<Self, T>): void;
package/dist/backup.js DELETED
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.composeClassFull = composeClassFull;
4
- exports.assertThisAs = assertThisAs;
5
- /**类组合
6
- * 将mixinList每个成员的字段混入base
7
- * @param base - 基础类
8
- * @param mixinList - 目标类
9
- * @returns - 混合完成的类
10
- */
11
- function composeClassFull(base, ...mixinList) {
12
- let obj = base;
13
- for (let mixin of mixinList) {
14
- let propks = Object.getOwnPropertyNames(mixin.constructor.prototype);
15
- for (const key of propks) {
16
- if (key != "constructor") {
17
- Object.defineProperty(obj, key, {
18
- get: () => mixin[key],
19
- set: (value) => { mixin[key] = value; },
20
- enumerable: true,
21
- //writable: true,
22
- configurable: true
23
- });
24
- //obj[key] = (mixin as any)[key];
25
- }
26
- }
27
- for (const key in mixin) {
28
- Object.defineProperty(obj, key, {
29
- get: () => mixin[key],
30
- set: (value) => { mixin[key] = value; },
31
- enumerable: true,
32
- //writable: true ,
33
- configurable: true
34
- });
35
- //obj[key] = (mixin as any)[key];
36
- }
37
- }
38
- return obj;
39
- }
40
- /**尝试断言一个类的原型
41
- * 其所有函数的 this 都必须为某个类型
42
- * assignThisAs<Self,T>(Self.prototype);
43
- * @template Self - 类的类型
44
- * @template T - 目标this类型
45
- * @param prototype - 类的原型
46
- */
47
- function assertThisAs(prototype) { }
File without changes