index.d.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. export interface Options {
  2. /**
  3. Add your own custom replacements.
  4. The replacements are run on the original string before any other transformations.
  5. This only overrides a default replacement if you set an item with the same key.
  6. @default []
  7. @example
  8. ```
  9. import transliterate from '@sindresorhus/transliterate';
  10. transliterate('Я люблю единорогов', {
  11. customReplacements: [
  12. ['единорогов', '🦄']
  13. ]
  14. })
  15. //=> 'Ya lyublyu 🦄'
  16. ```
  17. */
  18. readonly customReplacements?: ReadonlyArray<[string, string]>;
  19. }
  20. /**
  21. Convert Unicode characters to Latin characters using [transliteration](https://en.wikipedia.org/wiki/Transliteration).
  22. @param string - String to transliterate.
  23. @example
  24. ```
  25. import transliterate from '@sindresorhus/transliterate';
  26. transliterate('Fußgängerübergänge');
  27. //=> 'Fussgaengeruebergaenge'
  28. transliterate('Я люблю единорогов');
  29. //=> 'Ya lyublyu edinorogov'
  30. transliterate('أنا أحب حيدات');
  31. //=> 'ana ahb hydat'
  32. transliterate('tôi yêu những chú kỳ lân');
  33. //=> 'toi yeu nhung chu ky lan'
  34. ```
  35. */
  36. export default function transliterate(string: string, options?: Options): string;