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

frer

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frer - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

62

es/state.js

@@ -12,3 +12,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";

var eventLog = store.eventLog;
var conveyor$ = new Subject(); //传送带
var conveyor$ = new Subject(); //conveyor belt

@@ -105,4 +105,5 @@ function StateSubject(value) {

throw new Error("action's type must be string");
}
} //default options
var _options = {

@@ -113,4 +114,4 @@ useCache: false,

};
options = Object.assign({}, _options, options); //对eventBus中传递的数据进行处理,返回一个event$
//[this.name]: Object.assign({}, action(dispatch触发action), { type: this.name, new_value})
options = Object.assign({}, _options, options); //[this.name]: Object.assign({}, action, { type: this.name, new_value})
//type == name

@@ -120,3 +121,3 @@ var event$ = conveyor$.pipe(pluck(type), filter(function (event) {

if (!tools.isCorrectVal(event.payload)) event.payload = {};
if (!tools.isCorrectVal(event.options)) event.options = {}; //在headersMap里加上lastModifyId存储event
if (!tools.isCorrectVal(event.options)) event.options = {}; //Add lastModifyId to headersMap and store event

@@ -132,13 +133,14 @@ if (!tools.isCorrectVal(eventLog.pushHeadersMap[event.type])) {

var pushHeaders = eventLog.pushHeadersMap[event.type];
var lastEvent = pushHeaders.event; //有改动就更新header时间标识
var lastEvent = pushHeaders.event; //Update the header time mark if there is a change,
//and replace the event in the header
if (!options.useCache || JSON.stringify(lastEvent.payload) !== JSON.stringify(event.payload) || JSON.stringify(lastEvent.options) !== JSON.stringify(event.options)) {
eventLog.pushHeadersMap[event.type]["lastModifyId"] = new Date().getTime();
} //header中也更新下event
}
pushHeaders.event = event;
return true;
}));
var operations = [];
var operations = []; //Just as an order identifier
var _subscription = {

@@ -151,10 +153,10 @@ unsubscribe: function unsubscribe() {}

var obs$$ = new Subject();
obs$$.__type__ = type;
var new_obs$ = new Subject();
/* new_obs$.__type__ = type; */
var _obs$ = obs$.pipe(switchMap(function (event) {
var pushHeaders = eventLog.pushHeadersMap[event.type]; //需要更新
var pushHeaders = eventLog.pushHeadersMap[event.type]; //update tag
var hasModified = obs$$.lastModifyId !== pushHeaders.lastModifyId;
var cacheData; //允许使用缓存,并且没有更改的情况下,直接拿旧值
var hasModified = new_obs$.lastModifyId !== pushHeaders.lastModifyId;
var cacheData; //Cache is allowed, and if there is no change, the old value is taken directly

@@ -164,4 +166,4 @@ if (options.useCache && !hasModified) {

case "eventCache":
cacheData = eventLog.dataMap[event.type]; //拿到缓存值
//error
cacheData = eventLog.dataMap[event.type]; //get cache
//error log

@@ -175,9 +177,13 @@ if (!tools.isCorrectVal(cacheData)) {

}
} //给event上也加一个标识
}
event.hasModified = hasModified;
/*
The event is updated when it is updated, and the cacheData value is taken
if there is no or no update, and then passed to the next
*/
event.hasModified = hasModified; //event有更新就更新,没有或不需要更新就拿cacheData值
return hasModified ? operations.length === 0 ? of(event) : pipeFromArray(operations)(of(event)) : of(cacheData);
}), filter(function (data) {
//data is event
var canPass = !(data === null || typeof data === "undefined");

@@ -189,3 +195,3 @@ var pushHeaders = eventLog.pushHeadersMap[type];

if (canPass) {
obs$$.lastModifyId = pushHeaders.lastModifyId;
new_obs$.lastModifyId = pushHeaders.lastModifyId;
}

@@ -196,3 +202,3 @@

case "eventCache":
//做缓存
//cache
eventLog.dataMap[type] = data;

@@ -204,11 +210,13 @@ break;

return canPass;
}));
})); //_subscription is like an order,
//_subscription is SafeSubscriber,Automatically canceled the subscription after onNext
_subscription = _obs$.subscribe(obs$$);
return obs$$;
_subscription = _obs$.subscribe(new_obs$);
return new_obs$;
}
var processEvent$ = generateObs(event$);
var pE$ = generateObs(event$);
processEvent$.pipe = function () {
pE$.pipe = function () {
for (var i = 0; i < arguments.length; i++) {

@@ -221,3 +229,3 @@ operations.push(arguments[i]);

return processEvent$;
return pE$;
}

@@ -224,0 +232,0 @@

{
"name": "frer",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "./es/index.js",

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