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

luxon

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

luxon - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

2

package.json
{
"name": "luxon",
"version": "2.2.0",
"version": "2.3.0",
"description": "Immutable date wrapper",

@@ -5,0 +5,0 @@ "author": "Isaac Cambron",

@@ -429,2 +429,32 @@ import { InvalidArgumentError, InvalidDurationError, InvalidUnitError } from "./errors.js";

/**
* Returns a string representation of a Duration with all units included
* To modify its behavior use the `listStyle` and any Intl.NumberFormat option, though `unitDisplay` is especially relevant. See {@link Intl.NumberFormat}.
* @param opts - On option object to override the formatting. Accepts the same keys as the options parameter of the native `Int.NumberFormat` constructor, as well as `listStyle`.
* @example
* ```js
* var dur = Duration.fromObject({ days: 1, hours: 5, minutes: 6 })
* dur.toHuman() //=> '1 day, 5 hours, 6 minutes'
* dur.toHuman({ listStyle: "long" }) //=> '1 day, 5 hours, and 6 minutes'
* dur.toHuman({ unitDisplay: "short" }) //=> '1 day, 5 hr, 6 min'
* ```
*/
toHuman(opts = {}) {
const l = orderedUnits
.map((unit) => {
const val = this.values[unit];
if (isUndefined(val)) {
return null;
}
return this.loc
.numberFormatter({ style: "unit", unitDisplay: "long", ...opts, unit: unit.slice(0, -1) })
.format(val);
})
.filter((n) => n);
return this.loc
.listFormatter({ type: "conjunction", style: opts.listStyle || "narrow", ...opts })
.format(l);
}
/**
* Returns a JavaScript object with this Duration's values.

@@ -431,0 +461,0 @@ * @example Duration.fromObject({ years: 1, days: 6, seconds: 2 }).toObject() //=> { years: 1, days: 6, seconds: 2 }

@@ -7,2 +7,15 @@ import { padStart, roundTo, hasRelative } from "./util.js";

// todo - remap caching
let intlLFCache = {};
function getCachedLF(locString, opts = {}) {
const key = JSON.stringify([locString, opts]);
let dtf = intlLFCache[key];
if (!dtf) {
dtf = new Intl.ListFormat(locString, opts);
intlLFCache[key] = dtf;
}
return dtf;
}
let intlDTCache = {};

@@ -148,4 +161,6 @@ function getCachedDTF(locString, opts = {}) {

if (!forceSimple) {
const intlOpts = { useGrouping: false };
const { padTo, floor, ...otherOpts } = opts;
if (!forceSimple || Object.keys(otherOpts).length > 0) {
const intlOpts = { useGrouping: false, ...opts };
if (opts.padTo > 0) intlOpts.minimumIntegerDigits = opts.padTo;

@@ -313,3 +328,3 @@ this.inf = getCachedINF(intl, intlOpts);

listingMode(defaultOK = true) {
listingMode() {
const isActuallyEn = this.isEnglish();

@@ -427,2 +442,6 @@ const hasNoWeirdness =

listFormatter(opts = {}) {
return getCachedLF(this.intl, opts);
}
isEnglish() {

@@ -429,0 +448,0 @@ return (

@@ -90,13 +90,10 @@ /*

export function padStart(input, n = 2) {
const minus = input < 0 ? "-" : "";
const target = minus ? input * -1 : input;
let result;
if (target.toString().length < n) {
result = ("0".repeat(n) + target).slice(-n);
const isNeg = input < 0;
let padded;
if (isNeg) {
padded = "-" + ("" + -input).padStart(n, "0");
} else {
result = target.toString();
padded = ("" + input).padStart(n, "0");
}
return `${minus}${result}`;
return padded;
}

@@ -103,0 +100,0 @@

@@ -12,3 +12,3 @@ import DateTime from "./datetime.js";

const VERSION = "2.2.0";
const VERSION = "2.3.0";

@@ -15,0 +15,0 @@ export {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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