https://github.com/richardscarrott/trim-obj
🥓 Recursively trim object values
https://github.com/richardscarrott/trim-obj
Last synced: 2 months ago
JSON representation
🥓 Recursively trim object values
- Host: GitHub
- URL: https://github.com/richardscarrott/trim-obj
- Owner: richardscarrott
- License: mit
- Created: 2021-11-27T22:37:39.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-11-27T23:19:26.000Z (over 3 years ago)
- Last Synced: 2025-03-18T15:08:07.874Z (2 months ago)
- Language: TypeScript
- Homepage:
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Trim Obj
[](https://www.npmjs.com/package/trim-obj)
[](https://github.com/richardscarrott/trim-obj/actions/workflows/node.js.yml)
[](https://github.com/richardscarrott/trim-obj/blob/master/LICENSE)Recursively trim object values.
## Install
### NPM
```
npm install trim-obj
```### Yarn
```
yarn add trim-obj
```### Usage
```js
import { trimObj } from "trim-obj";const input = {
firstName: " Lewis",
lastName: "Hamilton ",
age: 36,
avatar: {
url: " https://static.wixstatic.com/media/23204b_787f58851a1042648b78f23f45adfe5c~mv2.jpg/v1/fill/w_1710,h_1592,al_c,q_90/23204b_787f58851a1042648b78f23f45adfe5c~mv2.webp ",
size: ["1000 ", " 2000px "],
},
};const output = trimObj(input);
console.log(output);
// {
// firstName: "Lewis",
// lastName: "Hamilton",
// age: 36,
// avatar: {
// url: "https://static.wixstatic.com/media/23204b_787f58851a1042648b78f23f45adfe5c~mv2.jpg/v1/fill/w_1710,h_1592,al_c,q_90/23204b_787f58851a1042648b78f23f45adfe5c~mv2.webp",
// size: ["1000", "2000px"],
// },
// }
console.log(output === input);
// false
```