UNPKG

node-beanstalk

Version:

The most comprehensive beanstalk client for nodejs

46 lines 1.97 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.JsonSerializer = void 0; /* eslint-disable class-methods-use-this */ var types_1 = require("../types"); var SerializerError_1 = require("../error/SerializerError"); var JsonSerializer = /** @class */ (function (_super) { __extends(JsonSerializer, _super); function JsonSerializer() { return _super !== null && _super.apply(this, arguments) || this; } JsonSerializer.prototype.serialize = function (data) { try { return Buffer.from(JSON.stringify(data), 'utf-8'); } catch (e) { throw new SerializerError_1.SerializerError(SerializerError_1.SerializerErrorCode.ErrSerializeError, e.message); } }; JsonSerializer.prototype.deserialize = function (buffer) { try { return JSON.parse(buffer.toString('utf-8')); } catch (e) { throw new SerializerError_1.SerializerError(SerializerError_1.SerializerErrorCode.ErrDeserializeError, e.message); } }; return JsonSerializer; }(types_1.Serializer)); exports.JsonSerializer = JsonSerializer; //# sourceMappingURL=JsonSerializer.js.map