@@ -139,10 +139,6 @@ function formatArgs(
139139 */
140140const log = console . debug || console . log || ( ( ) => { } )
141141
142- // Use non-null assertion operator because
143- // we handle the case where storage is undefined in load/save.
144- const storage = localstorage ( ) !
145-
146142const defaultOptions : Omit < Required < DebugOptions > , 'color' > = {
147143 useColors : true ,
148144
@@ -176,28 +172,11 @@ export function createDebug(
176172 )
177173}
178174
179- /**
180- * Localstorage attempts to return the localstorage.
181- *
182- * This is necessary because safari throws
183- * when a user disables cookies/localstorage
184- * and you attempt to access it.
185- */
186- function localstorage ( ) : Storage | undefined {
187- try {
188- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
189- // The Browser also has localStorage in the global context.
190- return localStorage
191- } catch {
192- // Swallow
193- // XXX (@Qix-) should we be logging these?
194- }
195- }
196-
197175function load ( ) : string {
198176 let r : string | null | undefined
199177 try {
200- r = storage . getItem ( 'debug' ) || storage . getItem ( 'DEBUG' )
178+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context.
179+ r = localStorage . getItem ( 'debug' ) || localStorage . getItem ( 'DEBUG' )
201180 } catch {
202181 // Swallow
203182 // XXX (@Qix-) should we be logging these?
@@ -214,9 +193,9 @@ function load(): string {
214193function save ( namespaces : string ) {
215194 try {
216195 if ( namespaces ) {
217- storage . setItem ( 'debug' , namespaces )
196+ localStorage . setItem ( 'debug' , namespaces )
218197 } else {
219- storage . removeItem ( 'debug' )
198+ localStorage . removeItem ( 'debug' )
220199 }
221200 } catch {
222201 // Swallow
0 commit comments