Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_saveRowHeightOnWinResize (rowsS: Bacon.Stream) {
return Bacon
.mergeAll(
rowsS.take(1),
Bacon.fromEvent(window, 'resize'))
.debounceImmediate(50) // ms
.onValue(() => {
const td = this._queryDOM('td')
if (td && td.clientHeight > 0) {
atom.config.set('textual-velocity.rowHeight', td.clientHeight)
}
})
}
});
}
// Bacon.fromEvent();
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);
// tab backup and restore
document.getElementById("backup_tabs").onclick = function() {
chrome.tabs.query({}, function(tabs) {
download(JSON.stringify(tabs, null, " "));
});
};
let restoreTab = Bacon.fromEvent(document.getElementById("restore_tabs_file"), "change");
let fileinput = document.getElementById("restore_tabs_file");
document.getElementById("restore_tabs").onclick = function() {
fileinput.click();
};
restoreTab.onValue(() => {
let filelist = fileinput.files;
var reader = new FileReader();
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
reader.onload = (function() { return function(e) {
let restoredata = e.target.result.replace(/^[^,]*,/g, "");
function handleDrawPath({map, settings, drawObject}) {
const pathMarker = Leaf.icon({
iconUrl: 'path-marker.png',
iconSize: [20, 20],
iconAnchor: [10, 10]
})
let path = []
let lastMoveAt = undefined
const del = drawObject.view(L.prop('del'))
const pathPolyline = Leaf.polyline([], {color: '#3e3e86', weight: 5})
pathPolyline.addTo(map)
Bacon.fromEvent(map, 'click')
.filter(settings.map('.drawMode'))
.filter(e => _.every(path, marker => e.latlng.distanceTo(marker._latlng) > 30))
.filter(() => lastMoveAt === undefined || Date.now() - lastMoveAt > 50) // Do not add new marker if one was just dragged
.map(e => {
const {latlng} = e
return Leaf.marker(latlng, {icon: pathMarker, draggable: true, zIndexOffset: 900})
})
.onValue(marker => {
marker.addTo(map)
path.push(marker)
marker.on('move', redrawPathAndChangeDistance)
redrawPathAndChangeDistance()
})
function redrawPathAndChangeDistance() {
lastMoveAt = Date.now()
_newChokidarEventStream (w, pathFilter, event) {
const rootPath = w.options.cwd
return Bacon
.fromEvent(w, event, (relPath, stat) => {
const path = Path.join(rootPath, relPath)
if (pathFilter.isFileAccepted(path)) {
return {
path: path,
rootPath: rootPath,
relPath: relPath,
stat: stat
}
}
})
.filter(R.is(Object))
}
inputStreams() {
const ticks = Bacon.interval(100);
const keys = Bacon.fromEvent(document.body, "keyup").map(".keyCode");
const lefts = keys.filter(key => key === 37);
const rights = keys.filter(key => key === 39);
return { ticks, lefts, rights };
}
[removedItemsStream], (items, path) => items.filter(item => item.path !== path),
[closeStream], (items, path) => items.filter(item => !item.path.startsWith(path))
)
this._queryTask = new Task(require.resolve('./query-task.js'))
this._queryTask.start()
this._unsubscribes.push(newItemsStream.onValue(item => this._queryTask.send({type: 'add', item: item})))
this._unsubscribes.push(removedItemsStream.onValue(path => this._queryTask.send({tyquerpe: 'rm', path: path})))
const queryStream = this.queryBus.map(R.trim).skipDuplicates()
const emptyQueryStream = queryStream.filter(R.isEmpty)
const queryProp = queryStream.toProperty('')
this._unsubscribes.push(queryProp
.filter(q => q !== '')
.onValue(q => this._queryTask.send({type: 'query', query: q})))
const queryResultsStream = Bacon.fromEvent(this._queryTask, 'results')
this.itemsProp = Bacon.update(
[],
[queryResultsStream, allItemsProp], (_, results, allItems) => results.items.map(({id}) => allItems[id]),
[emptyQueryStream, allItemsProp], R.nthArg(-1),
[allItemsProp.changes(), queryProp], (items, allItems, q) => R.isEmpty(q) ? allItems : items
)
}
const removedItemsStream = watchedPathTaskStream.flatMap(task => Bacon.fromEvent(task, 'unlink'))