fix(core): update and change scope

This commit is contained in:
Philipp Kunz 2018-06-10 14:00:18 +02:00
parent 69fee8f8a2
commit 874349ba32
21 changed files with 493 additions and 648 deletions

View File

@ -3,32 +3,39 @@ image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- trigger
- pages
- metadata
# ====================
# security stage
# ====================
mirror:
stage: security
script:
- npmci git mirror
tags:
- docker
- notpriv
snyk:
stage: security
script:
- npmci command yarn global add snyk
- npmci command yarn install --ignore-scripts
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
@ -38,6 +45,7 @@ testLEGACY:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
@ -49,6 +57,7 @@ testLTS:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test
@ -59,34 +68,60 @@ testSTABLE:
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci npm prepare
- npmci node install stable
- npmci npm publish
only:
- tags
tags:
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags:
- docker
- priv
trigger:
stage: trigger
stage: metadata
script:
- npmci trigger
only:
- tags
tags:
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
stage: metadata
script:
- npmci command yarn global add npmpage
- npmci command npm install -g npmpage
- npmci command npmpage
tags:
- docker
- notpriv
only:
- tags
artifacts:

5
dist/index.d.ts vendored
View File

@ -1,5 +0,0 @@
export * from './smarttime.classes.hrtmeasurement';
export * from './smarttime.classes.timer';
export * from './smarttime.classes.timestamp';
export * from './smarttime.units';
export { moment } from './smarttime.plugins';

12
dist/index.js vendored
View File

@ -1,12 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./smarttime.classes.hrtmeasurement"));
__export(require("./smarttime.classes.timer"));
__export(require("./smarttime.classes.timestamp"));
__export(require("./smarttime.units"));
var smarttime_plugins_1 = require("./smarttime.plugins");
exports.moment = smarttime_plugins_1.moment;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLHdEQUFtRDtBQUNuRCwrQ0FBMEM7QUFDMUMsbURBQThDO0FBQzlDLHVDQUFrQztBQUVsQyx5REFBNkM7QUFBcEMscUNBQUEsTUFBTSxDQUFBIn0=

View File

@ -1,22 +0,0 @@
/**
* easy high resolution time measurement
*/
export declare class HrtMeasurement {
nanoSeconds: number;
milliSeconds: number;
private _hrTimeStart;
private _hrTimeStopDiff;
private _started;
/**
* start the measurement
*/
start(): void;
/**
* stop the measurement
*/
stop(): this;
/**
* reset the measurement
*/
reset(): void;
}

View File

@ -1,47 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const process = require("process");
/**
* easy high resolution time measurement
*/
class HrtMeasurement {
constructor() {
this.nanoSeconds = null;
this.milliSeconds = null;
this._hrTimeStart = null;
this._hrTimeStopDiff = null;
this._started = false;
}
/**
* start the measurement
*/
start() {
this._started = true;
this._hrTimeStart = process.hrtime();
}
/**
* stop the measurement
*/
stop() {
if (this._started === false) {
console.log("Hasn't started yet");
return;
}
this._hrTimeStopDiff = process.hrtime(this._hrTimeStart);
this.nanoSeconds = this._hrTimeStopDiff[0] * 1e9 + this._hrTimeStopDiff[1];
this.milliSeconds = this.nanoSeconds / 1000000;
return this;
}
/**
* reset the measurement
*/
reset() {
this.nanoSeconds = null;
this.milliSeconds = null;
this._hrTimeStart = null;
this._hrTimeStopDiff = null;
this._started = false;
}
}
exports.HrtMeasurement = HrtMeasurement;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLmNsYXNzZXMuaHJ0bWVhc3VyZW1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHRpbWUuY2xhc3Nlcy5ocnRtZWFzdXJlbWVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLG1DQUFtQztBQUVuQzs7R0FFRztBQUNIO0lBQUE7UUFDRSxnQkFBVyxHQUFXLElBQUksQ0FBQztRQUMzQixpQkFBWSxHQUFXLElBQUksQ0FBQztRQUNwQixpQkFBWSxHQUFHLElBQUksQ0FBQztRQUNwQixvQkFBZSxHQUFHLElBQUksQ0FBQztRQUN2QixhQUFRLEdBQVksS0FBSyxDQUFDO0lBa0NwQyxDQUFDO0lBaENDOztPQUVHO0lBQ0gsS0FBSztRQUNILElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDO1FBQ3JCLElBQUksQ0FBQyxZQUFZLEdBQUcsT0FBTyxDQUFDLE1BQU0sRUFBRSxDQUFDO0lBQ3ZDLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUk7UUFDRixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsUUFBUSxLQUFLLEtBQUssQ0FBQyxDQUFDLENBQUM7WUFDNUIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFDO1lBQ2xDLE1BQU0sQ0FBQztRQUNULENBQUM7UUFDRCxJQUFJLENBQUMsZUFBZSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxDQUFDO1FBQ3pELElBQUksQ0FBQyxXQUFXLEdBQUcsSUFBSSxDQUFDLGVBQWUsQ0FBQyxDQUFDLENBQUMsR0FBRyxHQUFHLEdBQUcsSUFBSSxDQUFDLGVBQWUsQ0FBQyxDQUFDLENBQUMsQ0FBQztRQUMzRSxJQUFJLENBQUMsWUFBWSxHQUFHLElBQUksQ0FBQyxXQUFXLEdBQUcsT0FBTyxDQUFDO1FBQy9DLE1BQU0sQ0FBQyxJQUFJLENBQUM7SUFDZCxDQUFDO0lBRUQ7O09BRUc7SUFDSCxLQUFLO1FBQ0gsSUFBSSxDQUFDLFdBQVcsR0FBRyxJQUFJLENBQUM7UUFDeEIsSUFBSSxDQUFDLFlBQVksR0FBRyxJQUFJLENBQUM7UUFDekIsSUFBSSxDQUFDLFlBQVksR0FBRyxJQUFJLENBQUM7UUFDekIsSUFBSSxDQUFDLGVBQWUsR0FBRyxJQUFJLENBQUM7UUFDNUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxLQUFLLENBQUM7SUFDeEIsQ0FBQztDQUNGO0FBdkNELHdDQXVDQyJ9

View File

@ -1,37 +0,0 @@
import { TimeStamp } from './smarttime.classes.timestamp';
export declare type TimerState = 'initiated' | 'started' | 'paused' | 'completed';
export declare class Timer {
/**
* the original amount of milliseconds for this Timer
*/
timeInMilliseconds: number;
/**
* the state of the timer
*/
state: TimerState;
/**
* completed Promise
*/
completed: Promise<void>;
/**
* a reference to when the Timeout started
*/
startedAt: TimeStamp;
/**
* a reference to when a Timer has been potentially paused
*/
pausedAt: TimeStamp;
readonly timeLeft: number;
/**
* the current timeout the needs to be canceled when this Timer is stopped
*/
private currentTimeout;
private completedDeferred;
constructor(timeInMillisecondsArg: number);
/**
* starts the timer
*/
start(): void;
pause(): void;
resume(): void;
}

View File

@ -1,46 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smarttime.plugins");
const smarttime_classes_timestamp_1 = require("./smarttime.classes.timestamp");
class Timer {
constructor(timeInMillisecondsArg) {
/**
* the state of the timer
*/
this.state = 'initiated';
// a deferred triggeted when Timer has completed
this.completedDeferred = plugins.smartq.defer();
this.timeInMilliseconds = timeInMillisecondsArg;
this.completed = this.completedDeferred.promise;
}
get timeLeft() {
return this.timeInMilliseconds - this.pausedAt.change;
}
/**
* starts the timer
*/
start() {
if (!this.startedAt) {
this.currentTimeout = setTimeout(() => {
this.completedDeferred.resolve();
}, this.timeInMilliseconds);
this.startedAt = new smarttime_classes_timestamp_1.TimeStamp();
}
else {
throw new Error('timer has been started before. Please use resume instead');
}
}
pause() {
clearTimeout(this.currentTimeout);
this.pausedAt = smarttime_classes_timestamp_1.TimeStamp.fromTimeStamp(this.startedAt);
}
resume() {
if (this.startedAt) {
this.currentTimeout = setTimeout(() => {
this.completedDeferred.resolve();
}, this.timeLeft);
}
}
}
exports.Timer = Timer;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLmNsYXNzZXMudGltZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHRpbWUuY2xhc3Nlcy50aW1lci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLCtDQUErQztBQUUvQywrRUFBMEQ7QUFJMUQ7SUFxQ0UsWUFBWSxxQkFBNkI7UUEvQnpDOztXQUVHO1FBQ0ksVUFBSyxHQUFlLFdBQVcsQ0FBQztRQXlCdkMsZ0RBQWdEO1FBQ3hDLHNCQUFpQixHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxFQUFRLENBQUM7UUFHdkQsSUFBSSxDQUFDLGtCQUFrQixHQUFHLHFCQUFxQixDQUFDO1FBQ2hELElBQUksQ0FBQyxTQUFT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BQUMsRUFBRSxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUM7UUFDcEIsQ0FBQztJQUNILENBQUM7Q0FDRjtBQXBFRCxzQkFvRUMifQ==

View File

@ -1,40 +0,0 @@
/**
* TimeStamp
* smart timestamp
*/
export declare class TimeStamp {
/**
* returns new TimeStamp from milliseconds
*/
static fromMilliSeconds(milliSecondsArg: any): TimeStamp;
/**
* returns new TimeStamp for now with change set
* @param timeStampArg
*/
static fromTimeStamp(timeStampArg: TimeStamp): TimeStamp;
/**
* The standard JavaScript Date
*/
date: Date;
/**
* The time as linux time (milliseconds, not seconds though)
* good for comparison
*/
milliSeconds: number;
/**
* The standard epoch time in seconds
*/
epochtime: number;
/**
* if derived from another TimeStamp points out the change in milliseconds
*/
change: number;
constructor(creatorArg?: number);
/**
* Is the current instance older than the argument
* @param TimeStampArg
*/
isOlderThan(TimeStampArg: TimeStamp, tresholdTimeArg?: number): boolean;
isYoungerThanOtherTimeStamp(TimeStampArg: TimeStamp, tresholdTimeArg?: number): boolean;
isYoungerThanMilliSeconds(millisecondArg: number): boolean;
}

View File

@ -1,65 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* TimeStamp
* smart timestamp
*/
class TimeStamp {
constructor(creatorArg) {
/**
* if derived from another TimeStamp points out the change in milliseconds
*/
this.change = null;
if (!creatorArg) {
this.date = new Date();
}
else if (typeof creatorArg === 'number') {
this.date = new Date(creatorArg);
}
this.milliSeconds = this.date.getTime();
this.epochtime = Math.floor(this.milliSeconds / 1000);
}
/**
* returns new TimeStamp from milliseconds
*/
static fromMilliSeconds(milliSecondsArg) {
return new TimeStamp(milliSecondsArg);
}
/**
* returns new TimeStamp for now with change set
* @param timeStampArg
*/
static fromTimeStamp(timeStampArg) {
const localTimeStamp = new TimeStamp();
localTimeStamp.change = localTimeStamp.milliSeconds - timeStampArg.milliSeconds;
return localTimeStamp;
}
/**
* Is the current instance older than the argument
* @param TimeStampArg
*/
isOlderThan(TimeStampArg, tresholdTimeArg = 0) {
if (this.milliSeconds + tresholdTimeArg < TimeStampArg.milliSeconds) {
return true;
}
else {
return false;
}
}
isYoungerThanOtherTimeStamp(TimeStampArg, tresholdTimeArg = 0) {
if (this.milliSeconds > TimeStampArg.milliSeconds + tresholdTimeArg) {
return true;
}
else {
return false;
}
}
isYoungerThanMilliSeconds(millisecondArg) {
const nowTimeStamp = new TimeStamp();
const compareEpochTime = nowTimeStamp.epochtime - millisecondArg;
const compareTimeStamp = new TimeStamp(compareEpochTime);
return this.isYoungerThanOtherTimeStamp(compareTimeStamp);
}
}
exports.TimeStamp = TimeStamp;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLmNsYXNzZXMudGltZXN0YW1wLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnR0aW1lLmNsYXNzZXMudGltZXN0YW1wLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBRUE7OztHQUdHO0FBQ0g7SUF1Q0UsWUFBWSxVQUFtQjtRQUwvQjs7V0FFRztRQUNJLFdBQU0sR0FBVyxJQUFJLENBQUM7UUFHM0IsRUFBRSxDQUFDLENBQUMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDO1lBQ2hCLElBQUksQ0FBQyxJQUFJLEdBQUcsSUFBSSxJQUFJLEVBQUUsQ0FBQztRQUN6QixDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLE9BQU8sVUFBVSxLQUFLLFFBQVEsQ0FBQyxDQUFDLENBQUM7WUFDMUMsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FBQztRQUNuQyxDQUFDO1FBQ0QsSUFBSSxDQUFDLFlBQVksR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sRUFBRSxDQUFDO1FBQ3hDLElBQUksQ0FBQyx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xLQUFLLENBQUM7UUFDZixDQUFDO0lBQ0gsQ0FBQztJQUVNLHlCQUF5QixDQUFDLGNBQXNCO1FBQ3JELE1BQU0sWUFBWSxHQUFHLElBQUksU0FBUyxFQUFFLENBQUE7UUFDcEMsTUFBTSxnQkFBZ0IsR0FBRyxZQUFZLENBQUMsU0FBUyxHQUFHLGNBQWMsQ0FBQztRQUNqRSxNQUFNLGdCQUFnQixHQUFHLElBQUksU0FBUyxDQUFDLGdCQUFnQixDQUFDLENBQUM7UUFDekQsTUFBTSxDQUFDLElBQUksQ0FBQywyQkFBMkIsQ0FBQyxnQkFBZ0IsQ0FBQyxDQUFDO0lBQzVELENBQUM7Q0FDRjtBQTNFRCw4QkEyRUMifQ==

View File

@ -1,3 +0,0 @@
import * as moment from 'moment';
import * as smartq from 'smartq';
export { moment, smartq };

View File

@ -1,7 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const moment = require("moment");
exports.moment = moment;
const smartq = require("smartq");
exports.smartq = smartq;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHRpbWUucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGlDQUFpQztBQUd4Qix3QkFBTTtBQUZmLGlDQUFpQztBQUVoQix3QkFBTSJ9

View File

@ -1,17 +0,0 @@
export declare let units: {
years: (timesArg?: number) => number;
months: (timesArg?: number) => number;
weeks: (timesArg?: number) => number;
days: (timesArg?: number) => number;
hours: (timesArg?: number) => number;
minutes: (timesArg?: number) => number;
};
export interface IUnitCombinationArg {
years?: number;
months?: number;
weeks?: number;
days?: number;
hours?: number;
minutes?: number;
}
export declare let getMilliSecondsFromUnits: (combinationArg: IUnitCombinationArg) => number;

View File

@ -1,48 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.units = {
years: (timesArg = 1) => {
return timesArg * 3.154e10;
},
months: (timesArg = 1) => {
return timesArg * 2.628e9;
},
weeks: (timesArg = 1) => {
return timesArg * 6.048e8;
},
days: (timesArg = 1) => {
return timesArg * 8.64e7;
},
hours: (timesArg = 1) => {
return timesArg * 3.6e6;
},
minutes: (timesArg = 1) => {
return timesArg * 60000;
}
};
exports.getMilliSecondsFromUnits = (combinationArg) => {
let timeInMilliseconds = 0;
let addMilliSeconds = milliSecondsArg => {
timeInMilliseconds = timeInMilliseconds + milliSecondsArg;
};
if (combinationArg.years) {
addMilliSeconds(exports.units.years(combinationArg.years));
}
if (combinationArg.months) {
addMilliSeconds(exports.units.months(combinationArg.months));
}
if (combinationArg.weeks) {
addMilliSeconds(exports.units.weeks(combinationArg.weeks));
}
if (combinationArg.days) {
addMilliSeconds(exports.units.days(combinationArg.days));
}
if (combinationArg.hours) {
addMilliSeconds(exports.units.hours(combinationArg.hours));
}
if (combinationArg.minutes) {
addMilliSeconds(exports.units.minutes(combinationArg.minutes));
}
return timeInMilliseconds;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnR0aW1lLnVuaXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnR0aW1lLnVuaXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQVcsUUFBQSxLQUFLLEdBQUc7SUFDakIsS0FBSyxFQUFFLENBQUMsUUFBUSxHQUFHLENBQUMsRUFBVSxFQUFFO1FBQzlCLE1BQU0sQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDO0lBQzdCLENBQUM7SUFDRCxNQUFNLEVBQUUsQ0FBQyxRQUFRLEdBQUcsQ0FBQyxFQUFVLEVBQUU7UUFDL0IsTUFBTSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUM7SUFDNUIsQ0FBQztJQUNELEtBQUssRUFBRSxDQUFDLF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QUFDO0lBQ0QsRUFBRSxDQUFDLENBQUMsY0FBYyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUM7UUFDekIsZUFBZSxDQUFDLGFBQUssQ0FBQyxLQUFLLENBQUMsY0FBYyxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUM7SUFDckQsQ0FBQztJQUNELEVBQUUsQ0FBQyxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO1FBQ3hCLGVBQWUsQ0FBQyxhQUFLLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDO0lBQ25ELENBQUM7SUFDRCxFQUFFLENBQUMsQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztRQUN6QixlQUFlLENBQUMsYUFBSyxDQUFDLEtBQUssQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUMsQ0FBQztJQUNyRCxDQUFDO0lBQ0QsRUFBRSxDQUFDLENBQUMsY0FBYyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7UUFDM0IsZUFBZSxDQUFDLGFBQUssQ0FBQyxPQUFPLENBQUMsY0FBYyxDQUFDLE9BQU8sQ0FBQyxDQUFDLENBQUM7SUFDekQsQ0FBQztJQUVELE1BQU0sQ0FBQyxrQkFBa0IsQ0FBQztBQUM1QixDQUFDLENBQUMifQ==

View File

@ -1,33 +0,0 @@
# smarttime
handle timeformats in smart ways
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smarttime)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smarttime)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smarttime)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smarttime/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smarttime/badges/master/build.svg)](https://GitLab.com/pushrocks/smarttime/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smarttime/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smarttime/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smarttime.svg)](https://www.npmjs.com/package/smarttime)
[![Dependency Status](https://david-dm.org/pushrocks/smarttime.svg)](https://david-dm.org/pushrocks/smarttime)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smarttime/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smarttime/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smarttime/badges/code.svg)](https://www.bithound.io/github/pushrocks/smarttime)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

View File

@ -2,6 +2,7 @@
"npmci": {
"npmGlobalTools": [
"npmts"
]
],
"npmAccessLevel": "public"
}
}

435
package-lock.json generated Normal file
View File

@ -0,0 +1,435 @@
{
"name": "smarttime",
"version": "2.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@gitzone/tsrun": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.0.5.tgz",
"integrity": "sha512-zSiRnlvNAlBmrqknwH9B0gIRx7IEegPzmN+DZ4yN3f+L62WlVbKyPLeeV09SKE8BFiGo+0VIGiQW3EV/9mXMfw==",
"dev": true,
"requires": {
"ts-node": "^6.1.0",
"typescript": "^2.9.1"
}
},
"@types/chai": {
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.3.tgz",
"integrity": "sha512-f5dXGzOJycyzSMdaXVhiBhauL4dYydXwVpavfQ1mVCaGjR56a9QfklXObUxlIY9bGTmCPHEEZ04I16BZ/8w5ww==",
"dev": true
},
"@types/chai-as-promised": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-7.1.0.tgz",
"integrity": "sha512-MFiW54UOSt+f2bRw8J7LgQeIvE/9b4oGvwU7XW30S9QGAiHGnU/fmiOprsyMkdmH2rl8xSPc0/yrQw8juXU6bQ==",
"dev": true,
"requires": {
"@types/chai": "*"
}
},
"@types/chai-string": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/@types/chai-string/-/chai-string-1.4.1.tgz",
"integrity": "sha512-aRNMs6TKgjgPlCHwDfq/YNy5VtRR2hJ4AUWByddrT0TRVVD8eX4MiHW6/iHvmQHRlVuuPZcwnTUE7b4yFt7bEA==",
"dev": true,
"requires": {
"@types/chai": "*"
}
},
"@types/node": {
"version": "9.6.21",
"resolved": "https://registry.npmjs.org/@types/node/-/node-9.6.21.tgz",
"integrity": "sha512-zQS6mHzxEstR8Vvnpc3JDUCDGWnHFzMTcBu9UCZoVLuj1Uvkkk0qFKJQEhlvbsX34m3xt12ejV09eO/ljZcn7A==",
"dev": true
},
"ansi-256-colors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz",
"integrity": "sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo=",
"dev": true
},
"arrify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
"dev": true
},
"assertion-error": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
"dev": true
},
"beautycolor": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/beautycolor/-/beautycolor-1.0.11.tgz",
"integrity": "sha512-Uxl/39+2uqixPzsrV+0NOHf0sJlWmsKnRTV0oz8+bfwnHPA/E+SZuh3Upn3OXobv0W7LZg5BVoLj1nkMj7m5jA==",
"dev": true,
"requires": {
"ansi-256-colors": "^1.1.0",
"typings-global": "^1.0.14"
}
},
"bindings": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
"integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==",
"dev": true
},
"buffer-from": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz",
"integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==",
"dev": true
},
"chai": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz",
"integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=",
"dev": true,
"requires": {
"assertion-error": "^1.0.1",
"check-error": "^1.0.1",
"deep-eql": "^3.0.0",
"get-func-name": "^2.0.0",
"pathval": "^1.0.0",
"type-detect": "^4.0.0"
}
},
"chai-as-promised": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz",
"integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==",
"dev": true,
"requires": {
"check-error": "^1.0.2"
}
},
"chai-string": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/chai-string/-/chai-string-1.4.0.tgz",
"integrity": "sha1-NZFAwFHTak5LGl/GuRAVL0OKjUk=",
"dev": true
},
"check-error": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=",
"dev": true
},
"deep-eql": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
"dev": true,
"requires": {
"type-detect": "^4.0.0"
}
},
"define-properties": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz",
"integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=",
"requires": {
"foreach": "^2.0.5",
"object-keys": "^1.0.8"
}
},
"diff": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true
},
"early": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/early/-/early-2.1.1.tgz",
"integrity": "sha1-hB4jJU6l3FTYr67ugvWrZcAO4jw=",
"dev": true,
"requires": {
"beautycolor": "^1.0.7",
"smartq": "^1.1.1",
"typings-global": "^1.0.16"
}
},
"es-abstract": {
"version": "1.12.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
"integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
"requires": {
"es-to-primitive": "^1.1.1",
"function-bind": "^1.1.1",
"has": "^1.0.1",
"is-callable": "^1.1.3",
"is-regex": "^1.0.4"
}
},
"es-to-primitive": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz",
"integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=",
"requires": {
"is-callable": "^1.1.1",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.1"
}
},
"es6-error": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz",
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
"dev": true
},
"foreach": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k="
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"get-func-name": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
"dev": true
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"requires": {
"function-bind": "^1.1.1"
}
},
"is-callable": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz",
"integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI="
},
"is-date-object": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY="
},
"is-regex": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
"requires": {
"has": "^1.0.1"
}
},
"is-symbol": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI="
},
"leakage": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/leakage/-/leakage-0.3.0.tgz",
"integrity": "sha1-FdaYq9x2u8ZDlgH08wIOd+LVDDk=",
"dev": true,
"requires": {
"es6-error": "^4.0.2",
"left-pad": "^1.1.3",
"memwatch-next": "^0.3.0",
"minimist": "^1.2.0",
"pretty-bytes": "^4.0.2"
}
},
"left-pad": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz",
"integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==",
"dev": true
},
"make-error": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",
"integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==",
"dev": true
},
"memwatch-next": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/memwatch-next/-/memwatch-next-0.3.0.tgz",
"integrity": "sha1-IREFD5qQbgqi1ypOwPAInHhyb48=",
"dev": true,
"requires": {
"bindings": "^1.2.1",
"nan": "^2.3.2"
}
},
"minimist": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
"dev": true
},
"mkdirp": {
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"dev": true,
"requires": {
"minimist": "0.0.8"
},
"dependencies": {
"minimist": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
"dev": true
}
}
},
"moment": {
"version": "2.22.2",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
"integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y="
},
"nan": {
"version": "2.10.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==",
"dev": true
},
"object-keys": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz",
"integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0="
},
"object.getownpropertydescriptors": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz",
"integrity": "sha1-h1jIRvW0B62rDyNuCYbxSwUcqhY=",
"requires": {
"define-properties": "^1.1.2",
"es-abstract": "^1.5.1"
}
},
"pathval": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz",
"integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=",
"dev": true
},
"pretty-bytes": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz",
"integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=",
"dev": true
},
"smartchai": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/smartchai/-/smartchai-2.0.1.tgz",
"integrity": "sha512-9M+R56OhAHXScxgr2vzQqxGx0XMS0QXriNZuP7hjlbVbo2FUT+l60iEzbwPt9Ga+5u2cEEjSSoZEQVqlROaddA==",
"dev": true,
"requires": {
"@types/chai": "^4.1.2",
"@types/chai-as-promised": "^7.1.0",
"@types/chai-string": "^1.4.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-string": "^1.4.0"
}
},
"smartdelay": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/smartdelay/-/smartdelay-1.0.4.tgz",
"integrity": "sha512-ab+d8ADiMMPKwrQNhoJYjmOR20VIIIxjknoEF9/PfMryic7tmvTmFrDMdcnMRohGNw/pN+4/I5dSUBdsDya7uw==",
"requires": {
"smartq": "^1.1.1",
"typings-global": "^1.0.16"
}
},
"smartq": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/smartq/-/smartq-1.1.8.tgz",
"integrity": "sha512-FURlYW/C3bLeZjJcBVyw7bxCyQoCXiXbLCZcDUKznhXHaLu35c8m33/a2H8CA0rtb82lvzN8dRLnBZAcNMzNHQ==",
"requires": {
"util.promisify": "^1.0.0"
}
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"source-map-support": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.6.tgz",
"integrity": "sha512-N4KXEz7jcKqPf2b2vZF11lQIz9W5ZMuUcIOGj243lduidkf2fjkVKJS9vNxVWn3u/uxX38AcE8U9nnH9FPcq+g==",
"dev": true,
"requires": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"tapbundle": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/tapbundle/-/tapbundle-2.0.0.tgz",
"integrity": "sha512-NU4OG3pcPOgJAtACIPNRb68jJg5eSumRRhH9RyOuYBRU8fnhqIGNnv8YZngAIxpdUUunKKz6ABJCVhL0Z2ONHA==",
"dev": true,
"requires": {
"early": "^2.1.1",
"leakage": "^0.3.0",
"smartchai": "^2.0.0",
"smartdelay": "^1.0.3",
"smartq": "^1.1.1"
}
},
"ts-node": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-6.1.0.tgz",
"integrity": "sha512-mw11Bq08RZgrU/bzcVw/Ti9wNyefpOanXgWsHg008wyVHjvFhWxNatVVrciOAu8BcWSECoNOSunRzUokKH8Mmw==",
"dev": true,
"requires": {
"arrify": "^1.0.0",
"diff": "^3.1.0",
"make-error": "^1.1.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"source-map-support": "^0.5.6",
"yn": "^2.0.0"
}
},
"type-detect": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
"dev": true
},
"typescript": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.1.tgz",
"integrity": "sha512-h6pM2f/GDchCFlldnriOhs1QHuwbnmj6/v7499eMHqPeW4V2G0elua2eIc2nu8v2NdHV0Gm+tzX83Hr6nUFjQA==",
"dev": true
},
"typings-global": {
"version": "1.0.28",
"resolved": "https://registry.npmjs.org/typings-global/-/typings-global-1.0.28.tgz",
"integrity": "sha512-6VOwJWEY2971HOMHu/7sURzUXiD4/LiMJPsMAOqkHHAtS3MVpLFE5gzTiHilsH9KY5VE1mBQirWIgWFsDuo90A=="
},
"util.promisify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/util.promisify/-/util.promisify-1.0.0.tgz",
"integrity": "sha512-i+6qA2MPhvoKLuxnJNpXAGhg7HphQOSUq2LKMZD0m15EiskXUkMvKdF4Uui0WYeCUGea+o2cw/ZuwehtfsrNkA==",
"requires": {
"define-properties": "^1.1.2",
"object.getownpropertydescriptors": "^2.0.3"
}
},
"yn": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz",
"integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=",
"dev": true
}
}
}

