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

date-tools

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-tools - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

5

dist/src/index.d.ts

@@ -10,3 +10,5 @@ export declare enum Precision {

}
export declare type Duration = {};
export declare type Duration = {
toString(): string;
};
export declare const Duration: {

@@ -19,2 +21,3 @@ MilliSeconds(days: number): Duration;

Months(months: number): Duration;
fromString(string: string): Duration;
};

@@ -21,0 +24,0 @@ export declare type NaturalDifference = {};

@@ -33,2 +33,33 @@ "use strict";

});
(0, _rusted.impl)(Duration, {
$fromString: function $fromString(string) {
var matches = /^Duration\.([A-Za-z]+)\(([0-9]+)\)$/.exec(string);
if (!matches || matches.length !== 3) throw Error('Invalid string');
var unit = Duration[matches[1]];
if (!unit) throw Error('Invalid unit');
return unit.call(Duration, +matches[2]);
},
toString: function toString(self) {
return (0, _rusted.match)(self, {
MilliSeconds: function MilliSeconds(duration) {
return "Duration.MilliSeconds(" + duration + ")";
},
Seconds: function Seconds(duration) {
return "Duration.Seconds(" + duration + ")";
},
Minutes: function Minutes(duration) {
return "Duration.Minutes(" + duration + ")";
},
Hours: function Hours(duration) {
return "Duration.Hours(" + duration + ")";
},
Days: function Days(duration) {
return "Duration.Days(" + duration + ")";
},
Months: function Months(duration) {
return "Duration.Months(" + duration + ")";
}
});
}
});
var NaturalDifference = exports.NaturalDifference = (0, _rusted.Enum)({

@@ -35,0 +66,0 @@ Last: Duration,

2

package.json
{
"name": "date-tools",
"version": "1.1.0",
"version": "1.2.0",
"description": "Functions for comparing and counting with dates",

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

@@ -13,3 +13,5 @@ import {Enum, impl, match} from 'rusted'

export type Duration = {}
export type Duration = {
toString(): string
}
export const Duration = Enum({

@@ -29,4 +31,28 @@ MilliSeconds: 'number',

Months(months: number): Duration,
fromString(string: string): Duration
}
impl(Duration, {
$fromString(string: string) {
const matches = /^Duration\.([A-Za-z]+)\(([0-9]+)\)$/.exec(string)
if (!matches || matches.length !== 3) throw Error('Invalid string')
const unit = Duration[matches[1]]
if (!unit) throw Error('Invalid unit')
return unit.call(Duration, +matches[2])
},
toString(self) {
return match(self, {
MilliSeconds: duration => `Duration.MilliSeconds(${duration})`,
Seconds: duration => `Duration.Seconds(${duration})`,
Minutes: duration => `Duration.Minutes(${duration})`,
Hours: duration => `Duration.Hours(${duration})`,
Days: duration => `Duration.Days(${duration})`,
Months: duration => `Duration.Months(${duration})`,
})
},
})
export type NaturalDifference = {}

@@ -33,0 +59,0 @@ export const NaturalDifference = Enum({

Sorry, the diff of this file is not supported yet

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