dino_runtime 0.1.1

A Rust runtime for Deno
Documentation
const { to_base64, from_base64 } = Deno.core.ops;

Object.defineProperty(Uint8Array.prototype, 'toBase64', {
  value: function(options = {}) {
    
    const alphabet = (options && options.alphabet) === 'base64url' ? 'base64url' : 'base64';
    const omitPadding = !!(options && options.omitPadding);


    return to_base64(this, alphabet, omitPadding);
  },
  enumerable: false,
  configurable: true,
  writable: true
});

Object.defineProperty(Uint8Array, 'fromBase64', {
  value: function(string, options = {}) {
    if (typeof string !== 'string') {
      throw new TypeError('fromBase64: argument must be a string');
    }
    console.log("fromBase64 called with string:", string);

    const alphabet = (options && options.alphabet) === 'base64url' ? 'base64url' : 'base64';
    const omitPadding = !!(options && options.omitPadding);
    const bytes = from_base64(string, alphabet, omitPadding);
    return new Uint8Array(bytes);
  },
  configurable: true,
  enumerable: false,
  writable: true
});