How to use flatted - 10 common examples

To help you get started, we’ve selected a few flatted 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 mvolkmann / redux-easy / src / redux-easy.js View on Github external
export function saveState(state) {
  if (sessionStorageOptOut) return;
  try {
    const json = stringify(replacerFn(state));
    sessionStorage.setItem(STATE_KEY, json);
  } catch (e) {
    // istanbul ignore next
    if (!silent) console.error('redux-util saveState:', e.message);
    throw e;
  }
}
github samdenty / gqless / packages / logger / src / Logger.ts View on Github external
console.error(error)
    } else {
      console.log(...format(['Result', headerStyles]), response)
    }

    // Accessors
    console.groupCollapsed(...format(['Accessors', headerStyles]))
    for (const accessor of accessors) {
      console.log(accessor)
    }
    console.groupEnd()

    // Cache
    console.log(
      ...format(['Cache snapshot', headerStyles]),
      parse(stringify(this.client.cache))
    )

    console.groupEnd()
  }) as PluginMethod<'onFetch'>
}
github postmanlabs / uvm / lib / uvm / bridge.browser.js View on Github external
forwardEmits = function (e) {
            if (!(e && e.data && _.isString(e.data.__emit_uvm) && (e.data.__id_uvm === id))) { return; }

            var args;
            try { args = Flatted.parse(e.data.__emit_uvm); }
            catch (err) { return bridge.emit(ERROR, err); }
            bridge.emit.apply(bridge, args); // eslint-disable-line prefer-spread
        },
github cmux / koot / packages / koot-diagnose / index.js View on Github external
console.log('Running Crawler test...');
        console.log(' ');
        const errors = await require('./crawler')(crawler, {
            debug: true,
            // maxCrawl: 100,
            cluster: {
                maxConcurrency: 5,
                monitor: true
            }
        });
        console.log('\n' + chalk.bgRedBright(` ERROR `));
        const dir = path.resolve(__dirname, '../../logs/crawler/');
        await fs.ensureDir(dir);
        await fs.writeJson(
            path.resolve(dir, `${encodeURIComponent(crawler)}.json`),
            parse(stringify(errors)),
            {
                spaces: '\t'
            }
        );
        Object.entries(errors).forEach(([type, errors]) => {
            console.log('❌ ' + chalk.underline(type));
            errors.forEach(err => {
                console.log(`● ${err.url}`);
                if (err.pageUrl) console.log(`  pageUrl: ${err.pageUrl}`);
                switch (type) {
                    case 'no gzip':
                    case 'large file': {
                        let size = err.contentLength;
                        if (size > 1024 * 1024) {
                            size = getSize(size);
                        } else if (size > 1024) {
github log4js-node / log4js-node / lib / LoggingEvent.js View on Github external
serialise() {
    const logData = this.data.map((e) => {
      // JSON.stringify(new Error('test')) returns {}, which is not really useful for us.
      // The following allows us to serialize errors correctly.
      if (e && e.message && e.stack) {
        e = Object.assign({ message: e.message, stack: e.stack }, e);
      }
      return e;
    });
    this.data = logData;
    return flatted.stringify(this);
  }
github publiclab / Leaflet.DistortableImage / node_modules / log4js / lib / LoggingEvent.js View on Github external
serialise() {
    const logData = this.data.map((e) => {
      // JSON.stringify(new Error('test')) returns {}, which is not really useful for us.
      // The following allows us to serialize errors correctly.
      if (e && e.message && e.stack) {
        e = Object.assign({ message: e.message, stack: e.stack }, e);
      }
      return e;
    });
    this.data = logData;
    return flatted.stringify(this);
  }
github n8n-io / n8n / packages / editor-ui / src / components / mixins / restApi.ts View on Github external
function unflattenExecutionData (fullExecutionData: IExecutionFlattedResponse): IExecutionResponse {
	// Unflatten the data
	const returnData: IExecutionResponse = {
		...fullExecutionData,
		workflowData: fullExecutionData.workflowData as IWorkflowDb,
		data: parse(fullExecutionData.data),
	};

	returnData.finished = returnData.finished ? returnData.finished : false;

	if (fullExecutionData.id) {
		returnData.id = fullExecutionData.id;
	}

	return returnData;
}
github LucasBassetti / react-simple-chatbot / lib / storage.js View on Github external
const setData = (cacheName, cachedData) => {
  const data = parse(stringify(cachedData));
  // clean components
  for (const key in data) {
    for (let i = 0, len = data[key].length; i < len; i += 1) {
      if (data[key][i].component) {
        data[key][i].component = data[key][i].id;
      }
    }
  }

  localStorage.setItem(cacheName, stringify(data));
};
github LucasBassetti / react-simple-chatbot / tests / lib / schema.spec.js View on Github external
it('should delete a invalid key', () => {
    const step = schema.parse({
      id: '1',
      message: 'test',
      test: 'test',
    });
    const resultStep = stringify({ id: '1', message: 'test' });
    expect(stringify(step)).to.be.equal(resultStep);
  });
github TypeScriptToLua / TypeScriptToLua / test / test_thread.ts View on Github external
testRunner.onTestComplete(result => {
        if (result.outcome === TestOutcome.Fail) {
            if (result.error instanceof MatchError) {
                console.log(`Test ${result.testFixture.description}, ${result.test.key}(${flatted.stringify(result.testCase.caseArguments)}) Failed!`);
                console.log(" ---\n" +
                '   message: "' +
                result.error.message +
                '"\n' +
                "   severity: fail\n" +
                "   data:\n" +
                "     got: " +
                result.error.actual +
                "\n" +
                "     expect: " +
                result.error.expected +
                "\n");
            }
            failedTestCount++;
        }
        testCount++;

flatted

A super light and fast circular JSON parser.

ISC
Latest version published 3 days ago

Package Health Score

77 / 100
Full package analysis