File tree 6 files changed +70
-4
lines changed
6 files changed +70
-4
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,15 @@ function decrypt() {
61
61
case 1 :
62
62
decryptedTexts = _a . sent ( ) ;
63
63
results = decryptedTexts . map ( function ( text ) { return text . result ; } ) ;
64
+ if ( options === null || options === void 0 ? void 0 : options . trim ) {
65
+ results = results . map ( function ( result ) { return result . trim ( ) ; } ) ;
66
+ }
67
+ if ( options === null || options === void 0 ? void 0 : options . toLowerCase ) {
68
+ results = results . map ( function ( result ) { return result . toLowerCase ( ) ; } ) ;
69
+ }
70
+ if ( options === null || options === void 0 ? void 0 : options . toUpperCase ) {
71
+ results = results . map ( function ( result ) { return result . toUpperCase ( ) ; } ) ;
72
+ }
64
73
return [ 2 /*return*/ , ( options === null || options === void 0 ? void 0 : options . returnArray ) ? results : results . join ( "\n" ) ] ;
65
74
}
66
75
} ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,15 @@ function encrypt() {
48
48
case 0 :
49
49
texts = args . filter ( function ( arg ) { return typeof arg === "string" ; } ) ;
50
50
options = args . find ( function ( arg ) { return typeof arg === "object" ; } ) ;
51
+ if ( options === null || options === void 0 ? void 0 : options . trim ) {
52
+ texts = texts . map ( function ( text ) { return text . trim ( ) ; } ) ;
53
+ }
54
+ if ( options === null || options === void 0 ? void 0 : options . toLowerCase ) {
55
+ texts = texts . map ( function ( text ) { return text . toLowerCase ( ) ; } ) ;
56
+ }
57
+ if ( options === null || options === void 0 ? void 0 : options . toUpperCase ) {
58
+ texts = texts . map ( function ( text ) { return text . toUpperCase ( ) ; } ) ;
59
+ }
51
60
requests = texts . map ( function ( text ) {
52
61
return fetch ( "https://supercryptjs-api-v2.binaryblazer.me/api/encrypt" , {
53
62
method : "POST" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,16 @@ async function decrypt(...args) {
11
11
} ,
12
12
} ) . then ( ( res ) => res . json ( ) ) ) ;
13
13
const decryptedTexts = await Promise . all ( requests ) ;
14
- const results = decryptedTexts . map ( ( text ) => text . result ) ;
14
+ let results = decryptedTexts . map ( ( text ) => text . result ) ;
15
+ if ( options ?. trim ) {
16
+ results = results . map ( ( result ) => result . trim ( ) ) ;
17
+ }
18
+ if ( options ?. toLowerCase ) {
19
+ results = results . map ( ( result ) => result . toLowerCase ( ) ) ;
20
+ }
21
+ if ( options ?. toUpperCase ) {
22
+ results = results . map ( ( result ) => result . toUpperCase ( ) ) ;
23
+ }
15
24
return options ?. returnArray ? results : results . join ( "\n" ) ;
16
25
}
17
26
exports . default = decrypt ;
Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
2
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3
3
async function encrypt ( ...args ) {
4
- const texts = args . filter ( ( arg ) => typeof arg === "string" ) ;
4
+ let texts = args . filter ( ( arg ) => typeof arg === "string" ) ;
5
5
const options = args . find ( ( arg ) => typeof arg === "object" ) ;
6
+ if ( options ?. trim ) {
7
+ texts = texts . map ( ( text ) => text . trim ( ) ) ;
8
+ }
9
+ if ( options ?. toLowerCase ) {
10
+ texts = texts . map ( ( text ) => text . toLowerCase ( ) ) ;
11
+ }
12
+ if ( options ?. toUpperCase ) {
13
+ texts = texts . map ( ( text ) => text . toUpperCase ( ) ) ;
14
+ }
6
15
const requests = texts . map ( ( text ) => fetch ( "https://supercryptjs-api-v2.binaryblazer.me/api/encrypt" , {
7
16
method : "POST" ,
8
17
body : JSON . stringify ( { text } ) ,
Original file line number Diff line number Diff line change 1
1
interface DecryptOptions {
2
2
returnArray ?: boolean ;
3
+ trim ?: boolean ;
4
+ toLowerCase ?: boolean ;
5
+ toUpperCase ?: boolean ;
3
6
}
4
7
5
8
async function decrypt ( ...args : ( string | DecryptOptions ) [ ] ) {
@@ -19,7 +22,19 @@ async function decrypt(...args: (string | DecryptOptions)[]) {
19
22
) ;
20
23
21
24
const decryptedTexts = await Promise . all ( requests ) ;
22
- const results = decryptedTexts . map ( ( text ) => text . result ) ;
25
+ let results = decryptedTexts . map ( ( text ) => text . result ) ;
26
+
27
+ if ( options ?. trim ) {
28
+ results = results . map ( ( result ) => result . trim ( ) ) ;
29
+ }
30
+
31
+ if ( options ?. toLowerCase ) {
32
+ results = results . map ( ( result ) => result . toLowerCase ( ) ) ;
33
+ }
34
+
35
+ if ( options ?. toUpperCase ) {
36
+ results = results . map ( ( result ) => result . toUpperCase ( ) ) ;
37
+ }
23
38
24
39
return options ?. returnArray ? results : results . join ( "\n" ) ;
25
40
}
Original file line number Diff line number Diff line change 1
1
interface EncryptOptions {
2
2
returnArray ?: boolean ;
3
+ trim ?: boolean ;
4
+ toLowerCase ?: boolean ;
5
+ toUpperCase ?: boolean ;
3
6
}
4
7
5
8
async function encrypt ( ...args : ( string | EncryptOptions ) [ ] ) {
6
- const texts = args . filter ( ( arg ) => typeof arg === "string" ) as string [ ] ;
9
+ let texts = args . filter ( ( arg ) => typeof arg === "string" ) as string [ ] ;
7
10
const options = args . find ( ( arg ) => typeof arg === "object" ) as
8
11
| EncryptOptions
9
12
| undefined ;
10
13
14
+ if ( options ?. trim ) {
15
+ texts = texts . map ( ( text ) => text . trim ( ) ) ;
16
+ }
17
+
18
+ if ( options ?. toLowerCase ) {
19
+ texts = texts . map ( ( text ) => text . toLowerCase ( ) ) ;
20
+ }
21
+
22
+ if ( options ?. toUpperCase ) {
23
+ texts = texts . map ( ( text ) => text . toUpperCase ( ) ) ;
24
+ }
25
+
11
26
const requests = texts . map ( ( text ) =>
12
27
fetch ( "https://supercryptjs-api-v2.binaryblazer.me/api/encrypt" , {
13
28
method : "POST" ,
You can’t perform that action at this time.
0 commit comments