@sapphire/pieces
Advanced tools
Comparing version 2.1.1-next.de5de92.0 to 2.2.0-next.1214f75.0
@@ -149,2 +149,7 @@ import Collection from '@discordjs/collection'; | ||
/** | ||
* Called after all pieces have been unloaded. | ||
* @param store The store that unloaded all pieces. | ||
*/ | ||
onUnloadAll(store: Store<T>): Awaited<unknown>; | ||
/** | ||
* @param error The error that was thrown. | ||
@@ -221,3 +226,3 @@ * @param path The path of the file that caused the error to be thrown. | ||
* @param path The path of the file to load. | ||
* @return An async iterator that yields each one of the loaded pieces. | ||
* @return All the loaded pieces. | ||
*/ | ||
@@ -232,2 +237,6 @@ load(path: string): Promise<T[]>; | ||
/** | ||
* Unloads all pieces from the store. | ||
*/ | ||
unloadAll(): Promise<T[]>; | ||
/** | ||
* Loads all pieces from all directories specified by {@link paths}. | ||
@@ -536,2 +545,3 @@ */ | ||
onUnload(): unknown; | ||
onUnloadAll(): unknown; | ||
onError(error: Error, path: string): void; | ||
@@ -538,0 +548,0 @@ } |
@@ -92,2 +92,5 @@ "use strict"; | ||
} | ||
onUnloadAll() { | ||
return undefined; | ||
} | ||
onError(error, path) { | ||
@@ -94,0 +97,0 @@ console.error(`Error when loading '${path}':`, error); |
@@ -77,3 +77,3 @@ "use strict"; | ||
* @param path The path of the file to load. | ||
* @return An async iterator that yields each one of the loaded pieces. | ||
* @return All the loaded pieces. | ||
*/ | ||
@@ -111,2 +111,16 @@ async load(path) { | ||
/** | ||
* Unloads all pieces from the store. | ||
*/ | ||
async unloadAll() { | ||
var _a; | ||
const promises = []; | ||
for (const piece of this.values()) { | ||
promises.push(this.unload(piece)); | ||
} | ||
const results = await Promise.all(promises); | ||
this.strategy.onUnloadAll(this); | ||
(_a = Store.logger) === null || _a === void 0 ? void 0 : _a.call(Store, `[STORE => ${this.name}] [UNLOAD-ALL] Removed all pieces.`); | ||
return results; | ||
} | ||
/** | ||
* Loads all pieces from all directories specified by {@link paths}. | ||
@@ -124,3 +138,3 @@ */ | ||
// Clear the store before inserting the new pieces: | ||
this.clear(); | ||
await this.unloadAll(); | ||
(_b = Store.logger) === null || _b === void 0 ? void 0 : _b.call(Store, `[STORE => ${this.name}] [LOAD-ALL] Cleared all pieces.`); | ||
@@ -127,0 +141,0 @@ // Load each piece: |
{ | ||
"name": "@sapphire/pieces", | ||
"version": "2.1.1-next.de5de92.0", | ||
"version": "2.2.0-next.1214f75.0", | ||
"description": "Sapphire's piece loader.", | ||
@@ -29,20 +29,20 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@discordjs/collection": "^0.1.6", | ||
"@sapphire/utilities": "^1.6.1", | ||
"@discordjs/collection": "^0.2.0", | ||
"@sapphire/utilities": "^1.7.0", | ||
"tslib": "^2.3.0" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^12.1.4", | ||
"@commitlint/config-conventional": "^12.1.4", | ||
"@favware/rollup-type-bundler": "^1.0.2", | ||
"@sapphire/eslint-config": "^3.2.1", | ||
"@commitlint/cli": "^13.1.0", | ||
"@commitlint/config-conventional": "^13.1.0", | ||
"@favware/rollup-type-bundler": "^1.0.3", | ||
"@sapphire/eslint-config": "^3.2.3", | ||
"@sapphire/prettier-config": "^1.1.6", | ||
"@sapphire/ts-config": "^2.3.1", | ||
"@types/node": "^16.3.3", | ||
"@sapphire/ts-config": "^2.3.2", | ||
"@types/node": "^16.4.10", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"husky": "^7.0.1", | ||
"lint-staged": "^11.0.0", | ||
"lint-staged": "^11.0.1", | ||
"npm-run-all": "^4.1.5", | ||
"pretty-quick": "^3.1.1", | ||
"standard-version": "^9.3.0", | ||
"standard-version": "^9.3.1", | ||
"typedoc": "^0.21.4", | ||
@@ -49,0 +49,0 @@ "typedoc-plugin-nojekyll": "^1.0.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
71298
1436
+ Added@discordjs/collection@0.2.4(transitive)
- Removed@discordjs/collection@0.1.6(transitive)
Updated@discordjs/collection@^0.2.0
Updated@sapphire/utilities@^1.7.0