THERAS_T
Deno2y ago
THERAS_

Buffer.from equivalent in deno?

on node.js
  const signerPvtKey = Buffer.from(
    // process.env.PVT_KEY
    PVT_KEY,
    "hex"
  );

i found the deno from medium article to do it like this:
https://medium.com/deno-the-complete-reference/buffer-from-denos-equivalent-of-node-js-d42f7115af61
//Node.js
Buffer.from('48656c6c6f20576f726c64', 'hex');
//Deno
import {decodeString} from "https://deno.land/std/encoding/hex.ts";
new Buffer(decodeString('48656c6c6f20576f726c64'));

but it is outofdate for decodeString, so i use decodeHex

import { Buffer } from "https://deno.land/std/io/mod.ts";
// import {Buffer} from "https://deno.land/std/io/buffer.ts";
import {decodeHex} from "https://deno.land/std/encoding/hex.ts";

the decodeHex is working as intended but Buffer still not working, i got empty object instead and neither those 2 Buffer seems working from mod and buffer.ts
Was this page helpful?