Skip to content

Commit

Permalink
Remove getEntries polyfill for Object.entries.
Browse files Browse the repository at this point in the history
Object.entries is unsupported by Node.js < 7.0.0. We are currently figuring out which Node.js versions 4.0.0 of the client will support, but we plan on raising it to at least 8.0.0.
  • Loading branch information
Pimm committed Jul 9, 2024
1 parent 5117004 commit 1c88e74
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
5 changes: 2 additions & 3 deletions src/communication/buildUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { URLSearchParams } from 'url';

import { apply, runIf } from 'ruply';
import getEntries from '../plumbing/getEntries';
import type Maybe from '../types/Maybe';

export type SearchParameters = Record<string, any>;
Expand All @@ -21,7 +20,7 @@ export type SearchParameters = Record<string, any>;
* `?object[key]=value`).
*/
export default function buildUrl(originAndPathname: string, searchParameters?: SearchParameters): string {
const searchEntries = (runIf(searchParameters, getEntries) ?? []) as [string, Maybe<string | number | string[] | number[] | Record<string, string | number>>][];
const searchEntries = (runIf(searchParameters, Object.entries) ?? []) as [string, Maybe<string | number | string[] | number[] | Record<string, string | number>>][];
if (searchEntries.length == 0) {
return originAndPathname;
}
Expand All @@ -32,7 +31,7 @@ export default function buildUrl(originAndPathname: string, searchParameters?: S
continue;
}
if (typeof value == 'object' && !Array.isArray(value)) {
for (const [innerKey, innerValue] of getEntries(value)) {
for (const [innerKey, innerValue] of Object.entries(value)) {
flattenedEntries[`${key}[${innerKey}]`] = String(innerValue);
}
} /* if (typeof value != 'object' || Array.isArray(value)) */ else {
Expand Down
3 changes: 1 addition & 2 deletions src/data/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { inspect, type InspectOptionsStylized } from 'util';
import type TransformingNetworkClient from '../communication/TransformingNetworkClient';
import buildFromEntries from '../plumbing/buildFromEntries';
import capitalize from '../plumbing/capitalize';
import getEntries from '../plumbing/getEntries';
import renege from '../plumbing/renege';
import type Callback from '../types/Callback';
import type Maybe from '../types/Maybe';
Expand All @@ -22,7 +21,7 @@ function convertToString(subject: Model<string>, tag: string, depth: number, opt
if (depth < 0) {
return options.stylize(`[${parts.join(' ')}]`, 'special');
}
parts.push(inspect(buildFromEntries(getEntries<any>(subject).filter(([key]) => stringRepresentationBlacklist.has(key) === false)), { ...options, depth: 1, sorted: true }));
parts.push(inspect(buildFromEntries(Object.entries(subject).filter(([key]) => stringRepresentationBlacklist.has(key) === false)), { ...options, depth: 1, sorted: true }));
return parts.join(' ');
}

Expand Down
13 changes: 0 additions & 13 deletions src/plumbing/getEntries.ts

This file was deleted.

0 comments on commit 1c88e74

Please sign in to comment.