What is the error with my code for assertions tests in Javascripts?

Hi I am trying to do assertion tests on javascript using mocha and chai but it seems the test cannot trigger the functions inside the source code file (script.js).

Can anyone explain to me what’s wrong and how should i code it so it would work? Thanks.

Script.js

function addChar(input, character) {
    if(input.value == null || input.value == "0")
        input.value = character
    else
        input.value += character
}

function cos(form) {
    form.display.value = Math.cos(form.display.value);
}

function sin(form) {
    form.display.value = Math.sin(form.display.value);
}

function tan(form) {
    form.display.value = Math.tan(form.display.value);
}

function sqrt(form) {
    form.display.value = Math.sqrt(form.display.value);
}

function ln(form) {
    form.display.value = Math.log(form.display.value);
}

function exp(form) {
    form.display.value = Math.exp(form.display.value);
}

function deleteChar(input) {
    input.value = input.value.substring(0, input.value.length - 1)
}
var val = 0.0;
function percent(input) {
  val = input.value;
  input.value = input.value + "%";
}

function changeSign(input) {
    if(input.value.substring(0, 1) == "-")
        input.value = input.value.substring(1, input.value.length)
    else
        input.value = "-" + input.value
}

function compute(form) {
  //if (val !== 0.0) {
   // var percent = form.display.value;  
   // percent = pcent.substring(percent.indexOf("%")+1);
   // form.display.value = parseFloat(percent)/100 * val;
    //val = 0.0;
 // } else 
    form.display.value = eval(form.display.value);
  }


function square(form) {
    form.display.value = eval(form.display.value) * eval(form.display.value)
}

function checkNum(str) {
    for (var i = 0; i < str.length; i++) {
        var ch = str.charAt(i);
        if (ch < "0" || ch > "9") {
            if (ch != "/" && ch != "*" && ch != "+" && ch != "-" && ch != "."
                && ch != "(" && ch!= ")" && ch != "%") {
                alert("invalid entry!")
                return false
                }
            }
        }
        return true
}

Test.js

var assert = require('assert');
var addChar = require('../src/script').addChar;
var cos = require('../src/script').cos;
var sin = require('../src/script').sin;
var tan = require('../src/script').tan;
var sqrt = require('../src/script').sqrt;
var ln = require('../src/script').ln;
var exp = require('../src/script').exp;
var deleteChar = require('../src/script').deleteChar;
var changeSign = require('../src/script').changeSign;
var compute = require('../src/script').compute;
var square = require('../src/script').square;
var percent = require('../src/script').percent;
var checkNum = require('../src/script').checkNum;

describe('addChar()', function () {
    it('should add character to the input', function () {
        var input = { value: '123' };
        addChar(input, '4');
        assert.equal(input.value, '1234');
    });
});

describe('cos()', function () {
    it('should return the cosine of the input', function () {
        var form = { display: { value: '0' } };
        cos(form);
        assert.equal(form.display.value, '1');
    });
});

describe('sin()', function () {
    it('should return the sine of the input', function () {
        var form = { display: { value: '0' } };
        sin(form);
        assert.equal(form.display.value, '0');
    });
});

describe('tan()', function () {
    it('should return the tangent of the input', function () {
        var form = { display: { value: '0' } };
        tan(form);
        assert.equal(form.display.value, '0');
    });
});

describe('sqrt()', function () {
    it('should return the square root of the input', function () {
        var form = { display: { value: '4' } };
        sqrt(form);
        assert.equal(form.display.value, '2');
    });
});

describe('ln()', function () {
    it('should return the natural logarithm of the input', function () {
        var form = { display: { value: '2.71828' } };
        ln(form);
        assert.equal(form.display.value, '1');
    });
});

describe('exp()', function () {
    it('should return e to the power of the input', function () {
        var form = { display: { value: '1' } };
        exp(form);
        assert.equal(form.display.value, '2.718281828459045');
    });
});

describe('deleteChar()', function () {
    it('should delete a character from the input', function () {
        var input = { value: '1234' };
        deleteChar(input);
        assert.equal(input.value, '123');
    });
});

describe('changeSign()', function () {
    it('should change the sign of the input', function () {
        var input = { value: '123' };
        changeSign(input);
        assert.equal(input.value, '-123');
    });
});

describe('compute()', function () {
    it('should compute the result of the input', function () {
        var form = { display: { value: '1+2' } };
        compute(form);
        assert.equal(form.display.value, '3');
    });
});

describe('square()', function () {
    it('should compute the square of the input', function () {
        var form = { display: { value: '4' } };
        square(form);
        assert.equal(form.display.value, '16');
    });
});


I am expecting it to pass the test but as of now the test will fail because either it complains the function is undefined or it cannot be found.

Is there any tecnical meaning of Tech Stack

Yesterday, i had my Industrial Training viva and the external asked me about meaning of Stack in the Tech Stack.
I have HTML, CSS, JS, React as a Tech-stack.
I really get wondered that their is a literal meaning of what she said,

She told me that it is stack because Firstly, you are downloading React library, and then html, CSS, js
And said that the technology I am using follows LIFO principal.

How to make all images flow one direction in wowslider

I m going to make all images flow to one direction: right or left.
In my website, images flow left now, but the last image flows right to go to first image.
In Detail, all sliders have their id so they are shown from 1 to 4 .
when the 4 image is shown, it needs to show first image, I want to move images in same direction but now, it moves reverse direction to the first image and start sliding again.
please send me good idea to solve it.

I want to flow all images in one direction`


 jQuery("#wowslider-container1").wowSlider({
  
            effect: fade,
            prev: "",
            next: "",
            duration: <?= isset($page_contents->slider_duration) && ($page_contents->slider_duration > 0) ? $page_contents->slider_duration : 2 ?> * 1000,
            delay: <?= isset( $page_contents->slider_delay) && ($page_contents->slider_delay> 0) ? $page_contents->slider_delay: 2  ?> * 1000,
            width: 1560,
            height: 720,
          
            autoPlay: true,
            autoPlayVideo: false,
            playPause: false,
            stopOnHover: false,
            loop: true,
            bullets: 1,
            caption: true,
            captionEffect: "fade",
            controls: true,
            controlsThumb: false,
              onBeforeStep:0,
          
            responsive: 1,
            fullScreen: false,
            gestures: 2,
           direction: 'left',
            images: [
               image1,
               image2,
               ...
            ]
        });

AST Remove object with function from code insert function body to main function?

I try with ast (babel/parser) delete object assigment from function and insert operation function back to main function.

function ht(jW, d, e, f, g) {
  d = {}; d.SnIKx = function (h, i) {
    return i ^ h;
  }, d.cgmgz = function (h, i) {
    return i ^ h;
  },d.CelmY = function (h, i) {
    return h ^ i;
  };
  return f = this.h[e.SnIKx(e.cgmgz(this.h[this.g ^ 54.48][3], 108 + this.h[e.CelmY(54, this.g)][1].charCodeAt(this.h[54 ^ this.g][0]++) & 255.13), 46) ^ this.g], f;
}

this function have proxy function in object. anybody know how i can get with babel/parser

need get:

function ht(jW, d, e, f, g) {
   return f = this.h[this.h[this.g ^ 54.48][3] ^ 108 + this.h[54 ^ this.g][1].charCodeAt(this.h[54 ^ this.g][0]++) & 255.13 ^ 46 ^ this.g], f;
}
const parser = require("@babel/parser");
const traverse = require("@babel/traverse").default;
const generator = require("@babel/generator").default;

const code = `function ht(jW, d, e, f, g) {
  d = {}; d.SnIKx = function (h, i) {
    return i ^ h;
  }, d.cgmgz = function (h, i) {
    return i ^ h;
  },d.CelmY = function (h, i) {
    return h ^ i;
  };
  return f = this.h[e.SnIKx(e.cgmgz(this.h[this.g ^ 54.48][3], 108 + this.h[e.CelmY(54, this.g)][1].charCodeAt(this.h[54 ^ this.g][0]++) & 255.13), 46) ^ this.g], f;
}`;

// Parse the code
const ast = parser.parse(code, {
  sourceType: "module",
});


traverse(ast, {
BinaryExpression(path) {
        if (path.node.left.type === 'CallExpression')
        {
            if (path.node.left.callee && path.node.left.callee.property)
            {
                console.log(path.node.left.callee.property) // Get SnIKx
                console.log(path.node.left.callee.object) // Get e
            }
        }
    },
});

Get User’s Country Based on Time Zone in JavaScript [duplicate]

I’m looking for a solution to determine the user’s country based on their time zone in JavaScript, without relying on IP-to-location services such as maxmind, ipregistry, or ip2location. The goal is to utilize the moment-timezone library to map time zones to countries and return either the matching country or the original time zone if no match is found.

User password is being changed when the user clicks the email verification link

I am building api authentication routes using nodejs and express. The login and registration routes work perfectly until I try verifying a user by sending them a verification link via email. The user password is being changed, therefore after the email being verified, the user is unable to login. I don’t get what is happening to my code. I am encrypting my passwords using bcrypt but when try using unencrypted passwords, everything works. The password is only changed after email verification when I use bcrypt encryption! I need help please!

Here is my code:

User Model:

import { Schema, model } from "mongoose";
import bcrypt from 'bcrypt';

const UserSchema = new Schema({
    Admin: {
        type: Boolean,
        default: false
    },
    name: {
        type: String,
        required: [true, 'name field required!']
    },
    email: {
        type: String,
        required: [true, 'email field required'],
        unique: [true, 'email already taken!']
    },
    password: {
        type: String,
        required: [true, 'password field required']
    },
    verified: {
        type: Boolean,
        default: false
    },
    verificationToken: {
        type: String
    },
    addresses: [
        {
            name: String,
            mobileNo: String,
            houseNo: String,
            streetNo: String,
            landMark: String,
            city: String,
            country: String,
            postalCode: String
        }
    ],
    orders: [
        {
            type: Schema.Types.ObjectId,
            ref: 'Order'
        }
    ]
}, { timestamps: true });

/** fire function before saving document */
UserSchema.pre('save', async function (next) {
    const salt = await bcrypt.genSalt();
    this.password = await bcrypt.hash(this.password, salt);
    next();
});

/** fire function after saving document */
UserSchema.post("save", async (doc, next) => {
    console.log("User has been created!", doc);
    next();
});

/** fire this function to login the user */
UserSchema.statics.login = async function (email, password) {
    const user = await this.findOne({ email });
    
    if (user) {
        const auth = await bcrypt.compare(password, user.password);

        if (auth) {
            return user;
        }
        throw Error('Wrong password!')
    }

    throw Error('Email does not exist!')
}


const User = model('User', UserSchema);

export default User;

Controllers:

import crypto from 'crypto';
import User from "../models/User.js";
import sendEmailVerification from '../lib/nodemailer.js';
import { createToken, maxAge } from "../lib/token.js";

/** 
 * ! Register New User
 */
const registerUser = async (req, res) => {
    try {
        const { name, email, password } = req.body;

        /** check if user exists */
        const userExists = await User.findOne({ email });

        if (userExists) {
            return res.status(401).json({message: 'User already exists!'})
        }


        const user = await User.create({
            name,
            email,
            password,
            verificationToken: crypto.randomBytes(20).toString('hex')
        });

        /** send verification email */
        await sendEmailVerification(user.email, user.verificationToken);

        return res.status(200).json({message: 'User registration successful'})
    } catch (error) {
        console.log(error);
        return res.status(500).json({error: error.message})
    }
}

/**
 * ? Verify verification token
 */
const verifyToken = async (req, res) => {
    try {
        const { token } = req.params;

        /** find user with the given verification token */
        const user = await User.findOne({ verificationToken: token });
        if (!user) {
            return res.status(401).json({message: 'Invalid verification token!'})
        }

        /** mark as verified */
        user.verified = true;
        user.verificationToken = undefined;

        await user.save();

        res.status(200).json({message: 'User token has been verified!'})
    } catch (error) {
        console.log(error);
        return res.status(500).json({message: 'Token verification failed!'})
    }
}


/**
 * ! Login User;
 */
const loginUser = async (req, res) => {
    try {
        const { email, password } = req.body;

        /** check if user is verified */
        const user = await User.login(email, password);

        const token = await createToken(user._id, user.email, user.Admin, user.name);
        res.cookie("authToken", token, { maxAge: maxAge * 1000, httpOnly: true})
        res.status(200).json({ user });
    } catch (error) {
        console.log(error);
        return res.status(500).json({error: error.message})
    }
}

export {
    registerUser,
    verifyToken,
    loginUser
}

Routes:

import { Router } from "express";
import { loginUser, registerUser, verifyToken } from "../controllers/auth.js";


const router = Router();

/**
 * ! Create New User
 */
router.post("/register", registerUser);

/**
 * ? Verify verification token
 */
router.get('/verify/:token', verifyToken);

/**
 * ! Login User;
 */
router.post("/login", loginUser);

export default router;

Javascript – How to add auto language switch [closed]

I am creating a language translator using google APIs and I want to add auto language switch. If I type hindi in the box it should automatically transalated to english and if I type english it should transalted to hindi.

—– code below is my js file —————-

const dropdowns = document.querySelectorAll(".dropdown-container"),
  inputLanguageDropdown = document.querySelector("#input-language"),
  outputLanguageDropdown = document.querySelector("#output-language");

function populateDropdown(dropdown, options) {
  dropdown.querySelector("ul").innerHTML = "";
  options.forEach((option) => {
    const li = document.createElement("li");
    const title = option.name + " (" + option.native + ")";
    li.innerHTML = title;
    li.dataset.value = option.code;
    li.classList.add("option");
    dropdown.querySelector("ul").appendChild(li);
  });
}

populateDropdown(inputLanguageDropdown, languages);
populateDropdown(outputLanguageDropdown, languages);

dropdowns.forEach((dropdown) => {
  dropdown.addEventListener("click", (e) => {
    dropdown.classList.toggle("active");
  });

  dropdown.querySelectorAll(".option").forEach((item) => {
    item.addEventListener("click", (e) => {
      //remove active class from current dropdowns
      dropdown.querySelectorAll(".option").forEach((item) => {
        item.classList.remove("active");
      });
      item.classList.add("active");
      const selected = dropdown.querySelector(".selected");
      selected.innerHTML = item.innerHTML;
      selected.dataset.value = item.dataset.value;
      translate();
    });
  });
});
document.addEventListener("click", (e) => {
  dropdowns.forEach((dropdown) => {
    if (!dropdown.contains(e.target)) {
      dropdown.classList.remove("active");
    }
  });
});

const swapBtn = document.querySelector(".swap-position"),
  inputLanguage = inputLanguageDropdown.querySelector(".selected"),
  outputLanguage = outputLanguageDropdown.querySelector(".selected"),
  inputTextElem = document.querySelector("#input-text"),
  outputTextElem = document.querySelector("#output-text");

swapBtn.addEventListener("click", (e) => {
  const temp = inputLanguage.innerHTML;
  inputLanguage.innerHTML = outputLanguage.innerHTML;
  outputLanguage.innerHTML = temp;
  
  const tempValue = inputLanguage.dataset.value;
  inputLanguage.dataset.value = outputLanguage.dataset.value;
  outputLanguage.dataset.value = tempValue;

  //swap text
  const tempInputText = inputTextElem.value;
  inputTextElem.value = outputTextElem.value;
  outputTextElem.value = tempInputText;

  translate();
});

function translate() {
  const inputText = inputTextElem.value;
  const inputLanguage =
    inputLanguageDropdown.querySelector(".selected").dataset.value;
  const outputLanguage =
    outputLanguageDropdown.querySelector(".selected").dataset.value;
  const url = `https://translate.googleapis.com/translate_a/single?client=gtx&sl=${inputLanguage}&tl=${outputLanguage}&dt=t&q=${encodeURI(
    inputText
  )}`;
  fetch(url)
    .then((response) => response.json())
    .then((json) => {
      console.log(json);
      outputTextElem.value = json[0].map((item) => item[0]).join("");
    })
    .catch((error) => {
      console.log(error);
    });
}
inputTextElem.addEventListener("input", (e) => {
  //limit input to 5000 characters
  if (inputTextElem.value.length > 5000) {
    inputTextElem.value = inputTextElem.value.slice(0, 5000);
  }
  translate();
});

const uploadDocument = document.querySelector("#upload-document"),
  uploadTitle = document.querySelector("#upload-title");

uploadDocument.addEventListener("change", (e) => {
  const file = e.target.files[0];
  if (
    file.type === "application/pdf" ||
    file.type === "text/plain" ||
    file.type === "application/msword" ||
    file.type ===
      "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
  ) {
    uploadTitle.innerHTML = file.name;
    const reader = new FileReader();
    reader.readAsText(file);
    reader.onload = (e) => {
      inputTextElem.value = e.target.result;
      translate();
    };
  } else {
    alert("Please upload a valid file");
  }
});

const downloadBtn = document.querySelector("#download-btn");

downloadBtn.addEventListener("click", (e) => {
  const outputText = outputTextElem.value;
  const outputLanguage =
    outputLanguageDropdown.querySelector(".selected").dataset.value;
  if (outputText) {
    const blob = new Blob([outputText], { type: "text/plain" });
    const url = URL.createObjectURL(blob);
    const a = document.createElement("a");
    a.download = `translated-to-${outputLanguage}.txt`;
    a.href = url;
    a.click();
  }
});

const darkModeCheckbox = document.getElementById("dark-mode-btn");

darkModeCheckbox.addEventListener("change", () => {
  document.body.classList.toggle("dark");
});

const inputChars = document.querySelector("#input-chars");

inputTextElem.addEventListener("input", (e) => {
  inputChars.innerHTML = inputTextElem.value.length;
});

I tried switch statement but it didn’t worked well

How to find the tallest height between each pair of two divs and apply that tallest height to both the divs?

Say for example I have this following HTML:

<div class="TwoColumnUnit">
    <div class="col-md-6 col-xs-12 TwoColumnUnit_Left">
        <div class="newsLetterDiv">
            <div class="col-sm-12 col-md-12">
                <div class="left_Side">
                    <i class="fas fas fa-route"></i>
                    <h3>This is about Tennis</h3>
                </div>
                <div class="right_Side">
                    <p><span>Tennis is a racket sport that is played either individually against a single opponent or between two teams of two players each.&nbsp;</span></p>
                </div>
            </div>
        </div>
        <div class="newsLetterDiv">
            <div class="col-sm-12 col-md-12">
                <div class="left_Side">
                    <i class="fas fas fa-basketball"></i>
                    <h3>This is about Basketball</h3>
                </div>
                <div class="right_Side">
                    <p><span>Basketball is a team sport in which two teams, most commonly of five players each, opposing one another on a rectangular court, compete with the primary objective of shooting a basketball through the defender's hoop, while preventing the opposing team from shooting through their own hoop.Basketball is a team sport in which two teams, most commonly of five players each, opposing one another on a rectangular court, compete with the primary objective of shooting a basketball through the defender's hoop, while preventing the opposing team from shooting through their own hoop.</span></p>
                </div>
            </div>
        </div>
    </div>
    <div class="col-md-6 col-xs-12 TwoColumnUnit_Right">    
        <div class="newsLetterDiv">
            <div class="col-sm-12 col-md-12">
                <div class="left_Side">
                    <i class="fas fas fa-basketball"></i>
                    <h3>This is about Basketball</h3>
                </div>
                <div class="right_Side">
                    <p><span>Basketball is a team sport in which two teams, most commonly of five players each, opposing one another on a rectangular court, compete with the primary objective of shooting a basketball through the defender's hoop, while preventing the opposing team from shooting through their own hoop.Basketball is a team sport in which two teams, most commonly of five players each, opposing one another on a rectangular court, compete with the primary objective of shooting a basketball through the defender's hoop, while preventing the opposing team from shooting through their own hoop.</span></p>
                </div>
            </div>
        </div>
        <div class="newsLetterDiv">
            <div class="col-sm-12 col-md-12">
                <div class="left_Side">
                    <i class="fas fas fa-route"></i>
                    <h3>This is about Tennis</h3>
                </div>
                <div class="right_Side">
                    <p><span>Tennis is a racket sport that is played either individually against a single opponent or between two teams of two players each.&nbsp;</span></p>
                </div>
            </div>
        </div>
    </div>
</div>

Here is picture of how the HTML look picture.

I want to find the tallest height between Tennis and Football, and then set that tallest height, as the height for both Football and Tennis.

Likewise, I want to find the tallest height between Basketball and Swimming, and then set that tallest height as the height for both Football and Tennis.

I know how to find the max height using the Math.max. But how do find the tallest height between each pair of two divs?

What I tried:

('.TwoColumnUnit').each(function() {
  var pairs = [$(this).find('.TwoColumnUnit_Left'), $(this).find('.TwoColumnUnit_Right')];
  pairs.forEach(function(pair) {
      if (pair.length > 0) {
          var boxes = pair.find('.newsLetterDiv > div');
          var maxHeight = 0;
          boxes.each(function() {
              $(this).css('height', '');
              maxHeight = Math.max(maxHeight, $(this).height());
          });
          boxes.css('height', maxHeight + 'px');
      }
  });
});

The problem with this code is that it’s finding the tallest height between all 4 divs and then applying that tallest height value as height for all 4 of the items.

But how can I find the tallest height between the first left and right div, and then between the second left and right div?

Jquery add class to li element from selected li to bottom

HTML


<ul>
<li id="1">
  <div class="nodes">
    <div class="round"></div>
    <div class="line"></div>
  </div>
  <a href="#1"
    >1</a
  >
</li>
<li id="2">
  <div class="nodes">
    <div class="round"></div>
    <div class="line"></div>
  </div>
  <a href="#2"
    >1</a
  >
</li>
<li id="3">
  <div class="nodes">
    <div class="round"></div>
    <div class="line"></div>
  </div>
  <a href="#3"
    >1</a
  >
</li>
<li id="4">
  <div class="nodes">
    <div class="round"></div>
    <div class="line"></div>
  </div>
  <a href="#4"
    >1</a
  >
</li>
</ul>

Javascript

let $h3= $("article h3");
$(window)
  .scroll(function () {
    let $topCat = $h3.filter(
      (i, el) => $(el).offset().top > $(window).scrollTop() - 70
    );
    if ($topCat.attr("id")) {
      var parrent = $(`.toc ol`).find(`li#${$topCat.attr("id")}`);
      parrent.addClass("active");
var child = $(".toc li")[parrent.index()].id;
      $(`.toc li#${child}`).next().removeClass("active");
    }
    /*
   
    */
  })

  .scroll();

The code above only works once, but when the user scrolls back it doesn’t work

so, this is what I want
please look this

it starts from the li element which contains id #2
I want when starting from ID 2,3 and so on it will provide classes after that until the end.
is this possible, Is there a better and more effective way than my code above?

Removing the xy axis or Changing the color of the xy axis in a line chart in chart js 4

I have a issue in my chart.js code that is I want to remove both the axis lines from the graph, i want the grids to be displayed (NOTE)

`
const MAINCHARTCANVAS = document.querySelector(“.main-chart”)

new Chart(MAINCHARTCANVAS, {
type: ‘line’,
data: {
labels: [“Mon” , “Tue” , “Wed” , “Thu” , “Fri” , “Sat” , “Sun”],
datasets: [{
label: ‘My First Dataset’,
data: [7,5,7,7,8,7,4],
borderColor: “#4F3422”,
tension: 0.4,
borderWidth:7,
borderSkipped: true,
}]
},
options: {
scales: {

        x:{
            grid:{
                display:false,  
            },
            border:{
                didplay: false,
            }
        },

        y:{
            drawBorder: false, 
            beginAtZero: true,
            grid:{
                lineWidth:3,
                color:"#E8ddd9",
            },
            border: {
                display:false,
                dash: [10,16],
            },
            ticks: {display: false}
        }
    },

    plugins: {
        legend: false, // Hide legend
        tooltip:{
            enabled: false
        },
        backgroundCircle: false
    },
    responsive: true,
    maintainAspectRatio: false,
    elements: {
        point:{
            radius: 3
        }
    }
}

})
`

