{"_id":"rw-stream","_rev":"243482","name":"rw-stream","description":"A simple stream that allows reading and writing to the same file at the same time.\u001b[H\u001b[C\u001b[F","dist-tags":{"latest":"0.3.3"},"maintainers":[{"name":"michalcz","email":"cz@signicode.com"}],"time":{"modified":"2024-06-15T23:40:25.000Z","created":"2018-11-05T18:44:45.502Z","0.3.3":"2019-07-22T17:59:53.625Z","0.3.2":"2019-06-28T12:53:53.382Z","0.3.1":"2019-06-12T17:00:39.255Z","0.3.0":"2018-11-05T18:44:45.502Z"},"users":{},"author":{"name":"Signicode","email":"open-source@signicode.com"},"repository":{"type":"git","url":"git+https://github.com/signicode/rw-stream.git"},"versions":{"0.3.3":{"name":"rw-stream","version":"0.3.3","description":"A simple stream that allows reading and writing to the same file at the same time.\u001b[H\u001b[C\u001b[F","main":"index.js","scripts":{"test":"node test"},"author":{"name":"Signicode","email":"open-source@signicode.com"},"license":"MIT","homepage":"https://github.com/signicode/rw-stream","repository":{"type":"git","url":"git+https://github.com/signicode/rw-stream.git"},"engines":{"node":">=8.6.0"},"keywords":["stream","streams","async","await","transform","replace","fs","write","pipe"],"devDependencies":{"eslint":"^6.1.0","eslint-config-scramjet":"^2.0.0","scramjet":"^4.25.5"},"dependencies":{},"_resolved":"","_integrity":"","_from":"https://github.com/signicode/rw-stream/archive/v0.3.3.tar.gz","bugs":{"url":"https://github.com/signicode/rw-stream/issues"},"_id":"rw-stream@0.3.3","_nodeVersion":"12.4.0","_npmVersion":"6.10.1","dist":{"integrity":"sha512-bxfGiEmsCS7/dbJyVbh7kZw7JIftWCCVsFdJJeDmLxnH73sZ8gAeH87FuDIqxW8lDFIJc6lPUmgHZROy8N0chQ==","shasum":"2403819737fec3a50a668b3aa33c59dc5c6c0c05","tarball":"http://registry-npm.ywwl.com/rw-stream/download/rw-stream-0.3.3.tgz","fileCount":19,"unpackedSize":1079704,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdNfmaCRA9TVsSAnZWagAAz50QAKL8/iemX5nkL2cLgcfp\nQiFVmm+ofazlKS+fyuyhm3Z0fPB7TSc5pW9eNLro/qHFhzozlddW+5ysJ849\nSKdwu3yfkKz+MLOZ4etbSgOCOroEfDq92NmtaFo5r9D+uytFPV3oasb61oTo\nH8o3sAtd+RsZMOieWU1isZA/5ICB4SBX8eWiZOxGx6f0EYmOyJXYLEUwz+0Q\niXObqHToe7a/Ih7tId8tQ4uEJFdhcjlh3Z0yr8PZJrV5aVgPuPFyW1bgDCKq\nUW5pTAGyhEBWlRv2otgwl03V3+ONGy7ZMUaO898+hcbOj9Rmy1apxwgAVstf\n4Sojdhd3Knyiz897Qh/RKp8xSYpPCDCzSq77YOwPIGdMUvZLPkif33ts2UdI\nHr9AQsEgrwKln+m6bQVoUv3k8Ir3Esw/iKnj/Jaujvbz9P9njEo6mjjOI6Q9\nP/de9OPfy4A+XFWjAKVSyhv4tKMyutEBsJEGxgcxf6pil47SKBMlbp55W44M\nMWkOsmanuPCO4+MN45eApCf7AxsrfyCZdjCCoZL3nggOz4LChsCp+p/+eedA\nO459iPC3FlU503xmuuNYgTAES0uA4n8d/0GNuBQGwueSi6oalZGJaw70Jo0A\n3/UzAdhKCqDpP4TOTk/uHvThhCEGyDhPvAHkX6kEA1m0zJeqhKf7HUl17Li6\nFLNO\r\n=FL+N\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDVK3k2ybL3BRDT+H97LqhN0zgLaKiNnioKb0sBBVTwUwIgN/cKH7tWoYemCx+X7j+PxJxLH5Ijhlp6Ayrlcj43CTM="}],"size":28938,"noattachment":false,"key":"/rw-stream/-/rw-stream-0.3.3.tgz"},"maintainers":[{"name":"michalcz","email":"cz@signicode.com"}],"_npmUser":{"name":"michalcz","email":"cz@signicode.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rw-stream_0.3.3_1563818393507_0.672873957533697"},"_hasShrinkwrap":false,"publish_time":1563818393625,"_cnpm_publish_time":1563818393625},"0.3.2":{"name":"rw-stream","version":"0.3.2","description":"A simple stream that allows reading and writing to the same file at the same time.\u001b[H\u001b[C\u001b[F","main":"index.js","scripts":{"test":"node test"},"author":{"name":"Signicode","email":"open-source@signicode.com"},"license":"MIT","homepage":"https://github.com/signicode/rw-stream","repository":{"type":"git","url":"git+https://github.com/signicode/rw-stream.git"},"engines":{"node":">=8.6.0"},"keywords":["stream","streams","async","await","transform","replace","fs","write","pipe"],"devDependencies":{"eslint":"^6.0.1","eslint-config-scramjet":"^2.0.0","scramjet":"^4.25.2"},"dependencies":{},"_resolved":"","_integrity":"","_from":"https://github.com/signicode/rw-stream/archive/v0.3.2.tar.gz","bugs":{"url":"https://github.com/signicode/rw-stream/issues"},"_id":"rw-stream@0.3.2","_nodeVersion":"12.4.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-z445mryinFKE8wlVnKwAMt5yqhs0AfexJ/zCNNxZmKRtWb8ybOOaXnzh4JutRaraOF6GpAben7X7DvMOCLLgWQ==","shasum":"02ff5b0853b5b7524efd0c205294184c45f47aa6","tarball":"http://registry-npm.ywwl.com/rw-stream/download/rw-stream-0.3.2.tgz","fileCount":19,"unpackedSize":1080742,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdFg3hCRA9TVsSAnZWagAABi8P/R3ztLGBysv6jJ2R6iHT\nujMPd9iqD/KKgoJhY8lKw9SDFmuo0vVe62626ba1+1XB+N/VWNczyDu+FzAy\n8hOrug8SZnINV0Pasvm2/YP07sZfrHnGuyxnO2E8bpLMW7YF/LQoscSxmibr\nz39vU39Z5T0H4pJHmL4XXeJlK3N3yqWQQNqZm2guDnfJkycj9a/8Msk8HaaQ\nCUk1q1JosN1+lGPwW6UPQnc+HqYrMiBWPU6+/SeZYLPA9Ny4IDy6wyj9oxzg\nMjknuS+MuvBVXlxS+E8Rm701UwTbEPV8JIZp2SyrWeYcyQpYxOC577W6FObU\n4NdaboLlg4jgTtxdeQAJq864AyuSBXA79gRIXnJRhHAnVVrGVvPom/HSD399\n/O+s0BCAJ7g34NWKX9uMhLZ5YdFFGNH+rIk2MfbROyhng2QTKHv70ti5pjx7\nPilka7WiSq0pDNFYuCxor34p110AKgevd0duYtZ4UxQ3tGDqGYyTd97baK4A\nSjj88Yq6Hv98REtVLwAGYzBc9a6XkOW9MZj0oG6esppmcwqEmOAbsRfxMNV9\nhblu8qLnkNZ69YZyP6NHEgZYq4pNbL2OcDzE5dZwd9iSixW3zrpFHB9sIIMk\n4uQR6cd8esINA4q/3k/GrkBpBkq2PLRU3CODdXADLYBqglBh70RFd8+oV/yt\nhoci\r\n=ETmC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC+O8hA3r3ZrEuLQ+dDAV4t6OsDAMA8JnBjEld7iuH8dgIgHjK27qmWk0e9LN682UVaxVN6zP1XlMFsgL9fVBa1m7g="}],"size":28804,"noattachment":false,"key":"/rw-stream/-/rw-stream-0.3.2.tgz"},"maintainers":[{"name":"michalcz","email":"cz@signicode.com"}],"_npmUser":{"name":"michalcz","email":"cz@signicode.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rw-stream_0.3.2_1561726433242_0.21887002764823404"},"_hasShrinkwrap":false,"publish_time":1561726433382,"_cnpm_publish_time":1561726433382},"0.3.1":{"name":"rw-stream","version":"0.3.1","description":"A simple stream that allows reading and writing to the same file at the same time.\u001b[H\u001b[C\u001b[F","main":"index.js","scripts":{"test":"node test"},"author":{"name":"Signicode","email":"open-source@signicode.com"},"license":"MIT","homepage":"https://github.com/signicode/rw-stream","repository":{"type":"git","url":"git+https://github.com/signicode/rw-stream.git"},"engines":{"node":">=8.6.0"},"keywords":["stream","streams","async","await","transform","replace","fs","write","pipe"],"devDependencies":{"eslint":"^5.16.0","eslint-plugin-node":"^9.1.0","scramjet":"^4.25.1"},"dependencies":{},"_resolved":"","_integrity":"","_from":"https://github.com/signicode/rw-stream/archive/v0.3.1.tar.gz","bugs":{"url":"https://github.com/signicode/rw-stream/issues"},"_id":"rw-stream@0.3.1","_nodeVersion":"12.4.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-yRrLkuJ3PeQYw1gJ2U9Wn9htgwTeYbLUSoeTNwJ4odOTwaM4EMTG4gKdkRTYa6qCsAWxHmJcjjguV4BR78z+8A==","shasum":"e1967799e68018db4988c213fb8a1bf59f6f06a7","tarball":"http://registry-npm.ywwl.com/rw-stream/download/rw-stream-0.3.1.tgz","fileCount":19,"unpackedSize":1079436,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdAS+3CRA9TVsSAnZWagAAJ8UQAIhXY1hScfZz1379g0b8\n9E+bdwDJ1OEFUrPWytOGK9GPD9YIwwjdmXp1aVVbQF05fJQMn/gIX7zBsIis\nNaqtew+S14S0+GH1MQWSD43K5qfvsJSJZdfF1swCryiQMIqk/sl+zdkF4FVe\nHFhhXfAEkqyOT6ccWsOvKVpOlGZlqAWh1ZhzX4szaO577N8VyT8KPo3PNJ8B\n2iHdEwQjC6gyj2yChoQ6KzfC2L1oMdGaAffC7gsFmalqexjt1adal6MJSdn5\n9HXt3ufJfy+uPE9iANMZi+okkWX+WZbNEC4XqosV6w2yR8oBOv92OmvtQ0kD\nJqD6Xfz37xA3K5u5yIb6NQ97gbmT3cEpTfG1ybymNP652sK2/sHmchqnNVsy\neANK0wBHlXMkMxl7WL1vvKIbCyYDpfA4Ljc7WwKGpSwK0Fu3FZF9+6TIbloE\nGBES3QK1eUn0tHs27wWM/HJ6q4I1soCECEKIg8/axesvqAJVDtQ22yvgrwbU\nqlqnJsLl7dAG6Kb1LT95d37v6g2K/IEX0p1yyuM8Uo1B0mADHs8eJIqrQAEV\nwwz3M/AOGTt2E9Ba2Djhk1c7vIi9cueIS7A7zR1Rce9FAUYMhgKaeqppVdeG\nAgYRpTqHYS/CByKeTq34qxQJk+VVZpqn1IUM5sV3J2CvUiqCZT+jkZEJ0g4F\nivQt\r\n=UxdI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIA4jrZsfuHwrvmowEH+68+kzWXTAd0I39W7wQhLBy5sYAiEAuftAFFQXuol1K3MsGbRl0efcM+DSz5KDuv/k8kIa5kI="}],"size":28457,"noattachment":false,"key":"/rw-stream/-/rw-stream-0.3.1.tgz"},"maintainers":[{"name":"michalcz","email":"cz@signicode.com"}],"_npmUser":{"name":"michalcz","email":"cz@signicode.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rw-stream_0.3.1_1560358839098_0.36863297593359"},"_hasShrinkwrap":false,"publish_time":1560358839255,"_cnpm_publish_time":1560358839255},"0.3.0":{"name":"rw-stream","version":"0.3.0","description":"A simple stream that allows reading and writing to the same file at the same time.\u001b[H\u001b[C\u001b[F","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Signicode","email":"open-source@signicode.com"},"license":"MIT","homepage":"https://github.com/signicode/rw-stream","repository":{"type":"git","url":"git+https://github.com/signicode/rw-stream.git"},"engines":{"node":">=8.6.0"},"keywords":["stream","streams","async","await","transform","replace","fs","write","pipe"],"devDependencies":{"eslint":"^5.6.1","eslint-plugin-node":"^7.0.1","scramjet":"^4.18.14"},"dependencies":{},"_resolved":"","_integrity":"","_from":"https://github.com/signicode/rw-stream/archive/v0.3.0.tar.gz","bugs":{"url":"https://github.com/signicode/rw-stream/issues"},"_id":"rw-stream@0.3.0","_npmVersion":"6.4.1","_nodeVersion":"10.11.0","_npmUser":{"name":"michalcz","email":"cz@signicode.com"},"dist":{"integrity":"sha512-l9Biu1dKNjBdL8WS/lRjWLqET4TpOGTWaMYUoqHAa//2lBqiUnjfdV9whRqqbFGEdDBpcrmKWmpCmlLMsu4T9Q==","shasum":"36fc3036d587f5d14cead583b33ed799e6c88afd","tarball":"http://registry-npm.ywwl.com/rw-stream/download/rw-stream-0.3.0.tgz","fileCount":13,"unpackedSize":1077547,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb4I+eCRA9TVsSAnZWagAAzAUP/1p9PM0wIUwMz6N/VEsN\nXyjgipY/Jze50kQLqYIcB4Fh3pNRPmSsCZ8U+bUNPN42pLyjRKaFT1tQM43d\nQFGJE6xUCRpa2n5G2LXrtF4vgNpGlUcG6+mLbiSFoiEWaSjSJAUolvBcbhGd\nswGIVSndQfuCIbfF60inl7rE4dMurdFuBRiP1qUOm9tfsm5G6foHYNtFhqTE\nfWhzi1U7p5jtionJVNp3r2zqBcNVYB0pMW2b1rSu9kpVP8KUotAGqyOx1uYd\nEWmsuQqVoT3FtyytNYGQ4o0WpKl+ef3/YoZy/0yz4sCl0RNZ2kmwa0ueYIWO\nqWtHX+fG267iZDMoOJ5rlRzj9CYElaHDR6HDUbFSZB8uSA1vmYER1DVhiYI7\nWUOZm2CjuL/+2hin3/DvMh690rER1robMXQSvncimWNtkMBNSXwuEz3ye+L4\nMFUofc0wxqGXexaVV3pnIOeHm5IB4HTRvCkoHQu4H/TehFGltto1Z0qYQKmW\n2SLn9oVbsGHE2d9Vt0bk+C7ptn/Q3jcoiWRkrbU0KdBEQncLW8Ddd3zkHapb\n0jPrWYozJV9MICAITVIC+zBw4DRzt5D/D/UUB76RfqoaWRxEiHYeVLizgOJJ\nAEbbhk8sa9OX7mwPN5egsOnTy5w2rREQLOp2SX38nFJLGQIdxbb8Lf3Fvd+G\nkYpQ\r\n=o02v\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVKeXIxG6/YHUdRQUOobumlmKIccPFQJxMNCYh2tTMGQIhAJ85T8jkXTVoXJbe+Y8UcuGNCTxOuqVMB5W8y3fy8nfF"}],"size":27277,"noattachment":false,"key":"/rw-stream/-/rw-stream-0.3.0.tgz"},"maintainers":[{"name":"michalcz","email":"cz@signicode.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rw-stream_0.3.0_1541443485400_0.9014014891697635"},"_hasShrinkwrap":false,"publish_time":1541443485502,"_cnpm_publish_time":1541443485502}},"readme":"# rw-stream\n\nA stream that can substitute contents of a file in streaming fashion.\n\nThe aim of this module is to expose a readable and writable stream connected to a single file at the same time. It works similarily to `fs.createReadStream` and `fs.createWriteStream`, but allows writing and reading simultanously, without creating a new file or move operations.\n\nThis is achieved by disallowing any write operations to advance further than the current reading index. This module will then make sure that a byte of the file will be read before it's overwritten.\n\n***Note:*** In any case, the file will be accessed and it's contents may be overwritten even if there's no actual read operation done (due to node.js streams buffering mechanisms).\n\n## Usage:\n\n```javascript\nconst rw = require(\"../\");\n\nconst {fd, readStream, writeStream} = await rw(path, options);\n```\n\nArguments:\n\n * **path** `string` - the path of the file to access.\n * **options** `object` - options, currently none.\n\nReturns an `object` with the following properties:\n\n * **fd** `int` - file descriptor number (from `fs.open`)\n * **writeStream** `Writable` - Writable stream for new file contents.\n * **readStream** `Readable` - Readable stream containing previous contents.\n\n## Samples\n\nA simple module that replaces the contents of a file while keeping a backup:\n\n```javascript\nconst replaceAndBackup = async (newContentStream) => {\n    const {readStream, writeStream} = await rw(path);\n\n    readStream.pipe(fs.createWriteStream(`${path}.bak`));\n    newContentStream.pipe(writeStream);\n\n    return new Promise((res, rej) => writeStream.on('finish', res).on('error', rej));\n}\n```\n\n## Testing\n\nFor now there's just:\n\n```bash\n$ node test\n```\n\nTwo tests will be executed:\n\n* one for file that's being grown.\n* one for file that's being shrinked.\n\nWe're working on more and proper tests.\n","_attachments":{},"homepage":"https://github.com/signicode/rw-stream","bugs":{"url":"https://github.com/signicode/rw-stream/issues"},"license":"MIT"}