@zwa73/utils 1.0.113 → 1.0.114
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/QuickFunction.d.ts +1 -1
- package/dist/QuickFunction.js +2 -2
- package/dist/UtilFunctions.d.ts +7 -0
- package/dist/UtilFunctions.js +15 -0
- package/package.json +1 -1
- package/src/QuickFunction.ts +1 -0
- package/src/UtilFunctions.ts +16 -0
package/dist/QuickFunction.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { UtilFunc } from "./UtilFunctions";
|
|
2
|
-
export declare const outcome: typeof UtilFunc.outcome, matchProc: typeof UtilFunc.matchProc, sucesProc: typeof UtilFunc.sucesProc, isFailed: typeof UtilFunc.isFailed, isSafeNumber: typeof UtilFunc.isSafeNumber, isSuccess: typeof UtilFunc.isSuccess, likeNone: typeof UtilFunc.likeNone, expect: typeof UtilFunc.expect, assertType: typeof UtilFunc.assertType, assertLiteral: typeof UtilFunc.assertLiteral, deepClone: typeof UtilFunc.deepClone, sleep: typeof UtilFunc.sleep, stringifyJToken: typeof UtilFunc.stringifyJToken, getTime: typeof UtilFunc.getTime, mapEntries: typeof UtilFunc.mapEntries, dedent: typeof UtilFunc.dedent, throwError: typeof UtilFunc.throwError;
|
|
2
|
+
export declare const outcome: typeof UtilFunc.outcome, matchProc: typeof UtilFunc.matchProc, sucesProc: typeof UtilFunc.sucesProc, isFailed: typeof UtilFunc.isFailed, isSafeNumber: typeof UtilFunc.isSafeNumber, isSuccess: typeof UtilFunc.isSuccess, likeNone: typeof UtilFunc.likeNone, expect: typeof UtilFunc.expect, assertType: typeof UtilFunc.assertType, assertLiteral: typeof UtilFunc.assertLiteral, deepClone: typeof UtilFunc.deepClone, sleep: typeof UtilFunc.sleep, stringifyJToken: typeof UtilFunc.stringifyJToken, getTime: typeof UtilFunc.getTime, mapEntries: typeof UtilFunc.mapEntries, dedent: typeof UtilFunc.dedent, throwError: typeof UtilFunc.throwError, getFuncLoc: typeof UtilFunc.getFuncLoc;
|
package/dist/QuickFunction.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.throwError = exports.dedent = exports.mapEntries = exports.getTime = exports.stringifyJToken = exports.sleep = exports.deepClone = exports.assertLiteral = exports.assertType = exports.expect = exports.likeNone = exports.isSuccess = exports.isSafeNumber = exports.isFailed = exports.sucesProc = exports.matchProc = exports.outcome = void 0;
|
|
3
|
+
exports.getFuncLoc = exports.throwError = exports.dedent = exports.mapEntries = exports.getTime = exports.stringifyJToken = exports.sleep = exports.deepClone = exports.assertLiteral = exports.assertType = exports.expect = exports.likeNone = exports.isSuccess = exports.isSafeNumber = exports.isFailed = exports.sucesProc = exports.matchProc = exports.outcome = void 0;
|
|
4
4
|
const UtilFunctions_1 = require("./UtilFunctions");
|
|
5
5
|
const UtilSymbol_1 = require("./UtilSymbol");
|
|
6
|
-
exports.outcome = UtilFunctions_1.UtilFunc.outcome, exports.matchProc = UtilFunctions_1.UtilFunc.matchProc, exports.sucesProc = UtilFunctions_1.UtilFunc.sucesProc, exports.isFailed = UtilFunctions_1.UtilFunc.isFailed, exports.isSafeNumber = UtilFunctions_1.UtilFunc.isSafeNumber, exports.isSuccess = UtilFunctions_1.UtilFunc.isSuccess, exports.likeNone = UtilFunctions_1.UtilFunc.likeNone, exports.expect = UtilFunctions_1.UtilFunc.expect, exports.assertType = UtilFunctions_1.UtilFunc.assertType, exports.assertLiteral = UtilFunctions_1.UtilFunc.assertLiteral, exports.deepClone = UtilFunctions_1.UtilFunc.deepClone, exports.sleep = UtilFunctions_1.UtilFunc.sleep, exports.stringifyJToken = UtilFunctions_1.UtilFunc.stringifyJToken, exports.getTime = UtilFunctions_1.UtilFunc.getTime, exports.mapEntries = UtilFunctions_1.UtilFunc.mapEntries, exports.dedent = UtilFunctions_1.UtilFunc.dedent, exports.throwError = UtilFunctions_1.UtilFunc.throwError;
|
|
6
|
+
exports.outcome = UtilFunctions_1.UtilFunc.outcome, exports.matchProc = UtilFunctions_1.UtilFunc.matchProc, exports.sucesProc = UtilFunctions_1.UtilFunc.sucesProc, exports.isFailed = UtilFunctions_1.UtilFunc.isFailed, exports.isSafeNumber = UtilFunctions_1.UtilFunc.isSafeNumber, exports.isSuccess = UtilFunctions_1.UtilFunc.isSuccess, exports.likeNone = UtilFunctions_1.UtilFunc.likeNone, exports.expect = UtilFunctions_1.UtilFunc.expect, exports.assertType = UtilFunctions_1.UtilFunc.assertType, exports.assertLiteral = UtilFunctions_1.UtilFunc.assertLiteral, exports.deepClone = UtilFunctions_1.UtilFunc.deepClone, exports.sleep = UtilFunctions_1.UtilFunc.sleep, exports.stringifyJToken = UtilFunctions_1.UtilFunc.stringifyJToken, exports.getTime = UtilFunctions_1.UtilFunc.getTime, exports.mapEntries = UtilFunctions_1.UtilFunc.mapEntries, exports.dedent = UtilFunctions_1.UtilFunc.dedent, exports.throwError = UtilFunctions_1.UtilFunc.throwError, exports.getFuncLoc = UtilFunctions_1.UtilFunc.getFuncLoc;
|
|
7
7
|
if (false) {
|
|
8
8
|
let aaser = (0, exports.assertLiteral)({ a: 1 });
|
|
9
9
|
let a = null;
|
package/dist/UtilFunctions.d.ts
CHANGED
|
@@ -212,5 +212,12 @@ export declare class UtilFunc {
|
|
|
212
212
|
* @param opt - 额外参数
|
|
213
213
|
*/
|
|
214
214
|
static throwError(message: string, lvl?: LogLevel, opt?: {}): never;
|
|
215
|
+
/**获取函数调用位置 getFunctionLocation
|
|
216
|
+
* @param stack - 深度 默认1, 即getFuncLoc函数被调用的位置
|
|
217
|
+
*/
|
|
218
|
+
static getFuncLoc(stack?: number): {
|
|
219
|
+
filePath: string;
|
|
220
|
+
lineNumber: `${number}:${number}`;
|
|
221
|
+
} | undefined;
|
|
215
222
|
}
|
|
216
223
|
export {};
|
package/dist/UtilFunctions.js
CHANGED
|
@@ -572,6 +572,21 @@ class UtilFunc {
|
|
|
572
572
|
}
|
|
573
573
|
throw e;
|
|
574
574
|
}
|
|
575
|
+
/**获取函数调用位置 getFunctionLocation
|
|
576
|
+
* @param stack - 深度 默认1, 即getFuncLoc函数被调用的位置
|
|
577
|
+
*/
|
|
578
|
+
static getFuncLoc(stack = 1) {
|
|
579
|
+
const stackLines = new Error().stack.split('\n');
|
|
580
|
+
const regex = /([a-zA-Z]+?:.+?):(\d+?:\d+?)/;
|
|
581
|
+
//console.log(stackLines)
|
|
582
|
+
const match = regex.exec(stackLines[stack + 1]);
|
|
583
|
+
if (match) {
|
|
584
|
+
const filePath = match[1];
|
|
585
|
+
const lineNumber = match[2];
|
|
586
|
+
return { filePath, lineNumber };
|
|
587
|
+
}
|
|
588
|
+
return undefined;
|
|
589
|
+
}
|
|
575
590
|
}
|
|
576
591
|
exports.UtilFunc = UtilFunc;
|
|
577
592
|
__decorate([
|
package/package.json
CHANGED
package/src/QuickFunction.ts
CHANGED
package/src/UtilFunctions.ts
CHANGED
|
@@ -649,4 +649,20 @@ static throwError(message:string,lvl?:LogLevel,opt?:{}):never{
|
|
|
649
649
|
throw e;
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
+
/**获取函数调用位置 getFunctionLocation
|
|
653
|
+
* @param stack - 深度 默认1, 即getFuncLoc函数被调用的位置
|
|
654
|
+
*/
|
|
655
|
+
static getFuncLoc(stack=1) {
|
|
656
|
+
const stackLines = new Error().stack!.split('\n');
|
|
657
|
+
const regex = /([a-zA-Z]+?:.+?):(\d+?:\d+?)/;
|
|
658
|
+
//console.log(stackLines)
|
|
659
|
+
const match = regex.exec(stackLines[stack+1]);
|
|
660
|
+
if(match){
|
|
661
|
+
const filePath = match[1];
|
|
662
|
+
const lineNumber = match[2] as `${number}:${number}`;
|
|
663
|
+
return {filePath,lineNumber}
|
|
664
|
+
}
|
|
665
|
+
return undefined;
|
|
666
|
+
}
|
|
667
|
+
|
|
652
668
|
}
|