fs-tree-diff
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -1,8 +0,28 @@ | ||
### master | ||
# master | ||
* [BREAKING] entries must be lexigraphicaly sorted by relative path | ||
* [BREAKING] entries must include intermediate directories | ||
* [BREAKING] linkdir and unlinkdir no longer supported (BYO metadata) | ||
# v0.5.3 | ||
* Add `FSTree.prototype.addEntries` thanks @chriseppstein | ||
# v0.5.2 | ||
* bump version of heimdalljs-logger | ||
# v0.5.1 | ||
* replace direct use of debug with heimdalljs-logger | ||
# v0.5.0 | ||
* [BREAKING] drop `unlinkdir` and `linkDir` as operations. Downstream can | ||
implement this by examining entries, eg by marking them beforehand as | ||
broccoli-merge-trees does. | ||
* [BREAKING] `unlink` and `rmdir` operations are now passed the entry | ||
* [BREAKING] entries must be lexigraphicaly sorted by relative path. To do this | ||
implicitly, use `sortAndExpand`. | ||
* [BREAKING] entries must include intermediate directories. To do this | ||
implicitly, use `sortAndExpand`. | ||
* reworked implementation to diff via two sorted arrays | ||
* performance improvements | ||
* return entires as-provided, preserving user-specified metadata | ||
* directories in patches always end with a trailing slash | ||
@@ -13,4 +33,16 @@ * fixes various issues related to directory state transitions | ||
# v0.4.x | ||
# v0.4.4 | ||
* it works | ||
* throw errors on duplicate entries (previous behavior was unspecified) | ||
# v0.4.2 | ||
* coerce time to number before comparison | ||
# v0.4.1 | ||
* add `:` in debug namespace for ecosystem consistency | ||
# v0.4.0 | ||
* initial release |
@@ -56,2 +56,35 @@ 'use strict'; | ||
FSTree.prototype.addEntries = function(entries, options) { | ||
if (!Array.isArray(entries)) { | ||
throw new TypeError('entries must be an array'); | ||
} | ||
if (options && options.sortAndExpand) { | ||
sortAndExpand(entries); | ||
} else { | ||
validateSortedUnique(entries); | ||
} | ||
var fromIndex = 0; | ||
var toIndex = 0; | ||
while (fromIndex < entries.length) { | ||
while (toIndex < this.entries.length && | ||
this.entries[toIndex].relativePath < entries[fromIndex].relativePath) { | ||
toIndex++; | ||
} | ||
if (toIndex < this.entries.length && | ||
this.entries[toIndex].relativePath === entries[fromIndex].relativePath) { | ||
this.entries.splice(toIndex, 1, entries[fromIndex++]); | ||
} else { | ||
this.entries.splice(toIndex++, 0, entries[fromIndex++]); | ||
} | ||
} | ||
}; | ||
FSTree.prototype.addPaths = function(paths, options) { | ||
var entries = paths.map(function(path) { | ||
return new Entry(path, 0, ARBITRARY_START_OF_TIME); | ||
}); | ||
this.addEntries(entries, options); | ||
} | ||
FSTree.prototype.forEach = function(fn, context) { | ||
@@ -58,0 +91,0 @@ this.entries.forEach(fn, context); |
{ | ||
"name": "fs-tree-diff", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "Backs out file tree changes", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -120,6 +120,14 @@ # fs-tree-diff [![Build Status](https://travis-ci.org/stefanpenner/fs-tree-diff.svg?branch=master)](https://travis-ci.org/stefanpenner/fs-tree-diff) | ||
`newTree`. Optionally specify a custom `isEqual` (see Change Calculation). | ||
- `FSTree.prototype.addEntries(entries, options)` adds entries to an | ||
existing tree. Options are the same as for `FSTree.fromEntries`. | ||
Entries added with the same path will overwrite any existing entries. | ||
- `FSTree.prototype.addPaths(paths, options)` adds paths to an | ||
existing tree. Options are the same as for `FSTree.fromPaths`. | ||
If entries already exist for any of the paths added, those entries will | ||
be updated. | ||
## Input | ||
`FSTree.fromPaths` and `FSTree.fromEntries` both validate their inputs. Inputs | ||
`FSTree.fromPaths`, `FSTree.fromEntries`, `FSTree.prototype.addPaths`, | ||
and `FSTree.prototype.addEntries` all validate their inputs. Inputs | ||
must be sorted, path-unique (ie two entries with the same `relativePath` but | ||
@@ -126,0 +134,0 @@ different `size`s would still be illegal input) and include intermediate |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
16353
272
222
0