UNPKG

713 BJavaScriptView Raw
1'use strict';
2var DESCRIPTORS = require('../internals/descriptors');
3var uncurryThis = require('../internals/function-uncurry-this');
4var defineBuiltInAccessor = require('../internals/define-built-in-accessor');
5
6var URLSearchParamsPrototype = URLSearchParams.prototype;
7var forEach = uncurryThis(URLSearchParamsPrototype.forEach);
8
9// `URLSearchParams.prototype.size` getter
10// https://github.com/whatwg/url/pull/734
11if (DESCRIPTORS && !('size' in URLSearchParamsPrototype)) {
12 defineBuiltInAccessor(URLSearchParamsPrototype, 'size', {
13 get: function size() {
14 var count = 0;
15 forEach(this, function () { count++; });
16 return count;
17 },
18 configurable: true,
19 enumerable: true
20 });
21}