narou 0.5.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/index.browser.d.ts +30 -0
  2. package/dist/index.browser.d.ts.map +1 -0
  3. package/dist/index.browser.js +119 -0
  4. package/dist/index.browser.js.map +1 -0
  5. package/dist/index.common.d.ts +8 -0
  6. package/dist/index.common.d.ts.map +1 -0
  7. package/dist/index.common.js +17 -0
  8. package/dist/index.common.js.map +1 -0
  9. package/dist/index.d.ts +30 -31
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +120 -113
  12. package/dist/index.js.map +1 -1
  13. package/dist/narou-fetch.d.ts +13 -0
  14. package/dist/narou-fetch.d.ts.map +1 -0
  15. package/dist/narou-fetch.js +130 -0
  16. package/dist/narou-fetch.js.map +1 -0
  17. package/dist/narou-jsonp.d.ts +10 -0
  18. package/dist/narou-jsonp.d.ts.map +1 -0
  19. package/dist/narou-jsonp.js +102 -0
  20. package/dist/narou-jsonp.js.map +1 -0
  21. package/dist/narou-ranking-results.d.ts +8 -8
  22. package/dist/narou-ranking-results.js +2 -2
  23. package/dist/narou-search-results.d.ts +90 -89
  24. package/dist/narou-search-results.d.ts.map +1 -1
  25. package/dist/narou-search-results.js +51 -51
  26. package/dist/narou-search-results.js.map +1 -1
  27. package/dist/narou.d.ts +24 -25
  28. package/dist/narou.d.ts.map +1 -1
  29. package/dist/narou.js +104 -142
  30. package/dist/narou.js.map +1 -1
  31. package/dist/params.d.ts +230 -230
  32. package/dist/params.js +173 -173
  33. package/dist/ranking-history.d.ts +13 -13
  34. package/dist/ranking-history.js +13 -13
  35. package/dist/ranking-history.js.map +1 -1
  36. package/dist/ranking.d.ts +47 -45
  37. package/dist/ranking.d.ts.map +1 -1
  38. package/dist/ranking.js +167 -165
  39. package/dist/ranking.js.map +1 -1
  40. package/dist/search-builder-r18.d.ts +21 -21
  41. package/dist/search-builder-r18.d.ts.map +1 -1
  42. package/dist/search-builder-r18.js +64 -63
  43. package/dist/search-builder-r18.js.map +1 -1
  44. package/dist/search-builder.d.ts +228 -226
  45. package/dist/search-builder.d.ts.map +1 -1
  46. package/dist/search-builder.js +412 -412
  47. package/dist/search-builder.js.map +1 -1
  48. package/dist/util/jsonp.d.ts +14 -0
  49. package/dist/util/jsonp.d.ts.map +1 -0
  50. package/dist/util/jsonp.js +48 -0
  51. package/dist/util/jsonp.js.map +1 -0
  52. package/dist/util/unzipp.d.ts +3 -3
  53. package/dist/util/unzipp.js +56 -56
  54. package/dist/util/unzipp.js.map +1 -1
  55. package/dist/util/url.d.ts +10 -0
  56. package/dist/util/url.d.ts.map +1 -0
  57. package/dist/util/url.js +9 -0
  58. package/dist/util/url.js.map +1 -0
  59. package/dist.es2015/index.browser.js +50 -0
  60. package/dist.es2015/index.browser.js.map +1 -0
  61. package/dist.es2015/index.common.js +5 -0
  62. package/dist.es2015/index.common.js.map +1 -0
  63. package/dist.es2015/index.js +50 -49
  64. package/dist.es2015/index.js.map +1 -1
  65. package/dist.es2015/narou-fetch.js +44 -0
  66. package/dist.es2015/narou-fetch.js.map +1 -0
  67. package/dist.es2015/narou-jsonp.js +22 -0
  68. package/dist.es2015/narou-jsonp.js.map +1 -0
  69. package/dist.es2015/narou-ranking-results.js +1 -1
  70. package/dist.es2015/narou-search-results.js +46 -46
  71. package/dist.es2015/narou-search-results.js.map +1 -1
  72. package/dist.es2015/narou.js +23 -60
  73. package/dist.es2015/narou.js.map +1 -1
  74. package/dist.es2015/params.js +170 -170
  75. package/dist.es2015/ranking-history.js +9 -9
  76. package/dist.es2015/ranking.js +90 -90
  77. package/dist.es2015/ranking.js.map +1 -1
  78. package/dist.es2015/search-builder-r18.js +41 -42
  79. package/dist.es2015/search-builder-r18.js.map +1 -1
  80. package/dist.es2015/search-builder.js +383 -383
  81. package/dist.es2015/search-builder.js.map +1 -1
  82. package/dist.es2015/util/jsonp.js +43 -0
  83. package/dist.es2015/util/jsonp.js.map +1 -0
  84. package/dist.es2015/util/unzipp.js +7 -7
  85. package/dist.es2015/util/url.js +7 -0
  86. package/dist.es2015/util/url.js.map +1 -0
  87. package/dist.esm/index.browser.js +102 -0
  88. package/dist.esm/index.browser.js.map +1 -0
  89. package/dist.esm/index.common.js +5 -0
  90. package/dist.esm/index.common.js.map +1 -0
  91. package/dist.esm/index.js +102 -97
  92. package/dist.esm/index.js.map +1 -1
  93. package/dist.esm/narou-fetch.js +128 -0
  94. package/dist.esm/narou-fetch.js.map +1 -0
  95. package/dist.esm/narou-jsonp.js +100 -0
  96. package/dist.esm/narou-jsonp.js.map +1 -0
  97. package/dist.esm/narou-ranking-results.js +1 -1
  98. package/dist.esm/narou-search-results.js +49 -49
  99. package/dist.esm/narou-search-results.js.map +1 -1
  100. package/dist.esm/narou.js +102 -140
  101. package/dist.esm/narou.js.map +1 -1
  102. package/dist.esm/params.js +170 -170
  103. package/dist.esm/ranking-history.js +9 -9
  104. package/dist.esm/ranking.js +164 -162
  105. package/dist.esm/ranking.js.map +1 -1
  106. package/dist.esm/search-builder-r18.js +62 -61
  107. package/dist.esm/search-builder-r18.js.map +1 -1
  108. package/dist.esm/search-builder.js +410 -410
  109. package/dist.esm/search-builder.js.map +1 -1
  110. package/dist.esm/util/jsonp.js +44 -0
  111. package/dist.esm/util/jsonp.js.map +1 -0
  112. package/dist.esm/util/unzipp.js +52 -52
  113. package/dist.esm/util/url.js +7 -0
  114. package/dist.esm/util/url.js.map +1 -0
  115. package/package-lock.json +3328 -4289
  116. package/package.json +8 -9
  117. package/src/index.browser.ts +63 -0
  118. package/src/index.common.ts +17 -0
  119. package/src/index.ts +22 -23
  120. package/src/narou-fetch.ts +51 -0
  121. package/src/narou-jsonp.ts +29 -0
  122. package/src/narou-ranking-results.ts +9 -9
  123. package/src/narou-search-results.ts +11 -10
  124. package/src/narou.ts +21 -49
  125. package/src/params.ts +280 -280
  126. package/src/ranking.ts +111 -107
  127. package/src/search-builder-r18.ts +1 -2
  128. package/src/search-builder.ts +5 -3
  129. package/src/util/jsonp.ts +66 -0
  130. package/src/util/unzipp.ts +9 -9
  131. package/src/util/url.ts +7 -0
@@ -0,0 +1,100 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
+ return new (P || (P = Promise))(function (resolve, reject) {
30
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
34
+ });
35
+ };
36
+ var __generator = (this && this.__generator) || function (thisArg, body) {
37
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
+ function verb(n) { return function (v) { return step([n, v]); }; }
40
+ function step(op) {
41
+ if (f) throw new TypeError("Generator is already executing.");
42
+ while (_) try {
43
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
+ if (y = 0, t) op = [op[0] & 2, t.value];
45
+ switch (op[0]) {
46
+ case 0: case 1: t = op; break;
47
+ case 4: _.label++; return { value: op[1], done: false };
48
+ case 5: _.label++; y = op[1]; op = [0]; continue;
49
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
+ default:
51
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
+ if (t[2]) _.ops.pop();
56
+ _.trys.pop(); continue;
57
+ }
58
+ op = body.call(thisArg, _);
59
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
+ }
62
+ };
63
+ import nodeURL from "./util/url";
64
+ import NarouNovel from "./narou";
65
+ import { jsonp } from "./util/jsonp";
66
+ /**
67
+ * なろう小説APIへのリクエストを実行する
68
+ * @class NarouNovel
69
+ * @private
70
+ */
71
+ var NarouNovelJsonp = /** @class */ (function (_super) {
72
+ __extends(NarouNovelJsonp, _super);
73
+ function NarouNovelJsonp() {
74
+ return _super !== null && _super.apply(this, arguments) || this;
75
+ }
76
+ NarouNovelJsonp.prototype.execute = function (params, endpoint) {
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var query, url;
79
+ return __generator(this, function (_a) {
80
+ switch (_a.label) {
81
+ case 0:
82
+ query = __assign(__assign({}, params), { out: "jsonp" });
83
+ query.gzip = 0;
84
+ url = new nodeURL(endpoint);
85
+ Object.entries(query).forEach(function (_a) {
86
+ var key = _a[0], value = _a[1];
87
+ if (value) {
88
+ url.searchParams.append(key, value.toString());
89
+ }
90
+ });
91
+ return [4 /*yield*/, jsonp(url.toString())];
92
+ case 1: return [2 /*return*/, _a.sent()];
93
+ }
94
+ });
95
+ });
96
+ };
97
+ return NarouNovelJsonp;
98
+ }(NarouNovel));
99
+ export default NarouNovelJsonp;
100
+ //# sourceMappingURL=narou-jsonp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"narou-jsonp.js","sourceRoot":"","sources":["../src/narou-jsonp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,UAA2B,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC;;;;GAIG;AACH;IAA6C,mCAAU;IAAvD;;IAkBA,CAAC;IAjBiB,iCAAO,GAAvB,UACE,MAAmB,EACnB,QAAgB;;;;;;wBAEV,KAAK,yBAAQ,MAAM,KAAE,GAAG,EAAE,OAAO,GAAE,CAAC;wBAC1C,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;wBAET,GAAG,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC;wBAElC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAC,EAAY;gCAAX,GAAG,QAAA,EAAE,KAAK,QAAA;4BACxC,IAAI,KAAK,EAAE;gCACT,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;6BAChD;wBACH,CAAC,CAAC,CAAC;wBAEI,qBAAM,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAA;4BAAlC,sBAAO,SAA2B,EAAC;;;;KACpC;IACH,sBAAC;AAAD,CAAC,AAlBD,CAA6C,UAAU,GAkBtD"}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=narou-ranking-results.js.map
@@ -1,50 +1,50 @@
1
- /**
2
- * なろう小説API検索結果
3
- * @class NarouSearchResults
4
- */
5
- var NarouSearchResults = /** @class */ (function () {
6
- /**
7
- * @constractor
8
- * @private
9
- */
10
- function NarouSearchResults(_a, params) {
11
- var header = _a[0], result = _a.slice(1);
12
- var _b, _c;
13
- var count = header.allcount;
14
- var limit = (_b = params.lim) !== null && _b !== void 0 ? _b : 20;
15
- var start = (_c = params.st) !== null && _c !== void 0 ? _c : 0;
16
- /**
17
- * 検索結果数
18
- * @type {number}
19
- */
20
- this.allcount = count;
21
- /**
22
- * 結果表示上限数
23
- * @type {number}
24
- */
25
- this.limit = limit;
26
- /**
27
- * 結果表示開始数
28
- * @type {number}
29
- */
30
- this.start = start;
31
- /**
32
- * 結果表示ページ数
33
- * @type {number}
34
- */
35
- this.page = start / limit;
36
- /**
37
- * 結果数
38
- * @type {number}
39
- */
40
- this.length = result.length;
41
- /**
42
- * 検索結果
43
- * @type {NarouSearchResult[]}
44
- */
45
- this.values = result;
46
- }
47
- return NarouSearchResults;
48
- }());
49
- export default NarouSearchResults;
1
+ /**
2
+ * なろう小説API検索結果
3
+ * @class NarouSearchResults
4
+ */
5
+ var NarouSearchResults = /** @class */ (function () {
6
+ /**
7
+ * @constractor
8
+ * @private
9
+ */
10
+ function NarouSearchResults(_a, params) {
11
+ var header = _a[0], result = _a.slice(1);
12
+ var _b, _c;
13
+ var count = header.allcount;
14
+ var limit = (_b = params.lim) !== null && _b !== void 0 ? _b : 20;
15
+ var start = (_c = params.st) !== null && _c !== void 0 ? _c : 0;
16
+ /**
17
+ * 検索結果数
18
+ * @type {number}
19
+ */
20
+ this.allcount = count;
21
+ /**
22
+ * 結果表示上限数
23
+ * @type {number}
24
+ */
25
+ this.limit = limit;
26
+ /**
27
+ * 結果表示開始数
28
+ * @type {number}
29
+ */
30
+ this.start = start;
31
+ /**
32
+ * 結果表示ページ数
33
+ * @type {number}
34
+ */
35
+ this.page = start / limit;
36
+ /**
37
+ * 結果数
38
+ * @type {number}
39
+ */
40
+ this.length = result.length;
41
+ /**
42
+ * 検索結果
43
+ * @type {NarouSearchResult[]}
44
+ */
45
+ this.values = result;
46
+ }
47
+ return NarouSearchResults;
48
+ }());
49
+ export default NarouSearchResults;
50
50
  //# sourceMappingURL=narou-search-results.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"narou-search-results.js","sourceRoot":"","sources":["../src/narou-search-results.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;IAQE;;;OAGG;IACH,4BACE,EAAmE,EACnE,MAAoB;YADnB,MAAM,QAAA,EAAK,MAAM,cAAA;;QAGlB,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC9B,IAAM,KAAK,SAAG,MAAM,CAAC,GAAG,mCAAI,EAAE,CAAC;QAC/B,IAAM,KAAK,SAAG,MAAM,CAAC,EAAE,mCAAI,CAAC,CAAC;QAE7B;;;WAGG;QACH,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;QAC1B;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACH,yBAAC;AAAD,CAAC,AAnDD,IAmDC"}
