How to use fast-safe-stringify - 9 common examples

To help you get started, we’ve selected a few fast-safe-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 renanmav / relayable / packages / server / src / core / logger / formatter / console.ts View on Github external
const consoleFormatter = format(info => {
  const stringifiedRest = jsonStringify(
    Object.assign({}, info, {
      level: undefined,
      label: undefined,
      message: undefined,
      splat: undefined,
      timestamp: undefined,
      // in case error is an Error object, make it undefined here, since we print it separately
      error: info.error instanceof Error ? undefined : info.error
    }),
    undefined,
    2
  )

  const padding = (info.padding && info.padding[info.level]) || ''
  if (stringifiedRest !== '{}') {
    info[MESSAGE] = `${info.timestamp} [${info.label}] ${info.level}:${padding} ${info.message}\n${stringifiedRest}`
github microlinkhq / www / src / components / hook / use-query-state.js View on Github external
const eq = (str1, str2) => stringify(str1) === stringify(str2)
github apache-superset / superset-ui-plugins / packages / superset-ui-legacy-preset-chart-nvd3 / src / vendor / superset / exploreUtils.js View on Github external
export function getExploreLongUrl(formData, endpointType, allowOverflow = true, extraSearch = {}) {
  if (!formData.datasource) {
    return null;
  }

  const uri = new URI('/');
  const directory = getURIDirectory(formData, endpointType);
  const search = uri.search(true);
  Object.keys(extraSearch).forEach(key => {
    search[key] = extraSearch[key];
  });
  search.form_data = safeStringify(formData);
  if (endpointType === 'standalone') {
    search.standalone = 'true';
  }
  const url = uri
    .directory(directory)
    .search(search)
    .toString();
  if (!allowOverflow && url.length > MAX_URL_LENGTH) {
    const minimalFormData = {
      datasource: formData.datasource,
      viz_type: formData.viz_type,
    };

    return getExploreLongUrl(minimalFormData, endpointType, false, {
      URL_IS_TOO_LONG_TO_SHARE: null,
    });
github aigoncharov / class-logger / src / formatter.service.ts View on Github external
protected valueToString(res: any): string {
    if (res === undefined) {
      return this.placeholderUndefined
    }
    if (typeof res !== 'object') {
      return res.toString()
    }
    if (res instanceof Error) {
      res = this.errorFormat(res)
    }
    if (Array.isArray(res)) {
      const arrayWithStringifiedElements = res.map(this.valueToString.bind(this))
      return `[${arrayWithStringifiedElements.join(', ')}]`
    }
    return stringify(res)
  }
github plasma-group / nestd / packages / core / src / injector / module-token-factory.ts View on Github external
public getDynamicMetadataToken(
    dynamicModuleMetadata: Partial | undefined
  ): string {
    return dynamicModuleMetadata ? stringify(dynamicModuleMetadata) : ''
  }
github IBM / report-toolkit / packages / formatters / src / json.js View on Github external
        ? values => stringify(values, null, 2)
        : values => stringify(values)
github IBM / report-toolkit / packages / transformers / src / newline.js View on Github external
concatMap(value =>
      of(
        (json || _.isObject(value) ? stringify(value) : String(value)) + newline
      )
    )
github codejie / fastify-apollo-step / src / apollo-graphql.js View on Github external
'use strict'

const fastStringify = require('fast-safe-stringify').stable;
const runHttpQuery = require('apollo-server-core').runHttpQuery;

function graphql(options) {
    return {
        method: ['GET', 'POST'],
        url: options.path,
        schema: {
            querystring: {
                query: {
                    type: 'string'
                }
            },
            body: {
                type: 'object',
                properties: {
                    query: {
github winstonjs / logform / json.js View on Github external
module.exports = format((info, opts = {}) => {
  info[MESSAGE] = (opts.stable ? jsonStringify.stableStringify
    : jsonStringify)(info, opts.replacer || replacer, opts.space);
  return info;
});

fast-safe-stringify

Safely and quickly serialize JavaScript objects

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis