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

rsocket-flowable

Package Overview
Dependencies
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rsocket-flowable - npm Package Compare versions

Comparing version 0.0.14 to 0.0.20

build/FlowableAsyncIterable.js

143

build/Flowable.js

@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

*
*
*
*/

@@ -21,24 +21,37 @@

Object.defineProperty(exports, '__esModule', {value: true});
exports.default = void 0;
var _FlowableMapOperator = require('./FlowableMapOperator');
var _FlowableMapOperator2 = _interopRequireDefault(_FlowableMapOperator);
var _FlowableTakeOperator = require('./FlowableTakeOperator');
var _FlowableTakeOperator2 = _interopRequireDefault(_FlowableTakeOperator);
var _FlowableMapOperator = _interopRequireDefault(
require('./FlowableMapOperator')
);
var _FlowableTakeOperator = _interopRequireDefault(
require('./FlowableTakeOperator')
);
var _invariant = require('fbjs/lib/invariant');
var _invariant2 = _interopRequireDefault(_invariant);
var _warning = require('fbjs/lib/warning');
var _warning2 = _interopRequireDefault(_warning);
var _emptyFunction = require('fbjs/lib/emptyFunction');
var _emptyFunction2 = _interopRequireDefault(_emptyFunction);
var _invariant = _interopRequireDefault(require('fbjs/lib/invariant'));
var _warning = _interopRequireDefault(require('fbjs/lib/warning'));
var _emptyFunction = _interopRequireDefault(require('fbjs/lib/emptyFunction'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true,
});
} else {
obj[key] = value;
}
return obj;
}
/**
* Implements the ReactiveStream `Publisher` interface with Rx-style operators.
*/
* Implements the ReactiveStream `Publisher` interface with Rx-style operators.
*/
class Flowable {
static just(...values) {
return new Flowable(subscriber => {
return new Flowable((subscriber) => {
let cancelled = false;

@@ -50,3 +63,3 @@ let i = 0;

},
request: n => {
request: (n) => {
while (!cancelled && n > 0 && i < values.length) {

@@ -65,3 +78,3 @@ subscriber.onNext(values[i++]);

static error(error) {
return new Flowable(subscriber => {
return new Flowable((subscriber) => {
subscriber.onSubscribe({

@@ -77,6 +90,6 @@ cancel: () => {},

static never() {
return new Flowable(subscriber => {
return new Flowable((subscriber) => {
subscriber.onSubscribe({
cancel: _emptyFunction2.default,
request: _emptyFunction2.default,
cancel: _emptyFunction.default,
request: _emptyFunction.default,
});

@@ -103,4 +116,5 @@ });

lift(onSubscribeLift) {
return new Flowable(subscriber =>
this._source(onSubscribeLift(subscriber)));
return new Flowable((subscriber) =>
this._source(onSubscribeLift(subscriber))
);
}

@@ -110,3 +124,3 @@

return this.lift(
subscriber => new _FlowableMapOperator2.default(subscriber, fn)
(subscriber) => new _FlowableMapOperator.default(subscriber, fn)
);

@@ -117,3 +131,3 @@ }

return this.lift(
subscriber => new _FlowableTakeOperator2.default(subscriber, toTake)
(subscriber) => new _FlowableTakeOperator.default(subscriber, toTake)
);

@@ -132,43 +146,52 @@ }

}
exports.default = Flowable;
/**
* @private
*/
* @private
*/ exports.default = Flowable;
class FlowableSubscriber {
constructor(subscriber, max) {
this._cancel = () => {
if (!this._active) {
return;
_defineProperty(
this,
'_cancel',
() => {
if (!this._active) {
return;
}
this._active = false;
if (this._subscription) {
this._subscription.cancel();
}
}
this._active = false;
if (this._subscription) {
this._subscription.cancel();
}
};
this._request = n => {
(0, _invariant2.default)(
Number.isInteger(n) && n >= 1 && n <= this._max,
'Flowable: Expected request value to be an integer with a ' +
'value greater than 0 and less than or equal to %s, got ' +
'`%s`.',
this._max,
n
);
);
_defineProperty(
this,
'_request',
if (!this._active) {
return;
}
if (n === this._max) {
this._pending = this._max;
} else {
this._pending += n;
if (this._pending >= this._max) {
(n) => {
(0, _invariant.default)(
Number.isInteger(n) && n >= 1 && n <= this._max,
'Flowable: Expected request value to be an integer with a ' +
'value greater than 0 and less than or equal to %s, got ' +
'`%s`.',
this._max,
n
);
if (!this._active) {
return;
}
if (n === this._max) {
this._pending = this._max;
} else {
this._pending += n;
if (this._pending >= this._max) {
this._pending = this._max;
}
}
if (this._subscription) {
this._subscription.request(n);
}
}
if (this._subscription) {
this._subscription.request(n);
}
};
);
this._active = false;

@@ -183,3 +206,3 @@ this._max = max;

if (!this._active) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -207,3 +230,3 @@ 'Flowable: Invalid call to onComplete(): %s.',

if (this._started && !this._active) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -223,3 +246,3 @@ 'Flowable: Invalid call to onError(): %s.',

if (!this._active) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -234,3 +257,3 @@ 'Flowable: Invalid call to onNext(): %s.',

if (this._pending === 0) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -256,3 +279,3 @@ 'Flowable: Invalid call to onNext(), all request()ed values have been ' +

if (this._started) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -259,0 +282,0 @@ 'Flowable: Invalid call to onSubscribe(): already called.'

@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

*
*
*
*/

@@ -21,5 +21,5 @@

Object.defineProperty(exports, '__esModule', {value: true});
exports.default = void 0;
var _nullthrows = require('fbjs/lib/nullthrows');
var _nullthrows2 = _interopRequireDefault(_nullthrows);
var _nullthrows = _interopRequireDefault(require('fbjs/lib/nullthrows'));
function _interopRequireDefault(obj) {

@@ -30,6 +30,6 @@ return obj && obj.__esModule ? obj : {default: obj};

/**
* An operator that acts like Array.map, applying a given function to
* all values provided by its `Subscription` and passing the result to its
* `Subscriber`.
*/
* An operator that acts like Array.map, applying a given function to
* all values provided by its `Subscription` and passing the result to its
* `Subscriber`.
*/
class FlowableMapOperator {

@@ -54,3 +54,3 @@ constructor(subscriber, fn) {

} catch (e) {
(0, _nullthrows2.default)(this._subscription).cancel();
(0, _nullthrows.default)(this._subscription).cancel();
this._subscriber.onError(e);

@@ -57,0 +57,0 @@ }

'use strict';
Object.defineProperty(exports, '__esModule', {value: true});
var _warning = require('fbjs/lib/warning');
var _warning2 = _interopRequireDefault(_warning);
exports.default = void 0;
var _warning = _interopRequireDefault(require('fbjs/lib/warning'));
function _interopRequireDefault(obj) {

@@ -23,3 +23,3 @@ return obj && obj.__esModule ? obj : {default: obj};

if (!this._sink) {
(0, _warning2.default)(
(0, _warning.default)(
'Warning, premature onNext for processor, dropping value'

@@ -45,3 +45,3 @@ );

if (!this._sink) {
(0, _warning2.default)(
(0, _warning.default)(
'Warning, premature onError for processor, marking complete/errored'

@@ -57,3 +57,3 @@ );

if (!this._sink) {
(0, _warning2.default)(
(0, _warning.default)(
'Warning, premature onError for processor, marking complete'

@@ -60,0 +60,0 @@ );

@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

*
*
*
*/

@@ -21,7 +21,8 @@

Object.defineProperty(exports, '__esModule', {value: true});
exports.default = void 0;
/**
* An operator that `request()`s the given number of items immediately upon
* being subscribed.
*/
* An operator that `request()`s the given number of items immediately upon
* being subscribed.
*/
class FlowableRequestOperator {

@@ -28,0 +29,0 @@ constructor(subscriber, toRequest) {

@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

*
*
*
*/

@@ -21,5 +21,5 @@

Object.defineProperty(exports, '__esModule', {value: true});
exports.default = void 0;
var _nullthrows = require('fbjs/lib/nullthrows');
var _nullthrows2 = _interopRequireDefault(_nullthrows);
var _nullthrows = _interopRequireDefault(require('fbjs/lib/nullthrows'));
function _interopRequireDefault(obj) {

@@ -30,6 +30,6 @@ return obj && obj.__esModule ? obj : {default: obj};

/**
* An operator that requests a fixed number of values from its source
* `Subscription` and forwards them to its `Subscriber`, cancelling the
* subscription when the requested number of items has been reached.
*/
* An operator that requests a fixed number of values from its source
* `Subscription` and forwards them to its `Subscriber`, cancelling the
* subscription when the requested number of items has been reached.
*/
class FlowableTakeOperator {

@@ -57,3 +57,3 @@ constructor(subscriber, toTake) {

} catch (e) {
(0, _nullthrows2.default)(this._subscription).cancel();
(0, _nullthrows.default)(this._subscription).cancel();
this._subscriber.onError(e);

@@ -72,3 +72,3 @@ }

_cancelAndComplete() {
(0, _nullthrows2.default)(this._subscription).cancel();
(0, _nullthrows.default)(this._subscription).cancel();
this._subscriber.onComplete();

@@ -75,0 +75,0 @@ }

@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

*
*
*
*/

@@ -22,21 +22,21 @@

exports.every = every;
var _Flowable = require('./Flowable');
var _Flowable2 = _interopRequireDefault(_Flowable);
var _Flowable = _interopRequireDefault(require('./Flowable'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**
* Returns a Publisher that provides the current time (Date.now()) every `ms`
* milliseconds.
*
* The timer is established on the first call to `request`: on each
* interval a value is published if there are outstanding requests,
* otherwise nothing occurs for that interval. This approach ensures
* that the interval between `onNext` calls is as regular as possible
* and means that overlapping `request` calls (ie calling again before
* the previous values have been vended) behaves consistently.
*/ function every(
ms
) {
return new _Flowable2.default(subscriber => {
* Returns a Publisher that provides the current time (Date.now()) every `ms`
* milliseconds.
*
* The timer is established on the first call to `request`: on each
* interval a value is published if there are outstanding requests,
* otherwise nothing occurs for that interval. This approach ensures
* that the interval between `onNext` calls is as regular as possible
* and means that overlapping `request` calls (ie calling again before
* the previous values have been vended) behaves consistently.
*/
function every(ms) {
return new _Flowable.default((subscriber) => {
let intervalId = null;

@@ -51,3 +51,3 @@ let pending = 0;

},
request: n => {
request: (n) => {
if (n < Number.MAX_SAFE_INTEGER) {

@@ -61,13 +61,10 @@ pending += n;

}
intervalId = setInterval(
() => {
if (pending > 0) {
if (pending !== Number.MAX_SAFE_INTEGER) {
pending--;
}
subscriber.onNext(Date.now());
intervalId = setInterval(() => {
if (pending > 0) {
if (pending !== Number.MAX_SAFE_INTEGER) {
pending--;
}
},
ms
);
subscriber.onNext(Date.now());
}
}, ms);
},

@@ -74,0 +71,0 @@ });

@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

*
*
*
*/

@@ -21,10 +21,30 @@

Object.defineProperty(exports, '__esModule', {value: true});
exports.every = (exports.Single = (exports.FlowableProcessor = (exports.Flowable = undefined)));
Object.defineProperty(exports, 'Flowable', {
enumerable: true,
get: function () {
return _Flowable.default;
},
});
Object.defineProperty(exports, 'Single', {
enumerable: true,
get: function () {
return _Single.default;
},
});
Object.defineProperty(exports, 'FlowableProcessor', {
enumerable: true,
get: function () {
return _FlowableProcessor.default;
},
});
Object.defineProperty(exports, 'every', {
enumerable: true,
get: function () {
return _FlowableTimer.every;
},
});
var _Flowable = require('./Flowable');
var _Flowable2 = _interopRequireDefault(_Flowable);
var _Single = require('./Single');
var _Single2 = _interopRequireDefault(_Single);
var _FlowableProcessor = require('./FlowableProcessor');
var _FlowableProcessor2 = _interopRequireDefault(_FlowableProcessor);
var _Flowable = _interopRequireDefault(require('./Flowable'));
var _Single = _interopRequireDefault(require('./Single'));
var _FlowableProcessor = _interopRequireDefault(require('./FlowableProcessor'));
var _FlowableTimer = require('./FlowableTimer');

@@ -34,8 +54,1 @@ function _interopRequireDefault(obj) {

}
/**
* The public API of the `flowable` package.
*/ exports.Flowable = _Flowable2.default;
exports.FlowableProcessor = _FlowableProcessor2.default;
exports.Single = _Single2.default;
exports.every = _FlowableTimer.every;

@@ -15,3 +15,3 @@ /** Copyright (c) Facebook, Inc. and its affiliates.

*
*
*
*/

@@ -21,7 +21,6 @@

Object.defineProperty(exports, '__esModule', {value: true});
exports.default = void 0;
var _warning = require('fbjs/lib/warning');
var _warning2 = _interopRequireDefault(_warning);
var _emptyFunction = require('fbjs/lib/emptyFunction');
var _emptyFunction2 = _interopRequireDefault(_emptyFunction);
var _warning = _interopRequireDefault(require('fbjs/lib/warning'));
var _emptyFunction = _interopRequireDefault(require('fbjs/lib/emptyFunction'));
function _interopRequireDefault(obj) {

@@ -32,37 +31,37 @@ return obj && obj.__esModule ? obj : {default: obj};

/**
* Represents a lazy computation that will either produce a value of type T
* or fail with an error. Calling `subscribe()` starts the
* computation and returns a subscription object, which has an `unsubscribe()`
* method that can be called to prevent completion/error callbacks from being
* invoked and, where supported, to also cancel the computation.
* Implementations may optionally implement cancellation; if they do not
* `cancel()` is a no-op.
*
* Note: Unlike Promise, callbacks (onComplete/onError) may be invoked
* synchronously.
*
* Example:
*
* ```
* const value = new Single(subscriber => {
* const id = setTimeout(
* () => subscriber.onComplete('Hello!'),
* 250
* );
* // Optional: Call `onSubscribe` with a cancellation callback
* subscriber.onSubscribe(() => clearTimeout(id));
* });
*
* // Start the computation. onComplete will be called after the timeout
* // with 'hello' unless `cancel()` is called first.
* value.subscribe({
* onComplete: value => console.log(value),
* onError: error => console.error(error),
* onSubscribe: cancel => ...
* });
* ```
*/
* Represents a lazy computation that will either produce a value of type T
* or fail with an error. Calling `subscribe()` starts the
* computation and returns a subscription object, which has an `unsubscribe()`
* method that can be called to prevent completion/error callbacks from being
* invoked and, where supported, to also cancel the computation.
* Implementations may optionally implement cancellation; if they do not
* `cancel()` is a no-op.
*
* Note: Unlike Promise, callbacks (onComplete/onError) may be invoked
* synchronously.
*
* Example:
*
* ```
* const value = new Single(subscriber => {
* const id = setTimeout(
* () => subscriber.onComplete('Hello!'),
* 250
* );
* // Optional: Call `onSubscribe` with a cancellation callback
* subscriber.onSubscribe(() => clearTimeout(id));
* });
*
* // Start the computation. onComplete will be called after the timeout
* // with 'hello' unless `cancel()` is called first.
* value.subscribe({
* onComplete: value => console.log(value),
* onError: error => console.error(error),
* onSubscribe: cancel => ...
* });
* ```
*/
class Single {
static of(value) {
return new Single(subscriber => {
return new Single((subscriber) => {
subscriber.onSubscribe();

@@ -74,3 +73,3 @@ subscriber.onComplete(value);

static error(error) {
return new Single(subscriber => {
return new Single((subscriber) => {
subscriber.onSubscribe();

@@ -81,2 +80,8 @@ subscriber.onError(error);

static never() {
return new Single((subscriber) => {
subscriber.onSubscribe();
});
}
constructor(source) {

@@ -96,3 +101,3 @@ this._source = source;

flatMap(fn) {
return new Single(subscriber => {
return new Single((subscriber) => {
let currentCancel;

@@ -104,9 +109,9 @@ const cancel = () => {

this._source({
onComplete: value => {
onComplete: (value) => {
fn(value).subscribe({
onComplete: mapValue => {
onComplete: (mapValue) => {
subscriber.onComplete(mapValue);
},
onError: error => subscriber.onError(error),
onSubscribe: _cancel => {
onError: (error) => subscriber.onError(error),
onSubscribe: (_cancel) => {
currentCancel = _cancel;

@@ -116,4 +121,4 @@ },

},
onError: error => subscriber.onError(error),
onSubscribe: _cancel => {
onError: (error) => subscriber.onError(error),
onSubscribe: (_cancel) => {
currentCancel = _cancel;

@@ -127,11 +132,11 @@ subscriber.onSubscribe(cancel);

/**
* Return a new Single that resolves to the value of this Single applied to
* the given mapping function.
*/
* Return a new Single that resolves to the value of this Single applied to
* the given mapping function.
*/
map(fn) {
return new Single(subscriber => {
return new Single((subscriber) => {
return this._source({
onComplete: value => subscriber.onComplete(fn(value)),
onError: error => subscriber.onError(error),
onSubscribe: cancel => subscriber.onSubscribe(cancel),
onComplete: (value) => subscriber.onComplete(fn(value)),
onError: (error) => subscriber.onError(error),
onSubscribe: (cancel) => subscriber.onSubscribe(cancel),
});

@@ -143,12 +148,11 @@ });

this.subscribe({
onComplete: successFn || _emptyFunction2.default,
onError: errorFn || _emptyFunction2.default,
onComplete: successFn || _emptyFunction.default,
onError: errorFn || _emptyFunction.default,
});
}
}
exports.default = Single;
/**
* @private
*/
* @private
*/ exports.default = Single;
class FutureSubscriber {

@@ -163,3 +167,3 @@ constructor(subscriber) {

if (!this._active) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -189,3 +193,3 @@ 'Single: Invalid call to onComplete(): %s.',

if (this._started && !this._active) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -207,3 +211,3 @@ 'Single: Invalid call to onError(): %s.',

if (this._started) {
(0, _warning2.default)(
(0, _warning.default)(
false,

@@ -210,0 +214,0 @@ 'Single: Invalid call to onSubscribe(): already called.'

{
"name": "rsocket-flowable",
"description": "ReactiveStreams for JavaScript",
"version": "0.0.14",
"version": "0.0.20",
"repository": {

@@ -12,4 +12,5 @@ "type": "git",

"dependencies": {
"fbjs": "^1.0.0"
}
"fbjs": "^2.0.0"
},
"gitHead": "a1190c84ab5366aa2ed3305bb33beda7fdfab71d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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