Spaces:
Runtime error
Runtime error
Download static/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js from kaab4321/NarrativeFlow: direct link, hf CLI and curl.
- Browser
- Download file 847 Bytes
-
https://huggingface.co/spaces/kaab4321/NarrativeFlow/resolve/main/static/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js
- Command line
-
hf download hf://spaces/kaab4321/NarrativeFlow/static/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js
-
curl -L -o handleSpreadDoc.js https://huggingface.co/spaces/kaab4321/NarrativeFlow/resolve/main/static/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js
847 Bytes
| ; | |
| const utils = require('../../utils'); | |
| const keysToSkip = new Set(['__index', '__parentArray', '_doc']); | |
| /** | |
| * Using spread operator on a Mongoose document gives you a | |
| * POJO that has a tendency to cause infinite recursion. So | |
| * we use this function on `set()` to prevent that. | |
| */ | |
| module.exports = function handleSpreadDoc(v, includeExtraKeys) { | |
| if (utils.isPOJO(v) && v.$__ != null && v._doc != null) { | |
| if (includeExtraKeys) { | |
| const extraKeys = {}; | |
| for (const key of Object.keys(v)) { | |
| if (typeof key === 'symbol') { | |
| continue; | |
| } | |
| if (key[0] === '$') { | |
| continue; | |
| } | |
| if (keysToSkip.has(key)) { | |
| continue; | |
| } | |
| extraKeys[key] = v[key]; | |
| } | |
| return { ...v._doc, ...extraKeys }; | |
| } | |
| return v._doc; | |
| } | |
| return v; | |
| }; | |