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
expressjs/response-time
index.js
createSetHeader
function createSetHeader (options) { // response time digits var digits = options.digits !== undefined ? options.digits : 3 // header name var header = options.header || 'X-Response-Time' // display suffix var suffix = options.suffix !== undefined ? Boolean(options.suffix) : true return...
javascript
function createSetHeader (options) { // response time digits var digits = options.digits !== undefined ? options.digits : 3 // header name var header = options.header || 'X-Response-Time' // display suffix var suffix = options.suffix !== undefined ? Boolean(options.suffix) : true return...
[ "function", "createSetHeader", "(", "options", ")", "{", "// response time digits", "var", "digits", "=", "options", ".", "digits", "!==", "undefined", "?", "options", ".", "digits", ":", "3", "// header name", "var", "header", "=", "options", ".", "header", "...
Create function to set respoonse time header. @private
[ "Create", "function", "to", "set", "respoonse", "time", "header", "." ]
5b396e3c87420bdc5a1bd283495de54d4ded4abf
https://github.com/expressjs/response-time/blob/5b396e3c87420bdc5a1bd283495de54d4ded4abf/index.js#L71-L98
train
gerhardberger/electron-pdf-window
pdfjs/web/l10n.js
translateElement
function translateElement(element) { var l10n = getL10nAttributes(element); if (!l10n.id) return; // get the related l10n object var data = getL10nData(l10n.id, l10n.args); if (!data) { console.warn('#' + l10n.id + ' is undefined.'); return; } // translate element (TODO: ...
javascript
function translateElement(element) { var l10n = getL10nAttributes(element); if (!l10n.id) return; // get the related l10n object var data = getL10nData(l10n.id, l10n.args); if (!data) { console.warn('#' + l10n.id + ' is undefined.'); return; } // translate element (TODO: ...
[ "function", "translateElement", "(", "element", ")", "{", "var", "l10n", "=", "getL10nAttributes", "(", "element", ")", ";", "if", "(", "!", "l10n", ".", "id", ")", "return", ";", "// get the related l10n object", "var", "data", "=", "getL10nData", "(", "l10...
translate an HTML element
[ "translate", "an", "HTML", "element" ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/l10n.js#L893-L937
train
gerhardberger/electron-pdf-window
pdfjs/web/l10n.js
getChildElementCount
function getChildElementCount(element) { if (element.children) { return element.children.length; } if (typeof element.childElementCount !== 'undefined') { return element.childElementCount; } var count = 0; for (var i = 0; i < element.childNodes.length; i++) { count += element.n...
javascript
function getChildElementCount(element) { if (element.children) { return element.children.length; } if (typeof element.childElementCount !== 'undefined') { return element.childElementCount; } var count = 0; for (var i = 0; i < element.childNodes.length; i++) { count += element.n...
[ "function", "getChildElementCount", "(", "element", ")", "{", "if", "(", "element", ".", "children", ")", "{", "return", "element", ".", "children", ".", "length", ";", "}", "if", "(", "typeof", "element", ".", "childElementCount", "!==", "'undefined'", ")",...
webkit browsers don't currently support 'children' on SVG elements...
[ "webkit", "browsers", "don", "t", "currently", "support", "children", "on", "SVG", "elements", "..." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/l10n.js#L940-L952
train
gerhardberger/electron-pdf-window
pdfjs/web/l10n.js
translateFragment
function translateFragment(element) { element = element || document.documentElement; // check all translatable children (= w/ a `data-l10n-id' attribute) var children = getTranslatableChildren(element); var elementCount = children.length; for (var i = 0; i < elementCount; i++) { translateElem...
javascript
function translateFragment(element) { element = element || document.documentElement; // check all translatable children (= w/ a `data-l10n-id' attribute) var children = getTranslatableChildren(element); var elementCount = children.length; for (var i = 0; i < elementCount; i++) { translateElem...
[ "function", "translateFragment", "(", "element", ")", "{", "element", "=", "element", "||", "document", ".", "documentElement", ";", "// check all translatable children (= w/ a `data-l10n-id' attribute)", "var", "children", "=", "getTranslatableChildren", "(", "element", ")...
translate an HTML subtree
[ "translate", "an", "HTML", "subtree" ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/l10n.js#L955-L967
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
preferencesSet
function preferencesSet(name, value) { return this.initializedPromise.then(function () { if (this.defaults[name] === undefined) { throw new Error('preferencesSet: \'' + name + '\' is undefined.'); } else if (value === undefined) { throw new Error('preference...
javascript
function preferencesSet(name, value) { return this.initializedPromise.then(function () { if (this.defaults[name] === undefined) { throw new Error('preferencesSet: \'' + name + '\' is undefined.'); } else if (value === undefined) { throw new Error('preference...
[ "function", "preferencesSet", "(", "name", ",", "value", ")", "{", "return", "this", ".", "initializedPromise", ".", "then", "(", "function", "(", ")", "{", "if", "(", "this", ".", "defaults", "[", "name", "]", "===", "undefined", ")", "{", "throw", "n...
Set the value of a preference. @param {string} name The name of the preference that should be changed. @param {boolean|number|string} value The new value of the preference. @return {Promise} A promise that is resolved when the value has been set, provided that the preference exists and the types match.
[ "Set", "the", "value", "of", "a", "preference", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L606-L629
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
PDFOutlineViewer_addToggleButton
function PDFOutlineViewer_addToggleButton(div) { var toggler = document.createElement('div'); toggler.className = 'outlineItemToggler'; toggler.onclick = function (event) { event.stopPropagation(); toggler.classList.toggle('outlineItemsHidden'); ...
javascript
function PDFOutlineViewer_addToggleButton(div) { var toggler = document.createElement('div'); toggler.className = 'outlineItemToggler'; toggler.onclick = function (event) { event.stopPropagation(); toggler.classList.toggle('outlineItemsHidden'); ...
[ "function", "PDFOutlineViewer_addToggleButton", "(", "div", ")", "{", "var", "toggler", "=", "document", ".", "createElement", "(", "'div'", ")", ";", "toggler", ".", "className", "=", "'outlineItemToggler'", ";", "toggler", ".", "onclick", "=", "function", "(",...
Prepend a button before an outline item which allows the user to toggle the visibility of all outline items at that level. @private
[ "Prepend", "a", "button", "before", "an", "outline", "item", "which", "allows", "the", "user", "to", "toggle", "the", "visibility", "of", "all", "outline", "items", "at", "that", "level", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L1072-L1084
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
PDFOutlineViewer_toggleOutlineItem
function PDFOutlineViewer_toggleOutlineItem(root, show) { this.lastToggleIsShow = show; var togglers = root.querySelectorAll('.outlineItemToggler'); for (var i = 0, ii = togglers.length; i < ii; ++i) { togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden')...
javascript
function PDFOutlineViewer_toggleOutlineItem(root, show) { this.lastToggleIsShow = show; var togglers = root.querySelectorAll('.outlineItemToggler'); for (var i = 0, ii = togglers.length; i < ii; ++i) { togglers[i].classList[show ? 'remove' : 'add']('outlineItemsHidden')...
[ "function", "PDFOutlineViewer_toggleOutlineItem", "(", "root", ",", "show", ")", "{", "this", ".", "lastToggleIsShow", "=", "show", ";", "var", "togglers", "=", "root", ".", "querySelectorAll", "(", "'.outlineItemToggler'", ")", ";", "for", "(", "var", "i", "=...
Toggle the visibility of the subtree of an outline item. @param {Element} root - the root of the outline (sub)tree. @param {boolean} show - whether to show the outline (sub)tree. If false, the outline subtree rooted at |root| will be collapsed. @private
[ "Toggle", "the", "visibility", "of", "the", "subtree", "of", "an", "outline", "item", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L1094-L1100
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
PDFDocumentProperties_open
function PDFDocumentProperties_open() { Promise.all([ OverlayManager.open(this.overlayName), this.dataAvailablePromise ]).then(function () { this._getProperties(); }.bind(this)); }
javascript
function PDFDocumentProperties_open() { Promise.all([ OverlayManager.open(this.overlayName), this.dataAvailablePromise ]).then(function () { this._getProperties(); }.bind(this)); }
[ "function", "PDFDocumentProperties_open", "(", ")", "{", "Promise", ".", "all", "(", "[", "OverlayManager", ".", "open", "(", "this", ".", "overlayName", ")", ",", "this", ".", "dataAvailablePromise", "]", ")", ".", "then", "(", "function", "(", ")", "{", ...
Open the document properties overlay.
[ "Open", "the", "document", "properties", "overlay", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L2189-L2196
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
PDFFindController_updateMatchPosition
function PDFFindController_updateMatchPosition(pageIndex, index, elements, beginIdx) { if (this.selected.matchIdx === index && this.selected.pageIdx === pageIndex) { var spot = { top: FIND_SCROLL_OFFSET_TOP, left: FIND_SCROLL_OFFSET_LEFT }; ...
javascript
function PDFFindController_updateMatchPosition(pageIndex, index, elements, beginIdx) { if (this.selected.matchIdx === index && this.selected.pageIdx === pageIndex) { var spot = { top: FIND_SCROLL_OFFSET_TOP, left: FIND_SCROLL_OFFSET_LEFT }; ...
[ "function", "PDFFindController_updateMatchPosition", "(", "pageIndex", ",", "index", ",", "elements", ",", "beginIdx", ")", "{", "if", "(", "this", ".", "selected", ".", "matchIdx", "===", "index", "&&", "this", ".", "selected", ".", "pageIdx", "===", "pageInd...
The method is called back from the text layer when match presentation is updated. @param {number} pageIndex - page index. @param {number} index - match index. @param {Array} elements - text layer div elements array. @param {number} beginIdx - start index of the div array for the match.
[ "The", "method", "is", "called", "back", "from", "the", "text", "layer", "when", "match", "presentation", "is", "updated", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L2708-L2717
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
function () { return this._pages.map(function (pageView) { var viewport = pageView.pdfPage.getViewport(1); return { width: viewport.width, height: viewport.height }; }); }
javascript
function () { return this._pages.map(function (pageView) { var viewport = pageView.pdfPage.getViewport(1); return { width: viewport.width, height: viewport.height }; }); }
[ "function", "(", ")", "{", "return", "this", ".", "_pages", ".", "map", "(", "function", "(", "pageView", ")", "{", "var", "viewport", "=", "pageView", ".", "pdfPage", ".", "getViewport", "(", "1", ")", ";", "return", "{", "width", ":", "viewport", "...
Returns sizes of the pages. @returns {Array} Array of objects with width/height fields.
[ "Returns", "sizes", "of", "the", "pages", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L6435-L6443
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
pdfViewClose
function pdfViewClose() { var errorWrapper = this.appConfig.errorWrapper.container; errorWrapper.setAttribute('hidden', 'true'); if (!this.pdfLoadingTask) { return Promise.resolve(); } var promise = this.pdfLoadingTask.destroy(); this.pdfLoadingTas...
javascript
function pdfViewClose() { var errorWrapper = this.appConfig.errorWrapper.container; errorWrapper.setAttribute('hidden', 'true'); if (!this.pdfLoadingTask) { return Promise.resolve(); } var promise = this.pdfLoadingTask.destroy(); this.pdfLoadingTas...
[ "function", "pdfViewClose", "(", ")", "{", "var", "errorWrapper", "=", "this", ".", "appConfig", ".", "errorWrapper", ".", "container", ";", "errorWrapper", ".", "setAttribute", "(", "'hidden'", ",", "'true'", ")", ";", "if", "(", "!", "this", ".", "pdfLoa...
Closes opened PDF document. @returns {Promise} - Returns the promise, which is resolved when all destruction is completed.
[ "Closes", "opened", "PDF", "document", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L6835-L6860
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
pdfViewOpen
function pdfViewOpen(file, args) { if (arguments.length > 2 || typeof args === 'number') { return Promise.reject(new Error('Call of open() with obsolete signature.')); } if (this.pdfLoadingTask) { // We need to destroy already opened document. return thi...
javascript
function pdfViewOpen(file, args) { if (arguments.length > 2 || typeof args === 'number') { return Promise.reject(new Error('Call of open() with obsolete signature.')); } if (this.pdfLoadingTask) { // We need to destroy already opened document. return thi...
[ "function", "pdfViewOpen", "(", "file", ",", "args", ")", "{", "if", "(", "arguments", ".", "length", ">", "2", "||", "typeof", "args", "===", "'number'", ")", "{", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'Call of open() with obsolet...
Opens PDF document specified by URL or array with additional arguments. @param {string|TypedArray|ArrayBuffer} file - PDF location or binary data. @param {Object} args - (optional) Additional arguments for the getDocument call, e.g. HTTP headers ('httpHeaders') or alternative data transport ('range'). @returns {Promise...
[ "Opens", "PDF", "document", "specified", "by", "URL", "or", "array", "with", "additional", "arguments", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L6870-L6937
train
gerhardberger/electron-pdf-window
pdfjs/web/viewer.js
pdfViewError
function pdfViewError(message, moreInfo) { var moreInfoText = mozL10n.get('error_version_info', { version: pdfjsLib.version || '?', build: pdfjsLib.build || '?' }, 'PDF.js v{{version}} (build: {{build}})') + '\n'; if (moreInfo) { moreInfoText += mozL10n....
javascript
function pdfViewError(message, moreInfo) { var moreInfoText = mozL10n.get('error_version_info', { version: pdfjsLib.version || '?', build: pdfjsLib.build || '?' }, 'PDF.js v{{version}} (build: {{build}})') + '\n'; if (moreInfo) { moreInfoText += mozL10n....
[ "function", "pdfViewError", "(", "message", ",", "moreInfo", ")", "{", "var", "moreInfoText", "=", "mozL10n", ".", "get", "(", "'error_version_info'", ",", "{", "version", ":", "pdfjsLib", ".", "version", "||", "'?'", ",", "build", ":", "pdfjsLib", ".", "b...
Show the error box. @param {String} message A message that is human readable. @param {Object} moreInfo (optional) Further information about the error that is more technical. Should have a 'message' and optionally a 'stack' property.
[ "Show", "the", "error", "box", "." ]
61fc00ab545ee5170f9832aaa37dedb542d3b3e8
https://github.com/gerhardberger/electron-pdf-window/blob/61fc00ab545ee5170f9832aaa37dedb542d3b3e8/pdfjs/web/viewer.js#L6974-L7021
train
thegecko/webusb
gulpfile.js
lint
function lint() { return gulp.src(srcFiles) .pipe(gulpTslint({ program: tslint.Linter.createProgram("./tsconfig.json"), formatter: "stylish" })) .pipe(gulpTslint.report({ emitError: !watching })) }
javascript
function lint() { return gulp.src(srcFiles) .pipe(gulpTslint({ program: tslint.Linter.createProgram("./tsconfig.json"), formatter: "stylish" })) .pipe(gulpTslint.report({ emitError: !watching })) }
[ "function", "lint", "(", ")", "{", "return", "gulp", ".", "src", "(", "srcFiles", ")", ".", "pipe", "(", "gulpTslint", "(", "{", "program", ":", "tslint", ".", "Linter", ".", "createProgram", "(", "\"./tsconfig.json\"", ")", ",", "formatter", ":", "\"sty...
Lint the source
[ "Lint", "the", "source" ]
9e6e7f8872dcf5115f056f8b337b0d6aa28c952e
https://github.com/thegecko/webusb/blob/9e6e7f8872dcf5115f056f8b337b0d6aa28c952e/gulpfile.js#L41-L50
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_attr
function _attr(el, attr, attrs, i) { var result = (el.getAttribute && el.getAttribute(attr)) || 0; if (!result) { attrs = el.attributes; for (i = 0; i < attrs.length; ++i) { if (attrs[i].nodeName === attr) { return attrs[i].nodeValue; ...
javascript
function _attr(el, attr, attrs, i) { var result = (el.getAttribute && el.getAttribute(attr)) || 0; if (!result) { attrs = el.attributes; for (i = 0; i < attrs.length; ++i) { if (attrs[i].nodeName === attr) { return attrs[i].nodeValue; ...
[ "function", "_attr", "(", "el", ",", "attr", ",", "attrs", ",", "i", ")", "{", "var", "result", "=", "(", "el", ".", "getAttribute", "&&", "el", ".", "getAttribute", "(", "attr", ")", ")", "||", "0", ";", "if", "(", "!", "result", ")", "{", "at...
cross browser get attribute for an element @see http://stackoverflow.com/questions/3755227/cross-browser-javascript-getattribute-method @param {Node} el @param {string} attr attribute you are trying to get @returns {string|number}
[ "cross", "browser", "get", "attribute", "for", "an", "element" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L100-L114
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_getLanguageForBlock
function _getLanguageForBlock(block) { // if this doesn't have a language but the parent does then use that // this means if for example you have: <pre data-language="php"> // with a bunch of <code> blocks inside then you do not have // to specify the language for each block var...
javascript
function _getLanguageForBlock(block) { // if this doesn't have a language but the parent does then use that // this means if for example you have: <pre data-language="php"> // with a bunch of <code> blocks inside then you do not have // to specify the language for each block var...
[ "function", "_getLanguageForBlock", "(", "block", ")", "{", "// if this doesn't have a language but the parent does then use that", "// this means if for example you have: <pre data-language=\"php\">", "// with a bunch of <code> blocks inside then you do not have", "// to specify the language for ...
gets the language for this block of code @param {Element} block @returns {string|null}
[ "gets", "the", "language", "for", "this", "block", "of", "code" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L144-L165
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_intersects
function _intersects(start1, end1, start2, end2) { if (start2 >= start1 && start2 < end1) { return true; } return end2 > start1 && end2 < end1; }
javascript
function _intersects(start1, end1, start2, end2) { if (start2 >= start1 && start2 < end1) { return true; } return end2 > start1 && end2 < end1; }
[ "function", "_intersects", "(", "start1", ",", "end1", ",", "start2", ",", "end2", ")", "{", "if", "(", "start2", ">=", "start1", "&&", "start2", "<", "end1", ")", "{", "return", "true", ";", "}", "return", "end2", ">", "start1", "&&", "end2", "<", ...
determines if a new match intersects with an existing one @param {number} start1 start position of existing match @param {number} end1 end position of existing match @param {number} start2 start position of new match @param {number} end2 end position of new match @returns {boolean}
[ "determines", "if", "a", "new", "match", "intersects", "with", "an", "existing", "one" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L186-L192
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_hasCompleteOverlap
function _hasCompleteOverlap(start1, end1, start2, end2) { // if the starting and end positions are exactly the same // then the first one should stay and this one should be ignored if (start2 == start1 && end2 == end1) { return false; } return start2 <= start1 && e...
javascript
function _hasCompleteOverlap(start1, end1, start2, end2) { // if the starting and end positions are exactly the same // then the first one should stay and this one should be ignored if (start2 == start1 && end2 == end1) { return false; } return start2 <= start1 && e...
[ "function", "_hasCompleteOverlap", "(", "start1", ",", "end1", ",", "start2", ",", "end2", ")", "{", "// if the starting and end positions are exactly the same", "// then the first one should stay and this one should be ignored", "if", "(", "start2", "==", "start1", "&&", "en...
determines if two different matches have complete overlap with each other @param {number} start1 start position of existing match @param {number} end1 end position of existing match @param {number} start2 start position of new match @param {number} end2 end position of new match @returns {boolean}
[ "determines", "if", "two", "different", "matches", "have", "complete", "overlap", "with", "each", "other" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L203-L212
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_matchIsInsideOtherMatch
function _matchIsInsideOtherMatch(start, end) { for (var key in replacement_positions[CURRENT_LEVEL]) { key = parseInt(key, 10); // if this block completely overlaps with another block // then we should remove the other block and return false if (_hasCompleteOver...
javascript
function _matchIsInsideOtherMatch(start, end) { for (var key in replacement_positions[CURRENT_LEVEL]) { key = parseInt(key, 10); // if this block completely overlaps with another block // then we should remove the other block and return false if (_hasCompleteOver...
[ "function", "_matchIsInsideOtherMatch", "(", "start", ",", "end", ")", "{", "for", "(", "var", "key", "in", "replacement_positions", "[", "CURRENT_LEVEL", "]", ")", "{", "key", "=", "parseInt", "(", "key", ",", "10", ")", ";", "// if this block completely over...
determines if the match passed in falls inside of an existing match this prevents a regex pattern from matching inside of a bigger pattern @param {number} start - start position of new match @param {number} end - end position of new match @returns {boolean}
[ "determines", "if", "the", "match", "passed", "in", "falls", "inside", "of", "an", "existing", "match", "this", "prevents", "a", "regex", "pattern", "from", "matching", "inside", "of", "a", "bigger", "pattern" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L222-L239
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_indexOfGroup
function _indexOfGroup(match, group_number) { var index = 0, i; for (i = 1; i < group_number; ++i) { if (match[i]) { index += match[i].length; } } return index; }
javascript
function _indexOfGroup(match, group_number) { var index = 0, i; for (i = 1; i < group_number; ++i) { if (match[i]) { index += match[i].length; } } return index; }
[ "function", "_indexOfGroup", "(", "match", ",", "group_number", ")", "{", "var", "index", "=", "0", ",", "i", ";", "for", "(", "i", "=", "1", ";", "i", "<", "group_number", ";", "++", "i", ")", "{", "if", "(", "match", "[", "i", "]", ")", "{", ...
finds out the position of group match for a regular expression @see http://stackoverflow.com/questions/1985594/how-to-find-index-of-groups-in-match @param {Object} match @param {number} group_number @returns {number}
[ "finds", "out", "the", "position", "of", "group", "match", "for", "a", "regular", "expression" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L261-L272
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_getPatternsForLanguage
function _getPatternsForLanguage(language) { var patterns = language_patterns[language] || [], default_patterns = language_patterns[DEFAULT_LANGUAGE] || []; return _bypassDefaultPatterns(language) ? patterns : patterns.concat(default_patterns); }
javascript
function _getPatternsForLanguage(language) { var patterns = language_patterns[language] || [], default_patterns = language_patterns[DEFAULT_LANGUAGE] || []; return _bypassDefaultPatterns(language) ? patterns : patterns.concat(default_patterns); }
[ "function", "_getPatternsForLanguage", "(", "language", ")", "{", "var", "patterns", "=", "language_patterns", "[", "language", "]", "||", "[", "]", ",", "default_patterns", "=", "language_patterns", "[", "DEFAULT_LANGUAGE", "]", "||", "[", "]", ";", "return", ...
returns a list of regex patterns for this language @param {string} language @returns {Array}
[ "returns", "a", "list", "of", "regex", "patterns", "for", "this", "language" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L471-L476
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_replaceAtPosition
function _replaceAtPosition(position, replace, replace_with, code) { var sub_string = code.substr(position); return code.substr(0, position) + sub_string.replace(replace, replace_with); }
javascript
function _replaceAtPosition(position, replace, replace_with, code) { var sub_string = code.substr(position); return code.substr(0, position) + sub_string.replace(replace, replace_with); }
[ "function", "_replaceAtPosition", "(", "position", ",", "replace", ",", "replace_with", ",", "code", ")", "{", "var", "sub_string", "=", "code", ".", "substr", "(", "position", ")", ";", "return", "code", ".", "substr", "(", "0", ",", "position", ")", "+...
substring replace call to replace part of a string at a certain position @param {number} position the position where the replacement should happen @param {string} replace the text we want to replace @param {string} replace_with the text we want to replace it with @param {string} code t...
[ "substring", "replace", "call", "to", "replace", "part", "of", "a", "string", "at", "a", "certain", "position" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L487-L490
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
keys
function keys(object) { var locations = [], replacement, pos; for(var location in object) { if (object.hasOwnProperty(location)) { locations.push(location); } } // numeric descending return locations.sort(function(...
javascript
function keys(object) { var locations = [], replacement, pos; for(var location in object) { if (object.hasOwnProperty(location)) { locations.push(location); } } // numeric descending return locations.sort(function(...
[ "function", "keys", "(", "object", ")", "{", "var", "locations", "=", "[", "]", ",", "replacement", ",", "pos", ";", "for", "(", "var", "location", "in", "object", ")", "{", "if", "(", "object", ".", "hasOwnProperty", "(", "location", ")", ")", "{", ...
sorts an object by index descending @param {Object} object @return {Array}
[ "sorts", "an", "object", "by", "index", "descending" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L498-L513
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_processCodeWithPatterns
function _processCodeWithPatterns(code, patterns, callback) { // we have to increase the level here so that the // replacements will not conflict with each other when // processing sub blocks of code ++CURRENT_LEVEL; // patterns are processed one at a time through this funct...
javascript
function _processCodeWithPatterns(code, patterns, callback) { // we have to increase the level here so that the // replacements will not conflict with each other when // processing sub blocks of code ++CURRENT_LEVEL; // patterns are processed one at a time through this funct...
[ "function", "_processCodeWithPatterns", "(", "code", ",", "patterns", ",", "callback", ")", "{", "// we have to increase the level here so that the", "// replacements will not conflict with each other when", "// processing sub blocks of code", "++", "CURRENT_LEVEL", ";", "// patterns...
processes a block of code using specified patterns @param {string} code @param {Array} patterns @returns void
[ "processes", "a", "block", "of", "code", "using", "specified", "patterns" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L522-L553
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_processReplacements
function _processReplacements(code, onComplete) { /** * processes a single replacement * * @param {string} code * @param {Array} positions * @param {number} i * @param {Function} onComplete * @returns void */ function _processRepla...
javascript
function _processReplacements(code, onComplete) { /** * processes a single replacement * * @param {string} code * @param {Array} positions * @param {number} i * @param {Function} onComplete * @returns void */ function _processRepla...
[ "function", "_processReplacements", "(", "code", ",", "onComplete", ")", "{", "/**\n * processes a single replacement\n *\n * @param {string} code\n * @param {Array} positions\n * @param {number} i\n * @param {Function} onComplete\n * @returns ...
process replacements in the string of code to actually update the markup @param {string} code the code to process replacements in @param {Function} onComplete what to do when we are done processing @returns void
[ "process", "replacements", "in", "the", "string", "of", "code", "to", "actually", "update", "the", "markup" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L562-L594
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_highlightBlockForLanguage
function _highlightBlockForLanguage(code, language, onComplete) { var patterns = _getPatternsForLanguage(language); _processCodeWithPatterns(_htmlEntities(code), patterns, onComplete); }
javascript
function _highlightBlockForLanguage(code, language, onComplete) { var patterns = _getPatternsForLanguage(language); _processCodeWithPatterns(_htmlEntities(code), patterns, onComplete); }
[ "function", "_highlightBlockForLanguage", "(", "code", ",", "language", ",", "onComplete", ")", "{", "var", "patterns", "=", "_getPatternsForLanguage", "(", "language", ")", ";", "_processCodeWithPatterns", "(", "_htmlEntities", "(", "code", ")", ",", "patterns", ...
takes a string of code and highlights it according to the language specified @param {string} code @param {string} language @param {Function} onComplete @returns void
[ "takes", "a", "string", "of", "code", "and", "highlights", "it", "according", "to", "the", "language", "specified" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L604-L607
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
_highlightCodeBlock
function _highlightCodeBlock(code_blocks, i, onComplete) { if (i < code_blocks.length) { var block = code_blocks[i], language = _getLanguageForBlock(block); if (!_hasClass(block, 'rainbow') && language) { language = language.toLowerCase(); ...
javascript
function _highlightCodeBlock(code_blocks, i, onComplete) { if (i < code_blocks.length) { var block = code_blocks[i], language = _getLanguageForBlock(block); if (!_hasClass(block, 'rainbow') && language) { language = language.toLowerCase(); ...
[ "function", "_highlightCodeBlock", "(", "code_blocks", ",", "i", ",", "onComplete", ")", "{", "if", "(", "i", "<", "code_blocks", ".", "length", ")", "{", "var", "block", "=", "code_blocks", "[", "i", "]", ",", "language", "=", "_getLanguageForBlock", "(",...
highlight an individual code block @param {Array} code_blocks @param {number} i @returns void
[ "highlight", "an", "individual", "code", "block" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L616-L650
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
function(language, patterns, bypass) { // if there is only one argument then we assume that we want to // extend the default language rules if (arguments.length == 1) { patterns = language; language = DEFAULT_LANGUAGE; } bypas...
javascript
function(language, patterns, bypass) { // if there is only one argument then we assume that we want to // extend the default language rules if (arguments.length == 1) { patterns = language; language = DEFAULT_LANGUAGE; } bypas...
[ "function", "(", "language", ",", "patterns", ",", "bypass", ")", "{", "// if there is only one argument then we assume that we want to", "// extend the default language rules", "if", "(", "arguments", ".", "length", "==", "1", ")", "{", "patterns", "=", "language", ";"...
extends the language pattern matches @param {*} language name of language @param {*} patterns array of patterns to add on @param {boolean|null} bypass if true this will bypass the default language patterns
[ "extends", "the", "language", "pattern", "matches" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L723-L734
train
vkiryukhin/jsonfn
html/rainbow/rainbow.js
function() { // if you want to straight up highlight a string you can pass the string of code, // the language, and a callback function if (typeof arguments[0] == 'string') { return _highlightBlockForLanguage(arguments[0], arguments[1], arguments[2]); } ...
javascript
function() { // if you want to straight up highlight a string you can pass the string of code, // the language, and a callback function if (typeof arguments[0] == 'string') { return _highlightBlockForLanguage(arguments[0], arguments[1], arguments[2]); } ...
[ "function", "(", ")", "{", "// if you want to straight up highlight a string you can pass the string of code,", "// the language, and a callback function", "if", "(", "typeof", "arguments", "[", "0", "]", "==", "'string'", ")", "{", "return", "_highlightBlockForLanguage", "(", ...
starts the magic rainbow @returns void
[ "starts", "the", "magic", "rainbow" ]
299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac
https://github.com/vkiryukhin/jsonfn/blob/299b4beb4818f7ca98f5e01f0d2a6675b8b2e4ac/html/rainbow/rainbow.js#L759-L776
train
webroo/dummy-json
lib/helpers.js
getNumber
function getNumber (type, min, max, format, options) { var ret; // Juggle the arguments if the user didn't supply a format string if (!options) { options = format; format = null; } if (type === 'int') { ret = utils.randomInt(min, max); } else if (type === 'float') { ret = utils.randomFloat...
javascript
function getNumber (type, min, max, format, options) { var ret; // Juggle the arguments if the user didn't supply a format string if (!options) { options = format; format = null; } if (type === 'int') { ret = utils.randomInt(min, max); } else if (type === 'float') { ret = utils.randomFloat...
[ "function", "getNumber", "(", "type", ",", "min", ",", "max", ",", "format", ",", "options", ")", "{", "var", "ret", ";", "// Juggle the arguments if the user didn't supply a format string", "if", "(", "!", "options", ")", "{", "options", "=", "format", ";", "...
Generating int and floats is very similar so we route both to this single function
[ "Generating", "int", "and", "floats", "is", "very", "similar", "so", "we", "route", "both", "to", "this", "single", "function" ]
4a89d2533d5bf401eee59e6aee66e2fbbdfe7a46
https://github.com/webroo/dummy-json/blob/4a89d2533d5bf401eee59e6aee66e2fbbdfe7a46/lib/helpers.js#L8-L32
train
webroo/dummy-json
lib/helpers.js
getDate
function getDate (type, min, max, format, options) { var ret; // Juggle the arguments if the user didn't supply a format string if (!options) { options = format; format = null; } if (type === 'date') { min = Date.parse(min); max = Date.parse(max); } else if (type === 'time') { min = Da...
javascript
function getDate (type, min, max, format, options) { var ret; // Juggle the arguments if the user didn't supply a format string if (!options) { options = format; format = null; } if (type === 'date') { min = Date.parse(min); max = Date.parse(max); } else if (type === 'time') { min = Da...
[ "function", "getDate", "(", "type", ",", "min", ",", "max", ",", "format", ",", "options", ")", "{", "var", "ret", ";", "// Juggle the arguments if the user didn't supply a format string", "if", "(", "!", "options", ")", "{", "options", "=", "format", ";", "fo...
Generating time and dates is very similar so we route both to this single function
[ "Generating", "time", "and", "dates", "is", "very", "similar", "so", "we", "route", "both", "to", "this", "single", "function" ]
4a89d2533d5bf401eee59e6aee66e2fbbdfe7a46
https://github.com/webroo/dummy-json/blob/4a89d2533d5bf401eee59e6aee66e2fbbdfe7a46/lib/helpers.js#L35-L65
train
kentcdodds/genie
src/index.js
_createWish
function _createWish(wish) { const id = wish.id || `g-${_previousId++}` const newWish = { id, context: _createContext(wish.context), data: wish.data || {}, magicWords: _arrayify(wish.magicWords), action: _createAction(wish.action), } newWish.data.timesMade = { total: 0, magicWords: {...
javascript
function _createWish(wish) { const id = wish.id || `g-${_previousId++}` const newWish = { id, context: _createContext(wish.context), data: wish.data || {}, magicWords: _arrayify(wish.magicWords), action: _createAction(wish.action), } newWish.data.timesMade = { total: 0, magicWords: {...
[ "function", "_createWish", "(", "wish", ")", "{", "const", "id", "=", "wish", ".", "id", "||", "`", "${", "_previousId", "++", "}", "`", "const", "newWish", "=", "{", "id", ",", "context", ":", "_createContext", "(", "wish", ".", "context", ")", ",",...
Creates a new wish object. @param {object} wish @returns {wish} New wish object @private
[ "Creates", "a", "new", "wish", "object", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L156-L170
train
kentcdodds/genie
src/index.js
_createContext
function _createContext(context) { let newContext = context || _defaultContext if (_isString(newContext) || _isArray(newContext)) { newContext = { any: _arrayify(newContext), } } else { newContext = _arrayizeContext(context) } return newContext }
javascript
function _createContext(context) { let newContext = context || _defaultContext if (_isString(newContext) || _isArray(newContext)) { newContext = { any: _arrayify(newContext), } } else { newContext = _arrayizeContext(context) } return newContext }
[ "function", "_createContext", "(", "context", ")", "{", "let", "newContext", "=", "context", "||", "_defaultContext", "if", "(", "_isString", "(", "newContext", ")", "||", "_isArray", "(", "newContext", ")", ")", "{", "newContext", "=", "{", "any", ":", "_...
Transforms the given context to a context object. @param {object|string|Array.<string>} context @returns {context} @private
[ "Transforms", "the", "given", "context", "to", "a", "context", "object", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L178-L188
train
kentcdodds/genie
src/index.js
_arrayizeContext
function _arrayizeContext(context) { function checkAndAdd(type) { if (context[type]) { context[type] = _arrayify(context[type]) } } checkAndAdd('all') checkAndAdd('any') checkAndAdd('none') return context }
javascript
function _arrayizeContext(context) { function checkAndAdd(type) { if (context[type]) { context[type] = _arrayify(context[type]) } } checkAndAdd('all') checkAndAdd('any') checkAndAdd('none') return context }
[ "function", "_arrayizeContext", "(", "context", ")", "{", "function", "checkAndAdd", "(", "type", ")", "{", "if", "(", "context", "[", "type", "]", ")", "{", "context", "[", "type", "]", "=", "_arrayify", "(", "context", "[", "type", "]", ")", "}", "...
Makes all the context properties arrays. @param {object|string|Array.<string>} context @returns {context} @private
[ "Makes", "all", "the", "context", "properties", "arrays", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L196-L206
train
kentcdodds/genie
src/index.js
_createAction
function _createAction(action) { if (_isString(action)) { action = { destination: action, } } if (_isObject(action)) { action = (function() { const openNewTab = action.openNewTab const destination = action.destination return function() { if (openNewTab) { wind...
javascript
function _createAction(action) { if (_isString(action)) { action = { destination: action, } } if (_isObject(action)) { action = (function() { const openNewTab = action.openNewTab const destination = action.destination return function() { if (openNewTab) { wind...
[ "function", "_createAction", "(", "action", ")", "{", "if", "(", "_isString", "(", "action", ")", ")", "{", "action", "=", "{", "destination", ":", "action", ",", "}", "}", "if", "(", "_isObject", "(", "action", ")", ")", "{", "action", "=", "(", "...
Transforms the given action into an action callback. @param {Function|object|string} action @returns {WishAction} @private
[ "Transforms", "the", "given", "action", "into", "an", "action", "callback", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L215-L236
train
kentcdodds/genie
src/index.js
deregisterWish
function deregisterWish(wish) { let indexOfWish = _wishes.indexOf(wish) if (!indexOfWish) { _each(_wishes, (aWish, index) => { // the given parameter could be an id. if (wish === aWish.id || wish.id === aWish.id) { indexOfWish = index wish = aWish return false } }) ...
javascript
function deregisterWish(wish) { let indexOfWish = _wishes.indexOf(wish) if (!indexOfWish) { _each(_wishes, (aWish, index) => { // the given parameter could be an id. if (wish === aWish.id || wish.id === aWish.id) { indexOfWish = index wish = aWish return false } }) ...
[ "function", "deregisterWish", "(", "wish", ")", "{", "let", "indexOfWish", "=", "_wishes", ".", "indexOf", "(", "wish", ")", "if", "(", "!", "indexOfWish", ")", "{", "_each", "(", "_wishes", ",", "(", "aWish", ",", "index", ")", "=>", "{", "// the give...
Deregisters the given wish. Removes it from the registry and from the _enteredMagicWords map. This will delete an _enteredMagicWords listing if this is the only wish in the list. @param {object|string} wish The wish to deregister @returns {wish} The deregistered wish @public
[ "Deregisters", "the", "given", "wish", ".", "Removes", "it", "from", "the", "registry", "and", "from", "the", "_enteredMagicWords", "map", ".", "This", "will", "delete", "an", "_enteredMagicWords", "listing", "if", "this", "is", "the", "only", "wish", "in", ...
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L247-L263
train
kentcdodds/genie
src/index.js
_removeWishIdFromEnteredMagicWords
function _removeWishIdFromEnteredMagicWords(id) { function removeIdFromWishes(charObj, parent, charObjName) { _each(charObj, (childProp, propName) => { if (propName === 'wishes') { const index = childProp.indexOf(id) if (index !== -1) { childProp.splice(index, 1) } ...
javascript
function _removeWishIdFromEnteredMagicWords(id) { function removeIdFromWishes(charObj, parent, charObjName) { _each(charObj, (childProp, propName) => { if (propName === 'wishes') { const index = childProp.indexOf(id) if (index !== -1) { childProp.splice(index, 1) } ...
[ "function", "_removeWishIdFromEnteredMagicWords", "(", "id", ")", "{", "function", "removeIdFromWishes", "(", "charObj", ",", "parent", ",", "charObjName", ")", "{", "_each", "(", "charObj", ",", "(", "childProp", ",", "propName", ")", "=>", "{", "if", "(", ...
Iterates through _enteredMagicWords and removes all instances of this id. If this leaves the letter empty it removes the letter. @param {string} id @private
[ "Iterates", "through", "_enteredMagicWords", "and", "removes", "all", "instances", "of", "this", "id", ".", "If", "this", "leaves", "the", "letter", "empty", "it", "removes", "the", "letter", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L272-L293
train
kentcdodds/genie
src/index.js
deregisterWishesWithContext
function deregisterWishesWithContext(context, type, wishContextTypes) { const deregisteredWishes = getWishesWithContext( context, type, wishContextTypes, ) _each(deregisteredWishes, (wish, i) => { deregisteredWishes[i] = deregisterWish(wish) }) return deregisteredWishes }
javascript
function deregisterWishesWithContext(context, type, wishContextTypes) { const deregisteredWishes = getWishesWithContext( context, type, wishContextTypes, ) _each(deregisteredWishes, (wish, i) => { deregisteredWishes[i] = deregisterWish(wish) }) return deregisteredWishes }
[ "function", "deregisterWishesWithContext", "(", "context", ",", "type", ",", "wishContextTypes", ")", "{", "const", "deregisteredWishes", "=", "getWishesWithContext", "(", "context", ",", "type", ",", "wishContextTypes", ",", ")", "_each", "(", "deregisteredWishes", ...
Convenience method which calls getWishesWithContext and passes the arguments which are passed to this function. Then deregisters each of these. @param {string|Array.<string>} context The context the lookup @param {string} [type='any'] 'all', 'any', or 'none' referring to the context parameter @param {string|Array.<stri...
[ "Convenience", "method", "which", "calls", "getWishesWithContext", "and", "passes", "the", "arguments", "which", "are", "passed", "to", "this", "function", ".", "Then", "deregisters", "each", "of", "these", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L306-L316
train
kentcdodds/genie
src/index.js
_getWishContext
function _getWishContext(wish, wishContextTypes) { let wishContext = [] wishContextTypes = wishContextTypes || ['all', 'any', 'none'] wishContextTypes = _arrayify(wishContextTypes) _each(wishContextTypes, wishContextType => { if (wish.context[wishContextType]) { wishContext = wishContext.concat(wish....
javascript
function _getWishContext(wish, wishContextTypes) { let wishContext = [] wishContextTypes = wishContextTypes || ['all', 'any', 'none'] wishContextTypes = _arrayify(wishContextTypes) _each(wishContextTypes, wishContextType => { if (wish.context[wishContextType]) { wishContext = wishContext.concat(wish....
[ "function", "_getWishContext", "(", "wish", ",", "wishContextTypes", ")", "{", "let", "wishContext", "=", "[", "]", "wishContextTypes", "=", "wishContextTypes", "||", "[", "'all'", ",", "'any'", ",", "'none'", "]", "wishContextTypes", "=", "_arrayify", "(", "w...
Gets the wish context based on the wishContextTypes. @param {object} wish @param {string|Array.<string>} wishContextTypes @returns {Array.<string>} @private
[ "Gets", "the", "wish", "context", "based", "on", "the", "wishContextTypes", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L380-L392
train
kentcdodds/genie
src/index.js
_getWishIndexById
function _getWishIndexById(id) { let wishIndex = -1 if (_isArray(id)) { const wishIndexes = [] _each(id, wishId => { wishIndexes.push(_getWishIndexById(wishId)) }) return wishIndexes } else { _each(_wishes, (aWish, index) => { if (aWish.id === id) { wishIndex = index ...
javascript
function _getWishIndexById(id) { let wishIndex = -1 if (_isArray(id)) { const wishIndexes = [] _each(id, wishId => { wishIndexes.push(_getWishIndexById(wishId)) }) return wishIndexes } else { _each(_wishes, (aWish, index) => { if (aWish.id === id) { wishIndex = index ...
[ "function", "_getWishIndexById", "(", "id", ")", "{", "let", "wishIndex", "=", "-", "1", "if", "(", "_isArray", "(", "id", ")", ")", "{", "const", "wishIndexes", "=", "[", "]", "_each", "(", "id", ",", "wishId", "=>", "{", "wishIndexes", ".", "push",...
Gets a wish from the _wishes array by its ID @param {wishIds} id @returns {wish|Array.<wish>} @private
[ "Gets", "a", "wish", "from", "the", "_wishes", "array", "by", "its", "ID" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L428-L445
train
kentcdodds/genie
src/index.js
reset
function reset() { const oldOptions = options() options({ wishes: [], noWishMerge: true, previousId: 0, enteredMagicWords: {}, context: _defaultContext, previousContext: _defaultContext, enabled: true, }) return oldOptions }
javascript
function reset() { const oldOptions = options() options({ wishes: [], noWishMerge: true, previousId: 0, enteredMagicWords: {}, context: _defaultContext, previousContext: _defaultContext, enabled: true, }) return oldOptions }
[ "function", "reset", "(", ")", "{", "const", "oldOptions", "=", "options", "(", ")", "options", "(", "{", "wishes", ":", "[", "]", ",", "noWishMerge", ":", "true", ",", "previousId", ":", "0", ",", "enteredMagicWords", ":", "{", "}", ",", "context", ...
Sets genie's options to the default options @returns {GenieOptions} Genie's old options @public
[ "Sets", "genie", "s", "options", "to", "the", "default", "options" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L452-L464
train
kentcdodds/genie
src/index.js
_getWishIdsInEnteredMagicWords
function _getWishIdsInEnteredMagicWords(word) { const startingCharWishesObj = _climbDownChain( _enteredMagicWords, word.split(''), ) if (startingCharWishesObj) { return _getPropFromPosterity(startingCharWishesObj, 'wishes', true) } else { return [] } }
javascript
function _getWishIdsInEnteredMagicWords(word) { const startingCharWishesObj = _climbDownChain( _enteredMagicWords, word.split(''), ) if (startingCharWishesObj) { return _getPropFromPosterity(startingCharWishesObj, 'wishes', true) } else { return [] } }
[ "function", "_getWishIdsInEnteredMagicWords", "(", "word", ")", "{", "const", "startingCharWishesObj", "=", "_climbDownChain", "(", "_enteredMagicWords", ",", "word", ".", "split", "(", "''", ")", ",", ")", "if", "(", "startingCharWishesObj", ")", "{", "return", ...
Climbs down the chain with the _enteredMagicWords object to find where the word ends and then gets the 'wish' property from the posterity at that point in the _enteredMagicWords object. @param {string} word @returns {Array.<wish>} @private
[ "Climbs", "down", "the", "chain", "with", "the", "_enteredMagicWords", "object", "to", "find", "where", "the", "word", "ends", "and", "then", "gets", "the", "wish", "property", "from", "the", "posterity", "at", "that", "point", "in", "the", "_enteredMagicWords...
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L499-L509
train
kentcdodds/genie
src/index.js
_filterInContextWishes
function _filterInContextWishes(wishes) { const inContextWishes = [] _each(wishes, wish => { if (wish && _wishInContext(wish)) { inContextWishes.push(wish) } }) return inContextWishes }
javascript
function _filterInContextWishes(wishes) { const inContextWishes = [] _each(wishes, wish => { if (wish && _wishInContext(wish)) { inContextWishes.push(wish) } }) return inContextWishes }
[ "function", "_filterInContextWishes", "(", "wishes", ")", "{", "const", "inContextWishes", "=", "[", "]", "_each", "(", "wishes", ",", "wish", "=>", "{", "if", "(", "wish", "&&", "_wishInContext", "(", "wish", ")", ")", "{", "inContextWishes", ".", "push",...
Returns a filtered array of the wishes which are in context. @param {Array.<wish>} wishes - the wishes to filter @returns {Array.<wish>} wishes - the wishes which are in context @private
[ "Returns", "a", "filtered", "array", "of", "the", "wishes", "which", "are", "in", "context", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L517-L525
train
kentcdodds/genie
src/index.js
_getPropFromPosterity
function _getPropFromPosterity(objToStartWith, prop, unique) { let values = [] function loadValues(obj) { if (obj[prop]) { const propsToAdd = _arrayify(obj[prop]) _each(propsToAdd, propToAdd => { if (!unique || !_contains(values, propToAdd)) { values.push(propToAdd) } ...
javascript
function _getPropFromPosterity(objToStartWith, prop, unique) { let values = [] function loadValues(obj) { if (obj[prop]) { const propsToAdd = _arrayify(obj[prop]) _each(propsToAdd, propToAdd => { if (!unique || !_contains(values, propToAdd)) { values.push(propToAdd) } ...
[ "function", "_getPropFromPosterity", "(", "objToStartWith", ",", "prop", ",", "unique", ")", "{", "let", "values", "=", "[", "]", "function", "loadValues", "(", "obj", ")", "{", "if", "(", "obj", "[", "prop", "]", ")", "{", "const", "propsToAdd", "=", ...
Iterates through all child properties of the given object and if it has the given property, it will add that property to the array that's returned at the end. @param {*} objToStartWith @param {string} prop @param {boolean} [unique=false] @returns {Array.<object>} @private @examples _getPropFromPosterity({a: {p: 1, b: {...
[ "Iterates", "through", "all", "child", "properties", "of", "the", "given", "object", "and", "if", "it", "has", "the", "given", "property", "it", "will", "add", "that", "property", "to", "the", "array", "that", "s", "returned", "at", "the", "end", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L568-L587
train
kentcdodds/genie
src/index.js
_sortWishesByMatchingPriority
function _sortWishesByMatchingPriority( wishes, currentMatchingWishIds, givenMagicWord, ) { const matchPriorityArrays = [] let returnedIds = [] _each( wishes, wish => { if (_wishInContext(wish)) { const matchPriority = _bestMagicWordsMatch( wish.magicWords, givenMa...
javascript
function _sortWishesByMatchingPriority( wishes, currentMatchingWishIds, givenMagicWord, ) { const matchPriorityArrays = [] let returnedIds = [] _each( wishes, wish => { if (_wishInContext(wish)) { const matchPriority = _bestMagicWordsMatch( wish.magicWords, givenMa...
[ "function", "_sortWishesByMatchingPriority", "(", "wishes", ",", "currentMatchingWishIds", ",", "givenMagicWord", ",", ")", "{", "const", "matchPriorityArrays", "=", "[", "]", "let", "returnedIds", "=", "[", "]", "_each", "(", "wishes", ",", "wish", "=>", "{", ...
A matchPriority for a wish @typedef {object} MatchPriority @property {number} matchType - based on _matchRankMap @property {number} magicWordIndex - the index of the magic word in the wish's array of magic words. Takes the given wishes and sorts them by how well they match the givenMagicWord. The wish must be in cont...
[ "A", "matchPriority", "for", "a", "wish" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L607-L648
train
kentcdodds/genie
src/index.js
_bestMagicWordsMatch
function _bestMagicWordsMatch(wishesMagicWords, givenMagicWord) { const bestMatch = { matchType: _matchRankMap.noMatch, magicWordIndex: -1, } _each(wishesMagicWords, (wishesMagicWord, index) => { const matchRank = _stringsMatch(wishesMagicWord, givenMagicWord) if (matchRank > bestMatch.matchType) ...
javascript
function _bestMagicWordsMatch(wishesMagicWords, givenMagicWord) { const bestMatch = { matchType: _matchRankMap.noMatch, magicWordIndex: -1, } _each(wishesMagicWords, (wishesMagicWord, index) => { const matchRank = _stringsMatch(wishesMagicWord, givenMagicWord) if (matchRank > bestMatch.matchType) ...
[ "function", "_bestMagicWordsMatch", "(", "wishesMagicWords", ",", "givenMagicWord", ")", "{", "const", "bestMatch", "=", "{", "matchType", ":", "_matchRankMap", ".", "noMatch", ",", "magicWordIndex", ":", "-", "1", ",", "}", "_each", "(", "wishesMagicWords", ","...
Gets the best magic words match of the wish's magic words @param {string|Array.<string>} wishesMagicWords @param {string} givenMagicWord @returns {MatchPriority} @private
[ "Gets", "the", "best", "magic", "words", "match", "of", "the", "wish", "s", "magic", "words" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L657-L671
train
kentcdodds/genie
src/index.js
_getAcronym
function _getAcronym(string) { let acronym = '' const wordsInString = string.split(' ') _each(wordsInString, wordInString => { const splitByHyphenWords = wordInString.split('-') _each(splitByHyphenWords, splitByHyphenWord => { acronym += splitByHyphenWord.substr(0, 1) }) }) return acronym }
javascript
function _getAcronym(string) { let acronym = '' const wordsInString = string.split(' ') _each(wordsInString, wordInString => { const splitByHyphenWords = wordInString.split('-') _each(splitByHyphenWords, splitByHyphenWord => { acronym += splitByHyphenWord.substr(0, 1) }) }) return acronym }
[ "function", "_getAcronym", "(", "string", ")", "{", "let", "acronym", "=", "''", "const", "wordsInString", "=", "string", ".", "split", "(", "' '", ")", "_each", "(", "wordsInString", ",", "wordInString", "=>", "{", "const", "splitByHyphenWords", "=", "wordI...
Generates an acronym for a string. @param {string} string @returns {string} @private @examples _getAcronym('i love candy') // => 'ilc' _getAcronym('water-fall in the spring-time') // => 'wfitst'
[ "Generates", "an", "acronym", "for", "a", "string", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L733-L743
train
kentcdodds/genie
src/index.js
_stringsByCharOrder
function _stringsByCharOrder(magicWord, givenMagicWord) { let charNumber = 0 function _findMatchingCharacter(matchChar, string) { let found = false for (let j = charNumber; j < string.length; j++) { const stringChar = string[j] if (stringChar === matchChar) { found = true charNu...
javascript
function _stringsByCharOrder(magicWord, givenMagicWord) { let charNumber = 0 function _findMatchingCharacter(matchChar, string) { let found = false for (let j = charNumber; j < string.length; j++) { const stringChar = string[j] if (stringChar === matchChar) { found = true charNu...
[ "function", "_stringsByCharOrder", "(", "magicWord", ",", "givenMagicWord", ")", "{", "let", "charNumber", "=", "0", "function", "_findMatchingCharacter", "(", "matchChar", ",", "string", ")", "{", "let", "found", "=", "false", "for", "(", "let", "j", "=", "...
Returns a _matchRankMap.matches or noMatch score based on whether the characters in the givenMagicWord are found in order in the magicWord @param {string} magicWord @param {string} givenMagicWord @returns {number} @private
[ "Returns", "a", "_matchRankMap", ".", "matches", "or", "noMatch", "score", "based", "on", "whether", "the", "characters", "in", "the", "givenMagicWord", "are", "found", "in", "order", "in", "the", "magicWord" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L754-L778
train
kentcdodds/genie
src/index.js
_maybeAddWishToMatchPriorityArray
function _maybeAddWishToMatchPriorityArray( wish, matchPriority, matchPriorityArrays, currentMatchingWishIds, ) { const indexOfWishInCurrent = currentMatchingWishIds.indexOf(wish.id) if (matchPriority.matchType !== _matchRankMap.noMatch) { if (indexOfWishInCurrent === -1) { _getMatchPriorityArray(...
javascript
function _maybeAddWishToMatchPriorityArray( wish, matchPriority, matchPriorityArrays, currentMatchingWishIds, ) { const indexOfWishInCurrent = currentMatchingWishIds.indexOf(wish.id) if (matchPriority.matchType !== _matchRankMap.noMatch) { if (indexOfWishInCurrent === -1) { _getMatchPriorityArray(...
[ "function", "_maybeAddWishToMatchPriorityArray", "(", "wish", ",", "matchPriority", ",", "matchPriorityArrays", ",", "currentMatchingWishIds", ",", ")", "{", "const", "indexOfWishInCurrent", "=", "currentMatchingWishIds", ".", "indexOf", "(", "wish", ".", "id", ")", "...
If the wish has a matchType which is not equal to the _matchRankMap.noMatch and it is not contained in the currentMatchingWishIds, then it is added to the matchPriorityArrays based on the matchPriority. @param {wish} wish @param {MatchPriority} matchPriority @param {Array.<Array>} matchPriorityArrays @param {wishIds} c...
[ "If", "the", "wish", "has", "a", "matchType", "which", "is", "not", "equal", "to", "the", "_matchRankMap", ".", "noMatch", "and", "it", "is", "not", "contained", "in", "the", "currentMatchingWishIds", "then", "it", "is", "added", "to", "the", "matchPriorityA...
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L790-L805
train
kentcdodds/genie
src/index.js
_getMatchPriorityArray
function _getMatchPriorityArray(arry, matchPriority) { arry[matchPriority.matchType] = arry[matchPriority.matchType] || [] const matchTypeArray = arry[matchPriority.matchType] const matchPriorityArray = (matchTypeArray[matchPriority.magicWordIndex] = matchTypeArray[matchPriority.magicWordIndex] || []) retur...
javascript
function _getMatchPriorityArray(arry, matchPriority) { arry[matchPriority.matchType] = arry[matchPriority.matchType] || [] const matchTypeArray = arry[matchPriority.matchType] const matchPriorityArray = (matchTypeArray[matchPriority.magicWordIndex] = matchTypeArray[matchPriority.magicWordIndex] || []) retur...
[ "function", "_getMatchPriorityArray", "(", "arry", ",", "matchPriority", ")", "{", "arry", "[", "matchPriority", ".", "matchType", "]", "=", "arry", "[", "matchPriority", ".", "matchType", "]", "||", "[", "]", "const", "matchTypeArray", "=", "arry", "[", "ma...
Creates a spot in the given array for the matchPriority @param {Array.<Array>} arry @param {MatchPriority} matchPriority @returns {Array.<string>} @private
[ "Creates", "a", "spot", "in", "the", "given", "array", "for", "the", "matchPriority" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L814-L820
train
kentcdodds/genie
src/index.js
_convertToWishObjectFromNullOrId
function _convertToWishObjectFromNullOrId(wish, magicWord) { let wishObject = wish // Check if it may be a wish object if (!_isObject(wishObject)) { wishObject = getWish(wish) } if (_isNullOrUndefined(wishObject)) { const matchingWishes = getMatchingWishes(magicWord) if (matchingWishes.length > 0)...
javascript
function _convertToWishObjectFromNullOrId(wish, magicWord) { let wishObject = wish // Check if it may be a wish object if (!_isObject(wishObject)) { wishObject = getWish(wish) } if (_isNullOrUndefined(wishObject)) { const matchingWishes = getMatchingWishes(magicWord) if (matchingWishes.length > 0)...
[ "function", "_convertToWishObjectFromNullOrId", "(", "wish", ",", "magicWord", ")", "{", "let", "wishObject", "=", "wish", "// Check if it may be a wish object", "if", "(", "!", "_isObject", "(", "wishObject", ")", ")", "{", "wishObject", "=", "getWish", "(", "wis...
Convert the given wish argument to a valid wish object. It could be an ID, or null. @param {wish|string} [wish] An id, wish object, or null. @param {string} magicWord Used if wish is null to lookup the nearest matching wish to be used. @returns {wish} The wish object @private
[ "Convert", "the", "given", "wish", "argument", "to", "a", "valid", "wish", "object", ".", "It", "could", "be", "an", "ID", "or", "null", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L860-L873
train
kentcdodds/genie
src/index.js
_executeWish
function _executeWish(wish, magicWord) { wish.action(wish, magicWord) const timesMade = wish.data.timesMade timesMade.total++ timesMade.magicWords[magicWord] = timesMade.magicWords[magicWord] || 0 timesMade.magicWords[magicWord]++ }
javascript
function _executeWish(wish, magicWord) { wish.action(wish, magicWord) const timesMade = wish.data.timesMade timesMade.total++ timesMade.magicWords[magicWord] = timesMade.magicWords[magicWord] || 0 timesMade.magicWords[magicWord]++ }
[ "function", "_executeWish", "(", "wish", ",", "magicWord", ")", "{", "wish", ".", "action", "(", "wish", ",", "magicWord", ")", "const", "timesMade", "=", "wish", ".", "data", ".", "timesMade", "timesMade", ".", "total", "++", "timesMade", ".", "magicWords...
Calls the wish's action with the wish and magic word as the parameters and iterates the timesMade properties. @param {wish} wish @param {string} magicWord @private
[ "Calls", "the", "wish", "s", "action", "with", "the", "wish", "and", "magic", "word", "as", "the", "parameters", "and", "iterates", "the", "timesMade", "properties", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L902-L908
train
kentcdodds/genie
src/index.js
_contextIsDefault
function _contextIsDefault(context) { if (!_isObject(context)) { context = _arrayify(context) } if (_isArray(context) && context.length === 1) { return context[0] === _defaultContext[0] } else if (context.any && context.any.length === 1) { return context.any[0] === _defaultContext[0] } else { ...
javascript
function _contextIsDefault(context) { if (!_isObject(context)) { context = _arrayify(context) } if (_isArray(context) && context.length === 1) { return context[0] === _defaultContext[0] } else if (context.any && context.any.length === 1) { return context.any[0] === _defaultContext[0] } else { ...
[ "function", "_contextIsDefault", "(", "context", ")", "{", "if", "(", "!", "_isObject", "(", "context", ")", ")", "{", "context", "=", "_arrayify", "(", "context", ")", "}", "if", "(", "_isArray", "(", "context", ")", "&&", "context", ".", "length", "=...
Returns true if the given context is the default context. @param {string|Array.<string>|context} context @returns {boolean} contextIsDefault @private @examples _contextIsDefault(_defaultContext[0]) // => true _contextIsDefault(_defaultContext) // => true _contextIsDefault(_defaultContext.concat(['1', '2', '3'])) // => ...
[ "Returns", "true", "if", "the", "given", "context", "is", "the", "default", "context", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L921-L932
train
kentcdodds/genie
src/index.js
_createSpotInEnteredMagicWords
function _createSpotInEnteredMagicWords(spot, chars) { const firstChar = chars.substring(0, 1) const remainingChars = chars.substring(1) const nextSpot = (spot[firstChar] = spot[firstChar] || {}) if (remainingChars) { return _createSpotInEnteredMagicWords(nextSpot, remainingChars) } else { return next...
javascript
function _createSpotInEnteredMagicWords(spot, chars) { const firstChar = chars.substring(0, 1) const remainingChars = chars.substring(1) const nextSpot = (spot[firstChar] = spot[firstChar] || {}) if (remainingChars) { return _createSpotInEnteredMagicWords(nextSpot, remainingChars) } else { return next...
[ "function", "_createSpotInEnteredMagicWords", "(", "spot", ",", "chars", ")", "{", "const", "firstChar", "=", "chars", ".", "substring", "(", "0", ",", "1", ")", "const", "remainingChars", "=", "chars", ".", "substring", "(", "1", ")", "const", "nextSpot", ...
Recursively creates a new object property if one does not exist for each character in the chars string. @param {object} spot @param {string} chars @returns {object} - the final object. @private
[ "Recursively", "creates", "a", "new", "object", "property", "if", "one", "does", "not", "exist", "for", "each", "character", "in", "the", "chars", "string", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1026-L1035
train
kentcdodds/genie
src/index.js
_getContextsFromPath
function _getContextsFromPath(path) { const allContexts = { add: [], remove: [], } _each(_pathContexts, pathContext => { let contextAdded = false const contexts = pathContext.contexts const regexes = pathContext.regexes const paths = pathContext.paths _each(regexes, regex => { r...
javascript
function _getContextsFromPath(path) { const allContexts = { add: [], remove: [], } _each(_pathContexts, pathContext => { let contextAdded = false const contexts = pathContext.contexts const regexes = pathContext.regexes const paths = pathContext.paths _each(regexes, regex => { r...
[ "function", "_getContextsFromPath", "(", "path", ")", "{", "const", "allContexts", "=", "{", "add", ":", "[", "]", ",", "remove", ":", "[", "]", ",", "}", "_each", "(", "_pathContexts", ",", "pathContext", "=>", "{", "let", "contextAdded", "=", "false", ...
Gets the context paths that should be added based on the given path and the context paths that should be removed based ont he given path @param {string} path @returns {{add: Array, remove: Array}} @private
[ "Gets", "the", "context", "paths", "that", "should", "be", "added", "based", "on", "the", "given", "path", "and", "the", "context", "paths", "that", "should", "be", "removed", "based", "ont", "he", "given", "path" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1072-L1117
train
kentcdodds/genie
src/index.js
_getContextsMatchingRegexPathContexts
function _getContextsMatchingRegexPathContexts() { const regexContexts = [] _each(_pathContexts, pathContext => { const contexts = pathContext.contexts _each(contexts, context => { if (_contextRegex.test(context)) { // context string is a regex context const replaceContextRegex = cont...
javascript
function _getContextsMatchingRegexPathContexts() { const regexContexts = [] _each(_pathContexts, pathContext => { const contexts = pathContext.contexts _each(contexts, context => { if (_contextRegex.test(context)) { // context string is a regex context const replaceContextRegex = cont...
[ "function", "_getContextsMatchingRegexPathContexts", "(", ")", "{", "const", "regexContexts", "=", "[", "]", "_each", "(", "_pathContexts", ",", "pathContext", "=>", "{", "const", "contexts", "=", "pathContext", ".", "contexts", "_each", "(", "contexts", ",", "c...
Gets all the pathContext.contexts that are regex contexts and matches those to genie's contexts. Returns all the matching contexts. @returns {Array} @private
[ "Gets", "all", "the", "pathContext", ".", "contexts", "that", "are", "regex", "contexts", "and", "matches", "those", "to", "genie", "s", "contexts", ".", "Returns", "all", "the", "matching", "contexts", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1125-L1144
train
kentcdodds/genie
src/index.js
_addUniqueItems
function _addUniqueItems(arry, obj) { obj = _arrayify(obj) arry = _arrayify(arry) _each(obj, o => { if (arry.indexOf(o) < 0) { arry.push(o) } }) return arry }
javascript
function _addUniqueItems(arry, obj) { obj = _arrayify(obj) arry = _arrayify(arry) _each(obj, o => { if (arry.indexOf(o) < 0) { arry.push(o) } }) return arry }
[ "function", "_addUniqueItems", "(", "arry", ",", "obj", ")", "{", "obj", "=", "_arrayify", "(", "obj", ")", "arry", "=", "_arrayify", "(", "arry", ")", "_each", "(", "obj", ",", "o", "=>", "{", "if", "(", "arry", ".", "indexOf", "(", "o", ")", "<...
Adds items to the arry from the obj only if it is not in the arry already @param {Array.<*>} arry @param {*|Array.<*>} obj @returns {Array.<*>} arry @private @examples _addUniqueItems(1, 2) // => [1,2] _addUniqueItems(1, [2,3]) // => [1,2,3] _addUniqueItems([1,2], 3) // => [1,2,3] _addUniqueItems([1,2], [3,4]) // => [1...
[ "Adds", "items", "to", "the", "arry", "from", "the", "obj", "only", "if", "it", "is", "not", "in", "the", "arry", "already" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1185-L1194
train
kentcdodds/genie
src/index.js
_removeItems
function _removeItems(arry, obj) { arry = _arrayify(arry) obj = _arrayify(obj) let i = 0 while (i < arry.length) { if (_contains(obj, arry[i])) { arry.splice(i, 1) } else { i++ } } return arry }
javascript
function _removeItems(arry, obj) { arry = _arrayify(arry) obj = _arrayify(obj) let i = 0 while (i < arry.length) { if (_contains(obj, arry[i])) { arry.splice(i, 1) } else { i++ } } return arry }
[ "function", "_removeItems", "(", "arry", ",", "obj", ")", "{", "arry", "=", "_arrayify", "(", "arry", ")", "obj", "=", "_arrayify", "(", "obj", ")", "let", "i", "=", "0", "while", "(", "i", "<", "arry", ".", "length", ")", "{", "if", "(", "_conta...
Removes all instances of items in the given obj from the given arry. @param {Array.<*>} arry @param {*|Array.<*>} obj @returns {Array.<*>} arry @private @examples _removeItems(1, 2) // => [1] _removeItems(1, [2,3]) // => [1] _removeItems([1,2], 3) // => [1,2] _removeItems([1,2], [3,4]) // => [1,2] _removeItems([1,2], [...
[ "Removes", "all", "instances", "of", "items", "in", "the", "given", "obj", "from", "the", "given", "arry", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1212-L1225
train
kentcdodds/genie
src/index.js
_arrayContainsNone
function _arrayContainsNone(arry1, arry2) { arry1 = _arrayify(arry1) arry2 = _arrayify(arry2) for (let i = 0; i < arry2.length; i++) { if (_contains(arry1, arry2[i])) { return false } } return true }
javascript
function _arrayContainsNone(arry1, arry2) { arry1 = _arrayify(arry1) arry2 = _arrayify(arry2) for (let i = 0; i < arry2.length; i++) { if (_contains(arry1, arry2[i])) { return false } } return true }
[ "function", "_arrayContainsNone", "(", "arry1", ",", "arry2", ")", "{", "arry1", "=", "_arrayify", "(", "arry1", ")", "arry2", "=", "_arrayify", "(", "arry2", ")", "for", "(", "let", "i", "=", "0", ";", "i", "<", "arry2", ".", "length", ";", "i", "...
Returns true if arry1 does not contain any of arry2's elements @param {*|Array.<*>} arry1 @param {*|Array.<*>} arry2 @returns {boolean} @private
[ "Returns", "true", "if", "arry1", "does", "not", "contain", "any", "of", "arry2", "s", "elements" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1258-L1267
train
kentcdodds/genie
src/index.js
_isEmpty
function _isEmpty(obj) { if (_isNullOrUndefined(obj)) { return true } else if (_isArray(obj)) { return obj.length === 0 } else if (_isString(obj)) { return obj === '' } else if (_isPrimitive(obj)) { return false } else if (_isObject(obj)) { return Object.keys(obj).length < 1 } else { ...
javascript
function _isEmpty(obj) { if (_isNullOrUndefined(obj)) { return true } else if (_isArray(obj)) { return obj.length === 0 } else if (_isString(obj)) { return obj === '' } else if (_isPrimitive(obj)) { return false } else if (_isObject(obj)) { return Object.keys(obj).length < 1 } else { ...
[ "function", "_isEmpty", "(", "obj", ")", "{", "if", "(", "_isNullOrUndefined", "(", "obj", ")", ")", "{", "return", "true", "}", "else", "if", "(", "_isArray", "(", "obj", ")", ")", "{", "return", "obj", ".", "length", "===", "0", "}", "else", "if"...
Whether the given object is empty. @param obj @returns {boolean} @private @examples _isEmpty() // => true _isEmpty(null) // => true _isEmpty(undefined) // => true _isEmpty('') // => true _isEmpty({}) // => true _isEmpty([]) // => true _isEmpty(1) // => false _isEmpty('a') // => false _isEmpty(['a', 'b']) // => false _i...
[ "Whether", "the", "given", "object", "is", "empty", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1315-L1329
train
kentcdodds/genie
src/index.js
_eachArrayReverse
function _eachArrayReverse(arry, fn) { let ret = true for (let i = arry.length - 1; i >= 0; i--) { ret = fn(arry[i], i, arry) if (ret === false) { break } } return ret }
javascript
function _eachArrayReverse(arry, fn) { let ret = true for (let i = arry.length - 1; i >= 0; i--) { ret = fn(arry[i], i, arry) if (ret === false) { break } } return ret }
[ "function", "_eachArrayReverse", "(", "arry", ",", "fn", ")", "{", "let", "ret", "=", "true", "for", "(", "let", "i", "=", "arry", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "ret", "=", "fn", "(", "arry", "[", "i"...
Iterates through the array and calls the given function in reverse order. @param {Array.<*>} arry @param {eachCallback} fn @returns {boolean} - whether the loop broke early @private
[ "Iterates", "through", "the", "array", "and", "calls", "the", "given", "function", "in", "reverse", "order", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1389-L1398
train
kentcdodds/genie
src/index.js
_eachArrayForward
function _eachArrayForward(arry, fn) { let ret = true for (let i = 0; i < arry.length; i++) { ret = fn(arry[i], i, arry) if (ret === false) { break } } return ret }
javascript
function _eachArrayForward(arry, fn) { let ret = true for (let i = 0; i < arry.length; i++) { ret = fn(arry[i], i, arry) if (ret === false) { break } } return ret }
[ "function", "_eachArrayForward", "(", "arry", ",", "fn", ")", "{", "let", "ret", "=", "true", "for", "(", "let", "i", "=", "0", ";", "i", "<", "arry", ".", "length", ";", "i", "++", ")", "{", "ret", "=", "fn", "(", "arry", "[", "i", "]", ",",...
Iterates through the array and calls the given function @param {Array.<*>} arry @param {Function} fn @returns {boolean} - whether the loop broke early @private
[ "Iterates", "through", "the", "array", "and", "calls", "the", "given", "function" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1407-L1416
train
kentcdodds/genie
src/index.js
_eachProperty
function _eachProperty(obj, fn) { let ret = true for (const prop in obj) { if (obj.hasOwnProperty(prop)) { ret = fn(obj[prop], prop, obj) if (ret === false) { break } } } return ret }
javascript
function _eachProperty(obj, fn) { let ret = true for (const prop in obj) { if (obj.hasOwnProperty(prop)) { ret = fn(obj[prop], prop, obj) if (ret === false) { break } } } return ret }
[ "function", "_eachProperty", "(", "obj", ",", "fn", ")", "{", "let", "ret", "=", "true", "for", "(", "const", "prop", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "prop", ")", ")", "{", "ret", "=", "fn", "(", "obj", "[", ...
Iterates through each property and calls the callback if the object hasOwnProperty. @param {object} obj @param {Function} fn @returns {boolean} @private
[ "Iterates", "through", "each", "property", "and", "calls", "the", "callback", "if", "the", "object", "hasOwnProperty", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1426-L1437
train
kentcdodds/genie
src/index.js
_updateWishesWithOptions
function _updateWishesWithOptions(opts) { if (opts.wishes) { if (opts.noWishMerge) { _wishes = opts.wishes } else { mergeWishes(opts.wishes) } } }
javascript
function _updateWishesWithOptions(opts) { if (opts.wishes) { if (opts.noWishMerge) { _wishes = opts.wishes } else { mergeWishes(opts.wishes) } } }
[ "function", "_updateWishesWithOptions", "(", "opts", ")", "{", "if", "(", "opts", ".", "wishes", ")", "{", "if", "(", "opts", ".", "noWishMerge", ")", "{", "_wishes", "=", "opts", ".", "wishes", "}", "else", "{", "mergeWishes", "(", "opts", ".", "wishe...
If wishes are present, will update them based on options given. @param {object} opts @private
[ "If", "wishes", "are", "present", "will", "update", "them", "based", "on", "options", "given", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1658-L1666
train
kentcdodds/genie
src/index.js
context
function context(newContext) { if (!_isUndefined(newContext)) { _previousContext = _context if (!_isArray(newContext)) { newContext = [newContext] } _context = newContext } return _context }
javascript
function context(newContext) { if (!_isUndefined(newContext)) { _previousContext = _context if (!_isArray(newContext)) { newContext = [newContext] } _context = newContext } return _context }
[ "function", "context", "(", "newContext", ")", "{", "if", "(", "!", "_isUndefined", "(", "newContext", ")", ")", "{", "_previousContext", "=", "_context", "if", "(", "!", "_isArray", "(", "newContext", ")", ")", "{", "newContext", "=", "[", "newContext", ...
Set's then returns genie's current context. If no context is provided, simply acts as getter. If a context is provided, genie's previous context is set to the context before it is assigned to the given context. @param {string|Array.<string>} newContext The context to set genie's context to. @returns {Array.<string>} Th...
[ "Set", "s", "then", "returns", "genie", "s", "current", "context", ".", "If", "no", "context", "is", "provided", "simply", "acts", "as", "getter", ".", "If", "a", "context", "is", "provided", "genie", "s", "previous", "context", "is", "set", "to", "the",...
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1711-L1720
train
kentcdodds/genie
src/index.js
addContext
function addContext(newContext) { if (newContext && newContext.length) { _previousContext = _context _addUniqueItems(_context, newContext) } return _context }
javascript
function addContext(newContext) { if (newContext && newContext.length) { _previousContext = _context _addUniqueItems(_context, newContext) } return _context }
[ "function", "addContext", "(", "newContext", ")", "{", "if", "(", "newContext", "&&", "newContext", ".", "length", ")", "{", "_previousContext", "=", "_context", "_addUniqueItems", "(", "_context", ",", "newContext", ")", "}", "return", "_context", "}" ]
Adds the new context to genie's current context. Genie's context will maintain uniqueness, so don't worry about overloading genie's context with duplicates. @param {string|Array.<string>} newContext The context to add @returns {Array} Genie's new context @public
[ "Adds", "the", "new", "context", "to", "genie", "s", "current", "context", ".", "Genie", "s", "context", "will", "maintain", "uniqueness", "so", "don", "t", "worry", "about", "overloading", "genie", "s", "context", "with", "duplicates", "." ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1731-L1737
train
kentcdodds/genie
src/index.js
removeContext
function removeContext(contextToRemove) { if (contextToRemove && contextToRemove.length) { _previousContext = _context _removeItems(_context, contextToRemove) if (_isEmpty(context)) { _context = _defaultContext } } return _context }
javascript
function removeContext(contextToRemove) { if (contextToRemove && contextToRemove.length) { _previousContext = _context _removeItems(_context, contextToRemove) if (_isEmpty(context)) { _context = _defaultContext } } return _context }
[ "function", "removeContext", "(", "contextToRemove", ")", "{", "if", "(", "contextToRemove", "&&", "contextToRemove", ".", "length", ")", "{", "_previousContext", "=", "_context", "_removeItems", "(", "_context", ",", "contextToRemove", ")", "if", "(", "_isEmpty",...
Removes the given context @param {string|Array.<string>} contextToRemove The context to remove @returns {Array.<string>} Genie's new context @public
[ "Removes", "the", "given", "context" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1745-L1754
train
kentcdodds/genie
src/index.js
updatePathContext
function updatePathContext(path, noDeregister) { if (path) { const allContexts = _getContextsFromPath(path) const contextsToAdd = allContexts.add let contextsToRemove = _getContextsMatchingRegexPathContexts() contextsToRemove = contextsToRemove.concat(allContexts.remove) removeContext(contextsToR...
javascript
function updatePathContext(path, noDeregister) { if (path) { const allContexts = _getContextsFromPath(path) const contextsToAdd = allContexts.add let contextsToRemove = _getContextsMatchingRegexPathContexts() contextsToRemove = contextsToRemove.concat(allContexts.remove) removeContext(contextsToR...
[ "function", "updatePathContext", "(", "path", ",", "noDeregister", ")", "{", "if", "(", "path", ")", "{", "const", "allContexts", "=", "_getContextsFromPath", "(", "path", ")", "const", "contextsToAdd", "=", "allContexts", ".", "add", "let", "contextsToRemove", ...
Updates genie's context based on the given path @param {string} path the path to match @param {boolean} [noDeregister] Do not deregister wishes which are no longer in context @returns {Array.<string>} The new context @public
[ "Updates", "genie", "s", "context", "based", "on", "the", "given", "path" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1782-L1800
train
kentcdodds/genie
src/index.js
addPathContext
function addPathContext(pathContexts) { _each(pathContexts, pathContext => { if (pathContext.paths) { pathContext.paths = _arrayify(pathContext.paths) } if (pathContext.regexes) { pathContext.regexes = _arrayify(pathContext.regexes) } if (pathContext.contexts) { pathContext.con...
javascript
function addPathContext(pathContexts) { _each(pathContexts, pathContext => { if (pathContext.paths) { pathContext.paths = _arrayify(pathContext.paths) } if (pathContext.regexes) { pathContext.regexes = _arrayify(pathContext.regexes) } if (pathContext.contexts) { pathContext.con...
[ "function", "addPathContext", "(", "pathContexts", ")", "{", "_each", "(", "pathContexts", ",", "pathContext", "=>", "{", "if", "(", "pathContext", ".", "paths", ")", "{", "pathContext", ".", "paths", "=", "_arrayify", "(", "pathContext", ".", "paths", ")", ...
Add a path context to genie's pathContexts @param {Array.<PathContext>} pathContexts The path context to add @returns {Array.<PathContext>} The new path contexts @public
[ "Add", "a", "path", "context", "to", "genie", "s", "pathContexts" ]
9b868ea9dd41f4ce931abc7e37b3467a356443cf
https://github.com/kentcdodds/genie/blob/9b868ea9dd41f4ce931abc7e37b3467a356443cf/src/index.js#L1808-L1824
train
apigee-127/swagger-test-templates
index.js
setPathParamsFromArray
function setPathParamsFromArray(data, config, idx) { // only write parameters if they are not already defined in config if (data.requestData === undefined || config.pathParams) { return data; } // if we have requestData, fill the path params accordingly var mockParameters = {}; data.pathParameters.forE...
javascript
function setPathParamsFromArray(data, config, idx) { // only write parameters if they are not already defined in config if (data.requestData === undefined || config.pathParams) { return data; } // if we have requestData, fill the path params accordingly var mockParameters = {}; data.pathParameters.forE...
[ "function", "setPathParamsFromArray", "(", "data", ",", "config", ",", "idx", ")", "{", "// only write parameters if they are not already defined in config", "if", "(", "data", ".", "requestData", "===", "undefined", "||", "config", ".", "pathParams", ")", "{", "retur...
Populate path params from request data array @private @param {json} data Generated Data @param {json} config configuration for testGen @param {int} idx Index of request for response @returns {json} return all the properties information
[ "Populate", "path", "params", "from", "request", "data", "array" ]
3851930b9cc3ff946915990271ebcc7b7f29a32a
https://github.com/apigee-127/swagger-test-templates/blob/3851930b9cc3ff946915990271ebcc7b7f29a32a/index.js#L234-L250
train
apigee-127/swagger-test-templates
index.js
filterOutOptionalQueryParams
function filterOutOptionalQueryParams(data) { data.queryParameters = data.queryParameters.filter(function(queryParam) { // Let's be conservative and treat params without explicit required field as not-optional var optional = queryParam.required !== undefined && !queryParam.required; var dataProvided = dat...
javascript
function filterOutOptionalQueryParams(data) { data.queryParameters = data.queryParameters.filter(function(queryParam) { // Let's be conservative and treat params without explicit required field as not-optional var optional = queryParam.required !== undefined && !queryParam.required; var dataProvided = dat...
[ "function", "filterOutOptionalQueryParams", "(", "data", ")", "{", "data", ".", "queryParameters", "=", "data", ".", "queryParameters", ".", "filter", "(", "function", "(", "queryParam", ")", "{", "// Let's be conservative and treat params without explicit required field as...
Filter out optional query parameters with no value provided in request data @private @param {json} data Generated Data @returns {json} return all the properties information
[ "Filter", "out", "optional", "query", "parameters", "with", "no", "value", "provided", "in", "request", "data" ]
3851930b9cc3ff946915990271ebcc7b7f29a32a
https://github.com/apigee-127/swagger-test-templates/blob/3851930b9cc3ff946915990271ebcc7b7f29a32a/index.js#L258-L267
train
apigee-127/swagger-test-templates
lib/helpers.js
validateResponse
function validateResponse(type, noSchema, options) { if (arguments.length < 3) { throw new Error('Handlebars Helper \'validateResponse\'' + 'needs 2 parameters'); } if (!noSchema && mediaTypeContainsJson(type)) { return options.fn(this); } else { return options.inverse(this); } }
javascript
function validateResponse(type, noSchema, options) { if (arguments.length < 3) { throw new Error('Handlebars Helper \'validateResponse\'' + 'needs 2 parameters'); } if (!noSchema && mediaTypeContainsJson(type)) { return options.fn(this); } else { return options.inverse(this); } }
[ "function", "validateResponse", "(", "type", ",", "noSchema", ",", "options", ")", "{", "if", "(", "arguments", ".", "length", "<", "3", ")", "{", "throw", "new", "Error", "(", "'Handlebars Helper \\'validateResponse\\''", "+", "'needs 2 parameters'", ")", ";", ...
determines if content types are able to be validated @param {string} type content type to be evaluated @param {boolean} noSchema whether or not there is a defined schema @param {Object} options handlebars built-in options @returns {boolean} whether or not the content can be validated
[ "determines", "if", "content", "types", "are", "able", "to", "be", "validated" ]
3851930b9cc3ff946915990271ebcc7b7f29a32a
https://github.com/apigee-127/swagger-test-templates/blob/3851930b9cc3ff946915990271ebcc7b7f29a32a/lib/helpers.js#L62-L74
train
apigee-127/swagger-test-templates
lib/helpers.js
length
function length(description) { if (arguments.length < 2) { throw new Error('Handlebar Helper \'length\'' + ' needs 1 parameter'); } if ((typeof description) !== 'string') { throw new TypeError('Handlebars Helper \'length\'' + 'requires path to be a string'); } var desc = description; if ...
javascript
function length(description) { if (arguments.length < 2) { throw new Error('Handlebar Helper \'length\'' + ' needs 1 parameter'); } if ((typeof description) !== 'string') { throw new TypeError('Handlebars Helper \'length\'' + 'requires path to be a string'); } var desc = description; if ...
[ "function", "length", "(", "description", ")", "{", "if", "(", "arguments", ".", "length", "<", "2", ")", "{", "throw", "new", "Error", "(", "'Handlebar Helper \\'length\\''", "+", "' needs 1 parameter'", ")", ";", "}", "if", "(", "(", "typeof", "description...
split the long description into multiple lines @param {string} description request description to be splitted @returns {string} multiple lines
[ "split", "the", "long", "description", "into", "multiple", "lines" ]
3851930b9cc3ff946915990271ebcc7b7f29a32a
https://github.com/apigee-127/swagger-test-templates/blob/3851930b9cc3ff946915990271ebcc7b7f29a32a/lib/helpers.js#L177-L194
train
covenanttechnologysolutions/connectwise-rest
src/utils/Callback.js
verifyMessage
function verifyMessage(callbackBody, contentSignature, signingKey) { const hash = crypto.createHash('sha256').update(signingKey).digest(); const hmac = crypto.createHmac('sha256', hash); return contentSignature === hmac.update(JSON.stringify(callbackBody)).digest('base64'); }
javascript
function verifyMessage(callbackBody, contentSignature, signingKey) { const hash = crypto.createHash('sha256').update(signingKey).digest(); const hmac = crypto.createHmac('sha256', hash); return contentSignature === hmac.update(JSON.stringify(callbackBody)).digest('base64'); }
[ "function", "verifyMessage", "(", "callbackBody", ",", "contentSignature", ",", "signingKey", ")", "{", "const", "hash", "=", "crypto", ".", "createHash", "(", "'sha256'", ")", ".", "update", "(", "signingKey", ")", ".", "digest", "(", ")", ";", "const", "...
Validate a callback body against signed key @param {CallbackPayload} callbackBody @param {string} contentSignature @param {string} signingKey @returns {boolean}
[ "Validate", "a", "callback", "body", "against", "signed", "key" ]
311e4c78014643f325386f5f596f0ee744c36a3b
https://github.com/covenanttechnologysolutions/connectwise-rest/blob/311e4c78014643f325386f5f596f0ee744c36a3b/src/utils/Callback.js#L64-L69
train
freedomjs/freedom
demo/datachannels/chat.js
function (dispatchEvents, name) { this.dispatchEvent = dispatchEvents; this.name = name; this.connection = freedom['core.rtcpeerconnection'](); this.connection.on(function (type, msg) { if (type === 'onsignalingstatechange' || type === 'onnegotiationneeded' || type === 'oniceconnectionstatec...
javascript
function (dispatchEvents, name) { this.dispatchEvent = dispatchEvents; this.name = name; this.connection = freedom['core.rtcpeerconnection'](); this.connection.on(function (type, msg) { if (type === 'onsignalingstatechange' || type === 'onnegotiationneeded' || type === 'oniceconnectionstatec...
[ "function", "(", "dispatchEvents", ",", "name", ")", "{", "this", ".", "dispatchEvent", "=", "dispatchEvents", ";", "this", ".", "name", "=", "name", ";", "this", ".", "connection", "=", "freedom", "[", "'core.rtcpeerconnection'", "]", "(", ")", ";", "this...
This is the root module of the datachannel freedom.js demo. It runs in an isolated thread with its own namespace, peerconnection and datachannel objects are provided through freedom.
[ "This", "is", "the", "root", "module", "of", "the", "datachannel", "freedom", ".", "js", "demo", ".", "It", "runs", "in", "an", "isolated", "thread", "with", "its", "own", "namespace", "peerconnection", "and", "datachannel", "objects", "are", "provided", "th...
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/datachannels/chat.js#L11-L33
train
freedomjs/freedom
providers/core/core.peerconnection.js
PeerConnection
function PeerConnection(portModule, dispatchEvent, RTCPeerConnection, RTCSessionDescription, RTCIceCandidate) { // Channel for emitting events to consumer. this.dispatchEvent = dispatchEvent; // a (hopefully unique) ID for debugging. this.peerName = "p" + Math.ra...
javascript
function PeerConnection(portModule, dispatchEvent, RTCPeerConnection, RTCSessionDescription, RTCIceCandidate) { // Channel for emitting events to consumer. this.dispatchEvent = dispatchEvent; // a (hopefully unique) ID for debugging. this.peerName = "p" + Math.ra...
[ "function", "PeerConnection", "(", "portModule", ",", "dispatchEvent", ",", "RTCPeerConnection", ",", "RTCSessionDescription", ",", "RTCIceCandidate", ")", "{", "// Channel for emitting events to consumer.", "this", ".", "dispatchEvent", "=", "dispatchEvent", ";", "// a (ho...
_signallingChannel is a channel for emitting events back to the freedom Hub.
[ "_signallingChannel", "is", "a", "channel", "for", "emitting", "events", "back", "to", "the", "freedom", "Hub", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/providers/core/core.peerconnection.js#L336-L369
train
freedomjs/freedom
providers/core/core.peerconnection.js
function (dataChannel, info, event) { if (event.data instanceof ArrayBuffer) { self.dispatchEvent('onReceived', { 'channelLabel': info.label, 'buffer': event.data }); } else if (event.data instanceof Blob) { self.dispatchEvent('onReceived', { ...
javascript
function (dataChannel, info, event) { if (event.data instanceof ArrayBuffer) { self.dispatchEvent('onReceived', { 'channelLabel': info.label, 'buffer': event.data }); } else if (event.data instanceof Blob) { self.dispatchEvent('onReceived', { ...
[ "function", "(", "dataChannel", ",", "info", ",", "event", ")", "{", "if", "(", "event", ".", "data", "instanceof", "ArrayBuffer", ")", "{", "self", ".", "dispatchEvent", "(", "'onReceived'", ",", "{", "'channelLabel'", ":", "info", ".", "label", ",", "'...
Default on real message prints it to console.
[ "Default", "on", "real", "message", "prints", "it", "to", "console", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/providers/core/core.peerconnection.js#L399-L416
train
freedomjs/freedom
providers/core/core.peerconnection.js
function (dataChannel, info, err) { console.error(dataChannel.peerName + ": dataChannel(" + dataChannel.dataChannel.label + "): error: ", err); }
javascript
function (dataChannel, info, err) { console.error(dataChannel.peerName + ": dataChannel(" + dataChannel.dataChannel.label + "): error: ", err); }
[ "function", "(", "dataChannel", ",", "info", ",", "err", ")", "{", "console", ".", "error", "(", "dataChannel", ".", "peerName", "+", "\": dataChannel(\"", "+", "dataChannel", ".", "dataChannel", ".", "label", "+", "\"): error: \"", ",", "err", ")", ";", "...
Default on error, prints it.
[ "Default", "on", "error", "prints", "it", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/providers/core/core.peerconnection.js#L418-L421
train
freedomjs/freedom
providers/core/core.echo.js
function(cap, dispatchEvent) { this.mod = cap.module; this.dispatchEvent = dispatchEvent; util.handleEvents(this); // The Core object for managing channels. this.mod.once('core', function(Core) { this.core = new Core(); }.bind(this)); this.mod.emit(this.mod.controlChannel, { type: 'core request d...
javascript
function(cap, dispatchEvent) { this.mod = cap.module; this.dispatchEvent = dispatchEvent; util.handleEvents(this); // The Core object for managing channels. this.mod.once('core', function(Core) { this.core = new Core(); }.bind(this)); this.mod.emit(this.mod.controlChannel, { type: 'core request d...
[ "function", "(", "cap", ",", "dispatchEvent", ")", "{", "this", ".", "mod", "=", "cap", ".", "module", ";", "this", ".", "dispatchEvent", "=", "dispatchEvent", ";", "util", ".", "handleEvents", "(", "this", ")", ";", "// The Core object for managing channels."...
A minimal provider implementing the core.echo interface for interaction with custom channels. Primarily used for testing the robustness of the custom channel implementation. @Class Echo_unprivileged @constructor @param {module:Module} cap The module creating this provider.
[ "A", "minimal", "provider", "implementing", "the", "core", ".", "echo", "interface", "for", "interaction", "with", "custom", "channels", ".", "Primarily", "used", "for", "testing", "the", "robustness", "of", "the", "custom", "channel", "implementation", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/providers/core/core.echo.js#L13-L26
train
freedomjs/freedom
providers/core/core.console.js
function (cap) { this.level = (cap.config && cap.config.debug) || 'log'; this.console = (cap.config && cap.config.global.console); util.handleEvents(this); }
javascript
function (cap) { this.level = (cap.config && cap.config.debug) || 'log'; this.console = (cap.config && cap.config.global.console); util.handleEvents(this); }
[ "function", "(", "cap", ")", "{", "this", ".", "level", "=", "(", "cap", ".", "config", "&&", "cap", ".", "config", ".", "debug", ")", "||", "'log'", ";", "this", ".", "console", "=", "(", "cap", ".", "config", "&&", "cap", ".", "config", ".", ...
A freedom.js logging provider that logs to chrome, firefox, and node consoles. @Class Logger_console @constructor @private @param {config: Object} cap Capabilities - console requires global config.
[ "A", "freedom", ".", "js", "logging", "provider", "that", "logs", "to", "chrome", "firefox", "and", "node", "consoles", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/providers/core/core.console.js#L12-L16
train
freedomjs/freedom
src/module.js
function (manifestURL, manifest, creator, policy) { this.api = policy.api; this.policy = policy; this.resource = policy.resource; this.debug = policy.debug; this.config = {}; this.id = manifestURL + Math.random(); this.manifestId = manifestURL; this.manifest = manifest; this.lineage = [this.manifest...
javascript
function (manifestURL, manifest, creator, policy) { this.api = policy.api; this.policy = policy; this.resource = policy.resource; this.debug = policy.debug; this.config = {}; this.id = manifestURL + Math.random(); this.manifestId = manifestURL; this.manifest = manifest; this.lineage = [this.manifest...
[ "function", "(", "manifestURL", ",", "manifest", ",", "creator", ",", "policy", ")", "{", "this", ".", "api", "=", "policy", ".", "api", ";", "this", ".", "policy", "=", "policy", ";", "this", ".", "resource", "=", "policy", ".", "resource", ";", "th...
The external Port face of a module on a hub. @class Module @extends Port @param {String} manifestURL The manifest this module loads. @param {String[]} creator The lineage of creation for this module. @param {Policy} Policy The policy loader for dependencies. @constructor
[ "The", "external", "Port", "face", "of", "a", "module", "on", "a", "hub", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/module.js#L14-L42
train
freedomjs/freedom
src/moduleinternal.js
function (manager) { this.config = {}; this.manager = manager; this.debug = manager.debug; this.binder = new ProxyBinder(this.manager); this.api = this.manager.api; this.manifests = {}; this.providers = {}; this.id = 'ModuleInternal'; this.pendingPorts = 0; this.requests = {}; this.unboundPorts =...
javascript
function (manager) { this.config = {}; this.manager = manager; this.debug = manager.debug; this.binder = new ProxyBinder(this.manager); this.api = this.manager.api; this.manifests = {}; this.providers = {}; this.id = 'ModuleInternal'; this.pendingPorts = 0; this.requests = {}; this.unboundPorts =...
[ "function", "(", "manager", ")", "{", "this", ".", "config", "=", "{", "}", ";", "this", ".", "manager", "=", "manager", ";", "this", ".", "debug", "=", "manager", ".", "debug", ";", "this", ".", "binder", "=", "new", "ProxyBinder", "(", "this", "....
The internal logic for module setup, which makes sure the public facing exports have appropriate properties, and load user scripts. @class ModuleInternal @extends Port @param {Port} manager The manager in this module to use for routing setup. @constructor
[ "The", "internal", "logic", "for", "module", "setup", "which", "makes", "sure", "the", "public", "facing", "exports", "have", "appropriate", "properties", "and", "load", "user", "scripts", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/moduleinternal.js#L17-L32
train
freedomjs/freedom
src/resource.js
function (debug) { this.debug = debug; this.files = {}; this.resolvers = [this.httpResolver, this.nullResolver]; this.contentRetrievers = { 'http': this.xhrRetriever, 'https': this.xhrRetriever, 'chrome-extension': this.xhrRetriever, 'resource': this.xhrRetriever, 'chrome': this.xhrRetriever...
javascript
function (debug) { this.debug = debug; this.files = {}; this.resolvers = [this.httpResolver, this.nullResolver]; this.contentRetrievers = { 'http': this.xhrRetriever, 'https': this.xhrRetriever, 'chrome-extension': this.xhrRetriever, 'resource': this.xhrRetriever, 'chrome': this.xhrRetriever...
[ "function", "(", "debug", ")", "{", "this", ".", "debug", "=", "debug", ";", "this", ".", "files", "=", "{", "}", ";", "this", ".", "resolvers", "=", "[", "this", ".", "httpResolver", ",", "this", ".", "nullResolver", "]", ";", "this", ".", "conten...
The Resource registry for FreeDOM. Used to look up requested Resources, and provide lookup and migration of resources. @Class Resource @param {Debug} debug The logger to use for debugging. @constructor
[ "The", "Resource", "registry", "for", "FreeDOM", ".", "Used", "to", "look", "up", "requested", "Resources", "and", "provide", "lookup", "and", "migration", "of", "resources", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/resource.js#L14-L28
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
download
function download(cvs, data, callback) { var mime = data.mime || DEFAULT_MIME; root.location.href = cvs.toDataURL(mime).replace(mime, DOWNLOAD_MIME); if (typeof callback === 'function') callback(); }
javascript
function download(cvs, data, callback) { var mime = data.mime || DEFAULT_MIME; root.location.href = cvs.toDataURL(mime).replace(mime, DOWNLOAD_MIME); if (typeof callback === 'function') callback(); }
[ "function", "download", "(", "cvs", ",", "data", ",", "callback", ")", "{", "var", "mime", "=", "data", ".", "mime", "||", "DEFAULT_MIME", ";", "root", ".", "location", ".", "href", "=", "cvs", ".", "toDataURL", "(", "mime", ")", ".", "replace", "(",...
Force the canvas image to be downloaded in the browser. Optionally, a `callback` function can be specified which will be called upon completed. Since this is not an asynchronous operation, this is merely convenient and helps simplify the calling code.
[ "Force", "the", "canvas", "image", "to", "be", "downloaded", "in", "the", "browser", ".", "Optionally", "a", "callback", "function", "can", "be", "specified", "which", "will", "be", "called", "upon", "completed", ".", "Since", "this", "is", "not", "an", "a...
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L192-L198
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
overrideAPI
function overrideAPI(qr) { var methods = [ 'canvas', 'image', 'save', 'saveSync', 'toDataURL' ]; var i; function overrideMethod(name) { qr[name] = function () { throw new Error(name + ' requires HTML5 canvas element support'); }; } for (i = 0; i < methods.length; i++) { o...
javascript
function overrideAPI(qr) { var methods = [ 'canvas', 'image', 'save', 'saveSync', 'toDataURL' ]; var i; function overrideMethod(name) { qr[name] = function () { throw new Error(name + ' requires HTML5 canvas element support'); }; } for (i = 0; i < methods.length; i++) { o...
[ "function", "overrideAPI", "(", "qr", ")", "{", "var", "methods", "=", "[", "'canvas'", ",", "'image'", ",", "'save'", ",", "'saveSync'", ",", "'toDataURL'", "]", ";", "var", "i", ";", "function", "overrideMethod", "(", "name", ")", "{", "qr", "[", "na...
Override the `qr` API methods that require HTML5 canvas support to throw a relevant error.
[ "Override", "the", "qr", "API", "methods", "that", "require", "HTML5", "canvas", "support", "to", "throw", "a", "relevant", "error", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L207-L220
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
writeFile
function writeFile(cvs, data, callback) { if (typeof data.path !== 'string') { return callback(new TypeError('Invalid path type: ' + typeof data.path)); } var fd, buff; // Write the buffer to the open file stream once both prerequisites are met. function writeBuffer() { fs.write(fd, bu...
javascript
function writeFile(cvs, data, callback) { if (typeof data.path !== 'string') { return callback(new TypeError('Invalid path type: ' + typeof data.path)); } var fd, buff; // Write the buffer to the open file stream once both prerequisites are met. function writeBuffer() { fs.write(fd, bu...
[ "function", "writeFile", "(", "cvs", ",", "data", ",", "callback", ")", "{", "if", "(", "typeof", "data", ".", "path", "!==", "'string'", ")", "{", "return", "callback", "(", "new", "TypeError", "(", "'Invalid path type: '", "+", "typeof", "data", ".", "...
Asynchronously write the data of the rendered canvas to a given file path.
[ "Asynchronously", "write", "the", "data", "of", "the", "rendered", "canvas", "to", "a", "given", "file", "path", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L223-L258
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
writeBuffer
function writeBuffer() { fs.write(fd, buff, 0, buff.length, 0, function (error) { fs.close(fd); callback(error); }); }
javascript
function writeBuffer() { fs.write(fd, buff, 0, buff.length, 0, function (error) { fs.close(fd); callback(error); }); }
[ "function", "writeBuffer", "(", ")", "{", "fs", ".", "write", "(", "fd", ",", "buff", ",", "0", ",", "buff", ".", "length", ",", "0", ",", "function", "(", "error", ")", "{", "fs", ".", "close", "(", "fd", ")", ";", "callback", "(", "error", ")...
Write the buffer to the open file stream once both prerequisites are met.
[ "Write", "the", "buffer", "to", "the", "open", "file", "stream", "once", "both", "prerequisites", "are", "met", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L231-L237
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
writeFileSync
function writeFileSync(cvs, data) { if (typeof data.path !== 'string') { throw new TypeError('Invalid path type: ' + typeof data.path); } var buff = cvs.toBuffer(); var fd = fs.openSync(data.path, 'w', WRITE_MODE); try { fs.writeSync(fd, buff, 0, buff.length, 0); } catch (error) { ...
javascript
function writeFileSync(cvs, data) { if (typeof data.path !== 'string') { throw new TypeError('Invalid path type: ' + typeof data.path); } var buff = cvs.toBuffer(); var fd = fs.openSync(data.path, 'w', WRITE_MODE); try { fs.writeSync(fd, buff, 0, buff.length, 0); } catch (error) { ...
[ "function", "writeFileSync", "(", "cvs", ",", "data", ")", "{", "if", "(", "typeof", "data", ".", "path", "!==", "'string'", ")", "{", "throw", "new", "TypeError", "(", "'Invalid path type: '", "+", "typeof", "data", ".", "path", ")", ";", "}", "var", ...
Write the data of the rendered canvas to a given file path.
[ "Write", "the", "data", "of", "the", "rendered", "canvas", "to", "a", "given", "file", "path", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L261-L274
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
addAlignment
function addAlignment(x, y) { var i; frameBuffer[x + width * y] = 1; for (i = -2; i < 2; i++) { frameBuffer[(x + i) + width * (y - 2)] = 1; frameBuffer[(x - 2) + width * (y + i + 1)] = 1; frameBuffer[(x + 2) + width * (y + i)] = 1; frameBuffer[(x + i + 1) + widt...
javascript
function addAlignment(x, y) { var i; frameBuffer[x + width * y] = 1; for (i = -2; i < 2; i++) { frameBuffer[(x + i) + width * (y - 2)] = 1; frameBuffer[(x - 2) + width * (y + i + 1)] = 1; frameBuffer[(x + 2) + width * (y + i)] = 1; frameBuffer[(x + i + 1) + widt...
[ "function", "addAlignment", "(", "x", ",", "y", ")", "{", "var", "i", ";", "frameBuffer", "[", "x", "+", "width", "*", "y", "]", "=", "1", ";", "for", "(", "i", "=", "-", "2", ";", "i", "<", "2", ";", "i", "++", ")", "{", "frameBuffer", "["...
Enter alignment pattern. Foreground colour to frame, background to mask. Frame will be merged with mask later.
[ "Enter", "alignment", "pattern", ".", "Foreground", "colour", "to", "frame", "background", "to", "mask", ".", "Frame", "will", "be", "merged", "with", "mask", "later", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L297-L315
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
appendData
function appendData(data, dataLength, ecc, eccLength) { var bit, i, j; for (i = 0; i < eccLength; i++) { stringBuffer[ecc + i] = 0; } for (i = 0; i < dataLength; i++) { bit = GALOIS_LOG[stringBuffer[data + i] ^ stringBuffer[ecc]]; if (bit !== 255) { for (j = 1; j < eccLength...
javascript
function appendData(data, dataLength, ecc, eccLength) { var bit, i, j; for (i = 0; i < eccLength; i++) { stringBuffer[ecc + i] = 0; } for (i = 0; i < dataLength; i++) { bit = GALOIS_LOG[stringBuffer[data + i] ^ stringBuffer[ecc]]; if (bit !== 255) { for (j = 1; j < eccLength...
[ "function", "appendData", "(", "data", ",", "dataLength", ",", "ecc", ",", "eccLength", ")", "{", "var", "bit", ",", "i", ",", "j", ";", "for", "(", "i", "=", "0", ";", "i", "<", "eccLength", ";", "i", "++", ")", "{", "stringBuffer", "[", "ecc", ...
Calculate and append `ecc` data to the `data` block. If block is in the string buffer the indices to buffers are used.
[ "Calculate", "and", "append", "ecc", "data", "to", "the", "data", "block", ".", "If", "block", "is", "in", "the", "string", "buffer", "the", "indices", "to", "buffers", "are", "used", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L329-L353
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
isMasked
function isMasked(x, y) { var bit; if (x > y) { bit = x; x = y; y = bit; } bit = y; bit += y * y; bit >>= 1; bit += x; return frameMask[bit] === 1; }
javascript
function isMasked(x, y) { var bit; if (x > y) { bit = x; x = y; y = bit; } bit = y; bit += y * y; bit >>= 1; bit += x; return frameMask[bit] === 1; }
[ "function", "isMasked", "(", "x", ",", "y", ")", "{", "var", "bit", ";", "if", "(", "x", ">", "y", ")", "{", "bit", "=", "x", ";", "x", "=", "y", ";", "y", "=", "bit", ";", "}", "bit", "=", "y", ";", "bit", "+=", "y", "*", "y", ";", "...
Check mask since symmetricals use half.
[ "Check", "mask", "since", "symmetricals", "use", "half", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L356-L371
train
freedomjs/freedom
demo/connections/third-party/qr/qr.js
getBadRuns
function getBadRuns(length) { var badRuns = 0; var i; for (i = 0; i <= length; i++) { if (badBuffer[i] >= 5) { badRuns += N1 + badBuffer[i] - 5; } } // FBFFFBF as in finder. for (i = 3; i < length - 1; i += 2) { if (badBuffer[i - 2] === badBuffer[i + 2] && b...
javascript
function getBadRuns(length) { var badRuns = 0; var i; for (i = 0; i <= length; i++) { if (badBuffer[i] >= 5) { badRuns += N1 + badBuffer[i] - 5; } } // FBFFFBF as in finder. for (i = 3; i < length - 1; i += 2) { if (badBuffer[i - 2] === badBuffer[i + 2] && b...
[ "function", "getBadRuns", "(", "length", ")", "{", "var", "badRuns", "=", "0", ";", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<=", "length", ";", "i", "++", ")", "{", "if", "(", "badBuffer", "[", "i", "]", ">=", "5", ")", "{", ...
Using the table for the length of each run, calculate the amount of bad image. Long runs or those that look like finders are called twice; once for X and Y.
[ "Using", "the", "table", "for", "the", "length", "of", "each", "run", "calculate", "the", "amount", "of", "bad", "image", ".", "Long", "runs", "or", "those", "that", "look", "like", "finders", "are", "called", "twice", ";", "once", "for", "X", "and", "...
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/third-party/qr/qr.js#L486-L511
train
freedomjs/freedom
providers/core/core.websocket.js
function (cap, dispatchEvent, url, protocols, socket) { var WSImplementation = null, error; this.isNode = nodeStyle; if (typeof socket !== 'undefined') { WSImplementation = socket; } else if (WSHandle !== null) { WSImplementation = WSHandle; } else if (typeof WebSocket !== 'undefined') { WSImp...
javascript
function (cap, dispatchEvent, url, protocols, socket) { var WSImplementation = null, error; this.isNode = nodeStyle; if (typeof socket !== 'undefined') { WSImplementation = socket; } else if (WSHandle !== null) { WSImplementation = WSHandle; } else if (typeof WebSocket !== 'undefined') { WSImp...
[ "function", "(", "cap", ",", "dispatchEvent", ",", "url", ",", "protocols", ",", "socket", ")", "{", "var", "WSImplementation", "=", "null", ",", "error", ";", "this", ".", "isNode", "=", "nodeStyle", ";", "if", "(", "typeof", "socket", "!==", "'undefine...
A WebSocket core provider @param {Object} cap Capabilities for the provider @param {Function} dispatchEvent Function to dispatch events. @param {String} url The Remote URL to connect with. @param {String[]} protocols SubProtocols to open. @param {WebSocket?} socket An alternative socket class to use.
[ "A", "WebSocket", "core", "provider" ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/providers/core/core.websocket.js#L16-L66
train
freedomjs/freedom
src/provider.js
function (def, debug) { this.id = Consumer.nextId(); util.handleEvents(this); this.debug = debug; this.definition = def; this.mode = Provider.mode.synchronous; this.channels = {}; this.iface = null; this.closeHandlers = {}; this.providerCls = null; this.ifaces = {}; this.emits = {}; }
javascript
function (def, debug) { this.id = Consumer.nextId(); util.handleEvents(this); this.debug = debug; this.definition = def; this.mode = Provider.mode.synchronous; this.channels = {}; this.iface = null; this.closeHandlers = {}; this.providerCls = null; this.ifaces = {}; this.emits = {}; }
[ "function", "(", "def", ",", "debug", ")", "{", "this", ".", "id", "=", "Consumer", ".", "nextId", "(", ")", ";", "util", ".", "handleEvents", "(", "this", ")", ";", "this", ".", "debug", "=", "debug", ";", "this", ".", "definition", "=", "def", ...
A freedom port for a user-accessable provider. @class Provider @implements Port @uses handleEvents @param {Object} def The interface of the provider. @param {Debug} debug The debugger to use for logging. @contructor
[ "A", "freedom", "port", "for", "a", "user", "-", "accessable", "provider", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/provider.js#L14-L28
train
freedomjs/freedom
spec/providers/social/social.double.integration.src.js
function(evts, key) { var saw1 = false, saw2 = false; for (var i = 0; i < evts.length; i++) { if (typeof c1State !== "undefined" && evts[i][key] == c1State[key]) { saw1 = true; } if (typeof c2State !== "undefined" && evts[i][key] == c2State[key]) { saw2 = true; ...
javascript
function(evts, key) { var saw1 = false, saw2 = false; for (var i = 0; i < evts.length; i++) { if (typeof c1State !== "undefined" && evts[i][key] == c1State[key]) { saw1 = true; } if (typeof c2State !== "undefined" && evts[i][key] == c2State[key]) { saw2 = true; ...
[ "function", "(", "evts", ",", "key", ")", "{", "var", "saw1", "=", "false", ",", "saw2", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "evts", ".", "length", ";", "i", "++", ")", "{", "if", "(", "typeof", "c1State", "!==...
Checks if we see both users for a set of events
[ "Checks", "if", "we", "see", "both", "users", "for", "a", "set", "of", "events" ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/spec/providers/social/social.double.integration.src.js#L144-L155
train
freedomjs/freedom
spec/providers/social/social.double.integration.src.js
function(arr, info) { if (typeof arr !== "undefined") { arr.push(info); } if (!triggered && seeBoth(c1ProfileEvts, "userId") && seeBoth(c2ProfileEvts, "userId") && seeBoth(c1StateEvts, "clientId") && seeBoth(c2StateEvts, "clientId")) { triggered = true; Prom...
javascript
function(arr, info) { if (typeof arr !== "undefined") { arr.push(info); } if (!triggered && seeBoth(c1ProfileEvts, "userId") && seeBoth(c2ProfileEvts, "userId") && seeBoth(c1StateEvts, "clientId") && seeBoth(c2StateEvts, "clientId")) { triggered = true; Prom...
[ "function", "(", "arr", ",", "info", ")", "{", "if", "(", "typeof", "arr", "!==", "\"undefined\"", ")", "{", "arr", ".", "push", "(", "info", ")", ";", "}", "if", "(", "!", "triggered", "&&", "seeBoth", "(", "c1ProfileEvts", ",", "\"userId\"", ")", ...
Triggered on every event, waiting until all necessary events are collected
[ "Triggered", "on", "every", "event", "waiting", "until", "all", "necessary", "events", "are", "collected" ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/spec/providers/social/social.double.integration.src.js#L158-L178
train
freedomjs/freedom
src/link.js
function (name, resource) { this.id = 'Link' + Math.random(); this.name = name; this.resource = resource; this.config = {}; this.src = null; util.handleEvents(this); util.mixin(this, Link.prototype); }
javascript
function (name, resource) { this.id = 'Link' + Math.random(); this.name = name; this.resource = resource; this.config = {}; this.src = null; util.handleEvents(this); util.mixin(this, Link.prototype); }
[ "function", "(", "name", ",", "resource", ")", "{", "this", ".", "id", "=", "'Link'", "+", "Math", ".", "random", "(", ")", ";", "this", ".", "name", "=", "name", ";", "this", ".", "resource", "=", "resource", ";", "this", ".", "config", "=", "{"...
A link connects two freedom hubs. This is an abstract class providing common functionality of translating control channels, and integrating config information. @class Link @implements Port @constructor
[ "A", "link", "connects", "two", "freedom", "hubs", ".", "This", "is", "an", "abstract", "class", "providing", "common", "functionality", "of", "translating", "control", "channels", "and", "integrating", "config", "information", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/link.js#L12-L21
train
freedomjs/freedom
src/policy.js
function(manager, resource, config) { this.api = manager.api; this.debug = manager.debug; this.location = config.location; this.resource = resource; this.config = config; this.runtimes = []; this.policies = []; this.pending = {}; util.handleEvents(this); this.add(manager, config.policy); this.ru...
javascript
function(manager, resource, config) { this.api = manager.api; this.debug = manager.debug; this.location = config.location; this.resource = resource; this.config = config; this.runtimes = []; this.policies = []; this.pending = {}; util.handleEvents(this); this.add(manager, config.policy); this.ru...
[ "function", "(", "manager", ",", "resource", ",", "config", ")", "{", "this", ".", "api", "=", "manager", ".", "api", ";", "this", ".", "debug", "=", "manager", ".", "debug", ";", "this", ".", "location", "=", "config", ".", "location", ";", "this", ...
The Policy registry for freedom.js. Used to look up modules and provide migration and coallesing of execution. @Class Policy @param {Manager} manager The manager of the active runtime. @param {Resource} resource The resource loader of the active runtime. @param {Object} config The local config. @constructor
[ "The", "Policy", "registry", "for", "freedom", ".", "js", ".", "Used", "to", "look", "up", "modules", "and", "provide", "migration", "and", "coallesing", "of", "execution", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/policy.js#L16-L30
train
freedomjs/freedom
src/manager.js
function (hub, resource, api) { this.id = 'control'; this.config = {}; this.controlFlows = {}; this.dataFlows = {}; this.dataFlows[this.id] = []; this.reverseFlowMap = {}; this.debug = hub.debug; this.hub = hub; this.resource = resource; this.api = api; this.delegate = null; this.toDelegate = ...
javascript
function (hub, resource, api) { this.id = 'control'; this.config = {}; this.controlFlows = {}; this.dataFlows = {}; this.dataFlows[this.id] = []; this.reverseFlowMap = {}; this.debug = hub.debug; this.hub = hub; this.resource = resource; this.api = api; this.delegate = null; this.toDelegate = ...
[ "function", "(", "hub", ",", "resource", ",", "api", ")", "{", "this", ".", "id", "=", "'control'", ";", "this", ".", "config", "=", "{", "}", ";", "this", ".", "controlFlows", "=", "{", "}", ";", "this", ".", "dataFlows", "=", "{", "}", ";", "...
A freedom port which manages the control plane of of changing hub routes. @class Manager @implements Port @param {Hub} hub The routing hub to control. @param {Resource} resource The resource manager for the runtime. @param {Api} api The API manager for the runtime. @constructor
[ "A", "freedom", "port", "which", "manages", "the", "control", "plane", "of", "of", "changing", "hub", "routes", "." ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/src/manager.js#L14-L37
train
freedomjs/freedom
demo/connections/main.js
onState
function onState(data) { if (data.status === social.STATUS.OFFLINE) { if (users.hasOwnProperty(data.userId)) { delete users[data.userId]; } } else { //Only track non-offline clients users[data.userId] = data; } sendUsers(); // Handle my state separately if (myClientState !== null && data...
javascript
function onState(data) { if (data.status === social.STATUS.OFFLINE) { if (users.hasOwnProperty(data.userId)) { delete users[data.userId]; } } else { //Only track non-offline clients users[data.userId] = data; } sendUsers(); // Handle my state separately if (myClientState !== null && data...
[ "function", "onState", "(", "data", ")", "{", "if", "(", "data", ".", "status", "===", "social", ".", "STATUS", ".", "OFFLINE", ")", "{", "if", "(", "users", ".", "hasOwnProperty", "(", "data", ".", "userId", ")", ")", "{", "delete", "users", "[", ...
On newly online or offline clients, let's update the roster
[ "On", "newly", "online", "or", "offline", "clients", "let", "s", "update", "the", "roster" ]
9638e840aec9598c4d60383ed22444c525aefbf5
https://github.com/freedomjs/freedom/blob/9638e840aec9598c4d60383ed22444c525aefbf5/demo/connections/main.js#L49-L71
train