@triveria/wallet 0.0.159 → 0.0.160
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common.js +1 -40
- package/package.json +1 -1
package/common.js
CHANGED
|
@@ -135,49 +135,10 @@ const serializeDataIfNeeded = function (value, requestOptions, configuration) {
|
|
|
135
135
|
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
136
136
|
: nonString;
|
|
137
137
|
return needsSerialization
|
|
138
|
-
? JSON.stringify(value !== undefined ?
|
|
138
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
139
139
|
: (value || "");
|
|
140
140
|
};
|
|
141
141
|
exports.serializeDataIfNeeded = serializeDataIfNeeded;
|
|
142
|
-
function convertMapsAndSetsToPlain(value) {
|
|
143
|
-
if (typeof Set === "undefined")
|
|
144
|
-
return value;
|
|
145
|
-
if (typeof Map === "undefined")
|
|
146
|
-
return value;
|
|
147
|
-
if (typeof value !== "object" || !value) {
|
|
148
|
-
return value;
|
|
149
|
-
}
|
|
150
|
-
if (value instanceof Set) {
|
|
151
|
-
return Array.from(value).map(item => convertMapsAndSetsToPlain(item));
|
|
152
|
-
}
|
|
153
|
-
if (value instanceof Map) {
|
|
154
|
-
const entries = [];
|
|
155
|
-
value.forEach((value, key) => {
|
|
156
|
-
entries.push([key, convertMapsAndSetsToPlain(value)]);
|
|
157
|
-
});
|
|
158
|
-
return objectFromEntries(entries);
|
|
159
|
-
}
|
|
160
|
-
if (Array.isArray(value)) {
|
|
161
|
-
return value.map(it => convertMapsAndSetsToPlain(it));
|
|
162
|
-
}
|
|
163
|
-
return objectFromEntries(objectEntries(value)
|
|
164
|
-
.map(([k, v]) => [k, convertMapsAndSetsToPlain(v)]));
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Ponyfill for Object.entries
|
|
168
|
-
*/
|
|
169
|
-
function objectEntries(object) {
|
|
170
|
-
return Object.keys(object).map(key => [key, object[key]]);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Ponyfill for Object.fromEntries
|
|
174
|
-
*/
|
|
175
|
-
function objectFromEntries(entries) {
|
|
176
|
-
return [...entries].reduce((object, [key, val]) => {
|
|
177
|
-
object[key] = val;
|
|
178
|
-
return object;
|
|
179
|
-
}, {});
|
|
180
|
-
}
|
|
181
142
|
/**
|
|
182
143
|
*
|
|
183
144
|
* @export
|