| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/control.machinox.in/node_modules/redux-persist/src/ |
Upload File : |
// @flow
import { DEFAULT_VERSION } from './constants'
import type { PersistedState, MigrationManifest } from './types'
export default function createMigrate(
migrations: MigrationManifest,
config?: { debug: boolean }
) {
let { debug } = config || {}
return function(
state: PersistedState,
currentVersion: number
): Promise<PersistedState> {
if (!state) {
if (process.env.NODE_ENV !== 'production' && debug)
console.log('redux-persist: no inbound state, skipping migration')
return Promise.resolve(undefined)
}
let inboundVersion: number =
state._persist && state._persist.version !== undefined
? state._persist.version
: DEFAULT_VERSION
if (inboundVersion === currentVersion) {
if (process.env.NODE_ENV !== 'production' && debug)
console.log('redux-persist: versions match, noop migration')
return Promise.resolve(state)
}
if (inboundVersion > currentVersion) {
if (process.env.NODE_ENV !== 'production')
console.error('redux-persist: downgrading version is not supported')
return Promise.resolve(state)
}
let migrationKeys = Object.keys(migrations)
.map(ver => parseInt(ver))
.filter(key => currentVersion >= key && key > inboundVersion)
.sort((a, b) => a - b)
if (process.env.NODE_ENV !== 'production' && debug)
console.log('redux-persist: migrationKeys', migrationKeys)
try {
let migratedState = migrationKeys.reduce((state, versionKey) => {
if (process.env.NODE_ENV !== 'production' && debug)
console.log(
'redux-persist: running migration for versionKey',
versionKey
)
return migrations[versionKey](state)
}, state)
return Promise.resolve(migratedState)
} catch (err) {
return Promise.reject(err)
}
}
}