How to use the ejson.parse 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 RocketChat / Rocket.Chat.ReactNative / app / lib / ddp.js View on Github external
this.connection.onmessage = (e) => {
				try {
					// console.log('received', e.data, e.target.readyState);
					const data = EJSON.parse(e.data);
					this.emit(data.msg, data);
					return data.collection && this.emit(data.collection, data);
				} catch (err) {
					log('EJSON parse', err);
				}
			};
		});
github Losant / losant-mqtt-js / lib / device.js View on Github external
Device.prototype.parseMessage = function(message) {

  // Attempt to parse the message.
  try { message = EJSON.parse(message.toString()); }
  catch(e) { return null; }

  // The message has to be something.
  if(!message) {
    return null;
  }

  return message;
};
github funnyjerry / rocketchat / app / push / index.js View on Github external
export const onNotification = (notification) => {
	if (notification) {
		const data = notification.getData();
		if (data) {
			try {
				const { rid, name, sender, type, host } = EJSON.parse(data.ejson);

				const types = {
					c: 'channel',
					d: 'direct',
					p: 'group'
				};
				const roomName = type === 'd' ? sender.username : name;

				const params = {
					host,
					rid,
					path: `${types[type]}/${roomName}`
				};
				store.dispatch(deepLinkingOpen(params));
			} catch (e) {
				console.warn(e);
github RocketChat / Rocket.Chat.ReactNative / app / notifications / push / index.js View on Github external
export const onNotification = (notification) => {
	if (notification) {
		const data = notification.getData();
		if (data) {
			try {
				const {
					rid, name, sender, type, host
				} = EJSON.parse(data.ejson);

				const types = {
					c: 'channel', d: 'direct', p: 'group'
				};
				const roomName = type === 'd' ? sender.username : name;

				const params = {
					host,
					rid,
					path: `${ types[type] }/${ roomName }`
				};
				store.dispatch(deepLinkingOpen(params));
			} catch (e) {
				console.warn(e);
			}
		}
github primus / primus / parsers / ejson.js View on Github external
exports.decoder = function decoder(data, fn) {
  var err;

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

  fn(err, data);
};
github inProgress-team / react-native-meteor / src / ReactiveDict.js View on Github external
const parse = function(serialized) {
  if (serialized === undefined || serialized === 'undefined') return undefined;
  return EJSON.parse(serialized);
};
github RocketChat / Rocket.Chat.ReactNative / app / push.js View on Github external
const handleNotification = (notification) => {
	if (notification.usernInteraction) {
		return;
	}
	const { rid, name } = EJSON.parse(notification.ejson);
	return rid && name && goRoom({ rid, name });
};
PushNotification.configure({
github Gregivy / simpleddp / src / simpleddp.js View on Github external
return new Promise((resolve, reject) => {
			let c = typeof data === 'string' ? EJSON.parse(data) : data;

			let totalDocuments = 0;
			Object.keys(c).forEach((collection)=>{
				totalDocuments += Array.isArray(c[collection]) ? c[collection].length : 0;
			});

			let counter = 0;
			let uniqueId = this._id+"-"+this._opGenId();

			const listener = this.on('added',(m,id)=>{
				if (id == uniqueId) {
					counter++;
					if (counter==totalDocuments) {
						listener.stop();
						resolve();
					}
github Lemmmy / rocketchat-irc-gateway / src / rocketchat / rocketchat.js View on Github external
onData(msg) {
    log.trace(msg);

    try {
      msg = EJSON.parse(msg);

      if (msg.msg === "changed" && msg.collection === "stream-room-messages") {
        try {
          msg.fields.args.forEach(this.onMessage.bind(this));
        } catch (e) {
          log.error(e.stack || e);
        }
      }
    } catch (ignored) {}
  }
github thomasgazzoni / rxjs-ddp-client / example / MyDDPServer.ts View on Github external
mockServer.on('message', message => {
        const data = EJSON.parse(message);
        this.mockMessageResponse(mockServer, data);
      });
    });

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