Open jbenet opened 10 years ago
(type inference)
Thinking more about how conversion resolution should happen. As of now, we can pipe types together, and transformer will look at adjacent conversions. For example, this works:
> echo '1399425045' | transform number integer unix-time js-date iso-date
2014-05-07T01:10:45.000Z
But it should really be usable like this:
> echo '1399425045' | transform unix-time iso-date
2014-05-07T01:10:45.000Z
This requires resolving unix-time iso-date -> string number integer unix-time js-date iso-date string
. This is doable because the available transformer modules will be in npm (and tagged properly). So currently, the process looks like:
For 1 above, this is a really good use case for dat. Can have a dat-npm-transformer that filters out only transformer related modules, and serves the data to transformer clients.
How to find transformer modules on npm? Currently:
package.json
will have a "transformer"
key.transformer.<id>[.whatever]
. (e.g. transformer.iso-date-to-string
and transformer.iso-date-to-string.fast
)When the time comes, this will be done in https://github.com/jbenet/transformer-resolve
Should be able to search the type system and find the right conversion.
Trivial example: