nzh.d.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. interface Options {
  2. /*
  3. * 十的口语化开关, 默认值为 false
  4. * 注: Nzh.cn和Nzh.hk中的encodeS方法默认 true
  5. * */
  6. tenMin?: boolean;
  7. /**
  8. * "万万"化开关, 默认值为 true
  9. * */
  10. ww?: boolean;
  11. }
  12. interface ToMoneyOptions extends Options {
  13. /**
  14. * 输出完整金额开关, toMoney 函数专用配置, 默认 false
  15. * */
  16. complete?: boolean;
  17. /*
  18. * 输出金额前缀字符, toMoney 函数专用配置, 默认 true
  19. * */
  20. outSymbol?: boolean;
  21. /*
  22. * 个位为0时不省略元,toMoney 函数专用配置, 默认 false
  23. * */
  24. unOmitYuan?: boolean;
  25. /**
  26. * 不以源数据加整,以输出结果加“整”(只要输出的结果没有到分位就加“整”)
  27. */
  28. forceZheng?: boolean;
  29. }
  30. interface Lang {
  31. ch: string;
  32. ch_u: string;
  33. ch_f: string;
  34. ch_d: string;
  35. m_t: string;
  36. m_z: string;
  37. m_u: string;
  38. }
  39. interface Langs {
  40. s: Lang;
  41. b: Lang;
  42. hk_s: Lang;
  43. hk_b: Lang;
  44. }
  45. interface BuiltIn {
  46. encodeS(num: number | string, options?: Options): string;
  47. encodeB(num: number | string, options?: Options): string;
  48. decodeS(zhnum: string, options?: Options): string;
  49. decodeB(zhnum: string, options?: Options): string;
  50. toMoney(num: number | string, options?: ToMoneyOptions): string;
  51. }
  52. declare module 'nzh' {
  53. export default class Nzh {
  54. constructor(lang: Lang);
  55. public encode(num: number | string, options?: Options): string;
  56. public decode(zhnum: string, options?: Options): string;
  57. public toMoney(num: number | string, options?: ToMoneyOptions): string;
  58. static cn: BuiltIn;
  59. static hk: BuiltIn;
  60. static langs: Langs;
  61. }
  62. }
  63. declare module 'nzh/cn' {
  64. const nzhcn:BuiltIn;
  65. export default nzhcn;
  66. }
  67. declare module 'nzh/hk' {
  68. const nzhhk:BuiltIn;
  69. export default nzhhk;
  70. }