Spaces:
Runtime error
Runtime error
Download static/node_modules/mongoose/lib/helpers/minimize.js from kaab4321/NarrativeFlow: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/spaces/kaab4321/NarrativeFlow/resolve/main/static/node_modules/mongoose/lib/helpers/minimize.js
- Command line
-
hf download hf://spaces/kaab4321/NarrativeFlow/static/node_modules/mongoose/lib/helpers/minimize.js
-
curl -L -o minimize.js https://huggingface.co/spaces/kaab4321/NarrativeFlow/resolve/main/static/node_modules/mongoose/lib/helpers/minimize.js
636 Bytes
| ; | |
| const { isPOJO } = require('../utils'); | |
| module.exports = minimize; | |
| /** | |
| * Minimizes an object, removing undefined values and empty objects | |
| * | |
| * @param {Object} object to minimize | |
| * @return {Object|undefined} | |
| * @api private | |
| */ | |
| function minimize(obj) { | |
| const keys = Object.keys(obj); | |
| let i = keys.length; | |
| let hasKeys; | |
| let key; | |
| let val; | |
| while (i--) { | |
| key = keys[i]; | |
| val = obj[key]; | |
| if (isPOJO(val)) { | |
| obj[key] = minimize(val); | |
| } | |
| if (undefined === obj[key]) { | |
| delete obj[key]; | |
| continue; | |
| } | |
| hasKeys = true; | |
| } | |
| return hasKeys | |
| ? obj | |
| : undefined; | |
| } | |