Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let stdOutStream = Observable
.fromEvent(process.stdout, 'data')
.map(mapFrom('stdout'))
.share();
// Since STDERR is a stream just like STDOUT it doesn't
// really work to propagate that with Observable/error.
// Instead we combine STDOUT and STDERR to one stream.
let stdErrStream = Observable
.fromEvent(process.stderr, 'data')
.map(mapFrom('stderr'))
.share();
let closeStream = Observable.fromEvent(process, 'close').share();
return Observable.merge(stdOutStream, stdErrStream).takeUntil(closeStream);
}
.mergeMap(packageJsonUri => Observable.merge(
castArray(this.projectManager.getParentConfiguration(packageJsonUri) || []),
// Search child directories starting at the directory of the package.json
observableFromIterable(this.projectManager.getChildConfigurations(url.resolve(packageJsonUri, '.')))
))
// Else search all tsconfigs in the workspace
import {Actions, dispatch} from 'shared/actions'
import {add} from 'ramda'
import combineLatestObj from 'shared/utils/combineLatestObj'
/* ========================== state ========================================= */
const increase =
getPayload(Actions.COUNTER_INCREASED)
.mapTo(1)
const decrease =
getPayload(Actions.COUNTER_DECREASED)
.mapTo(-1)
export const count =
Observable
.merge(increase, decrease)
.scan(add)
.startWith(0)
/* ========================== handlers ====================================== */
export const increaseCount =
Observable.of(() => {
dispatch(Actions.COUNTER_INCREASED)
})
export const decreaseCount =
Observable.of(() => {
dispatch(Actions.COUNTER_DECREASED)
})
getStatistic(userId: string, year: number, month: ShortMonth): Observable {
let executions$ = Observable.merge(
dbRefBuilder.userExecutionsByMonthRef(userId, year, month).onceValue(),
dbRefBuilder.userExecutionsLiveRef(userId).onceValue()
)
.map(snapshot => snapshot.val())
.map(val => val ? Object.keys(val) : [])
.flatMap(executionIds => Observable.from(executionIds)
.flatMap(id => dbRefBuilder.executionRef(id).onceValue()))
.map(snapshot => snapshot.val())
.filter(execution => execution !== null);
return this.costCalculator.calc(executions$)
.map(costReport => ({
costReport: costReport,
secondsLeft: FREE_MONTHLY_COMPUTATION_SECONDS - costReport.totalSeconds
}));
}