Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
}
else {
qs = querystring(options.data)
qs && (url += (url.indexOf('?') >= 0 ? '&' : '?') + qs)
}
// create XMLHttpRequest
var http = xhr()
// handle error
if (http === null) {
err = new Error("Your broswer don't support ajax!")
isFunction(options.error) && options.error(err)
isFunction(callback) && callback(err)
if (typeof Promise !== "undefined") return Promise.reject(err)
return
}
// open XMLHttpRequest
http.open(method, url, options.async)
// set request headers
forEach(options.headers, function (value, key) {http.setRequestHeader(key, value)})
// set response type
options.type && (http.responseType = options.type)
function send (resolve, reject) {
http.onreadystatechange = function () {
// complete
XhrProvider.prototype.open = function(method, url, async, user, password) {
"use strict";
if (typeof async !== "undefined" && async !== true) {
return PromiseCompat.reject({
errcode: "InvalidAccessError",
message: "async should always be set to true"
});
}
// Force async to be true. undefined can lead to async=false in Chrome packaged apps
this._xhr.open(method, url, true, user, password);
return PromiseCompat.resolve();
};
.then(data => {
if (data[0]) {
// 邮箱已存在
return Promise.reject(statusCode.err10002)
}
if (data[1]) {
// 手机号已存在
return Promise.reject(statusCode.err10003)
}
return proxyUser.createUser({
email,
phone,
pass,
isNew: true
})
})
.then(() => {
it('should convert a rejected promise to a stream', (done: any) => {
const stream = xs.from(Promise.reject('no'));
stream.addListener({
next: (x: string) => done('next should not be called'),
error: (err: any) => {
assert.strictEqual(err, 'no');
done();
},
complete: () => done('complete should not be called'),
});
});
.catch(function(err){
console.log(new Date() + ' refresh day data error2 ' + err)
tmpDAO.save({aid: '', dtime: dtime});
return Promise.reject(err);
})
},
requestError(_requestError) {
if (!hasErrorModal) {
Modal.error({
title: DEFAULT_REQ_ERROR,
onOk: () => {
hasErrorModal = false;
}
});
hasErrorModal = true;
}
return Promise.reject(_requestError);
}
};
RTCPeerConnectionAdapter.prototype.getStreamById = function (id) {
return PromiseCompat.reject({
errcode: -1,
message: "Not Implemented"
});
};
const theListIsSuitable = path => function(list) {
if (!path.isa(list.type)) { return (Promise.reject(LIST_NOT_SUITABLE)); }
} ;
Daemon.prototype.set = function (data) {
if (!data && !data.token && !data.passphrase) {
return Promise.reject(new TypeError(
'Must provide object with token or passphrase properties'));
}
var id = uuid.v4();
var msg = {
type: 'request',
id: id,
command: 'set',
body: {
token: data.token,
passphrase: data.passphrase
}
};
var p = this._wrap(id);
this.client.send(msg).catch(p.reject);
public async scroll(topBottom: string, leftRight: string): P {
const size = await browser.manage().window().getSize();
const directions: Object = {
top: 0,
bottom: size.height,
left: 0,
right: size.width,
};
if (!directions.hasOwnProperty(topBottom) || !directions.hasOwnProperty(leftRight)) {
return P.reject(`unknown directions [${topBottom}, ${leftRight}`);
}
const x = directions[leftRight];
const y = directions[topBottom];
log.info(`scrolling to [x=${x},y=${y}]`);
return browser.driver.executeScript((browserX, browserY) => window.scrollTo(browserX, browserY), x, y);
}
}