randex 1.1.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.vscode/settings.json +1 -1
  2. package/README.md +20 -0
  3. package/eslint.config.js +29 -0
  4. package/lib/basic/set.js +48 -51
  5. package/lib/basic/type.js +27 -34
  6. package/lib/custom/bool.js +1 -2
  7. package/lib/custom/email.js +8 -9
  8. package/lib/custom/filenameX.js +7 -8
  9. package/lib/custom/fullnameX.js +7 -8
  10. package/lib/custom/index.d.ts +10 -8
  11. package/lib/custom/index.js +64 -45
  12. package/lib/custom/number.js +11 -12
  13. package/lib/custom/phrase.js +11 -12
  14. package/lib/custom/random.js +23 -29
  15. package/lib/custom/sentence.js +13 -14
  16. package/lib/custom/singleName.js +7 -8
  17. package/lib/custom/username.js +6 -7
  18. package/lib/custom/word.js +9 -10
  19. package/lib/index.js +1 -2
  20. package/lib/test/array.test.js +10 -13
  21. package/lib/test/arrayItem.test.js +17 -0
  22. package/lib/test/email.test.js +35 -35
  23. package/lib/test/filename.test.js +38 -38
  24. package/lib/test/fullname.test.js +7 -7
  25. package/lib/test/markdown.test.js +14 -14
  26. package/lib/test/name.test.js +13 -13
  27. package/lib/test/number.many.test.js +21 -24
  28. package/lib/test/number.test.js +26 -27
  29. package/lib/test/params.test.js +51 -51
  30. package/lib/test/phrase.test.js +22 -22
  31. package/lib/test/random.test.js +36 -38
  32. package/lib/test/sentence.test.js +22 -22
  33. package/lib/test/{set-util.test.js → setUtil.test.js} +7 -7
  34. package/lib/test/shuffle.test.d.ts +1 -0
  35. package/lib/test/shuffle.test.js +14 -0
  36. package/lib/test/spreader.test.js +13 -12
  37. package/lib/test/testUtil.js +121 -0
  38. package/lib/test/type.test.js +11 -14
  39. package/lib/test/username.test.js +11 -11
  40. package/lib/test/word.test.js +16 -16
  41. package/lib/utils/spreader.d.ts +1 -0
  42. package/lib/utils/spreader.js +19 -25
  43. package/package.json +4 -4
  44. package/.eslintignore +0 -3
  45. package/.eslintrc.js +0 -3
  46. package/lib/test/array-item.test.js +0 -18
  47. package/lib/test/test-util.js +0 -134
  48. /package/lib/test/{array-item.test.d.ts → arrayItem.test.d.ts} +0 -0
  49. /package/lib/test/{set-util.test.d.ts → setUtil.test.d.ts} +0 -0
  50. /package/lib/test/{test-util.d.ts → testUtil.d.ts} +0 -0
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randexManyPhrase = exports.randexPhrase = void 0;
4
- var const_1 = require("../basic/const");
5
- var set_1 = require("../basic/set");
6
- var type_1 = require("../basic/type");
7
- var word_1 = require("./word");
3
+ exports.randexPhrase = randexPhrase;
4
+ exports.randexManyPhrase = randexManyPhrase;
5
+ const const_1 = require("../basic/const");
6
+ const set_1 = require("../basic/set");
7
+ const type_1 = require("../basic/type");
8
+ const word_1 = require("./word");
8
9
  function randexPhrase(p1, p2) {
9
- var length = const_1.DEFAULT_PHRASE_RANGE;
10
- var alphabet = "english";
10
+ let length = const_1.DEFAULT_PHRASE_RANGE;
11
+ let alphabet = "english";
11
12
  if (type_1.RandexTypeParser.isLength(p1)) {
12
13
  length = p1;
13
14
  }
@@ -18,7 +19,7 @@ function randexPhrase(p1, p2) {
18
19
  }
19
20
  }
