repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
catapult-project/catapult
common/py_vulcanize/third_party/rcssmin/docs/apidoc/epydoc.js
collapse_all
function collapse_all(min_lines) { var elts = document.getElementsByTagName("div"); for (var i=0; i<elts.length; i++) { var elt = elts[i]; var split = elt.id.indexOf("-"); if (split > 0) if (elt.id.substring(split, elt.id.length) == "-expanded") if (num_lines(elt.innerHTML) > min_lines) ...
javascript
function collapse_all(min_lines) { var elts = document.getElementsByTagName("div"); for (var i=0; i<elts.length; i++) { var elt = elts[i]; var split = elt.id.indexOf("-"); if (split > 0) if (elt.id.substring(split, elt.id.length) == "-expanded") if (num_lines(elt.innerHTML) > min_lines) ...
[ "function", "collapse_all", "(", "min_lines", ")", "{", "var", "elts", "=", "document", ".", "getElementsByTagName", "(", "\"div\"", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "elts", ".", "length", ";", "i", "++", ")", "{", "var", ...
Collapse all blocks that mave more than `min_lines` lines.
[ "Collapse", "all", "blocks", "that", "mave", "more", "than", "min_lines", "lines", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/common/py_vulcanize/third_party/rcssmin/docs/apidoc/epydoc.js#L160-L170
train
catapult-project/catapult
third_party/gsutil/third_party/httplib2/doc/html/_static/doctools.js
function() { var params = $.getQueryParameters(); var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; if (terms.length) { var body = $('div.body'); window.setTimeout(function() { $.each(terms, function() { body.highlightText(this.toLowerCase(), 'highlight');...
javascript
function() { var params = $.getQueryParameters(); var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; if (terms.length) { var body = $('div.body'); window.setTimeout(function() { $.each(terms, function() { body.highlightText(this.toLowerCase(), 'highlight');...
[ "function", "(", ")", "{", "var", "params", "=", "$", ".", "getQueryParameters", "(", ")", ";", "var", "terms", "=", "(", "params", ".", "highlight", ")", "?", "params", ".", "highlight", "[", "0", "]", ".", "split", "(", "/", "\\s+", "/", ")", "...
highlight the search words provided in the url in the text
[ "highlight", "the", "search", "words", "provided", "in", "the", "url", "in", "the", "text" ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/gsutil/third_party/httplib2/doc/html/_static/doctools.js#L163-L177
train
catapult-project/catapult
third_party/gsutil/third_party/httplib2/doc/html/_static/doctools.js
function() { var togglers = $('img.toggler').click(function() { var src = $(this).attr('src'); var idnum = $(this).attr('id').substr(7); console.log($('tr.cg-' + idnum).toggle()); if (src.substr(-9) == 'minus.png') $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); ...
javascript
function() { var togglers = $('img.toggler').click(function() { var src = $(this).attr('src'); var idnum = $(this).attr('id').substr(7); console.log($('tr.cg-' + idnum).toggle()); if (src.substr(-9) == 'minus.png') $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); ...
[ "function", "(", ")", "{", "var", "togglers", "=", "$", "(", "'img.toggler'", ")", ".", "click", "(", "function", "(", ")", "{", "var", "src", "=", "$", "(", "this", ")", ".", "attr", "(", "'src'", ")", ";", "var", "idnum", "=", "$", "(", "this...
init the modindex toggle buttons
[ "init", "the", "modindex", "toggle", "buttons" ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/gsutil/third_party/httplib2/doc/html/_static/doctools.js#L182-L195
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/status.js
scrollTreeToPipeline
function scrollTreeToPipeline(pipelineIdOrElement) { var element = pipelineIdOrElement; if (!(pipelineIdOrElement instanceof jQuery)) { element = $(getTreePipelineElementId(pipelineIdOrElement)); } $('#sidebar').scrollTop(element.attr('offsetTop')); $('#sidebar').scrollLeft(element.attr('offsetLeft')); }
javascript
function scrollTreeToPipeline(pipelineIdOrElement) { var element = pipelineIdOrElement; if (!(pipelineIdOrElement instanceof jQuery)) { element = $(getTreePipelineElementId(pipelineIdOrElement)); } $('#sidebar').scrollTop(element.attr('offsetTop')); $('#sidebar').scrollLeft(element.attr('offsetLeft')); }
[ "function", "scrollTreeToPipeline", "(", "pipelineIdOrElement", ")", "{", "var", "element", "=", "pipelineIdOrElement", ";", "if", "(", "!", "(", "pipelineIdOrElement", "instanceof", "jQuery", ")", ")", "{", "element", "=", "$", "(", "getTreePipelineElementId", "(...
Scrolls to element of the pipeline in the tree.
[ "Scrolls", "to", "element", "of", "the", "pipeline", "in", "the", "tree", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/status.js#L63-L70
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/status.js
expandTreeToPipeline
function expandTreeToPipeline(pipelineId) { if (pipelineId == null) { return; } var elementId = getTreePipelineElementId(pipelineId); var parents = $(elementId).parents('.expandable'); if (parents.size() > 0) { // The toggle function will scroll to highlight the pipeline. parents.children('.hitare...
javascript
function expandTreeToPipeline(pipelineId) { if (pipelineId == null) { return; } var elementId = getTreePipelineElementId(pipelineId); var parents = $(elementId).parents('.expandable'); if (parents.size() > 0) { // The toggle function will scroll to highlight the pipeline. parents.children('.hitare...
[ "function", "expandTreeToPipeline", "(", "pipelineId", ")", "{", "if", "(", "pipelineId", "==", "null", ")", "{", "return", ";", "}", "var", "elementId", "=", "getTreePipelineElementId", "(", "pipelineId", ")", ";", "var", "parents", "=", "$", "(", "elementI...
Opens all pipelines down to the target one if not already expanded and scroll that pipeline into view.
[ "Opens", "all", "pipelines", "down", "to", "the", "target", "one", "if", "not", "already", "expanded", "and", "scroll", "that", "pipeline", "into", "view", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/status.js#L75-L88
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/status.js
handleTreeToggle
function handleTreeToggle(index, element) { var parentItem = $(element).parent(); var collapsing = parentItem.hasClass('expandable'); if (collapsing) { } else { // When expanded be sure the pipeline and its children are showing. scrollTreeToPipeline(parentItem); } }
javascript
function handleTreeToggle(index, element) { var parentItem = $(element).parent(); var collapsing = parentItem.hasClass('expandable'); if (collapsing) { } else { // When expanded be sure the pipeline and its children are showing. scrollTreeToPipeline(parentItem); } }
[ "function", "handleTreeToggle", "(", "index", ",", "element", ")", "{", "var", "parentItem", "=", "$", "(", "element", ")", ".", "parent", "(", ")", ";", "var", "collapsing", "=", "parentItem", ".", "hasClass", "(", "'expandable'", ")", ";", "if", "(", ...
Handles when the user toggles a leaf of the tree.
[ "Handles", "when", "the", "user", "toggles", "a", "leaf", "of", "the", "tree", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/status.js#L92-L100
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/status.js
countChildren
function countChildren(pipelineId) { var current = STATUS_MAP.pipelines[pipelineId]; if (!current) { return [0, 0]; } var total = 1; var done = 0; if (current.status == 'done') { done += 1; } for (var i = 0, n = current.children.length; i < n; i++) { var parts = countChildren(current.childre...
javascript
function countChildren(pipelineId) { var current = STATUS_MAP.pipelines[pipelineId]; if (!current) { return [0, 0]; } var total = 1; var done = 0; if (current.status == 'done') { done += 1; } for (var i = 0, n = current.children.length; i < n; i++) { var parts = countChildren(current.childre...
[ "function", "countChildren", "(", "pipelineId", ")", "{", "var", "current", "=", "STATUS_MAP", ".", "pipelines", "[", "pipelineId", "]", ";", "if", "(", "!", "current", ")", "{", "return", "[", "0", ",", "0", "]", ";", "}", "var", "total", "=", "1", ...
Counts the number of total and active children for the given pipeline. Will include the supplied pipeline in the totals.
[ "Counts", "the", "number", "of", "total", "and", "active", "children", "for", "the", "given", "pipeline", ".", "Will", "include", "the", "supplied", "pipeline", "in", "the", "totals", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/status.js#L105-L121
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/status.js
prettyName
function prettyName(name, sidebar) { var adjustedName = name; if (sidebar) { var adjustedName = name; var parts = name.split('.'); if (parts.length > 0) { adjustedName = parts[parts.length - 1]; } } return adjustedName.replace(/\./, '.<wbr>'); }
javascript
function prettyName(name, sidebar) { var adjustedName = name; if (sidebar) { var adjustedName = name; var parts = name.split('.'); if (parts.length > 0) { adjustedName = parts[parts.length - 1]; } } return adjustedName.replace(/\./, '.<wbr>'); }
[ "function", "prettyName", "(", "name", ",", "sidebar", ")", "{", "var", "adjustedName", "=", "name", ";", "if", "(", "sidebar", ")", "{", "var", "adjustedName", "=", "name", ";", "var", "parts", "=", "name", ".", "split", "(", "'.'", ")", ";", "if", ...
Create the readable name for the pipeline name.
[ "Create", "the", "readable", "name", "for", "the", "pipeline", "name", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/status.js#L125-L135
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/status.js
generateSidebar
function generateSidebar(statusMap, nextPipelineId, rootElement) { var currentElement = null; if (nextPipelineId) { currentElement = $('<li>'); // Value should match return of getTreePipelineElementId currentElement.attr('id', 'item-pipeline-' + nextPipelineId); } else { currentElement = rootElem...
javascript
function generateSidebar(statusMap, nextPipelineId, rootElement) { var currentElement = null; if (nextPipelineId) { currentElement = $('<li>'); // Value should match return of getTreePipelineElementId currentElement.attr('id', 'item-pipeline-' + nextPipelineId); } else { currentElement = rootElem...
[ "function", "generateSidebar", "(", "statusMap", ",", "nextPipelineId", ",", "rootElement", ")", "{", "var", "currentElement", "=", "null", ";", "if", "(", "nextPipelineId", ")", "{", "currentElement", "=", "$", "(", "'<li>'", ")", ";", "// Value should match re...
Recursively creates the sidebar. Use null nextPipelineId to create from root.
[ "Recursively", "creates", "the", "sidebar", ".", "Use", "null", "nextPipelineId", "to", "create", "from", "root", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/status.js#L582-L617
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/status.js
findActivePipeline
function findActivePipeline(pipelineId, isRoot) { var infoMap = STATUS_MAP.pipelines[pipelineId]; if (!infoMap) { return null; } // This is an active leaf node. if (infoMap.children.length == 0 && infoMap.status != 'done') { return pipelineId; } // Sort children by start time only. var childre...
javascript
function findActivePipeline(pipelineId, isRoot) { var infoMap = STATUS_MAP.pipelines[pipelineId]; if (!infoMap) { return null; } // This is an active leaf node. if (infoMap.children.length == 0 && infoMap.status != 'done') { return pipelineId; } // Sort children by start time only. var childre...
[ "function", "findActivePipeline", "(", "pipelineId", ",", "isRoot", ")", "{", "var", "infoMap", "=", "STATUS_MAP", ".", "pipelines", "[", "pipelineId", "]", ";", "if", "(", "!", "infoMap", ")", "{", "return", "null", ";", "}", "// This is an active leaf node."...
Depth-first search for active pipeline.
[ "Depth", "-", "first", "search", "for", "active", "pipeline", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/status.js#L630-L664
train
catapult-project/catapult
dashboard/dashboard/spa/chart-timeseries.js
filterTimeseriesesByLine
function filterTimeseriesesByLine(timeseriesesByLine) { const result = []; for (const {lineDescriptor, timeserieses} of timeseriesesByLine) { const filteredTimeserieses = timeserieses.filter(ts => ts); if (filteredTimeserieses.length === 0) continue; result.push({lineDescriptor, timeserieses: filteredTi...
javascript
function filterTimeseriesesByLine(timeseriesesByLine) { const result = []; for (const {lineDescriptor, timeserieses} of timeseriesesByLine) { const filteredTimeserieses = timeserieses.filter(ts => ts); if (filteredTimeserieses.length === 0) continue; result.push({lineDescriptor, timeserieses: filteredTi...
[ "function", "filterTimeseriesesByLine", "(", "timeseriesesByLine", ")", "{", "const", "result", "=", "[", "]", ";", "for", "(", "const", "{", "lineDescriptor", ",", "timeserieses", "}", "of", "timeseriesesByLine", ")", "{", "const", "filteredTimeserieses", "=", ...
Remove empty elements.
[ "Remove", "empty", "elements", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/dashboard/dashboard/spa/chart-timeseries.js#L524-L532
train
catapult-project/catapult
dashboard/dashboard/spa/chart-timeseries.js
getIcon
function getIcon(datum) { if (!datum.alert) return {}; if (datum.alert.improvement) { return { icon: 'cp:thumb-up', iconColor: 'var(--improvement-color, green)', }; } return { icon: 'cp:error', iconColor: datum.alert.bugId ? 'var(--neutral-color-dark, grey)' : 'var(--error-colo...
javascript
function getIcon(datum) { if (!datum.alert) return {}; if (datum.alert.improvement) { return { icon: 'cp:thumb-up', iconColor: 'var(--improvement-color, green)', }; } return { icon: 'cp:error', iconColor: datum.alert.bugId ? 'var(--neutral-color-dark, grey)' : 'var(--error-colo...
[ "function", "getIcon", "(", "datum", ")", "{", "if", "(", "!", "datum", ".", "alert", ")", "return", "{", "}", ";", "if", "(", "datum", ".", "alert", ".", "improvement", ")", "{", "return", "{", "icon", ":", "'cp:thumb-up'", ",", "iconColor", ":", ...
Improvement alerts display thumbs-up icons. Regression alerts display error icons.
[ "Improvement", "alerts", "display", "thumbs", "-", "up", "icons", ".", "Regression", "alerts", "display", "error", "icons", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/dashboard/dashboard/spa/chart-timeseries.js#L632-L645
train
catapult-project/catapult
third_party/mapreduce/mapreduce/static/status.js
listConfigs
function listConfigs(resultFunc) { $.ajax({ type: 'GET', url: 'command/list_configs', dataType: 'text', error: function(request, textStatus) { getResponseDataJson(textStatus); }, success: function(data, textStatus, request) { var response = getResponseDataJson(null, data); if...
javascript
function listConfigs(resultFunc) { $.ajax({ type: 'GET', url: 'command/list_configs', dataType: 'text', error: function(request, textStatus) { getResponseDataJson(textStatus); }, success: function(data, textStatus, request) { var response = getResponseDataJson(null, data); if...
[ "function", "listConfigs", "(", "resultFunc", ")", "{", "$", ".", "ajax", "(", "{", "type", ":", "'GET'", ",", "url", ":", "'command/list_configs'", ",", "dataType", ":", "'text'", ",", "error", ":", "function", "(", "request", ",", "textStatus", ")", "{...
Retrieve the list of configs.
[ "Retrieve", "the", "list", "of", "configs", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/mapreduce/mapreduce/static/status.js#L111-L126
train
catapult-project/catapult
third_party/mapreduce/mapreduce/static/status.js
listJobs
function listJobs(cursor, resultFunc) { // If the user is paging then they scrolled down so let's // help them by scrolling the window back to the top. var jumpToTop = !!cursor; cursor = cursor ? cursor : ''; setButter('Loading'); $.ajax({ type: 'GET', url: 'command/list_jobs?cursor=' + cursor, ...
javascript
function listJobs(cursor, resultFunc) { // If the user is paging then they scrolled down so let's // help them by scrolling the window back to the top. var jumpToTop = !!cursor; cursor = cursor ? cursor : ''; setButter('Loading'); $.ajax({ type: 'GET', url: 'command/list_jobs?cursor=' + cursor, ...
[ "function", "listJobs", "(", "cursor", ",", "resultFunc", ")", "{", "// If the user is paging then they scrolled down so let's", "// help them by scrolling the window back to the top.", "var", "jumpToTop", "=", "!", "!", "cursor", ";", "cursor", "=", "cursor", "?", "cursor"...
Return the list of job records and notifies the user the content is being fetched.
[ "Return", "the", "list", "of", "job", "records", "and", "notifies", "the", "user", "the", "content", "is", "being", "fetched", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/mapreduce/mapreduce/static/status.js#L130-L154
train
catapult-project/catapult
third_party/mapreduce/mapreduce/static/status.js
cleanUpJob
function cleanUpJob(name, mapreduce_id) { if (!confirm('Clean up job "' + name + '" with ID "' + mapreduce_id + '"?')) { return; } $.ajax({ async: false, type: 'POST', url: 'command/cleanup_job', data: {'mapreduce_id': mapreduce_id}, dataType: 'text', error: function(re...
javascript
function cleanUpJob(name, mapreduce_id) { if (!confirm('Clean up job "' + name + '" with ID "' + mapreduce_id + '"?')) { return; } $.ajax({ async: false, type: 'POST', url: 'command/cleanup_job', data: {'mapreduce_id': mapreduce_id}, dataType: 'text', error: function(re...
[ "function", "cleanUpJob", "(", "name", ",", "mapreduce_id", ")", "{", "if", "(", "!", "confirm", "(", "'Clean up job \"'", "+", "name", "+", "'\" with ID \"'", "+", "mapreduce_id", "+", "'\"?'", ")", ")", "{", "return", ";", "}", "$", ".", "ajax", "(", ...
Cleans up a job with the given name and ID, updates butter with status.
[ "Cleans", "up", "a", "job", "with", "the", "given", "name", "and", "ID", "updates", "butter", "with", "status", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/mapreduce/mapreduce/static/status.js#L157-L182
train
catapult-project/catapult
third_party/mapreduce/mapreduce/static/status.js
getJobDetail
function getJobDetail(jobId, resultFunc) { $.ajax({ type: 'GET', url: 'command/get_job_detail', dataType: 'text', data: {'mapreduce_id': jobId}, statusCode: { 404: function() { setButter('job ' + jobId + ' was not found.', true); } }, error: function(request, textStatus...
javascript
function getJobDetail(jobId, resultFunc) { $.ajax({ type: 'GET', url: 'command/get_job_detail', dataType: 'text', data: {'mapreduce_id': jobId}, statusCode: { 404: function() { setButter('job ' + jobId + ' was not found.', true); } }, error: function(request, textStatus...
[ "function", "getJobDetail", "(", "jobId", ",", "resultFunc", ")", "{", "$", ".", "ajax", "(", "{", "type", ":", "'GET'", ",", "url", ":", "'command/get_job_detail'", ",", "dataType", ":", "'text'", ",", "data", ":", "{", "'mapreduce_id'", ":", "jobId", "...
Retrieve the detail for a job.
[ "Retrieve", "the", "detail", "for", "a", "job", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/mapreduce/mapreduce/static/status.js#L209-L230
train
catapult-project/catapult
third_party/mapreduce/mapreduce/static/status.js
getSortedKeys
function getSortedKeys(obj) { var keys = []; $.each(obj, function(key, value) { keys.push(key); }); keys.sort(); return keys; }
javascript
function getSortedKeys(obj) { var keys = []; $.each(obj, function(key, value) { keys.push(key); }); keys.sort(); return keys; }
[ "function", "getSortedKeys", "(", "obj", ")", "{", "var", "keys", "=", "[", "]", ";", "$", ".", "each", "(", "obj", ",", "function", "(", "key", ",", "value", ")", "{", "keys", ".", "push", "(", "key", ")", ";", "}", ")", ";", "keys", ".", "s...
Returns an array of the keys of an object in sorted order.
[ "Returns", "an", "array", "of", "the", "keys", "of", "an", "object", "in", "sorted", "order", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/mapreduce/mapreduce/static/status.js#L239-L246
train
catapult-project/catapult
third_party/mapreduce/mapreduce/static/status.js
getElapsedTimeString
function getElapsedTimeString(start_timestamp_ms, updated_timestamp_ms) { var updatedDiff = updated_timestamp_ms - start_timestamp_ms; var updatedDays = Math.floor(updatedDiff / 86400000.0); updatedDiff -= (updatedDays * 86400000.0); var updatedHours = Math.floor(updatedDiff / 3600000.0); updatedDiff -= (upda...
javascript
function getElapsedTimeString(start_timestamp_ms, updated_timestamp_ms) { var updatedDiff = updated_timestamp_ms - start_timestamp_ms; var updatedDays = Math.floor(updatedDiff / 86400000.0); updatedDiff -= (updatedDays * 86400000.0); var updatedHours = Math.floor(updatedDiff / 3600000.0); updatedDiff -= (upda...
[ "function", "getElapsedTimeString", "(", "start_timestamp_ms", ",", "updated_timestamp_ms", ")", "{", "var", "updatedDiff", "=", "updated_timestamp_ms", "-", "start_timestamp_ms", ";", "var", "updatedDays", "=", "Math", ".", "floor", "(", "updatedDiff", "/", "86400000...
Get locale time string for time portion of job runtime. Specially handle number of days running as a prefix.
[ "Get", "locale", "time", "string", "for", "time", "portion", "of", "job", "runtime", ".", "Specially", "handle", "number", "of", "days", "running", "as", "a", "prefix", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/mapreduce/mapreduce/static/status.js#L274-L296
train
catapult-project/catapult
third_party/mapreduce/mapreduce/static/status.js
addParameters
function addParameters(params, prefix) { if (!params) { return; } var sortedParams = getSortedKeys(params); $.each(sortedParams, function(index, key) { var value = params[key]; var paramId = 'job-' + prefix + key + '-param'; var paramP = $('<p class="editable-inp...
javascript
function addParameters(params, prefix) { if (!params) { return; } var sortedParams = getSortedKeys(params); $.each(sortedParams, function(index, key) { var value = params[key]; var paramId = 'job-' + prefix + key + '-param'; var paramP = $('<p class="editable-inp...
[ "function", "addParameters", "(", "params", ",", "prefix", ")", "{", "if", "(", "!", "params", ")", "{", "return", ";", "}", "var", "sortedParams", "=", "getSortedKeys", "(", "params", ")", ";", "$", ".", "each", "(", "sortedParams", ",", "function", "...
Add parameter values to the job form.
[ "Add", "parameter", "values", "to", "the", "job", "form", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/mapreduce/mapreduce/static/status.js#L475-L509
train
catapult-project/catapult
dashboard/dashboard/spa/details-table.js
setCell
function setCell(map, key, columnCount, columnIndex, value) { if (!map.has(key)) map.set(key, new Array(columnCount)); map.get(key)[columnIndex] = value; }
javascript
function setCell(map, key, columnCount, columnIndex, value) { if (!map.has(key)) map.set(key, new Array(columnCount)); map.get(key)[columnIndex] = value; }
[ "function", "setCell", "(", "map", ",", "key", ",", "columnCount", ",", "columnIndex", ",", "value", ")", "{", "if", "(", "!", "map", ".", "has", "(", "key", ")", ")", "map", ".", "set", "(", "key", ",", "new", "Array", "(", "columnCount", ")", "...
Build a table map.
[ "Build", "a", "table", "map", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/dashboard/dashboard/spa/details-table.js#L231-L234
train
catapult-project/catapult
dashboard/dashboard/spa/details-table.js
getDescriptorParts
function getDescriptorParts(lineDescriptor, descriptorFlags) { const descriptorParts = []; if (descriptorFlags.suite) { descriptorParts.push(lineDescriptor.suites.map(breakWords).join('\n')); } if (descriptorFlags.measurement) { descriptorParts.push(breakWords(lineDescriptor.measurement)); } if (des...
javascript
function getDescriptorParts(lineDescriptor, descriptorFlags) { const descriptorParts = []; if (descriptorFlags.suite) { descriptorParts.push(lineDescriptor.suites.map(breakWords).join('\n')); } if (descriptorFlags.measurement) { descriptorParts.push(breakWords(lineDescriptor.measurement)); } if (des...
[ "function", "getDescriptorParts", "(", "lineDescriptor", ",", "descriptorFlags", ")", "{", "const", "descriptorParts", "=", "[", "]", ";", "if", "(", "descriptorFlags", ".", "suite", ")", "{", "descriptorParts", ".", "push", "(", "lineDescriptor", ".", "suites",...
Build an array of strings to display the parts of lineDescriptor that are not common to all of this details-table's lineDescriptors.
[ "Build", "an", "array", "of", "strings", "to", "display", "the", "parts", "of", "lineDescriptor", "that", "are", "not", "common", "to", "all", "of", "this", "details", "-", "table", "s", "lineDescriptors", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/dashboard/dashboard/spa/details-table.js#L367-L385
train
catapult-project/catapult
dashboard/dashboard/spa/timeseries-cache-request.js
findLowIndexInSortedArray
function findLowIndexInSortedArray(ary, getKey, loVal) { if (ary.length === 0) return 1; let low = 0; let high = ary.length - 1; let i; let comparison; let hitPos = -1; while (low <= high) { i = Math.floor((low + high) / 2); comparison = getKey(ary[i]) - loVal; if (comparison < 0) { low...
javascript
function findLowIndexInSortedArray(ary, getKey, loVal) { if (ary.length === 0) return 1; let low = 0; let high = ary.length - 1; let i; let comparison; let hitPos = -1; while (low <= high) { i = Math.floor((low + high) / 2); comparison = getKey(ary[i]) - loVal; if (comparison < 0) { low...
[ "function", "findLowIndexInSortedArray", "(", "ary", ",", "getKey", ",", "loVal", ")", "{", "if", "(", "ary", ".", "length", "===", "0", ")", "return", "1", ";", "let", "low", "=", "0", ";", "let", "high", "=", "ary", ".", "length", "-", "1", ";", ...
Finds the first index in the array whose value is >= loVal. The key for the search is defined by the getKey. This array must be prearranged such that ary.map(getKey) would also be sorted in ascending order. @param {Array} ary An array of arbitrary objects. @param {function():*} getKey Callback that produces a key val...
[ "Finds", "the", "first", "index", "in", "the", "array", "whose", "value", "is", ">", "=", "loVal", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/dashboard/dashboard/spa/timeseries-cache-request.js#L58-L80
train
catapult-project/catapult
netlog_viewer/netlog_viewer/log_util.js
createLogDump
function createLogDump( userComments, constants, events, polledData, tabData, numericDate) { var logDump = { 'userComments': userComments, 'constants': constants, 'events': events, 'polledData': polledData, 'tabData': tabData }; // Not technically client info, but it's u...
javascript
function createLogDump( userComments, constants, events, polledData, tabData, numericDate) { var logDump = { 'userComments': userComments, 'constants': constants, 'events': events, 'polledData': polledData, 'tabData': tabData }; // Not technically client info, but it's u...
[ "function", "createLogDump", "(", "userComments", ",", "constants", ",", "events", ",", "polledData", ",", "tabData", ",", "numericDate", ")", "{", "var", "logDump", "=", "{", "'userComments'", ":", "userComments", ",", "'constants'", ":", "constants", ",", "'...
Creates a new log dump. |events| is a list of all events, |polledData| is an object containing the results of each poll, |tabData| is an object containing data for individual tabs, |date| is the time the dump was created, as a formatted string. Returns the new log dump as an object. Resulting object may have a null ...
[ "Creates", "a", "new", "log", "dump", ".", "|events|", "is", "a", "list", "of", "all", "events", "|polledData|", "is", "an", "object", "containing", "the", "results", "of", "each", "poll", "|tabData|", "is", "an", "object", "containing", "data", "for", "in...
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/log_util.js#L33-L49
train
catapult-project/catapult
netlog_viewer/netlog_viewer/log_util.js
onUpdateAllCompleted
function onUpdateAllCompleted(userComments, callback, polledData) { var logDump = createLogDump( userComments, Constants, EventsTracker.getInstance().getAllCapturedEvents(), polledData, getTabData_(), timeutil.getCurrentTime()); callback(JSON.stringify(logDump)); }
javascript
function onUpdateAllCompleted(userComments, callback, polledData) { var logDump = createLogDump( userComments, Constants, EventsTracker.getInstance().getAllCapturedEvents(), polledData, getTabData_(), timeutil.getCurrentTime()); callback(JSON.stringify(logDump)); }
[ "function", "onUpdateAllCompleted", "(", "userComments", ",", "callback", ",", "polledData", ")", "{", "var", "logDump", "=", "createLogDump", "(", "userComments", ",", "Constants", ",", "EventsTracker", ".", "getInstance", "(", ")", ".", "getAllCapturedEvents", "...
Creates a full log dump using |polledData| and the return value of each tab's saveState function and passes it to |callback|.
[ "Creates", "a", "full", "log", "dump", "using", "|polledData|", "and", "the", "return", "value", "of", "each", "tab", "s", "saveState", "function", "and", "passes", "it", "to", "|callback|", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/log_util.js#L55-L61
train
catapult-project/catapult
netlog_viewer/netlog_viewer/log_util.js
createLogDumpAsync
function createLogDumpAsync(userComments, callback) { g_browser.updateAllInfo( onUpdateAllCompleted.bind(null, userComments, callback)); }
javascript
function createLogDumpAsync(userComments, callback) { g_browser.updateAllInfo( onUpdateAllCompleted.bind(null, userComments, callback)); }
[ "function", "createLogDumpAsync", "(", "userComments", ",", "callback", ")", "{", "g_browser", ".", "updateAllInfo", "(", "onUpdateAllCompleted", ".", "bind", "(", "null", ",", "userComments", ",", "callback", ")", ")", ";", "}" ]
Called to create a new log dump. Must not be called once a dump has been loaded. Once a log dump has been created, |callback| is passed the dumped text as a string.
[ "Called", "to", "create", "a", "new", "log", "dump", ".", "Must", "not", "be", "called", "once", "a", "dump", "has", "been", "loaded", ".", "Once", "a", "log", "dump", "has", "been", "created", "|callback|", "is", "passed", "the", "dumped", "text", "as...
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/log_util.js#L68-L71
train
catapult-project/catapult
netlog_viewer/netlog_viewer/log_util.js
getTabData_
function getTabData_() { var tabData = {}; var tabSwitcher = MainView.getInstance().tabSwitcher(); var tabIdToView = tabSwitcher.getAllTabViews(); for (var tabId in tabIdToView) { var view = tabIdToView[tabId]; if (view.saveState) tabData[tabId] = view.saveState(); } }
javascript
function getTabData_() { var tabData = {}; var tabSwitcher = MainView.getInstance().tabSwitcher(); var tabIdToView = tabSwitcher.getAllTabViews(); for (var tabId in tabIdToView) { var view = tabIdToView[tabId]; if (view.saveState) tabData[tabId] = view.saveState(); } }
[ "function", "getTabData_", "(", ")", "{", "var", "tabData", "=", "{", "}", ";", "var", "tabSwitcher", "=", "MainView", ".", "getInstance", "(", ")", ".", "tabSwitcher", "(", ")", ";", "var", "tabIdToView", "=", "tabSwitcher", ".", "getAllTabViews", "(", ...
Gather any tab-specific state information prior to creating a log dump.
[ "Gather", "any", "tab", "-", "specific", "state", "information", "prior", "to", "creating", "a", "log", "dump", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/log_util.js#L76-L85
train
catapult-project/catapult
netlog_viewer/netlog_viewer/log_util.js
loadLogFile
function loadLogFile(logFileContents, fileName) { // Try and parse the log dump as a single JSON string. If this succeeds, // it's most likely a full log dump. Otherwise, it may be a dump created by // --log-net-log. var parsedDump = null; var errorString = ''; try { parsedDump = JSON.pa...
javascript
function loadLogFile(logFileContents, fileName) { // Try and parse the log dump as a single JSON string. If this succeeds, // it's most likely a full log dump. Otherwise, it may be a dump created by // --log-net-log. var parsedDump = null; var errorString = ''; try { parsedDump = JSON.pa...
[ "function", "loadLogFile", "(", "logFileContents", ",", "fileName", ")", "{", "// Try and parse the log dump as a single JSON string. If this succeeds,", "// it's most likely a full log dump. Otherwise, it may be a dump created by", "// --log-net-log.", "var", "parsedDump", "=", "null"...
Loads a log dump from the string |logFileContents|, which can be either a full net-internals dump, or a NetLog dump only. Returns a string containing a log of the load.
[ "Loads", "a", "log", "dump", "from", "the", "string", "|logFileContents|", "which", "can", "be", "either", "a", "full", "net", "-", "internals", "dump", "or", "a", "NetLog", "dump", "only", ".", "Returns", "a", "string", "containing", "a", "log", "of", "...
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/log_util.js#L250-L276
train
catapult-project/catapult
dashboard/dashboard/spa/group-alerts.js
isRelated
function isRelated(a, b) { if (a.measurementAvg === b.measurementAvg) return true; if (a.relatedNames && a.relatedNames.has(b.measurementAvg)) { return true; } if (b.relatedNames && b.relatedNames.has(a.measurementAvg)) { return true; } return false; }
javascript
function isRelated(a, b) { if (a.measurementAvg === b.measurementAvg) return true; if (a.relatedNames && a.relatedNames.has(b.measurementAvg)) { return true; } if (b.relatedNames && b.relatedNames.has(a.measurementAvg)) { return true; } return false; }
[ "function", "isRelated", "(", "a", ",", "b", ")", "{", "if", "(", "a", ".", "measurementAvg", "===", "b", ".", "measurementAvg", ")", "return", "true", ";", "if", "(", "a", ".", "relatedNames", "&&", "a", ".", "relatedNames", ".", "has", "(", "b", ...
Two Alerts are related if either A) their measurements are equal, or B) either's relatedNames contains the other's measurement. @param {!Alert} a @param {!Alert} b @return {boolean}
[ "Two", "Alerts", "are", "related", "if", "either", "A", ")", "their", "measurements", "are", "equal", "or", "B", ")", "either", "s", "relatedNames", "contains", "the", "other", "s", "measurement", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/dashboard/dashboard/spa/group-alerts.js#L36-L47
train
catapult-project/catapult
third_party/polymer3/bower_components/polymer/lib/mixins/properties-mixin.js
superPropertiesClass
function superPropertiesClass(constructor) { const superCtor = Object.getPrototypeOf(constructor); // Note, the `PropertiesMixin` class below only refers to the class // generated by this call to the mixin; the instanceof test only works // because the mixin is deduped and guaranteed only to apply once, he...
javascript
function superPropertiesClass(constructor) { const superCtor = Object.getPrototypeOf(constructor); // Note, the `PropertiesMixin` class below only refers to the class // generated by this call to the mixin; the instanceof test only works // because the mixin is deduped and guaranteed only to apply once, he...
[ "function", "superPropertiesClass", "(", "constructor", ")", "{", "const", "superCtor", "=", "Object", ".", "getPrototypeOf", "(", "constructor", ")", ";", "// Note, the `PropertiesMixin` class below only refers to the class", "// generated by this call to the mixin; the instanceof...
Returns the super class constructor for the given class, if it is an instance of the PropertiesMixin. @param {!PropertiesMixinConstructor} constructor PropertiesMixin constructor @return {PropertiesMixinConstructor} Super class constructor
[ "Returns", "the", "super", "class", "constructor", "for", "the", "given", "class", "if", "it", "is", "an", "instance", "of", "the", "PropertiesMixin", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/polymer3/bower_components/polymer/lib/mixins/properties-mixin.js#L66-L75
train
catapult-project/catapult
tracing/third_party/gl-matrix/jsdoc-template/publish.js
makeSrcFile
function makeSrcFile(path, srcDir, name) { if (JSDOC.opt.s) return; if (!name) { name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_"); name = name.replace(/\:/g, "_"); } var src = {path: path, name:name, charset: IO.encoding, hilited: ""}; if (defined(JSDOC.PluginManager)) { JSDOC.PluginMana...
javascript
function makeSrcFile(path, srcDir, name) { if (JSDOC.opt.s) return; if (!name) { name = path.replace(/\.\.?[\\\/]/g, "").replace(/[\\\/]/g, "_"); name = name.replace(/\:/g, "_"); } var src = {path: path, name:name, charset: IO.encoding, hilited: ""}; if (defined(JSDOC.PluginManager)) { JSDOC.PluginMana...
[ "function", "makeSrcFile", "(", "path", ",", "srcDir", ",", "name", ")", "{", "if", "(", "JSDOC", ".", "opt", ".", "s", ")", "return", ";", "if", "(", "!", "name", ")", "{", "name", "=", "path", ".", "replace", "(", "/", "\\.\\.?[\\\\\\/]", "/", ...
Turn a raw source file into a code-hilited page in the docs.
[ "Turn", "a", "raw", "source", "file", "into", "a", "code", "-", "hilited", "page", "in", "the", "docs", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/gl-matrix/jsdoc-template/publish.js#L154-L171
train
catapult-project/catapult
tracing/third_party/gl-matrix/jsdoc-template/publish.js
makeSignature
function makeSignature(params) { if (!params) return "()"; var signature = "(" + params.filter( function($) { return $.name.indexOf(".") == -1; // don't show config params in signature } ).map( function($) { return $.name; } ).join(", ") + ")"; return signature; }
javascript
function makeSignature(params) { if (!params) return "()"; var signature = "(" + params.filter( function($) { return $.name.indexOf(".") == -1; // don't show config params in signature } ).map( function($) { return $.name; } ).join(", ") + ")"; return signature; }
[ "function", "makeSignature", "(", "params", ")", "{", "if", "(", "!", "params", ")", "return", "\"()\"", ";", "var", "signature", "=", "\"(\"", "+", "params", ".", "filter", "(", "function", "(", "$", ")", "{", "return", "$", ".", "name", ".", "index...
Build output for displaying function parameters.
[ "Build", "output", "for", "displaying", "function", "parameters", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/third_party/gl-matrix/jsdoc-template/publish.js#L174-L190
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/common.js
getIso8601String
function getIso8601String(timeMs) { var time = new Date(); time.setTime(timeMs); return '' + time.getUTCFullYear() + '-' + leftPadNumber(time.getUTCMonth() + 1, 2, '0') + '-' + leftPadNumber(time.getUTCDate(), 2, '0') + 'T' + leftPadNumber(time.getUTCHours(), 2, '0') + ':' + leftPadN...
javascript
function getIso8601String(timeMs) { var time = new Date(); time.setTime(timeMs); return '' + time.getUTCFullYear() + '-' + leftPadNumber(time.getUTCMonth() + 1, 2, '0') + '-' + leftPadNumber(time.getUTCDate(), 2, '0') + 'T' + leftPadNumber(time.getUTCHours(), 2, '0') + ':' + leftPadN...
[ "function", "getIso8601String", "(", "timeMs", ")", "{", "var", "time", "=", "new", "Date", "(", ")", ";", "time", ".", "setTime", "(", "timeMs", ")", ";", "return", "''", "+", "time", ".", "getUTCFullYear", "(", ")", "+", "'-'", "+", "leftPadNumber", ...
Convert milliseconds since the epoch to an ISO8601 datestring.
[ "Convert", "milliseconds", "since", "the", "epoch", "to", "an", "ISO8601", "datestring", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/common.js#L34-L44
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/common.js
getElapsedTimeString
function getElapsedTimeString(startTimestampMs, updatedTimestampMs) { var updatedDiff = Math.max(0, updatedTimestampMs - startTimestampMs); var updatedDays = Math.floor(updatedDiff / 86400000.0); updatedDiff -= (updatedDays * 86400000.0); var updatedHours = Math.floor(updatedDiff / 3600000.0); updatedDiff -= ...
javascript
function getElapsedTimeString(startTimestampMs, updatedTimestampMs) { var updatedDiff = Math.max(0, updatedTimestampMs - startTimestampMs); var updatedDays = Math.floor(updatedDiff / 86400000.0); updatedDiff -= (updatedDays * 86400000.0); var updatedHours = Math.floor(updatedDiff / 3600000.0); updatedDiff -= ...
[ "function", "getElapsedTimeString", "(", "startTimestampMs", ",", "updatedTimestampMs", ")", "{", "var", "updatedDiff", "=", "Math", ".", "max", "(", "0", ",", "updatedTimestampMs", "-", "startTimestampMs", ")", ";", "var", "updatedDays", "=", "Math", ".", "floo...
Get time string for job runtime. Specially handle number of days running as a prefix and milliseconds as a suffix. If the runtime is less than one minute, use the format "38.123 seconds" instead.
[ "Get", "time", "string", "for", "job", "runtime", ".", "Specially", "handle", "number", "of", "days", "running", "as", "a", "prefix", "and", "milliseconds", "as", "a", "suffix", ".", "If", "the", "runtime", "is", "less", "than", "one", "minute", "use", "...
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/common.js#L50-L84
train
catapult-project/catapult
third_party/pipeline/pipeline/ui/common.js
setButter
function setButter(message, error, traceback, asHtml) { var butter = $('#butter'); // Prevent flicker on butter update by hiding it first. butter.css('display', 'none'); if (error) { butter.removeClass('info').addClass('error'); } else { butter.removeClass('error').addClass('info'); } butter.child...
javascript
function setButter(message, error, traceback, asHtml) { var butter = $('#butter'); // Prevent flicker on butter update by hiding it first. butter.css('display', 'none'); if (error) { butter.removeClass('info').addClass('error'); } else { butter.removeClass('error').addClass('info'); } butter.child...
[ "function", "setButter", "(", "message", ",", "error", ",", "traceback", ",", "asHtml", ")", "{", "var", "butter", "=", "$", "(", "'#butter'", ")", ";", "// Prevent flicker on butter update by hiding it first.", "butter", ".", "css", "(", "'display'", ",", "'non...
Sets the status butter, optionally indicating if it's an error message.
[ "Sets", "the", "status", "butter", "optionally", "indicating", "if", "it", "s", "an", "error", "message", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/pipeline/pipeline/ui/common.js#L94-L129
train
catapult-project/catapult
third_party/snap-it/popup.js
completeProcess
function completeProcess(messages) { var html = outputHTMLString(messages); var file = new Blob([html], {type: 'text/html'}); var url = URL.createObjectURL(file); var a = document.getElementById('button'); a.className = 'download'; a.innerHTML = 'Download'; a.href = url; a.download = "snap-it.html"; }
javascript
function completeProcess(messages) { var html = outputHTMLString(messages); var file = new Blob([html], {type: 'text/html'}); var url = URL.createObjectURL(file); var a = document.getElementById('button'); a.className = 'download'; a.innerHTML = 'Download'; a.href = url; a.download = "snap-it.html"; }
[ "function", "completeProcess", "(", "messages", ")", "{", "var", "html", "=", "outputHTMLString", "(", "messages", ")", ";", "var", "file", "=", "new", "Blob", "(", "[", "html", "]", ",", "{", "type", ":", "'text/html'", "}", ")", ";", "var", "url", ...
Takes all the responses from the injected content scripts and creates the HTML file for download. @param {Array<Object>} messages The response from all of the injected content scripts.
[ "Takes", "all", "the", "responses", "from", "the", "injected", "content", "scripts", "and", "creates", "the", "HTML", "file", "for", "download", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L40-L50
train
catapult-project/catapult
third_party/snap-it/popup.js
outputHTMLString
function outputHTMLString(messages) { var rootIndex = 0; for (var i = 1; i < messages.length; i++) { rootIndex = messages[i].frameIndex === '0' ? i : rootIndex; } fillRemainingHolesAndMinimizeStyles(messages, rootIndex); return messages[rootIndex].html.join(''); }
javascript
function outputHTMLString(messages) { var rootIndex = 0; for (var i = 1; i < messages.length; i++) { rootIndex = messages[i].frameIndex === '0' ? i : rootIndex; } fillRemainingHolesAndMinimizeStyles(messages, rootIndex); return messages[rootIndex].html.join(''); }
[ "function", "outputHTMLString", "(", "messages", ")", "{", "var", "rootIndex", "=", "0", ";", "for", "(", "var", "i", "=", "1", ";", "i", "<", "messages", ".", "length", ";", "i", "++", ")", "{", "rootIndex", "=", "messages", "[", "i", "]", ".", ...
Converts the responses from the injected content scripts into a string representing the HTML. @param {Array<Object>} messages The response from all of the injected content scripts. @return {string} The resulting HTML.
[ "Converts", "the", "responses", "from", "the", "injected", "content", "scripts", "into", "a", "string", "representing", "the", "HTML", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L60-L67
train
catapult-project/catapult
third_party/snap-it/popup.js
minimizeStyles
function minimizeStyles(message) { var nestingDepth = message.frameIndex.split('.').length - 1; var iframe = document.createElement('iframe'); document.body.appendChild(iframe); iframe.setAttribute( 'style', `height: ${message.windowHeight}px;` + `width: ${message.windowWidth}px;`); var ht...
javascript
function minimizeStyles(message) { var nestingDepth = message.frameIndex.split('.').length - 1; var iframe = document.createElement('iframe'); document.body.appendChild(iframe); iframe.setAttribute( 'style', `height: ${message.windowHeight}px;` + `width: ${message.windowWidth}px;`); var ht...
[ "function", "minimizeStyles", "(", "message", ")", "{", "var", "nestingDepth", "=", "message", ".", "frameIndex", ".", "split", "(", "'.'", ")", ".", "length", "-", "1", ";", "var", "iframe", "=", "document", ".", "createElement", "(", "'iframe'", ")", "...
Removes all style attribute properties that are unneeded. @param {Object} message The message Object whose style attributes should be minimized.
[ "Removes", "all", "style", "attribute", "properties", "that", "are", "unneeded", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L99-L142
train
catapult-project/catapult
third_party/snap-it/popup.js
minimizePseudoElementStyle
function minimizePseudoElementStyle( message, doc, selector, finalPseudoElements) { var maxNumberOfIterations = 5; var match = selector.match(/^#(.*):(:.*)$/); var id = match[1]; var type = match[2]; var element = doc.getElementById(id); if (element) { var originalStyleMap = message.pseu...
javascript
function minimizePseudoElementStyle( message, doc, selector, finalPseudoElements) { var maxNumberOfIterations = 5; var match = selector.match(/^#(.*):(:.*)$/); var id = match[1]; var type = match[2]; var element = doc.getElementById(id); if (element) { var originalStyleMap = message.pseu...
[ "function", "minimizePseudoElementStyle", "(", "message", ",", "doc", ",", "selector", ",", "finalPseudoElements", ")", "{", "var", "maxNumberOfIterations", "=", "5", ";", "var", "match", "=", "selector", ".", "match", "(", "/", "^#(.*):(:.*)$", "/", ")", ";",...
Removes all style attribute properties that are unneeded for a single pseudo element. @param {Object} message The message Object that contains the pseudo element whose style attributes should be minimized. @param {Document} doc The Document that contains the rendered HTML. @param {string} selector The CSS selector for...
[ "Removes", "all", "style", "attribute", "properties", "that", "are", "unneeded", "for", "a", "single", "pseudo", "element", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L156-L203
train
catapult-project/catapult
third_party/snap-it/popup.js
minimizeStyle
function minimizeStyle(message, doc, element, id, index) { var originalStyleAttribute = element.getAttribute('style'); var originalStyleMap = message.idToStyleMap[id]; var requiredStyleMap = {}; var maxNumberOfIterations = 5; // We compare the computed style before and after removing the style attribute //...
javascript
function minimizeStyle(message, doc, element, id, index) { var originalStyleAttribute = element.getAttribute('style'); var originalStyleMap = message.idToStyleMap[id]; var requiredStyleMap = {}; var maxNumberOfIterations = 5; // We compare the computed style before and after removing the style attribute //...
[ "function", "minimizeStyle", "(", "message", ",", "doc", ",", "element", ",", "id", ",", "index", ")", "{", "var", "originalStyleAttribute", "=", "element", ".", "getAttribute", "(", "'style'", ")", ";", "var", "originalStyleMap", "=", "message", ".", "idToS...
Removes all style attribute properties that are unneeded for a single element. @param {Object} message The message Object that contains the element whose style attributes should be minimized. @param {Document} doc The Document that contains the rendered HTML. @param {Element} element The Element whose style attributes...
[ "Removes", "all", "style", "attribute", "properties", "that", "are", "unneeded", "for", "a", "single", "element", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L219-L255
train
catapult-project/catapult
third_party/snap-it/popup.js
updateMinimizedStyleMap
function updateMinimizedStyleMap( doc, element, originalStyleMap, minimizedStyleMap, pseudo) { var currentComputedStyle = doc.defaultView.getComputedStyle(element, pseudo); var foundNewRequiredStyle = false; for (var property in originalStyleMap) { var originalValue = originalStyleMap[prop...
javascript
function updateMinimizedStyleMap( doc, element, originalStyleMap, minimizedStyleMap, pseudo) { var currentComputedStyle = doc.defaultView.getComputedStyle(element, pseudo); var foundNewRequiredStyle = false; for (var property in originalStyleMap) { var originalValue = originalStyleMap[prop...
[ "function", "updateMinimizedStyleMap", "(", "doc", ",", "element", ",", "originalStyleMap", ",", "minimizedStyleMap", ",", "pseudo", ")", "{", "var", "currentComputedStyle", "=", "doc", ".", "defaultView", ".", "getComputedStyle", "(", "element", ",", "pseudo", ")...
We compare the original computed style with the minimized computed style and update |minimizedStyleMap| based on any differences. @param {Document} doc The Document that contains the rendered HTML. @param {Element} element The Element whose style attributes should be minimized. @param {Object<string, string>} original...
[ "We", "compare", "the", "original", "computed", "style", "with", "the", "minimized", "computed", "style", "and", "update", "|minimizedStyleMap|", "based", "on", "any", "differences", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L277-L293
train
catapult-project/catapult
third_party/snap-it/popup.js
buildStyleAttribute
function buildStyleAttribute(styleMap) { var styleAttribute = []; for (var property in styleMap) { styleAttribute.push(property + ': ' + styleMap[property] + ';'); } return styleAttribute.join(' '); }
javascript
function buildStyleAttribute(styleMap) { var styleAttribute = []; for (var property in styleMap) { styleAttribute.push(property + ': ' + styleMap[property] + ';'); } return styleAttribute.join(' '); }
[ "function", "buildStyleAttribute", "(", "styleMap", ")", "{", "var", "styleAttribute", "=", "[", "]", ";", "for", "(", "var", "property", "in", "styleMap", ")", "{", "styleAttribute", ".", "push", "(", "property", "+", "': '", "+", "styleMap", "[", "proper...
Build a style attribute from a map of property names to property values. @param {Object<string, string} styleMap The keys are style attribute property names. The values are the corresponding property values. @return {string} The correct style attribute.
[ "Build", "a", "style", "attribute", "from", "a", "map", "of", "property", "names", "to", "property", "values", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L302-L308
train
catapult-project/catapult
third_party/snap-it/popup.js
unescapeHTML
function unescapeHTML(html, nestingDepth) { var div = document.createElement('div'); for (var i = 0; i < nestingDepth; i++) { div.innerHTML = `<iframe srcdoc="${html}"></iframe>`; html = div.childNodes[0].attributes.srcdoc.value; } return html; }
javascript
function unescapeHTML(html, nestingDepth) { var div = document.createElement('div'); for (var i = 0; i < nestingDepth; i++) { div.innerHTML = `<iframe srcdoc="${html}"></iframe>`; html = div.childNodes[0].attributes.srcdoc.value; } return html; }
[ "function", "unescapeHTML", "(", "html", ",", "nestingDepth", ")", "{", "var", "div", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "nestingDepth", ";", "i", "++", ")", "{", "div", "...
Take a string that represents valid HTML and unescape it so that it can be rendered. @param {string} html The HTML to unescape. @param {number} nestingDepth The number of times the HTML must be unescaped. @return {string} The unescaped HTML.
[ "Take", "a", "string", "that", "represents", "valid", "HTML", "and", "unescape", "it", "so", "that", "it", "can", "be", "rendered", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/snap-it/popup.js#L318-L325
train
catapult-project/catapult
netlog_viewer/netlog_viewer/main.js
MainView
function MainView() { assertFirstConstructorCall(MainView); if (hasTouchScreen()) { document.body.classList.add('touch'); } // This must be initialized before the tabs, so they can register as // observers. g_browser = BrowserBridge.getInstance(); // This must be the first constants...
javascript
function MainView() { assertFirstConstructorCall(MainView); if (hasTouchScreen()) { document.body.classList.add('touch'); } // This must be initialized before the tabs, so they can register as // observers. g_browser = BrowserBridge.getInstance(); // This must be the first constants...
[ "function", "MainView", "(", ")", "{", "assertFirstConstructorCall", "(", "MainView", ")", ";", "if", "(", "hasTouchScreen", "(", ")", ")", "{", "document", ".", "body", ".", "classList", ".", "add", "(", "'touch'", ")", ";", "}", "// This must be initialize...
Main entry point. Called once the page has loaded. @constructor
[ "Main", "entry", "point", ".", "Called", "once", "the", "page", "has", "loaded", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/main.js#L54-L98
train
catapult-project/catapult
netlog_viewer/netlog_viewer/main.js
areValidConstants
function areValidConstants(receivedConstants) { return typeof(receivedConstants) === 'object' && typeof(receivedConstants.logEventTypes) === 'object' && typeof(receivedConstants.clientInfo) === 'object' && typeof(receivedConstants.logEventPhase) === 'object' && typeof(receivedConstants.logSour...
javascript
function areValidConstants(receivedConstants) { return typeof(receivedConstants) === 'object' && typeof(receivedConstants.logEventTypes) === 'object' && typeof(receivedConstants.clientInfo) === 'object' && typeof(receivedConstants.logEventPhase) === 'object' && typeof(receivedConstants.logSour...
[ "function", "areValidConstants", "(", "receivedConstants", ")", "{", "return", "typeof", "(", "receivedConstants", ")", "===", "'object'", "&&", "typeof", "(", "receivedConstants", ".", "logEventTypes", ")", "===", "'object'", "&&", "typeof", "(", "receivedConstants...
Returns true if it's given a valid-looking constants object. @param {Object} receivedConstants The received map of constants. @return {boolean} True if the |receivedConstants| object appears valid.
[ "Returns", "true", "if", "it", "s", "given", "a", "valid", "-", "looking", "constants", "object", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/main.js#L335-L346
train
catapult-project/catapult
third_party/polymer2/bower_components/web-animations-js/src/normalize-keyframes.js
expandShorthandAndAntiAlias
function expandShorthandAndAntiAlias(property, value, result) { if (isNotAnimatable(property)) { return; } var longProperties = shorthandToLonghand[property]; if (longProperties) { shorthandExpanderElem.style[property] = value; for (var i in longProperties) { var longProperty =...
javascript
function expandShorthandAndAntiAlias(property, value, result) { if (isNotAnimatable(property)) { return; } var longProperties = shorthandToLonghand[property]; if (longProperties) { shorthandExpanderElem.style[property] = value; for (var i in longProperties) { var longProperty =...
[ "function", "expandShorthandAndAntiAlias", "(", "property", ",", "value", ",", "result", ")", "{", "if", "(", "isNotAnimatable", "(", "property", ")", ")", "{", "return", ";", "}", "var", "longProperties", "=", "shorthandToLonghand", "[", "property", "]", ";",...
This delegates parsing shorthand value syntax to the browser.
[ "This", "delegates", "parsing", "shorthand", "value", "syntax", "to", "the", "browser", "." ]
992929ffccac68827869a497f01ee4d653ed4f25
https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/third_party/polymer2/bower_components/web-animations-js/src/normalize-keyframes.js#L159-L174
train
Shopify/slate
packages/slate-translations/index.js
createSchemaContentWithLocales
async function createSchemaContentWithLocales(localizedSchema, mainSchemaPath) { // eslint-disable-next-line func-style const traverse = async (obj) => { const objectKeys = Object.keys(obj); await Promise.all( objectKeys.map(async (key) => { if (typeof obj[key].t === 'string') { obj[...
javascript
async function createSchemaContentWithLocales(localizedSchema, mainSchemaPath) { // eslint-disable-next-line func-style const traverse = async (obj) => { const objectKeys = Object.keys(obj); await Promise.all( objectKeys.map(async (key) => { if (typeof obj[key].t === 'string') { obj[...
[ "async", "function", "createSchemaContentWithLocales", "(", "localizedSchema", ",", "mainSchemaPath", ")", "{", "// eslint-disable-next-line func-style", "const", "traverse", "=", "async", "(", "obj", ")", "=>", "{", "const", "objectKeys", "=", "Object", ".", "keys", ...
Goes through the main schema to get the translation keys and to fill the schema with translations @param {*} localizedSchema The schema with the combined locales @param {*} mainSchemaPath The path to the main schema (schema.json) @returns
[ "Goes", "through", "the", "main", "schema", "to", "get", "the", "translation", "keys", "and", "to", "fill", "the", "schema", "with", "translations" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-translations/index.js#L12-L29
train
Shopify/slate
packages/slate-translations/index.js
combineLocales
async function combineLocales(localesPath) { const localesFiles = await fs.readdir(localesPath); const jsonFiles = localesFiles.filter((fileName) => fileName.endsWith('.json'), ); return jsonFiles.reduce(async (promise, file) => { const accumulator = await promise; const localeCode = path .ba...
javascript
async function combineLocales(localesPath) { const localesFiles = await fs.readdir(localesPath); const jsonFiles = localesFiles.filter((fileName) => fileName.endsWith('.json'), ); return jsonFiles.reduce(async (promise, file) => { const accumulator = await promise; const localeCode = path .ba...
[ "async", "function", "combineLocales", "(", "localesPath", ")", "{", "const", "localesFiles", "=", "await", "fs", ".", "readdir", "(", "localesPath", ")", ";", "const", "jsonFiles", "=", "localesFiles", ".", "filter", "(", "(", "fileName", ")", "=>", "fileNa...
Creates a single JSON object from all the languages in locales @param {*} localesPath Absolute path to the locales folder /sections/section-name/locales/ @returns
[ "Creates", "a", "single", "JSON", "object", "from", "all", "the", "languages", "in", "locales" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-translations/index.js#L37-L55
train
Shopify/slate
packages/slate-translations/index.js
_getLocalizedValues
async function _getLocalizedValues(key, localizedSchema) { const combinedTranslationsObject = {}; await Promise.all( // eslint-disable-next-line array-callback-return Object.keys(localizedSchema).map((language) => { combinedTranslationsObject[language] = _.get( localizedSchema[language], ...
javascript
async function _getLocalizedValues(key, localizedSchema) { const combinedTranslationsObject = {}; await Promise.all( // eslint-disable-next-line array-callback-return Object.keys(localizedSchema).map((language) => { combinedTranslationsObject[language] = _.get( localizedSchema[language], ...
[ "async", "function", "_getLocalizedValues", "(", "key", ",", "localizedSchema", ")", "{", "const", "combinedTranslationsObject", "=", "{", "}", ";", "await", "Promise", ".", "all", "(", "// eslint-disable-next-line array-callback-return", "Object", ".", "keys", "(", ...
Gets all the translations for a translation key @param {*} key The key of the value to receive within the locales json object @param {*} localizedSchema Object containing all the translations in locales @returns Object with index for every language in the locales folder
[ "Gets", "all", "the", "translations", "for", "a", "translation", "key" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-translations/index.js#L64-L78
train
Shopify/slate
packages/slate-tools/tools/utilities/index.js
getAvailablePortSeries
function getAvailablePortSeries(start, quantity, increment = 1) { const startPort = start; const endPort = start + (quantity - 1); return findAPortInUse(startPort, endPort, '127.0.0.1').then((port) => { if (typeof port === 'number') { return getAvailablePortSeries(port + increment, quantity); } ...
javascript
function getAvailablePortSeries(start, quantity, increment = 1) { const startPort = start; const endPort = start + (quantity - 1); return findAPortInUse(startPort, endPort, '127.0.0.1').then((port) => { if (typeof port === 'number') { return getAvailablePortSeries(port + increment, quantity); } ...
[ "function", "getAvailablePortSeries", "(", "start", ",", "quantity", ",", "increment", "=", "1", ")", "{", "const", "startPort", "=", "start", ";", "const", "endPort", "=", "start", "+", "(", "quantity", "-", "1", ")", ";", "return", "findAPortInUse", "(",...
Finds a series of available ports of length quantity, starting at a given port number and incrementing up. Returns an array of port numbers.
[ "Finds", "a", "series", "of", "available", "ports", "of", "length", "quantity", "starting", "at", "a", "given", "port", "number", "and", "incrementing", "up", ".", "Returns", "an", "array", "of", "port", "numbers", "." ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-tools/tools/utilities/index.js#L36-L53
train
Shopify/slate
packages/slate-env/index.js
create
function create({values, name, root} = {}) { const envName = _getFileName(name); const envPath = path.resolve( root || config.get('env.rootDirectory'), envName, ); const envContents = _getFileContents(values); fs.writeFileSync(envPath, envContents); }
javascript
function create({values, name, root} = {}) { const envName = _getFileName(name); const envPath = path.resolve( root || config.get('env.rootDirectory'), envName, ); const envContents = _getFileContents(values); fs.writeFileSync(envPath, envContents); }
[ "function", "create", "(", "{", "values", ",", "name", ",", "root", "}", "=", "{", "}", ")", "{", "const", "envName", "=", "_getFileName", "(", "name", ")", ";", "const", "envPath", "=", "path", ".", "resolve", "(", "root", "||", "config", ".", "ge...
Creates a new env file with optional name and values
[ "Creates", "a", "new", "env", "file", "with", "optional", "name", "and", "values" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-env/index.js#L25-L34
train
Shopify/slate
packages/slate-env/index.js
_getFileName
function _getFileName(name) { if (typeof name === 'undefined' || name.trim() === '') { return config.get('env.basename'); } return `${config.get('env.basename')}.${name}`; }
javascript
function _getFileName(name) { if (typeof name === 'undefined' || name.trim() === '') { return config.get('env.basename'); } return `${config.get('env.basename')}.${name}`; }
[ "function", "_getFileName", "(", "name", ")", "{", "if", "(", "typeof", "name", "===", "'undefined'", "||", "name", ".", "trim", "(", ")", "===", "''", ")", "{", "return", "config", ".", "get", "(", "'env.basename'", ")", ";", "}", "return", "`", "${...
Return the default env file name, with optional name appended
[ "Return", "the", "default", "env", "file", "name", "with", "optional", "name", "appended" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-env/index.js#L37-L43
train
Shopify/slate
packages/slate-env/index.js
_getFileContents
function _getFileContents(values) { const env = getDefaultSlateEnv(); for (const key in values) { if (values.hasOwnProperty(key) && env.hasOwnProperty(key)) { env[key] = values[key]; } } return Object.entries(env) .map((keyValues) => { return `${keyValues.join('=')}\r\n`; }) .j...
javascript
function _getFileContents(values) { const env = getDefaultSlateEnv(); for (const key in values) { if (values.hasOwnProperty(key) && env.hasOwnProperty(key)) { env[key] = values[key]; } } return Object.entries(env) .map((keyValues) => { return `${keyValues.join('=')}\r\n`; }) .j...
[ "function", "_getFileContents", "(", "values", ")", "{", "const", "env", "=", "getDefaultSlateEnv", "(", ")", ";", "for", "(", "const", "key", "in", "values", ")", "{", "if", "(", "values", ".", "hasOwnProperty", "(", "key", ")", "&&", "env", ".", "has...
Return default list of env variables with their assigned value, if any.
[ "Return", "default", "list", "of", "env", "variables", "with", "their", "assigned", "value", "if", "any", "." ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-env/index.js#L46-L60
train
Shopify/slate
packages/slate-env/index.js
assign
function assign(name) { const envFileName = _getFileName(name); const envPath = path.resolve(config.get('env.rootDirectory'), envFileName); const result = dotenv.config({path: envPath}); if (typeof name !== 'undefined' && result.error) { throw result.error; } _setEnvName(name); }
javascript
function assign(name) { const envFileName = _getFileName(name); const envPath = path.resolve(config.get('env.rootDirectory'), envFileName); const result = dotenv.config({path: envPath}); if (typeof name !== 'undefined' && result.error) { throw result.error; } _setEnvName(name); }
[ "function", "assign", "(", "name", ")", "{", "const", "envFileName", "=", "_getFileName", "(", "name", ")", ";", "const", "envPath", "=", "path", ".", "resolve", "(", "config", ".", "get", "(", "'env.rootDirectory'", ")", ",", "envFileName", ")", ";", "c...
Reads an .env file and assigns their values to environment variables
[ "Reads", "an", ".", "env", "file", "and", "assigns", "their", "values", "to", "environment", "variables" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-env/index.js#L63-L73
train
Shopify/slate
packages/slate-env/index.js
validate
function validate() { const errors = [].concat( _validateStore(), _validatePassword(), _validateThemeId(), ); return { errors, isValid: errors.length === 0, }; }
javascript
function validate() { const errors = [].concat( _validateStore(), _validatePassword(), _validateThemeId(), ); return { errors, isValid: errors.length === 0, }; }
[ "function", "validate", "(", ")", "{", "const", "errors", "=", "[", "]", ".", "concat", "(", "_validateStore", "(", ")", ",", "_validatePassword", "(", ")", ",", "_validateThemeId", "(", ")", ",", ")", ";", "return", "{", "errors", ",", "isValid", ":",...
Checks if Slate env variables are the required value types and format
[ "Checks", "if", "Slate", "env", "variables", "are", "the", "required", "value", "types", "and", "format" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-env/index.js#L92-L103
train
Shopify/slate
packages/slate-env/index.js
getSlateEnv
function getSlateEnv() { const env = {}; SLATE_ENV_VARS.forEach((key) => { env[key] = process.env[key]; }); return env; }
javascript
function getSlateEnv() { const env = {}; SLATE_ENV_VARS.forEach((key) => { env[key] = process.env[key]; }); return env; }
[ "function", "getSlateEnv", "(", ")", "{", "const", "env", "=", "{", "}", ";", "SLATE_ENV_VARS", ".", "forEach", "(", "(", "key", ")", "=>", "{", "env", "[", "key", "]", "=", "process", ".", "env", "[", "key", "]", ";", "}", ")", ";", "return", ...
Get the values of Slate's required environment variables
[ "Get", "the", "values", "of", "Slate", "s", "required", "environment", "variables" ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/slate-env/index.js#L179-L187
train
Shopify/slate
packages/create-slate-theme/create-slate-theme.js
installThemeDeps
function installThemeDeps(root, options) { if (options.skipInstall) { console.log('Skipping theme dependency installation...'); return Promise.resolve(); } const prevDir = process.cwd(); console.log('Installing theme dependencies...'); process.chdir(root); const cmd = utils.shouldUseYarn() ? ...
javascript
function installThemeDeps(root, options) { if (options.skipInstall) { console.log('Skipping theme dependency installation...'); return Promise.resolve(); } const prevDir = process.cwd(); console.log('Installing theme dependencies...'); process.chdir(root); const cmd = utils.shouldUseYarn() ? ...
[ "function", "installThemeDeps", "(", "root", ",", "options", ")", "{", "if", "(", "options", ".", "skipInstall", ")", "{", "console", ".", "log", "(", "'Skipping theme dependency installation...'", ")", ";", "return", "Promise", ".", "resolve", "(", ")", ";", ...
Executes `npm install` or `yarn install` in rootPath.
[ "Executes", "npm", "install", "or", "yarn", "install", "in", "rootPath", "." ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/create-slate-theme/create-slate-theme.js#L88-L104
train
Shopify/slate
packages/create-slate-theme/create-slate-theme.js
copyFromDir
function copyFromDir(starter, root) { if (!fs.existsSync(starter)) { throw new Error(`starter ${starter} doesn't exist`); } // Chmod with 755. // 493 = parseInt('755', 8) return fs.mkdirp(root, {mode: 493}).then(() => { console.log( `Creating new theme from local starter: ${chalk.green(starter)...
javascript
function copyFromDir(starter, root) { if (!fs.existsSync(starter)) { throw new Error(`starter ${starter} doesn't exist`); } // Chmod with 755. // 493 = parseInt('755', 8) return fs.mkdirp(root, {mode: 493}).then(() => { console.log( `Creating new theme from local starter: ${chalk.green(starter)...
[ "function", "copyFromDir", "(", "starter", ",", "root", ")", "{", "if", "(", "!", "fs", ".", "existsSync", "(", "starter", ")", ")", "{", "throw", "new", "Error", "(", "`", "${", "starter", "}", "`", ")", ";", "}", "// Chmod with 755.", "// 493 = parse...
Copy starter from file system.
[ "Copy", "starter", "from", "file", "system", "." ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/create-slate-theme/create-slate-theme.js#L107-L123
train
Shopify/slate
packages/create-slate-theme/create-slate-theme.js
cloneFromGit
function cloneFromGit(hostInfo, root, ssh) { const branch = hostInfo.committish ? `-b ${hostInfo.committish}` : ''; let url; if (ssh) { url = hostInfo.ssh({noCommittish: true}); } else { url = hostInfo.https({noCommittish: true, noGitPlus: true}); } console.log(`Cloning theme from a git repo: ${ch...
javascript
function cloneFromGit(hostInfo, root, ssh) { const branch = hostInfo.committish ? `-b ${hostInfo.committish}` : ''; let url; if (ssh) { url = hostInfo.ssh({noCommittish: true}); } else { url = hostInfo.https({noCommittish: true, noGitPlus: true}); } console.log(`Cloning theme from a git repo: ${ch...
[ "function", "cloneFromGit", "(", "hostInfo", ",", "root", ",", "ssh", ")", "{", "const", "branch", "=", "hostInfo", ".", "committish", "?", "`", "${", "hostInfo", ".", "committish", "}", "`", ":", "''", ";", "let", "url", ";", "if", "(", "ssh", ")", ...
Clones starter from URI.
[ "Clones", "starter", "from", "URI", "." ]
c698803aa1106d0b6d555d463ddf59bf97e41bd1
https://github.com/Shopify/slate/blob/c698803aa1106d0b6d555d463ddf59bf97e41bd1/packages/create-slate-theme/create-slate-theme.js#L126-L153
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
CustomError
function CustomError (message, cause) { Error.call(this) if (Error.captureStackTrace) Error.captureStackTrace(this, arguments.callee) init.call(this, 'CustomError', message, cause) }
javascript
function CustomError (message, cause) { Error.call(this) if (Error.captureStackTrace) Error.captureStackTrace(this, arguments.callee) init.call(this, 'CustomError', message, cause) }
[ "function", "CustomError", "(", "message", ",", "cause", ")", "{", "Error", ".", "call", "(", "this", ")", "if", "(", "Error", ".", "captureStackTrace", ")", "Error", ".", "captureStackTrace", "(", "this", ",", "arguments", ".", "callee", ")", "init", "....
generic prototype, not intended to be actually used - helpful for `instanceof`
[ "generic", "prototype", "not", "intended", "to", "be", "actually", "used", "-", "helpful", "for", "instanceof" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L1578-L1583
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
doVisitFull
function doVisitFull(visit, node) { if(node.left) { var v = doVisitFull(visit, node.left) if(v) { return v } } var v = visit(node.key, node.value) if(v) { return v } if(node.right) { return doVisitFull(visit, node.right) } }
javascript
function doVisitFull(visit, node) { if(node.left) { var v = doVisitFull(visit, node.left) if(v) { return v } } var v = visit(node.key, node.value) if(v) { return v } if(node.right) { return doVisitFull(visit, node.right) } }
[ "function", "doVisitFull", "(", "visit", ",", "node", ")", "{", "if", "(", "node", ".", "left", ")", "{", "var", "v", "=", "doVisitFull", "(", "visit", ",", "node", ".", "left", ")", "if", "(", "v", ")", "{", "return", "v", "}", "}", "var", "v"...
Visit all nodes inorder
[ "Visit", "all", "nodes", "inorder" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L2168-L2178
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
doVisitHalf
function doVisitHalf(lo, compare, visit, node) { var l = compare(lo, node.key) if(l <= 0) { if(node.left) { var v = doVisitHalf(lo, compare, visit, node.left) if(v) { return v } } var v = visit(node.key, node.value) if(v) { return v } } if(node.right) { return doVisitHalf(lo, com...
javascript
function doVisitHalf(lo, compare, visit, node) { var l = compare(lo, node.key) if(l <= 0) { if(node.left) { var v = doVisitHalf(lo, compare, visit, node.left) if(v) { return v } } var v = visit(node.key, node.value) if(v) { return v } } if(node.right) { return doVisitHalf(lo, com...
[ "function", "doVisitHalf", "(", "lo", ",", "compare", ",", "visit", ",", "node", ")", "{", "var", "l", "=", "compare", "(", "lo", ",", "node", ".", "key", ")", "if", "(", "l", "<=", "0", ")", "{", "if", "(", "node", ".", "left", ")", "{", "va...
Visit half nodes in order
[ "Visit", "half", "nodes", "in", "order" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L2181-L2194
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
doVisit
function doVisit(lo, hi, compare, visit, node) { var l = compare(lo, node.key) var h = compare(hi, node.key) var v if(l <= 0) { if(node.left) { v = doVisit(lo, hi, compare, visit, node.left) if(v) { return v } } if(h > 0) { v = visit(node.key, node.value) if(v) { return v } ...
javascript
function doVisit(lo, hi, compare, visit, node) { var l = compare(lo, node.key) var h = compare(hi, node.key) var v if(l <= 0) { if(node.left) { v = doVisit(lo, hi, compare, visit, node.left) if(v) { return v } } if(h > 0) { v = visit(node.key, node.value) if(v) { return v } ...
[ "function", "doVisit", "(", "lo", ",", "hi", ",", "compare", ",", "visit", ",", "node", ")", "{", "var", "l", "=", "compare", "(", "lo", ",", "node", ".", "key", ")", "var", "h", "=", "compare", "(", "hi", ",", "node", ".", "key", ")", "var", ...
Visit all nodes within a range
[ "Visit", "all", "nodes", "within", "a", "range" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L2197-L2214
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
swapNode
function swapNode(n, v) { n.key = v.key n.value = v.value n.left = v.left n.right = v.right n._color = v._color n._count = v._count }
javascript
function swapNode(n, v) { n.key = v.key n.value = v.value n.left = v.left n.right = v.right n._color = v._color n._count = v._count }
[ "function", "swapNode", "(", "n", ",", "v", ")", "{", "n", ".", "key", "=", "v", ".", "key", "n", ".", "value", "=", "v", ".", "value", "n", ".", "left", "=", "v", ".", "left", "n", ".", "right", "=", "v", ".", "right", "n", ".", "_color", ...
Swaps two nodes
[ "Swaps", "two", "nodes" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L2460-L2467
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
collate
function collate(a, b) { if (a === b) { return 0; } a = normalizeKey(a); b = normalizeKey(b); var ai = collationIndex(a); var bi = collationIndex(b); if ((ai - bi) !== 0) { return ai - bi; } switch (typeof a) { case 'number': return a - b; case 'boolean': return a < b ? ...
javascript
function collate(a, b) { if (a === b) { return 0; } a = normalizeKey(a); b = normalizeKey(b); var ai = collationIndex(a); var bi = collationIndex(b); if ((ai - bi) !== 0) { return ai - bi; } switch (typeof a) { case 'number': return a - b; case 'boolean': return a < b ? ...
[ "function", "collate", "(", "a", ",", "b", ")", "{", "if", "(", "a", "===", "b", ")", "{", "return", "0", ";", "}", "a", "=", "normalizeKey", "(", "a", ")", ";", "b", "=", "normalizeKey", "(", "b", ")", ";", "var", "ai", "=", "collationIndex", ...
set to '_' for easier debugging
[ "set", "to", "_", "for", "easier", "debugging" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L6732-L6755
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
pop
function pop(stack, metaStack) { var obj = stack.pop(); if (metaStack.length) { var lastMetaElement = metaStack[metaStack.length - 1]; if (obj === lastMetaElement.element) { // popping a meta-element, e.g. an object whose value is another object metaStack.pop(); lastMetaElement = metaStac...
javascript
function pop(stack, metaStack) { var obj = stack.pop(); if (metaStack.length) { var lastMetaElement = metaStack[metaStack.length - 1]; if (obj === lastMetaElement.element) { // popping a meta-element, e.g. an object whose value is another object metaStack.pop(); lastMetaElement = metaStac...
[ "function", "pop", "(", "stack", ",", "metaStack", ")", "{", "var", "obj", "=", "stack", ".", "pop", "(", ")", ";", "if", "(", "metaStack", ".", "length", ")", "{", "var", "lastMetaElement", "=", "metaStack", "[", "metaStack", ".", "length", "-", "1"...
move up the stack while parsing this function moved outside of parseIndexableString for performance
[ "move", "up", "the", "stack", "while", "parsing", "this", "function", "moved", "outside", "of", "parseIndexableString", "for", "performance" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L6894-L6915
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
getHost
function getHost(name, opts) { // encode db name if opts.prefix is a url (#5574) if (hasUrlPrefix(opts)) { var dbName = opts.name.substr(opts.prefix.length); name = opts.prefix + encodeURIComponent(dbName); } // Prase the URI into all its little bits var uri = pouchdbUtils.parseUri(name); // Stor...
javascript
function getHost(name, opts) { // encode db name if opts.prefix is a url (#5574) if (hasUrlPrefix(opts)) { var dbName = opts.name.substr(opts.prefix.length); name = opts.prefix + encodeURIComponent(dbName); } // Prase the URI into all its little bits var uri = pouchdbUtils.parseUri(name); // Stor...
[ "function", "getHost", "(", "name", ",", "opts", ")", "{", "// encode db name if opts.prefix is a url (#5574)", "if", "(", "hasUrlPrefix", "(", "opts", ")", ")", "{", "var", "dbName", "=", "opts", ".", "name", ".", "substr", "(", "opts", ".", "prefix", ".", ...
Get all the information you possibly can about the URI given by name and return it as a suitable object.
[ "Get", "all", "the", "information", "you", "possibly", "can", "about", "the", "URI", "given", "by", "name", "and", "return", "it", "as", "a", "suitable", "object", "." ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L7222-L7255
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
genUrl
function genUrl(opts, path) { // If the host already has a path, then we need to have a path delimiter // Otherwise, the path delimiter is the empty string var pathDel = !opts.path ? '' : '/'; // If the host already has a path, then we need to have a path delimiter // Otherwise, the path delimiter is the emp...
javascript
function genUrl(opts, path) { // If the host already has a path, then we need to have a path delimiter // Otherwise, the path delimiter is the empty string var pathDel = !opts.path ? '' : '/'; // If the host already has a path, then we need to have a path delimiter // Otherwise, the path delimiter is the emp...
[ "function", "genUrl", "(", "opts", ",", "path", ")", "{", "// If the host already has a path, then we need to have a path delimiter", "// Otherwise, the path delimiter is the empty string", "var", "pathDel", "=", "!", "opts", ".", "path", "?", "''", ":", "'/'", ";", "// I...
Generate a URL with the host data given by opts and the given path
[ "Generate", "a", "URL", "with", "the", "host", "data", "given", "by", "opts", "and", "the", "given", "path" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L7263-L7273
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
function (since, callback) { if (opts.aborted) { return; } params.since = since; // "since" can be any kind of json object in Coudant/CouchDB 2.x /* istanbul ignore next */ if (typeof params.since === "object") { params.since = JSON.stringify(params.since); } ...
javascript
function (since, callback) { if (opts.aborted) { return; } params.since = since; // "since" can be any kind of json object in Coudant/CouchDB 2.x /* istanbul ignore next */ if (typeof params.since === "object") { params.since = JSON.stringify(params.since); } ...
[ "function", "(", "since", ",", "callback", ")", "{", "if", "(", "opts", ".", "aborted", ")", "{", "return", ";", "}", "params", ".", "since", "=", "since", ";", "// \"since\" can be any kind of json object in Coudant/CouchDB 2.x", "/* istanbul ignore next */", "if",...
Get all the changes starting wtih the one immediately after the sequence number given by since.
[ "Get", "all", "the", "changes", "starting", "wtih", "the", "one", "immediately", "after", "the", "sequence", "number", "given", "by", "since", "." ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L7999-L8037
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
decodeDoc
function decodeDoc(doc) { if (!doc) { return doc; } var idx = doc._doc_id_rev.lastIndexOf(':'); doc._id = doc._doc_id_rev.substring(0, idx - 1); doc._rev = doc._doc_id_rev.substring(idx + 1); delete doc._doc_id_rev; return doc; }
javascript
function decodeDoc(doc) { if (!doc) { return doc; } var idx = doc._doc_id_rev.lastIndexOf(':'); doc._id = doc._doc_id_rev.substring(0, idx - 1); doc._rev = doc._doc_id_rev.substring(idx + 1); delete doc._doc_id_rev; return doc; }
[ "function", "decodeDoc", "(", "doc", ")", "{", "if", "(", "!", "doc", ")", "{", "return", "doc", ";", "}", "var", "idx", "=", "doc", ".", "_doc_id_rev", ".", "lastIndexOf", "(", "':'", ")", ";", "doc", ".", "_id", "=", "doc", ".", "_doc_id_rev", ...
read the doc back out from the database. we don't store the _id or _rev because we already have _doc_id_rev.
[ "read", "the", "doc", "back", "out", "from", "the", "database", ".", "we", "don", "t", "store", "the", "_id", "or", "_rev", "because", "we", "already", "have", "_doc_id_rev", "." ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L8238-L8247
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
readBlobData
function readBlobData(body, type, asBlob, callback) { if (asBlob) { if (!body) { callback(pouchdbBinaryUtils.blob([''], {type: type})); } else if (typeof body !== 'string') { // we have blob support callback(body); } else { // no blob support callback(pouchdbBinaryUtils.base64StringToBlo...
javascript
function readBlobData(body, type, asBlob, callback) { if (asBlob) { if (!body) { callback(pouchdbBinaryUtils.blob([''], {type: type})); } else if (typeof body !== 'string') { // we have blob support callback(body); } else { // no blob support callback(pouchdbBinaryUtils.base64StringToBlo...
[ "function", "readBlobData", "(", "body", ",", "type", ",", "asBlob", ",", "callback", ")", "{", "if", "(", "asBlob", ")", "{", "if", "(", "!", "body", ")", "{", "callback", "(", "pouchdbBinaryUtils", ".", "blob", "(", "[", "''", "]", ",", "{", "typ...
Read a blob from the database, encoding as necessary and translating from base64 if the IDB doesn't support native Blobs
[ "Read", "a", "blob", "from", "the", "database", "encoding", "as", "necessary", "and", "translating", "from", "base64", "if", "the", "IDB", "doesn", "t", "support", "native", "Blobs" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L8252-L8272
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
postProcessAttachments
function postProcessAttachments(results, asBlob) { return Promise.all(results.map(function (row) { if (row.doc && row.doc._attachments) { var attNames = Object.keys(row.doc._attachments); return Promise.all(attNames.map(function (att) { var attObj = row.doc._attachments[att]; if (!('bo...
javascript
function postProcessAttachments(results, asBlob) { return Promise.all(results.map(function (row) { if (row.doc && row.doc._attachments) { var attNames = Object.keys(row.doc._attachments); return Promise.all(attNames.map(function (att) { var attObj = row.doc._attachments[att]; if (!('bo...
[ "function", "postProcessAttachments", "(", "results", ",", "asBlob", ")", "{", "return", "Promise", ".", "all", "(", "results", ".", "map", "(", "function", "(", "row", ")", "{", "if", "(", "row", ".", "doc", "&&", "row", ".", "doc", ".", "_attachments...
IDB-specific postprocessing necessary because we don't know whether we stored a true Blob or a base64-encoded string, and if it's a Blob it needs to be read outside of the transaction context
[ "IDB", "-", "specific", "postprocessing", "necessary", "because", "we", "don", "t", "know", "whether", "we", "stored", "a", "true", "Blob", "or", "a", "base64", "-", "encoded", "string", "and", "if", "it", "s", "a", "Blob", "it", "needs", "to", "be", "...
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L8311-L8334
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
insertAttachmentMappings
function insertAttachmentMappings(docInfo, seq, callback) { var attsAdded = 0; var attsToAdd = Object.keys(docInfo.data._attachments || {}); if (!attsToAdd.length) { return callback(); } function checkDone() { if (++attsAdded === attsToAdd.length) { callback(); } } ...
javascript
function insertAttachmentMappings(docInfo, seq, callback) { var attsAdded = 0; var attsToAdd = Object.keys(docInfo.data._attachments || {}); if (!attsToAdd.length) { return callback(); } function checkDone() { if (++attsAdded === attsToAdd.length) { callback(); } } ...
[ "function", "insertAttachmentMappings", "(", "docInfo", ",", "seq", ",", "callback", ")", "{", "var", "attsAdded", "=", "0", ";", "var", "attsToAdd", "=", "Object", ".", "keys", "(", "docInfo", ".", "data", ".", "_attachments", "||", "{", "}", ")", ";", ...
map seqs to attachment digests, which we will need later during compaction
[ "map", "seqs", "to", "attachment", "digests", "which", "we", "will", "need", "later", "during", "compaction" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L8725-L8760
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
fetchDocAsynchronously
function fetchDocAsynchronously(metadata, row, winningRev$$1) { var key = metadata.id + "::" + winningRev$$1; docIdRevIndex.get(key).onsuccess = function onGetDoc(e) { row.doc = decodeDoc(e.target.result); if (opts.conflicts) { var conflicts = pouchdbMerge.collectConflicts(metadata); ...
javascript
function fetchDocAsynchronously(metadata, row, winningRev$$1) { var key = metadata.id + "::" + winningRev$$1; docIdRevIndex.get(key).onsuccess = function onGetDoc(e) { row.doc = decodeDoc(e.target.result); if (opts.conflicts) { var conflicts = pouchdbMerge.collectConflicts(metadata); ...
[ "function", "fetchDocAsynchronously", "(", "metadata", ",", "row", ",", "winningRev$$1", ")", "{", "var", "key", "=", "metadata", ".", "id", "+", "\"::\"", "+", "winningRev$$1", ";", "docIdRevIndex", ".", "get", "(", "key", ")", ".", "onsuccess", "=", "fun...
if the user specifies include_docs=true, then we don't want to block the main cursor while we're fetching the doc
[ "if", "the", "user", "specifies", "include_docs", "=", "true", "then", "we", "don", "t", "want", "to", "block", "the", "main", "cursor", "while", "we", "re", "fetching", "the", "doc" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L8961-L8973
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
createSchema
function createSchema(db) { var docStore = db.createObjectStore(DOC_STORE, {keyPath : 'id'}); db.createObjectStore(BY_SEQ_STORE, {autoIncrement: true}) .createIndex('_doc_id_rev', '_doc_id_rev', {unique: true}); db.createObjectStore(ATTACH_STORE, {keyPath: 'digest'}); db.createObjectStore(META_STO...
javascript
function createSchema(db) { var docStore = db.createObjectStore(DOC_STORE, {keyPath : 'id'}); db.createObjectStore(BY_SEQ_STORE, {autoIncrement: true}) .createIndex('_doc_id_rev', '_doc_id_rev', {unique: true}); db.createObjectStore(ATTACH_STORE, {keyPath: 'digest'}); db.createObjectStore(META_STO...
[ "function", "createSchema", "(", "db", ")", "{", "var", "docStore", "=", "db", ".", "createObjectStore", "(", "DOC_STORE", ",", "{", "keyPath", ":", "'id'", "}", ")", ";", "db", ".", "createObjectStore", "(", "BY_SEQ_STORE", ",", "{", "autoIncrement", ":",...
called when creating a fresh new database
[ "called", "when", "creating", "a", "fresh", "new", "database" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L9352-L9371
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
addDeletedOrLocalIndex
function addDeletedOrLocalIndex(txn, callback) { var docStore = txn.objectStore(DOC_STORE); docStore.createIndex('deletedOrLocal', 'deletedOrLocal', {unique : false}); docStore.openCursor().onsuccess = function (event) { var cursor = event.target.result; if (cursor) { var metadata = cur...
javascript
function addDeletedOrLocalIndex(txn, callback) { var docStore = txn.objectStore(DOC_STORE); docStore.createIndex('deletedOrLocal', 'deletedOrLocal', {unique : false}); docStore.openCursor().onsuccess = function (event) { var cursor = event.target.result; if (cursor) { var metadata = cur...
[ "function", "addDeletedOrLocalIndex", "(", "txn", ",", "callback", ")", "{", "var", "docStore", "=", "txn", ".", "objectStore", "(", "DOC_STORE", ")", ";", "docStore", ".", "createIndex", "(", "'deletedOrLocal'", ",", "'deletedOrLocal'", ",", "{", "unique", ":...
migration to version 2 unfortunately "deletedOrLocal" is a misnomer now that we no longer store local docs in the main doc-store, but whaddyagonnado
[ "migration", "to", "version", "2", "unfortunately", "deletedOrLocal", "is", "a", "misnomer", "now", "that", "we", "no", "longer", "store", "local", "docs", "in", "the", "main", "doc", "-", "store", "but", "whaddyagonnado" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L9376-L9392
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
verifyAttachment
function verifyAttachment(digest, callback) { txn.get(stores.attachmentStore, digest, function (levelErr) { if (levelErr) { var err = pouchdbErrors.createError(pouchdbErrors.MISSING_STUB, 'unknown stub attachment with digest ' + dig...
javascript
function verifyAttachment(digest, callback) { txn.get(stores.attachmentStore, digest, function (levelErr) { if (levelErr) { var err = pouchdbErrors.createError(pouchdbErrors.MISSING_STUB, 'unknown stub attachment with digest ' + dig...
[ "function", "verifyAttachment", "(", "digest", ",", "callback", ")", "{", "txn", ".", "get", "(", "stores", ".", "attachmentStore", ",", "digest", ",", "function", "(", "levelErr", ")", "{", "if", "(", "levelErr", ")", "{", "var", "err", "=", "pouchdbErr...
verify any stub attachments as a precondition test
[ "verify", "any", "stub", "attachments", "as", "a", "precondition", "test" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L10649-L10660
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
fromList
function fromList(n, state) { // nothing buffered if (state.length === 0) return null; var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret =...
javascript
function fromList(n, state) { // nothing buffered if (state.length === 0) return null; var ret; if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) { // read it all, truncate the list if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret =...
[ "function", "fromList", "(", "n", ",", "state", ")", "{", "// nothing buffered", "if", "(", "state", ".", "length", "===", "0", ")", "return", "null", ";", "var", "ret", ";", "if", "(", "state", ".", "objectMode", ")", "ret", "=", "state", ".", "buff...
Pluck off n bytes from an array of buffers. Length is the combined lengths of all the buffers in the list. This function is designed to be inlinable, so please take care when making changes to the function body.
[ "Pluck", "off", "n", "bytes", "from", "an", "array", "of", "buffers", ".", "Length", "is", "the", "combined", "lengths", "of", "all", "the", "buffers", "in", "the", "list", ".", "This", "function", "is", "designed", "to", "be", "inlinable", "so", "please...
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L12580-L12595
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
fromListPartial
function fromListPartial(n, list, hasStrings) { var ret; if (n < list.head.data.length) { // slice is the same for buffers and strings ret = list.head.data.slice(0, n); list.head.data = list.head.data.slice(n); } else if (n === list.head.data.length) { // first chunk is a perfect match ret = l...
javascript
function fromListPartial(n, list, hasStrings) { var ret; if (n < list.head.data.length) { // slice is the same for buffers and strings ret = list.head.data.slice(0, n); list.head.data = list.head.data.slice(n); } else if (n === list.head.data.length) { // first chunk is a perfect match ret = l...
[ "function", "fromListPartial", "(", "n", ",", "list", ",", "hasStrings", ")", "{", "var", "ret", ";", "if", "(", "n", "<", "list", ".", "head", ".", "data", ".", "length", ")", "{", "// slice is the same for buffers and strings", "ret", "=", "list", ".", ...
Extracts only enough buffered data to satisfy the amount requested. This function is designed to be inlinable, so please take care when making changes to the function body.
[ "Extracts", "only", "enough", "buffered", "data", "to", "satisfy", "the", "amount", "requested", ".", "This", "function", "is", "designed", "to", "be", "inlinable", "so", "please", "take", "care", "when", "making", "changes", "to", "the", "function", "body", ...
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L12600-L12614
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
writeOrBuffer
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { chunk = decodeChunk(state, chunk, encoding); if (Buffer.isBuffer(chunk)) encoding = 'buffer'; } var len = state.objectMode ? 1 : chunk.length; state.length += len; var ret = state.length < state.highWaterMark; // we ...
javascript
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { if (!isBuf) { chunk = decodeChunk(state, chunk, encoding); if (Buffer.isBuffer(chunk)) encoding = 'buffer'; } var len = state.objectMode ? 1 : chunk.length; state.length += len; var ret = state.length < state.highWaterMark; // we ...
[ "function", "writeOrBuffer", "(", "stream", ",", "state", ",", "isBuf", ",", "chunk", ",", "encoding", ",", "cb", ")", "{", "if", "(", "!", "isBuf", ")", "{", "chunk", "=", "decodeChunk", "(", "state", ",", "chunk", ",", "encoding", ")", ";", "if", ...
if we're already writing something, then just put this in the queue, and wait our turn. Otherwise, call _write If we return false, then we need a drain event, so set that flag.
[ "if", "we", "re", "already", "writing", "something", "then", "just", "put", "this", "in", "the", "queue", "and", "wait", "our", "turn", ".", "Otherwise", "call", "_write", "If", "we", "return", "false", "then", "we", "need", "a", "drain", "event", "so", ...
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L13199-L13226
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
normalizeEncoding
function normalizeEncoding(enc) { var nenc = _normalizeEncoding(enc); if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); return nenc || enc; }
javascript
function normalizeEncoding(enc) { var nenc = _normalizeEncoding(enc); if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc); return nenc || enc; }
[ "function", "normalizeEncoding", "(", "enc", ")", "{", "var", "nenc", "=", "_normalizeEncoding", "(", "enc", ")", ";", "if", "(", "typeof", "nenc", "!==", "'string'", "&&", "(", "Buffer", ".", "isEncoding", "===", "isEncoding", "||", "!", "isEncoding", "("...
Do not cache `Buffer.isEncoding` when checking encoding names as some modules monkey-patch it to support additional encodings
[ "Do", "not", "cache", "Buffer", ".", "isEncoding", "when", "checking", "encoding", "names", "as", "some", "modules", "monkey", "-", "patch", "it", "to", "support", "additional", "encodings" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L13567-L13571
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
utf8FillLast
function utf8FillLast(buf) { var p = this.lastTotal - this.lastNeed; var r = utf8CheckExtraBytes(this, buf, p); if (r !== undefined) return r; if (this.lastNeed <= buf.length) { buf.copy(this.lastChar, p, 0, this.lastNeed); return this.lastChar.toString(this.encoding, 0, this.lastTotal); } buf.copy(...
javascript
function utf8FillLast(buf) { var p = this.lastTotal - this.lastNeed; var r = utf8CheckExtraBytes(this, buf, p); if (r !== undefined) return r; if (this.lastNeed <= buf.length) { buf.copy(this.lastChar, p, 0, this.lastNeed); return this.lastChar.toString(this.encoding, 0, this.lastTotal); } buf.copy(...
[ "function", "utf8FillLast", "(", "buf", ")", "{", "var", "p", "=", "this", ".", "lastTotal", "-", "this", ".", "lastNeed", ";", "var", "r", "=", "utf8CheckExtraBytes", "(", "this", ",", "buf", ",", "p", ")", ";", "if", "(", "r", "!==", "undefined", ...
Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
[ "Attempts", "to", "complete", "a", "multi", "-", "byte", "UTF", "-", "8", "character", "using", "bytes", "from", "a", "Buffer", "." ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L13699-L13709
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
utf8Text
function utf8Text(buf, i) { var total = utf8CheckIncomplete(this, buf, i); if (!this.lastNeed) return buf.toString('utf8', i); this.lastTotal = total; var end = buf.length - (total - this.lastNeed); buf.copy(this.lastChar, 0, end); return buf.toString('utf8', i, end); }
javascript
function utf8Text(buf, i) { var total = utf8CheckIncomplete(this, buf, i); if (!this.lastNeed) return buf.toString('utf8', i); this.lastTotal = total; var end = buf.length - (total - this.lastNeed); buf.copy(this.lastChar, 0, end); return buf.toString('utf8', i, end); }
[ "function", "utf8Text", "(", "buf", ",", "i", ")", "{", "var", "total", "=", "utf8CheckIncomplete", "(", "this", ",", "buf", ",", "i", ")", ";", "if", "(", "!", "this", ".", "lastNeed", ")", "return", "buf", ".", "toString", "(", "'utf8'", ",", "i"...
Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a partial character, the character's bytes are buffered until the required number of bytes are available.
[ "Returns", "all", "complete", "UTF", "-", "8", "characters", "in", "a", "Buffer", ".", "If", "the", "Buffer", "ended", "on", "a", "partial", "character", "the", "character", "s", "bytes", "are", "buffered", "until", "the", "required", "number", "of", "byte...
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L13714-L13721
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
utf16End
function utf16End(buf) { var r = buf && buf.length ? this.write(buf) : ''; if (this.lastNeed) { var end = this.lastTotal - this.lastNeed; return r + this.lastChar.toString('utf16le', 0, end); } return r; }
javascript
function utf16End(buf) { var r = buf && buf.length ? this.write(buf) : ''; if (this.lastNeed) { var end = this.lastTotal - this.lastNeed; return r + this.lastChar.toString('utf16le', 0, end); } return r; }
[ "function", "utf16End", "(", "buf", ")", "{", "var", "r", "=", "buf", "&&", "buf", ".", "length", "?", "this", ".", "write", "(", "buf", ")", ":", "''", ";", "if", "(", "this", ".", "lastNeed", ")", "{", "var", "end", "=", "this", ".", "lastTot...
For UTF-16LE we do not explicitly append special replacement characters if we end on a partial character, we simply let v8 handle that.
[ "For", "UTF", "-", "16LE", "we", "do", "not", "explicitly", "append", "special", "replacement", "characters", "if", "we", "end", "on", "a", "partial", "character", "we", "simply", "let", "v8", "handle", "that", "." ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L13758-L13765
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
through2
function through2 (construct) { return function (options, transform, flush) { if (typeof options == 'function') { flush = transform transform = options options = {} } if (typeof transform != 'function') transform = noop if (typeof flush != 'function') flush = null...
javascript
function through2 (construct) { return function (options, transform, flush) { if (typeof options == 'function') { flush = transform transform = options options = {} } if (typeof transform != 'function') transform = noop if (typeof flush != 'function') flush = null...
[ "function", "through2", "(", "construct", ")", "{", "return", "function", "(", "options", ",", "transform", ",", "flush", ")", "{", "if", "(", "typeof", "options", "==", "'function'", ")", "{", "flush", "=", "transform", "transform", "=", "options", "optio...
create a new export function, used by both the main export and the .ctor export, contains common logic for dealing with arguments
[ "create", "a", "new", "export", "function", "used", "by", "both", "the", "main", "export", "and", "the", ".", "ctor", "export", "contains", "common", "logic", "for", "dealing", "with", "arguments" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L13828-L13844
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
parseDoc
function parseDoc(doc, newEdits) { var nRevNum; var newRevId; var revInfo; var opts = {status: 'available'}; if (doc._deleted) { opts.deleted = true; } if (newEdits) { if (!doc._id) { doc._id = pouchdbUtils.uuid(); } newRevId = pouchdbUtils.uuid(32, 16).toLowerCase(); if (doc._...
javascript
function parseDoc(doc, newEdits) { var nRevNum; var newRevId; var revInfo; var opts = {status: 'available'}; if (doc._deleted) { opts.deleted = true; } if (newEdits) { if (!doc._id) { doc._id = pouchdbUtils.uuid(); } newRevId = pouchdbUtils.uuid(32, 16).toLowerCase(); if (doc._...
[ "function", "parseDoc", "(", "doc", ",", "newEdits", ")", "{", "var", "nRevNum", ";", "var", "newRevId", ";", "var", "revInfo", ";", "var", "opts", "=", "{", "status", ":", "'available'", "}", ";", "if", "(", "doc", ".", "_deleted", ")", "{", "opts",...
Preprocess documents, parse their revisions, assign an id and a revision for new writes that are missing them, etc
[ "Preprocess", "documents", "parse", "their", "revisions", "assign", "an", "id", "and", "a", "revision", "for", "new", "writes", "that", "are", "missing", "them", "etc" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L14006-L14079
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
readAsBinaryString
function readAsBinaryString(blob, callback) { if (typeof FileReader === 'undefined') { // fix for Firefox in a web worker // https://bugzilla.mozilla.org/show_bug.cgi?id=901097 return callback(arrayBufferToBinaryString( new FileReaderSync().readAsArrayBuffer(blob))); } var reader = new FileRead...
javascript
function readAsBinaryString(blob, callback) { if (typeof FileReader === 'undefined') { // fix for Firefox in a web worker // https://bugzilla.mozilla.org/show_bug.cgi?id=901097 return callback(arrayBufferToBinaryString( new FileReaderSync().readAsArrayBuffer(blob))); } var reader = new FileRead...
[ "function", "readAsBinaryString", "(", "blob", ",", "callback", ")", "{", "if", "(", "typeof", "FileReader", "===", "'undefined'", ")", "{", "// fix for Firefox in a web worker", "// https://bugzilla.mozilla.org/show_bug.cgi?id=901097", "return", "callback", "(", "arrayBuff...
shim for browsers that don't support it
[ "shim", "for", "browsers", "that", "don", "t", "support", "it" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L14827-L14849
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
yankError
function yankError(callback) { return function (err, results) { if (err || (results[0] && results[0].error)) { callback(err || results[0]); } else { callback(null, results.length ? results[0] : results); } }; }
javascript
function yankError(callback) { return function (err, results) { if (err || (results[0] && results[0].error)) { callback(err || results[0]); } else { callback(null, results.length ? results[0] : results); } }; }
[ "function", "yankError", "(", "callback", ")", "{", "return", "function", "(", "err", ",", "results", ")", "{", "if", "(", "err", "||", "(", "results", "[", "0", "]", "&&", "results", "[", "0", "]", ".", "error", ")", ")", "{", "callback", "(", "...
Wrapper for functions that call the bulkdocs api with a single doc, if the first result is an error, return an error
[ "Wrapper", "for", "functions", "that", "call", "the", "bulkdocs", "api", "with", "a", "single", "doc", "if", "the", "first", "result", "is", "an", "error", "return", "an", "error" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L16030-L16038
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
cleanDocs
function cleanDocs(docs) { for (var i = 0; i < docs.length; i++) { var doc = docs[i]; if (doc._deleted) { delete doc._attachments; // ignore atts for deleted docs } else if (doc._attachments) { // filter out extraneous keys from _attachments var atts = Object.keys(doc._attachments); ...
javascript
function cleanDocs(docs) { for (var i = 0; i < docs.length; i++) { var doc = docs[i]; if (doc._deleted) { delete doc._attachments; // ignore atts for deleted docs } else if (doc._attachments) { // filter out extraneous keys from _attachments var atts = Object.keys(doc._attachments); ...
[ "function", "cleanDocs", "(", "docs", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "docs", ".", "length", ";", "i", "++", ")", "{", "var", "doc", "=", "docs", "[", "i", "]", ";", "if", "(", "doc", ".", "_deleted", ")", "{", "d...
clean docs given to us by the user
[ "clean", "docs", "given", "to", "us", "by", "the", "user" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L16041-L16056
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
compareByIdThenRev
function compareByIdThenRev(a, b) { var idCompare = compare(a._id, b._id); if (idCompare !== 0) { return idCompare; } var aStart = a._revisions ? a._revisions.start : 0; var bStart = b._revisions ? b._revisions.start : 0; return compare(aStart, bStart); }
javascript
function compareByIdThenRev(a, b) { var idCompare = compare(a._id, b._id); if (idCompare !== 0) { return idCompare; } var aStart = a._revisions ? a._revisions.start : 0; var bStart = b._revisions ? b._revisions.start : 0; return compare(aStart, bStart); }
[ "function", "compareByIdThenRev", "(", "a", ",", "b", ")", "{", "var", "idCompare", "=", "compare", "(", "a", ".", "_id", ",", "b", ".", "_id", ")", ";", "if", "(", "idCompare", "!==", "0", ")", "{", "return", "idCompare", ";", "}", "var", "aStart"...
compare two docs, first by _id then by _rev
[ "compare", "two", "docs", "first", "by", "_id", "then", "by", "_rev" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L16059-L16067
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
computeHeight
function computeHeight(revs) { var height = {}; var edges = []; pouchdbMerge.traverseRevTree(revs, function (isLeaf, pos, id, prnt) { var rev = pos + "-" + id; if (isLeaf) { height[rev] = 0; } if (prnt !== undefined) { edges.push({from: prnt, to: rev}); } return rev; }); e...
javascript
function computeHeight(revs) { var height = {}; var edges = []; pouchdbMerge.traverseRevTree(revs, function (isLeaf, pos, id, prnt) { var rev = pos + "-" + id; if (isLeaf) { height[rev] = 0; } if (prnt !== undefined) { edges.push({from: prnt, to: rev}); } return rev; }); e...
[ "function", "computeHeight", "(", "revs", ")", "{", "var", "height", "=", "{", "}", ";", "var", "edges", "=", "[", "]", ";", "pouchdbMerge", ".", "traverseRevTree", "(", "revs", ",", "function", "(", "isLeaf", ",", "pos", ",", "id", ",", "prnt", ")",...
for every node in a revision tree computes its distance from the closest leaf
[ "for", "every", "node", "in", "a", "revision", "tree", "computes", "its", "distance", "from", "the", "closest", "leaf" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L16071-L16094
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
doNextCompaction
function doNextCompaction(self) { var task = self._compactionQueue[0]; var opts = task.opts; var callback = task.callback; self.get('_local/compaction').catch(function () { return false; }).then(function (doc) { if (doc && doc.last_seq) { opts.last_seq = doc.last_seq; } self._compact(opt...
javascript
function doNextCompaction(self) { var task = self._compactionQueue[0]; var opts = task.opts; var callback = task.callback; self.get('_local/compaction').catch(function () { return false; }).then(function (doc) { if (doc && doc.last_seq) { opts.last_seq = doc.last_seq; } self._compact(opt...
[ "function", "doNextCompaction", "(", "self", ")", "{", "var", "task", "=", "self", ".", "_compactionQueue", "[", "0", "]", ";", "var", "opts", "=", "task", ".", "opts", ";", "var", "callback", "=", "task", ".", "callback", ";", "self", ".", "get", "(...
all compaction is done in a queue, to avoid attaching too many listeners at once
[ "all", "compaction", "is", "done", "in", "a", "queue", "to", "avoid", "attaching", "too", "many", "listeners", "at", "once" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L16132-L16157
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
createFieldSorter
function createFieldSorter(sort) { function getFieldValuesAsArray(doc) { return sort.map(function (sorting) { var fieldName = getKey(sorting); var parsedField = parseField(fieldName); var docFieldValue = getFieldFromDoc(doc, parsedField); return docFieldValue; }); } return functi...
javascript
function createFieldSorter(sort) { function getFieldValuesAsArray(doc) { return sort.map(function (sorting) { var fieldName = getKey(sorting); var parsedField = parseField(fieldName); var docFieldValue = getFieldFromDoc(doc, parsedField); return docFieldValue; }); } return functi...
[ "function", "createFieldSorter", "(", "sort", ")", "{", "function", "getFieldValuesAsArray", "(", "doc", ")", "{", "return", "sort", ".", "map", "(", "function", "(", "sorting", ")", "{", "var", "fieldName", "=", "getKey", "(", "sorting", ")", ";", "var", ...
create a comparator based on the sort object
[ "create", "a", "comparator", "based", "on", "the", "sort", "object" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L19347-L19368
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
checkFieldInIndex
function checkFieldInIndex(index, field) { var indexFields = index.def.fields.map(getKey); for (var i = 0, len = indexFields.length; i < len; i++) { var indexField = indexFields[i]; if (field === indexField) { return true; } } return false; }
javascript
function checkFieldInIndex(index, field) { var indexFields = index.def.fields.map(getKey); for (var i = 0, len = indexFields.length; i < len; i++) { var indexField = indexFields[i]; if (field === indexField) { return true; } } return false; }
[ "function", "checkFieldInIndex", "(", "index", ",", "field", ")", "{", "var", "indexFields", "=", "index", ".", "def", ".", "fields", ".", "map", "(", "getKey", ")", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "indexFields", ".", "length"...
couchdb second-lowest collation value
[ "couchdb", "second", "-", "lowest", "collation", "value" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L19780-L19789
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
sortFieldsByIndex
function sortFieldsByIndex(userFields, index) { var indexFields = index.def.fields.map(getKey); return userFields.slice().sort(function (a, b) { var aIdx = indexFields.indexOf(a); var bIdx = indexFields.indexOf(b); if (aIdx === -1) { aIdx = Number.MAX_VALUE; } if (bIdx === -1) { bId...
javascript
function sortFieldsByIndex(userFields, index) { var indexFields = index.def.fields.map(getKey); return userFields.slice().sort(function (a, b) { var aIdx = indexFields.indexOf(a); var bIdx = indexFields.indexOf(b); if (aIdx === -1) { aIdx = Number.MAX_VALUE; } if (bIdx === -1) { bId...
[ "function", "sortFieldsByIndex", "(", "userFields", ",", "index", ")", "{", "var", "indexFields", "=", "index", ".", "def", ".", "fields", ".", "map", "(", "getKey", ")", ";", "return", "userFields", ".", "slice", "(", ")", ".", "sort", "(", "function", ...
sort the user fields by their position in the index, if they're in the index
[ "sort", "the", "user", "fields", "by", "their", "position", "in", "the", "index", "if", "they", "re", "in", "the", "index" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L19805-L19819
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
getBasicInMemoryFields
function getBasicInMemoryFields(index, selector, userFields) { userFields = sortFieldsByIndex(userFields, index); // check if any of the user selectors lose precision var needToFilterInMemory = false; for (var i = 0, len = userFields.length; i < len; i++) { var field = userFields[i]; if (needToFilterI...
javascript
function getBasicInMemoryFields(index, selector, userFields) { userFields = sortFieldsByIndex(userFields, index); // check if any of the user selectors lose precision var needToFilterInMemory = false; for (var i = 0, len = userFields.length; i < len; i++) { var field = userFields[i]; if (needToFilterI...
[ "function", "getBasicInMemoryFields", "(", "index", ",", "selector", ",", "userFields", ")", "{", "userFields", "=", "sortFieldsByIndex", "(", "userFields", ",", "index", ")", ";", "// check if any of the user selectors lose precision", "var", "needToFilterInMemory", "=",...
first pass to try to find fields that will need to be sorted in-memory
[ "first", "pass", "to", "try", "to", "find", "fields", "that", "will", "need", "to", "be", "sorted", "in", "-", "memory" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L19822-L19838
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
checkIndexFieldsMatch
function checkIndexFieldsMatch(indexFields, sortOrder, fields) { if (sortOrder) { // array has to be a strict subarray of index array. furthermore, // the sortOrder fields need to all be represented in the index var sortMatches = utils.oneArrayIsStrictSubArrayOfOther(sortOrder, indexFields); var selec...
javascript
function checkIndexFieldsMatch(indexFields, sortOrder, fields) { if (sortOrder) { // array has to be a strict subarray of index array. furthermore, // the sortOrder fields need to all be represented in the index var sortMatches = utils.oneArrayIsStrictSubArrayOfOther(sortOrder, indexFields); var selec...
[ "function", "checkIndexFieldsMatch", "(", "indexFields", ",", "sortOrder", ",", "fields", ")", "{", "if", "(", "sortOrder", ")", "{", "// array has to be a strict subarray of index array. furthermore,", "// the sortOrder fields need to all be represented in the index", "var", "so...
check that at least one field in the user's query is represented in the index. order matters in the case of sorts
[ "check", "that", "at", "least", "one", "field", "in", "the", "user", "s", "query", "is", "represented", "in", "the", "index", ".", "order", "matters", "in", "the", "case", "of", "sorts" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L19868-L19882
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
findBestMatchingIndex
function findBestMatchingIndex(selector, userFields, sortOrder, indexes) { var matchingIndexes = findMatchingIndexes(selector, userFields, sortOrder, indexes); if (matchingIndexes.length === 0) { //return `all_docs` as a default index; //I'm assuming that _all_docs is always first var defaultIndex = i...
javascript
function findBestMatchingIndex(selector, userFields, sortOrder, indexes) { var matchingIndexes = findMatchingIndexes(selector, userFields, sortOrder, indexes); if (matchingIndexes.length === 0) { //return `all_docs` as a default index; //I'm assuming that _all_docs is always first var defaultIndex = i...
[ "function", "findBestMatchingIndex", "(", "selector", ",", "userFields", ",", "sortOrder", ",", "indexes", ")", "{", "var", "matchingIndexes", "=", "findMatchingIndexes", "(", "selector", ",", "userFields", ",", "sortOrder", ",", "indexes", ")", ";", "if", "(", ...
find the best index, i.e. the one that matches the most fields in the user's query
[ "find", "the", "best", "index", "i", ".", "e", ".", "the", "one", "that", "matches", "the", "most", "fields", "in", "the", "user", "s", "query" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L19948-L19978
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
massageSort
function massageSort(sort) { if (!Array.isArray(sort)) { throw new Error('invalid sort json - should be an array'); } return sort.map(function (sorting) { if (typeof sorting === 'string') { var obj = {}; obj[sorting] = 'asc'; return obj; } else { return sorting; } }); }
javascript
function massageSort(sort) { if (!Array.isArray(sort)) { throw new Error('invalid sort json - should be an array'); } return sort.map(function (sorting) { if (typeof sorting === 'string') { var obj = {}; obj[sorting] = 'asc'; return obj; } else { return sorting; } }); }
[ "function", "massageSort", "(", "sort", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "sort", ")", ")", "{", "throw", "new", "Error", "(", "'invalid sort json - should be an array'", ")", ";", "}", "return", "sort", ".", "map", "(", "function", ...
normalize the "sort" value
[ "normalize", "the", "sort", "value" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L20289-L20302
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
filterInclusiveStart
function filterInclusiveStart(rows, targetValue, index) { var indexFields = index.def.fields; for (var i = 0, len = rows.length; i < len; i++) { var row = rows[i]; // shave off any docs at the beginning that are <= the // target value var docKey = getKeyFromDoc(row.doc, index); if (indexFields...
javascript
function filterInclusiveStart(rows, targetValue, index) { var indexFields = index.def.fields; for (var i = 0, len = rows.length; i < len; i++) { var row = rows[i]; // shave off any docs at the beginning that are <= the // target value var docKey = getKeyFromDoc(row.doc, index); if (indexFields...
[ "function", "filterInclusiveStart", "(", "rows", ",", "targetValue", ",", "index", ")", "{", "var", "indexFields", "=", "index", ".", "def", ".", "fields", ";", "for", "(", "var", "i", "=", "0", ",", "len", "=", "rows", ".", "length", ";", "i", "<", ...
have to do this manually because REASONS. I don't know why CouchDB didn't implement inclusive_start
[ "have", "to", "do", "this", "manually", "because", "REASONS", ".", "I", "don", "t", "know", "why", "CouchDB", "didn", "t", "implement", "inclusive_start" ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L20501-L20526
train
HospitalRun/hospitalrun-frontend
prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js
generateReplicationId
function generateReplicationId(src, target, opts) { var docIds = opts.doc_ids ? opts.doc_ids.sort(pouchdbCollate.collate) : ''; var filterFun = opts.filter ? opts.filter.toString() : ''; var queryParams = ''; var filterViewName = ''; var selector = ''; // possibility for checkpoints to be lost here as beh...
javascript
function generateReplicationId(src, target, opts) { var docIds = opts.doc_ids ? opts.doc_ids.sort(pouchdbCollate.collate) : ''; var filterFun = opts.filter ? opts.filter.toString() : ''; var queryParams = ''; var filterViewName = ''; var selector = ''; // possibility for checkpoints to be lost here as beh...
[ "function", "generateReplicationId", "(", "src", ",", "target", ",", "opts", ")", "{", "var", "docIds", "=", "opts", ".", "doc_ids", "?", "opts", ".", "doc_ids", ".", "sort", "(", "pouchdbCollate", ".", "collate", ")", ":", "''", ";", "var", "filterFun",...
Generate a unique id particular to this replication. Not guaranteed to align perfectly with CouchDB's rep ids.
[ "Generate", "a", "unique", "id", "particular", "to", "this", "replication", ".", "Not", "guaranteed", "to", "align", "perfectly", "with", "CouchDB", "s", "rep", "ids", "." ]
60b692a1b7aa6f2ef007c28717e76582014e07ad
https://github.com/HospitalRun/hospitalrun-frontend/blob/60b692a1b7aa6f2ef007c28717e76582014e07ad/prod/service-worker-28ddbc7ef7a575da0539a0f05f4bfdae.js#L21762-L21797
train