MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxUint8ArrayGetBase64Options

Function fxUint8ArrayGetBase64Options

xs/sources/xsDataView.c:3566–3605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3564}
3565
3566static void fxUint8ArrayGetBase64Options(txMachine* the, txInteger argi, txU1** alphabet, txInteger* lastChunkHandling, txBoolean* omitPadding)
3567{
3568 if ((mxArgc > argi) && !mxIsUndefined(mxArgv(argi))) {
3569 if (!mxIsReference(mxArgv(argi)))
3570 mxTypeError("options: not an object");
3571 mxPushSlot(mxArgv(argi));
3572 mxGetID(mxID(_alphabet));
3573 if (!mxIsUndefined(the->stack)) {
3574 if (!mxIsStringPrimitive(the->stack))
3575 mxTypeError("options.alphabet: not a string");
3576 if (!c_strcmp(the->stack->value.string, "base64url"))
3577 *alphabet = (txU1*)gxBase64URLAlphabet;
3578 else if (c_strcmp(the->stack->value.string, "base64"))
3579 mxTypeError("options.alphabet: neither 'base64' nor 'base64url'");
3580 }
3581 mxPop();
3582 if (lastChunkHandling) {
3583 mxPushSlot(mxArgv(argi));
3584 mxGetID(mxID(_lastChunkHandling));
3585 if (!mxIsUndefined(the->stack)) {
3586 if (!mxIsStringPrimitive(the->stack))
3587 mxTypeError("options.lastChunkHandling: not a string");
3588 if (!c_strcmp(the->stack->value.string, "stop-before-partial"))
3589 *lastChunkHandling = mxBase64StopBeforePartial;
3590 else if (!c_strcmp(the->stack->value.string, "strict"))
3591 *lastChunkHandling = mxBase64Strict;
3592 else if (c_strcmp(the->stack->value.string, "loose"))
3593 mxTypeError("options.lastChunkHandling: neither 'loose' nor 'strict' nor 'stop-before-partial'");
3594 }
3595 mxPop();
3596 }
3597 if (omitPadding) {
3598 mxPushSlot(mxArgv(argi));
3599 mxGetID(mxID(_omitPadding));
3600 fxToBoolean(the, the->stack);
3601 *omitPadding = the->stack->value.boolean;
3602 mxPop();
3603 }
3604 }
3605}
3606
3607void fx_Uint8Array_fromBase64(txMachine* the)
3608{

Calls 1

fxToBooleanFunction · 0.85

Tested by

no test coverage detected