diff --git a/node_modules/minimatch/minimatch.js b/node_modules/minimatch/minimatch.js index 0087359..a2221ee 100644 --- a/node_modules/minimatch/minimatch.js +++ b/node_modules/minimatch/minimatch.js @@ -30,7 +30,7 @@ if (!require) { minimatch.Minimatch = Minimatch var LRU = require("lru-cache") - , cache = minimatch.cache = new LRU(100) + , cache = minimatch.cache = new LRU({max: 100}) , GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} var path = require("path") diff --git a/node_modules/minimatch/node_modules/lru-cache/AUTHORS b/node_modules/minimatch/node_modules/lru-cache/AUTHORS index d8e2061..82f1a66 100644 --- a/node_modules/minimatch/node_modules/lru-cache/AUTHORS +++ b/node_modules/minimatch/node_modules/lru-cache/AUTHORS @@ -3,3 +3,5 @@ Isaac Z. Schlueter Carlos Brito Lage Marko Mikulicic Trent Mick +Kevin O'Hara +Marco Rogers diff --git a/node_modules/minimatch/node_modules/lru-cache/README.md b/node_modules/minimatch/node_modules/lru-cache/README.md index f342b51..8ea0dd9 100644 --- a/node_modules/minimatch/node_modules/lru-cache/README.md +++ b/node_modules/minimatch/node_modules/lru-cache/README.md @@ -2,25 +2,45 @@ A cache object that deletes the least-recently-used items. -Usage: +## Usage: - var LRU = require("lru-cache") - , cache = LRU(10, // max length. default = Infinity - // calculate how "big" each item is - // - // defaults to function(){return 1}, ie, just limit - // the item count, without any knowledge as to their - // relative size. - function (item) { return item.length }) +```javascript +var LRU = require("lru-cache") + , options = { max: 500 + , length: function (n) { return n * 2 } + , dispose: function (key, n) { n.close() } + , maxAge: 1000 * 60 * 60 } + , cache = LRU(options) + , otherCache = LRU(50) // sets just the max size - cache.set("key", "value") - cache.get("key") // "value" +cache.set("key", "value") +cache.get("key") // "value" - cache.reset() // empty the cache +cache.reset() // empty the cache +``` If you put more stuff in it, then items will fall out. If you try to put an oversized thing in it, then it'll fall out right away. -RTFS for more info. +## Options + +* `max` The maximum number of items. Not setting this is kind of + silly, since that's the whole purpose of this lib, but it defaults + to `Infinity`. +* `maxAge` Maximum age in ms. Items are not pro-actively pruned out + as they age, but if you try to get an item that is too old, it'll + drop it and return undefined instead of giving it to you. +* `length` Function that is used to calculate the length of stored + items. If you're storing strings or buffers, then you probably want + to do something like `function(n){return n.length}`. The default is + `function(n){return 1}`, which is fine if you want to store `n` + like-sized things. +* `dispose` Function that is called on items when they are dropped + from the cache. This can be handy if you want to close file + descriptors or do other cleanup tasks when items are no longer + accessible. Called with `key, value`. It's called *before* + actually removing the item from the internal cache, so if you want + to immediately put it back in, you'll have to do that in a + `nextTick` or `setTimeout` callback or it won't do anything. diff --git a/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js b/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js index 1bd4e58..27a9a5e 100644 --- a/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js +++ b/node_modules/minimatch/node_modules/lru-cache/lib/lru-cache.js @@ -4,7 +4,7 @@ if (module) { module.exports = LRUCache } else { // just set the global for non-node platforms. - ;(function () { return this })().LRUCache = LRUCache + this.LRUCache = LRUCache } function hOP (obj, key) { @@ -13,18 +13,32 @@ function hOP (obj, key) { function naiveLength () { return 1 } -function LRUCache (maxLength, lengthCalculator) { +function LRUCache (options) { if (!(this instanceof LRUCache)) { - return new LRUCache(maxLength, lengthCalculator) + return new LRUCache(options) } + var max + if (typeof options === 'number') { + max = options + options = {max: max} + } + max = options.max + + if (!options) options = {} + + var lengthCalculator = options.length || naiveLength + if (typeof lengthCalculator !== "function") { lengthCalculator = naiveLength } - if (!maxLength || !(typeof maxLength === "number") || maxLength <= 0 ) { - maxLength = Infinity + if (!max || !(typeof max === "number") || max <= 0 ) { + max = Infinity } + var maxAge = options.maxAge || null + + var dispose = options.dispose var cache = {} // hash of items by key , lruList = {} // list of items in order of use recency @@ -34,16 +48,16 @@ function LRUCache (maxLength, lengthCalculator) { , itemCount = 0 - // resize the cache when the maxLength changes. - Object.defineProperty(this, "maxLength", + // resize the cache when the max changes. + Object.defineProperty(this, "max", { set : function (mL) { if (!mL || !(typeof mL === "number") || mL <= 0 ) mL = Infinity - maxLength = mL - // if it gets above double maxLength, trim right away. + max = mL + // if it gets above double max, trim right away. // otherwise, do it whenever it's convenient. - if (length > maxLength) trim() + if (length > max) trim() } - , get : function () { return maxLength } + , get : function () { return max } , enumerable : true }) @@ -65,7 +79,7 @@ function LRUCache (maxLength, lengthCalculator) { }) } - if (length > maxLength) trim() + if (length > max) trim() } , get : function () { return lengthCalculator } , enumerable : true @@ -83,6 +97,11 @@ function LRUCache (maxLength, lengthCalculator) { }) this.reset = function () { + if (dispose) { + Object.keys(cache).forEach(function (k) { + dispose(k, cache[k].value) + }) + } cache = {} lruList = {} lru = 0 @@ -99,26 +118,40 @@ function LRUCache (maxLength, lengthCalculator) { this.set = function (key, value) { if (hOP(cache, key)) { - this.get(key) + // dispose of the old one before overwriting + if (dispose) dispose(key, cache[key].value) + if (maxAge) cache[key].now = Date.now() cache[key].value = value - return + this.get(key) + return true } - var hit = {key:key, value:value, lu:mru++, length:lengthCalculator(value)} + var hit = { + key:key, + value:value, + lu:mru++, + length:lengthCalculator(value), + now: (maxAge) ? Date.now() : 0 + } // oversized objects fall out of cache automatically. - if (hit.length > maxLength) return + if (hit.length > max) return false length += hit.length lruList[hit.lu] = cache[key] = hit itemCount ++ - if (length > maxLength) trim() + if (length > max) trim() + return true } this.get = function (key) { if (!hOP(cache, key)) return var hit = cache[key] + if (maxAge && (Date.now() - hit.now > maxAge)) { + this.del(key) + return + } delete lruList[hit.lu] if (hit.lu === lru) lruWalk() hit.lu = mru ++ @@ -129,6 +162,7 @@ function LRUCache (maxLength, lengthCalculator) { this.del = function (key) { if (!hOP(cache, key)) return var hit = cache[key] + if (dispose) dispose(key, hit.value) delete cache[key] delete lruList[hit.lu] if (hit.lu === lru) lruWalk() @@ -142,13 +176,16 @@ function LRUCache (maxLength, lengthCalculator) { } function trim () { - if (length <= maxLength) return + if (length <= max) return var prune = Object.keys(lruList) - for (var i = 0; i < prune.length && length > maxLength; i ++) { - length -= lruList[prune[i]].length - delete cache[ lruList[prune[i]].key ] + for (var i = 0; i < prune.length && length > max; i ++) { + var hit = lruList[prune[i]] + if (dispose) dispose(hit.key, hit.value) + length -= hit.length + delete cache[ hit.key ] delete lruList[prune[i]] } + lruWalk() } } diff --git a/node_modules/minimatch/node_modules/lru-cache/package.json b/node_modules/minimatch/node_modules/lru-cache/package.json index d985764..f81d33f 100644 --- a/node_modules/minimatch/node_modules/lru-cache/package.json +++ b/node_modules/minimatch/node_modules/lru-cache/package.json @@ -1,7 +1,7 @@ { "name": "lru-cache", "description": "A cache object that deletes the least-recently-used items.", - "version": "1.1.0", + "version": "2.0.1", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me" @@ -21,11 +21,6 @@ "type": "MIT", "url": "http://github.com/isaacs/node-lru-cache/raw/master/LICENSE" }, - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "_id": "lru-cache@1.1.0", "contributors": [ { "name": "Isaac Z. Schlueter", @@ -42,19 +37,17 @@ { "name": "Trent Mick", "email": "trentm@gmail.com" + }, + { + "name": "Kevin O'Hara", + "email": "kevinohara80@gmail.com" + }, + { + "name": "Marco Rogers", + "email": "marco.rogers@gmail.com" } ], - "dependencies": {}, - "optionalDependencies": {}, - "engines": { - "node": "*" - }, - "_engineSupported": true, - "_npmVersion": "1.1.18", - "_nodeVersion": "v0.6.18", - "_defaultsLoaded": true, - "dist": { - "shasum": "d04716a22fc9499aaec8d70ab63e04be307bc4ea" - }, - "_from": "lru-cache@~1" + "readme": "# lru cache\n\nA cache object that deletes the least-recently-used items.\n\n## Usage:\n\n```javascript\nvar LRU = require(\"lru-cache\")\n , options = { max: 500\n , length: function (n) { return n * 2 }\n , dispose: function (key, n) { n.close() }\n , maxAge: 1000 * 60 * 60 }\n , cache = LRU(options)\n , otherCache = LRU(50) // sets just the max size\n\ncache.set(\"key\", \"value\")\ncache.get(\"key\") // \"value\"\n\ncache.reset() // empty the cache\n```\n\nIf you put more stuff in it, then items will fall out.\n\nIf you try to put an oversized thing in it, then it'll fall out right\naway.\n\n## Options\n\n* `max` The maximum number of items. Not setting this is kind of\n silly, since that's the whole purpose of this lib, but it defaults\n to `Infinity`.\n* `maxAge` Maximum age in ms. Items are not pro-actively pruned out\n as they age, but if you try to get an item that is too old, it'll\n drop it and return undefined instead of giving it to you.\n* `length` Function that is used to calculate the length of stored\n items. If you're storing strings or buffers, then you probably want\n to do something like `function(n){return n.length}`. The default is\n `function(n){return 1}`, which is fine if you want to store `n`\n like-sized things.\n* `dispose` Function that is called on items when they are dropped\n from the cache. This can be handy if you want to close file\n descriptors or do other cleanup tasks when items are no longer\n accessible. Called with `key, value`. It's called *before*\n actually removing the item from the internal cache, so if you want\n to immediately put it back in, you'll have to do that in a\n `nextTick` or `setTimeout` callback or it won't do anything.\n", + "_id": "lru-cache@2.0.1", + "_from": "lru-cache@~2.0.0" } diff --git a/node_modules/minimatch/node_modules/lru-cache/test/basic.js b/node_modules/minimatch/node_modules/lru-cache/test/basic.js index 6af0edf..d04af0b 100644 --- a/node_modules/minimatch/node_modules/lru-cache/test/basic.js +++ b/node_modules/minimatch/node_modules/lru-cache/test/basic.js @@ -2,12 +2,12 @@ var test = require("tap").test , LRU = require("../") test("basic", function (t) { - var cache = new LRU(10) + var cache = new LRU({max: 10}) cache.set("key", "value") t.equal(cache.get("key"), "value") t.equal(cache.get("nada"), undefined) t.equal(cache.length, 1) - t.equal(cache.maxLength, 10) + t.equal(cache.max, 10) t.end() }) @@ -42,17 +42,17 @@ test("del", function (t) { t.end() }) -test("maxLength", function (t) { +test("max", function (t) { var cache = new LRU(3) - // test changing the maxLength, verify that the LRU items get dropped. - cache.maxLength = 100 + // test changing the max, verify that the LRU items get dropped. + cache.max = 100 for (var i = 0; i < 100; i ++) cache.set(i, i) t.equal(cache.length, 100) for (var i = 0; i < 100; i ++) { t.equal(cache.get(i), i) } - cache.maxLength = 3 + cache.max = 3 t.equal(cache.length, 3) for (var i = 0; i < 97; i ++) { t.equal(cache.get(i), undefined) @@ -61,15 +61,15 @@ test("maxLength", function (t) { t.equal(cache.get(i), i) } - // now remove the maxLength restriction, and try again. - cache.maxLength = "hello" + // now remove the max restriction, and try again. + cache.max = "hello" for (var i = 0; i < 100; i ++) cache.set(i, i) t.equal(cache.length, 100) for (var i = 0; i < 100; i ++) { t.equal(cache.get(i), i) } // should trigger an immediate resize - cache.maxLength = 3 + cache.max = 3 t.equal(cache.length, 3) for (var i = 0; i < 97; i ++) { t.equal(cache.get(i), undefined) @@ -86,7 +86,7 @@ test("reset", function (t) { cache.set("b", "B") cache.reset() t.equal(cache.length, 0) - t.equal(cache.maxLength, 10) + t.equal(cache.max, 10) t.equal(cache.get("a"), undefined) t.equal(cache.get("b"), undefined) t.end() @@ -119,20 +119,26 @@ test("dump", function (t) { test("basic with weighed length", function (t) { - var cache = new LRU(100, function (item) { return item.size } ) + var cache = new LRU({ + max: 100, + length: function (item) { return item.size } + }) cache.set("key", {val: "value", size: 50}) t.equal(cache.get("key").val, "value") t.equal(cache.get("nada"), undefined) t.equal(cache.lengthCalculator(cache.get("key")), 50) t.equal(cache.length, 50) - t.equal(cache.maxLength, 100) + t.equal(cache.max, 100) t.end() }) test("weighed length item too large", function (t) { - var cache = new LRU(10, function (item) { return item.size } ) - t.equal(cache.maxLength, 10) + var cache = new LRU({ + max: 10, + length: function (item) { return item.size } + }) + t.equal(cache.max, 10) // should fall out immediately cache.set("key", {val: "value", size: 50}) @@ -143,7 +149,10 @@ test("weighed length item too large", function (t) { }) test("least recently set with weighed length", function (t) { - var cache = new LRU(8, function (item) { return item.length }) + var cache = new LRU({ + max:8, + length: function (item) { return item.length } + }) cache.set("a", "A") cache.set("b", "BB") cache.set("c", "CCC") @@ -156,7 +165,10 @@ test("least recently set with weighed length", function (t) { }) test("lru recently gotten with weighed length", function (t) { - var cache = new LRU(8, function (item) { return item.length }) + var cache = new LRU({ + max: 8, + length: function (item) { return item.length } + }) cache.set("a", "A") cache.set("b", "BB") cache.set("c", "CCC") @@ -169,3 +181,68 @@ test("lru recently gotten with weighed length", function (t) { t.equal(cache.get("a"), "A") t.end() }) + +test("set returns proper booleans", function(t) { + var cache = new LRU({ + max: 5, + length: function (item) { return item.length } + }) + + t.equal(cache.set("a", "A"), true) + + // should return false for max exceeded + t.equal(cache.set("b", "donuts"), false) + + t.equal(cache.set("b", "B"), true) + t.equal(cache.set("c", "CCCC"), true) + t.end() +}) + +test("drop the old items", function(t) { + var cache = new LRU({ + max: 5, + maxAge: 50 + }) + + cache.set("a", "A") + + setTimeout(function () { + cache.set("b", "b") + t.equal(cache.get("a"), "A") + }, 25) + + setTimeout(function () { + cache.set("c", "C") + // timed out + t.notOk(cache.get("a")) + }, 60) + + setTimeout(function () { + t.notOk(cache.get("b")) + t.equal(cache.get("c"), "C") + }, 90) + + setTimeout(function () { + t.notOk(cache.get("c")) + t.end() + }, 155) +}) + +test("disposal function", function(t) { + var disposed = false + var cache = new LRU({ + max: 1, + dispose: function (k, n) { + disposed = n + } + }) + + cache.set(1, 1) + cache.set(2, 2) + t.equal(disposed, 1) + cache.set(3, 3) + t.equal(disposed, 2) + cache.reset() + t.equal(disposed, 3) + t.end() +}) diff --git a/node_modules/minimatch/package.json b/node_modules/minimatch/package.json index eff463d..3e6c6ce 100644 --- a/node_modules/minimatch/package.json +++ b/node_modules/minimatch/package.json @@ -6,7 +6,7 @@ }, "name": "minimatch", "description": "a glob matcher in javascript", - "version": "0.2.5", + "version": "0.2.6", "repository": { "type": "git", "url": "git://github.com/isaacs/minimatch.git" @@ -19,29 +19,19 @@ "node": "*" }, "dependencies": { - "lru-cache": "~1" + "lru-cache": "~2.0.0" }, "devDependencies": { "tap": "" }, - "licenses": [ - { - "type": "MIT", - "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE" - } - ], - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" + "license": { + "type": "MIT", + "url": "http://github.com/isaacs/minimatch/raw/master/LICENSE" }, - "_id": "minimatch@0.2.5", - "optionalDependencies": {}, - "_engineSupported": true, - "_npmVersion": "1.1.18", - "_nodeVersion": "v0.6.18", - "_defaultsLoaded": true, + "readme": "# minimatch\n\nA minimal matching utility.\n\n[![Build Status](https://secure.travis-ci.org/isaacs/minimatch.png)](http://travis-ci.org/isaacs/minimatch)\n\n\nThis is the matching library used internally by npm.\n\nEventually, it will replace the C binding in node-glob.\n\nIt works by converting glob expressions into JavaScript `RegExp`\nobjects.\n\n## Usage\n\n```javascript\nvar minimatch = require(\"minimatch\")\n\nminimatch(\"bar.foo\", \"*.foo\") // true!\nminimatch(\"bar.foo\", \"*.bar\") // false!\n```\n\n## Features\n\nSupports these glob features:\n\n* Brace Expansion\n* Extended glob matching\n* \"Globstar\" `**` matching\n\nSee:\n\n* `man sh`\n* `man bash`\n* `man 3 fnmatch`\n* `man 5 gitignore`\n\n### Comparisons to other fnmatch/glob implementations\n\nWhile strict compliance with the existing standards is a worthwhile\ngoal, some discrepancies exist between minimatch and other\nimplementations, and are intentional.\n\nIf the pattern starts with a `!` character, then it is negated. Set the\n`nonegate` flag to suppress this behavior, and treat leading `!`\ncharacters normally. This is perhaps relevant if you wish to start the\npattern with a negative extglob pattern like `!(a|B)`. Multiple `!`\ncharacters at the start of a pattern will negate the pattern multiple\ntimes.\n\nIf a pattern starts with `#`, then it is treated as a comment, and\nwill not match anything. Use `\\#` to match a literal `#` at the\nstart of a line, or set the `nocomment` flag to suppress this behavior.\n\nThe double-star character `**` is supported by default, unless the\n`noglobstar` flag is set. This is supported in the manner of bsdglob\nand bash 4.1, where `**` only has special significance if it is the only\nthing in a path part. That is, `a/**/b` will match `a/x/y/b`, but\n`a/**b` will not. **Note that this is different from the way that `**` is\nhandled by ruby's `Dir` class.**\n\nIf an escaped pattern has no matches, and the `nonull` flag is set,\nthen minimatch.match returns the pattern as-provided, rather than\ninterpreting the character escapes. For example,\n`minimatch.match([], \"\\\\*a\\\\?\")` will return `\"\\\\*a\\\\?\"` rather than\n`\"*a?\"`. This is akin to setting the `nullglob` option in bash, except\nthat it does not resolve escaped pattern characters.\n\nIf brace expansion is not disabled, then it is performed before any\nother interpretation of the glob pattern. Thus, a pattern like\n`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded\n**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are\nchecked for validity. Since those two are valid, matching proceeds.\n\n\n## Minimatch Class\n\nCreate a minimatch object by instanting the `minimatch.Minimatch` class.\n\n```javascript\nvar Minimatch = require(\"minimatch\").Minimatch\nvar mm = new Minimatch(pattern, options)\n```\n\n### Properties\n\n* `pattern` The original pattern the minimatch object represents.\n* `options` The options supplied to the constructor.\n* `set` A 2-dimensional array of regexp or string expressions.\n Each row in the\n array corresponds to a brace-expanded pattern. Each item in the row\n corresponds to a single path-part. For example, the pattern\n `{a,b/c}/d` would expand to a set of patterns like:\n\n [ [ a, d ]\n , [ b, c, d ] ]\n\n If a portion of the pattern doesn't have any \"magic\" in it\n (that is, it's something like `\"foo\"` rather than `fo*o?`), then it\n will be left as a string rather than converted to a regular\n expression.\n\n* `regexp` Created by the `makeRe` method. A single regular expression\n expressing the entire pattern. This is useful in cases where you wish\n to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled.\n* `negate` True if the pattern is negated.\n* `comment` True if the pattern is a comment.\n* `empty` True if the pattern is `\"\"`.\n\n### Methods\n\n* `makeRe` Generate the `regexp` member if necessary, and return it.\n Will return `false` if the pattern is invalid.\n* `match(fname)` Return true if the filename matches the pattern, or\n false otherwise.\n* `matchOne(fileArray, patternArray, partial)` Take a `/`-split\n filename, and match it against a single row in the `regExpSet`. This\n method is mainly for internal use, but is exposed so that it can be\n used by a glob-walker that needs to avoid excessive filesystem calls.\n\nAll other methods are internal, and will be called as necessary.\n\n## Functions\n\nThe top-level exported function has a `cache` property, which is an LRU\ncache set to store 100 items. So, calling these methods repeatedly\nwith the same pattern and options will use the same Minimatch object,\nsaving the cost of parsing it multiple times.\n\n### minimatch(path, pattern, options)\n\nMain export. Tests a path against the pattern using the options.\n\n```javascript\nvar isJS = minimatch(file, \"*.js\", { matchBase: true })\n```\n\n### minimatch.filter(pattern, options)\n\nReturns a function that tests its\nsupplied argument, suitable for use with `Array.filter`. Example:\n\n```javascript\nvar javascripts = fileList.filter(minimatch.filter(\"*.js\", {matchBase: true}))\n```\n\n### minimatch.match(list, pattern, options)\n\nMatch against the list of\nfiles, in the style of fnmatch or glob. If nothing is matched, and\noptions.nonull is set, then return a list containing the pattern itself.\n\n```javascript\nvar javascripts = minimatch.match(fileList, \"*.js\", {matchBase: true}))\n```\n\n### minimatch.makeRe(pattern, options)\n\nMake a regular expression object from the pattern.\n\n## Options\n\nAll options are `false` by default.\n\n### debug\n\nDump a ton of stuff to stderr.\n\n### nobrace\n\nDo not expand `{a,b}` and `{1..3}` brace sets.\n\n### noglobstar\n\nDisable `**` matching against multiple folder names.\n\n### dot\n\nAllow patterns to match filenames starting with a period, even if\nthe pattern does not explicitly have a period in that spot.\n\nNote that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot`\nis set.\n\n### noext\n\nDisable \"extglob\" style patterns like `+(a|b)`.\n\n### nocase\n\nPerform a case-insensitive match.\n\n### nonull\n\nWhen a match is not found by `minimatch.match`, return a list containing\nthe pattern itself. When set, an empty list is returned if there are\nno matches.\n\n### matchBase\n\nIf set, then patterns without slashes will be matched\nagainst the basename of the path if it contains slashes. For example,\n`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.\n\n### nocomment\n\nSuppress the behavior of treating `#` at the start of a pattern as a\ncomment.\n\n### nonegate\n\nSuppress the behavior of treating a leading `!` character as negation.\n\n### flipNegate\n\nReturns from negate expressions the same as if they were not negated.\n(Ie, true on a hit, false on a miss.)\n", + "_id": "minimatch@0.2.6", "dist": { - "shasum": "4504732638e4004de37c67362dce628bec49c7cf" + "shasum": "bfe2f3df927666671c5c654af99ea8f042de9146" }, - "_from": "minimatch@0.2.x" + "_from": "minimatch@0.2.6" }