Skip to content

Instantly share code, notes, and snippets.

@nilfalse

nilfalse/README.md

Last active Mar 8, 2021
Embed
What would you like to do?
Running node-maxmind in browser
import { Buffer } from 'buffer';
import * as maxmind from 'maxmind';
export async function load() {
const response = await fetch('./data/GeoLite2-Country.mmdb');
const buf = Buffer.from(await response.arrayBuffer());
buf.utf8Slice = function (start, end) {
return this.toString('utf8', start, end);
};
return new maxmind.Reader(buf);
}
const path = require('path');
module.exports = {
node: {
net: 'empty',
},
module: {
rules: [
{
test: path.resolve(__dirname, './node_modules/maxmind/lib/fs.js'),
use: 'null-loader',
},
],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment