Skip to content

Commit

Permalink
isDefined
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Nov 19, 2024
1 parent accc973 commit d3735ad
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/ten-kiwis-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@elbwalker/connector-gcp': patch
'@elbwalker/utils': patch
---

gcp connector [#453](https://github.com/elbwalker/walkerOS/issues/453)
3 changes: 2 additions & 1 deletion packages/utils/src/core/byPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { WalkerOS } from '@elbwalker/types';
import { isDefined } from '..';

export function getByPath(
event: unknown,
Expand Down Expand Up @@ -31,7 +32,7 @@ export function getByPath(
if (!values) break;
}

return typeof values !== 'undefined' ? values : defaultValue;
return isDefined(values) ? values : defaultValue;
}

export function setByPath(
Expand Down
4 changes: 2 additions & 2 deletions packages/utils/src/core/mapping.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Mapping, WalkerOS } from '@elbwalker/types';
import { castToProperty, getByPath, getGrantedConsent } from '.';
import { castToProperty, getByPath, getGrantedConsent, isDefined } from '.';

export function getEventMapping(
event: string,
Expand Down Expand Up @@ -84,6 +84,6 @@ export function getMappingValue(
const property = castToProperty(mappingValue);

// Finally, check and convert the type
return typeof property !== 'undefined' ? property : value; // Always use value as a fallback
return isDefined(property) ? property : value; // Always use value as a fallback
}, undefined as WalkerOS.Property | undefined);
}
4 changes: 3 additions & 1 deletion packages/utils/src/web/getHashWeb.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { isDefined } from '../web';

async function sha256(message: string): Promise<string | undefined> {
const crypto: Crypto | undefined =
typeof window !== 'undefined' && window.crypto ? window.crypto : undefined;
isDefined(window) && window.crypto ? window.crypto : undefined;

// Crypto API not available
if (!crypto || !crypto.subtle || !TextEncoder) return;
Expand Down

0 comments on commit d3735ad

Please sign in to comment.