Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lookup protocol data at top-level of module, without specifying a dataset version? #14

Closed
deathcap opened this issue Jan 26, 2016 · 2 comments

Comments

@deathcap
Copy link
Member

The usage for looking up protocolVersions with node-minecraft-data seems to be slightly awkward, requiring calling the module with a supported version:

> require('minecraft-data')('1.8.9').versionsByMinecraftVersion['1.5.2']
{ minecraftVersion: '1.5.2',
  version: 61,
  usesNetty: false,
  majorVersion: '1.5' }

even though this is the same data in all datasets:

> require('minecraft-data')('1.9').versionsByMinecraftVersion['1.5.2']
{ minecraftVersion: '1.5.2',
  version: 61,
  usesNetty: false,
  majorVersion: '1.5' }

and you have to know a current dataset to lookup any version:

> require('minecraft-data')('1.5.2').versionsByMinecraftVersion['1.5.2']
TypeError: Cannot read property 'versionsByMinecraftVersion' of null

Wouldn't it be cleaner if you could lookup versions, and versionsByMinecraftVersion like this:

> require('minecraft-data').versionsByMinecraftVersion['1.5.2']

or perhaps to maintain the function-calling syntax, something like:

> require('minecraft-data')('common').versionsByMinecraftVersion['1.5.2']

(I started to make this change myself, but got stuck on building the indexes)

@rom1504
Copy link
Member

rom1504 commented Jan 26, 2016

Yeah I guess require('minecraft-data').versionsByMinecraftVersion['1.5.2'] is indeed better.
It's possible by "abusing" the fact js functions are objects.
I'll do that.

@rom1504
Copy link
Member

rom1504 commented Jan 26, 2016

Released as 0.19.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants