1 | import { type } from '@antv/dw-analyzer';
|
2 | import { Random, TextRandom } from '@antv/dw-random';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export function oneMoreValue(sample) {
|
9 | var dataProps = type(sample);
|
10 | var isUnique = dataProps.count === dataProps.distinct;
|
11 | var tr = new TextRandom();
|
12 | var r = new Random();
|
13 | if (dataProps.recommendation === 'string') {
|
14 | if (isUnique) {
|
15 |
|
16 | return tr.word({ length: r.n(r.natural, 1, { min: dataProps.minLength, max: dataProps.maxLength })[0] });
|
17 | }
|
18 | else {
|
19 | return dataProps.samples[Math.floor(Math.random() * dataProps.samples.length)];
|
20 | }
|
21 | }
|
22 | else {
|
23 | return dataProps.samples[Math.floor(Math.random() * dataProps.samples.length)];
|
24 | }
|
25 | }
|