RC Helper
Helper function in javascript
Installation
With Yarn:
yarn add rc-helper
With npm:
npm install --save rc-helper
General Helper
isObjectExistKeys
A function that checks if an object has at least one key.
Parameters
-
data
(object): The object to check.
Returns
- (boolean): Returns
true
if the object has at least one key, elsefalse
.
Example
const obj1 = { a: 1, b: 2 };
const obj2 = {};
const obj3 = null;
isObjectExistKeys(obj1); // true
isObjectExistKeys(obj2); // false
isObjectExistKeys(obj3); // false
String Helper
removeSpace
Removes all spaces in a given string.
Parameters
-
string
: A string value to remove spaces.
Returns
- Returns a string value without spaces.
Throws
- Throws a TypeError if the input is not a string.
Example
const result = removeSpace(" hello world ");
console.log(result); // "helloworld"