* Inject properties from options object. * @private * @param {Object} options
(options)
| 84 | */ |
| 85 | |
| 86 | fromOptions(options) { |
| 87 | assert(options, 'Script data is required.'); |
| 88 | |
| 89 | if (Buffer.isBuffer(options)) |
| 90 | return this.fromRaw(options); |
| 91 | |
| 92 | if (Array.isArray(options)) |
| 93 | return this.fromArray(options); |
| 94 | |
| 95 | if (options.raw) { |
| 96 | if (!options.code) |
| 97 | return this.fromRaw(options.raw); |
| 98 | assert(Buffer.isBuffer(options.raw), 'Raw must be a Buffer.'); |
| 99 | this.raw = options.raw; |
| 100 | } |
| 101 | |
| 102 | if (options.code) { |
| 103 | if (!options.raw) |
| 104 | return this.fromArray(options.code); |
| 105 | assert(Array.isArray(options.code), 'Code must be an array.'); |
| 106 | this.code = options.code; |
| 107 | } |
| 108 | |
| 109 | return this; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Insantiate script from options object. |
no test coverage detected