electron-store
Advanced tools
Comparing version 8.0.2 to 8.1.0
{ | ||
"name": "electron-store", | ||
"version": "8.0.2", | ||
"version": "8.1.0", | ||
"description": "Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc", | ||
@@ -37,4 +37,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"conf": "^10.1.2", | ||
"type-fest": "^2.12.2" | ||
"conf": "^10.2.0", | ||
"type-fest": "^2.17.0" | ||
}, | ||
@@ -41,0 +41,0 @@ "devDependencies": { |
@@ -161,2 +161,48 @@ # electron-store | ||
### beforeEachMigration | ||
Type: `Function`\ | ||
Default: `undefined` | ||
The given callback function will be called before each migration step. | ||
The function receives the store as the first argument and a context object as the second argument with the following properties: | ||
- `fromVersion` - The version the migration step is being migrated from. | ||
- `toVersion` - The version the migration step is being migrated to. | ||
- `finalVersion` - The final version after all the migrations are applied. | ||
- `versions` - All the versions with a migration step. | ||
This can be useful for logging purposes, preparing migration data, etc. | ||
Example: | ||
```js | ||
const Store = require('electron-store'); | ||
console.log = someLogger.log; | ||
const mainConfig = new Store({ | ||
beforeEachMigration: (store, context) => { | ||
console.log(`[main-config] migrate from ${context.fromVersion} → ${context.toVersion}`); | ||
}, | ||
migrations: { | ||
'0.4.0': store => { | ||
store.set('debugPhase', true); | ||
} | ||
} | ||
}); | ||
const secondConfig = new Store({ | ||
beforeEachMigration: (store, context) => { | ||
console.log(`[second-config] migrate from ${context.fromVersion} → ${context.toVersion}`); | ||
}, | ||
migrations: { | ||
'1.0.1': store => { | ||
store.set('debugPhase', true); | ||
} | ||
} | ||
}); | ||
``` | ||
#### name | ||
@@ -163,0 +209,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20074
488
Updatedconf@^10.2.0
Updatedtype-fest@^2.17.0