Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
discounts () {
const coupon = this.items.coupon;
let promise = Promise.resolve();
this.price.now.discount = 0;
this.price.next.discount = 0;
// Remove all previously-applied coupons
this.validSubscriptions.forEach(sub => {
promise = promise.then(() => sub.coupon().reprice(null, { internal: true }));
});
if (!coupon) return promise;
if (coupon.discount.type === 'free_trial') {
promise = promise.then(() => this.applyFreeTrialCoupon());
} else {
const { discountNow, discountNext } = this.discountAmounts();
this.price.now.discount = discountNow;
}).then(([depNames, dependencies]) => {
let p = Promise.resolve();
const filteredPairs = [];
dependencies.forEach((modDep, i) => {
const name = depNames[i];
if (modDep == null) {
// It is possible to require mocks that don't have a real
// module backing them. If a dependency cannot be found but there
// exists a mock with the desired ID, resolve it and add it as
// a dependency.
if (allMocks && allMocks[name] && !mocks[name]) {
const mockModule = this._moduleCache.getModule(allMocks[name]);
mocks[name] = allMocks[name];
return filteredPairs.push([name, mockModule]);
}
debug(
async function h(arg) {
return await Promise.all([
g(arg),
Promise.resolve("dummy")
]);
}
update: sinon.spy(function(packages, options, projectPath, callback) {
return Promise.resolve('1.2.4').nodeify(callback);
}),
reset: function() {
it('should concatMapTo values to resolved promises with resultSelector', function (done) {
var source = Rx.Observable.from([4,3,2,1]);
var resultSelectorCalledWith = [];
var inner = Observable.from(Promise.resolve(42));
var resultSelector = function (outerVal, innerVal, outerIndex, innerIndex) {
resultSelectorCalledWith.push([].slice.call(arguments));
return 8;
};
var results = [];
var expectedCalls = [
[4, 42, 0, 0],
[3, 42, 1, 0],
[2, 42, 2, 0],
[1, 42, 3, 0]
];
source.concatMapTo(inner, resultSelector).subscribe(
function next(x) {
results.push(x);
},
export const stopDaemon = log(() => Promise
.resolve(ipcRenderer.sendSync("stop-daemon"))
.then(stopped => {
return stopped;
}), "Stop Daemon");
}).then(value => {
if (method && method.type) {
return Promise.resolve(
validateMutationReturnType(schema, logging, method.type, value),
).then(value => {
return {s: true, v: value};
});
} else {
return true;
}
});
}
npmInstall() {
return Promise.resolve(
npm(this.command, [], {}, this.options).
then(this.errorLog.bind(this))
).
finally(this.finally.bind(this)).
then(this.announceCompletion.bind(this)).
catch(this.announceFailure.bind(this));
}
.then(transformedModules =>
Promise.resolve(
finalizeBundle({bundle, transformedModules, response, modulesByName})
).then(() => bundle)
);
triggerRoute (url, options) {
options = options || {};
options.triggerUrlChange = typeof options.triggerUrlChange !== 'undefined' ? options.triggerUrlChange : true;
if (url !== this._currentPath) {
return this._onRouteRequest(url, options);
} else {
return Promise.resolve();
}
}