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

thriftrw

Package Overview
Dependencies
Maintainers
4
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

thriftrw - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

3

errors.js

@@ -87,4 +87,3 @@ // Copyright (c) 2015 Uber Technologies, Inc.

id: null,
structName: null,
what: null
structName: null
});

@@ -91,0 +90,0 @@

{
"name": "thriftrw",
"version": "2.2.0",
"version": "2.2.1",
"description": "thrift encoding/decoding using bufrw",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -190,2 +190,25 @@ // Copyright (c) 2015 Uber Technologies, Inc.

ThriftStruct.prototype.validateStruct = function validateStruct(struct) {
var self = this;
// Validate required fields
for (var index = 0; index < self.fields.length; index++) {
var field = self.fields[index];
if (!field.required || field.defaultValue != null) {
continue;
}
var value = struct && struct[field.name];
var available = value !== null && value !== undefined;
if (!available) {
return errors.FieldRequiredError({
name: field.name,
id: field.id,
structName: self.name
});
}
}
return null;
};
// The following methods have alternate implementations for Exception and Union.

@@ -385,2 +408,8 @@

// Validate required fields
var err = self.spec.validateStruct(struct);
if (err) {
return new ReadResult(err);
}
return new ReadResult(null, offset, self.spec.finalize(struct));

@@ -387,0 +416,0 @@ };

@@ -83,2 +83,12 @@ // Copyright (c) 2015 Uber Technologies, Inc.

test('complains of missing required field', function t(assert) {
var res = Health.rw.readFrom(new Buffer([
0x00 // typeid:1 -- 0 -- STOP
]), 0);
assert.ok(res.err, 'required field error');
if (!res.err) return;
assert.equal(res.err.message, 'missing required field "ok" with id 1 on Health');
assert.end();
});
test('struct skips unknown void', function t(assert) {

@@ -89,2 +99,5 @@ var res = Health.rw.readFrom(new Buffer([

0x01, // typeid:1 -- 1 -- VOID
0x02, // type:1 -- 2 -- BOOL
0x00, 0x01, // id:2 -- 1 -- ok
0x01, // ok:1 -- 1 -- true
0x00 // typeid:1 -- 0 -- STOP

@@ -95,3 +108,3 @@ ]), 0);

}
assert.deepEqual(res.value, new Health());
assert.deepEqual(res.value, new Health({ok: true}));
assert.end();

@@ -118,2 +131,5 @@ });

var res = Health.rw.readFrom(new Buffer([
0x02, // type:1 -- 2 -- BOOL
0x00, 0x01, // id:2 -- 1 -- ok
0x01, // ok:1 -- 1 -- true
0x02, // type:1 -- 2 -- BOOL

@@ -129,3 +145,3 @@ 0x00, 0x02, // id:2 -- 2 -- WHAT EVEN IS!?

}
assert.deepEqual(res.value, new Health());
assert.deepEqual(res.value, new Health({ok: true}));
assert.end();

@@ -136,2 +152,5 @@ });

var res = Health.rw.readFrom(new Buffer([
0x02, // type:1 -- 2 -- BOOL
0x00, 0x01, // id:2 -- 1 -- ok
0x01, // ok:1 -- 1 -- true
0x02, // type:1 -- 2 -- BOOL

@@ -152,3 +171,3 @@ 0x00, 0x02, // id:2 -- 2 -- WHAT EVEN IS!?

}
assert.deepEqual(res.value, new Health());
assert.deepEqual(res.value, new Health({ok: true}));
assert.end();

@@ -159,6 +178,10 @@ });

var res = Health.rw.readFrom(new Buffer([
0x02, // type:1 -- 2 BOOL
0x00, 0x02, // id:2 -- 2 UNKNOWN
0x0d, // typeid:1 -- 13, map
0x02, // type:1 -- 2 BOOL
0x00, 0x01, // id:2 -- 1 ok
0x01, // ok:1 -- 1 true
0x02, // type:1 -- 2 BOOL
0x00, 0x02, // id:2 -- 2 UNKNOWN
0x0d, // typeid:1 -- 13, map
// Thus begins a large map

@@ -209,3 +232,3 @@ 0x0b, // key_type:1 -- string @ 4

}
assert.deepEqual(res.value, new Health());
assert.deepEqual(res.value, new Health({ok: true}));
assert.end();

@@ -216,2 +239,6 @@ });

var res = Health.rw.readFrom(new Buffer([
0x02, // type:1 -- 2 BOOL
0x00, 0x01, // id:2 -- 1 ok
0x00, // ok:1 -- 0 false
0x02, // type:1 -- 2 BOOL

@@ -243,3 +270,3 @@ 0x00, 0x02, // id:2 -- 2 UNKNOWN

}
assert.deepEqual(res.value, new Health());
assert.deepEqual(res.value, new Health({ok: false}));
assert.end();

@@ -246,0 +273,0 @@ });

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