MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / bom

Function bom

scripts/libs/file-saver/index.js:30–48  ·  view source on GitHub ↗
(blob, opts)

Source from the content-addressed store, hash-verified

28 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;
29
30 function bom(blob, opts) {
31 if (typeof opts === 'undefined') opts = {
32 autoBom: false
33 };else if (typeof opts !== 'object') {
34 console.warn('Deprecated: Expected third argument to be a object');
35 opts = {
36 autoBom: !opts
37 };
38 } // prepend BOM for UTF-8 XML and text/* types (including HTML)
39 // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
40
41 if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
42 return new Blob([String.fromCharCode(0xFEFF), blob], {
43 type: blob.type
44 });
45 }
46
47 return blob;
48 }
49
50 function download(url, name, opts) {
51 var xhr = new XMLHttpRequest();

Callers 1

index.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected