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.1 to 1.0.2

4

dist/index.d.ts

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

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

@@ -24,3 +24,6 @@ "use strict";

from: lib_1.daysFrom
}
},
valueFrom: lib_1.valueFrom
};
var lib_2 = require("./lib");
exports.isTypedDuration = lib_2.isTypedDuration;

@@ -28,3 +28,12 @@ interface TypedDuration {

export declare type MaybeTimeDuration = TimeDuration | number;
export declare const isTypedDuration: (maybeTypedDuration: any) => maybeTypedDuration is TimeDuration;
/**
* Returns true if the argument is a typed duration object.
* Also, acts as a type guard.
*
*/
export declare const isTypedDuration: (maybeTypedDuration: MaybeTimeDuration) => maybeTypedDuration is TimeDuration;
/**
* Return the unwrapped number from any typed duration, regardless of its type
*/
export declare const valueFrom: (time: MaybeTimeDuration) => number;
export declare function secondsOf(time: MaybeTimeDuration): Seconds;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Returns true if the argument is a typed duration object.
* Also, acts as a type guard.
*
*/
exports.isTypedDuration = (maybeTypedDuration) => typeof maybeTypedDuration === "object" &&
maybeTypedDuration.valueType === "TYPED_DURATION";
/**
* Return the unwrapped number from any typed duration, regardless of its type
*/
exports.valueFrom = (time) => exports.isTypedDuration(time) ? time.value : time;
const isSeconds = (maybeSeconds) => exports.isTypedDuration(maybeSeconds) && maybeSeconds.type === "SECONDS";

@@ -6,0 +15,0 @@ const isMilliseconds = (maybeMilliseconds) => exports.isTypedDuration(maybeMilliseconds) &&

{
"name": "typed-duration",
"version": "1.0.1",
"version": "1.0.2",
"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