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
@@ -1,411 +1,411 @@
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
- import api from "./narou";
13
- /**
14
- * 検索ヘルパー
15
- * @class SearchBuilder
16
- */
17
- var SearchBuilder = /** @class */ (function () {
18
- /**
19
- * constructor
20
- * @private
21
- */
22
- function SearchBuilder(params) {
23
- if (params === void 0) { params = {}; }
24
- this.params = params;
25
- }
26
- /**
27
- * a
28
- * @return {SearchBuilder} this
29
- */
30
- SearchBuilder.prototype.word = function (word) {
31
- this.set({ word: word });
32
- return this;
33
- };
34
- /**
35
- *
36
- * @return {SearchBuilder} this
37
- */
38
- SearchBuilder.prototype.notWord = function (word) {
39
- this.set({ notword: word });
40
- return this;
41
- };
42
- /**
43
- *
44
- * @return {SearchBuilder} this
45
- */
46
- SearchBuilder.prototype.byTitle = function (bool) {
47
- if (bool === void 0) { bool = true; }
48
- this.set({ title: bool ? 1 : 0 });
49
- return this;
50
- };
51
- /**
52
- *
53
- * @return {SearchBuilder} this
54
- */
55
- SearchBuilder.prototype.byOutline = function (bool) {
56
- if (bool === void 0) { bool = true; }
57
- this.set({ ex: bool ? 1 : 0 });
58
- return this;
59
- };
60
- /**
61
- *
62
- * @return {SearchBuilder} this
63
- */
64
- SearchBuilder.prototype.byKeyword = function (bool) {
65
- if (bool === void 0) { bool = true; }
66
- this.set({ keyword: bool ? 1 : 0 });
67
- return this;
68
- };
69
- /**
70
- *
71
- * @return {SearchBuilder} this
72
- */
73
- SearchBuilder.prototype.byAuthor = function (bool) {
74
- if (bool === void 0) { bool = true; }
75
- this.set({ wname: bool ? 1 : 0 });
76
- return this;
77
- };
78
- /**
79
- *
80
- * @return {SearchBuilder} this
81
- */
82
- SearchBuilder.prototype.bigGenre = function (genre) {
83
- this.set({ biggenre: array2string(genre) });
84
- return this;
85
- };
86
- /**
87
- *
88
- * @return {SearchBuilder} this
89
- */
90
- SearchBuilder.prototype.notBigGenre = function (genre) {
91
- this.set({ notbiggenre: array2string(genre) });
92
- return this;
93
- };
94
- /**
95
- *
96
- * @return {SearchBuilder} this
97
- */
98
- SearchBuilder.prototype.genre = function (genre) {
99
- this.set({ genre: array2string(genre) });
100
- return this;
101
- };
102
- /**
103
- *
104
- * @return {SearchBuilder} this
105
- */
106
- SearchBuilder.prototype.notGenre = function (genre) {
107
- this.set({ notgenre: array2string(genre) });
108
- return this;
109
- };
110
- /**
111
- *
112
- * @return {SearchBuilder} this
113
- */
114
- SearchBuilder.prototype.userId = function (ids) {
115
- this.set({ userid: array2string(ids) });
116
- return this;
117
- };
118
- /**
119
- *
120
- * @return {SearchBuilder} this
121
- */
122
- SearchBuilder.prototype.isR15 = function (bool) {
123
- if (bool === void 0) { bool = true; }
124
- if (bool) {
125
- this.set({ isr15: 1 });
126
- }
127
- else {
128
- this.set({ notr15: 1 });
129
- }
130
- return this;
131
- };
132
- /**
133
- *
134
- * @return {SearchBuilder} this
135
- */
136
- SearchBuilder.prototype.isBL = function (bool) {
137
- if (bool === void 0) { bool = true; }
138
- if (bool) {
139
- this.set({ isbl: 1 });
140
- }
141
- else {
142
- this.set({ notbl: 1 });
143
- }
144
- return this;
145
- };
146
- /**
147
- *
148
- * @return {SearchBuilder} this
149
- */
150
- SearchBuilder.prototype.isGL = function (bool) {
151
- if (bool === void 0) { bool = true; }
152
- if (bool) {
153
- this.set({ isgl: 1 });
154
- }
155
- else {
156
- this.set({ notgl: 1 });
157
- }
158
- return this;
159
- };
160
- /**
161
- *
162
- * @return {SearchBuilder} this
163
- */
164
- SearchBuilder.prototype.isZankoku = function (bool) {
165
- if (bool === void 0) { bool = true; }
166
- if (bool) {
167
- this.set({ iszankoku: 1 });
168
- }
169
- else {
170
- this.set({ notzankoku: 1 });
171
- }
172
- return this;
173
- };
174
- /**
175
- *
176
- * @return {SearchBuilder} this
177
- */
178
- SearchBuilder.prototype.isTensei = function (bool) {
179
- if (bool === void 0) { bool = true; }
180
- if (bool) {
181
- this.set({ istensei: 1 });
182
- }
183
- else {
184
- this.set({ nottensei: 1 });
185
- }
186
- return this;
187
- };
188
- /**
189
- *
190
- * @return {SearchBuilder} this
191
- */
192
- SearchBuilder.prototype.isTenni = function (bool) {
193
- if (bool === void 0) { bool = true; }
194
- if (bool) {
195
- this.set({ istenni: 1 });
196
- }
197
- else {
198
- this.set({ nottenni: 1 });
199
- }
200
- return this;
201
- };
202
- /**
203
- *
204
- * @return {SearchBuilder} this
205
- */
206
- SearchBuilder.prototype.isTT = function () {
207
- this.set({ istt: 1 });
208
- return this;
209
- };
210
- /**
211
- *
212
- * @return {SearchBuilder} this
213
- */
214
- SearchBuilder.prototype.length = function (length) {
215
- this.set({ length: array2string(length) });
216
- return this;
217
- };
218
- SearchBuilder.prototype.kaiwaritu = function (min, max) {
219
- var n;
220
- if (max != null) {
221
- n = min + "-" + max;
222
- }
223
- else {
224
- n = min;
225
- }
226
- this.set({ kaiwaritu: n });
227
- return this;
228
- };
229
- /**
230
- *
231
- * @return {SearchBuilder} this
232
- */
233
- SearchBuilder.prototype.sasie = function (num) {
234
- this.set({ sasie: array2string(num) });
235
- return this;
236
- };
237
- /**
238
- *
239
- * @return {SearchBuilder} this
240
- */
241
- SearchBuilder.prototype.time = function (num) {
242
- this.set({ time: array2string(num) });
243
- return this;
244
- };
245
- /**
246
- *
247
- * @return {SearchBuilder} this
248
- */
249
- SearchBuilder.prototype.ncode = function (ncodes) {
250
- this.set({ ncode: array2string(ncodes) });
251
- return this;
252
- };
253
- /**
254
- *
255
- * @return {SearchBuilder} this
256
- */
257
- SearchBuilder.prototype.type = function (type) {
258
- this.set({ type: type });
259
- return this;
260
- };
261
- /**
262
- *
263
- * @return {SearchBuilder} this
264
- */
265
- SearchBuilder.prototype.buntai = function (buntai) {
266
- this.set({ buntai: array2string(buntai) });
267
- return this;
268
- };
269
- /**
270
- *
271
- * @return {SearchBuilder} this
272
- */
273
- SearchBuilder.prototype.isStop = function (bool) {
274
- if (bool === void 0) { bool = true; }
275
- this.set({ stop: bool ? 1 : 0 });
276
- return this;
277
- };
278
- /**
279
- *
280
- * @return {SearchBuilder} this
281
- */
282
- SearchBuilder.prototype.isPickup = function (bool) {
283
- if (bool === void 0) { bool = true; }
284
- this.set({ ispickup: bool ? 1 : 0 });
285
- return this;
286
- };
287
- SearchBuilder.prototype.lastUpdate = function (x, y) {
288
- var date;
289
- if (typeof x == "string") {
290
- date = x;
291
- }
292
- else if (x instanceof Date && y instanceof Date) {
293
- date = Math.floor(x.getTime() / 1000) + "-" + Math.floor(x.getTime() / 1000);
294
- }
295
- else {
296
- date = x + "-" + y;
297
- }
298
- this.set({ lastup: date });
299
- return this;
300
- };
301
- /**
302
- *
303
- * @return {SearchBuilder} this
304
- */
305
- SearchBuilder.prototype.fields = function (fields) {
306
- this.set({ of: array2string(fields) });
307
- return this;
308
- };
309
- /**
310
- *
311
- * @return {SearchBuilder} this
312
- */
313
- SearchBuilder.prototype.limit = function (num) {
314
- this.set({ lim: num });
315
- return this;
316
- };
317
- /**
318
- *
319
- * @return {SearchBuilder} this
320
- */
321
- SearchBuilder.prototype.start = function (num) {
322
- this.set({ st: num });
323
- return this;
324
- };
325
- /**
326
- *
327
- * @return {SearchBuilder} this
328
- */
329
- SearchBuilder.prototype.page = function (no, count) {
330
- if (count === void 0) { count = 20; }
331
- return this.limit(count).start(no * count);
332
- };
333
- SearchBuilder.prototype.opt = function (option) {
334
- return this.set({ opt: option });
335
- };
336
- /**
337
- * 出力順序を指定する。指定しない場合は新着順となります。
338
- *
339
- * @description
340
- * allunique 閲覧者の多い順(未実装)
341
- * favnovelcnt ブックマーク数の多い順
342
- * reviewcnt レビュー数の多い順
343
- * hyoka 総合評価の高い順
344
- * hyokaasc 総合評価の低い順
345
- * impressioncnt 感想の多い順
346
- * hyokacnt 評価者数の多い順
347
- * hyokacntasc 評価者数の少ない順
348
- * weekly 週間ユニークユーザの多い順 毎週火曜日早朝リセット
349
- * (前週の日曜日から土曜日分)
350
- * lengthdesc 小説本文の文字数が多い順
351
- * lengthasc 小説本文の文字数が少ない順
352
- * ncodedesc Nコードが新しい順
353
- * old 古い順
354
- * @param {Order} order 出力順序
355
- * @return {SearchBuilder} this
356
- */
357
- SearchBuilder.prototype.order = function (order) {
358
- this.set({ order: order });
359
- return this;
360
- };
361
- /**
362
- * gzip圧縮する。
363
- *
364
- * 転送量上限を減らすためにも推奨
365
- * @param {GzipLevel} level gzip圧縮レベル(1~5)
366
- * @return {SearchBuilder} this
367
- */
368
- SearchBuilder.prototype.gzip = function (level) {
369
- this.set({ gzip: level });
370
- return this;
371
- };
372
- /**
373
- * クエリパラメータをセットする
374
- * @private
375
- * @return {SearchBuilder} this
376
- */
377
- SearchBuilder.prototype.set = function (obj) {
378
- this.params = __assign(__assign({}, this.params), obj);
379
- return this;
380
- };
381
- /**
382
- * クエリパラメータを削除する
383
- * @private
384
- * @return {SearchBuilder} this
385
- */
386
- SearchBuilder.prototype.unset = function (key) {
387
- delete this.params[key];
388
- return this;
389
- };
390
- /**
391
- * なろう小説APIへの検索リクエストを実行する
392
- * @returns {Promise<NarouSearchResults>} 検索結果
393
- */
394
- SearchBuilder.prototype.execute = function () {
395
- return api.executeNovel(this.params);
396
- };
397
- return SearchBuilder;
398
- }());
399
- export default SearchBuilder;
400
- function distinct(array) {
401
- return Array.from(new Set(array));
402
- }
403
- function array2string(n) {
404
- if (Array.isArray(n)) {
405
- return distinct(n).join("-");
406
- }
407
- else {
408
- return n.toString();
409
- }
410
- }
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
+ /**
13
+ * 検索ヘルパー
14
+ * @class SearchBuilder
15
+ */
16
+ var SearchBuilder = /** @class */ (function () {
17
+ /**
18
+ * constructor
19
+ * @private
20
+ */
21
+ function SearchBuilder(params, api) {
22
+ if (params === void 0) { params = {}; }
23
+ this.params = params;
24
+ this.api = api;
25
+ }
26
+ /**
27
+ * a
28
+ * @return {SearchBuilder} this
29
+ */
30
+ SearchBuilder.prototype.word = function (word) {
31
+ this.set({ word: word });
32
+ return this;
33
+ };
34
+ /**
35
+ *
36
+ * @return {SearchBuilder} this
37
+ */
38
+ SearchBuilder.prototype.notWord = function (word) {
39
+ this.set({ notword: word });
40
+ return this;
41
+ };
42
+ /**
43
+ *
44
+ * @return {SearchBuilder} this
45
+ */
46
+ SearchBuilder.prototype.byTitle = function (bool) {
47
+ if (bool === void 0) { bool = true; }
48
+ this.set({ title: bool ? 1 : 0 });
49
+ return this;
50
+ };
51
+ /**
52
+ *
53
+ * @return {SearchBuilder} this
54
+ */
55
+ SearchBuilder.prototype.byOutline = function (bool) {
56
+ if (bool === void 0) { bool = true; }
57
+ this.set({ ex: bool ? 1 : 0 });
58
+ return this;
59
+ };
60
+ /**
61
+ *
62
+ * @return {SearchBuilder} this
63
+ */
64
+ SearchBuilder.prototype.byKeyword = function (bool) {
65
+ if (bool === void 0) { bool = true; }
66
+ this.set({ keyword: bool ? 1 : 0 });
67
+ return this;
68
+ };
69
+ /**
70
+ *
71
+ * @return {SearchBuilder} this
72
+ */
73
+ SearchBuilder.prototype.byAuthor = function (bool) {
74
+ if (bool === void 0) { bool = true; }
75
+ this.set({ wname: bool ? 1 : 0 });
76
+ return this;
77
+ };
78
+ /**
79
+ *
80
+ * @return {SearchBuilder} this
81
+ */
82
+ SearchBuilder.prototype.bigGenre = function (genre) {
83
+ this.set({ biggenre: array2string(genre) });
84
+ return this;
85
+ };
86
+ /**
87
+ *
88
+ * @return {SearchBuilder} this
89
+ */
90
+ SearchBuilder.prototype.notBigGenre = function (genre) {
91
+ this.set({ notbiggenre: array2string(genre) });
92
+ return this;
93
+ };
94
+ /**
95
+ *
96
+ * @return {SearchBuilder} this
97
+ */
98
+ SearchBuilder.prototype.genre = function (genre) {
99
+ this.set({ genre: array2string(genre) });
100
+ return this;
101
+ };
102
+ /**
103
+ *
104
+ * @return {SearchBuilder} this
105
+ */
106
+ SearchBuilder.prototype.notGenre = function (genre) {
107
+ this.set({ notgenre: array2string(genre) });
108
+ return this;
109
+ };
110
+ /**
111
+ *
112
+ * @return {SearchBuilder} this
113
+ */
114
+ SearchBuilder.prototype.userId = function (ids) {
115
+ this.set({ userid: array2string(ids) });
116
+ return this;
117
+ };
118
+ /**
119
+ *
120
+ * @return {SearchBuilder} this
121
+ */
122
+ SearchBuilder.prototype.isR15 = function (bool) {
123
+ if (bool === void 0) { bool = true; }
124
+ if (bool) {
125
+ this.set({ isr15: 1 });
126
+ }
127
+ else {
128
+ this.set({ notr15: 1 });
129
+ }
130
+ return this;
131
+ };
132
+ /**
133
+ *
134
+ * @return {SearchBuilder} this
135
+ */
136
+ SearchBuilder.prototype.isBL = function (bool) {
137
+ if (bool === void 0) { bool = true; }
138
+ if (bool) {
139
+ this.set({ isbl: 1 });
140
+ }
141
+ else {
142
+ this.set({ notbl: 1 });
143
+ }
144
+ return this;
145
+ };
146
+ /**
147
+ *
148
+ * @return {SearchBuilder} this
149
+ */
150
+ SearchBuilder.prototype.isGL = function (bool) {
151
+ if (bool === void 0) { bool = true; }
152
+ if (bool) {
153
+ this.set({ isgl: 1 });
154
+ }
155
+ else {
156
+ this.set({ notgl: 1 });
157
+ }
158
+ return this;
159
+ };
160
+ /**
161
+ *
162
+ * @return {SearchBuilder} this
163
+ */
164
+ SearchBuilder.prototype.isZankoku = function (bool) {
165
+ if (bool === void 0) { bool = true; }
166
+ if (bool) {
167
+ this.set({ iszankoku: 1 });
168
+ }
169
+ else {
170
+ this.set({ notzankoku: 1 });
171
+ }
172
+ return this;
173
+ };
174
+ /**
175
+ *
176
+ * @return {SearchBuilder} this
177
+ */
178
+ SearchBuilder.prototype.isTensei = function (bool) {
179
+ if (bool === void 0) { bool = true; }
180
+ if (bool) {
181
+ this.set({ istensei: 1 });
182
+ }
183
+ else {
184
+ this.set({ nottensei: 1 });
185
+ }
186
+ return this;
187
+ };
188
+ /**
189
+ *
190
+ * @return {SearchBuilder} this
191
+ */
192
+ SearchBuilder.prototype.isTenni = function (bool) {
193
+ if (bool === void 0) { bool = true; }
194
+ if (bool) {
195
+ this.set({ istenni: 1 });
196
+ }
197
+ else {
198
+ this.set({ nottenni: 1 });
199
+ }
200
+ return this;
201
+ };
202
+ /**
203
+ *
204
+ * @return {SearchBuilder} this
205
+ */
206
+ SearchBuilder.prototype.isTT = function () {
207
+ this.set({ istt: 1 });
208
+ return this;
209
+ };
210
+ /**
211
+ *
212
+ * @return {SearchBuilder} this
213
+ */
214
+ SearchBuilder.prototype.length = function (length) {
215
+ this.set({ length: array2string(length) });
216
+ return this;
217
+ };
218
+ SearchBuilder.prototype.kaiwaritu = function (min, max) {
219
+ var n;
220
+ if (max != null) {
221
+ n = min + "-" + max;
222
+ }
223
+ else {
224
+ n = min;
225
+ }
226
+ this.set({ kaiwaritu: n });
227
+ return this;
228
+ };
229
+ /**
230
+ *
231
+ * @return {SearchBuilder} this
232
+ */
233
+ SearchBuilder.prototype.sasie = function (num) {
234
+ this.set({ sasie: array2string(num) });
235
+ return this;
236
+ };
237
+ /**
238
+ *
239
+ * @return {SearchBuilder} this
240
+ */
241
+ SearchBuilder.prototype.time = function (num) {
242
+ this.set({ time: array2string(num) });
243
+ return this;
244
+ };
245
+ /**
246
+ *
247
+ * @return {SearchBuilder} this
248
+ */
249
+ SearchBuilder.prototype.ncode = function (ncodes) {
250
+ this.set({ ncode: array2string(ncodes) });
251
+ return this;
252
+ };
253
+ /**
254
+ *
255
+ * @return {SearchBuilder} this
256
+ */
257
+ SearchBuilder.prototype.type = function (type) {
258
+ this.set({ type: type });
259
+ return this;
260
+ };
261
+ /**
262
+ *
263
+ * @return {SearchBuilder} this
264
+ */
265
+ SearchBuilder.prototype.buntai = function (buntai) {
266
+ this.set({ buntai: array2string(buntai) });
267
+ return this;
268
+ };
269
+ /**
270
+ *
271
+ * @return {SearchBuilder} this
272
+ */
273
+ SearchBuilder.prototype.isStop = function (bool) {
274
+ if (bool === void 0) { bool = true; }
275
+ this.set({ stop: bool ? 1 : 0 });
276
+ return this;
277
+ };
278
+ /**
279
+ *
280
+ * @return {SearchBuilder} this
281
+ */
282
+ SearchBuilder.prototype.isPickup = function (bool) {
283
+ if (bool === void 0) { bool = true; }
284
+ this.set({ ispickup: bool ? 1 : 0 });
285
+ return this;
286
+ };
287
+ SearchBuilder.prototype.lastUpdate = function (x, y) {
288
+ var date;
289
+ if (typeof x == "string") {
290
+ date = x;
291
+ }
292
+ else if (x instanceof Date && y instanceof Date) {
293
+ date = Math.floor(x.getTime() / 1000) + "-" + Math.floor(x.getTime() / 1000);
294
+ }
295
+ else {
296
+ date = x + "-" + y;
297
+ }
298
+ this.set({ lastup: date });
299
+ return this;
300
+ };
301
+ /**
302
+ *
303
+ * @return {SearchBuilder} this
304
+ */
305
+ SearchBuilder.prototype.fields = function (fields) {
306
+ this.set({ of: array2string(fields) });
307
+ return this;
308
+ };
309
+ /**
310
+ *
311
+ * @return {SearchBuilder} this
312
+ */
313
+ SearchBuilder.prototype.limit = function (num) {
314
+ this.set({ lim: num });
315
+ return this;
316
+ };
317
+ /**
318
+ *
319
+ * @return {SearchBuilder} this
320
+ */
321
+ SearchBuilder.prototype.start = function (num) {
322
+ this.set({ st: num });
323
+ return this;
324
+ };
325
+ /**
326
+ *
327
+ * @return {SearchBuilder} this
328
+ */
329
+ SearchBuilder.prototype.page = function (no, count) {
330
+ if (count === void 0) { count = 20; }
331
+ return this.limit(count).start(no * count);
332
+ };
333
+ SearchBuilder.prototype.opt = function (option) {
334
+ return this.set({ opt: option });
335
+ };
336
+ /**
337
+ * 出力順序を指定する。指定しない場合は新着順となります。
338
+ *
339
+ * @description
340
+ * allunique 閲覧者の多い順(未実装)
341
+ * favnovelcnt ブックマーク数の多い順
342
+ * reviewcnt レビュー数の多い順
343
+ * hyoka 総合評価の高い順
344
+ * hyokaasc 総合評価の低い順
345
+ * impressioncnt 感想の多い順
346
+ * hyokacnt 評価者数の多い順
347
+ * hyokacntasc 評価者数の少ない順
348
+ * weekly 週間ユニークユーザの多い順 毎週火曜日早朝リセット
349
+ * (前週の日曜日から土曜日分)
350
+ * lengthdesc 小説本文の文字数が多い順
351
+ * lengthasc 小説本文の文字数が少ない順
352
+ * ncodedesc Nコードが新しい順
353
+ * old 古い順
354
+ * @param {Order} order 出力順序
355
+ * @return {SearchBuilder} this
356
+ */
357
+ SearchBuilder.prototype.order = function (order) {
358
+ this.set({ order: order });
359
+ return this;
360
+ };
361
+ /**
362
+ * gzip圧縮する。
363
+ *
364
+ * 転送量上限を減らすためにも推奨
365
+ * @param {GzipLevel} level gzip圧縮レベル(1~5)
366
+ * @return {SearchBuilder} this
367
+ */
368
+ SearchBuilder.prototype.gzip = function (level) {
369
+ this.set({ gzip: level });
370
+ return this;
371
+ };
372
+ /**
373
+ * クエリパラメータをセットする
374
+ * @private
375
+ * @return {SearchBuilder} this
376
+ */
377
+ SearchBuilder.prototype.set = function (obj) {
378
+ this.params = __assign(__assign({}, this.params), obj);
379
+ return this;
380
+ };
381
+ /**
382
+ * クエリパラメータを削除する
383
+ * @private
384
+ * @return {SearchBuilder} this
385
+ */
386
+ SearchBuilder.prototype.unset = function (key) {
387
+ delete this.params[key];
388
+ return this;
389
+ };
390
+ /**
391
+ * なろう小説APIへの検索リクエストを実行する
392
+ * @returns {Promise<NarouSearchResults>} 検索結果
393
+ */
394
+ SearchBuilder.prototype.execute = function () {
395
+ return this.api.executeNovel(this.params);
396
+ };
397
+ return SearchBuilder;
398
+ }());
399
+ export default SearchBuilder;
400
+ function distinct(array) {
401
+ return Array.from(new Set(array));
402
+ }
403
+ function array2string(n) {
404
+ if (Array.isArray(n)) {
405
+ return distinct(n).join("-");
406
+ }
407
+ else {
408
+ return n.toString();
409
+ }
410
+ }
411
411
  //# sourceMappingURL=search-builder.js.map