One of the intended use cases of the library is to assist in producing mock data for use in test code.
With this in mind, the existing Reporter objects help determine what data within an object is relevant to the client code, but it would be better to have an explicit representation of the object as seen by the client code.
Suggested implementation
Reconstruct an object having only the property paths (and corresponding values) which were accessed by client code through the wrapper object, by examining observation data.
It isn't necessary to store property values which are non-function objects in the output, since client code will only "see" primitive values and call methods, but is otherwise unaware of the remaining structure of such properties.
Pick the earliest values of properties -values that were accessed before the client code made any changes to the properties.
The reconstructed object should be made available as a JSON string (e.g. in a text file) for easy copying.
Use the serialize-javascript module to allow functions and regular expressions to appear in the output.
Allow the user to pass in an option determining whether functions are copied into the output, or mocked.
A mock function would be a function which stores a map of arguments to return values, used to reproduce the behaviour of the function as it was during the observation period (excluding side effects, of course). There are probably libraries for this purpose.
Validation
Mock/reconstructed objects should not include wrapper code (and therefore should not output observation events when used).
One of the intended use cases of the library is to assist in producing mock data for use in test code.
With this in mind, the existing
Reporter
objects help determine what data within an object is relevant to the client code, but it would be better to have an explicit representation of the object as seen by the client code.Suggested implementation
Validation