Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

temporal-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

temporal-polyfill

A spec-compliant Temporal JavaScript polyfill in 15kb

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
72K
increased by7.11%
Maintainers
1
Weekly downloads
 
Created
Source

temporal-polyfill

A spec-compliant* Temporal JavaScript polyfill in 15kb**.

Works in modern browsers***, not Internet Explorer.

Codepen

CDN link

Installation

npm install temporal-polyfill

A) Import globally:

import 'temporal-polyfill/global'

// the global Temporal object is now available
const zdt = Temporal.ZonedDateTime.from('2020-08-05T20:06:13[America/Chicago]')
console.log(zdt.toLocaleString())

B) Import as an ES module without side effects:

import { ZonedDateTime } from 'temporal-polyfill'

const zdt = ZonedDateTime.from('2020-08-05T20:06:13[America/Chicago]')
console.log(zdt.toLocaleString())

C) The above techniques try using the built-in Temporal object and fall back to the polyfill. To guarantee using the polyfill, do this:

import { ZonedDateTime } from 'temporal-polyfill/impl'

const zdt = ZonedDateTime.from('2020-08-05T20:06:13[America/Chicago]')
console.log(zdt.toLocaleString())

* = almost spec-compliant. a few more tests must pass (see results)

** = the size will shrink as the codebase is cleaned up

*** = targets browsers that support BigInt, however, more browser-compatibility work is needed

FAQs

Package last updated on 17 Mar 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc