1.1.7 ā€¢ Published 4 years ago

@easytech-international-sdn-bhd/jstring v1.1.7

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

JString

Handy tool for Javascript String. Can be used in NodeJSReact-NativeReactJS applications.


Table of Contents


Installation

With npm:

$ npm install @easytech-international-sdn-bhd/jstring

With yarn:

$ yarn add @easytech-international-sdn-bhd/jstring

Methods

Any string like 'null'/'undefined' will be auto converted to ''
methoddescriptionexample
trimHtmlRemove all the html tags from stringJString(<p>Hello World</p>).trimHtml().toStr(); output: Hello World
searchDeepSearch case insensitive in stringJString('Hello World').searchDeep('w'); output: true
searchTokensSearch tokens in string(case insensitive)JString('Hello World').searchTokens('w','h'); output: true
isSafeCheck if the string isValid and returns the string if it's valid otherwise empty stringJString(' ').isSafe(); output: ''
removeLastCharRemove last character from string. This method comes with an optional parameter. If the optional parameter is provided, the function will remove that parameter onlyvar ex = JString('abc-com').removeLastChar().toStr(); output: 'abc-co'ex.removeLastChar('o').toStr();output: 'abc-c'
removeFirstCharRemove first char. Same functionality as removeLastChar-
removeSpecialCharRemove all the special or sensitive characters from stringJString('abc_d*e/f^g%h%i$j').removeSpecialChar().toStr();output: 'abcdefghij'
replaceInfinityReplace all from string based on given parameterJString('Dogge Doggo').replaceInfinity('g','').toStr();output: 'Doe Doo'
rollbackRollback changesJString('Dogge Doggo').replaceInfinity('g','').rollback();
inCurrencyConvert into currency formatJString('12345.67').inCurrency('$').toStr();output: '$12,345.67'
isJsonCheck whether the string is JSONJString('{"jstring":"JSON example"}').isJson();output: true
toJsonConvert string to JSON. Return null if not JSONJString('{"jstring":"JSON example"}').toJson();
isNumberCheck if the string can be a numberJString('101').isNumber();output: true
toNumberConvert string to numberJString('101').toNumber();output: 101
isPasswordCheck if the string is a number with an optional parameter of minimum number of charactersJString('abc*'o').isPassword();output:false
isFormSafeCheck if a string is valid for form or databaseJString('ab#c').isFormSafe();output:false
isEmailCheck if the string is an emailJString('abc.com').isEmail();output:false
isValidCheck if the string is a valid stringJString('').isValid();output:false
instanceOfJStringReturn JString instance-
instanceOfStringReturn String instance-
firstUpperCaseConvert first character to upper caseJString('aBC').firstUpperCase().toStr();output:'ABC'
firstLowerCaseConvert first character to lower caseJString('ABC').firstLowerCase().toStr();output:'aBC'
lastUpperCaseConvert last character to upper caseJString('abc').lastUpperCase().toStr();output:'abC'
lastLowerCaseConvert last character to lower caseJString('ABC').lastLowerCase().toStr();output:'ABc'
isEqualCompare string case sensitiveJString('AC').isEqual('ac');output:false
isEqualDeepCompare string case insensitiveJString('AC').isEqualDeep('ac');output:true
toArrayConvert string into array of charJString('ADC').toArray();output:['A','D','C']
walkLoop through stringJString('abcd').walk((char,index)=>{ });
occurrenceOfCount number of occurance of charJString('abcdcc').occurrenceOf('c');output:3

TODO

  • Allow schema for password validation
  • Allow schema for form validation
  • Compress & Decompress string
  • Allow tokenize search

Author

šŸ’» šŸ›  Mohammad Julfikar Mahmud

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago