Comparing version 2.4.0 to 2.5.0
@@ -5,2 +5,17 @@ # Change Log | ||
<a name="2.5.0"></a> | ||
# [2.5.0](https://github.com/zkat/pacote/compare/v2.4.0...v2.5.0) (2017-04-28) | ||
### Bug Fixes | ||
* **registry:** JSON text is not a valid header value ([78951ea](https://github.com/zkat/pacote/commit/78951ea)) | ||
### Features | ||
* **memoization:** allow injection and control of memoizers ([d8a2be7](https://github.com/zkat/pacote/commit/d8a2be7)) | ||
<a name="2.4.0"></a> | ||
@@ -7,0 +22,0 @@ # [2.4.0](https://github.com/zkat/pacote/compare/v2.3.2...v2.4.0) (2017-04-27) |
@@ -20,2 +20,3 @@ 'use strict' | ||
integrity: opts.integrity, | ||
memoize: opts.memoize, | ||
noProxy: opts.noProxy, | ||
@@ -22,0 +23,0 @@ proxy: opts.proxy, |
@@ -75,4 +75,5 @@ 'use strict' | ||
function fetchPackument (uri, spec, registry, opts) { | ||
if (MEMO.has(uri)) { | ||
return BB.resolve(MEMO.get(uri)) | ||
const mem = pickMem(opts) | ||
if (mem && mem.has(uri)) { | ||
return BB.resolve(mem.get(uri)) | ||
} | ||
@@ -90,3 +91,8 @@ | ||
packument._contentLength = +res.headers.get('content-length') | ||
MEMO.set(uri, packument) | ||
// NOTE - we need to call pickMem again because proxy | ||
// objects get reused! | ||
const mem = pickMem(opts) | ||
if (mem) { | ||
mem.set(uri, packument) | ||
} | ||
return packument | ||
@@ -96,2 +102,23 @@ })) | ||
class ObjProxy { | ||
get (key) { return this.obj[key] } | ||
set (key, val) { this.obj[key] = val } | ||
} | ||
// This object is used synchronously and immediately, so | ||
// we can safely reuse it instead of consing up new ones | ||
const PROX = new ObjProxy() | ||
function pickMem (opts) { | ||
if (!opts || !opts.memoize) { | ||
return MEMO | ||
} else if (opts.memoize.get && opts.memoize.set) { | ||
return opts.memoize | ||
} else if (typeof opts.memoize === 'object') { | ||
PROX.obj = opts.memoize | ||
return PROX | ||
} else { | ||
return null | ||
} | ||
} | ||
function annotateManifest (uri, registry, manifest) { | ||
@@ -98,0 +125,0 @@ const shasum = manifest.dist && manifest.dist.shasum |
@@ -40,4 +40,3 @@ 'use strict' | ||
'pacote-req-type': 'tarball', | ||
'pacote-pkg-id': `registry:${manifest.name}@${manifest.version}`, | ||
'pacote-pkg-manifest': JSON.stringify(manifest) | ||
'pacote-pkg-id': `registry:${manifest.name}@${manifest.version}` | ||
}, | ||
@@ -44,0 +43,0 @@ integrity: manifest._integrity, |
@@ -17,2 +17,3 @@ 'use strict' | ||
this.log = opts.log || silentlog | ||
this.memoize = opts.memoize | ||
this.maxSockets = opts.maxSockets || 10 | ||
@@ -19,0 +20,0 @@ this.offline = opts.offline |
{ | ||
"name": "pacote", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "JavaScript package downloader", | ||
@@ -45,6 +45,6 @@ "main": "index.js", | ||
"bluebird": "^3.5.0", | ||
"cacache": "^8.0.0", | ||
"cacache": "^9.0.0", | ||
"glob": "^7.1.1", | ||
"lru-cache": "^4.0.2", | ||
"make-fetch-happen": "^2.3.0", | ||
"make-fetch-happen": "^2.4.1", | ||
"minimatch": "^3.0.3", | ||
@@ -51,0 +51,0 @@ "mississippi": "^1.2.0", |
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
70915
1512
+ Addedcacache@9.3.0(transitive)
+ Addedy18n@3.2.2(transitive)
- Removedcacache@8.0.0(transitive)
Updatedcacache@^9.0.0
Updatedmake-fetch-happen@^2.4.1