Coder Social home page Coder Social logo

gen3-poke-data's People

Contributors

mizdra avatar

Watchers

 avatar

gen3-poke-data's Issues

export方法の変更の提案

現在、本モジュールではJSONSchemaPokeDataクラスを_named exports_しているが、それらのモジュールの内、PokeDataクラスを_Default exports_に変更してみるのはどうだろうか。

初めに、本モジュールが提供するクラスは上述のJSONSchemaPokeDataクラスの二つのみであることを確認してほしい。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';

参考資料

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.