libram 0.3.2 → 0.4.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.
- package/dist/Clan.js +268 -485
- package/dist/Copier.js +11 -48
- package/dist/Dungeon.js +77 -157
- package/dist/Kmail.d.ts +13 -7
- package/dist/Kmail.js +92 -233
- package/dist/Path.js +68 -120
- package/dist/ascend.js +153 -172
- package/dist/combat.d.ts +86 -1
- package/dist/combat.js +295 -387
- package/dist/console.js +13 -36
- package/dist/diet/index.d.ts +31 -0
- package/dist/diet/index.js +333 -0
- package/dist/diet/knapsack.d.ts +7 -0
- package/dist/diet/knapsack.js +106 -0
- package/dist/dungeons/Dreadsylvania.d.ts +4 -0
- package/dist/dungeons/Dreadsylvania.js +14 -0
- package/dist/dungeons/Dungeon.d.ts +28 -0
- package/dist/dungeons/Dungeon.js +99 -0
- package/dist/dungeons/Hobopolis.d.ts +4 -0
- package/dist/dungeons/Hobopolis.js +14 -0
- package/dist/dungeons/SlimeTube.d.ts +4 -0
- package/dist/dungeons/SlimeTube.js +14 -0
- package/dist/freerun.d.ts +23 -0
- package/dist/freerun.js +92 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +21 -263
- package/dist/lib.d.ts +43 -0
- package/dist/lib.js +296 -405
- package/dist/logger.js +23 -63
- package/dist/maximize.d.ts +29 -12
- package/dist/maximize.js +318 -421
- package/dist/modifier.d.ts +13 -0
- package/dist/modifier.js +35 -0
- package/dist/modifierTypes.d.ts +16 -0
- package/dist/modifierTypes.js +9 -0
- package/dist/mood.js +220 -531
- package/dist/property.d.ts +2 -0
- package/dist/property.js +96 -242
- package/dist/propertyTypes.d.ts +9 -0
- package/dist/propertyTypes.js +1 -0
- package/dist/propertyTyping.d.ts +2 -9
- package/dist/propertyTyping.js +42 -53
- package/dist/resources/2007/CandyHearts.d.ts +9 -0
- package/dist/resources/2007/CandyHearts.js +24 -0
- package/dist/resources/2008/DivineFavors.d.ts +9 -0
- package/dist/resources/2008/DivineFavors.js +27 -0
- package/dist/resources/2009/Bandersnatch.js +37 -112
- package/dist/resources/2009/LoveSongs.d.ts +9 -0
- package/dist/resources/2009/LoveSongs.js +24 -0
- package/dist/resources/2009/SpookyPutty.js +20 -46
- package/dist/resources/2010/Brickos.d.ts +9 -0
- package/dist/resources/2010/Brickos.js +21 -0
- package/dist/resources/2010/CrownOfThrones.d.ts +18 -0
- package/dist/resources/2010/CrownOfThrones.js +550 -0
- package/dist/resources/2011/Gygaxian.d.ts +9 -0
- package/dist/resources/2011/Gygaxian.js +24 -0
- package/dist/resources/2011/ObtuseAngel.js +21 -63
- package/dist/resources/2012/RainDoh.js +14 -40
- package/dist/resources/2012/Resolutions.d.ts +9 -0
- package/dist/resources/2012/Resolutions.js +28 -0
- package/dist/resources/2013/Florist.d.ts +61 -0
- package/dist/resources/2013/Florist.js +149 -0
- package/dist/resources/2013/PulledTaffy.d.ts +9 -0
- package/dist/resources/2013/PulledTaffy.js +33 -0
- package/dist/resources/2014/WinterGarden.js +15 -43
- package/dist/resources/2015/ChateauMantegna.js +52 -86
- package/dist/resources/2015/MayoClinic.d.ts +13 -0
- package/dist/resources/2015/MayoClinic.js +36 -0
- package/dist/resources/2016/SourceTerminal.d.ts +1 -0
- package/dist/resources/2016/SourceTerminal.js +114 -237
- package/dist/resources/2016/Witchess.js +33 -59
- package/dist/resources/2017/TunnelOfLove.js +62 -111
- package/dist/resources/2018/SongBoom.js +32 -68
- package/dist/resources/2019/BeachComb.d.ts +2 -0
- package/dist/resources/2019/BeachComb.js +26 -0
- package/dist/resources/2019/Snapper.d.ts +28 -0
- package/dist/resources/2019/Snapper.js +70 -0
- package/dist/resources/2020/Guzzlr.js +79 -163
- package/dist/resources/LibramSummon.d.ts +12 -0
- package/dist/resources/LibramSummon.js +66 -0
- package/dist/resources/index.d.ts +18 -11
- package/dist/resources/index.js +19 -85
- package/dist/resources/putty-likes.js +15 -30
- package/dist/ring-buffer.d.ts +24 -0
- package/dist/ring-buffer.js +135 -0
- package/dist/since.d.ts +1 -0
- package/dist/since.js +56 -112
- package/dist/template-string.js +40 -132
- package/dist/utils.d.ts +14 -0
- package/dist/utils.js +50 -114
- package/package.json +5 -3
- package/dist/libram-example-briefcase.js +0 -16073
- package/dist/libram-example-clan.js +0 -8898
- package/dist/libram-example-consult.js +0 -6179
- package/dist/libram-example-item.js +0 -3248
- package/dist/libram-example-kmail.js +0 -2065
- package/dist/libram-example-lib.js +0 -7608
- package/dist/libram-example-props.js +0 -4770
- package/dist/libram-example-resources.js +0 -12226
package/dist/template-string.js
CHANGED
|
@@ -1,299 +1,207 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports.$thralls = exports.$thrall = exports.$stats = exports.$stat = exports.$slots = exports.$slot = exports.$skills = exports.$skill = exports.$servants = exports.$servant = exports.$phyla = exports.$phylum = exports.$monsters = exports.$monster = exports.$locations = exports.$location = exports.$items = exports.$item = exports.$familiars = exports.$familiar = exports.$elements = exports.$element = exports.$effects = exports.$effect = exports.$coinmasters = exports.$coinmaster = exports.$classes = exports.$class = exports.$bounties = exports.$bounty = void 0;
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/es.array.concat.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
11
|
-
|
|
12
|
-
require("core-js/modules/es.string.split.js");
|
|
13
|
-
|
|
14
|
-
var concatTemplateString = function concatTemplateString(literals) {
|
|
15
|
-
for (var _len = arguments.length, placeholders = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
16
|
-
placeholders[_key - 1] = arguments[_key];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return literals.reduce((acc, literal, i) => acc + literal + (placeholders[i] || ""), "");
|
|
1
|
+
const concatTemplateString = (literals, ...placeholders) => literals.reduce((acc, literal, i) => acc + literal + (placeholders[i] || ""), "");
|
|
2
|
+
const createSingleConstant = (Type) => (literals, ...placeholders) => {
|
|
3
|
+
const input = concatTemplateString(literals, ...placeholders);
|
|
4
|
+
return Type.get(input);
|
|
20
5
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var input = concatTemplateString.apply(void 0, [literals].concat(placeholders));
|
|
28
|
-
return Type.get(input);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var createPluralConstant = Type => function (literals) {
|
|
32
|
-
for (var _len3 = arguments.length, placeholders = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
33
|
-
placeholders[_key3 - 1] = arguments[_key3];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
var input = concatTemplateString.apply(void 0, [literals].concat(placeholders));
|
|
37
|
-
|
|
38
|
-
if (input === "") {
|
|
39
|
-
return Type.all();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return Type.get(input.split(/\s*,\s*/));
|
|
6
|
+
const createPluralConstant = (Type) => (literals, ...placeholders) => {
|
|
7
|
+
const input = concatTemplateString(literals, ...placeholders);
|
|
8
|
+
if (input === "") {
|
|
9
|
+
return Type.all();
|
|
10
|
+
}
|
|
11
|
+
return Type.get(input.split(/\s*,\s*/));
|
|
43
12
|
};
|
|
44
13
|
/**
|
|
45
14
|
* A Bounty specified by name.
|
|
46
15
|
*
|
|
47
16
|
* @category In-game constant
|
|
48
17
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var $bounty = createSingleConstant(Bounty);
|
|
18
|
+
export const $bounty = createSingleConstant(Bounty);
|
|
52
19
|
/**
|
|
53
20
|
* A list of Bounties specified by a comma-separated list of names.
|
|
54
21
|
* For a list of all possible Bounties, leave the template string blank.
|
|
55
22
|
*
|
|
56
23
|
* @category In-game constant
|
|
57
24
|
*/
|
|
58
|
-
|
|
59
|
-
exports.$bounty = $bounty;
|
|
60
|
-
var $bounties = createPluralConstant(Bounty);
|
|
25
|
+
export const $bounties = createPluralConstant(Bounty);
|
|
61
26
|
/**
|
|
62
27
|
* A Class specified by name.
|
|
63
28
|
*
|
|
64
29
|
* @category In-game constant
|
|
65
30
|
*/
|
|
66
|
-
|
|
67
|
-
exports.$bounties = $bounties;
|
|
68
|
-
var $class = createSingleConstant(Class);
|
|
31
|
+
export const $class = createSingleConstant(Class);
|
|
69
32
|
/**
|
|
70
33
|
* A list of Classes specified by a comma-separated list of names.
|
|
71
34
|
* For a list of all possible Classes, leave the template string blank.
|
|
72
35
|
*
|
|
73
36
|
* @category In-game constant
|
|
74
37
|
*/
|
|
75
|
-
|
|
76
|
-
exports.$class = $class;
|
|
77
|
-
var $classes = createPluralConstant(Class);
|
|
38
|
+
export const $classes = createPluralConstant(Class);
|
|
78
39
|
/**
|
|
79
40
|
* A Coinmaster specified by name.
|
|
80
41
|
*
|
|
81
42
|
* @category In-game constant
|
|
82
43
|
*/
|
|
83
|
-
|
|
84
|
-
exports.$classes = $classes;
|
|
85
|
-
var $coinmaster = createSingleConstant(Coinmaster);
|
|
44
|
+
export const $coinmaster = createSingleConstant(Coinmaster);
|
|
86
45
|
/**
|
|
87
46
|
* A list of Coinmasters specified by a comma-separated list of names.
|
|
88
47
|
* For a list of all possible Coinmasters, leave the template string blank.
|
|
89
48
|
*
|
|
90
49
|
* @category In-game constant
|
|
91
50
|
*/
|
|
92
|
-
|
|
93
|
-
exports.$coinmaster = $coinmaster;
|
|
94
|
-
var $coinmasters = createPluralConstant(Coinmaster);
|
|
51
|
+
export const $coinmasters = createPluralConstant(Coinmaster);
|
|
95
52
|
/**
|
|
96
53
|
* An Effect specified by name.
|
|
97
54
|
*
|
|
98
55
|
* @category In-game constant
|
|
99
56
|
*/
|
|
100
|
-
|
|
101
|
-
exports.$coinmasters = $coinmasters;
|
|
102
|
-
var $effect = createSingleConstant(Effect);
|
|
57
|
+
export const $effect = createSingleConstant(Effect);
|
|
103
58
|
/**
|
|
104
59
|
* A list of Effects specified by a comma-separated list of names.
|
|
105
60
|
* For a list of all possible Effects, leave the template string blank.
|
|
106
61
|
*
|
|
107
62
|
* @category In-game constant
|
|
108
63
|
*/
|
|
109
|
-
|
|
110
|
-
exports.$effect = $effect;
|
|
111
|
-
var $effects = createPluralConstant(Effect);
|
|
64
|
+
export const $effects = createPluralConstant(Effect);
|
|
112
65
|
/**
|
|
113
66
|
* An Element specified by name.
|
|
114
67
|
*
|
|
115
68
|
* @category In-game constant
|
|
116
69
|
*/
|
|
117
|
-
|
|
118
|
-
exports.$effects = $effects;
|
|
119
|
-
var $element = createSingleConstant(Element);
|
|
70
|
+
export const $element = createSingleConstant(Element);
|
|
120
71
|
/**
|
|
121
72
|
* A list of Elements specified by a comma-separated list of names.
|
|
122
73
|
* For a list of all possible Elements, leave the template string blank.
|
|
123
74
|
*
|
|
124
75
|
* @category In-game constant
|
|
125
76
|
*/
|
|
126
|
-
|
|
127
|
-
exports.$element = $element;
|
|
128
|
-
var $elements = createPluralConstant(Element);
|
|
77
|
+
export const $elements = createPluralConstant(Element);
|
|
129
78
|
/**
|
|
130
79
|
* A Familiar specified by name.
|
|
131
80
|
*
|
|
132
81
|
* @category In-game constant
|
|
133
82
|
*/
|
|
134
|
-
|
|
135
|
-
exports.$elements = $elements;
|
|
136
|
-
var $familiar = createSingleConstant(Familiar);
|
|
83
|
+
export const $familiar = createSingleConstant(Familiar);
|
|
137
84
|
/**
|
|
138
85
|
* A list of Familiars specified by a comma-separated list of names.
|
|
139
86
|
* For a list of all possible Familiars, leave the template string blank.
|
|
140
87
|
*
|
|
141
88
|
* @category In-game constant
|
|
142
89
|
*/
|
|
143
|
-
|
|
144
|
-
exports.$familiar = $familiar;
|
|
145
|
-
var $familiars = createPluralConstant(Familiar);
|
|
90
|
+
export const $familiars = createPluralConstant(Familiar);
|
|
146
91
|
/**
|
|
147
92
|
* An Item specified by name.
|
|
148
93
|
*
|
|
149
94
|
* @category In-game constant
|
|
150
95
|
*/
|
|
151
|
-
|
|
152
|
-
exports.$familiars = $familiars;
|
|
153
|
-
var $item = createSingleConstant(Item);
|
|
96
|
+
export const $item = createSingleConstant(Item);
|
|
154
97
|
/**
|
|
155
98
|
* A list of Items specified by a comma-separated list of names.
|
|
156
99
|
* For a list of all possible Items, leave the template string blank.
|
|
157
100
|
*
|
|
158
101
|
* @category In-game constant
|
|
159
102
|
*/
|
|
160
|
-
|
|
161
|
-
exports.$item = $item;
|
|
162
|
-
var $items = createPluralConstant(Item);
|
|
103
|
+
export const $items = createPluralConstant(Item);
|
|
163
104
|
/**
|
|
164
105
|
* A Location specified by name.
|
|
165
106
|
*
|
|
166
107
|
* @category In-game constant
|
|
167
108
|
*/
|
|
168
|
-
|
|
169
|
-
exports.$items = $items;
|
|
170
|
-
var $location = createSingleConstant(Location);
|
|
109
|
+
export const $location = createSingleConstant(Location);
|
|
171
110
|
/**
|
|
172
111
|
* A list of Locations specified by a comma-separated list of names.
|
|
173
112
|
* For a list of all possible Locations, leave the template string blank.
|
|
174
113
|
*
|
|
175
114
|
* @category In-game constant
|
|
176
115
|
*/
|
|
177
|
-
|
|
178
|
-
exports.$location = $location;
|
|
179
|
-
var $locations = createPluralConstant(Location);
|
|
116
|
+
export const $locations = createPluralConstant(Location);
|
|
180
117
|
/**
|
|
181
118
|
* A Monster specified by name.
|
|
182
119
|
*
|
|
183
120
|
* @category In-game constant
|
|
184
121
|
*/
|
|
185
|
-
|
|
186
|
-
exports.$locations = $locations;
|
|
187
|
-
var $monster = createSingleConstant(Monster);
|
|
122
|
+
export const $monster = createSingleConstant(Monster);
|
|
188
123
|
/**
|
|
189
124
|
* A list of Monsters specified by a comma-separated list of names.
|
|
190
125
|
* For a list of all possible Monsters, leave the template string blank.
|
|
191
126
|
*
|
|
192
127
|
* @category In-game constant
|
|
193
128
|
*/
|
|
194
|
-
|
|
195
|
-
exports.$monster = $monster;
|
|
196
|
-
var $monsters = createPluralConstant(Monster);
|
|
129
|
+
export const $monsters = createPluralConstant(Monster);
|
|
197
130
|
/**
|
|
198
131
|
* A Phylum specified by name.
|
|
199
132
|
*
|
|
200
133
|
* @category In-game constant
|
|
201
134
|
*/
|
|
202
|
-
|
|
203
|
-
exports.$monsters = $monsters;
|
|
204
|
-
var $phylum = createSingleConstant(Phylum);
|
|
135
|
+
export const $phylum = createSingleConstant(Phylum);
|
|
205
136
|
/**
|
|
206
137
|
* A list of Phyla specified by a comma-separated list of names.
|
|
207
138
|
* For a list of all possible Phyla, leave the template string blank.
|
|
208
139
|
*
|
|
209
140
|
* @category In-game constant
|
|
210
141
|
*/
|
|
211
|
-
|
|
212
|
-
exports.$phylum = $phylum;
|
|
213
|
-
var $phyla = createPluralConstant(Phylum);
|
|
142
|
+
export const $phyla = createPluralConstant(Phylum);
|
|
214
143
|
/**
|
|
215
144
|
* A Servant specified by name.
|
|
216
145
|
*
|
|
217
146
|
* @category In-game constant
|
|
218
147
|
*/
|
|
219
|
-
|
|
220
|
-
exports.$phyla = $phyla;
|
|
221
|
-
var $servant = createSingleConstant(Servant);
|
|
148
|
+
export const $servant = createSingleConstant(Servant);
|
|
222
149
|
/**
|
|
223
150
|
* A list of Servants specified by a comma-separated list of names.
|
|
224
151
|
* For a list of all possible Servants, leave the template string blank.
|
|
225
152
|
*
|
|
226
153
|
* @category In-game constant
|
|
227
154
|
*/
|
|
228
|
-
|
|
229
|
-
exports.$servant = $servant;
|
|
230
|
-
var $servants = createPluralConstant(Servant);
|
|
155
|
+
export const $servants = createPluralConstant(Servant);
|
|
231
156
|
/**
|
|
232
157
|
* A Skill specified by name.
|
|
233
158
|
*
|
|
234
159
|
* @category In-game constant
|
|
235
160
|
*/
|
|
236
|
-
|
|
237
|
-
exports.$servants = $servants;
|
|
238
|
-
var $skill = createSingleConstant(Skill);
|
|
161
|
+
export const $skill = createSingleConstant(Skill);
|
|
239
162
|
/**
|
|
240
163
|
* A list of Skills specified by a comma-separated list of names.
|
|
241
164
|
* For a list of all possible Skills, leave the template string blank.
|
|
242
165
|
*
|
|
243
166
|
* @category In-game constant
|
|
244
167
|
*/
|
|
245
|
-
|
|
246
|
-
exports.$skill = $skill;
|
|
247
|
-
var $skills = createPluralConstant(Skill);
|
|
168
|
+
export const $skills = createPluralConstant(Skill);
|
|
248
169
|
/**
|
|
249
170
|
* A Slot specified by name.
|
|
250
171
|
*
|
|
251
172
|
* @category In-game constant
|
|
252
173
|
*/
|
|
253
|
-
|
|
254
|
-
exports.$skills = $skills;
|
|
255
|
-
var $slot = createSingleConstant(Slot);
|
|
174
|
+
export const $slot = createSingleConstant(Slot);
|
|
256
175
|
/**
|
|
257
176
|
* A list of Slots specified by a comma-separated list of names.
|
|
258
177
|
* For a list of all possible Slots, leave the template string blank.
|
|
259
178
|
*
|
|
260
179
|
* @category In-game constant
|
|
261
180
|
*/
|
|
262
|
-
|
|
263
|
-
exports.$slot = $slot;
|
|
264
|
-
var $slots = createPluralConstant(Slot);
|
|
181
|
+
export const $slots = createPluralConstant(Slot);
|
|
265
182
|
/**
|
|
266
183
|
* A Stat specified by name.
|
|
267
184
|
*
|
|
268
185
|
* @category In-game constant
|
|
269
186
|
*/
|
|
270
|
-
|
|
271
|
-
exports.$slots = $slots;
|
|
272
|
-
var $stat = createSingleConstant(Stat);
|
|
187
|
+
export const $stat = createSingleConstant(Stat);
|
|
273
188
|
/**
|
|
274
189
|
* A list of Stats specified by a comma-separated list of names.
|
|
275
190
|
* For a list of all possible Stats, leave the template string blank.
|
|
276
191
|
*
|
|
277
192
|
* @category In-game constant
|
|
278
193
|
*/
|
|
279
|
-
|
|
280
|
-
exports.$stat = $stat;
|
|
281
|
-
var $stats = createPluralConstant(Stat);
|
|
194
|
+
export const $stats = createPluralConstant(Stat);
|
|
282
195
|
/**
|
|
283
196
|
* A Thrall specified by name.
|
|
284
197
|
*
|
|
285
198
|
* @category In-game constant
|
|
286
199
|
*/
|
|
287
|
-
|
|
288
|
-
exports.$stats = $stats;
|
|
289
|
-
var $thrall = createSingleConstant(Thrall);
|
|
200
|
+
export const $thrall = createSingleConstant(Thrall);
|
|
290
201
|
/**
|
|
291
202
|
* A list of Thralls specified by a comma-separated list of names.
|
|
292
203
|
* For a list of all possible Thralls, leave the template string blank.
|
|
293
204
|
*
|
|
294
205
|
* @category In-game constant
|
|
295
206
|
*/
|
|
296
|
-
|
|
297
|
-
exports.$thrall = $thrall;
|
|
298
|
-
var $thralls = createPluralConstant(Thrall);
|
|
299
|
-
exports.$thralls = $thralls;
|
|
207
|
+
export const $thralls = createPluralConstant(Thrall);
|
package/dist/utils.d.ts
CHANGED
|
@@ -25,3 +25,17 @@ export declare function countedMapToString<T>(map: Map<T, number>): string;
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function sum<T>(addends: T[], mappingFunction: (element: T) => number): number;
|
|
27
27
|
export declare function sumNumbers(addends: number[]): number;
|
|
28
|
+
/**
|
|
29
|
+
* Checks if a given item is in a readonly array, acting as a typeguard.
|
|
30
|
+
* @param item Needle
|
|
31
|
+
* @param array Readonly array haystack
|
|
32
|
+
* @returns Whether the item is in the array, and narrows the type of the item.
|
|
33
|
+
*/
|
|
34
|
+
export declare function arrayContains<T, A extends T>(item: T, array: ReadonlyArray<A>): item is A;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if two arrays contain the same elements in the same quantity.
|
|
37
|
+
* @param a First array for comparison
|
|
38
|
+
* @param b Second array for comparison
|
|
39
|
+
* @returns Whether the two arrays are equal, irrespective of order.
|
|
40
|
+
*/
|
|
41
|
+
export declare function setEqual<T>(a: T[], b: T[]): boolean;
|
package/dist/utils.js
CHANGED
|
@@ -1,70 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require("core-js/modules/es.symbol.js");
|
|
4
|
-
|
|
5
|
-
require("core-js/modules/es.symbol.description.js");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.notNull = notNull;
|
|
11
|
-
exports.parseNumber = parseNumber;
|
|
12
|
-
exports.clamp = clamp;
|
|
13
|
-
exports.chunk = chunk;
|
|
14
|
-
exports.arrayToCountedMap = arrayToCountedMap;
|
|
15
|
-
exports.countedMapToArray = countedMapToArray;
|
|
16
|
-
exports.countedMapToString = countedMapToString;
|
|
17
|
-
exports.sum = sum;
|
|
18
|
-
exports.sumNumbers = sumNumbers;
|
|
19
|
-
|
|
20
|
-
require("core-js/modules/es.number.parse-int.js");
|
|
21
|
-
|
|
22
|
-
require("core-js/modules/es.regexp.exec.js");
|
|
23
|
-
|
|
24
|
-
require("core-js/modules/es.string.replace.js");
|
|
25
|
-
|
|
26
|
-
require("core-js/modules/es.array.slice.js");
|
|
27
|
-
|
|
28
|
-
require("core-js/modules/es.array.iterator.js");
|
|
29
|
-
|
|
30
|
-
require("core-js/modules/es.object.to-string.js");
|
|
31
|
-
|
|
32
|
-
require("core-js/modules/es.array.flat-map.js");
|
|
33
|
-
|
|
34
|
-
require("core-js/modules/es.array.unscopables.flat-map.js");
|
|
35
|
-
|
|
36
|
-
require("core-js/modules/es.array.fill.js");
|
|
37
|
-
|
|
38
|
-
require("core-js/modules/es.array.map.js");
|
|
39
|
-
|
|
40
|
-
require("core-js/modules/es.array.concat.js");
|
|
41
|
-
|
|
42
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
43
|
-
|
|
44
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
45
|
-
|
|
46
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
47
|
-
|
|
48
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
|
-
|
|
50
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
51
|
-
|
|
52
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
53
|
-
|
|
54
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
55
|
-
|
|
56
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
57
|
-
|
|
58
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
59
|
-
|
|
60
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
61
|
-
|
|
62
|
-
function notNull(value) {
|
|
63
|
-
return value !== null;
|
|
1
|
+
export function notNull(value) {
|
|
2
|
+
return value !== null;
|
|
64
3
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return Number.parseInt(n.replace(/,/g, ""));
|
|
4
|
+
export function parseNumber(n) {
|
|
5
|
+
return Number.parseInt(n.replace(/,/g, ""));
|
|
68
6
|
}
|
|
69
7
|
/**
|
|
70
8
|
* Clamp a number between lower and upper bounds.
|
|
@@ -73,10 +11,8 @@ function parseNumber(n) {
|
|
|
73
11
|
* @param min Lower bound.
|
|
74
12
|
* @param max Upper bound.
|
|
75
13
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
function clamp(n, min, max) {
|
|
79
|
-
return Math.max(min, Math.min(max, n));
|
|
14
|
+
export function clamp(n, min, max) {
|
|
15
|
+
return Math.max(min, Math.min(max, n));
|
|
80
16
|
}
|
|
81
17
|
/**
|
|
82
18
|
* Split an {@param array} into {@param chunkSize} sized chunks
|
|
@@ -84,57 +20,57 @@ function clamp(n, min, max) {
|
|
|
84
20
|
* @param array Array to split
|
|
85
21
|
* @param chunkSize Size of chunk
|
|
86
22
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
result.push(array.slice(i, i + chunkSize));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return result;
|
|
23
|
+
export function chunk(array, chunkSize) {
|
|
24
|
+
const result = [];
|
|
25
|
+
for (let i = 0; i < array.length; i += chunkSize) {
|
|
26
|
+
result.push(array.slice(i, i + chunkSize));
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
97
29
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
30
|
+
export function arrayToCountedMap(array) {
|
|
31
|
+
if (!Array.isArray(array))
|
|
32
|
+
return array;
|
|
33
|
+
const map = new Map();
|
|
34
|
+
array.forEach((item) => {
|
|
35
|
+
map.set(item, (map.get(item) || 0) + 1);
|
|
36
|
+
});
|
|
37
|
+
return map;
|
|
106
38
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return _toConsumableArray(map).flatMap(_ref => {
|
|
110
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
111
|
-
item = _ref2[0],
|
|
112
|
-
quantity = _ref2[1];
|
|
113
|
-
|
|
114
|
-
return Array(quantity).fill(item);
|
|
115
|
-
});
|
|
39
|
+
export function countedMapToArray(map) {
|
|
40
|
+
return [...map].flatMap(([item, quantity]) => Array(quantity).fill(item));
|
|
116
41
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return _toConsumableArray(map).map(_ref3 => {
|
|
120
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
121
|
-
item = _ref4[0],
|
|
122
|
-
quantity = _ref4[1];
|
|
123
|
-
|
|
124
|
-
return "".concat(quantity, " x ").concat(item);
|
|
125
|
-
}).join(", ");
|
|
42
|
+
export function countedMapToString(map) {
|
|
43
|
+
return [...map].map(([item, quantity]) => `${quantity} x ${item}`).join(", ");
|
|
126
44
|
}
|
|
127
45
|
/**
|
|
128
46
|
* Sum an array of numbers.
|
|
129
47
|
* @param addends Addends to sum.
|
|
130
48
|
* @param mappingFunction function to turn elements into numbers
|
|
131
49
|
*/
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
50
|
+
export function sum(addends, mappingFunction) {
|
|
51
|
+
return addends.reduce((subtotal, element) => subtotal + mappingFunction(element), 0);
|
|
52
|
+
}
|
|
53
|
+
export function sumNumbers(addends) {
|
|
54
|
+
return sum(addends, (x) => x);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks if a given item is in a readonly array, acting as a typeguard.
|
|
58
|
+
* @param item Needle
|
|
59
|
+
* @param array Readonly array haystack
|
|
60
|
+
* @returns Whether the item is in the array, and narrows the type of the item.
|
|
61
|
+
*/
|
|
62
|
+
export function arrayContains(item, array) {
|
|
63
|
+
return array.includes(item);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Checks if two arrays contain the same elements in the same quantity.
|
|
67
|
+
* @param a First array for comparison
|
|
68
|
+
* @param b Second array for comparison
|
|
69
|
+
* @returns Whether the two arrays are equal, irrespective of order.
|
|
70
|
+
*/
|
|
71
|
+
export function setEqual(a, b) {
|
|
72
|
+
const sortedA = [...a].sort();
|
|
73
|
+
const sortedB = [...b].sort();
|
|
74
|
+
return (a.length === b.length &&
|
|
75
|
+
sortedA.every((item, index) => item === sortedB[index]));
|
|
136
76
|
}
|
|
137
|
-
|
|
138
|
-
function sumNumbers(addends) {
|
|
139
|
-
return sum(addends, x => x);
|
|
140
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libram",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "JavaScript helper library for KoLmafia",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"private": false,
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "yarn run tsc
|
|
12
|
+
"build": "yarn run tsc",
|
|
13
13
|
"clean": "rm -rf dist",
|
|
14
14
|
"docs": "yarn run typedoc",
|
|
15
15
|
"format": "yarn run prettier --write .",
|
|
@@ -37,8 +37,10 @@
|
|
|
37
37
|
"babel-loader": "^8.2.2",
|
|
38
38
|
"eslint": "^7.16.0",
|
|
39
39
|
"eslint-config-prettier": "^8.3.0",
|
|
40
|
+
"eslint-plugin-import": "^2.24.2",
|
|
40
41
|
"eslint-plugin-libram": "^0.1.9",
|
|
41
42
|
"husky": "^4.3.6",
|
|
43
|
+
"java-parser": "^1.4.0",
|
|
42
44
|
"lint-staged": ">=10",
|
|
43
45
|
"node-fetch": "^2.6.1",
|
|
44
46
|
"prettier": "^2.1.2",
|
|
@@ -51,7 +53,7 @@
|
|
|
51
53
|
"dependencies": {
|
|
52
54
|
"@babel/runtime-corejs3": "^7.14.9",
|
|
53
55
|
"core-js": "3.15.2",
|
|
54
|
-
"kolmafia": "^1.
|
|
56
|
+
"kolmafia": "^1.3.0",
|
|
55
57
|
"lodash": "^4.17.21"
|
|
56
58
|
},
|
|
57
59
|
"husky": {
|