@konomi-app/kintone-utilities 5.10.4 → 5.11.0
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/decorator.d.ts +16 -0
- package/dist/decorator.js +32 -0
- package/dist/decorator.js.map +1 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 指定された関数にロギング機能を追加するデコレータ関数。
|
|
3
|
+
*
|
|
4
|
+
* ログはグループ化され、関数名、引数、戻り値、処理時間が表示される。
|
|
5
|
+
*
|
|
6
|
+
* @template T - 関数の型。
|
|
7
|
+
* @param {T} fn - ロギングを追加する対象の関数。
|
|
8
|
+
* @param {string} [name=fn.name] - ログに表示する関数名。デフォルトは関数の名前。
|
|
9
|
+
* @returns {(...args: Parameters<T>) => ReturnType<T>} ロギング機能が追加された新しい関数。
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const add = (a: number, b: number) => a + b;
|
|
13
|
+
* const addWithLogging = withLogging(add);
|
|
14
|
+
* addWithLogging(2, 3); // ログが出力される
|
|
15
|
+
*/
|
|
16
|
+
export declare const withLogging: <T extends (...args: any[]) => any>(fn: T, name?: string) => (...args: Parameters<T>) => ReturnType<T>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 指定された関数にロギング機能を追加するデコレータ関数。
|
|
3
|
+
*
|
|
4
|
+
* ログはグループ化され、関数名、引数、戻り値、処理時間が表示される。
|
|
5
|
+
*
|
|
6
|
+
* @template T - 関数の型。
|
|
7
|
+
* @param {T} fn - ロギングを追加する対象の関数。
|
|
8
|
+
* @param {string} [name=fn.name] - ログに表示する関数名。デフォルトは関数の名前。
|
|
9
|
+
* @returns {(...args: Parameters<T>) => ReturnType<T>} ロギング機能が追加された新しい関数。
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const add = (a: number, b: number) => a + b;
|
|
13
|
+
* const addWithLogging = withLogging(add);
|
|
14
|
+
* addWithLogging(2, 3); // ログが出力される
|
|
15
|
+
*/
|
|
16
|
+
export const withLogging = (fn, name = fn.name) => {
|
|
17
|
+
return (...args) => {
|
|
18
|
+
try {
|
|
19
|
+
console.groupCollapsed(`🔧 ${name}`);
|
|
20
|
+
console.log('🔧 args', args);
|
|
21
|
+
const now = performance.now();
|
|
22
|
+
const result = fn(...args);
|
|
23
|
+
console.log('✨ result', result);
|
|
24
|
+
console.log(`🕒 took ${performance.now() - now}ms`);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
console.groupEnd();
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../src/decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAoC,EAAK,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE;IACtF,OAAO,CAAC,GAAG,IAAmB,EAAiB,EAAE;QAC/C,IAAI,CAAC;YACH,OAAO,CAAC,cAAc,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;YACrC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC7B,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,WAAW,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC;YACpD,OAAO,MAAM,CAAC;QAChB,CAAC;gBAAS,CAAC;YACT,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export type { kintoneAPI } from './types/api';
|
|
2
|
-
export type * from './types/kintone-config';
|
|
3
|
-
export type * from './types/plugin-config';
|
|
4
1
|
export * from './character-width-conversion';
|
|
2
|
+
export * from './cybozu';
|
|
3
|
+
export * from './cybozu-api';
|
|
4
|
+
export * from './date';
|
|
5
|
+
export * from './decorator';
|
|
5
6
|
export * from './event-manager';
|
|
6
7
|
export * from './plugin';
|
|
7
8
|
export * from './rest-api';
|
|
8
|
-
export
|
|
9
|
+
export type { kintoneAPI } from './types/api';
|
|
10
|
+
export type * from './types/kintone-config';
|
|
11
|
+
export type * from './types/plugin-config';
|
|
9
12
|
export * from './utilities';
|
|
10
13
|
export * from './utility-types';
|
|
11
|
-
export * from './date';
|
|
12
|
-
export * from './cybozu';
|
|
13
14
|
export * from './xapp';
|
|
14
|
-
export * from './cybozu-api';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export * from './character-width-conversion';
|
|
2
|
+
export * from './cybozu';
|
|
3
|
+
export * from './cybozu-api';
|
|
4
|
+
export * from './date';
|
|
5
|
+
export * from './decorator';
|
|
2
6
|
export * from './event-manager';
|
|
3
7
|
export * from './plugin';
|
|
4
8
|
export * from './rest-api';
|
|
5
|
-
export * from './types/kintone-config';
|
|
6
9
|
export * from './utilities';
|
|
7
10
|
export * from './utility-types';
|
|
8
|
-
export * from './date';
|
|
9
|
-
export * from './cybozu';
|
|
10
11
|
export * from './xapp';
|
|
11
|
-
export * from './cybozu-api';
|
|
12
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC;AAC7C,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAI3B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC"}
|