proto-toolkit 1.0.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 ADDED
File without changes
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ function mask() {
4
+ const str = this.trim();
5
+
6
+ if (str.length <= 4) {
7
+ return str;
8
+ }
9
+
10
+ const start = str.slice(0, 2);
11
+ const end = str.slice(-2);
12
+ const middleLength = str.length - 4;
13
+
14
+ return start + '*'.repeat(middleLength) + end;
15
+ }
16
+
17
+
18
+ if (!String.prototype.mask) {
19
+ String.prototype.mask = mask;
20
+ }
21
+
22
+ function toAbbreviatedName() {
23
+ const fullName = this;
24
+
25
+ if (typeof fullName !== 'string') {
26
+ throw new TypeError('Input must be a string');
27
+ }
28
+
29
+ const parts = fullName.trim().split(/\s+/).filter(Boolean);
30
+
31
+ if (parts.length === 0) return '';
32
+
33
+ if (parts.length === 1) {
34
+ return capitalize(parts[0]);
35
+ }
36
+
37
+ const lastName = parts.pop();
38
+
39
+ const initials = parts.map((name) => name[0].toUpperCase() + '.');
40
+
41
+ return `${initials.join(' ')} ${capitalize(lastName)}`;
42
+ }
43
+
44
+ function capitalize(word) {
45
+ return word[0].toUpperCase() + word.slice(1).toLowerCase();
46
+ }
47
+
48
+ if (!String.prototype.toAbbreviatedName) {
49
+ String.prototype.toAbbreviatedName = toAbbreviatedName;
50
+ }
@@ -0,0 +1,48 @@
1
+ function mask() {
2
+ const str = this.trim();
3
+
4
+ if (str.length <= 4) {
5
+ return str;
6
+ }
7
+
8
+ const start = str.slice(0, 2);
9
+ const end = str.slice(-2);
10
+ const middleLength = str.length - 4;
11
+
12
+ return start + '*'.repeat(middleLength) + end;
13
+ }
14
+
15
+
16
+ if (!String.prototype.mask) {
17
+ String.prototype.mask = mask;
18
+ }
19
+
20
+ function toAbbreviatedName() {
21
+ const fullName = this;
22
+
23
+ if (typeof fullName !== 'string') {
24
+ throw new TypeError('Input must be a string');
25
+ }
26
+
27
+ const parts = fullName.trim().split(/\s+/).filter(Boolean);
28
+
29
+ if (parts.length === 0) return '';
30
+
31
+ if (parts.length === 1) {
32
+ return capitalize(parts[0]);
33
+ }
34
+
35
+ const lastName = parts.pop();
36
+
37
+ const initials = parts.map((name) => name[0].toUpperCase() + '.');
38
+
39
+ return `${initials.join(' ')} ${capitalize(lastName)}`;
40
+ }
41
+
42
+ function capitalize(word) {
43
+ return word[0].toUpperCase() + word.slice(1).toLowerCase();
44
+ }
45
+
46
+ if (!String.prototype.toAbbreviatedName) {
47
+ String.prototype.toAbbreviatedName = toAbbreviatedName;
48
+ }
@@ -0,0 +1,55 @@
1
+ (function (factory) {
2
+ typeof define === 'function' && define.amd ? define(factory) :
3
+ factory();
4
+ })((function () { 'use strict';
5
+
6
+ function mask() {
7
+ const str = this.trim();
8
+
9
+ if (str.length <= 4) {
10
+ return str;
11
+ }
12
+
13
+ const start = str.slice(0, 2);
14
+ const end = str.slice(-2);
15
+ const middleLength = str.length - 4;
16
+
17
+ return start + '*'.repeat(middleLength) + end;
18
+ }
19
+
20
+
21
+ if (!String.prototype.mask) {
22
+ String.prototype.mask = mask;
23
+ }
24
+
25
+ function toAbbreviatedName() {
26
+ const fullName = this;
27
+
28
+ if (typeof fullName !== 'string') {
29
+ throw new TypeError('Input must be a string');
30
+ }
31
+
32
+ const parts = fullName.trim().split(/\s+/).filter(Boolean);
33
+
34
+ if (parts.length === 0) return '';
35
+
36
+ if (parts.length === 1) {
37
+ return capitalize(parts[0]);
38
+ }
39
+
40
+ const lastName = parts.pop();
41
+
42
+ const initials = parts.map((name) => name[0].toUpperCase() + '.');
43
+
44
+ return `${initials.join(' ')} ${capitalize(lastName)}`;
45
+ }
46
+
47
+ function capitalize(word) {
48
+ return word[0].toUpperCase() + word.slice(1).toLowerCase();
49
+ }
50
+
51
+ if (!String.prototype.toAbbreviatedName) {
52
+ String.prototype.toAbbreviatedName = toAbbreviatedName;
53
+ }
54
+
55
+ }));
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "proto-toolkit",
3
+ "version": "1.0.0",
4
+ "description": "A lightweight JavaScript utility toolkit",
5
+ "type": "module",
6
+ "main": "dist/proto-toolkit.cjs.js",
7
+ "module": "dist/proto-toolkit.esm.js",
8
+ "browser": "dist/proto-toolkit.umd.js",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "build": "rollup -c"
14
+ },
15
+ "keywords": [
16
+ "javascript",
17
+ "utility",
18
+ "toolkit",
19
+ "helpers"
20
+ ],
21
+ "author": "Kousik Chowdhury",
22
+ "license": "MIT",
23
+ "devDependencies": {
24
+ "rollup": "^4.59.0"
25
+ }
26
+ }