1
+ {"version":3,"file":"narou-search-results.js","sourceRoot":"","sources":["../src/narou-search-results.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;IAQE;;;OAGG;IACH,4BACE,EAAmE,EACnE,MAAoB;YADnB,MAAM,QAAA,EAAK,MAAM,cAAA;;QAGlB,IAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC;QAC9B,IAAM,KAAK,GAAG,MAAA,MAAM,CAAC,GAAG,mCAAI,EAAE,CAAC;QAC/B,IAAM,KAAK,GAAG,MAAA,MAAM,CAAC,EAAE,mCAAI,CAAC,CAAC;QAE7B;;;WAGG;QACH,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;QAC1B;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IACH,yBAAC;AAAD,CAAC,AAnDD,IAmDC"}
package/dist.esm/narou.js CHANGED
@@ -1,141 +1,103 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __generator = (this && this.__generator) || function (thisArg, body) {
22
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
- function verb(n) { return function (v) { return step([n, v]); }; }
25
- function step(op) {
26
- if (f) throw new TypeError("Generator is already executing.");
27
- while (_) try {
28
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
- if (y = 0, t) op = [op[0] & 2, t.value];
30
- switch (op[0]) {
31
- case 0: case 1: t = op; break;
32
- case 4: _.label++; return { value: op[1], done: false };
33
- case 5: _.label++; y = op[1]; op = [0]; continue;
34
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
- default:
36
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
- if (t[2]) _.ops.pop();
41
- _.trys.pop(); continue;
42
- }
43
- op = body.call(thisArg, _);
44
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
- }
47
- };
48
- import fetch from "node-fetch";
49
- import { URL } from "url";
50
- import NarouSearchResults from "./narou-search-results";
51
- import { unzipp } from "./util/unzipp";
52
- /**
53
- * なろう小説APIへのリクエストを実行する
54
- * @class NarouNovel
55
- * @private
56
- */
57
- var NarouNovel = /** @class */ (function () {
58
- function NarouNovel() {
59
- }
60
- /**
61
- * なろう小説APIへの検索リクエストを実行する
62
- * @param params クエリパラメータ
63
- * @param endpoint APIエンドポイント
64
- * @returns {Promise<NarouSearchResults>} 検索結果
65
- */
66
- NarouNovel.execute = function (params, endpoint) {
67
- if (endpoint === void 0) { endpoint = "http://api.syosetu.com/novelapi/api/"; }
68
- return __awaiter(this, void 0, void 0, function () {
69
- var query, url, res, buffer, _a;
70
- return __generator(this, function (_b) {
71
- switch (_b.label) {
72
- case 0:
73
- query = __assign(__assign({}, params), { out: "json" });
74
- if (query.gzip === undefined) {
75
- query.gzip = 5;
76
- }
77
- url = new URL(endpoint);
78
- Object.entries(query).forEach(function (_a) {
79
- var key = _a[0], value = _a[1];
80
- if (value) {
81
- url.searchParams.append(key, value.toString());
82
- }
83
- });
84
- return [4 /*yield*/, fetch(url)];
85
- case 1:
86
- res = _b.sent();
87
- if (!(query.gzip === 0)) return [3 /*break*/, 3];
88
- return [4 /*yield*/, res.json()];
89
- case 2: return [2 /*return*/, _b.sent()];
90
- case 3: return [4 /*yield*/, res.buffer()];
91
- case 4:
92
- buffer = _b.sent();
93
- _b.label = 5;
94
- case 5:
95
- _b.trys.push([5, 7, , 8]);
96
- return [4 /*yield*/, unzipp(buffer)];
97
- case 6: return [2 /*return*/, _b.sent()];
98
- case 7:
99
- _a = _b.sent();
100
- try {
101
- return [2 /*return*/, JSON.stringify(buffer.toString())];
102
- }
103
- catch (_c) {
104
- return [2 /*return*/, buffer.toString()];
105
- }
106
- return [3 /*break*/, 8];
107
- case 8: return [2 /*return*/];
108
- }
109
- });
110
- });
111
- };
112
- NarouNovel.executeSearch = function (params, endpoint) {
113
- if (endpoint === void 0) { endpoint = "http://api.syosetu.com/novelapi/api/"; }
114
- return __awaiter(this, void 0, void 0, function () {
115
- var _a;
116
- return __generator(this, function (_b) {
117
- switch (_b.label) {
118
- case 0:
119
- _a = NarouSearchResults.bind;
120
- return [4 /*yield*/, this.execute(params, endpoint)];
121
- case 1: return [2 /*return*/, new (_a.apply(NarouSearchResults, [void 0, _b.sent(), params]))()];
122
- }
123
- });
124
- });
125
- };
126
- NarouNovel.executeNovel = function (params) {
127
- return this.executeSearch(params, "http://api.syosetu.com/novelapi/api/");
128
- };
129
- NarouNovel.executeNovel18 = function (params) {
130
- return this.executeSearch(params, "http://api.syosetu.com/novel18api/api/");
131
- };
132
- NarouNovel.executeRanking = function (params) {
133
- return this.execute(params, "http://api.syosetu.com/rank/rankget/");
134
- };
135
- NarouNovel.executeRankingHistory = function (params) {
136
- return this.execute(params, "http://api.syosetu.com/rank/rankin/");
137
- };
138
- return NarouNovel;
139
- }());
140
- export default NarouNovel;
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import NarouSearchResults from "./narou-search-results";
38
+ /**
39
+ * なろう小説APIへのリクエストを実行する
40
+ * @class NarouNovel
41
+ * @private
42
+ */
43
+ var NarouNovel = /** @class */ (function () {
44
+ function NarouNovel() {
45
+ }
46
+ NarouNovel.prototype.executeSearch = function (params, endpoint) {
47
+ if (endpoint === void 0) { endpoint = "http://api.syosetu.com/novelapi/api/"; }
48
+ return __awaiter(this, void 0, void 0, function () {
49
+ var _a;
50
+ return __generator(this, function (_b) {
51
+ switch (_b.label) {
52
+ case 0:
53
+ _a = NarouSearchResults.bind;
54
+ return [4 /*yield*/, this.execute(params, endpoint)];
55
+ case 1: return [2 /*return*/, new (_a.apply(NarouSearchResults, [void 0, _b.sent(), params]))()];
56
+ }
57
+ });
58
+ });
59
+ };
60
+ NarouNovel.prototype.executeNovel = function (params) {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ return __generator(this, function (_a) {
63
+ switch (_a.label) {
64
+ case 0: return [4 /*yield*/, this.executeSearch(params, "http://api.syosetu.com/novelapi/api/")];
65
+ case 1: return [2 /*return*/, _a.sent()];
66
+ }
67
+ });
68
+ });
69
+ };
70
+ NarouNovel.prototype.executeNovel18 = function (params) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0: return [4 /*yield*/, this.executeSearch(params, "http://api.syosetu.com/novel18api/api/")];
75
+ case 1: return [2 /*return*/, _a.sent()];
76
+ }
77
+ });
78
+ });
79
+ };
80
+ NarouNovel.prototype.executeRanking = function (params) {
81
+ return __awaiter(this, void 0, void 0, function () {
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0: return [4 /*yield*/, this.execute(params, "http://api.syosetu.com/rank/rankget/")];
85
+ case 1: return [2 /*return*/, _a.sent()];
86
+ }
87
+ });
88
+ });
89
+ };
90
+ NarouNovel.prototype.executeRankingHistory = function (params) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0: return [4 /*yield*/, this.execute(params, "http://api.syosetu.com/rank/rankin/")];
95
+ case 1: return [2 /*return*/, _a.sent()];
96
+ }
97
+ });
98
+ });
99
+ };
100
+ return NarouNovel;
101
+ }());
102
+ export default NarouNovel;
141
103
  //# sourceMappingURL=narou.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"narou.js","sourceRoot":"","sources":["../src/narou.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1B,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvC;;;;GAIG;AACH;IAAA;IAkEA,CAAC;IAjEC;;;;;OAKG;IACU,kBAAO,GAApB,UACE,MAAmB,EACnB,QAAiD;QAAjD,yBAAA,EAAA,iDAAiD;;;;;;wBAE3C,K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