New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

timer-logs

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timer-logs - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

1

exemplar/index.js

@@ -23,2 +23,3 @@ "use strict";

.catch(timer.postgresErrorReturn({ rows: [] }));
console.assert(rows instanceof Array, 'Rows should be an array even if an error is thrown');
};

@@ -25,0 +26,0 @@ postgresExample().then(() => {

@@ -29,2 +29,3 @@ import Timer from '../index'

.catch(timer.postgresErrorReturn({rows:[]}))
console.assert(rows instanceof Array, 'Rows should be an array even if an error is thrown')
}

@@ -31,0 +32,0 @@ postgresExample().then(()=>{

13

index.d.ts

@@ -125,3 +125,2 @@ declare type Config = {

* @param e the error object returned by postgres client
* @param returnVal specify a custom value to be returned. Defaults to null.
* @return null so the promise resolves to a value

@@ -132,4 +131,12 @@ * @example

*/
postgresError(e: PostgresError, returnVal?: any): any;
postgresError(e: PostgresError): null;
/**
* Logs a postgres error and returns the value passed as the second parameter.
*
* @param e the postgres error object
* @param returnVal the value for this function to return after logging the error
* @private
*/
private _postgresError;
/**
* Convenience wrapper for postgresError, to return a value.

@@ -144,3 +151,3 @@ * By default it returns null, but can be overriden with this method.

*/
postgresErrorReturn(returnValue: any): (e: PostgresError) => any;
postgresErrorReturn<ReturnType>(returnValue: ReturnType): (e: PostgresError) => ReturnType;
/**

@@ -147,0 +154,0 @@ * Logs a generic error in a separate log to the main Timer.

@@ -30,2 +30,3 @@ "use strict";

this.uniqueId = crypto.randomBytes(8).toString('hex');
this.start('operationTime');
this.start(this.config.label);

@@ -71,2 +72,3 @@ }

this.finishTime = Date.now();
this.stop('operationTime');
if (this.mostRecentlyStartedLabel && !this.savedTimes[this.mostRecentlyStartedLabel].finishTime)

@@ -105,10 +107,15 @@ this.end();

}
postgresError(e, returnVal) {
postgresError(e) {
return this._postgresError(e, null);
}
_postgresError(e, returnVal) {
const errorDetails = new Map(Object.entries(e));
if (!errorDetails.has('message'))
errorDetails.set('message', 'Postgres error code ' + e.code);
errorDetails.set("databaseType", "postgres");
this.printLog(errorDetails, Severity.ERROR);
return returnVal !== null && returnVal !== void 0 ? returnVal : null;
return returnVal;
}
postgresErrorReturn(returnValue) {
return (e) => this.postgresError(e, returnValue);
return (e) => this._postgresError(e, returnValue);
}

@@ -134,2 +141,5 @@ genericError(e, message) {

var _a;
if (!details.has('message')) {
details.set('message', 'timer-logs unset message in file ' + this.config.filename);
}
const log = {

@@ -136,0 +146,0 @@ severity: severity,

@@ -208,3 +208,2 @@ import * as crypto from 'crypto'

* @param e the error object returned by postgres client
* @param returnVal specify a custom value to be returned. Defaults to null.
* @return null so the promise resolves to a value

@@ -215,3 +214,14 @@ * @example

*/
public postgresError(e: PostgresError, returnVal?: any): any {
public postgresError(e: PostgresError): null{
return this._postgresError(e, null)
}
/**
* Logs a postgres error and returns the value passed as the second parameter.
*
* @param e the postgres error object
* @param returnVal the value for this function to return after logging the error
* @private
*/
private _postgresError<ReturnType>(e: PostgresError, returnVal: ReturnType): ReturnType {
const errorDetails = new Map(Object.entries(e))

@@ -221,3 +231,3 @@ if(!errorDetails.has('message')) errorDetails.set('message', 'Postgres error code '+e.code)

this.printLog(errorDetails, Severity.ERROR)
return returnVal ?? null
return returnVal
}

@@ -235,4 +245,4 @@

*/
public postgresErrorReturn(returnValue: any) {
return (e: PostgresError) => this.postgresError(e, returnValue)
public postgresErrorReturn<ReturnType>(returnValue: ReturnType): (e: PostgresError) => ReturnType {
return (e: PostgresError) => this._postgresError(e, returnValue)
}

@@ -239,0 +249,0 @@

{
"name": "timer-logs",
"version": "1.2.2",
"version": "1.3.0",
"devDependencies": {

@@ -5,0 +5,0 @@ "@types/node": "^15.00.0"

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