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.0 to 1.0.1

11

dist/index.d.ts

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

of: typeof millisecondsOf;
from: (time: number | import("./lib").Seconds | import("./lib").Milliseconds | import("./lib").Minutes | import("./lib").Hours | import("./lib").Days) => number;
from: (time: import("./lib").MaybeTimeDuration) => number;
};
seconds: {
of: typeof secondsOf;
from: (time: number | import("./lib").Seconds | import("./lib").Milliseconds | import("./lib").Minutes | import("./lib").Hours | import("./lib").Days) => number;
from: (time: import("./lib").MaybeTimeDuration) => number;
};
minutes: {
of: typeof minutesOf;
from: (time: number | import("./lib").Seconds | import("./lib").Milliseconds | import("./lib").Minutes | import("./lib").Hours | import("./lib").Days) => number;
from: (time: import("./lib").MaybeTimeDuration) => number;
};
hours: {
of: typeof hoursOf;
from: (time: number | import("./lib").Seconds | import("./lib").Milliseconds | import("./lib").Minutes | import("./lib").Hours | import("./lib").Days) => number;
from: (time: import("./lib").MaybeTimeDuration) => number;
};
days: {
of: typeof daysOf;
from: (time: number | import("./lib").Seconds | import("./lib").Milliseconds | import("./lib").Minutes | import("./lib").Hours | import("./lib").Days) => number;
from: (time: import("./lib").MaybeTimeDuration) => number;
};
};
export type { Milliseconds, Seconds, Minutes, Hours, Days, TimeDuration, MaybeTimeDuration, isTypedDuration } from "./lib";

@@ -27,3 +27,4 @@ interface TypedDuration {

export declare type TimeDuration = Milliseconds | Seconds | Minutes | Hours | Days;
declare type MaybeTimeDuration = TimeDuration | number;
export declare type MaybeTimeDuration = TimeDuration | number;
export declare const isTypedDuration: (maybeTypedDuration: any) => maybeTypedDuration is TimeDuration;
export declare function secondsOf(time: MaybeTimeDuration): Seconds;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const isTypedDuration = (maybeTypedDuration) => typeof maybeTypedDuration === "object" &&
exports.isTypedDuration = (maybeTypedDuration) => typeof maybeTypedDuration === "object" &&
maybeTypedDuration.valueType === "TYPED_DURATION";
const isSeconds = (maybeSeconds) => isTypedDuration(maybeSeconds) && maybeSeconds.type === "SECONDS";
const isMilliseconds = (maybeMilliseconds) => isTypedDuration(maybeMilliseconds) &&
const isSeconds = (maybeSeconds) => exports.isTypedDuration(maybeSeconds) && maybeSeconds.type === "SECONDS";
const isMilliseconds = (maybeMilliseconds) => exports.isTypedDuration(maybeMilliseconds) &&
maybeMilliseconds.type === "MILLISECONDS";
const isMinutes = (maybeMinutes) => isTypedDuration(maybeMinutes) && maybeMinutes.type === "MINUTES";
const isHours = (maybeHours) => isTypedDuration(maybeHours) && maybeHours.type === "HOURS";
const isDays = (maybeDays) => isTypedDuration(maybeDays) && maybeDays.type === "DAYS";
const isMinutes = (maybeMinutes) => exports.isTypedDuration(maybeMinutes) && maybeMinutes.type === "MINUTES";
const isHours = (maybeHours) => exports.isTypedDuration(maybeHours) && maybeHours.type === "HOURS";
const isDays = (maybeDays) => exports.isTypedDuration(maybeDays) && maybeDays.type === "DAYS";
const isNumber = (maybeNumber) => typeof maybeNumber === "number";

@@ -117,3 +117,3 @@ const newSeconds = (time) => ({

exports.daysOf = daysOf;
exports.numberFrom = (time) => isTypedDuration(time) ? time.value : time;
exports.numberFrom = (time) => exports.isTypedDuration(time) ? time.value : time;
exports.millisecondsFrom = (time) => isNumber(time)

@@ -120,0 +120,0 @@ ? time

{
"name": "typed-duration",
"version": "1.0.0",
"version": "1.0.1",
"description": "Zero-dependency typed duration library for JavaScript",

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

# Typed Duration
![Node.js CI](https://github.com/jwulf/typed-duration/workflows/Node.js%20CI/badge.svg)
[![npm version](https://badge.fury.io/js/typed-duration.svg)](https://badge.fury.io/js/typed-duration)

@@ -5,0 +6,0 @@ A Zero-dependency typed duration library for JavaScript/TypeScript. Express and convert time durations with type-safety.

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