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

@hypothesis/frontend-shared

Package Overview
Dependencies
Maintainers
4
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hypothesis/frontend-shared - npm Package Compare versions

Comparing version 7.7.0 to 7.7.1

2

lib/hooks/use-ordered-rows.d.ts

@@ -5,3 +5,5 @@ import type { Order } from '../types';

* Provided rows are not mutated, but a copy is returned instead.
* Strings are compared using `Intl.Collator`, other types are compared using
* standard JavaScript comparisons.
*/
export declare function useOrderedRows<Row>(rows: Row[], order?: Order<keyof Row>): Row[];

23

lib/hooks/use-ordered-rows.js
import { useMemo } from 'preact/hooks';
const collator = new Intl.Collator(undefined, {
sensitivity: 'case'
});
/**
* Orders a list of rows based on provided order options.
* Provided rows are not mutated, but a copy is returned instead.
* Strings are compared using `Intl.Collator`, other types are compared using
* standard JavaScript comparisons.
*/

@@ -11,10 +17,15 @@ export function useOrderedRows(rows, order) {

}
return [...rows].sort((a, b) => {
if (a[order.field] === b[order.field]) {
return [...rows].sort(({
[order.field]: a
}, {
[order.field]: b
}) => {
const [x, y] = order.direction === 'ascending' ? [a, b] : [b, a];
if (typeof x === 'string' && typeof y === 'string') {
return collator.compare(x, y);
}
if (x === y) {
return 0;
}
if (order.direction === 'ascending') {
return a[order.field] > b[order.field] ? 1 : -1;
}
return a[order.field] > b[order.field] ? -1 : 1;
return x > y ? 1 : -1;
});

@@ -21,0 +32,0 @@ }, [order, rows]);

{
"name": "@hypothesis/frontend-shared",
"version": "7.7.0",
"version": "7.7.1",
"description": "Shared components, styles and utilities for Hypothesis projects",

@@ -5,0 +5,0 @@ "license": "BSD-2-Clause",

Sorry, the diff of this file is not supported yet

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