1.0.4 • Published 1 year ago

get-trim-all v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

get-trim-all

npm install get-trim-all

Import

const trimAll = require('get-trim-all')

OR

import trimAll from "get-trim-all";

Use Case

  • String
    let str = ' Helloworld ';

console.log(trimAll(str)); // 'helloworld' //or console.log(typeof trimAll(str)); // string

- Number
 ```js
let num = 1524;

console.log(trimAll(num)); // 1524
//or
console.log(typeof trimAll(num)); // number
  • Boolean
    let bool = true;

console.log(trimAll(bool)); // true //or console.log(typeof trimAll(bool)); // boolean

- Array of String(s)
```js
let arr = [' google ', ' facebook '];

console.log(trimAll(arr)); // ['google', 'facebook']
//or
console.log(typeof trimAll(arr)); // object
//or
console.log(Array.isArray(trimAll(arr))); // true
  • Object
let obj = {
  name: ' Sahil Kumar ',
  age: 19,
  hobbies: [' programming ', ' badminton ']
};

console.log(trimAll(obj)); // { name: 'Sahil Kumar', age: 19, hobbies: ['programming', 'badminton'] }
//or
console.log(typeof trimAll(obj)); // object
let obj = { ' name ': ' sahil   Kumar ' }

console.log(trimAll(obj)) // { ' name ': 'sahil   Kumar' }
//or
console.log(typeof trimAll(obj)); // object
  • Array of Object
let arr = [
  { city: [' bbsr ', ' ctc '] }
];

console.log(trimAll(arr)); // [{ city: ['bbsr', 'ctc']}]
//or
console.log(typeof trimAll(arr)); // object
//or
console.log(Array.isArray(trimAll(arr))); // true