Add weblock package
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
/** Lock a key from being accessed by `localStorage` and `sessionStorage`. */
|
||||
function lockStorageKey(key: string): void {
|
||||
const proto = Object.getPrototypeOf(localStorage ?? sessionStorage);
|
||||
const _getItem = proto.getItem;
|
||||
|
||||
proto.getItem = function(_key: string) {
|
||||
if (_key === key) {
|
||||
throw new Error(`${_key} is locked`);
|
||||
} else {
|
||||
return _getItem.bind(this)(_key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { lockStorageKey };
|
||||
Reference in New Issue
Block a user