Throw an error if configure() is called with unrecognised options.
This commit is contained in:
@@ -29,6 +29,13 @@ var common = {
|
||||
return _default;
|
||||
},
|
||||
|
||||
validateOptions: function(options, validKeys) {
|
||||
for (var key in options) {
|
||||
if (validKeys.indexOf(key) < 0)
|
||||
throw new Error('Unrecognized option: ' + key);
|
||||
}
|
||||
},
|
||||
|
||||
validParams: function(params) {
|
||||
var keys = Object.keys(params), i = keys.length;
|
||||
while (i--) {
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var ClientSession = require('./client_session'),
|
||||
ServerSession = require('./server_session');
|
||||
ServerSession = require('./server_session'),
|
||||
common = require('./common');
|
||||
|
||||
var VALID_OPTIONS = [
|
||||
'level',
|
||||
'memLevel',
|
||||
'strategy',
|
||||
'noContextTakeover',
|
||||
'maxWindowBits',
|
||||
'requestNoContextTakeover',
|
||||
'requestMaxWindowBits'
|
||||
];
|
||||
|
||||
var PermessageDeflate = {
|
||||
configure: function(options) {
|
||||
common.validateOptions(options, VALID_OPTIONS);
|
||||
var opts = this._options || {};
|
||||
for (var key in opts) options[key] = opts[key];
|
||||
return Object.create(this, {_options: {value: options}});
|
||||
|
||||
Reference in New Issue
Block a user