tranlsate cpp to js