flatbuffers-addon
Advanced tools
Comparing version 0.1.0 to 0.1.1
19
index.js
const addon = require('bindings')('addon.node'); | ||
const fs = require("fs"); | ||
const StringBuffer = str => { | ||
const buffer = Buffer.from(str); | ||
const len = buffer.length; | ||
const target = Buffer.allocUnsafe(len + 1); | ||
buffer.copy(target); | ||
target[len] = 0; | ||
return target; | ||
} | ||
const schemaOptions = options => { | ||
@@ -19,3 +28,3 @@ if (Buffer.isBuffer(options.schema) && options.schema_contents != null) { | ||
if (typeof options.schema_contents === "string") { | ||
options.schema_contents = Buffer.from(options.schema_contents); | ||
options.schema_contents = StringBuffer(options.schema_contents); | ||
} | ||
@@ -45,3 +54,3 @@ | ||
if (typeof options.conform_contents === "string") { | ||
options.conform_contents = Buffer.from(options.conform_contents); | ||
options.conform_contents = StringBuffer(options.conform_contents); | ||
} | ||
@@ -65,3 +74,3 @@ | ||
if (typeof str === "string") { | ||
arr[i] = Buffer.from(str); | ||
arr[i] = StringBuffer(str); | ||
} | ||
@@ -93,5 +102,5 @@ }); | ||
if (typeof options.json_contents === "string") { | ||
options.json_contents = Buffer.from(options.json_contents); | ||
options.json_contents = StringBuffer(options.json_contents); | ||
} else if (options.json_contents != null && typeof options.json_contents === "object" && !Buffer.isBuffer(options.json_contents)) { | ||
options.json_contents = Buffer.from(JSON.stringify(options.json_contents)); | ||
options.json_contents = StringBuffer(JSON.stringify(options.json_contents)); | ||
} | ||
@@ -98,0 +107,0 @@ |
{ | ||
"name": "flatbuffers-addon", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Node flatbuffers addon", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
583
56932