@odms/streamutils
Advanced tools
Comparing version 0.1.5 to 0.2.0
@@ -15,3 +15,8 @@ /// <reference types="node" /> | ||
fetch: () => Transform; | ||
/** | ||
* Transform the input stream items of type `Response` using `.json()`. | ||
* | ||
*/ | ||
json: () => Transform; | ||
}; | ||
//# sourceMappingURL=http.d.ts.map |
@@ -26,2 +26,5 @@ import { Transform } from "node:stream"; | ||
}); | ||
if (!response.ok) { | ||
throw `${response.url} ${response.status} ${response.statusText}`; | ||
} | ||
} | ||
@@ -34,2 +37,12 @@ catch (err) { | ||
}), | ||
/** | ||
* Transform the input stream items of type `Response` using `.json()`. | ||
* | ||
*/ | ||
json: () => new Transform({ | ||
objectMode: true, | ||
async transform(response, _, callback) { | ||
callback(null, await response.json()); | ||
}, | ||
}), | ||
}; |
export * from "./http"; | ||
export * from "./jq"; | ||
export * from "./json"; | ||
export * from "./limit"; | ||
export * from "./props"; | ||
export * from "./split"; | ||
export * from "./text"; | ||
export * from "./throttle"; | ||
export * from "./toString"; | ||
//# sourceMappingURL=index.d.ts.map |
export * from "./http"; | ||
export * from "./jq"; | ||
export * from "./json"; | ||
export * from "./limit"; | ||
export * from "./props"; | ||
export * from "./split"; | ||
export * from "./text"; | ||
export * from "./throttle"; | ||
export * from "./toString"; |
{ | ||
"name": "@odms/streamutils", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"author": "Jakob Hohlfeld <jakob.hohlfeld@netronaut.de>", | ||
@@ -33,3 +33,4 @@ "repository": { | ||
"test": "bun test src", | ||
"test:coverage": "bun run test --coverage" | ||
"test:coverage": "bun run test --coverage", | ||
"postinstall": "bunx patch-package" | ||
}, | ||
@@ -43,3 +44,6 @@ "devDependencies": { | ||
"typescript": "^5.4.5" | ||
}, | ||
"dependencies": { | ||
"node-jq": "^4.3.1" | ||
} | ||
} |
![Bun Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fopen-dms%2Fodms-streamutils%2Fmain%2Fpackage.json&query=%24.engines.bun&logo=bun&logoColor=%23f9f1e1&label=Bun&color=%23f9f1e1) | ||
![Typescript Badge](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fopen-dms%2Fodms-streamutils%2Fmain%2Fpackage.json&query=%24.devDependencies.typescript&label=Typescript) | ||
![CodeQL](https://github.com/open-dms/odms-streamutils/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main) | ||
![Coverage](https://open-dms.github.io/odms-streamutils/coverage.svg) | ||
@@ -73,4 +74,25 @@ | ||
# Documentation | ||
## jq | ||
Transform the stream using `jq`. | ||
```ts | ||
import { jq } from "@odms/streamutils"; | ||
pipeline(process.stdin, jq(".filter[].items"), process.out); | ||
``` | ||
Thanks to [node-js](https://www.npmjs.com/package/node-jq). For filter syntax, refer to the [jq manual](https://jqlang.github.io/jq/). | ||
**Parameters** | ||
- filter: string | ||
filter used to work on the json | ||
example: `.data[] | {id,name}` | ||
--- | ||
<center>Proudly developing with <a href="https://bun.sh/"><img alt="Bun typescript runtime" src="https://bun.sh/logo-square.png" height="24px" style="vertical-align: bottom;" /> Bun</a></center> |
@@ -30,2 +30,5 @@ import { Transform } from "node:stream"; | ||
}); | ||
if (!response.ok) { | ||
throw `${response.url} ${response.status} ${response.statusText}`; | ||
} | ||
} catch (err) { | ||
@@ -38,2 +41,14 @@ error = err instanceof Error ? err : new Error(String(err)); | ||
}), | ||
/** | ||
* Transform the input stream items of type `Response` using `.json()`. | ||
* | ||
*/ | ||
json: () => | ||
new Transform({ | ||
objectMode: true, | ||
async transform(response, _, callback) { | ||
callback(null, await response.json()); | ||
}, | ||
}), | ||
}; |
export * from "./http"; | ||
export * from "./jq"; | ||
export * from "./json"; | ||
export * from "./limit"; | ||
export * from "./props"; | ||
export * from "./split"; | ||
export * from "./text"; | ||
export * from "./throttle"; | ||
export * from "./toString"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30966
43
780
98
1
1
+ Addednode-jq@^4.3.1
+ Added@hapi/hoek@9.3.0(transitive)
+ Added@hapi/topo@5.1.0(transitive)
+ Added@sideway/address@4.1.5(transitive)
+ Added@sideway/formula@3.0.1(transitive)
+ Added@sideway/pinpoint@2.0.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbin-build@3.0.0(transitive)
+ Addedbl@1.2.3(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-alloc@1.2.0(transitive)
+ Addedbuffer-alloc-unsafe@1.1.0(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedbuffer-fill@1.0.0(transitive)
+ Addedcaw@2.0.1(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedconfig-chain@1.1.13(transitive)
+ Addedcontent-disposition@0.5.4(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedcross-spawn@5.1.0(transitive)
+ Addeddecompress@4.2.1(transitive)
+ Addeddecompress-response@3.3.0(transitive)
+ Addeddecompress-tar@4.1.1(transitive)
+ Addeddecompress-tarbz2@4.1.1(transitive)
+ Addeddecompress-targz@4.1.1(transitive)
+ Addeddecompress-unzip@4.0.1(transitive)
+ Addeddownload@6.2.5(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexeca@0.7.0(transitive)
+ Addedext-list@2.2.2(transitive)
+ Addedext-name@5.0.0(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedfile-type@3.9.05.2.06.2.0(transitive)
+ Addedfilename-reserved-regex@2.0.0(transitive)
+ Addedfilenamify@2.1.0(transitive)
+ Addedfs-constants@1.0.0(transitive)
+ Addedget-proxy@2.1.0(transitive)
+ Addedget-stream@2.3.13.0.0(transitive)
+ Addedgot@7.1.0(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-symbol-support-x@1.4.2(transitive)
+ Addedhas-to-string-tag-x@1.4.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedini@1.3.8(transitive)
+ Addedis-extglob@1.0.0(transitive)
+ Addedis-glob@2.0.1(transitive)
+ Addedis-invalid-path@0.1.0(transitive)
+ Addedis-natural-number@4.0.1(transitive)
+ Addedis-object@1.0.2(transitive)
+ Addedis-plain-obj@1.1.0(transitive)
+ Addedis-retry-allowed@1.2.0(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedis-valid-path@0.1.1(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedisurl@1.0.0(transitive)
+ Addedjoi@17.13.3(transitive)
+ Addedlowercase-keys@1.0.1(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmake-dir@1.3.0(transitive)
+ Addedmime-db@1.53.0(transitive)
+ Addedmimic-response@1.0.1(transitive)
+ Addednode-downloader-helper@2.1.9(transitive)
+ Addednode-jq@4.4.0(transitive)
+ Addednpm-conf@1.1.3(transitive)
+ Addednpm-run-path@2.0.2(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedp-cancelable@0.3.0(transitive)
+ Addedp-event@1.3.0(transitive)
+ Addedp-finally@1.0.0(transitive)
+ Addedp-map-series@1.0.0(transitive)
+ Addedp-reduce@1.0.0(transitive)
+ Addedp-timeout@1.2.1(transitive)
+ Addedpath-key@2.0.1(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedpify@2.3.03.0.0(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedprepend-http@1.0.4(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedproto-list@1.2.4(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.25.2.1(transitive)
+ Addedseek-bzip@1.0.6(transitive)
+ Addedshebang-command@1.2.0(transitive)
+ Addedshebang-regex@1.0.0(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsort-keys@1.1.2(transitive)
+ Addedsort-keys-length@1.0.1(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedstrip-dirs@2.1.0(transitive)
+ Addedstrip-eof@1.0.0(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedstrip-outer@1.0.1(transitive)
+ Addedtar-stream@1.6.2(transitive)
+ Addedtemp-dir@1.0.02.0.0(transitive)
+ Addedtempfile@2.0.03.0.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtimed-out@4.0.1(transitive)
+ Addedto-buffer@1.1.1(transitive)
+ Addedtrim-repeated@1.0.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedunbzip2-stream@1.4.3(transitive)
+ Addedurl-parse-lax@1.0.0(transitive)
+ Addedurl-to-options@1.0.1(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedwhich@1.3.1(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedxtend@4.0.2(transitive)
+ Addedyallist@2.1.2(transitive)
+ Addedyauzl@2.10.0(transitive)