Files
xahau.js/packages/ripple-binary-codec/test/utils.js
Nathan Nichols 5a711afb7e fix: polyfill Buffer for browser compatibility (#112)
* Polyfill with "buffer" and "assert" for browser environments
* Instead of relying on webpack to make this library browser compatible, we now use a buffer library that provides a polyfill when used in the browser
2020-12-03 21:38:57 -06:00

31 lines
586 B
JavaScript

const fs = require("fs");
const { Buffer } = require('buffer/')
function hexOnly(hex) {
return hex.replace(/[^a-fA-F0-9]/g, "");
}
function unused() {}
function parseHexOnly(hex) {
return Buffer.from(hexOnly(hex), "hex");
}
function loadFixture(relativePath) {
const fn = __dirname + "/fixtures/" + relativePath;
return require(fn);
}
function loadFixtureText(relativePath) {
const fn = __dirname + "/fixtures/" + relativePath;
return fs.readFileSync(fn).toString("utf8");
}
module.exports = {
hexOnly,
parseHexOnly,
loadFixture,
loadFixtureText,
unused,
};