citation-js
Version:
Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
1,038 lines (998 loc) • 3.5 MB
JavaScript
require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function async(data, options, callback) {
if (typeof options === 'function' && !callback) {
callback = options;
options = undefined;
}
var promise = new this().setAsync(data, options);
if (typeof callback === 'function') {
promise.then(callback);
return undefined;
} else {
return promise;
}
}
var _default = exports["default"] = async;
},{}],2:[function(require,module,exports){
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.format = format;
exports.get = get;
exports.getIds = getIds;
var _validate = require("./validate.js");
var _output = require("../plugins/output.js");
var _csl = require("../plugins/input/csl.js");
function getIds() {
return this.data.map(function (entry) {
return entry.id;
});
}
function format(format) {
for (var _len = arguments.length, options = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
options[_key - 1] = arguments[_key];
}
return (0, _output.format).apply(void 0, [format, (0, _csl.clean)(this.data)].concat(options));
}
function get() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _validate.validateOutputOptions)(options);
var parsedOptions = Object.assign({}, this.defaultOptions, this._options.output, options);
var type = parsedOptions.type,
style = parsedOptions.style;
var _style$split = style.split('-'),
_style$split2 = _slicedToArray(_style$split, 2),
styleType = _style$split2[0],
styleFormat = _style$split2[1];
var newStyle = styleType === 'citation' ? 'bibliography' : styleType === 'csl' ? 'data' : styleType;
var newType = type === 'string' ? 'text' : type === 'json' ? 'object' : type;
var formatOptions;
switch (newStyle) {
case 'bibliography':
{
var lang = parsedOptions.lang,
append = parsedOptions.append,
prepend = parsedOptions.prepend;
formatOptions = {
template: styleFormat,
lang: lang,
format: newType,
append: append,
prepend: prepend
};
break;
}
case 'data':
case 'bibtex':
case 'bibtxt':
case 'ndjson':
case 'ris':
formatOptions = {
type: newType
};
break;
default:
throw new Error("Invalid style \"".concat(newStyle, "\""));
}
var result = this.format(newStyle, Object.assign(formatOptions, options._newOptions));
var format = parsedOptions.format;
if (format === 'real' && newType === 'html' && typeof document !== 'undefined' && typeof document.createElement === 'function') {
var tmp = document.createElement('div');
tmp.innerHTML = result;
return tmp.firstChild;
} else if (format === 'string' && _typeof(result) === 'object') {
return JSON.stringify(result);
} else {
return result;
}
}
},{"../plugins/input/csl.js":25,"../plugins/output.js":33,"./validate.js":9}],3:[function(require,module,exports){
"use strict";
function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var log = _interopRequireWildcard(require("./log.js"));
var options = _interopRequireWildcard(require("./options.js"));
var set = _interopRequireWildcard(require("./set.js"));
var sort = _interopRequireWildcard(require("./sort.js"));
var get = _interopRequireWildcard(require("./get.js"));
var staticMethods = _interopRequireWildcard(require("./static.js"));
function _getRequireWildcardCache(e) {
if ("function" != typeof WeakMap) return null;
var r = new WeakMap(),
t = new WeakMap();
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
return e ? t : r;
})(e);
}
function _interopRequireWildcard(e, r) {
if (!r && e && e.__esModule) return e;
if (null === e || "object" != _typeof(e) && "function" != typeof e) return {
"default": e
};
var t = _getRequireWildcardCache(r);
if (t && t.has(e)) return t.get(e);
var n = {
__proto__: null
},
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
}
return n["default"] = e, t && t.set(e, n), n;
}
function Cite(data) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (!(this instanceof Cite)) {
return new Cite(data, options);
}
this._options = options;
this.log = [];
this.data = [];
this.set(data, options);
this.options(options);
return this;
}
Object.assign(Cite.prototype, log, options, set, sort, get);
Cite.prototype[Symbol.iterator] = _regenerator().m(function _callee() {
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
return _context.d(_regeneratorValues(this.data), 1);
case 1:
return _context.a(2);
}
}, _callee, this);
});
Object.assign(Cite, staticMethods);
var _default = exports["default"] = Cite;
},{"./get.js":2,"./log.js":4,"./options.js":5,"./set.js":6,"./sort.js":7,"./static.js":8}],4:[function(require,module,exports){
"use strict";
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.currentVersion = currentVersion;
exports.retrieveLastVersion = retrieveLastVersion;
exports.retrieveVersion = retrieveVersion;
exports.save = save;
exports.undo = undo;
function currentVersion() {
return this.log.length;
}
function retrieveVersion() {
var versnum = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
if (versnum <= 0 || versnum > this.currentVersion()) {
return null;
} else {
var _this$log = _slicedToArray(this.log[versnum - 1], 2),
data = _this$log[0],
options = _this$log[1];
var image = new this.constructor(JSON.parse(data), JSON.parse(options));
image.log = this.log.slice(0, versnum);
return image;
}
}
function undo() {
var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
return this.retrieveVersion(this.currentVersion() - number);
}
function retrieveLastVersion() {
return this.retrieveVersion(this.currentVersion());
}
function save() {
this.log.push([JSON.stringify(this.data), JSON.stringify(this._options)]);
return this;
}
},{}],5:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.defaultOptions = void 0;
exports.options = options;
var _validate = require("./validate.js");
var defaultOptions = exports.defaultOptions = {
format: 'real',
type: 'json',
style: 'csl',
lang: 'en-US'
};
function options(options, log) {
(0, _validate.validateOutputOptions)(options);
if (log) {
this.save();
}
Object.assign(this._options, options);
return this;
}
},{"./validate.js":9}],6:[function(require,module,exports){
"use strict";
function _regenerator() { var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.add = add;
exports.addAsync = addAsync;
exports.reset = reset;
exports.set = set;
exports.setAsync = setAsync;
var _index = require("../plugins/input/index.js");
var _fetchId = _interopRequireDefault(require("../util/fetchId.js"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
function add(data) {
var _this$data,
_this = this;
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var log = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (options === true || log === true) {
this.save();
}
(_this$data = this.data).push.apply(_this$data, _toConsumableArray((0, _index.chain)(data, options)));
this.data.filter(function (entry) {
return !Object.prototype.hasOwnProperty.call(entry, 'id');
}).forEach(function (entry) {
entry.id = (0, _fetchId["default"])(_this.getIds(), 'temp_id_');
});
return this;
}
function addAsync(_x) {
return _addAsync.apply(this, arguments);
}
function _addAsync() {
_addAsync = _asyncToGenerator(_regenerator().m(function _callee(data) {
var _this$data2,
_this2 = this;
var options,
log,
_args = arguments,
_t,
_t2,
_t3;
return _regenerator().w(function (_context) {
while (1) switch (_context.n) {
case 0:
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
log = _args.length > 2 && _args[2] !== undefined ? _args[2] : false;
if (options === true || log === true) {
this.save();
}
_t = (_this$data2 = this.data).push;
_t2 = _this$data2;
_t3 = _toConsumableArray;
_context.n = 1;
return (0, _index.chainAsync)(data, options);
case 1:
_t.apply.call(_t, _t2, _t3(_context.v));
this.data.filter(function (entry) {
return !Object.prototype.hasOwnProperty.call(entry, 'id');
}).forEach(function (entry) {
entry.id = (0, _fetchId["default"])(_this2.getIds(), 'temp_id_');
});
return _context.a(2, this);
}
}, _callee, this);
}));
return _addAsync.apply(this, arguments);
}
function set(data) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var log = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (options === true || log === true) {
this.save();
}
this.data = [];
return typeof options !== 'boolean' ? this.add(data, options) : this.add(data);
}
function setAsync(_x2) {
return _setAsync.apply(this, arguments);
}
function _setAsync() {
_setAsync = _asyncToGenerator(_regenerator().m(function _callee2(data) {
var options,
log,
_args2 = arguments;
return _regenerator().w(function (_context2) {
while (1) switch (_context2.n) {
case 0:
options = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
log = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : false;
if (options === true || log === true) {
this.save();
}
this.data = [];
return _context2.a(2, typeof options !== 'boolean' ? this.addAsync(data, options) : this.addAsync(data));
}
}, _callee2, this);
}));
return _setAsync.apply(this, arguments);
}
function reset(log) {
if (log) {
this.save();
}
this.data = [];
this._options = {};
return this;
}
},{"../plugins/input/index.js":29,"../util/fetchId.js":37}],7:[function(require,module,exports){
"use strict";
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.sort = sort;
var _label = require("../plugin-common/output/label.js");
var _name = require("@citation-js/name");
function getComparisonValue(obj, prop) {
var label = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : prop === 'label';
var value = label ? (0, _label.getLabel)(obj) : obj[prop];
switch (prop) {
case 'author':
case 'editor':
return value.map(function (name) {
return name.literal || name.family || (0, _name.format)(name);
});
case 'accessed':
case 'issued':
return value['date-parts'][0];
case 'page':
return value.split('-').map(function (num) {
return parseInt(num);
});
case 'edition':
case 'issue':
case 'volume':
value = parseInt(value);
return !isNaN(value) ? value : -Infinity;
default:
return value || -Infinity;
}
}
function compareProp(entryA, entryB, prop) {
var flip = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : /^!/.test(prop);
prop = prop.replace(/^!/, '');
var a = getComparisonValue(entryA, prop);
var b = getComparisonValue(entryB, prop);
return (flip ? -1 : 1) * (a > b ? 1 : a < b ? -1 : 0);
}
function getSortCallback() {
for (var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++) {
props[_key] = arguments[_key];
}
return function (a, b) {
var keys = props.slice();
var output = 0;
while (!output && keys.length) {
output = compareProp(a, b, keys.shift());
}
return output;
};
}
function sort() {
var method = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var log = arguments.length > 1 ? arguments[1] : undefined;
if (log) {
this.save();
}
this.data.sort(typeof method === 'function' ? method : getSortCallback.apply(void 0, _toConsumableArray(method).concat(['label'])));
return this;
}
},{"../plugin-common/output/label.js":20,"@citation-js/name":47}],8:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
async: true
};
Object.defineProperty(exports, "async", {
enumerable: true,
get: function get() {
return _async["default"];
}
});
var _async = _interopRequireDefault(require("./async.js"));
var _validate = require("./validate.js");
Object.keys(_validate).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _validate[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _validate[key];
}
});
});
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
},{"./async.js":1,"./validate.js":9}],9:[function(require,module,exports){
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.validateOptions = validateOptions;
exports.validateOutputOptions = validateOutputOptions;
var formats = ['real', 'string'];
var types = ['json', 'html', 'string', 'rtf'];
var styles = ['csl', 'bibtex', 'bibtxt', 'citation-*', 'ris', 'ndjson'];
var wrapperTypes = ['string', 'function'];
function validateOutputOptions(options) {
if (_typeof(options) !== 'object') {
throw new TypeError('Options not an object!');
}
var format = options.format,
type = options.type,
style = options.style,
lang = options.lang,
append = options.append,
prepend = options.prepend;
if (format && !formats.includes(format)) {
throw new TypeError("Option format (\"".concat(format, "\") should be one of: ").concat(formats));
} else if (type && !types.includes(type)) {
throw new TypeError("Option type (\"".concat(type, "\") should be one of: ").concat(types));
} else if (style && !styles.includes(style) && !/^citation/.test(style)) {
throw new TypeError("Option style (\"".concat(style, "\") should be one of: ").concat(styles));
} else if (lang && typeof lang !== 'string') {
throw new TypeError("Option lang should be a string, but is a ".concat(_typeof(lang)));
} else if (prepend && !wrapperTypes.includes(_typeof(prepend))) {
throw new TypeError("Option prepend should be a string or a function, but is a ".concat(_typeof(prepend)));
} else if (append && !wrapperTypes.includes(_typeof(append))) {
throw new TypeError("Option append should be a string or a function, but is a ".concat(_typeof(append)));
}
if (/^citation/.test(style) && type === 'json') {
throw new Error("Combination type/style of json/citation-* is not valid: ".concat(type, "/").concat(style));
}
return true;
}
function validateOptions(options) {
if (_typeof(options) !== 'object') {
throw new TypeError('Options should be an object');
}
if (options.output) {
validateOutputOptions(options.output);
} else if (options.maxChainLength && typeof options.maxChainLength !== 'number') {
throw new TypeError('Option maxChainLength should be a number');
} else if (options.forceType && typeof options.forceType !== 'string') {
throw new TypeError('Option forceType should be a string');
} else if (options.generateGraph != null && typeof options.generateGraph !== 'boolean') {
throw new TypeError('Option generateGraph should be a boolean');
} else if (options.strict != null && typeof options.strict !== 'boolean') {
throw new TypeError('Option strict should be a boolean');
} else if (options.target != null && typeof options.target !== 'string') {
throw new TypeError('Option target should be a boolean');
}
return true;
}
},{}],10:[function(require,module,exports){
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "Cite", {
enumerable: true,
get: function get() {
return _index["default"];
}
});
Object.defineProperty(exports, "logger", {
enumerable: true,
get: function get() {
return _logger["default"];
}
});
exports.version = exports.util = exports.plugins = void 0;
var _index = _interopRequireDefault(require("./Cite/index.js"));
var plugins = _interopRequireWildcard(require("./plugins/index.js"));
exports.plugins = plugins;
var util = _interopRequireWildcard(require("./util/index.js"));
exports.util = util;
var _logger = _interopRequireDefault(require("./logger.js"));
var _package = _interopRequireDefault(require("../package.json"));
require("./plugin-common/index.js");
function _getRequireWildcardCache(e) {
if ("function" != typeof WeakMap) return null;
var r = new WeakMap(),
t = new WeakMap();
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
return e ? t : r;
})(e);
}
function _interopRequireWildcard(e, r) {
if (!r && e && e.__esModule) return e;
if (null === e || "object" != _typeof(e) && "function" != typeof e) return {
"default": e
};
var t = _getRequireWildcardCache(r);
if (t && t.has(e)) return t.get(e);
var n = {
__proto__: null
},
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
}
return n["default"] = e, t && t.set(e, n), n;
}
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
var version = exports.version = _package["default"].version;
},{"../package.json":43,"./Cite/index.js":3,"./logger.js":11,"./plugin-common/index.js":12,"./plugins/index.js":23,"./util/index.js":39}],11:[function(require,module,exports){
(function (process){(function (){
"use strict";
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var logger = {
_output: function _output(level, scope, msg) {
var _this$_console;
this._log.push(scope, msg);
if (this._levels.indexOf(level) < this._levels.indexOf(this.level)) {
return;
}
(_this$_console = this._console).log.apply(_this$_console, [scope].concat(_toConsumableArray(msg)));
},
_console: null,
_log: [],
_levels: ['http', 'debug', 'unmapped', 'info', 'warn', 'error', 'silent'],
level: 'silent'
};
var _iterator = _createForOfIteratorHelper(logger._levels),
_step;
try {
var _loop = function _loop() {
var level = _step.value;
logger[level] = function (scope) {
for (var _len = arguments.length, msg = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
msg[_key - 1] = arguments[_key];
}
return logger._output(level, scope, msg);
};
};
for (_iterator.s(); !(_step = _iterator.n()).done;) {
_loop();
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (typeof console.Console === 'function') {
logger._console = new console.Console(process.stderr);
} else {
logger._console = console;
}
var _default = exports["default"] = logger;
}).call(this)}).call(this,require('_process'))
},{"_process":742}],12:[function(require,module,exports){
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var plugins = _interopRequireWildcard(require("../plugins"));
var _input = require("./input/");
var _output = _interopRequireDefault(require("./output/"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
function _getRequireWildcardCache(e) {
if ("function" != typeof WeakMap) return null;
var r = new WeakMap(),
t = new WeakMap();
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
return e ? t : r;
})(e);
}
function _interopRequireWildcard(e, r) {
if (!r && e && e.__esModule) return e;
if (null === e || "object" != _typeof(e) && "function" != typeof e) return {
"default": e
};
var t = _getRequireWildcardCache(r);
if (t && t.has(e)) return t.get(e);
var n = {
__proto__: null
},
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
}
return n["default"] = e, t && t.set(e, n), n;
}
plugins.add(_input.ref, {
input: _input.formats,
output: _output["default"]
});
},{"../plugins":23,"./input/":15,"./output/":18}],13:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parse = parse;
function parse() {
return [];
}
},{}],14:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parse = parse;
function parse(input) {
return input.value || input.textContent;
}
},{}],15:[function(require,module,exports){
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ref = exports.parsers = exports.formats = void 0;
var empty = _interopRequireWildcard(require("./empty.js"));
var json = _interopRequireWildcard(require("./json.js"));
var jquery = _interopRequireWildcard(require("./jquery.js"));
var html = _interopRequireWildcard(require("./html.js"));
function _getRequireWildcardCache(e) {
if ("function" != typeof WeakMap) return null;
var r = new WeakMap(),
t = new WeakMap();
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
return e ? t : r;
})(e);
}
function _interopRequireWildcard(e, r) {
if (!r && e && e.__esModule) return e;
if (null === e || "object" != _typeof(e) && "function" != typeof e) return {
"default": e
};
var t = _getRequireWildcardCache(r);
if (t && t.has(e)) return t.get(e);
var n = {
__proto__: null
},
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
}
return n["default"] = e, t && t.set(e, n), n;
}
var ref = exports.ref = '@else';
var parsers = exports.parsers = {
empty: empty,
json: json,
jquery: jquery,
html: html
};
var formats = exports.formats = {
'@empty/text': {
parse: empty.parse,
parseType: {
dataType: 'String',
predicate: function predicate(input) {
return input === '';
}
}
},
'@empty/whitespace+text': {
parse: empty.parse,
parseType: {
dataType: 'String',
predicate: /^\s+$/
}
},
'@empty': {
parse: empty.parse,
parseType: {
dataType: 'Primitive',
predicate: function predicate(input) {
return input == null;
}
}
},
'@else/json': {
parse: json.parse,
parseType: {
dataType: 'String',
predicate: /^\s*(\{[\S\s]*\}|\[[\S\s]*\])\s*$/
}
},
'@else/url': {
parseType: {
dataType: 'String',
predicate: /^https?:\/\/(([\w-]+\.)*[\w-]+)(:\d+)?(\/[^?/]*)*(\?[^#]*)?(#.*)?$/i
}
},
'@else/jquery': {
parse: jquery.parse,
parseType: {
dataType: 'ComplexObject',
predicate: function predicate(input) {
return typeof jQuery !== 'undefined' && input instanceof jQuery;
}
}
},
'@else/html': {
parse: html.parse,
parseType: {
dataType: 'ComplexObject',
predicate: function predicate(input) {
return typeof HTMLElement !== 'undefined' && input instanceof HTMLElement;
}
}
}
};
},{"./empty.js":13,"./html.js":14,"./jquery.js":16,"./json.js":17}],16:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parse = parse;
function parse(input) {
return input.val() || input.text() || input.html();
}
},{}],17:[function(require,module,exports){
"use strict";
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.parse = parseJSON;
var _logger = _interopRequireDefault(require("../../logger.js"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
var substituters = [[/((?:\[|:|,)\s*)'((?:\\'|[^'])*?[^\\])?'(?=\s*(?:\]|}|,))/g, '$1"$2"'], [/((?:(?:"|]|}|\/[gmiuys]|\.|(?:\d|\.|-)*\d)\s*,|{)\s*)(?:"([^":\n]+?)"|'([^":\n]+?)'|([^":\n]+?))(\s*):/g, '$1"$2$3$4"$5:']];
function parseJSON(str) {
if (typeof str !== 'string') {
return JSON.parse(str);
}
try {
return JSON.parse(str);
} catch (e) {
_logger["default"].debug('[plugin-common]', 'Invalid JSON, switching to experimental parser');
substituters.forEach(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
regex = _ref2[0],
subst = _ref2[1];
str = str.replace(regex, subst);
});
return JSON.parse(str);
}
}
},{"../../logger.js":11}],18:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _json = _interopRequireDefault(require("./json.js"));
var _label = _interopRequireDefault(require("./label.js"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
var _default = exports["default"] = Object.assign({}, _json["default"], _label["default"]);
},{"./json.js":19,"./label.js":20}],19:[function(require,module,exports){
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
exports.getJsonWrapper = getJsonWrapper;
var plugins = _interopRequireWildcard(require("../../plugins/index.js"));
var util = _interopRequireWildcard(require("../../util/index.js"));
var _logger = _interopRequireDefault(require("../../logger.js"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
function _getRequireWildcardCache(e) {
if ("function" != typeof WeakMap) return null;
var r = new WeakMap(),
t = new WeakMap();
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
return e ? t : r;
})(e);
}
function _interopRequireWildcard(e, r) {
if (!r && e && e.__esModule) return e;
if (null === e || "object" != _typeof(e) && "function" != typeof e) return {
"default": e
};
var t = _getRequireWildcardCache(r);
if (t && t.has(e)) return t.get(e);
var n = {
__proto__: null
},
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
}
return n["default"] = e, t && t.set(e, n), n;
}
function appendCommas(string, index, array) {
return string + (index < array.length - 1 ? ',' : '');
}
function getJsonObject(src, dict) {
var isArray = Array.isArray(src);
var entries;
if (isArray) {
entries = src.map(function (entry) {
return getJsonValue(entry, dict);
});
} else {
entries = Object.keys(src).filter(function (prop) {
return JSON.stringify(src[prop]);
}).map(function (prop) {
return "\"".concat(prop, "\": ").concat(getJsonValue(src[prop], dict));
});
}
entries = entries.map(appendCommas).map(function (entry) {
return dict.listItem.join(entry);
});
entries = dict.list.join(entries.join(''));
return isArray ? "[".concat(entries, "]") : "{".concat(entries, "}");
}
function getJsonValue(src, dict) {
if (_typeof(src) === 'object' && src !== null) {
if (src.length === 0) {
return '[]';
} else if (Object.keys(src).length === 0) {
return '{}';
} else {
return getJsonObject(src, dict);
}
} else {
return JSON.stringify(src);
}
}
function getJson(src, dict) {
var entries = src.map(function (entry) {
return getJsonObject(entry, dict);
});
entries = entries.map(appendCommas).map(function (entry) {
return dict.entry.join(entry);
});
entries = entries.join('');
return dict.bibliographyContainer.join("[".concat(entries, "]"));
}
function getJsonWrapper(src) {
return getJson(src, plugins.dict.get('html'));
}
var _default = exports["default"] = {
data: function data(_data) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
type = _ref.type,
_ref$format = _ref.format,
format = _ref$format === void 0 ? type || 'text' : _ref$format,
_ref$version = _ref.version,
version = _ref$version === void 0 ? '1.0.2' : _ref$version;
if (version < '1.0.2') {
_data = util.downgradeCsl(_data);
}
if (format === 'object') {
return util.deepCopy(_data);
} else if (format === 'text') {
return JSON.stringify(_data, null, 2);
} else {
_logger["default"].warn('[core]', 'This feature (JSON output with special formatting) is unstable. See https://github.com/larsgw/citation.js/issues/144');
return getJson(_data, plugins.dict.get(format));
}
},
ndjson: function ndjson(data) {
var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref2$version = _ref2.version,
version = _ref2$version === void 0 ? '1.0.2' : _ref2$version;
if (version < '1.0.2') {
data = util.downgradeCsl(data);
}
return data.map(function (entry) {
return JSON.stringify(entry);
}).join('\n');
}
};
},{"../../logger.js":11,"../../plugins/index.js":23,"../../util/index.js":39}],20:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
exports.getLabel = getLabel;
function getLabel(entry) {
if ('citation-label' in entry) {
return entry['citation-label'];
}
var res = '';
if (entry.author) {
res += entry.author[0].family || entry.author[0].literal;
}
if (entry.issued && entry.issued['date-parts'] && entry.issued['date-parts'][0]) {
res += entry.issued['date-parts'][0][0];
}
if (entry['year-suffix']) {
res += entry['year-suffix'];
} else if (entry.title) {
res += entry.title.replace(/<\/?.*?>/g, '').match(/^(?:(?:the|a|an)\s+)?(\S+)/i)[1];
}
return res;
}
var _default = exports["default"] = {
label: function label(data) {
return data.reduce(function (object, entry) {
object[entry.id] = getLabel(entry);
return object;
}, {});
}