Permalink
Browse files

Better module-environment detection

  • Loading branch information...
1 parent a5dbd30 commit a591fd7f398396a8a80d67a149fc58181b5b7254 @isaacs committed Sep 17, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/lru-cache.js
View
@@ -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
}

0 comments on commit a591fd7

Please sign in to comment.