mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-21 13:34:46 +00:00
.
This commit is contained in:
parent
beb1329f9f
commit
2b95e76931
7736 changed files with 1874747 additions and 51184 deletions
125
node_modules/natural-compare/README.md
generated
vendored
Normal file
125
node_modules/natural-compare/README.md
generated
vendored
Normal file
|
@ -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 – [![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 <lauri@rooden.ee>
|
||||
[The MIT License](http://lauri.rooden.ee/mit-license.txt)
|
||||
|
||||
|
57
node_modules/natural-compare/index.js
generated
vendored
Normal file
57
node_modules/natural-compare/index.js
generated
vendored
Normal file
|
@ -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;
|
||||
}
|
77
node_modules/natural-compare/package.json
generated
vendored
Normal file
77
node_modules/natural-compare/package.json
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"natural-compare@1.4.0",
|
||||
"/Users/eric/repos/actions/setup-node"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "natural-compare@1.4.0",
|
||||
"_id": "natural-compare@1.4.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=",
|
||||
"_location": "/natural-compare",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"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": [
|
||||
"/jest-snapshot"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
|
||||
"_spec": "1.4.0",
|
||||
"_where": "/Users/eric/repos/actions/setup-node",
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue