MCPcopy Create free account
hub / github.com/hoothin/UserScripts / bom

Function bom

Picviewer CE+/dist.user.js:102–120  ·  view source on GitHub ↗
(blob, opts)

Source from the content-addressed store, hash-verified

100 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;
101
102 function bom(blob, opts) {
103 if (typeof opts === 'undefined') opts = {
104 autoBom: false
105 };else if (typeof opts !== 'object') {
106 console.warn('Deprecated: Expected third argument to be a object');
107 opts = {
108 autoBom: !opts
109 };
110 } // prepend BOM for UTF-8 XML and text/* types (including HTML)
111 // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
112
113 if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
114 return new Blob([String.fromCharCode(0xFEFF), blob], {
115 type: blob.type
116 });
117 }
118
119 return blob;
120 }
121
122 function download(url, name, opts) {
123 var xhr = new XMLHttpRequest();

Callers 1

dist.user.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected