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
| extend layout.jade | |
| block content | |
| p Content |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <title>for-of loop vs forEach</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
| <script src="./suite.js"></script> | |
| </head> | |
| <body> | |
| <h1>Open the console to view the results</h1> |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <title>64bit comparison</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
| <script src="./suite.js"></script> | |
| </head> | |
| <body> | |
| <h1>Open the console to view the results</h1> |
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
| 'use strict'; | |
| const OriginalArray = global.Array; | |
| global.Array = function Array(...args) { | |
| const arr = new OriginalArray(...args); | |
| let length = arr.length; | |
| return new Proxy(arr, { | |
| set(target, propKey, value, Receiver) { | |
| if (propKey === 'length') { |
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
| "use strict"; | |
| // Example integration of the new vm.Module API into jsdom. | |
| const vm = require("vm"); | |
| const { URL } = require("url"); | |
| class ModuleScript { | |
| constructor() { | |
| this.context = null; |
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
| 'use strict'; | |
| const { Module } = require('vm'); | |
| process.on('unhandledRejection', p => { | |
| process.nextTick(() => { throw p; }); | |
| }); | |
| (async () => { | |
| const rootModule = new Module('export default 5;'); |
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
| 'use strict'; | |
| const { Module } = require('vm'); | |
| process.on('unhandledRejection', p => { | |
| process.nextTick(() => { throw p; }); | |
| }); | |
| (async () => { | |
| const rootModule = new Module('export default 5;'); |
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
| diff --git a/lib/internal/vm/Module.js b/lib/internal/vm/Module.js | |
| index c7f90a83a3..806c7ae20f 100644 | |
| --- a/lib/internal/vm/Module.js | |
| +++ b/lib/internal/vm/Module.js | |
| @@ -32,6 +32,7 @@ const perContextModuleId = new WeakMap(); | |
| const wrapMap = new WeakMap(); | |
| const dependencyCacheMap = new WeakMap(); | |
| const linkingStatusMap = new WeakMap(); | |
| +const linkingStatusDeferredMap = new WeakMap(); | |
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
| "g" | |
| >>> {"id":16,"method":"Runtime.evaluate","params":{"expression":"this","objectGroup":"completion","includeCommandLineAPI":true,"silent":true,"contextId":1,"returnByValue":false,"generatePreview":false,"userGesture":false,"awaitPromise":false,"throwOnSideEffect":false}} | |
| <<< {"id":16,"result":{"result":{"type":"object","className":"global","description":"global","objectId":"{\"injectedScriptId\":1,\"id\":9}"}}} | |
| >>> {"id":17,"method":"Runtime.evaluate","params":{"expression":"g","includeCommandLineAPI":true,"contextId":1,"generatePreview":true,"userGesture":true,"awaitPromise":false,"throwOnSideEffect":true,"timeout":500}} | |
| <<< {"id":17,"result":{"result":{"type":"object","subtype":"error","className":"ReferenceError","description":"ReferenceError: g is not defined\n at <anonymous>:1:1","objectId":"{\"injectedScriptId\":1,\"id\":10}"},"exceptionDetails":{"exceptionId":4,"text":"Uncaught","lineNumber":0,"columnNumber":0,"scriptId":"88","stackTrace":{"callFrames":[{"functionName":"","scriptId":"88","url":" |
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
| "use strict"; | |
| const http = require("http"); | |
| const server = http.createServer((req, res) => { | |
| if (req.url.includes("slow.js")) { | |
| setTimeout(() => { | |
| res.setHeader("Content-Type", "text/javascript"); | |
| res.end("void 0;"); | |
| }, 5000); |