Sjeiti / TinySort

TinySort is a small script that sorts HTML elements. It sorts by text- or attribute value, or by that of one of it's children.
http://tinysort.sjeiti.com/
MIT License
454 stars 68 forks source link

TypeScript d.ts file for TinySort? #141

Open daiplusplus opened 6 years ago

daiplusplus commented 6 years ago

Would it be possible to get a TypeScript d.ts file for TinySort?

Sjeiti commented 6 years ago

I currently don't have the time to figure out how to write a proper Typescript definition file but I'd welcome a pull request. Tinysort does have thorough JSDoc declarations so it shouldn't be too hard if you know how to.

ChrisSargent commented 4 years ago

Started work on this, not sure if it's complete but got we what I needed in my app. Might be useful for someone to complete?

declare module 'tinysort' {
  export interface Options {
    selector?: string;
    order?: 'asc' | 'desc' | 'rand';
    attr?: string;
    data?: string;
    place?: 'start' | 'end' | 'first' | 'last' | 'org';
    useVal?: boolean;
    cases?: boolean;
    natural?: boolean;
    forceStrings?: boolean;
    ignoreDashes?: boolean;
    sortFunction?(el: HTMLElement): function;
    useFlex?: boolean;
    emptyEnd?: boolean;
    console?: boolean;
  }

  export default function tinysort(
    nodelist: string | NodeList | JQuery<HTMLElement>,
    options?: Options
  );
}