Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var func1: (a: string, cb: (result: number) => void) => number = () => 0;
obsNum = Rx.Observable.fromCallback(func1)("");
obsNum = Rx.Observable.fromCallback(func1, {})("");
obsNum = Rx.Observable.fromCallback(func1, {}, (results: number[]) => results[0])("");
// 2 arguments
var func2: (a: number, b: string, cb: (result: string) => number) => Date = () => new Date();
obsStr = Rx.Observable.fromCallback(func2)(1, "");
obsStr = Rx.Observable.fromCallback(func2, {})(1, "");
obsStr = Rx.Observable.fromCallback(func2, {}, (results: string[]) => results[0])(1, "");
// 3 arguments
var func3: (a: number, b: string, c: boolean, cb: (result: string) => number) => Date = () => new Date();
obsStr = Rx.Observable.fromCallback(func3)(1, "", true);
obsStr = Rx.Observable.fromCallback(func3, {})(1, "", true);
obsStr = Rx.Observable.fromCallback(func3, {}, (results: string[]) => results[0])(1, "", true);
// multiple results
var func0m: (cb: (result1: number, result2: number, result3: number) => void) => void = () => { };
obsNum = Rx.Observable.fromCallback(func0m, obsStr, (results: number[]) => results[0])();
var func1m: (a: string, cb: (result1: number, result2: number, result3: number) => void) => void = () => { };
obsNum = Rx.Observable.fromCallback(func1m, obsStr, (results: number[]) => results[0])("");
var func2m: (a: string, b: number, cb: (result1: string, result2: string, result3: string) => void) => void = () => { };
obsStr = Rx.Observable.fromCallback(func2m, obsStr, (results: string[]) => results[0])("", 10);
}
var DHTSensor = require('node-dht-sensor');
var Rx = require('rx-lite');
// 大于,condi < value
Rx.Observable.prototype.max = function (condi) {
var input = this;
return Rx.Observable.create(function (observe) {
var handle = input.subscribe(
function (value) {
if (value > condi) {
observe.onNext(value);
}
},
function (error) {
observe.onError(error);
},
function(value) {
observe.onCompleted(value);
}
);
return function () {
buildObservable({startTime, endTime}) {
const $events = super.buildObservable({startTime, endTime});
const $proposedTimes = Rx.Observable.fromStore(ProposedTimeCalendarStore)
.map((store) => store.proposalsAsEvents())
const $obs = Rx.Observable.combineLatest([$events, $proposedTimes])
.map(([calEvents, proposedTimes]) => {
return {events: calEvents.concat(proposedTimes)}
})
this.observable = $obs;
return $obs;
}
}
const end = Event.attributes.recurrenceEnd;
const start = Event.attributes.recurrenceStart;
let matcher = new Matcher.Or([
new Matcher.And([start.lte(endTime), end.gte(startTime)]),
new Matcher.And([start.lte(endTime), start.gte(startTime)]),
new Matcher.And([end.gte(startTime), end.lte(endTime)]),
new Matcher.And([end.gte(endTime), start.lte(startTime)]),
]);
if (disabledCalendars && disabledCalendars.length) {
new Matcher.And([matcher, Event.attributes.calendarId.notIn(disabledCalendars)]);
}
const query = DatabaseStore.findAll(Event).where(matcher);
this.observable = Rx.Observable.fromQuery(query).flatMapLatest(results => {
const events = [];
results.forEach(result => {
const icalExpander = new IcalExpander({ ics: result.ics, maxIterations: 100 });
const expanded = icalExpander.between(new Date(startTime * 1000), new Date(endTime * 1000));
[...expanded.events, ...expanded.occurrences].forEach((e, idx) => {
const start = e.startDate.toJSDate().getTime() / 1000;
const end = e.endDate.toJSDate().getTime() / 1000;
const item = e.item || e;
events.push({
start,
end,
id: `${result.id}-e${idx}`,
calendarId: result.calendarId,
title: item.summary,
displayTitle: item.summary,
buildObservable({startTime, endTime}) {
const $events = super.buildObservable({startTime, endTime});
const $proposedTimes = Rx.Observable.fromStore(ProposedTimeCalendarStore)
.map((store) => store.proposalsAsEvents())
const $obs = Rx.Observable.combineLatest([$events, $proposedTimes])
.map(([calEvents, proposedTimes]) => {
return {events: calEvents.concat(proposedTimes)}
})
this.observable = $obs;
return $obs;
}
}
end,
id: `${result.id}-e${idx}`,
calendarId: result.calendarId,
title: item.summary,
displayTitle: item.summary,
description: item.description,
isAllDay: end - start >= 86400 - 1,
organizer: item.organizer ? { email: item.organizer } : null,
attendees: item.attendees.map(a => ({
...a.jCal[1],
email: a.getFirstValue(),
})),
});
});
});
return Rx.Observable.from([{ events }]);
});
return this.observable;
_initializeComponent(props) {
this.todayYear = this._now().year()
this.todayDayOfYear = this._now().dayOfYear()
if (this._sub) {
this._sub.dispose();
}
const startMoment = this._calculateStartMoment(props);
const endMoment = this._calculateEndMoment(props);
const mouseHandlerObserver = Rx.Observable.create(this._mouseHandlerSubscribe);
this._sub = this.props.dataSource.buildObservable({
disabledCalendars: props.disabledCalendars,
startTime: startMoment.unix(),
endTime: endMoment.unix(),
mouseHandlerObserver: mouseHandlerObserver,
}).subscribe((state) => {
this.setState(state);
})
this.setState({startMoment, endMoment})
const percent = (this._scrollTime - startMoment.unix()) / (endMoment.unix() - startMoment.unix())
if (percent < 0 || percent > 1) {
this._scrollTime = startMoment.unix();
} else {
const weekStart = moment(props.currentMoment).startOf('day').weekday(0).unix()
this._scrollTime = weekStart
load(uri) {
let dir = this.getDirectory(uri)
let cd
if (dir != this.compilerOptions.src) {
this.compilerOptions.src = dir
cd = this.changeDirectory(dir).map((_) => {
return dir
})
} else {
cd = Rx.Observable.of(dir)
}
return cd.flatMap((_) => {
return this.prepareCommand([':load-file', uri])
})
}
constructor() {
super()
this._waitForModalClose = []
this.NoProAccess = NoProAccess
/**
* The IdentityStore triggers both after we update it, and when it
* polls for new data every several minutes or so.
*/
this._disp = Rx.Observable.fromStore(IdentityStore).subscribe(() => {
this.trigger()
})
this._usub = Actions.closeModal.listen(this._onModalClose)
}
Rx.Observable.fromAction = action => {
return Rx.Observable.create(observer => {
const unsubscribe = action.listen((...args) => observer.onNext(...args));
return Rx.Disposable.create(unsubscribe);
});
};
Rx.Observable.fromQuery = query => {
return Rx.Observable.create(observer => {
const unsubscribe = QuerySubscriptionPool.add(query, result => observer.onNext(result));
return Rx.Disposable.create(unsubscribe);
});
};
Rx.Observable.fromNamedQuerySubscription = (name, subscription) => {
return Rx.Observable.create(observer => {
const unsubscribe = QuerySubscriptionPool.addPrivateSubscription(name, subscription, result =>
observer.onNext(result)
);
return Rx.Disposable.create(unsubscribe);
});
};