Skip to content

Commit

Permalink
Removed reliance on downlevelIteration
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianhelvikspond committed Mar 19, 2024
1 parent c604e02 commit 44c90da
Show file tree
Hide file tree
Showing 17 changed files with 234 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
9 changes: 7 additions & 2 deletions samples/client/echo_api/typescript-axios/build/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
129 changes: 129 additions & 0 deletions samples/client/echo_api/typescript-axios/build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"target": "ES5",
"module": "commonjs",
"noImplicitAny": true,
"downlevelIteration": true,
"outDir": "dist",
"rootDir": ".",
"lib": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,20 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any,
}

function convertMapsAndSetsToPlain(value: any): any {
if (typeof Set === "undefined") return value;
if (typeof Map === "undefined") return value;
if (typeof value !== "object" || !value) {
return value;
}
if (value instanceof Set) {
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
}
if (value instanceof Map) {
return objectFromEntries([...value.entries()]
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
const entries: Array<[string, any]> = [];
value.forEach((value: any, key: any) => {
entries.push([key, convertMapsAndSetsToPlain(value)])
});
return objectFromEntries(entries);
}
if (Array.isArray(value)) {
return value.map(it => convertMapsAndSetsToPlain(it));
Expand Down
Loading

0 comments on commit 44c90da

Please sign in to comment.