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.10.2 to 1.11.2

2

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

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

@@ -56,2 +56,3 @@ ![table-sort-js](https://img.shields.io/npm/v/table-sort-js)

| "file-size-sort" | Sort file sizes(B->TiB) uses the binary prefix. (e.g KiB) |
| "runtime-sort" | Sorts runtime in minutes and seconds e.g (1m 20s). Useful for sorting the GitHub actions Run time column... |
| "disable-sort" | Disallow sorting the table by this specific column. |

@@ -58,0 +59,0 @@ | "alpha-sort" | Sort alphabetically (z11,z2); default is [natural sort](https://en.wikipedia.org/wiki/Natural_sort_order) (z2,z11). |

@@ -125,2 +125,28 @@ /*

function sortByRuntime(tableRows, columnData) {
for (let [i, tr] of tableRows.entries()) {
const regexMinutesAndSeconds = /^(\d+m)\s?(\d+s)$/i;
let columnOfTd = tr
.querySelectorAll("td")
.item(columnIndex).textContent;
let match = columnOfTd.match(regexMinutesAndSeconds);
let minutesInSeconds,
seconds,
timeinSeconds = [0, 0, 0];
if (match) {
const regexMinutes = match[1];
if (regexMinutes) {
minutesInSeconds = Number(regexMinutes.replace("m", "")) * 60;
}
const regexSeconds = match[2];
if (regexSeconds) {
seconds = Number(regexSeconds.replace("s", ""));
}
timeinSeconds = minutesInSeconds + seconds;
}
columnData.push(`${timeinSeconds}#${i}`);
columnIndexAndTableRow[columnData[i]] = tr.innerHTML;
}
}
let [timesClickedColumn, columnIndexesClicked] = [0, []];

@@ -156,2 +182,3 @@

isFileSize,
isTimeSort,
isDataAttribute,

@@ -176,3 +203,3 @@ colSpanData,

}
if (!isFileSize && !isDataAttribute) {
if (!isFileSize && !isDataAttribute && !isTimeSort) {
columnData.push(`${tdTextContent}#${i}`);

@@ -313,2 +340,7 @@ columnIndexAndTableRow[`${tdTextContent}#${i}`] = tr.innerHTML;

const isTimeSort = th.classList.contains("runtime-sort");
if (isTimeSort) {
sortByRuntime(visibleTableRows, columnData);
}
const isRememberSort = sortableTable.classList.contains("remember-sort");

@@ -327,2 +359,3 @@ if (!isRememberSort) {

isDataAttribute,
isTimeSort,
colSpanData,

@@ -329,0 +362,0 @@ colSpanSum,

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