index.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // Generated by typings
  2. // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/chance/chance.d.ts
  3. declare namespace Chance {
  4. interface ChanceStatic {
  5. (): Chance
  6. (seed: number): Chance
  7. (generator: () => any): Chance
  8. new(): Chance;
  9. new(seed: number): Chance;
  10. new(generator: () => any): Chance;
  11. }
  12. interface Chance {
  13. // Basics
  14. bool(opts?: Options): boolean;
  15. character(opts?: Options): string;
  16. floating(opts?: Options): number;
  17. integer(opts?: Options): number;
  18. natural(opts?: Options): number;
  19. string(opts?: Options): string;
  20. // Text
  21. paragraph(opts?: Options): string;
  22. sentence(opts?: Options): string;
  23. syllable(opts?: Options): string;
  24. word(opts?: Options): string;
  25. // Person
  26. age(opts?: Options): number;
  27. birthday(): Date;
  28. birthday(opts?: Options): Date|string;
  29. cpf(): string;
  30. first(opts?: Options): string;
  31. last(opts?: Options): string;
  32. name(opts?: Options): string;
  33. name_prefix(opts?: Options): string;
  34. name_suffix(opts?: Options): string;
  35. prefix(opts?: Options): string;
  36. ssn(opts?: Options): string;
  37. suffix(opts?: Options): string;
  38. // Mobile
  39. android_id(): string;
  40. apple_token(): string;
  41. bb_pin(): string;
  42. wp7_anid(): string;
  43. wp8_anid2(): string;
  44. // Web
  45. color(opts?: Options): string;
  46. domain(opts?: Options): string;
  47. email(opts?: Options): string;
  48. fbid(): string;
  49. google_analytics(): string;
  50. hashtag(): string;
  51. ip(): string;
  52. ipv6(): string;
  53. klout(): string;
  54. tld(): string;
  55. twitter(): string;
  56. url(opts?: Options): string;
  57. // Location
  58. address(opts?: Options): string;
  59. altitude(opts?: Options): number;
  60. areacode(): string;
  61. city(): string;
  62. coordinates(opts?: Options): string;
  63. country(opts?: Options): string;
  64. depth(opts?: Options): number;
  65. geohash(opts?: Options): string;
  66. latitude(opts?: Options): number;
  67. longitude(opts?: Options): number;
  68. phone(opts?: Options): string;
  69. postal(): string;
  70. province(opts?: Options): string;
  71. state(opts?: Options): string;
  72. street(opts?: Options): string;
  73. zip(opts?: Options): string;
  74. // Time
  75. ampm(): string;
  76. date(): Date;
  77. date(opts: DateOptions): Date|string;
  78. hammertime(): number;
  79. hour(opts?: Options): number;
  80. millisecond(): number;
  81. minute(): number;
  82. month(): string;
  83. month(opts: Options): Month;
  84. second(): number;
  85. timestamp(): number;
  86. year(opts?: Options): string;
  87. // Finance
  88. cc(opts?: Options): string;
  89. cc_type(): string;
  90. cc_type(opts: Options): string|CreditCardType;
  91. currency(): Currency;
  92. currency_pair(): [ Currency, Currency ];
  93. dollar(opts?: Options): string;
  94. exp(): string;
  95. exp(opts: Options): string|CreditCardExpiration;
  96. exp_month(opts?: Options): string;
  97. exp_year(opts?: Options): string;
  98. // Helpers
  99. capitalize(str: string): string;
  100. mixin(desc: MixinDescriptor): any;
  101. pad(num: number, width: number, padChar?: string): string;
  102. pick<T>(arr: T[]): T;
  103. pick<T>(arr: T[], count: number): T[];
  104. set: Setter;
  105. shuffle<T>(arr: T[]): T[];
  106. // Miscellaneous
  107. d4(): number;
  108. d6(): number;
  109. d8(): number;
  110. d10(): number;
  111. d12(): number;
  112. d20(): number;
  113. d30(): number;
  114. d100(): number;
  115. guid(): string;
  116. hash(opts?: Options): string;
  117. n<T>(generator: () => T, count: number, opts?: Options): T[];
  118. normal(opts?: Options): number;
  119. radio(opts?: Options): string;
  120. rpg(dice: string): number[];
  121. rpg(dice: string, opts?: Options): number[]|number;
  122. tv(opts?: Options): string;
  123. unique<T>(generator: () => T, count: number, opts?: Options): T[];
  124. weighted<T>(values: T[], weights: number[]): T;
  125. // "Hidden"
  126. cc_types(): CreditCardType[];
  127. mersenne_twister(seed?: number): any; // API return type not defined in docs
  128. months(): Month[];
  129. name_prefixes(): Name[];
  130. provinces(): Name[];
  131. states(): Name[];
  132. street_suffix(): Name;
  133. street_suffixes(): Name[];
  134. }
  135. // A more rigorous approach might be to produce
  136. // the correct options interfaces for each method
  137. interface Options { [id: string]: any; }
  138. interface DateOptions {
  139. string?: boolean;
  140. american?: boolean;
  141. year?: number;
  142. month?: number;
  143. day?: number;
  144. }
  145. interface Month {
  146. name: string;
  147. short_name: string;
  148. numeric: string;
  149. }
  150. interface CreditCardType {
  151. name: string;
  152. short_name: string;
  153. prefix: string;
  154. length: number;
  155. }
  156. interface Currency {
  157. code: string;
  158. name: string;
  159. }
  160. interface CreditCardExpiration {
  161. month: string;
  162. year: string;
  163. }
  164. interface MixinDescriptor { [id: string]: () => any; }
  165. interface Setter {
  166. (key: 'firstNames', values: string[]): any;
  167. (key: 'lastNames', values: string[]): any;
  168. (key: 'provinces', values: string[]): any;
  169. (key: 'us_states_and_dc', values: string[]): any;
  170. (key: 'territories', values: string[]): any;
  171. (key: 'armed_forces', values: string[]): any;
  172. (key: 'street_suffixes', values: string[]): any;
  173. (key: 'months', values: string[]): any;
  174. (key: 'cc_types', values: string[]): any;
  175. (key: 'currency_types', values: string[]): any;
  176. <T>(key: string, values: T[]): any;
  177. }
  178. interface Name {
  179. name: string;
  180. abbreviation: string;
  181. }
  182. }
  183. // window.chance
  184. declare var chance: Chance.Chance;
  185. declare var Chance: Chance.ChanceStatic;
  186. // import Chance = require('chance');
  187. declare module 'chance' {
  188. interface ExportedChance extends Chance.ChanceStatic {
  189. Chance: ExportedChance;
  190. }
  191. var Chance: ExportedChance;
  192. export = Chance;
  193. }