gulpjs / vinyl

Virtual file format.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Split "lib" utilities into npm packages?

phated opened this issue · comments

We have a few utilities that I think could benefit being on npm. Such as stripTrailingSlashes and cloneBuffer

Thoughts? cc @contra

Not sure if we want to increase the dependency count, etc.

@phated Seems like overkill + more overhead to maintain. We should look to see if we can replace anything in lib with existing modules though - there has to be a clone buffer, is buffer, is null, etc. that we can rely on instead of rolling our own.

On second look, most of these can be straight up scrapped - we're only using some of them in one place. For example, isNull is only being used once in this whole project:

vinyl/index.js

Line 66 in a6da597

return isNull(this.contents);
but we have tests and whatnot to confirm that == null works.

I agree. Sadly there isn't a buffer cloning utility. I was thinking about splitting that out.

@phated We're only using it in one spot:

vinyl/index.js

Line 120 in a6da597

contents = opt.contents ? cloneBuffer(this.contents) : this.contents;
might be worth inlining that too, its two lines of code

@contra there's actually a new/proper way to clone in node 5.something+ - Buffer.from(buff). I was thinking about combining both strategies into a utility module.

I've removed the utility methods that made sense to use external modules. The only module I personally split out was clone-buffer.