strhelper
v1.2.0
Published
Powerful library to manage and interact with strings
Downloads
1
Readme
strhelper
Powerful library to manage and interact with strings
Implementation
const STRHelper = require('strhelper');
Now there is 2 ways:
- Patch
String
class and add methods into:
STRHelper.patch();
- Get object with methods to use on strings
let strhelper = STRHeleper.get();
Usage
If patched string class:
let string = 'example';
let newString = string.mixedCase(true);
// newString == 'ExAmPlE'
If using as object with functions:
let string = 'example';
let newString = sthelper.mixedCase(string, false);
// newString == 'eXaMpLe'
Methods
Bit shift (left) - 'string'.shiftLeft(bits: number)
- Number should be positive
Bit shift (right) - 'string'.shiftRight(bits: number)
- Number should be positive
Encode/Decode from Base64 - 'string'.toBase64()
/ 'c3RyaW5n'.fromBase64()
Encode/Decode from Hex - 'string'.toHex()
/ '737472696e67'.fromHex()
Split string every N characters - 'string'.splitEvery(count: number)
- Count should be more than 0
Make string mixed case - 'string'.mixedCase(startFromFirst: boolean)
Match regex - 'string'.matchR(/test/g)
- Always returns array, even if no matches (instead of default null)