Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.flatMap((t: {file: FileType, fileReaders: Array}) => {
const {filename, stats: fileStats} = t.file
let fileReaders = t.fileReaders
if (notes) {
const note = notes[filename]
if (note && note.stats.mtime.getTime() === fileStats.mtime.getTime()) {
fileReaders = fileReaders.filter(fileReader => note[fileReader.notePropName] === undefined)
}
if (fileReaders.length === 0) return Bacon.never() // e.g. a cached note that have all read values already
}
return Bacon
.fromArray(fileReaders)
.flatMap((fileReader: FileReaderType) => {
const readResult: FileReaderResultType = {
filename: filename,
notePropName: fileReader.notePropName,
value: null
}
return Bacon
.fromNodeCallback(fileReader.read.bind(fileReader), notesPath.fullPath(filename), fileStats)
.map(value => {
readResult.value = value === undefined ? null : value // make sure value cannot be undefined
return readResult
})
.mapError(err => {
console.warn('failed to read file:', err)
return readResult
it('debounces two streams', () => {
var streams = Bacon.fromArray([ 1, 2 ].map(idx => [ makeEvent(idx) ]))
var compiler = new PipelineCompiler
var opData = { compiler }
return compiler.compile([
op => streams,
plugin(debounce, 100)
])
.then(streams => streams.toPromise(Promise))
.then(events => {
events = events.sort()
events[0].path.should.equal('file1.js')
events.length.should.equal(2)
events[1].path.should.equal('file2.js')
})
})
})
function connectForever(_url) {
expect(_url).toStrictEqual(url);
return Bacon.fromArray([
{
radio1: {
type: "song",
song: {
id: "song1-1",
startTime: 100
}
},
radio2: {
type: "song",
song: {
id: "song2-1",
startTime: 110
}
},
radio3: {
.add('bacon', function(deferred) {
runners.runBacon(deferred, bacon.fromArray(a).scan(0, sum).reduce(0, passthrough));
}, options)
.add('highland', function(deferred) {
if (binaryExists(distribution)) {
return Bacon.once('Already downloaded ' + distribution.name + '@' + distribution.version)
}
return fetchBinary(distribution.dist)
.doAction(function(data) {
if (sha1(data) != distribution.dist.shasum) {
throw new Error('SHA checksum of ' + distribution.name + '@' + distribution.version + ' does not match')
}
fs.writeFileSync(packageBinaryFilePath(distribution.name, distribution.version), data)
})
.map('Downloaded ' + distribution.name + '@' + distribution.version)
})
}
var dependencies = dependenciesToArray(require(rootPackage).dependencies)
var downloaded = Bacon.fromArray(dependencies)
.flatMap(resolveVersionAndDependencies)
.mapEnd(collectedPackagesAsArray)
.flatMap(Bacon.fromArray)
.flatMapWithConcurrencyLimit(5, downloadPackage)
downloaded.log()
downloaded.onError(function(err) {
throw new Error(err)
})
ais: {
enabled: false
},
worldBaseChart: true,
chartProviders: [],
loadingChartProviders: true,
data: [],
instruments: _.keys(InstrumentConfig)
}
const fromLocalStorage = Store.get(LOCAL_STORAGE_KEY) || {}
const charts = _.get(window.INITIAL_SETTINGS, 'charts', [])
const settings = Atom(_.assign(defaultSettings, _.omit(window.INITIAL_SETTINGS, ['charts']) || {}, fromLocalStorage))
const chartProviders = Bacon.fromArray(charts)
.flatMap(provider => {
switch (provider.type) {
case 'local':
return fetchLocalCharts(provider, fromLocalStorage.hiddenChartProviders)
case 'signalk':
return fetchSignalKCharts(provider, fromLocalStorage.hiddenChartProviders)
default:
return Bacon.once(provider)
}
})
.fold([], _.concat)
chartProviders.onValue(charts => {
settings.view(L.prop('chartProviders')).set(charts)
settings.view(L.prop('loadingChartProviders')).set(false)
})
.add('bacon', function (deferred) {
var source = bacon.fromArray(a);
var inc = source.filter(isPositive).map(returnPlus1);
var dec = source.filter(isNegative).map(returnMinus1);
var count = inc.merge(dec).scan(0, addXY);
var label = bacon.fromArray(['initial', 'Count is ']);
var view = bacon.combineWith(renderWithArgs, label, count);
runners.runBacon(deferred, view);
}, options)
.flatMap(charts => {
return Bacon.fromArray(
_.map(charts, chart => {
const from = _.pick(chart, [
'tilemapUrl',
'index',
'type',
'name',
'minzoom',
'maxzoom',
'center',
'description',
'format',
'bounds'
])
return _.merge(
{
id: chart.name,
.add('bacon', function(deferred) {
runners.runBacon(deferred, bacon.fromArray(a).map(add1).filter(odd).map(add1).map(add1).filter(even).reduce(0, sum));
}, options)
.add('highland', function(deferred) {
.flatMap(function(packageAndDependencies) {
if (collectPackage(packageAndDependencies)) {
return Bacon.fromArray(packageAndDependencies.dependencies)
.flatMapConcat(resolveVersionAndDependencies)
}
return Bacon.never()
})
}