Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
temporal-polyfill
Advanced tools
A spec-compliant Temporal JavaScript polyfill in 16kb.
Minimum required version if... | Chrome | Edge | Safari | Safari iOS | Firefox | Node |
---|---|---|---|---|---|---|
...transpiling to target environment | 36 (Jul 2014) | 14 (Aug 2016) | 10 (Sep 2016) | 10 (Sep 2016) | 52 (Mar 2017) | 12 (Apr 2019) |
...leaving untranspiled | 60 (Jul 2017) | 79 (Jan 2020) | 11.1 (Mar 2018) | 11.3 (Mar 2018) | 55 (Aug 2017) | 12 (Apr 2019) |
...using BigInt features | 67 (May 2018) | 79 (Jan 2020) | 14 (Sep 2020) | 14 (Sep 2020) | 68 (July 2019) | 12 (Apr 2019) |
This polyfill works fine in environments without BigInt. However, without BigInt, the following will throw errors:
❌ Avoid microseconds/nanoseconds | ✅ Use milliseconds instead |
---|---|
instant.epochMicroseconds | instant.epochMilliseconds |
instant.epochNanoseconds | instant.epochMilliseconds |
Temporal.Instant.fromEpochMicroseconds(micro) | Temporal.Instant.fromEpochMilliseconds(milli) |
Temporal.Instant.fromEpochNanoseconds(nano) | Temporal.Instant.fromEpochMilliseconds(milli) |
new Temporal.Instant(nano) | Temporal.Instant.fromEpochMilliseconds(milli) |
zonedDateTime.epochMicroseconds | zonedDateTime.epochMilliseconds |
zonedDateTime.epochNanoseconds | zonedDateTime.epochMilliseconds |
new Temporal.ZonedDateTime(nano, tz, cal) | Temporal.Instant.fromEpochMilliseconds(milli).toZonedDateTimeISO() |
Temporal.Instant.fromEpochMilliseconds(milli).toZonedDateTime(cal) |
FYI, it is not possible to properly polyfill BigInt. More Information
npm install temporal-polyfill
A) Import globally:
import 'temporal-polyfill/global'
console.log(Temporal.Now.zonedDateTimeISO().toString())
B) Import as an ES module without side effects:
import { Temporal } from 'temporal-polyfill'
console.log(Temporal.Now.zonedDateTimeISO().toString())
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 { Temporal } from 'temporal-polyfill/impl'
console.log(Temporal.Now.zonedDateTimeISO().toString())
FAQs
A lightweight polyfill for Temporal, successor to the JavaScript Date object
The npm package temporal-polyfill receives a total of 46,912 weekly downloads. As such, temporal-polyfill popularity was classified as popular.
We found that temporal-polyfill demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.