@cao-mei-you-ren/postlight_parser
Version:
Postlight Parser transforms web pages into clean text. Publishers and programmers use it to make the web make sense, and readers use it to read any web article comfortably.
1 lines • 523 kB
Source Map (JSON)
{"version":3,"sources":["../node_modules/.pnpm/tsup@8.2.3_typescript@5.5.4/node_modules/tsup/assets/cjs_shims.js","../node_modules/.pnpm/heap@0.2.7/node_modules/heap/lib/heap.js","../node_modules/.pnpm/heap@0.2.7/node_modules/heap/index.js","../node_modules/.pnpm/difflib@git+https+++git@github.com+postlight+difflib.js.git#32e8e38c7fcd935241b9baab71bb432fd9b166ed/node_modules/difflib/lib/difflib.js","../node_modules/.pnpm/difflib@git+https+++git@github.com+postlight+difflib.js.git#32e8e38c7fcd935241b9baab71bb432fd9b166ed/node_modules/difflib/index.js","../src/mercury.js","../src/extractors/add-extractor.js","../src/utils/merge-supported-domains.js","../src/extractors/get-extractor.js","../src/extractors/all.js","../src/extractors/custom/index.js","../src/extractors/custom/blogspot.com/index.js","../src/extractors/custom/nymag.com/index.js","../src/extractors/custom/wikipedia.org/index.js","../src/extractors/custom/twitter.com/index.js","../src/extractors/custom/www.nytimes.com/index.js","../src/extractors/custom/www.theatlantic.com/index.js","../src/extractors/custom/www.newyorker.com/index.js","../src/extractors/custom/www.wired.com/index.js","../src/extractors/custom/www.msn.com/index.js","../src/extractors/custom/www.yahoo.com/index.js","../src/extractors/custom/www.buzzfeed.com/index.js","../src/extractors/custom/fandom.wikia.com/index.js","../src/extractors/custom/www.littlethings.com/index.js","../src/extractors/custom/www.politico.com/index.js","../src/extractors/custom/deadspin.com/index.js","../src/extractors/custom/www.broadwayworld.com/index.js","../src/extractors/custom/www.apartmenttherapy.com/index.js","../src/extractors/custom/medium.com/index.js","../src/extractors/custom/www.tmz.com/index.js","../src/extractors/custom/www.washingtonpost.com/index.js","../src/extractors/custom/www.huffingtonpost.com/index.js","../src/extractors/custom/newrepublic.com/index.js","../src/extractors/custom/money.cnn.com/index.js","../src/extractors/custom/www.theverge.com/index.js","../src/extractors/custom/www.cnn.com/index.js","../src/extractors/custom/www.aol.com/index.js","../src/extractors/custom/www.youtube.com/index.js","../src/extractors/custom/www.theguardian.com/index.js","../src/extractors/custom/www.sbnation.com/index.js","../src/extractors/custom/www.bloomberg.com/index.js","../src/extractors/custom/www.bustle.com/index.js","../src/extractors/custom/www.npr.org/index.js","../src/extractors/custom/www.recode.net/index.js","../src/extractors/custom/qz.com/index.js","../src/extractors/custom/www.dmagazine.com/index.js","../src/extractors/custom/www.reuters.com/index.js","../src/extractors/custom/mashable.com/index.js","../src/extractors/custom/www.chicagotribune.com/index.js","../src/extractors/custom/www.vox.com/index.js","../src/extractors/custom/news.nationalgeographic.com/index.js","../src/extractors/custom/www.nationalgeographic.com/index.js","../src/extractors/custom/www.latimes.com/index.js","../src/extractors/custom/pagesix.com/index.js","../src/extractors/custom/thefederalistpapers.org/index.js","../src/extractors/custom/www.cbssports.com/index.js","../src/extractors/custom/www.msnbc.com/index.js","../src/extractors/custom/www.thepoliticalinsider.com/index.js","../src/extractors/custom/www.mentalfloss.com/index.js","../src/extractors/custom/abcnews.go.com/index.js","../src/extractors/custom/www.nydailynews.com/index.js","../src/extractors/custom/www.cnbc.com/index.js","../src/extractors/custom/www.popsugar.com/index.js","../src/extractors/custom/observer.com/index.js","../src/extractors/custom/people.com/index.js","../src/extractors/custom/www.usmagazine.com/index.js","../src/extractors/custom/www.rollingstone.com/index.js","../src/extractors/custom/247sports.com/index.js","../src/extractors/custom/uproxx.com/index.js","../src/extractors/custom/www.eonline.com/index.js","../src/extractors/custom/www.miamiherald.com/index.js","../src/extractors/custom/www.refinery29.com/index.js","../src/extractors/custom/www.macrumors.com/index.js","../src/extractors/custom/www.androidcentral.com/index.js","../src/extractors/custom/www.si.com/index.js","../src/extractors/custom/www.rawstory.com/index.js","../src/extractors/custom/www.cnet.com/index.js","../src/extractors/custom/www.today.com/index.js","../src/extractors/custom/www.al.com/index.js","../src/extractors/custom/www.thepennyhoarder.com/index.js","../src/extractors/custom/www.westernjournalism.com/index.js","../src/extractors/custom/www.americanow.com/index.js","../src/extractors/custom/sciencefly.com/index.js","../src/extractors/custom/hellogiggles.com/index.js","../src/extractors/custom/thoughtcatalog.com/index.js","../src/extractors/custom/www.inquisitr.com/index.js","../src/extractors/custom/www.nbcnews.com/index.js","../src/extractors/custom/fortune.com/index.js","../src/extractors/custom/www.linkedin.com/index.js","../src/extractors/custom/obamawhitehouse.archives.gov/index.js","../src/extractors/custom/www.opposingviews.com/index.js","../src/extractors/custom/www.prospectmagazine.co.uk/index.js","../src/extractors/custom/forward.com/index.js","../src/extractors/custom/www.qdaily.com/index.js","../src/extractors/custom/gothamist.com/index.js","../src/extractors/custom/www.fool.com/index.js","../src/extractors/custom/www.slate.com/index.js","../src/extractors/custom/ici.radio-canada.ca/index.js","../src/extractors/custom/www.fortinet.com/index.js","../src/extractors/custom/www.fastcompany.com/index.js","../src/extractors/custom/blisterreview.com/index.js","../src/extractors/custom/news.mynavi.jp/index.js","../src/extractors/custom/clinicaltrials.gov/index.js","../src/extractors/custom/github.com/index.js","../src/extractors/custom/www.reddit.com/index.js","../src/extractors/custom/otrs.com/index.js","../src/extractors/custom/www.ossnews.jp/index.js","../src/extractors/custom/buzzap.jp/index.js","../src/extractors/custom/www.asahi.com/index.js","../src/extractors/custom/www.sanwa.co.jp/index.js","../src/extractors/custom/www.elecom.co.jp/index.js","../src/extractors/custom/scan.netsecurity.ne.jp/index.js","../src/extractors/custom/jvndb.jvn.jp/index.js","../src/extractors/custom/genius.com/index.js","../src/extractors/custom/www.jnsa.org/index.js","../src/extractors/custom/phpspot.org/index.js","../src/extractors/custom/www.infoq.com/index.js","../src/extractors/custom/www.moongift.jp/index.js","../src/extractors/custom/www.itmedia.co.jp/index.js","../src/extractors/custom/www.publickey1.jp/index.js","../src/extractors/custom/takagi-hiromitsu.jp/index.js","../src/extractors/custom/bookwalker.jp/index.js","../src/extractors/custom/www.yomiuri.co.jp/index.js","../src/extractors/custom/japan.cnet.com/index.js","../src/extractors/custom/deadline.com/index.js","../src/extractors/custom/www.gizmodo.jp/index.js","../src/extractors/custom/getnews.jp/index.js","../src/extractors/custom/www.lifehacker.jp/index.js","../src/extractors/custom/sect.iij.ad.jp/index.js","../src/extractors/custom/www.oreilly.co.jp/index.js","../src/extractors/custom/www.ipa.go.jp/index.js","../src/extractors/custom/weekly.ascii.jp/index.js","../src/extractors/custom/techlog.iij.ad.jp/index.js","../src/extractors/custom/wired.jp/index.js","../src/extractors/custom/japan.zdnet.com/index.js","../src/extractors/custom/www.rbbtoday.com/index.js","../src/extractors/custom/www.lemonde.fr/index.js","../src/extractors/custom/www.phoronix.com/index.js","../src/extractors/custom/pitchfork.com/index.js","../src/extractors/custom/biorxiv.org/index.js","../src/extractors/custom/epaper.zeit.de/index.js","../src/extractors/custom/www.ladbible.com/index.js","../src/extractors/custom/timesofindia.indiatimes.com/index.js","../src/extractors/custom/ma.ttias.be/index.js","../src/extractors/custom/pastebin.com/index.js","../src/extractors/custom/www.abendblatt.de/index.js","../src/extractors/custom/www.gruene.de/index.js","../src/extractors/custom/www.engadget.com/index.js","../src/extractors/custom/arstechnica.com/index.js","../src/extractors/custom/www.ndtv.com/index.js","../src/extractors/custom/www.spektrum.de/index.js","../src/extractors/custom/postlight.com/index.js","../src/extractors/custom/www.investmentexecutive.com/index.js","../src/extractors/custom/www.cbc.ca/index.js","../src/extractors/generic/index.js","../src/extractors/generic/content/extractor.js","../src/utils/dom/index.js","../src/utils/dom/strip-unlikely-candidates.js","../src/utils/dom/constants.js","../src/utils/dom/brs-to-ps.js","../src/utils/dom/paragraphize.js","../src/utils/dom/convert-to-paragraphs.js","../src/utils/dom/convert-node-to.js","../src/utils/dom/clean-images.js","../src/utils/dom/mark-to-keep.js","../src/utils/dom/strip-junk-tags.js","../src/utils/dom/clean-h-ones.js","../src/utils/dom/clean-attributes.js","../src/utils/dom/remove-empty.js","../src/utils/dom/clean-tags.js","../src/extractors/generic/content/scoring/index.js","../src/extractors/generic/content/scoring/get-weight.js","../src/extractors/generic/content/scoring/constants.js","../src/extractors/generic/content/scoring/get-score.js","../src/extractors/generic/content/scoring/score-commas.js","../src/extractors/generic/content/scoring/score-length.js","../src/extractors/generic/content/scoring/score-paragraph.js","../src/extractors/generic/content/scoring/set-score.js","../src/extractors/generic/content/scoring/add-score.js","../src/extractors/generic/content/scoring/add-to-parent.js","../src/extractors/generic/content/scoring/get-or-init-score.js","../src/extractors/generic/content/scoring/score-node.js","../src/extractors/generic/content/scoring/score-content.js","../src/extractors/generic/content/scoring/find-top-candidate.js","../src/extractors/generic/content/scoring/merge-siblings.js","../src/utils/text/index.js","../src/utils/text/normalize-spaces.js","../src/utils/text/extract-from-url.js","../src/utils/text/page-num-from-url.js","../src/utils/text/constants.js","../src/utils/text/remove-anchor.js","../src/utils/text/article-base-url.js","../src/utils/text/has-sentence-end.js","../src/utils/text/excerpt-content.js","../src/utils/text/get-encoding.js","../src/utils/dom/clean-headers.js","../src/utils/dom/rewrite-top-level.js","../src/utils/dom/make-links-absolute.js","../src/utils/dom/link-density.js","../src/utils/dom/extract-from-meta.js","../src/utils/dom/extract-from-selectors.js","../src/utils/dom/strip-tags.js","../src/utils/dom/within-comment.js","../src/utils/dom/node-is-sufficient.js","../src/utils/dom/is-wordpress.js","../src/utils/dom/get-attrs.js","../src/utils/dom/set-attr.js","../src/utils/dom/set-attrs.js","../src/cleaners/index.js","../src/cleaners/author.js","../src/cleaners/constants.js","../src/cleaners/lead-image-url.js","../src/cleaners/dek.js","../src/cleaners/date-published.js","../src/cleaners/content.js","../src/cleaners/title.js","../src/cleaners/resolve-split-title.js","../src/extractors/generic/content/extract-best-node.js","../src/extractors/generic/title/extractor.js","../src/extractors/generic/title/constants.js","../src/extractors/generic/author/extractor.js","../src/extractors/generic/author/constants.js","../src/extractors/generic/date-published/extractor.js","../src/extractors/generic/date-published/constants.js","../src/extractors/generic/dek/extractor.js","../src/extractors/generic/lead-image-url/extractor.js","../src/extractors/generic/lead-image-url/constants.js","../src/extractors/generic/lead-image-url/score-image.js","../src/extractors/generic/next-page-url/extractor.js","../src/extractors/generic/next-page-url/scoring/score-links.js","../src/extractors/generic/next-page-url/scoring/utils/index.js","../src/extractors/generic/next-page-url/scoring/utils/score-similarity.js","../src/extractors/generic/next-page-url/scoring/utils/score-link-text.js","../src/extractors/generic/next-page-url/scoring/utils/score-page-in-link.js","../src/extractors/generic/next-page-url/scoring/utils/score-extraneous-links.js","../src/extractors/generic/next-page-url/scoring/constants.js","../src/extractors/generic/next-page-url/scoring/utils/score-by-parents.js","../src/utils/index.js","../src/utils/range.js","../src/utils/validate-url.js","../src/extractors/generic/next-page-url/scoring/utils/score-prev-link.js","../src/extractors/generic/next-page-url/scoring/utils/should-score.js","../src/extractors/generic/next-page-url/scoring/utils/score-base-url.js","../src/extractors/generic/next-page-url/scoring/utils/score-next-link-text.js","../src/extractors/generic/next-page-url/scoring/utils/score-cap-links.js","../src/extractors/generic/url/extractor.js","../src/extractors/generic/url/constants.js","../src/extractors/generic/excerpt/extractor.js","../src/extractors/generic/excerpt/constants.js","../src/extractors/generic/word-count/extractor.js","../src/extractors/detect-by-html.js","../src/extractors/root-extractor.js","../src/extractors/collect-all-pages.js","../src/resource/index.js","../src/resource/utils/index.js","../src/resource/utils/fetch-resource.js","../src/resource/utils/constants.js","../src/resource/utils/dom/index.js","../src/resource/utils/dom/normalize-meta-tags.js","../src/resource/utils/dom/convert-lazy-loaded-images.js","../src/resource/utils/dom/constants.js","../src/resource/utils/dom/clean.js"],"sourcesContent":["// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","// Generated by CoffeeScript 1.8.0\n(function() {\n var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;\n\n floor = Math.floor, min = Math.min;\n\n\n /*\n Default comparison function to be used\n */\n\n defaultCmp = function(x, y) {\n if (x < y) {\n return -1;\n }\n if (x > y) {\n return 1;\n }\n return 0;\n };\n\n\n /*\n Insert item x in list a, and keep it sorted assuming a is sorted.\n \n If x is already in a, insert it to the right of the rightmost x.\n \n Optional args lo (default 0) and hi (default a.length) bound the slice\n of a to be searched.\n */\n\n insort = function(a, x, lo, hi, cmp) {\n var mid;\n if (lo == null) {\n lo = 0;\n }\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (lo < 0) {\n throw new Error('lo must be non-negative');\n }\n if (hi == null) {\n hi = a.length;\n }\n while (lo < hi) {\n mid = floor((lo + hi) / 2);\n if (cmp(x, a[mid]) < 0) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);\n };\n\n\n /*\n Push item onto heap, maintaining the heap invariant.\n */\n\n heappush = function(array, item, cmp) {\n if (cmp == null) {\n cmp = defaultCmp;\n }\n array.push(item);\n return _siftdown(array, 0, array.length - 1, cmp);\n };\n\n\n /*\n Pop the smallest item off the heap, maintaining the heap invariant.\n */\n\n heappop = function(array, cmp) {\n var lastelt, returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n lastelt = array.pop();\n if (array.length) {\n returnitem = array[0];\n array[0] = lastelt;\n _siftup(array, 0, cmp);\n } else {\n returnitem = lastelt;\n }\n return returnitem;\n };\n\n\n /*\n Pop and return the current smallest value, and add the new item.\n \n This is more efficient than heappop() followed by heappush(), and can be\n more appropriate when using a fixed size heap. Note that the value\n returned may be larger than item! That constrains reasonable use of\n this routine unless written as part of a conditional replacement:\n if item > array[0]\n item = heapreplace(array, item)\n */\n\n heapreplace = function(array, item, cmp) {\n var returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n returnitem = array[0];\n array[0] = item;\n _siftup(array, 0, cmp);\n return returnitem;\n };\n\n\n /*\n Fast version of a heappush followed by a heappop.\n */\n\n heappushpop = function(array, item, cmp) {\n var _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (array.length && cmp(array[0], item) < 0) {\n _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];\n _siftup(array, 0, cmp);\n }\n return item;\n };\n\n\n /*\n Transform list into a heap, in-place, in O(array.length) time.\n */\n\n heapify = function(array, cmp) {\n var i, _i, _j, _len, _ref, _ref1, _results, _results1;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n _ref1 = (function() {\n _results1 = [];\n for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }\n return _results1;\n }).apply(this).reverse();\n _results = [];\n for (_i = 0, _len = _ref1.length; _i < _len; _i++) {\n i = _ref1[_i];\n _results.push(_siftup(array, i, cmp));\n }\n return _results;\n };\n\n\n /*\n Update the position of the given item in the heap.\n This function should be called every time the item is being modified.\n */\n\n updateItem = function(array, item, cmp) {\n var pos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n pos = array.indexOf(item);\n if (pos === -1) {\n return;\n }\n _siftdown(array, 0, pos, cmp);\n return _siftup(array, pos, cmp);\n };\n\n\n /*\n Find the n largest elements in a dataset.\n */\n\n nlargest = function(array, n, cmp) {\n var elem, result, _i, _len, _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n result = array.slice(0, n);\n if (!result.length) {\n return result;\n }\n heapify(result, cmp);\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n heappushpop(result, elem, cmp);\n }\n return result.sort(cmp).reverse();\n };\n\n\n /*\n Find the n smallest elements in a dataset.\n */\n\n nsmallest = function(array, n, cmp) {\n var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (n * 10 <= array.length) {\n result = array.slice(0, n).sort(cmp);\n if (!result.length) {\n return result;\n }\n los = result[result.length - 1];\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n if (cmp(elem, los) < 0) {\n insort(result, elem, 0, null, cmp);\n result.pop();\n los = result[result.length - 1];\n }\n }\n return result;\n }\n heapify(array, cmp);\n _results = [];\n for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {\n _results.push(heappop(array, cmp));\n }\n return _results;\n };\n\n _siftdown = function(array, startpos, pos, cmp) {\n var newitem, parent, parentpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n newitem = array[pos];\n while (pos > startpos) {\n parentpos = (pos - 1) >> 1;\n parent = array[parentpos];\n if (cmp(newitem, parent) < 0) {\n array[pos] = parent;\n pos = parentpos;\n continue;\n }\n break;\n }\n return array[pos] = newitem;\n };\n\n _siftup = function(array, pos, cmp) {\n var childpos, endpos, newitem, rightpos, startpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n endpos = array.length;\n startpos = pos;\n newitem = array[pos];\n childpos = 2 * pos + 1;\n while (childpos < endpos) {\n rightpos = childpos + 1;\n if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {\n childpos = rightpos;\n }\n array[pos] = array[childpos];\n pos = childpos;\n childpos = 2 * pos + 1;\n }\n array[pos] = newitem;\n return _siftdown(array, startpos, pos, cmp);\n };\n\n Heap = (function() {\n Heap.push = heappush;\n\n Heap.pop = heappop;\n\n Heap.replace = heapreplace;\n\n Heap.pushpop = heappushpop;\n\n Heap.heapify = heapify;\n\n Heap.updateItem = updateItem;\n\n Heap.nlargest = nlargest;\n\n Heap.nsmallest = nsmallest;\n\n function Heap(cmp) {\n this.cmp = cmp != null ? cmp : defaultCmp;\n this.nodes = [];\n }\n\n Heap.prototype.push = function(x) {\n return heappush(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pop = function() {\n return heappop(this.nodes, this.cmp);\n };\n\n Heap.prototype.peek = function() {\n return this.nodes[0];\n };\n\n Heap.prototype.contains = function(x) {\n return this.nodes.indexOf(x) !== -1;\n };\n\n Heap.prototype.replace = function(x) {\n return heapreplace(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pushpop = function(x) {\n return heappushpop(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.heapify = function() {\n return heapify(this.nodes, this.cmp);\n };\n\n Heap.prototype.updateItem = function(x) {\n return updateItem(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.clear = function() {\n return this.nodes = [];\n };\n\n Heap.prototype.empty = function() {\n return this.nodes.length === 0;\n };\n\n Heap.prototype.size = function() {\n return this.nodes.length;\n };\n\n Heap.prototype.clone = function() {\n var heap;\n heap = new Heap();\n heap.nodes = this.nodes.slice(0);\n return heap;\n };\n\n Heap.prototype.toArray = function() {\n return this.nodes.slice(0);\n };\n\n Heap.prototype.insert = Heap.prototype.push;\n\n Heap.prototype.top = Heap.prototype.peek;\n\n Heap.prototype.front = Heap.prototype.peek;\n\n Heap.prototype.has = Heap.prototype.contains;\n\n Heap.prototype.copy = Heap.prototype.clone;\n\n return Heap;\n\n })();\n\n (function(root, factory) {\n if (typeof define === 'function' && define.amd) {\n return define([], factory);\n } else if (typeof exports === 'object') {\n return module.exports = factory();\n } else {\n return root.Heap = factory();\n }\n })(this, function() {\n return Heap;\n });\n\n}).call(this);\n","module.exports = require('./lib/heap');\n","// Generated by CoffeeScript 1.3.1\n\n/*\nModule difflib -- helpers for computing deltas between objects.\n\nFunction getCloseMatches(word, possibilities, n=3, cutoff=0.6):\n Use SequenceMatcher to return list of the best \"good enough\" matches.\n\nFunction contextDiff(a, b):\n For two lists of strings, return a delta in context diff format.\n\nFunction ndiff(a, b):\n Return a delta: the difference between `a` and `b` (lists of strings).\n\nFunction restore(delta, which):\n Return one of the two sequences that generated an ndiff delta.\n\nFunction unifiedDiff(a, b):\n For two lists of strings, return a delta in unified diff format.\n\nClass SequenceMatcher:\n A flexible class for comparing pairs of sequences of any type.\n\nClass Differ:\n For producing human-readable deltas from sequences of lines of text.\n*/\n\n\n(function() {\n var Differ, Heap, IS_CHARACTER_JUNK, IS_LINE_JUNK, SequenceMatcher, contextDiff, floor, getCloseMatches, max, min, ndiff, restore, unifiedDiff, _any, _arrayCmp, _calculateRatio, _countLeading, _formatRangeContext, _formatRangeUnified, _has,\n __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i } return -1 }\n\n floor = Math.floor, max = Math.max, min = Math.min\n\n Heap = require('heap')\n\n _calculateRatio = function(matches, length) {\n if (length) {\n return 2.0 * matches / length\n } else {\n return 1.0\n }\n }\n\n _arrayCmp = function(a, b) {\n var i, la, lb, _i, _ref, _ref1\n _ref = [a.length, b.length], la = _ref[0], lb = _ref[1]\n for (i = _i = 0, _ref1 = min(la, lb); 0 <= _ref1 ? _i < _ref1 : _i > _ref1; i = 0 <= _ref1 ? ++_i : --_i) {\n if (a[i] < b[i]) {\n return -1\n }\n if (a[i] > b[i]) {\n return 1\n }\n }\n return la - lb\n }\n\n _has = function(obj, key) {\n return Object.prototype.hasOwnProperty.call(obj, key)\n }\n\n _any = function(items) {\n var item, _i, _len\n for (_i = 0, _len = items.length; _i < _len; _i++) {\n item = items[_i]\n if (item) {\n return true\n }\n }\n return false\n }\n\n SequenceMatcher = (function() {\n\n /*\n SequenceMatcher is a flexible class for comparing pairs of sequences of\n any type, so long as the sequence elements are hashable. The basic\n algorithm predates, and is a little fancier than, an algorithm\n published in the late 1980's by Ratcliff and Obershelp under the\n hyperbolic name \"gestalt pattern matching\". The basic idea is to find\n the longest contiguous matching subsequence that contains no \"junk\"\n elements (R-O doesn't address junk). The same idea is then applied\n recursively to the pieces of the sequences to the left and to the right\n of the matching subsequence. This does not yield minimal edit\n sequences, but does tend to yield matches that \"look right\" to people.\n \n SequenceMatcher tries to compute a \"human-friendly diff\" between two\n sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the\n longest *contiguous* & junk-free matching subsequence. That's what\n catches peoples' eyes. The Windows(tm) windiff has another interesting\n notion, pairing up elements that appear uniquely in each sequence.\n That, and the method here, appear to yield more intuitive difference\n reports than does diff. This method appears to be the least vulnerable\n to synching up on blocks of \"junk lines\", though (like blank lines in\n ordinary text files, or maybe \"<P>\" lines in HTML files). That may be\n because this is the only method of the 3 that has a *concept* of\n \"junk\" <wink>.\n \n Example, comparing two strings, and considering blanks to be \"junk\":\n \n >>> isjunk = (c) -> c is ' '\n >>> s = new SequenceMatcher(isjunk,\n 'private Thread currentThread;',\n 'private volatile Thread currentThread;')\n \n .ratio() returns a float in [0, 1], measuring the \"similarity\" of the\n sequences. As a rule of thumb, a .ratio() value over 0.6 means the\n sequences are close matches:\n \n >>> s.ratio().toPrecision(3)\n '0.866'\n \n If you're only interested in where the sequences match,\n .getMatchingBlocks() is handy:\n \n >>> for [a, b, size] in s.getMatchingBlocks()\n ... console.log(\"a[#{a}] and b[#{b}] match for #{size} elements\");\n a[0] and b[0] match for 8 elements\n a[8] and b[17] match for 21 elements\n a[29] and b[38] match for 0 elements\n \n Note that the last tuple returned by .get_matching_blocks() is always a\n dummy, (len(a), len(b), 0), and this is the only case in which the last\n tuple element (number of elements matched) is 0.\n \n If you want to know how to change the first sequence into the second,\n use .get_opcodes():\n \n >>> for [op, a1, a2, b1, b2] in s.getOpcodes()\n ... console.log \"#{op} a[#{a1}:#{a2}] b[#{b1}:#{b2}]\"\n equal a[0:8] b[0:8]\n insert a[8:8] b[8:17]\n equal a[8:29] b[17:38]\n \n See the Differ class for a fancy human-friendly file differencer, which\n uses SequenceMatcher both to compare sequences of lines, and to compare\n sequences of characters within similar (near-matching) lines.\n \n See also function getCloseMatches() in this module, which shows how\n simple code building on SequenceMatcher can be used to do useful work.\n \n Timing: Basic R-O is cubic time worst case and quadratic time expected\n case. SequenceMatcher is quadratic time for the worst case and has\n expected-case behavior dependent in a complicated way on how many\n elements the sequences have in common; best case time is linear.\n \n Methods:\n \n constructor(isjunk=null, a='', b='')\n Construct a SequenceMatcher.\n \n setSeqs(a, b)\n Set the two sequences to be compared.\n \n setSeq1(a)\n Set the first sequence to be compared.\n \n setSeq2(b)\n Set the second sequence to be compared.\n \n findLongestMatch(alo, ahi, blo, bhi)\n Find longest matching block in a[alo:ahi] and b[blo:bhi].\n \n getMatchingBlocks()\n Return list of triples describing matching subsequences.\n \n getOpcodes()\n Return list of 5-tuples describing how to turn a into b.\n \n ratio()\n Return a measure of the sequences' similarity (float in [0,1]).\n \n quickRatio()\n Return an upper bound on .ratio() relatively quickly.\n \n realQuickRatio()\n Return an upper bound on ratio() very quickly.\n */\n\n\n function SequenceMatcher(isjunk, a, b, autojunk) {\n this.isjunk = isjunk\n if (a == null) {\n a = ''\n }\n if (b == null) {\n b = ''\n }\n this.autojunk = autojunk != null ? autojunk : true\n /*\n Construct a SequenceMatcher.\n \n Optional arg isjunk is null (the default), or a one-argument\n function that takes a sequence element and returns true iff the\n element is junk. Null is equivalent to passing \"(x) -> 0\", i.e.\n no elements are considered to be junk. For example, pass\n (x) -> x in ' \\t'\n if you're comparing lines as sequences of characters, and don't\n want to synch up on blanks or hard tabs.\n \n Optional arg a is the first of two sequences to be compared. By\n default, an empty string. The elements of a must be hashable. See\n also .setSeqs() and .setSeq1().\n \n Optional arg b is the second of two sequences to be compared. By\n default, an empty string. The elements of b must be hashable. See\n also .setSeqs() and .setSeq2().\n \n Optional arg autojunk should be set to false to disable the\n \"automatic junk heuristic\" that treats popular elements as junk\n (see module documentation for more information).\n */\n\n this.a = this.b = null\n this.setSeqs(a, b)\n }\n\n SequenceMatcher.prototype.setSeqs = function(a, b) {\n /* \n Set the two sequences to be compared. \n \n >>> s = new SequenceMatcher()\n >>> s.setSeqs('abcd', 'bcde')\n >>> s.ratio()\n 0.75\n */\n this.setSeq1(a)\n return this.setSeq2(b)\n }\n\n SequenceMatcher.prototype.setSeq1 = function(a) {\n /* \n Set the first sequence to be compared. \n \n The second sequence to be compared is not changed.\n \n >>> s = new SequenceMatcher(null, 'abcd', 'bcde')\n >>> s.ratio()\n 0.75\n >>> s.setSeq1('bcde')\n >>> s.ratio()\n 1.0\n \n SequenceMatcher computes and caches detailed information about the\n second sequence, so if you want to compare one sequence S against\n many sequences, use .setSeq2(S) once and call .setSeq1(x)\n repeatedly for each of the other sequences.\n \n See also setSeqs() and setSeq2().\n */\n if (a === this.a) {\n return\n }\n this.a = a\n return this.matchingBlocks = this.opcodes = null\n }\n\n SequenceMatcher.prototype.setSeq2 = function(b) {\n /*\n Set the second sequence to be compared. \n \n The first sequence to be compared is not changed.\n \n >>> s = new SequenceMatcher(null, 'abcd', 'bcde')\n >>> s.ratio()\n 0.75\n >>> s.setSeq2('abcd')\n >>> s.ratio()\n 1.0\n \n SequenceMatcher computes and caches detailed information about the\n second sequence, so if you want to compare one sequence S against\n many sequences, use .setSeq2(S) once and call .setSeq1(x)\n repeatedly for each of the other sequences.\n \n See also setSeqs() and setSeq1().\n */\n if (b === this.b) {\n return\n }\n this.b = b\n this.matchingBlocks = this.opcodes = null\n this.fullbcount = null\n return this._chainB()\n }\n\n SequenceMatcher.prototype._chainB = function() {\n var b, b2j, elt, i, idxs, indices, isjunk, junk, n, ntest, popular, _i, _j, _len, _len1, _ref\n b = this.b\n this.b2j = b2j = {}\n for (i = _i = 0, _len = b.length; _i < _len; i = ++_i) {\n elt = b[i]\n indices = _has(b2j, elt) ? b2j[elt] : b2j[elt] = []\n indices.push(i)\n }\n junk = {}\n isjunk = this.isjunk\n if (isjunk) {\n _ref = Object.keys(b2j)\n for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {\n elt = _ref[_j]\n if (isjunk(elt)) {\n junk[elt] = true\n delete b2j[elt]\n }\n }\n }\n popular = {}\n n = b.length\n if (this.autojunk && n >= 200) {\n ntest = floor(n / 100) + 1\n for (elt in b2j) {\n idxs = b2j[elt]\n if (idxs.length > ntest) {\n popular[elt] = true\n delete b2j[elt]\n }\n }\n }\n this.isbjunk = function(b) {\n return _has(junk, b)\n }\n return this.isbpopular = function(b) {\n return _has(popular, b)\n }\n }\n\n SequenceMatcher.prototype.findLongestMatch = function(alo, ahi, blo, bhi) {\n /* \n Find longest matching block in a[alo...ahi] and b[blo...bhi]. \n \n If isjunk is not defined:\n \n Return [i,j,k] such that a[i...i+k] is equal to b[j...j+k], where\n alo <= i <= i+k <= ahi\n blo <= j <= j+k <= bhi\n and for all [i',j',k'] meeting those conditions,\n k >= k'\n i <= i'\n and if i == i', j <= j'\n \n In other words, of all maximal matching blocks, return one that\n starts earliest in a, and of all those maximal matching blocks that\n start earliest in a, return the one that starts earliest in b.\n \n >>> isjunk = (x) -> x is ' '\n >>> s = new SequenceMatcher(isjunk, ' abcd', 'abcd abcd')\n >>> s.findLongestMatch(0, 5, 0, 9)\n [1, 0, 4]\n \n >>> s = new SequenceMatcher(null, 'ab', 'c')\n >>> s.findLongestMatch(0, 2, 0, 1)\n [0, 0, 0]\n */\n\n var a, b, b2j, besti, bestj, bestsize, i, isbjunk, j, j2len, k, newj2len, _i, _j, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5\n _ref = [this.a, this.b, this.b2j, this.isbjunk], a = _ref[0], b = _ref[1], b2j = _ref[2], isbjunk = _ref[3]\n _ref1 = [alo, blo, 0], besti = _ref1[0], bestj = _ref1[1], bestsize = _ref1[2]\n j2len = {}\n for (i = _i = alo; alo <= ahi ? _i < ahi : _i > ahi; i = alo <= ahi ? ++_i : --_i) {\n newj2len = {}\n _ref2 = (_has(b2j, a[i]) ? b2j[a[i]] : [])\n for (_j = 0, _len = _ref2.length; _j < _len; _j++) {\n j = _ref2[_j]\n if (j < blo) {\n continue\n }\n if (j >= bhi) {\n break\n }\n k = newj2len[j] = (j2len[j - 1] || 0) + 1\n if (k > bestsize) {\n _ref3 = [i - k + 1, j - k + 1, k], besti = _ref3[0], bestj = _ref3[1], bestsize = _ref3[2]\n }\n }\n j2len = newj2len\n }\n while (besti > alo && bestj > blo && !isbjunk(b[bestj - 1]) && a[besti - 1] === b[bestj - 1]) {\n _ref4 = [besti - 1, bestj - 1, bestsize + 1], besti = _ref4[0], bestj = _ref4[1], bestsize = _ref4[2]\n }\n while (besti + bestsize < ahi && bestj + bestsize < bhi && !isbjunk(b[bestj + bestsize]) && a[besti + bestsize] === b[bestj + bestsize]) {\n bestsize++\n }\n while (besti > alo && bestj > blo && isbjunk(b[bestj - 1]) && a[besti - 1] === b[bestj - 1]) {\n _ref5 = [besti - 1, bestj - 1, bestsize + 1], besti = _ref5[0], bestj = _ref5[1], bestsize = _ref5[2]\n }\n while (besti + bestsize < ahi && bestj + bestsize < bhi && isbjunk(b[bestj + bestsize]) && a[besti + bestsize] === b[bestj + bestsize]) {\n bestsize++\n }\n return [besti, bestj, bestsize]\n }\n\n SequenceMatcher.prototype.getMatchingBlocks = function() {\n /*\n Return list of triples describing matching subsequences.\n \n Each triple is of the form [i, j, n], and means that\n a[i...i+n] == b[j...j+n]. The triples are monotonically increasing in\n i and in j. it's also guaranteed that if\n [i, j, n] and [i', j', n'] are adjacent triples in the list, and\n the second is not the last triple in the list, then i+n != i' or\n j+n != j'. IOW, adjacent triples never describe adjacent equal\n blocks.\n \n The last triple is a dummy, [a.length, b.length, 0], and is the only\n triple with n==0.\n \n >>> s = new SequenceMatcher(null, 'abxcd', 'abcd')\n >>> s.getMatchingBlocks()\n [[0, 0, 2], [3, 2, 2], [5, 4, 0]]\n */\n\n var ahi, alo, bhi, blo, i, i1, i2, j, j1, j2, k, k1, k2, la, lb, matchingBlocks, nonAdjacent, queue, x, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4\n if (this.matchingBlocks) {\n return this.matchingBlocks\n }\n _ref = [this.a.length, this.b.length], la = _ref[0], lb = _ref[1]\n queue = [[0, la, 0, lb]]\n matchingBlocks = []\n while (queue.length) {\n _ref1 = queue.pop(), alo = _ref1[0], ahi = _ref1[1], blo = _ref1[2], bhi = _ref1[3]\n _ref2 = x = this.findLongestMatch(alo, ahi, blo, bhi), i = _ref2[0], j = _ref2[1], k = _ref2[2]\n if (k) {\n matchingBlocks.push(x)\n if (alo < i && blo < j) {\n queue.push([alo, i, blo, j])\n }\n if (i + k < ahi && j + k < bhi) {\n queue.push([i + k, ahi, j + k, bhi])\n }\n }\n }\n matchingBlocks.sort(_arrayCmp)\n i1 = j1 = k1 = 0\n nonAdjacent = []\n for (_i = 0, _len = matchingBlocks.length; _i < _len; _i++) {\n _ref3 = matchingBlocks[_i], i2 = _ref3[0], j2 = _ref3[1], k2 = _ref3[2]\n if (i1 + k1 === i2 && j1 + k1 === j2) {\n k1 += k2\n } else {\n if (k1) {\n nonAdjacent.push([i1, j1, k1])\n }\n _ref4 = [i2, j2, k2], i1 = _ref4[0], j1 = _ref4[1], k1 = _ref4[2]\n }\n }\n if (k1) {\n nonAdjacent.push([i1, j1, k1])\n }\n nonAdjacent.push([la, lb, 0])\n return this.matchingBlocks = nonAdjacent\n }\n\n SequenceMatcher.prototype.getOpcodes = function() {\n /* \n Return list of 5-tuples describing how to turn a into b.\n \n Each tuple is of the form [tag, i1, i2, j1, j2]. The first tuple\n has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the\n tuple preceding it, and likewise for j1 == the previous j2.\n \n The tags are strings, with these meanings:\n \n 'replace': a[i1...i2] should be replaced by b[j1...j2]\n 'delete': a[i1...i2] should be deleted.\n Note that j1==j2 in this case.\n 'insert': b[j1...j2] should be inserted at a[i1...i1].\n Note that i1==i2 in this case.\n 'equal': a[i1...i2] == b[j1...j2]\n \n >>> s = new SequenceMatcher(null, 'qabxcd', 'abycdf')\n >>> s.getOpcodes()\n [ [ 'delete' , 0 , 1 , 0 , 0 ] ,\n [ 'equal' , 1 , 3 , 0 , 2 ] ,\n [ 'replace' , 3 , 4 , 2 , 3 ] ,\n [ 'equal' , 4 , 6 , 3 , 5 ] ,\n [ 'insert' , 6 , 6 , 5 , 6 ] ]\n */\n\n var ai, answer, bj, i, j, size, tag, _i, _len, _ref, _ref1, _ref2\n if (this.opcodes) {\n return this.opcodes\n }\n i = j = 0\n this.opcodes = answer = []\n _ref = this.getMatchingBlocks()\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n _ref1 = _ref[_i], ai = _ref1[0], bj = _ref1[1], size = _ref1[2]\n tag = ''\n if (i < ai && j < bj) {\n tag = 'replace'\n } else if (i < ai) {\n tag = 'delete'\n } else if (j < bj) {\n tag = 'insert'\n }\n if (tag) {\n answer.push([tag, i, ai, j, bj])\n }\n _ref2 = [ai + size, bj + size], i = _ref2[0], j = _ref2[1]\n if (size) {\n answer.push(['equal', ai, i, bj, j])\n }\n }\n return answer\n }\n\n SequenceMatcher.prototype.getGroupedOpcodes = function(n) {\n var codes, group, groups, i1, i2, j1, j2, nn, tag, _i, _len, _ref, _ref1, _ref2, _ref3\n if (n == null) {\n n = 3\n }\n /* \n Isolate change clusters by eliminating ranges with no changes.\n \n Return a list groups with upto n lines of context.\n Each group is in the same format as returned by get_opcodes().\n \n >>> a = [1...40].map(String)\n >>> b = a.slice()\n >>> b[8...8] = 'i'\n >>> b[20] += 'x'\n >>> b[23...28] = []\n >>> b[30] += 'y'\n >>> s = new SequenceMatcher(null, a, b)\n >>> s.getGroupedOpcodes()\n [ [ [ 'equal' , 5 , 8 , 5 , 8 ],\n [ 'insert' , 8 , 8 , 8 , 9 ],\n [ 'equal' , 8 , 11 , 9 , 12 ] ],\n [ [ 'equal' , 16 , 19 , 17 , 20 ],\n [ 'replace' , 19 , 20 , 20 , 21 ],\n [ 'equal' , 20 , 22 , 21 , 23 ],\n [ 'delete' , 22 , 27 , 23 , 23 ],\n [ 'equal' , 27 , 30 , 23 , 26 ] ],\n [ [ 'equal' , 31 , 34 , 27 , 30 ],\n [ 'replace' , 34 , 35 , 30 , 31 ],\n [ 'equal' , 35 , 38 , 31 , 34 ] ] ]\n */\n\n codes = this.getOpcodes()\n if (!codes.length) {\n codes = [['equal', 0, 1, 0, 1]]\n }\n if (codes[0][0] === 'equal') {\n _ref = codes[0], tag = _ref[0], i1 = _ref[1], i2 = _ref[2], j1 = _ref[3], j2 = _ref[4]\n codes[0] = [tag, max(i1, i2 - n), i2, max(j1, j2 - n), j2]\n }\n if (codes[codes.length - 1][0] === 'equal') {\n _ref1 = codes[codes.length - 1], tag = _ref1[0], i1 = _ref1[1], i2 = _ref1[2], j1 = _ref1[3], j2 = _ref1[4]\n codes[codes.length - 1] = [tag, i1, min(i2, i1 + n), j1, min(j2, j1 + n)]\n }\n nn = n + n\n groups = []\n group = []\n for (_i = 0, _len = codes.length; _i < _len; _i++) {\n _ref2 = codes[_i], tag = _ref2[0], i1 = _ref2[1], i2 = _ref2[2], j1 = _ref2[3], j2 = _ref2[4]\n if (tag === 'equal' && i2 - i1 > nn) {\n group.push([tag, i1, min(i2, i1 + n), j1, min(j2, j1 + n)])\n groups.push(group)\n group = []\n _ref3 = [max(i1, i2 - n), max(j1, j2 - n)], i1 = _ref3[0], j1 = _ref3[1]\n }\n group.push([tag, i1, i2, j1, j2])\n }\n if (group.length && !(group.length === 1 && group[0][0] === 'equal')) {\n groups.push(group)\n }\n return groups\n }\n\n SequenceMatcher.prototype.ratio = function() {\n /*\n Return a measure of the sequences' similarity (float in [0,1]).\n \n Where T is the total number of elements in both sequences, and\n M is the number of matches, this is 2.0*M / T.\n Note that this is 1 if the sequences are identical, and 0 if\n they have nothing in common.\n \n .ratio() is expensive to compute if you haven't already computed\n .getMatchingBlocks() or .getOpcodes(), in which case you may\n want to try .quickRatio() or .realQuickRatio() first to get an\n upper bound.\n \n >>> s = new SequenceMatcher(null, 'abcd', 'bcde')\n >>> s.ratio()\n 0.75\n >>> s.quickRatio()\n 0.75\n >>> s.realQuickRatio()\n 1.0\n */\n\n var match, matches, _i, _len, _ref\n matches = 0\n _ref = this.getMatchingBlocks()\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n match = _ref[_i]\n matches += match[2]\n }\n return _calculateRatio(matches, this.a.length + this.b.length)\n }\n\n SequenceMatcher.prototype.quickRatio = function() {\n /*\n Return an upper bound on ratio() relatively quickly.\n \n This isn't defined beyond that it is an upper bound on .ratio(), and\n is faster to compute.\n */\n\n var avail, elt, fullbcount, matches, numb, _i, _j, _len, _len1, _ref, _ref1\n if (!this.fullbcount) {\n this.fullbcount = fullbcount = {}\n _ref = this.b\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elt = _ref[_i]\n fullbcount[elt] = (fullbcount[elt] || 0) + 1\n }\n }\n fullbcount = this.fullbcount\n avail = {}\n matches = 0\n _ref1 = this.a\n for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {\n elt = _ref1[_j]\n if (_has(avail, elt)) {\n numb = avail[elt]\n } else {\n numb = fullbcount[elt] || 0\n }\n avail[elt] = numb - 1\n if (numb > 0) {\n matches++\n }\n }\n return _calculateRatio(matches, this.a.length + this.b.length)\n }\n\n SequenceMatcher.prototype.realQuickRatio = function() {\n /*\n Return an upper bound on ratio() very quickly.\n \n This isn't defined beyond that it is an upper bound on .ratio(), and\n is faster to compute than either .ratio() or .quickRatio().\n */\n\n var la, lb, _ref\n _ref = [this.a.length, this.b.length], la = _ref[0], lb = _ref[1]\n return _calculateRatio(min(la, lb), la + lb)\n }\n\n return SequenceMatcher\n\n })()\n\n getCloseMatches = function(word, possibilities, n, cutoff) {\n var result, s, score, x, _i, _j, _len, _len1, _ref, _results\n if (n == null) {\n n = 3\n }\n if (cutoff == null) {\n cutoff = 0.6\n }\n /*\n Use SequenceMatcher to return list of the best \"good enough\" matches.\n \n word is a sequence for which close matches are desired (typically a\n string).\n \n possibilities is a list of sequences against which to match word\n (typically a list of strings).\n \n Optional arg n (default 3) is the maximum number of close matches to\n return. n must be > 0.\n \n Optional arg cutoff (default 0.6) is a float in [0, 1]. Possibilities\n that don't score at least that similar to word are ignored.\n \n The best (no more than n) matches among the possibilities are returned\n in a list, sorted by similarity score, most similar first.\n \n >>> getCloseMatches('appel', ['ape', 'apple', 'peach', 'puppy'])\n ['apple', 'ape']\n >>> KEYWORDS = require('coffee-script').RESERVED\n >>> getCloseMatches('wheel', KEYWORDS)\n ['when', 'while']\n >>> getCloseMatches('accost', KEYWORDS)\n ['const']\n */\n\n if (!(n > 0)) {\n throw new Error(\"n must be > 0: (\" + n + \")\")\n }\n if (!((0.0 <= cutoff && cutoff <= 1.0))) {\n throw new Error(\"cutoff must be in [0.0, 1.0]: (\" + cutoff + \")\")\n }\n result = []\n s = new SequenceMatcher()\n s.setSeq2(word)\n for (_i = 0, _len = possibilities.length; _i < _len; _i++) {\n x = possibilities[_i]\n s.setSeq1(x)\n if (s.realQuickRatio() >= cutoff && s.quickRatio() >= cutoff && s.ratio() >= cutoff) {\n result.push([s.ratio(), x])\n }\n }\n result = Heap.nlargest(result, n, _arrayCmp)\n _results = []\n for (_j = 0, _len1 = result.length; _j < _len1; _j++) {\n _ref = result[_j], score = _ref[0], x = _ref[1]\n _results.push(x)\n }\n return _results\n }\n\n _countLeading = function(line, ch) {\n /*\n Return number of `ch` characters at the start of `line`.\n \n >>> _countLeading(' abc', ' ')\n 3\n */\n\n var i, n, _ref\n _ref = [0, line.length], i = _ref[0], n = _ref[1]\n while (i < n && line[i] === ch) {\n i++\n }\n return i\n }\n\n Differ = (function() {\n\n /*\n Differ is a class for comparing sequences of lines of text, and\n producing human-readable differences or deltas. Differ uses\n SequenceMatcher both to compare sequences of lines, and to compare\n sequences of characters within similar (near-matching) lines.\n \n Each line of a Differ delta begins with a two-letter code:\n \n '- ' line unique to sequence 1\n '+ ' line unique to sequence 2\n ' ' line common to both sequences\n '? ' line not present in either input sequence\n \n Lines beginning with '? ' attempt to guide the eye to intraline\n differences, and were not present in either input sequence. These lines\n can be confusing if the sequences contain tab characters.\n \n Note that Differ makes no claim to produce a *minimal* diff. To the\n contrary, minimal diffs are often counter-intuitive, because they synch\n up anywhere possible, sometimes accidental