{"metapak":{"configs":["main","readme","tsesm","jest","jsdocs","eslint","codeclimate","ghactions"],"data":{"files":"'src/**/*.ts'","testsFiles":"'src/**/*.tests.ts'","distFiles":"'dist/**/*.js'","ignore":["dist"],"bundleFiles":["dist","src"]}},"name":"streamfilter","version":"4.0.0","description":"Filtering streams.","main":"dist/index.js","scripts":{"build":"rimraf 'dist' && tsc --outDir dist","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md","cli":"env NODE_ENV=${NODE_ENV:-cli}","cover":"npm run jest -- --coverage","cz":"env NODE_ENV=${NODE_ENV:-cli} git cz","doc":"echo \"# API\" > API.md; jsdoc2md 'dist/**/*.js' >> API.md && git add API.md","format":"npm run prettier","jest":"NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest","lint":"eslint 'src/**/*.ts'","metapak":"metapak","precz":"npm t && npm run lint && npm run build && npm run doc && npm run metapak -- -s","prettier":"prettier --write 'src/**/*.ts'","preversion":"npm t && npm run lint && npm run build && npm run doc && npm run metapak -- -s","rebuild":"swc ./src -s -d dist -C jsc.target=es2022","test":"echo \"WARNING: No tests specified\" && npm run jest","type-check":"tsc --pretty --noEmit","version":"npm run changelog"},"repository":{"type":"git","url":"git+ssh://git@github.com/nfroidure/streamfilter.git"},"keywords":["assert","deepEqual","neat"],"author":{"name":"Nicolas Froidure","email":"nicolas.froidure@insertafter.com","url":"http://insertafter.com/en/index.html"},"license":"MIT","bugs":{"url":"https://github.com/nfroidure/streamfilter/issues"},"homepage":"https://github.com/nfroidure/streamfilter","devDependencies":{"@eslint/js":"^9.7.0","@swc/cli":"^0.4.0","@swc/core":"^1.6.13","@swc/helpers":"^0.5.12","@swc/jest":"^0.2.36","commitizen":"^4.3.0","conventional-changelog-cli":"^5.0.0","cz-conventional-changelog":"^3.3.0","eslint":"^9.7.0","eslint-config-prettier":"^9.1.0","eslint-plugin-jest":"^28.6.0","eslint-plugin-prettier":"^5.1.3","jest":"^29.7.0","jsdoc-to-markdown":"^8.0.0","metapak":"^6.0.1","metapak-nfroidure":"^18.2.0","prettier":"^3.3.3","rimraf":"^6.0.1","streamtest":"^3.0.0","typescript":"^5.5.3","typescript-eslint":"^7.16.0"},"engines":{"node":">=20.11.1"},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"contributors":[],"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"all","proseWrap":"always"},"greenkeeper":{"ignore":["commitizen","cz-conventional-changelog","conventional-changelog-cli","typescript","rimraf","@swc/cli","@swc/core","@swc/helpers","jest","@swc/jest","jsdoc-to-markdown","eslint","prettier","eslint-config-prettier","eslint-plugin-prettier","typescript-eslint"]},"overrides":{"eslint":"^9.7.0"},"type":"module","types":"dist/index.d.ts","jest":{"coverageReporters":["lcov"],"testPathIgnorePatterns":["/node_modules/"],"roots":["<rootDir>/src"],"transform":{"^.+\\.tsx?$":["@swc/jest",{}]},"testEnvironment":"node","moduleNameMapper":{"(.+)\\.js":"$1"},"extensionsToTreatAsEsm":[".ts"],"prettierPath":null},"dependencies":{"yerror":"^8.0.0"},"_id":"streamfilter@4.0.0","gitHead":"7921539bec0b7978252602be61b9ffc5bbf6be2a","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-tWRZu1Y+k/hn0K2BgXPQriIN5kM7HOW0qw8qyKXaO9my2XAgahRjVXrfqqoeBKfiepE9Y4jsTEHw79MkLK/J4w==","shasum":"03ed09587e9af23a43697d346bab08506435f1c2","tarball":"http://registry-npm.ywwl.com/streamfilter/download/streamfilter-4.0.0.tgz","fileCount":12,"unpackedSize":83437,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEHVYODel+5aLwxhVUtT2+CFv/R2wkuDbtVre8QJ7JALAiBtQDhefWdACYnyklWkEaOj+fyTKzpvzNXvkpXr1bjbgg=="}],"size":14658,"noattachment":false,"key":"/streamfilter/-/streamfilter-4.0.0.tgz"},"_npmUser":{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},"directories":{},"maintainers":[{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/streamfilter_4.0.0_1721212687246_0.23344884734340487"},"_hasShrinkwrap":false,"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# streamfilter\n> Filtering streams.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/streamfilter/blob/main/LICENSE)\n\n\n[//]: # (::contents:start)\n\n`streamfilter` is a function based filter for streams inspired per gulp-filter\nbut no limited to Gulp nor to objectMode streams.\n\n## Installation\n\nFirst, install `streamfilter` in your project:\n\n```sh\nnpm install --save streamfilter\n```\n\n## Getting started\n\nThere are 3 common usages:\n\n### Simple filter\n\n```js\nimport { StreamFilter } from 'streamfilter';\n\nconst filter = new StreamFilter((chunk, encoding, cb) => {\n  const mustBeFiltered = chunk.length() > 128;\n\n  if (mustBeFiltered) {\n    cb(true);\n    return;\n  }\n  cb(false);\n});\n\n// Print to stdout a filtered stdin\nprocess.stdin.pipe(filter).pipe(process.stdout);\n```\n\n### Filter and restore\n\n```js\nimport { filterStream } from 'streamfilter';\n\n// Here we use the functionnal help\nconst filter = new filterStream(\n  // Here we use an async callback instead\n  async (chunk, encoding) => {\n    const mustBeFiltered = chunk.length() > 128;\n\n    if (mustBeFiltered) {\n      return true;\n    }\n    return false;\n  },\n  {\n    restore: true,\n  },\n);\n\n// Print accepted chunks in stdout\nfilter.pipe(process.stdout);\n\n// Print filtered one to stderr\nfilter.restore.pipe(process.stderr);\n```\n\n### Filter and restore as a passthrough stream\n\nLet's reach total hype!\n\n```js\nimport { StreamFilter } from 'streamfilter';\nimport { Transform } from 'stream';\n\n// Filter values\nconst filter = new StreamFilter(\n  (chunk, encoding, cb) => {\n    const mustBeFiltered = chunk.length() > 128;\n    if (mustBeFiltered) {\n      cb(true);\n      return;\n    }\n    cb(false);\n  },\n  {\n    restore: true,\n    passthrough: true,\n  },\n);\n\n// Uppercase strings\nconst mySuperTransformStream = new Transform({\n  transform: (chunk, encoding, cb) =>\n    cb(null, Buffer.from(chunk.toString(encoding).toUpperCase(), encoding)),\n});\n\n// Pipe stdin\nprocess.stdin\n  .pipe(filter)\n  // Edit kept chunks\n  .pipe(mySuperTransformStream)\n  // Restore filtered chunks\n  .pipe(filter.restore)\n  // and output!\n  .pipe(process.stdout);\n```\n\nNote that in this case, this is _your_ responsibility to end the restore stream\nby piping in another stream or ending it manually.\n\n[//]: # (::contents:end)\n\n# API\n## Classes\n\n<dl>\n<dt><a href=\"#StreamFilter\">StreamFilter</a></dt>\n<dd><p>Filter piped in streams according to the given <code>filterCallback</code>.</p>\n</dd>\n</dl>\n\n## Functions\n\n<dl>\n<dt><a href=\"#filterStream\">filterStream(filterCallback, options)</a> ⇒</dt>\n<dd><p>Utility function if you prefer a functional way of using this lib</p>\n</dd>\n</dl>\n\n<a name=\"StreamFilter\"></a>\n\n## StreamFilter\nFilter piped in streams according to the given `filterCallback`.\n\n**Kind**: global class  \n<a name=\"new_StreamFilter_new\"></a>\n\n### new StreamFilter(filterCallback, options)\nOptions are passed in as is in the various stream instances spawned by this\n module. So, to use the objectMode, simply pass in the `options.objectMode`\n value set to `true`.\n\n**Returns**: [<code>StreamFilter</code>](#StreamFilter) - The filtering stream  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| filterCallback | <code>function</code> | Callback applying the filters |\n| options | <code>Object</code> | Filtering options |\n| options.passthrough | <code>boolean</code> | Set to `true`, this option changes the restore stream nature from a readable  stream to a passthrough one, allowing you to reuse the filtered chunks in an  existing pipeline. |\n| options.restore | <code>boolean</code> | Set to `true`, this option create a readable stream allowing you to use the  filtered chunks elsewhere. The restore stream is exposed in the `FilterStream`  instance as a `restore` named property. |\n\n<a name=\"filterStream\"></a>\n\n## filterStream(filterCallback, options) ⇒\nUtility function if you prefer a functional way of using this lib\n\n**Kind**: global function  \n**Returns**: Stream  \n\n| Param |\n| --- |\n| filterCallback | \n| options | \n\n\n# Authors\n- [Nicolas Froidure](http://insertafter.com/en/index.html)\n\n# License\n[MIT](https://github.com/nfroidure/streamfilter/blob/main/LICENSE)\n","publish_time":1721212687436,"_cnpm_publish_time":1721212687436,"dist-tags":{"latest":"4.0.0"}}