| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bd5ef38 commit 1e20b05
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 | |
|---|---|---|---|
@@ -268,6 +268,12 @@ class URLSearchParams { | |||
| 268 | 268 | return `${this.constructor.name} {}`; | |
| 269 | 269 | } | |
| 270 | 270 | ||
| 271 | + get size() { | ||
| 272 | + if (!isURLSearchParams(this)) | ||
| 273 | + throw new ERR_INVALID_THIS('URLSearchParams'); | ||
| 274 | + return this[searchParams].length / 2; | ||
| 275 | + } | ||
| 276 | + | ||
| 271 | 277 | append(name, value) { | |
| 272 | 278 | if (!isURLSearchParams(this)) | |
| 273 | 279 | throw new ERR_INVALID_THIS('URLSearchParams'); | |
@@ -511,6 +517,7 @@ ObjectDefineProperties(URLSearchParams.prototype, { | |||
| 511 | 517 | getAll: kEnumerableProperty, | |
| 512 | 518 | has: kEnumerableProperty, | |
| 513 | 519 | set: kEnumerableProperty, | |
| 520 | + size: kEnumerableProperty, | ||
| 514 | 521 | sort: kEnumerableProperty, | |
| 515 | 522 | entries: kEnumerableProperty, | |
| 516 | 523 | forEach: kEnumerableProperty, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,6 +65,14 @@ const { URL, URLSearchParams, format } = require('url'); | |||
| 65 | 65 | testMethod(URLSearchParams.prototype, name, methodName); | |
| 66 | 66 | }); | |
| 67 | 67 | ||
| 68 | + { | ||
| 69 | + const params = new URLSearchParams(); | ||
| 70 | + params.append('a', 'b'); | ||
| 71 | + params.append('a', 'c'); | ||
| 72 | + params.append('b', 'c'); | ||
| 73 | + assert.strictEqual(params.size, 3); | ||
| 74 | + } | ||
| 75 | + | ||
| 68 | 76 | function stringifyName(name) { | |
| 69 | 77 | if (typeof name === 'symbol') { | |
| 70 | 78 | const { description } = name; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments