randex 0.25.0 → 0.28.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 (56) hide show
  1. package/README.md +80 -45
  2. package/lib/basic/const.d.ts +3 -0
  3. package/lib/basic/const.js +5 -0
  4. package/lib/basic/set.d.ts +10 -8
  5. package/lib/basic/set.js +14 -1
  6. package/lib/basic/type.d.ts +2 -2
  7. package/lib/custom/bool.d.ts +1 -0
  8. package/lib/custom/bool.js +7 -0
  9. package/lib/custom/email.d.ts +4 -13
  10. package/lib/custom/email.js +41 -0
  11. package/lib/custom/filenameX.d.ts +5 -0
  12. package/lib/custom/filenameX.js +43 -0
  13. package/lib/custom/fullnameX.d.ts +6 -0
  14. package/lib/custom/fullnameX.js +35 -0
  15. package/lib/custom/index.d.ts +36 -45
  16. package/lib/custom/index.js +23 -289
  17. package/lib/custom/number.d.ts +3 -3
  18. package/lib/custom/number.js +37 -0
  19. package/lib/custom/random.d.ts +2 -5
  20. package/lib/custom/random.js +81 -0
  21. package/lib/custom/sentence.d.ts +11 -0
  22. package/lib/custom/sentence.js +50 -0
  23. package/lib/custom/singleName.d.ts +5 -0
  24. package/lib/custom/singleName.js +30 -0
  25. package/lib/custom/username.d.ts +2 -4
  26. package/lib/custom/username.js +10 -0
  27. package/lib/custom/word.d.ts +11 -5
  28. package/lib/custom/word.js +35 -0
  29. package/lib/interfaces/base.d.ts +21 -0
  30. package/lib/interfaces/email.d.ts +13 -0
  31. package/lib/{custom → interfaces}/filename.d.ts +3 -3
  32. package/lib/interfaces/filename.js +2 -0
  33. package/lib/interfaces/fullname.d.ts +6 -0
  34. package/lib/interfaces/fullname.js +2 -0
  35. package/lib/interfaces/index.d.ts +9 -21
  36. package/lib/interfaces/index.js +23 -0
  37. package/lib/interfaces/number.d.ts +3 -0
  38. package/lib/interfaces/number.js +2 -0
  39. package/lib/interfaces/random.d.ts +5 -0
  40. package/lib/interfaces/random.js +2 -0
  41. package/lib/interfaces/sentence.d.ts +5 -0
  42. package/lib/interfaces/sentence.js +2 -0
  43. package/lib/interfaces/username.d.ts +4 -0
  44. package/lib/interfaces/username.js +2 -0
  45. package/lib/interfaces/word.d.ts +5 -0
  46. package/lib/interfaces/word.js +2 -0
  47. package/lib/test/sentence.test.d.ts +1 -0
  48. package/lib/test/sentence.test.js +33 -0
  49. package/lib/test/test-util.d.ts +10 -9
  50. package/lib/test/test-util.js +15 -3
  51. package/lib/test/word.test.js +16 -1
  52. package/package.json +1 -1
  53. package/todo +2 -4
  54. package/lib/custom/fullname.d.ts +0 -6
  55. /package/lib/{custom/filename.js → interfaces/base.js} +0 -0
  56. /package/lib/{custom/fullname.js → interfaces/email.js} +0 -0
@@ -0,0 +1,13 @@
1
+ import { RandexRange } from "./base";
2
+ interface BasicEmailOptions {
3
+ prefixLength?: RandexRange;
4
+ }
5
+ interface DomainLengthEmailOptions {
6
+ hightDomainLength?: RandexRange;
7
+ lowDomainLength?: RandexRange;
8
+ }
9
+ interface DomainEmailOptions {
10
+ domain?: string;
11
+ }
12
+ export type RandexEmailOptions = BasicEmailOptions & (DomainLengthEmailOptions | DomainEmailOptions);
13
+ export {};
@@ -1,9 +1,9 @@
1
- import { RandexLength } from "../interfaces";
1
+ import { RandexRange } from "./base";
2
2
  interface BasicFileNameOptions {
3
- fileNameLength?: RandexLength;
3
+ fileNameLength?: RandexRange;
4
4
  }
5
5
  interface ExtensionLengthFileNameOptions {
6
- extensionLength?: RandexLength;
6
+ extensionLength?: RandexRange;
7
7
  }
8
8
  interface ExtensionFileNameOptions {
9
9
  extension?: string;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { RandexAlphabet, RandexRange } from "./base";
2
+ export interface RandexFullNameOptions {
3
+ alphabet?: RandexAlphabet;
4
+ firstLength?: RandexRange;
5
+ secondLength?: RandexRange;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +1,9 @@
1
- export type RandexCase = "default" | "lower" | "upper" | "l" | "u";
2
- export type RandexAlphabet = "english" | "french" | "spanish" | "russian";
3
- export type RandexSingleSet = RandexAlphabet | "hex" | "symbol" | "number" | "binary";
4
- export type RandexAlphabetCase = [RandexAlphabet, RandexCase];
5
- export type RandexItemSet = RandexSingleSet | RandexAlphabetCase;
6
- export type RandexSet = RandexItemSet | RandexItemSet[];
7
- export type RandexLength = number | [number, number];
8
- interface RandexItemBasicOptions {
9
- set?: RandexSet;
10
- range?: string;
11
- length?: RandexLength;
12
- }
13
- export interface RandexContentSetOptions extends Omit<RandexItemBasicOptions, "set"> {
14
- set: RandexSet;
15
- }
16
- export interface RandexContentRangeOptions extends Omit<RandexItemBasicOptions, "range"> {
17
- range: string;
18
- }
19
- export type RandexContentArrayOptions = [RandexSet, string | RandexLength] | [RandexSet, string, RandexLength];
20
- export type RandexContentOptions = RandexContentSetOptions | RandexContentRangeOptions | RandexContentArrayOptions | RandexSet;
21
- export {};
1
+ export * from "./base";
2
+ export * from "./email";
3
+ export * from "./filename";
4
+ export * from "./fullname";
5
+ export * from "./number";
6
+ export * from "./random";
7
+ export * from "./username";
8
+ export * from "./word";
9
+ export * from "./sentence";
@@ -1,2 +1,25 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base"), exports);
18
+ __exportStar(require("./email"), exports);
19
+ __exportStar(require("./filename"), exports);
20
+ __exportStar(require("./fullname"), exports);
21
+ __exportStar(require("./number"), exports);
22
+ __exportStar(require("./random"), exports);
23
+ __exportStar(require("./username"), exports);
24
+ __exportStar(require("./word"), exports);
25
+ __exportStar(require("./sentence"), exports);
@@ -0,0 +1,3 @@
1
+ export interface RandomNumberOptions {
2
+ decimals?: number;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { RandexRange } from "./base";
2
+ export interface RandexRangeOptions {
3
+ range: string;
4
+ length: RandexRange;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { RandexAlphabet, RandexRange } from "./base";
2
+ export interface RandexSentenceOptions {
3
+ alphabet?: RandexAlphabet;
4
+ wordRange?: RandexRange;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { RandexRange } from "./base";
2
+ export interface RandexUsernameOptions {
3
+ length?: RandexRange;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { RandexAlphabet, RandexRange } from "./base";
2
+ export interface RandexWordOptions {
3
+ alphabet?: RandexAlphabet;
4
+ length?: RandexRange;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var custom_1 = require("../custom");
4
+ var test_util_1 = require("./test-util");
5
+ describe("sentence", function () {
6
+ it("default", function () {
7
+ test_util_1.TestUtil.loop(function () {
8
+ var text = custom_1.Randex.sentence();
9
+ expect(test_util_1.TestUtil.isSentenceValid(text)).toBeTruthy();
10
+ });
11
+ });
12
+ it("range", function () {
13
+ var range = [10, 20];
14
+ test_util_1.TestUtil.loop(function () {
15
+ var text = custom_1.Randex.sentence(range);
16
+ expect(test_util_1.TestUtil.isSentenceValid(text, range)).toBeTruthy();
17
+ });
18
+ });
19
+ it("specific number", function () {
20
+ var range = 5;
21
+ test_util_1.TestUtil.loop(function () {
22
+ var text = custom_1.Randex.sentence(range);
23
+ expect(test_util_1.TestUtil.isSentenceValid(text, range)).toBeTruthy();
24
+ });
25
+ });
26
+ it("many", function () {
27
+ var count = 5;
28
+ var sentences = custom_1.Randex.many(count).sentence();
29
+ for (var i = 0; i < count; i++) {
30
+ expect(test_util_1.TestUtil.isSentenceValid(sentences[i])).toBeTruthy();
31
+ }
32
+ });
33
+ });
@@ -1,20 +1,21 @@
1
- import { RandexLength, RandexSet } from "../interfaces";
1
+ import { RandexRange, RandexSet } from "../interfaces";
2
2
  export declare class TestUtil {
3
- static testIn(value: string, length: RandexLength | undefined, action: () => void): void;
3
+ static testIn(value: string, length: RandexRange | undefined, action: () => void): void;
4
4
  static loop(action: (index: number) => void): void;
5
- static testInSet(value: string, set: RandexSet, length?: RandexLength): void;
6
- static testInSetRange(value: string, set: RandexSet, range: string, length?: RandexLength): void;
7
- static testInRange(value: string, range: string, length?: RandexLength): void;
8
- static testInBoth(value: string, set: RandexSet, range: string, length?: RandexLength): void;
5
+ static testInSet(value: string, set: RandexSet, length?: RandexRange): void;
6
+ static testInSetRange(value: string, set: RandexSet, range: string, length?: RandexRange): void;
7
+ static testInRange(value: string, range: string, length?: RandexRange): void;
8
+ static testInBoth(value: string, set: RandexSet, range: string, length?: RandexRange): void;
9
9
  static inRange(value: string, range: string): boolean;
10
10
  static inSet(value: string, set: RandexSet, range?: string): boolean;
11
11
  static inBoth(value: string, set: RandexSet, range: string): boolean;
12
12
  static isEmailValid(email: string): RegExpMatchArray | null;
13
13
  static isUsernameValid(email: string): RegExpMatchArray | null;
14
14
  static isNameValid(email: string): RegExpMatchArray | null;
15
- static isWordValid(word: string, length?: RandexLength): RegExpMatchArray | null;
16
- static isUpperCharValid(value: string, length?: RandexLength): RegExpMatchArray | null;
17
- static isLowerCharValid(value: string, length?: RandexLength): RegExpMatchArray | null;
15
+ static isWordValid(text: string, length?: RandexRange): RegExpMatchArray | null;
16
+ static isSentenceValid(text: string, length?: RandexRange): boolean;
17
+ static isUpperCharValid(value: string, length?: RandexRange): RegExpMatchArray | null;
18
+ static isLowerCharValid(value: string, length?: RandexRange): RegExpMatchArray | null;
18
19
  static isFullNameValid(email: string): RegExpMatchArray | null;
19
20
  static isFileNameValid(email: string): RegExpMatchArray | null;
20
21
  static inNumberRange(value: number, range: [number, number]): boolean;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TestUtil = void 0;
4
+ var const_1 = require("../basic/const");
4
5
  var set_1 = require("../basic/set");
5
6
  var TestUtil = /** @class */ (function () {
6
7
  function TestUtil() {
@@ -77,10 +78,21 @@ var TestUtil = /** @class */ (function () {
77
78
  TestUtil.isNameValid = function (email) {
78
79
  return String(email).match(/^[A-Z][a-z]{1,}$/);
79
80
  };
80
- TestUtil.isWordValid = function (word, length) {
81
- if (length === void 0) { length = 2; }
81
+ TestUtil.isWordValid = function (text, length) {
82
+ if (length === void 0) { length = const_1.DEFAULT_WORD_RANGE; }
82
83
  var l = TestUtil.getLength(length);
83
- return String(word).match(new RegExp("^[a-z]{".concat(l, "}$")));
84
+ return String(text).match(new RegExp("^[a-z]{".concat(l, "}$")));
85
+ };
86
+ TestUtil.isSentenceValid = function (text, length) {
87
+ if (length === void 0) { length = const_1.DEFAULT_SENTENCE_RANGE; }
88
+ var splits = text.split(" ");
89
+ if (Array.isArray(length)) {
90
+ var min = length[0], max = length[1];
91
+ return splits.length >= min && splits.length <= max;
92
+ }
93
+ else {
94
+ return splits.length === length;
95
+ }
84
96
  };
85
97
  TestUtil.isUpperCharValid = function (value, length) {
86
98
  if (length === void 0) { length = 1; }
@@ -1,12 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ var const_1 = require("../basic/const");
3
4
  var custom_1 = require("../custom");
4
5
  var test_util_1 = require("./test-util");
5
6
  describe("word", function () {
6
7
  it("classic", function () {
7
8
  test_util_1.TestUtil.loop(function () {
8
9
  var w = custom_1.Randex.word();
9
- expect(test_util_1.TestUtil.isWordValid(w, [2, 10])).toBeTruthy();
10
+ expect(test_util_1.TestUtil.isWordValid(w, const_1.DEFAULT_WORD_RANGE)).toBeTruthy();
10
11
  });
11
12
  });
13
+ it("many - number", function () {
14
+ var count = 5;
15
+ var ws = custom_1.Randex.many(count).word();
16
+ expect(ws.length).toBe(count);
17
+ for (var i = 0; i < count; i++) {
18
+ expect(test_util_1.TestUtil.isWordValid(ws[i], const_1.DEFAULT_WORD_RANGE)).toBeTruthy();
19
+ }
20
+ });
21
+ it("many - range", function () {
22
+ var count = [5, 10];
23
+ var ws = custom_1.Randex.many(count).word();
24
+ expect(ws.length).toBeGreaterThanOrEqual(5);
25
+ expect(ws.length).toBeLessThanOrEqual(10);
26
+ });
12
27
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "randex",
3
- "version": "0.25.0",
3
+ "version": "0.28.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/todo CHANGED
@@ -1,4 +1,2 @@
1
- * randomWord
2
- * randomSentence
3
-
4
- randomNumber: add decimals numbers to option
1
+ randomNumber: add decimals numbers to option
2
+ randex - add count function for word, name, ...
@@ -1,6 +0,0 @@
1
- import { RandexAlphabet, RandexLength } from "../interfaces";
2
- export interface RandexFullNameOptions {
3
- alphabet?: RandexAlphabet;
4
- firstLength?: RandexLength;
5
- secondLength?: RandexLength;
6
- }
File without changes
File without changes