20
21
  else if (typeof p1 === "object") {
21
- var options = p1;
22
+ const options = p1;
22
23
  if (options.alphabet) {
23
24
  alphabet = options.alphabet;
24
25
  }
@@ -26,14 +27,12 @@ function randexPhrase(p1, p2) {
26
27
  length = options.words;
27
28
  }
28
29
  }
29
- var words = (0, word_1.randexManyWord)(length)(alphabet);
30
+ const words = (0, word_1.randexManyWord)(length)(alphabet);
30
31
  return words.join(" ");
31
32
  }
32
- exports.randexPhrase = randexPhrase;
33
33
  function randexManyPhrase(count) {
34
34
  function many(p1, p2) {
35
- return set_1.RandexSetUtil.many(count, function () { return randexPhrase(p1, p2); });
35
+ return set_1.RandexSetUtil.many(count, () => randexPhrase(p1, p2));
36
36
  }
37
37
  return many;
38
38
  }
39
- exports.randexManyPhrase = randexManyPhrase;
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randexRandom = void 0;
4
- var set_1 = require("../basic/set");
5
- var type_1 = require("../basic/type");
3
+ exports.randexRandom = randexRandom;
4
+ const set_1 = require("../basic/set");
5
+ const type_1 = require("../basic/type");
6
6
  function randomString(params) {
7
- var length = params.length, range = params.range;
8
- var result = "";
9
- var currentLength = 0;
7
+ const { length, range } = params;
8
+ let result = "";
9
+ let currentLength = 0;
10
10
  if (typeof length === "number") {
11
11
  currentLength = length;
12
12
  }
13
13
  else if (Array.isArray(length)) {
14
- var min = length[0], max = length[1];
14
+ const [min, max] = length;
15
15
  currentLength = set_1.RandexSetUtil.randomRangeNumber(min, max);
16
16
  }
17
- for (var i = 0; i < currentLength; i++) {
18
- var index = set_1.RandexSetUtil.randomSingleNumber(range.length - 1);
17
+ for (let i = 0; i < currentLength; i++) {
18
+ const index = set_1.RandexSetUtil.randomSingleNumber(range.length - 1);
19
19
  if (range.length >= index || range.length <= index) {
20
20
  result += range[index];
21
21
  }
@@ -30,31 +30,31 @@ function toContent(options) {
30
30
  }
31
31
  else if (type_1.RandexTypeParser.isPartArray(options)) {
32
32
  if (options.length === 2) {
33
- var set = options[0], rangeOrLength = options[1];
33
+ const [set, rangeOrLength] = options;
34
34
  return type_1.RandexTypeParser.isLength(rangeOrLength)
35
35
  ? {
36
- set: set,
36
+ set,
37
37
  length: rangeOrLength,
38
38
  }
39
39
  : {
40
- set: set,
40
+ set,
41
41
  charRange: rangeOrLength,
42
42
  };
43
43
  }
44
44
  else if (options.length === 3) {
45
- var set = options[0], range = options[1], length_1 = options[2];
45
+ const [set, range, length] = options;
46
46
  return {
47
- set: set,
47
+ set,
48
48
  charRange: range,
49
- length: length_1,
49
+ length,
50
50
  };
51
51
  }
52
52
  }
53
53
  return options;
54
54
  }
55
55
  function toRangeOptions(options) {
56
- var fullRange = "";
57
- var set = options.set, range = options.charRange, _a = options.length, length = _a === void 0 ? 1 : _a;
56
+ let fullRange = "";
57
+ const { set, charRange: range, length = 1 } = options;
58
58
  if (range) {
59
59
  fullRange += range;
60
60
  }
@@ -63,21 +63,15 @@ function toRangeOptions(options) {
63
63
  }
64
64
  return {
65
65
  range: fullRange,
66
- length: length,
66
+ length,
67
67
  };
68
68
  }
69
- function randexRandom() {
70
- var options = [];
71
- for (var _i = 0; _i < arguments.length; _i++) {
72
- options[_i] = arguments[_i];
73
- }
74
- var result = "";
75
- for (var _a = 0, options_1 = options; _a < options_1.length; _a++) {
76
- var option = options_1[_a];
77
- var content = toContent(option);
78
- var p = toRangeOptions(content);
69
+ function randexRandom(...options) {
70
+ let result = "";
71
+ for (const option of options) {
72
+ const content = toContent(option);
73
+ const p = toRangeOptions(content);
79
74
  result += randomString(p);
80
75
  }
81
76
  return result;
82
77
  }
83
- exports.randexRandom = randexRandom;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randexManySentence = exports.randexSentence = void 0;
4
- var const_1 = require("../basic/const");
5
- var set_1 = require("../basic/set");
6
- var type_1 = require("../basic/type");
7
- var word_1 = require("./word");
3
+ exports.randexSentence = randexSentence;
4
+ exports.randexManySentence = randexManySentence;
5
+ const const_1 = require("../basic/const");
6
+ const set_1 = require("../basic/set");
7
+ const type_1 = require("../basic/type");
8
+ const word_1 = require("./word");
8
9
  function randexSentence(p1, p2) {
9
- var length = const_1.DEFAULT_SENTENCE_RANGE;
10
- var alphabet = "english";
10
+ let length = const_1.DEFAULT_SENTENCE_RANGE;
11
+ let alphabet = "english";
11
12
  if (type_1.RandexTypeParser.isLength(p1)) {
12
13
  length = p1;
13
14
  }
@@ -18,7 +19,7 @@ function randexSentence(p1, p2) {
18
19
  }
19
20
  }
20
21
  else if (typeof p1 === "object") {
21
- var options = p1;
22
+ const options = p1;
22
23
  if (options.alphabet) {
23
24
  alphabet = options.alphabet;
24
25
  }
@@ -26,10 +27,10 @@ function randexSentence(p1, p2) {
26
27
  length = options.words;
27
28
  }
28
29
  }
29
- var words = (0, word_1.randexManyWord)(length)(alphabet);
30
+ const words = (0, word_1.randexManyWord)(length)(alphabet);
30
31
  return words
31
- .map(function (text, index) {
32
- var wordText = text;
32
+ .map((text, index) => {
33
+ let wordText = text;
33
34
  if (index === 0 && text.length > 0) {
34
35
  wordText = text[0].toUpperCase() + text.slice(1);
35
36
  }
@@ -40,11 +41,9 @@ function randexSentence(p1, p2) {
40
41
  })
41
42
  .join(" ");
42
43
  }
43
- exports.randexSentence = randexSentence;
44
44
  function randexManySentence(count) {
45
45
  function many(p1, p2) {
46
- return set_1.RandexSetUtil.many(count, function () { return randexSentence(p1, p2); });
46
+ return set_1.RandexSetUtil.many(count, () => randexSentence(p1, p2));
47
47
  }
48
48
  return many;
49
49
  }
50
- exports.randexManySentence = randexManySentence;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randexSingleName = void 0;
4
- var set_1 = require("../basic/set");
5
- var type_1 = require("../basic/type");
6
- var random_1 = require("./random");
3
+ exports.randexSingleName = randexSingleName;
4
+ const set_1 = require("../basic/set");
5
+ const type_1 = require("../basic/type");
6
+ const random_1 = require("./random");
7
7
  function randexSingleName(p1, p2) {
8
- var length = 0;
9
- var alphabet = "english";
8
+ let length = 0;
9
+ let alphabet = "english";
10
10
  if (type_1.RandexTypeParser.isLength(p1)) {
11
11
  length = p1;
12
12
  }
@@ -24,7 +24,6 @@ function randexSingleName(p1, p2) {
24
24
  length = p1.length;
25
25
  }
26
26
  }
27
- var currentLength = set_1.RandexSetUtil.getLength(1, length, [1, 9]);
27
+ const currentLength = set_1.RandexSetUtil.getLength(1, length, [1, 9]);
28
28
  return (0, random_1.randexRandom)([alphabet, "u"], [[alphabet, "l"], currentLength]);
29
29
  }
30
- exports.randexSingleName = randexSingleName;
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randexUsername = void 0;
4
- var set_1 = require("../basic/set");
5
- var type_1 = require("../basic/type");
6
- var random_1 = require("./random");
3
+ exports.randexUsername = randexUsername;
4
+ const set_1 = require("../basic/set");
5
+ const type_1 = require("../basic/type");
6
+ const random_1 = require("./random");
7
7
  function randexUsername(options) {
8
- var length = type_1.RandexTypeParser.isLength(options) ? options : options === null || options === void 0 ? void 0 : options.length;
9
- var currentLength = set_1.RandexSetUtil.getLength(1, length, [6, 10]);
8
+ const length = type_1.RandexTypeParser.isLength(options) ? options : options?.length;
9
+ const currentLength = set_1.RandexSetUtil.getLength(1, length, [6, 10]);
10
10
  return (0, random_1.randexRandom)(["english", "l"], [[["english", "l"], "number"], currentLength]);
11
11
  }
12
- exports.randexUsername = randexUsername;
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.randexManyWord = exports.randexWord = void 0;
4
- var const_1 = require("../basic/const");
5
- var set_1 = require("../basic/set");
6
- var type_1 = require("../basic/type");
7
- var random_1 = require("./random");
3
+ exports.randexWord = randexWord;
4
+ exports.randexManyWord = randexManyWord;
5
+ const const_1 = require("../basic/const");
6
+ const set_1 = require("../basic/set");
7
+ const type_1 = require("../basic/type");
8
+ const random_1 = require("./random");
8
9
  function randexWord(p1, p2) {
9
- var length = const_1.DEFAULT_WORD_RANGE;
10
- var alphabet = "english";
10
+ let length = const_1.DEFAULT_WORD_RANGE;
11
+ let alphabet = "english";
11
12
  if (type_1.RandexTypeParser.isLength(p1)) {
12
13
  length = p1;
13
14
  }
@@ -27,11 +28,9 @@ function randexWord(p1, p2) {
27
28
  }
28
29
  return (0, random_1.randexRandom)([[alphabet, "l"], length]);
29
30
  }
30
- exports.randexWord = randexWord;
31
31
  function randexManyWord(count) {
32
32
  function many(p1, p2) {
33
- return set_1.RandexSetUtil.many(count, function () { return randexWord(p1, p2); });
33
+ return set_1.RandexSetUtil.many(count, () => randexWord(p1, p2));
34
34
  }
35
35
  return many;
36
36
  }
37
- exports.randexManyWord = randexManyWord;
package/lib/index.js CHANGED
@@ -14,9 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- var custom_1 = require("./custom");
17
+ const custom_1 = require("./custom");
18
18
  __exportStar(require("./interfaces"), exports);
19
19
  __exportStar(require("./custom"), exports);
20
20
  __exportStar(require("./utils"), exports);
21
- // eslint-disable-next-line import/no-default-export
22
21
  exports.default = custom_1.Randex;
@@ -1,26 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
3
+ const custom_1 = require("../custom");
4
4
  function testUniqueArray(array, count) {
5
- var value = custom_1.Randex.array(array, count);
6
- var uniqueResult = [];
7
- var _loop_1 = function (i) {
8
- var uniqueValue = value[i];
9
- expect(uniqueResult.find(function (x) { return x === uniqueValue; })).toBeFalsy();
5
+ const value = custom_1.Randex.array(array, count);
6
+ const uniqueResult = [];
7
+ for (let i = 0; i < count; i++) {
8
+ const uniqueValue = value[i];
9
+ expect(uniqueResult.find(x => x === uniqueValue)).toBeFalsy();
10
10
  uniqueResult.push(uniqueValue);
11
- };
12
- for (var i = 0; i < count; i++) {
13
- _loop_1(i);
14
11
  }
15
12
  }
16
- describe("randomNumberArray", function () {
17
- it("param: number", function () {
13
+ describe("randomNumberArray", () => {
14
+ it("param: number", () => {
18
15
  testUniqueArray([1, 2, 3, 4, 5, 6], 6);
19
16
  });
20
- it("param: string", function () {
17
+ it("param: string", () => {
21
18
  testUniqueArray(["1", "2", "3", "4", "5", "6"], 6);
22
19
  });
23
- it("max count - array count", function () {
20
+ it("max count - array count", () => {
24
21
  testUniqueArray([1, 2, 3, 4, 5, 6], 8);
25
22
  });
26
23
  });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const custom_1 = require("../custom");
4
+ const testUtil_1 = require("./testUtil");
5
+ describe("randomArrayItem", () => {
6
+ it("param: number", () => {
7
+ const array = [1, 2, 3, 4, 5, 6];
8
+ const resultArray = {};
9
+ testUtil_1.TestUtil.loop(() => {
10
+ const value = custom_1.Randex.arrayItem(array);
11
+ resultArray[value] = (resultArray[value] || 0) + 1;
12
+ });
13
+ for (const item of array) {
14
+ expect(resultArray[item]).toBeTruthy();
15
+ }
16
+ });
17
+ });
@@ -1,60 +1,60 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var set_1 = require("../basic/set");
4
- var custom_1 = require("../custom");
5
- var test_util_1 = require("./test-util");
6
- var r = set_1.RandexSetUtil;
3
+ const set_1 = require("../basic/set");
4
+ const custom_1 = require("../custom");
5
+ const testUtil_1 = require("./testUtil");
6
+ const r = set_1.RandexSetUtil;
7
7
  function splitEmail(email) {
8
- var _a = email.split("@"), prefix = _a[0], domain = _a[1];
9
- var _b = domain.split("."), lowDomain = _b[0], hightDomain = _b[1];
8
+ const [prefix, domain] = email.split("@");
9
+ const [lowDomain, hightDomain] = domain.split(".");
10
10
  return [prefix, domain, lowDomain, hightDomain];
11
11
  }
12
12
  function testEmail(options) {
13
- var email = options.email, _a = options.prefixLength, prefixLength = _a === void 0 ? r.defaultEmailPrefixLength : _a, _b = options.hightDomainLength, hightDomainLength = _b === void 0 ? r.defaultHightDomainEmailLength : _b, _c = options.lowDomainLength, lowDomainLength = _c === void 0 ? r.defaultLowDomainEmailLength : _c, emailDomain = options.domain;
14
- var _d = splitEmail(email), prefix = _d[0], domain = _d[1], lowDomain = _d[2], hightDomain = _d[3];
13
+ const { email, prefixLength = r.defaultEmailPrefixLength, hightDomainLength = r.defaultHightDomainEmailLength, lowDomainLength = r.defaultLowDomainEmailLength, domain: emailDomain, } = options;
14
+ const [prefix, domain, lowDomain, hightDomain] = splitEmail(email);
15
15
  // // last char only english
16
- test_util_1.TestUtil.testInSet(prefix, [["english", "l"], "number"], prefixLength);
16
+ testUtil_1.TestUtil.testInSet(prefix, [["english", "l"], "number"], prefixLength);
17
17
  if (emailDomain) {
18
18
  expect(emailDomain).toBe(domain);
19
19
  }
20
20
  else {
21
- test_util_1.TestUtil.testInSet(lowDomain, ["english"], lowDomainLength);
22
- test_util_1.TestUtil.testInSet(hightDomain, ["english"], hightDomainLength);
21
+ testUtil_1.TestUtil.testInSet(lowDomain, ["english"], lowDomainLength);
22
+ testUtil_1.TestUtil.testInSet(hightDomain, ["english"], hightDomainLength);
23
23
  }
24
24
  }
25
- describe("randomEmail", function () {
26
- it("simple", function () {
27
- test_util_1.TestUtil.loop(function () {
28
- var email = custom_1.Randex.email();
29
- testEmail({ email: email });
25
+ describe("randomEmail", () => {
26
+ it("simple", () => {
27
+ testUtil_1.TestUtil.loop(() => {
28
+ const email = custom_1.Randex.email();
29
+ testEmail({ email });
30
30
  });
31
31
  });
32
- it("options: prefixLength", function () {
33
- var prefixLength = [10, 15];
34
- test_util_1.TestUtil.loop(function () {
35
- var email = custom_1.Randex.email({ prefixLength: prefixLength });
36
- testEmail({ email: email, prefixLength: prefixLength });
32
+ it("options: prefixLength", () => {
33
+ const prefixLength = [10, 15];
34
+ testUtil_1.TestUtil.loop(() => {
35
+ let email = custom_1.Randex.email({ prefixLength });
36
+ testEmail({ email, prefixLength });
37
37
  email = custom_1.Randex.email(prefixLength);
38
- testEmail({ email: email, prefixLength: prefixLength });
38
+ testEmail({ email, prefixLength });
39
39
  });
40
40
  });
41
- it("options: hightDomainLength, lowDomainLength", function () {
42
- var hightDomainLength = 8;
43
- var lowDomainLength = 12;
44
- test_util_1.TestUtil.loop(function () {
45
- var email = custom_1.Randex.email({ hightDomainLength: hightDomainLength, lowDomainLength: lowDomainLength });
46
- testEmail({ email: email, hightDomainLength: hightDomainLength, lowDomainLength: lowDomainLength });
41
+ it("options: hightDomainLength, lowDomainLength", () => {
42
+ const hightDomainLength = 8;
43
+ const lowDomainLength = 12;
44
+ testUtil_1.TestUtil.loop(() => {
45
+ let email = custom_1.Randex.email({ hightDomainLength, lowDomainLength });
46
+ testEmail({ email, hightDomainLength, lowDomainLength });
47
47
  email = custom_1.Randex.email(r.defaultEmailPrefixLength, lowDomainLength, hightDomainLength);
48
- testEmail({ email: email, hightDomainLength: hightDomainLength, lowDomainLength: lowDomainLength, prefixLength: r.defaultEmailPrefixLength });
48
+ testEmail({ email, hightDomainLength, lowDomainLength, prefixLength: r.defaultEmailPrefixLength });
49
49
  });
50
50
  });
51
- it("options: domain", function () {
52
- var domain = "delta.com";
53
- test_util_1.TestUtil.loop(function () {
54
- var email = custom_1.Randex.email({ domain: domain });
55
- testEmail({ email: email, domain: domain });
51
+ it("options: domain", () => {
52
+ const domain = "delta.com";
53
+ testUtil_1.TestUtil.loop(() => {
54
+ let email = custom_1.Randex.email({ domain });
55
+ testEmail({ email, domain });
56
56
  email = custom_1.Randex.email(domain);
57
- testEmail({ email: email, domain: domain });
57
+ testEmail({ email, domain });
58
58
  });
59
59
  });
60
60
  });
@@ -1,66 +1,66 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var set_1 = require("../basic/set");
4
- var custom_1 = require("../custom");
5
- var test_util_1 = require("./test-util");
6
- var r = set_1.RandexSetUtil;
3
+ const set_1 = require("../basic/set");
4
+ const custom_1 = require("../custom");
5
+ const testUtil_1 = require("./testUtil");
6
+ const r = set_1.RandexSetUtil;
7
7
  function splitFileName(fullFileName) {
8
- var matches = fullFileName.match(/\.[a-z]+$/);
9
- var extension = (matches === null || matches === void 0 ? void 0 : matches[0]) || "";
10
- var fileName = fullFileName.replace(extension, "");
8
+ const matches = fullFileName.match(/\.[a-z]+$/);
9
+ let extension = matches?.[0] || "";
10
+ const fileName = fullFileName.replace(extension, "");
11
11
  extension = extension.replace(/^\./, "");
12
12
  return [fileName, extension];
13
13
  }
14
14
  function testFileName(options) {
15
- var fullFileName = options.fullFileName, _a = options.fileNameLength, fileNameLength = _a === void 0 ? r.defaultFileNameLength : _a, _b = options.extensionLength, extensionLength = _b === void 0 ? r.defaultExtensionLength : _b, extension = options.extension;
16
- var _c = splitFileName(fullFileName), fileName = _c[0], fileExtension = _c[1];
15
+ const { fullFileName, fileNameLength = r.defaultFileNameLength, extensionLength = r.defaultExtensionLength, extension } = options;
16
+ const [fileName, fileExtension] = splitFileName(fullFileName);
17
17
  // last char only english
18
- test_util_1.TestUtil.testInSet(fileName[fileName.length - 1], ["english", "number"], 1);
19
- test_util_1.TestUtil.testInSetRange(fileName, ["english", "number"], r.fileNameExtraChars, fileNameLength);
18
+ testUtil_1.TestUtil.testInSet(fileName[fileName.length - 1], ["english", "number"], 1);
19
+ testUtil_1.TestUtil.testInSetRange(fileName, ["english", "number"], r.fileNameExtraChars, fileNameLength);
20
20
  if (extension) {
21
21
  expect(extension).toBe(fileExtension);
22
22
  }
23
23
  else {
24
- test_util_1.TestUtil.testInSet(fileExtension, "english", extensionLength);
24
+ testUtil_1.TestUtil.testInSet(fileExtension, "english", extensionLength);
25
25
  }
26
26
  }
27
- describe("randomFileName", function () {
28
- it("simple", function () {
29
- test_util_1.TestUtil.loop(function () {
30
- var fullFileName = custom_1.Randex.fileName();
31
- testFileName({ fullFileName: fullFileName });
27
+ describe("randomFileName", () => {
28
+ it("simple", () => {
29
+ testUtil_1.TestUtil.loop(() => {
30
+ const fullFileName = custom_1.Randex.fileName();
31
+ testFileName({ fullFileName });
32
32
  });
33
33
  });
34
- it("params: fileNameLength", function () {
35
- var fileNameLength = [10, 15];
36
- test_util_1.TestUtil.loop(function () {
37
- var fullFileName = custom_1.Randex.fileName({ fileNameLength: fileNameLength });
38
- testFileName({ fullFileName: fullFileName, fileNameLength: fileNameLength });
34
+ it("params: fileNameLength", () => {
35
+ const fileNameLength = [10, 15];
36
+ testUtil_1.TestUtil.loop(() => {
37
+ let fullFileName = custom_1.Randex.fileName({ fileNameLength });
38
+ testFileName({ fullFileName, fileNameLength });
39
39
  fullFileName = custom_1.Randex.fileName(fileNameLength);
40
- testFileName({ fullFileName: fullFileName, fileNameLength: fileNameLength });
40
+ testFileName({ fullFileName, fileNameLength });
41
41
  });
42
42
  });
43
- it("params: extensionLength", function () {
44
- var extensionLength = [10, 15];
45
- test_util_1.TestUtil.loop(function () {
46
- var fullFileName = custom_1.Randex.fileName({ extensionLength: extensionLength });
47
- testFileName({ fullFileName: fullFileName, extensionLength: extensionLength });
43
+ it("params: extensionLength", () => {
44
+ const extensionLength = [10, 15];
45
+ testUtil_1.TestUtil.loop(() => {
46
+ let fullFileName = custom_1.Randex.fileName({ extensionLength });
47
+ testFileName({ fullFileName, extensionLength });
48
48
  fullFileName = custom_1.Randex.fileName(r.defaultFileNameLength, extensionLength);
49
- testFileName({ fullFileName: fullFileName, fileNameLength: r.defaultFileNameLength, extensionLength: extensionLength });
49
+ testFileName({ fullFileName, fileNameLength: r.defaultFileNameLength, extensionLength });
50
50
  });
51
51
  });
52
- it("params2: extension", function () {
53
- var fileNameLength = [10, 15];
54
- var extension = "xml";
55
- test_util_1.TestUtil.loop(function () {
56
- var fullFileName = custom_1.Randex.fileName({ extension: extension });
57
- testFileName({ fullFileName: fullFileName, extension: extension });
52
+ it("params2: extension", () => {
53
+ const fileNameLength = [10, 15];
54
+ const extension = "xml";
55
+ testUtil_1.TestUtil.loop(() => {
56
+ let fullFileName = custom_1.Randex.fileName({ extension });
57
+ testFileName({ fullFileName, extension });
58
58
  fullFileName = custom_1.Randex.fileName(extension);
59
- testFileName({ fullFileName: fullFileName, extension: extension });
59
+ testFileName({ fullFileName, extension });
60
60
  fullFileName = custom_1.Randex.fileName("." + extension);
61
- testFileName({ fullFileName: fullFileName, extension: extension });
61
+ testFileName({ fullFileName, extension });
62
62
  fullFileName = custom_1.Randex.fileName(fileNameLength, extension);
63
- testFileName({ fullFileName: fullFileName, fileNameLength: fileNameLength, extension: extension });
63
+ testFileName({ fullFileName, fileNameLength, extension });
64
64
  });
65
65
  });
66
66
  });
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
4
- var test_util_1 = require("./test-util");
5
- describe("randomFullName", function () {
6
- it("simple", function () {
7
- test_util_1.TestUtil.loop(function () {
8
- var value = custom_1.Randex.fullName();
9
- expect(test_util_1.TestUtil.isFullNameValid(value)).toBeTruthy();
3
+ const custom_1 = require("../custom");
4
+ const testUtil_1 = require("./testUtil");
5
+ describe("randomFullName", () => {
6
+ it("simple", () => {
7
+ testUtil_1.TestUtil.loop(() => {
8
+ const value = custom_1.Randex.fullName();
9
+ expect(testUtil_1.TestUtil.isFullNameValid(value)).toBeTruthy();
10
10
  });
11
11
  });
12
12
  });
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var custom_1 = require("../custom");
4
- describe("markdown", function () {
5
- it("random", function () {
6
- var value = custom_1.Randex.random({
3
+ const custom_1 = require("../custom");
4
+ describe("markdown", () => {
5
+ it("random", () => {
6
+ let value = custom_1.Randex.random({
7
7
  set: "english",
8
8
  length: 3,
9
9
  });
@@ -60,8 +60,8 @@ describe("markdown", function () {
60
60
  value = custom_1.Randex.random(["english", 2], [["english", "number"], 2]);
61
61
  expect(value.length).toBe(4);
62
62
  });
63
- it("randomFileName", function () {
64
- var value = custom_1.Randex.fileName();
63
+ it("randomFileName", () => {
64
+ let value = custom_1.Randex.fileName();
65
65
  value = custom_1.Randex.fileName({
66
66
  extension: "txt",
67
67
  });
@@ -78,12 +78,12 @@ describe("markdown", function () {
78
78
  value = custom_1.Randex.fileName(8, "xml");
79
79
  expect(value).toBeTruthy();
80
80
  });
81
- it("randomUsername", function () {
82
- var value = custom_1.Randex.username();
81
+ it("randomUsername", () => {
82
+ const value = custom_1.Randex.username();
83
83
  expect(value).toBeTruthy();
84
84
  });
85
- it("randomEmail", function () {
86
- var value = custom_1.Randex.email();
85
+ it("randomEmail", () => {
86
+ let value = custom_1.Randex.email();
87
87
  value = custom_1.Randex.email({
88
88
  prefixLength: 8,
89
89
  });
@@ -100,8 +100,8 @@ describe("markdown", function () {
100
100
  value = custom_1.Randex.email("test.com");
101
101
  expect(value).toBeTruthy();
102
102
  });
103
- it("singleName", function () {
104
- var value = custom_1.Randex.singleName();
103
+ it("singleName", () => {
104
+ let value = custom_1.Randex.singleName();
105
105
  expect(value).toBeTruthy();
106
106
  value = custom_1.Randex.singleName({ alphabet: "french" });
107
107
  expect(value).toBeTruthy();
@@ -110,8 +110,8 @@ describe("markdown", function () {
110
110
  value = custom_1.Randex.singleName({ length: [2, 5] });
111
111
  expect(value).toBeTruthy();
112
112
  });
113
- it("randomFullName", function () {
114
- var value = custom_1.Randex.fullName();
113
+ it("randomFullName", () => {
114
+ const value = custom_1.Randex.fullName();
115
115
  expect(value).toBeTruthy();
116
116
  });
117
117
  });