muggle-string 0.4.0 → 0.4.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/out/track.d.ts +1 -0
- package/out/track.js +13 -12
- package/package.json +1 -1
package/out/track.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare function setTracking(value: boolean): void;
|
|
|
3
3
|
export declare function offsetStack(): void;
|
|
4
4
|
export declare function resetOffsetStack(): void;
|
|
5
5
|
export declare function track<T extends Segment<any>[]>(segments: T, stacks?: StackNode[]): [T, StackNode[]];
|
|
6
|
+
export declare function getStack(): string;
|
package/out/track.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.track = exports.resetOffsetStack = exports.offsetStack = exports.setTracking = void 0;
|
|
3
|
+
exports.getStack = exports.track = exports.resetOffsetStack = exports.offsetStack = exports.setTracking = void 0;
|
|
4
4
|
let tracking = true;
|
|
5
5
|
let stackOffset = 0;
|
|
6
6
|
function setTracking(value) {
|
|
@@ -116,17 +116,18 @@ function track(segments, stacks = []) {
|
|
|
116
116
|
stacks.splice(0, stacks.length, { stack: getStack(), length: segments.length });
|
|
117
117
|
return segments.reverse();
|
|
118
118
|
}
|
|
119
|
-
function getStack() {
|
|
120
|
-
const stack = new Error().stack;
|
|
121
|
-
let source = stack.split('\n')[3 + stackOffset].trim();
|
|
122
|
-
if (source.endsWith(')')) {
|
|
123
|
-
source = source.slice(source.lastIndexOf('(') + 1, -1);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
source = source.slice(source.lastIndexOf(' ') + 1);
|
|
127
|
-
}
|
|
128
|
-
return source;
|
|
129
|
-
}
|
|
130
119
|
}
|
|
131
120
|
exports.track = track;
|
|
121
|
+
function getStack() {
|
|
122
|
+
const stack = new Error().stack;
|
|
123
|
+
let source = stack.split('\n')[3 + stackOffset].trim();
|
|
124
|
+
if (source.endsWith(')')) {
|
|
125
|
+
source = source.slice(source.lastIndexOf('(') + 1, -1);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
source = source.slice(source.lastIndexOf(' ') + 1);
|
|
129
|
+
}
|
|
130
|
+
return source;
|
|
131
|
+
}
|
|
132
|
+
exports.getStack = getStack;
|
|
132
133
|
//# sourceMappingURL=track.js.map
|