Skip to content

Commit

Permalink
Expose PartialDateString type
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Aug 3, 2023
1 parent 4147f08 commit 9ec2df2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alveusgg/data",
"version": "0.17.3",
"version": "0.17.4",
"private": true,
"license": "SEE LICENSE IN LICENSE.md",
"repository": {
Expand Down
14 changes: 1 addition & 13 deletions src/ambassadors/core.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
import type { IUCNStatus } from "../iucn";
import type { EnclosureKey } from "../enclosures";
import type { PartialDateString, Nullable } from "../types";
import { Class } from "./classification";

type OneToNine = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
type ZeroToNine = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
type DateStringYear =
| `19${ZeroToNine}${ZeroToNine}`
| `20${ZeroToNine}${ZeroToNine}`;
type DateStringMonth = `0${OneToNine}` | `1${0 | 1 | 2}`;
type DateStringYearMonth = `${DateStringYear}-${DateStringMonth}`;
type DateStringDay = `${0}${OneToNine}` | `${1 | 2}${ZeroToNine}` | `3${0 | 1}`;
type DateString = `${DateStringYearMonth}-${DateStringDay}`;
type PartialDateString = DateStringYear | DateStringYearMonth | DateString;

type Nullable<T> = T | null;

export type Ambassadors = typeof ambassadors;

export type AmbassadorKey = keyof Ambassadors;
Expand Down
15 changes: 15 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
type OneToNine = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
type ZeroToNine = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
type DateStringYear =
| `19${ZeroToNine}${ZeroToNine}`
| `20${ZeroToNine}${ZeroToNine}`;
type DateStringMonth = `0${OneToNine}` | `1${0 | 1 | 2}`;
type DateStringYearMonth = `${DateStringYear}-${DateStringMonth}`;
type DateStringDay = `${0}${OneToNine}` | `${1 | 2}${ZeroToNine}` | `3${0 | 1}`;
type DateString = `${DateStringYearMonth}-${DateStringDay}`;
export type PartialDateString =
| DateStringYear
| DateStringYearMonth
| DateString;

export type Nullable<T> = T | null;

0 comments on commit 9ec2df2

Please sign in to comment.