View File

@ -1,5 +1,6 @@
{
"name": "smarttime",
"name": "@pushrocks/smarttime",
"private": false,
"version": "2.0.0",
"description": "handle timeformats in smart ways",
"main": "dist/index.js",
@ -7,9 +8,11 @@
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(npmts)"
"test": "(tsrun ./test/test.ts)",
"build": "(npmts)"
},
"devDependencies": {
"@gitzone/tsrun": "^1.0.5",
"@types/node": "^9.4.7",
"tapbundle": "^2.0.0"
},

View File

@ -7,12 +7,12 @@ let testTimer: Timer;
tap.test('should create a valid timer', async () => {
testTimer = new Timer(1000);
expect(testTimer).to.be.instanceof(Timer)
})
expect(testTimer).to.be.instanceof(Timer);
});
tap.test('should start timer', async () => {
testTimer.start()
testTimer.start();
await testTimer.completed;
})
});
tap.start()
tap.start();

View File

@ -0,0 +1 @@
import * as plugins from './smarttime.plugins';

View File

@ -74,7 +74,7 @@ export class TimeStamp {
}
public isYoungerThanMilliSeconds(millisecondArg: number) {
const nowTimeStamp = new TimeStamp()
const nowTimeStamp = new TimeStamp();
const compareEpochTime = nowTimeStamp.epochtime - millisecondArg;
const compareTimeStamp = new TimeStamp(compareEpochTime);
return this.isYoungerThanOtherTimeStamp(compareTimeStamp);

248
yarn.lock
View File

@ -1,248 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@types/chai-as-promised@^7.1.0":
version "7.1.0"
resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-7.1.0.tgz#010b04cde78eacfb6e72bfddb3e58fe23c2e78b9"
dependencies:
"@types/chai" "*"
"@types/chai-string@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@types/chai-string/-/chai-string-1.4.0.tgz#c8b78deb9ae53e86c05a446c256138faeaff53c1"
dependencies:
"@types/chai" "*"
"@types/chai@*", "@types/chai@^4.1.2":
version "4.1.2"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.2.tgz#f1af664769cfb50af805431c407425ed619daa21"
"@types/node@^9.4.7":
version "9.4.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.7.tgz#57d81cd98719df2c9de118f2d5f3b1120dcd7275"
ansi-256-colors@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz#910de50efcc7c09e3d82f2f87abd6b700c18818a"
assertion-error@^1.0.1:
version "1.1.0"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
beautycolor@^1.0.7:
version "1.0.11"
resolved "https://registry.yarnpkg.com/beautycolor/-/beautycolor-1.0.11.tgz#71c5568d5a7ed5c144d3a54f753ad1b08862aea5"
dependencies:
ansi-256-colors "^1.1.0"
typings-global "^1.0.14"
bindings@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
chai-as-promised@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-7.1.1.tgz#08645d825deb8696ee61725dbf590c012eb00ca0"
dependencies:
check-error "^1.0.2"
chai-string@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/chai-string/-/chai-string-1.4.0.tgz#359140c051d36a4e4b1a5fc6b910152f438a8d49"
chai@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c"
dependencies:
assertion-error "^1.0.1"
check-error "^1.0.1"
deep-eql "^3.0.0"
get-func-name "^2.0.0"
pathval "^1.0.0"
type-detect "^4.0.0"
check-error@^1.0.1, check-error@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
deep-eql@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
dependencies:
type-detect "^4.0.0"
define-properties@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.2.tgz#83a73f2fea569898fb737193c8f873caf6d45c94"
dependencies:
foreach "^2.0.5"
object-keys "^1.0.8"
early@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/early/-/early-2.1.1.tgz#841e23254ea5dc54d8afaeee82f5ab65c00ee23c"
dependencies:
beautycolor "^1.0.7"
smartq "^1.1.1"
typings-global "^1.0.16"
es-abstract@^1.5.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.10.0.tgz#1ecb36c197842a00d8ee4c2dfd8646bb97d60864"
dependencies:
es-to-primitive "^1.1.1"
function-bind "^1.1.1"
has "^1.0.1"
is-callable "^1.1.3"
is-regex "^1.0.4"
es-to-primitive@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d"
dependencies:
is-callable "^1.1.1"
is-date-object "^1.0.1"
is-symbol "^1.0.1"
es6-error@^4.0.2:
version "4.1.1"
resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"
foreach@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99"
function-bind@^1.0.2, function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"
get-func-name@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
has@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28"
dependencies:
function-bind "^1.0.2"
is-callable@^1.1.1, is-callable@^1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"
is-date-object@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16"
is-regex@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"
dependencies:
has "^1.0.1"
is-symbol@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.1.tgz#3cc59f00025194b6ab2e38dbae6689256b660572"
leakage@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/leakage/-/leakage-0.3.0.tgz#15d698abdc76bbc6439601f4f3020e77e2d50c39"
dependencies:
es6-error "^4.0.2"
left-pad "^1.1.3"
memwatch-next "^0.3.0"
minimist "^1.2.0"
pretty-bytes "^4.0.2"
left-pad@^1.1.3:
version "1.2.0"
resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.2.0.tgz#d30a73c6b8201d8f7d8e7956ba9616087a68e0ee"
memwatch-next@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/memwatch-next/-/memwatch-next-0.3.0.tgz#2111050f9a906e0aa2d72a4ec0f0089c78726f8f"
dependencies:
bindings "^1.2.1"
nan "^2.3.2"
minimist@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"
moment@^2.21.0:
version "2.21.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.21.0.tgz#2a114b51d2a6ec9e6d83cf803f838a878d8a023a"
nan@^2.3.2:
version "2.9.2"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.9.2.tgz#f564d75f5f8f36a6d9456cca7a6c4fe488ab7866"
object-keys@^1.0.8:
version "1.0.11"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d"
object.getownpropertydescriptors@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16"
dependencies:
define-properties "^1.1.2"
es-abstract "^1.5.1"
pathval@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0"
pretty-bytes@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-4.0.2.tgz#b2bf82e7350d65c6c33aa95aaa5a4f6327f61cd9"
smartchai@^2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/smartchai/-/smartchai-2.0.1.tgz#d20f17221f0e3c6c3473600b78ddfba0ab0ea762"
dependencies:
"@types/chai" "^4.1.2"
"@types/chai-as-promised" "^7.1.0"
"@types/chai-string" "^1.4.0"
chai "^4.1.2"
chai-as-promised "^7.1.1"
chai-string "^1.4.0"
smartdelay@^1.0.3, smartdelay@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/smartdelay/-/smartdelay-1.0.4.tgz#791c1a4ee6770494064c10b1d2d2b8e6f3105b82"
dependencies:
smartq "^1.1.1"
typings-global "^1.0.16"
smartq@^1.1.1, smartq@^1.1.6:
version "1.1.6"
resolved "https://registry.yarnpkg.com/smartq/-/smartq-1.1.6.tgz#0c1ff4336d95e95b4f1fdd8ccd7e2c5a323b8412"
dependencies:
typings-global "^1.0.19"
util.promisify "^1.0.0"
tapbundle@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/tapbundle/-/tapbundle-2.0.0.tgz#79fce68ff185c786fabaf6eb589a4afc7d2714b7"
dependencies:
early "^2.1.1"
leakage "^0.3.0"
smartchai "^2.0.0"
smartdelay "^1.0.3"
smartq "^1.1.1"
type-detect@^4.0.0:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.19:
version "1.0.28"
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.28.tgz#e28cc965476564cbc00e438739e0aa0735d323d4"
util.promisify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.0.tgz#440f7165a459c9a16dc145eb8e72f35687097030"
dependencies:
define-properties "^1.1.2"
object.getownpropertydescriptors "^2.0.3"