Commit e5b871e1 authored by Ray Bellis's avatar Ray Bellis
Browse files

cleanups for 0.2 release

parent a64c9020
...@@ -19,7 +19,7 @@ const Code = require('./code'); ...@@ -19,7 +19,7 @@ const Code = require('./code');
const crypto = require('crypto'); const crypto = require('crypto');
const inspect = Symbol.for('nodejs.util.inspect.custom'); const inspect = Symbol.for('nodejs.util.inspect.custom');
function checkCode(code) function parseCode(code)
{ {
if (code instanceof Code) { if (code instanceof Code) {
return code; return code;
...@@ -28,7 +28,7 @@ function checkCode(code) ...@@ -28,7 +28,7 @@ function checkCode(code)
} }
} }
function checkId(id) function parseId(id)
{ {
if (typeof id !== 'number') { if (typeof id !== 'number') {
throw new TypeError('id must be a number'); throw new TypeError('id must be a number');
...@@ -41,7 +41,7 @@ function checkId(id) ...@@ -41,7 +41,7 @@ function checkId(id)
return id; return id;
} }
function checkAuthenticator(authenticator) function parseAuthenticator(authenticator)
{ {
if (! (authenticator instanceof Buffer)) { if (! (authenticator instanceof Buffer)) {
throw new TypeError('authenticator must be a Buffer'); throw new TypeError('authenticator must be a Buffer');
...@@ -54,7 +54,7 @@ function checkAuthenticator(authenticator) ...@@ -54,7 +54,7 @@ function checkAuthenticator(authenticator)
return authenticator; return authenticator;
} }
function checkAttributes(attributes) { function parseAttributes(attributes) {
if (attributes === undefined || attributes === null) { if (attributes === undefined || attributes === null) {
return new AttributeList(); return new AttributeList();
} else if (attributes instanceof AttributeList) { } else if (attributes instanceof AttributeList) {
...@@ -88,11 +88,11 @@ class RadiusPacket { ...@@ -88,11 +88,11 @@ class RadiusPacket {
constructor(code, id, authenticator, attrs) { constructor(code, id, authenticator, attrs) {
// check the parameters // check and parse the parameters
code = checkCode(code); code = parseCode(code);
id = checkId(id); id = parseId(id);
authenticator = checkAuthenticator(authenticator); authenticator = parseAuthenticator(authenticator);
attrs = checkAttributes(attrs); attrs = parseAttributes(attrs);
/** /**
* @name RadiusPacket#attributes - the packet authenticator * @name RadiusPacket#attributes - the packet authenticator
...@@ -107,7 +107,7 @@ class RadiusPacket { ...@@ -107,7 +107,7 @@ class RadiusPacket {
*/ */
code: { code: {
get: () => code, get: () => code,
set: (val) => code = checkCode(val), set: (val) => code = parseCode(val),
enumerable: true, enumerable: true,
configurable: true configurable: true
}, },
...@@ -127,7 +127,7 @@ class RadiusPacket { ...@@ -127,7 +127,7 @@ class RadiusPacket {
*/ */
authenticator: { authenticator: {
get: () => authenticator.slice(0), get: () => authenticator.slice(0),
set: (val) => authenticator = checkAuthenticator(val), set: (val) => authenticator = parseAuthenticator(val),
enumerable: true, enumerable: true,
configurable: true configurable: true
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment