const promise = connectionPromise.then(connection => { cancelObj.cancel = async () => { cancelled = true; }; return fn(connection, queryId) .then(res => this.pool.release(connection).then(() => { if (cancelled) { throw new Error('Query cancelled'); .catch((err) => this.pool.release(connection).then(() => { if (cancelled) { throw new Error('Query cancelled');
const promise = connectionPromise.then(conn => { cancelObj.cancel = async () => { cancelled = true; }; return fn(conn) .then(res => this.pool.release(conn).then(() => { if (cancelled) { throw new Error('Query cancelled'); .catch((err) => this.pool.release(conn).then(() => { if (cancelled) { throw new Error('Query cancelled');
return metrics.report('escape', {inspecter: 'javier'}) .should.be.fulfilled .then(() => { counter.should.equal(reportable); }) .then(() => axios.create.restore()); }); })); return metrics.report() .then(() => { metrics.log.debug.callCount.should.equal(reportable + 1); }) .should.be.fulfilled .then(() => axios.create.restore()); }); return metrics.report('escape', {freedman: 'valjean'}) .delay(5) .then(() => metrics.report('apprehended', {prisoner: 'valjean'})) .then(() => axios.create.restore()); }); });
sinon.stub(_shell, 'exec').callsFake(fakeExec); return shell.sh(['slip', 'sliding', 'away']) .then(result => { result.should.equal('EXEC: slip sliding away'); }) .then(_shell.exec.restore()) .should.be.fulfilled; }); _.forEach([{mode: 'collect'}, {detached: true}], opts => { return shell.sh(['tupelo', 'honey', 'baby'], opts) .then(result => { result.should.equal('SPAWN: tupelo honey baby'); }) sinon.stub(child, 'spawn').callsFake(fakeSpawn); return shell.sh(['set', 'us', 'up', 'the', 'bomb'], {mode: 'attach'}).should.be.rejected .then(child.spawn.restore()); }); sinon.stub(child, 'spawn').callsFake(fakeSpawn); return shell.sh(['van', 'the', 'man'], {detached: true}).should.be.fulfilled .then(child.spawn.restore()); }); }); return shell.sh(['van', 'the', 'man'], {mode: 'attach'}).should.be.fulfilled .then(child.spawn.restore()) .then(() => {
const promise = connectionPromise.then(async conn => { const [{ connectionId }] = await conn.execute('select connection_id() as connectionId'); cancelObj.cancel = async () => { }; return fn(conn) .then(res => this.pool.release(conn).then(() => { if (cancelled) { throw new Error('Query cancelled'); .catch((err) => this.pool.release(conn).then(() => { if (cancelled) { throw new Error('Query cancelled');
auth.createUser(args.username, args.password).then((userCreatedSucessfully) => { if (userCreatedSucessfully) { return "User created sucessfully!"; } else { throw new Error("User could not be created"); } })
export default function configureStore(onComplete) { const rootReducer = storage.reducer(reducers); const engine = createEngine('Docstash'); const storeMiddleware = storage.createMiddleware(engine, reduxStorageActions); let store = createStore(rootReducer, compose(applyMiddleware(thunk, reduxImmutableStateInvariant(), logger, storeMiddleware), window.devToolsExtension && window.devToolsExtension())); const load = storage.createLoader(engine); load(store).then(onComplete).catch(() => console.log('Failed to load previous state')); return store; }
const sendPromise = () => (req: Request, res: Response, next: NextFunction) => { res.sendPromise = (promise: PromiseLike<any>) => { promise.then( (item: any) => res.json(item), (err: Error) => { next(err); } ); }; next(); }
export default function configureStore(onComplete) { const rootReducer = storage.reducer(reducers); const engine = createEngine('Docstash'); const storeMiddleware = storage.createMiddleware(engine, reduxStorageActions); let store = createStore(rootReducer, applyMiddleware(thunk, storeMiddleware)); const load = storage.createLoader(engine); load(store).then(onComplete).catch(() => console.log('Failed to load previous state')); return store; }
userRepository.getUserShowReviews(root._id).then(function (reviews) { console.log(reviews); return reviews; })
auth.validatePassword(args.username, args.password).then((validLogin) => { if (validLogin) { context.session.name = args.username; return "Logged in successfully!"; } else { throw new Error("login failed!"); } })
userRepository.getUserEpisodeReviews(root._id).then((reviews) => { console.log(reviews); return reviews; })
const sendPromise = () => (req: Request, res: Response, next: NextFunction) => { res.sendPromise = (promise: PromiseLike<any>) => { promise.then( (item: any) => res.json(item), (err: Error) => { next(err); } ); }; next(); }
auth.validatePassword(args.username, args.password).then(function (validLogin) { if (validLogin) { context.session.name = args.username; return "Logged in successfully!"; } else { throw new Error("login failed!"); } })