Comparing version 2.0.0-212 to 2.0.0-213
export interface MsgHdrs extends Iterable<[string, string[]]> { | ||
hasError: boolean; | ||
status: string; | ||
code?: number; | ||
get(k: string): string; | ||
@@ -14,3 +17,4 @@ set(k: string, v: string): void; | ||
static HEADER: string; | ||
error?: number; | ||
code?: number; | ||
description: string; | ||
headers: Map<string, string[]>; | ||
@@ -32,2 +36,4 @@ constructor(); | ||
delete(k: string): void; | ||
get hasError(): boolean; | ||
get status(): string; | ||
} |
@@ -27,2 +27,3 @@ "use strict"; | ||
constructor() { | ||
this.description = ""; | ||
this.headers = new Map(); | ||
@@ -42,3 +43,3 @@ } | ||
if (mh && this.headers.size === mh.headers.size && | ||
this.error === mh.error) { | ||
this.code === mh.code) { | ||
for (const [k, v] of this.headers) { | ||
@@ -67,4 +68,11 @@ const a = mh.values(k); | ||
if (h !== MsgHdrsImpl.HEADER) { | ||
const str = h.replace(MsgHdrsImpl.HEADER, ""); | ||
mh.error = parseInt(str, 10); | ||
let str = h.replace(MsgHdrsImpl.HEADER, ""); | ||
mh.code = parseInt(str, 10); | ||
const scode = mh.code.toString(); | ||
mh.set("Status", scode); | ||
str = str.replace(scode, ""); | ||
mh.description = str.trim(); | ||
if (mh.description) { | ||
mh.set("Description", mh.description); | ||
} | ||
} | ||
@@ -176,2 +184,11 @@ else { | ||
} | ||
get hasError() { | ||
if (this.code) { | ||
return this.code > 0 && (this.code < 200 || this.code >= 300); | ||
} | ||
return false; | ||
} | ||
get status() { | ||
return `${this.code} ${this.description}`.trim(); | ||
} | ||
} | ||
@@ -178,0 +195,0 @@ exports.MsgHdrsImpl = MsgHdrsImpl; |
@@ -44,4 +44,4 @@ "use strict"; | ||
const headers = m.headers; | ||
if (headers.error) { | ||
err = new error_1.NatsError(headers.error.toString(), error_1.ErrorCode.REQUEST_ERROR); | ||
if (headers.hasError) { | ||
err = new error_1.NatsError(headers.status, error_1.ErrorCode.REQUEST_ERROR); | ||
} | ||
@@ -48,0 +48,0 @@ } |
@@ -532,2 +532,3 @@ "use strict"; | ||
this.noMorePublishing = true; | ||
yield this.flush(); | ||
return this.close(); | ||
@@ -534,0 +535,0 @@ })) |
@@ -45,3 +45,3 @@ "use strict"; | ||
const { readFile, existsSync } = require("fs"); | ||
const VERSION = "2.0.0-212"; | ||
const VERSION = "2.0.0-213"; | ||
const LANG = "nats.js"; | ||
@@ -48,0 +48,0 @@ class NodeTransport { |
{ | ||
"name": "nats", | ||
"version": "2.0.0-212", | ||
"version": "2.0.0-213", | ||
"description": "Node.js client for NATS, a lightweight, high-performance cloud native messaging system", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
"clean": "rm -Rf ./lib/* ./nats-base-client ./.deps", | ||
"clone-nbc": "mkdir -p ./.deps && cd ./.deps && git clone --branch=v1.0.0-11 https://github.com/nats-io/nats.deno.git", | ||
"clone-nbc": "mkdir -p ./.deps && cd ./.deps && git clone --branch=v1.0.0-12 https://github.com/nats-io/nats.deno.git", | ||
"fmt": "deno fmt ./src/ ./examples/ ./test/", | ||
@@ -47,0 +47,0 @@ "prepack": "npm run clone-nbc && npm run cjs && npm run build", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
381215
113
6390
4