Socket
Socket
Sign inDemoInstall

@js-temporal/polyfill

Package Overview
Dependencies
2
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @js-temporal/polyfill

Polyfill for Tc39 Stage 3 proposal Temporal (https://github.com/tc39/proposal-temporal)


Version published
Maintainers
3
Install size
3.84 MB
Created

Changelog

Source

0.4.3

Bug fixes:

  • Fix an off-by-one error when dates in the Hebrew calendar were created using monthCode, the year was a leap year, and the month was after the leap month ([f3d0ca9f])
  • Fix addition of months and years for lunisolar calendars ([4f8b04c1])
  • Fix the ISO8601 representation of years between 1 BCE and 999 BCE ([b251dc0e]).
  • Fix a bug causing time to appear to go backwards for a small number of milliseconds ([bb59ca97])
  • Always validate ISO8601 time components as well as date components ([34662a05])
  • Fix comparison of dates that might have a differing number of hours in their respective days ([a4c60241])
  • Include calendar reference information when calendarName='always' is passed to various Temporal toString method's options bags ([54fcc4f3])
  • Fix a nonconformant use of the relativeTo property bag ([9992f9b1])
  • Fix ZonedDateTime.prototype.withPlainTime(null) to throw a TypeError, instead of treating it as midnight ([ec2b0546])
  • Fix parsing of some valid Instant strings when they would be out of range before considering the UTC offset ([d9de9e74])
  • Bail out early in non-ISO calendar implementations to avoid an infinte loop when calculating the duration between two identical dates. ([6f3c42c9])
  • Fix type resolution when using TypeScript Node16 and transpiling to CJS ([9bab0eb5], see also the relevant TypeScript issue)

Non-breaking changes:

  • Consistently call observable operations with undefined options arguments, instead of empty objects ([297b8f38])

Readme

Source

Temporal Polyfill

Polyfill for TC39 Proposal: Temporal

This polyfill was kicked off by some of the champions of the Temporal proposal. The goal is to be ready for production use when the Temporal proposal reaches Stage 4, although like with all OSS work progress is dependent on contributors. We're eagerly welcoming to contributors who want to help build and maintain this polyfill. PRs are always welcome!

Note that this polyfill is not affiliated with TC39. Links to other polyfills can be found here.

This polyfill is compatible with Node.js 14 or later.

Roadmap

  • Fork non-production polyfill from tc39/proposal-temporal repo
  • Release initial pre-alpha to NPM at @js-temporal/polyfill
  • Sync the code in this repo with the handful of polyfill changes that have recently been made in the tc39/proposal-temporal repo
  • Release alpha version to NPM
  • Deprecate all other earlier Temporal polyfills
  • Optimize slow operations by reducing calls to Intl.DateTimeFormat constructor (see #7, #8, #10, #12)
  • Convert to TypeScript for better maintainability
  • Improve typing of sources for better maintainability
  • Migrate to JSBI for improved compile-time safety around BigInt operations.
  • Optimize performance of other slow operations
  • Release production version to NPM

Bug Reports and Feedback

If you think you've found a bug in the Temporal API itself (not the implementation in this polyfill), please file an issue in the tc39/proposal-temporal issue tracker issue tracker.

If you've found a bug in this polyfill—meaning that the implementation here doesn't match the Temporal spec—please file an issue in this repo's issue tracker.

Documentation

Reference documentation and examples for the Temporal API can be found here.

A cookbook to help you get started and learn the ins and outs of Temporal is available here

If you find a bug in the documentation, please file a bug over in the tc39/proposal-temporal issue tracker issue tracker.

Note that the Temporal documentation is in the process of being migrated to MDN. You can track the progress of the MDN migration here.

Usage

To install:

$ npm install @js-temporal/polyfill

CJS Usage:

const { Temporal, Intl, toTemporalInstant } = require('@js-temporal/polyfill');
Date.prototype.toTemporalInstant = toTemporalInstant;

Import the polyfill as an ES6 module:

import { Temporal, Intl, toTemporalInstant } from '@js-temporal/polyfill';
Date.prototype.toTemporalInstant = toTemporalInstant;

Note that this polyfill currently does not install a global Temporal object like a real implementation will. This behavior avoids hiding the global Temporal object in environments where a real Temporal implementation is present. See this issue for more background on this decision. Once JS engines start shipping with Temporal, we may decide to change this behavior to match built-in behavior more closely. See #2 to provide feedback or track this issue.

This polyfill ships ES2020 code for both CJS and ESM bundles - if your environment does not support ES2020, then please make sure to transpile the content of this package along with the rest of your code.

This polyfill uses JSBI to enable backwards-compatibility for environments that don't support native bigints. If your project only ever runs in environments that do support native bigints (see caniuse data), we highly recommend configuring the JSBI Babel plugin that translates JSBI calls to their native bigint equivalent, improving code-size and performance. We are exploring ways to provide separate builds for these use-cases in #155.

Contributing / Help Wanted

We're eagerly welcoming to contributors who want to help build and maintain this polyfill. PRs are always welcome!

Keywords

FAQs

Last updated on 18 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc