@ridi/comic-parser
Advanced tools
Comparing version 0.7.0 to 0.7.1
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
@@ -34,13 +36,13 @@ | ||
var _path = _interopRequireDefault(require("path")); | ||
var path = _interopRequireWildcard(require("path")); | ||
var _stringNaturalCompare = _interopRequireDefault(require("string-natural-compare")); | ||
var _Book = _interopRequireDefault(require("./model/Book")); | ||
var _ComicBook = _interopRequireDefault(require("./model/ComicBook")); | ||
var _Item = _interopRequireDefault(require("./model/Item")); | ||
var _ComicItem = _interopRequireDefault(require("./model/ComicItem")); | ||
var _ReadContext = _interopRequireDefault(require("./model/ReadContext")); | ||
var _ComicReadContext = _interopRequireDefault(require("./model/ComicReadContext")); | ||
var _ParseContext = _interopRequireDefault(require("./model/ParseContext")); | ||
var _ComicParseContext = _interopRequireDefault(require("./model/ComicParseContext")); | ||
@@ -55,3 +57,3 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
var ComicParser = /*#__PURE__*/function (_Parser) { | ||
var ComicParser = function (_Parser) { | ||
(0, _inherits2["default"])(ComicParser, _Parser); | ||
@@ -63,18 +65,8 @@ | ||
key: "parseDefaultOptions", | ||
/** | ||
* Get default values of parse options | ||
*/ | ||
get: function get() { | ||
return _objectSpread(_objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(ComicParser), "parseDefaultOptions", this)), {}, { | ||
// File extension to allow when extracting lists. | ||
ext: ['jpg', 'jpeg', 'png', 'bmp', 'gif'], | ||
// If true, image size parse. (parse may be slower.) | ||
parseImageSize: false | ||
}); | ||
} | ||
/** | ||
* Get types of parse options | ||
*/ | ||
}, { | ||
@@ -88,6 +80,2 @@ key: "parseOptionTypes", | ||
} | ||
/** | ||
* Get default values of read options | ||
*/ | ||
}, { | ||
@@ -97,10 +85,5 @@ key: "readDefaultOptions", | ||
return _objectSpread(_objectSpread({}, (0, _get2["default"])((0, _getPrototypeOf2["default"])(ComicParser), "readDefaultOptions", this)), {}, { | ||
// If false, reads image into a buffer. | ||
base64: false | ||
}); | ||
} | ||
/** | ||
* Get types of read option | ||
*/ | ||
}, { | ||
@@ -113,12 +96,2 @@ key: "readOptionTypes", | ||
} | ||
/** | ||
* Create new ComicParser | ||
* @param {string} input file or directory | ||
* @param {?CryptoProvider} cryptoProvider en/decrypto provider | ||
* @param {?string} logLevel logging level | ||
* @throws {Errors.ENOENT} no such file or directory | ||
* @throws {Errors.EINVAL} invalid input | ||
* @example new ComicParser('./foo/bar.zip' or './foo/bar'); | ||
*/ | ||
}]); | ||
@@ -128,4 +101,2 @@ | ||
(0, _classCallCheck2["default"])(this, ComicParser); | ||
/* istanbul ignore next */ | ||
logLevel = (0, _parserCore.isString)(cryptoProvider) ? cryptoProvider : logLevel; | ||
@@ -138,43 +109,23 @@ cryptoProvider = (0, _parserCore.isString)(cryptoProvider) ? undefined : cryptoProvider; | ||
} | ||
/** | ||
* @returns {ParseContext} | ||
*/ | ||
(0, _createClass2["default"])(ComicParser, [{ | ||
key: "_getParseContextClass", | ||
value: function _getParseContextClass() { | ||
return _ParseContext["default"]; | ||
return _ComicParseContext["default"]; | ||
} | ||
/** | ||
* @returns {Book} | ||
*/ | ||
}, { | ||
key: "_getBookClass", | ||
value: function _getBookClass() { | ||
return _Book["default"]; | ||
return _ComicBook["default"]; | ||
} | ||
/** | ||
* @returns {ReadContext} | ||
*/ | ||
}, { | ||
key: "_getReadContextClass", | ||
value: function _getReadContextClass() { | ||
return _ReadContext["default"]; | ||
return _ComicReadContext["default"]; | ||
} | ||
/** | ||
* @returns {Item} | ||
*/ | ||
}, { | ||
key: "_getReadItemClass", | ||
value: function _getReadItemClass() { | ||
return _Item["default"]; | ||
return _ComicItem["default"]; | ||
} | ||
/** | ||
* @returns {ParseTask[]} return tasks | ||
*/ | ||
}, { | ||
@@ -188,14 +139,6 @@ key: "_parseTasks", | ||
} | ||
/** | ||
* extracts only necessary metadata from entries and create item list | ||
* @param {ReadContext} context intermediate result | ||
* @returns {Promise.<ReadContext>} return Context containing item list | ||
* @see ComicParser.parseDefaultOptions.ext | ||
* @see ComicParser.parseDefaultOptions.parseImageSize | ||
*/ | ||
}, { | ||
key: "_parse", | ||
value: function () { | ||
var _parse2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(context) { | ||
var _parse2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(context) { | ||
var _this = this; | ||
@@ -212,4 +155,3 @@ | ||
}).filter(function (entry) { | ||
var ext = _path["default"].extname(entry.entryPath); | ||
var ext = path.extname(entry.entryPath); | ||
return ext.length > 0 && (0, _parserCore.stringContains)(options.ext.map(function (e) { | ||
@@ -222,3 +164,3 @@ return ".".concat(e); | ||
return items.reduce(function (prevPromise, item, index) { | ||
return prevPromise.then( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() { | ||
return prevPromise.then((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() { | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
@@ -233,3 +175,3 @@ while (1) { | ||
path: item.entryPath, | ||
fileSize: item.size | ||
size: item.size | ||
}; | ||
@@ -271,13 +213,6 @@ _context.next = 5; | ||
}() | ||
/** | ||
* parse image size from entry | ||
* @param {object} entry image entry | ||
* @param {object} options parse options | ||
* @returns {Promise.<object>} return image size | ||
*/ | ||
}, { | ||
key: "_parseImageSize", | ||
value: function () { | ||
var _parseImageSize2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(entry, options) { | ||
var _parseImageSize2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(entry, options) { | ||
var parseImageSize, readOptions, buffer, size; | ||
@@ -336,14 +271,6 @@ return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
}() | ||
/** | ||
* Contents is read using loader suitable for context | ||
* @param {ReadContext} context properties required for reading | ||
* @returns {(string|Buffer)[]} reading results | ||
* @throws {Errors.ENOFILE} no such file | ||
* @see ComicParser.readDefaultOptions.base64 | ||
*/ | ||
}, { | ||
key: "_read", | ||
value: function () { | ||
var _read2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(context) { | ||
var _read2 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(context) { | ||
var items, entries, options, results; | ||
@@ -358,3 +285,3 @@ return _regenerator["default"].wrap(function _callee5$(_context5) { | ||
return items.reduce(function (prevPromise, item) { | ||
return prevPromise.then( /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { | ||
return prevPromise.then((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4() { | ||
var entry, file; | ||
@@ -366,3 +293,2 @@ return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
entry = entries.find(item.path); | ||
/* istanbul ignore next */ | ||
@@ -369,0 +295,0 @@ if (!(!options.force && !(0, _parserCore.isExists)(entry))) { |
@@ -47,3 +47,3 @@ "use strict"; | ||
get: function get() { | ||
return _Book["default"]; | ||
return _ComicBook["default"]; | ||
} | ||
@@ -56,2 +56,2 @@ }); | ||
var _Book = _interopRequireDefault(require("./model/Book")); | ||
var _ComicBook = _interopRequireDefault(require("./model/ComicBook")); |
{ | ||
"name": "@ridi/comic-parser", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Common comic data parser for Ridibooks services", | ||
@@ -17,11 +17,17 @@ "author": { | ||
"files": [ | ||
"lib" | ||
"lib", | ||
"type" | ||
], | ||
"main": "lib/index.js", | ||
"types": "type/index.d.ts", | ||
"dependencies": { | ||
"@ridi/parser-core": "0.7.0", | ||
"@ridi/parser-core": "0.7.1", | ||
"fs-extra": "^9.0.1", | ||
"image-size": "^0.9.1", | ||
"string-natural-compare": "^3.0.1" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.6" | ||
}, | ||
"gitHead": "9ec93110b3040830b688cc1c29388a9a48d7a6ba" | ||
} |
@@ -200,3 +200,3 @@ # @ridi/comic-parser | ||
- path: *?string* | ||
- fileSize: *?number* | ||
- size: *?number* | ||
- width: *?number* | ||
@@ -203,0 +203,0 @@ - height: *?number* |
39200
15
675
1
+ Added@ridi/parser-core@0.7.1(transitive)
- Removed@ridi/parser-core@0.7.0(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstream-chopper@3.0.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updated@ridi/parser-core@0.7.1