Skip to content

Instantly share code, notes, and snippets.

@natterstefan
Created May 13, 2020 07:01
Show Gist options
  • Save natterstefan/345c47230822e318c60213941965e473 to your computer and use it in GitHub Desktop.
Save natterstefan/345c47230822e318c60213941965e473 to your computer and use it in GitHub Desktop.
@types/ellipsize
/**
* custom ellipsize typings - tested with ellipsize@0.1.0
*/
declare module 'ellipsize' {
/**
* @param text text to ellipsize
* @param maxLength of the text before it is ellipsized
* @param options
*/
function ellipsize(
text: string,
maxLength: number,
options: {
/**
* breakpoints - after this char the ellipse can be rendered
*/
chars?: string[]
/**
* custom ellipse element
* @default '...'
*/
ellipse?: string
/**
* truncate words or not
* @default: true
*/
truncate?: boolean
},
): string
export default ellipsize
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment