Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

table-sort-js

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

table-sort-js - npm Package Compare versions

Comparing version 1.8.2 to 1.9.0

2

package.json
{
"name": "table-sort-js",
"version": "1.8.2",
"version": "1.9.0",
"description": "A JavaScript client-side HTML table sorting library with no dependencies required.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -53,5 +53,7 @@ ![table-sort-js](https://img.shields.io/npm/v/table-sort-js)

| "order-by-desc" | Order by descending on first click. (default is aescending) |
| "file-size" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) |
| "data-sort" | Sort by [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes), e.g <td data-sort="42"> |
| "disable-sort" | Disallow sorting the table by this specific column
| "file-size-sort" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) |
| "alpha-sort" | Sort alphabetically (z11,z2); default is [natural sort](https://en.wikipedia.org/wiki/Natural_sort_order) (z2,z11). |
| "punct-sort" | Sort punctuation; default ignores punctuation. |
| "disable-sort" | Disallow sorting the table by this specific column. |

@@ -58,0 +60,0 @@ #### Development:

@@ -210,3 +210,5 @@ /*

function naturalSortAscending(a, b) {
const isPunctSort = th.classList.contains("punct-sort");
const isAlphaSort = th.classList.contains("alpha-sort");
function sortAscending(a, b) {
if (a.includes(`${fillValue}#`)) {

@@ -220,3 +222,3 @@ return 1;

navigator.languages[0] || navigator.language,
{ numeric: true, ignorePunctuation: true }
{ numeric: !isAlphaSort, ignorePunctuation: !isPunctSort }
);

@@ -226,4 +228,4 @@ }

function naturalSortDescending(a, b) {
return naturalSortAscending(b, a);
function sortDescending(a, b) {
return sortAscending(b, a);
}

@@ -249,4 +251,4 @@

columnData.sort(sortDirection, {
numeric: true,
ignorePunctuation: true,
numeric: !isAlphaSort,
ignorePunctuation: !isPunctSort,
});

@@ -258,6 +260,6 @@ }

changeTableArrow(arrowDown);
sortColumn(naturalSortDescending);
sortColumn(sortDescending);
} else {
changeTableArrow(arrowUp);
sortColumn(naturalSortAscending);
sortColumn(sortAscending);
}

@@ -268,6 +270,6 @@ } else if (timesClickedColumn === 2) {

changeTableArrow(arrowUp);
sortColumn(naturalSortAscending);
sortColumn(sortAscending);
} else {
changeTableArrow(arrowDown);
sortColumn(naturalSortDescending);
sortColumn(sortDescending);
}

@@ -364,3 +366,3 @@ }

const isFileSize = th.classList.contains("file-size");
const isFileSize = th.classList.contains("file-size-sort");
if (isFileSize) {

@@ -367,0 +369,0 @@ sortFileSize(visibleTableRows, columnData);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc