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

typed-duration

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-duration - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

1

dist/index.d.ts

@@ -24,4 +24,5 @@ import { millisecondsOf, secondsOf, minutesOf, hoursOf, daysOf } from "./lib";

valueFrom: (time: import("./lib").MaybeTimeDuration) => number;
valueOf: (time: import("./lib").MaybeTimeDuration) => string;
isTypedDuration: (maybeTypedDuration: any) => maybeTypedDuration is import("./lib").TimeDuration;
};
export type { Milliseconds, Seconds, Minutes, Hours, Days, TimeDuration, MaybeTimeDuration, } from "./lib";

@@ -26,3 +26,4 @@ "use strict";

valueFrom: lib_1.valueFrom,
valueOf: lib_1.valueOf,
isTypedDuration: lib_1.isTypedDuration
};

@@ -5,2 +5,3 @@ interface TypedDuration {

value: number;
unit: string;
}

@@ -10,2 +11,3 @@ export interface Seconds extends TypedDuration {

valueType: "TYPED_DURATION";
unit: "s";
}

@@ -15,2 +17,3 @@ export interface Milliseconds extends TypedDuration {

valueType: "TYPED_DURATION";
unit: "ms";
}

@@ -20,2 +23,3 @@ export interface Minutes extends TypedDuration {

valueType: "TYPED_DURATION";
unit: "m";
}

@@ -25,2 +29,3 @@ export interface Hours extends TypedDuration {

valueType: "TYPED_DURATION";
unit: "h";
}

@@ -30,2 +35,3 @@ export interface Days extends TypedDuration {

valueType: "TYPED_DURATION";
unit: "d";
}

@@ -44,2 +50,7 @@ export declare type TimeDuration = Milliseconds | Seconds | Minutes | Hours | Days;

export declare const valueFrom: (time: MaybeTimeDuration) => number;
/**
*
* Return a string representation, with units. For example: `60000ms`
*/
export declare const valueOf: (time: MaybeTimeDuration) => string;
export declare function secondsOf(time: MaybeTimeDuration): Seconds;

@@ -46,0 +57,0 @@ export declare function millisecondsOf(time: MaybeTimeDuration): Milliseconds;

20

dist/lib/index.js

@@ -14,2 +14,7 @@ "use strict";

exports.valueFrom = (time) => exports.isTypedDuration(time) ? time.value : time;
/**
*
* Return a string representation, with units. For example: `60000ms`
*/
exports.valueOf = (time) => `${time}${exports.isTypedDuration(time) ? time.unit : ""}`;
const isSeconds = (maybeSeconds) => exports.isTypedDuration(maybeSeconds) && maybeSeconds.type === "SECONDS";

@@ -25,3 +30,4 @@ const isMilliseconds = (maybeMilliseconds) => exports.isTypedDuration(maybeMilliseconds) &&

value: time,
valueType: "TYPED_DURATION"
valueType: "TYPED_DURATION",
unit: "s"
});

@@ -47,3 +53,4 @@ function secondsOf(time) {

value: time,
valueType: "TYPED_DURATION"
valueType: "TYPED_DURATION",
unit: "ms"
});

@@ -69,3 +76,4 @@ function millisecondsOf(time) {

value: time,
valueType: "TYPED_DURATION"
valueType: "TYPED_DURATION",
unit: "m"
});

@@ -91,3 +99,4 @@ function minutesOf(time) {

value: time,
valueType: "TYPED_DURATION"
valueType: "TYPED_DURATION",
unit: "h"
});

@@ -113,3 +122,4 @@ function hoursOf(time) {

value: time,
valueType: "TYPED_DURATION"
valueType: "TYPED_DURATION",
unit: "d"
});

@@ -116,0 +126,0 @@ function daysOf(time) {

{
"name": "typed-duration",
"version": "1.0.5",
"version": "1.0.6",
"description": "Zero-dependency typed duration library for JavaScript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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