Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jerrybendy/url-search-params-polyfill
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.2.4
Choose a base ref
...
head repository: jerrybendy/url-search-params-polyfill
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c8944fe0f5b55a3aa107ee977bb7015a8bb40b1a
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Sep 5, 2023

  1. Copy the full SHA
    c8944fe View commit details
Showing with 57 additions and 47 deletions.
  1. +2 −1 .gitignore
  2. +54 −45 index.js
  3. +1 −1 package.json
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
coverage
coverage
.idea
99 changes: 54 additions & 45 deletions index.js
Original file line number Diff line number Diff line change
@@ -169,84 +169,93 @@
* @param {function} callback
* @param {object} thisArg
*/
USPProto.forEach = USPProto.forEach || function(callback, thisArg) {
var dict = parseToDict(this.toString());
Object.getOwnPropertyNames(dict).forEach(function(name) {
dict[name].forEach(function(value) {
callback.call(thisArg, value, name, this);
if (!('forEach' in USPProto)) {
USPProto.forEach = function(callback, thisArg) {
var dict = parseToDict(this.toString());
Object.getOwnPropertyNames(dict).forEach(function(name) {
dict[name].forEach(function(value) {
callback.call(thisArg, value, name, this);
}, this);
}, this);
}, this);
};
};
}

/**
* Sort all name-value pairs
*/
USPProto.sort = USPProto.sort || function() {
var dict = parseToDict(this.toString()), keys = [], k, i, j;
for (k in dict) {
keys.push(k);
}
keys.sort();
if (!('sort' in USPProto)) {
USPProto.sort = function() {
var dict = parseToDict(this.toString()), keys = [], k, i, j;
for (k in dict) {
keys.push(k);
}
keys.sort();

for (i = 0; i < keys.length; i++) {
this['delete'](keys[i]);
}
for (i = 0; i < keys.length; i++) {
var key = keys[i], values = dict[key];
for (j = 0; j < values.length; j++) {
this.append(key, values[j]);
for (i = 0; i < keys.length; i++) {
this['delete'](keys[i]);
}
}
};
for (i = 0; i < keys.length; i++) {
var key = keys[i], values = dict[key];
for (j = 0; j < values.length; j++) {
this.append(key, values[j]);
}
}
};
}

/**
* Returns an iterator allowing to go through all keys of
* the key/value pairs contained in this object.
*
* @returns {function}
*/
USPProto.keys = USPProto.keys || function() {
var items = [];
this.forEach(function(item, name) {
items.push(name);
});
return makeIterator(items);
};
if (!('keys' in USPProto)) {
USPProto.keys = function() {
var items = [];
this.forEach(function(item, name) {
items.push(name);
});
return makeIterator(items);
};
}

/**
* Returns an iterator allowing to go through all values of
* the key/value pairs contained in this object.
*
* @returns {function}
*/
USPProto.values = USPProto.values || function() {
var items = [];
this.forEach(function(item) {
items.push(item);
});
return makeIterator(items);
};
if (!('values' in USPProto)) {
USPProto.values = function() {
var items = [];
this.forEach(function(item) {
items.push(item);
});
return makeIterator(items);
};
}

/**
* Returns an iterator allowing to go through all key/value
* pairs contained in this object.
*
* @returns {function}
*/
USPProto.entries = USPProto.entries || function() {
var items = [];
this.forEach(function(item, name) {
items.push([name, item]);
});
return makeIterator(items);
};

if (!('entries' in USPProto)) {
USPProto.entries = function() {
var items = [];
this.forEach(function(item, name) {
items.push([name, item]);
});
return makeIterator(items);
};
}

if (iterable) {
USPProto[self.Symbol.iterator] = USPProto[self.Symbol.iterator] || USPProto.entries;
}

if (!USPProto.size) {
if (!('size' in USPProto)) {
Object.defineProperty(USPProto, 'size', {
get: function () {
var dict = parseToDict(this.toString())
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "url-search-params-polyfill",
"version": "8.2.4",
"version": "8.2.5",
"description": "a simple polyfill for javascript URLSearchParams",
"homepage": "https://github.com/jerrybendy/url-search-params-polyfill",
"main": "index.js",