hassansin / parse-address

US Street Address Parser
http://hassansin.github.io/parse-address/
Other
157 stars 81 forks source link

Calling init only when necessary #9

Closed fabiomcosta closed 7 years ago

fabiomcosta commented 7 years ago

The init function is called when the parse-address module is required, which happens eagerly on a regular webpack setup. The init function is very expensive and can take up to 100ms just to run, on one of these expensive MacBooks, on mobile phones it can take 2-3x that. This PR allows us to call the init function only when the one of the parse functions are actually called, saving precious ms on the application startup that are using it.

As a bonus I removed State_FIPS which isn't used anywhere in the code.

fabiomcosta commented 7 years ago

That was really quick, thank you very much, I appreciate your work!

hassansin commented 7 years ago

You are welcome and thank you for the PR!