Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "tsbuffer", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "", | ||
@@ -31,2 +31,2 @@ "main": "index.js", | ||
"homepage": "https://github.com/k8w/tsbuffer#readme" | ||
} | ||
} |
@@ -5,2 +5,3 @@ import { TSBufferProto } from "tsbuffer-schema"; | ||
import { Decoder } from "./decoder/Decoder"; | ||
import { ValidateResult } from "tsbuffer-validator/src/ValidateResult"; | ||
export declare class TSBuffer { | ||
@@ -30,2 +31,3 @@ protected _validator: TSBufferValidator; | ||
}): unknown; | ||
validate(value: any, schemaId: string): ValidateResult; | ||
} |
@@ -27,3 +27,4 @@ "use strict"; | ||
if (!vRes.isSucc) { | ||
throw new Error("Invalid value: " + vRes.originalError.message); | ||
var err = vRes.originalError; | ||
throw new Error("Invalid value: " + (err.fieldName ? (err.fieldName + ' ') : '') + vRes.originalError.message); | ||
} | ||
@@ -44,7 +45,14 @@ } | ||
} | ||
var value = this._decoder.decode(buf, schema); | ||
var value; | ||
try { | ||
value = this._decoder.decode(buf, schema); | ||
} | ||
catch (e) { | ||
throw new Error('Invalid encoding: ' + e.message); | ||
} | ||
if (!options || !options.skipValidate) { | ||
var vRes = this._validator.validateBySchema(value, schema); | ||
if (!vRes.isSucc) { | ||
throw new Error("Invalid decoded value: " + vRes.originalError.message); | ||
var err = vRes.originalError; | ||
throw new Error("Invalid decoded value: " + (err.fieldName ? (err.fieldName + ' ') : '') + vRes.originalError.message); | ||
} | ||
@@ -54,4 +62,7 @@ } | ||
}; | ||
TSBuffer.prototype.validate = function (value, schemaId) { | ||
return this._validator.validate(value, schemaId); | ||
}; | ||
return TSBuffer; | ||
}()); | ||
exports.TSBuffer = TSBuffer; |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
61580
1246
0