25 lines
470 B
JavaScript
25 lines
470 B
JavaScript
|
var BufferReader = require('./bufferreader');
|
||
|
var Opcode = require('./opcode');
|
||
|
|
||
|
var Script = function Script(buf) {
|
||
|
if (!(this instanceof Script))
|
||
|
return new Script(buf);
|
||
|
|
||
|
this.chunks = [];
|
||
|
|
||
|
if (Buffer.isBuffer(buf)) {
|
||
|
this.parse(buf);
|
||
|
}
|
||
|
else if (typeof buf !== 'undefined') {
|
||
|
var obj = buf;
|
||
|
this.set(obj);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
Script.prototype.set = function(obj) {
|
||
|
this.chunks = obj.chunks || this.chunks;
|
||
|
return this;
|
||
|
};
|
||
|
|
||
|
module.exports = Script;
|