Skip to content

Commit b45f7c1

Browse files
committed
Updated readme and fixed the type distribution
1 parent 545fa04 commit b45f7c1

File tree

11 files changed

+146
-29
lines changed

11 files changed

+146
-29
lines changed

.github/workflows/publish.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ jobs:
3939
- name: Build
4040
run: bun run build
4141

42-
- name: Generate types
43-
run: bun run types
44-
4542
- name: Publish to NPM
4643
run: bun publish --access public
4744
continue-on-error: true

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11

22
# Tinytime ⏰
3-
> A straightforward date and time formatter in <850b.
3+
4+
> A straightforward date and time formatter in <840b.
45
56
[![Publish to NPM and JSR](https://github.com/Atulin/tinytime/actions/workflows/publish.yml/badge.svg)](https://github.com/Atulin/tinytime/actions/workflows/publish.yml)
67
[![NPM Version](https://img.shields.io/npm/v/%40angius%2Ftinytime)](https://www.npmjs.com/package/@angius/tinytime)
78
[![JSR Version](https://img.shields.io/jsr/v/%40angius/tinytime?color=f7df1e)](https://jsr.io/@angius/tinytime)
9+
[![Checked with Biome](https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev)
10+
11+
## This fork
812

13+
* Proper type definitions
14+
* More correct code at the cost of 38 more bytes gzipped
15+
* ESM-only
916

1017
## API
1118

@@ -24,34 +31,35 @@ template.render(new Date());
2431

2532
* `MMMM` - Full Month (September)
2633
* `MM` - Partial Month (Sep)
27-
* `Mo` - Numeric Month (9) <sup>1</sup>
34+
* `Mo` - Numeric Month (9) <sup>*</sup>
2835
* `YYYY` - Full Year (1992)
2936
* `YY` - Partial Year (92)
3037
* `dddd` - Day of the Week (Monday)
31-
* `DD` - Day of the Month (24)
38+
* `DD` - Day of the Month (24) <sup>*</sup>
3239
* `Do` - Day (24th)
33-
* `h` - Hours - 12h format
34-
* `H` - Hours - 24h format
40+
* `h` - Hours - 12h format <sup>*</sup>
41+
* `H` - Hours - 24h format <sup>*</sup>
3542
* `mm` - Minutes (zero padded)
3643
* `ss` - Seconds (zero padded)
3744
* `a` - AM/PM
3845

39-
<sup>1</sup> - you get padded months (`09` instead of `9`) by passing in the `padMonth` option.
40-
41-
```js
42-
const template = tinytime('{Mo}', { padMonth: true })
43-
```
46+
> [!NOTE]
47+
> <sup>*</sup> you can pad them with zeroes (`09` instead of `9`) by passing in the `padMonths`, `padDays`, `padHours` option.
48+
>
49+
> ```js
50+
> const template = tinytime('{Mo}', { padMonth: true })
51+
> ```
4452
4553
4654
## Efficiency
4755
4856
tinytime takes an approach similar to a compiler and generates an AST representing your template. This AST is generated when
4957
you call the main `tinytime` function. This lets you efficiently re-render your template without tinytime having to parse the
50-
template string again. That means its important that you aren'type recreating the template object frequently.
58+
template string again. That means its important that you aren't recreating the template object frequently.
5159
5260
Here's an example showing the right and wrong way to use tinytime with React.
5361
54-
Don'type do this:
62+
Don't do this:
5563
5664
```jsx
5765
function Time({ date }) {

build.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { type BuildConfig, Glob } from "bun";
2+
import isolatedDecl from "bun-plugin-isolated-decl";
23

34
const config = (min: boolean): BuildConfig => ({
4-
entrypoints: ["./src/index.ts"],
5+
entrypoints: ["./src/tinytime.ts"],
56
outdir: "./dist",
67
format: "esm",
7-
naming: min ? "[dir]/tinytime.min.[ext]" : "[dir]/tinytime.[ext]",
8+
naming: min ? "[dir]/[name].min.[ext]" : "[dir]/[name].[ext]",
9+
plugins: [isolatedDecl({})],
810
});
911

1012
for (const m of [true, false]) {

bun.lock

Lines changed: 102 additions & 0 deletions
Large diffs are not rendered by default.

jsr.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://jsr.io/schema/config-file.v1.json",
33
"name": "@angius/tinytime",
4-
"version": "1.0.2",
4+
"version": "1.0.3",
55
"license": "MIT",
6-
"exports": "./src/index.ts"
6+
"exports": "./src/tinytime.ts"
77
}

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angius/tinytime",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"exports": ["./dist/tinytime.js", "./dist/tinytime.min.js"],
55
"types": "./dist/tinytime.d.ts",
66
"license": "MIT",
@@ -13,15 +13,16 @@
1313
"scripts": {
1414
"build": "bun ./build.ts",
1515
"test": "bun test",
16-
"types": "bunx tsc",
17-
"prepublish": "bun run build && bun run types",
16+
"prepublish": "bun run build",
1817
"fix": "bunx biome check --fix"
1918
},
2019
"devDependencies": {
2120
"@biomejs/biome": "1.9.4",
2221
"@types/bun": "latest",
22+
"bun-plugin-isolated-decl": "^0.1.9",
2323
"dts-bundle-generator": "^9.5.1",
24-
"jsr": "^0.13.4"
24+
"jsr": "^0.13.4",
25+
"oxc-transform": "^0.58.1"
2526
},
2627
"peerDependencies": {
2728
"typescript": "^5.8.2"

src/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import type { TinyTimeOptions } from "./index";
21
import type { Token } from "./parser";
32
import {
43
Day,
@@ -16,6 +15,7 @@ import {
1615
Seconds,
1716
UserText,
1817
} from "./subs";
18+
import type { TinyTimeOptions } from "./tinytime";
1919

2020
const months = [
2121
"January",
File renamed without changes.

src/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"skipLibCheck": true
8+
}
9+
}

tests/tinytime.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "bun:test";
2-
import { tinytime } from "../src/index";
2+
import { tinytime } from "../src/tinytime.js";
33

44
// My birthday!
55
const date = new Date("September 24, 1992 021:07:30");

0 commit comments

Comments
 (0)