jbenet / transformer

transformer - multiformat data conversion
transform.datadex.io
130 stars 7 forks source link

find conversion #8

Open jbenet opened 10 years ago

jbenet commented 10 years ago

Should be able to search the type system and find the right conversion.

Trivial example:

echo '127.0.0.1' | transform ip-address hex
# ip-address -> ip-address-buffer -> hex
# ip-address [str] -> [str] ip-address-buffer [buffer] -> [buffer] hex [str]
jbenet commented 10 years ago

(type inference)

jbenet commented 10 years ago

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:

  1. list transformer modules on npm*
  2. build a graph, where types are nodes and conversions are directed edges. (levelgraph?)
  3. find shortest paths. either use shortest, or prompt user to select one. (both use cases will be wanted)

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:

jbenet commented 10 years ago

When the time comes, this will be done in https://github.com/jbenet/transformer-resolve