{"_id":"@amilajack/random-access-file","_rev":"1-4e4690c5f54ae228b53d4be13949c3de","name":"@amilajack/random-access-file","dist-tags":{"latest":"2.0.1"},"versions":{"2.0.1":{"name":"@amilajack/random-access-file","version":"2.0.1","description":"Continuous reading or writing to a file using random offsets and lengths","main":"index.js","scripts":{"test":"standard && tape test.js"},"dependencies":{"mkdirp":"^0.5.1","random-access-storage":"^1.1.1"},"devDependencies":{"standard":"^10.0.3","tape":"^4.8.0"},"repository":{"type":"git","url":"git+https://github.com/random-access-storage/random-access-file.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/random-access-storage/random-access-file/issues"},"homepage":"https://github.com/random-access-storage/random-access-file","gitHead":"9013b20710e97a41574b5037aafd494c861141c9","_id":"@amilajack/random-access-file@2.0.1","_npmVersion":"5.6.0","_nodeVersion":"8.11.4","_npmUser":{"name":"amilajack","email":"amilajack@gmail.com"},"dist":{"integrity":"sha512-vxfoYlR8/2IU2E7/ino6t714trGlr8SyiwTi8+Pj56czXBymMqxPQdsBMZDE2qpYG9XIr+ZhR2/Enkl/oooGrg==","shasum":"74f08aeb9af04635fdf2592b1184f48d168732de","tarball":"https://registry.npmjs.org/@amilajack/random-access-file/-/random-access-file-2.0.1.tgz","fileCount":7,"unpackedSize":57110,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbjHNNCRA9TVsSAnZWagAAc7YP/2k4tqM+bcPogJfGByxT\nx5EnO0QJS067fU6M0CdChhM95PsXlZ/FjeMIEcE2nvaJ6I38KSm7KyV3pcdr\nPy94g/Y09MfnWxcLUyZTZFnI+emmmK++f0dhqoiFw0R5ibdpKnJFoI57uyZ2\nifi/t2QwqoUNVFRPGPcelJCoHnAbq6uKE76cRyUQzBHoQ9SKnRKm6JbhQPVR\n8mhXwjyHC+VOW1oaUf+kq3lQUdUQyQJf6TmsNmZnM+x9x3iMR31Q+paNplZE\n0oV3DwEUk19BCtwyodanP4woBWKtFTC8Q0EYK0OBuOdgUg1+DxDCEhdxUyfW\nlx0jWFGxN4sm2sgnd/hl8Scff+QT1WwPagzZCNxe3OWwsfmycQ3EnOwhLyhz\ntAxivhBBU3D5IwEmxqc3cJcwvay0P1/0Ym8zbgF6ysfXhNVIvjsOiiQy1eiG\nK+WwAjssW9/DY+CRpv3cveP7WAgIdneLUqf3Yjyn9XLvpq+a+UN7pUuj3mku\nCSP7PZ6dxDvd68KrqUu2l2l6EHmdYm5cJjaPlLvciBzqeHWHIpQ1Xk1mQWvU\nhfHDA0RD7bgETzVlWBk67aAvFE+QraJUbpV9Kzd072IxAmadXrFM9/mG4Ia+\nfe6LS1vYbPRJg7Yx1O+1ayMEF1bAzFGLxu3Bo4KJ+vEOERPWBsEThmiWmU1a\n/LcO\r\n=R3IU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBm6TtbFxJ7lbBrKdPjVnNcBxLCZWvd6Xy/z0KZq7JRtAiEA2CpePU8X7AYg84+kHszNDuhIIhUT4nesr1F0G2vpE4M="}]},"maintainers":[{"name":"amilajack","email":"amilajack@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/random-access-file_2.0.1_1535931212904_0.6182751471718622"},"_hasShrinkwrap":false}},"time":{"created":"2018-09-02T23:33:32.748Z","2.0.1":"2018-09-02T23:33:33.050Z","modified":"2022-04-04T13:48:47.457Z"},"maintainers":[{"name":"amilajack","email":"amilajack@gmail.com"}],"description":"Continuous reading or writing to a file using random offsets and lengths","homepage":"https://github.com/random-access-storage/random-access-file","repository":{"type":"git","url":"git+https://github.com/random-access-storage/random-access-file.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"bugs":{"url":"https://github.com/random-access-storage/random-access-file/issues"},"license":"MIT","readme":"# random-access-file\n\nContinuous reading or writing to a file using random offsets and lengths\n\n```\nnpm install random-access-file\n```\n\n[![build status](https://travis-ci.org/random-access-storage/random-access-file.svg?branch=master)](https://travis-ci.org/random-access-storage/random-access-file)\n\n## Why?\n\nIf you are receiving a file in multiple pieces in a distributed system it can be useful to write these pieces to disk one by one in various places throughout the file without having to open and close a file descriptor all the time.\n\nrandom-access-file allows you to do just this.\n\n## Usage\n\n``` js\nvar randomAccessFile = require('random-access-file')\n\nvar file = randomAccessFile('my-file.txt')\n\nfile.write(10, Buffer.from('hello'), function(err) {\n  // write a buffer to offset 10\n  file.read(10, 5, function(err, buffer) {\n    console.log(buffer) // read 5 bytes from offset 10\n    file.close(function() {\n      console.log('file is closed')\n    })\n  })\n})\n```\n\nfile will use an open file descriptor. When you are done with the file you should call `file.close()`.\n\n## API\n\n#### `var file = randomAccessFile(filename, [options])`\n\nCreate a new file. Options include:\n\n``` js\n{\n  truncate: false, // truncate the file before reading / writing\n  size: someSize, // truncate the file to this size first\n  readable: true, // should the file be opened as readable?\n  writable: true  // should the file be opened as writable?\n}\n```\n\n#### `file.write(offset, buffer, [callback])`\n\nWrite a buffer at a specific offset.\n\n#### `file.read(offset, length, callback)`\n\nRead a buffer at a specific offset. Callback is called with the buffer read.\n\n#### `file.del(offset, length, callback)`\n\nWill truncate the file if offset + length is larger than the current file length.\nIs otherwise a noop.\n\n#### `file.close([callback])`\n\nClose the underlying file descriptor.\n\n#### `file.destroy([callback])`\n\nUnlink the underlying file.\n\n#### `file.on('open')`\n\nEmitted when the file descriptor has been opened. You can access the fd using `file.fd`.\nYou do not need to wait for this event before doing any reads/writes.\n\n#### `file.on('close')`\n\nEmitted when the file has been closed.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}