fs-tree-diff
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -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() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
24670
10
625
0
91
0