Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better module-environment detection

  • Loading branch information...
commit a591fd7f398396a8a80d67a149fc58181b5b7254 1 parent a5dbd30
@isaacs authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/lru-cache.js
View
5 lib/lru-cache.js
@@ -1,6 +1,6 @@
;(function () { // closure for web browsers
-if (module) {
+if (typeof module === 'object' && module.exports) {
module.exports = LRUCache
} else {
// just set the global for non-node platforms.
@@ -21,7 +21,7 @@ function LRUCache (options) {
var max
if (typeof options === 'number') {
max = options
- options = {max: max}
+ options = { max: max }
}
max = options.max
@@ -33,6 +33,7 @@ function LRUCache (options) {
lengthCalculator = naiveLength
}
if (!max || !(typeof max === "number") || max <= 0 ) {
+ // a little bit silly. maybe this should throw?
max = Infinity
}
Please sign in to comment.
Something went wrong with that request. Please try again.