Sha256: 55e489bed0c103fda5a202bfc266a787d553beaf6db7aada489be3d52fcc2fcb
Contents?: true
Size: 1.12 KB
Versions: 8
Compression:
Stored size: 1.12 KB
Contents
(function (self) { var $root, $meta, $cache; if (typeof document === 'object') { $meta = document.querySelector('[name=fixture_root]'); $root = $meta && $meta.content; } $root || ($root = '/assets/fixtures/'); $cache = {}; function download(path) { return new Promise(function (resolve, reject) { var xhr = new XMLHttpRequest(); xhr.open('GET', $root + path, true); xhr.onload = function (_e) { var result; if (xhr.readyState === 4) { result = xhr.responseText; if (xhr.status === 200) { if (/\.json$/.test(path)) { try { result = JSON.parse(result); } catch (error) { console.warn('JSON parse error:', error) } } resolve(result); } else { reject(xhr.statusText); } } }; xhr.onerror = function (_error) { reject(xhr.statusText); }; xhr.send(null); }); } function fixture(path) { return $cache[path] || ($cache[path] = download(path)); } self.fixture = fixture; })(this);
Version data entries
8 entries across 8 versions & 1 rubygems