Skip to content

Commit

Permalink
Merge pull request #58 from yusufshakeel/dev-refactoring-and-make-mor…
Browse files Browse the repository at this point in the history
…e-configurable

v0.12.0
  • Loading branch information
yusufshakeel authored May 18, 2023
2 parents 3fe4825 + 5cb43ad commit 010ffbc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Generate coupons.

[![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/yusufshakeel/couponjs)
[![npm version](https://img.shields.io/badge/npm-0.11.0-blue.svg)](https://www.npmjs.com/package/couponjs)
[![npm version](https://img.shields.io/badge/npm-0.12.0-blue.svg)](https://www.npmjs.com/package/couponjs)
[![npm Downloads](https://img.shields.io/npm/dm/couponjs.svg)](https://www.npmjs.com/package/couponjs)

![CouponJS](./resource/couponjs-500x150.png)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "couponjs",
"version": "0.11.0",
"version": "0.12.0",
"description": "Generate coupons.",
"main": "lib/esm/index.js",
"types": "lib/types/index.d.ts",
Expand Down
20 changes: 9 additions & 11 deletions src/helpers/performance.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import { PerformanceType } from '../ts-def/performance-type';

const NS_PER_SEC = 1e9;

export default class Performance {
private startedAt: [number, number] = [0, 0];
private duration: [number, number] = [0, 0];
private startedAt = 0;
private endedAt = 0;

public startTimer() {
this.startedAt = process.hrtime();
this.startedAt = new Date().getTime();
}

public stopTimer() {
this.duration = process.hrtime(this.startedAt);
this.endedAt = new Date().getTime();
}

public stats(): PerformanceType {
const nano = (this.duration)[0] * NS_PER_SEC + (this.duration)[1];
const milli = this.endedAt - this.startedAt;
return {
duration: {
nano,
micro: nano / 1e3,
milli: nano / 1e6,
second: nano / 1e9
nano: milli * 1e6,
micro: milli * 1e3,
milli,
second: milli / 1e3
}
};
}
Expand Down

0 comments on commit 010ffbc

Please sign in to comment.