Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add minimal node example to Readme #33

Open
ocramz opened this issue Nov 5, 2022 · 0 comments
Open

Add minimal node example to Readme #33

ocramz opened this issue Nov 5, 2022 · 0 comments

Comments

@ocramz
Copy link

ocramz commented Nov 5, 2022

Hi, thank you for maintaining this! I've just used it successfully for building a data labeling webapp, where the datasets are 100s of MB each.

I've cobbled this together from a stackoverflow answer (https://stackoverflow.com/questions/23747892/how-would-i-design-and-implement-a-non-blocking-memory-mapping-module-for-node-j), and perhaps others would enjoy something like as a starter example in the README too

var mmap = require('mmap-io')
var fs = require('fs')

fs.open('/file/path', 'r', (err, fd) => {
            fs.fstat(fd, (err, stats) => {
                var buf = mmap.map(stats.size, mmap.PROT_READ, mmap.MAP_SHARED, fd, 0);
                const start = 0;
                const len = 100;
                var line = buf.slice(start, len).toString();
                ...
            })
        })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant