How to use circular-json - 10 common examples

To help you get started, we’ve selected a few circular-json 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 vck3000 / ProAvalon / sockets / sockets.1.js View on Github external
function saveGameToDb(roomToSave) {
    if (roomToSave.gameStarted === true && roomToSave.finished !== true) {
        if (roomToSave.savedGameRecordId === undefined) {
            savedGameObj.create({ room: JSON.stringify(roomToSave) }, (err, savedGame) => {
                if (err) {
                    console.log(err);
                } else {
                    rooms[rooms.indexOf(roomToSave)].savedGameRecordId = savedGame.id;
                    // console.log("Successfully created this save game");
                }
            });
        } else {
            savedGameObj.findByIdAndUpdate(roomToSave.savedGameRecordId, { room: JSON.stringify(roomToSave) }, (err, savedGame) => {
                // console.log("Successfully saved this game");
            });
        }
    }
}
function deleteSaveGameFromDb(room) {
github vck3000 / ProAvalon / sockets / sockets.js View on Github external
function saveGameToDb(roomToSave) {
    if (roomToSave.gameStarted === true && roomToSave.finished !== true) {
        if (roomToSave.savedGameRecordId === undefined) {
            savedGameObj.create({ room: JSON.stringify(roomToSave) }, (err, savedGame) => {
                if (err) {
                    console.log(err);
                } else {
                    rooms[rooms.indexOf(roomToSave)].savedGameRecordId = savedGame.id;
                    // console.log("Successfully created this save game");
                }
            });
        } else {
            savedGameObj.findByIdAndUpdate(roomToSave.savedGameRecordId, { room: JSON.stringify(roomToSave) }, (err, savedGame) => {
                // console.log("Successfully saved this game");
            });
        }
    }
}
function deleteSaveGameFromDb(room) {
github LakeYS / Discord-Trivia-Bot / triviabot.js View on Github external
Trivia.exportGame = (file) => {
  // Copy the data so we don't modify the actual game object.
  var json = JSON.parse(JSON.stringify(game));

  // Remove the timeout so the game can be exported.
  Object.keys(json).forEach((key) => {
    if(typeof json[key].timeout !== "undefined") {
      delete json[key].timeout;
      delete json[key].message;
    }

    // If there is no guild ID, the game is a DM game.
    // DM games are re-assigned to make sure they show up last.
    // This ensures that the first key is always a non-DM game if possible.
    if(typeof json[key].guildId === "undefined") {
      var replace = json[key];
      delete json[key];
      json[key] = replace;
    }
github JamieMason / shrinkpack / src / lib / snitch.ts View on Github external
const logPromise = (file: string, key: string, args: any[], resolvedValue: any) => {
  const template = `${file} %s(${token}).then(${token})`;
  console.log(template, key, stringifyArgs(args), circularJSON.stringify(resolvedValue));
};
github samdenty / injectify / src / inject / core / core / components / Websockets / index.ts View on Github external
static send(topic: string, data?: any) {
    /**
     * If the websocket is dead, return
     */
    if (ws.readyState !== ws.OPEN) return
    try {
      let json = CircularJSON.stringify({
        t: topic,
        d: data,
      })
      if (injectify.info.compression) {
        json = '#' + pako.deflate(json, {to: 'string'})
      }
      ws.send(json)
    } catch (e) {
      if (injectify.debug) console.error(e)
      injectify.error(e.stack)
    }
  }
github dadi / web / dadi / lib / debug / views.js View on Github external
function encode (data) {
  data =
    typeof data === 'object'
      ? CircularJSON.stringify(data, null, 2)
      : data.toString()
  return data
    .replace(/&/g, '&')
    .replace(//g, '>')
}
github cartant / rxjs-spy / source / plugins / devtools-plugin.ts View on Github external
function toValue(value: any): { json: string } {

    return { json: stringify(value, null, null, true) };
}
github joola / joola / lib / common / index.js View on Github external
common.stringify = function (obj, callback) {
  callback = callback || function () {
  };
  return callback(null, stringify.stringify(obj));
};
github kolodny / jsan / perf / bench.js View on Github external
      .add('CircularJSON', () => CircularJSON.stringify(obj))
      .add('json-stringify-safe', () => stringify(obj))
github luan007 / edge-node-wrt / Modules / Shared / Basic / cjson.ts View on Github external
global.CJSONString = function(obj): string {
    return cjson.stringify(obj);
}

circular-json

JSON does not handle circular references. This version does

MIT
Latest version published 5 years ago

Package Health Score

55 / 100
Full package analysis

Popular circular-json functions