Skip to content

Commit

Permalink
fix: make sure that environment dont break
Browse files Browse the repository at this point in the history
  • Loading branch information
emkis committed Apr 5, 2022
1 parent 0e178c3 commit 0ff8162
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/data-layer/data-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export function createDataLayerModule(): DataLayerModule {
}

function assertIsAvailable() {
const isServer = typeof window === 'undefined'
const isDefined = typeof window.dataLayer !== 'undefined'
const isArray = Array.isArray(window.dataLayer)
const isServer = () => typeof window === 'undefined'
const isDefined = () => typeof window.dataLayer !== 'undefined'
const isArray = () => Array.isArray(window.dataLayer)

if (isServer) throwIsServer()
else if (!isDefined) throwIsNotDefined()
else if (!isArray) throwIsNotArray()
if (isServer()) throwIsServer()
else if (!isDefined()) throwIsNotDefined()
else if (!isArray()) throwIsNotArray()
}

return {
Expand Down

0 comments on commit 0ff8162

Please sign in to comment.