throw error when input to script constructor is not an array

[]
This commit is contained in:
Wei Lu 2014-03-09 13:43:36 +08:00
parent 8a2a9cb4e7
commit d2b790fef9
2 changed files with 20 additions and 0 deletions

View file

@ -6,6 +6,9 @@ var network = require('./network');
var Script = function(data) {
this.buffer = data || [];
if(!Array.isArray(data)) {
throw new Error('expect Script to be initialized with Array, but got ' + data)
}
this.parse();
};