MCPcopy Index your code
hub / github.com/NativeScript/capacitor / fixArgs

Method fixArgs

testing/browser.ts:269–302  ·  view source on GitHub ↗
(value: any)

Source from the content-addressed store, hash-verified

267 }
268
269 fixArgs(value: any) {
270 // eslint-disable-next-line no-async-promise-executor
271 return new Promise(async resolve => {
272 if (value == null) {
273 return resolve(null);
274 }
275 if (Array.isArray(value)) {
276 for (let i = 0; i < value.length; i++) {
277 value[i] = await this.fixArgs(value[i]);
278 }
279 } else if (typeof value.then === 'function') {
280 value = await Promise.resolve(value);
281 } else if (typeof value === 'function') {
282 const idx = ++this._callbackId;
283 const callId = '__NS_CALLBACK__' + idx;
284 this._callbacks[idx] = value;
285 value = callId;
286 } else if (typeof value === 'number' || typeof value === 'string') {
287 resolve(value);
288 return;
289 } else {
290 const keys = Object.keys(value);
291 if (!keys.length) {
292 resolve(value.toString());
293 return;
294 }
295 // eslint-disable-next-line @typescript-eslint/prefer-for-of
296 for (let i = 0; i < keys.length; i++) {
297 value[keys[i]] = await this.fixArgs(value[keys[i]]);
298 }
299 }
300 resolve(value);
301 });
302 }
303
304 marshall(type: any, func: any, prop: any, value: any = null) {
305 if (DEBUGGING) {

Callers 1

marshallMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected