Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose PartialDateString type #30

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;