Socket
Socket
Sign inDemoInstall

@matrixai/timer

Package Overview
Dependencies
3
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 2.0.0

jest.config.mjs

10

dist/errors.js

@@ -1,13 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorTimerEnded = exports.ErrorTimer = void 0;
const errors_1 = require("@matrixai/errors");
class ErrorTimer extends errors_1.AbstractError {
import { AbstractError } from '@matrixai/errors';
class ErrorTimer extends AbstractError {
static description = 'Timer error';
}
exports.ErrorTimer = ErrorTimer;
class ErrorTimerEnded extends ErrorTimer {
static description = 'The timer has already ended';
}
exports.ErrorTimerEnded = ErrorTimerEnded;
export { ErrorTimer, ErrorTimerEnded };
//# sourceMappingURL=errors.js.map

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

export { default as Timer } from './Timer';
export * as errors from './errors';
export { default as Timer } from './Timer.js';
export * as errors from './errors.js';

@@ -1,33 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.errors = exports.Timer = void 0;
var Timer_1 = require("./Timer");
Object.defineProperty(exports, "Timer", { enumerable: true, get: function () { return __importDefault(Timer_1).default; } });
exports.errors = __importStar(require("./errors"));
export { default as Timer } from './Timer.js';
export * as errors from './errors.js';
//# sourceMappingURL=index.js.map

@@ -1,6 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const perf_hooks_1 = require("perf_hooks");
const async_cancellable_1 = require("@matrixai/async-cancellable");
const errors_1 = require("./errors");
import { performance } from 'node:perf_hooks';
import { PromiseCancellable } from '@matrixai/async-cancellable';
import { ErrorTimerEnded } from './errors.js';
/**

@@ -100,3 +98,3 @@ * Just like `setTimeout` or `setInterval`,

}
this.p = new async_cancellable_1.PromiseCancellable((resolve, reject) => {
this.p = new PromiseCancellable((resolve, reject) => {
this.resolveP = resolve.bind(this.p);

@@ -110,3 +108,3 @@ this.rejectP = reject.bind(this.p);

this.timeoutRef = setTimeout(() => void this.fulfill(), delay);
this.timestamp = new Date(perf_hooks_1.performance.timeOrigin + perf_hooks_1.performance.now());
this.timestamp = new Date(performance.timeOrigin + performance.now());
this._scheduled = new Date(this.timestamp.getTime() + delay);

@@ -118,3 +116,3 @@ }

this.timeoutRef = setInterval(() => { }, 2 ** 31 - 1);
this.timestamp = new Date(perf_hooks_1.performance.timeOrigin + perf_hooks_1.performance.now());
this.timestamp = new Date(performance.timeOrigin + performance.now());
}

@@ -154,3 +152,3 @@ }

return Math.max(Math.trunc(this._scheduled.getTime() -
(perf_hooks_1.performance.timeOrigin + perf_hooks_1.performance.now())), 0);
(performance.timeOrigin + performance.now())), 0);
}

@@ -197,5 +195,5 @@ /**

if (this.timeoutRef == null)
throw new errors_1.ErrorTimerEnded();
throw new ErrorTimerEnded();
this.timeoutRef.refresh();
this._scheduled = new Date(perf_hooks_1.performance.timeOrigin + perf_hooks_1.performance.now() + this._delay);
this._scheduled = new Date(performance.timeOrigin + performance.now() + this._delay);
}

@@ -207,3 +205,3 @@ /**

if (this.timeoutRef == null)
throw new errors_1.ErrorTimerEnded();
throw new ErrorTimerEnded();
// This needs to re-create the timeout with the constructor logic.

@@ -216,3 +214,3 @@ clearTimeout(this.timeoutRef);

this.timeoutRef = setTimeout(() => void this.fulfill(), delay);
this._scheduled = new Date(perf_hooks_1.performance.timeOrigin + perf_hooks_1.performance.now() + delay);
this._scheduled = new Date(performance.timeOrigin + performance.now() + delay);
}

@@ -256,3 +254,3 @@ else {

}
exports.default = Timer;
export default Timer;
//# sourceMappingURL=Timer.js.map
{
"name": "@matrixai/timer",
"version": "1.1.1",
"version": "2.0.0",
"author": "Roger Qiu",

@@ -16,4 +16,18 @@ "description": "Stopwatch timer object",

},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./*.js": {
"types": "./dist/*.d.ts",
"import": "./dist/*.js"
},
"./*": "./dist/*"
},
"imports": {
"#*": "./dist/*"
},
"scripts": {

@@ -23,6 +37,6 @@ "prepare": "tsc -p ./tsconfig.build.json",

"postversion": "npm install --package-lock-only --ignore-scripts --silent",
"ts-node": "ts-node",
"test": "jest",
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,ts}'",
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,ts}' --fix",
"tsx": "tsx",
"test": "node ./scripts/test.mjs",
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}'",
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}' --fix",
"lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +",

@@ -32,27 +46,25 @@ "docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"

"dependencies": {
"@matrixai/async-cancellable": "^1.1.1",
"@matrixai/errors": "^1.1.7"
"@matrixai/async-cancellable": "^2.0.0",
"@matrixai/errors": "^2.0.1"
},
"devDependencies": {
"@swc/core": "^1.3.62",
"@swc/jest": "^0.2.26",
"@types/jest": "^28.1.3",
"@swc/core": "^1.3.76",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.2",
"@types/node": "^18.15.0",
"@typescript-eslint/eslint-plugin": "^5.45.1",
"@typescript-eslint/parser": "^5.45.1",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.1",
"jest-extended": "^3.0.1",
"jest-junit": "^14.0.0",
"prettier": "^2.6.2",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"jest": "^29.6.2",
"jest-extended": "^4.0.0",
"jest-junit": "^16.0.0",
"prettier": "^3.0.0",
"shx": "^0.3.4",
"ts-jest": "^28.0.5",
"ts-node": "^10.9.1",
"tsconfig-paths": "^3.9.0",
"typedoc": "^0.23.21",
"typescript": "^4.9.3"
"tsx": "^3.12.7",
"typedoc": "^0.24.8",
"typescript": "^5.1.6"
}
}

@@ -26,3 +26,3 @@ # js-timer

# run the repl (this allows you to import from ./src)
npm run ts-node
npm run tsx
# run the tests

@@ -29,0 +29,0 @@ npm run test

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc