@mhmdhammoud/meritt-utils 1.0.4 → 1.0.6
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/ReleaseNotes.md +17 -2
- package/dist/lib/cypto.js +1 -1
- package/dist/lib/formatter.d.ts +12 -0
- package/dist/lib/formatter.js +31 -3
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +3 -1
- package/dist/lib/pdf.d.ts +15 -0
- package/dist/lib/pdf.js +27 -0
- package/dist/utilities/axios.d.ts +2 -0
- package/dist/utilities/axios.js +8 -0
- package/dist/utilities/index.d.ts +1 -0
- package/dist/utilities/index.js +8 -0
- package/package.json +8 -8
- package/src/lib/cypto.ts +1 -1
- package/src/lib/formatter.ts +34 -4
- package/src/lib/index.ts +1 -0
- package/src/lib/pdf.ts +25 -0
- package/src/utilities/axios.ts +4 -0
- package/src/utilities/index.ts +1 -0
package/ReleaseNotes.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## Version 1.0.5
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Added toUpperTitle method that accepts a string and removes all non alphanumeric characters and capitalizes each letter of every first word
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import {Formatter} from '@mhmdhammoud/meritt-utils'
|
|
11
|
+
|
|
12
|
+
// Usage Example
|
|
13
|
+
const sentence:string = "hello__world$$99"
|
|
14
|
+
console.log(Formatter.toUpperTitle(sentence))
|
|
15
|
+
|
|
16
|
+
console : Hello World 99
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
|
|
3
20
|
## Version 1.0.4
|
|
4
21
|
|
|
5
22
|
### Added
|
|
@@ -41,9 +58,7 @@ const slug = Formatter.slugify('My Product Name') // my-product-name
|
|
|
41
58
|
### Fixes and Improvements
|
|
42
59
|
|
|
43
60
|
- Fixed bug in Crypto class where encrypting a string with a key that is not a number would throw an error
|
|
44
|
-
|
|
45
61
|
- Improved Crypto class to allow encrypting and decrypting numbers and objects
|
|
46
|
-
|
|
47
62
|
- Documented Crypto class
|
|
48
63
|
|
|
49
64
|
## Version 1.0.2
|
package/dist/lib/cypto.js
CHANGED
package/dist/lib/formatter.d.ts
CHANGED
|
@@ -28,6 +28,18 @@ declare class Formatter {
|
|
|
28
28
|
* ```
|
|
29
29
|
* */
|
|
30
30
|
obfuscate: (email: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Capitalizes the first letter of each word in a sentence and removes non-alphanumeric characters.
|
|
33
|
+
* @param sentence - The input sentence to be processed.
|
|
34
|
+
* @returns A new sentence with the first letter of each word capitalized and non-alphanumeric characters removed.
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const sentence = 'this is34354345a---sentence'
|
|
38
|
+
* const newSentence = ToUpperTitle(sentence)
|
|
39
|
+
* console.log(newSentence) // 'This Is A Sentence'
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
toUpperTitle: (sentence: string) => string;
|
|
31
43
|
/**
|
|
32
44
|
* @remarks Generates a slug from a given string
|
|
33
45
|
* @param title - string to be converted to slug
|
package/dist/lib/formatter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
/*
|
|
4
|
-
Author : Mhmd Hammoud
|
|
4
|
+
Author : Mhmd Hammoud https://github.com/mhmdhammoud
|
|
5
5
|
Date : 2023-06-17
|
|
6
6
|
Description : String manipulation
|
|
7
7
|
Version : 1.0
|
|
@@ -23,7 +23,8 @@ class Formatter {
|
|
|
23
23
|
if (typeof _ !== 'string')
|
|
24
24
|
throw new Error('Provide a valid string');
|
|
25
25
|
if (withSpacing) {
|
|
26
|
-
return _.
|
|
26
|
+
return _.toLowerCase()
|
|
27
|
+
.split(' ')
|
|
27
28
|
.map((val) => val.charAt(0).toUpperCase() + val.slice(1))
|
|
28
29
|
.join(' ')
|
|
29
30
|
.replace(/ /g, '-')
|
|
@@ -31,7 +32,8 @@ class Formatter {
|
|
|
31
32
|
.replace(/\./g, '');
|
|
32
33
|
}
|
|
33
34
|
else {
|
|
34
|
-
return _.
|
|
35
|
+
return _.toLowerCase()
|
|
36
|
+
.split(' ')
|
|
35
37
|
.map((val) => val.charAt(0).toUpperCase() + val.slice(1))
|
|
36
38
|
.join(' ')
|
|
37
39
|
.replace(/\//g, '-')
|
|
@@ -78,6 +80,32 @@ class Formatter {
|
|
|
78
80
|
email.slice(2, separatorIndex).replace(/./g, '*') +
|
|
79
81
|
email.slice(separatorIndex));
|
|
80
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Capitalizes the first letter of each word in a sentence and removes non-alphanumeric characters.
|
|
85
|
+
* @param sentence - The input sentence to be processed.
|
|
86
|
+
* @returns A new sentence with the first letter of each word capitalized and non-alphanumeric characters removed.
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const sentence = 'this is34354345a---sentence'
|
|
90
|
+
* const newSentence = ToUpperTitle(sentence)
|
|
91
|
+
* console.log(newSentence) // 'This Is A Sentence'
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
this.toUpperTitle = (sentence) => {
|
|
95
|
+
if (typeof sentence !== 'string')
|
|
96
|
+
throw new Error('Provide a valid string');
|
|
97
|
+
if (!sentence)
|
|
98
|
+
throw new Error('Provide a valid string');
|
|
99
|
+
const sanitizedSentence = sentence.replace(/[^a-zA-Z0-9]+/g, ' ');
|
|
100
|
+
const words = sanitizedSentence.split(' ');
|
|
101
|
+
const capitalizedWords = [];
|
|
102
|
+
for (let i = 0; i < words.length; i++) {
|
|
103
|
+
const word = words[i];
|
|
104
|
+
const capitalizedWord = word.charAt(0).toUpperCase() + word.slice(1);
|
|
105
|
+
capitalizedWords.push(capitalizedWord);
|
|
106
|
+
}
|
|
107
|
+
return capitalizedWords.join(' ');
|
|
108
|
+
};
|
|
81
109
|
/**
|
|
82
110
|
* @remarks Generates a slug from a given string
|
|
83
111
|
* @param title - string to be converted to slug
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Formatter = exports.Crypto = void 0;
|
|
6
|
+
exports.Pdf = exports.Formatter = exports.Crypto = void 0;
|
|
7
7
|
var cypto_1 = require("./cypto");
|
|
8
8
|
Object.defineProperty(exports, "Crypto", { enumerable: true, get: function () { return __importDefault(cypto_1).default; } });
|
|
9
9
|
var formatter_1 = require("./formatter");
|
|
10
10
|
Object.defineProperty(exports, "Formatter", { enumerable: true, get: function () { return __importDefault(formatter_1).default; } });
|
|
11
|
+
var formatter_2 = require("./formatter");
|
|
12
|
+
Object.defineProperty(exports, "Pdf", { enumerable: true, get: function () { return __importDefault(formatter_2).default; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare class Pdf {
|
|
2
|
+
/**
|
|
3
|
+
* @remarks Convert image links into base64 format
|
|
4
|
+
* @param url - The image url
|
|
5
|
+
* @returns string
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* pdf.getBase64Images('https://fastly.picsum.photos/id/15/200/300.jpg?hmac=lozQletmrLG9PGBV1hTM1PnmvHxKEU0lAZWu8F2oL30')
|
|
9
|
+
* // => 'Hello-World'
|
|
10
|
+
* ```
|
|
11
|
+
* */
|
|
12
|
+
getBase64Images: (url: string) => string;
|
|
13
|
+
}
|
|
14
|
+
declare const pdf: Pdf;
|
|
15
|
+
export default pdf;
|
package/dist/lib/pdf.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*
|
|
4
|
+
Author : Mustafa Halabi https://github.com/mustafahalabi
|
|
5
|
+
Date : 2023-06-24
|
|
6
|
+
Description : Image to PDF converter
|
|
7
|
+
Version : 1.0
|
|
8
|
+
*/
|
|
9
|
+
class Pdf {
|
|
10
|
+
constructor() {
|
|
11
|
+
/**
|
|
12
|
+
* @remarks Convert image links into base64 format
|
|
13
|
+
* @param url - The image url
|
|
14
|
+
* @returns string
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* pdf.getBase64Images('https://fastly.picsum.photos/id/15/200/300.jpg?hmac=lozQletmrLG9PGBV1hTM1PnmvHxKEU0lAZWu8F2oL30')
|
|
18
|
+
* // => 'Hello-World'
|
|
19
|
+
* ```
|
|
20
|
+
* */
|
|
21
|
+
this.getBase64Images = (url) => {
|
|
22
|
+
return '';
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const pdf = new Pdf();
|
|
27
|
+
exports.default = pdf;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const axiosInstance = axios_1.default.create({});
|
|
8
|
+
exports.default = axiosInstance;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AxiosInstance } from './axios';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AxiosInstance = void 0;
|
|
7
|
+
var axios_1 = require("./axios");
|
|
8
|
+
Object.defineProperty(exports, "AxiosInstance", { enumerable: true, get: function () { return __importDefault(axios_1).default; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mhmdhammoud/meritt-utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -21,19 +21,19 @@
|
|
|
21
21
|
"lint": "eslint src --fix",
|
|
22
22
|
"prepublish": "npm run build"
|
|
23
23
|
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"dotenv": "^10.0.0"
|
|
26
|
-
},
|
|
27
24
|
"devDependencies": {
|
|
28
|
-
"ts-node-dev": "^1.1.8",
|
|
29
|
-
"typescript": "^4.6.3",
|
|
30
25
|
"@types/jest": "^27.5.1",
|
|
31
26
|
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
32
27
|
"@typescript-eslint/parser": "^5.17.0",
|
|
33
28
|
"eslint": "^8.12.0",
|
|
34
29
|
"eslint-plugin-tsdoc": "^0.2.14",
|
|
35
|
-
"husky": "^8.0.0"
|
|
30
|
+
"husky": "^8.0.0",
|
|
31
|
+
"ts-node-dev": "^1.1.8",
|
|
32
|
+
"typescript": "^4.6.3"
|
|
36
33
|
},
|
|
37
34
|
"author": "Mhmdhammoud",
|
|
38
|
-
"license": "ISC"
|
|
35
|
+
"license": "ISC",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"axios": "^1.4.0"
|
|
38
|
+
}
|
|
39
39
|
}
|
package/src/lib/cypto.ts
CHANGED
package/src/lib/formatter.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Author : Mhmd Hammoud
|
|
2
|
+
Author : Mhmd Hammoud https://github.com/mhmdhammoud
|
|
3
3
|
Date : 2023-06-17
|
|
4
4
|
Description : String manipulation
|
|
5
5
|
Version : 1.0
|
|
@@ -16,17 +16,19 @@ class Formatter {
|
|
|
16
16
|
* // => 'Hello-World'
|
|
17
17
|
* ```
|
|
18
18
|
* */
|
|
19
|
-
toUpperFirst = (_: string | number, withSpacing = true) => {
|
|
19
|
+
toUpperFirst = (_: string | number, withSpacing = true): string => {
|
|
20
20
|
if (typeof _ !== 'string') throw new Error('Provide a valid string')
|
|
21
21
|
if (withSpacing) {
|
|
22
|
-
return _.
|
|
22
|
+
return _.toLowerCase()
|
|
23
|
+
.split(' ')
|
|
23
24
|
.map((val: string) => val.charAt(0).toUpperCase() + val.slice(1))
|
|
24
25
|
.join(' ')
|
|
25
26
|
.replace(/ /g, '-')
|
|
26
27
|
.replace(/\//g, '-')
|
|
27
28
|
.replace(/\./g, '')
|
|
28
29
|
} else {
|
|
29
|
-
return _.
|
|
30
|
+
return _.toLowerCase()
|
|
31
|
+
.split(' ')
|
|
30
32
|
.map((val: string) => val.charAt(0).toUpperCase() + val.slice(1))
|
|
31
33
|
.join(' ')
|
|
32
34
|
.replace(/\//g, '-')
|
|
@@ -79,6 +81,34 @@ class Formatter {
|
|
|
79
81
|
)
|
|
80
82
|
}
|
|
81
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Capitalizes the first letter of each word in a sentence and removes non-alphanumeric characters.
|
|
86
|
+
* @param sentence - The input sentence to be processed.
|
|
87
|
+
* @returns A new sentence with the first letter of each word capitalized and non-alphanumeric characters removed.
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const sentence = 'this is34354345a---sentence'
|
|
91
|
+
* const newSentence = ToUpperTitle(sentence)
|
|
92
|
+
* console.log(newSentence) // 'This Is A Sentence'
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
toUpperTitle = (sentence: string): string => {
|
|
96
|
+
if (typeof sentence !== 'string') throw new Error('Provide a valid string')
|
|
97
|
+
if (!sentence) throw new Error('Provide a valid string')
|
|
98
|
+
|
|
99
|
+
const sanitizedSentence = sentence.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
100
|
+
const words = sanitizedSentence.split(' ')
|
|
101
|
+
const capitalizedWords = []
|
|
102
|
+
|
|
103
|
+
for (let i = 0; i < words.length; i++) {
|
|
104
|
+
const word = words[i]
|
|
105
|
+
const capitalizedWord = word.charAt(0).toUpperCase() + word.slice(1)
|
|
106
|
+
capitalizedWords.push(capitalizedWord)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return capitalizedWords.join(' ')
|
|
110
|
+
}
|
|
111
|
+
|
|
82
112
|
/**
|
|
83
113
|
* @remarks Generates a slug from a given string
|
|
84
114
|
* @param title - string to be converted to slug
|
package/src/lib/index.ts
CHANGED
package/src/lib/pdf.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {AxiosInstance} from '../utilities'
|
|
2
|
+
/*
|
|
3
|
+
Author : Mustafa Halabi https://github.com/mustafahalabi
|
|
4
|
+
Date : 2023-06-24
|
|
5
|
+
Description : Image to PDF converter
|
|
6
|
+
Version : 1.0
|
|
7
|
+
*/
|
|
8
|
+
class Pdf {
|
|
9
|
+
/**
|
|
10
|
+
* @remarks Convert image links into base64 format
|
|
11
|
+
* @param url - The image url
|
|
12
|
+
* @returns string
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* pdf.getBase64Images('https://fastly.picsum.photos/id/15/200/300.jpg?hmac=lozQletmrLG9PGBV1hTM1PnmvHxKEU0lAZWu8F2oL30')
|
|
16
|
+
* // => 'Hello-World'
|
|
17
|
+
* ```
|
|
18
|
+
* */
|
|
19
|
+
getBase64Images = (url: string): string => {
|
|
20
|
+
return ''
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const pdf = new Pdf()
|
|
25
|
+
export default pdf
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as AxiosInstance} from './axios'
|