@kakasoo/sortable
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -0,1 +1,2 @@ | ||
import { DeepStrictObjectKeys } from "@kakasoo/deep-strict-types"; | ||
import { StringType } from "@kakasoo/proto-typescript"; | ||
@@ -5,2 +6,8 @@ import { StringToDeepObject } from "./types"; | ||
export declare function getSortable<Key extends string, Direction extends "asc" | "desc">(key: Key, direction: Direction): StringToDeepObject<Split<Key>, Direction>; | ||
/** | ||
* Create getSortable Function by using interface and type. | ||
* | ||
* @returns getSortable {@link getSortable sortableFn} function | ||
*/ | ||
export declare const createSortable: <T extends object>() => <Key extends DeepStrictObjectKeys<T>, Direction extends "asc" | "desc">(key: Key, direction: Direction) => StringToDeepObject<Split<Key>, Direction>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createSortable = void 0; | ||
exports.getSortable = getSortable; | ||
@@ -20,1 +21,8 @@ const proto_typescript_1 = require("@kakasoo/proto-typescript"); | ||
} | ||
/** | ||
* Create getSortable Function by using interface and type. | ||
* | ||
* @returns getSortable {@link getSortable sortableFn} function | ||
*/ | ||
const createSortable = () => (key, direction) => getSortable(key, direction); | ||
exports.createSortable = createSortable; |
{ | ||
"name": "@kakasoo/sortable", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
# sortable | ||
## getSortable | ||
```bash | ||
@@ -43,1 +45,20 @@ $ npm i @kakasoo/sortable | ||
``` | ||
## createSortable | ||
```ts | ||
interface Example { | ||
user: { | ||
name: string; | ||
createdAt: string; | ||
}; | ||
} | ||
// #1 | ||
const sortable = createSortable<Example>(); | ||
sortable("user.createdAt", "asc"); // It guarantees type inference. | ||
// #2 | ||
// also you can use like this: | ||
createSortable<Example>()("user.createdAt", "asc"); | ||
``` |
@@ -0,1 +1,2 @@ | ||
import { DeepStrictObjectKeys } from "@kakasoo/deep-strict-types"; | ||
import { StringPrototype, StringType } from "@kakasoo/proto-typescript"; | ||
@@ -26,1 +27,14 @@ import { StringToDeepObject } from "./types"; | ||
} | ||
/** | ||
* Create getSortable Function by using interface and type. | ||
* | ||
* @returns getSortable {@link getSortable sortableFn} function | ||
*/ | ||
export const createSortable = | ||
<T extends object>() => | ||
<Key extends DeepStrictObjectKeys<T>, Direction extends "asc" | "desc">( | ||
key: Key, | ||
direction: Direction | ||
) => | ||
getSortable<Key, Direction>(key, direction); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18671
10
188
64