New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@date-vir/duration

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@date-vir/duration - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

dist/convert-duration.d.ts

55

dist/duration-unit.d.ts

@@ -0,1 +1,6 @@

/**
* All duration units supported by date-vir.
*
* @category Duration
*/
export declare enum DurationUnit {

@@ -12,17 +17,47 @@ Years = "years",

}
/**
* A mapping of {@link DurationUnit} to to all of its values' singular duration names in English.
*
* @category Util
*/
export declare const singularDurationUnitNames: {
readonly years: "year";
readonly quarters: "quarter";
readonly months: "month";
readonly weeks: "week";
readonly days: "day";
readonly hours: "hour";
readonly minutes: "minute";
readonly seconds: "second";
readonly milliseconds: "millisecond";
readonly seconds: "second";
readonly minutes: "minute";
readonly hours: "hour";
readonly days: "day";
readonly weeks: "week";
readonly months: "month";
readonly quarters: "quarter";
readonly years: "year";
};
/**
* Array of DurationUnit values: from smallest unit (milliseconds at index 0) to longest unit
* (years).
* A mapping of {@link DurationUnit} to to all of its values' abbreviations in English.
*
* @category Util
*/
export declare const durationUnitNameAbbreviations: {
readonly years: "yr";
readonly quarters: "q";
readonly months: "mo";
readonly weeks: "wk";
readonly days: "d";
readonly hours: "hr";
readonly minutes: "min";
readonly seconds: "sec";
readonly milliseconds: "ms";
};
/**
* Array of sorted {@link DurationUnit} possibilities: from smallest unit (milliseconds at index 0)
* to longest unit (years).
*
* @category Util
*/
export declare const orderedDurationUnits: readonly [DurationUnit.Milliseconds, DurationUnit.Seconds, DurationUnit.Minutes, DurationUnit.Hours, DurationUnit.Days, DurationUnit.Weeks, DurationUnit.Months, DurationUnit.Quarters, DurationUnit.Years];
/**
* The maximum value, exclusive, for each duration unit before it should roll-over into the next
* duration unit.
*
* @category Util
*/
export declare const maxDurations: Readonly<Record<DurationUnit, number>>;

@@ -0,1 +1,6 @@

/**
* All duration units supported by date-vir.
*
* @category Duration
*/
export var DurationUnit;

@@ -13,17 +18,40 @@ (function (DurationUnit) {

})(DurationUnit || (DurationUnit = {}));
/**
* A mapping of {@link DurationUnit} to to all of its values' singular duration names in English.
*
* @category Util
*/
export const singularDurationUnitNames = {
[DurationUnit.Years]: 'year',
[DurationUnit.Quarters]: 'quarter',
[DurationUnit.Months]: 'month',
[DurationUnit.Weeks]: 'week',
[DurationUnit.Days]: 'day',
[DurationUnit.Hours]: 'hour',
[DurationUnit.Minutes]: 'minute',
[DurationUnit.Seconds]: 'second',
[DurationUnit.Milliseconds]: 'millisecond',
[DurationUnit.Seconds]: 'second',
[DurationUnit.Minutes]: 'minute',
[DurationUnit.Hours]: 'hour',
[DurationUnit.Days]: 'day',
[DurationUnit.Weeks]: 'week',
[DurationUnit.Months]: 'month',
[DurationUnit.Quarters]: 'quarter',
[DurationUnit.Years]: 'year',
};
/**
* Array of DurationUnit values: from smallest unit (milliseconds at index 0) to longest unit
* (years).
* A mapping of {@link DurationUnit} to to all of its values' abbreviations in English.
*
* @category Util
*/
export const durationUnitNameAbbreviations = {
[DurationUnit.Years]: 'yr',
[DurationUnit.Quarters]: 'q',
[DurationUnit.Months]: 'mo',
[DurationUnit.Weeks]: 'wk',
[DurationUnit.Days]: 'd',
[DurationUnit.Hours]: 'hr',
[DurationUnit.Minutes]: 'min',
[DurationUnit.Seconds]: 'sec',
[DurationUnit.Milliseconds]: 'ms',
};
/**
* Array of sorted {@link DurationUnit} possibilities: from smallest unit (milliseconds at index 0)
* to longest unit (years).
*
* @category Util
*/
export const orderedDurationUnits = [

@@ -40,1 +68,18 @@ DurationUnit.Milliseconds,

];
/**
* The maximum value, exclusive, for each duration unit before it should roll-over into the next
* duration unit.
*
* @category Util
*/
export const maxDurations = {
[DurationUnit.Milliseconds]: 1000,
[DurationUnit.Seconds]: 60,
[DurationUnit.Minutes]: 60,
[DurationUnit.Hours]: 24,
[DurationUnit.Days]: 30,
[DurationUnit.Weeks]: 4,
[DurationUnit.Months]: 12,
[DurationUnit.Quarters]: 4,
[DurationUnit.Years]: Infinity,
};

74

dist/duration.d.ts

@@ -1,6 +0,4 @@

import { IsUnknown, RequireAtLeastOne, UnionToIntersection } from 'type-fest';
import { DurationUnit } from './duration-unit';
/**
* Copied from `@augment-vir/common`.
*/
import type { RequireAtLeastOne, UnionToIntersection } from 'type-fest';
import { DurationUnit } from './duration-unit.js';
/** Copied from `@augment-vir/common` so this package doesn't depend on augment-vir. */
type RequiredAndNotNull<T> = {

@@ -10,17 +8,13 @@ [P in keyof T]-?: NonNullable<T[P]>;

/**
* All possible options for the more strict Duration type. Matches the DurationObjectUnits type from
* the luxon package.
* A looser type with all possible options, based on the stricter {@link Duration} type. Matches the
* DurationObjectUnits type from the luxon package.
*
* @category Util
*/
export type AnyDuration = {
years?: number | undefined;
quarters?: number | undefined;
months?: number | undefined;
weeks?: number | undefined;
days?: number | undefined;
hours?: number | undefined;
minutes?: number | undefined;
seconds?: number | undefined;
milliseconds?: number | undefined;
};
/** Requires at least one duration unit to be set. */
export type AnyDuration = Partial<Record<DurationUnit, number | undefined>>;
/**
* Requires at least one duration unit to be set.
*
* @category Util
*/
export type AtLeastOneDuration = RequireAtLeastOne<RequiredAndNotNull<AnyDuration>>;

@@ -31,2 +25,4 @@ /**

* units depends on the context of this type's usage.
*
* @category Util
*/

@@ -36,6 +32,42 @@ export type AllDurations = RequiredAndNotNull<AnyDuration>;

* Not a single date instance, but a description of a date duration. Used to calculate diffs between
* dates, or add offsets to an existing date, or describe a single time duration. Usually only one
* dates, add offsets to an existing date, or describe a single time duration. Usually only one
* property is set on this at any given time.
*
* Settings a type parameter of `true` allows any {@link DurationUnit}.
*
* @category Duration
*/
export type Duration<DurationKeys extends DurationUnit | unknown> = UnionToIntersection<IsUnknown<DurationKeys> extends true ? AnyDuration : DurationKeys extends DurationUnit ? Pick<AllDurations, `${DurationKeys}`> : never>;
export type Duration<DurationKeys extends DurationUnit | true> = UnionToIntersection<DurationKeys extends true ? AnyDuration : DurationKeys extends DurationUnit ? Pick<AllDurations, DurationKeys> : never>;
/**
* An object with all {@link DurationUnit} keys set to `0`.
*
* @category Zero
*/
export declare const zeroDuration: {
readonly years: 0;
readonly quarters: 0;
readonly months: 0;
readonly weeks: 0;
readonly days: 0;
readonly hours: 0;
readonly minutes: 0;
readonly seconds: 0;
readonly milliseconds: 0;
};
/**
* An object with all {@link DurationUnit} keys set to `0`. Alias for {@link zeroDuration}.
*
* @category Zero
*/
export declare const emptyDuration: {
readonly years: 0;
readonly quarters: 0;
readonly months: 0;
readonly weeks: 0;
readonly days: 0;
readonly hours: 0;
readonly minutes: 0;
readonly seconds: 0;
readonly milliseconds: 0;
};
export {};

@@ -1,1 +0,22 @@

export {};
/**
* An object with all {@link DurationUnit} keys set to `0`.
*
* @category Zero
*/
export const zeroDuration = {
years: 0,
quarters: 0,
months: 0,
weeks: 0,
days: 0,
hours: 0,
minutes: 0,
seconds: 0,
milliseconds: 0,
};
/**
* An object with all {@link DurationUnit} keys set to `0`. Alias for {@link zeroDuration}.
*
* @category Zero
*/
export const emptyDuration = zeroDuration;

@@ -0,3 +1,6 @@

export * from './convert-duration.js';
export * from './duration-selection.js';
export * from './duration-unit.js';
export * from './duration-utils.js';
export * from './duration.js';
export * from './equalize-duration.js';
export * from './round-options.js';

@@ -0,3 +1,6 @@

export * from './convert-duration.js';
export * from './duration-selection.js';
export * from './duration-unit.js';
export * from './duration-utils.js';
export * from './duration.js';
export * from './equalize-duration.js';
export * from './round-options.js';
{
"name": "@date-vir/duration",
"version": "6.0.0",
"description": "",
"keywords": [],
"version": "6.0.1",
"description": "Durations units an utils for date-vir.",
"keywords": [
"duration",
"date",
"util",
"time"
],
"homepage": "https://github.com/electrovir/date-vir",

@@ -26,8 +31,23 @@ "bugs": {

"docs": "virmator docs",
"start": "tsx src/index.ts",
"test": "virmator test node",
"test": "virmator test web",
"test:coverage": "npm run test coverage",
"test:docs": "virmator docs check",
"test:update": "npm test update"
"test:docs": "virmator docs check"
},
"dependencies": {
"@types/luxon": "^3.4.2",
"luxon": "^3.5.0",
"type-fest": "^4.26.1"
},
"devDependencies": {
"@augment-vir/assert": "^30.1.0",
"@augment-vir/test": "^30.1.0",
"@web/dev-server-esbuild": "^1.0.2",
"@web/test-runner": "^0.19.0",
"@web/test-runner-commands": "^0.9.0",
"@web/test-runner-playwright": "^0.11.0",
"@web/test-runner-visual-regression": "^0.10.0",
"istanbul-smart-text-reporter": "^1.1.4",
"markdown-code-example-inserter": "^3.0.0",
"typedoc": "^0.26.7"
},
"engines": {

@@ -38,7 +58,3 @@ "node": ">=22"

"access": "public"
},
"dependencies": {
"@types/luxon": "^3.4.2",
"luxon": "^3.5.0"
}
}
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