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

stack-promises

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stack-promises - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

92

dist/index.js

@@ -1,15 +0,15 @@

const b = "ERROR_NOT_RUNNING", I = (e) => {
const L = "ERROR_NOT_RUNNING", b = (n) => {
const o = new Error("Promise was not running");
return o.basePromise = e, o.id = b, o.name = "Not running", o;
}, L = async (e, o) => e.reduce(
async (a, c) => a.then(async ({ success: k, errors: m, results: f }) => (!o || o(c) ? c() : Promise.reject(I(c))).then((i) => ({
return o.basePromise = n, o.id = L, o.name = "Not running", o;
}, x = async (n, o) => n.reduce(
async (a, c) => a.then(async ({ success: k, errors: m, results: f }) => (!o || o(c) ? c() : Promise.reject(b(c))).then((u) => ({
errors: m,
success: [...k, i],
results: [...f, i],
success: [...k, u],
results: [...f, u],
isSuccessful: !0,
isError: !1
})).catch((i) => ({
})).catch((u) => ({
success: k,
errors: [...m, i],
results: [...f, i],
errors: [...m, u],
results: [...f, u],
isSuccessful: !1,

@@ -25,6 +25,6 @@ isError: !0

})
), S = new Error("Stack is empty"), B = (e) => e === S, E = new Error("Promise is not actual"), O = (e) => e === E, x = new Error(
), E = new Error("Stack is empty"), T = (n) => n[n.length - 1], O = (n) => n === E, y = new Error("Promise is not actual"), _ = (n) => n === y, z = new Error(
"stackPromises only works with functions that returns a Promise"
), _ = ({
noRejectIsNotActual: e = !1,
), C = ({
noRejectIsNotActual: n = !1,
noRunIsNotActual: o = !1

@@ -35,8 +35,8 @@ } = {}) => {

}, m = (s, { task: r, index: t }) => {
const n = c.find(({ task: l, index: P }) => r === l && t === P);
if (!n)
const e = c.find(({ task: l, index: P }) => r === l && t === P);
if (!e)
throw new Error("Task not found");
if (n.promise)
if (e.promise)
throw new Error("Task is already running");
n.promise = s;
e.promise = s;
}, f = ({

@@ -46,20 +46,20 @@ task: s,

}) => {
const t = c.find(({ task: n, index: l }) => s === n && r === l);
const t = c.find(({ task: e, index: l }) => s === e && r === l);
if (t)
return t.promise;
}, i = ({ task: s }) => {
const r = c.at(-1);
}, u = ({ task: s }) => {
const r = T(c);
return (r == null ? void 0 : r.task) === s;
}, y = ({ task: s, index: r }) => (k({ task: s, index: r }), async () => {
}, p = ({ task: s, index: r }) => (k({ task: s, index: r }), async () => {
let t = f({ task: s, index: r });
const n = i({ task: s });
return !t && o && !n ? Promise.resolve() : (t || (t = s({ isActual: n }), m(t, { task: s, index: r })), t);
}), p = ({
const e = u({ task: s });
return !t && o && !e ? Promise.resolve() : (t || (t = s({ isActual: e }), m(t, { task: s, index: r })), t);
}), w = ({
resolve: s,
reject: r
}) => ({ results: t, isSuccessful: n }) => {
}) => ({ results: t, isSuccessful: e }) => {
const l = t.length, P = a.length;
if (l === P) {
const h = t.at(-1);
if (n) {
const h = T(t);
if (e) {
s(h);

@@ -71,38 +71,38 @@ return;

}
if (e) {
const h = t.at(-1);
if (n) {
const h = T(t);
s(h);
return;
}
r(E);
r(y);
};
let d = !1;
const w = () => {
const R = () => {
d = !0;
}, R = () => {
}, g = () => {
d = !1;
}, g = () => d, N = async () => (w(), L(a, g)), u = async () => {
}, N = () => d, A = async () => (R(), x(a, N)), i = async () => {
if (a.length === 0)
throw S;
throw E;
return new Promise((s, r) => {
const t = p({ resolve: s, reject: r });
N().then(t).catch(t);
const t = w({ resolve: s, reject: r });
A().then(t).catch(t);
});
}, T = (s) => {
}, S = (s) => {
if (typeof s != "function")
throw x;
throw z;
const r = a.length;
return a.push(y({ task: s, index: r })), u;
}, A = async (s) => (T(s), u()), v = () => {
return a.push(p({ task: s, index: r })), i;
}, v = async (s) => (S(s), i()), F = () => {
a.length = 0, c.length = 0;
}, F = () => {
R(), v();
}, I = () => {
g(), F();
};
return u.add = T, u.run = A, u.stop = F, u;
return i.add = S, i.run = v, i.stop = I, i;
};
export {
_ as default,
B as isEmptyStackError,
O as isPromiseIsNotActualError,
E as promiseIsNotActualError
C as default,
O as isEmptyStackError,
_ as isPromiseIsNotActualError,
y as promiseIsNotActualError
};
{
"name": "stack-promises",
"version": "1.0.1",
"version": "1.0.2",
"description": "sequentPromises resolves Promises sequentially",

@@ -30,2 +30,12 @@ "keywords": [

"types": "dist/index.d.ts",
"typesVersions": {
"*": {
"dist/index.d.ts": [
"dist/index.d.ts"
],
"*": [
"dist/*"
]
}
},
"files": [

@@ -36,6 +46,7 @@ "dist"

"build": "vite build",
"commitlint": "commitlint --edit",
"lint": "yarn lint:js && yarn lint:ts",
"lint:js": "eslint src --ext ts,tsx --ignore-path .gitignore --report-unused-disable-directives --max-warnings 0",
"lint:ts": "tsc",
"prepare": "husky install",
"prepare": "husky",
"prepublishOnly": "yarn build",

@@ -55,21 +66,21 @@ "preview": "vite preview",

"devDependencies": {
"@babel/preset-typescript": "^7.23.2",
"@commitlint/cli": "^18.0.0",
"@commitlint/config-conventional": "^18.0.0",
"@nabla/vite-plugin-eslint": "^1.5.0",
"@types/jest": "^29.5.6",
"@typescript-eslint/eslint-plugin": "^6.9.0",
"@typescript-eslint/parser": "^6.9.0",
"@babel/preset-typescript": "^7.23.3",
"@commitlint/cli": "^18.6.0",
"@commitlint/config-conventional": "^18.6.0",
"@nabla/vite-plugin-eslint": "^2.0.2",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"cross-env": "^7.0.3",
"eslint": "^8.52.0",
"eslint": "^8.56.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^27.4.3",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-unicorn": "^48.0.1",
"husky": "^8.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unicorn": "^50.0.1",
"husky": "^9.0.7",
"jest": "^29.7.0",

@@ -79,12 +90,12 @@ "jest-environment-jsdom": "^29.7.0",

"jest-junit": "^16.0.0",
"lint-staged": "^15.0.2",
"prettier": "^3.0.3",
"lint-staged": "^15.2.1",
"prettier": "^3.2.4",
"standard-version": "^9.5.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"tsc-files": "^1.1.4",
"typescript": "^5.2.2",
"vite": "^4.5.0",
"vite-plugin-dts": "^3.6.1",
"vite-tsconfig-paths": "^4.2.1"
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vite-plugin-dts": "^3.7.2",
"vite-tsconfig-paths": "^4.3.1"
},

@@ -91,0 +102,0 @@ "peerDependencies": {},

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