UNPKG

feeles-ide

Version:

The hackable and serializable IDE to make learning material

65 lines (55 loc) 1.97 kB
import _regeneratorRuntime from 'babel-runtime/regenerator'; import _asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator'; var _this = this; import { BinaryFile, SourceFile, validateType } from './'; export default (function () { var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(script) { var name, type, options, credits, lastModified, composed; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: _context.next = 2; return 1; case 2: // Be asynchronus. name = script.getAttribute('name'); type = script.getAttribute('data-type'); options = { isTrashed: script.hasAttribute('is-trashed') }; credits = script.hasAttribute('data-credits') ? JSON.parse(script.getAttribute('data-credits')) : []; lastModified = +script.getAttribute('data-last-modified') || 0; composed = script.textContent; if (!validateType('blob', type)) { _context.next = 12; break; } return _context.abrupt('return', new BinaryFile({ type: type, name: name, options: options, credits: credits, lastModified: lastModified, composed: composed })); case 12: return _context.abrupt('return', new SourceFile({ type: type, name: name, options: options, credits: credits, lastModified: lastModified, composed: composed })); case 13: case 'end': return _context.stop(); } } }, _callee, _this); })); return function (_x) { return _ref.apply(this, arguments); }; })();