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

@dmail/action

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dmail/action - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

3

dist/src/action.js

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

// more or less equivalent to
// http://folktale.origamitower.com/api/v2.0.0/en/folktale.result.html
// http://folktale.origamitower.com/api/v2.0.0/en/folktale.validation.html
var isAction = exports.isAction = function isAction(value) {

@@ -11,0 +14,0 @@ return value && typeof value.then === "function";

34

dist/src/any/any.js

@@ -16,7 +16,13 @@ "use strict";

pass = _ref.pass;
var failedOrPassed = false;
var running = true;
var someHasFailed = false;
var lastFailure = void 0;
var count = 0;
var endedCount = 0;
var compositePass = function compositePass(value) {
if (failedOrPassed === false) {
failedOrPassed = true;
endedCount++;
if (running) {
running = false;
pass(value);

@@ -27,5 +33,12 @@ }

var compositeFail = function compositeFail(value) {
if (failedOrPassed === false) {
failedOrPassed = true;
fail(value);
endedCount++;
if (running) {
lastFailure = value;
someHasFailed = true;
if (endedCount === count) {
running = false;
fail(lastFailure);
}
}

@@ -48,5 +61,7 @@ };

if (failedOrPassed) {
if (running === false) {
break;
}
count++;
}

@@ -67,4 +82,9 @@ } catch (err) {

}
if (endedCount === count && running && someHasFailed) {
running = false;
fail(lastFailure);
}
});
};
//# sourceMappingURL=any.js.map
"use strict";
var _any = require("./any.js");
var _testCheap = require("@dmail/test-cheap");

@@ -7,4 +9,6 @@

var _any = require("./any.js");
var _passed = require("../passed/passed.js");
var _failed = require("../failed/failed.js");
var _assertions = require("../assertions.js");

@@ -66,3 +70,22 @@

});
ensure("fails with last failure", function () {
var action = (0, _any.any)([(0, _failed.failed)(0), (0, _failed.failed)(1), (0, _failed.failed)(2)]);
(0, _assertions.assertFailed)(action);
(0, _assertions.assertResult)(action, 2);
});
ensure("pass even if passed surrounded by failure", function () {
var action = (0, _any.any)([(0, _failed.failed)(0), (0, _passed.passed)(1), (0, _failed.failed)(2)]);
(0, _assertions.assertPassed)(action);
(0, _assertions.assertResult)(action, 1);
});
ensure("multiple disordonned failure", function () {
var first = (0, _action.createAction)();
var second = (0, _action.createAction)();
var action = (0, _any.any)([first, second]);
second.fail(0);
first.fail(1);
(0, _assertions.assertFailed)(action);
(0, _assertions.assertResult)(action, 1);
});
});
//# sourceMappingURL=any.test.js.map
{
"name": "@dmail/action",
"version": "1.6.0",
"version": "1.7.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": {

@@ -0,1 +1,5 @@

// more or less equivalent to
// http://folktale.origamitower.com/api/v2.0.0/en/folktale.result.html
// http://folktale.origamitower.com/api/v2.0.0/en/folktale.validation.html
export const isAction = value => value && typeof value.then === "function"

@@ -2,0 +6,0 @@

@@ -6,6 +6,11 @@ import { isAction } from "../action.js"

fromFunction(({ fail, pass }) => {
let failedOrPassed = false
let running = true
let someHasFailed = false
let lastFailure
let count = 0
let endedCount = 0
const compositePass = value => {
if (failedOrPassed === false) {
failedOrPassed = true
endedCount++
if (running) {
running = false
pass(value)

@@ -15,5 +20,10 @@ }

const compositeFail = value => {
if (failedOrPassed === false) {
failedOrPassed = true
fail(value)
endedCount++
if (running) {
lastFailure = value
someHasFailed = true
if (endedCount === count) {
running = false
fail(lastFailure)
}
}

@@ -29,6 +39,12 @@ }

if (failedOrPassed) {
if (running === false) {
break
}
count++
}
if (endedCount === count && running && someHasFailed) {
running = false
fail(lastFailure)
}
})

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

import { any } from "./any.js"
import { test } from "@dmail/test-cheap"
import { createAction } from "../action.js"
import { any } from "./any.js"
import { passed } from "../passed/passed.js"
import { failed } from "../failed/failed.js"
import { assertPassed, assertFailed, assertResult } from "../assertions.js"

@@ -66,2 +68,24 @@

})
ensure("fails with last failure", () => {
const action = any([failed(0), failed(1), failed(2)])
assertFailed(action)
assertResult(action, 2)
})
ensure("pass even if passed surrounded by failure", () => {
const action = any([failed(0), passed(1), failed(2)])
assertPassed(action)
assertResult(action, 1)
})
ensure("multiple disordonned failure", () => {
const first = createAction()
const second = createAction()
const action = any([first, second])
second.fail(0)
first.fail(1)
assertFailed(action)
assertResult(action, 1)
})
})

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