1
1
class stringUDFs {
2
- constructor ( ) { }
2
+ constructor ( ) { }
3
3
4
4
// ************************************************************************************************
5
5
// stringToJSON
@@ -71,13 +71,14 @@ class stringUDFs {
71
71
// isAlphaNumeric('abcd xtyz5245/',true,true,true,'&^'); //Output will be - false;
72
72
// isAlphaNumeric('abcd xtyz5245/',true,true,true,'/'); //Output will be - true;
73
73
// ************************************************************************************************
74
- isAlphaNumeric ( text , isSpaceAllowed = false , isAlphaAllowed = true , isNumericAllowed = true , allowedChars = null ) {
74
+ isAlphaNumeric ( text , isSpaceAllowed = false , isAlphaAllowed = true ,
75
+ isNumericAllowed = true , allowedChars = undefined , maxLength = 100 , minLength = 1 ) {
75
76
var regex = "" ;
76
77
77
78
regex = isSpaceAllowed ? regex += " " : regex ;
78
79
regex = isAlphaAllowed ? regex += 'A-Za-z' : regex ;
79
80
regex = isNumericAllowed ? regex += '1-9' : regex ;
80
- regex = allowedChars == null ? regex : regex += allowedChars ;
81
+ regex = allowedChars ? regex : regex += allowedChars ;
81
82
if ( regex == "" ) return false ;
82
83
83
84
let isValid = new RegExp ( `\[${ regex } \]\+\$` ) . test ( text ) ;
@@ -118,7 +119,7 @@ class stringUDFs {
118
119
// properCase('abc'); //Output will be - Abc
119
120
// ************************************************************************************************
120
121
properCase ( text ) {
121
- let output = text . length > 0 ? text . charAt ( 0 ) . toUpperCase ( ) + text . substr ( 1 ) . toLowerCase ( ) : " " ;
122
+ let output = text . length > 0 ? text . charAt ( 0 ) . toUpperCase ( ) + text . substr ( 1 ) . toLowerCase ( ) : "" ;
122
123
return output ;
123
124
}
124
125
@@ -163,9 +164,9 @@ class stringUDFs {
163
164
// ************************************************************************************************
164
165
// exportArrayColumn
165
166
//
166
- // This extract a column from multi-dimentional array
167
+ // This extract a column from multi-dimensional array
167
168
// It will have two argument.
168
- // 1. Pass the multi-dimentional array.
169
+ // 1. Pass the multi-dimensional array.
169
170
// 2. col >> the column number which needs to be exported.
170
171
171
172
// Examples:
@@ -191,7 +192,7 @@ class stringUDFs {
191
192
//
192
193
// ************************************************************************************************
193
194
isObject ( value ) {
194
- return ( typeof value === 'object' ) ;
195
+ return ( typeof value === 'object' && value !== null ) ;
195
196
}
196
197
197
198
// ************************************************************************************************
@@ -227,10 +228,12 @@ class stringUDFs {
227
228
//
228
229
// ************************************************************************************************
229
230
isNoValue ( value ) {
230
- return ( value === null || value == undefined || typeof value === 'undefined' || ( isNaN ( value ) && ! value . length ) ) ;
231
+ return ( value === null || value || typeof value === 'undefined' || ( isNaN ( value ) && ! value . length ) ) ;
231
232
}
232
233
233
- deleleColumns ( arr , col = 0 ) {
234
+ objectToArray = ( data ) => Array . isArray ( data ) ? data : [ data ] ;
235
+
236
+ deleteColumns ( arr , col = 0 ) {
234
237
if ( col == 0 ) throw new Error ( 'Argument col must not be zero.' ) ;
235
238
if ( col > arr [ 0 ] . length ) throw new Error ( 'Delete column is greater than arr columns.' ) ;
236
239
0 commit comments