forked from confused-Techie/atom-backend
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from pulsar-edit/simplify-call-stack
Simplify `CallStack`
- Loading branch information
Showing
6 changed files
with
104 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { performance } = require("node:perf_hooks"); | ||
|
||
module.exports = | ||
class CallStack { | ||
constructor() { | ||
this.calls = {}; | ||
|
||
this.initialize(); | ||
} | ||
|
||
initialize() { | ||
this.addCall("init", {}); | ||
} | ||
|
||
addCall(id, content) { | ||
this.calls[id] = { | ||
content: this.sanitize(content), | ||
time: performance.now() | ||
}; | ||
} | ||
|
||
// Attempts to remove any sensitive data that may be found within | ||
sanitize(content) { | ||
if (typeof content !== "object") { | ||
return content; | ||
} | ||
|
||
let outContent = {}; | ||
|
||
for (const key in content) { | ||
switch(key) { | ||
case "token": | ||
outContent[key] = "*****"; | ||
break; | ||
default: | ||
outContent[key] = content[key]; | ||
break; | ||
} | ||
} | ||
|
||
return outContent; | ||
} | ||
} |
Oops, something went wrong.