Socket
Socket
Sign inDemoInstall

proxy-state-tree

Package Overview
Dependencies
Maintainers
1
Versions
865
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-state-tree - npm Package Compare versions

Comparing version 1.0.0-1532274233141 to 1.0.0-1532533507115

10

es/index.d.ts

@@ -22,6 +22,10 @@ import { IS_PROXY, STATUS } from './proxify';

proxy: any;
currentFlushId: number;
constructor(state: object, options?: Options);
get(): any;
addTrackingPath(path: any): void;
flush(): Mutation[];
flush(): {
mutations: Mutation[];
flushId: number;
};
startMutationTracking(): void;

@@ -31,6 +35,6 @@ clearMutationTracking(): Mutation[];

clearPathsTracking(index: number): Set<string>;
addMutationListener(cb: (mutations: Mutation[]) => void): any;
addMutationListener(initialPaths: Set<string>, cb: () => void): any;
addMutationListener(cb: (mutations: Mutation[], flushId: number) => void): any;
addMutationListener(initialPaths: Set<string>, cb: (flushId: number) => void): any;
}
export { IS_PROXY };
export default ProxyStateTree;

@@ -21,2 +21,3 @@ import proxify, { IS_PROXY, STATUS } from './proxify';

this.proxy = proxify(this, state);
this.currentFlushId = 0;
}

@@ -34,2 +35,3 @@ get() {

const mutations = this.mutations.slice();
const flushId = this.currentFlushId++;
for (let objectChange of this.objectChanges) {

@@ -51,3 +53,3 @@ if (this.pathDependencies[objectChange]) {

for (let callback of pathCallbacksToCall) {
callback();
callback(flushId);
}

@@ -58,5 +60,8 @@ pathCallbacksToCall.clear();

for (let globalDependency of this.globalDependencies) {
globalDependency(mutations);
globalDependency(mutations, flushId);
}
return mutations;
return {
mutations,
flushId,
};
}

@@ -63,0 +68,0 @@ startMutationTracking() {

@@ -367,2 +367,3 @@ import ProxyStateTree, { IS_PROXY } from './';

test('should be able to register a listener using paths', () => {
expect.assertions(2);
let reactionCount = 0;

@@ -376,4 +377,5 @@ const tree = new ProxyStateTree({

const paths = tree.clearPathsTracking(trackId);
tree.addMutationListener(paths, () => {
tree.addMutationListener(paths, (flushId) => {
reactionCount++;
expect(flushId).toBe(0);
});

@@ -387,3 +389,3 @@ tree.startMutationTracking();

test('should be able to register a global listener', () => {
expect.assertions(1);
expect.assertions(2);
const tree = new ProxyStateTree({

@@ -393,3 +395,3 @@ foo: 'bar',

const state = tree.get();
tree.addMutationListener((mutations) => {
tree.addMutationListener((mutations, flushId) => {
expect(mutations).toEqual([

@@ -402,2 +404,3 @@ {

]);
expect(flushId).toBe(0);
});

@@ -511,15 +514,18 @@ tree.startMutationTracking();

tree.clearMutationTracking();
const mutations = tree.flush();
expect(mutations).toEqual([
{
path: 'foo',
method: 'set',
args: ['bar2'],
},
{
path: 'foo',
method: 'set',
args: ['bar3'],
},
]);
const flushResult = tree.flush();
expect(flushResult).toEqual({
flushId: 0,
mutations: [
{
path: 'foo',
method: 'set',
args: ['bar2'],
},
{
path: 'foo',
method: 'set',
args: ['bar3'],
},
],
});
});

@@ -526,0 +532,0 @@ });

@@ -22,6 +22,10 @@ import { IS_PROXY, STATUS } from './proxify';

proxy: any;
currentFlushId: number;
constructor(state: object, options?: Options);
get(): any;
addTrackingPath(path: any): void;
flush(): Mutation[];
flush(): {
mutations: Mutation[];
flushId: number;
};
startMutationTracking(): void;

@@ -31,6 +35,6 @@ clearMutationTracking(): Mutation[];

clearPathsTracking(index: number): Set<string>;
addMutationListener(cb: (mutations: Mutation[]) => void): any;
addMutationListener(initialPaths: Set<string>, cb: () => void): any;
addMutationListener(cb: (mutations: Mutation[], flushId: number) => void): any;
addMutationListener(initialPaths: Set<string>, cb: (flushId: number) => void): any;
}
export { IS_PROXY };
export default ProxyStateTree;

@@ -24,2 +24,3 @@ "use strict";

this.proxy = proxify_1.default(this, state);
this.currentFlushId = 0;
}

@@ -37,2 +38,3 @@ get() {

const mutations = this.mutations.slice();
const flushId = this.currentFlushId++;
for (let objectChange of this.objectChanges) {

@@ -54,3 +56,3 @@ if (this.pathDependencies[objectChange]) {

for (let callback of pathCallbacksToCall) {
callback();
callback(flushId);
}

@@ -61,5 +63,8 @@ pathCallbacksToCall.clear();

for (let globalDependency of this.globalDependencies) {
globalDependency(mutations);
globalDependency(mutations, flushId);
}
return mutations;
return {
mutations,
flushId,
};
}

@@ -66,0 +71,0 @@ startMutationTracking() {

@@ -369,2 +369,3 @@ "use strict";

test('should be able to register a listener using paths', () => {
expect.assertions(2);
let reactionCount = 0;

@@ -378,4 +379,5 @@ const tree = new _1.default({

const paths = tree.clearPathsTracking(trackId);
tree.addMutationListener(paths, () => {
tree.addMutationListener(paths, (flushId) => {
reactionCount++;
expect(flushId).toBe(0);
});

@@ -389,3 +391,3 @@ tree.startMutationTracking();

test('should be able to register a global listener', () => {
expect.assertions(1);
expect.assertions(2);
const tree = new _1.default({

@@ -395,3 +397,3 @@ foo: 'bar',

const state = tree.get();
tree.addMutationListener((mutations) => {
tree.addMutationListener((mutations, flushId) => {
expect(mutations).toEqual([

@@ -404,2 +406,3 @@ {

]);
expect(flushId).toBe(0);
});

@@ -513,15 +516,18 @@ tree.startMutationTracking();

tree.clearMutationTracking();
const mutations = tree.flush();
expect(mutations).toEqual([
{
path: 'foo',
method: 'set',
args: ['bar2'],
},
{
path: 'foo',
method: 'set',
args: ['bar3'],
},
]);
const flushResult = tree.flush();
expect(flushResult).toEqual({
flushId: 0,
mutations: [
{
path: 'foo',
method: 'set',
args: ['bar2'],
},
{
path: 'foo',
method: 'set',
args: ['bar3'],
},
],
});
});

@@ -528,0 +534,0 @@ });

{
"name": "proxy-state-tree",
"version": "1.0.0-1532274233141",
"version": "1.0.0-1532533507115",
"description": "An implementation of the Mobx/Vue state tracking approach, for library authors",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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