synunu-libs 1.0.24 → 1.0.25

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,3 +1,4 @@
1
1
  export * from "./time.util";
2
2
  export * from "./transaction.util";
3
+ export * from "./string.utiil";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC"}
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./time.util"), exports);
18
18
  __exportStar(require("./transaction.util"), exports);
19
+ __exportStar(require("./string.utiil"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,qDAAmC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,qDAAmC;AACnC,iDAA+B"}
@@ -0,0 +1,5 @@
1
+ export declare function removeVietnameseAccents(str: string, { removePunctuations }: {
2
+ removePunctuations?: boolean | undefined;
3
+ }): string;
4
+ export declare function slugify(str: string): string;
5
+ //# sourceMappingURL=string.utiil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.utiil.d.ts","sourceRoot":"","sources":["../../src/utils/string.utiil.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,EACX,EAAE,kBAA0B,EAAE;;CAAA,UA8B/B;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,UAQlC"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeVietnameseAccents = removeVietnameseAccents;
4
+ exports.slugify = slugify;
5
+ function removeVietnameseAccents(str, { removePunctuations = false }) {
6
+ str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
7
+ str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
8
+ str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
9
+ str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
10
+ str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
11
+ str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
12
+ str = str.replace(/đ/g, "d");
13
+ str = str.replace(/À|Á|Ạ|Ả|Ã|Â|Ầ|Ấ|Ậ|Ẩ|Ẫ|Ă|Ằ|Ắ|Ặ|Ẳ|Ẵ/g, "A");
14
+ str = str.replace(/È|É|Ẹ|Ẻ|Ẽ|Ê|Ề|Ế|Ệ|Ể|Ễ/g, "E");
15
+ str = str.replace(/Ì|Í|Ị|Ỉ|Ĩ/g, "I");
16
+ str = str.replace(/Ò|Ó|Ọ|Ỏ|Õ|Ô|Ồ|Ố|Ộ|Ổ|Ỗ|Ơ|Ờ|Ớ|Ợ|Ở|Ỡ/g, "O");
17
+ str = str.replace(/Ù|Ú|Ụ|Ủ|Ũ|Ư|Ừ|Ứ|Ự|Ử|Ữ/g, "U");
18
+ str = str.replace(/Ỳ|Ý|Ỵ|Ỷ|Ỹ/g, "Y");
19
+ str = str.replace(/Đ/g, "D");
20
+ // Some system encode vietnamese combining accent as individual utf-8 characters
21
+ str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // ̀ ́ ̃ ̉
22
+ str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // ˆ ̆ ̛ Â, Ê, Ă, Ơ, Ư
23
+ // Remove punctuations
24
+ if (removePunctuations) {
25
+ str = str.replace(/%|\^|\*|\(|\)|\+|=|<|>|\?|\/|'|"|&|#|\[|\]|~|\$|_|`|{|}|\||\\/g, "");
26
+ }
27
+ str = str.trim();
28
+ return str;
29
+ }
30
+ function slugify(str) {
31
+ str = removeVietnameseAccents(str, { removePunctuations: true });
32
+ return str
33
+ .toLowerCase()
34
+ .replace(/\s+/g, "-")
35
+ .replace(/-+/g, "-")
36
+ .replace(/^-+|-+$/g, "");
37
+ }
38
+ //# sourceMappingURL=string.utiil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.utiil.js","sourceRoot":"","sources":["../../src/utils/string.utiil.ts"],"names":[],"mappings":";;AAAA,0DAgCC;AAED,0BAQC;AA1CD,SAAgB,uBAAuB,CACrC,GAAW,EACX,EAAE,kBAAkB,GAAG,KAAK,EAAE;IAE9B,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;IAC7D,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;IACjD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACrC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAC;IAC7D,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;IACjD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACrC,GAAG,GAAG,GAAG,CA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EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synunu-libs",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Shared DTOs, constants, and utilities for Synunu microservices",