Compare commits

..

3 Commits

Author SHA1 Message Date
52396913c7 1.1.0 2025-01-04 13:11:59 +01:00
7b3965ab2b feat(core): Add concurrent processing support 2025-01-04 13:11:58 +01:00
e0a9030bcd update description 2024-05-29 14:11:48 +02:00
6 changed files with 7135 additions and 2760 deletions

29
changelog.md Normal file
View File

@ -0,0 +1,29 @@
# Changelog
## 2025-01-04 - 1.1.0 - feat(core)
Add concurrent processing support
- Introduced ConcurrentProcessor class for handling asynchronous operations with a concurrency limit.
## 2024-05-29 - 1.0.8 - Documentation
Updated project description for clarity and accuracy.
- Enhanced documentation details in the project description.
## 2024-04-01 to 2024-04-27 - 1.0.5 to 1.0.7 - Maintenance and Configuration Updates
Multiple updates focusing on configuration and core functionality.
- Updated `tsconfig` for improved TypeScript setup.
- Refined `npmextra.json` to configure `githost`.
- Applied numerous core functionality enhancements and fixes.
## 2023-07-10 to 2023-08-02 - 1.0.3 to 1.0.4 - Organizational Changes and Fixes
Transition to new organizational structure and related updates.
- Implemented a new organizational scheme for the project.
- Applied essential fixes to core components ensuring stability.
## 2021-06-29 to 2021-06-30 - 1.0.1 to 1.0.2 - Core Fixes
Addressed core system updates and enhancements.
- Implemented bug fixes to enhance core functionality.

View File

@ -1,6 +1,6 @@
{ {
"name": "@push.rocks/smartarray", "name": "@push.rocks/smartarray",
"version": "1.0.8", "version": "1.1.0",
"private": false, "private": false,
"description": "A TypeScript library for enhancing array manipulation with asynchronous operations such as mapping, filtering, and deduplication.", "description": "A TypeScript library for enhancing array manipulation with asynchronous operations such as mapping, filtering, and deduplication.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -13,12 +13,12 @@
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.1.66", "@git.zone/tsbuild": "^2.2.0",
"@git.zone/tsbundle": "^2.0.8", "@git.zone/tsbundle": "^2.1.0",
"@git.zone/tsrun": "^1.2.44", "@git.zone/tsrun": "^1.3.3",
"@git.zone/tstest": "^1.0.77", "@git.zone/tstest": "^1.0.77",
"@push.rocks/tapbundle": "^5.0.12", "@push.rocks/tapbundle": "^5.5.4",
"@types/node": "^20.4.6" "@types/node": "^22.10.5"
}, },
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
@ -47,5 +47,10 @@
"software development", "software development",
"npm package", "npm package",
"open source" "open source"
] ],
"homepage": "https://code.foss.global/push.rocks/smartarray",
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartarray.git"
}
} }

9792
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/** /**
* autocreated commitinfo by @pushrocks/commitinfo * autocreated commitinfo by @push.rocks/commitinfo
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartarray', name: '@push.rocks/smartarray',
version: '1.0.8', version: '1.1.0',
description: 'A TypeScript library for enhancing array manipulation with asynchronous operations such as mapping, filtering, and deduplication.' description: 'A TypeScript library for enhancing array manipulation with asynchronous operations such as mapping, filtering, and deduplication.'
} }

View File

@ -0,0 +1,35 @@
export class ConcurrentProcessor<T> {
private asyncFunction: (item: T) => Promise<void>;
private concurrencyLimit: number;
constructor(asyncFunction: (item: T) => Promise<void>, concurrencyLimit: number) {
this.asyncFunction = asyncFunction;
this.concurrencyLimit = concurrencyLimit;
}
async process(items: T[]): Promise<void> {
const queue: Array<Promise<void>> = [];
let totalProcessed = 0;
for (const item of items) {
const promise = this.asyncFunction(item).then(() => {
totalProcessed++;
if (totalProcessed % 10000 === 0) {
console.log(`${totalProcessed} items processed.`);
}
// Remove the completed promise from the queue
queue.splice(queue.indexOf(promise), 1);
});
queue.push(promise);
// Wait if the number of promises exceeds the concurrency limit
if (queue.length >= this.concurrencyLimit) {
await Promise.race(queue);
}
}
// Wait for the remaining promises to resolve
await Promise.all(queue);
}
}

View File

@ -1,3 +1,5 @@
export * from './classes.concurrentprocessor.js';
export const map = async <T = any, R = any>( export const map = async <T = any, R = any>(
arrayArg: T[], arrayArg: T[],
mapFunction: (itemArg: T) => Promise<R> mapFunction: (itemArg: T) => Promise<R>