@ngx-grpc/protoc-gen-ng
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -0,1 +1,8 @@ | ||
## [0.4.1](https://github.com/ngx-grpc/protoc-gen-ng/compare/v0.4.0...v0.4.1) (2020-01-10) | ||
### Features | ||
* add wkt timestamp helper functions ([3e88b89](https://github.com/ngx-grpc/protoc-gen-ng/commit/3e88b89be0821bf56e2c12647fb04c146197ecdd)) | ||
# [0.4.0](https://github.com/ngx-grpc/protoc-gen-ng/compare/v0.3.2...v0.4.0) (2020-01-02) | ||
@@ -2,0 +9,0 @@ |
@@ -61,2 +61,5 @@ "use strict"; | ||
printer.addLine("export class " + this.message.name + " {\n\n static toBinary(instance: " + this.message.name + ") {\n const writer = new BinaryWriter();\n " + this.message.name + ".toBinaryWriter(instance, writer);\n return writer.getResultBuffer();\n }\n\n static fromBinary(bytes: ByteSource) {\n const instance = new " + this.message.name + "();\n " + this.message.name + ".fromBinaryReader(instance, new BinaryReader(bytes));\n return instance;\n }\n "); | ||
if (this.message.name === 'Timestamp' && this.proto.pb_package === 'google.protobuf') { | ||
this.printTimestampStaticMethods(printer); | ||
} | ||
this.printStaticRefineValues(printer); | ||
@@ -85,2 +88,5 @@ printer.newLine(); | ||
printer.addLine('toJSON() { return this.toObject(); }'); | ||
if (this.message.name === 'Timestamp' && this.proto.pb_package === 'google.protobuf') { | ||
this.printTimestampMemberMethods(printer); | ||
} | ||
printer.addLine('}'); | ||
@@ -157,4 +163,10 @@ this.printSubTypes(printer); | ||
}; | ||
Message.prototype.printTimestampStaticMethods = function (printer) { | ||
printer.addLine("\n static fromDate(date: Date) {\n var timestamp = new Timestamp();\n timestamp.fromDate(date);\n return timestamp;\n }\n\n static fromISOString(isoDate: string) {\n var timestamp = new Timestamp();\n timestamp.fromISOString(isoDate);\n return timestamp;\n }\n "); | ||
}; | ||
Message.prototype.printTimestampMemberMethods = function (printer) { | ||
printer.addLine("\n fromDate(date: Date) {\n this.seconds = Math.floor(date.getTime() / 1e3);\n this.nanos = date.getMilliseconds() * 1e6;\n }\n\n toDate() {\n return new Date((this.seconds || 0) * 1e3 + (this.nanos || 0) / 1e6);\n }\n\n fromISOString(isoDate: string) {\n this.fromDate(new Date(isoDate));\n }\n\n toISOString() {\n return this.toDate().toISOString();\n }\n "); | ||
}; | ||
return Message; | ||
}()); | ||
exports.Message = Message; |
{ | ||
"name": "@ngx-grpc/protoc-gen-ng", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"author": "smnbbrv", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
935992
28157