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

dtss

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dtss - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

dist/dtss.js

118

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var LEVEL;
(function (LEVEL) {
LEVEL[LEVEL["ms"] = 0] = "ms";
LEVEL[LEVEL["s"] = 1] = "s";
LEVEL[LEVEL["m"] = 2] = "m";
LEVEL[LEVEL["h"] = 3] = "h";
LEVEL[LEVEL["d"] = 4] = "d";
LEVEL[LEVEL["M"] = 5] = "M";
LEVEL[LEVEL["y"] = 6] = "y";
})(LEVEL = exports.LEVEL || (exports.LEVEL = {}));
// tslint:disable-next-line:class-name
class dtss {
constructor(level) {
this.level = LEVEL.ms;
if (level) {
this.setLevel(level);
}
}
setLevel(level) {
this.level = level;
return this;
}
getLevel() {
return this.level;
}
ms(time) {
return time === 0 ? 0 : this.cal(time, LEVEL.ms);
}
s(time) {
return time === 0 ? 0 : this.cal(time, LEVEL.s);
}
m(time) {
return time === 0 ? 0 : this.cal(time, LEVEL.m);
}
h(time) {
return time === 0 ? 0 : this.cal(time, LEVEL.h);
}
d(time) {
return time === 0 ? 0 : this.cal(time, LEVEL.d);
}
M(time) {
return time === 0 ? 0 : this.cal(time, LEVEL.M);
}
y(time) {
return time === 0 ? 0 : this.cal(time, LEVEL.y);
}
cal(time, level) {
if (level === this.level) {
return time;
}
if (level < this.level) {
return NaN;
}
switch (level) {
case LEVEL.y:
time *= 12;
case LEVEL.M:
if (LEVEL.M === this.level) {
break;
}
time *= 30;
if (level === LEVEL.y) {
time /= 360;
time *= 365;
}
case LEVEL.d:
if (LEVEL.d === this.level) {
break;
}
time *= 24;
case LEVEL.h:
if (LEVEL.h === this.level) {
break;
}
time *= 60;
case LEVEL.m:
if (LEVEL.m === this.level) {
break;
}
time *= 60;
case LEVEL.s:
if (LEVEL.s === this.level) {
break;
}
time *= 1000;
case LEVEL.ms:
time *= 1;
break;
}
return time;
}
}
dtss.LEVEL = LEVEL;
exports.dtss = dtss;
exports.ms = (time) => {
return new dtss().ms(time);
};
exports.s = (time) => {
return new dtss().s(time);
};
exports.m = (time) => {
return new dtss().m(time);
};
exports.h = (time) => {
return new dtss().h(time);
};
exports.d = (time) => {
return new dtss().d(time);
};
exports.M = (time) => {
return new dtss().M(time);
};
exports.y = (time) => {
return new dtss().y(time);
};
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./dtss"), exports);
tslib_1.__exportStar(require("./static"), exports);

@@ -1,122 +0,2 @@

export enum LEVEL {
ms, s, m, h, d, M, y
}
// tslint:disable-next-line:class-name
export class dtss {
public static LEVEL = LEVEL;
private level = LEVEL.ms;
constructor(level?: LEVEL) {
if (level) {
this.setLevel(level);
}
}
public setLevel(level: LEVEL) {
this.level = level;
return this;
}
public getLevel() {
return this.level;
}
public ms(time: number) {
return time === 0 ? 0 : this.cal(time, LEVEL.ms);
}
public s(time: number) {
return time === 0 ? 0 : this.cal(time, LEVEL.s);
}
public m(time: number) {
return time === 0 ? 0 : this.cal(time, LEVEL.m);
}
public h(time: number) {
return time === 0 ? 0 : this.cal(time, LEVEL.h);
}
public d(time: number) {
return time === 0 ? 0 : this.cal(time, LEVEL.d);
}
public M(time: number) {
return time === 0 ? 0 : this.cal(time, LEVEL.M);
}
public y(time: number) {
return time === 0 ? 0 : this.cal(time, LEVEL.y);
}
private cal(time: number, level: LEVEL) {
if (level === this.level) {
return time;
}
if (level < this.level) {
return NaN;
}
switch (level) {
case LEVEL.y:
time *= 12;
case LEVEL.M:
if (LEVEL.M === this.level) {
break;
}
time *= 30;
if (level === LEVEL.y) {
time /= 360;
time *= 365;
}
case LEVEL.d:
if (LEVEL.d === this.level) {
break;
}
time *= 24;
case LEVEL.h:
if (LEVEL.h === this.level) {
break;
}
time *= 60;
case LEVEL.m:
if (LEVEL.m === this.level) {
break;
}
time *= 60;
case LEVEL.s:
if (LEVEL.s === this.level) {
break;
}
time *= 1000;
case LEVEL.ms:
time *= 1;
break;
}
return time;
}
}
export const ms = (time: number) => {
return new dtss().ms(time);
};
export const s = (time: number) => {
return new dtss().s(time);
};
export const m = (time: number) => {
return new dtss().m(time);
};
export const h = (time: number) => {
return new dtss().h(time);
};
export const d = (time: number) => {
return new dtss().d(time);
};
export const M = (time: number) => {
return new dtss().M(time);
};
export const y = (time: number) => {
return new dtss().y(time);
};
export * from "./dtss";
export * from "./static";
{
"name": "dtss",
"version": "1.0.1",
"version": "1.1.0",
"description": "Set the delay time quickly.",

@@ -12,3 +12,3 @@ "main": "dist/index.js",

"pretest": "npm run clean && npm run tsc -- -P tsconfig.test.json",
"test": "ava dist/test",
"test": "ava dist/test/**/*.spec.*",
"lint": "npm run lint:typescript && npm run lint:javascript",

@@ -15,0 +15,0 @@ "lint:typescript": "tslint lib/**/*.ts test/**/*.ts",

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