Socket
Socket
Sign inDemoInstall

vinyl

Package Overview
Dependencies
28
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.3 to 0.3.0

23

index.js
var path = require('path');
var cloneStats = require('clone-stats');
var cloneDeep = require('lodash.clonedeep');

@@ -46,12 +47,14 @@ var isBuffer = require('./lib/isBuffer');

File.prototype.clone = function() {
var clonedContents = this.isBuffer() ? cloneBuffer(this.contents) : this.contents;
var clonedStat = this.stat ? cloneStats(this.stat) : null;
var clone = new File();
return new File({
cwd: this.cwd,
base: this.base,
path: this.path,
stat: clonedStat,
contents: clonedContents
});
Object.keys(this).forEach(function(key) {
if (key !== '_contents' && key !== 'stat') {
clone[key] = cloneDeep(this[key]);
}
}, this);
clone.contents = this.isBuffer() ? cloneBuffer(this.contents) : this.contents;
clone.stat = this.stat ? cloneStats(this.stat) : null;
return clone;
};

@@ -78,4 +81,2 @@

}
return stream;
};

@@ -82,0 +83,0 @@

{
"name": "vinyl",
"description": "A virtual file format",
"version": "0.2.3",
"version": "0.3.0",
"homepage": "http://github.com/wearefractal/vinyl",

@@ -10,3 +10,4 @@ "repository": "git://github.com/wearefractal/vinyl.git",

"dependencies": {
"clone-stats": "~0.0.1"
"clone-stats": "~0.0.1",
"lodash.clonedeep": "^2.4.1"
},

@@ -13,0 +14,0 @@ "devDependencies": {

@@ -28,3 +28,3 @@ # vinyl [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Dependency Status](https://david-dm.org/wearefractal/vinyl.png?theme=shields.io)](https://david-dm.org/wearefractal/vinyl)

base: "/test/",
path: "/test/file.coffee"
path: "/test/file.coffee",
contents: new Buffer("test = 123")

@@ -83,3 +83,3 @@ });

Returns a new File object with all attributes cloned.
Returns a new File object with all attributes cloned. Custom attributes are deep-cloned.

@@ -94,3 +94,3 @@ ### pipe(stream[, opt])

If opt.end is true, the destination stream will not be ended (same as node core).
If opt.end is false, the destination stream will not be ended (same as node core).

@@ -126,2 +126,2 @@ Returns the stream.

[depstat-url]: https://david-dm.org/wearefractal/vinyl
[depstat-image]: https://david-dm.org/wearefractal/vinyl.png
[depstat-image]: https://david-dm.org/wearefractal/vinyl.png
var File = require('../');
var Stream = require('stream');
var fs = require('fs');
var path = require('path');

@@ -253,2 +254,25 @@ var should = require('should');

});
it('should copy custom properties', function(done) {
var options = {
cwd: "/",
base: "/test/",
path: "/test/test.coffee",
contents: null
};
var file = new File(options);
file.custom = { a: 'custom property' };
var file2 = file.clone();
file2.should.not.equal(file, 'refs should be different');
file2.cwd.should.equal(file.cwd);
file2.base.should.equal(file.base);
file2.path.should.equal(file.path);
file2.custom.should.not.equal(file.custom);
file2.custom.a.should.equal(file.custom.a);
done();
});
});

@@ -536,3 +560,3 @@

});
file.relative.should.equal("test/test.coffee");
file.relative.should.equal(path.join("test","test.coffee"));
done();

@@ -539,0 +563,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc