How to use the ejson.clone 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 / Meteor.js View on Github external
if (!existing.ready) existing.readyCallback = callbacks.onReady;
      }
      if (callbacks.onStop) {
        existing.stopCallback = callbacks.onStop;
      }
    } else {
      // New sub! Generate an id, save it locally, and send message.

      id = Random.id();
      const subIdRemember = Data.ddp.sub(name, params);

      Data.subscriptions[id] = {
        id: id,
        subIdRemember: subIdRemember,
        name: name,
        params: EJSON.clone(params),
        inactive: false,
        ready: false,
        readyDeps: new Trackr.Dependency(),
        readyCallback: callbacks.onReady,
        stopCallback: callbacks.onStop,
        stop: function() {
          Data.ddp.unsub(this.subIdRemember);
          delete Data.subscriptions[this.id];
          this.ready && this.readyDeps.changed();

          if (callbacks.onStop) {
            callbacks.onStop();
          }
        },
      };
    }
github DefinitelyTyped / DefinitelyTyped / ejson / ejson-tests.ts View on Github external
function testImportedClone() {
  var obj: Object = {
    a: "a"
  };
  var retval: Object = importedClone(obj);

  var str: string = "as";
  var retval2: string = importedClone(str);
}
github DefinitelyTyped / DefinitelyTyped / ejson / ejson-tests.ts View on Github external
function testImportedClone() {
  var obj: Object = {
    a: "a"
  };
  var retval: Object = importedClone(obj);

  var str: string = "as";
  var retval2: string = importedClone(str);
}
github Streemo / react-ddp / src / ddp.js View on Github external
_registerSub(id, opts){
    this._subsCache[id] = {
      id: id,
      name: opts.name,
      data: clone(opts.data || null),
      cached: opts.cache || false,
      stop: () => {
        this.unsub(id);
        delete this._subsCache[id];
      }
    }
  }
  _findExactSub(opts){
github Streemo / react-ddp / src / ddp.js View on Github external
call(opts, cb){
    /*
      opts = {
        name: string,
        check: validationFunc,
        data: payload (params)
      }
    */
    let d = clone(opts.data);
    try {
      if (!opts.name){
        cb && cb(new Error('method-name'));
      }
      opts.check && opts.check(d, this._userId.v);
    } catch (err){
      return cb && cb(err);
    }
    if (d){
      d.password && (d.password = this._encrypt(d.password));
    }
    let mId = this.method(opts.name, d ? [d] : []);
    if (!cb){return;};
    let listener = (res) => {
      if (res.id === mId){
        res.error ? cb && cb(res.error) : cb && cb(null,res.result)
github Streemo / react-ddp / src / ddp.js View on Github external
changePassword(opts,cb){
    /*
      opts = {
        check: validationFunc,
        data: {
          oldPassword: ...,
          newPassword: ...
        }
      }
    */
    let d = clone(opts.data);
    try {
      if (!d){
        throw new Error('no-params')
      } else if (!d.oldPassword){
        throw new Error('no-old-password')
      } else if (!d.newPassword){
        throw new Error('no-new-password')
      }
      opts.check && opts.check(d, this._userId.v);
    } catch (err){
      return cb && cb(err);
    }
    d.oldPassword = this._encrypt(d.oldPassword);
    d.newPassword = this._encrypt(d.newPassword);
    let mId = this.method("changePassword", [d.oldPassword,d.newPassword]);
    if (!cb){return;};

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