code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function getNearestIndex(allPoints, intersectedIndexes, ray, maxDistanceFromRay) { if (intersectedIndexes.length === 0) return; // This is not necessary the fastest solution, but in practice it is very fast intersectedIndexes.sort(byProximityToRay); var candidate = intersectedIndexes[0]; if (getDistanceToR...
Based on octree search results tries to find index of a point which is nearest to the ray in z-direction, and is closer than maxDistanceFromRay
getNearestIndex
javascript
anvaka/pm
src/galaxy/native/getNearestIndex.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/getNearestIndex.js
MIT
function byProximityToRay(x, y) { var distX = getDistanceToRay(x); var distY = getDistanceToRay(y); return distX - distY; }
Based on octree search results tries to find index of a point which is nearest to the ray in z-direction, and is closer than maxDistanceFromRay
byProximityToRay
javascript
anvaka/pm
src/galaxy/native/getNearestIndex.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/getNearestIndex.js
MIT
function getDistanceToRay(idx) { var x = allPoints[idx]; var y = allPoints[idx + 1]; var z = allPoints[idx + 2]; var dx = ray.direction.x * (x - ray.origin.x); var dy = ray.direction.y * (y - ray.origin.y); var dz = ray.direction.z * (z - ray.origin.z); var directionDistance = dx + dy + dz...
Based on octree search results tries to find index of a point which is nearest to the ray in z-direction, and is closer than maxDistanceFromRay
getDistanceToRay
javascript
anvaka/pm
src/galaxy/native/getNearestIndex.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/getNearestIndex.js
MIT
function setOrGetLinksVisible(newValue) { if (newValue === undefined) { return linksVisible; } if (newValue) { scene.add(linkMesh); } else { scene.remove(linkMesh); } linksVisible = newValue; return linksVisible; }
Gets or sets links visibility. If you pass truthy argument sets visibility to that value. Otherwise returns current visibility
setOrGetLinksVisible
javascript
anvaka/pm
src/galaxy/native/lineView.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/lineView.js
MIT
function render(links, idxToPos, linksCount) { var jsPos = []; var jsColors = []; var r = 16000; var i = 0; var linkId = 0; var maxVisibleDistance = appConfig.getMaxVisibleEdgeLength(); for (i = 0; i < links.length; ++i) { var to = links[i]; if (to === undefined) continue; // no...
Gets or sets links visibility. If you pass truthy argument sets visibility to that value. Otherwise returns current visibility
render
javascript
anvaka/pm
src/galaxy/native/lineView.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/lineView.js
MIT
function distance(x1, y1, z1, x2, y2, z2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2); }
Gets or sets links visibility. If you pass truthy argument sets visibility to that value. Otherwise returns current visibility
distance
javascript
anvaka/pm
src/galaxy/native/lineView.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/lineView.js
MIT
function sceneRenderer(container) { var renderer, positions, graphModel, touchControl; var hitTest, lastHighlight, lastHighlightSize, cameraPosition; var lineView, links, lineViewNeedsUpdate; var queryUpdateId = setInterval(updateQuery, 200); appEvents.positionsDownloaded.on(setPositions); appEvents.linksD...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
sceneRenderer
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function accelarate(isPrecise) { var input = renderer.input(); if (isPrecise) { input.movementSpeed *= 4; input.rollSpeed *= 4; } else { input.movementSpeed /= 4; input.rollSpeed /= 4; } }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
accelarate
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function updateQuery() { if (!renderer) return; var camera = renderer.camera(); appConfig.setCameraConfig(camera.position, camera.quaternion); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
updateQuery
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function toggleSteering() { if (!renderer) return; var input = renderer.input(); var isDragToLookEnabled = input.toggleDragToLook(); // steering does not require "drag": var isSteering = !isDragToLookEnabled; appEvents.showSteeringMode.fire(isSteering); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
toggleSteering
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function clearHover() { appEvents.nodeHover.fire({ nodeIndex: undefined, mouseInfo: undefined }); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
clearHover
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function focusOnNode(nodeId) { if (!renderer) return; renderer.lookAt(nodeId * 3, highlightFocused); function highlightFocused() { appEvents.selectNode.fire(nodeId); } }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
focusOnNode
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function around(r, x, y, z) { renderer.around(r, x, y, z); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
around
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function setPositions(_positions) { destroyHitTest(); positions = _positions; focusScene(); if (!renderer) { renderer = unrender(container); touchControl = createTouchControl(renderer); moveCameraInternal(); var input = renderer.input(); input.on('move', clearHover); ...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
setPositions
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function adjustMovementSpeed(tree) { var input = renderer.input(); if (tree) { var root = tree.getRoot(); input.movementSpeed = root.bounds.half * 0.02; } else { input.movementSpeed *= 2; } }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
adjustMovementSpeed
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function focusScene() { // need to be within timeout, in case if we are detached (e.g. // first load) setTimeout(function() { container.focus(); }, 30); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
focusScene
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function setLinks(outLinks, inLinks) { links = outLinks; lineViewNeedsUpdate = true; updateSizes(outLinks, inLinks); renderLineViewIfNeeded(); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
setLinks
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function updateSizes(outLinks, inLinks) { var maxInDegree = getMaxSize(inLinks); var view = renderer.getParticleView(); var sizes = view.sizes(); for (var i = 0; i < sizes.length; ++i) { var degree = inLinks[i]; if (degree) { sizes[i] = ((200 / maxInDegree) * degree.length + 15); ...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
updateSizes
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function getMaxSize(sparseArray) { var maxSize = 0; for (var i = 0; i < sparseArray.length; ++i) { var item = sparseArray[i]; if (item && item.length > maxSize) maxSize = item.length; } return maxSize; }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
getMaxSize
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function renderLineViewIfNeeded() { if (!appConfig.getShowLinks()) return; if (!lineView) { lineView = createLineView(renderer.scene(), unrender.THREE); } lineView.render(links, positions); lineViewNeedsUpdate = false; }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
renderLineViewIfNeeded
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function toggleLinks() { if (lineView) { if (lineViewNeedsUpdate) renderLineViewIfNeeded(); lineView.toggleLinks(); } else { renderLineViewIfNeeded(); } }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
toggleLinks
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function moveCameraInternal() { if (!renderer) return; var camera = renderer.camera(); var pos = appConfig.getCameraPosition(); if (pos) { camera.position.set(pos.x, pos.y, pos.z); } var lookAt = appConfig.getCameraLookAt(); if (lookAt) { camera.quaternion.set(lookAt.x, lookAt.y...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
moveCameraInternal
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function destroyHitTest() { if (!hitTest) return; // nothing to destroy hitTest.off('over', handleOver); hitTest.off('click', handleClick); hitTest.off('dblclick', handleDblClick); hitTest.off('hitTestReady', adjustMovementSpeed); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
destroyHitTest
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function handleClick(e) { var nearestIndex = getNearestIndex(positions, e.indexes, e.ray, 30); appEvents.selectNode.fire(getModelIndex(nearestIndex)); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
handleClick
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function handleDblClick(e) { var nearestIndex = getNearestIndex(positions, e.indexes, e.ray, 30); if (nearestIndex !== undefined) { focusOnNode(nearestIndex/3); } }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
handleDblClick
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function handleOver(e) { var nearestIndex = getNearestIndex(positions, e.indexes, e.ray, 30); highlightNode(nearestIndex); appEvents.nodeHover.fire({ nodeIndex: getModelIndex(nearestIndex), mouseInfo: e }); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
handleOver
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function highlightNode(nodeIndex) { var view = renderer.getParticleView(); var colors = view.colors(); var sizes = view.sizes(); if (lastHighlight !== undefined) { colorNode(lastHighlight, colors, defaultNodeColor); sizes[lastHighlight/3] = lastHighlightSize; } lastHighlight = node...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
highlightNode
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function highlightQuery(query, color, scale) { if (!renderer) return; var nodeIds = query.results.map(toNativeIndex); var view = renderer.getParticleView(); var colors = view.colors(); for (var i = 0; i < nodeIds.length; ++i) { colorNode(nodeIds[i], colors, color) } view.colors(colo...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
highlightQuery
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function colorNode(nodeId, colors, color) { var colorOffset = (nodeId/3) * 4; colors[colorOffset + 0] = (color >> 24) & 0xff; colors[colorOffset + 1] = (color >> 16) & 0xff; colors[colorOffset + 2] = (color >> 8) & 0xff; colors[colorOffset + 3] = (color & 0xff); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
colorNode
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function highlightLinks(links, color) { var lines = new Float32Array(links.length * 3); for (var i = 0; i < links.length; ++i) { var i3 = links[i] * 3; lines[i * 3] = positions[i3]; lines[i * 3 + 1] = positions[i3 + 1]; lines[i * 3 + 2] = positions[i3 + 2]; } renderer.lines(lines...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
highlightLinks
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function cls() { var view = renderer.getParticleView(); var colors = view.colors(); for (var i = 0; i < colors.length/4; i++) { colorNode(i * 3, colors, 0xffffffff); } view.colors(colors); }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
cls
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function toNativeIndex(i) { return i.id * 3; }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
toNativeIndex
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function getModelIndex(nearestIndex) { if (nearestIndex !== undefined) { // since each node represented as triplet we need to divide by 3 to // get actual index: return nearestIndex/3 } }
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
getModelIndex
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function destroy() { var input = renderer.input(); if (input) input.off('move', clearHover); renderer.destroy(); appEvents.positionsDownloaded.off(setPositions); appEvents.linksDownloaded.off(setLinks); if (touchControl) touchControl.destroy(); renderer = null; clearInterval(queryUpdat...
This is a bridge between ultrafast particle renderer and react world. It listens to graph loading events. Once graph positions are loaded it calls native renderer to show the positions. It also listens to native renderer for user interaction. When user hovers over a node or clicks on it - it reports user actions back...
destroy
javascript
anvaka/pm
src/galaxy/native/renderer.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/renderer.js
MIT
function sceneKeyboardBinding(container) { var api = { destroy: destroy }; var lastShiftKey = false; container.addEventListener('keydown', keydown, false); container.addEventListener('keyup', keyup, false); return api; function destroy() { container.removeEventListener('keydown', keydown, false)...
This file defines special keyboard bindings for the scene. Most movement keyboard bindings are handled by `unrender` module (e.g. WASD). Here we handle additional keyboard shortcuts. For example toggle steering mode
sceneKeyboardBinding
javascript
anvaka/pm
src/galaxy/native/sceneKeyboardBinding.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/sceneKeyboardBinding.js
MIT
function destroy() { container.removeEventListener('keydown', keydown, false); container.removeEventListener('keyup', keyup, false); }
This file defines special keyboard bindings for the scene. Most movement keyboard bindings are handled by `unrender` module (e.g. WASD). Here we handle additional keyboard shortcuts. For example toggle steering mode
destroy
javascript
anvaka/pm
src/galaxy/native/sceneKeyboardBinding.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/sceneKeyboardBinding.js
MIT
function keydown(e) { if (e.which === Key.Space) { events.toggleSteering.fire(); } else if (e.which === Key.L) { // L - toggle links if (!e.ctrlKey && !e.metaKey) { events.toggleLinks.fire(); } } else if (e.which === Key.H || (e.which === Key['/'] && e.shiftKey)) { // 'h' or '?' ke...
This file defines special keyboard bindings for the scene. Most movement keyboard bindings are handled by `unrender` module (e.g. WASD). Here we handle additional keyboard shortcuts. For example toggle steering mode
keydown
javascript
anvaka/pm
src/galaxy/native/sceneKeyboardBinding.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/sceneKeyboardBinding.js
MIT
function keyup(e) { if (lastShiftKey && !e.shiftKey) { lastShiftKey = false; events.accelerateNavigation.fire(false); } }
This file defines special keyboard bindings for the scene. Most movement keyboard bindings are handled by `unrender` module (e.g. WASD). Here we handle additional keyboard shortcuts. For example toggle steering mode
keyup
javascript
anvaka/pm
src/galaxy/native/sceneKeyboardBinding.js
https://github.com/anvaka/pm/blob/master/src/galaxy/native/sceneKeyboardBinding.js
MIT
function nodeDetailsStore() { var api = { getSelectedNode: getSelectedNode }; var currentNodeId, degreeVisible = false, currentConnectionType; appEvents.selectNode.on(updateDetails); appEvents.showDegree.on(updateDegreeDetails); eventify(api); return api; function updateDetails(nodeId) { ...
Prepares data for selected node details
nodeDetailsStore
javascript
anvaka/pm
src/galaxy/nodeDetails/nodeDetailsStore.js
https://github.com/anvaka/pm/blob/master/src/galaxy/nodeDetails/nodeDetailsStore.js
MIT
function updateDetails(nodeId) { currentNodeId = nodeId; updateDegreeDetails(currentNodeId, currentConnectionType); }
Prepares data for selected node details
updateDetails
javascript
anvaka/pm
src/galaxy/nodeDetails/nodeDetailsStore.js
https://github.com/anvaka/pm/blob/master/src/galaxy/nodeDetails/nodeDetailsStore.js
MIT
function updateDegreeDetails(id, connectionType) { currentNodeId = id; degreeVisible = currentNodeId !== undefined; if (degreeVisible) { currentConnectionType = connectionType; var rootInfo = scene.getNodeInfo(id); var conenctions = scene.getConnected(id, connectionType); var viewM...
Prepares data for selected node details
updateDegreeDetails
javascript
anvaka/pm
src/galaxy/nodeDetails/nodeDetailsStore.js
https://github.com/anvaka/pm/blob/master/src/galaxy/nodeDetails/nodeDetailsStore.js
MIT
function getSelectedNode() { if (currentNodeId === undefined) return; return getBaseNodeViewModel(currentNodeId); }
Prepares data for selected node details
getSelectedNode
javascript
anvaka/pm
src/galaxy/nodeDetails/nodeDetailsStore.js
https://github.com/anvaka/pm/blob/master/src/galaxy/nodeDetails/nodeDetailsStore.js
MIT
function eventMirror(eventNames, eventBus) { var events = Object.create(null); eventNames.forEach(setActiveCommand); return events; function setActiveCommand(eventName, idx) { events[eventName] = { id: eventName, fire: fire(eventName), on: on(eventName), off: off(eventName) }; ...
This is a syntax sugar wrapper which allows consumer to register events on a given event bus, later clients can have rich API to consume events. For example: // Create a simple event bus: var myBus = require('ngraph.events')({}); // Register several events on this bus: var events = eventMirror(['sayHi', 'sayBye'], m...
eventMirror
javascript
anvaka/pm
src/galaxy/service/eventMirror.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/eventMirror.js
MIT
function setActiveCommand(eventName, idx) { events[eventName] = { id: eventName, fire: fire(eventName), on: on(eventName), off: off(eventName) }; }
This is a syntax sugar wrapper which allows consumer to register events on a given event bus, later clients can have rich API to consume events. For example: // Create a simple event bus: var myBus = require('ngraph.events')({}); // Register several events on this bus: var events = eventMirror(['sayHi', 'sayBye'], m...
setActiveCommand
javascript
anvaka/pm
src/galaxy/service/eventMirror.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/eventMirror.js
MIT
function fire(name) { return function () { eventBus.fire.apply(this, [name].concat(Array.prototype.slice.call(arguments))); } }
This is a syntax sugar wrapper which allows consumer to register events on a given event bus, later clients can have rich API to consume events. For example: // Create a simple event bus: var myBus = require('ngraph.events')({}); // Register several events on this bus: var events = eventMirror(['sayHi', 'sayBye'], m...
fire
javascript
anvaka/pm
src/galaxy/service/eventMirror.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/eventMirror.js
MIT
function on(name) { return function (callback) { eventBus.on(name, callback); } }
This is a syntax sugar wrapper which allows consumer to register events on a given event bus, later clients can have rich API to consume events. For example: // Create a simple event bus: var myBus = require('ngraph.events')({}); // Register several events on this bus: var events = eventMirror(['sayHi', 'sayBye'], m...
on
javascript
anvaka/pm
src/galaxy/service/eventMirror.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/eventMirror.js
MIT
function off(name) { return function (callback) { eventBus.off(name, callback); } }
This is a syntax sugar wrapper which allows consumer to register events on a given event bus, later clients can have rich API to consume events. For example: // Create a simple event bus: var myBus = require('ngraph.events')({}); // Register several events on this bus: var events = eventMirror(['sayHi', 'sayBye'], m...
off
javascript
anvaka/pm
src/galaxy/service/eventMirror.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/eventMirror.js
MIT
function graph(rawGraphLoaderData) { var {labels, outLinks, inLinks, positions} = rawGraphLoaderData; var empty = []; var api = { getNodeInfo: getNodeInfo, getConnected: getConnected, find: find, findLinks: findLinks }; return api; function findLinks(from, to) { return linkFinder(from...
Wrapper on top of graph data. Not sure where it will go yet.
graph
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function findLinks(from, to) { return linkFinder(from, to, outLinks, inLinks, labels); }
Wrapper on top of graph data. Not sure where it will go yet.
findLinks
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function find(query) { var result = []; if (!labels) return result; if (typeof query === 'string') { // short circuit if it's blank string - no results if (!query) return result; query = regexMatcher(query); } for (var i = 0; i < labels.length; ++i) { if (query(i, labels, o...
Wrapper on top of graph data. Not sure where it will go yet.
find
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function regexMatcher(str) { var regex = compileRegex(str); if (!regex) return no; return function (i, labels, outLinks, inLinks, pos) { var label = labels[i]; if (typeof label === 'string') { return label.match(regex); } return label.toString().match(regex); } }
Wrapper on top of graph data. Not sure where it will go yet.
regexMatcher
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function compileRegex(pattern) { try { return new RegExp(pattern, 'ig'); } catch (e) { // this cannot be compiled. Ignore it. } }
Wrapper on top of graph data. Not sure where it will go yet.
compileRegex
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function getConnected(startId, connectionType) { if (connectionType === 'out') { return outLinks[startId] || empty; } else if (connectionType === 'in') { return inLinks[startId] || empty; } return empty; }
Wrapper on top of graph data. Not sure where it will go yet.
getConnected
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function getNodeInfo(id) { if (!labels) return; var outLinksCount = 0; if (outLinks[id]) { outLinksCount = outLinks[id].length; } var inLinksCount = 0; if (inLinks[id]) { inLinksCount = inLinks[id].length; } return { id: id, name: labels[id], out: outLink...
Wrapper on top of graph data. Not sure where it will go yet.
getNodeInfo
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function getName(id) { if (!labels) return ''; if (id < 0 || id > labels.length) { throw new Error(id + " is outside of labels range"); } return labels[id]; }
Wrapper on top of graph data. Not sure where it will go yet.
getName
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function getPositions() { return positions; }
Wrapper on top of graph data. Not sure where it will go yet.
getPositions
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function getLinks() { return links; }
Wrapper on top of graph data. Not sure where it will go yet.
getLinks
javascript
anvaka/pm
src/galaxy/service/graph.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graph.js
MIT
function loadGraph(name, progress) { var positions, labels; var outLinks = []; var inLinks = []; // todo: handle errors var manifestEndpoint = config.dataUrl + name; var galaxyEndpoint = manifestEndpoint; var manifest; return loadManifest() .then(loadPositions) .then(loadLinks) .then(load...
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
loadGraph
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function convertToGraph() { return createGraph({ positions: positions, labels: labels, outLinks: outLinks, inLinks: inLinks }); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
convertToGraph
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function loadManifest() { return request(manifestEndpoint + '/manifest.json?nocache=' + (+new Date()), { responseType: 'json' }).then(setManifest); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
loadManifest
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function setManifest(response) { manifest = response; var version = getFromAppConfig(manifest) || manifest.last; if (manifest.endpoint) { // the endpoint is overridden. Since we trust manifest endpoint, we also // trust overridden endpoint: galaxyEndpoint = manifest.endpoint; } else { ...
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
setManifest
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function getFromAppConfig(manifest) { var appConfigVersion = appConfig.getManifestVersion(); var approvedVersions = manifest && manifest.all; // default to the last version: if (!approvedVersions || !appConfigVersion) return; // If this version is whitelisted, let it through: if (approvedVersi...
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
getFromAppConfig
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function loadPositions() { return request(galaxyEndpoint + '/positions.bin', { responseType: 'arraybuffer', progress: reportProgress(name, 'positions') }).then(setPositions); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
loadPositions
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function setPositions(buffer) { positions = new Int32Array(buffer); var scaleFactor = appConfig.getScaleFactor(); for (var i = 0; i < positions.length; ++i) { positions[i] *= scaleFactor; } appEvents.positionsDownloaded.fire(positions); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
setPositions
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function loadLinks() { return request(galaxyEndpoint + '/links.bin', { responseType: 'arraybuffer', progress: reportProgress(name, 'links') }).then(setLinks); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
loadLinks
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function setLinks(buffer) { var links = new Int32Array(buffer); var lastArray = []; outLinks[0] = lastArray; var srcIndex; var processed = 0; var total = links.length; asyncFor(links, processLink, reportBack); var deffered = defer(); function processLink(link) { if (link < 0)...
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
setLinks
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function processLink(link) { if (link < 0) { srcIndex = -link - 1; lastArray = outLinks[srcIndex] = []; } else { var toNode = link - 1; lastArray.push(toNode); if (inLinks[toNode] === undefined) { inLinks[toNode] = [srcIndex]; } else { inLi...
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
processLink
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function reportLinkProgress(percent) { progress({ message: name + ': initializing edges ', completed: Math.round(percent * 100) + '%' }); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
reportLinkProgress
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function reportBack() { appEvents.linksDownloaded.fire(outLinks, inLinks); deffered.resolve(); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
reportBack
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function loadLabels() { return request(galaxyEndpoint + '/labels.json', { responseType: 'json', progress: reportProgress(name, 'labels') }).then(setLabels); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
loadLabels
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function setLabels(data) { labels = data; appEvents.labelsDownloaded.fire(labels); }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
setLabels
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function reportProgress(name, file) { return function(e) { let progressInfo = { message: name + ': downloading ' + file, }; if (e.percent !== undefined) { progressInfo.completed = Math.round(e.percent * 100) + '%' } else { progressInfo.completed = Math.round(e.loaded)...
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
reportProgress
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function defer() { var resolve, reject; var promise = new Promise(function() { resolve = arguments[0]; reject = arguments[1]; }); return { resolve: resolve, reject: reject, promise: promise }; }
@param {string} name of the graph to be downloaded @param {progressCallback} progress notifies when download progress event is received @param {completeCallback} complete notifies when all graph files are downloaded
defer
javascript
anvaka/pm
src/galaxy/service/graphLoader.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/graphLoader.js
MIT
function request(url, options) { if (!options) options = {}; return new Promise(download); function download(resolve, reject) { var req = new XMLHttpRequest(); if (typeof options.progress === 'function') { req.addEventListener("progress", updateProgress, false); } req.addEventListener("l...
A very basic ajax client with promises and progress reporting.
request
javascript
anvaka/pm
src/galaxy/service/request.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/request.js
MIT
function download(resolve, reject) { var req = new XMLHttpRequest(); if (typeof options.progress === 'function') { req.addEventListener("progress", updateProgress, false); } req.addEventListener("load", transferComplete, false); req.addEventListener("error", transferFailed, false); req.a...
A very basic ajax client with promises and progress reporting.
download
javascript
anvaka/pm
src/galaxy/service/request.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/request.js
MIT
function updateProgress(e) { if (e.lengthComputable) { options.progress({ loaded: e.loaded, total: e.total, percent: e.loaded / e.total }); } else { options.progress({ loaded: e.loaded, }); } }
A very basic ajax client with promises and progress reporting.
updateProgress
javascript
anvaka/pm
src/galaxy/service/request.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/request.js
MIT
function transferComplete() { if (req.status !== 200) { reject(`Unexpected status code ${req.status} when calling ${url}`); return; } var response = req.response; if (options.responseType === 'json' && typeof response === 'string') { // IE response = JSON.parse(r...
A very basic ajax client with promises and progress reporting.
transferComplete
javascript
anvaka/pm
src/galaxy/service/request.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/request.js
MIT
function transferFailed() { reject(`Failed to download ${url}`); }
A very basic ajax client with promises and progress reporting.
transferFailed
javascript
anvaka/pm
src/galaxy/service/request.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/request.js
MIT
function transferCanceled() { reject(`Cancelled download of ${url}`); }
A very basic ajax client with promises and progress reporting.
transferCanceled
javascript
anvaka/pm
src/galaxy/service/request.js
https://github.com/anvaka/pm/blob/master/src/galaxy/service/request.js
MIT
function sceneStore() { var loadInProgress = true; var currentGraphName; var unknownNodeInfo = { inDegree: '?', outDegree: '?' } var graph; var api = { isLoading: isLoading, getGraph: getGraph, getGraphName: getGraphName, getNodeInfo: getNodeInfo, getConnected: getConnected, ...
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
sceneStore
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function find(query) { return graph.find(query); }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
find
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function isLoading() { return loadInProgress; }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
isLoading
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function downloadGraph(graphName) { if (graphName === currentGraphName) return; loadInProgress = true; currentGraphName = graphName; loadGraph(graphName, reportProgress).then(loadComplete); }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
downloadGraph
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function getGraph() { return graph; }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
getGraph
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function getGraphName() { return currentGraphName; }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
getGraphName
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function getNodeInfo(nodeId) { if (!graph) { unknownNodeInfo.name = nodeId; return unknownNodeInfo; } var nodeInfo = graph.getNodeInfo(nodeId); // TODO: too tired, need to get this out from here if (currentGraphName === 'github') { nodeInfo.icon = 'https://avatars.githubusercontent...
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
getNodeInfo
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function getConnected(nodeId, connectionType) { if (!graph) { return []; } return graph.getConnected(nodeId, connectionType).map(getNodeInfo); }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
getConnected
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function reportProgress(progress) { api.fire('loadProgress', progress); }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
reportProgress
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function loadComplete(model) { loadInProgress = false; graph = model; api.fire('loadProgress', {}); appEvents.graphDownloaded.fire(); }
Manages graph model life cycle. The low-level rendering of the particles is handled by ../native/renderer.js
loadComplete
javascript
anvaka/pm
src/galaxy/store/scene.js
https://github.com/anvaka/pm/blob/master/src/galaxy/store/scene.js
MIT
function ProcessError(code, message) { const callee = arguments.callee; Error.apply(this, [message]); Error.captureStackTrace(this, callee); this.code = code; this.message = message; this.name = callee.name; }
@function Object() { [native code] } @param {number} code Error code. @param {string} message Error message.
ProcessError
javascript
tschaub/gh-pages
lib/git.js
https://github.com/tschaub/gh-pages/blob/master/lib/git.js
MIT
function spawn(exe, args, cwd) { return new Promise((resolve, reject) => { const child = cp.spawn(exe, args, {cwd: cwd || process.cwd()}); const buffer = []; child.stderr.on('data', (chunk) => { buffer.push(chunk.toString()); }); child.stdout.on('data', (chunk) => { buffer.push(chunk.t...
Util function for handling spawned processes as promises. @param {string} exe Executable. @param {Array<string>} args Arguments. @param {string} cwd Working directory. @return {Promise} A promise.
spawn
javascript
tschaub/gh-pages
lib/git.js
https://github.com/tschaub/gh-pages/blob/master/lib/git.js
MIT
function Git(cwd, cmd) { this.cwd = cwd; this.cmd = cmd || 'git'; this.output = ''; }
Create an object for executing git commands. @param {string} cwd Repository directory. @param {string} cmd Git executable (full path if not already on path). @function Object() { [native code] }
Git
javascript
tschaub/gh-pages
lib/git.js
https://github.com/tschaub/gh-pages/blob/master/lib/git.js
MIT
function getCacheDir(optPath) { const dir = findCacheDir({name: 'gh-pages'}); if (!optPath) { return dir; } return path.join(dir, filenamify(optPath)); }
Get the cache directory. @param {string} [optPath] Optional path. @return {string} The full path to the cache directory.
getCacheDir
javascript
tschaub/gh-pages
lib/index.js
https://github.com/tschaub/gh-pages/blob/master/lib/index.js
MIT
function done(err) { try { callback(err); } catch (err2) { log('Publish callback threw: %s', err2.message); } }
Push a git branch to a remote (pushes gh-pages by default). @param {string} basePath The base path. @param {Object} config Publish options. @param {Function} callback Callback. @return {Promise} A promise.
done
javascript
tschaub/gh-pages
lib/index.js
https://github.com/tschaub/gh-pages/blob/master/lib/index.js
MIT
function uniqueDirs(files) { const dirs = new Set(); files.forEach((filepath) => { const parts = path.dirname(filepath).split(path.sep); let partial = parts[0] || '/'; dirs.add(partial); for (let i = 1, ii = parts.length; i < ii; ++i) { partial = path.join(partial, parts[i]); dirs.add(pa...
Generate a list of unique directory paths given a list of file paths. @param {Array<string>} files List of file paths. @return {Array<string>} List of directory paths.
uniqueDirs
javascript
tschaub/gh-pages
lib/util.js
https://github.com/tschaub/gh-pages/blob/master/lib/util.js
MIT
function byShortPath(a, b) { const aParts = a.split(path.sep); const bParts = b.split(path.sep); const aLength = aParts.length; const bLength = bParts.length; let cmp = 0; if (aLength < bLength) { cmp = -1; } else if (aLength > bLength) { cmp = 1; } else { let aPart, bPart; for (let i = ...
Sort function for paths. Sorter paths come first. Paths of equal length are sorted alphanumerically in path segment order. @param {string} a First path. @param {string} b Second path. @return {number} Comparison.
byShortPath
javascript
tschaub/gh-pages
lib/util.js
https://github.com/tschaub/gh-pages/blob/master/lib/util.js
MIT
function dirsToCreate(files) { return uniqueDirs(files).sort(byShortPath); }
Generate a list of directories to create given a list of file paths. @param {Array<string>} files List of file paths. @return {Array<string>} List of directory paths ordered by path length.
dirsToCreate
javascript
tschaub/gh-pages
lib/util.js
https://github.com/tschaub/gh-pages/blob/master/lib/util.js
MIT
function copyFile(obj, callback) { let called = false; function done(err) { if (!called) { called = true; callback(err); } } const read = fs.createReadStream(obj.src); read.on('error', (err) => { done(err); }); const write = fs.createWriteStream(obj.dest); write.on('error', (er...
Copy a file. @param {Object} obj Object with src and dest properties. @param {function(Error):void} callback Callback
copyFile
javascript
tschaub/gh-pages
lib/util.js
https://github.com/tschaub/gh-pages/blob/master/lib/util.js
MIT
function done(err) { if (!called) { called = true; callback(err); } }
Copy a file. @param {Object} obj Object with src and dest properties. @param {function(Error):void} callback Callback
done
javascript
tschaub/gh-pages
lib/util.js
https://github.com/tschaub/gh-pages/blob/master/lib/util.js
MIT
function makeDir(path, callback) { fs.mkdir(path, (err) => { if (err) { // check if directory exists fs.stat(path, (err2, stat) => { if (err2 || !stat.isDirectory()) { callback(err); } else { callback(); } }); } else { callback(); } });...
Make directory, ignoring errors if directory already exists. @param {string} path Directory path. @param {function(Error):void} callback Callback.
makeDir
javascript
tschaub/gh-pages
lib/util.js
https://github.com/tschaub/gh-pages/blob/master/lib/util.js
MIT