
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
localstorage-vcs
Advanced tools
As usage of localStorage evolves over time, particular meaning of keys in the storage may change
it's shape or meaning. That may result in inconsistent state of an application. localstorage-vcs
let's you track versions of localStorage and enables you to programmatically manage changes of stored data,
so localStorage is always up to date.
Localstorage script exposes a single function, that will run each time your client code gets executed in the browser. This function will mutate localStorage based on a configuration that gets passed into the function as it's only argument.
config.version: stringThis property notes current version of localStorage that the application expects. Any string will qualify as
a valid version, as long as it is unique in reference to previously used versions.
Since this property is used to determinate whether localStorage mutation should be executed, it is advised to set it manually only when localStorage changes it's shape.
Note: version will be kept in localStorage under LOCAL_STORAGE_VERSION key
Bad practice
Good practice
config.removeAll: booleanIf set true each time version changes, every key on localStorage will be removed via localStorage.clear() method.
Beware that this set to true will have priority over other below methods.
Example:
const config = {
version: '1',
removeAll: true
}
config.remove: string[]Collection of keys on localStorage that should be removed after version changes.
A key refers to localStorage.getItem(key)
Beware that key present in this array will not be migrated even if specified in below option
Example:
const config = {
version: '1',
remove: ['someKey1', 'someKey2']
}
config.migrationsMigrationsMigration is represented as an array of length of 2.Migration is a reference to version, that triggers migration functions.Migration is an object that has localStorage keys, as properties and functions
as valesMigration function
Example:
const config = {
version: '2',
migrations: [
['1', { someKey: oldKey => `${oldKey}_v1` }],
['2', { someKey: oldKey => oldKey.replace('_v1', '_v2') }],
]
}
type Key = string;
type Version = string;
type MigrationFunction = (oldKey: Key | null) => Key;
interface IMigrationKeys {
[key: string]: MigrationFunction
}
type Migration = [Version, IMigrationKeys]
export interface IConfig {
migrations?: Migration[],
removeAll?: boolean,
remove?: Key[],
version: Version
}
FAQs
Library that will keep your localStorage predictable.
The npm package localstorage-vcs receives a total of 7 weekly downloads. As such, localstorage-vcs popularity was classified as not popular.
We found that localstorage-vcs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.

Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.

Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.