Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2018-05-24 23:31:26 +0300
committerRebecca Turner <me@re-becca.org>2018-05-24 23:31:38 +0300
commit0483f5c5deaf18c968a128657923103e49f4e67a (patch)
tree210f154da2f60938471d96a844dcb32cbda09e2a /node_modules/natural-compare
parent6c294614d800cb95a49ef1c422fbdde65b0731a2 (diff)
Flatten dependencies and add dev deps to git
Diffstat (limited to 'node_modules/natural-compare')
-rw-r--r--node_modules/natural-compare/README.md125
-rw-r--r--node_modules/natural-compare/index.js57
-rw-r--r--node_modules/natural-compare/package.json73
3 files changed, 255 insertions, 0 deletions
diff --git a/node_modules/natural-compare/README.md b/node_modules/natural-compare/README.md
new file mode 100644
index 000000000..c85dfdf98
--- /dev/null
+++ b/node_modules/natural-compare/README.md
@@ -0,0 +1,125 @@
+
+[Build]: http://img.shields.io/travis/litejs/natural-compare-lite.png
+[Coverage]: http://img.shields.io/coveralls/litejs/natural-compare-lite.png
+[1]: https://travis-ci.org/litejs/natural-compare-lite
+[2]: https://coveralls.io/r/litejs/natural-compare-lite
+[npm package]: https://npmjs.org/package/natural-compare-lite
+[GitHub repo]: https://github.com/litejs/natural-compare-lite
+
+
+
+ @version 1.4.0
+ @date 2015-10-26
+ @stability 3 - Stable
+
+
+Natural Compare &ndash; [![Build][]][1] [![Coverage][]][2]
+===============
+
+Compare strings containing a mix of letters and numbers
+in the way a human being would in sort order.
+This is described as a "natural ordering".
+
+```text
+Standard sorting: Natural order sorting:
+ img1.png img1.png
+ img10.png img2.png
+ img12.png img10.png
+ img2.png img12.png
+```
+
+String.naturalCompare returns a number indicating
+whether a reference string comes before or after or is the same
+as the given string in sort order.
+Use it with builtin sort() function.
+
+
+
+### Installation
+
+- In browser
+
+```html
+<script src=min.natural-compare.js></script>
+```
+
+- In node.js: `npm install natural-compare-lite`
+
+```javascript
+require("natural-compare-lite")
+```
+
+### Usage
+
+```javascript
+// Simple case sensitive example
+var a = ["z1.doc", "z10.doc", "z17.doc", "z2.doc", "z23.doc", "z3.doc"];
+a.sort(String.naturalCompare);
+// ["z1.doc", "z2.doc", "z3.doc", "z10.doc", "z17.doc", "z23.doc"]
+
+// Use wrapper function for case insensitivity
+a.sort(function(a, b){
+ return String.naturalCompare(a.toLowerCase(), b.toLowerCase());
+})
+
+// In most cases we want to sort an array of objects
+var a = [ {"street":"350 5th Ave", "room":"A-1021"}
+ , {"street":"350 5th Ave", "room":"A-21046-b"} ];
+
+// sort by street, then by room
+a.sort(function(a, b){
+ return String.naturalCompare(a.street, b.street) || String.naturalCompare(a.room, b.room);
+})
+
+// When text transformation is needed (eg toLowerCase()),
+// it is best for performance to keep
+// transformed key in that object.
+// There are no need to do text transformation
+// on each comparision when sorting.
+var a = [ {"make":"Audi", "model":"A6"}
+ , {"make":"Kia", "model":"Rio"} ];
+
+// sort by make, then by model
+a.map(function(car){
+ car.sort_key = (car.make + " " + car.model).toLowerCase();
+})
+a.sort(function(a, b){
+ return String.naturalCompare(a.sort_key, b.sort_key);
+})
+```
+
+- Works well with dates in ISO format eg "Rev 2012-07-26.doc".
+
+
+### Custom alphabet
+
+It is possible to configure a custom alphabet
+to achieve a desired order.
+
+```javascript
+// Estonian alphabet
+String.alphabet = "ABDEFGHIJKLMNOPRSŠZŽTUVÕÄÖÜXYabdefghijklmnoprsšzžtuvõäöüxy"
+["t", "z", "x", "õ"].sort(String.naturalCompare)
+// ["z", "t", "õ", "x"]
+
+// Russian alphabet
+String.alphabet = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя"
+["Ё", "А", "Б"].sort(String.naturalCompare)
+// ["А", "Б", "Ё"]
+```
+
+
+External links
+--------------
+
+- [GitHub repo][https://github.com/litejs/natural-compare-lite]
+- [jsperf test](http://jsperf.com/natural-sort-2/12)
+
+
+Licence
+-------
+
+Copyright (c) 2012-2015 Lauri Rooden &lt;lauri@rooden.ee&gt;
+[The MIT License](http://lauri.rooden.ee/mit-license.txt)
+
+
diff --git a/node_modules/natural-compare/index.js b/node_modules/natural-compare/index.js
new file mode 100644
index 000000000..e705d49f5
--- /dev/null
+++ b/node_modules/natural-compare/index.js
@@ -0,0 +1,57 @@
+
+
+
+/*
+ * @version 1.4.0
+ * @date 2015-10-26
+ * @stability 3 - Stable
+ * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
+ * @license MIT License
+ */
+
+
+var naturalCompare = function(a, b) {
+ var i, codeA
+ , codeB = 1
+ , posA = 0
+ , posB = 0
+ , alphabet = String.alphabet
+
+ function getCode(str, pos, code) {
+ if (code) {
+ for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
+ return +str.slice(pos - 1, i)
+ }
+ code = alphabet && alphabet.indexOf(str.charAt(pos))
+ return code > -1 ? code + 76 : ((code = str.charCodeAt(pos) || 0), code < 45 || code > 127) ? code
+ : code < 46 ? 65 // -
+ : code < 48 ? code - 1
+ : code < 58 ? code + 18 // 0-9
+ : code < 65 ? code - 11
+ : code < 91 ? code + 11 // A-Z
+ : code < 97 ? code - 37
+ : code < 123 ? code + 5 // a-z
+ : code - 63
+ }
+
+
+ if ((a+="") != (b+="")) for (;codeB;) {
+ codeA = getCode(a, posA++)
+ codeB = getCode(b, posB++)
+
+ if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
+ codeA = getCode(a, posA, posA)
+ codeB = getCode(b, posB, posA = i)
+ posB = i
+ }
+
+ if (codeA != codeB) return (codeA < codeB) ? -1 : 1
+ }
+ return 0
+}
+
+try {
+ module.exports = naturalCompare;
+} catch (e) {
+ String.naturalCompare = naturalCompare;
+}
diff --git a/node_modules/natural-compare/package.json b/node_modules/natural-compare/package.json
new file mode 100644
index 000000000..3ede6082a
--- /dev/null
+++ b/node_modules/natural-compare/package.json
@@ -0,0 +1,73 @@
+{
+ "_from": "natural-compare@^1.4.0",
+ "_id": "natural-compare@1.4.0",
+ "_inBundle": false,
+ "_integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
+ "_location": "/natural-compare",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "natural-compare@^1.4.0",
+ "name": "natural-compare",
+ "escapedName": "natural-compare",
+ "rawSpec": "^1.4.0",
+ "saveSpec": null,
+ "fetchSpec": "^1.4.0"
+ },
+ "_requiredBy": [
+ "/eslint"
+ ],
+ "_resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
+ "_shasum": "4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7",
+ "_spec": "natural-compare@^1.4.0",
+ "_where": "/Users/rebecca/code/npm/node_modules/eslint",
+ "author": {
+ "name": "Lauri Rooden",
+ "url": "https://github.com/litejs/natural-compare-lite"
+ },
+ "bugs": {
+ "url": "https://github.com/litejs/natural-compare-lite/issues"
+ },
+ "buildman": {
+ "dist/index-min.js": {
+ "banner": "/*! litejs.com/MIT-LICENSE.txt */",
+ "input": "index.js"
+ }
+ },
+ "bundleDependencies": false,
+ "deprecated": false,
+ "description": "Compare strings containing a mix of letters and numbers in the way a human being would in sort order.",
+ "devDependencies": {
+ "buildman": "*",
+ "testman": "*"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/litejs/natural-compare-lite#readme",
+ "keywords": [
+ "string",
+ "natural",
+ "order",
+ "sort",
+ "natsort",
+ "natcmp",
+ "compare",
+ "alphanum",
+ "litejs"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "natural-compare",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/litejs/natural-compare-lite.git"
+ },
+ "scripts": {
+ "build": "node node_modules/buildman/index.js --all",
+ "test": "node tests/index.js"
+ },
+ "stability": 3,
+ "version": "1.4.0"
+}