Skip to content

Commit

Permalink
optimize relativePath
Browse files Browse the repository at this point in the history
  • Loading branch information
Clements, David authored and Clements, David committed Feb 13, 2017
1 parent 3b240bb commit c965ba9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var fs = require('fs');
var path = require('path');
var relativePath = require('cached-path-relative')

var browserResolve = require('browser-resolve');
var nodeResolve = require('resolve');
var detective = require('detective');
Expand All @@ -12,6 +10,7 @@ var combine = require('stream-combiner2');
var duplexer = require('duplexer2');
var xtend = require('xtend');
var defined = require('defined');
var relativePathCache = {};

var inherits = require('inherits');
var Transform = require('readable-stream').Transform;
Expand Down Expand Up @@ -562,3 +561,9 @@ function wrapTransform (tr) {
tr.on('error', function (err) { wrapper.emit('error', err) });
return wrapper;
}

function relativePath (from, to) {
var key = from + to;
return relativePathCache[key] ||
(relativePathCache[key] = path.relative(from, to));
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"dependencies": {
"JSONStream": "^1.0.3",
"browser-resolve": "^1.7.0",
"cached-path-relative": "^1.0.0",
"concat-stream": "~1.5.0",
"defined": "^1.0.0",
"detective": "^4.0.0",
Expand Down

0 comments on commit c965ba9

Please sign in to comment.