From 489b8ca195971196d07c4882337935ef8b8c9ed2 Mon Sep 17 00:00:00 2001 From: korya Date: Tue, 24 Oct 2023 15:53:01 -0400 Subject: [PATCH] Import buffer from npm modules explicitly (#10) The official docs (https://github.com/feross/buffer) suggest: > To depend on this module explicitly (without browserify), require it like > this: > var Buffer = require('buffer/').Buffer // note: the trailing slash is important! > To require this module explicitly, use require('buffer/') which tells the > node.js module lookup algorithm (also used by browserify) to use the npm > module named buffer instead of the node.js core module named buffer! --- tar-extractor.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tar-extractor.ts b/tar-extractor.ts index 8cfe9d0..a19996e 100644 --- a/tar-extractor.ts +++ b/tar-extractor.ts @@ -1,5 +1,12 @@ import RNFS from 'react-native-fs'; -import { Buffer } from 'buffer'; +// The official docs suggest to import it with a trailing slash: +// > To depend on this module explicitly (without browserify), require it like +// > this: +// > var Buffer = require('buffer/').Buffer // note: the trailing slash is important! +// > To require this module explicitly, use require('buffer/') which tells the +// > node.js module lookup algorithm (also used by browserify) to use the npm +// > module named buffer instead of the node.js core module named buffer! +import { Buffer } from 'buffer/'; type LogLevel = '' | 'debug' | 'trace';