Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@schibsted/niche-utils

Package Overview
Dependencies
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@schibsted/niche-utils - npm Package Compare versions

Comparing version 0.1.2 to 0.2.0

2

lib/localStorage/localStorage.d.ts
export declare function getFromLocalStorage(item: string): string | null | undefined;
export declare function saveToLocalStorage(item: string, value: any): void;
export declare function removeFromLocalStorage(item: string): void;
export declare function getFromLocalStorageWithExpiration(key: string, expiration: number): any;
export declare function saveToLocalStorageWithExpiration(key: string, value: any): void;

@@ -25,1 +25,27 @@ export function getFromLocalStorage(item) {

}
export function getFromLocalStorageWithExpiration(key, expiration) {
try {
const data = JSON.parse(localStorage.getItem(key) || '');
if ((data === null || data === void 0 ? void 0 : data.timestamp) && data.timestamp + expiration > new Date().getTime()) {
return data.data;
}
}
catch (e) {
// ignore
}
return undefined;
}
export function saveToLocalStorageWithExpiration(key, value) {
try {
if (value) {
const data = {
data: value,
timestamp: new Date().getTime(),
};
localStorage.setItem(key, JSON.stringify(data));
}
}
catch (e) {
// ignore
}
}

4

package.json
{
"name": "@schibsted/niche-utils",
"version": "0.1.2",
"version": "0.2.0",
"license": "Apache-2.0",

@@ -22,3 +22,3 @@ "main": "lib/index.js",

},
"gitHead": "9facbdde0c84693cfe066edab199fbe062b49461"
"gitHead": "cac17de15fd80ae74eb553d7a29ddb8f819b7963"
}

@@ -24,1 +24,29 @@ export function getFromLocalStorage(item: string) {

}
export function getFromLocalStorageWithExpiration(key: string, expiration: number) {
try {
const data = JSON.parse(localStorage.getItem(key) || '');
if (data?.timestamp && data.timestamp + expiration > new Date().getTime()) {
return data.data;
}
} catch (e) {
// ignore
}
return undefined;
}
export function saveToLocalStorageWithExpiration(key: string, value: any) {
try {
if (value) {
const data = {
data: value,
timestamp: new Date().getTime(),
};
localStorage.setItem(key, JSON.stringify(data));
}
} catch (e) {
// ignore
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc