Commit e5b871e1 authored by Ray Bellis's avatar Ray Bellis

cleanups for 0.2 release

parent a64c9020
......@@ -19,7 +19,7 @@ const Code = require('./code');
const crypto = require('crypto');
const inspect = Symbol.for('nodejs.util.inspect.custom');
function checkCode(code)
function parseCode(code)
{
if (code instanceof Code) {
return code;
......@@ -28,7 +28,7 @@ function checkCode(code)
}
}
function checkId(id)
function parseId(id)
{
if (typeof id !== 'number') {
throw new TypeError('id must be a number');
......@@ -41,7 +41,7 @@ function checkId(id)
return id;
}
function checkAuthenticator(authenticator)
function parseAuthenticator(authenticator)
{
if (! (authenticator instanceof Buffer)) {
throw new TypeError('authenticator must be a Buffer');
......@@ -54,7 +54,7 @@ function checkAuthenticator(authenticator)
return authenticator;
}
function checkAttributes(attributes) {
function parseAttributes(attributes) {
if (attributes === undefined || attributes === null) {
return new AttributeList();
} else if (attributes instanceof AttributeList) {
......@@ -88,11 +88,11 @@ class RadiusPacket {
constructor(code, id, authenticator, attrs) {
// check the parameters
code = checkCode(code);
id = checkId(id);
authenticator = checkAuthenticator(authenticator);
attrs = checkAttributes(attrs);
// check and parse the parameters
code = parseCode(code);
id = parseId(id);
authenticator = parseAuthenticator(authenticator);
attrs = parseAttributes(attrs);
/**
* @name RadiusPacket#attributes - the packet authenticator
......@@ -107,7 +107,7 @@ class RadiusPacket {
*/
code: {
get: () => code,
set: (val) => code = checkCode(val),
set: (val) => code = parseCode(val),
enumerable: true,
configurable: true
},
......@@ -127,7 +127,7 @@ class RadiusPacket {
*/
authenticator: {
get: () => authenticator.slice(0),
set: (val) => authenticator = checkAuthenticator(val),
set: (val) => authenticator = parseAuthenticator(val),
enumerable: 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