Skip to content

Instantly share code, notes, and snippets.

@bmeck

bmeck/day-6.mjs Secret

Created December 30, 2021 20:43
Show Gist options
  • Save bmeck/89fbf0bf9e2baa3b907be7f2bf1a1372 to your computer and use it in GitHub Desktop.
Save bmeck/89fbf0bf9e2baa3b907be7f2bf1a1372 to your computer and use it in GitHub Desktop.
///////////////////////////////////////////////////////////////////////////////
// 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