How to use the js-beautify/js/lib/beautify.js_beautify function in js-beautify

To help you get started, we’ve selected a few js-beautify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github easy-mock / easy-mock / views / pages / editor / index.vue View on Github external
format () {
      const context = this.codeEditor.getValue()
      let code = /^http(s)?/.test(context)
        ? context
        : jsBeautify.js_beautify(context, { indent_size: 2 })
      this.codeEditor.setValue(code)
    },
    onChange () {
github doug2k1 / webpack-generator / src / components / Code.js View on Github external
.map(rule => `{ test: ${rule.test}, use: ${rule.use} }`)
            .join(',\n\n')}]
        }`
    }

    if (plugins.length > 0) {
      code += `,
  
        plugins: [
          ${plugins.map(plugin => plugin.init).join(',\n')}
        ]`
    }

    code += `};`

    code = beautify(code, {
      indent_size: 2
    })

    return hljs.highlight('javascript', code).value
  }
github circlecell / jsoncompare.com / packages / frontend / js / main / index.js View on Github external
lint: (instance) => {
                const { reformat } = this;
                let { code } = instance;

                if (reformat === 'minify') {
                    code = minify(code);
                } else if (reformat === 'beautify_tabs') {
                    code = beautify.js_beautify(code, {
                        indent_with_tabs: true
                    });
                } else if (reformat === 'beautify_2') {
                    code = beautify.js_beautify(code, {
                        indent_size: 2
                    });
                } else if (reformat === 'beautify_4') {
                    code = beautify.js_beautify(code, {
                        indent_size: 4
                    });
                }

                instance.set({ code }, {
                    fromReformat: true
                });
            },
            lintRemoteStart: () => {
github easy-mock / easy-mock / views / pages / project-detail / mock-expand.vue View on Github external
        js: getJavaScriptEntities(response).map(o => jsBeautify.js_beautify(o, { indent_size: 2 })),
        oc: getObjectiveCEntities(response)