gulpjs / vinyl

Virtual file format.
MIT License
1.28k stars 107 forks source link

`vinyl.toJSON` method? #83

Open Marak opened 8 years ago

Marak commented 8 years ago

Hello.

Was wondering if there is any support for turning a vinyl File into a JSON object? I couldn't seem to find anything.

Obviously I can write a simple serialization method, but I was wondering if it exists anywhere else in the tool-chain. If not, would you want to add File.toJSON to core?

phated commented 8 years ago

Good idea. I want to test this against a logging stream to make sure the custom display is used over toJSON

yocontra commented 7 years ago

@Marak Still interested in this?

I'd like it to support this ideally: new File(otherFile.toJSON()) - might be overkill though to include history and other fields that might not be pretty to look at in a log.

Should we lose history here? Just stat/path/contents? LMK

phated commented 7 years ago

@contra we can't actually do this due to streaming contents. It's the main reason I opened #133, which will be revisited in the next major (after gulp 4).

Marak commented 7 years ago

I can't remember the specifics, but it seemed to be having been working fine for my use-case.

I needed to serialize the object in order to inspect its properties, not inspect it's binary contents or stream data.