index.ts 768 B

1234567891011121314151617181920212223
  1. // Copyright 2017-2019 @polkadot/app-accounts authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import { GeneratorMatches, GeneratorResult, GeneratorOptions } from './types';
  5. import generate from './generate';
  6. export default function generator (options: GeneratorOptions): GeneratorResult {
  7. const { match, runs = 10, withCase = false } = options;
  8. const test = (withCase ? match : match.toLowerCase()).split(',').map((c): string[] => c.split(''));
  9. const startAt = Date.now();
  10. const found: GeneratorMatches = [];
  11. while (found.length !== runs) {
  12. found.push(generate(test, options));
  13. }
  14. return {
  15. elapsed: Date.now() - startAt,
  16. found
  17. };
  18. }