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

mobx-utils

Package Overview
Dependencies
Maintainers
3
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-utils - npm Package Compare versions

Comparing version 5.5.0 to 5.5.1

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 5.5.1
* Fix for `actionAsync` giving errors when it didn't await a task inside.
* `task` now supports plain values as well.
# 5.5.0

@@ -2,0 +7,0 @@

2

lib/action-async.d.ts

@@ -1,2 +0,2 @@

export declare function task<R>(promise: Promise<R>): Promise<R>;
export declare function task<R>(value: R | PromiseLike<R>): Promise<R>;
export declare function actionAsync(target: object, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;

@@ -3,0 +3,0 @@ export declare function actionAsync(target: object, propertyKey: string): void;

@@ -45,9 +45,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

var actionAsyncContextStack = [];
function getCurrentActionAsyncContext() {
if (actionAsyncContextStack.length <= 0) {
fail("'actionAsync' context not present. did you await inside an 'actionAsync' without using 'task(promise)'?");
}
return actionAsyncContextStack[actionAsyncContextStack.length - 1];
}
export function task(promise) {
export function task(value) {
return __awaiter(this, void 0, void 0, function () {

@@ -58,4 +52,6 @@ var ctx, runId, actionName, args, scope, actionRunInfo, step, nextStep, actionRunInfo_1;

case 0:
invariant(typeof promise === "object" && typeof promise.then === "function", "'task' expects a promise");
ctx = getCurrentActionAsyncContext();
ctx = actionAsyncContextStack[actionAsyncContextStack.length - 1];
if (!ctx) {
fail("'actionAsync' context not present when running 'task'. did you await inside an 'actionAsync' without using 'task(promise)'? did you forget to await the task?");
}
runId = ctx.runId, actionName = ctx.actionName, args = ctx.args, scope = ctx.scope, actionRunInfo = ctx.actionRunInfo, step = ctx.step;

@@ -69,3 +65,3 @@ nextStep = step + 1;

_a.trys.push([1, , 3, 4]);
return [4 /*yield*/, promise];
return [4 /*yield*/, value];
case 2: return [2 /*return*/, _a.sent()];

@@ -177,3 +173,3 @@ case 3:

return __awaiter(this, void 0, void 0, function () {
var nextRunId, actionRunInfo, errThrown, ret, err_1, ctx;
var nextRunId, actionRunInfo, finish, promise, ret, err_1;
return __generator(this, function (_a) {

@@ -194,26 +190,48 @@ switch (_a.label) {

currentlyActiveIds.add(nextRunId);
finish = function (err) {
unfinishedIds.delete(nextRunId);
var ctx = actionAsyncContextStack.pop();
if (!ctx || ctx.runId !== nextRunId) {
var msg = "invalid 'actionAsync' context when finishing action '" + actionName + "'.";
if (!ctx) {
msg += " no action context could be found instead.";
}
else {
msg += " an action context for '" + ctx.actionName + "' was found instead.";
}
msg +=
" did you await inside an 'actionAsync' without using 'task(promise)'? did you forget to await the task?";
fail(msg);
}
ctx.actionRunInfo.error = err;
_endAction(ctx.actionRunInfo);
currentlyActiveIds.delete(nextRunId);
if (err) {
throw err;
}
};
try {
promise = fn.apply(this, args);
}
catch (err) {
finish(err);
}
// are we done sync? (no task run)
if (currentlyActiveIds.has(nextRunId)) {
finish(undefined);
return [2 /*return*/, promise];
}
_a.label = 1;
case 1:
_a.trys.push([1, 3, 4, 5]);
return [4 /*yield*/, fn.apply(this, args)];
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, promise];
case 2:
ret = _a.sent();
finish(undefined);
return [2 /*return*/, ret];
case 3:
err_1 = _a.sent();
errThrown = err_1;
throw err_1;
case 4:
unfinishedIds.delete(nextRunId);
if (currentlyActiveIds.has(nextRunId)) {
ctx = actionAsyncContextStack.pop();
if (!ctx || ctx.runId !== nextRunId) {
fail("'actionAsync' context not present or invalid. did you await inside an 'actionAsync' without using 'task(promise)'?");
}
ctx.actionRunInfo.error = errThrown;
_endAction(ctx.actionRunInfo);
currentlyActiveIds.delete(nextRunId);
}
return [7 /*endfinally*/];
case 5: return [2 /*return*/];
finish(err_1);
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}

@@ -220,0 +238,0 @@ });

{
"name": "mobx-utils",
"version": "5.5.0",
"version": "5.5.1",
"description": "Utility functions and common patterns for MobX",

@@ -5,0 +5,0 @@ "main": "mobx-utils.umd.js",

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

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