index.d.ts 6.4 KB

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