create a ram disk with node.js
var ramdisk = require('node-ramdisk')
return a ramdisk
object
var disk = ramdisk('my_ramdisk')
- size - {integer} the size of the volume in MB
- callback - {function}
- err - {Error} error message
- mount - {string} the mounted block, in case of error is undefined
- mount - {string} the mounted block
- callback {function}
- err - {Error} error message
- res - {string} return 'ok' in case of success, in case of error is undefined
Note: delete will eject the volume and remove the mount folder
var ramdisk = require('node-ramdisk')
var disk = ramdisk('my_ramdisk')
var volumePoint
// create a disk with 100MB of size
disk.create(100, function (err, mount) {
if (err) {
console.log(err)
} else {
volumePoint = mount
console.log(mount)
}
})
// when isn't needed then delete the disk
disk.delete(volumePoint, function (err) {
if (err) {
console.log(err)
} else {
console.log('ok')
}
})
DEBUG=node-ramdisk ...
- darwin (bad performance - is taking around 1 sec. to create the disk in my macbook pro mid 2012)
- linux (good performance - 20/30 mls to create the disk in a vagrant vm with few resources)
this projet has been set up with a precommit that forces you to follow a code style, no jshint issues and 100% of code coverage before commit
to run test
npm test
to run jshint
npm run jshint
to run code style
npm run code-style
to run check code coverage
npm run check-coverage
to open the code coverage report
npm run open-coverage