| 134 | }); |
| 135 | |
| 136 | class Blob { |
| 137 | /** |
| 138 | * @typedef {string|ArrayBuffer|ArrayBufferView|Blob} SourcePart |
| 139 | */ |
| 140 | |
| 141 | /** |
| 142 | * @param {SourcePart[]} [sources] |
| 143 | * @param {{ |
| 144 | * endings? : string, |
| 145 | * type? : string, |
| 146 | * }} [options] |
| 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) |
| 184 | return this; |
| 185 | |
| 186 | const opts = { |
| 187 | ...options, |
| 188 | depth: options.depth == null ? null : options.depth - 1, |
| 189 | }; |
| 190 | |
| 191 | return `Blob ${inspect({ |
| 192 | size: this.size, |
| 193 | type: this.type, |
no outgoing calls
no test coverage detected
searching dependent graphs…