| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2bba6cd commit 8ab0540
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,20 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | + const { | ||
| 4 | + codes: { ERR_MISSING_ARGS }, | ||
| 5 | + } = require('internal/errors'); | ||
| 6 | + | ||
| 3 | 7 | const { | |
| 4 | 8 | MessageChannel, | |
| 5 | 9 | receiveMessageOnPort, | |
| 6 | 10 | } = require('internal/worker/io'); | |
| 7 | 11 | ||
| 8 | 12 | let channel; | |
| 9 | 13 | function structuredClone(value, options = undefined) { | |
| 14 | + if (arguments.length === 0) { | ||
| 15 | + throw new ERR_MISSING_ARGS('value'); | ||
| 16 | + } | ||
| 17 | + | ||
| 10 | 18 | // TODO: Improve this with a more efficient solution that avoids | |
| 11 | 19 | // instantiating a MessageChannel | |
| 12 | 20 | channel ??= new MessageChannel(); | |
@@ -17,5 +25,5 @@ function structuredClone(value, options = undefined) { | |||
| 17 | 25 | } | |
| 18 | 26 | ||
| 19 | 27 | module.exports = { | |
| 20 | - structuredClone | ||
| 28 | + structuredClone, | ||
| 21 | 29 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,10 +5,12 @@ | |||
| 5 | 5 | require('../common'); | |
| 6 | 6 | ||
| 7 | 7 | const { | |
| 8 | - structuredClone: _structuredClone | ||
| 8 | + structuredClone: _structuredClone, | ||
| 9 | 9 | } = require('internal/structured_clone'); | |
| 10 | + | ||
| 10 | 11 | const { | |
| 11 | - strictEqual | ||
| 12 | + strictEqual, | ||
| 13 | + throws, | ||
| 12 | 14 | } = require('assert'); | |
| 13 | 15 | ||
| 14 | 16 | strictEqual(globalThis.structuredClone, _structuredClone); | |
@@ -17,3 +19,5 @@ strictEqual(globalThis.structuredClone, undefined); | |||
| 17 | 19 | ||
| 18 | 20 | // Restore the value for the known globals check. | |
| 19 | 21 | structuredClone = _structuredClone; | |
| 22 | + | ||
| 23 | + throws(() => _structuredClone(), /ERR_MISSING_ARGS/); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments