New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

estream

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

estream - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

api/debounce.md

118

api/estream.md

@@ -1,16 +0,1 @@

# Estream
The Estream Object. To create use the exposed factory function.
**Parameters**
- `opts` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** stream options
**Examples**
```javascript
var ES = require('estream');
var estream1 = ES();
```
# addMethods

@@ -91,21 +76,2 @@

# debounce
Creates an Estream that debounces all events from the source stream.
**Signature**: `Number -> Estream`
**Parameters**
- `interval` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the debounce timeout amount
**Examples**
```javascript
var estream = ES();
var mEstream = estream.debounce(1000);
```
Returns **Estream**
# end

@@ -131,9 +97,2 @@

# endOnError
Returns a new Estream that ends on any error.
The new Estream will have _this_ as a parent/source Estream.
Returns **Estream** that will end on error
# error

@@ -197,2 +156,17 @@

# Estream
The Estream Object. To create use the exposed factory function.
**Parameters**
- `opts` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** stream options
**Examples**
```javascript
var ES = require('estream');
var estream1 = ES();
```
# filter

@@ -239,12 +213,2 @@

# forEach
A helper function for getting only data event values from Estreams.
**Parameters**
- `consumer` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** the consuming function
Returns **Estream**
# getHistory

@@ -293,8 +257,15 @@

# off
# on
Removes a consumer from a estream.
Adds a consumer to an estream.
When an event gets pushed down this estream,
**Signature**: `(a -> *) -> Boolean`
the consumer will get as params:
- the event (EsData | EsError | EsEnd)
- a reference to the estream
- the off/unsubscribe function
**Signature**: `(a -> *) -> Estream a`
**Parameters**

@@ -308,15 +279,23 @@

var estream1 = es();
var onEvent = function(x) { console.log(x); };
estream1.on(onEvent);
estream1.off(onEvent);
var estream1.on(function(event, estream1, unsubscribe) {
console.log('got an event', event.value);
});
```
Returns **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** if the consumer was found and removed.
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** off - the unsubscribe function
# on
# onData
Adds a consumer to an estream.
A helper function for getting only data events from Estreams.
**Signature**: `(a -> *) -> Estream a`
**Parameters**
- `consumer` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** the consuming function
Returns **Estream**
# onError
A helper function for getting only error events from Estreams.
**Parameters**

@@ -326,13 +305,14 @@

**Examples**
Returns **Estream**
```javascript
var estream1 = es();
var estream1.on(function(x, estream1, unsubscribe) {
console.log('got some data', x);
});
```
# onError
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** off - the unsubscribe function
A helper function for getting only end events from Estreams.
**Parameters**
- `consumer` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** the consuming function
Returns **Estream**
# push

@@ -339,0 +319,0 @@

@@ -414,11 +414,11 @@ var uuid = require('node-uuid');

/**
* A helper function for getting only data event values from Estreams.
* A helper function for getting only data events from Estreams.
*
* @name forEach
* @name onData
* @param {Function} consumer - the consuming function
* @return {Estream}
*/
Estream.prototype.forEach = function(consumer) {
return this.on(function(event) {
consumer(event.value);
Estream.prototype.onData = function(consumer) {
return this.on(function(event, estream, offFn) {
if (event.isData) consumer(event, estream, offFn);
});

@@ -428,2 +428,28 @@ };

/**
* A helper function for getting only error events from Estreams.
*
* @name onError
* @param {Function} consumer - the consuming function
* @return {Estream}
*/
Estream.prototype.onError = function(consumer) {
return this.on(function(event, estream, offFn) {
if (event.isError) consumer(event, estream, offFn);
});
};
/**
* A helper function for getting only end events from Estreams.
*
* @name onError
* @param {Function} consumer - the consuming function
* @return {Estream}
*/
Estream.prototype.onEnd = function(consumer) {
return this.on(function(event, estream, offFn) {
if (event.isEnd) consumer(event, estream, offFn);
});
};
/**
* Sets the _keepHistory property. Set to true by default.

@@ -430,0 +456,0 @@ * If this is set to true then an Estream keeps a record of all it's pushed events.

{
"name": "estream",
"version": "0.1.0",
"version": "0.2.0",
"description": "A javascript library with a simplified take on event streams.",

@@ -5,0 +5,0 @@ "main": "estream.js",

@@ -116,2 +116,21 @@ var assert = require('assert');

it('has helper methods for consuming error and end messages', function(done) {
var s = ES();
var errorCalled;
s.onError(function(x) {
assert.equal(x.value, 'error');
errorCalled = true;
});
s.onEnd(function(x) {
assert.deepEqual(x.value, ['bye']);
assert.ok(errorCalled);
done();
});
s.push(5);
s.error('error');
s.end('bye');
});
it('passes unsubscribe functions to consumers when events are emitted', function(done) {

@@ -118,0 +137,0 @@ var s = ES();

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