-
-
Save bmeck/89fbf0bf9e2baa3b907be7f2bf1a1372 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/////////////////////////////////////////////////////////////////////////////// | |
// Day 6 - Is anybody listening? // | |
// #region problem // | |
/////////////////////////////////////////////////////////////////////////////// | |
// Detect if DevTools can connect to the current Node.js instance and return // | |
// a different result if connected or not. // | |
/////////////////////////////////////////////////////////////////////////////// | |
/** | |
* @returns {boolean} | |
*/ | |
function isListeningForDevToolsConnections() { | |
// ... | |
} | |
/////////////////////////////////////////////////////////////////////////////// | |
// #endregion problem // | |
/////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////////// | |
// Test - Leave code after this alone // | |
// #region test // | |
/////////////////////////////////////////////////////////////////////////////// | |
import inspector from 'node:inspector'; | |
import assert from 'node:assert/strict'; | |
assert.strictEqual(isListeningForDevToolsConnections(), false); | |
inspector.open(0, '127.0.0.1', false); | |
assert.strictEqual(isListeningForDevToolsConnections(), true); | |
inspector.close(); | |
assert.strictEqual(isListeningForDevToolsConnections(), false); | |
/////////////////////////////////////////////////////////////////////////////// | |
// #endregion test // | |
/////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////////// | |
// Hints - Encoded in ROT13 encoded // | |
// #region hints // | |
/////////////////////////////////////////////////////////////////////////////// | |
// // | |
// Fvzcyr: hfr gur abqr:vafcrpgbe zbqhyr. // | |
// // | |
/////////////////////////////////////////////////////////////////////////////// | |
// #endregion hints // | |
/////////////////////////////////////////////////////////////////////////////// | |
/////////////////////////////////////////////////////////////////////////////// | |
// Use Cases // | |
// #region uses // | |
/////////////////////////////////////////////////////////////////////////////// | |
// // | |
// Sometimes you only want to do compute heavy workflows if someone is going // | |
// to listen, so debug level tracking etc. is available, or saving variables // | |
// and keeping debug data around that would normally be cleaned up. // | |
// // | |
/////////////////////////////////////////////////////////////////////////////// | |
// #endregion uses // | |
/////////////////////////////////////////////////////////////////////////////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment