mobx-state-tree 5.0.5 → 5.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  [![npm version](https://badge.fury.io/js/mobx-state-tree.svg)](https://badge.fury.io/js/mobx-state-tree)
6
6
  [![CircleCI](https://circleci.com/gh/mobxjs/mobx-state-tree.svg?style=svg)](https://circleci.com/gh/mobxjs/mobx-state-tree)
7
- [![Coverage Status](https://coveralls.io/repos/github/mobxjs/mobx-state-tree/badge.svg?branch=master)](https://coveralls.io/github/mobxjs/mobx-state-tree?branch=master)
7
+ [![Codecov](https://codecov.io/gh/mobxjs/mobx-state-tree/branch/master/graph/badge.svg?token=BFkuCB6CtL)](https://codecov.io/gh/mobxjs/mobx-state-tree)
8
8
  [![Have a question? Ask on GitHub Discussions!](https://img.shields.io/badge/Have%20a%20question%3F-Ask%20on%20GitHub%20Discussions!-blue)](https://github.com/mobxjs/mobx-state-tree/discussions)
9
9
 
10
10
  ## What is mobx-state-tree?
@@ -7,7 +7,7 @@ export declare type FlowReturn<R> = R extends Promise<infer T> ? T : R;
7
7
  *
8
8
  * @returns The flow as a promise.
9
9
  */
10
- export declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<Promise<any>, R, any>): (...args: Args) => Promise<FlowReturn<R>>;
10
+ export declare function flow<R, Args extends any[]>(generator: (...args: Args) => Generator<PromiseLike<any>, R, any>): (...args: Args) => Promise<FlowReturn<R>>;
11
11
  /**
12
12
  * @deprecated Not needed since TS3.6.
13
13
  * Used for TypeScript to make flows that return a promise return the actual promise result.
@@ -580,7 +580,7 @@ function resolveIdentifier(type, target, identifier) {
580
580
  assertIsStateTreeNode(target, 2);
581
581
  assertIsValidIdentifier(identifier, 3);
582
582
  var node = getStateTreeNode(target).root.identifierCache.resolve(type, normalizeIdentifier(identifier));
583
- return node ? node.value : undefined;
583
+ return node === null || node === void 0 ? void 0 : node.value;
584
584
  }
585
585
  /**
586
586
  * Returns the identifier of the target node.
@@ -3930,14 +3930,12 @@ function isMutable(value) {
3930
3930
  */
3931
3931
  function isPrimitive(value, includeDate) {
3932
3932
  if (includeDate === void 0) { includeDate = true; }
3933
- if (value === null || value === undefined)
3934
- return true;
3935
- if (typeof value === "string" ||
3933
+ return (value === null ||
3934
+ value === undefined ||
3935
+ typeof value === "string" ||
3936
3936
  typeof value === "number" ||
3937
3937
  typeof value === "boolean" ||
3938
- (includeDate && value instanceof Date))
3939
- return true;
3940
- return false;
3938
+ (includeDate && value instanceof Date));
3941
3939
  }
3942
3940
  /**
3943
3941
  * @internal
@@ -5033,18 +5031,17 @@ var MapType = /** @class */ (function (_super) {
5033
5031
  }
5034
5032
  var modelTypes = [];
5035
5033
  if (tryCollectModelTypes(this._subType, modelTypes)) {
5036
- var identifierAttribute_1 = undefined;
5037
- modelTypes.forEach(function (type) {
5038
- if (type.identifierAttribute) {
5039
- if (identifierAttribute_1 && identifierAttribute_1 !== type.identifierAttribute) {
5040
- throw fail$1("The objects in a map should all have the same identifier attribute, expected '" + identifierAttribute_1 + "', but child of type '" + type.name + "' declared attribute '" + type.identifierAttribute + "' as identifier");
5041
- }
5042
- identifierAttribute_1 = type.identifierAttribute;
5034
+ var identifierAttribute = modelTypes.reduce(function (current, type) {
5035
+ if (!type.identifierAttribute)
5036
+ return current;
5037
+ if (current && current !== type.identifierAttribute) {
5038
+ throw fail$1("The objects in a map should all have the same identifier attribute, expected '" + current + "', but child of type '" + type.name + "' declared attribute '" + type.identifierAttribute + "' as identifier");
5043
5039
  }
5044
- });
5045
- if (identifierAttribute_1) {
5040
+ return type.identifierAttribute;
5041
+ }, undefined);
5042
+ if (identifierAttribute) {
5046
5043
  this.identifierMode = MapIdentifierMode.YES;
5047
- this.mapIdentifierAttribute = identifierAttribute_1;
5044
+ this.mapIdentifierAttribute = identifierAttribute;
5048
5045
  }
5049
5046
  else {
5050
5047
  this.identifierMode = MapIdentifierMode.NO;