Comparing version 0.3.11 to 0.3.12
39
index.js
@@ -33,2 +33,3 @@ 'use strict'; | ||
this._values = null; | ||
this._mutableValues = false; | ||
this._active = null; | ||
@@ -43,3 +44,3 @@ this._ended = false; | ||
this._init = init; | ||
} | ||
} // Whether we can mutate the _values Set. | ||
@@ -110,3 +111,2 @@ (0, _createClass3.default)(LiveSet, [{ | ||
if (this._values) { | ||
var _values = this._values; | ||
if (this._active) { | ||
@@ -119,3 +119,8 @@ var _listenHandler = this._active.listenHandler; | ||
} | ||
return this._ended ? _values : new _set2.default(_values); | ||
if (this._mutableValues) { | ||
this._mutableValues = false; | ||
makeSetImmutable(this._values); | ||
} | ||
/*:: if (!this._values) throw new Error(); */ | ||
return this._values; | ||
} else { | ||
@@ -125,3 +130,5 @@ if (this._active) { | ||
} | ||
return this._init.read(); | ||
var s = this._init.read(); | ||
makeSetImmutable(s); | ||
return s; | ||
} | ||
@@ -228,2 +235,6 @@ } | ||
if (!_this2._ended && !values.has(value)) { | ||
if (!_this2._mutableValues) { | ||
_this2._values = values = new _set2.default(values); | ||
_this2._mutableValues = true; | ||
} | ||
values.add(value); | ||
@@ -237,2 +248,6 @@ _this2._queueChange({ type: 'add', value: value }); | ||
if (!_this2._ended && values.has(value)) { | ||
if (!_this2._mutableValues) { | ||
_this2._values = values = new _set2.default(values); | ||
_this2._mutableValues = true; | ||
} | ||
values.delete(value); | ||
@@ -268,3 +283,5 @@ _this2._queueChange({ type: 'remove', value: value }); | ||
_setValues2 = setValuesError; | ||
makeSetImmutable(values); | ||
_this2._values = values; | ||
_this2._mutableValues = false; | ||
}; | ||
@@ -324,2 +341,3 @@ var listenHandlerOrFunction = this._init.listen(function (values) { | ||
value: function constant(values) { | ||
makeSetImmutable(values); | ||
var shouldNotHappen = function shouldNotHappen() { | ||
@@ -334,2 +352,3 @@ throw new Error('Should not happen'); | ||
ls._values = values; | ||
ls._mutableValues = false; | ||
return ls; | ||
@@ -349,3 +368,13 @@ } | ||
}; | ||
function makeSetImmutable(set) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
set.add = set.delete = set.clear = readOnly; | ||
} | ||
} | ||
function readOnly() { | ||
throw new Error('Do not modify Set passed to or from LiveSet: Set is read-only in development'); | ||
} | ||
module.exports = exports['default']; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9pbmRleC5qcyJdLCJuYW1lcyI6WyJMaXZlU2V0IiwiaW5pdCIsIl92YWx1ZXMiLCJfYWN0aXZlIiwiX2VuZGVkIiwiX2VuZGVkV2l0aEVycm9yIiwiX2Vycm9yIiwiX3F1ZXVlZENhbGwiLCJfY2hhbmdlUXVldWUiLCJfb2JzZXJ2ZXJzIiwiX2luaXQiLCJyZWNvcmQiLCJwdXNoIiwiY2hhbmdlcyIsIm9ic2VydmVyc1RvQ2FsbCIsImVuZGVkIiwic2xpY2UiLCJmb3JFYWNoIiwib2JzZXJ2ZXIiLCJpZ25vcmUiLCJvYnNlcnZlck5leHQiLCJuZXh0IiwiY2FsbCIsImNoYW5nZXNUb0RlbGl2ZXIiLCJsZW5ndGgiLCJlcnJvciIsImNvbXBsZXRlIiwiRXJyb3IiLCJsaXN0ZW5IYW5kbGVyIiwidW5zdWJzY3JpYmUiLCJ2YWx1ZXMiLCJwdWxsQ2hhbmdlcyIsInJlYWQiLCJvYnNlcnZlck9yT25OZXh0Iiwib25FcnJvciIsIm9uQ29tcGxldGUiLCJsaXZlU2V0Iiwic3Vic2NyaXB0aW9uIiwiY2xvc2VkIiwic3RhcnQiLCJvYnNlcnZlclJlY29yZCIsImlzU3RhcnRpbmciLCJ1bnN1YnNjcmliZWRJblN0YXJ0IiwiaW5kZXhPZiIsIml4Iiwic3BsaWNlIiwiX2RlYWN0aXZhdGUiLCJjaGFuZ2VRdWV1ZUxlbmd0aCIsIm9yaWdpbmFsTmV4dCIsImNvbnRyb2xsZXIiLCJhZGQiLCJoYXMiLCJ2YWx1ZSIsIl9xdWV1ZU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FjZWJvb2svZmxvdy9pc3N1ZXMvMjI4NlxuKExpdmVTZXQ6YW55KS5wcm90b3R5cGVbJCRvYnNlcnZhYmxlXSA9IGZ1bmN0aW9uKCkge1xuICByZXR1cm4gdGhpcztcbn07XG5cbmZ1bmN0aW9uIG1ha2VTZXRJbW11dGFibGUoc2V0OiBTZXQ8YW55Pikge1xuICBpZiAocHJvY2Vzcy5lbnYuTk9ERV9FTlYgIT09ICdwcm9kdWN0aW9uJykge1xuICAgIChzZXQ6YW55KS5hZGQgPSAoc2V0OmFueSkuZGVsZXRlID0gKHNldDphbnkpLmNsZWFyID0gcmVhZE9ubHk7XG4gIH1cbn1cblxuZnVuY3Rpb24gcmVhZE9ubHkoKSB7XG4gIHRocm93IG5ldyBFcnJvcignRG8gbm90IG1vZGlmeSBTZXQgcGFzc2VkIHRvIG9yIGZyb20gTGl2ZVNldDogU2V0IGlzIHJlYWQtb25seSBpbiBkZXZlbG9wbWVudCcpO1xufVxuIl19 |
{ | ||
"name": "live-set", | ||
"version": "0.3.11", | ||
"version": "0.3.12", | ||
"description": "Class representing a changing and transformable collection of items.", | ||
@@ -21,5 +21,11 @@ "main": "index.js", | ||
"license": "MIT", | ||
"browserify": { | ||
"transform": [ | ||
"envify" | ||
] | ||
}, | ||
"dependencies": { | ||
"asap": "^2.0.5", | ||
"babel-runtime": "^6.22.0", | ||
"envify": "^4.0.0", | ||
"symbol-observable": "^1.0.4", | ||
@@ -39,3 +45,3 @@ "zen-observable": "^0.4.0" | ||
"eslint-plugin-flowtype": "^2.30.0", | ||
"flow-bin": "^0.39.0", | ||
"flow-bin": "^0.40.0", | ||
"flow-copy-source": "^1.1.0", | ||
@@ -42,0 +48,0 @@ "jest": "^18.1.0", |
189
README.md
@@ -6,2 +6,5 @@ # live-set | ||
This class is basically a Set with a subscribe() method that calls your | ||
callback after changes happen to the set of values. | ||
This class represents a set of values which may change over time or have | ||
@@ -253,26 +256,135 @@ transformations applied to it, resulting in a new LiveSet. After modifications | ||
The constructor must be passed an object containing `read` and `listen` | ||
functions. | ||
The `read` function is called if the values() method is called on the LiveSet | ||
instance while it is inactive but not yet ended. The `read` function is | ||
expected to return a Set object containing the LiveSet's current values. If a | ||
LiveSet is not intended to be read while inactive, then you should give a | ||
function which throws an error. | ||
The `listen` function is called whenever the LiveSet is activated. Activation | ||
occurs whenever the LiveSet goes from zero to one subscribers. Activation may | ||
happen multiple times for a LiveSet if it is unsubscribed from and resubscribed | ||
to. The `listen` function is passed two parameters, `setValues` and | ||
`controller`. | ||
`setValues` is a function that must be called with the initial values as a Set | ||
before the passed `listen` function ends and before any new subscriptions are | ||
added to the LiveSet being activated. | ||
`controller` is an object with three methods, `add(value)`, `remove(value)`, | ||
`error(error: any)` and `end()`. These are to be used to modify the LiveSet's | ||
values. Do not modify the Set originally passed to `setValues` to manipulate the | ||
LiveSet. `end()` may be called to signify that the LiveSet will have no more | ||
changes; the LiveSet will become frozen with its current values at that point. | ||
References to subscribers will be released when a LiveSet is ended. The `error` | ||
function ends the LiveSet and delivers an error value to any current | ||
subscribers. | ||
The `listen` function may return a function to call upon deactivation, or an | ||
object with an `unsubscribe` method (to call upon deactivation) and optionally | ||
a `pullChanges` method. The pullChanges method will be called to flush any | ||
changes from the source when the `values()` method is called on the LiveSet, or | ||
the `pullChanges` method is called on a LiveSetSubscription. If the `listen` | ||
function subscribes to a LiveSet, then it may be useful to have the `listen` | ||
function return the LiveSetSubscription, which has unsubscribe and pullChanges | ||
methods. | ||
#### LiveSet.constant | ||
`LiveSet.constant<T>(values: Set<T>): LiveSet<T>` | ||
This creates a LiveSet with a set of values that will never change. The LiveSet | ||
will start in the ended state, and therefore will never deliver change | ||
notifications or keep references to subscribers. | ||
#### LiveSet.active | ||
`LiveSet.active<T>(initialValues?: Set<T>): {liveSet: LiveSet<T>, controller: LiveSetController<T>}` | ||
This is a convenience method to create a LiveSet that starts out in the | ||
activated state and never exits the activated state. The new LiveSet and its | ||
controller (the same type as passed to the `listen` callback passed to the | ||
constructor) are returned. | ||
Be warned that this function eschews the normal activation/deactivation | ||
lifecycle of LiveSets. If the LiveSet requires some resource to be held open to | ||
keep it populated, then you will not be able to auto-close the resource when | ||
the LiveSet loses its subscribers. You will have to provide your own mechanism | ||
to close the resource manually if necessary. | ||
This function is inspired by the nonstandard "Promise.defer()" function that | ||
some Promise libraries have implemented. | ||
#### LiveSet::isEnded | ||
`LiveSet<T>::isEnded(): boolean` | ||
This returns whether the LiveSet is in the ended state. LiveSets in the ended | ||
state will never have their values change, deliver any change notifications, or | ||
keep references to their subscribers. | ||
#### LiveSet::values | ||
`LiveSet<T>::values(): Set<T>` | ||
This returns a Set containing all of the LiveSet's current values at the time | ||
of the method call. If the LiveSet is modified, then previously-returned Set | ||
objects will not include the modifications. The Set object return by the | ||
values() method must not be modified. | ||
If the LiveSet is currently inactive, then this will trigger the `read` | ||
function passed to the constructor to be called. If the LiveSet is currently | ||
active, then this will trigger the `pullChanges` function returned by the | ||
constructor's `listen` function if present. | ||
#### LiveSet::subscribe | ||
`LiveSet<T>::subscribe(observer): LiveSetSubscription` | ||
This function is used to subscribe to change notifications from the LiveSet. | ||
The observer parameter must either be an Observer object with optional `start`, | ||
`next`, `error`, and `complete` functions, or a function which is treated as an | ||
Observer object with that function as the `next` method. The subscribe method | ||
returns a LiveSetSubscription object. | ||
The `start` function is called when the subscription first starts, before the | ||
subscribe call has returned, and it is passed a reference to the | ||
LiveSetSubscription object which will be returned. During the `start` function, | ||
the LiveSet being subscribed to is guaranteed to be active, so it's a good time | ||
to read the current values of the LiveSet with the values() method. | ||
The `next` function is called after any changes have been made to the LiveSet's | ||
set of values. These changes notifications are delivered either asynchronously, | ||
or whenever change notifications are flushed early due to a `LiveSet::values()` | ||
or `LiveSetSubscription::pullChanges()` call. | ||
The `error` function is called if the LiveSet is ended by a call to | ||
`controller.error`, and it's passed the value passed to the `controller.error` | ||
method. | ||
The `complete` function is called if the LiveSet is ended by a call to | ||
`controller.end`. | ||
If either the `error` or `complete` function is called, then there will be no | ||
more calls to any of the observer's functions after that. | ||
This function is intended to be compatible with the Observable subscribe method | ||
of the [Observable proposal](https://tc39.github.io/proposal-observable/). | ||
#### LiveSetSubscription::closed | ||
`LiveSetSubscription::closed: boolean` | ||
This is true if the LiveSet has ended, or the subscription has been | ||
unsubscribed from. | ||
#### LiveSetSubscription::unsubscribe | ||
`LiveSetSubscription::unsubscribe(): void` | ||
This immediately unsubscribes the subscription. None of the observer functions | ||
will be called after unsubscription. | ||
#### LiveSetSubscription::pullChanges | ||
`LiveSetSubscription::pullChanges(): void` | ||
This will cause any queued change notifications to be immediately flushed to | ||
this subscription's observer's `next` function. This will not affect other | ||
subscriptions to the LiveSet. | ||
### Transformations | ||
@@ -288,20 +400,97 @@ | ||
This creates a LiveSet that contains only the values of the input `liveSet` | ||
for which they given callback function returns a truthy value for. | ||
#### live-set/map | ||
`map<T,U>(liveSet: LiveSet<T>, cb: (value: T) => U): LiveSet<U>` | ||
This creates a LiveSet that contains the result of `cb(value)` for each value | ||
in the input `liveSet` instead of the original values. The callback will only | ||
be called for the initial values and when values are added; the callback will | ||
not be called when a value is removed. | ||
The behavior is undefined if the callback returns the same value for distinct | ||
input values present in the input `liveSet` at the same time. | ||
#### live-set/transduce | ||
`transduce(liveSet: LiveSet<any>, transducer: Function): LiveSet<any>` | ||
This creates a new LiveSet based on a transformation implemented by the given | ||
transducer function. It supports any transducers implementation that follows | ||
[the transducer protocol](https://github.com/cognitect-labs/transducers-js#the-transducer-protocol), | ||
for example | ||
[jlongster/transducers.js](https://github.com/jlongster/transducers.js) | ||
or | ||
[cognitect-labs/transducers-js](https://github.com/cognitect-labs/transducers-js). | ||
To learn more about transducers please visit those libraries' pages. | ||
Transducers are recommended to be used to replace any sequence of multiple map | ||
or filter function calls. The use of transducers removes the need for | ||
intermediate LiveSets to be created. | ||
Note that each input value from the `liveSet` passed to the transducer is | ||
expected to immediately map to zero or more values. This mapping is remembered | ||
so that if the input value is later removed from the input `liveSet`, then the | ||
associated output values are all removed from the output LiveSet. This is fine | ||
for any combination of common transducers such as `map(cb)`, `filter(cb)`, and | ||
`take(n)`, but transducers which produce a many-to-one relationship between | ||
values such as `partition(n)` will not function in a sensible manner. | ||
The behavior is undefined if the transducer outputs equal values to be present | ||
in the output LiveSet at the same time. | ||
#### live-set/merge | ||
`merge<T>(liveSets: Array<LiveSet<T>>): LiveSet<T>` | ||
This function takes an array of LiveSets and returns a single LiveSet | ||
containing all of their values. | ||
The behavior is undefined if multiple input LiveSets contain the same value at | ||
the same time. | ||
#### live-set/flatMap | ||
`flatMap<T,U>(liveSet: LiveSet<T>, cb: (value: T) => LiveSet<U>): LiveSet<U>` | ||
This function calls the given callback function for each value in the input | ||
`liveSet`, and merges the values of all returned LiveSets into one LiveSet. | ||
When a new value is added to the input `liveSet`, then the callback will be | ||
called a new LiveSet's values will be merged in. When a value is removed from | ||
the input `liveSet`, then the values from the LiveSet created for that value | ||
will be removed from the output LiveSet. | ||
The behavior is undefined if any of the LiveSets returned by the callback | ||
contain equal values at the same time. | ||
#### live-set/mapWithRemoval | ||
`mapWithRemoval<T,U>(input: LiveSet<T>, cb: (value: T, removal: Promise<void>) => U): LiveSet<U>` | ||
This is similar to the live-set/map function, but the callback is also passed a | ||
promise that will resolve when the value is removed from the input `liveSet`. | ||
The LiveSet returned by this function may not have `values()` called on it | ||
while it is inactive. | ||
The behavior is undefined if the callback returns the same value for distinct | ||
input values present in the input `liveSet` at the same time. | ||
#### live-set/toValueObservable | ||
`toValueObservable<T>(liveSet: LiveSet<T>): Observable<{value: T, removal: Promise<void>}>` | ||
This will return an [Observable](https://tc39.github.io/proposal-observable/) | ||
instance which upon subscription will emit a `{value, removal}` object for | ||
every `value` currently in the input `liveSet` where `removal` is a Promise | ||
which will resolve after the `value` is removed from the input `liveSet`. | ||
## Bundling Note | ||
To use this module in browsers, a CommonJS bundler such as Browserify or | ||
Webpack should be used. | ||
LiveSet's code adds additional checks in some places if `process.env.NODE_ENV` | ||
is not set to "production". If you're using Browserify, then setting the | ||
NODE_ENV environment variable to "production" is enough to disable these | ||
checks. Webpack may require additional configuration. | ||
The additional checks make sure that the Set passed to `setValues` and the Set | ||
returned from the `values()` method are not modified. | ||
## Types | ||
@@ -308,0 +497,0 @@ |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
153369
991
497
5
2
+ Addedenvify@^4.0.0
+ Addedenvify@4.1.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedthrough@2.3.8(transitive)