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 2.2.0 to 2.3.0

17

dist/src/allocableMsTalent/allocableMsTalent.js

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

var failureIsOutOfMs = exports.failureIsOutOfMs = function failureIsOutOfMs(failure) {
return typeof failure === "string" && failure.startsWith("must pass or fail in less");
};
var createOutOfMsMessage = exports.createOutOfMsMessage = function createOutOfMsMessage(allocatedMs) {

@@ -35,2 +31,9 @@ return "must pass or fail in less than ".concat(allocatedMs, "ms");

var allocateMs = function allocateMs(ms) {
var outOfMsToken = {
ms: ms,
toString: function toString() {
return createOutOfMsMessage(ms);
}
};
if (isEnded()) {

@@ -46,9 +49,11 @@ throw new Error("cannot allocateMs once the action has ".concat(getState()));

if (allocatedMs < 0) {
shortcircuit(fail, createOutOfMsMessage(allocatedMs));
shortcircuit(fail, outOfMsToken);
} else if (allocatedMs !== Infinity) {
startMs = Date.now();
timeoutid = setTimeout(function () {
return shortcircuit(fail, createOutOfMsMessage(allocatedMs));
return shortcircuit(fail, outOfMsToken);
}, allocatedMs);
}
return outOfMsToken;
};

@@ -55,0 +60,0 @@

@@ -80,7 +80,8 @@ "use strict";

var action = createActionWithAllocableMs();
action.allocateMs(10);
var token = action.allocateMs(10);
setTimeout(action.pass, 11);
clock.tick(10);
(0, _assertions.assert)((0, _allocableMsTalent.failureIsOutOfMs)(action.getResult()));
_assertions.assert.equal(action.getResult(), token);
_assertions.assert.doesNotThrow(function () {

@@ -95,7 +96,8 @@ return clock.tick(1);

var action = createActionWithAllocableMs();
action.allocateMs(10);
var token = action.allocateMs(10);
setTimeout(action.fail, 11);
clock.tick(10);
(0, _assertions.assert)((0, _allocableMsTalent.failureIsOutOfMs)(action.getResult()));
_assertions.assert.equal(action.getResult(), token);
_assertions.assert.doesNotThrow(function () {

@@ -109,7 +111,7 @@ return clock.tick(1);

var action = createActionWithAllocableMs();
action.allocateMs(-1);
var token = action.allocateMs(-1);
_assertions.assert.equal(action.getState(), "failed");
(0, _assertions.assert)((0, _allocableMsTalent.failureIsOutOfMs)(action.getResult()));
_assertions.assert.equal(action.getResult(), token);
});

@@ -116,0 +118,0 @@ ensure("allocateMs() throw when action is passed", function () {

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

});
exports.collectSequenceWithAllocatedMs = exports.collectSequence = void 0;
exports.collectSequenceWithAllocatedMs = exports.createActionWithAllocableMs = exports.collectSequence = void 0;

@@ -65,6 +65,4 @@ var _allocableMsTalent = require("../allocableMsTalent/allocableMsTalent.js");

var createActionWithAllocatedMs = function createActionWithAllocatedMs(allocatedMs) {
var action = (0, _mixin.mixin)((0, _action.createAction)(), _allocableMsTalent.allocableMsTalent);
action.allocateMs(allocatedMs);
return action;
var createActionWithAllocableMs = exports.createActionWithAllocableMs = function createActionWithAllocableMs() {
return (0, _mixin.mixin)((0, _action.createAction)(), _allocableMsTalent.allocableMsTalent);
};

@@ -79,3 +77,4 @@

var someHasFailed = false;
var from = createActionWithAllocatedMs(allocatedMs);
var from = createActionWithAllocableMs(allocatedMs);
var currentExpirationToken = from.allocateMs(allocatedMs);
from.pass();

@@ -104,3 +103,3 @@ return (0, _compose.compose)({

if (state === "failed") {
if ((0, _allocableMsTalent.failureIsOutOfMs)(value)) {
if (value === currentExpirationToken) {
// fail saying we are out of 10ms

@@ -122,14 +121,6 @@ // even if the action may say it failed because it had only 8ms

return pass(results);
} // ah bah oui allocableMsTalent apelle then
// qui apelle replicate sur lastValueOf
// qui du coup rapelle allocableMsTalent
// dans une boucle infinie
// le then qu'on utilise dans allocableMsTalent
// ne "devrait" par réappliquer le talent
// soit then n'utilise pas lastValueOf
// soit c'est l'utilisation même du then qui est foireuse
}
var nextAction = createActionWithAllocatedMs();
nextAction.allocateMs(action.getRemainingMs());
var nextAction = createActionWithAllocableMs();
currentExpirationToken = nextAction.allocateMs(action.getRemainingMs());
nextAction.pass(nextValue);

@@ -136,0 +127,0 @@ return nextAction;

{
"name": "@dmail/action",
"version": "2.2.0",
"version": "2.3.0",
"license": "MIT",

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

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

export const failureIsOutOfMs = (failure) =>
typeof failure === "string" && failure.startsWith("must pass or fail in less")
export const createOutOfMsMessage = (allocatedMs) => {

@@ -22,2 +19,7 @@ return `must pass or fail in less than ${allocatedMs}ms`

const allocateMs = (ms) => {
const outOfMsToken = {
ms,
toString: () => createOutOfMsMessage(ms),
}
if (isEnded()) {

@@ -32,10 +34,9 @@ throw new Error(`cannot allocateMs once the action has ${getState()}`)

if (allocatedMs < 0) {
shortcircuit(fail, createOutOfMsMessage(allocatedMs))
shortcircuit(fail, outOfMsToken)
} else if (allocatedMs !== Infinity) {
startMs = Date.now()
timeoutid = setTimeout(
() => shortcircuit(fail, createOutOfMsMessage(allocatedMs)),
allocatedMs,
)
timeoutid = setTimeout(() => shortcircuit(fail, outOfMsToken), allocatedMs)
}
return outOfMsToken
}

@@ -42,0 +43,0 @@

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

import { allocableMsTalent, failureIsOutOfMs } from "./allocableMsTalent.js"
import { allocableMsTalent } from "./allocableMsTalent.js"
import { createAction } from "../action.js"

@@ -58,6 +58,6 @@ import { mixin } from "@dmail/mixin"

const action = createActionWithAllocableMs()
action.allocateMs(10)
const token = action.allocateMs(10)
setTimeout(action.pass, 11)
clock.tick(10)
assert(failureIsOutOfMs(action.getResult()))
assert.equal(action.getResult(), token)
assert.doesNotThrow(() => clock.tick(1))

@@ -70,6 +70,6 @@ clock.uninstall()

const action = createActionWithAllocableMs()
action.allocateMs(10)
const token = action.allocateMs(10)
setTimeout(action.fail, 11)
clock.tick(10)
assert(failureIsOutOfMs(action.getResult()))
assert.equal(action.getResult(), token)
assert.doesNotThrow(() => clock.tick(1))

@@ -81,5 +81,5 @@ clock.uninstall()

const action = createActionWithAllocableMs()
action.allocateMs(-1)
const token = action.allocateMs(-1)
assert.equal(action.getState(), "failed")
assert(failureIsOutOfMs(action.getResult()))
assert.equal(action.getResult(), token)
})

@@ -86,0 +86,0 @@

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

import {
allocableMsTalent,
failureIsOutOfMs,
createOutOfMsMessage,
} from "../allocableMsTalent/allocableMsTalent.js"
import { allocableMsTalent, createOutOfMsMessage } from "../allocableMsTalent/allocableMsTalent.js"
import { mixin } from "@dmail/mixin"

@@ -37,6 +33,4 @@ import { createAction } from "../action"

const createActionWithAllocatedMs = (allocatedMs) => {
const action = mixin(createAction(), allocableMsTalent)
action.allocateMs(allocatedMs)
return action
export const createActionWithAllocableMs = () => {
return mixin(createAction(), allocableMsTalent)
}

@@ -48,3 +42,4 @@

const from = createActionWithAllocatedMs(allocatedMs)
const from = createActionWithAllocableMs(allocatedMs)
let currentExpirationToken = from.allocateMs(allocatedMs)
from.pass()

@@ -61,3 +56,3 @@

if (state === "failed") {
if (failureIsOutOfMs(value)) {
if (value === currentExpirationToken) {
// fail saying we are out of 10ms

@@ -78,13 +73,4 @@ // even if the action may say it failed because it had only 8ms

// ah bah oui allocableMsTalent apelle then
// qui apelle replicate sur lastValueOf
// qui du coup rapelle allocableMsTalent
// dans une boucle infinie
// le then qu'on utilise dans allocableMsTalent
// ne "devrait" par réappliquer le talent
// soit then n'utilise pas lastValueOf
// soit c'est l'utilisation même du then qui est foireuse
const nextAction = createActionWithAllocatedMs()
nextAction.allocateMs(action.getRemainingMs())
const nextAction = createActionWithAllocableMs()
currentExpirationToken = nextAction.allocateMs(action.getRemainingMs())
nextAction.pass(nextValue)

@@ -91,0 +77,0 @@

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