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

@concurrent-tasks/strategy-sync

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@concurrent-tasks/strategy-sync - npm Package Compare versions

Comparing version 2.1.0-beta.0 to 2.2.0-beta.0

64

dist/cjs/index.js

@@ -5,2 +5,4 @@ 'use strict';

var core = require('@concurrent-tasks/core');
/*! *****************************************************************************

@@ -21,13 +23,2 @@ Copyright (c) Microsoft Corporation.

var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {

@@ -72,36 +63,41 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var dummyDone = function () { return void 0; };
function Strategy(strategyOptions) {
if (strategyOptions === void 0) { strategyOptions = {}; }
var options = __assign({ passErrorToDone: false, passResultToDone: true, logError: false }, strategyOptions);
return function InnerStrategy(task, done) {
var Strategy = core.createStrategy({
options: {
passErrorToDone: false,
passResultToDone: true,
logError: false,
},
getTask: function () {
return this.tasks.list.shift();
},
execute: function (task, done) {
return __awaiter(this, void 0, void 0, function () {
var result, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
var _a, passResultToDone, passErrorToDone, logError, result, error_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a.trys.push([0, 2, , 3]);
_a = this.options, passResultToDone = _a.passResultToDone, passErrorToDone = _a.passErrorToDone, logError = _a.logError;
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, task(dummyDone)];
case 1:
result = _a.sent();
done(options.passResultToDone && result !== undefined
? result
: undefined);
return [3 /*break*/, 3];
case 2:
error_1 = _a.sent();
if (options.logError) {
result = _b.sent();
done(passResultToDone && result !== undefined ? result : undefined);
return [3 /*break*/, 4];
case 3:
error_1 = _b.sent();
if (logError) {
console.error(error_1);
}
done(options.passErrorToDone && error_1 !== undefined
? error_1
: undefined);
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
done(passErrorToDone && error_1 !== undefined ? error_1 : undefined);
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
};
}
},
});
exports.Strategy = Strategy;
//# sourceMappingURL=index.js.map

@@ -0,1 +1,3 @@

import { createStrategy } from '@concurrent-tasks/core';
/*! *****************************************************************************

@@ -16,13 +18,2 @@ Copyright (c) Microsoft Corporation.

var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {

@@ -67,36 +58,41 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var dummyDone = function () { return void 0; };
function Strategy(strategyOptions) {
if (strategyOptions === void 0) { strategyOptions = {}; }
var options = __assign({ passErrorToDone: false, passResultToDone: true, logError: false }, strategyOptions);
return function InnerStrategy(task, done) {
var Strategy = createStrategy({
options: {
passErrorToDone: false,
passResultToDone: true,
logError: false,
},
getTask: function () {
return this.tasks.list.shift();
},
execute: function (task, done) {
return __awaiter(this, void 0, void 0, function () {
var result, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
var _a, passResultToDone, passErrorToDone, logError, result, error_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a.trys.push([0, 2, , 3]);
_a = this.options, passResultToDone = _a.passResultToDone, passErrorToDone = _a.passErrorToDone, logError = _a.logError;
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, task(dummyDone)];
case 1:
result = _a.sent();
done(options.passResultToDone && result !== undefined
? result
: undefined);
return [3 /*break*/, 3];
case 2:
error_1 = _a.sent();
if (options.logError) {
result = _b.sent();
done(passResultToDone && result !== undefined ? result : undefined);
return [3 /*break*/, 4];
case 3:
error_1 = _b.sent();
if (logError) {
console.error(error_1);
}
done(options.passErrorToDone && error_1 !== undefined
? error_1
: undefined);
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
done(passErrorToDone && error_1 !== undefined ? error_1 : undefined);
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
};
}
},
});
export { Strategy };
//# sourceMappingURL=index.js.map

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

import { IStrategy } from '@concurrent-tasks/core';
import { StrategySyncOptions } from './Interface';
export declare function Strategy<T>(strategyOptions?: Partial<StrategySyncOptions>): IStrategy<T>;
export declare const Strategy: <T = any>(options?: Partial<StrategySyncOptions> | undefined) => import("@concurrent-tasks/core").IStrategy<T, StrategySyncOptions>;
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ConcurrentTasks = {}));
}(this, (function (exports) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@concurrent-tasks/core')) :
typeof define === 'function' && define.amd ? define(['exports', '@concurrent-tasks/core'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ConcurrentTasks = {}, global.core));
}(this, (function (exports, core) { 'use strict';

@@ -22,13 +22,2 @@ /*! *****************************************************************************

var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __awaiter(thisArg, _arguments, P, generator) {

@@ -73,34 +62,39 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var dummyDone = function () { return void 0; };
function Strategy(strategyOptions) {
if (strategyOptions === void 0) { strategyOptions = {}; }
var options = __assign({ passErrorToDone: false, passResultToDone: true, logError: false }, strategyOptions);
return function InnerStrategy(task, done) {
var Strategy = core.createStrategy({
options: {
passErrorToDone: false,
passResultToDone: true,
logError: false,
},
getTask: function () {
return this.tasks.list.shift();
},
execute: function (task, done) {
return __awaiter(this, void 0, void 0, function () {
var result, error_1;
return __generator(this, function (_a) {
switch (_a.label) {
var _a, passResultToDone, passErrorToDone, logError, result, error_1;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a.trys.push([0, 2, , 3]);
_a = this.options, passResultToDone = _a.passResultToDone, passErrorToDone = _a.passErrorToDone, logError = _a.logError;
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, task(dummyDone)];
case 1:
result = _a.sent();
done(options.passResultToDone && result !== undefined
? result
: undefined);
return [3 /*break*/, 3];
case 2:
error_1 = _a.sent();
if (options.logError) {
result = _b.sent();
done(passResultToDone && result !== undefined ? result : undefined);
return [3 /*break*/, 4];
case 3:
error_1 = _b.sent();
if (logError) {
console.error(error_1);
}
done(options.passErrorToDone && error_1 !== undefined
? error_1
: undefined);
return [3 /*break*/, 3];
case 3: return [2 /*return*/];
done(passErrorToDone && error_1 !== undefined ? error_1 : undefined);
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
});
};
}
},
});

@@ -107,0 +101,0 @@ exports.Strategy = Strategy;

{
"name": "@concurrent-tasks/strategy-sync",
"version": "2.1.0-beta.0",
"version": "2.2.0-beta.0",
"description": "A simple runner to run tasks concurrently while maintaining limits.",

@@ -18,3 +18,3 @@ "author": "Samrith Shankar <samrith.shankar@outlook.com>",

"README",
"../../LICENSE"
"../../../LICENSE"
],

@@ -31,6 +31,6 @@ "engines": {

"devDependencies": {
"@concurrent-tasks/core": "2.1.0-beta.0"
"@concurrent-tasks/core": "^2.2.0-beta.0"
},
"peerDependencies": {
"@concurrent-tasks/core": "2.1.0-beta.0"
"@concurrent-tasks/core": "2.2.0-beta.0"
},

@@ -37,0 +37,0 @@ "keywords": [

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