data-structure
This small library lets you declare a custom data structure.
var DataStructure = var Event = position: Number beat: Number time: Number
Usage
var event = position: 1 beat: 1 time: 05
Why?
Well, sometimes you create an object, that's fine...
var event = position: 1 beat: 1 time: 05
But when you pass it around in your application:
{ }
Users of your class may wonder what an "event" look like. Some solutions exist:
- Use comments to describe the structure of the object.
- May quickly be out of date!
- Create an opaque class to hold values.
- Maintenance burden!
- Use Flow/TypeScript
- Now what if we're using 6to5 or CoffeeScript?
- Use this library!!
- Now your code is self-documenting.
- The returned function just validates and returns passed object.
- Code becomes self-checking code!
- No extra type to mess with!