New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mobx-state-tree

Package Overview
Dependencies
Maintainers
2
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-state-tree - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

lib/types/utility-types/late.d.ts

8

changelog.md

@@ -0,1 +1,9 @@

# 0.5.0
* ** BREAKING ** protection is now enabled by default (#101)
* ** BREAKING ** it is no longer possible to read values from a dead object. Except through `getSnapshot` or `clone` (#102)
* ** BREAKING ** `types.recursive` has been removed in favor of `types.late`
* Introduced `unprotect`, to disable protection mode for a certain instance. Useful in `afterCreate` hooks
* Introduced `types.late`. Usage: `types.late(() => typeDefinition)`. Can be used for circular / recursive type definitions, even across files. See `test/circular(1|2).ts` for an example (#74)
# 0.4.0

@@ -2,0 +10,0 @@

11

lib/core/mst-node-administration.d.ts

@@ -12,6 +12,6 @@ import { IType } from "../types/type";

readonly type: ComplexType<any, any>;
isProtectionEnabled: boolean;
_environment: any;
_isRunningAction: boolean;
private _isAlive;
private _isProtected;
private _isDetaching;

@@ -32,2 +32,4 @@ readonly middlewares: IMiddleWareHandler[];

die(): void;
aboutToDie(): void;
finalizeDeath(): void;
assertAlive(): void;

@@ -54,3 +56,7 @@ readonly snapshot: any;

readonly isProtected: boolean;
protect(): void;
/**
* Pseudo action is an action that is not named, does not trigger middleware but does unlock the tree.
* Used for applying (initial) snapshots and patches
*/
pseudoAction(fn: () => void): void;
assertWritable(): void;

@@ -60,2 +66,3 @@ removeChild(subpath: string): void;

fireHook(name: string): void;
toString(): string;
}

67

lib/core/mst-node-administration.js

@@ -23,6 +23,6 @@ "use strict";

this.subpath = "";
this.isProtectionEnabled = true;
this._environment = undefined;
this._isRunningAction = false; // only relevant for root
this._isAlive = true; // optimization: use binary flags for all these switches
this._isProtected = false;
this._isDetaching = false;

@@ -95,9 +95,14 @@ this.middlewares = [];

return;
this.type.getChildMSTs(this).forEach(function (_a) {
var _ = _a[0], node = _a[1];
node.die();
});
// TODO: kill $mobx.values
mst_operations_1.walk(this.target, function (child) { return mst_node_1.getMSTAdministration(child).aboutToDie(); });
mst_operations_1.walk(this.target, function (child) { return mst_node_1.getMSTAdministration(child).finalizeDeath(); });
};
MSTAdministration.prototype.aboutToDie = function () {
this.disposers.splice(0).forEach(function (f) { return f(); });
this.fireHook("beforeDestroy");
this.disposers.splice(0).reverse().forEach(function (f) { return f(); });
};
MSTAdministration.prototype.finalizeDeath = function () {
// invariant: not called directly but from "die"
var self = this;
var oldPath = this.path;
utils_1.addReadOnlyProp(this, "snapshot", this.snapshot); // kill the computed prop and just store the last snapshot
this.patchSubscribers.splice(0);

@@ -109,7 +114,13 @@ this.snapshotSubscribers.splice(0);

this.subpath = "";
// Post conditions, element will not be in the tree anymore...
// This is quite a hack, once interceptable objects / arrays / maps are extracted from mobx,
// we could express this in a much nicer way
Object.defineProperty(this.target, "$mobx", {
get: function () {
utils_1.fail("This object has died and is no longer part of a state tree. It cannot be used anymore. The object (of type '" + self.type.name + "') used to live at '" + oldPath + "'. It is possible to access the last snapshot of this object using 'getSnapshot', or to create a fresh copy using 'clone'. If you want to remove an object from the tree without killing it, use 'detach' instead.");
}
});
};
MSTAdministration.prototype.assertAlive = function () {
if (!this._isAlive)
utils_1.fail("The model cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value");
utils_1.fail(this + " cannot be used anymore as it has died; it has been removed from a state tree. If you want to remove an element from a tree and let it live on, use 'detach' or 'clone' the value");
};

@@ -129,3 +140,2 @@ Object.defineProperty(MSTAdministration.prototype, "snapshot", {

MSTAdministration.prototype.applySnapshot = function (snapshot) {
this.assertWritable();
type_1.typecheck(this.type, snapshot);

@@ -137,3 +147,5 @@ return this.type.applySnapshot(this, snapshot);

var node = this.resolvePath(parts.slice(0, -1));
node.applyPatchLocally(parts[parts.length - 1], patch);
node.pseudoAction(function () {
node.applyPatchLocally(parts[parts.length - 1], patch);
});
};

@@ -162,6 +174,6 @@ MSTAdministration.prototype.applyPatchLocally = function (subpath, patch) {

if (this._parent && newParent && newParent !== this._parent) {
utils_1.fail("A node cannot exists twice in the state tree. Failed to add object to path '" + newParent.path + "\"/\"" + subpath + "', it exists already at '" + this.path + "'");
utils_1.fail("A node cannot exists twice in the state tree. Failed to add " + this + " to path '" + newParent.path + "/" + subpath + "'.");
}
if (!this._parent && newParent && newParent.root === this) {
utils_1.fail("A state tree is not allowed to contain itself. Cannot add root to path '" + newParent.path + "\"/\"" + subpath + "'");
utils_1.fail("A state tree is not allowed to contain itself. Cannot assign " + this + " to path '" + newParent.path + "/" + subpath + "'");
}

@@ -176,3 +188,3 @@ if (!this._parent && !!this._environment) {

this._parent = newParent;
this.subpath = subpath || ""; // TODO: mweh
this.subpath = subpath || "";
this.fireHook("afterAttach");

@@ -182,3 +194,3 @@ }

MSTAdministration.prototype.addDisposer = function (disposer) {
this.disposers.push(disposer);
this.disposers.unshift(disposer);
};

@@ -299,7 +311,7 @@ MSTAdministration.prototype.reconcileChildren = function (childType, oldValues, newValues, newPaths) {

while (cur) {
if (cur._isProtected === true)
return true;
if (cur.isProtectionEnabled === false)
return false;
cur = cur.parent;
}
return false;
return true;
},

@@ -309,4 +321,11 @@ enumerable: true,

});
MSTAdministration.prototype.protect = function () {
this._isProtected = true;
/**
* Pseudo action is an action that is not named, does not trigger middleware but does unlock the tree.
* Used for applying (initial) snapshots and patches
*/
MSTAdministration.prototype.pseudoAction = function (fn) {
var inAction = this._isRunningAction;
this._isRunningAction = true;
fn();
this._isRunningAction = inAction;
};

@@ -316,3 +335,3 @@ MSTAdministration.prototype.assertWritable = function () {

if (!this.isRunningAction() && this.isProtected) {
utils_1.fail("Cannot modify '" + this.path + "', the object is protected and can only be modified from model actions");
utils_1.fail("Cannot modify '" + this + "', the object is protected and can only be modified by using an action.");
}

@@ -342,2 +361,7 @@ };

};
MSTAdministration.prototype.toString = function () {
var identifierAttr = object_1.getIdentifierAttribute(this.type);
var identifier = identifierAttr ? "(" + identifierAttr + ": " + this.target[identifierAttr] + ")" : "";
return this.type.name + "@" + (this.path || "<root>") + identifier + (this.isAlive ? "" : "[dead]");
};
return MSTAdministration;

@@ -361,2 +385,3 @@ }());

exports.MSTAdministration = MSTAdministration;
var mst_operations_1 = require("./mst-operations");
//# sourceMappingURL=mst-node-administration.js.map

@@ -136,2 +136,3 @@ import { IRawActionCall, ISerializedActionCall } from "./action";

export declare function protect(target: IMSTNode): void;
export declare function unprotect(target: IMSTNode): void;
/**

@@ -257,2 +258,6 @@ * Returns true if the object is in protected mode, @see protect

export declare function getEnv(thing: IMSTNode): any;
/**
* Performs a depth first walk through a tree
*/
export declare function walk(thing: IMSTNode, processor: (item: IMSTNode) => void): void;
export declare function testActions<S, T>(factory: IType<S, IMSTNode>, initialState: S, ...actions: ISerializedActionCall[]): S;

@@ -52,3 +52,3 @@ "use strict";

var node = mst_node_1.getMSTAdministration(target);
if (!node.isProtected)
if (!node.isProtectionEnabled)
console.warn("It is recommended to protect the state tree before attaching action middleware, as otherwise it cannot be guaranteed that all changes are passed through middleware. See `protect`");

@@ -165,5 +165,9 @@ return node.addMiddleWare(middleware);

function protect(target) {
mst_node_1.getMSTAdministration(target).protect();
mst_node_1.getMSTAdministration(target).isProtectionEnabled = true;
}
exports.protect = protect;
function unprotect(target) {
mst_node_1.getMSTAdministration(target).isProtectionEnabled = false;
}
exports.unprotect = unprotect;
/**

@@ -173,3 +177,3 @@ * Returns true if the object is in protected mode, @see protect

function isProtected(target) {
return mst_node_1.getMSTAdministration(target).isProtected;
return mst_node_1.getMSTAdministration(target).isProtectionEnabled;
}

@@ -223,3 +227,3 @@ exports.isProtected = isProtected;

}
return utils_1.fail("Failed to find a parent for '" + getPath(target) + " with depth " + depth);
return utils_1.fail("Failed to find the parent of " + mst_node_1.getMSTAdministration(target) + " at depth " + depth);
}

@@ -346,6 +350,19 @@ exports.getParent = getParent;

var env = node.root._environment;
utils_1.invariant(!!env, "Node '" + node.path + "' is not part of state tree that was initialized with an environment. Environment can be passed as second argumentt to .create()");
utils_1.invariant(!!env, "Node '" + node + "' is not part of state tree that was initialized with an environment. Environment can be passed as second argumentt to .create()");
return env;
}
exports.getEnv = getEnv;
/**
* Performs a depth first walk through a tree
*/
function walk(thing, processor) {
var node = mst_node_1.getMSTAdministration(thing);
// tslint:disable-next-line:no_unused-variable
node.getChildMSTs().forEach(function (_a) {
var _ = _a[0], childNode = _a[1];
walk(childNode.target, processor);
});
processor(node.target);
}
exports.walk = walk;
// TODO: remove or to test utils?

@@ -352,0 +369,0 @@ function testActions(factory, initialState) {

import "./types/type";
import "./types/complex-types/complex-type";
export { types } from "./types";
export { types, IType } from "./types";
export * from "./core/mst-operations";

@@ -5,0 +5,0 @@ export * from "./core/json-patch";

@@ -5,2 +5,3 @@ import { IObservableArray, IArrayWillChange, IArrayWillSplice, IArrayChange, IArraySplice } from "mobx";

import { ComplexType } from "./complex-type";
export declare function arrayToString(this: IObservableArray<any>): string;
export declare class ArrayType<T> extends ComplexType<T[], IObservableArray<T>> {

@@ -7,0 +8,0 @@ isArrayFactory: boolean;

@@ -25,2 +25,6 @@ "use strict";

var with_default_1 = require("../utility-types/with-default");
function arrayToString() {
return core_1.getMSTAdministration(this) + "(" + this.length + " items)";
}
exports.arrayToString = arrayToString;
var ArrayType = (function (_super) {

@@ -38,3 +42,5 @@ __extends(ArrayType, _super);

ArrayType.prototype.createNewInstance = function () {
return mobx_1.observable.shallowArray();
var array = mobx_1.observable.shallowArray();
utils_1.addHiddenFinalProp(array, "toString", arrayToString);
return array;
};

@@ -131,4 +137,6 @@ ArrayType.prototype.finalizeNewInstance = function (instance, snapshot) {

ArrayType.prototype.applySnapshot = function (node, snapshot) {
var target = node.target;
target.replace(snapshot);
node.pseudoAction(function () {
var target = node.target;
target.replace(snapshot);
});
};

@@ -135,0 +143,0 @@ ArrayType.prototype.getChildType = function (key) {

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

ComplexType.prototype.create = function (snapshot, environment, parent, subpath) {
var _this = this;
if (snapshot === void 0) { snapshot = this.getDefaultSnapshot(); }

@@ -35,3 +36,5 @@ if (environment === void 0) { environment = undefined; }

var node = new mst_node_administration_1.MSTAdministration(parent, subpath, instance, this, environment);
this.finalizeNewInstance(instance, snapshot);
node.pseudoAction(function () {
_this.finalizeNewInstance(instance, snapshot);
});
node.fireHook("afterCreate");

@@ -38,0 +41,0 @@ if (parent)

@@ -8,2 +8,3 @@ import { ObservableMap, IMapChange, IMapWillChange } from "mobx";

}
export declare function mapToString(this: ObservableMap<any>): string;
export declare class MapType<S, T> extends ComplexType<{

@@ -10,0 +11,0 @@ [key: string]: S;

@@ -26,2 +26,13 @@ "use strict";

var complex_type_1 = require("./complex-type");
function mapToString() {
return core_1.getMSTAdministration(this) + "(" + this.size + " items)";
}
exports.mapToString = mapToString;
function put(value) {
var identifierAttr = object_1.getIdentifierAttribute(core_1.getMSTAdministration(this).type.subType);
utils_1.invariant(!!identifierAttr, "Map.put is only supported if the subtype has an idenfier attribute");
utils_1.invariant(!!value, "Map.put cannot be used to set empty values");
this.set(value[identifierAttr], value);
return this;
}
var MapType = (function (_super) {

@@ -41,8 +52,4 @@ __extends(MapType, _super);

var map = mobx_1.observable.shallowMap();
map.put = function (value) {
utils_1.invariant(!!identifierAttr, "Map.put is only supported if the subtype has an idenfier attribute");
utils_1.invariant(!!value, "Map.put cannot be used to set empty values");
this.set(value[identifierAttr], value);
return this;
};
utils_1.addHiddenFinalProp(map, "put", put);
utils_1.addHiddenFinalProp(map, "toString", mapToString);
return map;

@@ -139,29 +146,32 @@ };

MapType.prototype.applySnapshot = function (node, snapshot) {
var target = node.target;
var identifierAttr = object_1.getIdentifierAttribute(this.subType);
// Try to update snapshot smartly, by reusing instances under the same key as much as possible
var currentKeys = {};
target.keys().forEach(function (key) { currentKeys[key] = false; });
Object.keys(snapshot).forEach(function (key) {
var item = snapshot[key];
if (identifierAttr && item && typeof item === "object" && key !== item[identifierAttr])
utils_1.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '" + key + "', but expected: '" + item[identifierAttr] + "'");
// if snapshot[key] is non-primitive, and this.get(key) has a Node, update it, instead of replace
if (key in currentKeys && !utils_1.isPrimitive(item)) {
currentKeys[key] = true;
core_1.maybeMST(target.get(key), function (propertyNode) {
// update existing instance
propertyNode.applySnapshot(item);
}, function () {
var _this = this;
node.pseudoAction(function () {
var target = node.target;
var identifierAttr = object_1.getIdentifierAttribute(_this.subType);
// Try to update snapshot smartly, by reusing instances under the same key as much as possible
var currentKeys = {};
target.keys().forEach(function (key) { currentKeys[key] = false; });
Object.keys(snapshot).forEach(function (key) {
var item = snapshot[key];
if (identifierAttr && item && typeof item === "object" && key !== item[identifierAttr])
utils_1.fail("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '" + key + "', but expected: '" + item[identifierAttr] + "'");
// if snapshot[key] is non-primitive, and this.get(key) has a Node, update it, instead of replace
if (key in currentKeys && !utils_1.isPrimitive(item)) {
currentKeys[key] = true;
core_1.maybeMST(target.get(key), function (propertyNode) {
// update existing instance
propertyNode.applySnapshot(item);
}, function () {
target.set(key, item);
});
}
else {
target.set(key, item);
});
}
else {
target.set(key, item);
}
}
});
Object.keys(currentKeys).forEach(function (key) {
if (currentKeys[key] === false)
target.delete(key);
});
});
Object.keys(currentKeys).forEach(function (key) {
if (currentKeys[key] === false)
target.delete(key);
});
};

@@ -168,0 +178,0 @@ MapType.prototype.getChildType = function (key) {

@@ -36,3 +36,3 @@ import { IObjectChange, IObjectWillChange } from "mobx";

}
export declare type IBaseModelDefinition<T> = {
export declare type IModelProperties<T> = {
[K in keyof T]: IType<any, T[K]> | T[K];

@@ -45,6 +45,6 @@ };

}
export declare function createModelFactory<T>(baseModel: IBaseModelDefinition<T> & ThisType<T>): IModelType<T, {}>;
export declare function createModelFactory<T>(name: string, baseModel: IBaseModelDefinition<T> & ThisType<T>): IModelType<T, {}>;
export declare function createModelFactory<T, A>(baseModel: IBaseModelDefinition<T> & ThisType<T>, actions: A & ThisType<T & A>): IModelType<T, A>;
export declare function createModelFactory<T, A>(name: string, baseModel: IBaseModelDefinition<T> & ThisType<T>, actions: A & ThisType<T & A>): IModelType<T, A>;
export declare function createModelFactory<T>(properties: IModelProperties<T> & ThisType<T>): IModelType<T, {}>;
export declare function createModelFactory<T>(name: string, properties: IModelProperties<T> & ThisType<T>): IModelType<T, {}>;
export declare function createModelFactory<T, A>(properties: IModelProperties<T> & ThisType<T>, operations: A & ThisType<T & A>): IModelType<T, A>;
export declare function createModelFactory<T, A>(name: string, properties: IModelProperties<T> & ThisType<T>, operations: A & ThisType<T & A>): IModelType<T, A>;
export declare function extend<A, B, AA, BA>(name: string, a: IModelType<A, AA>, b: IModelType<B, BA>): IModelType<A & B, AA & BA>;

@@ -51,0 +51,0 @@ export declare function extend<A, B, C, AA, BA, CA>(name: string, a: IModelType<A, AA>, b: IModelType<B, BA>, c: IModelType<C, CA>): IModelType<A & B & C, AA & BA & CA>;

@@ -34,2 +34,5 @@ "use strict";

var view_property_1 = require("../property-types/view-property");
function objectTypeToString() {
return core_1.getMSTAdministration(this).toString();
}
var ObjectType = (function (_super) {

@@ -54,5 +57,3 @@ __extends(ObjectType, _super);

_this.modelConstructor = new Function("return function " + name + " (){}")(); // fancy trick to get a named function...., http://stackoverflow.com/questions/5905492/dynamic-function-name-in-javascript
_this.modelConstructor.prototype.toString = function () {
return "" + name + JSON.stringify(core_1.getSnapshot(this));
};
_this.modelConstructor.prototype.toString = objectTypeToString;
_this.parseModelProps();

@@ -154,7 +155,10 @@ _this.forAllProps(function (prop) { return prop.initializePrototype(_this.modelConstructor.prototype); });

ObjectType.prototype.applySnapshot = function (node, snapshot) {
// TODO:fix: all props should be processed when applying snapshot, and reset to default if needed
for (var key in snapshot)
if (key in this.props) {
this.props[key].deserialize(node.target, snapshot);
}
var _this = this;
// TODO:fix: all props should be processed when applying snapshot, and reset to default if needed?
node.pseudoAction(function () {
for (var key in snapshot)
if (key in _this.props) {
_this.props[key].deserialize(node.target, snapshot);
}
});
};

@@ -161,0 +165,0 @@ ObjectType.prototype.getChildType = function (key) {

@@ -5,16 +5,17 @@ import { IObservableArray } from "mobx";

import { IModelType } from "./complex-types/object";
export { IType };
export declare const types: {
model: {
<T>(baseModel: {
<T>(properties: {
[K in keyof T]: T[K] | IType<any, T[K]>;
} & ThisType<T>): IModelType<T, {}>;
<T>(name: string, baseModel: {
<T>(name: string, properties: {
[K in keyof T]: T[K] | IType<any, T[K]>;
} & ThisType<T>): IModelType<T, {}>;
<T, A>(baseModel: {
<T, A>(properties: {
[K in keyof T]: T[K] | IType<any, T[K]>;
} & ThisType<T>, actions: A & ThisType<T & A>): IModelType<T, A>;
<T, A>(name: string, baseModel: {
} & ThisType<T>, operations: A & ThisType<T & A>): IModelType<T, A>;
<T, A>(name: string, properties: {
[K in keyof T]: T[K] | IType<any, T[K]>;
} & ThisType<T>, actions: A & ThisType<T & A>): IModelType<T, A>;
} & ThisType<T>, operations: A & ThisType<T & A>): IModelType<T, A>;
};

@@ -56,4 +57,7 @@ extend: {

frozen: ISimpleType<any>;
recursive: <S, T>(name: string, def: (type: IType<S, T>) => IType<any, any>) => IType<any, any>;
identifier: () => string;
late: {
<S, T>(type: () => IType<S, T>): IType<S, T>;
<S, T>(name: string, type: () => IType<S, T>): IType<S, T>;
};
};

@@ -16,3 +16,3 @@ "use strict";

var primitives_1 = require("./primitives");
var recursive_1 = require("./utility-types/recursive");
var late_1 = require("./utility-types/late");
/**

@@ -54,5 +54,5 @@ *

frozen: frozen_1.frozen,
recursive: recursive_1.recursive,
identifier: identifier_1.identifier
identifier: identifier_1.identifier,
late: late_1.late
};
//# sourceMappingURL=index.js.map

@@ -39,3 +39,3 @@ "use strict";

var defaultValue = mst_node_1.isMST(defaultValueOrNode) ? mst_node_1.getMSTAdministration(defaultValueOrNode).snapshot : defaultValueOrNode;
utils_1.invariant(type.is(defaultValue), "Default value " + JSON.stringify(defaultValue) + " is not assignable to type " + type.name + ". Expected " + JSON.stringify(type.describe()));
type_1.typecheck(type, defaultValue);
return new DefaultValue(type, defaultValue);

@@ -45,3 +45,2 @@ }

var mst_node_1 = require("../../core/mst-node");
var utils_1 = require("../../utils");
//# sourceMappingURL=with-default.js.map
{
"name": "mobx-state-tree",
"version": "0.4.0",
"version": "0.5.0",
"description": "Opinionated, transactional, MobX powered state container",

@@ -11,7 +11,7 @@ "main": "lib/index.js",

"webpack": "webpack -p",
"build-tests": "tsc && tsc -p test/",
"build-tests": "tsc -p test/",
"test": "npm run build-tests && ava",
"watch": "concurrently --kill-others --names 'build,build-tests,test-runner' 'tsc --watch' 'tsc --watch -p test' --raw 'ava --watch'",
"prepublish": "npm run build && npm run build-docs",
"coverage": "tsc && tsc -p test/ && nyc ava && nyc report -r html && nyc report -r lcov",
"watch": "concurrently --kill-others --names 'build-tests,test-runner' 'tsc --watch -p test' --raw 'ava --watch'",
"_prepublish": "npm run build && npm run build-docs",
"coverage": "npm run build-tests && nyc ava && nyc report -r html && nyc report -r lcov",
"build-docs": "npm run quick-build && documentation readme lib/index.js --github --section API",

@@ -43,3 +43,3 @@ "lint": "tslint -c tslint.json 'src/**/*.ts'",

"tslint": "^3.15.1",
"typescript": "next",
"typescript": "2.3.2",
"webpack": "^1.13.1",

@@ -65,8 +65,8 @@ "webpack-fail-plugin": "^1.0.6"

"files": [
"test-lib/**/*.js"
"test-lib/test/**/*.js"
],
"source": [
"lib/**/*.js"
"test-lib/src/**/*.js"
]
}
}

@@ -67,2 +67,4 @@ # mobx-state-tree

TODO: properties & operations
Example:

@@ -163,2 +165,6 @@

## (Un) protecting state tree
`afterCreate() { unprotect(this) }`
## Views

@@ -325,3 +331,3 @@

[lib/core/mst-node.js:28-40](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-node.js#L28-L40 "Source code on GitHub")
[lib/core/mst-node.js:28-40](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-node.js#L28-L40 "Source code on GitHub")

@@ -340,3 +346,3 @@ Tries to convert a value to a TreeNode. If possible or already done,

[lib/types/complex-types/complex-type.js:18-50](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/types/complex-types/complex-type.js#L18-L50 "Source code on GitHub")
[lib/types/complex-types/complex-type.js:18-53](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/types/complex-types/complex-type.js#L18-L53 "Source code on GitHub")

@@ -347,9 +353,20 @@ A complex type produces a MST node (Node in the state tree)

[lib/core/mst-node-administration.js:51-55](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-node-administration.js#L51-L55 "Source code on GitHub")
[lib/core/mst-node-administration.js:51-55](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-node-administration.js#L51-L55 "Source code on GitHub")
Returnes (escaped) path representation as string
## pseudoAction
[lib/core/mst-node-administration.js:316-321](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-node-administration.js#L316-L321 "Source code on GitHub")
Pseudo action is an action that is not named, does not trigger middleware but does unlock the tree.
Used for applying (initial) snapshots and patches
**Parameters**
- `fn`
## map
[lib/types/index.js:24-26](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/types/index.js#L24-L26 "Source code on GitHub")
[lib/types/index.js:24-26](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/types/index.js#L24-L26 "Source code on GitHub")

@@ -362,3 +379,3 @@ **Parameters**

[lib/types/index.js:34-36](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/types/index.js#L34-L36 "Source code on GitHub")
[lib/types/index.js:34-36](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/types/index.js#L34-L36 "Source code on GitHub")

@@ -371,3 +388,3 @@ **Parameters**

[lib/types/complex-types/object.js:42-42](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/types/complex-types/object.js#L42-L42 "Source code on GitHub")
[lib/types/complex-types/object.js:45-45](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/types/complex-types/object.js#L45-L45 "Source code on GitHub")

@@ -378,3 +395,3 @@ Parsed description of all properties

[lib/core/mst-operations.js:50-55](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L50-L55 "Source code on GitHub")
[lib/core/mst-operations.js:50-55](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L50-L55 "Source code on GitHub")

@@ -423,3 +440,3 @@ TODO: update docs

[lib/core/mst-operations.js:67-69](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L67-L69 "Source code on GitHub")
[lib/core/mst-operations.js:67-69](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L67-L69 "Source code on GitHub")

@@ -439,3 +456,3 @@ Registers a function that will be invoked for each that as made to the provided model instance, or any of it's children.

[lib/core/mst-operations.js:83-85](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L83-L85 "Source code on GitHub")
[lib/core/mst-operations.js:83-85](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L83-L85 "Source code on GitHub")

@@ -451,3 +468,3 @@ Applies a JSON-patch to the given model instance or bails out if the patch couldn't be applied

[lib/core/mst-operations.js:94-99](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L94-L99 "Source code on GitHub")
[lib/core/mst-operations.js:94-99](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L94-L99 "Source code on GitHub")

@@ -463,3 +480,3 @@ Applies a number of JSON patches in a single MobX transaction

[lib/core/mst-operations.js:125-129](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L125-L129 "Source code on GitHub")
[lib/core/mst-operations.js:125-129](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L125-L129 "Source code on GitHub")

@@ -478,3 +495,3 @@ Applies a series of actions in a single MobX transaction.

[lib/core/mst-operations.js:163-165](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L163-L165 "Source code on GitHub")
[lib/core/mst-operations.js:163-165](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L163-L165 "Source code on GitHub")

@@ -509,3 +526,3 @@ By default it is allowed to both directly modify a model or through an action.

[lib/core/mst-operations.js:170-172](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L170-L172 "Source code on GitHub")
[lib/core/mst-operations.js:174-176](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L174-L176 "Source code on GitHub")

@@ -520,3 +537,3 @@ Returns true if the object is in protected mode, @see protect

[lib/core/mst-operations.js:182-184](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L182-L184 "Source code on GitHub")
[lib/core/mst-operations.js:186-188](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L186-L188 "Source code on GitHub")

@@ -532,3 +549,3 @@ Applies a snapshot to a given model instances. Patch and snapshot listeners will be invoked as usual.

[lib/core/mst-operations.js:198-208](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L198-L208 "Source code on GitHub")
[lib/core/mst-operations.js:202-212](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L202-L212 "Source code on GitHub")

@@ -546,3 +563,3 @@ Given a model instance, returns `true` if the object has a parent, that is, is part of another object, map or array

[lib/core/mst-operations.js:234-236](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L234-L236 "Source code on GitHub")
[lib/core/mst-operations.js:238-240](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L238-L240 "Source code on GitHub")

@@ -559,3 +576,3 @@ Returns the path of the given object in the model tree

[lib/core/mst-operations.js:245-247](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L245-L247 "Source code on GitHub")
[lib/core/mst-operations.js:249-251](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L249-L251 "Source code on GitHub")

@@ -572,3 +589,3 @@ Returns the path of the given object as unescaped string array

[lib/core/mst-operations.js:256-258](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L256-L258 "Source code on GitHub")
[lib/core/mst-operations.js:260-262](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L260-L262 "Source code on GitHub")

@@ -585,3 +602,3 @@ Returns true if the given object is the root of a model tree

[lib/core/mst-operations.js:268-272](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L268-L272 "Source code on GitHub")
[lib/core/mst-operations.js:272-276](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L272-L276 "Source code on GitHub")

@@ -599,3 +616,3 @@ Resolves a path relatively to a given object.

[lib/core/mst-operations.js:282-287](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L282-L287 "Source code on GitHub")
[lib/core/mst-operations.js:286-291](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L286-L291 "Source code on GitHub")

@@ -611,3 +628,3 @@ **Parameters**

[lib/core/mst-operations.js:301-310](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L301-L310 "Source code on GitHub")
[lib/core/mst-operations.js:305-314](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L305-L314 "Source code on GitHub")

@@ -623,3 +640,3 @@ **Parameters**

[lib/core/mst-operations.js:315-318](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L315-L318 "Source code on GitHub")
[lib/core/mst-operations.js:319-322](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L319-L322 "Source code on GitHub")

@@ -634,3 +651,3 @@ Removes a model element from the state tree, and let it live on as a new state tree

[lib/core/mst-operations.js:323-329](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/mst-operations.js#L323-L329 "Source code on GitHub")
[lib/core/mst-operations.js:327-333](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L327-L333 "Source code on GitHub")

@@ -643,5 +660,16 @@ Removes a model element from the state tree, and mark it as end-of-life; the element should not be used anymore

## walk
[lib/core/mst-operations.js:353-361](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/mst-operations.js#L353-L361 "Source code on GitHub")
Performs a depth first walk through a tree
**Parameters**
- `thing`
- `processor`
## applyAction
[lib/core/action.js:107-114](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/action.js#L107-L114 "Source code on GitHub")
[lib/core/action.js:107-114](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/action.js#L107-L114 "Source code on GitHub")

@@ -659,3 +687,3 @@ Dispatches an Action on a model instance. All middlewares will be triggered.

[lib/core/json-patch.js:9-11](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/json-patch.js#L9-L11 "Source code on GitHub")
[lib/core/json-patch.js:9-11](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/json-patch.js#L9-L11 "Source code on GitHub")

@@ -671,3 +699,3 @@ escape slashes and backslashes

[lib/core/json-patch.js:16-18](https://github.com/mweststrate/mobx-state-tree/blob/5fed6103994a6cf505e69651c17a064fb2b6d697/lib/core/json-patch.js#L16-L18 "Source code on GitHub")
[lib/core/json-patch.js:16-18](https://github.com/mweststrate/mobx-state-tree/blob/abcd0210045bbf48f3ea094b030495549d0ec481/lib/core/json-patch.js#L16-L18 "Source code on GitHub")

@@ -674,0 +702,0 @@ unescape slashes and backslashes

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

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

Sorry, the diff of this file is too big to display

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