Skip to content

Commit

Permalink
0.0.8 (#129)
Browse files Browse the repository at this point in the history
* 0.0.8

* remove wrong deps

* fix useless import

* adds createconsolelog in test utils
  • Loading branch information
albertobarrila authored Dec 21, 2023
1 parent 1a9232d commit 4d156ac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
4 changes: 2 additions & 2 deletions 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": "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": {
Expand Down
19 changes: 0 additions & 19 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import { inspect } from "node:util"
import { createLogger, format, transports } from "winston"

export function removeFrom<T>(l: T[], predicate: (x: T) => boolean): T | undefined {
const i = l.findIndex(predicate)
if (i === -1) return
const [e] = l.splice(i, 1)
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++) {
Expand Down
28 changes: 23 additions & 5 deletions test/support/util.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/unit/response_decoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand Down

0 comments on commit 4d156ac

Please sign in to comment.