revdev 0.25.0 → 0.26.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.
@@ -1,4 +1,4 @@
1
1
  export * from "./feed";
2
2
  export * from "./converter";
3
3
  export * from "./string";
4
- export * from "./slug";
4
+ export * from "./regex";
@@ -13,4 +13,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./feed"), exports);
14
14
  __exportStar(require("./converter"), exports);
15
15
  __exportStar(require("./string"), exports);
16
- __exportStar(require("./slug"), exports);
16
+ __exportStar(require("./regex"), exports);
@@ -0,0 +1,6 @@
1
+ export declare class RegexUtil {
2
+ private static slugRegex;
3
+ private static tagCodeRegex;
4
+ static isSlug(slug: string): boolean;
5
+ static isTagCode(code: string): boolean;
6
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegexUtil = void 0;
4
+ var RegexUtil = /** @class */ (function () {
5
+ function RegexUtil() {
6
+ }
7
+ RegexUtil.isSlug = function (slug) {
8
+ this.slugRegex.lastIndex = 0;
9
+ return this.slugRegex.test(slug);
10
+ };
11
+ RegexUtil.isTagCode = function (code) {
12
+ this.tagCodeRegex.lastIndex = 0;
13
+ return this.tagCodeRegex.test(code);
14
+ };
15
+ // min: 6, max: 50
16
+ RegexUtil.slugRegex = /^[a-z][a-z0-9\-]{4,48}[a-z0-9]$/g;
17
+ RegexUtil.tagCodeRegex = /^[a-z]([\-]?[a-z]+)*$/g;
18
+ return RegexUtil;
19
+ }());
20
+ exports.RegexUtil = RegexUtil;
@@ -1,22 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var slug_1 = require("../slug");
4
- function trueSlug(slug) {
5
- expect(slug_1.SlugUtil.isSlug(slug)).toBe(true);
6
- }
7
- function falseSlug(slug) {
8
- expect(slug_1.SlugUtil.isSlug(slug)).toBe(false);
9
- }
10
- describe("slug", function () {
11
- test("true", function () {
12
- trueSlug("my-list");
13
- trueSlug("mylist");
14
- trueSlug("mylist-25");
15
- trueSlug("m12345");
3
+ var regex_1 = require("../regex");
4
+ describe("RegexUtil", function () {
5
+ describe("slug", function () {
6
+ function trueSlug(text) {
7
+ expect(regex_1.RegexUtil.isSlug(text)).toBe(true);
8
+ }
9
+ function falseSlug(text) {
10
+ expect(regex_1.RegexUtil.isSlug(text)).toBe(false);
11
+ }
12
+ test("true", function () {
13
+ trueSlug("my-list");
14
+ trueSlug("mylist");
15
+ trueSlug("mylist-25");
16
+ trueSlug("m12345");
17
+ });
18
+ test("false", function () {
19
+ falseSlug("my");
20
+ falseSlug("-mylist");
21
+ falseSlug("1mylist");
22
+ });
16
23
  });
17
- test("false", function () {
18
- falseSlug("my");
19
- falseSlug("-mylist");
20
- falseSlug("1mylist");
24
+ describe("tag", function () {
25
+ function trueCode(text) {
26
+ expect(regex_1.RegexUtil.isTagCode(text)).toBe(true);
27
+ }
28
+ function falseCode(text) {
29
+ expect(regex_1.RegexUtil.isTagCode(text)).toBe(false);
30
+ }
31
+ test("true", function () {
32
+ trueCode("my-code");
33
+ trueCode("tag");
34
+ trueCode("a");
35
+ trueCode("abcd-e-ef-ji");
36
+ });
37
+ test("false", function () {
38
+ falseCode("");
39
+ falseCode("a-");
40
+ falseCode("-b");
41
+ falseCode("my1");
42
+ });
21
43
  });
22
44
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "revdev",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,4 +0,0 @@
1
- export declare class SlugUtil {
2
- private static slugRegex;
3
- static isSlug(slug: string): boolean;
4
- }
package/lib/utils/slug.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlugUtil = void 0;
4
- var SlugUtil = /** @class */ (function () {
5
- function SlugUtil() {
6
- }
7
- SlugUtil.isSlug = function (slug) {
8
- this.slugRegex.lastIndex = 0;
9
- return this.slugRegex.test(slug);
10
- };
11
- // min: 6, max: 50
12
- SlugUtil.slugRegex = /^[a-z][a-z0-9\-]{4,48}[a-z0-9]$/g;
13
- return SlugUtil;
14
- }());
15
- exports.SlugUtil = SlugUtil;