sort-array
Advanced tools
Comparing version
@@ -22,2 +22,3 @@ import arrayify from 'array-back' | ||
* @param {number} [options.undefinedRank] - Configures whether `undefined` values will be sorted before or after defined values. Set to `-1` for before, `1` for after. Defaults to `1`. | ||
* @param {number} [options.nanRank] - Configures whether `NaN` values will be sorted before or after defined values. Set to `-1` for before, `1` for after. Defaults to `1`. | ||
* @returns {Array} Returns the array that was passed in. | ||
@@ -83,2 +84,4 @@ * @alias module:sort-array | ||
result = options.undefinedRank | ||
} else if (Number.isNaN(x) && t.isDefinedValue(y)) { | ||
result = options.nanRank | ||
} else if (t.isNull(y) && t.isDefinedValue(x)) { | ||
@@ -88,2 +91,4 @@ result = -options.nullRank | ||
result = -options.undefinedRank | ||
} else if (Number.isNaN(y) && t.isDefinedValue(x)) { | ||
result = -options.nanRank | ||
} else { | ||
@@ -90,0 +95,0 @@ result = x < y ? -1 : x > y ? 1 : 0 |
{ | ||
"name": "sort-array", | ||
"author": "Lloyd Brookes <75pound@gmail.com>", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Isomorphic, load-anywhere function to sort an array by scalar, deep or computed values in any standard or custom order", | ||
"repository": "https://github.com/75lb/sort-array", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/75lb/sort-array.git" | ||
}, | ||
"license": "MIT", | ||
@@ -29,4 +32,4 @@ "type": "module", | ||
"test:ci": "75lb-nature test-runner test/defaults.js test/sort-computed-property.js test/sort-custom-order.js test/sort-falsy.js test/sort-primitives.js test/sort-small.js test/sort.js test/validation.js", | ||
"docs": "75lb-nature jsdoc2md -c jsdoc.conf -t README.hbs index.js -d 3 > README.md", | ||
"dist": "75lb-nature cjs-build index.js" | ||
"docs": "75lb-nature jsdoc2md -t README.hbs index.js -d 3 > README.md", | ||
"dist": "75lb-nature cjs-build index.js && 75lb-nature simple-rollup index.js" | ||
}, | ||
@@ -33,0 +36,0 @@ "dependencies": { |
@@ -196,2 +196,3 @@ [](https://www.npmjs.org/package/sort-array) | ||
| [options.undefinedRank] | <code>number</code> | Configures whether `undefined` values will be sorted before or after defined values. Set to `-1` for before, `1` for after. Defaults to `1`. | | ||
| [options.nanRank] | <code>number</code> | Configures whether `NaN` values will be sorted before or after defined values. Set to `-1` for before, `1` for after. Defaults to `1`. | | ||
@@ -203,3 +204,3 @@ | ||
Node.js: | ||
Node.js CommonJS: | ||
@@ -210,3 +211,3 @@ ```js | ||
Within Node.js with ECMAScript Module support enabled: | ||
Node.js ECMAScript: | ||
@@ -223,12 +224,6 @@ ```js | ||
Old browser (adds `window.sortArray`): | ||
```html | ||
<script nomodule src="./node_modules/sort-array/dist/index.js"></script> | ||
``` | ||
* * * | ||
© 2015-24 Lloyd Brookes \<75pound@gmail.com\>. | ||
© 2015-25 Lloyd Brookes \<75pound@gmail.com\>. | ||
Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
36524
15.2%7
16.67%628
20.77%0
-100%226
-2.16%