| 1 |
{ |
| 2 |
"_id": "natural-compare", |
| 3 |
"_rev": "3-b11e57e7c88bced3beef647f94d36141", |
| 4 |
"name": "natural-compare", |
| 5 |
"description": "Compare strings containing a mix of letters and numbers in the way a human being would in sort order.", |
| 6 |
"dist-tags": { |
| 7 |
"latest": "1.4.0" |
| 8 |
}, |
| 9 |
"versions": { |
| 10 |
"1.2.2": { |
| 11 |
"name": "natural-compare", |
| 12 |
"version": "1.2.2", |
| 13 |
"license": "MIT", |
| 14 |
"author": { |
| 15 |
"name": "Graeme Yeates", |
| 16 |
"url": "https://github.com/megawac/natural-compare" |
| 17 |
}, |
| 18 |
"description": "Compare strings containing a mix of letters and numbers in the way a human being would in sort order.", |
| 19 |
"keywords": [ |
| 20 |
"string", |
| 21 |
"natural", |
| 22 |
"order", |
| 23 |
"sort", |
| 24 |
"natsort", |
| 25 |
"natcmp", |
| 26 |
"compare", |
| 27 |
"alphanum" |
| 28 |
], |
| 29 |
"main": "index.js", |
| 30 |
"scripts": { |
| 31 |
"travis-test": "istanbul cover ./tests/run.js && (coveralls < coverage/lcov.info || exit 0)", |
| 32 |
"test": "node tests/run.js" |
| 33 |
}, |
| 34 |
"repository": { |
| 35 |
"type": "git", |
| 36 |
"url": "git://github.com/litejs/natural-compare.git" |
| 37 |
}, |
| 38 |
"bugs": { |
| 39 |
"url": "https://github.com/litejs/natural-compare/issues" |
| 40 |
}, |
| 41 |
"devDependencies": { |
| 42 |
"testman": "*" |
| 43 |
}, |
| 44 |
"gitHead": "1e0e6650d31f87577a2452f59b379cd1eb226b22", |
| 45 |
"homepage": "https://github.com/litejs/natural-compare", |
| 46 |
"_id": "[email protected]", |
| 47 |
"_shasum": "1f96d60e3141cac1b6d05653ce0daeac763af6aa", |
| 48 |
"_from": ".", |
| 49 |
"_npmVersion": "2.1.8", |
| 50 |
"_nodeVersion": "0.10.33", |
| 51 |
"_npmUser": { |
| 52 |
"name": "megawac", |
| 53 |
"email": "[email protected]" |
| 54 |
}, |
| 55 |
"maintainers": [ |
| 56 |
{ |
| 57 |
"name": "megawac", |
| 58 |
"email": "[email protected]" |
| 59 |
} |
| 60 |
], |
| 61 |
"dist": { |
| 62 |
"shasum": "1f96d60e3141cac1b6d05653ce0daeac763af6aa", |
| 63 |
"tarball": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.2.2.tgz" |
| 64 |
}, |
| 65 |
"directories": {} |
| 66 |
}, |
| 67 |
"1.4.0": { |
| 68 |
"name": "natural-compare", |
| 69 |
"version": "1.4.0", |
| 70 |
"stability": 3, |
| 71 |
"author": { |
| 72 |
"name": "Lauri Rooden", |
| 73 |
"url": "https://github.com/litejs/natural-compare-lite" |
| 74 |
}, |
| 75 |
"license": "MIT", |
| 76 |
"description": "Compare strings containing a mix of letters and numbers in the way a human being would in sort order.", |
| 77 |
"keywords": [ |
| 78 |
"string", |
| 79 |
"natural", |
| 80 |
"order", |
| 81 |
"sort", |
| 82 |
"natsort", |
| 83 |
"natcmp", |
| 84 |
"compare", |
| 85 |
"alphanum", |
| 86 |
"litejs" |
| 87 |
], |
| 88 |
"main": "index.js", |
| 89 |
"files": [ |
| 90 |
"index.js" |
| 91 |
], |
| 92 |
"scripts": { |
| 93 |
"build": "node node_modules/buildman/index.js --all", |
| 94 |
"test": "node tests/index.js" |
| 95 |
}, |
| 96 |
"repository": { |
| 97 |
"type": "git", |
| 98 |
"url": "git://github.com/litejs/natural-compare-lite.git" |
| 99 |
}, |
| 100 |
"bugs": { |
| 101 |
"url": "https://github.com/litejs/natural-compare-lite/issues" |
| 102 |
}, |
| 103 |
"devDependencies": { |
| 104 |
"buildman": "*", |
| 105 |
"testman": "*" |
| 106 |
}, |
| 107 |
"buildman": { |
| 108 |
"dist/index-min.js": { |
| 109 |
"banner": "/*! litejs.com/MIT-LICENSE.txt */", |
| 110 |
"input": "index.js" |
| 111 |
} |
| 112 |
}, |
| 113 |
"gitHead": "eec83eee67cfac84d6db30cdd65363f155673770", |
| 114 |
"homepage": "https://github.com/litejs/natural-compare-lite#readme", |
| 115 |
"_id": "[email protected]", |
| 116 |
"_shasum": "4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7", |
| 117 |
"_from": ".", |
| 118 |
"_npmVersion": "3.9.5", |
| 119 |
"_nodeVersion": "6.2.2", |
| 120 |
"_npmUser": { |
| 121 |
"name": "megawac", |
| 122 |
"email": "[email protected]" |
| 123 |
}, |
| 124 |
"dist": { |
| 125 |
"shasum": "4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7", |
| 126 |
"tarball": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz" |
| 127 |
}, |
| 128 |
"maintainers": [ |
| 129 |
{ |
| 130 |
"name": "megawac", |
| 131 |
"email": "[email protected]" |
| 132 |
} |
| 133 |
], |
| 134 |
"_npmOperationalInternal": { |
| 135 |
"host": "packages-12-west.internal.npmjs.com", |
| 136 |
"tmp": "tmp/natural-compare-1.4.0.tgz_1469220490086_0.1379237591754645" |
| 137 |
}, |
| 138 |
"directories": {} |
| 139 |
} |
| 140 |
}, |
| 141 |
"readme": "\n[Build]: http://img.shields.io/travis/litejs/natural-compare-lite.png\n[Coverage]: http://img.shields.io/coveralls/litejs/natural-compare-lite.png\n[1]: https://travis-ci.org/litejs/natural-compare-lite\n[2]: https://coveralls.io/r/litejs/natural-compare-lite\n[npm package]: https://npmjs.org/package/natural-compare-lite\n[GitHub repo]: https://github.com/litejs/natural-compare-lite\n\n\n\n @version 1.4.0\n @date 2015-10-26\n @stability 3 - Stable\n\n\nNatural Compare – [![Build][]][1] [![Coverage][]][2]\n===============\n\nCompare strings containing a mix of letters and numbers\nin the way a human being would in sort order.\nThis is described as a \"natural ordering\".\n\n```text\nStandard sorting: Natural order sorting:\n img1.png img1.png\n img10.png img2.png\n img12.png img10.png\n img2.png img12.png\n```\n\nString.naturalCompare returns a number indicating\nwhether a reference string comes before or after or is the same\nas the given string in sort order.\nUse it with builtin sort() function.\n\n\n\n### Installation\n\n- In browser\n\n```html\n<script src=min.natural-compare.js></script>\n```\n\n- In node.js: `npm install natural-compare-lite`\n\n```javascript\nrequire(\"natural-compare-lite\")\n```\n\n### Usage\n\n```javascript\n// Simple case sensitive example\nvar a = [\"z1.doc\", \"z10.doc\", \"z17.doc\", \"z2.doc\", \"z23.doc\", \"z3.doc\"];\na.sort(String.naturalCompare);\n// [\"z1.doc\", \"z2.doc\", \"z3.doc\", \"z10.doc\", \"z17.doc\", \"z23.doc\"]\n\n// Use wrapper function for case insensitivity\na.sort(function(a, b){\n return String.naturalCompare(a.toLowerCase(), b.toLowerCase());\n})\n\n// In most cases we want to sort an array of objects\nvar a = [ {\"street\":\"350 5th Ave\", \"room\":\"A-1021\"}\n , {\"street\":\"350 5th Ave\", \"room\":\"A-21046-b\"} ];\n\n// sort by street, then by room\na.sort(function(a, b){\n return String.naturalCompare(a.street, b.street) || String.naturalCompare(a.room, b.room);\n})\n\n// When text transformation is needed (eg toLowerCase()),\n// it is best for performance to keep\n// transformed key in that object.\n// There are no need to do text transformation\n// on each comparision when sorting.\nvar a = [ {\"make\":\"Audi\", \"model\":\"A6\"}\n , {\"make\":\"Kia\", \"model\":\"Rio\"} ];\n\n// sort by make, then by model\na.map(function(car){\n car.sort_key = (car.make + \" \" + car.model).toLowerCase();\n})\na.sort(function(a, b){\n return String.naturalCompare(a.sort_key, b.sort_key);\n})\n```\n\n- Works well with dates in ISO format eg \"Rev 2012-07-26.doc\".\n\n\n### Custom alphabet\n\nIt is possible to configure a custom alphabet\nto achieve a desired order.\n\n```javascript\n// Estonian alphabet\nString.alphabet = \"ABDEFGHIJKLMNOPRSŠZŽTUVÕÄÖÜXYabdefghijklmnoprsšzžtuvõäöüxy\"\n[\"t\", \"z\", \"x\", \"õ\"].sort(String.naturalCompare)\n// [\"z\", \"t\", \"õ\", \"x\"]\n\n// Russian alphabet\nString.alphabet = \"АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя\"\n[\"Ё\", \"А\", \"Б\"].sort(String.naturalCompare)\n// [\"А\", \"Б\", \"Ё\"]\n```\n\n\nExternal links\n--------------\n\n- [GitHub repo][https://github.com/litejs/natural-compare-lite]\n- [jsperf test](http://jsperf.com/natural-sort-2/12)\n\n\nLicence\n-------\n\nCopyright (c) 2012-2015 Lauri Rooden <[email protected]> \n[The MIT License](http://lauri.rooden.ee/mit-license.txt)\n\n\n", |
| 142 |
"maintainers": [ |
| 143 |
{ |
| 144 |
"name": "megawac", |
| 145 |
"email": "[email protected]" |
| 146 |
} |
| 147 |
], |
| 148 |
"time": { |
| 149 |
"modified": "2016-07-22T20:48:12.217Z", |
| 150 |
"created": "2014-11-18T01:04:27.323Z", |
| 151 |
"1.2.2": "2014-11-18T01:04:27.323Z", |
| 152 |
"1.4.0": "2016-07-22T20:48:12.217Z" |
| 153 |
}, |
| 154 |
"homepage": "https://github.com/litejs/natural-compare-lite#readme", |
| 155 |
"keywords": [ |
| 156 |
"string", |
| 157 |
"natural", |
| 158 |
"order", |
| 159 |
"sort", |
| 160 |
"natsort", |
| 161 |
"natcmp", |
| 162 |
"compare", |
| 163 |
"alphanum", |
| 164 |
"litejs" |
| 165 |
], |
| 166 |
"repository": { |
| 167 |
"type": "git", |
| 168 |
"url": "git://github.com/litejs/natural-compare-lite.git" |
| 169 |
}, |
| 170 |
"author": { |
| 171 |
"name": "Lauri Rooden", |
| 172 |
"url": "https://github.com/litejs/natural-compare-lite" |
| 173 |
}, |
| 174 |
"bugs": { |
| 175 |
"url": "https://github.com/litejs/natural-compare-lite/issues" |
| 176 |
}, |
| 177 |
"license": "MIT", |
| 178 |
"readmeFilename": "README.md", |
| 179 |
"_attachments": {} |
| 180 |
} |