Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
filter( ( [ , visible ] ) => visible ),
take( 1 ),
map( ( [ value ] ) => ( {
type: 'VALIDATE',
payload: {
value,
transient: true
}
} ) )
),
pipe(
value$,
dropUntil( mount$ ),
distinctUntilChanged(),
debounce( 250 ),
map( ( value ) => ( {
type: 'VALIDATE',
payload: {
value,
transient: false
}
} ) )
),
pipe(
unmount$,
map( () => ( {
type: 'RESET'
} ) )
)
);
const pipeline2 = actions =>
pipe(
actions,
debounce(250),
reducerFromMap(reducers2),
startWith({ counter: 1 })
);
const aperture = ({ observe }) =>
pipe(
observe('username'),
filter(Boolean),
debounce(1000),
map(username =>
fromPromise(
fetch(`https://api.github.com/users/${username}`).then(res =>
res.json()
)
)
),
flatten,
map(({ message }) => ({
type: message === 'Not Found' ? 'USERNAME_AVAILABLE' : 'USER_FOUND'
}))
)
const aperture = ({ observe }) =>
pipe(
observe('username'),
filter(Boolean),
debounce(1000),
map(username =>
fromPromise(
fetch(`https://api.github.com/users/${username}`).then(res =>
res.json()
)
)
),
flatten,
map(payload => ({ type: 'USER_DATA_RECEIVE', payload }))
)
map(({ items = [] }) => items.slice(0, 10)),
map(suggestions => ({ suggestions })),
map(toState)
)
const clearSuggestions$ = pipe(
search$,
filter(search => search === ''),
map(() => ({ suggestions: [] })),
map(toState)
)
const user$ = pipe(
component.observe('selection'),
filter(Boolean),
debounce(200),
map(selection =>
fromPromise(
fetch(`https://api.github.com/users/${selection}`).then(res =>
res.json()
)
)
),
flatten,
map(user => ({ user })),
map(toState)
)
return merge(suggestions$, clearSuggestions$, user$)
}