diff options
author | isaacs <i@izs.me> | 2013-01-18 00:26:18 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-01-18 00:26:18 +0400 |
commit | cd420c55c20860393d713dd919b893407caeb3fd (patch) | |
tree | 029ffb993b4473dbd788c602d379f5d7b0c69198 /node_modules/abbrev | |
parent | c716ed61d9feb5d65d7db46a2709b9f0bd2d9354 (diff) |
abbrev@1.0.4
Diffstat (limited to 'node_modules/abbrev')
-rw-r--r-- | node_modules/abbrev/lib/abbrev.js | 25 | ||||
-rw-r--r-- | node_modules/abbrev/package.json | 34 |
2 files changed, 39 insertions, 20 deletions
diff --git a/node_modules/abbrev/lib/abbrev.js b/node_modules/abbrev/lib/abbrev.js index 037de2d8d..bee4132c9 100644 --- a/node_modules/abbrev/lib/abbrev.js +++ b/node_modules/abbrev/lib/abbrev.js @@ -4,8 +4,15 @@ module.exports = exports = abbrev.abbrev = abbrev abbrev.monkeyPatch = monkeyPatch function monkeyPatch () { - Array.prototype.abbrev = function () { return abbrev(this) } - Object.prototype.abbrev = function () { return abbrev(Object.keys(this)) } + Object.defineProperty(Array.prototype, 'abbrev', { + value: function () { return abbrev(this) }, + enumerable: false, configurable: true, writable: true + }) + + Object.defineProperty(Object.prototype, 'abbrev', { + value: function () { return abbrev(Object.keys(this)) }, + enumerable: false, configurable: true, writable: true + }) } function abbrev (list) { @@ -32,8 +39,7 @@ function abbrev (list) { var curChar = current.charAt(j) nextMatches = nextMatches && curChar === next.charAt(j) prevMatches = prevMatches && curChar === prev.charAt(j) - if (nextMatches || prevMatches) continue - else { + if (!nextMatches && !prevMatches) { j ++ break } @@ -60,19 +66,18 @@ function lexSort (a, b) { if (module === require.main) { var assert = require("assert") - , sys -sys = require("util") +var util = require("util") console.log("running tests") function test (list, expect) { var actual = abbrev(list) assert.deepEqual(actual, expect, - "abbrev("+sys.inspect(list)+") === " + sys.inspect(expect) + "\n"+ - "actual: "+sys.inspect(actual)) + "abbrev("+util.inspect(list)+") === " + util.inspect(expect) + "\n"+ + "actual: "+util.inspect(actual)) actual = abbrev.apply(exports, list) assert.deepEqual(abbrev.apply(exports, list), expect, - "abbrev("+list.map(JSON.stringify).join(",")+") === " + sys.inspect(expect) + "\n"+ - "actual: "+sys.inspect(actual)) + "abbrev("+list.map(JSON.stringify).join(",")+") === " + util.inspect(expect) + "\n"+ + "actual: "+util.inspect(actual)) } test([ "ruby", "ruby", "rules", "rules", "rules" ], diff --git a/node_modules/abbrev/package.json b/node_modules/abbrev/package.json index 045cbd4b2..bea853e6e 100644 --- a/node_modules/abbrev/package.json +++ b/node_modules/abbrev/package.json @@ -1,11 +1,25 @@ -{ "name" : "abbrev" -, "version" : "1.0.3" -, "description" : "Like ruby's abbrev module, but in js" -, "author" : "Isaac Z. Schlueter <i@izs.me>" -, "main" : "./lib/abbrev.js" -, "scripts" : { "test" : "node lib/abbrev.js" } -, "repository" : "http://github.com/isaacs/abbrev-js" -, "license" : - { "type" : "MIT" - , "url" : "https://github.com/isaacs/abbrev-js/raw/master/LICENSE" } +{ + "name": "abbrev", + "version": "1.0.4", + "description": "Like ruby's abbrev module, but in js", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me" + }, + "main": "./lib/abbrev.js", + "scripts": { + "test": "node lib/abbrev.js" + }, + "repository": { + "type": "git", + "url": "http://github.com/isaacs/abbrev-js" + }, + "license": { + "type": "MIT", + "url": "https://github.com/isaacs/abbrev-js/raw/master/LICENSE" + }, + "readme": "# abbrev-js\n\nJust like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).\n\nUsage:\n\n var abbrev = require(\"abbrev\");\n abbrev(\"foo\", \"fool\", \"folding\", \"flop\");\n \n // returns:\n { fl: 'flop'\n , flo: 'flop'\n , flop: 'flop'\n , fol: 'folding'\n , fold: 'folding'\n , foldi: 'folding'\n , foldin: 'folding'\n , folding: 'folding'\n , foo: 'foo'\n , fool: 'fool'\n }\n\nThis is handy for command-line scripts, or other cases where you want to be able to accept shorthands.\n", + "readmeFilename": "README.md", + "_id": "abbrev@1.0.4", + "_from": "abbrev@latest" } |