Skip to content

Commit

Permalink
Merge dffb0b8 into 0fdb6aa
Browse files Browse the repository at this point in the history
  • Loading branch information
heyjul3s committed Feb 8, 2021
2 parents 0fdb6aa + dffb0b8 commit b293461
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/media/src/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function createQueryArray(queries: Partial<Media> = {}): string {
boundaryTypes.hasOwnProperty(key)
? acc.concat(mediaBounds({ [key]: queries[key] }))
: acc.concat(formatQueryValue(queries[key])),
[]
[] as string[]
)
.join(' and ');
}
Expand Down
13 changes: 10 additions & 3 deletions packages/media/src/mediaBoundaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function mediaBounds(
): string | string[] {
if (!!query && Object.keys(query).length) {
const [key, value] = Object.entries(query)[0];
return createBoundaryString(key, value);
return createBoundaryString(key, value as string);
}

return '';
Expand Down Expand Up @@ -63,6 +63,13 @@ const VALUE_REGEX = /((\d{1,}\/\d{1,})|(\d{1,}(rem|em|px|vh|vw)))+/g;
export const extractValues = extractByRegex.bind(null, VALUE_REGEX);
export const extractOperators = extractByRegex.bind(null, OPERATOR_REGEX);

export function extractByRegex(REGEX: RegExp, value: string): string[] {
return isNonEmptyString(value) ? value.match(REGEX) : [];
export function extractByRegex(
REGEX: RegExp,
value: string
): RegExpMatchArray | string[] {
if (!isNonEmptyString(value)) {
return [];
}

return value.match(REGEX) || [];
}

0 comments on commit b293461

Please sign in to comment.