Socket
Socket
Sign inDemoInstall

valtio

Package Overview
Dependencies
Maintainers
2
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valtio - npm Package Compare versions

Comparing version 2.0.0-alpha.1 to 2.0.0-alpha.2

2

package.json
{
"name": "valtio",
"private": false,
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"publishConfig": {

@@ -6,0 +6,0 @@ "tag": "next"

@@ -317,3 +317,3 @@ <img src="logo.svg" alt="valtio">

```js
import { proxyWithHistory } from 'valtio/utils'
import { proxyWithHistory } from 'valtio-history'

@@ -320,0 +320,0 @@ const state = proxyWithHistory({ count: 0 })

@@ -5,4 +5,3 @@ export { subscribeKey } from './utils/subscribeKey';

export { deepClone } from './utils/deepClone';
export { proxyWithHistory } from './utils/proxyWithHistory';
export { proxySet } from './utils/proxySet';
export { proxyMap } from './utils/proxyMap';

@@ -588,52 +588,2 @@ 'use strict';

function proxyWithHistory(initialValue, skipSubscribe) {
if (skipSubscribe === void 0) {
skipSubscribe = false;
}
var proxyObject = vanilla.proxy({
value: initialValue,
history: vanilla.ref({
wip: undefined,
snapshots: [],
index: -1
}),
clone: deepClone,
canUndo: function canUndo() {
return proxyObject.history.index > 0;
},
undo: function undo() {
if (proxyObject.canUndo()) {
proxyObject.value = proxyObject.history.wip = proxyObject.clone(proxyObject.history.snapshots[--proxyObject.history.index]);
}
},
canRedo: function canRedo() {
return proxyObject.history.index < proxyObject.history.snapshots.length - 1;
},
redo: function redo() {
if (proxyObject.canRedo()) {
proxyObject.value = proxyObject.history.wip = proxyObject.clone(proxyObject.history.snapshots[++proxyObject.history.index]);
}
},
saveHistory: function saveHistory() {
proxyObject.history.snapshots.splice(proxyObject.history.index + 1);
proxyObject.history.snapshots.push(vanilla.snapshot(proxyObject).value);
++proxyObject.history.index;
},
subscribe: function subscribe() {
return vanilla.subscribe(proxyObject, function (ops) {
if (ops.every(function (op) {
return op[1][0] === 'value' && (op[0] !== 'set' || op[2] !== proxyObject.history.wip);
})) {
proxyObject.saveHistory();
}
});
}
});
proxyObject.saveHistory();
if (!skipSubscribe) {
proxyObject.subscribe();
}
return proxyObject;
}
function proxySet(initialValues) {

@@ -792,4 +742,3 @@ var _proxy;

exports.proxySet = proxySet;
exports.proxyWithHistory = proxyWithHistory;
exports.subscribeKey = subscribeKey;
exports.watch = watch;

Sorry, the diff of this file is not supported yet

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