MCPcopy Index your code
hub / github.com/hoothin/UserScripts / bom

Function bom

DownloadAllContent/DownloadAllContent.user.js:69–86  ·  view source on GitHub ↗
(blob, opts)

Source from the content-addressed store, hash-verified

67 var _global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof global === 'object' && global.global === global ? global : void 0;
68
69 function bom(blob, opts) {
70 if (typeof opts === 'undefined') opts = {
71 autoBom: false
72 };else if (typeof opts !== 'object') {
73 console.warn('Deprecated: Expected third argument to be a object');
74 opts = {
75 autoBom: !opts
76 };
77 }
78
79 if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
80 return new Blob([String.fromCharCode(0xFEFF), blob], {
81 type: blob.type
82 });
83 }
84
85 return blob;
86 }
87
88 function download(url, name, opts) {
89 var xhr = new XMLHttpRequest();

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected