From 98a73fab07d9fedd1691a050c420f63d1553fab2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Mon, 22 May 2023 10:56:27 +0200 Subject: [PATCH 1/5] Add Deno config to exclude the npm directory --- deno.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 deno.json diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..05fe940 --- /dev/null +++ b/deno.json @@ -0,0 +1,18 @@ +{ + "lock": false, + "lint": { + "exclude": [ + "npm/" + ] + }, + "fmt": { + "exclude": [ + "npm/" + ] + }, + "test": { + "exclude": [ + "npm/" + ] + } +} From 3fdbb3f11cbd5e4a6a0d2de28d25ce5f4aa2b5f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Mon, 22 May 2023 10:57:44 +0200 Subject: [PATCH 2/5] Add docs for package maintainers & contributors --- DEVELOPMENT.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 DEVELOPMENT.md diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md new file mode 100644 index 0000000..097552f --- /dev/null +++ b/DEVELOPMENT.md @@ -0,0 +1,40 @@ +# Development + +```sh +# Run tests +deno test + +# Linter +deno lint + +# Formatter +deno fmt --check +deno fmt +``` + +## Releases + +Releases are to be created and managed through +[GitHub Releases](https://github.com/bjuppa/com-plain-date/releases). + +New releases are automatically published to +[deno.land](https://deno.land/x/complaindate) with a +[GitHub Webhook](https://github.com/bjuppa/com-plain-date/settings/hooks) and to +[npm](https://www.npmjs.com/package/complaindate) with a +[GitHub Action](https://github.com/bjuppa/com-plain-date/actions). + +## Testing the package + +There's a script (using [dnt](https://github.com/denoland/dnt)) that generates +an npm package from the current code into [the `npm/` directory](/npm): + +```sh +# Version tag is not required for local testing +deno run -A scripts/build_npm.ts +``` + +If you have an npm project setup locally for testing, you may install the built package using a local path: + +```sh +npm install path/to/com-plain-date/npm +``` From 0e3b0fd5e1ed3a90bc081fd914ad8077254c33a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Mon, 22 May 2023 11:04:50 +0200 Subject: [PATCH 3/5] Remove type-lift from factory --- ExPlainDate.ts | 1 - PlainDate.ts | 6 +----- utils/splitDateTime.ts | 2 +- utils/splitLocalDateTime.ts | 2 +- utils/splitUtcDateTime.ts | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/ExPlainDate.ts b/ExPlainDate.ts index b71f266..0bdb4b3 100644 --- a/ExPlainDate.ts +++ b/ExPlainDate.ts @@ -230,5 +230,4 @@ export function ExPlainDate( return exPlainDate; } -ExPlainDate.of = ExPlainDate; ExPlainDate.fromString = PlainDate.fromString; diff --git a/PlainDate.ts b/PlainDate.ts index 04d5e48..402e255 100644 --- a/PlainDate.ts +++ b/PlainDate.ts @@ -85,8 +85,6 @@ export interface ComPlainDate { /** Describes a factory function that creates plain-date objects */ export interface PlainDateFactory { (x: SloppyDate): T; - /** Type lift (unit) */ - of: PlainDateFactory; /** Create a new plain-date object from an ISO string */ fromString: ( this: PlainDateFactory, @@ -178,8 +176,6 @@ export function PlainDate( return plainDate; } -PlainDate.of = PlainDate; - PlainDate.fromString = function ( this: PlainDateFactory, isoDateString: string, @@ -188,5 +184,5 @@ PlainDate.fromString = function ( if (!parts) { throw TypeError(`No date parts found in string: ${isoDateString}`); } - return this.of(parts); + return this(parts); }; diff --git a/utils/splitDateTime.ts b/utils/splitDateTime.ts index f62e7d6..f0b6c9b 100644 --- a/utils/splitDateTime.ts +++ b/utils/splitDateTime.ts @@ -13,7 +13,7 @@ export function splitDateTime(timezone: string) { instant ??= new Date(); const locale = "en"; const options = { timeZone: timezone, hour12: false }; - const plainDate = PlainDate.of({ + const plainDate = PlainDate({ year: instant.toLocaleDateString(locale, { ...options, year: "numeric" }), month: instant.toLocaleDateString(locale, { ...options, diff --git a/utils/splitLocalDateTime.ts b/utils/splitLocalDateTime.ts index b974911..136b695 100644 --- a/utils/splitLocalDateTime.ts +++ b/utils/splitLocalDateTime.ts @@ -7,7 +7,7 @@ import { SplitDateTime } from "../support/date-time-types.ts"; */ export function splitLocalDateTime(instant?: Date): SplitDateTime { instant ??= new Date(); - const plainDate = PlainDate.of({ + const plainDate = PlainDate({ year: instant.getFullYear(), month: instant.getMonth() + 1, day: instant.getDate(), diff --git a/utils/splitUtcDateTime.ts b/utils/splitUtcDateTime.ts index cb09705..63b15f8 100644 --- a/utils/splitUtcDateTime.ts +++ b/utils/splitUtcDateTime.ts @@ -7,7 +7,7 @@ import { SplitDateTime } from "../support/date-time-types.ts"; */ export function splitUtcDateTime(instant?: Date): SplitDateTime { instant ??= new Date(); - const plainDate = PlainDate.of({ + const plainDate = PlainDate({ year: instant.getUTCFullYear(), month: instant.getUTCMonth() + 1, day: instant.getUTCDate(), From 628c6c1a936560e789f5de2609ba48396f47b564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Mon, 22 May 2023 11:44:53 +0200 Subject: [PATCH 4/5] Format markdown --- DEVELOPMENT.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 097552f..f9ff291 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -33,7 +33,8 @@ an npm package from the current code into [the `npm/` directory](/npm): deno run -A scripts/build_npm.ts ``` -If you have an npm project setup locally for testing, you may install the built package using a local path: +If you have an npm project setup locally for testing, you may install the built +package using a local path: ```sh npm install path/to/com-plain-date/npm From 9e29f235ff2521ff9be2a0b0345189d0ec15b418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Mon, 22 May 2023 11:47:52 +0200 Subject: [PATCH 5/5] Document the minimal expected build footprint --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6190f5f..e133d74 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ available — only time will tell... [API documentation at deno.land](https://deno.land/x/complaindate/mod.ts) +The footprint of a tree-shaken and compressed production build starts below +`1.5 kB` when using just the `PlainDate` object API. + ## Quick example ```ts