booru 2.7.0 → 2.8.0
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.
- package/LICENSE.md +1 -1
- package/dist/Constants.d.ts +1 -0
- package/dist/Constants.d.ts.map +1 -1
- package/dist/Constants.js +11 -5
- package/dist/Constants.js.map +1 -1
- package/dist/Utils.d.ts +10 -2
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +38 -4
- package/dist/Utils.js.map +1 -1
- package/dist/boorus/Booru.d.ts +29 -0
- package/dist/boorus/Booru.d.ts.map +1 -1
- package/dist/boorus/Booru.js +84 -3
- package/dist/boorus/Booru.js.map +1 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/sites.json +24 -12
- package/dist/structures/SearchResults.d.ts.map +1 -1
- package/dist/structures/SearchResults.js.map +1 -1
- package/dist/structures/SiteApi.d.ts +2 -0
- package/dist/structures/SiteApi.d.ts.map +1 -1
- package/dist/structures/SiteApi.js.map +1 -1
- package/dist/structures/Tag.d.ts +42 -0
- package/dist/structures/Tag.d.ts.map +1 -0
- package/dist/structures/Tag.js +52 -0
- package/dist/structures/Tag.js.map +1 -0
- package/dist/structures/TagListParameters.d.ts +14 -0
- package/dist/structures/TagListParameters.d.ts.map +1 -0
- package/dist/structures/TagListParameters.js +7 -0
- package/dist/structures/TagListParameters.js.map +1 -0
- package/dist/structures/TagListResults.d.ts +53 -0
- package/dist/structures/TagListResults.d.ts.map +1 -0
- package/dist/structures/TagListResults.js +73 -0
- package/dist/structures/TagListResults.js.map +1 -0
- package/package.json +14 -15
- package/readme.md +22 -5
package/dist/index.js
CHANGED
|
@@ -10,21 +10,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
10
|
exports.XmlBooru = exports.Site = exports.SearchResults = exports.Post = exports.Derpibooru = exports.resolveSite = exports.sites = exports.BooruError = exports.BooruClass = void 0;
|
|
11
11
|
exports.forSite = booruForSite;
|
|
12
12
|
exports.search = search;
|
|
13
|
+
exports.tagList = tagList;
|
|
13
14
|
exports.commonfy = commonfy;
|
|
14
|
-
const Constants_1 = require("./Constants");
|
|
15
15
|
const node_util_1 = require("node:util");
|
|
16
|
-
const Utils_1 = require("./Utils");
|
|
17
16
|
const Booru_1 = __importDefault(require("./boorus/Booru"));
|
|
18
17
|
const Derpibooru_1 = __importDefault(require("./boorus/Derpibooru"));
|
|
19
18
|
exports.Derpibooru = Derpibooru_1.default;
|
|
20
19
|
const XmlBooru_1 = __importDefault(require("./boorus/XmlBooru"));
|
|
21
20
|
exports.XmlBooru = XmlBooru_1.default;
|
|
21
|
+
const Constants_1 = require("./Constants");
|
|
22
22
|
const Post_1 = __importDefault(require("./structures/Post"));
|
|
23
23
|
exports.Post = Post_1.default;
|
|
24
24
|
const SearchResults_1 = __importDefault(require("./structures/SearchResults"));
|
|
25
25
|
exports.SearchResults = SearchResults_1.default;
|
|
26
26
|
const Site_1 = __importDefault(require("./structures/Site"));
|
|
27
27
|
exports.Site = Site_1.default;
|
|
28
|
+
const Utils_1 = require("./Utils");
|
|
28
29
|
const BooruTypes = {
|
|
29
30
|
derpi: Derpibooru_1.default,
|
|
30
31
|
xml: XmlBooru_1.default,
|
|
@@ -96,6 +97,31 @@ function search(site, tags = [], { limit = 1, random = false, page = 0, credenti
|
|
|
96
97
|
booruCache[rSite].credentials = credentials;
|
|
97
98
|
return booruCache[rSite].search(tags, { limit, random, page });
|
|
98
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Get a list of tags from a site
|
|
102
|
+
* @param {String} site The site to get the tags from
|
|
103
|
+
* @param {TagListParameters} [options={}] The options for the tag list
|
|
104
|
+
* @return {Promise<TagListResults>} A promise with the tags as an array of objects
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```
|
|
108
|
+
* const Booru = require('booru')
|
|
109
|
+
* // Returns a promise with the first 100 tags from e926
|
|
110
|
+
* Booru.tagList('e926')
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
function tagList(site, { limit = 1, page = 0, credentials = {} } = {}) {
|
|
114
|
+
const rSite = (0, Utils_1.resolveSite)(site);
|
|
115
|
+
if (rSite === null) {
|
|
116
|
+
throw new Constants_1.BooruError('Site not supported');
|
|
117
|
+
}
|
|
118
|
+
const booruSite = new Site_1.default(Constants_1.sites[rSite]);
|
|
119
|
+
if (!booruCache[rSite]) {
|
|
120
|
+
booruCache[rSite] = booruFrom(booruSite, credentials);
|
|
121
|
+
}
|
|
122
|
+
booruCache[rSite].credentials = credentials;
|
|
123
|
+
return booruCache[rSite].tagList({ limit, page });
|
|
124
|
+
}
|
|
99
125
|
const deprecatedCommonfy = (0, node_util_1.deprecate)(() => { }, 'Common is now deprecated, just access the properties directly');
|
|
100
126
|
/**
|
|
101
127
|
* Deprecated, now a noop
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAwDsB,+BAAO;AA0BhC,wBAgCC;AAeD,0BAkBC;AAgBD,4BAGC;AApKD,yCAAqC;AACrC,2DAA6D;AAC7D,qEAA4C;AAuKnC,qBAvKF,oBAAU,CAuKE;AAtKnB,iEAAwC;AAsKQ,mBAtKzC,kBAAQ,CAsKyC;AArKxD,2CAA6D;AAC7D,6DAAoC;AAoKf,eApKd,cAAI,CAoKc;AAlKzB,+EAAsD;AAkK3B,wBAlKpB,uBAAa,CAkKoB;AAjKxC,6DAAoC;AAiKM,eAjKnC,cAAI,CAiKmC;AA9J9C,mCAAqC;AAErC,MAAM,UAAU,GAAiC;IAC/C,KAAK,EAAE,oBAAU;IACjB,GAAG,EAAE,kBAAQ;CACd,CAAA;AAED,M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AW,CAAC,CAAA;IACvD,CAAC;IAED,UAAU,CAAC,KAAK,CAAC,CAAC,WAAW,GAAG,WAAW,CAAA;IAC3C,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;AACnD,CAAC;AAED,MAAM,kBAAkB,GAAG,IAAA,qBAAS,EAClC,GAAG,EAAE,GAAE,CAAC,EACR,+DAA+D,CAChE,CAAA;AAED;;;;;;;;GAQG;AACH,SAAgB,QAAQ,CAAC,MAAc;IACrC,kBAAkB,EAAE,CAAA;IACpB,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC;AAED,wCAAoD;AAA3C,mGAAA,KAAK,OAAc;AAC5B,yCAA+C;AAAtC,uGAAA,UAAU,OAAA;AAAE,kGAAA,KAAK,OAAA;AAC1B,iCAAqC;AAA5B,oGAAA,WAAW,OAAA","sourcesContent":["/**\n * @packageDocumentation\n * @module Index\n */\n\nimport { deprecate } from 'node:util'\nimport Booru, { type BooruCredentials } from './boorus/Booru'\nimport Derpibooru from './boorus/Derpibooru'\nimport XmlBooru from './boorus/XmlBooru'\nimport { type AnySite, BooruError, sites } from './Constants'\nimport Post from './structures/Post'\nimport type SearchParameters from './structures/SearchParameters'\nimport SearchResults from './structures/SearchResults'\nimport Site from './structures/Site'\nimport type TagListParameters from './structures/TagListParameters'\nimport type TagListResults from './structures/TagListResults'\nimport { resolveSite } from './Utils'\n\nconst BooruTypes: Record<string, typeof Booru> = {\n derpi: Derpibooru,\n xml: XmlBooru,\n}\n\nconst booruCache: Partial<Record<AnySite, Booru>> = {}\n\n/**\n * Create a new booru, if special type, use that booru, else use default Booru\n *\n * @param booruSite The site to use\n * @param credentials The credentials to use, if any\n * @return A new booru\n */\nfunction booruFrom(booruSite: Site, credentials?: BooruCredentials): Booru {\n return new (\n booruSite.type !== undefined && BooruTypes[booruSite.type]\n ? BooruTypes[booruSite.type]\n : Booru\n )(booruSite, credentials)\n}\n\n/**\n * Create a new booru to search with\n *\n * @constructor\n * @param {String} site The {@link Site} domain (or alias of it) to create a booru from\n * @param {BooruCredentials} credentials The credentials to use on this booru\n * @return {Booru} A booru to use\n */\nfunction booruForSite(site: string, credentials?: BooruCredentials): Booru {\n const rSite = resolveSite(site)\n\n if (!rSite) throw new BooruError('Site not supported')\n\n const booruSite = new Site(sites[rSite])\n\n // If special type, use that booru, else use default Booru\n return booruFrom(booruSite, credentials)\n}\n\nexport { booruForSite as forSite }\nexport default booruForSite\n\nexport interface BooruSearch extends SearchParameters {\n credentials?: BooruCredentials\n}\n\nexport interface BooruTagList extends TagListParameters {\n credentials?: BooruCredentials\n}\n\n/**\n * Searches a site for images with tags and returns the results\n * @param {String} site The site to search\n * @param {String[]|String} [tags=[]] Tags to search with\n * @param {SearchParameters} [searchOptions={}] The options for searching\n * if provided (Unused)\n * @return {Promise<SearchResults>} A promise with the images as an array of objects\n *\n * @example\n * ```\n * const Booru = require('booru')\n * // Returns a promise with the latest cute glace pic from e926\n * Booru.search('e926', ['glaceon', 'cute'])\n * ```\n */\nexport function search(\n site: string,\n tags: string[] | string = [],\n { limit = 1, random = false, page = 0, credentials = {} }: BooruSearch = {},\n): Promise<SearchResults> {\n const rSite = resolveSite(site)\n\n if (typeof limit === 'string') {\n limit = Number.parseInt(limit, 10)\n }\n\n if (rSite === null) {\n throw new BooruError('Site not supported')\n }\n\n if (!Array.isArray(tags) && typeof tags !== 'string') {\n throw new BooruError('`tags` should be an array or string')\n }\n\n if (typeof limit !== 'number' || Number.isNaN(limit)) {\n throw new BooruError('`limit` should be an int')\n }\n\n const booruSite = new Site(sites[rSite])\n\n if (!booruCache[rSite]) {\n booruCache[rSite] = booruFrom(booruSite, credentials)\n }\n\n // This is ugly and a hack, I know this\n booruCache[rSite].credentials = credentials\n return booruCache[rSite].search(tags, { limit, random, page })\n}\n\n/**\n * Get a list of tags from a site\n * @param {String} site The site to get the tags from\n * @param {TagListParameters} [options={}] The options for the tag list\n * @return {Promise<TagListResults>} A promise with the tags as an array of objects\n *\n * @example\n * ```\n * const Booru = require('booru')\n * // Returns a promise with the first 100 tags from e926\n * Booru.tagList('e926')\n * ```\n */\nexport function tagList(\n site: string,\n { limit = 1, page = 0, credentials = {} }: BooruTagList = {},\n): Promise<TagListResults> {\n const rSite = resolveSite(site)\n\n if (rSite === null) {\n throw new BooruError('Site not supported')\n }\n\n const booruSite = new Site(sites[rSite])\n\n if (!booruCache[rSite]) {\n booruCache[rSite] = booruFrom(booruSite, credentials)\n }\n\n booruCache[rSite].credentials = credentials\n return booruCache[rSite].tagList({ limit, page })\n}\n\nconst deprecatedCommonfy = deprecate(\n () => {},\n 'Common is now deprecated, just access the properties directly',\n)\n\n/**\n * Deprecated, now a noop\n * <p>This will be removed *soon* please stop using it</p>\n * <p>Just access <code><{@link Post}>.prop</code>, no need to commonfy anymore\n *\n * @deprecated Just use <code><{@link Post}>.prop</code> instead\n * @param {Post[]} images Array of {@link Post} objects\n * @return {Promise<Post[]>} Array of {@link Post} objects\n */\nexport function commonfy(images: Post[]): Promise<Post[]> {\n deprecatedCommonfy()\n return Promise.resolve(images)\n}\n\nexport { Booru as BooruClass } from './boorus/Booru'\nexport { BooruError, sites } from './Constants'\nexport { resolveSite } from './Utils'\nexport { Derpibooru, Post, SearchResults, Site, XmlBooru }\nexport type { BooruCredentials, SearchParameters }\n"]}
|
package/dist/sites.json
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"nsfw": true,
|
|
9
9
|
"api": {
|
|
10
10
|
"search": "/posts.json?",
|
|
11
|
-
"postView": "/post/show/"
|
|
11
|
+
"postView": "/post/show/",
|
|
12
|
+
"tagList": "/tags.json?"
|
|
12
13
|
},
|
|
13
14
|
"random": true
|
|
14
15
|
},
|
|
@@ -21,7 +22,8 @@
|
|
|
21
22
|
"nsfw": false,
|
|
22
23
|
"api": {
|
|
23
24
|
"search": "/posts.json?",
|
|
24
|
-
"postView": "/post/show/"
|
|
25
|
+
"postView": "/post/show/",
|
|
26
|
+
"tagList": "/tags.json?"
|
|
25
27
|
},
|
|
26
28
|
"random": true,
|
|
27
29
|
"defaultTags": ["rating:safe"]
|
|
@@ -36,7 +38,8 @@
|
|
|
36
38
|
"nsfw": true,
|
|
37
39
|
"api": {
|
|
38
40
|
"search": "/index.php?page=dapi&s=post&q=index&json=1&",
|
|
39
|
-
"postView": "/post/show/"
|
|
41
|
+
"postView": "/post/show/",
|
|
42
|
+
"tagList": "/index.php?page=dapi&s=tag&q=index&json=1&"
|
|
40
43
|
},
|
|
41
44
|
"paginate": "pid",
|
|
42
45
|
"random": false
|
|
@@ -51,7 +54,8 @@
|
|
|
51
54
|
"nsfw": true,
|
|
52
55
|
"api": {
|
|
53
56
|
"search": "/posts.json?",
|
|
54
|
-
"postView": "/posts/"
|
|
57
|
+
"postView": "/posts/",
|
|
58
|
+
"tagList": "/tags.json?"
|
|
55
59
|
},
|
|
56
60
|
"random": true
|
|
57
61
|
},
|
|
@@ -65,7 +69,8 @@
|
|
|
65
69
|
"nsfw": true,
|
|
66
70
|
"api": {
|
|
67
71
|
"search": "/post.json?",
|
|
68
|
-
"postView": "/post/show/"
|
|
72
|
+
"postView": "/post/show/",
|
|
73
|
+
"tagList": "/tag.json?"
|
|
69
74
|
},
|
|
70
75
|
"random": true
|
|
71
76
|
},
|
|
@@ -79,7 +84,8 @@
|
|
|
79
84
|
"nsfw": false,
|
|
80
85
|
"api": {
|
|
81
86
|
"search": "/post.json?",
|
|
82
|
-
"postView": "/post/show/"
|
|
87
|
+
"postView": "/post/show/",
|
|
88
|
+
"tagList": "/tag.json?"
|
|
83
89
|
},
|
|
84
90
|
"random": true
|
|
85
91
|
},
|
|
@@ -93,7 +99,8 @@
|
|
|
93
99
|
"nsfw": true,
|
|
94
100
|
"api": {
|
|
95
101
|
"search": "/post.json?",
|
|
96
|
-
"postView": "/post/show/"
|
|
102
|
+
"postView": "/post/show/",
|
|
103
|
+
"tagList": "/tag.json?"
|
|
97
104
|
},
|
|
98
105
|
"random": true
|
|
99
106
|
},
|
|
@@ -107,7 +114,8 @@
|
|
|
107
114
|
"nsfw": true,
|
|
108
115
|
"api": {
|
|
109
116
|
"search": "/index.php?page=dapi&s=post&q=index&json=1&",
|
|
110
|
-
"postView": "/index.php?page=post&s=view&json=1&id="
|
|
117
|
+
"postView": "/index.php?page=post&s=view&json=1&id=",
|
|
118
|
+
"tagList": "/index.php?page=dapi&s=tag&q=index&json=1&"
|
|
111
119
|
},
|
|
112
120
|
"paginate": "pid",
|
|
113
121
|
"random": false
|
|
@@ -121,7 +129,8 @@
|
|
|
121
129
|
"nsfw": true,
|
|
122
130
|
"api": {
|
|
123
131
|
"search": "/index.php?page=dapi&s=post&q=index&json=1&",
|
|
124
|
-
"postView": "/index.php?page=post&s=view&json=1&id="
|
|
132
|
+
"postView": "/index.php?page=post&s=view&json=1&id=",
|
|
133
|
+
"tagList": "/index.php?page=dapi&s=tag&q=index&json=1&"
|
|
125
134
|
},
|
|
126
135
|
"paginate": "pid",
|
|
127
136
|
"random": false
|
|
@@ -136,7 +145,8 @@
|
|
|
136
145
|
"nsfw": false,
|
|
137
146
|
"api": {
|
|
138
147
|
"search": "/index.php?page=dapi&s=post&q=index&json=1&",
|
|
139
|
-
"postView": "/index.php?page=post&s=view&json=1&id="
|
|
148
|
+
"postView": "/index.php?page=post&s=view&json=1&id=",
|
|
149
|
+
"tagList": "/index.php?page=dapi&s=tag&q=index&json=1&"
|
|
140
150
|
},
|
|
141
151
|
"paginate": "pid",
|
|
142
152
|
"random": false
|
|
@@ -151,7 +161,8 @@
|
|
|
151
161
|
"nsfw": false,
|
|
152
162
|
"api": {
|
|
153
163
|
"search": "/index.php?page=dapi&s=post&q=index&json=1&",
|
|
154
|
-
"postView": "/index.php?page=post&s=view&json=1&id="
|
|
164
|
+
"postView": "/index.php?page=post&s=view&json=1&id=",
|
|
165
|
+
"tagList": "/index.php?page=dapi&s=tag&q=index&json=1&"
|
|
155
166
|
},
|
|
156
167
|
"paginate": "pid",
|
|
157
168
|
"random": false
|
|
@@ -165,7 +176,8 @@
|
|
|
165
176
|
"nsfw": true,
|
|
166
177
|
"api": {
|
|
167
178
|
"search": "/index.php?page=dapi&s=post&q=index&json=1&",
|
|
168
|
-
"postView": "/index.php?page=post&s=view&json=1&id="
|
|
179
|
+
"postView": "/index.php?page=post&s=view&json=1&id=",
|
|
180
|
+
"tagList": "/index.php?page=dapi&s=tag&q=index&json=1&"
|
|
169
181
|
},
|
|
170
182
|
"paginate": "pid",
|
|
171
183
|
"random": false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResults.d.ts","sourceRoot":"","sources":["../../src/structures/SearchResults.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"SearchResults.d.ts","sourceRoot":"","sources":["../../src/structures/SearchResults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAA;AAE1C,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAA;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,KAAK,CAAC,IAAI,CAAC;IACpD,qCAAqC;IAC9B,KAAK,EAAE,KAAK,CAAA;IACnB,8BAA8B;IACvB,IAAI,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,SAAgB,IAAI,EAAE,MAAM,EAAE,CAAA;IAC9B,uCAAuC;IACvC,SAAgB,OAAO,EAAE,gBAAgB,CAAA;IACzC,wCAAwC;IACxC,SAAgB,KAAK,EAAE,IAAI,EAAE,CAAA;IAE7B,eAAe;gBAEb,KAAK,EAAE,IAAI,EAAE,EACb,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,KAAK;IAed;;;OAGG;IACH,IAAI,KAAK,IAAI,IAAI,CAEhB;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,IAAI,CAEf;IAED;;;;OAIG;IACI,QAAQ,IAAI,OAAO,CAAC,aAAa,CAAC;IAOzC;;;;;;;;OAQG;IACI,MAAM,CACX,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EACvB,EAAE,MAAc,EAAE;;KAAK,GACtB,aAAa;IAchB;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,aAAa;CAGzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResults.js","sourceRoot":"","sources":["../../src/structures/SearchResults.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"SearchResults.js","sourceRoot":"","sources":["../../src/structures/SearchResults.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,gDAAiC;AAGjC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAqB,aAAc,SAAQ,KAAW;IACpD,qCAAqC;IAC9B,KAAK,CAAO;IACnB,8BAA8B;IACvB,IAAI,CAAQ;IACnB,oCAAoC;IACpB,IAAI,CAAU;IAC9B,uCAAuC;IACvB,OAAO,CAAkB;IACzC,wCAAwC;IACxB,KAAK,CAAQ;IAE7B,eAAe;IACf,YACE,KAAa,EACb,IAAc,EACd,OAAyB,EACzB,KAAY;QAEZ,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,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AAC,CAAC,CAAA;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACtE,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,IAAuB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5C,CAAC;CACF;AA9FD,gCA8FC","sourcesContent":["/**\n * @packageDocumentation\n * @module Structures\n */\n\nimport type Booru from '../boorus/Booru'\nimport type Post from '../structures/Post'\nimport * as Utils from '../Utils'\nimport type SearchParameters from './SearchParameters'\n\n/**\n * Represents a page of search results, works like an array of {@link Post}\n * <p> Usable like an array and allows to easily get the next page\n *\n * @example\n * ```\n * const Booru = require('booru')\n * // Safebooru\n * const sb = new Booru('sb')\n *\n * const imgs = await sb.search('cat')\n *\n * // Log the images from the first page, then from the second\n * imgs.forEach(i => console.log(i.postView))\n * const imgs2 = await imgs.nextPage()\n * imgs2.forEach(i => console.log(i.postView))\n * ```\n */\nexport default class SearchResults extends Array<Post> {\n /** The booru used for this search */\n public booru: Booru\n /** The page of this search */\n public page: number\n /** The tags used for this search */\n public readonly tags: string[]\n /** The options used for this search */\n public readonly options: SearchParameters\n /** The posts from this search result */\n public readonly posts: Post[]\n\n /** @private */\n constructor(\n posts: Post[],\n tags: string[],\n options: SearchParameters,\n booru: Booru,\n ) {\n super(posts.length)\n\n for (let i = 0; i < posts.length; i++) {\n this[i] = posts[i]\n }\n\n this.posts = posts\n this.tags = tags\n this.options = options\n this.booru = booru\n this.page = options ? (options.page ?? 0) : 0\n }\n\n /**\n * Get the first post in this result set\n * @return {Post}\n */\n get first(): Post {\n return this[0]\n }\n\n /**\n * Get the last post in this result set\n * @return {Post}\n */\n get last(): Post {\n return this[this.length - 1]\n }\n\n /**\n * Get the next page\n * <p>Works like <code>sb.search('cat', {page: 1}); sb.search('cat', {page: 2})</code>\n * @return {Promise<SearchResults>}\n */\n public nextPage(): Promise<SearchResults> {\n const opts: SearchParameters = this.options\n opts.page = this.page + 1\n\n return this.booru.search(this.tags, opts)\n }\n\n /**\n * Create a new SearchResults with just images with the matching tags\n *\n * @param {String[]|String} tags The tags (or tag) to search for\n * @param {Object} options The extra options for the search\n * @param {Boolean} [options.invert=false] If the results should be inverted and\n * return images *not* tagged\n * @return {SearchResults}\n */\n public tagged(\n tags: string[] | string,\n { invert = false } = {},\n ): SearchResults {\n const searchTags = Array.isArray(tags) ? tags : [tags]\n const posts: Post[] = []\n\n for (const p of this) {\n const m: number = Utils.compareArrays(searchTags, p.tags).length\n if ((!invert && m > 0) || (invert && m === 0)) {\n posts.push(p)\n }\n }\n\n return new SearchResults(posts, this.tags, this.options, this.booru)\n }\n\n /**\n * Returns a SearchResults with images *not* tagged with any of the specified tags (or tag)\n * @param {String[]|String} tags The tags (or tag) to blacklist\n * @return {SearchResults} The results without any images with the specified tags\n */\n public blacklist(tags: string[] | string): SearchResults {\n return this.tagged(tags, { invert: true })\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SiteApi.d.ts","sourceRoot":"","sources":["../../src/structures/SiteApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,OAAO,WAAW,OAAO;IAC9B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;CACjB"}
|
|
1
|
+
{"version":3,"file":"SiteApi.d.ts","sourceRoot":"","sources":["../../src/structures/SiteApi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,CAAC,OAAO,WAAW,OAAO;IAC9B,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SiteApi.js","sourceRoot":"","sources":["../../src/structures/SiteApi.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * @packageDocumentation\n * @module Structures\n */\n\n/**\n * Represents the api of a {@link Site}\n * <p>Each property is a path on the {@link Site}\n */\nexport default interface SiteApi {\n /** The path to search for posts */\n search: string\n /** The path to view a post by ID */\n postView: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"SiteApi.js","sourceRoot":"","sources":["../../src/structures/SiteApi.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * @packageDocumentation\n * @module Structures\n */\n\n/**\n * Represents the api of a {@link Site}\n * <p>Each property is a path on the {@link Site}\n */\nexport default interface SiteApi {\n /** The path to search for posts */\n search: string\n /** The path to view a post by ID */\n postView: string\n /** The path to retrieve a list of tags */\n tagList?: string\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
import type Booru from '../boorus/Booru';
|
|
6
|
+
/**
|
|
7
|
+
* A tag from a booru with a few common props
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* Tag {
|
|
12
|
+
* name: 'tag_name',
|
|
13
|
+
* count: 1234,
|
|
14
|
+
* type: 0,
|
|
15
|
+
* ambiguous: false,
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export default class Tag {
|
|
20
|
+
/** The {@link Booru} it came from */
|
|
21
|
+
booru: Booru;
|
|
22
|
+
/** The id of the tag */
|
|
23
|
+
id: number | string;
|
|
24
|
+
/** The name of the tag */
|
|
25
|
+
name: string;
|
|
26
|
+
/** The count of the tag */
|
|
27
|
+
count: number;
|
|
28
|
+
/** If the tag is a meta tag */
|
|
29
|
+
type: number;
|
|
30
|
+
/** If the tag is ambiguous */
|
|
31
|
+
ambiguous?: boolean | null;
|
|
32
|
+
/** All the data given by the booru @private */
|
|
33
|
+
protected data: any;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new tag from the data given by the booru
|
|
36
|
+
*
|
|
37
|
+
* @param data The data from the booru
|
|
38
|
+
* @param booru The booru this tag is from
|
|
39
|
+
*/
|
|
40
|
+
constructor(data: any, booru: Booru);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=Tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.d.ts","sourceRoot":"","sources":["../../src/structures/Tag.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AAExC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,qCAAqC;IAC9B,KAAK,EAAE,KAAK,CAAA;IACnB,wBAAwB;IACjB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B,0BAA0B;IACnB,IAAI,EAAE,MAAM,CAAA;IACnB,2BAA2B;IACpB,KAAK,EAAE,MAAM,CAAA;IACpB,+BAA+B;IACxB,IAAI,EAAE,MAAM,CAAA;IACnB,8BAA8B;IACvB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IAEjC,+CAA+C;IAC/C,SAAS,CAAC,IAAI,EAAE,GAAG,CAAA;IAEnB;;;;;OAKG;gBACS,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK;CAUpC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
* @module Structures
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
/**
|
|
8
|
+
* A tag from a booru with a few common props
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* Tag {
|
|
13
|
+
* name: 'tag_name',
|
|
14
|
+
* count: 1234,
|
|
15
|
+
* type: 0,
|
|
16
|
+
* ambiguous: false,
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
class Tag {
|
|
21
|
+
/** The {@link Booru} it came from */
|
|
22
|
+
booru;
|
|
23
|
+
/** The id of the tag */
|
|
24
|
+
id;
|
|
25
|
+
/** The name of the tag */
|
|
26
|
+
name;
|
|
27
|
+
/** The count of the tag */
|
|
28
|
+
count;
|
|
29
|
+
/** If the tag is a meta tag */
|
|
30
|
+
type;
|
|
31
|
+
/** If the tag is ambiguous */
|
|
32
|
+
ambiguous;
|
|
33
|
+
/** All the data given by the booru @private */
|
|
34
|
+
data;
|
|
35
|
+
/**
|
|
36
|
+
* Create a new tag from the data given by the booru
|
|
37
|
+
*
|
|
38
|
+
* @param data The data from the booru
|
|
39
|
+
* @param booru The booru this tag is from
|
|
40
|
+
*/
|
|
41
|
+
constructor(data, booru) {
|
|
42
|
+
this.data = data;
|
|
43
|
+
this.booru = booru;
|
|
44
|
+
this.id = data.id;
|
|
45
|
+
this.name = data.name;
|
|
46
|
+
this.count = data.count ?? data.post_count ?? 0;
|
|
47
|
+
this.type = data.type ?? data.category ?? 0;
|
|
48
|
+
this.ambiguous = data.ambiguous ? data.ambiguous !== 'false' : null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.default = Tag;
|
|
52
|
+
//# sourceMappingURL=Tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.js","sourceRoot":"","sources":["../../src/structures/Tag.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAIH;;;;;;;;;;;;GAYG;AACH,MAAqB,GAAG;IACtB,qCAAqC;IAC9B,KAAK,CAAO;IACnB,wBAAwB;IACjB,EAAE,CAAiB;IAC1B,0BAA0B;IACnB,IAAI,CAAQ;IACnB,2BAA2B;IACpB,KAAK,CAAQ;IACpB,+BAA+B;IACxB,IAAI,CAAQ;IACnB,8BAA8B;IACvB,SAAS,CAAiB;IAEjC,+CAA+C;IACrC,IAAI,CAAK;IAEnB;;;;;OAKG;IACH,YAAY,IAAS,EAAE,KAAY;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAElB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAA;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,CAAA;QAC/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAA;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IACrE,CAAC;CACF;AAjCD,sBAiCC","sourcesContent":["/**\n * @packageDocumentation\n * @module Structures\n */\n\nimport type Booru from '../boorus/Booru'\n\n/**\n * A tag from a booru with a few common props\n *\n * @example\n * ```\n * Tag {\n * name: 'tag_name',\n * count: 1234,\n * type: 0,\n * ambiguous: false,\n * }\n * ```\n */\nexport default class Tag {\n /** The {@link Booru} it came from */\n public booru: Booru\n /** The id of the tag */\n public id: number | string\n /** The name of the tag */\n public name: string\n /** The count of the tag */\n public count: number\n /** If the tag is a meta tag */\n public type: number\n /** If the tag is ambiguous */\n public ambiguous?: boolean | null\n\n /** All the data given by the booru @private */\n protected data: any\n\n /**\n * Create a new tag from the data given by the booru\n *\n * @param data The data from the booru\n * @param booru The booru this tag is from\n */\n constructor(data: any, booru: Booru) {\n this.data = data\n this.booru = booru\n\n this.id = data.id\n this.name = data.name\n this.count = data.count ?? data.post_count ?? 0\n this.type = data.type ?? data.category ?? 0\n this.ambiguous = data.ambiguous ? data.ambiguous !== 'false' : null\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Just an interface for {@link Booru}'s tag list params :)
|
|
7
|
+
*/
|
|
8
|
+
export default interface SearchParameters {
|
|
9
|
+
/** The limit on *max* tags to show, you might get less tags than this */
|
|
10
|
+
limit?: number | undefined;
|
|
11
|
+
/** Which page of results to fetch */
|
|
12
|
+
page?: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=TagListParameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagListParameters.d.ts","sourceRoot":"","sources":["../../src/structures/TagListParameters.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,CAAC,OAAO,WAAW,gBAAgB;IACvC,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagListParameters.js","sourceRoot":"","sources":["../../src/structures/TagListParameters.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * @packageDocumentation\n * @module Structures\n */\n\n/**\n * Just an interface for {@link Booru}'s tag list params :)\n */\nexport default interface SearchParameters {\n /** The limit on *max* tags to show, you might get less tags than this */\n limit?: number | undefined\n /** Which page of results to fetch */\n page?: number | undefined\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module Structures
|
|
4
|
+
*/
|
|
5
|
+
import type Booru from '../boorus/Booru';
|
|
6
|
+
import type Tag from './Tag';
|
|
7
|
+
import type TagListParameters from './TagListParameters';
|
|
8
|
+
/**
|
|
9
|
+
* Represents a page of tag list results, works like an array of {@link Tag}
|
|
10
|
+
* <p> Usable like an array and allows to easily get the next page
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```
|
|
14
|
+
* const Booru = require('booru')
|
|
15
|
+
* // Safebooru
|
|
16
|
+
* const sb = new Booru('sb')
|
|
17
|
+
*
|
|
18
|
+
* const tags = await sb.tagList()
|
|
19
|
+
*
|
|
20
|
+
* // Log the tags from the first page, then from the second
|
|
21
|
+
* tags.forEach(t => console.log(t.name))
|
|
22
|
+
* const tags2 = await tags.nextPage()
|
|
23
|
+
* tags2.forEach(t => console.log(t.name))
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export default class TagListResults extends Array<Tag> {
|
|
27
|
+
/** The booru used for this tag list */
|
|
28
|
+
booru: Booru;
|
|
29
|
+
/** The page of this tag list */
|
|
30
|
+
page: number;
|
|
31
|
+
/** The options used for this tag list */
|
|
32
|
+
readonly options: TagListParameters;
|
|
33
|
+
/** The tags from this tag list result */
|
|
34
|
+
readonly tags: Tag[];
|
|
35
|
+
/** @private */
|
|
36
|
+
constructor(tags: Tag[], options: TagListParameters, booru: Booru);
|
|
37
|
+
/**
|
|
38
|
+
* Get the first tag in this result set
|
|
39
|
+
* @return {Tag}
|
|
40
|
+
*/
|
|
41
|
+
get first(): Tag;
|
|
42
|
+
/**
|
|
43
|
+
* Get the last tag in this result set
|
|
44
|
+
* @return {Tag}
|
|
45
|
+
*/
|
|
46
|
+
get last(): Tag;
|
|
47
|
+
/**
|
|
48
|
+
* Get the next page of results
|
|
49
|
+
* @returns {Promise<TagListResults>} The next page of results
|
|
50
|
+
*/
|
|
51
|
+
nextPage(): Promise<TagListResults>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=TagListResults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagListResults.d.ts","sourceRoot":"","sources":["../../src/structures/TagListResults.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,GAAG,MAAM,OAAO,CAAA;AAC5B,OAAO,KAAK,iBAAiB,MAAM,qBAAqB,CAAA;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,KAAK,CAAC,GAAG,CAAC;IACpD,uCAAuC;IAChC,KAAK,EAAE,KAAK,CAAA;IACnB,gCAAgC;IACzB,IAAI,EAAE,MAAM,CAAA;IACnB,yCAAyC;IACzC,SAAgB,OAAO,EAAE,iBAAiB,CAAA;IAC1C,yCAAyC;IACzC,SAAgB,IAAI,EAAE,GAAG,EAAE,CAAA;IAE3B,eAAe;gBACH,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK;IAajE;;;OAGG;IACH,IAAI,KAAK,IAAI,GAAG,CAEf;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,GAAG,CAEd;IAED;;;OAGG;IACU,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;CAYjD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
* @module Structures
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
/**
|
|
8
|
+
* Represents a page of tag list results, works like an array of {@link Tag}
|
|
9
|
+
* <p> Usable like an array and allows to easily get the next page
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* const Booru = require('booru')
|
|
14
|
+
* // Safebooru
|
|
15
|
+
* const sb = new Booru('sb')
|
|
16
|
+
*
|
|
17
|
+
* const tags = await sb.tagList()
|
|
18
|
+
*
|
|
19
|
+
* // Log the tags from the first page, then from the second
|
|
20
|
+
* tags.forEach(t => console.log(t.name))
|
|
21
|
+
* const tags2 = await tags.nextPage()
|
|
22
|
+
* tags2.forEach(t => console.log(t.name))
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
class TagListResults extends Array {
|
|
26
|
+
/** The booru used for this tag list */
|
|
27
|
+
booru;
|
|
28
|
+
/** The page of this tag list */
|
|
29
|
+
page;
|
|
30
|
+
/** The options used for this tag list */
|
|
31
|
+
options;
|
|
32
|
+
/** The tags from this tag list result */
|
|
33
|
+
tags;
|
|
34
|
+
/** @private */
|
|
35
|
+
constructor(tags, options, booru) {
|
|
36
|
+
super(tags.length);
|
|
37
|
+
for (let i = 0; i < tags.length; i++) {
|
|
38
|
+
this[i] = tags[i];
|
|
39
|
+
}
|
|
40
|
+
this.tags = tags;
|
|
41
|
+
this.options = options;
|
|
42
|
+
this.booru = booru;
|
|
43
|
+
this.page = options ? (options.page ?? 0) : 0;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the first tag in this result set
|
|
47
|
+
* @return {Tag}
|
|
48
|
+
*/
|
|
49
|
+
get first() {
|
|
50
|
+
return this[0];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get the last tag in this result set
|
|
54
|
+
* @return {Tag}
|
|
55
|
+
*/
|
|
56
|
+
get last() {
|
|
57
|
+
return this[this.length - 1];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get the next page of results
|
|
61
|
+
* @returns {Promise<TagListResults>} The next page of results
|
|
62
|
+
*/
|
|
63
|
+
async nextPage() {
|
|
64
|
+
const nextPage = this.page + 1;
|
|
65
|
+
const newTags = await this.booru.tagList({
|
|
66
|
+
limit: this.options.limit,
|
|
67
|
+
page: nextPage,
|
|
68
|
+
});
|
|
69
|
+
return new TagListResults(newTags, { ...this.options, page: nextPage }, this.booru);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.default = TagListResults;
|
|
73
|
+
//# sourceMappingURL=TagListResults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagListResults.js","sourceRoot":"","sources":["../../src/structures/TagListResults.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAMH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAqB,cAAe,SAAQ,KAAU;IACpD,uCAAuC;IAChC,KAAK,CAAO;IACnB,gCAAgC;IACzB,IAAI,CAAQ;IACnB,yCAAyC;IACzB,OAAO,CAAmB;IAC1C,yCAAyC;IACzB,IAAI,CAAO;IAE3B,eAAe;IACf,YAAY,IAAW,EAAE,OAA0B,EAAE,KAAY;QAC/D,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAElB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/C,CAAC;IAED;;;OAGG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,CAAC,CAAC,CAAA;IAChB,CAAC;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC9B,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,QAAQ;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,GAAG,CAAC,CAAA;QAC9B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;YACvC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,IAAI,EAAE,QAAQ;SACf,CAAC,CAAA;QACF,OAAO,IAAI,cAAc,CACvB,OAAO,EACP,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,EACnC,IAAI,CAAC,KAAK,CACX,CAAA;IACH,CAAC;CACF;AAxDD,iCAwDC","sourcesContent":["/**\n * @packageDocumentation\n * @module Structures\n */\n\nimport type Booru from '../boorus/Booru'\nimport type Tag from './Tag'\nimport type TagListParameters from './TagListParameters'\n\n/**\n * Represents a page of tag list results, works like an array of {@link Tag}\n * <p> Usable like an array and allows to easily get the next page\n *\n * @example\n * ```\n * const Booru = require('booru')\n * // Safebooru\n * const sb = new Booru('sb')\n *\n * const tags = await sb.tagList()\n *\n * // Log the tags from the first page, then from the second\n * tags.forEach(t => console.log(t.name))\n * const tags2 = await tags.nextPage()\n * tags2.forEach(t => console.log(t.name))\n * ```\n */\nexport default class TagListResults extends Array<Tag> {\n /** The booru used for this tag list */\n public booru: Booru\n /** The page of this tag list */\n public page: number\n /** The options used for this tag list */\n public readonly options: TagListParameters\n /** The tags from this tag list result */\n public readonly tags: Tag[]\n\n /** @private */\n constructor(tags: Tag[], options: TagListParameters, booru: Booru) {\n super(tags.length)\n\n for (let i = 0; i < tags.length; i++) {\n this[i] = tags[i]\n }\n\n this.tags = tags\n this.options = options\n this.booru = booru\n this.page = options ? (options.page ?? 0) : 0\n }\n\n /**\n * Get the first tag in this result set\n * @return {Tag}\n */\n get first(): Tag {\n return this[0]\n }\n\n /**\n * Get the last tag in this result set\n * @return {Tag}\n */\n get last(): Tag {\n return this[this.length - 1]\n }\n\n /**\n * Get the next page of results\n * @returns {Promise<TagListResults>} The next page of results\n */\n public async nextPage(): Promise<TagListResults> {\n const nextPage = this.page + 1\n const newTags = await this.booru.tagList({\n limit: this.options.limit,\n page: nextPage,\n })\n return new TagListResults(\n newTags,\n { ...this.options, page: nextPage },\n this.booru,\n )\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "booru",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "Search (and do other things) on a bunch of different boorus!",
|
|
5
5
|
"author": "AtoraSuunva (https://github.com/AtoraSuunva/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,14 +14,6 @@
|
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/AtoraSuunva/booru/issues"
|
|
16
16
|
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "tsx --test",
|
|
19
|
-
"lint": "biome check && tsc --noEmit",
|
|
20
|
-
"lint:fix": "biome check --write && tsc --noEmit",
|
|
21
|
-
"prebuild": "npm run lint",
|
|
22
|
-
"build": "tsc --build",
|
|
23
|
-
"prepublishOnly": "npm run build"
|
|
24
|
-
},
|
|
25
17
|
"keywords": [
|
|
26
18
|
"booru",
|
|
27
19
|
"e621",
|
|
@@ -38,15 +30,15 @@
|
|
|
38
30
|
"derpibooru"
|
|
39
31
|
],
|
|
40
32
|
"engines": {
|
|
41
|
-
"node": ">=
|
|
33
|
+
"node": ">=20"
|
|
42
34
|
},
|
|
43
35
|
"dependencies": {
|
|
44
|
-
"fast-xml-parser": "^
|
|
36
|
+
"fast-xml-parser": "^5.2.5",
|
|
45
37
|
"undici": "^7.2.0"
|
|
46
38
|
},
|
|
47
39
|
"devDependencies": {
|
|
48
|
-
"@biomejs/biome": "^
|
|
49
|
-
"@types/node": "^
|
|
40
|
+
"@biomejs/biome": "^2.0.5",
|
|
41
|
+
"@types/node": "^24.0.3",
|
|
50
42
|
"tsx": "^4.19.2",
|
|
51
43
|
"typescript": "^5.7.2"
|
|
52
44
|
},
|
|
@@ -74,5 +66,12 @@
|
|
|
74
66
|
"name": "AtoraSuunva",
|
|
75
67
|
"url": "https://github.com/AtoraSuunva"
|
|
76
68
|
}
|
|
77
|
-
]
|
|
78
|
-
|
|
69
|
+
],
|
|
70
|
+
"scripts": {
|
|
71
|
+
"test": "tsx --test",
|
|
72
|
+
"lint": "biome check && tsc --noEmit",
|
|
73
|
+
"lint:fix": "biome check --write && tsc --noEmit",
|
|
74
|
+
"prebuild": "pnpm run lint",
|
|
75
|
+
"build": "tsc --build"
|
|
76
|
+
}
|
|
77
|
+
}
|