New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flatbuffers-addon

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatbuffers-addon - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

95

index.js

@@ -1,3 +0,2 @@

const addon = require('bindings')('addon.node');
const fs = require("fs");
const addon = require("bindings")("addon.node");

@@ -12,53 +11,46 @@ const StringBuffer = str => {

const schemaOptions = options => {
if (Buffer.isBuffer(options.schema) && options.schema_contents != null) {
throw new TypeError("if schema option is a Buffer, schema_contents must be null or undefined");
const setOption = (options, prop, basename, ext, stringify) => {
if (options[prop] != null && options[`${ prop }_contents`] == null) {
options[`${ prop }_contents`] = options[prop];
options[prop] = null;
}
if (options.schema != null && options.schema_contents == null) {
options.schema_contents = options.schema;
options.schema = null;
if (options[prop] == null && options[`${ prop }_contents`] != null) {
options[prop] = `${ basename || prop }.${ ext }`;
}
if (options.schema == null && options.schema_contents != null) {
options.schema = "schema.fbs";
if (stringify && options[`${ prop }_contents`] !== null && typeof options[`${ prop }_contents`] === "object" && !Buffer.isBuffer(options[`${ prop }_contents`])) {
options[`${ prop }_contents`] = JSON.stringify(options[`${ prop }_contents`]);
}
if (typeof options.schema_contents === "string") {
options.schema_contents = StringBuffer(options.schema_contents);
if (typeof options[`${ prop }_contents`] === "string") {
options[`${ prop }_contents`] = StringBuffer(options[`${ prop }_contents`]);
}
if (!Buffer.isBuffer(options.schema_contents)) {
throw new TypeError("schema_contents must either be a string or a Buffer");
if (options[`${ prop }_contents`] != null && !Buffer.isBuffer(options[`${ prop }_contents`])) {
throw new TypeError(`${ prop }_contents must be a string or a Buffer`);
}
if (options.schema_length == null) {
options.schema_length = options.schema_contents.length;
if (options[`${ prop }_length`] == null && options[`${ prop }_contents`]) {
options[`${ prop }_length`] = options[`${ prop }_contents`].length;
}
if (Buffer.isBuffer(options.conform) && options.conform_contents != null) {
throw new TypeError("if conform option is a Buffer, conform_contents must be null or undefined");
if (options[`${ prop }_contents`] != null && Buffer.isBuffer(options[prop])) {
throw new TypeError(`if ${ prop } is a Buffer, ${ prop }_contents must be null or undefined`);
}
if (options.conform != null && options.conform_contents == null) {
options.conform_contents = options.conform;
options.conform = null;
if (options[prop] != null && typeof options[prop] !== "string") {
throw new TypeError(`${ prop } must be a string`);
}
};
if (options.conform == null && options.conform_contents != null) {
options.conform = "conform.fbs";
}
const schemaOptions = options => {
[ "schema", "conform" ].forEach(prop => {
setOption(options, prop, prop, "fbs");
});
if (typeof options.conform_contents === "string") {
options.conform_contents = StringBuffer(options.conform_contents);
if (!options.schema_contents) {
throw new TypeError("schema_contents must be a string or a Buffer");
}
if (options.conform_contents != null && !Buffer.isBuffer(options.conform_contents)) {
throw new TypeError("conform_contents must either be a string or a Buffer");
}
if (options.conform_contents != null && options.conform_length == null) {
options.conform_length = options.conform_contents.length;
}
[ "include_directories", "conform_include_directories" ].forEach(prop => {

@@ -70,5 +62,7 @@ if (options[prop] == null) {

if (Array.isArray(options[prop])) {
options[prop].forEach((str, i, arr) => {
if (typeof str === "string") {
arr[i] = StringBuffer(str);
options[prop].forEach((item, i, arr) => {
if (typeof item === "string") {
arr[i] = StringBuffer(item);
} else if (!Buffer.isBuffer(item)) {
throw new TypeError(`element ${ i } of ${ prop } must be a string or a Buffer`);
}

@@ -90,29 +84,4 @@ });

if (options.json_contents != null && (Buffer.isBuffer(options.json) || typeof options.json === "object")) {
throw new TypeError("if json option is a Buffer or an Object, json_contents must be null or undefined");
}
setOption(options, "json", "data", "json", true);
if (options.json != null && options.json_contents == null) {
options.json_contents = options.json;
options.json = null;
}
if (options.json == null && options.json_contents != null) {
options.json = "data.json";
}
if (typeof options.json_contents === "string") {
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 = StringBuffer(JSON.stringify(options.json_contents));
}
if (options.json_contents != null && !Buffer.isBuffer(options.json_contents)) {
throw new TypeError("json_contents must either be a string, a Buffer or an Object");
}
if (options.json_contents != null && options.json_length == null) {
options.json_length = options.json_contents.length;
}
if (options.schema_binary && options.json_contents != null) {

@@ -119,0 +88,0 @@ throw new TypeError("if schema_binary option is true, json_contents must be null or undefined");

{
"name": "flatbuffers-addon",
"version": "0.1.2",
"version": "0.1.3",
"description": "Node flatbuffers addon",

@@ -5,0 +5,0 @@ "repository": {

@@ -61,4 +61,2 @@ # flatbuffers-addon

**NOT TESTED**
`type: String|Buffer`

@@ -72,4 +70,2 @@

**NOT TESTED**
`type: String|Buffer`

@@ -81,4 +77,2 @@

**NOT TESTED**
`type: [String]`

@@ -168,8 +162,6 @@

**NOT TESTED**
`type: bool`
`default: false`
Emit default values in binary output from JSON.
If false, don't serialize values equal to the default, therefore reducing size of the binary output.

@@ -211,4 +203,2 @@ ## Generate js

**NOT TESTED**
`type: String|Buffer`

@@ -222,4 +212,2 @@

**NOT TESTED**
`type: String|Buffer`

@@ -231,4 +219,2 @@

**NOT TESTED**
`type: [String]`

@@ -235,0 +221,0 @@

@@ -1,3 +0,1 @@

"use strict";
const fs = require("fs");

@@ -112,3 +110,3 @@ const sysPath = require("path");

const patchFromBuffer = (dmp, tokenizer, q, cwd, patchfile, options, buffer, len, eof) => {
let match, file, left, right, lines1, lines2, lf, diff, start, end, tmp, lastEnd, i, j;
let match, file, left, right, lines1, lines2, lf, start, end, tmp, lastEnd, i, j;

@@ -251,3 +249,3 @@ let lastIndex = -1;

if (!performed) {
next(null, performed)
next(null, performed);
return;

@@ -266,3 +264,3 @@ }

if (!performed) {
next()
next();
return;

@@ -269,0 +267,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc