Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

restream

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

restream - npm Package Compare versions

Comparing version 3.7.1 to 3.7.2

6

build/index.js

@@ -7,3 +7,3 @@ const { Transform } = require('stream');

*/
function createRegexTransformStream(regex) {
function createRegexTransformStream(regex) {
let buffer = ''

@@ -37,6 +37,2 @@

const $_lib_markers = require('./lib/markers');

@@ -43,0 +39,0 @@

4

build/lib/index.js

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

function checkRule(reObject) {
function checkRule(reObject) {
if (typeof reObject != 'object') {

@@ -11,3 +11,3 @@ return false

const hideStack = (commonError, thrownError) => {
const hideStack = (commonError, thrownError) => {
if (!(thrownError instanceof Error)) throw thrownError

@@ -14,0 +14,0 @@ const [, , commonLine] = commonError.stack.split('\n', 3)

@@ -52,3 +52,3 @@ const SyncReplaceable = require('../SyncReplaceable');

*/
const makeMarkers = (matchers, config) => {
const makeMarkers = (matchers, config) => {
const res = Object.keys(matchers).reduce((acc, key) => {

@@ -72,3 +72,3 @@ const re = matchers[key]

*/
const makePasteRule = (marker, pipeRules = []) => {
const makePasteRule = (marker, pipeRules = []) => {
const { regExp: re, map } = marker

@@ -93,3 +93,3 @@ const rule = {

*/
const makeCutRule = (marker) => {
const makeCutRule = (marker) => {
const { re, map, getReplacement, name } = marker

@@ -96,0 +96,0 @@ const rule = {

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

let Stream = require('stream'); const { Transform } = Stream; if (Stream && Stream.__esModule) Stream = Stream.default;
const Stream = require('stream'); const { Transform } = Stream;
let cleanStack = require('@artdeco/clean-stack'); if (cleanStack && cleanStack.__esModule) cleanStack = cleanStack.default;

@@ -6,3 +6,3 @@ const { collect } = require('catchment');

class Replaceable extends Transform {
class Replaceable extends Transform {
/**

@@ -143,3 +143,3 @@ * Replaceable class that extends Transform and pushes data when it's done replacing each incoming chunk. If the replacement is passed as a function, it will work in the same way as the replacer for `string.replace` method (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace), taking the `match` as the first argument, and matched `p1`, `p2`, _etc_ parameters as following arguments. The replacer can also be an async function.

*/
class SerialAsyncReplaceable extends Replaceable {
class SerialAsyncReplaceable extends Replaceable {
/**

@@ -146,0 +146,0 @@ * @param {!(_restream.Rule|Array<!_restream.Rule>)} rules

@@ -32,2 +32,3 @@ const { checkRule, hideStack } = require('./lib');

Acc = Acc.replace(re, replacement)
return Acc
} else {

@@ -34,0 +35,0 @@ let commonError

@@ -0,1 +1,7 @@

## 26 July 2019
### [3.7.2](https://github.com/artdecocode/restream/compare/v3.7.1...v3.7.2)
- [fix] Fix specifying a string replacement in _SyncReplaceable_.
## 20 April 2019

@@ -2,0 +8,0 @@

{
"name": "restream",
"version": "3.7.1",
"version": "3.7.2",
"description": "Regular Expression Detection & Replacement streams.",

@@ -59,8 +59,8 @@ "main": "build/index.js",

"devDependencies": {
"alamode": "^1.9.3",
"documentary": "^1.24.1",
"alamode": "^2.3.4",
"documentary": "^1.27.7",
"eslint-config-artdeco": "1.0.1",
"spawncommand": "^2.1.2",
"spawncommand": "^2.2.0",
"yarn-s": "1.1.0",
"zoroaster": "^3.11.6"
"zoroaster": "^4.1.1-alpha"
},

@@ -67,0 +67,0 @@ "dependencies": {

@@ -25,3 +25,3 @@ # restream

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/0.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/0.svg?sanitize=true"></a></p>

@@ -60,3 +60,3 @@ ## Table of Contents

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/1.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/1.svg?sanitize=true"></a></p>

@@ -76,3 +76,3 @@ ## API

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/2.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/2.svg?sanitize=true"></a></p>

@@ -117,3 +117,3 @@ ## `restream(`<br/>&nbsp;&nbsp;`regex: RegExp,`<br/>`): Transform`

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/3.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/3.svg?sanitize=true"></a></p>

@@ -124,3 +124,3 @@ ## `Replaceable` Class

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/4.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/4.svg?sanitize=true" width="25"></a></p>

@@ -217,3 +217,3 @@ ### `Rule` Type

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/5.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/5.svg?sanitize=true" width="25"></a></p>

@@ -281,6 +281,6 @@ ### `constructor(`<br/>&nbsp;&nbsp;`rule: Rule|Rules[],`<br/>&nbsp;&nbsp;`options?: TransformOptions,`<br/>`): Replaceable`

Author: <strong>John</strong>
on <em>2019-4-20 03:46:59</em>
on <em>2019-7-26 00:34:17</em>
```
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/6.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/6.svg?sanitize=true" width="25"></a></p>

@@ -362,10 +362,11 @@ ### `Replacer` Context

__<a name="type-_restreamreplaceableinterface">`_restream.ReplaceableInterface`</a>__: An interface for the context accessible via this in replacer functions.
<strong><a name="type-_restreamreplaceableinterface">`_restream.ReplaceableInterface`</a></strong>: An interface for the context accessible via this in replacer functions.
| Name | Type | Description |
| ------------ | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| __brake*__ | _function()_ | After calling this method, the following rules and matches within the same rule won't be able to make any more changes. |
| __replace*__ | _function(string, !Object&lt;string, *&gt;?): !Promise&lt;string>_ | Creates a new _Replaceable_ by copying all rules, assigns the context to it and replaces the data. The `this` won't be shared by rules, but the context will be updated: `const context = { test: this.test }; content = await this.replace(content, context); this.test = context.test`. |
| Name | Type | Description |
| ------------ | ---------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| __emit*__ | <em>function(string, ...*)</em> | Emit an event. Inherited from the `EventEmitter` which _Replaceable_ extends. |
| __brake*__ | <em>function()</em> | After calling this method, the following rules and matches within the same rule won't be able to make any more changes. |
| __replace*__ | <em>function(string, !Object&lt;string, *&gt;=): !Promise&lt;string&gt;</em> | Creates a new _Replaceable_ by copying all rules, assigns the context to it and replaces the data. The `this` won't be shared by rules, but the context will be updated: `const context = { test: this.test }; content = await this.replace(content, context); this.test = context.test`. |
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/7.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/7.svg?sanitize=true" width="25"></a></p>

@@ -406,3 +407,3 @@ ### `brake(): void`

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/8.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/8.svg?sanitize=true" width="25"></a></p>

@@ -480,3 +481,3 @@ ### `async replace(`<br/>&nbsp;&nbsp;`input: string,`<br/>&nbsp;&nbsp;`context?: Object,`<br/>`): string`

<span>Hello World</span>
<footer>London</footer>
<address>London</address>
<em>Art Deco</em>

@@ -496,3 +497,3 @@ </div>`

Total found: 2, replacer lane: 2 [span]
Total found: 3, replacer lane: 3 [footer]
Total found: 3, replacer lane: 3 [address]
Total found: 3, replacer lane: 2 [summary]

@@ -506,3 +507,3 @@

<span-replaced>Hello World</span-replaced>
<footer>London</footer>
<address>London</address>
<em>Art Deco</em>

@@ -512,3 +513,3 @@ </div-replaced>

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/9.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/9.svg?sanitize=true" width="25"></a></p>

@@ -554,3 +555,3 @@ ### `Replacer` Errors

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/10.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/10.svg?sanitize=true" width="25"></a></p>

@@ -599,3 +600,3 @@ ### `static replace`

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/11.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/11.svg?sanitize=true"></a></p>

@@ -667,3 +668,3 @@ ### Collecting Into Catchment

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/12.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/12.svg?sanitize=true"></a></p>

@@ -707,8 +708,8 @@ ## `SerialAsyncReplaceable` Class

```
Test: serial 110ms, parallel 438ms,
Example: serial 228ms, parallel 438ms,
Total: serial 332ms, parallel 438ms,
Test: serial 113ms, parallel 427ms,
Example: serial 218ms, parallel 427ms,
Total: serial 320ms, parallel 427ms,
```
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/13.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/13.svg?sanitize=true"></a></p>

@@ -756,3 +757,3 @@ ## `SyncReplaceable(`<br/>&nbsp;&nbsp;`input: string,`<br/>&nbsp;&nbsp;`rules: Rules[],`<br/>`): string`

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/14.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/14.svg?sanitize=true"></a></p>

@@ -847,3 +848,3 @@ ## Markers

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/15.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/15.svg?sanitize=true" width="25"></a></p>

@@ -905,12 +906,12 @@ ### `makeMarkers(`<br/>&nbsp;&nbsp;`matchers: { [name]: RegExp },`<br/>&nbsp;&nbsp;`config?: MakeMarkersConfig,`<br/>`): { [name]: Marker }`

__<a name="type-_restreammakemarkersconfig">`_restream.MakeMarkersConfig`</a>__: Additional configuration.
<strong><a name="type-_restreammakemarkersconfig">`_restream.MakeMarkersConfig`</a></strong>: Additional configuration.
| Name | Type | Description |
| -------------- | -------------------------------------------- | ------------------------------------------------------------------------- |
| getReplacement | _(name: string, index: number) =&gt; string_ | The function used to create a replacement when some text needs to be cut. |
| getRegex | _(name: string) =&gt; !RegExp_ | The function used to create a RegExp to detect replaced chunks. |
| Name | Type | Description |
| -------------- | ------------------------------------------------ | ------------------------------------------------------------------------- |
| getReplacement | <em>(name: string, index: number) => string</em> | The function used to create a replacement when some text needs to be cut. |
| getRegex | <em>(name: string) => !RegExp</em> | The function used to create a RegExp to detect replaced chunks. |
By default, `%%_RESTREAM_${name.toUpperCase()}_REPLACEMENT_${index}_%%` replacement is used with <code>new RegExp(&#96;%%&#95;RESTREAM&#95;${name.toUpperCase()}&#95;REPLACEMENT&#95;(\\d+)&#95;%%&#96;, 'g')</code> regex to detect it and restore the original value.
<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/16.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/16.svg?sanitize=true" width="25"></a></p>

@@ -921,3 +922,3 @@ ### `makeCutRule(`<br/>&nbsp;&nbsp;`marker: Marker,`<br/>`): Rule`

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/17.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/17.svg?sanitize=true" width="25"></a></p>

@@ -964,3 +965,3 @@ ### `makePasteRule(`<br/>&nbsp;&nbsp;`marker: Marker,`<br/>&nbsp;&nbsp;`pipeRules?: Rule|Rules,`<br/>`): Rule`

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/18.svg?sanitize=true" width="25"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/18.svg?sanitize=true" width="25"></a></p>

@@ -1096,3 +1097,3 @@ ### Accessing Replacements

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/19.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/19.svg?sanitize=true"></a></p>

@@ -1111,3 +1112,3 @@ ## Related Packages

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/20.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/20.svg?sanitize=true"></a></p>

@@ -1120,3 +1121,4 @@ ## Copyright

<a href="https://artd.eco">
<img src="https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png" alt="Art Deco" />
<img width="100" src="https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png"
alt="Art Deco">
</a>

@@ -1127,4 +1129,4 @@ </th>

<a href="https://www.technation.sucks" title="Tech Nation Visa">
<img src="https://raw.githubusercontent.com/artdecoweb/www.technation.sucks/master/anim.gif"
alt="Tech Nation Visa" />
<img width="100" src="https://raw.githubusercontent.com/idiocc/cookies/master/wiki/arch4.jpg"
alt="Tech Nation Visa">
</a>

@@ -1136,2 +1138,2 @@ </th>

<p align="center"><a href="#table-of-contents"><img src=".documentary/section-breaks/-1.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/-1.svg?sanitize=true"></a></p>

@@ -32,2 +32,3 @@ import { checkRule, hideStack } from './lib'

Acc = Acc.replace(re, replacement)
return Acc
} else {

@@ -34,0 +35,0 @@ let commonError

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc