Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gc committed Feb 21, 2024
1 parent 4aff070 commit 1a760d6
Show file tree
Hide file tree
Showing 449 changed files with 11,606 additions and 74,709 deletions.
118 changes: 2 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OldSchoolJS

A NodeJS library for doing everything OSRS related. Access the OSRS hiscores, news, worlds, wiki, items, simulating killing monsters, and opening clue caskets - and more.
A NodeJS library for doing everything OSRS related. Access the OSRS hiscores, wiki, items, simulating killing monsters, and opening clue caskets - and more.

For discussion, help or questions - please join https://discord.gg/ob and then our `#developers` channel.

Expand Down Expand Up @@ -129,91 +129,6 @@ const CorporealBeastTable = new LootTable()
CorporealBeastTable.roll();
```
## News
```js
import { News } from 'oldschooljs';
```
Be careful with _fetching_ news articles too often, as the website will ratelimit you after roughly 30 requests in a short period. Whenever a fetch is done, the `News` collection will have any new articles cached.
Rather than fetching articles on demand, you may want to
#### Fetch recent news articles
```js
const recentArticles = await News.fetchRecent();

const mostRecentArticle = recentArticles.first();
```
#### Get news articles for a specific month
```js
const monthOfArticles = await News.filter(article => article.year === 2018 && article.month === 12);

console.log(`There were ${monthOfArticles.size} articles in that month.`);
```
#### Fetch news articles for a specific month
This will _fetch_ news articles for a specific month, i.e it wont be cached. In most cases you can just use `News.filter()` instead of this.
```js
const monthOfArticles = await News.fetchMonth({ year: 2018, month: 12 });

console.log(`There were ${monthOfArticles.size} articles in that month.`);
```
#### List every available news article
If you want this to be up to 100% up to date, you need to call `News.fetchNewArticles()` to fetch newly released articles that aren't cached by oldschooljs.
```js
for (const article of News.values()) {
console.log(article);
}
```
## Worlds
```js
import { Worlds } from 'oldschooljs';
```
#### Fetch and cache all worlds
You **must** call this atleast once to be able to use `Worlds`. To keep worlds up to date, fetching once at startup and then once every few days is enough. If you need an up to date playercount of worlds, you can call it more often or on demand.
```js
await Worlds.fetch();
```
#### Getting a particular world
You can use either form of numbering, giving `301` and `1` will both give you World 1.
```js
const worldOne = Worlds.get(301);
const worldTwo = Worlds.get(2);
```
#### Filtering Worlds
```js
const australianWorlds = Worlds.filter(world => world.location === 'Australia');

console.log(`There are ${australianWorlds.size} Australian Worlds!`);
```
#### Iterating over worlds
```js
for (const world of Worlds.values()) {
console.log(world);
}
```
## Wiki
```js
Expand Down Expand Up @@ -244,27 +159,6 @@ const twistedBowPage = await Wiki.fetchPage(82098);
console.log(twistedBowPage);
```
## Polls
```js
import { Polls } from 'oldschooljs';
```
#### Iterating over worlds
```js
for (const poll of Polls.values()) {
console.log(poll.title);
}
```
#### Getting all polls in a year
```js
const pollsFrom2013 = Polls.filter(poll => new Date(poll.datePosted).getFullYear() === 2013);
console.log(pollsFrom2013.size);
```
## Utilities
```js
Expand Down Expand Up @@ -293,12 +187,4 @@ Util.fromKMB('5'); // 5
Util.fromKMB('1k'); // 1000
Util.fromKMB('1m'); // 1000000
Util.fromKMB('1.2b'); // 1200000000
```
## Planned features
- Ability to ping worlds?
- CrystalMathLabs
- Simulating: killing monsters, opening clue scrolls, pets (like in osbot)
- Quests (e.g. containing all wiki data on quests)
- fetch wiki page by item ID?
```
13 changes: 11 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"organizeImports": {
"enabled": true
},
"files": {
"maxSize": 10000000
},
"linter": {
"enabled": true,
"rules": {
Expand All @@ -16,10 +19,16 @@
},
"style": {
"noNonNullAssertion": "warn",
"noParameterAssign": "off"
"noParameterAssign": "off",
"useExponentiationOperator": "off",
"noUselessElse": "off"
},
"correctness": {
"useExhaustiveDependencies": "warn"
"useExhaustiveDependencies": "warn",
"noUnnecessaryContinue": "warn"
},
"complexity": {
"noExtraBooleanCast": "warn"
}
}
},
Expand Down
24 changes: 10 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oldschooljs",
"version": "2.3.8",
"description": "Allows you to interact with the OSRS Hiscores, Wiki, Worlds, Items, News & more.",
"description": "Allows you to interact with the OSRS Hiscores, Wiki, Items, & more.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
Expand All @@ -17,30 +17,26 @@
"build": "tsc -p .",
"dev": "tsc --watch -p .",
"prepareData": "yarn build && yarn prepareData:run",
"prepareData:run": "ts-node scripts/prepare",
"prepmon": "yarn build && ts-node scripts/prepareMonsters.ts",
"lint": "biome check --apply ./{src,test,scripts} --diagnostic-level=error",
"test:lint": "biome check ./scripts --diagnostic-level=error"
"prepareData:run": "tsx scripts/prepare",
"prepmon": "yarn build && tsx scripts/prepareMonsters.ts",
"lint": "biome check --apply ./src --diagnostic-level=error",
"test:lint": "biome check ./src --diagnostic-level=error"
},
"dependencies": {
"deepmerge": "^4.2.2",
"deepmerge": "^4.3.1",
"e": "^0.2.32",
"jsdom": "^21.1.1",
"node-fetch": "^2.6.7"
},
"devDependencies": {
"@biomejs/biome": "^1.5.3",
"@oldschoolgg/ts-config": "^0.0.1",
"@types/deepmerge": "^2.2.0",
"@types/jsdom": "^16.2.5",
"@types/node": "^14.18.12",
"@types/node-fetch": "^2.6.1",
"@vitest/coverage-c8": "^0.31.0",
"@vitest/coverage-v8": "^1.3.1",
"concurrently": "^8.2.2",
"eslint": "^8.36.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.2",
"vitest": "^0.31.0"
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"vitest": "^1.3.1"
},
"keywords": [
"osrs",
Expand Down
4 changes: 0 additions & 4 deletions scripts/prepare.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import minifyDist from './minifyDist';
import prepareItems from './prepareItems';
import prepareNews from './prepareNews';
import preparePolls from './preparePolls';

prepareNews();
preparePolls();
minifyDist();
prepareItems();
2 changes: 2 additions & 0 deletions scripts/prepareItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ export default async function prepareItems(): Promise<void> {
item.wiki_name = previousItem.wiki_name;
item.release_date = previousItem.release_date;
if (previousItem.equipment?.requirements) {
// @ts-ignore ignore
item.equipment = {
...item.equipment,
requirements: previousItem.equipment.requirements
Expand All @@ -403,6 +404,7 @@ export default async function prepareItems(): Promise<void> {
}

if (previousItem?.equipment?.requirements && !item.equipment?.requirements) {
// @ts-ignore ignore
item.equipment = {
...item.equipment,
requirements: previousItem.equipment.requirements
Expand Down
17 changes: 0 additions & 17 deletions scripts/prepareNews.ts

This file was deleted.

21 changes: 0 additions & 21 deletions scripts/preparePolls.ts

This file was deleted.

Loading

0 comments on commit 1a760d6

Please sign in to comment.