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.
- package/README.md +80 -45
- package/lib/basic/const.d.ts +3 -0
- package/lib/basic/const.js +5 -0
- package/lib/basic/set.d.ts +10 -8
- package/lib/basic/set.js +14 -1
- package/lib/basic/type.d.ts +2 -2
- package/lib/custom/bool.d.ts +1 -0
- package/lib/custom/bool.js +7 -0
- package/lib/custom/email.d.ts +4 -13
- package/lib/custom/email.js +41 -0
- package/lib/custom/filenameX.d.ts +5 -0
- package/lib/custom/filenameX.js +43 -0
- package/lib/custom/fullnameX.d.ts +6 -0
- package/lib/custom/fullnameX.js +35 -0
- package/lib/custom/index.d.ts +36 -45
- package/lib/custom/index.js +23 -289
- package/lib/custom/number.d.ts +3 -3
- package/lib/custom/number.js +37 -0
- package/lib/custom/random.d.ts +2 -5
- package/lib/custom/random.js +81 -0
- package/lib/custom/sentence.d.ts +11 -0
- package/lib/custom/sentence.js +50 -0
- package/lib/custom/singleName.d.ts +5 -0
- package/lib/custom/singleName.js +30 -0
- package/lib/custom/username.d.ts +2 -4
- package/lib/custom/username.js +10 -0
- package/lib/custom/word.d.ts +11 -5
- package/lib/custom/word.js +35 -0
- package/lib/interfaces/base.d.ts +21 -0
- package/lib/interfaces/email.d.ts +13 -0
- package/lib/{custom → interfaces}/filename.d.ts +3 -3
- package/lib/interfaces/filename.js +2 -0
- package/lib/interfaces/fullname.d.ts +6 -0
- package/lib/interfaces/fullname.js +2 -0
- package/lib/interfaces/index.d.ts +9 -21
- package/lib/interfaces/index.js +23 -0
- package/lib/interfaces/number.d.ts +3 -0
- package/lib/interfaces/number.js +2 -0
- package/lib/interfaces/random.d.ts +5 -0
- package/lib/interfaces/random.js +2 -0
- package/lib/interfaces/sentence.d.ts +5 -0
- package/lib/interfaces/sentence.js +2 -0
- package/lib/interfaces/username.d.ts +4 -0
- package/lib/interfaces/username.js +2 -0
- package/lib/interfaces/word.d.ts +5 -0
- package/lib/interfaces/word.js +2 -0
- package/lib/test/sentence.test.d.ts +1 -0
- package/lib/test/sentence.test.js +33 -0
- package/lib/test/test-util.d.ts +10 -9
- package/lib/test/test-util.js +15 -3
- package/lib/test/word.test.js +16 -1
- package/package.json +1 -1
- package/todo +2 -4
- package/lib/custom/fullname.d.ts +0 -6
- /package/lib/{custom/filename.js → interfaces/base.js} +0 -0
- /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 {
|
|
1
|
+
import { RandexRange } from "./base";
|
|
2
2
|
interface BasicFileNameOptions {
|
|
3
|
-
fileNameLength?:
|
|
3
|
+
fileNameLength?: RandexRange;
|
|
4
4
|
}
|
|
5
5
|
interface ExtensionLengthFileNameOptions {
|
|
6
|
-
extensionLength?:
|
|
6
|
+
extensionLength?: RandexRange;
|
|
7
7
|
}
|
|
8
8
|
interface ExtensionFileNameOptions {
|
|
9
9
|
extension?: string;
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
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";
|
package/lib/interfaces/index.js
CHANGED
|
@@ -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 @@
|
|
|
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
|
+
});
|
package/lib/test/test-util.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RandexRange, RandexSet } from "../interfaces";
|
|
2
2
|
export declare class TestUtil {
|
|
3
|
-
static testIn(value: string, length:
|
|
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?:
|
|
6
|
-
static testInSetRange(value: string, set: RandexSet, range: string, length?:
|
|
7
|
-
static testInRange(value: string, range: string, length?:
|
|
8
|
-
static testInBoth(value: string, set: RandexSet, range: string, length?:
|
|
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(
|
|
16
|
-
static
|
|
17
|
-
static
|
|
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;
|
package/lib/test/test-util.js
CHANGED
|
@@ -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 (
|
|
81
|
-
if (length === void 0) { length =
|
|
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(
|
|
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; }
|
package/lib/test/word.test.js
CHANGED
|
@@ -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,
|
|
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
package/todo
CHANGED
package/lib/custom/fullname.d.ts
DELETED
|
File without changes
|
|
File without changes
|