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 queueCompletedSegment(boundary, segment) { if (segment.chunks.length === 0 && segment.children.length === 1 && segment.children[0].boundary === null) { var childSegment = segment.children[0]; childSegment.id = segment.id; childSegment.parentFlushed ...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
queueCompletedSegment
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function finishedTask(request, boundary, segment) { if (boundary === null) { if (segment.parentFlushed) { if (request.completedRootSegment !== null) { throw new Error("There can only be one root segment. This is a bug in React."); } ...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
finishedTask
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function retryTask(request, task) { var segment = task.blockedSegment; if (segment.status !== PENDING) { return; } switchContext(task.context); var prevTaskInDEV = null; { prevTaskInDEV = currentTaskInDEV...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
retryTask
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function performWork(request) { if (request.status === CLOSED) { return; } var prevContext = getActiveContext(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = Dispatcher; var p...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
performWork
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushSubtree(request, destination, segment) { segment.parentFlushed = true; switch (segment.status) { case PENDING: { var segmentID = segment.id = request.nextSegmentId++; segment.lastPushedText = false; segment.t...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushSubtree
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushSegment(request, destination, segment) { var boundary = segment.boundary; if (boundary === null) { return flushSubtree(request, destination, segment); } boundary.parentFlushed = true; if (boundary.forceClientRender) { ...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushSegment
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushClientRenderedBoundary(request, destination, boundary) { return writeClientRenderBoundaryInstruction(destination, request.responseState, boundary.id, boundary.errorDigest, boundary.errorMessage, boundary.errorComponentStack); }
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushClientRenderedBoundary
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushSegmentContainer(request, destination, segment) { writeStartSegment(destination, request.responseState, segment.formatContext, segment.id); flushSegment(request, destination, segment); return writeEndSegment(destination, segment.formatContext); }
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushSegmentContainer
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushCompletedBoundary(request, destination, boundary) { var completedSegments = boundary.completedSegments; var i = 0; for (; i < completedSegments.length; i++) { var segment = completedSegments[i]; flushPartiallyCompletedSegment(reques...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushCompletedBoundary
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushPartialBoundary(request, destination, boundary) { var completedSegments = boundary.completedSegments; var i = 0; for (; i < completedSegments.length; i++) { var segment = completedSegments[i]; if (!flushPartiallyCompletedSegment(req...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushPartialBoundary
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushPartiallyCompletedSegment(request, destination, boundary, segment) { if (segment.status === FLUSHED) { return true; } var segmentID = segment.id; if (segmentID === -1) { var rootSegmentID = segment.id = boundary.rootSe...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushPartiallyCompletedSegment
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function flushCompletedQueues(request, destination) { beginWriting(); try { var completedRootSegment = request.completedRootSegment; if (completedRootSegment !== null && request.pendingRootTasks === 0) { flushSegment(request, destination, com...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
flushCompletedQueues
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function startWork(request) { scheduleWork(function() { return performWork(request); }); }
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
startWork
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function startFlowing(request, destination) { if (request.status === CLOSING) { request.status = CLOSED; closeWithError(destination, request.fatalError); return; } if (request.status === CLOSED) { return; ...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
startFlowing
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function abort(request, reason) { try { var abortableTasks = request.abortableTasks; abortableTasks.forEach(function(task) { return abortTask(task, request, reason); }); abortableTasks.clear(); if (request.de...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
abort
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function renderToReadableStream(children, options) { return new Promise(function(resolve, reject) { var onFatalError; var onAllReady; var allReady = new Promise(function(res, rej) { onAllReady = res; onFatalError = rej; ...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
renderToReadableStream
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function onShellReady() { var stream = new ReadableStream( { type: "bytes", pull: function(controller) { startFlowing(request, controller); }, cancel: function(reason) { ...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
onShellReady
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function onShellError(error2) { allReady.catch(function() { }); reject(error2); }
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
onShellError
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
listener = function() { abort(request, signal.reason); signal.removeEventListener("abort", listener); }
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
listener
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
constructHTML = (app) => { return ` <!doctype html> <html> <body> <div id="content">${app}</div> </body> </html> `; }
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
constructHTML
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
handleRequest = async (request) => { const headers = { "Content-Type": "text/html; charset=utf-8" }; const app = import_server.default.renderToString(/* @__PURE__ */ import_react2.default.createElement(app_default, null)); const html = constructHTML(app); return new Response(html, { status: 200,...
Sets a subset of the state. This only exists because _pendingState is internal. This provides a merging strategy that is not available to deep properties which is confusing. TODO: Expose pendingState or don't use it during the merge. @param {ReactClass} publicInstance The instance that should rerender. @param {object}...
handleRequest
javascript
wasmerio/winterjs
tests/complex.js
https://github.com/wasmerio/winterjs/blob/master/tests/complex.js
MIT
function combineBypassData(generator, bypassArr, plopArgV) { // skip bypass if prompts is a function if (typeof generator.prompts === "function") { return []; } // Get named prompts that are passed to the command line const promptNames = generator.prompts.map((prompt) => prompt.name); // Check if bypas...
Combine different types of bypass data @param generator - The generator object involved @param bypassArr - The array of overwritten properties @param plopArgV - The original args passed to plop without using names
combineBypassData
javascript
plopjs/plop
packages/plop/src/bypass.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/bypass.js
MIT
function mergeArrays(baseArr, overlay) { const length = Math.max(baseArr.length, overlay.length); return new Array(length) .fill() .map((v, i) => (overlay[i] !== undefined ? overlay[i] : baseArr[i])); }
Combine different types of bypass data @param generator - The generator object involved @param bypassArr - The array of overwritten properties @param plopArgV - The original args passed to plop without using names
mergeArrays
javascript
plopjs/plop
packages/plop/src/bypass.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/bypass.js
MIT
function getBypassAndGenerator(plop, passArgsBeforeDashes) { // See if there are args to pass to generator const eoaIndex = args.indexOf("--"); const { plopArgV, eoaArg } = passArgsBeforeDashes ? { plopArgV: argv } : eoaIndex === -1 ? { plopArgV: [] } : { plopArgV: minimist(args.slic...
Parses the user input to identify the generator to run and any bypass data @param plop - The plop context @param passArgsBeforeDashes - Should we pass args before `--` to the generator API
getBypassAndGenerator
javascript
plopjs/plop
packages/plop/src/input-processing.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/input-processing.js
MIT
function listHasOptionThatStartsWith(list, prefix) { return list.some(function (txt) { return txt.indexOf(prefix) === 0; }); }
Parses the user input to identify the generator to run and any bypass data @param plop - The plop context @param passArgsBeforeDashes - Should we pass args before `--` to the generator API
listHasOptionThatStartsWith
javascript
plopjs/plop
packages/plop/src/input-processing.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/input-processing.js
MIT
function handleArgFlags(env) { // Make sure that we're not overwriting `help`, `init,` or `version` args in generators if (argv._.length === 0) { // handle request for usage and options if (argv.help || argv.h) { out.displayHelpScreen(); process.exit(0); } // handle request for initiali...
Handles all basic argument flags @param env - Values parsed by Liftoff
handleArgFlags
javascript
plopjs/plop
packages/plop/src/input-processing.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/input-processing.js
MIT
async function run(env, _, passArgsBeforeDashes) { const plopfilePath = env.configPath; // handle basic argument flags like --help, --version, etc handleArgFlags(env); // use base path from argv or env if any is present, otherwise set it to the plopfile directory const destBasePath = argv.dest || env.dest; ...
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
run
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
runGeneratorByName = (name) => { const generator = plop.getGenerator(name); const bypassData = combineBypassData(generator, bypassArr, plopArgV); doThePlop(generator, bypassData); }
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
runGeneratorByName
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
runGeneratorByName = (name) => { const generator = plop.getGenerator(name); const bypassData = combineBypassData(generator, bypassArr, plopArgV); doThePlop(generator, bypassData); }
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
runGeneratorByName
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
function doThePlop(generator, bypassArr) { let failedActions = false; generator .runPrompts(bypassArr) .then(async (answers) => { return answers; }) .then((answers) => { const noMap = argv["show-type-names"] || argv.t; const onComment = (msg) => { progressSpinner.info(msg);...
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
doThePlop
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
onComment = (msg) => { progressSpinner.info(msg); progressSpinner.start(); }
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
onComment
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
onComment = (msg) => { progressSpinner.info(msg); progressSpinner.start(); }
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
onComment
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
onSuccess = (change) => { let line = ""; if (change.type) { line += ` ${out.typeMap(change.type, noMap)}`; } if (change.path) { line += ` ${change.path}`; } progressSpinner.succeed(line); progressSpinner.start(); }
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
onSuccess
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
onSuccess = (change) => { let line = ""; if (change.type) { line += ` ${out.typeMap(change.type, noMap)}`; } if (change.path) { line += ` ${change.path}`; } progressSpinner.succeed(line); progressSpinner.start(); }
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
onSuccess
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
onFailure = (fail) => { let line = ""; if (fail.type) { line += ` ${out.typeMap(fail.type, noMap)}`; } if (fail.path) { line += ` ${fail.path}`; } const errMsg = fail.error || fail.message; if (errMsg) { line += ` ${errMsg}`; ...
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
onFailure
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
onFailure = (fail) => { let line = ""; if (fail.type) { line += ` ${out.typeMap(fail.type, noMap)}`; } if (fail.path) { line += ` ${fail.path}`; } const errMsg = fail.error || fail.message; if (errMsg) { line += ` ${errMsg}`; ...
The function to pass as the second argument to `Plop.execute` @param env - This is passed implicitly @param _ - Passed implicitly. Not needed, but allows for `passArgsBeforeDashes` to be explicitly passed @param passArgsBeforeDashes - An opt-in `true` boolean that will allow merging of plop CLI API and generator API @e...
onFailure
javascript
plopjs/plop
packages/plop/src/plop.js
https://github.com/plopjs/plop/blob/master/packages/plop/src/plop.js
MIT
function renderScript(script, args = [], opts = {}) { const { cwd = __dirname } = opts; return render( resolve(__dirname, "../node_modules/.bin/nyc"), ["--silent", "node", script, ...args], { cwd, spawnOpts: { env: { ...process.env, NODE_ENV: "test" }, }, }, ); }
@param {String} script @param {Array} args @param {Object} opts
renderScript
javascript
plopjs/plop
packages/plop/tests/render.js
https://github.com/plopjs/plop/blob/master/packages/plop/tests/render.js
MIT
function renderPlop(args = [], opts = {}) { return renderScript( resolve(__dirname, "../instrumented/bin/plop.js"), args, opts, ); }
@param {Array} args @param {Object} opts
renderPlop
javascript
plopjs/plop
packages/plop/tests/render.js
https://github.com/plopjs/plop/blob/master/packages/plop/tests/render.js
MIT
RollerProvider = function(_mongoose, _TaskMdl) { mongoose = _mongoose; TaskMdl = _TaskMdl; dbUtils = require("./utils/db.utils")(mongoose); getModel = dbUtils.getModel; getCollectionForStep = dbUtils.getCollectionForStep; return Roller; }
Initializes variables and gets the roller. @param _mongoose the mongoose instance @param _TaskMdl the task model @returns An object containing rollback functions @constructor
RollerProvider
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
function rollBackTask(task) { var db = mongoose.connection.db; var chain = Promise.resolve(); var lastIndex = task.steps.length - 1; var firstStep = task.steps[0]; var lastStep = task.steps[lastIndex]; var step; if (lastStep.state !== DONE && firstStep.state !== INITIAL) { for(var i = lastIndex; i >=...
Rollback for a single task @param task the task to roll back @returns {Promise|*}
rollBackTask
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
function getRollbackFunc(step) { switch(step.type) { case SAVE: return rollbackSave; case UPDATE: case REMOVE: return rollbackRemoveOrUpdate; case FILE_SAVE: return rollbackFileSave; case FILE_REMOVE: return rollbackFileRemove; } }
Gets the correct rollback function for a step @param step the step to rollback @returns a function to rollback step
getRollbackFunc
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
function rollbackSave(db, save, task) { var collection = getCollectionForStep(db, save); var _id = save.dataStore[0]._id; return collection.deleteOne({_id: _id}).then(function(){ return updateState(task, save.index, ROLLED); }); }
Rollback for a save step @param db native db @param save the save step @param task the task containing the step @returns {Promise|*}
rollbackSave
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
function rollbackRemoveOrUpdate(db, step, task) { var collection = getCollectionForStep(db, step); var chain = Promise.resolve(); step.dataStore.forEach(function(data) { chain = chain.then(function() { var condition = {_id: data._id}; return collection.findOne(condition).then(function (doc) { ...
Rollback for remove or update step. @param db native db @param step the update or remove step @param task the task containing the step. @returns {Promise|*}
rollbackRemoveOrUpdate
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
function rollbackFileSave(db, step, task) { var gfs = new Grid(db); return dbUtils.removeFile(step.dataStore[0]._id, gfs) .then(function () { return updateState(task, step.index, ROLLED); }); }
Rollback for file save step. @param db native db @param step the file save step @param task the task containing the step. @returns {Promise|*}
rollbackFileSave
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
function rollbackFileRemove(db, step, task) { return new Promise(function (resolve, reject) { var gfs = Grid(db); var data = step.dataStore[0]; gfs.exist({_id: data.removed}, function (err, exists) { if (err) return reject(err); gfs.findOne({_id: data.shadow}, function (err, shadowFile) { ...
Rollback for file remove step. @param db native db @param step the file remove step @param task the task containing the step. @returns {Promise|*}
rollbackFileRemove
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
function done() { dbUtils.removeFile(data.shadow, gfs).then(function () { updateState(task, step.index, ROLLED) .then(resolve) .catch(reject); }); }
Rollback for file remove step. @param db native db @param step the file remove step @param task the task containing the step. @returns {Promise|*}
done
javascript
e-oj/Fawn
lib/roller.js
https://github.com/e-oj/Fawn/blob/master/lib/roller.js
MIT
TaskProvider = function (_mongoose, _TaskMdl) { mongoose = _mongoose; Grid.mongo = mongoose.mongo; TaskMdl = _TaskMdl; Roller = require("./roller")(mongoose, _TaskMdl); dbUtils = require("./utils/db.utils")(mongoose); native.setDbUtils(dbUtils); modelCache = dbUtils.modelCache; setModel = dbUtils.setMod...
Provider for the Task class. It initializes all the required variables and returns the Task class. Used internally. @param _mongoose The mongoose instance to be used @param _TaskMdl The mongoose model for tasks (where tasks are stored) @returns {Task} @constructor
TaskProvider
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
Task = function() { var task = this; var index = 0; var steps = []; /** * Mainly used internally for tests. * * @returns {TaskMdl} the mongoose model for the tasks */ task.getTaskCollection = function() { return TaskMdl; }; /** * @see dbUtils.initModel * * @param modelName The i...
The task class. It contains all the functions associated with a task. Enables edits to be queued as a series of steps and run, in the order they were queued, in a way that allows the edits to be rolled back in the event of a failure. @constructor
Task
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function getResolveFunc(step) { switch(step.type){ case UPDATE: return performUpdate; case SAVE: return performSave; case REMOVE: return performRemove; case FILE_SAVE: return performFileSave; case FILE_REMOVE: return performFileRemove; } }
The appropriate function to resolve a step @param step the step to resolve @returns a function to handle the step
getResolveFunc
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function performUpdate(step, task, results) { var db = mongoose.connection.db; return step.useMongoose ? goose.performUpdate(db, step, task, results) : native.nativeUpdate(db, step, task, results) }
This function handles the update step. @param step the update step @param task the task which step belongs to @param results array of results from previous operations @returns {Promise|*}
performUpdate
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function performSave(step, task, results) { var db = mongoose.connection.db; return step.useMongoose ? goose.performSave(step, task, results) : native.nativeSave(db, step, task, results) }
This function handles the save step. @param step the save step @param task the task which step belongs to @param results array of results from previous operations @returns {Promise|*}
performSave
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function performRemove(step, task, results) { var db = mongoose.connection.db; return step.useMongoose ? goose.performRemove(db, step, task, results) : native.nativeRemove(db, step, task, results) }
This function handles the remove step. @param step the remove step @param task the task which step belongs to @param results array of results from previous operations @returns {Promise|*}
performRemove
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function performFileSave(step, task, results) { var options = step.options ? xcode(step.options, true) : {}; resolveFuture(options, results); options._id = options._id || dbUtils.generateId(); step.options = options; step.dataStore = [{_id: options._id}]; return updateState(task, step.index, PENDING).the...
This function handles the file save step. @param step the file save step @param task the task which step belongs to @param results array of results from previous operations @returns {Promise|*}
performFileSave
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function performFileRemove(step, task, results) { var options = xcode(step.options, true); resolveFuture(options, results); return storeOldFile(task, step).then(function (file) { return updateState(task, step.index, PENDING).then(function () { var chain = Promise.resolve(); if (!file) { ...
This function handles the file remove step. @param step the file remove step @param task the task which step belongs to @param results array of results from previous operations @returns {Promise|*}
performFileRemove
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function storeOldFile(task, step) { return new Promise(function (resolve, reject) { var gfs = Grid(mongoose.connection.db); var options = xcode(step.options, true); gfs.findOne(options, function (err, file) { if (err) return reject(err); if (!file) return resolve(false); var collection...
This function stores a file that's about to be removed by a step, for rollback purposes @param task the task @param step the step @returns {Promise|*}
storeOldFile
javascript
e-oj/Fawn
lib/task.js
https://github.com/e-oj/Fawn/blob/master/lib/task.js
MIT
function getCollection(name, schema){ if (schema) return mongoose.model(name, schema); try { return mongoose.model(name); } catch (err){ initModel(name, schema); return mongoose.model(name); } }
gets a collection as a mongoose model. @param name name of the collection @param schema schema for the model
getCollection
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function setModel(name, schema) { modelCache[name] = getCollection(name, schema); }
Adds a model to the model cache @param name name of model @param schema schema for the model
setModel
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function getModel(name, schema) { if (!modelCache[name]) { setModel(name, schema); } return modelCache[name]; }
Gets a mongoose model. Creates one if it doesn't exist already. @param name name of the model to retrieve @param schema schema for the model @returns a mongoose model
getModel
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function initModel(modelName, schema) { if (modelCache[modelName]) throw new Error("The schema for this model has already been set"); if (schema && typeof schema !== "object") throw new Error("Invalid Schema"); var DEFAULT_SCHEMA = new Schema({}, {strict: false}); setModel(modelName, schema ? new Sche...
Initializes a mongoose model with name: modelName. If a schema is provided, it will be used to construct the model else, the model will be initialized with a default, unrestricted schema. @param modelName The intended name of the model @param schema The schema associated with this model
initModel
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function dropCollection(collection) { return new Promise(function(resolve, reject) { mongoose.connection.db.dropCollection(collection, function(err) { if(err) reject(err); else resolve(); }); }); }
Drops a MongoDB collection. For testing. @param collection the name of the collection to be dropped
dropCollection
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function removeFile(id, gfs) { var options = {_id: id}; if (id.constructor && id.constructor === Object) { options = id; } return new Promise(function (resolve, reject) { gfs.remove(options, function (err, result) { if (err) return reject(err); resolve(result); }); ...
Removes a file from the db @param id file id or options object @param gfs GridFS
removeFile
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function fileExists(id, gfs) { return new Promise(function (resolve, reject) { gfs.exist({_id: id}, function (err, exists) { if (err) return reject(err); resolve(exists); }); }); }
Checks if a file exists in the db with the specified file name @param id MongoDB ObjectId @param gfs GridFS
fileExists
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function makeRemoveChain(task, gfs) { var removeChain = Promise.resolve(); task.steps.forEach(function (step) { if (step.type !== constants.FILE_REMOVE) return; var shadowId = step.dataStore[0].shadow; removeChain = removeChain.then(function () { return fileExists(shadowId, gfs) ...
Chains together the deletion of shadow files from file remove steps. @param task the task to check for shadow files @param gfs GridFS @returns {Promise|*}
makeRemoveChain
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function getCollectionForStep(db, step){ return step.useMongoose ? mongoose.model(step.name).collection : db.collection(step.name) }
Gets the collection for a step @param db native db @param step the step in question @returns native collection
getCollectionForStep
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function storeOldData(db, step, condition){ var Collection = getCollectionForStep(db, step); var options = step.options ? utils.xcode(step.options) : step.type === constants.REMOVE ? {multi: true} : null; var query = Collection.find(condition); var searchQuery = o...
This function stores data that's about to be changed by a step, for rollback purposes @param db native db @param step the step @param condition literal obj rep of the step's condition @returns {Promise|*}
storeOldData
javascript
e-oj/Fawn
lib/utils/db.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/db.utils.js
MIT
function encode(obj, key){ var newKey = null; if(key[0] === "$"){ newKey = $ + key; } if(key.includes(".")){ newKey = (newKey || key).split(".").join(DOT); } if(newKey){ obj[newKey] = obj[key]; delete obj[key] } }
encodes object keys starting with "$" or containing "." @param obj object containing suspect key @param key key to encode
encode
javascript
e-oj/Fawn
lib/utils/gen.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/gen.utils.js
MIT
function decode(obj, key){ var newKey = key.split($).join("").split(DOT).join("."); if(key !== newKey){ obj[newKey] = obj[key]; delete obj[key]; } }
Decodes an object's encoded keys @param obj obj with possibly encoded key @param key key to decode
decode
javascript
e-oj/Fawn
lib/utils/gen.utils.js
https://github.com/e-oj/Fawn/blob/master/lib/utils/gen.utils.js
MIT
constructor () { /** * Stores prop->value mappings. * @type {Map<string|symbol, unknown>} */ this._properties = new Map() /** * Stores prop->Promise mappings. * @type {Map<string|symbol, pDefer.DeferredPromise<unknown>>} */ this._promiseMap = new Map() }
Context helps the app do many different things without explicitly depending on each other. Instead, each module can set a property on the context and other modules can get that property from the context when they need it. Benefits: * Avoid passing the same object to many different modules. * Avoid circular dependencie...
constructor
javascript
ipfs/ipfs-desktop
src/context.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/context.js
MIT
setProp (propertyName, value) { if (this._properties.has(propertyName)) { logger.error('[ctx] Property already exists') throw new Error(`[ctx] Property ${String(propertyName)} already exists`) } logger.info(`[ctx] setting ${String(propertyName)}`) try { this._properties.set(propertyNam...
Set the value of a property to a value. This method supports overwriting values. @template T @param {ContextProperties} propertyName @param {T} value @returns {void}
setProp
javascript
ipfs/ipfs-desktop
src/context.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/context.js
MIT
async getProp (propertyName) { logger.info(`[ctx] getting ${String(propertyName)}`) const value = this._properties.get(propertyName) if (value != null) { logger.info(`[ctx] Found existing property ${String(propertyName)}`) this._resolvePropToValue(propertyName, value) // @ts-ignore ...
Get the value of a property wrapped in a promise. @template T @param {ContextProperties} propertyName @returns {Promise<T>}
getProp
javascript
ipfs/ipfs-desktop
src/context.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/context.js
MIT
getFn (propertyName) { const originalFnPromise = this.getProp(propertyName) return async (...args) => { const originalFn = await originalFnPromise try { return await originalFn(...args) } catch (err) { logger.error(`[ctx] Error calling ${String(propertyName)}`) logger....
A simple helper to improve DX and UX when calling functions. This function allows you to request a function from AppContext without blocking until you actually need to call it. @param {ContextProperties} propertyName @returns {(...args: unknown[]) => Promise<unknown>}
getFn
javascript
ipfs/ipfs-desktop
src/context.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/context.js
MIT
_resolvePropToValue (propertyName, value) { let deferred = this._promiseMap.get(propertyName) if (deferred == null) { logger.info(`[ctx] No promise found for ${String(propertyName)}`) deferred = this._createDeferredForProp(propertyName) } logger.info(`[ctx] Resolving promise for ${String(pro...
Gets existing promise and resolves it with the given value. @private @template T @param {ContextProperties} propertyName @param {T} value @returns {void}
_resolvePropToValue
javascript
ipfs/ipfs-desktop
src/context.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/context.js
MIT
_createDeferredForProp (propertyName) { let deferred = this._promiseMap.get(propertyName) if (deferred == null) { deferred = pDefer() this._promiseMap.set(propertyName, deferred) } // @ts-expect-error - Need to fix generics return deferred }
Returns the existing promise for a property if it exists. If not, one is created and set in the `_promiseMap`, then returned @private @template T @param {ContextProperties} propertyName @returns {pDefer.DeferredPromise<T>}
_createDeferredForProp
javascript
ipfs/ipfs-desktop
src/context.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/context.js
MIT
function icon (status) { const dir = path.resolve(path.join(__dirname, '../assets/icons/tray')) if (IS_MAC) { return path.join(dir, 'macos', `${status}-22Template.png`) } const bw = store.get(CONFIG_KEYS.MONOCHROME_TRAY_ICON, false) if (bw) { const theme = nativeTheme.shouldUseDarkColors ? 'dark' : ...
we need to wait for i18n to be ready before we translate the tray menu @type {boolean}
icon
javascript
ipfs/ipfs-desktop
src/tray.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/tray.js
MIT
function getKuboRepositoryPath () { let ipfsPath = store.get('ipfsConfig.path') if (!ipfsPath) { ipfsPath = process.env.IPFS_PATH if (!ipfsPath) { const homeDir = os.homedir() ipfsPath = path.join(homeDir, '.ipfs') } } return ipfsPath }
we need to wait for i18n to be ready before we translate the tray menu @type {boolean}
getKuboRepositoryPath
javascript
ipfs/ipfs-desktop
src/tray.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/tray.js
MIT
function getConfigFilePath (ipfsd) { return join(ipfsd.path, 'config') }
Get repository configuration file path. @param {import('ipfsd-ctl').Controller} ipfsd @returns {string} config file path
getConfigFilePath
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function getApiFilePath (ipfsd) { return join(ipfsd.path, 'api') }
Get repository api file path. @param {import('ipfsd-ctl').Controller} ipfsd @returns {string} api file path
getApiFilePath
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function configExists (ipfsd) { return fs.pathExistsSync(getConfigFilePath(ipfsd)) }
Checks if the repository configuration file exists. @param {import('ipfsd-ctl').Controller} ipfsd @returns {boolean} true if config file exists
configExists
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function apiFileExists (ipfsd) { return fs.pathExistsSync(getApiFilePath(ipfsd)) }
Checks if the repository api file exists. @param {import('ipfsd-ctl').Controller} ipfsd @returns {boolean} true if config file exists
apiFileExists
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function readConfigFile (ipfsd) { return fs.readJsonSync(getConfigFilePath(ipfsd)) }
Reads the repository configuration file. @param {import('ipfsd-ctl').Controller} ipfsd @returns {any} the configuration
readConfigFile
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function writeConfigFile (ipfsd, config) { fs.writeJsonSync(getConfigFilePath(ipfsd), config, { spaces: 2 }) }
Writes the repository configuration file. @param {import('ipfsd-ctl').Controller} ipfsd @param {Object<string, any>} config
writeConfigFile
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function applyDefaults (ipfsd) { const config = readConfigFile(ipfsd) // Ensure strict CORS checking // See: https://github.com/ipfs/js-ipfsd-ctl/issues/333 config.API = { HTTPHeaders: {} } config.Swarm = config.Swarm ?? {} config.Swarm.DisableNatPortMap = false // uPnP config.Swarm.ConnMgr = config.Swa...
Set default minimum and maximum of connections to maintain by default. This must only be called for repositories created by IPFS Desktop. Existing ones shall remain intact. @param {import('ipfsd-ctl').Controller} ipfsd
applyDefaults
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function parseMultiaddr (addr) { return addr.includes('/http') ? multiaddr(addr) : multiaddr(addr).encapsulate('/http') }
Parses multiaddr from the configuration. @param {string} addr @returns {import('multiaddr').Multiaddr}
parseMultiaddr
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function getHttpPort (addrs) { let httpUrl = null if (Array.isArray(addrs)) { httpUrl = addrs.find(v => v.includes('127.0.0.1')) } else { httpUrl = addrs } const gw = parseMultiaddr(httpUrl) return gw.nodeAddress().port }
Get local HTTP port. @param {array|string} addrs @returns {number} the port
getHttpPort
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function migrateConfig (ipfsd) { // Bump revision number when new migration rule is added const REVISION = 6 const REVISION_KEY = 'daemonConfigRevision' const CURRENT_REVISION = store.get(REVISION_KEY, 0) // Migration is applied only once per revision if (CURRENT_REVISION >= REVISION) return // Read con...
Apply one-time updates to the config of IPFS node. This is the place where we execute fixes and performance tweaks for existing users. @param {import('ipfsd-ctl').Controller} ipfsd
migrateConfig
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
addURL = url => { if (!accessControlAllowOrigin.includes(url)) { accessControlAllowOrigin.push(url) return true } return false }
Apply one-time updates to the config of IPFS node. This is the place where we execute fixes and performance tweaks for existing users. @param {import('ipfsd-ctl').Controller} ipfsd
addURL
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
addURL = url => { if (!accessControlAllowOrigin.includes(url)) { accessControlAllowOrigin.push(url) return true } return false }
Apply one-time updates to the config of IPFS node. This is the place where we execute fixes and performance tweaks for existing users. @param {import('ipfsd-ctl').Controller} ipfsd
addURL
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
async function checkIfAddrIsDaemon (addr) { const options = { timeout: 3000, // 3s is plenty for localhost request method: 'POST', host: addr.address, port: addr.port, path: '/api/v0/refs?arg=/ipfs/QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn' } return new Promise(resolve => { const req...
Checks if the given address is a daemon address. @param {{ family: 4 | 6, address: string, port: number }} addr @returns {Promise<boolean>}
checkIfAddrIsDaemon
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
findFreePort = async (port) => { port = Math.max(port, 1024) return portfinder.getPortPromise({ port }) }
Find free close to port. @param {number} port @returns {Promise<number>}
findFreePort
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
findFreePort = async (port) => { port = Math.max(port, 1024) return portfinder.getPortPromise({ port }) }
Find free close to port. @param {number} port @returns {Promise<number>}
findFreePort
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
async function checkPortsArray (ipfsd, addrs) { addrs = addrs.filter(Boolean) for (const addr of addrs) { const ma = parseMultiaddr(addr) const port = ma.nodeAddress().port if (port === 0) { continue } const isDaemon = await checkIfAddrIsDaemon(ma.nodeAddress()) if (isDaemon) { ...
Check if all the ports in the array are available. @param {import('ipfsd-ctl').Controller} ipfsd @param {string[]} addrs @returns {Promise<boolean>}
checkPortsArray
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
async function checkPorts (ipfsd) { const config = readConfigFile(ipfsd) const apiIsArr = Array.isArray(config.Addresses.API) const gatewayIsArr = Array.isArray(config.Addresses.Gateway) if (apiIsArr || gatewayIsArr) { logger.info('[daemon] custom configuration with array of API or Gateway addrs') ret...
Check if ports are available and handle it. Returns true if ports are cleared for IPFS to start. @param {import('ipfsd-ctl').Controller} ipfsd @returns {Promise<boolean>}
checkPorts
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function checkRepositoryAndConfiguration (ipfsd) { if (!fs.pathExistsSync(ipfsd.path)) { // If the repository doesn't exist, skip verification. return true } try { const stats = fs.statSync(ipfsd.path) if (!stats.isDirectory()) { logger.error(`${ipfsd.path} must be a directory`) dialo...
Checks if the repository and the configuration file are valid. @param {import('ipfsd-ctl').Controller} ipfsd @returns {boolean}
checkRepositoryAndConfiguration
javascript
ipfs/ipfs-desktop
src/daemon/config.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/config.js
MIT
function getIpfsBinPath () { return process.env.IPFS_GO_EXEC || getCustomBinary() || require('kubo') .path() .replace('app.asar', 'app.asar.unpacked') }
Get the IPFS binary file path. @returns {string}
getIpfsBinPath
javascript
ipfs/ipfs-desktop
src/daemon/daemon.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js
MIT
async function getIpfsd (flags, path) { const ipfsBin = getIpfsBinPath() const ipfsd = await Ctl.createController({ ipfsHttpModule: require('ipfs-http-client'), ipfsBin, ipfsOptions: { repo: path }, remote: false, disposable: false, test: false, args: flags }) // Checks i...
Gets the IPFS daemon controller. If null is returned, it means that the repository or some configuration is wrong and IPFS Desktop should quit. @param {string[]} flags @param {string} path @returns {Promise<import('ipfsd-ctl').Controller|null>}
getIpfsd
javascript
ipfs/ipfs-desktop
src/daemon/daemon.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js
MIT
function listenToIpfsLogs (ipfsd, callback) { let stdout, stderr const listener = data => { callback(data.toString()) } const interval = setInterval(() => { if (!ipfsd.subprocess) { return } stdout = ipfsd.subprocess.stdout stderr = ipfsd.subprocess.stderr stdout.on('data', lis...
Gets the IPFS daemon controller. If null is returned, it means that the repository or some configuration is wrong and IPFS Desktop should quit. @param {string[]} flags @param {string} path @returns {Promise<import('ipfsd-ctl').Controller|null>}
listenToIpfsLogs
javascript
ipfs/ipfs-desktop
src/daemon/daemon.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js
MIT
stop = () => { clearInterval(interval) if (stdout) stdout.removeListener('data', listener) if (stderr) stderr.removeListener('data', listener) }
Gets the IPFS daemon controller. If null is returned, it means that the repository or some configuration is wrong and IPFS Desktop should quit. @param {string[]} flags @param {string} path @returns {Promise<import('ipfsd-ctl').Controller|null>}
stop
javascript
ipfs/ipfs-desktop
src/daemon/daemon.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js
MIT
stop = () => { clearInterval(interval) if (stdout) stdout.removeListener('data', listener) if (stderr) stderr.removeListener('data', listener) }
Gets the IPFS daemon controller. If null is returned, it means that the repository or some configuration is wrong and IPFS Desktop should quit. @param {string[]} flags @param {string} path @returns {Promise<import('ipfsd-ctl').Controller|null>}
stop
javascript
ipfs/ipfs-desktop
src/daemon/daemon.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js
MIT
async function startIpfsWithLogs (ipfsd) { let err, id, migrationPrompt let isMigrating, isErrored, isFinished let logs = '' const isSpawnedDaemonDead = (ipfsd) => { if (typeof ipfsd.subprocess === 'undefined') throw new Error('undefined ipfsd.subprocess, unable to reason about startup errors') if (ipf...
Start IPFS, collects the logs, detects errors and migrations. @param {import('ipfsd-ctl').Controller} ipfsd @returns {Promise<IpfsLogs>}
startIpfsWithLogs
javascript
ipfs/ipfs-desktop
src/daemon/daemon.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js
MIT
isSpawnedDaemonDead = (ipfsd) => { if (typeof ipfsd.subprocess === 'undefined') throw new Error('undefined ipfsd.subprocess, unable to reason about startup errors') if (ipfsd.subprocess === null) return false // not spawned yet or remote if (ipfsd.subprocess?.failed) return true // explicit failure // ...
Start IPFS, collects the logs, detects errors and migrations. @param {import('ipfsd-ctl').Controller} ipfsd @returns {Promise<IpfsLogs>}
isSpawnedDaemonDead
javascript
ipfs/ipfs-desktop
src/daemon/daemon.js
https://github.com/ipfs/ipfs-desktop/blob/master/src/daemon/daemon.js
MIT