this my previous code I had tried

changing color or removing the axis enough for me

sample img for the reference

i am expecting like this

expected output

Try to change the color of it to transparent or try to remove it

Trouble retrieving gRPC error details in gRPC-web client

I’m working on a project that uses gRPC-web for communication between the client (written in JavaScript) and the server. I’m having difficulties retrieving error details from the gRPC response on the client side.

Could someone guide me on the correct approach or library for retrieving error details from a gRPC response in a gRPC-web client, specifically when using the grpc-web-client library?

Any help or suggestions would be greatly appreciated. Thank you!

What I Tried:
I attempted to retrieve error details from gRPC metadata in my gRPC-web client. The error details are present in the metadata as a string. Here’s a simplified version of my client code:

const detailsBase64 = error.metadata['grpc-status-details-bin'];
const detailsBinary = atob(detailsBase64);
const uint8Array = new Uint8Array(detailsBinary.length);
for (let i = 0; i < detailsBinary.length; ++i) {
  uint8Array[i] = detailsBinary.charCodeAt(i);
}
const myProto = MyProto.deserializeBinary(uint8Array);

What I Expected:
I expected that by accessing the metadata, I would be able to retrieve the error details.

What Actually Resulted:
When attempting to access the metadata and retrieve the error details, I encountered issues during deserialization. The error details retrieved from the metadata as a string could not be deserialized properly, resulting in an error. The specific error message or type of deserialization issue is Error: Assertion failed.