How to use the javascript-stringify.stringify function in javascript-stringify

To help you get started, we’ve selected a few javascript-stringify 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 neutrinojs / webpack-chain / test / Config.js View on Github external
// Nested rules
  config.module
    .rule('alpha')
    .rule('nested')
    .use('babel')
    .loader('babel-loader');

  // Default rules
  config.module
    .defaultRule('default')
    .rule('nested')
    .use('babel')
    .loader('babel-loader');

  const envPluginPath = require.resolve('webpack/lib/EnvironmentPlugin');
  const stringifiedEnvPluginPath = stringify(envPluginPath);

  class FooPlugin {}
  FooPlugin.__expression = `require('foo-plugin')`;

  config
    .plugin('env')
    .use(envPluginPath, [{ VAR: false }])
    .end()
    .plugin('gamma')
    .use(FooPlugin)
    .end()
    .plugin('delta')
    .use(class BarPlugin {}, ['bar'])
    .end()
    .plugin('epsilon')
    .use(class BazPlugin {}, [{ n: 1 }, [2, 3]]);
github universal-vue / uvue / packages / @uvue / vue-cli-plugin-ssr / generator / index.js View on Github external
if (name === 'cookie' && options.cookieSecret) {
          pluginOptions = { secret: options.cookieSecret };
        }

        if (pluginOptions) {
          serverConfig.plugins.push([pluginPath, pluginOptions]);
        } else {
          serverConfig.plugins.push(pluginPath);
        }
      }
    }

    fs.writeFileSync(
      api.resolve('server.config.js'),
      `export default ${stringify(serverConfig, null, 2)}`,
    );
  }

  // When this plugin is invoked
  api.onCreateComplete(async () => {
    await execCodeFixer(api);

    const { blue, underline, bold } = chalk;

    api.exitLog(
      `UVue installed, please read this before starting:\n${bold(
        underline(
          blue(
            'https://universal-vue.github.io/docs/guide/post-install.html#post-installation-notes',
          ),
        ),
github universal-vue / uvue / packages / @uvue / vue-cli-plugin-ssr / generator / index.js View on Github external
opts[optionName] = true;
            return opts;
          }, {});
        }

        if (pluginOptions) {
          uvueConfig.plugins.push([pluginPath, pluginOptions]);
        } else {
          uvueConfig.plugins.push(pluginPath);
        }
      }
    }

    fs.writeFileSync(
      api.resolve('uvue.config.js'),
      `export default ${stringify(uvueConfig, null, 2)}`,
    );

    // Server config
    const serverConfig = {
      plugins: [],
    };

    if (options.serverPlugins) {
      for (const name of options.serverPlugins) {
        const pluginPath = `@uvue/server/plugins/${name}`;
        let pluginOptions = null;

        if (name === 'cookie' && options.cookieSecret) {
          pluginOptions = { secret: options.cookieSecret };
        }
github neutrinojs / neutrino / packages / create-project / commands / init / utils.js View on Github external
const getNeutrinorcOptions = (name, project) => {
  if (!project.options) {
    return '';
  }

  const [head, ...tail] = stringify(project.options(name), null, 2).split('\n');

  return `${head}\n${tail.join('\n').replace(RE_INDENT, '    ')}`;
};
github seek-oss / treat / packages / treat / webpack-plugin / loader.js View on Github external
const stringifyExports = value =>
  stringify(
    value,
    (value, indent, next) => {
      const valueType = typeof value;
      if (
        valueType === 'string' ||
        valueType === 'number' ||
        valueType === 'undefined' ||
        value === null ||
        Array.isArray(value) ||
        isPlainObject(value)
      ) {
        return next(value);
      }

      throw new Error(dedent`
        Invalid treat file exports.
github octokit / routes / lib / endpoint / add-code-samples.js View on Github external
const params = route.operation.parameters
    .filter(param => !param.deprecated)
    .filter(param => param.name != "owner")
    .filter(param => param.in !== "header")
    .filter(param => param.required)
    .reduce(
      (params, param) =>
        Object.assign(params, {
          [param.name]: getExampleParamValue(param.name, param.schema)
        }),
      {}
    );
  Object.assign(params, getExampleBodyParams(route));

  const method = `${snakeCase(idName).replace(/get_|list_/, "")}`;
  const parameters = `${stringify(Object.values(params), null, 2)}`;
  return `octokit.${method}(${
    Object.keys(params).length
      ? parameters.substring(1, parameters.length - 1)
      : ""
  })`;
}
github octokit / routes / lib / endpoint / add-code-samples.js View on Github external
const params = route.operation.parameters
    .filter(param => !param.deprecated)
    .filter(param => param.in !== "header")
    .filter(param => param.required)
    .reduce(
      (params, param) =>
        Object.assign(params, {
          [param.name]: getExampleParamValue(param.name, param.schema)
        }),
      {}
    );
  Object.assign(params, getExampleBodyParams(route));

  const method = `${camelCase(scope)}.${camelCase(idName)}`;
  return `octokit.${method}(${
    Object.keys(params).length ? stringify(params, null, 2) : ""
  })`;
}
github octokit / routes / lib / openapi.js View on Github external
function toJsExample ({ scope, endpoint, baseUrl }) {
  const params = endpoint.params
    .filter(param => !param.deprecated)
    .filter(param => param.required)
    .reduce((params, param) => Object.assign(params, {
      [param.name]: PARAMETER_EXAMPLES[param.name] || param.name
    }), {})

  return `octokit.${scope}.get(${Object.keys(params).length ? stringify(params, null, 2) : ''})`
}

javascript-stringify

Stringify is to `eval` as `JSON.stringify` is to `JSON.parse`

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis