diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index f47fb75..961f820 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -35,12 +35,12 @@ repo ``` ### Mass Patches -One of the largest advantages of Repository Script is the ability to mass patch items. To do so, use the functions ```Repository::patchAll``` and/or ```Repository::patchAllAsync```. +One of the largest advantages of Repository Script is the ability to mass patch items. To do so, use the functions ```Repository::patchAll```, ```Repository::patchAllFn``` and ```Repository::patchAllAsync```. ```ts repo.patchAll(RepositoryGroups.Pistols, { TestProp: 'asd' }) -repo.patchAll(RepositoryGroups.Explosives, item => ({ +repo.patchAllFn(RepositoryGroups.Explosives, item => ({ TestProp: item.id })) await repo.patchAllAsync(RepositoryGroups.Tools, async (item) => ({ diff --git a/package.json b/package.json index 580c9df..5cbd024 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "repository-script", - "version": "1.0.7", + "version": "1.0.8", "description": "An easier way of writing repository files with code", "main": "dist/src/lib.js", "types": "./dist/src/index.d.ts", diff --git a/src/repository.ts b/src/repository.ts index 9139dd3..a70bfca 100644 --- a/src/repository.ts +++ b/src/repository.ts @@ -26,17 +26,15 @@ export class Repository { return this } - public patchAll(ids: TUUIDv4[], handler: (entry: RepositoryEntry) => void): this - public patchAll(ids: TUUIDv4[], handler: Partial): this - public patchAll(ids, handler): this { + public patchAll(ids: TUUIDv4[], data: Partial): this { + ids.forEach(id => this.patch(id, data)) + return this + } + + public patchAllFn(ids: TUUIDv4[], handler: (entry: RepositoryEntry) => Partial): this { ids.forEach(id => { const entry = this.getItem(id) - if(!(handler instanceof Function)) { - entry.patch(handler) - return - } - entry.patch(handler(entry)) }) return this