{"action":"created","issue":{"url":"https://api.github.com/repos/jamestalmage/caching-transform/issues/3","repository_url":"https://api.github.com/repos/jamestalmage/caching-transform","labels_url":"https://api.github.com/repos/jamestalmage/caching-transform/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/jamestalmage/caching-transform/issues/3/comments","events_url":"https://api.github.com/repos/jamestalmage/caching-transform/issues/3/events","html_url":"https://github.com/jamestalmage/caching-transform/issues/3","id":153814082,"number":3,"title":"Support one-to-many transforms","user":{"login":"novemberborn","id":33538,"avatar_url":"https://avatars.githubusercontent.com/u/33538?v=3","gravatar_id":"","url":"https://api.github.com/users/novemberborn","html_url":"https://github.com/novemberborn","followers_url":"https://api.github.com/users/novemberborn/followers","following_url":"https://api.github.com/users/novemberborn/following{/other_user}","gists_url":"https://api.github.com/users/novemberborn/gists{/gist_id}","starred_url":"https://api.github.com/users/novemberborn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/novemberborn/subscriptions","organizations_url":"https://api.github.com/users/novemberborn/orgs","repos_url":"https://api.github.com/users/novemberborn/repos","events_url":"https://api.github.com/users/novemberborn/events{/privacy}","received_events_url":"https://api.github.com/users/novemberborn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-05-09T16:18:27Z","updated_at":"2016-05-15T14:07:00Z","closed_at":null,"body":"Currently transforms are one-to-one. It'd be useful if the transform implementation could return multiple values. For instance with AVA we'll want to cache static analysis of the test files.\r\n\r\nThere should also be an interface for accessing cached values, given the cache directory and the hash. Again in AVA the transform implementation writes source maps to disk, coordinating their location with the test worker which needs to read them. This could be done through `caching-transform` itself.\r\n\r\n(Source maps should still be written to disk in order to play nice with `source-map-support`, but the precompiler could do that without having to coordinate with the worker.)\r\n\r\nMy proposal is to allow the `transform()` implementation to return an object. Keys can be used to access particular results, values must be strings or buffers. When called for an input that has already been cached a similar object can be returned.\r\n\r\nCurrently `caching-transform` is a factory for a `transform` function. We could add a `get(hash, key?)` method. Without the `key` the default result (string / buffer / object) is returned. With the `key` a specific value is returned. If there is no value for the `hash` or `key`, `null` is returned.\r\n\r\nWe could write a JSON object to disk, though that'd be tricky with binary data. It also means that getting a particular value would require the entire cache entry to be read into memory. Alternatively we could write a simple packing implementation that allows random access. (Tar would be an obvious solution, but existing implementations seem to be asynchronous, and as far as I can tell tar requires you to seek for individual files.) A final option is to write a \"header\" and individual results as separate files."},"comment":{"url":"https://api.github.com/repos/jamestalmage/caching-transform/issues/comments/219287841","html_url":"https://github.com/jamestalmage/caching-transform/issues/3#issuecomment-219287841","issue_url":"https://api.github.com/repos/jamestalmage/caching-transform/issues/3","id":219287841,"user":{"login":"jamestalmage","id":4082216,"avatar_url":"https://avatars.githubusercontent.com/u/4082216?v=3","gravatar_id":"","url":"https://api.github.com/users/jamestalmage","html_url":"https://github.com/jamestalmage","followers_url":"https://api.github.com/users/jamestalmage/followers","following_url":"https://api.github.com/users/jamestalmage/following{/other_user}","gists_url":"https://api.github.com/users/jamestalmage/gists{/gist_id}","starred_url":"https://api.github.com/users/jamestalmage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamestalmage/subscriptions","organizations_url":"https://api.github.com/users/jamestalmage/orgs","repos_url":"https://api.github.com/users/jamestalmage/repos","events_url":"https://api.github.com/users/jamestalmage/events{/privacy}","received_events_url":"https://api.github.com/users/jamestalmage/received_events","type":"User","site_admin":false},"created_at":"2016-05-15T14:07:00Z","updated_at":"2016-05-15T14:07:00Z","body":"> Protections?\r\n\r\n`graceful-fs` avoids write collisions."}}