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

protodef

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

protodef - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

15

dist/datatypes/conditional.js
'use strict';
var _objectWithoutProperties = require('babel-runtime/helpers/object-without-properties')['default'];
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

@@ -12,2 +12,3 @@ var _require = require('../utils');

module.exports = {

@@ -28,6 +29,6 @@ 'switch': [readSwitch, writeSwitch, sizeOfSwitch],

compareTo = compareToValue !== undefined ? compareToValue : getField(compareTo, rootNode);
if (typeof fields[compareTo] === 'undefined' && typeof rest['default'] === "undefined") throw new Error(compareTo + " has no associated fieldInfo in switch");
if (typeof fields[compareTo] === 'undefined' && typeof rest.default === "undefined") throw new Error(compareTo + " has no associated fieldInfo in switch");
var caseDefault = typeof fields[compareTo] === 'undefined';
var resultingType = caseDefault ? rest['default'] : fields[compareTo];
var resultingType = caseDefault ? rest.default : fields[compareTo];
var fieldInfo = getFieldInfo(resultingType);

@@ -49,6 +50,6 @@ return tryDoc(function () {

compareTo = compareToValue !== undefined ? compareToValue : getField(compareTo, rootNode);
if (typeof fields[compareTo] === 'undefined' && typeof rest['default'] === "undefined") throw new Error(compareTo + " has no associated fieldInfo in switch");
if (typeof fields[compareTo] === 'undefined' && typeof rest.default === "undefined") throw new Error(compareTo + " has no associated fieldInfo in switch");
var caseDefault = typeof fields[compareTo] === 'undefined';
var fieldInfo = getFieldInfo(caseDefault ? rest['default'] : fields[compareTo]);
var fieldInfo = getFieldInfo(caseDefault ? rest.default : fields[compareTo]);
return tryDoc(function () {

@@ -69,6 +70,6 @@ return _this2.write(value, buffer, offset, fieldInfo, rootNode);

compareTo = compareToValue !== undefined ? compareToValue : getField(compareTo, rootNode);
if (typeof fields[compareTo] === 'undefined' && typeof rest['default'] === "undefined") throw new Error(compareTo + " has no associated fieldInfo in switch");
if (typeof fields[compareTo] === 'undefined' && typeof rest.default === "undefined") throw new Error(compareTo + " has no associated fieldInfo in switch");
var caseDefault = typeof fields[compareTo] === 'undefined';
var fieldInfo = getFieldInfo(caseDefault ? rest['default'] : fields[compareTo]);
var fieldInfo = getFieldInfo(caseDefault ? rest.default : fields[compareTo]);
return tryDoc(function () {

@@ -75,0 +76,0 @@ return _this3.sizeOf(value, fieldInfo, rootNode);

'use strict';
var _Object$keys = require('babel-runtime/core-js/object/keys')['default'];
var _require = require('../utils');

@@ -9,2 +7,3 @@

function readI64(buffer, offset) {

@@ -51,3 +50,3 @@ if (offset + 8 > buffer.length) return null;

var types = _Object$keys(nums).reduce(function (types, num) {
var types = Object.keys(nums).reduce(function (types, num) {
types[num] = generateFunctions(nums[num][0], nums[num][1], nums[num][2]);

@@ -54,0 +53,0 @@ return types;

'use strict';
var _Object$keys = require('babel-runtime/core-js/object/keys')['default'];
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

@@ -10,2 +10,3 @@ var _require = require("../utils");

module.exports = {

@@ -35,3 +36,3 @@ 'array': [readArray, writeArray, sizeOfArray],

var c;
if (typeof count === "number") c = count;else if (typeof count === "object") c = evalCount(count, rootNode);else if (typeof count !== "undefined") c = getField(count, rootNode);else if (typeof countType !== "undefined") {
if (typeof count === "number") c = count;else if ((typeof count === 'undefined' ? 'undefined' : _typeof(count)) === "object") c = evalCount(count, rootNode);else if (typeof count !== "undefined") c = getField(count, rootNode);else if (typeof countType !== "undefined") {
var _tryDoc = tryDoc(function () {

@@ -120,3 +121,3 @@ return _this.read(buffer, offset, { type: countType, typeArgs: countTypeArgs }, rootNode);

if (anon) {
if (readResults.value !== undefined) _Object$keys(readResults.value).forEach(function (key) {
if (readResults.value !== undefined) Object.keys(readResults.value).forEach(function (key) {
results.value[key] = readResults.value[key];

@@ -123,0 +124,0 @@ });

'use strict';
var _Object$keys = require('babel-runtime/core-js/object/keys')['default'];
var assert = require('assert');

@@ -13,2 +11,3 @@

module.exports = {

@@ -46,3 +45,3 @@ 'varint': [readVarInt, writeVarInt, sizeOfVarInt],

var keys = _Object$keys(mappings);
var keys = Object.keys(mappings);
var mappedValue = null;

@@ -63,3 +62,3 @@ for (var i = 0; i < keys.length; i++) {

var keys = _Object$keys(mappings);
var keys = Object.keys(mappings);
var mappedValue = null;

@@ -311,4 +310,5 @@ for (var i = 0; i < keys.length; i++) {

var str = "";
while (offset < buffer.length && buffer[offset] != 0x00) str += buffer[offset++];
if (offset < buffer.length) throw new PartialReadError();else return str;
while (offset < buffer.length && buffer[offset] != 0x00) {
str += buffer[offset++];
}if (offset < buffer.length) throw new PartialReadError();else return str;
}

@@ -315,0 +315,0 @@

'use strict';
var _createClass = require('babel-runtime/helpers/create-class')['default'];
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _classCallCheck = require('babel-runtime/helpers/class-call-check')['default'];
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _Object$keys = require('babel-runtime/core-js/object/keys')['default'];
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -21,3 +21,3 @@ var _require = require('./utils');

function findArgs(acc, v, k) {
if (typeof v === "string" && v.charAt(0) === '$') acc.push({ "path": k, "val": v.substr(1) });else if (Array.isArray(v) || typeof v === "object") acc = acc.concat(reduce(v, findArgs, []).map(function (v) {
if (typeof v === "string" && v.charAt(0) === '$') acc.push({ "path": k, "val": v.substr(1) });else if (Array.isArray(v) || (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === "object") acc = acc.concat(reduce(v, findArgs, []).map(function (v) {
return { "path": k + "." + v.path, "val": v.val };

@@ -55,3 +55,3 @@ }));

var ProtoDef = (function () {
var ProtoDef = function () {
function ProtoDef() {

@@ -61,3 +61,2 @@ _classCallCheck(this, ProtoDef);

this.types = {};
this.addDefaultTypes();

@@ -92,3 +91,3 @@ }

_Object$keys(types).forEach(function (name) {
Object.keys(types).forEach(function (name) {
return _this.addType(name, types[name]);

@@ -185,5 +184,5 @@ });

return ProtoDef;
})();
}();
module.exports = ProtoDef;
//# sourceMappingURL=maps/protodef.js.map
"use strict";
var _get = require("babel-runtime/helpers/get")["default"];
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _inherits = require("babel-runtime/helpers/inherits")["default"];
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _createClass = require("babel-runtime/helpers/create-class")["default"];
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
var _classCallCheck = require("babel-runtime/helpers/class-call-check")["default"];
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

@@ -17,3 +17,3 @@ var Transform = require("readable-stream").Transform;

var Serializer = (function (_Transform) {
var Serializer = function (_Transform) {
_inherits(Serializer, _Transform);

@@ -24,6 +24,8 @@

_get(Object.getPrototypeOf(Serializer.prototype), "constructor", this).call(this, { writableObjectMode: true });
this.proto = proto;
this.mainType = mainType;
this.queue = new Buffer(0);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Serializer).call(this, { writableObjectMode: true }));
_this.proto = proto;
_this.mainType = mainType;
_this.queue = new Buffer(0);
return _this;
}

@@ -50,5 +52,5 @@

return Serializer;
})(Transform);
}(Transform);
var Parser = (function (_Transform2) {
var Parser = function (_Transform2) {
_inherits(Parser, _Transform2);

@@ -59,6 +61,8 @@

_get(Object.getPrototypeOf(Parser.prototype), "constructor", this).call(this, { readableObjectMode: true });
this.proto = proto;
this.mainType = mainType;
this.queue = new Buffer(0);
var _this2 = _possibleConstructorReturn(this, Object.getPrototypeOf(Parser).call(this, { readableObjectMode: true }));
_this2.proto = proto;
_this2.mainType = mainType;
_this2.queue = new Buffer(0);
return _this2;
}

@@ -82,3 +86,3 @@

} catch (e) {
if (e instanceof PartialReadError) return cb();else {
if (e.partialReadError) return cb();else {
e.buffer = this.queue;

@@ -94,3 +98,3 @@ this.queue = new Buffer(0);

return Parser;
})(Transform);
}(Transform);

@@ -97,0 +101,0 @@ module.exports = {

"use strict";
var _get = require("babel-runtime/helpers/get")["default"];
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _inherits = require("babel-runtime/helpers/inherits")["default"];
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
var _classCallCheck = require("babel-runtime/helpers/class-call-check")["default"];
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

@@ -13,7 +13,9 @@ function getField(countField, context) {

if (countFieldArr[i] === "") {
while (context.hasOwnProperty("..")) context = context[".."];
i++;
while (context.hasOwnProperty("..")) {
context = context[".."];
}i++;
}
for (; i < countFieldArr.length; i++) context = context[countFieldArr[i]];
return context;
for (; i < countFieldArr.length; i++) {
context = context[countFieldArr[i]];
}return context;
}

@@ -44,3 +46,3 @@

var ExtendableError = (function (_Error) {
var ExtendableError = function (_Error) {
_inherits(ExtendableError, _Error);

@@ -51,12 +53,14 @@

_get(Object.getPrototypeOf(ExtendableError.prototype), "constructor", this).call(this, message);
this.name = this.constructor.name;
this.message = message;
Error.captureStackTrace(this, this.constructor.name);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ExtendableError).call(this, message));
_this.name = _this.constructor.name;
_this.message = message;
Error.captureStackTrace(_this, _this.constructor.name);
return _this;
}
return ExtendableError;
})(Error);
}(Error);
var PartialReadError = (function (_ExtendableError) {
var PartialReadError = function (_ExtendableError) {
_inherits(PartialReadError, _ExtendableError);

@@ -67,7 +71,10 @@

_get(Object.getPrototypeOf(PartialReadError.prototype), "constructor", this).call(this, message);
var _this2 = _possibleConstructorReturn(this, Object.getPrototypeOf(PartialReadError).call(this, message));
_this2.partialReadError = true;
return _this2;
}
return PartialReadError;
})(ExtendableError);
}(ExtendableError);

@@ -74,0 +81,0 @@ module.exports = {

# History
## 1.1.0
* update to babel6, remove some dependencies
## 1.0.3

@@ -4,0 +8,0 @@

@@ -6,4 +6,4 @@ var gulp = require('gulp');

var options = {
stage: 0, // Dat ES7 goodness
optional: ["runtime"]
presets: ['es2015'],
"plugins": ["transform-object-rest-spread"]
};

@@ -10,0 +10,0 @@

{
"name": "protodef",
"version": "1.0.3",
"version": "1.1.0",
"description": "A simple yet powerful way to define binary protocols",

@@ -9,3 +9,3 @@ "main": "index.js",

"prepublish": "gulp && require-self",
"test": "mocha --recursive --require intelli-espower-loader --require source-map-support/register --reporter spec"
"test": "mocha --recursive --require source-map-support/register --reporter spec"
},

@@ -15,7 +15,8 @@ "tonicExampleFilename": "example.js",

"dependencies": {
"babel-runtime": "^5.4.4",
"lodash.reduce": "^3.1.2",
"yargs": "^1.3.1",
"lodash.reduce": "^4.2.0",
"readable-stream": "^1.1.0"
},
"engines": {
"node": ">=4"
},
"bugs": {

@@ -30,14 +31,13 @@ "url": "https://github.com/roblabla/ProtoDef/issues"

"devDependencies": {
"babel-plugin-transform-object-rest-spread": "^6.5.0",
"babel-preset-es2015": "^6.5.0",
"chai": "^1.9.2",
"gulp": "^3.8.11",
"gulp-babel": "^5.1.0",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.2",
"gulp-plumber": "^1.0.1",
"gulp-sourcemaps": "^1.3.0",
"intelli-espower-loader": "^1.0.0",
"gulp-sourcemaps": "^1.6.0",
"mocha": "^1.21.5",
"power-assert": "^1.0.0",
"require-self": "^0.1.0",
"sinon": "^1.11.1",
"source-map-support": "^0.3.2"
}
}

@@ -50,5 +50,4 @@ var { getFieldInfo, tryCatch } = require('./utils');

{
types={};
constructor() {
this.types={};
this.addDefaultTypes();

@@ -55,0 +54,0 @@ }

@@ -48,3 +48,3 @@ var Transform = require("readable-stream").Transform;

} catch (e) {
if (e instanceof PartialReadError)
if (e.partialReadError)
return cb();

@@ -51,0 +51,0 @@ else {

@@ -51,2 +51,3 @@

super(message);
this.partialReadError=true;
}

@@ -53,0 +54,0 @@ }

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

var assert = require('power-assert');
var assert = require('chai').assert;
var expect = require('chai').expect;

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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