@clds/feature-flags
Advanced tools
Comparing version 0.7.4 to 0.7.5
export declare const createLocalStorageFeatureFlag: (key: string) => { | ||
isEnabled: () => boolean; | ||
setEnabled: (enabled: boolean) => void; | ||
setEnabled: (enabled: boolean) => string | void; | ||
whenEnabled: <T>(valueWhenEnabled: T) => { | ||
@@ -5,0 +5,0 @@ orElse: (defaultValue: T) => T; |
@@ -12,3 +12,12 @@ "use strict"; | ||
}; | ||
const getLocalStorageImpl = () => { var _a; return (_a = global.localStorage) !== null && _a !== void 0 ? _a : getInMemoryStorageImpl(); }; | ||
const getLocalStorageImpl = () => { var _a; return (_a = tryGetLocalStorage()) !== null && _a !== void 0 ? _a : getInMemoryStorageImpl(); }; | ||
const tryGetLocalStorage = () => { | ||
try { | ||
return global.localStorage; | ||
} | ||
catch (e) { | ||
console.error('@clds/feature-flags: could not access localStorage'); | ||
return null; | ||
} | ||
}; | ||
const createLocalStorageFeatureFlag = (key) => { | ||
@@ -15,0 +24,0 @@ const localStorageImpl = getLocalStorageImpl(); |
export declare const quickWinsTypography: { | ||
isEnabled: () => boolean; | ||
setEnabled: (enabled: boolean) => void; | ||
setEnabled: (enabled: boolean) => string | void; | ||
whenEnabled: <T>(valueWhenEnabled: T) => { | ||
@@ -5,0 +5,0 @@ orElse: (defaultValue: T) => T; |
export declare const createLocalStorageFeatureFlag: (key: string) => { | ||
isEnabled: () => boolean; | ||
setEnabled: (enabled: boolean) => void; | ||
setEnabled: (enabled: boolean) => string | void; | ||
whenEnabled: <T>(valueWhenEnabled: T) => { | ||
@@ -5,0 +5,0 @@ orElse: (defaultValue: T) => T; |
@@ -9,3 +9,12 @@ const getInMemoryStorageImpl = () => { | ||
}; | ||
const getLocalStorageImpl = () => { var _a; return (_a = global.localStorage) !== null && _a !== void 0 ? _a : getInMemoryStorageImpl(); }; | ||
const getLocalStorageImpl = () => { var _a; return (_a = tryGetLocalStorage()) !== null && _a !== void 0 ? _a : getInMemoryStorageImpl(); }; | ||
const tryGetLocalStorage = () => { | ||
try { | ||
return global.localStorage; | ||
} | ||
catch (e) { | ||
console.error('@clds/feature-flags: could not access localStorage'); | ||
return null; | ||
} | ||
}; | ||
export const createLocalStorageFeatureFlag = (key) => { | ||
@@ -12,0 +21,0 @@ const localStorageImpl = getLocalStorageImpl(); |
export declare const quickWinsTypography: { | ||
isEnabled: () => boolean; | ||
setEnabled: (enabled: boolean) => void; | ||
setEnabled: (enabled: boolean) => string | void; | ||
whenEnabled: <T>(valueWhenEnabled: T) => { | ||
@@ -5,0 +5,0 @@ orElse: (defaultValue: T) => T; |
{ | ||
"name": "@clds/feature-flags", | ||
"description": "", | ||
"version": "0.7.4", | ||
"version": "0.7.5", | ||
"author": "Cloudinary", | ||
@@ -6,0 +6,0 @@ "main": "./dist/cjs/index.js", |
@@ -12,4 +12,13 @@ const getInMemoryStorageImpl = () => { | ||
const getLocalStorageImpl = () => | ||
global.localStorage ?? getInMemoryStorageImpl(); | ||
tryGetLocalStorage() ?? getInMemoryStorageImpl(); | ||
const tryGetLocalStorage = () => { | ||
try { | ||
return global.localStorage; | ||
} catch (e) { | ||
console.error('@clds/feature-flags: could not access localStorage'); | ||
return null; | ||
} | ||
}; | ||
export const createLocalStorageFeatureFlag = (key: string) => { | ||
@@ -16,0 +25,0 @@ const localStorageImpl = getLocalStorageImpl(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11602
180