1.1.2 • Published 9 months ago

rc-helper v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

RC Helper

npm version downloads license

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, else false.

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"