MCPcopy Index your code
hub / github.com/nodejs/node / constructor

Method constructor

lib/internal/blob.js:149–180  ·  view source on GitHub ↗

* @param {SourcePart[]} [sources] * @param {{ * endings? : string, * type? : string, * }} [options] * @constructs Blob

(sources = [], options)

Source from the content-addressed store, hash-verified

147 * @constructs Blob
148 */
149 constructor(sources = [], options) {
150 markTransferMode(this, true, false);
151
152 const sources_ = sourcesConverter(sources);
153
154 validateDictionary(options, 'options');
155 let {
156 endings = 'transparent',
157 type = '',
158 } = options ?? kEmptyObject;
159
160 endings = `${endings}`;
161 if (endings !== 'transparent' && endings !== 'native')
162 throw new ERR_INVALID_ARG_VALUE('options.endings', endings);
163
164 let length = 0;
165 for (let i = 0; i < sources_.length; ++i) {
166 const { 0: len, 1: src } = getSource(sources_[i], endings);
167 length += len;
168 sources_[i] = src;
169 }
170
171 if (length > kMaxLength)
172 throw new ERR_BUFFER_TOO_LARGE(kMaxLength);
173
174 this[kHandle] = _createBlob(sources_, length);
175 this[kLength] = length;
176
177 type = `${type}`;
178 this[kType] = RegExpPrototypeExec(disallowedTypeCharacters, type) !== null ?
179 '' : StringPrototypeToLowerCase(type);
180 }
181
182 [kInspect](depth, options) {
183 if (depth < 0)

Callers

nothing calls this directly

Calls 3

markTransferModeFunction · 0.85
validateDictionaryFunction · 0.85
getSourceFunction · 0.70

Tested by

no test coverage detected