Skip to content

Commit 6906172

Browse files
committed
chore: deprecate constants.items
1 parent 81e54ed commit 6906172

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/base/api/constants.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import * as api from 'src/utils/4.api.js';
22
import Item from 'src/structures/constants/item.js';
3+
import Priority from 'src/structures/constants/priority';
34

45
const constants = api.mod.constants;
5-
Object.keys(Item).forEach((key) => {
6-
constants[key] = Item[key];
7-
});
6+
Object.entries(Item).forEach((([key, value]) => {
7+
Object.defineProperty(constants, key, {
8+
get() {
9+
console.warn(`'underscript.constants.${key}' is deprecated, use 'underscript.items.${key}' instead.`);
10+
return value;
11+
},
12+
});
13+
}));
14+
15+
constants.getItem = (value) => Item.find(value);
16+
constants.isItem = (other) => Item.find(other) !== undefined;
17+
constants.getPriority = (value) => Priority.find(value);
18+
constants.isPriority = (other) => Priority.find(other) !== undefined;

0 commit comments

Comments
 (0)