From 4d156acc052401888a5f6f62ca8e0b644284df7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Barril=C3=A1?= Date: Thu, 21 Dec 2023 10:00:29 +0100 Subject: [PATCH] 0.0.8 (#129) * 0.0.8 * remove wrong deps * fix useless import * adds createconsolelog in test utils --- package-lock.json | 4 ++-- package.json | 2 +- src/util.ts | 19 ------------------- test/support/util.ts | 28 +++++++++++++++++++++++----- test/unit/response_decoder.test.ts | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/package-lock.json b/package-lock.json index b016cfed..6de81df4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rabbitmq-stream-js-client", - "version": "0.0.7", + "version": "0.0.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rabbitmq-stream-js-client", - "version": "0.0.7", + "version": "0.0.8", "license": "ISC", "devDependencies": { "@tsconfig/node16": "^1.0.3", diff --git a/package.json b/package.json index 0ad29fa7..e1c7004d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rabbitmq-stream-js-client", - "version": "0.0.7", + "version": "0.0.8", "description": "Rabbit stream client for JS/TS application", "main": "dist/index.js", "scripts": { diff --git a/src/util.ts b/src/util.ts index 115e9a72..b8364c7d 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,6 +1,3 @@ -import { inspect } from "node:util" -import { createLogger, format, transports } from "winston" - export function removeFrom(l: T[], predicate: (x: T) => boolean): T | undefined { const i = l.findIndex(predicate) if (i === -1) return @@ -8,22 +5,6 @@ export function removeFrom(l: T[], predicate: (x: T) => boolean): T | undefin return e } -export function createConsoleLog({ silent, level } = { silent: false, level: "debug" }) { - return createLogger({ - silent, - level, - format: format.combine( - format.colorize(), - format.timestamp(), - format.align(), - format.splat(), - format.label(), - format.printf((info) => `${info.timestamp} ${info.level}: ${info.message} ${info.meta ? inspect(info.meta) : ""}`) - ), - transports: new transports.Console(), - }) -} - export function range(count: number): number[] { const ret = Array(count) for (let index = 0; index < count; index++) { diff --git a/test/support/util.ts b/test/support/util.ts index ccabb431..69130972 100644 --- a/test/support/util.ts +++ b/test/support/util.ts @@ -1,12 +1,30 @@ -import { AssertionError, expect } from "chai" import * as ampq from "amqplib" -import { DataReader } from "../../src/responses/raw_response" -import { Message, MessageApplicationProperties, MessageHeader, MessageProperties } from "../../src/producer" +import { AssertionError, expect } from "chai" +import { inspect } from "node:util" +import { createLogger, format, transports } from "winston" +import { ApplicationProperties } from "../../src/amqp10/applicationProperties" import { FormatCodeType } from "../../src/amqp10/decoder" -import { decodeFormatCode } from "../../src/response_decoder" import { Header } from "../../src/amqp10/messageHeader" import { Properties } from "../../src/amqp10/properties" -import { ApplicationProperties } from "../../src/amqp10/applicationProperties" +import { Message, MessageApplicationProperties, MessageHeader, MessageProperties } from "../../src/producer" +import { decodeFormatCode } from "../../src/response_decoder" +import { DataReader } from "../../src/responses/raw_response" + +export function createConsoleLog({ silent, level } = { silent: false, level: "debug" }) { + return createLogger({ + silent, + level, + format: format.combine( + format.colorize(), + format.timestamp(), + format.align(), + format.splat(), + format.label(), + format.printf((info) => `${info.timestamp} ${info.level}: ${info.message} ${info.meta ? inspect(info.meta) : ""}`) + ), + transports: new transports.Console(), + }) +} export function elapsedFrom(from: number): number { return Date.now() - from diff --git a/test/unit/response_decoder.test.ts b/test/unit/response_decoder.test.ts index be967ee2..99f3d1b1 100644 --- a/test/unit/response_decoder.test.ts +++ b/test/unit/response_decoder.test.ts @@ -5,7 +5,7 @@ import { BufferDataWriter } from "../../src/requests/abstract_request" import { ResponseDecoder } from "../../src/response_decoder" import { PeerPropertiesResponse } from "../../src/responses/peer_properties_response" import { Response } from "../../src/responses/response" -import { createConsoleLog } from "../../src/util" +import { createConsoleLog } from "../support/util" class MockDecoderListener { readonly responses: Response[] = []