Skip to content

Commit 3bd56f9

Browse files
committed
tree api mods
1 parent 07ece31 commit 3bd56f9

1 file changed

Lines changed: 32 additions & 14 deletions

File tree

  • packages/temporal-polyfill/docs/fns

packages/temporal-polyfill/docs/fns/index.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
# Tree-shakeable API
22

3-
The tree-shakeable function-based API docs are organized by Temporal type or
4-
support object. Each page catalogs the public functions exported for that area
5-
and shows the codemod-shaped rewrite to the real Temporal API.
3+
Instead of large `Temporal.*` classes, the tree-shakeable API exposes every
4+
operation as a standalone function that acts on a plain record, so a bundler
5+
keeps only the functions you actually import:
66

7-
Unlike the class-based entry points, the tree-shakeable API always uses the
8-
runtime's native `Temporal` when one is available, with no option to force the
9-
bundled JavaScript implementation.
7+
```js
8+
import * as PlainDateFns from 'temporal-polyfill/fns/PlainDate'
109

11-
Abbreviations used by the type pages:
10+
const date = PlainDateFns.create(2024, 1, 1)
11+
const later = PlainDateFns.addMonths(date, 2)
1212

13-
- `Record` is the record type exported by the file being cataloged.
14-
- `CalendarFns.Record` is the opaque calendar handle used by tree-shakeable API
15-
functions that accept calendar behavior.
16-
- `OverflowOptions` is the calendar-field overflow options bag.
17-
- `RoundingMathOptions` contains rounding increment and rounding mode options.
18-
The unit is implied by the `roundTo*` function name. Round helpers also
19-
accept a `RoundingMode` string as shorthand for `options.roundingMode`.
13+
PlainDateFns.toString(later) // '2024-03-01'
14+
```
15+
16+
Each Temporal type has its own entrypoint under `temporal-polyfill/fns/*` — for
17+
example `temporal-polyfill/fns/PlainDate` or `temporal-polyfill/fns/ZonedDateTime`.
18+
These docs are organized by Temporal type or support object: each page catalogs
19+
the public functions exported for that area and shows the codemod-shaped rewrite
20+
to the real Temporal API.
21+
22+
The tree-shakeable API always uses the runtime's native `Temporal` when one is
23+
available. Unlike the class-based entry points — which offer
24+
`/implementation` variants for forcing the bundled JavaScript implementation —
25+
the tree-shakeable API has no such option.
2026

2127
## Catalog
2228

@@ -47,3 +53,15 @@ before calling `toTemporal`; we recommend this package's own
4753
`temporal-polyfill/global` entrypoint for optimal code sharing.
4854

4955
`toTemporal` throws when no global `Temporal` is present.
56+
57+
## Abbreviations
58+
59+
Abbreviations used by the type pages:
60+
61+
- `Record` is the record type exported by the file being cataloged.
62+
- `CalendarFns.Record` is the opaque calendar handle used by tree-shakeable API
63+
functions that accept calendar behavior.
64+
- `OverflowOptions` is the calendar-field overflow options bag.
65+
- `RoundingMathOptions` contains rounding increment and rounding mode options.
66+
The unit is implied by the `roundTo*` function name. Round helpers also
67+
accept a `RoundingMode` string as shorthand for `options.roundingMode`.

0 commit comments

Comments
 (0)