normalize-agent
Advanced tools
Comparing version 0.1.8 to 0.1.9
@@ -6,2 +6,4 @@ | ||
var slice = [].slice | ||
Agent.prototype.shorthands = | ||
@@ -13,1 +15,25 @@ Agent.prototype.shorthand = function* (str) { | ||
} | ||
Agent.prototype.shorten = function* (remote) { | ||
var shorthand = this._shorthand | ||
|| (this._shorthand = shorthands(yield* this.proxy())) | ||
var args = slice.call(arguments) | ||
if (typeof remote === 'string') { | ||
var proxy = yield* this.proxy() | ||
var remotes = proxy.remotes | ||
for (var i = 0; i < remotes.length; i++) { | ||
var _remote = remotes[i] | ||
if (~_remote.aliases.indexOf(remote)) { | ||
args[0] = remote = _remote | ||
break | ||
} | ||
} | ||
if (typeof remote === 'string') { | ||
throw new Error('unknown remote: ' + remote) | ||
} | ||
} | ||
return shorthand.js.apply(null, args) | ||
} |
{ | ||
"name": "normalize-agent", | ||
"description": "SPDY client for normalize-proxy", | ||
"version": "0.1.8", | ||
"version": "0.1.9", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Jonathan Ong", |
@@ -17,1 +17,17 @@ | ||
}) | ||
describe('.shorten()', function () { | ||
describe('npm', co(function* () { | ||
it('/npm/-/emitter/1/index.js', co(function* () { | ||
var shorthand = yield* agent.shorten('npm', '-', 'emitter', '1', 'index.js') | ||
shorthand.should.equal('emitter@1') | ||
})) | ||
})) | ||
describe('github', co(function* () { | ||
it('/github/component/emitter/1/index.js', co(function* () { | ||
var shorthand = yield* agent.shorten('github', 'component', 'emitter', '1', 'index.js') | ||
shorthand.should.equal('component/emitter@1') | ||
})) | ||
})) | ||
}) |
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
29661
774