Skip to content

Commit

Permalink
fix: agrega opcion de stacktracelimit al contructor
Browse files Browse the repository at this point in the history
  • Loading branch information
drusco committed Aug 28, 2023
1 parent 8696da1 commit 4086671
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
Error.stackTraceLimit = 3;
export { default } from "./Emulator.js";
7 changes: 3 additions & 4 deletions src/lib/constructor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import Emulator from "../Emulator";
import Exotic from "../types/Exotic";
import { map } from "../utils";
import { map, constants } from "../utils";

describe("(constructor)", () => {
it("Creates a new emulator", () => {
const config: Exotic.emulator.options = {
traceErrors: false,
};
const config: Exotic.emulator.options = constants.CONFIG;
const emulator = new Emulator(config);
const data: Record<string, any> = map.emulators.get(emulator) || {};
const dataProps = ["options", "refs", "links", "counter", "proxySet"];
Expand All @@ -17,6 +15,7 @@ describe("(constructor)", () => {
expect(options).toEqual(config);
expect(Object.keys(refs).length).toBe(0);
expect(Object.keys(links).length).toBe(0);
expect(Error.stackTraceLimit).toBe(config.stackTraceLimit);
expect(counter).toBe(0);
});
});
14 changes: 6 additions & 8 deletions src/lib/constructor.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import Exotic from "../types/Exotic.js";
import { map } from "../utils/index.js";
import { map, constants } from "../utils/index.js";

export default function constructor(
scope: Exotic.Emulator,
options?: Exotic.emulator.options,
options: Exotic.emulator.options = {},
): void {
// set config defaults
const config: Exotic.emulator.options = {
traceErrors: false,
};
if (options) {
Object.assign(config, options);
}
const config: Exotic.emulator.options = constants.CONFIG;
Object.assign(config, options);
Error.stackTraceLimit = config.stackTraceLimit;

const data: Exotic.emulator.data = {
options: config,
refs: Object.create(null),
Expand Down
1 change: 1 addition & 0 deletions src/types/Exotic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ declare namespace Exotic {
namespace emulator {
interface options {
traceErrors?: boolean;
stackTraceLimit?: number;
}

interface data {
Expand Down
8 changes: 8 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Exotic from "../types/Exotic.js";

const CONFIG: Exotic.emulator.options = {
traceErrors: false,
stackTraceLimit: 3,
};

export default { CONFIG };
2 changes: 2 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import encode from "./encode.js";
import decode from "./decode.js";
import isPayload from "./isPayload.js";
import findProxyById from "./findProxyById.js";
import constants from "./constants.js";

export {
isTraceable,
Expand All @@ -22,4 +23,5 @@ export {
isPayload,
decode,
findProxyById,
constants,
};

0 comments on commit 4086671

Please sign in to comment.