Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
}
},
};
}
function testImportedClone() {
var obj: Object = {
a: "a"
};
var retval: Object = importedClone(obj);
var str: string = "as";
var retval2: string = importedClone(str);
}
function testImportedClone() {
var obj: Object = {
a: "a"
};
var retval: Object = importedClone(obj);
var str: string = "as";
var retval2: string = importedClone(str);
}
_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){
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)
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;};