@kakasoo/sortable
Advanced tools
Comparing version
import { StringType } from "@kakasoo/proto-typescript"; | ||
import { StringToDeepObject } from "./types"; | ||
export declare function getSortable<Key extends string, Direction extends "asc" | "desc">(key: Key, direction: Direction): StringToDeepObject<StringType.Split<Key, ".">, Direction>; | ||
type Split<U extends string> = U extends infer K extends string ? StringType.Split<K, "."> : never; | ||
export declare function getSortable<Key extends string, Direction extends "asc" | "desc">(key: Key, direction: Direction): StringToDeepObject<Split<Key>, Direction>; | ||
export {}; |
{ | ||
"name": "@kakasoo/sortable", | ||
"version": "1.0.2", | ||
"version": "1.0.4", | ||
"main": "dist/index.js", | ||
@@ -11,3 +11,3 @@ "types": "dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc" | ||
"build": "rimraf ./dist && tsc" | ||
}, | ||
@@ -19,2 +19,3 @@ "keywords": [], | ||
"devDependencies": { | ||
"rimraf": "^6.0.1", | ||
"typescript": "^5.7.2" | ||
@@ -21,0 +22,0 @@ }, |
import { StringPrototype, StringType } from "@kakasoo/proto-typescript"; | ||
import { StringToDeepObject } from "./types"; | ||
type Split<U extends string> = U extends infer K extends string | ||
? StringType.Split<K, "."> | ||
: never; | ||
export function getSortable< | ||
Key extends string, | ||
Direction extends "asc" | "desc" | ||
>( | ||
key: Key, | ||
direction: Direction | ||
): StringToDeepObject<StringType.Split<Key, ".">, Direction> { | ||
>(key: Key, direction: Direction): StringToDeepObject<Split<Key>, Direction> { | ||
const sortable: any = {}; | ||
@@ -12,0 +13,0 @@ const keys = StringPrototype.split(key, "."); |
15126
1.47%160
1.27%2
100%