Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-tree-diff

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-tree-diff - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.travis.yml

17

lib/index.js

@@ -6,7 +6,5 @@ 'use strict';

var Set = require('fast-ordered-set');
var util = require('./util');
var Tree = require('./tree');
var Entry = require('./entry');
var byRelativePath = util.byRelativePath;
var ARBITRARY_START_OF_TIME = 0;

@@ -16,6 +14,2 @@

function toChangeOp(change) {
return ['change', change.relativePath];
}
function FSTree(options) {

@@ -31,4 +25,4 @@ options = options || {};

FSTree.fromPaths = function (paths) {
var entries = paths.map(function (path) {
FSTree.fromPaths = function(paths) {
var entries = paths.map(function(path) {
return new Entry(path, 0, ARBITRARY_START_OF_TIME);

@@ -42,2 +36,9 @@ });

FSTree.fromEntries = function(entries) {
return new FSTree({
entries: entries
});
};
FSTree._fromOwnSet = function(set) {

@@ -44,0 +45,0 @@ return new FSTree({ _entries: set });

{
"name": "fs-tree-diff",
"version": "0.1.0",
"version": "0.2.0",
"description": "Backs out file tree changes",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -20,3 +20,3 @@ 'use strict';

};
};
}

@@ -59,2 +59,30 @@ it('can be instantiated', function() {

describe('.fromEntries', function() {
it('creates empty trees', function() {
fsTree = FSTree.fromEntries([ ]);
expect(fsTree.size).to.eq(0);
});
it('creates tree from entries', function() {
var fsTree = FSTree.fromEntries([
entry({ relativePath: 'a/b.js', mode: '0o666', size: 1, mtime: 1 }),
entry({ relativePath: 'c/d.js', mode: '0o666', size: 1, mtime: 1 }),
entry({ relativePath: 'a/c.js', mode: '0o666', size: 1, mtime: 1 })
]);
expect(fsTree.size).to.eq(3);
var result = fsTree.calculatePatch(FSTree.fromEntries([
entry({ relativePath: 'a/b.js', mode: '0o666', size: 1, mtime: 2 }),
entry({ relativePath: 'c/d.js', mode: '0o666', size: 1, mtime: 1 }),
entry({ relativePath: 'a/c.js', mode: '0o666', size: 1, mtime: 1 })
])
);
expect(result).to.deep.equal([
['change', 'a/b.js']
]);
});
});
describe('#calculatePatch', function() {

@@ -61,0 +89,0 @@ context('from an empty tree', function() {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc