UNPKG

@tinkoff/invest-js

Version:
93 lines 3.12 kB
"use strict"; // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.6.1 // protoc v3.19.1 // source: google/protobuf/timestamp.proto Object.defineProperty(exports, "__esModule", { value: true }); exports.Timestamp = void 0; /* eslint-disable */ const wire_1 = require("@bufbuild/protobuf/wire"); function createBaseTimestamp() { return { seconds: 0, nanos: 0 }; } exports.Timestamp = { encode(message, writer = new wire_1.BinaryWriter()) { if (message.seconds !== 0) { writer.uint32(8).int64(message.seconds); } if (message.nanos !== 0) { writer.uint32(16).int32(message.nanos); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseTimestamp(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.seconds = longToNumber(reader.int64()); continue; } case 2: { if (tag !== 16) { break; } message.nanos = reader.int32(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { seconds: isSet(object.seconds) ? globalThis.Number(object.seconds) : 0, nanos: isSet(object.nanos) ? globalThis.Number(object.nanos) : 0, }; }, toJSON(message) { const obj = {}; if (message.seconds !== 0) { obj.seconds = Math.round(message.seconds); } if (message.nanos !== 0) { obj.nanos = Math.round(message.nanos); } return obj; }, create(base) { return exports.Timestamp.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a, _b; const message = createBaseTimestamp(); message.seconds = (_a = object.seconds) !== null && _a !== void 0 ? _a : 0; message.nanos = (_b = object.nanos) !== null && _b !== void 0 ? _b : 0; return message; }, }; function longToNumber(int64) { const num = globalThis.Number(int64.toString()); if (num > globalThis.Number.MAX_SAFE_INTEGER) { throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); } if (num < globalThis.Number.MIN_SAFE_INTEGER) { throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER"); } return num; } function isSet(value) { return value !== null && value !== undefined; } //# sourceMappingURL=timestamp.js.map