namefully 1.1.0 → 1.2.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 (156) hide show
  1. package/dist/example/index.js +2734 -0
  2. package/dist/lib/config.d.ts +121 -0
  3. package/dist/lib/config.js +189 -0
  4. package/dist/lib/config.js.map +1 -0
  5. package/dist/lib/constants.d.ts +4 -0
  6. package/dist/lib/constants.js +31 -0
  7. package/dist/lib/constants.js.map +1 -0
  8. package/dist/lib/error.d.ts +172 -0
  9. package/dist/lib/error.js +210 -0
  10. package/dist/lib/error.js.map +1 -0
  11. package/dist/lib/example/example.d.ts +1 -0
  12. package/dist/lib/full-name.d.ts +71 -0
  13. package/dist/lib/full-name.js +147 -0
  14. package/dist/lib/full-name.js.map +1 -0
  15. package/dist/lib/index.d.ts +16 -6
  16. package/dist/lib/index.js +29 -8
  17. package/dist/lib/index.js.map +1 -1
  18. package/dist/lib/name.d.ts +177 -0
  19. package/dist/lib/name.js +322 -0
  20. package/dist/lib/name.js.map +1 -0
  21. package/dist/lib/namefully.d.ts +285 -208
  22. package/dist/lib/namefully.js +576 -576
  23. package/dist/lib/namefully.js.map +1 -1
  24. package/dist/lib/parser.d.ts +46 -0
  25. package/dist/lib/parser.js +173 -0
  26. package/dist/lib/parser.js.map +1 -0
  27. package/dist/lib/src/config.d.ts +121 -0
  28. package/dist/lib/src/constants.d.ts +4 -0
  29. package/dist/lib/src/error.d.ts +172 -0
  30. package/dist/lib/src/full-name.d.ts +71 -0
  31. package/dist/lib/src/index.d.ts +20 -0
  32. package/dist/lib/src/name.d.ts +177 -0
  33. package/dist/lib/src/namefully.d.ts +379 -0
  34. package/dist/lib/src/parser.d.ts +46 -0
  35. package/dist/lib/src/types.d.ts +127 -0
  36. package/dist/lib/src/utils.d.ts +63 -0
  37. package/dist/lib/src/validator.d.ts +66 -0
  38. package/dist/lib/types.d.ts +127 -0
  39. package/dist/lib/types.js +181 -0
  40. package/dist/lib/types.js.map +1 -0
  41. package/dist/lib/utils.d.ts +63 -0
  42. package/dist/lib/utils.js +138 -0
  43. package/dist/lib/utils.js.map +1 -0
  44. package/dist/lib/validator.d.ts +66 -0
  45. package/dist/lib/validator.js +332 -0
  46. package/dist/lib/validator.js.map +1 -0
  47. package/dist/umd/namefully.js +2118 -2700
  48. package/dist/umd/namefully.js.map +1 -1
  49. package/dist/umd/namefully.min.js +1 -1
  50. package/dist/umd/namefully.min.js.LICENSE.txt +1 -18
  51. package/dist/umd/namefully.min.js.map +1 -1
  52. package/package.json +50 -54
  53. package/readme.md +132 -162
  54. package/changelog.md +0 -134
  55. package/dist/lib/core/constants.d.ts +0 -48
  56. package/dist/lib/core/constants.js +0 -101
  57. package/dist/lib/core/constants.js.map +0 -1
  58. package/dist/lib/core/core.d.ts +0 -17
  59. package/dist/lib/core/core.js +0 -24
  60. package/dist/lib/core/core.js.map +0 -1
  61. package/dist/lib/core/index.d.ts +0 -9
  62. package/dist/lib/core/index.js +0 -13
  63. package/dist/lib/core/index.js.map +0 -1
  64. package/dist/lib/core/parsers/array-name.parser.d.ts +0 -41
  65. package/dist/lib/core/parsers/array-name.parser.js +0 -86
  66. package/dist/lib/core/parsers/array-name.parser.js.map +0 -1
  67. package/dist/lib/core/parsers/array-string.parser.d.ts +0 -47
  68. package/dist/lib/core/parsers/array-string.parser.js +0 -95
  69. package/dist/lib/core/parsers/array-string.parser.js.map +0 -1
  70. package/dist/lib/core/parsers/index.d.ts +0 -11
  71. package/dist/lib/core/parsers/index.js +0 -11
  72. package/dist/lib/core/parsers/index.js.map +0 -1
  73. package/dist/lib/core/parsers/nama.parser.d.ts +0 -33
  74. package/dist/lib/core/parsers/nama.parser.js +0 -74
  75. package/dist/lib/core/parsers/nama.parser.js.map +0 -1
  76. package/dist/lib/core/parsers/parser.d.ts +0 -28
  77. package/dist/lib/core/parsers/parser.js +0 -3
  78. package/dist/lib/core/parsers/parser.js.map +0 -1
  79. package/dist/lib/core/parsers/string.parser.d.ts +0 -60
  80. package/dist/lib/core/parsers/string.parser.js +0 -62
  81. package/dist/lib/core/parsers/string.parser.js.map +0 -1
  82. package/dist/lib/core/utils.d.ts +0 -52
  83. package/dist/lib/core/utils.js +0 -178
  84. package/dist/lib/core/utils.js.map +0 -1
  85. package/dist/lib/models/enums.d.ts +0 -106
  86. package/dist/lib/models/enums.js +0 -114
  87. package/dist/lib/models/enums.js.map +0 -1
  88. package/dist/lib/models/firstname.d.ts +0 -77
  89. package/dist/lib/models/firstname.js +0 -131
  90. package/dist/lib/models/firstname.js.map +0 -1
  91. package/dist/lib/models/fullname.d.ts +0 -73
  92. package/dist/lib/models/fullname.js +0 -99
  93. package/dist/lib/models/fullname.js.map +0 -1
  94. package/dist/lib/models/index.d.ts +0 -13
  95. package/dist/lib/models/index.js +0 -16
  96. package/dist/lib/models/index.js.map +0 -1
  97. package/dist/lib/models/lastname.d.ts +0 -80
  98. package/dist/lib/models/lastname.js +0 -157
  99. package/dist/lib/models/lastname.js.map +0 -1
  100. package/dist/lib/models/misc.d.ts +0 -108
  101. package/dist/lib/models/misc.js +0 -3
  102. package/dist/lib/models/misc.js.map +0 -1
  103. package/dist/lib/models/name.d.ts +0 -76
  104. package/dist/lib/models/name.js +0 -115
  105. package/dist/lib/models/name.js.map +0 -1
  106. package/dist/lib/models/summary.d.ts +0 -26
  107. package/dist/lib/models/summary.js +0 -61
  108. package/dist/lib/models/summary.js.map +0 -1
  109. package/dist/lib/validators/array-name.validator.d.ts +0 -25
  110. package/dist/lib/validators/array-name.validator.js +0 -75
  111. package/dist/lib/validators/array-name.validator.js.map +0 -1
  112. package/dist/lib/validators/array-string.validator.d.ts +0 -43
  113. package/dist/lib/validators/array-string.validator.js +0 -76
  114. package/dist/lib/validators/array-string.validator.js.map +0 -1
  115. package/dist/lib/validators/common/validation-error.d.ts +0 -19
  116. package/dist/lib/validators/common/validation-error.js +0 -26
  117. package/dist/lib/validators/common/validation-error.js.map +0 -1
  118. package/dist/lib/validators/common/validation-rule.d.ts +0 -72
  119. package/dist/lib/validators/common/validation-rule.js +0 -76
  120. package/dist/lib/validators/common/validation-rule.js.map +0 -1
  121. package/dist/lib/validators/common/validation-type.d.ts +0 -24
  122. package/dist/lib/validators/common/validation-type.js +0 -28
  123. package/dist/lib/validators/common/validation-type.js.map +0 -1
  124. package/dist/lib/validators/firstname.validator.d.ts +0 -20
  125. package/dist/lib/validators/firstname.validator.js +0 -29
  126. package/dist/lib/validators/firstname.validator.js.map +0 -1
  127. package/dist/lib/validators/fullname.validator.d.ts +0 -21
  128. package/dist/lib/validators/fullname.validator.js +0 -38
  129. package/dist/lib/validators/fullname.validator.js.map +0 -1
  130. package/dist/lib/validators/index.d.ts +0 -21
  131. package/dist/lib/validators/index.js +0 -35
  132. package/dist/lib/validators/index.js.map +0 -1
  133. package/dist/lib/validators/lastname.validator.d.ts +0 -20
  134. package/dist/lib/validators/lastname.validator.js +0 -29
  135. package/dist/lib/validators/lastname.validator.js.map +0 -1
  136. package/dist/lib/validators/middlename.validator.d.ts +0 -20
  137. package/dist/lib/validators/middlename.validator.js +0 -38
  138. package/dist/lib/validators/middlename.validator.js.map +0 -1
  139. package/dist/lib/validators/nama.validator.d.ts +0 -21
  140. package/dist/lib/validators/nama.validator.js +0 -44
  141. package/dist/lib/validators/nama.validator.js.map +0 -1
  142. package/dist/lib/validators/namon.validator.d.ts +0 -20
  143. package/dist/lib/validators/namon.validator.js +0 -29
  144. package/dist/lib/validators/namon.validator.js.map +0 -1
  145. package/dist/lib/validators/prefix.validator.d.ts +0 -14
  146. package/dist/lib/validators/prefix.validator.js +0 -31
  147. package/dist/lib/validators/prefix.validator.js.map +0 -1
  148. package/dist/lib/validators/string-name.validator.d.ts +0 -20
  149. package/dist/lib/validators/string-name.validator.js +0 -29
  150. package/dist/lib/validators/string-name.validator.js.map +0 -1
  151. package/dist/lib/validators/suffix.validator.d.ts +0 -14
  152. package/dist/lib/validators/suffix.validator.js +0 -31
  153. package/dist/lib/validators/suffix.validator.js.map +0 -1
  154. package/dist/lib/validators/validator.d.ts +0 -13
  155. package/dist/lib/validators/validator.js +0 -9
  156. package/dist/lib/validators/validator.js.map +0 -1
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var array_name_parser_1 = require("./array-name.parser");
4
- exports.ArrayNameParser = array_name_parser_1.default;
5
- var array_string_parser_1 = require("./array-string.parser");
6
- exports.ArrayStringParser = array_string_parser_1.default;
7
- var nama_parser_1 = require("./nama.parser");
8
- exports.NamaParser = nama_parser_1.default;
9
- var string_parser_1 = require("./string.parser");
10
- exports.StringParser = string_parser_1.default;
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/parsers/index.ts"],"names":[],"mappings":";;AAOA,yDAAiE;AAAxD,8CAAA,OAAO,CAAmB;AACnC,6DAAqE;AAA5D,kDAAA,OAAO,CAAqB;AACrC,6CAAsD;AAA7C,mCAAA,OAAO,CAAc;AAC9B,iDAA0D;AAAjD,uCAAA,OAAO,CAAgB"}
@@ -1,33 +0,0 @@
1
- /**
2
- * A `Nama` (JSON signature) parser
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Nama, Fullname } from '../../models/index';
8
- import { Parser } from './parser';
9
- /**
10
- * Represents a `Nama` parser
11
- * @class
12
- * @implements {Parser<Nama>}
13
- *
14
- * This parser parses a JSON signature of the name parts provided as string
15
- * values. This is to facilitate a developer's life that holds users' info in a
16
- * JSON format. In other words, the developer only needs to provide similar info
17
- * and the rest will follow.
18
- */
19
- export default class NamaParser implements Parser<Nama> {
20
- raw: Nama;
21
- /**
22
- * Create a parser ready to parse the raw data
23
- * @param {Nama} raw data as JSON object
24
- */
25
- constructor(raw: Nama);
26
- /**
27
- * Parses the raw data into a full name
28
- */
29
- parse(options: {
30
- bypass: boolean;
31
- }): Fullname;
32
- private distribute;
33
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * A `Nama` (JSON signature) parser
5
- *
6
- * Created on March 15, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const index_1 = require("../../models/index");
10
- const index_2 = require("../../validators/index");
11
- /**
12
- * Represents a `Nama` parser
13
- * @class
14
- * @implements {Parser<Nama>}
15
- *
16
- * This parser parses a JSON signature of the name parts provided as string
17
- * values. This is to facilitate a developer's life that holds users' info in a
18
- * JSON format. In other words, the developer only needs to provide similar info
19
- * and the rest will follow.
20
- */
21
- class NamaParser {
22
- /**
23
- * Create a parser ready to parse the raw data
24
- * @param {Nama} raw data as JSON object
25
- */
26
- constructor(raw) {
27
- this.raw = raw;
28
- }
29
- /**
30
- * Parses the raw data into a full name
31
- */
32
- parse(options) {
33
- // validate first
34
- if (!options.bypass)
35
- new index_2.NamaValidator().validate(this.raw);
36
- // then distribute all the elements accordingly
37
- const fullname = this.distribute();
38
- // finally return high quality of data
39
- return fullname;
40
- }
41
- distribute() {
42
- const fullname = {
43
- firstname: null,
44
- lastname: null,
45
- middlename: [],
46
- prefix: null,
47
- suffix: null,
48
- };
49
- for (const entry of Object.entries(this.raw)) {
50
- const key = entry[0];
51
- const value = entry[1];
52
- switch (key) {
53
- case index_1.Namon.FIRST_NAME:
54
- fullname.firstname = new index_1.Firstname(value);
55
- break;
56
- case index_1.Namon.LAST_NAME:
57
- fullname.lastname = new index_1.Lastname(value);
58
- break;
59
- case index_1.Namon.MIDDLE_NAME:
60
- fullname.middlename.push(new index_1.Name(value, index_1.Namon.MIDDLE_NAME));
61
- break;
62
- case index_1.Namon.PREFIX:
63
- fullname.prefix = value;
64
- break;
65
- case index_1.Namon.SUFFIX:
66
- fullname.suffix = value;
67
- break;
68
- }
69
- }
70
- return fullname;
71
- }
72
- }
73
- exports.default = NamaParser;
74
- //# sourceMappingURL=nama.parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nama.parser.js","sourceR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WAAW,CAAC,CAAC,CAAC;oBAC7D,MAAM;gBACV,KAAK,aAAK,CAAC,MAAM;oBACb,QAAQ,CAAC,MAAM,GAAG,KAAe,CAAC;oBAClC,MAAM;gBACV,KAAK,aAAK,CAAC,MAAM;oBACb,QAAQ,CAAC,MAAM,GAAG,KAAe,CAAC;oBAClC,MAAM;aACb;SACJ;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AAtDD,6BAsDC"}
@@ -1,28 +0,0 @@
1
- /**
2
- * A `Parser` contract
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Fullname, Separator, NameOrder, LastnameFormat } from '../../models/index';
8
- /**
9
- * Interface for JSON signature that represents a generic parser
10
- * @interface
11
- */
12
- export interface Parser<T> {
13
- /**
14
- * raw data to be parsed
15
- * @type {T}
16
- */
17
- raw: T;
18
- /**
19
- * Parses the raw data into a full name
20
- * @param {Config} [options]
21
- */
22
- parse(options?: Partial<{
23
- orderedBy: NameOrder;
24
- separator: Separator;
25
- bypass: boolean;
26
- lastnameFormat: LastnameFormat;
27
- }>): Fullname;
28
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../../src/core/parsers/parser.ts"],"names":[],"mappings":""}
@@ -1,60 +0,0 @@
1
- /**
2
- * A string parser
3
- *
4
- * Created on March 15, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { Separator, Fullname, NameOrder } from '../../models/index';
8
- import { Parser } from './index';
9
- /**
10
- * Represents a string parser
11
- * @class
12
- * @implements {Parser}
13
- * @classdesc
14
- * This parser parses a string name using a separator, if set, or simply using
15
- * the space character <' '> as a basis for the split.
16
- *
17
- * **NOTE**:
18
- * A string name is basically a string type containing the name parts differentiated
19
- * with the help of a separator. The default separator is the character <space>
20
- * or <' '>. However, it can be very, very helpful to use a distinct separator
21
- * (e.g., a colon <:>) to handle multiple names for a `Namon`. That is to say,
22
- * a piece of name shaped as `De La Cruz` is a last name that needs to be handled
23
- * as a whole, and therefore requires that a different type of separator to split
24
- * up the name parts. Alternatively, the `ArrayStringParser` can be used by indicating
25
- * specifically which part of the name is what. Do note that this parser is actually
26
- * a wrapper of the `ArrayStringParser`.
27
- *
28
- * @example
29
- * Given the name `Maria De La Cruz`, using this parser without indicating a
30
- * separator different than <space> will definitely throw an error. So, if the proper
31
- * proper of doing when `De La Cruz` is the last name:
32
- * ```
33
- * > const name = new Namefully('Maria:De La Cruz', { separator: Separator.COLON })
34
- * > console.log(name.getLastname())
35
- * De La Cruz
36
- * ```
37
- * Or
38
- * ```
39
- * > const name = new Namefully(['Maria', 'De La Cruz'])
40
- * > console.log(name.getLastname())
41
- * De La Cruz
42
- * ```
43
- */
44
- export default class StringParser implements Parser<string> {
45
- raw: string;
46
- /**
47
- * Create a parser ready to parse the raw data
48
- * @param {string} raw data as a string representation
49
- */
50
- constructor(raw: string);
51
- /**
52
- * Parses the raw data into a full name
53
- * @param options how to parse
54
- */
55
- parse(options: {
56
- orderedBy: NameOrder;
57
- separator: Separator;
58
- bypass: boolean;
59
- }): Fullname;
60
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("./index");
4
- /**
5
- * Represents a string parser
6
- * @class
7
- * @implements {Parser}
8
- * @classdesc
9
- * This parser parses a string name using a separator, if set, or simply using
10
- * the space character <' '> as a basis for the split.
11
- *
12
- * **NOTE**:
13
- * A string name is basically a string type containing the name parts differentiated
14
- * with the help of a separator. The default separator is the character <space>
15
- * or <' '>. However, it can be very, very helpful to use a distinct separator
16
- * (e.g., a colon <:>) to handle multiple names for a `Namon`. That is to say,
17
- * a piece of name shaped as `De La Cruz` is a last name that needs to be handled
18
- * as a whole, and therefore requires that a different type of separator to split
19
- * up the name parts. Alternatively, the `ArrayStringParser` can be used by indicating
20
- * specifically which part of the name is what. Do note that this parser is actually
21
- * a wrapper of the `ArrayStringParser`.
22
- *
23
- * @example
24
- * Given the name `Maria De La Cruz`, using this parser without indicating a
25
- * separator different than <space> will definitely throw an error. So, if the proper
26
- * proper of doing when `De La Cruz` is the last name:
27
- * ```
28
- * > const name = new Namefully('Maria:De La Cruz', { separator: Separator.COLON })
29
- * > console.log(name.getLastname())
30
- * De La Cruz
31
- * ```
32
- * Or
33
- * ```
34
- * > const name = new Namefully(['Maria', 'De La Cruz'])
35
- * > console.log(name.getLastname())
36
- * De La Cruz
37
- * ```
38
- */
39
- class StringParser {
40
- /**
41
- * Create a parser ready to parse the raw data
42
- * @param {string} raw data as a string representation
43
- */
44
- constructor(raw) {
45
- this.raw = raw;
46
- }
47
- /**
48
- * Parses the raw data into a full name
49
- * @param options how to parse
50
- */
51
- parse(options) {
52
- // given this setting
53
- const { orderedBy, separator, bypass } = options;
54
- // then distribute all the elements accordingly
55
- const nama = this.raw.split(separator);
56
- const fullname = new index_1.ArrayStringParser(nama).parse({ orderedBy, bypass });
57
- // finally return high quality of data
58
- return fullname;
59
- }
60
- }
61
- exports.default = StringParser;
62
- //# sourceMappingURL=string.parser.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"string.parser.js","sourceRoot":"","sources":["../../../../src/core/parsers/string.parser.ts"],"names":[],"mappings":";;AAOA,mCAAoD;AAGpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAqB,YAAY;IAE7B;;;OAGG;IACH,YAAmB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAElC;;;OAGG;IACH,KAAK,CAAC,OAIL;QAEG,qBAAqB;QACrB,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEjD,+CAA+C;QAC/C,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,yBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QAE1E,sCAAsC;QACtC,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ;AA5BD,+BA4BC"}
@@ -1,52 +0,0 @@
1
- /**
2
- * Utils for the core functionalities of `Namefully`
3
- *
4
- * Created on March 16, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- import { NameIndex, NameOrder, NameType } from '../models';
8
- /**
9
- * Capitalizes a string
10
- * @param str string value
11
- * @param {'initial' | 'all'} [option] how to capitalize it
12
- */
13
- export declare function capitalize(str: string, option?: 'initial' | 'all'): string;
14
- /**
15
- * De-capitalizes a string
16
- * @param str string value
17
- * @param {'initial' | 'all'} [option] how to decapitalize it
18
- */
19
- export declare function decapitalize(str: string, option?: 'initial' | 'all'): string;
20
- /**
21
- * Toggles a string representation
22
- * @param str string value to toggle
23
- */
24
- export declare function toggleCase(str: string): string;
25
- /**
26
- * Reorganizes the existing global indexes for array of name parts
27
- * @param orderedBy by first or last name
28
- * @param argLength length of the provided array
29
- * @param nameIndex global preset of indexing
30
- */
31
- export declare function organizeNameIndex(orderedBy: NameOrder, argLength: number, nameIndex?: NameIndex): NameIndex;
32
- /**
33
- * Makes it easy to manipulate shortcuts for this `NameType`
34
- * @param type name type
35
- */
36
- export declare function allowShortNameType(type: NameType): NameType;
37
- /**
38
- * Makes it easy to manipulate shortcuts for this `NameOrder`
39
- * @param type name type
40
- */
41
- export declare function allowShortNameOrder(type: NameOrder): NameOrder;
42
- /**
43
- * Converts to ascii characters (using UTF-16)
44
- * @param str string content
45
- * @param restrictions unneeded content to skip
46
- */
47
- export declare function convertToAscii(str: string, restrictions?: string[]): number[];
48
- /**
49
- * Generates a password
50
- * @param str string content
51
- */
52
- export declare function generatePassword(str: string): string;
@@ -1,178 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * Utils for the core functionalities of `Namefully`
5
- *
6
- * Created on March 16, 2020
7
- * @author Ralph Florent <ralflornt@gmail.com>
8
- */
9
- const models_1 = require("../models");
10
- const core_1 = require("../core");
11
- /**
12
- * Capitalizes a string
13
- * @param str string value
14
- * @param {'initial' | 'all'} [option] how to capitalize it
15
- */
16
- function capitalize(str, option = 'initial') {
17
- if (!str)
18
- return '';
19
- const initial = str[0].toUpperCase();
20
- const rest = str.slice(1).toLowerCase();
21
- return option === 'initial' ? initial.concat(rest) : str.toUpperCase();
22
- }
23
- exports.capitalize = capitalize;
24
- /**
25
- * De-capitalizes a string
26
- * @param str string value
27
- * @param {'initial' | 'all'} [option] how to decapitalize it
28
- */
29
- function decapitalize(str, option = 'initial') {
30
- if (!str)
31
- return '';
32
- const initial = str[0].toLowerCase();
33
- const rest = str.slice(1);
34
- return option === 'initial' ? initial.concat(rest) : str.toLowerCase();
35
- }
36
- exports.decapitalize = decapitalize;
37
- /**
38
- * Toggles a string representation
39
- * @param str string value to toggle
40
- */
41
- function toggleCase(str) {
42
- const chars = [];
43
- for (const c of str) {
44
- if (c === c.toUpperCase()) {
45
- chars.push(c.toLowerCase());
46
- }
47
- else {
48
- chars.push(c.toUpperCase());
49
- }
50
- }
51
- return chars.join(models_1.Separator.EMPTY);
52
- }
53
- exports.toggleCase = toggleCase;
54
- /**
55
- * Reorganizes the existing global indexes for array of name parts
56
- * @param orderedBy by first or last name
57
- * @param argLength length of the provided array
58
- * @param nameIndex global preset of indexing
59
- */
60
- function organizeNameIndex(orderedBy, argLength, nameIndex = core_1.NAME_INDEX) {
61
- const out = Object.assign({}, nameIndex);
62
- if (orderedBy === 'firstname') {
63
- switch (argLength) {
64
- case core_1.FIRST_LAST_NAME_INDEX: // first name + last name
65
- out.firstname = 0;
66
- out.lastname = 1;
67
- break;
68
- case core_1.FIRST_MIDDLE_LAST_NAME_INDEX: // first name + middle name + last name
69
- out.firstname = 0;
70
- out.middlename = 1;
71
- out.lastname = 2;
72
- break;
73
- case core_1.PREFIX_FIRST_MIDDLE_LAST_NAME_INDEX: // prefix + first name + middle name + last name
74
- out.prefix = 0;
75
- out.firstname = 1;
76
- out.middlename = 2;
77
- out.lastname = 3;
78
- break;
79
- case core_1.PREFIX_FIRST_MIDDLE_LAST_SUFFIX_NAME_INDEX: // prefix + first name + middle name + last name + suffix
80
- out.prefix = 0;
81
- out.firstname = 1;
82
- out.middlename = 2;
83
- out.lastname = 3;
84
- out.suffix = 4;
85
- break;
86
- }
87
- }
88
- else {
89
- switch (argLength) {
90
- case core_1.LAST_FIRST_NAME_INDEX: // last name + first name
91
- out.lastname = 0;
92
- out.firstname = 1;
93
- break;
94
- case core_1.LAST_FIRST_MIDDLE_NAME_INDEX: // last name + first name + middle name
95
- out.lastname = 0;
96
- out.firstname = 1;
97
- out.middlename = 2;
98
- break;
99
- case core_1.PREFIX_LAST_FIRST_MIDDLE_NAME_INDEX: // prefix + last name + first name + middle name
100
- out.prefix = 0;
101
- out.lastname = 1;
102
- out.firstname = 2;
103
- out.middlename = 3;
104
- break;
105
- case core_1.PREFIX_LAST_FIRST_MIDDLE_SUFFIX_NAME_INDEX: // prefix + last name + first name + middle name + suffix
106
- out.prefix = 0;
107
- out.lastname = 1;
108
- out.firstname = 2;
109
- out.middlename = 3;
110
- out.suffix = 4;
111
- break;
112
- }
113
- }
114
- return out;
115
- }
116
- exports.organizeNameIndex = organizeNameIndex;
117
- /**
118
- * Makes it easy to manipulate shortcuts for this `NameType`
119
- * @param type name type
120
- */
121
- function allowShortNameType(type) {
122
- switch (type) {
123
- case 'firstname':
124
- case 'fn': return 'firstname';
125
- case 'lastname':
126
- case 'ln': return 'lastname';
127
- case 'middlename':
128
- case 'mn': return 'middlename';
129
- default:
130
- return type;
131
- }
132
- }
133
- exports.allowShortNameType = allowShortNameType;
134
- /**
135
- * Makes it easy to manipulate shortcuts for this `NameOrder`
136
- * @param type name type
137
- */
138
- function allowShortNameOrder(type) {
139
- switch (type) {
140
- case 'firstname':
141
- case 'fn': return 'firstname';
142
- case 'lastname':
143
- case 'ln': return 'lastname';
144
- default:
145
- return type;
146
- }
147
- }
148
- exports.allowShortNameOrder = allowShortNameOrder;
149
- /**
150
- * Converts to ascii characters (using UTF-16)
151
- * @param str string content
152
- * @param restrictions unneeded content to skip
153
- */
154
- function convertToAscii(str, restrictions = [...core_1.RESTRICTED_CHARS]) {
155
- return str
156
- .split(models_1.Separator.EMPTY)
157
- .filter(c => restrictions.indexOf(c) === -1)
158
- .map(c => c.charCodeAt(0));
159
- }
160
- exports.convertToAscii = convertToAscii;
161
- /**
162
- * Generates a password
163
- * @param str string content
164
- */
165
- function generatePassword(str) {
166
- const mapper = core_1.PASSWORD_MAPPER;
167
- const password = str
168
- .split(models_1.Separator.EMPTY)
169
- .map(char => {
170
- if (mapper.has(char.toLowerCase()))
171
- return mapper.get(char.toLowerCase()).random();
172
- return mapper.get('$').random();
173
- })
174
- .join(models_1.Separator.EMPTY);
175
- return password;
176
- }
177
- exports.generatePassword = generatePassword;
178
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/core/utils.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,sCAAsE;AACtE,kCAYiB;AAEjB;;;;GAIG;AACH,SAAgB,UAAU,CAAC,GAAW,EAAE,SAA4B,SAAS;IACzE,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,MAAM,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACxC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;AAC3E,CAAC;AALD,gC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wCAQC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,GAAW;IACxC,MAAM,MAAM,GAAG,sBAAe,CAAC;IAE/B,MAAM,QAAQ,GAAG,GAAG;SACf,KAAK,CAAC,kBAAS,CAAC,KAAK,CAAC;SACtB,GAAG,CAAC,IAAI,CAAC,EAAE;QACR,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;QACnD,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC,CAAC;SACD,IAAI,CAAC,kBAAS,CAAC,KAAK,CAAC,CAAC;IAC3B,OAAO,QAAQ,CAAC;AACpB,CAAC;AAZD,4CAYC"}
@@ -1,106 +0,0 @@
1
- /**
2
- * All the enums are listed here
3
- *
4
- * Created on March 06, 2020
5
- * @author Ralph Florent <ralflornt@gmail.com>
6
- */
7
- /**
8
- * Enum `Namon` contains the finite set of a representative piece of a name
9
- * @readonly
10
- * @enum {string}
11
- * The word `Namon` is the singular form used to refer to a chunk|part|piece of
12
- * a name. And the plural form is `Nama`. (Same idea as in criterion/criteria)
13
- */
14
- export declare enum Namon {
15
- PREFIX = "prefix",
16
- LAST_NAME = "lastname",
17
- MIDDLE_NAME = "middlename",
18
- FIRST_NAME = "firstname",
19
- SUFFIX = "suffix"
20
- }
21
- /**
22
- * Enum `Alphabet` for the list of writing systems
23
- * @readonly
24
- * @enum {string}
25
- */
26
- export declare enum Alphabet {
27
- LATIN = "Latin",
28
- CYRILLIC = "Cyrillic",
29
- GREEK = "Greek",
30
- ARMENIAN = "Armenian",
31
- GEORGIAN = "Georgian",
32
- HANGUL = "Hangul"
33
- }
34
- /**
35
- * Enum for the prefix values
36
- * @readonly
37
- * @enum {string}
38
- * American and Canadian English follow slightly different rules for abbreviated
39
- * titles than British and Australian English. In North American English, titles
40
- * before a name require a period: `Mr., Mrs., Ms., Dr.` In British and Australian
41
- * English, no full stops are used in these abbreviations.
42
- */
43
- export declare enum Prefix {
44
- FIRT_LIEUTENANT = "1st Lt",
45
- ADMIRAL = "Adm",
46
- ATTORNEY = "Atty",
47
- BROTHER = "Brother",
48
- CAPTAIN = "Capt",
49
- CHIEF = "Chief",
50
- COMMANDER = "Cmdr",
51
- COLONEL = "Col",
52
- UNI_DEAN = "Dean",
53
- DOCTOR = "Dr",
54
- ELDER = "Elder",
55
- FATHER = "Father",
56
- GENERAL = "Gen",
57
- HONORABLE = "Hon",
58
- LIEUTENANT_COLONEL = "Lt Col",
59
- MAJOR = "Maj",
60
- MASTER_SERGEANT = "MSgt",
61
- MISTER = "Mr",
62
- MARRIED_WOMAN = "Mrs",
63
- SINGLE_WOMAN = "Ms",
64
- PRINCE = "Prince",
65
- PROFESSOR = "Prof",
66
- RABBI = "Rabbi",
67
- REVEREND = "Rev",
68
- SISTER = "Sister"
69
- }
70
- /**
71
- * Enum for the suffix values
72
- * @readonly
73
- * @enum {string}
74
- */
75
- export declare enum Suffix {
76
- THE_SECOND = "II",
77
- THE_THIRD = "III",
78
- THE_FOURTH = "IV",
79
- CERT_PUB_ACCOUNTANT = "CPA",
80
- DOCTOR_DENTAL_MED = "DDS",
81
- ESQUIRE = "Esq",
82
- JURIST_DOCTOR = "JD",
83
- JUNIOR = "Jr",
84
- DOCTOR_OF_LAWS = "LLD",
85
- DOCTORATE = "PhD",
86
- RETIRED_ARMED_FORCES = "Ret",
87
- REGISTERED_NURSE = "RN",
88
- SENIOR = "Sr",
89
- DOCTOR_OF_OSTEO = "DO"
90
- }
91
- /**
92
- * Enum for the separator values representing some of the ASCII characters
93
- * @readonly
94
- * @enum {string}
95
- */
96
- export declare enum Separator {
97
- COLON = ":",
98
- COMMA = ",",
99
- EMPTY = "",
100
- HYPHEN = "-",
101
- PERIOD = ".",
102
- SPACE = " ",
103
- SINGLE_QUOTE = "'",
104
- DOUBLE_QUOTE = "\"",
105
- UNDERSCORE = "_"
106
- }