spatialillusions / milstd

MIT License
6 stars 4 forks source link

Consider using valid JS identifier property names to allow dot notation #1

Closed kjellmf closed 6 years ago

kjellmf commented 6 years ago

In JS you can access an object property using bracket notation or dot notation obj['foo'] vs obj.foo. In order to use the dot notation the property name has to be a valid JS identifier name (no spaces etc.).

In the symbology data you provide you use property names like main icon, entity type, modifier 1. This means that we have to use the bracket notation:

let entityType = data['main icon'][3]['entity type'];

If you change the property names to be valid identifier names you allow a more compact syntax:

let entityType = data.mainIcon[3].entityType;

An additional benefit is that the dot notation plays more nicely with auto completion in editors (especially if you provide typings).

Just an idea. Thanks for providing the data!

spatialillusions commented 6 years ago

I was considering this, but at the moment I wanted to keep it as closely as possible as the data is written in the standards. Also at the moment I just wanted to break out this code from milsymbol but make as few changes as possible to the code, so for the moment I will keep the data as it is, but it might change in the future.

spatialillusions commented 6 years ago

This is now fixed in the two repositories that replaces this: https://github.com/spatialillusions/mil-std-2525 https://github.com/spatialillusions/stanag-app6