Skip to content

Commit

Permalink
rename UUID_MATCHER from uuid_matcher for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Jun 28, 2024
1 parent 64969f1 commit f974a64
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/healthy-toys-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ryanatkn/belt': minor
---

rename `UUID_MATCHER` from `uuid_matcher` for consistency
4 changes: 2 additions & 2 deletions src/lib/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ export const hex_string_to_hsl = (hex: string): Hsl => {
return rgb_to_hsl(rgb[0], rgb[1], rgb[2]);
};

const hsl_string_matcher = /^hsl\((\d+),?\s*(\d+)%,?\s*(\d+)%/u;
const HSL_STRING_MATCHER = /^hsl\((\d+),?\s*(\d+)%,?\s*(\d+)%/u;

export const parse_hsl_string = (hsl: string): Hsl => {
const match = hsl_string_matcher.exec(hsl);
const match = HSL_STRING_MATCHER.exec(hsl);
if (!match) throw new Error('invalid HSL string');
return [Number(match[1]) / 360, Number(match[2]) / 100, Number(match[3]) / 100];
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {create_counter} from '$lib/counter.js';

export type Uuid = Flavored<string, 'Uuid'>;

export const is_uuid = (str: string): str is Uuid => uuid_matcher.test(str);
export const is_uuid = (str: string): str is Uuid => UUID_MATCHER.test(str);

/**
* Postgres doesn't support the namespace prefix, so neither does Felt.
* For more see the UUID RFC - https://tools.ietf.org/html/rfc4122
* The Ajv validator does support the namespace, hence this custom implementation.
*/
export const uuid_matcher = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/iu;
export const UUID_MATCHER = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/iu;

export interface Client_Id_Creator {
(): string;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const src_json = {
declarations: [
{name: 'Uuid', kind: 'type'},
{name: 'is_uuid', kind: 'function'},
{name: 'uuid_matcher', kind: 'variable'},
{name: 'UUID_MATCHER', kind: 'variable'},
{name: 'Client_Id_Creator', kind: 'type'},
{name: 'create_client_id_creator', kind: 'function'},
],
Expand Down

0 comments on commit f974a64

Please sign in to comment.