Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

avsc

Package Overview
Dependencies
Maintainers
1
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avsc - npm Package Compare versions

Comparing version 3.3.9 to 3.3.10

109

lib/schemas.js

@@ -107,5 +107,7 @@ /* jshint node: true */

// We are done with this file. We prepend all imported types to this
// file's and we can return the final result.
// file's and we can return the final result. We also perform a JSON
// serialization rountrip to remove non-numerical attributes from unions
// and transform Javadocs into strings.
attrs.types = importedTypes.concat(attrs.types);
cb(null, attrs);
cb(null, JSON.parse(JSON.stringify(attrs)));
} else if (info.kind === 'idl') {

@@ -146,2 +148,3 @@ assemble(info.path, opts, assembleImports);

}
tk.addJavadoc(attrs);
tk.get({val: 'protocol'});

@@ -205,3 +208,9 @@ attrs.protocol = tk.next({id: 'name'}).val;

function readMessage(protocolAttrs, responseAttrs, oneWay) {
var messageAttrs = {response: responseAttrs};
var messageAttrs;
if (opts.reassignJavadoc) {
messageAttrs = {};
messageAttrs.response = reassignJavadoc(responseAttrs, messageAttrs);
} else {
messageAttrs = {response: responseAttrs};
}
if (oneWay) {

@@ -247,11 +256,4 @@ messageAttrs['one-way'] = true;

var attrs = {type: readType()};
// The spec somehow breaks consistency by allowing the `order` annotation
// to be placed before the type's name rather than before the field's name.
// We must manually place it correctly and fix up the type.
if (attrs.type.order) {
attrs.order = attrs.type.order;
delete attrs.type.order;
if (Object.keys(attrs.type).length === 1) {
attrs.type = attrs.type.type;
}
if (opts.reassignJavadoc) {
attrs.type = reassignJavadoc(attrs.type, attrs);
}

@@ -261,2 +263,3 @@ while (tk.get().val === '@') {

}
tk.addJavadoc(attrs);
attrs.name = tk.get({id: 'name'}).val;

@@ -275,2 +278,3 @@ if (tk.next().val === '=') {

}
tk.addJavadoc(attrs);

@@ -290,6 +294,3 @@ switch (tk.get().val) {

case 'union':
if (Object.keys(attrs).length) {
throw new Error('unions cannot be annotated');
}
return readUnion();
return readUnion(attrs);
default:

@@ -351,4 +352,4 @@ var type = tk.get().val;

function readUnion() {
var attrs = [];
function readUnion(attrs) {
var arr = [];
tk.get({val: 'union'});

@@ -358,6 +359,12 @@ tk.next({val: '{'});

tk.next();
attrs.push(readType());
arr.push(readType());
} while (tk.get().val !== '}');
tk.next();
return attrs;
Object.keys(attrs).forEach(function (name) {
// We can do this since `JSON.stringify` will ignore non-numeric keys on
// array objects. This lets us be consistent with field and message
// attribute transfer (e.g. for `doc` and `order`).
arr[name] = attrs[name];
});
return arr;
}

@@ -401,2 +408,4 @@

*
* This tokenizer also handles Javadoc extraction, via the `addJavadoc` method.
*
*/

@@ -408,2 +417,3 @@ function Tokenizer(str) {

this._token = undefined; // Current token.
this._doc = undefined; // Javadoc.
}

@@ -497,2 +507,10 @@

Tokenizer.prototype.addJavadoc = function (attrs) {
if (this._doc === undefined || attrs.doc !== undefined) {
return;
}
attrs.doc = this._doc;
this._doc = undefined;
};
/**

@@ -504,3 +522,3 @@ * Skip whitespace and comments.

var str = this._str;
var c;
var pos, c; // `pos` used for javadocs.

@@ -520,5 +538,11 @@ while ((c = str.charAt(this._pos)) && /\s/.test(c)) {

this._pos += 2;
if (str.charAt(this._pos) === '*') {
pos = this._pos + 1;
}
while ((c = str.charAt(this._pos++))) {
if (c === '*' && str.charAt(this._pos) === '/') {
this._pos++;
if (pos !== undefined) {
this._doc = new Javadoc(str.slice(pos, this._pos - 2));
}
return this._skip();

@@ -648,3 +672,46 @@ }

/**
* Javadoc wrapper class.
*
* This is used to be able to distinguish between normal `doc` annotations and
* Javadoc comments, to correctly support the `reassignJavadoc` option.
*
* The parsing done is very simple and simply removes the line prefixes and
* leading / trailing empty lines. It's better to be conservative with
* formatting rather than risk losing information.
*
*/
function Javadoc(str) {
str = str.replace(/^[ \t]+|[ \t]+$/g, ''); // Trim whitespace.
var lines = str.split('\n').map(function (line, i) {
return i ? line.replace(/^\s*\*\s?/, '') : line;
});
while (!lines[0]) {
lines.shift();
}
while (!lines[lines.length - 1]) {
lines.pop();
}
this._str = lines.join('\n');
}
Javadoc.prototype.toJSON = function () { return this._str; };
/**
* Transfer a key from an object to another and return the new source.
*
* If the source becomes an object with a single type attribute set, its `type`
* attribute is returned instead.
*
*/
function reassignJavadoc(from, to) {
if (!(from.doc instanceof Javadoc)) {
// Nothing to transfer.
return from;
}
to.doc = from.doc;
delete from.doc;
return Object.keys(from).length === 1 ? from.type : from;
}
module.exports = {

@@ -651,0 +718,0 @@ BoundedQueue: BoundedQueue,

2

package.json
{
"name": "avsc",
"version": "3.3.9",
"version": "3.3.10",
"description": "Avro for JavaScript",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/mtth/avsc",

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