mizdra / gen3-poke-data Goto Github PK
View Code? Open in Web Editor NEWNode.jsで作られた第三世代ポケモン情報クラスです。
License: MIT License
Node.jsで作られた第三世代ポケモン情報クラスです。
License: MIT License
現在、本モジュールではJSONSchema
とPokeData
クラスを_named exports_しているが、それらのモジュールの内、PokeData
クラスを_Default exports_に変更してみるのはどうだろうか。
初めに、本モジュールが提供するクラスは上述のJSONSchema
とPokeData
クラスの二つのみであることを確認してほしい。JSONSchema
は図鑑情報を持つjsonをjsオブジェクトにパースする際に用いるものであり、パーサーのためだけに提供されているクラスである。一方でPokeData
は、jsオブジェクトからPokeDataインスタンスを生成するクラスであり、PokeDataインスタンスを作成する全ての外部モジュールに機能を提供している。
本モジュールはそもそもポケモンの情報を保持するクラスを提供するのが真の目的であって、パーサーがそれらを扱いやすくする機能はオプションとして扱っている。従ってPokeData
クラスを_Default exports_、JSONSchema
クラスを_named exports_と変更することで、本モジュールを読み込む外部モジュールにこれらのクラスの役割を明確にしていくべきではないだろうか。
変更するファイルはgen3-poke-data/src/index.ts。
変更前
import JSONSchema from './jsonSchema';
import PokeData from './pokeData';
export {JSONSchema, PokeData};
変更後
export {JSONSchema} from './jsonSchema';
export {PokeData as default} from './pokeData';
export方法の変更により、外部モジュールからのimport方法も変更になる。
変更前
import {PokeData, JSONSchema} from '@mizdra/gen3-poke-data';
変更後
import PokeData, {JSONSchema} from '@mizdra/gen3-poke-data';
data
は意味が曖昧すぎるのでinfo
やstats
, status
に変更したい。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.