code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
function jscoverage_findPos(obj) { var result = 0; do { result += obj.offsetTop; obj = obj.offsetParent; } while (obj); return result; }
Initializes the _$jscoverage object in a window. This should be the first function called in the page. @param w this should always be the global window object
jscoverage_findPos
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_getViewportHeight() { //#JSCOVERAGE_IF /MSIE/.test(navigator.userAgent) if (self.innerHeight) { // all except Explorer return self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode return document.documentElement.clientHeight; } else if (document.body) { // other Explorers return document.body.clientHeight; } else { throw "Couldn't calculate viewport height"; } //#JSCOVERAGE_ENDIF }
Initializes the _$jscoverage object in a window. This should be the first function called in the page. @param w this should always be the global window object
jscoverage_getViewportHeight
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_beginLengthyOperation() { jscoverage_inLengthyOperation = true; /* blacklist buggy browsers */ //#JSCOVERAGE_IF if (! /Opera|WebKit/.test(navigator.userAgent)) { /* Change the cursor style of each element. Note that changing the class of the element (to one with a busy cursor) is buggy in IE. */ var tabs = document.getElementById('tabs').getElementsByTagName('div'); var i; for (i = 0; i < tabs.length; i++) { tabs.item(i).style.cursor = 'wait'; } } }
Indicates visually that a lengthy operation has begun. The progress bar is displayed, and the cursor is changed to busy (on browsers which support this).
jscoverage_beginLengthyOperation
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_endLengthyOperation() { setTimeout(function() { jscoverage_inLengthyOperation = false; var tabs = document.getElementById('tabs').getElementsByTagName('div'); var i; for (i = 0; i < tabs.length; i++) { tabs.item(i).style.cursor = ''; } }, 50); }
Removes the progress bar and busy cursor.
jscoverage_endLengthyOperation
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_setSize() { //#JSCOVERAGE_IF /MSIE/.test(navigator.userAgent) var viewportHeight = jscoverage_getViewportHeight(); /* border-top-width: 1px padding-top: 10px padding-bottom: 10px border-bottom-width: 1px margin-bottom: 10px ---- 32px */ var tabPages = document.getElementById('tabPages'); var tabPageHeight = (viewportHeight - jscoverage_findPos(tabPages) - 32) + 'px'; var nodeList = tabPages.childNodes; var length = nodeList.length; for (var i = 0; i < length; i++) { var node = nodeList.item(i); if (node.nodeType !== 1) { continue; } node.style.height = tabPageHeight; } var iframeDiv = document.getElementById('iframeDiv'); // may not exist if we have removed the first tab if (iframeDiv) { iframeDiv.style.height = (viewportHeight - jscoverage_findPos(iframeDiv) - 21) + 'px'; } var summaryDiv = document.getElementById('summaryDiv'); summaryDiv.style.height = (viewportHeight - jscoverage_findPos(summaryDiv) - 21) + 'px'; var sourceDiv = document.getElementById('sourceDiv'); sourceDiv.style.height = (viewportHeight - jscoverage_findPos(sourceDiv) - 21) + 'px'; var storeDiv = document.getElementById('storeDiv'); if (storeDiv) { storeDiv.style.height = (viewportHeight - jscoverage_findPos(storeDiv) - 21) + 'px'; } //#JSCOVERAGE_ENDIF }
Removes the progress bar and busy cursor.
jscoverage_setSize
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_getBooleanValue(s) { s = s.toLowerCase(); if (s === 'false' || s === 'f' || s === 'no' || s === 'n' || s === 'off' || s === '0') { return false; } return true; }
Returns the boolean value of a string. Values 'false', 'f', 'no', 'n', 'off', and '0' (upper or lower case) are false. @param s the string @return a boolean value
jscoverage_getBooleanValue
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_removeTab(id) { var tab = document.getElementById(id + 'Tab'); if(tab){ tab.parentNode.removeChild(tab); } var tabPage = document.getElementById(id + 'TabPage'); if(tabPage){ tabPage.parentNode.removeChild(tabPage); } }
Returns the boolean value of a string. Values 'false', 'f', 'no', 'n', 'off', and '0' (upper or lower case) are false. @param s the string @return a boolean value
jscoverage_removeTab
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_isValidURL(url) { // RFC 3986 var matches = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/.exec(url); if (matches === null) { return false; } var scheme = matches[1]; if (typeof scheme === 'string') { scheme = scheme.toLowerCase(); return scheme === '' || scheme === 'file:' || scheme === 'http:' || scheme === 'https:'; } return true; }
Returns the boolean value of a string. Values 'false', 'f', 'no', 'n', 'off', and '0' (upper or lower case) are false. @param s the string @return a boolean value
jscoverage_isValidURL
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_initTabContents(queryString) { var showMissingColumn = false; var url = null; var windowURL = null; var parameters, parameter, i, index, name, value; if (queryString.length > 0) { // chop off the question mark queryString = queryString.substring(1); parameters = queryString.split(/&|;/); for (i = 0; i < parameters.length; i++) { parameter = parameters[i]; index = parameter.indexOf('='); if (index === -1) { // still works with old syntax url = decodeURIComponent(parameter); } else { name = parameter.substr(0, index); value = decodeURIComponent(parameter.substr(index + 1)); if (name === 'missing' || name === 'm') { showMissingColumn = jscoverage_getBooleanValue(value); } else if (name === 'url' || name === 'u' || name === 'frame' || name === 'f') { url = value; } else if (name === 'window' || name === 'w') { windowURL = value; } } } } var checkbox = document.getElementById('checkbox'); checkbox.checked = showMissingColumn; if (showMissingColumn) { jscoverage_appendMissingColumn(); } var isValidURL = function (url) { var result = jscoverage_isValidURL(url); if (! result) { alert('Invalid URL: ' + url); } return result; }; if (url !== null && isValidURL(url)) { // this will automatically propagate to the input field frames[0].location = url; } else if (windowURL !== null && isValidURL(windowURL)) { window.open(windowURL); } // if the browser tab is absent, we have to initialize the summary tab if (! document.getElementById('browserTab')) { jscoverage_recalculateSummaryTab(); } }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_initTabContents
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
isValidURL = function (url) { var result = jscoverage_isValidURL(url); if (! result) { alert('Invalid URL: ' + url); } return result; }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
isValidURL
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_body_load() { function reportError(e) { jscoverage_endLengthyOperation(); var summaryThrobber = document.getElementById('summaryThrobber'); summaryThrobber.style.visibility = 'hidden'; var div = document.getElementById('summaryErrorDiv'); div.innerHTML = 'Error: ' + e; } if (jscoverage_isReport) { jscoverage_beginLengthyOperation(); var summaryThrobber = document.getElementById('summaryThrobber'); summaryThrobber.style.visibility = 'visible'; var request = jscoverage_createRequest(); try { request.open('GET', 'jscoverage.json', true); request.onreadystatechange = function (event) { if (request.readyState === 4) { try { if (request.status !== 0 && request.status !== 200) { throw request.status; } var response = request.responseText; if (response === '') { throw 404; } _$jscoverage = jscoverage_parseCoverageJSON(response); jscoverage_recalculateSummaryTab(); summaryThrobber.style.visibility = 'hidden'; } catch (e) { reportError(e); } } }; request.send(null); } catch (e) { reportError(e); } jscoverage_removeTab('browser'); jscoverage_removeTab('store'); } else { if (jscoverage_isInvertedMode) { jscoverage_removeTab('browser'); } if (! jscoverage_isServer) { jscoverage_removeTab('store'); } } jscoverage_initTabControl(); jscoverage_initTabContents(location.search); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_body_load
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function reportError(e) { jscoverage_endLengthyOperation(); var summaryThrobber = document.getElementById('summaryThrobber'); summaryThrobber.style.visibility = 'hidden'; var div = document.getElementById('summaryErrorDiv'); div.innerHTML = 'Error: ' + e; }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
reportError
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_body_resize() { if (/MSIE/.test(navigator.userAgent)) { jscoverage_setSize(); } }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_body_resize
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_updateBrowser() { var input = document.getElementById("location"); frames[0].location = input.value; }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_updateBrowser
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_openWindow() { var input = document.getElementById("location"); var url = input.value; window.open(url,'jscoverage_window'); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_openWindow
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_input_keypress(e) { if (e.keyCode === 13) { if (e.shiftKey) { jscoverage_openWindow(); } else { jscoverage_updateBrowser(); } } }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_input_keypress
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_browser_load() { /* update the input box */ var input = document.getElementById("location"); /* sometimes IE seems to fire this after the tab has been removed */ if (input) { input.value = frames[0].location; } }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_browser_load
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_createHandler(file, line) { return function () { jscoverage_get(file, line); return false; }; }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_createHandler
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_createLink(file, line) { var link = document.createElement("a"); link.href = '#'+file; link.onclick = jscoverage_createHandler(file, line); var text; if (line) { text = line.toString(); } else { text = file; } link.appendChild(document.createTextNode(text)); return link; }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_createLink
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_recalculateSummaryTabBy(type) { sortReOrder = true; if (sortColumn !== type) sortOrder = 1; sortColumn = type; jscoverage_recalculateSummaryTab(null); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_recalculateSummaryTabBy
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_recalculateSummaryTab(cc) { var checkbox = document.getElementById('checkbox'); var showMissingColumn = checkbox.checked; if (! cc) { cc = window._$jscoverage; } if (! cc) { //#JSCOVERAGE_IF 0 throw "No coverage information found."; //#JSCOVERAGE_ENDIF } var totals = { files:0, statements:0, executed:0, branches:0, branches_covered:0 , functions:0, functions_covered:0 }; var file; var files = []; for (file in cc) { files.push(file); } if (files.length === 0) return; if (sortReOrder || files.length != sortedFiles.length) { sortedFiles = getFilesSortedByCoverage(files); sortOrder++; sortReOrder = false; } files = sortedFiles; var tbody = document.getElementById("summaryTbody"); while (tbody.hasChildNodes()) { tbody.removeChild(tbody.firstChild); } var rowCounter = 0; for (var f = 0; f < files.length; f++) { file = files[f]; var lineNumber; var num_statements = 0; var num_executed = 0; var missing = []; var fileCC = cc[file].lineData; var length = fileCC.length; var currentConditionalEnd = 0; var conditionals = null; if (fileCC.conditionals) { conditionals = fileCC.conditionals; } for (lineNumber = 0; lineNumber < length; lineNumber++) { var n = fileCC[lineNumber]; if (lineNumber === currentConditionalEnd) { currentConditionalEnd = 0; } else if (currentConditionalEnd === 0 && conditionals && conditionals[lineNumber]) { currentConditionalEnd = conditionals[lineNumber]; } if (currentConditionalEnd !== 0) { continue; } if (n === undefined || n === null) { continue; } if (n === 0) { missing.push(lineNumber); } else { num_executed++; } num_statements++; } var percentage = ( num_statements === 0 ? 0 : parseInt(100 * num_executed / num_statements) ); var num_functions = 0; var num_executed_functions = 0; var fileFunctionCC = cc[file].functionData; if (fileFunctionCC) { num_functions += fileFunctionCC.length; for (var fnNumber = 0; fnNumber < fileFunctionCC.length; fnNumber++) { var fnHits = fileFunctionCC[fnNumber]; if (fnHits !== undefined && fnHits !== null && fnHits > 0) num_executed_functions++; } } var percentageFn = ( num_functions === 0 ? 0 : parseInt(100 * num_executed_functions / num_functions)); var num_branches = 0; var num_executed_branches = 0; var fileBranchCC = cc[file].branchData; if (fileBranchCC) { for (var lineNumber in fileBranchCC) { var conditions = fileBranchCC[lineNumber]; var covered = undefined; if (conditions !== undefined && conditions !== null && conditions.length) { covered = true; for (var conditionIndex = 0; conditionIndex < conditions.length; conditionIndex++) { var branchData = fileBranchCC[lineNumber][conditionIndex]; if (branchData === undefined || branchData === null) continue; num_branches += 2; num_executed_branches += branchData.pathsCovered; if (!branchData.covered) { covered = false; } } } } var percentageBranch = ( num_branches === 0 ? 0 : parseInt(100 * num_executed_branches / num_branches)); } var row = document.createElement("tr"); row.className = ( rowCounter++ % 2 == 0 ? "odd" : "even" ); var cell = document.createElement("td"); row.id = "row-"+file; cell.className = 'leftColumn'; var link = jscoverage_createLink(file); cell.appendChild(link); row.appendChild(cell); cell = document.createElement("td"); cell.className = 'numeric'; cell.appendChild(document.createTextNode(num_statements)); row.appendChild(cell); cell = document.createElement("td"); cell.className = 'numeric'; cell.appendChild(document.createTextNode(num_executed)); row.appendChild(cell); cell = document.createElement("td"); cell.className = 'numeric'; cell.appendChild(document.createTextNode(num_branches)); row.appendChild(cell); cell = document.createElement("td"); cell.className = 'numeric'; cell.appendChild(document.createTextNode(num_executed_branches)); row.appendChild(cell); cell = document.createElement("td"); cell.className = 'numeric'; cell.appendChild(document.createTextNode(num_functions)); row.appendChild(cell); cell = document.createElement("td"); cell.className = 'numeric'; cell.appendChild(document.createTextNode(num_executed_functions)); row.appendChild(cell); // new coverage td containing a bar graph cell = document.createElement("td"); cell.className = 'coverage'; var pctGraph = document.createElement("div"), covered = document.createElement("div"), pct = document.createElement("span"); pctGraph.className = "pctGraph"; if( num_statements === 0 ) { covered.className = "skipped"; pct.appendChild(document.createTextNode("N/A")); } else { covered.className = "covered"; covered.style.width = percentage + "px"; pct.appendChild(document.createTextNode(percentage + '%')); } pct.className = "pct"; pctGraph.appendChild(covered); cell.appendChild(pctGraph); cell.appendChild(pct); row.appendChild(cell); // new coverage td containing a branch bar graph cell = document.createElement("td"); cell.className = 'coverage'; pctGraph = document.createElement("div"), covered = document.createElement("div"), pct = document.createElement("span"); pctGraph.className = "pctGraph"; if(fileBranchCC === undefined || num_branches === 0 ) { covered.className = "skipped"; pct.appendChild(document.createTextNode("N/A")); } else { covered.className = "covered"; covered.style.width = percentageBranch + "px"; pct.appendChild(document.createTextNode(percentageBranch + '%')); } pct.className = "pct"; pctGraph.appendChild(covered); cell.appendChild(pctGraph); cell.appendChild(pct); row.appendChild(cell); // new coverage td containing a function bar graph cell = document.createElement("td"); cell.className = 'coverage'; pctGraph = document.createElement("div"), covered = document.createElement("div"), pct = document.createElement("span"); pctGraph.className = "pctGraph"; if(fileFunctionCC === undefined || num_functions === 0 ) { covered.className = "skipped"; pct.appendChild(document.createTextNode("N/A")); } else { covered.className = "covered"; covered.style.width = percentageFn + "px"; pct.appendChild(document.createTextNode(percentageFn + '%')); } pct.className = "pct"; pctGraph.appendChild(covered); cell.appendChild(pctGraph); cell.appendChild(pct); row.appendChild(cell); if (showMissingColumn) { cell = document.createElement("td"); for (var i = 0; i < missing.length; i++) { if (i !== 0) { cell.appendChild(document.createTextNode(", ")); } link = jscoverage_createLink(file, missing[i]); // group contiguous missing lines; e.g., 10, 11, 12 -> 10-12 var j, start = missing[i]; for (;;) { j = 1; while (i + j < missing.length && missing[i + j] == missing[i] + j) { j++; } var nextmissing = missing[i + j], cur = missing[i] + j; if (isNaN(nextmissing)) { break; } while (cur < nextmissing && ! fileCC[cur]) { cur++; } if (cur < nextmissing || cur >= length) { break; } i += j; } if (start != missing[i] || j > 1) { i += j - 1; link.innerHTML += "-" + missing[i]; } cell.appendChild(link); } row.appendChild(cell); } tbody.appendChild(row); totals['files'] ++; totals['statements'] += num_statements; totals['executed'] += num_executed; totals['branches'] += num_branches; totals['branches_covered'] += num_executed_branches; totals['functions'] += num_functions; totals['functions_covered'] += num_executed_functions; // write totals data into summaryTotals row var tr = document.getElementById("summaryTotals"); if (tr) { var tds = tr.getElementsByTagName("td"); tds[0].getElementsByTagName("span")[1].firstChild.nodeValue = totals['files']; tds[1].firstChild.nodeValue = totals['statements']; tds[2].firstChild.nodeValue = totals['executed']; tds[3].firstChild.nodeValue = totals['branches']; tds[4].firstChild.nodeValue = totals['branches_covered']; tds[5].firstChild.nodeValue = totals['functions']; tds[6].firstChild.nodeValue = totals['functions_covered']; var coverage = parseInt(100 * totals['executed'] / totals['statements']); if( isNaN( coverage ) ) { coverage = 0; } tds[7].getElementsByTagName("span")[0].firstChild.nodeValue = coverage + '%'; tds[7].getElementsByTagName("div")[1].style.width = coverage + 'px'; coverage = 0; if (fileBranchCC !== undefined) { coverage = parseInt(100 * totals['branches_covered'] / totals['branches']); if( isNaN( coverage ) ) { coverage = 0; } } tds[8].getElementsByTagName("span")[0].firstChild.nodeValue = coverage + '%'; tds[8].getElementsByTagName("div")[1].style.width = coverage + 'px'; coverage = 0; if (fileFunctionCC !== undefined) { coverage = parseInt(100 * totals['functions_covered'] / totals['functions']); if( isNaN( coverage ) ) { coverage = 0; } } tds[9].getElementsByTagName("span")[0].firstChild.nodeValue = coverage + '%'; tds[9].getElementsByTagName("div")[1].style.width = coverage + 'px'; } } jscoverage_endLengthyOperation(); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_recalculateSummaryTab
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function getFilesSortedByCoverage(filesIn) { var tbody = document.getElementById("summaryTbody"); if (tbody.children.length < 2) { sortOrder=1; return filesIn; } var files = []; for (var i=0;i<tbody.children.length;i++) { files[i] = {}; files[i].file = tbody.children[i].children[0].children[0].innerHTML; files[i].perc = parseInt(tbody.children[i].children[7].children[1].innerHTML, 10); files[i].brPerc = parseInt(tbody.children[i].children[8].children[1].innerHTML, 10); files[i].fnPerc = parseInt(tbody.children[i].children[9].children[1].innerHTML, 10); if (isNaN(files[i].perc)) files[i].perc = -1; if (isNaN(files[i].brPerc)) files[i].brPerc = -1; if (isNaN(files[i].fnPerc)) files[i].fnPerc = -1; } if (sortOrder%3===1) { if (sortColumn == 'Coverage') files.sort(function(file1,file2) {return file1.perc-file2.perc}); else if (sortColumn == 'Branch') files.sort(function(file1,file2) {return file1.brPerc-file2.brPerc}); else if (sortColumn == 'Function') files.sort(function(file1,file2) {return file1.fnPerc-file2.fnPerc}); else files.sort(function(file1,file2) {return file1.file>=file2.file}); } else if (sortOrder%3===2) { if (sortColumn == 'Coverage') files.sort(function(file1,file2) {return file2.perc-file1.perc}); else if (sortColumn == 'Branch') files.sort(function(file1,file2) {return file2.brPerc-file1.brPerc}); else if (sortColumn == 'Function') files.sort(function(file1,file2) {return file2.fnPerc-file1.fnPerc}); else files.sort(function(file1,file2) {return file2.file>=file1.file}); } else { return filesIn.sort(); } var result = []; for (var i=0;i<files.length;i++) { result[i] = files[i].file; } return result; }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
getFilesSortedByCoverage
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_appendMissingColumn() { var headerRow = document.getElementById('headerRow'); var missingHeader = document.createElement('th'); missingHeader.id = 'missingHeader'; missingHeader.innerHTML = '<abbr title="List of statements missed during execution">Missing</abbr>'; headerRow.appendChild(missingHeader); var summaryTotals = document.getElementById('summaryTotals'); var empty = document.createElement('td'); empty.id = 'missingCell'; summaryTotals.appendChild(empty); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_appendMissingColumn
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_removeMissingColumn() { var missingNode; missingNode = document.getElementById('missingHeader'); missingNode.parentNode.removeChild(missingNode); missingNode = document.getElementById('missingCell'); missingNode.parentNode.removeChild(missingNode); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_removeMissingColumn
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_checkbox_click() { if (jscoverage_inLengthyOperation) { return false; } jscoverage_beginLengthyOperation(); var checkbox = document.getElementById('checkbox'); var showMissingColumn = checkbox.checked; setTimeout(function() { if (showMissingColumn) { jscoverage_appendMissingColumn(); } else { jscoverage_removeMissingColumn(); } jscoverage_recalculateSummaryTab(); }, 50); return true; }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_checkbox_click
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function encodeHTML(str){ return String(str) .replace(/&/g, '&amp;') .replace(/"/g, '&quot;') .replace(/'/g, '&#39;') .replace(/`/g, '&#96;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;'); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
encodeHTML
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_makeTable() { var fileInfo = _$jscoverage[jscoverage_currentFile]; var coverage = fileInfo.lineData; var branchData = fileInfo.branchData; var lines = fileInfo.source; // this can happen if there is an error in the original JavaScript file if (! lines) { lines = []; } var rows = ['<table id="sourceTable">']; var i = 0; var tableHTML; var currentConditionalEnd = 0; function joinTableRows() { tableHTML = rows.join(''); /* This may be a long delay, so set a timeout of 100 ms to make sure the display is updated. */ setTimeout(function() {appendTable(jscoverage_currentFile);}, 100); } function appendTable(jscoverage_currentFile) { var sourceDiv = document.getElementById('sourceDiv'); sourceDiv.innerHTML = tableHTML; setTimeout(jscoverage_scrollToLine, 0); } while (i < lines.length) { var lineNumber = i + 1; if (lineNumber === currentConditionalEnd) { currentConditionalEnd = 0; } else if (currentConditionalEnd === 0 && coverage.conditionals && coverage.conditionals[lineNumber]) { currentConditionalEnd = coverage.conditionals[lineNumber]; } var row = '<tr>'; row += '<td class="numeric">' + lineNumber + '</td>'; var timesExecuted = coverage[lineNumber]; if (timesExecuted !== undefined && timesExecuted !== null) { if (currentConditionalEnd !== 0) { row += '<td class="y numeric">'; } else if (timesExecuted === 0) { row += '<td class="r numeric" id="line-' + lineNumber + '">'; } else { row += '<td class="g numeric">'; } row += timesExecuted; row += '</td>'; } else { row += '<td></td>'; } lineNumber = '' + lineNumber; if (branchData !== undefined && branchData !== null) { var branchClass = ''; var branchText = '&#160;'; if (branchData[lineNumber] !== undefined && branchData[lineNumber] !== null) { branchClass = 'g'; for (var conditionIndex = 0; conditionIndex < branchData[lineNumber].length; conditionIndex++) { if (branchData[lineNumber][conditionIndex] !== undefined && branchData[lineNumber][conditionIndex] !== null && !branchData[lineNumber][conditionIndex].covered) { branchClass = 'r'; break; } } } if (branchClass === 'r') { branchText = '<a href="#" onclick="alert(buildBranchMessage(_$jscoverage[\''+jscoverage_currentFile+'\'].branchData[\''+lineNumber+'\']));">info</a>'; } row += '<td class="numeric '+branchClass+'"><pre>' + branchText + '</pre></td>'; } row += '<td><pre>' + encodeHTML(lines[i]) + '</pre></td>'; row += '</tr>'; row += '\n'; rows[lineNumber] = row; i++; } rows[i + 1] = '</table>'; setTimeout(joinTableRows, 0); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_makeTable
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function joinTableRows() { tableHTML = rows.join(''); /* This may be a long delay, so set a timeout of 100 ms to make sure the display is updated. */ setTimeout(function() {appendTable(jscoverage_currentFile);}, 100); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
joinTableRows
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function appendTable(jscoverage_currentFile) { var sourceDiv = document.getElementById('sourceDiv'); sourceDiv.innerHTML = tableHTML; setTimeout(jscoverage_scrollToLine, 0); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
appendTable
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_scrollToLine() { jscoverage_selectTab('sourceTab'); if (! window.jscoverage_currentLine) { jscoverage_endLengthyOperation(); return; } var div = document.getElementById('sourceDiv'); if (jscoverage_currentLine === 1) { div.scrollTop = 0; } else { var cell = document.getElementById('line-' + jscoverage_currentLine); // this might not be there if there is an error in the original JavaScript if (cell) { var divOffset = jscoverage_findPos(div); var cellOffset = jscoverage_findPos(cell); div.scrollTop = cellOffset - divOffset; } } jscoverage_currentLine = 0; jscoverage_endLengthyOperation(); }
Initializes the contents of the tabs. This sets the initial values of the input field and iframe in the "Browser" tab and the checkbox in the "Summary" tab. @param queryString this should always be location.search
jscoverage_scrollToLine
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_get(file, line) { if (jscoverage_inLengthyOperation) { return; } jscoverage_beginLengthyOperation(); setTimeout(function() { var sourceDiv = document.getElementById('sourceDiv'); sourceDiv.innerHTML = ''; jscoverage_selectTab('sourceTab'); if (file === jscoverage_currentFile) { jscoverage_currentLine = line; jscoverage_recalculateSourceTab(); } else { if (jscoverage_currentFile === null) { var tab = document.getElementById('sourceTab'); tab.className = ''; tab.onclick = jscoverage_tab_click; } jscoverage_currentFile = file; jscoverage_currentLine = line || 1; // when changing the source, always scroll to top var fileDiv = document.getElementById('fileDiv'); fileDiv.innerHTML = jscoverage_currentFile; jscoverage_recalculateSourceTab(); return; } }, 50); }
Loads the given file (and optional line) in the source tab.
jscoverage_get
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_recalculateSourceTab() { if (! jscoverage_currentFile) { jscoverage_endLengthyOperation(); return; } setTimeout(jscoverage_makeTable, 0); }
Calculates coverage statistics for the current source file.
jscoverage_recalculateSourceTab
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_initTabControl() { var tabs = document.getElementById('tabs'); var i; var child; var tabNum = 0; for (i = 0; i < tabs.childNodes.length; i++) { child = tabs.childNodes.item(i); if (child.nodeType === 1) { if (child.className !== 'disabled') { child.onclick = jscoverage_tab_click; } tabNum++; } } jscoverage_selectTab(0); }
Initializes the tab control. This function must be called when the document is loaded.
jscoverage_initTabControl
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_selectTab(tab) { if (typeof tab !== 'number') { tab = jscoverage_tabIndexOf(tab); } var tabs = document.getElementById('tabs'); var tabPages = document.getElementById('tabPages'); var nodeList; var tabNum; var i; var node; nodeList = tabs.childNodes; tabNum = 0; for (i = 0; i < nodeList.length; i++) { node = nodeList.item(i); if (node.nodeType !== 1) { continue; } if (node.className !== 'disabled') { if (tabNum === tab) { node.className = 'selected'; } else { node.className = ''; } } tabNum++; } nodeList = tabPages.childNodes; tabNum = 0; for (i = 0; i < nodeList.length; i++) { node = nodeList.item(i); if (node.nodeType !== 1) { continue; } if (tabNum === tab) { node.className = 'selected TabPage'; } else { node.className = 'TabPage'; } tabNum++; } }
Selects a tab. @param tab the integer index of the tab (0, 1, 2, or 3) OR the ID of the tab element OR the tab element itself
jscoverage_selectTab
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_tabIndexOf(tab) { if (typeof tab === 'string') { tab = document.getElementById(tab); } var tabs = document.getElementById('tabs'); var i; var child; var tabNum = 0; for (i = 0; i < tabs.childNodes.length; i++) { child = tabs.childNodes.item(i); if (child.nodeType === 1) { if (child === tab) { return tabNum; } tabNum++; } } //#JSCOVERAGE_IF 0 throw "Tab not found"; //#JSCOVERAGE_ENDIF }
Returns an integer (0, 1, 2, or 3) representing the index of a given tab. @param tab the ID of the tab element OR the tab element itself
jscoverage_tabIndexOf
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_tab_click(e) { if (jscoverage_inLengthyOperation) { return; } var target; //#JSCOVERAGE_IF if (e) { target = e.target; } else if (window.event) { // IE target = window.event.srcElement; } if (target.className === 'selected') { return; } jscoverage_beginLengthyOperation(); setTimeout(function() { if (target.id === 'summaryTab') { var tbody = document.getElementById("summaryTbody"); while (tbody.hasChildNodes()) { tbody.removeChild(tbody.firstChild); } } else if (target.id === 'sourceTab') { var sourceDiv = document.getElementById('sourceDiv'); sourceDiv.innerHTML = ''; } jscoverage_selectTab(target); if (target.id === 'summaryTab') { jscoverage_recalculateSummaryTab(); } else if (target.id === 'sourceTab') { jscoverage_recalculateSourceTab(); } else { jscoverage_endLengthyOperation(); } }, 50); }
Returns an integer (0, 1, 2, or 3) representing the index of a given tab. @param tab the ID of the tab element OR the tab element itself
jscoverage_tab_click
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_storeButton_click() { if (jscoverage_inLengthyOperation) { return; } jscoverage_beginLengthyOperation(); var img = document.getElementById('storeImg'); img.style.visibility = 'visible'; var request = jscoverage_createRequest(); request.open('POST', '/jscoverage-store', true); request.onreadystatechange = function (event) { if (request.readyState === 4) { var message; try { if (request.status !== 200 && request.status !== 201 && request.status !== 204) { throw request.status; } message = request.responseText; } catch (e) { if (e.toString().search(/^\d{3}$/) === 0) { message = e + ': ' + request.responseText; } else { message = 'Could not connect to server: ' + e; } } jscoverage_endLengthyOperation(); var img = document.getElementById('storeImg'); img.style.visibility = 'hidden'; var div = document.getElementById('storeDiv'); div.appendChild(document.createTextNode(new Date() + ': ' + message)); div.appendChild(document.createElement('br')); } }; request.setRequestHeader('Content-Type', 'application/json'); request.send(jscoverage_serializeCoverageToJSON()); }
Returns an integer (0, 1, 2, or 3) representing the index of a given tab. @param tab the ID of the tab element OR the tab element itself
jscoverage_storeButton_click
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
function jscoverage_stopButton_click() { if (jscoverage_inLengthyOperation) { return; } jscoverage_beginLengthyOperation(); var img = document.getElementById('storeImg'); img.style.visibility = 'visible'; var request = jscoverage_createRequest(); request.open('GET', '/stop', true); request.onreadystatechange = function (event) { if (request.readyState === 4) { var message; try { if (request.status !== 200 && request.status !== 201 && request.status !== 204) { throw request.status; } message = request.responseText; } catch (e) { if (e.toString().search(/^\d{3}$/) === 0) { message = e + ': ' + request.responseText; } else { message = 'Could not connect to server: ' + e; } } jscoverage_endLengthyOperation(); var img = document.getElementById('storeImg'); img.style.visibility = 'hidden'; var div = document.getElementById('storeDiv'); div.appendChild(document.createTextNode(new Date() + ': ' + message)); div.appendChild(document.createElement('br')); } }; request.send(); }
Returns an integer (0, 1, 2, or 3) representing the index of a given tab. @param tab the ID of the tab element OR the tab element itself
jscoverage_stopButton_click
javascript
alibaba/f2etest
f2etest-web/public/jscover/jscoverage.js
https://github.com/alibaba/f2etest/blob/master/f2etest-web/public/jscover/jscoverage.js
MIT
constructor() { this.emitter = createNanoEvents(); /** @type {HTMLFormElement | null} */ this.container = null; domReady.then(() => { this.container = document.querySelector('.view-toggler'); // stop browsers remembering previous form state this.container.output[0].checked = true; this.container.addEventListener('change', () => { this.emitter.emit('change', { value: this.container.output.value, }); }); }); }
Tabs that toggle between showing the SVG image and XML markup.
constructor
javascript
jakearchibald/svgomg
src/js/page/ui/view-toggler.js
https://github.com/jakearchibald/svgomg/blob/master/src/js/page/ui/view-toggler.js
MIT
replyByType = function (name, json, request, h) { if (request.headers.accept === 'application/xml') { return h.response(Js2xmlparser(name, json)).type('application/xml'); } return h.response(json).type('application/json'); }
allows a reply to have either a json or xml response @param {String} name @param {Object} json @param {Object} request @param {Object} reply
replyByType
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-complex.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-complex.js
MIT
replyByType = function (name, json, request, h) { if (request.headers.accept === 'application/xml') { return h.response(Js2xmlparser(name, json)).type('application/xml'); } return h.response(json).type('application/json'); }
allows a reply to have either a json or xml response @param {String} name @param {Object} json @param {Object} request @param {Object} reply
replyByType
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-complex.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-complex.js
MIT
defaultHandler = function (request, h) { const sum = { id: 'x78P9c', a: 5, b: 5, operator: '+', equals: 10, created: '2015-12-01', modified: '2015-12-01' }; const list = { items: [sum], count: 1, pageSize: 10, page: 1, pageCount: 1 }; if (request.path.indexOf('/v1/sum/') > -1) { return replyByType('result', { equals: 43 }, request, h); } if (request.path === '/v1/store/' && request.method === 'get') { return replyByType('list', list, request, h); } return replyByType('sum', sum, request, h); }
mock handler for routes @param {Object} request @param {Object} reply
defaultHandler
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-complex.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-complex.js
MIT
defaultHandler = function (request, h) { const sum = { id: 'x78P9c', a: 5, b: 5, operator: '+', equals: 10, created: '2015-12-01', modified: '2015-12-01' }; const list = { items: [sum], count: 1, pageSize: 10, page: 1, pageCount: 1 }; if (request.path.indexOf('/v1/sum/') > -1) { return replyByType('result', { equals: 43 }, request, h); } if (request.path === '/v1/store/' && request.method === 'get') { return replyByType('list', list, request, h); } return replyByType('sum', sum, request, h); }
mock handler for routes @param {Object} request @param {Object} reply
defaultHandler
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-complex.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-complex.js
MIT
replyByType = function (name, json, request, h) { if (request.headers.accept === 'application/xml') { return h.response(Js2xmlparser(name, json)).type('application/xml'); } return h.response(json).type('application/json'); }
allows a reply to have either a json or xml response @param {string} name @param {Object} json @param {Object} request @param {Object} reply
replyByType
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-simple.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-simple.js
MIT
replyByType = function (name, json, request, h) { if (request.headers.accept === 'application/xml') { return h.response(Js2xmlparser(name, json)).type('application/xml'); } return h.response(json).type('application/json'); }
allows a reply to have either a json or xml response @param {string} name @param {Object} json @param {Object} request @param {Object} reply
replyByType
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-simple.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-simple.js
MIT
defaultHandler = function (request, h) { const sum = { id: 'x78P9c', a: 5, b: 5, operator: '+', equals: 10, created: '2015-12-01', modified: '2015-12-01' }; const list = { items: [sum], count: 1, pageSize: 10, page: 1, pageCount: 1 }; if (request.path.indexOf('/v1/sum/') > -1) { return replyByType('result', { equals: 43 }, request, h); } if (request.path === '/v1/store/' && request.method === 'get') { return replyByType('list', list, request, h); } return replyByType('sum', sum, request, h); }
mock handler for routes @param {Object} request @param {Object} reply
defaultHandler
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-simple.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-simple.js
MIT
defaultHandler = function (request, h) { const sum = { id: 'x78P9c', a: 5, b: 5, operator: '+', equals: 10, created: '2015-12-01', modified: '2015-12-01' }; const list = { items: [sum], count: 1, pageSize: 10, page: 1, pageCount: 1 }; if (request.path.indexOf('/v1/sum/') > -1) { return replyByType('result', { equals: 43 }, request, h); } if (request.path === '/v1/store/' && request.method === 'get') { return replyByType('list', list, request, h); } return replyByType('sum', sum, request, h); }
mock handler for routes @param {Object} request @param {Object} reply
defaultHandler
javascript
hapi-swagger/hapi-swagger
examples/assets/routes-simple.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/examples/assets/routes-simple.js
MIT
appendDataContext = function (plugin, settings) { plugin.ext('onPostHandler', (request, h) => { const response = request.response; const routePrefix = plugin.realm.modifiers.route.prefix; // if the reply is a view add settings data into template system if (response.variety === 'view') { // skip if the request is not for this handler if (routePrefix && !request.path.startsWith(routePrefix)) { return h.continue; } // Added to fix bug that cannot yet be reproduced in test - REVIEW /* $lab:coverage:off$ */ if (!response.source.context) { response.source.context = {}; } /* $lab:coverage:on$ */ const prefixedSettings = Hoek.clone(settings); // append tags from document request to JSON request prefixedSettings.jsonPath = request.query.tags ? Utilities.appendQueryString(settings.jsonPath, 'tags', request.query.tags) : settings.jsonPath; if (routePrefix) { ['jsonPath', 'swaggerUIPath'].forEach((setting) => { prefixedSettings[setting] = routePrefix + prefixedSettings[setting]; }); } // Need JWT plugin to work with Hapi v17+ to test this again const prefix = findAPIKeyPrefix(settings); if (prefix) { prefixedSettings.keyPrefix = prefix; } prefixedSettings.stringified = JSON.stringify(prefixedSettings); response.source.context.hapiSwagger = prefixedSettings; } return h.continue; }); }
appends settings data in template context @param {Object} plugin @param {Object} settings @return {Object}
appendDataContext
javascript
hapi-swagger/hapi-swagger
lib/index.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/index.js
MIT
appendDataContext = function (plugin, settings) { plugin.ext('onPostHandler', (request, h) => { const response = request.response; const routePrefix = plugin.realm.modifiers.route.prefix; // if the reply is a view add settings data into template system if (response.variety === 'view') { // skip if the request is not for this handler if (routePrefix && !request.path.startsWith(routePrefix)) { return h.continue; } // Added to fix bug that cannot yet be reproduced in test - REVIEW /* $lab:coverage:off$ */ if (!response.source.context) { response.source.context = {}; } /* $lab:coverage:on$ */ const prefixedSettings = Hoek.clone(settings); // append tags from document request to JSON request prefixedSettings.jsonPath = request.query.tags ? Utilities.appendQueryString(settings.jsonPath, 'tags', request.query.tags) : settings.jsonPath; if (routePrefix) { ['jsonPath', 'swaggerUIPath'].forEach((setting) => { prefixedSettings[setting] = routePrefix + prefixedSettings[setting]; }); } // Need JWT plugin to work with Hapi v17+ to test this again const prefix = findAPIKeyPrefix(settings); if (prefix) { prefixedSettings.keyPrefix = prefix; } prefixedSettings.stringified = JSON.stringify(prefixedSettings); response.source.context.hapiSwagger = prefixedSettings; } return h.continue; }); }
appends settings data in template context @param {Object} plugin @param {Object} settings @return {Object}
appendDataContext
javascript
hapi-swagger/hapi-swagger
lib/index.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/index.js
MIT
findAPIKeyPrefix = function (settings) { // Need JWT plugin to work with Hapi v17+ to test this again /* $lab:coverage:off$ */ let out = ''; if (settings.securityDefinitions) { Object.keys(settings.securityDefinitions).forEach((key) => { if (settings.securityDefinitions[key]['x-keyPrefix']) { out = settings.securityDefinitions[key]['x-keyPrefix']; } }); } return out; /* $lab:coverage:on$ */ }
finds any keyPrefix in securityDefinitions - also add x- to name @param {Object} settings @return {string}
findAPIKeyPrefix
javascript
hapi-swagger/hapi-swagger
lib/index.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/index.js
MIT
findAPIKeyPrefix = function (settings) { // Need JWT plugin to work with Hapi v17+ to test this again /* $lab:coverage:off$ */ let out = ''; if (settings.securityDefinitions) { Object.keys(settings.securityDefinitions).forEach((key) => { if (settings.securityDefinitions[key]['x-keyPrefix']) { out = settings.securityDefinitions[key]['x-keyPrefix']; } }); } return out; /* $lab:coverage:on$ */ }
finds any keyPrefix in securityDefinitions - also add x- to name @param {Object} settings @return {string}
findAPIKeyPrefix
javascript
hapi-swagger/hapi-swagger
lib/index.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/index.js
MIT
buildAlternativesArray = (schemas) => { return schemas .map((schema) => { const childMetaName = Utilities.getJoiMetaProperty(schema, 'swaggerLabel'); const altName = childMetaName || Utilities.getJoiLabel(schema) || name; //name, joiObj, parent, parameterType, useDefinitions, isAlt return this.parseProperty(altName, schema, property, parameterType, useDefinitions, true); }) .filter((obj) => obj); }
parse alternatives property @param {Object} property @param {Object} joiObj @param {string} name @param {string} parameterType @param {Boolean} useDefinitions @return {Object}
buildAlternativesArray
javascript
hapi-swagger/hapi-swagger
lib/properties.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/properties.js
MIT
buildAlternativesArray = (schemas) => { return schemas .map((schema) => { const childMetaName = Utilities.getJoiMetaProperty(schema, 'swaggerLabel'); const altName = childMetaName || Utilities.getJoiLabel(schema) || name; //name, joiObj, parent, parameterType, useDefinitions, isAlt return this.parseProperty(altName, schema, property, parameterType, useDefinitions, true); }) .filter((obj) => obj); }
parse alternatives property @param {Object} property @param {Object} joiObj @param {string} name @param {string} parameterType @param {Boolean} useDefinitions @return {Object}
buildAlternativesArray
javascript
hapi-swagger/hapi-swagger
lib/properties.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/properties.js
MIT
tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }
is passed item a regex @param {Object} obj @return {Boolean}
tryRegexExec
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }
is passed item a regex @param {Object} obj @return {Boolean}
tryRegexExec
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
makeCompareFunction = function (f, direction) { if (typeof f !== 'function') { const prop = f; // make unary function f = function (v1) { return v1[prop]; }; } if (f.length === 1) { // f is a unary function mapping a single item to its sort score const uf = f; f = function (v1, v2) { return uf(v1) < uf(v2) ? -1 : uf(v1) > uf(v2) ? 1 : 0; }; } if (direction === -1) { return function (v1, v2) { return -f(v1, v2); }; } return f; }
get chained functions for sorting @return {Function}
makeCompareFunction
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
makeCompareFunction = function (f, direction) { if (typeof f !== 'function') { const prop = f; // make unary function f = function (v1) { return v1[prop]; }; } if (f.length === 1) { // f is a unary function mapping a single item to its sort score const uf = f; f = function (v1, v2) { return uf(v1) < uf(v2) ? -1 : uf(v1) > uf(v2) ? 1 : 0; }; } if (direction === -1) { return function (v1, v2) { return -f(v1, v2); }; } return f; }
get chained functions for sorting @return {Function}
makeCompareFunction
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
extend = function (f, d) { f = makeCompareFunction(f, d); f.thenBy = tb; return f; }
get chained functions for sorting @return {Function}
extend
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
extend = function (f, d) { f = makeCompareFunction(f, d); f.thenBy = tb; return f; }
get chained functions for sorting @return {Function}
extend
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
tb = function (y, d) { const self = this; y = makeCompareFunction(y, d); return extend((a, b) => { return self(a, b) || y(a, b); }); }
get chained functions for sorting @return {Function}
tb
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
tb = function (y, d) { const self = this; y = makeCompareFunction(y, d); return extend((a, b) => { return self(a, b) || y(a, b); }); }
get chained functions for sorting @return {Function}
tb
javascript
hapi-swagger/hapi-swagger
lib/utilities.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/lib/utilities.js
MIT
validateJWT = (decoded) => { if (!people[decoded.id]) { return { valid: false }; } return { valid: true }; }
creates a Hapi server using JWT auth @param {Object} swaggerOptions @param {Object} routes @param {Function} callback
validateJWT
javascript
hapi-swagger/hapi-swagger
test/helper.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/test/helper.js
MIT
validateJWT = (decoded) => { if (!people[decoded.id]) { return { valid: false }; } return { valid: true }; }
creates a Hapi server using JWT auth @param {Object} swaggerOptions @param {Object} routes @param {Function} callback
validateJWT
javascript
hapi-swagger/hapi-swagger
test/helper.js
https://github.com/hapi-swagger/hapi-swagger/blob/master/test/helper.js
MIT
function px2dp(px) { return px * deviceW / basePx }
Sample React Native App https://github.com/facebook/react-native @flow
px2dp
javascript
ptomasroos/react-native-tab-navigator
example/TabDemo/launcher.js
https://github.com/ptomasroos/react-native-tab-navigator/blob/master/example/TabDemo/launcher.js
MIT
render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Home </Text> </View> ) }
Sample React Native App https://github.com/facebook/react-native @flow
render
javascript
ptomasroos/react-native-tab-navigator
example/TabDemo/launcher.js
https://github.com/ptomasroos/react-native-tab-navigator/blob/master/example/TabDemo/launcher.js
MIT
render() { return ( <View style={styles.container}> <Text style={styles.welcome}> Profile </Text> </View> ) }
Sample React Native App https://github.com/facebook/react-native @flow
render
javascript
ptomasroos/react-native-tab-navigator
example/TabDemo/launcher.js
https://github.com/ptomasroos/react-native-tab-navigator/blob/master/example/TabDemo/launcher.js
MIT
render() { return ( <TabNavigator style={styles.container}> <TabNavigator.Item selected={this.state.selectedTab === 'home'} title="Home" selectedTitleStyle={{color: "#3496f0"}} renderIcon={() => <Icon name="home" size={px2dp(22)} color="#666"/>} renderSelectedIcon={() => <Icon name="home" size={px2dp(22)} color="#3496f0"/>} badgeText="1" onPress={() => this.setState({selectedTab: 'home'})}> <Home/> </TabNavigator.Item> <TabNavigator.Item selected={this.state.selectedTab === 'profile'} title="Profile" selectedTitleStyle={{color: "#3496f0"}} renderIcon={() => <Icon name="user" size={px2dp(22)} color="#666"/>} renderSelectedIcon={() => <Icon name="user" size={px2dp(22)} color="#3496f0"/>} onPress={() => this.setState({selectedTab: 'profile'})}> <Profile/> </TabNavigator.Item> </TabNavigator> ); }
Sample React Native App https://github.com/facebook/react-native @flow
render
javascript
ptomasroos/react-native-tab-navigator
example/TabDemo/launcher.js
https://github.com/ptomasroos/react-native-tab-navigator/blob/master/example/TabDemo/launcher.js
MIT
function parseTime(str) { if (!str) { return 0; } var strings = str.split(":"); var l = strings.length, i = l; var ms = 0, parsed; if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) { throw new Error("tick only understands numbers and 'h:m:s'"); } while (i--) { parsed = parseInt(strings[i], 10); if (parsed >= 60) { throw new Error("Invalid time " + str); } ms += parsed * Math.pow(60, (l - i - 1)); } return ms * 1000; }
Parse strings like "01:10:00" (meaning 1 hour, 10 minutes, 0 seconds) into number of milliseconds. This is used to support human-readable strings passed to clock.tick()
parseTime
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function getEpoch(epoch) { if (!epoch) { return 0; } if (typeof epoch.getTime === "function") { return epoch.getTime(); } if (typeof epoch === "number") { return epoch; } throw new TypeError("now should be milliseconds since UNIX epoch"); }
Used to grok the `now` parameter to createClock.
getEpoch
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function inRange(from, to, timer) { return timer && timer.callAt >= from && timer.callAt <= to; }
Used to grok the `now` parameter to createClock.
inRange
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function mirrorDateProperties(target, source) { var prop; for (prop in source) { if (source.hasOwnProperty(prop)) { target[prop] = source[prop]; } } // set special now implementation if (source.now) { target.now = function now() { return target.clock.now; }; } else { delete target.now; } // set special toSource implementation if (source.toSource) { target.toSource = function toSource() { return source.toSource(); }; } else { delete target.toSource; } // set special toString implementation target.toString = function toString() { return source.toString(); }; target.prototype = source.prototype; target.parse = source.parse; target.UTC = source.UTC; target.prototype.toUTCString = source.prototype.toUTCString; return target; }
Used to grok the `now` parameter to createClock.
mirrorDateProperties
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function createDate() { function ClockDate(year, month, date, hour, minute, second, ms) { // Defensive and verbose to avoid potential harm in passing // explicit undefined when user does not pass argument switch (arguments.length) { case 0: return new NativeDate(ClockDate.clock.now); case 1: return new NativeDate(year); case 2: return new NativeDate(year, month); case 3: return new NativeDate(year, month, date); case 4: return new NativeDate(year, month, date, hour); case 5: return new NativeDate(year, month, date, hour, minute); case 6: return new NativeDate(year, month, date, hour, minute, second); default: return new NativeDate(year, month, date, hour, minute, second, ms); } } return mirrorDateProperties(ClockDate, NativeDate); }
Used to grok the `now` parameter to createClock.
createDate
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function ClockDate(year, month, date, hour, minute, second, ms) { // Defensive and verbose to avoid potential harm in passing // explicit undefined when user does not pass argument switch (arguments.length) { case 0: return new NativeDate(ClockDate.clock.now); case 1: return new NativeDate(year); case 2: return new NativeDate(year, month); case 3: return new NativeDate(year, month, date); case 4: return new NativeDate(year, month, date, hour); case 5: return new NativeDate(year, month, date, hour, minute); case 6: return new NativeDate(year, month, date, hour, minute, second); default: return new NativeDate(year, month, date, hour, minute, second, ms); } }
Used to grok the `now` parameter to createClock.
ClockDate
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function addTimer(clock, timer) { if (timer.func === undefined) { throw new Error("Callback must be provided to timer calls"); } if (!clock.timers) { clock.timers = {}; } timer.id = uniqueTimerId++; timer.createdAt = clock.now; timer.callAt = clock.now + (timer.delay || (clock.duringTick ? 1 : 0)); clock.timers[timer.id] = timer; if (addTimerReturnsObject) { return { id: timer.id, ref: NOOP, unref: NOOP }; } return timer.id; }
Used to grok the `now` parameter to createClock.
addTimer
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function compareTimers(a, b) { // Sort first by absolute timing if (a.callAt < b.callAt) { return -1; } if (a.callAt > b.callAt) { return 1; } // Sort next by immediate, immediate timers take precedence if (a.immediate && !b.immediate) { return -1; } if (!a.immediate && b.immediate) { return 1; } // Sort next by creation time, earlier-created timers take precedence if (a.createdAt < b.createdAt) { return -1; } if (a.createdAt > b.createdAt) { return 1; } // Sort next by id, lower-id timers take precedence if (a.id < b.id) { return -1; } if (a.id > b.id) { return 1; } // As timer ids are unique, no fallback `0` is necessary }
Used to grok the `now` parameter to createClock.
compareTimers
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function firstTimerInRange(clock, from, to) { var timers = clock.timers, timer = null, id, isInRange; for (id in timers) { if (timers.hasOwnProperty(id)) { isInRange = inRange(from, to, timers[id]); if (isInRange && (!timer || compareTimers(timer, timers[id]) === 1)) { timer = timers[id]; } } } return timer; }
Used to grok the `now` parameter to createClock.
firstTimerInRange
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function callTimer(clock, timer) { var exception; if (typeof timer.interval === "number") { clock.timers[timer.id].callAt += timer.interval; } else { delete clock.timers[timer.id]; } try { if (typeof timer.func === "function") { timer.func.apply(null, timer.args); } else { eval(timer.func); } } catch (e) { exception = e; } if (!clock.timers[timer.id]) { if (exception) { throw exception; } return; } if (exception) { throw exception; } }
Used to grok the `now` parameter to createClock.
callTimer
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function timerType(timer) { if (timer.immediate) { return "Immediate"; } else if (typeof timer.interval !== "undefined") { return "Interval"; } else { return "Timeout"; } }
Used to grok the `now` parameter to createClock.
timerType
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function clearTimer(clock, timerId, ttype) { if (!timerId) { // null appears to be allowed in most browsers, and appears to be // relied upon by some libraries, like Bootstrap carousel return; } if (!clock.timers) { clock.timers = []; } // in Node, timerId is an object with .ref()/.unref(), and // its .id field is the actual timer id. if (typeof timerId === "object") { timerId = timerId.id; } if (clock.timers.hasOwnProperty(timerId)) { // check that the ID matches a timer of the correct type var timer = clock.timers[timerId]; if (timerType(timer) === ttype) { delete clock.timers[timerId]; } else { throw new Error("Cannot clear timer: timer created with set" + ttype + "() but cleared with clear" + timerType(timer) + "()"); } } }
Used to grok the `now` parameter to createClock.
clearTimer
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function uninstall(clock, target) { var method, i, l; for (i = 0, l = clock.methods.length; i < l; i++) { method = clock.methods[i]; if (target[method].hadOwnProperty) { target[method] = clock["_" + method]; } else { try { delete target[method]; } catch (ignore) {} } } // Prevent multiple executions which will completely remove these props clock.methods = []; }
Used to grok the `now` parameter to createClock.
uninstall
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function hijackMethod(target, method, clock) { var prop; clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(target, method); clock["_" + method] = target[method]; if (method === "Date") { var date = mirrorDateProperties(clock[method], target[method]); target[method] = date; } else { target[method] = function () { return clock[method].apply(clock, arguments); }; for (prop in clock[method]) { if (clock[method].hasOwnProperty(prop)) { target[method][prop] = clock[method][prop]; } } } target[method].clock = clock; }
Used to grok the `now` parameter to createClock.
hijackMethod
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function createClock(now) { var clock = { now: getEpoch(now), timeouts: {}, Date: createDate() }; clock.Date.clock = clock; clock.setTimeout = function setTimeout(func, timeout) { return addTimer(clock, { func: func, args: Array.prototype.slice.call(arguments, 2), delay: timeout }); }; clock.clearTimeout = function clearTimeout(timerId) { return clearTimer(clock, timerId, "Timeout"); }; clock.setInterval = function setInterval(func, timeout) { return addTimer(clock, { func: func, args: Array.prototype.slice.call(arguments, 2), delay: timeout, interval: timeout }); }; clock.clearInterval = function clearInterval(timerId) { return clearTimer(clock, timerId, "Interval"); }; clock.setImmediate = function setImmediate(func) { return addTimer(clock, { func: func, args: Array.prototype.slice.call(arguments, 1), immediate: true }); }; clock.clearImmediate = function clearImmediate(timerId) { return clearTimer(clock, timerId, "Immediate"); }; clock.tick = function tick(ms) { ms = typeof ms === "number" ? ms : parseTime(ms); var tickFrom = clock.now, tickTo = clock.now + ms, previous = clock.now; var timer = firstTimerInRange(clock, tickFrom, tickTo); var oldNow; clock.duringTick = true; var firstException; while (timer && tickFrom <= tickTo) { if (clock.timers[timer.id]) { tickFrom = clock.now = timer.callAt; try { oldNow = clock.now; callTimer(clock, timer); // compensate for any setSystemTime() call during timer callback if (oldNow !== clock.now) { tickFrom += clock.now - oldNow; tickTo += clock.now - oldNow; previous += clock.now - oldNow; } } catch (e) { firstException = firstException || e; } } timer = firstTimerInRange(clock, previous, tickTo); previous = tickFrom; } clock.duringTick = false; clock.now = tickTo; if (firstException) { throw firstException; } return clock.now; }; clock.reset = function reset() { clock.timers = {}; }; clock.setSystemTime = function setSystemTime(now) { // determine time difference var newNow = getEpoch(now); var difference = newNow - clock.now; // update 'system clock' clock.now = newNow; // update timers and intervals to keep them stable for (var id in clock.timers) { if (clock.timers.hasOwnProperty(id)) { var timer = clock.timers[id]; timer.createdAt += difference; timer.callAt += difference; } } }; return clock; }
Used to grok the `now` parameter to createClock.
createClock
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function getEffectiveOptions(opts) { var options = {}; Object.keys(defaultOptions).forEach(function (key) { options[key] = defaultOptions[key]; }); if (opts) { Object.keys(opts).forEach(function (key) { options[key] = opts[key]; }); } return options; }
Used to grok the `now` parameter to createClock.
getEffectiveOptions
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function resolveFilename(request, parent) { var filename = m._resolveFilename(request, parent); if (Array.isArray(filename)) { filename = filename[1]; } return filename; }
Used to grok the `now` parameter to createClock.
resolveFilename
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function hookedLoader(request, parent, isMain) { var subst, allow, file; if (!originalLoader) { throw new Error("Loader has not been hooked"); } if (registeredMocks.hasOwnProperty(request)) { return registeredMocks[request]; } if (registeredSubstitutes.hasOwnProperty(request)) { subst = registeredSubstitutes[request]; if (!subst.module && subst.name) { subst.module = originalLoader(subst.name, parent, isMain); } if (!subst.module) { throw new Error("Misconfigured substitute for '" + request + "'"); } return subst.module; } if (registeredAllowables.hasOwnProperty(request)) { allow = registeredAllowables[request]; if (allow.unhook) { file = resolveFilename(request, parent); if (file.indexOf('/') !== -1 && allow.paths.indexOf(file) === -1) { allow.paths.push(file); } } } else { if (options.warnOnUnregistered) { console.warn("WARNING: loading non-allowed module: " + request); } } return originalLoader(request, parent, isMain); }
Used to grok the `now` parameter to createClock.
hookedLoader
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function enable(opts) { if (originalLoader) { // Already hooked return; } options = getEffectiveOptions(opts); if (options.useCleanCache) { originalCache = m._cache; m._cache = {}; } originalLoader = m._load; m._load = hookedLoader; }
Used to grok the `now` parameter to createClock.
enable
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function disable() { if (!originalLoader) { // Not hooked return; } if (options.useCleanCache) { m._cache = originalCache; originalCache = null; } m._load = originalLoader; originalLoader = null; }
Used to grok the `now` parameter to createClock.
disable
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function resetCache() { if (options.useCleanCache && originalCache) { m._cache = {}; } }
Used to grok the `now` parameter to createClock.
resetCache
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function warnOnReplace(enable) { options.warnOnReplace = enable; }
Used to grok the `now` parameter to createClock.
warnOnReplace
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function warnOnUnregistered(enable) { options.warnOnUnregistered = enable; }
Used to grok the `now` parameter to createClock.
warnOnUnregistered
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function registerMock(mod, mock) { if (options.warnOnReplace && registeredMocks.hasOwnProperty(mod)) { console.warn("WARNING: Replacing existing mock for module: " + mod); } registeredMocks[mod] = mock; }
Used to grok the `now` parameter to createClock.
registerMock
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function deregisterMock(mod) { if (registeredMocks.hasOwnProperty(mod)) { delete registeredMocks[mod]; } }
Used to grok the `now` parameter to createClock.
deregisterMock
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function registerSubstitute(mod, subst) { if (options.warnOnReplace && registeredSubstitutes.hasOwnProperty(mod)) { console.warn("WARNING: Replacing existing substitute for module: " + mod); } registeredSubstitutes[mod] = { name: subst }; }
Used to grok the `now` parameter to createClock.
registerSubstitute
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function deregisterSubstitute(mod) { if (registeredSubstitutes.hasOwnProperty(mod)) { delete registeredSubstitutes[mod]; } }
Used to grok the `now` parameter to createClock.
deregisterSubstitute
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function registerAllowable(mod, unhook) { registeredAllowables[mod] = { unhook: !!unhook, paths: [] }; }
Used to grok the `now` parameter to createClock.
registerAllowable
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function registerAllowables(mods, unhook) { mods.forEach(function (mod) { registerAllowable(mod, unhook); }); }
Used to grok the `now` parameter to createClock.
registerAllowables
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function deregisterAllowable(mod) { if (registeredAllowables.hasOwnProperty(mod)) { var allow = registeredAllowables[mod]; if (allow.unhook) { allow.paths.forEach(function (p) { delete m._cache[p]; }); } delete registeredAllowables[mod]; } }
Used to grok the `now` parameter to createClock.
deregisterAllowable
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function deregisterAllowables(mods) { mods.forEach(function (mod) { deregisterAllowable(mod); }); }
Used to grok the `now` parameter to createClock.
deregisterAllowables
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function deregisterAll() { Object.keys(registeredAllowables).forEach(function (mod) { var allow = registeredAllowables[mod]; if (allow.unhook) { allow.paths.forEach(function (p) { delete m._cache[p]; }); } }); registeredMocks = {}; registeredSubstitutes = {}; registeredAllowables = {}; }
Used to grok the `now` parameter to createClock.
deregisterAll
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT
function cleanUpNextTick() { draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } }
Used to grok the `now` parameter to createClock.
cleanUpNextTick
javascript
rowanmanning/joblint
build/test.js
https://github.com/rowanmanning/joblint/blob/master/build/test.js
MIT