MCPcopy Index your code
hub / github.com/bcoin-org/bcoin / fromOptions

Method fromOptions

lib/script/script.js:86–110  ·  view source on GitHub ↗

* Inject properties from options object. * @private * @param {Object} options

(options)

Source from the content-addressed store, hash-verified

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.

Callers 1

constructorMethod · 0.95

Calls 2

fromRawMethod · 0.95
fromArrayMethod · 0.95

Tested by

no test coverage detected