| ; | |
| Object.defineProperty(exports, "__esModule", { | |
| value: true | |
| }); | |
| exports.parse = parse; | |
| exports.parseBibtex = parseBibtex; | |
| var _config = _interopRequireDefault(require("../config.js")); | |
| var _index = require("../mapping/index.js"); | |
| var _value = require("./value.js"); | |
| var _constants = require("./constants.js"); | |
| function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | |
| function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | |
| function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } | |
| function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } | |
| function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } | |
| function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } | |
| function validate(entries, requirements) { | |
| const problems = []; | |
| for (const { | |
| type, | |
| label, | |
| properties | |
| } of entries) { | |
| if (type in requirements) { | |
| const missing = []; | |
| for (const field of requirements[type]) { | |
| if (Array.isArray(field) && !field.some(field => field in properties)) { | |
| missing.push(field.join('/')); | |
| } else if (typeof field === 'string' && !(field in properties)) { | |
| missing.push(field); | |
| } | |
| } | |
| if (missing.length) { | |
| problems.push([label, `missing fields: ${missing.join(', ')}`]); | |
| } | |
| } else { | |
| problems.push([label, `invalid type: "${type}"`]); | |
| } | |
| } | |
| if (problems.length) { | |
| throw new RangeError(['Invalid entries:'].concat(problems.map(([label, problem]) => ` - ${label} has ${problem}`)).join('\n')); | |
| } | |
| } | |
| function parseEntryValues(entry) { | |
| const output = {}; | |
| if ('language' in entry.properties) { | |
| output.language = (0, _value.parse)(entry.properties.language, 'language'); | |
| } | |
| for (const property in entry.properties) { | |
| const value = entry.properties[property]; | |
| if (value === '') { | |
| continue; | |
| } | |
| output[property] = (0, _value.parse)(value + '', property, output.language); | |
| } | |
| for (const property in entry.annotations) { | |
| for (const annotation in entry.annotations[property]) { | |
| output[property + '+an:' + annotation] = (0, _value.parseAnnotation)(entry.annotations[property][annotation]); | |
| } | |
| } | |
| return _objectSpread(_objectSpread({}, entry), {}, { | |
| properties: output | |
| }); | |
| } | |
| function parse(entries) { | |
| if (_config.default.parse.strict) { | |
| validate(entries, _constants.required.biblatex); | |
| } | |
| return (0, _index.parse)(entries.map(parseEntryValues)); | |
| } | |
| function parseBibtex(entries) { | |
| if (_config.default.parse.strict) { | |
| validate(entries, _constants.required.bibtex); | |
| } | |
| return (0, _index.parseBibtex)(entries.map(parseEntryValues)); | |
| } |
Xet Storage Details
- Size:
- 3.64 kB
- Xet hash:
- 2e0cdddabc9417553f4c45f755adc256a728d6c50cca179538a3d74d5eeb6bd2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.