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

@ngneat/elf-state-history

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ngneat/elf-state-history - npm Package Compare versions

Comparing version 1.0.0-beta.2 to 1.0.1

CHANGELOG.md

2

package.json
{
"name": "@ngneat/elf-state-history",
"version": "1.0.0-beta.2",
"version": "1.0.1",
"description": "State history management for elf store",

@@ -5,0 +5,0 @@ "publishConfig": {

import { BehaviorSubject } from 'rxjs';
import { distinctUntilChanged, pairwise } from 'rxjs/operators';
import { distinctUntilChanged, filter } from 'rxjs/operators';
import { isFunction } from '@ngneat/elf';

@@ -20,7 +20,6 @@

this.hasFuture$ = this.hasFutureSubject.asObservable().pipe(distinctUntilChanged());
this.mergedOptions = {
this.mergedOptions = Object.assign({
maxAge: 10,
comparatorFn: () => true,
...options
};
comparatorFn: () => true
}, options);
this.activate();

@@ -38,10 +37,6 @@ }

activate() {
this.history.present = this.store.getValue();
this.subscription = this.store.pipe(pairwise()).subscribe(([past, present]) => {
if (this.skipUpdate || this.paused) {
return;
}
this.subscription = this.store.pipe(filter(() => !(this.skipUpdate || this.paused))).subscribe(present => {
const past = this.history.present;
const shouldUpdate = !past || this.mergedOptions.comparatorFn(past, present);
const shouldUpdate = this.mergedOptions.comparatorFn(past, present);
if (shouldUpdate) {

@@ -52,3 +47,6 @@ if (this.history.past.length === this.mergedOptions.maxAge) {

this.history.past = [...this.history.past, past];
if (past) {
this.history.past = [...this.history.past, past];
}
this.history.present = present;

@@ -163,2 +161,4 @@ this.updateHasHistory();

} = {}) {
var _this$subscription;
if (clearHistory) {

@@ -168,3 +168,3 @@ this.clear();

this.subscription?.unsubscribe();
(_this$subscription = this.subscription) == null ? void 0 : _this$subscription.unsubscribe();
}

@@ -171,0 +171,0 @@

@@ -5,3 +5,3 @@ (function (global, factory) {

(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.StateHistory = {}, global.Rx, global.Rx, global.elf));
}(this, (function (exports, rxjs, operators, elf) { 'use strict';
})(this, (function (exports, rxjs, operators, elf) { 'use strict';

@@ -40,3 +40,5 @@ /*! *****************************************************************************

var StateHistory = function () {
var StateHistory =
/** @class */
function () {
function StateHistory(store, options) {

@@ -87,13 +89,9 @@ if (options === void 0) {

this.history.present = this.store.getValue();
this.subscription = this.store.pipe(operators.pairwise()).subscribe(function (_a) {
var past = _a[0],
present = _a[1];
this.subscription = this.store.pipe(operators.filter(function () {
return !(_this.skipUpdate || _this.paused);
})).subscribe(function (present) {
var past = _this.history.present;
if (_this.skipUpdate || _this.paused) {
return;
}
var shouldUpdate = !past || _this.mergedOptions.comparatorFn(past, present);
var shouldUpdate = _this.mergedOptions.comparatorFn(past, present);
if (shouldUpdate) {

@@ -104,3 +102,6 @@ if (_this.history.past.length === _this.mergedOptions.maxAge) {

_this.history.past = __spreadArray(__spreadArray([], _this.history.past), [past]);
if (past) {
_this.history.past = __spreadArray(__spreadArray([], _this.history.past, true), [past]);
}
_this.history.present = present;

@@ -135,3 +136,3 @@

var newFuture = future.slice(1);
this.history.past = __spreadArray(__spreadArray([], past), [present]);
this.history.past = __spreadArray(__spreadArray([], past, true), [present]);
this.history.present = next;

@@ -151,3 +152,3 @@ this.history.future = newFuture;

var newFuture = __spreadArray(__spreadArray(__spreadArray([], past.slice(index + 1)), [present]), future);
var newFuture = __spreadArray(__spreadArray(__spreadArray([], past.slice(index + 1), true), [present], false), future);

@@ -168,3 +169,3 @@ var newPresent = past[index];

var newPast = __spreadArray(__spreadArray(__spreadArray([], past), [present]), future.slice(0, index));
var newPast = __spreadArray(__spreadArray(__spreadArray([], past, true), [present], false), future.slice(0, index));

@@ -269,2 +270,2 @@ var newPresent = future[index];

})));
}));
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