| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8b636c3 commit 1ece4a7
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -940,6 +940,14 @@ console.log(params.toString()); | |||
| 940 | 940 | // Prints foo=def&abc=def&xyz=opq | |
| 941 | 941 | ``` | |
| 942 | 942 | ||
| 943 | + #### `urlSearchParams.size` | ||
| 944 | + | ||
| 945 | + <!-- YAML | ||
| 946 | + added: REPLACEME | ||
| 947 | + --> | ||
| 948 | + | ||
| 949 | + The total number of parameter entries. | ||
| 950 | + | ||
| 943 | 951 | #### `urlSearchParams.sort()` | |
| 944 | 952 | ||
| 945 | 953 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -290,6 +290,12 @@ class URLSearchParams { | |||
| 290 | 290 | return `${this.constructor.name} {}`; | |
| 291 | 291 | } | |
| 292 | 292 | ||
| 293 | + get size() { | ||
| 294 | + if (!isURLSearchParams(this)) | ||
| 295 | + throw new ERR_INVALID_THIS('URLSearchParams'); | ||
| 296 | + return this[searchParams].length / 2; | ||
| 297 | + } | ||
| 298 | + | ||
| 293 | 299 | append(name, value) { | |
| 294 | 300 | if (!isURLSearchParams(this)) | |
| 295 | 301 | throw new ERR_INVALID_THIS('URLSearchParams'); | |
@@ -525,6 +531,7 @@ ObjectDefineProperties(URLSearchParams.prototype, { | |||
| 525 | 531 | getAll: kEnumerableProperty, | |
| 526 | 532 | has: kEnumerableProperty, | |
| 527 | 533 | set: kEnumerableProperty, | |
| 534 | + size: kEnumerableProperty, | ||
| 528 | 535 | sort: kEnumerableProperty, | |
| 529 | 536 | entries: kEnumerableProperty, | |
| 530 | 537 | forEach: kEnumerableProperty, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,14 @@ const { URL, URLSearchParams } = require('url'); | |||
| 54 | 54 | testMethod(URLSearchParams.prototype, name, methodName); | |
| 55 | 55 | }); | |
| 56 | 56 | ||
| 57 | + { | ||
| 58 | + const params = new URLSearchParams(); | ||
| 59 | + params.append('a', 'b'); | ||
| 60 | + params.append('a', 'c'); | ||
| 61 | + params.append('b', 'c'); | ||
| 62 | + assert.strictEqual(params.size, 3); | ||
| 63 | + } | ||
| 64 | + | ||
| 57 | 65 | function stringifyName(name) { | |
| 58 | 66 | if (typeof name === 'symbol') { | |
| 59 | 67 | const { description } = name; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments