How to use the ejson.equals 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 inProgress-team / react-native-meteor / src / Collection.js View on Github external
// collection has no _id.
      throw new Error('can only transform documents with _id');
    }

    var id = doc._id;
    // XXX consider making tracker a weak dependency and checking Package.tracker here
    var transformed = Tracker.nonreactive(function() {
      return transform(doc);
    });

    if (!isPlainObject(transformed)) {
      throw new Error('transform must return object');
    }

    if (_.has(transformed, '_id')) {
      if (!EJSON.equals(transformed._id, id)) {
        throw new Error("transformed document can't have different _id");
      }
    } else {
      transformed._id = id;
    }
    return transformed;
  };
  wrapped.__wrappedTransform__ = true;
github inProgress-team / react-native-meteor / src / Meteor.js View on Github external
//       Meteor.subscribe("foo", Session.get("foo"));
    //       Meteor.subscribe("bar", Session.get("bar"));
    //     });
    //
    // If "foo" has changed but "bar" has not, we will match the "bar"
    // subcribe to an existing inactive subscription in order to not
    // unsub and resub the subscription unnecessarily.
    //
    // We only look for one such sub; if there are N apparently-identical subs
    // being invalidated, we will require N matching subscribe calls to keep
    // them all active.

    let existing = false;
    for (var i in Data.subscriptions) {
      const sub = Data.subscriptions[i];
      if (sub.inactive && sub.name === name && EJSON.equals(sub.params, params))
        existing = sub;
    }

    let id;
    if (existing) {
      id = existing.id;
      existing.inactive = false;

      if (callbacks.onReady) {
        // If the sub is not already ready, replace any ready callback with the
        // one provided now. (It's not really clear what users would expect for
        // an onReady callback inside an autorun; the semantics we provide is
        // that at the time the sub first becomes ready, we call the last
        // onReady callback provided, if any.)
        if (!existing.ready) existing.readyCallback = callbacks.onReady;
      }
github DefinitelyTyped / DefinitelyTyped / ejson / ejson-tests.ts View on Github external
function testEquals() {
  var a: any;
  var b: any;
  var retval: boolean = importedEquals(a,b);
}
github Streemo / react-ddp / src / ddp.js View on Github external
_findExactSub(opts){
    let subs = this._subsCache;
    let sub;
    if (!opts.id && !opts.name){
      return null;
    } else if (opts.id){
      sub = subs[opts.id]
    }
    if (!sub && opts.name){
      for (let id in subs){
        let s = subs[id];
        if (s.name === opts.name){
          if (equals(opts.data || null,s.data)){
            sub = s;
            break;
          }
        }
      }
    }
    return sub || null;
  }
  _findSubsWithName(name){
github inProgress-team / react-native-meteor / src / ReactiveDict.js View on Github external
typeof value !== 'number' &&
      typeof value !== 'boolean' &&
      typeof value !== 'undefined' &&
      !(value instanceof Date) &&
      !(ObjectID && value instanceof ObjectID) &&
      value !== null
    )
      throw new Error('ReactiveDict.equals: value must be scalar');

    const serializedValue = stringify(value);

    let oldValue = undefined;
    if (Object.keys(this.keys).indexOf(key) != -1) {
      oldValue = parse(this.keys[key]);
    }
    return EJSON.equals(oldValue, value);
  }
  _setObject(object) {

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