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

remotedev-utils

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remotedev-utils - npm Package Compare versions

Comparing version 0.0.5 to 0.1.0

lib/importState.js

48

lib/filters.js
'use strict';
exports.__esModule = true;
exports.FilterState = undefined;

@@ -70,10 +71,20 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

function filterState(state, type, localFilter, statesFilter, actionsFilter, nextActionId) {
if (type === 'ACTION') return !statesFilter ? state : statesFilter(state, nextActionId - 1);else if (type !== 'STATE') return state;
var FilterState = exports.FilterState = {
DO_NOT_FILTER: 'DO_NOT_FILTER',
BLACKLIST_SPECIFIC: 'BLACKLIST_SPECIFIC',
WHITELIST_SPECIFIC: 'WHITELIST_SPECIFIC'
};
if (localFilter) {
function filterState(state, type, localFilter, stateSanitizer, actionSanitizer, nextActionId, predicate) {
if (type === 'ACTION') return !stateSanitizer ? state : stateSanitizer(state, nextActionId - 1);else if (type !== 'STATE') return state;
var _ref2 = typeof window !== 'undefined' && window.devToolsOptions || {};
var filter = _ref2.filter;
if (predicate || localFilter || filter && filter !== FilterState.DO_NOT_FILTER) {
var _ret = function () {
var filteredStagedActionIds = [];
var filteredComputedStates = [];
var filteredActionsById = actionsFilter && {};
var sanitizedActionsById = actionSanitizer && {};
var actionsById = state.actionsById;

@@ -84,10 +95,17 @@ var computedStates = state.computedStates;

state.stagedActionIds.forEach(function (id, idx) {
if (!isFiltered(actionsById[id], localFilter)) {
filteredStagedActionIds.push(id);
filteredComputedStates.push(statesFilter ? _extends({}, computedStates[idx], { state: statesFilter(computedStates[idx].state, idx) }) : computedStates[idx]);
if (actionsFilter) {
filteredActionsById[id] = _extends({}, actionsById[id], { action: actionsFilter(actionsById[id].action, id)
});
}
var liftedAction = actionsById[id];
var currAction = liftedAction.action;
var liftedState = computedStates[idx];
var currState = liftedState.state;
if (idx) {
if (predicate && !predicate(currState, currAction)) return;
if (isFiltered(currAction, localFilter)) return;
}
filteredStagedActionIds.push(id);
filteredComputedStates.push(stateSanitizer ? _extends({}, liftedState, { state: stateSanitizer(currState, idx) }) : liftedState);
if (actionSanitizer) {
sanitizedActionsById[id] = _extends({}, liftedAction, { action: actionSanitizer(currAction, id)
});
}
});

@@ -97,3 +115,3 @@

v: _extends({}, state, {
actionsById: filteredActionsById || actionsById,
actionsById: sanitizedActionsById || actionsById,
stagedActionIds: filteredStagedActionIds,

@@ -108,7 +126,7 @@ computedStates: filteredComputedStates

if (!statesFilter && !actionsFilter) return state;
if (!stateSanitizer && !actionSanitizer) return state;
return _extends({}, state, {
actionsById: filterActions(state.actionsById, actionsFilter),
computedStates: filterStates(state.computedStates, statesFilter)
actionsById: filterActions(state.actionsById, actionSanitizer),
computedStates: filterStates(state.computedStates, stateSanitizer)
});
}

@@ -12,2 +12,3 @@ 'use strict';

exports.evalMethod = evalMethod;
exports.stringify = stringify;

@@ -18,6 +19,14 @@ var _getParams = require('get-params');

var _jsan = require('jsan');
var _jsan2 = _interopRequireDefault(_jsan);
var _shortid = require('shortid');
var _shortid2 = _interopRequireDefault(_shortid);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function generateId() {
return Math.random().toString(36).substr(2);
function generateId(id) {
return id || _shortid2.default.generate();
}

@@ -100,2 +109,26 @@

}
/* eslint-enable */
/* eslint-enable */
function tryCatchStringify(obj) {
try {
return JSON.stringify(obj);
} catch (err) {
/* eslint-disable no-console */
if (process.env.NODE_ENV !== 'production') console.log('Failed to stringify', err);
/* eslint-enable no-console */
return _jsan2.default.stringify(obj, null, null, { circular: '[CIRCULAR]' });
}
}
function stringify(obj, serialize) {
if (typeof serialize === 'undefined') {
return tryCatchStringify(obj);
}
if (serialize === true) {
return _jsan2.default.stringify(obj, function (key, value) {
if (value && typeof value.toJS === 'function') return value.toJS();
return value;
}, null, true);
}
return _jsan2.default.stringify(obj, serialize.replacer, null, serialize.options);
}
{
"name": "remotedev-utils",
"version": "0.0.5",
"version": "0.1.0",
"description": "Utils for remotedev infrastructure",

@@ -15,2 +15,3 @@ "main": "lib/index.js",

"lint": "eslint src test",
"lintfix": "eslint src --fix",
"prepublish": "npm run lint && npm run clean && npm run build"

@@ -47,4 +48,9 @@ },

"get-params": "^0.1.2",
"lodash": "^4.0.0"
}
"jsan": "^3.1.5",
"lodash": "^4.0.0",
"shortid": "^2.2.6"
},
"pre-commit": [
"lint"
]
}

@@ -51,10 +51,19 @@ import mapValues from 'lodash/mapValues';

export function filterState(state, type, localFilter, statesFilter, actionsFilter, nextActionId) {
if (type === 'ACTION') return !statesFilter ? state : statesFilter(state, nextActionId - 1);
export const FilterState = {
DO_NOT_FILTER: 'DO_NOT_FILTER',
BLACKLIST_SPECIFIC: 'BLACKLIST_SPECIFIC',
WHITELIST_SPECIFIC: 'WHITELIST_SPECIFIC'
};
export function filterState(
state, type, localFilter, stateSanitizer, actionSanitizer, nextActionId, predicate
) {
if (type === 'ACTION') return !stateSanitizer ? state : stateSanitizer(state, nextActionId - 1);
else if (type !== 'STATE') return state;
if (localFilter) {
const { filter } = (typeof window !== 'undefined' && window.devToolsOptions) || {};
if (predicate || localFilter || (filter && filter !== FilterState.DO_NOT_FILTER)) {
const filteredStagedActionIds = [];
const filteredComputedStates = [];
const filteredActionsById = actionsFilter && {};
const sanitizedActionsById = actionSanitizer && {};
const { actionsById } = state;

@@ -64,15 +73,20 @@ const { computedStates } = state;

state.stagedActionIds.forEach((id, idx) => {
if (!isFiltered(actionsById[id], localFilter)) {
filteredStagedActionIds.push(id);
filteredComputedStates.push(
statesFilter ?
{ ...computedStates[idx], state: statesFilter(computedStates[idx].state, idx) } :
computedStates[idx]
);
if (actionsFilter) {
filteredActionsById[id] = {
...actionsById[id], action: actionsFilter(actionsById[id].action, id)
};
}
const liftedAction = actionsById[id];
const currAction = liftedAction.action;
const liftedState = computedStates[idx];
const currState = liftedState.state;
if (idx) {
if (predicate && !predicate(currState, currAction)) return;
if (isFiltered(currAction, localFilter)) return;
}
filteredStagedActionIds.push(id);
filteredComputedStates.push(
stateSanitizer ? { ...liftedState, state: stateSanitizer(currState, idx) } : liftedState
);
if (actionSanitizer) {
sanitizedActionsById[id] = {
...liftedAction, action: actionSanitizer(currAction, id)
};
}
});

@@ -82,3 +96,3 @@

...state,
actionsById: filteredActionsById || actionsById,
actionsById: sanitizedActionsById || actionsById,
stagedActionIds: filteredStagedActionIds,

@@ -89,8 +103,8 @@ computedStates: filteredComputedStates

if (!statesFilter && !actionsFilter) return state;
if (!stateSanitizer && !actionSanitizer) return state;
return {
...state,
actionsById: filterActions(state.actionsById, actionsFilter),
computedStates: filterStates(state.computedStates, statesFilter)
actionsById: filterActions(state.actionsById, actionSanitizer),
computedStates: filterStates(state.computedStates, stateSanitizer)
};
}
import getParams from 'get-params';
import jsan from 'jsan';
import shortid from 'shortid';
export function generateId() {
return Math.random().toString(36).substr(2);
export function generateId(id) {
return id || shortid.generate();
}

@@ -79,1 +81,25 @@

/* eslint-enable */
function tryCatchStringify(obj) {
try {
return JSON.stringify(obj);
} catch (err) {
/* eslint-disable no-console */
if (process.env.NODE_ENV !== 'production') console.log('Failed to stringify', err);
/* eslint-enable no-console */
return jsan.stringify(obj, null, null, { circular: '[CIRCULAR]' });
}
}
export function stringify(obj, serialize) {
if (typeof serialize === 'undefined') {
return tryCatchStringify(obj);
}
if (serialize === true) {
return jsan.stringify(obj, function (key, value) {
if (value && typeof value.toJS === 'function') return value.toJS();
return value;
}, null, true);
}
return jsan.stringify(obj, serialize.replacer, null, serialize.options);
}
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