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

@frui.ts/data

Package Overview
Dependencies
Maintainers
5
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@frui.ts/data - npm Package Compare versions

Comparing version 1.0.0-alpha.2 to 1.0.0-alpha.3

5

dist/sortingHelper.d.ts

@@ -0,2 +1,5 @@

import { SortingDirection } from "./sortingDirection";
import type { IPagingFilter } from "./types";
export declare function applySort(filter: IPagingFilter, columnName: string): void;
export declare function getSortingDirection(filter: IPagingFilter, columnName: string): SortingDirection | undefined;
export declare function setSort(filter: IPagingFilter, columnName: string, direction?: SortingDirection): void;
export declare function addSort(filter: IPagingFilter, columnName: string, direction?: SortingDirection): void;

46

dist/sortingHelper.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applySort = void 0;
exports.addSort = exports.setSort = exports.getSortingDirection = void 0;
var sortingDirection_1 = require("./sortingDirection");
function applySort(filter, columnName) {
if (filter.sortColumn === columnName) {
filter.sortDirection =
filter.sortDirection === sortingDirection_1.SortingDirection.Ascending ? sortingDirection_1.SortingDirection.Descending : sortingDirection_1.SortingDirection.Ascending;
function getSortingDirection(filter, columnName) {
var _a, _b;
var existingIndex = (_a = filter.sorting) === null || _a === void 0 ? void 0 : _a.findIndex(function (x) { return x.column === columnName; });
if (existingIndex === undefined || existingIndex < 0) {
return undefined;
}
return (_b = filter.sorting) === null || _b === void 0 ? void 0 : _b[existingIndex].direction;
}
exports.getSortingDirection = getSortingDirection;
function setSort(filter, columnName, direction) {
var _a;
var existingSort = (_a = filter.sorting) === null || _a === void 0 ? void 0 : _a[0];
var sortDirection = direction !== null && direction !== void 0 ? direction : ((existingSort === null || existingSort === void 0 ? void 0 : existingSort.column) === columnName && existingSort.direction === sortingDirection_1.SortingDirection.Ascending
? sortingDirection_1.SortingDirection.Descending
: sortingDirection_1.SortingDirection.Ascending);
if (filter.sorting) {
filter.sorting[0] = { column: columnName, direction: sortDirection };
filter.sorting.length = 1;
}
else {
filter.sortColumn = columnName;
filter.sortDirection = sortingDirection_1.SortingDirection.Ascending;
filter.sorting = [{ column: columnName, direction: sortDirection }];
}
}
exports.applySort = applySort;
exports.setSort = setSort;
function addSort(filter, columnName, direction) {
if (!filter.sorting) {
filter.sorting = [{ column: columnName, direction: direction !== null && direction !== void 0 ? direction : sortingDirection_1.SortingDirection.Ascending }];
return;
}
var existingIndex = filter.sorting.findIndex(function (x) { return x.column === columnName; });
if (existingIndex === -1) {
filter.sorting.push({ column: columnName, direction: direction !== null && direction !== void 0 ? direction : sortingDirection_1.SortingDirection.Ascending });
}
else {
filter.sorting[existingIndex].direction =
direction !== null && direction !== void 0 ? direction : (filter.sorting[existingIndex].direction === sortingDirection_1.SortingDirection.Ascending
? sortingDirection_1.SortingDirection.Descending
: sortingDirection_1.SortingDirection.Ascending);
}
}
exports.addSort = addSort;
//# sourceMappingURL=sortingHelper.js.map
import type { SortingDirection } from "./sortingDirection";
export interface IPagingInfo {
totalItems: number;
offset: number;
limit: number;
readonly totalItems: number;
readonly offset: number;
readonly limit: number;
}

@@ -10,5 +10,7 @@ export interface IPagingFilter {

limit: number;
sortColumn?: string;
sortDirection?: SortingDirection;
sorting?: {
column: string;
direction: SortingDirection;
}[];
}
export declare type PagedQueryResult<TEntity> = [TEntity[], IPagingInfo];

@@ -6,3 +6,3 @@ {

},
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.3",
"description": "Helpers and interfaces for handling paged and sorted data sets",

@@ -37,3 +37,3 @@ "keywords": [

},
"gitHead": "99546362efd91f923e743ed07477bb6ef0b1caa3"
"gitHead": "6ec9e7bcdb60a72fe3fe4d63a458702e33487801"
}

Sorry, the diff of this file is not supported yet

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