Skip to content

Commit

Permalink
Remove boilerplate from minimatch.js
Browse files Browse the repository at this point in the history
Also remove unused path module, which was blowing up the browser.js
file, and the reference to process module.
  • Loading branch information
isaacs committed Dec 1, 2014
1 parent 0c7a2f8 commit 66681f4
Showing 1 changed file with 1 addition and 51 deletions.
52 changes: 1 addition & 51 deletions minimatch.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,11 @@
;(function (require, exports, module, platform) {

if (module) module.exports = minimatch
else exports.minimatch = minimatch

if (!require) {
require = function (id) {
switch (id) {
case "sigmund": return function sigmund (obj) {
return JSON.stringify(obj)
}
case "path": return { basename: function (f) {
f = f.split(/[\/\\]/)
var e = f.pop()
if (!e) e = f.pop()
return e
}}
case "lru-cache": return function LRUCache () {
// not quite an LRU, but still space-limited.
var cache = {}
var cnt = 0
this.set = function (k, v) {
cnt ++
if (cnt >= 100) cache = {}
cache[k] = v
}
this.get = function (k) { return cache[k] }
}
}
}
}

module.exports = minimatch
minimatch.Minimatch = Minimatch

var LRU = require("lru-cache")
, cache = minimatch.cache = new LRU({max: 100})
, GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
, sigmund = require("sigmund")

var path = require("path")
// any single thing other than /
// don't need to escape / when using new RegExp()
, qmark = "[^/]"
Expand Down Expand Up @@ -141,12 +109,6 @@ function Minimatch (pattern, options) {
if (!options) options = {}
pattern = pattern.trim()

// windows: need to use /, not \
// On other platforms, \ is a valid (albeit bad) filename char.
if (platform === "win32") {
pattern = pattern.split("\\").join("/")
}

// lru storage.
// these things aren't particularly big, but walking down the string
// and turning it into a regexp can get pretty costly.
Expand Down Expand Up @@ -848,12 +810,6 @@ function match (f, partial) {

var options = this.options

// windows: need to use /, not \
// On other platforms, \ is a valid (albeit bad) filename char.
if (platform === "win32") {
f = f.split("\\").join("/")
}

// treat the test path as a set of pathparts.
f = f.split(slashSplit)
this.debug(this.pattern, "split", f)
Expand Down Expand Up @@ -1065,9 +1021,3 @@ function globUnescape (s) {
function regExpEscape (s) {
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
}

})( typeof require === "function" ? require : null,
this,
typeof module === "object" ? module : null,
typeof process === "object" ? process.platform : "win32"
)

0 comments on commit 66681f4

Please sign in to comment.