{"name":"sonic-boom","version":"0.6.0","description":"Extremely fast utf8 only stream implementation","main":"index.js","scripts":{"test":"standard | snazzy && tap test.js "},"repository":{"type":"git","url":"git+https://github.com/mcollina/sonic-boom.git"},"keywords":["stream","fs","net","fd","file","descriptor","fast"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/sonic-boom/issues"},"homepage":"https://github.com/mcollina/sonic-boom#readme","devDependencies":{"fastbench":"^1.0.1","pre-commit":"^1.2.2","snazzy":"^7.1.1","standard":"^11.0.0","tap":"^11.1.4"},"dependencies":{"flatstr":"^1.0.5"},"gitHead":"a2f80a7196fb0dcf6ff9242077a71cb40e88028a","_id":"sonic-boom@0.6.0","_npmVersion":"6.2.0","_nodeVersion":"8.11.3","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"integrity":"sha512-D97oommxLtlZtIHKSwt9z+DK8LwBkghKEQ6aZ1gFQruCvhydiMf9S/RrSkXzBIAJkC1U96fPxuvQL1IwTRhz9A==","shasum":"c1a6ef9444b0b83bcafeb48731e4b26254cca3d5","tarball":"http://registry-npm.ywwl.com/sonic-boom/download/sonic-boom-0.6.0.tgz","fileCount":9,"unpackedSize":16842,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbWIWTCRA9TVsSAnZWagAAWnIP/jcwxHB0rkbKSblSt8Xe\nt92eDOG5t3rEt5rSnmkVWAcPoZ1/YY+d6Fk/O6izT3+z9FbGj6j85aWgnbrV\nwEwefpWEj8oYqmEH8s2hydPr/Z631e3D2iAh850O1MN2bcSryF8EgNDVlAOh\nIPVKcnoXBafj7zVJDE7uAoXlx1aUGrXdUVZ4H9q+8VsVr/9LAYdmLHqDP2SS\nVUdJ5g0ant2oshKpSs2T1Q1K0YlrbThDWB3UcfFKezRyMBx68w39c1CAnwvX\nnzbBMXjU5BcQGX/kDZh/rAbJQ7fRjnBI3Kz0C01YBSdwJ/TQv94iLjAmyYEh\n04r1ROZeeQMbOjvjYll6lI4QuCrJEY8dv+3VnXJMJefDJJ6w9rUBer4nqG4T\nGohjcbFFVSyNig4b9Go6EJgZ3kS6zqBSnkDv/RvAOJfmCSmGGD5SYCdM3B6B\nB4e5tjChiE+KPHY+iM15BIFgtccSJN6WvRh6EDnSsS3V5stlL+eM6CGS0pXd\njdxo1gm7lhB4l2PYYjdVqBegyZROd0+5cqdm6gpCSQiapkCi+BTr3ZGvIVQC\nbOc45xyZZLFeaLlmfq+B1w9J5zNgiKYLq8UvFKC7y47W9Y1BEICur7Lqy5Jo\nxCxpoYZxdjk9QODbkIfTTyg5PiqrYr1m+uqvzDwgt6V0R3MB+aK6MIdHZS9w\nxOAv\r\n=N9C1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDvHd/5aABvpExTGTzH/7F7edIZuzKY31dAns2hEQpaGAiEAyE05N7ebflKsIfDg9ZAPPkKQMYeXHMglt1cqjiHB0so="}],"size":4538,"noattachment":false,"key":"/sonic-boom/-/sonic-boom-0.6.0.tgz"},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/sonic-boom_0.6.0_1532528019162_0.5613866190313344"},"_hasShrinkwrap":false,"readme":"# sonic-boom\n\n[![NPM Package Version](https://img.shields.io/npm/v/sonic-boom)](https://www.npmjs.com/package/sonic-boom)\n[![Build Status](https://github.com/pinojs/sonic-boom/workflows/CI/badge.svg)](https://github.com/pinojs/sonic-boom/actions?query=workflow%3ACI)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n\nExtremely fast utf8-only stream implementation to write to files and\nfile descriptors.\n\nThis implementation is partial, but support backpressure and `.pipe()` in is here.\nHowever, it is 2-3x faster than Node Core `fs.createWriteStream()`:\n\n```\nbenchSonic*1000: 1916.904ms\nbenchSonicSync*1000: 8605.265ms\nbenchSonic4k*1000: 1965.231ms\nbenchSonicSync4k*1000: 1588.224ms\nbenchCore*1000: 5851.959ms\nbenchConsole*1000: 7605.713ms\n```\n\nNote that sync mode without buffering is _slower_ than a Node Core WritableStream, however\nthis mode matches the expected behavior of `console.log()`.\n\nNote that if this is used to log to a windows terminal (`cmd.exe` or\npowershell), it is needed to run `chcp 65001` in the terminal to\ncorrectly display utf-8 characters, see\n[chcp](https://ss64.com/nt/chcp.html) for more details.\n\n## Install\n\n```\nnpm i sonic-boom\n```\n\n## Example\n\n```js\n'use strict'\n\nconst SonicBoom = require('sonic-boom')\nconst sonic = new SonicBoom({ fd: process.stdout.fd }) // or { dest: '/path/to/destination' }\n\nfor (let i = 0; i < 10; i++) {\n  sonic.write('hello sonic\\n')\n}\n```\n\n## API\n\n### SonicBoom(opts)\n\nCreates a new instance of SonicBoom.\n\nThe options are:\n\n* `fd`: a file descriptor, something that is returned by `fs.open` or\n   `fs.openSync`.\n* `dest`: a string that is a path to a file to be written to (mode controlled by the `append` option).\n* `minLength`: the minimum length of the internal buffer that is\n  required to be full before flushing.\n* `maxLength`: the maximum length of the internal buffer. If a write operation would cause the buffer\n  to exceed `maxLength`, the data written is dropped and a `drop` event is emitted with the dropped data\n* `maxWrite`: the maximum number of bytes that can be written; default: 16384\n* `sync`: perform writes synchronously (similar to `console.log`).\n* `fsync`: perform a [fsyncSync](https://nodejs.org/api/fs.html#fsfsyncsyncfd) every time a write is completed.\n* `append`: appends writes to dest file instead of truncating it (default `true`).\n* `mode`: specify the creating file `mode` (see [fs.open()](https://nodejs.org/api/fs.html#fsopenpath-flags-mode-callback) from Node.js core).\n* `mkdir`: ensure directory for dest file exists when `true` (default `false`).\n* `retryEAGAIN(err, writeBufferLen, remainingBufferLen)`: a function that will be called when sonic-boom\n    write/writeSync/flushSync encounters a EAGAIN or EBUSY error. If the return value is\n    true sonic-boom will retry the operation, otherwise it will bubble the\n    error. `err` is the error that caused this function to be called,\n    `writeBufferLen` is the length of the buffer sonic-boom tried to write, and\n    `remainingBufferLen` is the length of the remaining buffer sonic-boom didn't try to write.\n\nFor `sync:false`  a `SonicBoom` instance will emit the `'ready'` event when a file descriptor is available.\nFor `sync:true` this is not relevant because the `'ready'` event will be fired when the `SonicBoom` instance is created, before it can be subscribed to.\n\n\n### SonicBoom#write(string)\n\nWrites the string to the file.\nIt will return false to signal the producer to slow down.\n\n### SonicBoom#flush([cb])\n\nWrites the current buffer to the file if a write was not in progress.\nDo nothing if `minLength` is zero or if it is already writing.\n\ncall the callback when the flush operation is completed. when failed the callback is called with an error.\n\n### SonicBoom#reopen([file])\n\nReopen the file in place, useful for log rotation.\n\nExample:\n\n```js\nconst stream = new SonicBoom('./my.log')\nprocess.on('SIGUSR2', function () {\n  stream.reopen()\n})\n```\n\n### SonicBoom#flushSync()\n\nFlushes the buffered data synchronously. This is a costly operation.\n\n### SonicBoom#end()\n\nCloses the stream, the data will be flushed down asynchronously\n\n### SonicBoom#destroy()\n\nCloses the stream immediately, the data is not flushed.\n\n### Events\n\n\n#### SonicBoom#close\n\nSee [Stream#close](https://nodejs.org/api/stream.html#event-close). The `'close'` event when the instance has been closed.\n\n#### SonicBoom#drain\n\nSee [Stream#drain](https://nodejs.org/api/stream.html#event-drain). The `'drain'` event is emitted when source can resume sending data.\n\n#### SonicBoom#drop <any>\n\nWhen destination file maximal length is reached, the `'drop'` event is emitted with data that could not be written. \n\n#### SonicBoom#error <Error>\n\nThe `'error'` event is emitted when the destination file can not be opened, or written.\n\n#### SonicBoom#finish\n\nSee [Stream#finish](https://nodejs.org/api/stream.html#event-finish). The `'finish'` event after calling `end()` method and when all data was written.\n\n#### SonicBoom#ready\n\nThe `'ready'` event occurs when the created instance is ready to process input.\n\n#### SonicBoom#write <number>\n\nThe `'write'` event occurs every time data is written to the underlying file. It emits the number of written bytes.\n\n## License\n\nMIT\n","publish_time":1532528019275,"_cnpm_publish_time":1532528019275,"dist-tags":{"four":"2.4.2","latest":"5.0.2"}}