Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return createErrorObservable(
new Error('Next Challenge could not be found')
);
}
if (nextChallenge.isLocked) {
return Observable.of(
makeToast({
message: 'The next challenge has not been unlocked. ' +
'Please revisit the required (*) challenges ' +
'that have not been passed yet. ',
timeout: 15000
}),
onRouteCurrentChallenge()
);
}
return Observable.of(
// normally we wouldn't need to add the lang as
// addLangToRoutesEnhancer should add langs for us, but the way
// enhancers/middlewares and RFR orders things this action will not
// see addLangToRoutesEnhancer and cause RFR to render NotFound
onRouteChallenges({ lang, ...nextChallenge }),
makeToast({ message: 'Your next challenge has arrived.' })
);
});
}
it("merges the values from the demuxed list", done => {
const list$$ = O.merge(
O.just([{A: O.of("a1_1"), B: O.of("b1_1")}, {A: O.of("a1_21", "a1_22"), B: O.of("b1_2")}]),
O.just([{A: O.of("a2_1"), B: O.of("b2_1")}, {A: O.of("a2_2"), B: O.of("b2_2")}]).delay(1)
)
const out = flatMerge(list$$, "A")
out.A.bufferWithCount(5).subscribe(x => {
x.should.deepEqual(["a1_1", "a1_21", "a1_22", "a2_1", "a2_2"])
done()
})
})
() => {
const history = createServerHistory('/')
const router = makeRouterDriver(history, switchPath)(Observable.of('/'), RxAdapter)
.path('/')
assert.notStrictEqual(router.path, null)
assert.strictEqual(typeof router.path, 'function')
assert.notStrictEqual(router.define, null)
assert.strictEqual(typeof router.define, 'function')
assert.notStrictEqual(router.history$, null)
assert.strictEqual(typeof router.history$, 'object')
assert.strictEqual(typeof router.history$.subscribe, 'function')
assert.notStrictEqual(router.createHref, null)
assert.strictEqual(typeof router.createHref, 'function')
})
function app () {
return {
html: Observable.of(h('div.test-element', [
Observable.of(h('div.a-nice-element', [
String('foobar'),
Observable.of(h('h3.myelementclass'))
]))
]))
}
}
let {sinks, sources} = Cycle.run(app, {
function main () {
return {
DOM: Observable.of(
div('.my-render-only-container', [
h2('Cycle.js framework')
])
)
}
}
function App (sources) {
const triangleElement$ = sources.DOM.select('.triangle').elements
const svgTriangle = svg({width: 150, height: 150}, [
svg.polygon({
attrs: {
class: 'triangle',
points: '20 0 20 150 150 20'
}
})
])
return {
DOM: Observable.of(svgTriangle),
triangleElement: triangleElement$
}
}
export function mergeStores(...stores) {
const cstates$ = stores.map((cstore) => cstore.getObservable());
const state$ = Observable.of({})
.concat(Observable.merge(...cstates$))
.scan((state, cstate) => {
return Object.keys(cstate).reduce((s, prop) => {
const value = cstate[prop];
return s[prop] === value ? s : { ...s, [prop]: value };
}, state);
})
.skip(1)
.distinctUntilChanged()
.shareReplay(1)
;
const action$ = new Subject();
action$.subscribe((action) => {
stores.forEach((cstore) => cstore.dispatch(action));
});
return new Store(action$, state$);
const body = { ...challengeInfo, _csrf };
const saveChallenge = postJSON$(url, body)
.retry(3)
.map(({ points, lastUpdated, completedDate }) =>
submitChallengeComplete(
username,
points,
{ ...challengeInfo, lastUpdated, completedDate }
)
)
.catch(createErrorObservable);
const challengeCompleted = Observable.of(moveToNextChallenge());
return Observable.merge(saveChallenge, challengeCompleted)
.startWith({ type: types.submitChallenge.start });
}),
Observable.of(moveToNextChallenge())
);
}
User.prototype.getCompletedChallenges$ = function getCompletedChallenges$() {
if (
Array.isArray(this.completedChallenges) &&
this.completedChallenges.length
) {
return Observable.of(this.completedChallenges);
}
const id = this.getId();
const filter = {
where: { id },
fields: { completedChallenges: true }
};
return this.constructor.findOne$(filter).map(user => {
this.completedChallenges = user.completedChallenges;
return user.completedChallenges;
});
};
module.exports = function authorize(routerInstance, match, next) {
if (!match.authorize) {
return Observable.
of(true).
flatMap(function() { return next; });
}
var out = match.authorize.call(routerInstance, match);
return outputToObservable(out).
doAction(function(isAuthorized) {
if (!isAuthorized) {
throw new JSONGraphError({
$type: $type.$error,
value: {
unauthorized: true,
message: 'unauthorized'
}
});
}