tsironis/lockr

View on GitHub
src/flush.ts

Summary

Maintainability
A
0 mins
Test Coverage
import keys from './keys';
import { hasPrefix, getPrefixedKey } from './prefix';

export default function flush() {
  if (hasPrefix()) {
    keys().forEach(key => {
      localStorage.removeItem(getPrefixedKey(key));
    });
  } else {
    localStorage.clear();
  }
}