Socket
Socket
Sign inDemoInstall

@hapi/good-squeeze

Package Overview
Dependencies
2
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.2.1 to 6.0.0

2

LICENSE.md

@@ -1,2 +0,2 @@

Copyright (c) 2014-2019, Sideway Inc, and project contributors
Copyright (c) 2014-2020, Sideway Inc, and project contributors
Copyright (c) 2014-2016, Walmart.

@@ -3,0 +3,0 @@ All rights reserved.

{
"name": "@hapi/good-squeeze",
"version": "5.2.1",
"version": "6.0.0",
"description": "Collection of utility transform streams.",
"repository": "https://github.com/hapijs/good-squeeze.git",
"main": "lib/index.js",
"files": [
"lib"
],
"keywords": [

@@ -15,10 +18,10 @@ "good",

"dependencies": {
"@hapi/hoek": "8.x.x",
"@hapi/hoek": "9.x.x",
"fast-safe-stringify": "2.x.x"
},
"devDependencies": {
"@hapi/boom": "7.x.x",
"@hapi/code": "6.x.x",
"@hapi/lab": "20.x.x",
"@hapi/teamwork": "3.x.x"
"@hapi/boom": "9.x.x",
"@hapi/code": "8.x.x",
"@hapi/lab": "22.x.x",
"@hapi/teamwork": "4.x.x"
},

@@ -25,0 +28,0 @@ "scripts": {

@@ -1,81 +0,19 @@

<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# good-squeeze
# @hapi/good-squeeze
Simple transform streams useful in creating [good](https://github.com/hapijs/good) data pipelines.
#### Simple transform stream for event filtering with good.
[![Build Status](https://travis-ci.org/hapijs/good-squeeze.svg?branch=master&style=flat)](https://travis-ci.org/hapijs/good-squeeze)
![Current Version](https://img.shields.io/npm/v/good-squeeze.svg?style=flat)
**good-squeeze** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) – they work even better together.
Lead Maintainer: [Open Position](https://github.com/hapijs/good-squeeze/issues/29)
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
## Usage
## Useful resources
good-squeeze is a collection of small transform streams. The `Squeeze` stream is useful for filtering events based on the good event options. The `SafeJson` stream is useful for stringifying objects to prevent circular object errors.
- [Documentation and API](https://hapi.dev/family/good-squeeze/)
- [Version status](https://hapi.dev/resources/status/#good-squeeze) (builds, dependencies, node versions, licenses, eol)
- [Changelog](https://hapi.dev/family/good-squeeze/changelog/)
- [Project policies](https://hapi.dev/policies/)
- [Free and commercial support options](https://hapi.dev/support/)
## Methods
### `Squeeze(events, [options])`
Creates a new Squeeze transform stream where:
- `events` an object where each key is a valid good event and the value is one of the following:
- `string` - a tag to include when filtering. '*' indicates no filtering.
- `array` - array of tags to filter. `[]` indicates no filtering.
- `object` - an object with the following values
- `include` - string or array representing tag(s) to *include* when filtering
- `exclude` - string or array representing tag(s) to *exclude* when filtering. `exclude` takes precedence over any `include` tags.
- `[options]` configuration object that gets passed to the Node [`Stream.Transform`](http://nodejs.org/api/stream.html#stream_class_stream_transform) constructor. **Note** `objectMode` is always `true` for all `Squeeze` objects.
The transform stream only passes on events that satisfy the event filtering based on event name and tags. If the upstream event doesn't satisfy the filter, it is not continued down the pipe line.
### `Squeeze.subscription(events)`
A static method on `Squeeze` that creates a new event subscription map where:
- `events` the same arguments used in the `Squeeze` constructor.
```js
const Squeeze = require('good-squeeze');
Squeeze.subscription({ log: 'user', ops: '*', request: ['hapi', 'foo'] });
// Results in
// {
// log: { include: [ 'user' ], exclude: [] },
// ops: { include: [], exclude: [] },
// request: { include: [ 'hapi', 'foo' ], exclude: [] }
// }
Squeeze.subscription({ log: 'user', ops: { exclude: 'debug' }, request: { include: ['hapi', 'foo'], exclude: 'sensitive' } });
// Results in
// {
// log: { include: [ 'user' ], exclude: [] },
// ops: { include: [], exclude: [ 'debug' ] },
// request: { include: [ 'hapi', 'foo' ], exclude: [ 'sensitive' ] }
// }
```
Useful for creating an event subscription to be used with `Squeeze.filter` if you do not plan on creating a pipeline coming from good and instead want to manage event filtering manually.
### `Squeeze.filter(subscription, data)`
Returns `true` if the supplied `data.event` + `data.tags` should be reported based on `subscription` where:
- `subscription` - a subscription map created by `Squeeze.subscription()`.
- `data` - event object emitted from good/hapi which should contain the following keys:
- `event` - a string representing the event name of `data`
- `tags` - an array of strings representing tags associated with this event.
### `SafeJson([options], [stringify])`
Creates a new SafeJson transform stream where:
- `[options]` configuration object that gets passed to the Node [`Stream.Transform`](http://nodejs.org/api/stream.html#stream_class_stream_transform) constructor. **Note** `objectMode` is always `true` for all `Squeeze` objects.
- `[stringify]` configuration object for controlling how stringify is handled.
- `separator` - string to append to each message. Defaults to "\n".
- `space` - number of spaces in pretty printed JSON. Doesn't pretty print when set to 0. Defaults to 0.
The transform stream stringifys the incoming data and pipes it forward. It will not crash in the cases of circular references and will instead include a "~Circular" string in the result.
## Note: this module is being deprecated on December 31st, 2020 due to lack to available support resources. Please consider using [another logging plugin](https://hapi.dev/plugins/#logging).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc