UNPKG

@nestjs/swagger

Version:

Nest - modern, fast, powerful node.js web framework (@swagger)

22 lines (21 loc) 728 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.buildJSInitOptions = buildJSInitOptions; const crypto_1 = require("crypto"); function buildJSInitOptions(initOptions) { const fns = []; const placeholders = []; let json = JSON.stringify(initOptions, (key, value) => { if (typeof value === 'function') { const placeholder = (0, crypto_1.randomUUID)(); fns.push(value); placeholders.push(placeholder); return placeholder; } return value; }, 2); placeholders.forEach((placeholder, i) => { json = json.replace(`"${placeholder}"`, fns[i].toString()); }); return `let options = ${json};`; }