PrismarineJS / node-minecraft-data

Provide easy access to minecraft-data in node.js
https://prismarinejs.github.io/minecraft-data/
100 stars 55 forks source link

fix: add `supportType` type #312

Closed zardoy closed 10 months ago

zardoy commented 1 year ago

I see this repository frequently updated so I''ll prioritize any requests from here.

I'm more interested in the interface I'll be using in my application than the actual type of the supportFeature function. This is what I want to be able to do:

import minecraftData, { SupportsFeature } from 'minecraft-data'

const getSupportFeaturesMap = (version: string) => {
    const supportsFeature = minecraftData(version).supportFeature

    return new Proxy({} as SupportsFeature, {
        get: (target, name) => {
            if (typeof name === 'string') {
                return supportsFeature(version, name)
            }
            return undefined
        }
    })
}

// than do
if (supportsFeature.someThing) { // ...

This thing would give really good intellisense along with descriptions and concise code, so maybe there is a chance I can add it as well?


I don't really know how features.json is generated, but why there are duplicating entries like dimensionDataIsAvailable?

UPDATE: I also can suggest to use code-block-writer in case if generator becomes big

rom1504 commented 10 months ago

I don't really know how features.json is generated

it is not generated, we write it manually

rom1504 commented 10 months ago

lgtm