How to use the ejson.stringify function in ejson

To help you get started, we’ve selected a few ejson 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 DistributedObjectProtocol / dop / test / .djson_date.js View on Github external
function testEJSON(t, patch, expected, recursive = true) {
    const string_djson = DJSON.stringify(patch)
    const string_ejson = EJSON.stringify(patch)
    const parsed_json_djson = JSON.parse(string_djson)
    const parsed_json_ejson = JSON.parse(string_ejson)
    t.deepEqual(parsed_json_djson, expected)
    t.deepEqual(parsed_json_djson, parsed_json_ejson)
    if (recursive) {
        testEJSON(t, DJSON.parse(string_djson), expected, false)
        // testEJSON(t, EJSON.parse(string_ejson), expected, false)
    }
}
github nrkno / tv-automation-server-core / meteor / __mocks__ / check / match.js View on Github external
var stringForErrorMessage = function (value, options) {
  options = options || {};

  if ( value === null ) return "null";

  if ( options.onlyShowType ) {
    return typeof value;
  }

  // Your average non-object things.  Saves from doing the try/catch below for.
  if ( typeof value !== "object" ) {
    return EJSON.stringify(value)
  }

  try {
    // Find objects with circular references since EJSON doesn't support them yet (Issue #4778 + Unaccepted PR)
    // If the native stringify is going to choke, EJSON.stringify is going to choke too.
    JSON.stringify(value);
  } catch (stringifyError) {
    if ( stringifyError.name === "TypeError" ) {
      return typeof value;
    }
  }

  return EJSON.stringify(value);
};
github primus / primus / parsers / ejson.js View on Github external
exports.encoder = function encoder(data, fn) {
  var err;

  try { data = EJSON.stringify(data); }
  catch (e) { err = e; }

  fn(err, data);
};
github Losant / losant-mqtt-js / lib / device.js View on Github external
Device.prototype.sendState = function(state, time, callback) {

  if(typeof(time) === 'function') {
    callback = time;
    time = null;
  }

  time = time || new Date();
  var payload = { time: time, data: state };

  debug('Publishing state:');
  debug(EJSON.stringify(payload));
  debug('Topic: ' + this.stateTopic);

  this.mqtt.publish(this.stateTopic, EJSON.stringify(payload), callback);

  return { topic: this.stateTopic, payload: payload };
};
github inProgress-team / react-native-meteor / src / ReactiveDict.js View on Github external
const stringify = function(value) {
  if (value === undefined) return 'undefined';
  return EJSON.stringify(value);
};
github thomasgazzoni / rxjs-ddp-client / example / MyDDPServer.ts View on Github external
let responseUpdate = {
      msg: 'updated',
      id,
    };

    switch (method) {
      case 'login':
        response.result = 'mock_session_id';
        break;
      default:
        break;
    }

    server.send(EJSON.stringify(response));
    server.send(EJSON.stringify(responseUpdate));
  }
github thomasgazzoni / rxjs-ddp-client / example / MyDDPServer.ts View on Github external
publicationName: string,
    id: number,
    params: any,
  ) {
    const response = {
      id: `test_${publicationName}`,
      msg: 'added',
      collection: publicationName,
      fields: {
        _id: `test_${publicationName}`,
        full_name: 'Test',
        email: 'test@test.com',
      },
    };

    server.send(EJSON.stringify(response));
  }
}
github Gregivy / simpleddp / src / simpleddp.js View on Github external
exportData(format) {
		if (format === undefined || format == 'string') {
			return EJSON.stringify(this.collections);
		} else if (format == 'raw') {
			return fullCopy(this.collections);
		}
	}

ejson

EJSON - Extended and Extensible JSON library from Meteor made compatible for Nodejs and Browserify

MIT
Latest version published 2 years ago

Package Health Score

54 / 100
Full package analysis