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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
tscanlin/tocbot | src/js/parse-content.js | getHeadingObject | function getHeadingObject (heading) {
var obj = {
id: heading.id,
children: [],
nodeName: heading.nodeName,
headingLevel: getHeadingLevel(heading),
textContent: heading.textContent.trim()
}
if (options.includeHtml) {
obj.childNodes = heading.childNodes
}
return ... | javascript | function getHeadingObject (heading) {
var obj = {
id: heading.id,
children: [],
nodeName: heading.nodeName,
headingLevel: getHeadingLevel(heading),
textContent: heading.textContent.trim()
}
if (options.includeHtml) {
obj.childNodes = heading.childNodes
}
return ... | [
"function",
"getHeadingObject",
"(",
"heading",
")",
"{",
"var",
"obj",
"=",
"{",
"id",
":",
"heading",
".",
"id",
",",
"children",
":",
"[",
"]",
",",
"nodeName",
":",
"heading",
".",
"nodeName",
",",
"headingLevel",
":",
"getHeadingLevel",
"(",
"headin... | Get important properties from a heading element and store in a plain object.
@param {HTMLElement} heading
@return {Object} | [
"Get",
"important",
"properties",
"from",
"a",
"heading",
"element",
"and",
"store",
"in",
"a",
"plain",
"object",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/parse-content.js#L34-L48 | train |
tscanlin/tocbot | src/js/parse-content.js | addNode | function addNode (node, nest) {
var obj = getHeadingObject(node)
var level = getHeadingLevel(node)
var array = nest
var lastItem = getLastItem(array)
var lastItemLevel = lastItem
? lastItem.headingLevel
: 0
var counter = level - lastItemLevel
while (counter > 0) {
lastItem... | javascript | function addNode (node, nest) {
var obj = getHeadingObject(node)
var level = getHeadingLevel(node)
var array = nest
var lastItem = getLastItem(array)
var lastItemLevel = lastItem
? lastItem.headingLevel
: 0
var counter = level - lastItemLevel
while (counter > 0) {
lastItem... | [
"function",
"addNode",
"(",
"node",
",",
"nest",
")",
"{",
"var",
"obj",
"=",
"getHeadingObject",
"(",
"node",
")",
"var",
"level",
"=",
"getHeadingLevel",
"(",
"node",
")",
"var",
"array",
"=",
"nest",
"var",
"lastItem",
"=",
"getLastItem",
"(",
"array"... | Add a node to the nested array.
@param {Object} node
@param {Array} nest
@return {Array} | [
"Add",
"a",
"node",
"to",
"the",
"nested",
"array",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/parse-content.js#L56-L80 | train |
tscanlin/tocbot | src/js/parse-content.js | selectHeadings | function selectHeadings (contentSelector, headingSelector) {
var selectors = headingSelector
if (options.ignoreSelector) {
selectors = headingSelector.split(',')
.map(function mapSelectors (selector) {
return selector.trim() + ':not(' + options.ignoreSelector + ')'
})
}
t... | javascript | function selectHeadings (contentSelector, headingSelector) {
var selectors = headingSelector
if (options.ignoreSelector) {
selectors = headingSelector.split(',')
.map(function mapSelectors (selector) {
return selector.trim() + ':not(' + options.ignoreSelector + ')'
})
}
t... | [
"function",
"selectHeadings",
"(",
"contentSelector",
",",
"headingSelector",
")",
"{",
"var",
"selectors",
"=",
"headingSelector",
"if",
"(",
"options",
".",
"ignoreSelector",
")",
"{",
"selectors",
"=",
"headingSelector",
".",
"split",
"(",
"','",
")",
".",
... | Select headings in content area, exclude any selector in options.ignoreSelector
@param {String} contentSelector
@param {Array} headingSelector
@return {Array} | [
"Select",
"headings",
"in",
"content",
"area",
"exclude",
"any",
"selector",
"in",
"options",
".",
"ignoreSelector"
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/parse-content.js#L88-L103 | train |
tscanlin/tocbot | src/js/parse-content.js | nestHeadingsArray | function nestHeadingsArray (headingsArray) {
return reduce.call(headingsArray, function reducer (prev, curr) {
var currentHeading = getHeadingObject(curr)
addNode(currentHeading, prev.nest)
return prev
}, {
nest: []
})
} | javascript | function nestHeadingsArray (headingsArray) {
return reduce.call(headingsArray, function reducer (prev, curr) {
var currentHeading = getHeadingObject(curr)
addNode(currentHeading, prev.nest)
return prev
}, {
nest: []
})
} | [
"function",
"nestHeadingsArray",
"(",
"headingsArray",
")",
"{",
"return",
"reduce",
".",
"call",
"(",
"headingsArray",
",",
"function",
"reducer",
"(",
"prev",
",",
"curr",
")",
"{",
"var",
"currentHeading",
"=",
"getHeadingObject",
"(",
"curr",
")",
"addNode... | Nest headings array into nested arrays with 'children' property.
@param {Array} headingsArray
@return {Object} | [
"Nest",
"headings",
"array",
"into",
"nested",
"arrays",
"with",
"children",
"property",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/parse-content.js#L110-L119 | train |
tscanlin/tocbot | src/js/build-html.js | createEl | function createEl (d, container) {
var link = container.appendChild(createLink(d))
if (d.children.length) {
var list = createList(d.isCollapsed)
d.children.forEach(function (child) {
createEl(child, list)
})
link.appendChild(list)
}
} | javascript | function createEl (d, container) {
var link = container.appendChild(createLink(d))
if (d.children.length) {
var list = createList(d.isCollapsed)
d.children.forEach(function (child) {
createEl(child, list)
})
link.appendChild(list)
}
} | [
"function",
"createEl",
"(",
"d",
",",
"container",
")",
"{",
"var",
"link",
"=",
"container",
".",
"appendChild",
"(",
"createLink",
"(",
"d",
")",
")",
"if",
"(",
"d",
".",
"children",
".",
"length",
")",
"{",
"var",
"list",
"=",
"createList",
"(",... | Create link and list elements.
@param {Object} d
@param {HTMLElement} container
@return {HTMLElement} | [
"Create",
"link",
"and",
"list",
"elements",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L20-L29 | train |
tscanlin/tocbot | src/js/build-html.js | render | function render (selector, data) {
var collapsed = false
var container = createList(collapsed)
data.forEach(function (d) {
createEl(d, container)
})
var parent = document.querySelector(selector)
// Return if no parent is found.
if (parent === null) {
return
}
// Remov... | javascript | function render (selector, data) {
var collapsed = false
var container = createList(collapsed)
data.forEach(function (d) {
createEl(d, container)
})
var parent = document.querySelector(selector)
// Return if no parent is found.
if (parent === null) {
return
}
// Remov... | [
"function",
"render",
"(",
"selector",
",",
"data",
")",
"{",
"var",
"collapsed",
"=",
"false",
"var",
"container",
"=",
"createList",
"(",
"collapsed",
")",
"data",
".",
"forEach",
"(",
"function",
"(",
"d",
")",
"{",
"createEl",
"(",
"d",
",",
"conta... | Render nested heading array data into a given selector.
@param {String} selector
@param {Array} data
@return {HTMLElement} | [
"Render",
"nested",
"heading",
"array",
"data",
"into",
"a",
"given",
"selector",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L37-L64 | train |
tscanlin/tocbot | src/js/build-html.js | createLink | function createLink (data) {
var item = document.createElement('li')
var a = document.createElement('a')
if (options.listItemClass) {
item.setAttribute('class', options.listItemClass)
}
if (options.onClick) {
a.onclick = options.onClick
}
if (options.includeHtml && data.childNo... | javascript | function createLink (data) {
var item = document.createElement('li')
var a = document.createElement('a')
if (options.listItemClass) {
item.setAttribute('class', options.listItemClass)
}
if (options.onClick) {
a.onclick = options.onClick
}
if (options.includeHtml && data.childNo... | [
"function",
"createLink",
"(",
"data",
")",
"{",
"var",
"item",
"=",
"document",
".",
"createElement",
"(",
"'li'",
")",
"var",
"a",
"=",
"document",
".",
"createElement",
"(",
"'a'",
")",
"if",
"(",
"options",
".",
"listItemClass",
")",
"{",
"item",
"... | Create link element.
@param {Object} data
@return {HTMLElement} | [
"Create",
"link",
"element",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L71-L96 | train |
tscanlin/tocbot | src/js/build-html.js | createList | function createList (isCollapsed) {
var listElement = (options.orderedList) ? 'ol' : 'ul'
var list = document.createElement(listElement)
var classes = options.listClass +
SPACE_CHAR + options.extraListClasses
if (isCollapsed) {
classes += SPACE_CHAR + options.collapsibleClass
classes +... | javascript | function createList (isCollapsed) {
var listElement = (options.orderedList) ? 'ol' : 'ul'
var list = document.createElement(listElement)
var classes = options.listClass +
SPACE_CHAR + options.extraListClasses
if (isCollapsed) {
classes += SPACE_CHAR + options.collapsibleClass
classes +... | [
"function",
"createList",
"(",
"isCollapsed",
")",
"{",
"var",
"listElement",
"=",
"(",
"options",
".",
"orderedList",
")",
"?",
"'ol'",
":",
"'ul'",
"var",
"list",
"=",
"document",
".",
"createElement",
"(",
"listElement",
")",
"var",
"classes",
"=",
"opt... | Create list element.
@param {Boolean} isCollapsed
@return {HTMLElement} | [
"Create",
"list",
"element",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L103-L114 | train |
tscanlin/tocbot | src/js/build-html.js | updateFixedSidebarClass | function updateFixedSidebarClass () {
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
var top = document.querySelector(options.scrollContainer).scrollTop
} else {
var top = document.documentElement.scrollTop || body.scrollTop
}
var posFixedEl = document.quer... | javascript | function updateFixedSidebarClass () {
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
var top = document.querySelector(options.scrollContainer).scrollTop
} else {
var top = document.documentElement.scrollTop || body.scrollTop
}
var posFixedEl = document.quer... | [
"function",
"updateFixedSidebarClass",
"(",
")",
"{",
"if",
"(",
"options",
".",
"scrollContainer",
"&&",
"document",
".",
"querySelector",
"(",
"options",
".",
"scrollContainer",
")",
")",
"{",
"var",
"top",
"=",
"document",
".",
"querySelector",
"(",
"option... | Update fixed sidebar class.
@return {HTMLElement} | [
"Update",
"fixed",
"sidebar",
"class",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L120-L139 | train |
tscanlin/tocbot | src/js/build-html.js | getHeadingTopPos | function getHeadingTopPos (obj) {
var position = 0
if (obj != document.querySelector(options.contentSelector && obj != null)) {
position = obj.offsetTop
if (options.hasInnerContainers)
position += getHeadingTopPos(obj.offsetParent)
}
return position
} | javascript | function getHeadingTopPos (obj) {
var position = 0
if (obj != document.querySelector(options.contentSelector && obj != null)) {
position = obj.offsetTop
if (options.hasInnerContainers)
position += getHeadingTopPos(obj.offsetParent)
}
return position
} | [
"function",
"getHeadingTopPos",
"(",
"obj",
")",
"{",
"var",
"position",
"=",
"0",
"if",
"(",
"obj",
"!=",
"document",
".",
"querySelector",
"(",
"options",
".",
"contentSelector",
"&&",
"obj",
"!=",
"null",
")",
")",
"{",
"position",
"=",
"obj",
".",
... | Get top position of heading
@param {HTMLElement}
@return {integer} position | [
"Get",
"top",
"position",
"of",
"heading"
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L146-L154 | train |
tscanlin/tocbot | src/js/build-html.js | updateToc | function updateToc (headingsArray) {
// If a fixed content container was set
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
var top = document.querySelector(options.scrollContainer).scrollTop
} else {
var top = document.documentElement.scrollTop || body.scrollT... | javascript | function updateToc (headingsArray) {
// If a fixed content container was set
if (options.scrollContainer && document.querySelector(options.scrollContainer)) {
var top = document.querySelector(options.scrollContainer).scrollTop
} else {
var top = document.documentElement.scrollTop || body.scrollT... | [
"function",
"updateToc",
"(",
"headingsArray",
")",
"{",
"// If a fixed content container was set",
"if",
"(",
"options",
".",
"scrollContainer",
"&&",
"document",
".",
"querySelector",
"(",
"options",
".",
"scrollContainer",
")",
")",
"{",
"var",
"top",
"=",
"doc... | Update TOC highlighting and collpased groupings. | [
"Update",
"TOC",
"highlighting",
"and",
"collpased",
"groupings",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L159-L233 | train |
tscanlin/tocbot | src/js/build-html.js | removeCollapsedFromParents | function removeCollapsedFromParents (element) {
if (element.className.indexOf(options.collapsibleClass) !== -1 && element.className.indexOf(options.isCollapsedClass) !== -1) {
element.className = element.className.split(SPACE_CHAR + options.isCollapsedClass).join('')
return removeCollapsedFromParents(el... | javascript | function removeCollapsedFromParents (element) {
if (element.className.indexOf(options.collapsibleClass) !== -1 && element.className.indexOf(options.isCollapsedClass) !== -1) {
element.className = element.className.split(SPACE_CHAR + options.isCollapsedClass).join('')
return removeCollapsedFromParents(el... | [
"function",
"removeCollapsedFromParents",
"(",
"element",
")",
"{",
"if",
"(",
"element",
".",
"className",
".",
"indexOf",
"(",
"options",
".",
"collapsibleClass",
")",
"!==",
"-",
"1",
"&&",
"element",
".",
"className",
".",
"indexOf",
"(",
"options",
".",... | Remove collpased class from parent elements.
@param {HTMLElement} element
@return {HTMLElement} | [
"Remove",
"collpased",
"class",
"from",
"parent",
"elements",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L240-L246 | train |
tscanlin/tocbot | src/js/build-html.js | disableTocAnimation | function disableTocAnimation (event) {
var target = event.target || event.srcElement
if (typeof target.className !== 'string' || target.className.indexOf(options.linkClass) === -1) {
return
}
// Bind to tocLink clicks to temporarily disable highlighting
// while smoothScroll is animating.
... | javascript | function disableTocAnimation (event) {
var target = event.target || event.srcElement
if (typeof target.className !== 'string' || target.className.indexOf(options.linkClass) === -1) {
return
}
// Bind to tocLink clicks to temporarily disable highlighting
// while smoothScroll is animating.
... | [
"function",
"disableTocAnimation",
"(",
"event",
")",
"{",
"var",
"target",
"=",
"event",
".",
"target",
"||",
"event",
".",
"srcElement",
"if",
"(",
"typeof",
"target",
".",
"className",
"!==",
"'string'",
"||",
"target",
".",
"className",
".",
"indexOf",
... | Disable TOC Animation when a link is clicked.
@param {Event} event | [
"Disable",
"TOC",
"Animation",
"when",
"a",
"link",
"is",
"clicked",
"."
] | b1437aea1efbb2cccc82180be7465ed2d54508be | https://github.com/tscanlin/tocbot/blob/b1437aea1efbb2cccc82180be7465ed2d54508be/src/js/build-html.js#L252-L260 | train |
paulkr/overhang.js | lib/overhang.js | raise | function raise (runCallback, identifier) {
$overlay.fadeOut(100);
$overhang.slideUp(attributes.speed, function () {
if (runCallback) {
attributes.callback(identifier !== null ? $element.data(identifier) : "");
}
});
} | javascript | function raise (runCallback, identifier) {
$overlay.fadeOut(100);
$overhang.slideUp(attributes.speed, function () {
if (runCallback) {
attributes.callback(identifier !== null ? $element.data(identifier) : "");
}
});
} | [
"function",
"raise",
"(",
"runCallback",
",",
"identifier",
")",
"{",
"$overlay",
".",
"fadeOut",
"(",
"100",
")",
";",
"$overhang",
".",
"slideUp",
"(",
"attributes",
".",
"speed",
",",
"function",
"(",
")",
"{",
"if",
"(",
"runCallback",
")",
"{",
"a... | Raise the overhang alert | [
"Raise",
"the",
"overhang",
"alert"
] | 97ad104aca7ce24b5de3239df0c00cd946ffe06e | https://github.com/paulkr/overhang.js/blob/97ad104aca7ce24b5de3239df0c00cd946ffe06e/lib/overhang.js#L53-L60 | train |
gregjacobs/Autolinker.js | gulpfile.js | buildSrcCheckMinifiedSizeTask | async function buildSrcCheckMinifiedSizeTask() {
const stats = await fs.stat( './dist/Autolinker.min.js' );
const sizeInKb = stats.size / 1000;
const maxExpectedSizeInKb = 46;
if( sizeInKb > maxExpectedSizeInKb ) {
throw new Error( `
Minified file size of ${sizeInKb.toFixed( 2 )}kb is greater than max
ex... | javascript | async function buildSrcCheckMinifiedSizeTask() {
const stats = await fs.stat( './dist/Autolinker.min.js' );
const sizeInKb = stats.size / 1000;
const maxExpectedSizeInKb = 46;
if( sizeInKb > maxExpectedSizeInKb ) {
throw new Error( `
Minified file size of ${sizeInKb.toFixed( 2 )}kb is greater than max
ex... | [
"async",
"function",
"buildSrcCheckMinifiedSizeTask",
"(",
")",
"{",
"const",
"stats",
"=",
"await",
"fs",
".",
"stat",
"(",
"'./dist/Autolinker.min.js'",
")",
";",
"const",
"sizeInKb",
"=",
"stats",
".",
"size",
"/",
"1000",
";",
"const",
"maxExpectedSizeInKb",... | Checks that we don't accidentally add an extra dependency that bloats the
minified size of Autolinker | [
"Checks",
"that",
"we",
"don",
"t",
"accidentally",
"add",
"an",
"extra",
"dependency",
"that",
"bloats",
"the",
"minified",
"size",
"of",
"Autolinker"
] | acdf9a5dd9208f27c144efaa068ae4b5d924b38c | https://github.com/gregjacobs/Autolinker.js/blob/acdf9a5dd9208f27c144efaa068ae4b5d924b38c/gulpfile.js#L295-L311 | train |
chariotsolutions/phonegap-nfc | www/phonegap-nfc-blackberry.js | function(ndefMessageAsString) {
"use strict";
var ndefMessage = JSON.parse(ndefMessageAsString);
cordova.fireDocumentEvent("ndef", {
type: "ndef",
tag: {
ndefMessage: ndefMessage
}
});
} | javascript | function(ndefMessageAsString) {
"use strict";
var ndefMessage = JSON.parse(ndefMessageAsString);
cordova.fireDocumentEvent("ndef", {
type: "ndef",
tag: {
ndefMessage: ndefMessage
}
});
} | [
"function",
"(",
"ndefMessageAsString",
")",
"{",
"\"use strict\"",
";",
"var",
"ndefMessage",
"=",
"JSON",
".",
"parse",
"(",
"ndefMessageAsString",
")",
";",
"cordova",
".",
"fireDocumentEvent",
"(",
"\"ndef\"",
",",
"{",
"type",
":",
"\"ndef\"",
",",
"tag",... | takes an ndefMessage from the success callback and fires a javascript event | [
"takes",
"an",
"ndefMessage",
"from",
"the",
"success",
"callback",
"and",
"fires",
"a",
"javascript",
"event"
] | aa92afca3686dff038d71d2ecb270c62e07c4bcb | https://github.com/chariotsolutions/phonegap-nfc/blob/aa92afca3686dff038d71d2ecb270c62e07c4bcb/www/phonegap-nfc-blackberry.js#L59-L68 | train | |
chariotsolutions/phonegap-nfc | src/blackberry10/index.js | function(pluginResult, payloadString) {
var payload = JSON.parse(payloadString),
ndefObjectAsString = JSON.stringify(decode(b64toArray(payload.data)));
pluginResult.callbackOk(ndefObjectAsString, true);
} | javascript | function(pluginResult, payloadString) {
var payload = JSON.parse(payloadString),
ndefObjectAsString = JSON.stringify(decode(b64toArray(payload.data)));
pluginResult.callbackOk(ndefObjectAsString, true);
} | [
"function",
"(",
"pluginResult",
",",
"payloadString",
")",
"{",
"var",
"payload",
"=",
"JSON",
".",
"parse",
"(",
"payloadString",
")",
",",
"ndefObjectAsString",
"=",
"JSON",
".",
"stringify",
"(",
"decode",
"(",
"b64toArray",
"(",
"payload",
".",
"data",
... | called by invoke, when NFC tag is scanned | [
"called",
"by",
"invoke",
"when",
"NFC",
"tag",
"is",
"scanned"
] | aa92afca3686dff038d71d2ecb270c62e07c4bcb | https://github.com/chariotsolutions/phonegap-nfc/blob/aa92afca3686dff038d71d2ecb270c62e07c4bcb/src/blackberry10/index.js#L127-L131 | train | |
FaridSafi/react-native-gifted-form | GiftedFormManager.js | formatValues | function formatValues(values) {
var formatted = {};
for (var key in values) {
if (values.hasOwnProperty(key)) {
if (typeof values[key] === 'boolean') {
var position = key.indexOf('{');
if (position !== -1) {
if (values[key] === true) {
// Each options of SelectWidget ... | javascript | function formatValues(values) {
var formatted = {};
for (var key in values) {
if (values.hasOwnProperty(key)) {
if (typeof values[key] === 'boolean') {
var position = key.indexOf('{');
if (position !== -1) {
if (values[key] === true) {
// Each options of SelectWidget ... | [
"function",
"formatValues",
"(",
"values",
")",
"{",
"var",
"formatted",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"key",
"in",
"values",
")",
"{",
"if",
"(",
"values",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"if",
"(",
"typeof",
"values",
"... | the select widgets values need to be formated because even when the values are 'False' they are stored formatValues return only selected values of select widgets | [
"the",
"select",
"widgets",
"values",
"need",
"to",
"be",
"formated",
"because",
"even",
"when",
"the",
"values",
"are",
"False",
"they",
"are",
"stored",
"formatValues",
"return",
"only",
"selected",
"values",
"of",
"select",
"widgets"
] | 7910cb47157b35841f93d72febb39317dc0002c0 | https://github.com/FaridSafi/react-native-gifted-form/blob/7910cb47157b35841f93d72febb39317dc0002c0/GiftedFormManager.js#L94-L128 | train |
mhart/aws4 | aws4.js | encodeRfc3986 | function encodeRfc3986(urlEncodedString) {
return urlEncodedString.replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
} | javascript | function encodeRfc3986(urlEncodedString) {
return urlEncodedString.replace(/[!'()*]/g, function(c) {
return '%' + c.charCodeAt(0).toString(16).toUpperCase()
})
} | [
"function",
"encodeRfc3986",
"(",
"urlEncodedString",
")",
"{",
"return",
"urlEncodedString",
".",
"replace",
"(",
"/",
"[!'()*]",
"/",
"g",
",",
"function",
"(",
"c",
")",
"{",
"return",
"'%'",
"+",
"c",
".",
"charCodeAt",
"(",
"0",
")",
".",
"toString"... | This function assumes the string has already been percent encoded | [
"This",
"function",
"assumes",
"the",
"string",
"has",
"already",
"been",
"percent",
"encoded"
] | e2052432f836af766b33ce5782a3bfa21f40db99 | https://github.com/mhart/aws4/blob/e2052432f836af766b33ce5782a3bfa21f40db99/aws4.js#L19-L23 | train |
alexeyten/qr-image | lib/qr-base.js | getTemplate | function getTemplate(message, ec_level) {
var i = 1;
var len;
if (message.data1) {
len = Math.ceil(message.data1.length / 8);
} else {
i = 10;
}
for (/* i */; i < 10; i++) {
var version = versions[i][ec_level];
if (version.data_len >= len) {
return _d... | javascript | function getTemplate(message, ec_level) {
var i = 1;
var len;
if (message.data1) {
len = Math.ceil(message.data1.length / 8);
} else {
i = 10;
}
for (/* i */; i < 10; i++) {
var version = versions[i][ec_level];
if (version.data_len >= len) {
return _d... | [
"function",
"getTemplate",
"(",
"message",
",",
"ec_level",
")",
"{",
"var",
"i",
"=",
"1",
";",
"var",
"len",
";",
"if",
"(",
"message",
".",
"data1",
")",
"{",
"len",
"=",
"Math",
".",
"ceil",
"(",
"message",
".",
"data1",
".",
"length",
"/",
"... | {{{1 Get version template | [
"{{{",
"1",
"Get",
"version",
"template"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/qr-base.js#L89-L125 | train |
alexeyten/qr-image | lib/qr-base.js | fillTemplate | function fillTemplate(message, template) {
var blocks = new Buffer(template.data_len);
blocks.fill(0);
if (template.version < 10) {
message = message.data1;
} else if (template.version < 27) {
message = message.data10;
} else {
message = message.data27;
}
var len = ... | javascript | function fillTemplate(message, template) {
var blocks = new Buffer(template.data_len);
blocks.fill(0);
if (template.version < 10) {
message = message.data1;
} else if (template.version < 27) {
message = message.data10;
} else {
message = message.data27;
}
var len = ... | [
"function",
"fillTemplate",
"(",
"message",
",",
"template",
")",
"{",
"var",
"blocks",
"=",
"new",
"Buffer",
"(",
"template",
".",
"data_len",
")",
";",
"blocks",
".",
"fill",
"(",
"0",
")",
";",
"if",
"(",
"template",
".",
"version",
"<",
"10",
")"... | {{{1 Fill template | [
"{{{",
"1",
"Fill",
"template"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/qr-base.js#L128-L165 | train |
alexeyten/qr-image | lib/qr-base.js | QR | function QR(text, ec_level, parse_url) {
ec_level = EC_LEVELS.indexOf(ec_level) > -1 ? ec_level : 'M';
var message = encode(text, parse_url);
var data = fillTemplate(message, getTemplate(message, ec_level));
return matrix.getMatrix(data);
} | javascript | function QR(text, ec_level, parse_url) {
ec_level = EC_LEVELS.indexOf(ec_level) > -1 ? ec_level : 'M';
var message = encode(text, parse_url);
var data = fillTemplate(message, getTemplate(message, ec_level));
return matrix.getMatrix(data);
} | [
"function",
"QR",
"(",
"text",
",",
"ec_level",
",",
"parse_url",
")",
"{",
"ec_level",
"=",
"EC_LEVELS",
".",
"indexOf",
"(",
"ec_level",
")",
">",
"-",
"1",
"?",
"ec_level",
":",
"'M'",
";",
"var",
"message",
"=",
"encode",
"(",
"text",
",",
"parse... | {{{1 All-in-one | [
"{{{",
"1",
"All",
"-",
"in",
"-",
"one"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/qr-base.js#L168-L173 | train |
alexeyten/qr-image | lib/encode.js | encode_8bit | function encode_8bit(data) {
var len = data.length;
var bits = [];
for (var i = 0; i < len; i++) {
pushBits(bits, 8, data[i]);
}
var res = {};
var d = [0, 1, 0, 0];
pushBits(d, 16, len);
res.data10 = res.data27 = d.concat(bits);
if (len < 256) {
var d = [0, 1, 0, ... | javascript | function encode_8bit(data) {
var len = data.length;
var bits = [];
for (var i = 0; i < len; i++) {
pushBits(bits, 8, data[i]);
}
var res = {};
var d = [0, 1, 0, 0];
pushBits(d, 16, len);
res.data10 = res.data27 = d.concat(bits);
if (len < 256) {
var d = [0, 1, 0, ... | [
"function",
"encode_8bit",
"(",
"data",
")",
"{",
"var",
"len",
"=",
"data",
".",
"length",
";",
"var",
"bits",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"pushBits",
"(",
"bits",
","... | {{{1 8bit encode | [
"{{{",
"1",
"8bit",
"encode"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/encode.js#L10-L31 | train |
alexeyten/qr-image | lib/encode.js | encode_numeric | function encode_numeric(str) {
var len = str.length;
var bits = [];
for (var i = 0; i < len; i += 3) {
var s = str.substr(i, 3);
var b = Math.ceil(s.length * 10 / 3);
pushBits(bits, b, parseInt(s, 10));
}
var res = {};
var d = [0, 0, 0, 1];
pushBits(d, 14, len);
... | javascript | function encode_numeric(str) {
var len = str.length;
var bits = [];
for (var i = 0; i < len; i += 3) {
var s = str.substr(i, 3);
var b = Math.ceil(s.length * 10 / 3);
pushBits(bits, b, parseInt(s, 10));
}
var res = {};
var d = [0, 0, 0, 1];
pushBits(d, 14, len);
... | [
"function",
"encode_numeric",
"(",
"str",
")",
"{",
"var",
"len",
"=",
"str",
".",
"length",
";",
"var",
"bits",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"+=",
"3",
")",
"{",
"var",
"s",
"=",
"st... | {{{1 numeric encode | [
"{{{",
"1",
"numeric",
"encode"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/encode.js#L78-L107 | train |
alexeyten/qr-image | lib/encode.js | encode_url | function encode_url(str) {
var slash = str.indexOf('/', 8) + 1 || str.length;
var res = encode(str.slice(0, slash).toUpperCase(), false);
if (slash >= str.length) {
return res;
}
var path_res = encode(str.slice(slash), false);
res.data27 = res.data27.concat(path_res.data27);
if (... | javascript | function encode_url(str) {
var slash = str.indexOf('/', 8) + 1 || str.length;
var res = encode(str.slice(0, slash).toUpperCase(), false);
if (slash >= str.length) {
return res;
}
var path_res = encode(str.slice(slash), false);
res.data27 = res.data27.concat(path_res.data27);
if (... | [
"function",
"encode_url",
"(",
"str",
")",
"{",
"var",
"slash",
"=",
"str",
".",
"indexOf",
"(",
"'/'",
",",
"8",
")",
"+",
"1",
"||",
"str",
".",
"length",
";",
"var",
"res",
"=",
"encode",
"(",
"str",
".",
"slice",
"(",
"0",
",",
"slash",
")"... | {{{1 url encode | [
"{{{",
"1",
"url",
"encode"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/encode.js#L110-L131 | train |
alexeyten/qr-image | lib/encode.js | encode | function encode(data, parse_url) {
var str;
var t = typeof data;
if (t == 'string' || t == 'number') {
str = '' + data;
data = new Buffer(str);
} else if (Buffer.isBuffer(data)) {
str = data.toString();
} else if (Array.isArray(data)) {
data = new Buffer(data);
... | javascript | function encode(data, parse_url) {
var str;
var t = typeof data;
if (t == 'string' || t == 'number') {
str = '' + data;
data = new Buffer(str);
} else if (Buffer.isBuffer(data)) {
str = data.toString();
} else if (Array.isArray(data)) {
data = new Buffer(data);
... | [
"function",
"encode",
"(",
"data",
",",
"parse_url",
")",
"{",
"var",
"str",
";",
"var",
"t",
"=",
"typeof",
"data",
";",
"if",
"(",
"t",
"==",
"'string'",
"||",
"t",
"==",
"'number'",
")",
"{",
"str",
"=",
"''",
"+",
"data",
";",
"data",
"=",
... | {{{1 Choose encode mode and generates struct with data for different version | [
"{{{",
"1",
"Choose",
"encode",
"mode",
"and",
"generates",
"struct",
"with",
"data",
"for",
"different",
"version"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/encode.js#L134-L172 | train |
alexeyten/qr-image | lib/matrix.js | init | function init(version) {
var N = version * 4 + 17;
var matrix = [];
var zeros = new Buffer(N);
zeros.fill(0);
zeros = [].slice.call(zeros);
for (var i = 0; i < N; i++) {
matrix[i] = zeros.slice();
}
return matrix;
} | javascript | function init(version) {
var N = version * 4 + 17;
var matrix = [];
var zeros = new Buffer(N);
zeros.fill(0);
zeros = [].slice.call(zeros);
for (var i = 0; i < N; i++) {
matrix[i] = zeros.slice();
}
return matrix;
} | [
"function",
"init",
"(",
"version",
")",
"{",
"var",
"N",
"=",
"version",
"*",
"4",
"+",
"17",
";",
"var",
"matrix",
"=",
"[",
"]",
";",
"var",
"zeros",
"=",
"new",
"Buffer",
"(",
"N",
")",
";",
"zeros",
".",
"fill",
"(",
"0",
")",
";",
"zero... | {{{1 Initialize matrix with zeros | [
"{{{",
"1",
"Initialize",
"matrix",
"with",
"zeros"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/matrix.js#L4-L14 | train |
alexeyten/qr-image | lib/matrix.js | fillFinders | function fillFinders(matrix) {
var N = matrix.length;
for (var i = -3; i <= 3; i++) {
for (var j = -3; j <= 3; j++) {
var max = Math.max(i, j);
var min = Math.min(i, j);
var pixel = (max == 2 && min >= -2) || (min == -2 && max <= 2) ? 0x80 : 0x81;
matrix[3... | javascript | function fillFinders(matrix) {
var N = matrix.length;
for (var i = -3; i <= 3; i++) {
for (var j = -3; j <= 3; j++) {
var max = Math.max(i, j);
var min = Math.min(i, j);
var pixel = (max == 2 && min >= -2) || (min == -2 && max <= 2) ? 0x80 : 0x81;
matrix[3... | [
"function",
"fillFinders",
"(",
"matrix",
")",
"{",
"var",
"N",
"=",
"matrix",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"-",
"3",
";",
"i",
"<=",
"3",
";",
"i",
"++",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"-",
"3",
";",
"j",
"<=",
... | {{{1 Put finders into matrix | [
"{{{",
"1",
"Put",
"finders",
"into",
"matrix"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/matrix.js#L17-L34 | train |
alexeyten/qr-image | lib/matrix.js | fillAlignAndTiming | function fillAlignAndTiming(matrix) {
var N = matrix.length;
if (N > 21) {
var len = N - 13;
var delta = Math.round(len / Math.ceil(len / 28));
if (delta % 2) delta++;
var res = [];
for (var p = len + 6; p > 10; p -= delta) {
res.unshift(p);
}
... | javascript | function fillAlignAndTiming(matrix) {
var N = matrix.length;
if (N > 21) {
var len = N - 13;
var delta = Math.round(len / Math.ceil(len / 28));
if (delta % 2) delta++;
var res = [];
for (var p = len + 6; p > 10; p -= delta) {
res.unshift(p);
}
... | [
"function",
"fillAlignAndTiming",
"(",
"matrix",
")",
"{",
"var",
"N",
"=",
"matrix",
".",
"length",
";",
"if",
"(",
"N",
">",
"21",
")",
"{",
"var",
"len",
"=",
"N",
"-",
"13",
";",
"var",
"delta",
"=",
"Math",
".",
"round",
"(",
"len",
"/",
"... | {{{1 Put align and timinig | [
"{{{",
"1",
"Put",
"align",
"and",
"timinig"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/matrix.js#L37-L66 | train |
alexeyten/qr-image | lib/matrix.js | fillStub | function fillStub(matrix) {
var N = matrix.length;
for (var i = 0; i < 8; i++) {
if (i != 6) {
matrix[8][i] = matrix[i][8] = 0x80;
}
matrix[8][N - 1 - i] = 0x80;
matrix[N - 1 - i][8] = 0x80;
}
matrix[8][8] = 0x80;
matrix[N - 8][8] = 0x81;
if (N < 45) ... | javascript | function fillStub(matrix) {
var N = matrix.length;
for (var i = 0; i < 8; i++) {
if (i != 6) {
matrix[8][i] = matrix[i][8] = 0x80;
}
matrix[8][N - 1 - i] = 0x80;
matrix[N - 1 - i][8] = 0x80;
}
matrix[8][8] = 0x80;
matrix[N - 8][8] = 0x81;
if (N < 45) ... | [
"function",
"fillStub",
"(",
"matrix",
")",
"{",
"var",
"N",
"=",
"matrix",
".",
"length",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"6",
")",
"{",
"matrix",
"[",
"8",
"]",
... | {{{1 Fill reserved areas with zeroes | [
"{{{",
"1",
"Fill",
"reserved",
"areas",
"with",
"zeroes"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/matrix.js#L69-L88 | train |
alexeyten/qr-image | lib/matrix.js | getMatrix | function getMatrix(data) {
var matrix = init(data.version);
fillFinders(matrix);
fillAlignAndTiming(matrix);
fillStub(matrix);
var penalty = Infinity;
var bestMask = 0;
for (var mask = 0; mask < 8; mask++) {
fillData(matrix, data, mask);
fillReserved(matrix, data.ec_level, m... | javascript | function getMatrix(data) {
var matrix = init(data.version);
fillFinders(matrix);
fillAlignAndTiming(matrix);
fillStub(matrix);
var penalty = Infinity;
var bestMask = 0;
for (var mask = 0; mask < 8; mask++) {
fillData(matrix, data, mask);
fillReserved(matrix, data.ec_level, m... | [
"function",
"getMatrix",
"(",
"data",
")",
"{",
"var",
"matrix",
"=",
"init",
"(",
"data",
".",
"version",
")",
";",
"fillFinders",
"(",
"matrix",
")",
";",
"fillAlignAndTiming",
"(",
"matrix",
")",
";",
"fillStub",
"(",
"matrix",
")",
";",
"var",
"pen... | {{{1 All-in-one function | [
"{{{",
"1",
"All",
"-",
"in",
"-",
"one",
"function"
] | 9b5ee0e8f38152f29cfd59eedaf037fafb47e740 | https://github.com/alexeyten/qr-image/blob/9b5ee0e8f38152f29cfd59eedaf037fafb47e740/lib/matrix.js#L314-L340 | train |
Autodesk/hig | packages/components/scripts/build.js | getPackageExportNames | function getPackageExportNames(packagePath) {
const packageMeta = getPackageMeta(packagePath);
const packageModulePath = path.join(packagePath, packageMeta.module);
const moduleFileSource = fs.readFileSync(packageModulePath, "utf8");
const { body } = esprima.parseModule(moduleFileSource);
return body.reduce(... | javascript | function getPackageExportNames(packagePath) {
const packageMeta = getPackageMeta(packagePath);
const packageModulePath = path.join(packagePath, packageMeta.module);
const moduleFileSource = fs.readFileSync(packageModulePath, "utf8");
const { body } = esprima.parseModule(moduleFileSource);
return body.reduce(... | [
"function",
"getPackageExportNames",
"(",
"packagePath",
")",
"{",
"const",
"packageMeta",
"=",
"getPackageMeta",
"(",
"packagePath",
")",
";",
"const",
"packageModulePath",
"=",
"path",
".",
"join",
"(",
"packagePath",
",",
"packageMeta",
".",
"module",
")",
";... | Parsed the package's main module and returns all of the export names
@param {string} packageName
@returns {string[]} | [
"Parsed",
"the",
"package",
"s",
"main",
"module",
"and",
"returns",
"all",
"of",
"the",
"export",
"names"
] | b51406a358ec536d70dc404199c62dafe7e4f75e | https://github.com/Autodesk/hig/blob/b51406a358ec536d70dc404199c62dafe7e4f75e/packages/components/scripts/build.js#L60-L77 | train |
Autodesk/hig | packages/flyout/src/coordinateHelpers.js | offsetContainerProperty | function offsetContainerProperty(offsetProperty, coordinates, diff) {
return {
...coordinates,
containerPosition: {
...coordinates.containerPosition,
[offsetProperty]: coordinates.containerPosition[offsetProperty] + diff
}
};
} | javascript | function offsetContainerProperty(offsetProperty, coordinates, diff) {
return {
...coordinates,
containerPosition: {
...coordinates.containerPosition,
[offsetProperty]: coordinates.containerPosition[offsetProperty] + diff
}
};
} | [
"function",
"offsetContainerProperty",
"(",
"offsetProperty",
",",
"coordinates",
",",
"diff",
")",
"{",
"return",
"{",
"...",
"coordinates",
",",
"containerPosition",
":",
"{",
"...",
"coordinates",
".",
"containerPosition",
",",
"[",
"offsetProperty",
"]",
":",
... | Offsets the container
@param {string} offsetProperty
@param {Coordinates} coordinates
@param {number} diff
@returns {Coordinates} | [
"Offsets",
"the",
"container"
] | b51406a358ec536d70dc404199c62dafe7e4f75e | https://github.com/Autodesk/hig/blob/b51406a358ec536d70dc404199c62dafe7e4f75e/packages/flyout/src/coordinateHelpers.js#L17-L25 | train |
Autodesk/hig | packages/flyout/src/getCoordinates.js | createViewportDeterminer | function createViewportDeterminer(props) {
const { viewportRect, panelRect, actionRect } = props;
return function isInViewport({ containerPosition }) {
const containerTop = actionRect.top + containerPosition.top;
const containerLeft = actionRect.left + containerPosition.left;
const containerRight = con... | javascript | function createViewportDeterminer(props) {
const { viewportRect, panelRect, actionRect } = props;
return function isInViewport({ containerPosition }) {
const containerTop = actionRect.top + containerPosition.top;
const containerLeft = actionRect.left + containerPosition.left;
const containerRight = con... | [
"function",
"createViewportDeterminer",
"(",
"props",
")",
"{",
"const",
"{",
"viewportRect",
",",
"panelRect",
",",
"actionRect",
"}",
"=",
"props",
";",
"return",
"function",
"isInViewport",
"(",
"{",
"containerPosition",
"}",
")",
"{",
"const",
"containerTop"... | Determines whether the given position is entirely within the viewport
@param {Payload} payload
@returns {function(Coordinates): boolean} | [
"Determines",
"whether",
"the",
"given",
"position",
"is",
"entirely",
"within",
"the",
"viewport"
] | b51406a358ec536d70dc404199c62dafe7e4f75e | https://github.com/Autodesk/hig/blob/b51406a358ec536d70dc404199c62dafe7e4f75e/packages/flyout/src/getCoordinates.js#L234-L250 | train |
canonical-web-and-design/vanilla-framework | gulp/styles.js | throwSassError | function throwSassError(sassError) {
throw new gutil.PluginError({
plugin: 'sass',
message: util.format("Sass error: '%s' on line %s of %s", sassError.message, sassError.line, sassError.file)
});
} | javascript | function throwSassError(sassError) {
throw new gutil.PluginError({
plugin: 'sass',
message: util.format("Sass error: '%s' on line %s of %s", sassError.message, sassError.line, sassError.file)
});
} | [
"function",
"throwSassError",
"(",
"sassError",
")",
"{",
"throw",
"new",
"gutil",
".",
"PluginError",
"(",
"{",
"plugin",
":",
"'sass'",
",",
"message",
":",
"util",
".",
"format",
"(",
"\"Sass error: '%s' on line %s of %s\"",
",",
"sassError",
".",
"message",
... | Provide details of Sass errors | [
"Provide",
"details",
"of",
"Sass",
"errors"
] | 720e10be29350c847e64b928ebf604f5cf64adcd | https://github.com/canonical-web-and-design/vanilla-framework/blob/720e10be29350c847e64b928ebf604f5cf64adcd/gulp/styles.js#L10-L15 | train |
Operational-Transformation/ot.js | lib/simple-text-operation.js | Insert | function Insert (str, position) {
if (!this || this.constructor !== SimpleTextOperation) {
// => function was called without 'new'
return new Insert(str, position);
}
this.str = str;
this.position = position;
} | javascript | function Insert (str, position) {
if (!this || this.constructor !== SimpleTextOperation) {
// => function was called without 'new'
return new Insert(str, position);
}
this.str = str;
this.position = position;
} | [
"function",
"Insert",
"(",
"str",
",",
"position",
")",
"{",
"if",
"(",
"!",
"this",
"||",
"this",
".",
"constructor",
"!==",
"SimpleTextOperation",
")",
"{",
"// => function was called without 'new'",
"return",
"new",
"Insert",
"(",
"str",
",",
"position",
")... | Insert the string `str` at the zero-based `position` in the document. | [
"Insert",
"the",
"string",
"str",
"at",
"the",
"zero",
"-",
"based",
"position",
"in",
"the",
"document",
"."
] | 8873b7e28e83f9adbf6c3a28ec639c9151a838ae | https://github.com/Operational-Transformation/ot.js/blob/8873b7e28e83f9adbf6c3a28ec639c9151a838ae/lib/simple-text-operation.js#L14-L21 | train |
Operational-Transformation/ot.js | lib/simple-text-operation.js | Delete | function Delete (count, position) {
if (!this || this.constructor !== SimpleTextOperation) {
return new Delete(count, position);
}
this.count = count;
this.position = position;
} | javascript | function Delete (count, position) {
if (!this || this.constructor !== SimpleTextOperation) {
return new Delete(count, position);
}
this.count = count;
this.position = position;
} | [
"function",
"Delete",
"(",
"count",
",",
"position",
")",
"{",
"if",
"(",
"!",
"this",
"||",
"this",
".",
"constructor",
"!==",
"SimpleTextOperation",
")",
"{",
"return",
"new",
"Delete",
"(",
"count",
",",
"position",
")",
";",
"}",
"this",
".",
"coun... | Delete `count` many characters at the zero-based `position` in the document. | [
"Delete",
"count",
"many",
"characters",
"at",
"the",
"zero",
"-",
"based",
"position",
"in",
"the",
"document",
"."
] | 8873b7e28e83f9adbf6c3a28ec639c9151a838ae | https://github.com/Operational-Transformation/ot.js/blob/8873b7e28e83f9adbf6c3a28ec639c9151a838ae/lib/simple-text-operation.js#L42-L48 | train |
Operational-Transformation/ot.js | lib/undo-manager.js | UndoManager | function UndoManager (maxItems) {
this.maxItems = maxItems || 50;
this.state = NORMAL_STATE;
this.dontCompose = false;
this.undoStack = [];
this.redoStack = [];
} | javascript | function UndoManager (maxItems) {
this.maxItems = maxItems || 50;
this.state = NORMAL_STATE;
this.dontCompose = false;
this.undoStack = [];
this.redoStack = [];
} | [
"function",
"UndoManager",
"(",
"maxItems",
")",
"{",
"this",
".",
"maxItems",
"=",
"maxItems",
"||",
"50",
";",
"this",
".",
"state",
"=",
"NORMAL_STATE",
";",
"this",
".",
"dontCompose",
"=",
"false",
";",
"this",
".",
"undoStack",
"=",
"[",
"]",
";"... | Create a new UndoManager with an optional maximum history size. | [
"Create",
"a",
"new",
"UndoManager",
"with",
"an",
"optional",
"maximum",
"history",
"size",
"."
] | 8873b7e28e83f9adbf6c3a28ec639c9151a838ae | https://github.com/Operational-Transformation/ot.js/blob/8873b7e28e83f9adbf6c3a28ec639c9151a838ae/lib/undo-manager.js#L14-L20 | train |
notwaldorf/emoji-translate | emoji-translate.js | getEmojiForWord | function getEmojiForWord(word) {
let translations = getAllEmojiForWord(word);
return translations[Math.floor(Math.random() * translations.length)];
} | javascript | function getEmojiForWord(word) {
let translations = getAllEmojiForWord(word);
return translations[Math.floor(Math.random() * translations.length)];
} | [
"function",
"getEmojiForWord",
"(",
"word",
")",
"{",
"let",
"translations",
"=",
"getAllEmojiForWord",
"(",
"word",
")",
";",
"return",
"translations",
"[",
"Math",
".",
"floor",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"translations",
".",
"length",
")... | Returns a random emoji translation of an english word.
@param {String} word The word to be translated.
@returns {String} A random emoji translation or '' if none exists. | [
"Returns",
"a",
"random",
"emoji",
"translation",
"of",
"an",
"english",
"word",
"."
] | ed74d89410dc4aa3c67e19c5a9171b7267aba362 | https://github.com/notwaldorf/emoji-translate/blob/ed74d89410dc4aa3c67e19c5a9171b7267aba362/emoji-translate.js#L108-L111 | train |
notwaldorf/emoji-translate | emoji-translate.js | translate | function translate(sentence, onlyEmoji) {
let translation = '';
let words = sentence.split(' ');
for (let i = 0; i < words.length; i++ ) {
// Punctuation blows. Get all the punctuation at the start and end of the word.
// TODO: stop copy pasting this.
let firstSymbol = '';
let lastSymbol = '';
... | javascript | function translate(sentence, onlyEmoji) {
let translation = '';
let words = sentence.split(' ');
for (let i = 0; i < words.length; i++ ) {
// Punctuation blows. Get all the punctuation at the start and end of the word.
// TODO: stop copy pasting this.
let firstSymbol = '';
let lastSymbol = '';
... | [
"function",
"translate",
"(",
"sentence",
",",
"onlyEmoji",
")",
"{",
"let",
"translation",
"=",
"''",
";",
"let",
"words",
"=",
"sentence",
".",
"split",
"(",
"' '",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"words",
".",
"length"... | Translates an entire sentence to emoji. If multiple translations exist
for a particular word, a random emoji is picked.
@param {String} sentence The sentence to be translated
@param {Bool} onlyEmoji True if the translation should omit all untranslatable words
@returns {String} An emoji translation! | [
"Translates",
"an",
"entire",
"sentence",
"to",
"emoji",
".",
"If",
"multiple",
"translations",
"exist",
"for",
"a",
"particular",
"word",
"a",
"random",
"emoji",
"is",
"picked",
"."
] | ed74d89410dc4aa3c67e19c5a9171b7267aba362 | https://github.com/notwaldorf/emoji-translate/blob/ed74d89410dc4aa3c67e19c5a9171b7267aba362/emoji-translate.js#L165-L196 | train |
fzaninotto/uptime | lib/pollers/udp/udpPoller.js | function() {
var udpServer = dgram.createSocket('udp4');
// binding required for getting responses
udpServer.bind();
udpServer.on('error', function () {});
getUdpServer = function() {
return udpServer;
};
return getUdpServer();
} | javascript | function() {
var udpServer = dgram.createSocket('udp4');
// binding required for getting responses
udpServer.bind();
udpServer.on('error', function () {});
getUdpServer = function() {
return udpServer;
};
return getUdpServer();
} | [
"function",
"(",
")",
"{",
"var",
"udpServer",
"=",
"dgram",
".",
"createSocket",
"(",
"'udp4'",
")",
";",
"// binding required for getting responses",
"udpServer",
".",
"bind",
"(",
")",
";",
"udpServer",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
")"... | UdpServer Singleton, using self-redefining function | [
"UdpServer",
"Singleton",
"using",
"self",
"-",
"redefining",
"function"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/lib/pollers/udp/udpPoller.js#L12-L21 | train | |
fzaninotto/uptime | lib/pollers/udp/udpPoller.js | UdpPoller | function UdpPoller(target, timeout, callback) {
UdpPoller.super_.call(this, target, timeout, callback);
} | javascript | function UdpPoller(target, timeout, callback) {
UdpPoller.super_.call(this, target, timeout, callback);
} | [
"function",
"UdpPoller",
"(",
"target",
",",
"timeout",
",",
"callback",
")",
"{",
"UdpPoller",
".",
"super_",
".",
"call",
"(",
"this",
",",
"target",
",",
"timeout",
",",
"callback",
")",
";",
"}"
] | UDP Poller, to check UDP services
@param {Mixed} Poller Target (e.g. URL)
@param {Number} Poller timeout in milliseconds. Without response before this duration, the poller stops and executes the error callback.
@param {Function} Error/success callback
@api public | [
"UDP",
"Poller",
"to",
"check",
"UDP",
"services"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/lib/pollers/udp/udpPoller.js#L31-L33 | train |
fzaninotto/uptime | fixtures/populate.js | function(callback) {
console.log('Removing Checks');
async.series([
function(cb) { CheckEvent.collection.remove(cb); },
function(cb) { Check.collection.remove(cb); }
], callback);
} | javascript | function(callback) {
console.log('Removing Checks');
async.series([
function(cb) { CheckEvent.collection.remove(cb); },
function(cb) { Check.collection.remove(cb); }
], callback);
} | [
"function",
"(",
"callback",
")",
"{",
"console",
".",
"log",
"(",
"'Removing Checks'",
")",
";",
"async",
".",
"series",
"(",
"[",
"function",
"(",
"cb",
")",
"{",
"CheckEvent",
".",
"collection",
".",
"remove",
"(",
"cb",
")",
";",
"}",
",",
"funct... | defaults to 3 months ago | [
"defaults",
"to",
"3",
"months",
"ago"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/fixtures/populate.js#L9-L15 | train | |
fzaninotto/uptime | lib/pollers/https/httpsPoller.js | HttpsPoller | function HttpsPoller(target, timeout, callback) {
HttpsPoller.super_.call(this, target, timeout, callback);
} | javascript | function HttpsPoller(target, timeout, callback) {
HttpsPoller.super_.call(this, target, timeout, callback);
} | [
"function",
"HttpsPoller",
"(",
"target",
",",
"timeout",
",",
"callback",
")",
"{",
"HttpsPoller",
".",
"super_",
".",
"call",
"(",
"this",
",",
"target",
",",
"timeout",
",",
"callback",
")",
";",
"}"
] | HTTPS Poller, to check web pages served via SSL
@param {Mixed} Poller Target (e.g. URL)
@param {Number} Poller timeout in milliseconds. Without response before this duration, the poller stops and executes the error callback.
@param {Function} Error/success callback
@api public | [
"HTTPS",
"Poller",
"to",
"check",
"web",
"pages",
"served",
"via",
"SSL"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/lib/pollers/https/httpsPoller.js#L24-L26 | train |
fzaninotto/uptime | lib/pollers/http/httpPoller.js | HttpPoller | function HttpPoller(target, timeout, callback) {
HttpPoller.super_.call(this, target, timeout, callback);
} | javascript | function HttpPoller(target, timeout, callback) {
HttpPoller.super_.call(this, target, timeout, callback);
} | [
"function",
"HttpPoller",
"(",
"target",
",",
"timeout",
",",
"callback",
")",
"{",
"HttpPoller",
".",
"super_",
".",
"call",
"(",
"this",
",",
"target",
",",
"timeout",
",",
"callback",
")",
";",
"}"
] | HTTP Poller, to check web pages
@param {Mixed} Poller Target (e.g. URL)
@param {Number} Poller timeout in milliseconds. Without response before this duration, the poller stops and executes the error callback.
@param {Function} Error/success callback
@api public | [
"HTTP",
"Poller",
"to",
"check",
"web",
"pages"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/lib/pollers/http/httpPoller.js#L24-L26 | train |
fzaninotto/uptime | lib/pollers/basePoller.js | BasePoller | function BasePoller(target, timeout, callback) {
this.target = target;
this.timeout = timeout || 5000;
this.callback = callback;
this.isDebugEnabled = false;
this.initialize();
} | javascript | function BasePoller(target, timeout, callback) {
this.target = target;
this.timeout = timeout || 5000;
this.callback = callback;
this.isDebugEnabled = false;
this.initialize();
} | [
"function",
"BasePoller",
"(",
"target",
",",
"timeout",
",",
"callback",
")",
"{",
"this",
".",
"target",
"=",
"target",
";",
"this",
".",
"timeout",
"=",
"timeout",
"||",
"5000",
";",
"this",
".",
"callback",
"=",
"callback",
";",
"this",
".",
"isDeb... | Base Poller constructor
@param {Mixed} Poller Target (e.g. URL)
@param {Number} Poller timeout in milliseconds. Without response before this duration, the poller stops and executes the error callback.
@param {Function} Error/success callback
@api public | [
"Base",
"Poller",
"constructor"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/lib/pollers/basePoller.js#L14-L20 | train |
fzaninotto/uptime | app/api/routes/check.js | function(req, res, next) {
Check
.find({ _id: req.params.id })
.select({qos: 0})
.findOne(function(err, check) {
if (err) return next(err);
if (!check) return res.json(404, { error: 'failed to load check ' + req.params.id });
req.check = check;
next();
});
} | javascript | function(req, res, next) {
Check
.find({ _id: req.params.id })
.select({qos: 0})
.findOne(function(err, check) {
if (err) return next(err);
if (!check) return res.json(404, { error: 'failed to load check ' + req.params.id });
req.check = check;
next();
});
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"Check",
".",
"find",
"(",
"{",
"_id",
":",
"req",
".",
"params",
".",
"id",
"}",
")",
".",
"select",
"(",
"{",
"qos",
":",
"0",
"}",
")",
".",
"findOne",
"(",
"function",
"(",
"err",... | check route middleware | [
"check",
"route",
"middleware"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/app/api/routes/check.js#L41-L51 | train | |
fzaninotto/uptime | app/api/routes/tag.js | function(req, res, next) {
Tag.findOne({ name: req.params.name }, function(err, tag) {
if (err) return next(err);
if (!tag) return res.json(404, { error: 'failed to load tag ' + req.params.name });
req.tag = tag;
next();
});
} | javascript | function(req, res, next) {
Tag.findOne({ name: req.params.name }, function(err, tag) {
if (err) return next(err);
if (!tag) return res.json(404, { error: 'failed to load tag ' + req.params.name });
req.tag = tag;
next();
});
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"Tag",
".",
"findOne",
"(",
"{",
"name",
":",
"req",
".",
"params",
".",
"name",
"}",
",",
"function",
"(",
"err",
",",
"tag",
")",
"{",
"if",
"(",
"err",
")",
"return",
"next",
"(",
... | tag route middleware | [
"tag",
"route",
"middleware"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/app/api/routes/tag.js#L26-L33 | train | |
fzaninotto/uptime | lib/pollers/http/baseHttpPoller.js | BaseHttpPoller | function BaseHttpPoller(target, timeout, callback) {
BaseHttpPoller.super_.call(this, target, timeout, callback);
} | javascript | function BaseHttpPoller(target, timeout, callback) {
BaseHttpPoller.super_.call(this, target, timeout, callback);
} | [
"function",
"BaseHttpPoller",
"(",
"target",
",",
"timeout",
",",
"callback",
")",
"{",
"BaseHttpPoller",
".",
"super_",
".",
"call",
"(",
"this",
",",
"target",
",",
"timeout",
",",
"callback",
")",
";",
"}"
] | Abstract class for HTTP and HTTPS Pollers, to check web pages
@param {Mixed} Poller Target (e.g. URL)
@param {Number} Poller timeout in milliseconds. Without response before this duration, the poller stops and executes the error callback.
@param {Function} Error/success callback
@api public | [
"Abstract",
"class",
"for",
"HTTP",
"and",
"HTTPS",
"Pollers",
"to",
"check",
"web",
"pages"
] | e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294 | https://github.com/fzaninotto/uptime/blob/e2f6bfe42da7b9e8e1416cf9e0668fd9fb5e4294/lib/pollers/http/baseHttpPoller.js#L20-L22 | train |
Lucifier129/react-lite | addons/shallowCompare.js | shallowCompare | function shallowCompare(instance, nextProps, nextState) {
return (
!shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState)
);
} | javascript | function shallowCompare(instance, nextProps, nextState) {
return (
!shallowEqual(instance.props, nextProps) ||
!shallowEqual(instance.state, nextState)
);
} | [
"function",
"shallowCompare",
"(",
"instance",
",",
"nextProps",
",",
"nextState",
")",
"{",
"return",
"(",
"!",
"shallowEqual",
"(",
"instance",
".",
"props",
",",
"nextProps",
")",
"||",
"!",
"shallowEqual",
"(",
"instance",
".",
"state",
",",
"nextState",... | Does a shallow comparison for props and state.
See ReactComponentWithPureRenderMixin | [
"Does",
"a",
"shallow",
"comparison",
"for",
"props",
"and",
"state",
".",
"See",
"ReactComponentWithPureRenderMixin"
] | b7586ae247615f2d4c4373f206e6c284d7931f81 | https://github.com/Lucifier129/react-lite/blob/b7586ae247615f2d4c4373f206e6c284d7931f81/addons/shallowCompare.js#L17-L22 | train |
Lucifier129/react-lite | addons/utils/getIteratorFn.js | getIteratorFn | function getIteratorFn(maybeIterable) {
var iteratorFn = maybeIterable && (
(ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL]) ||
maybeIterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
} | javascript | function getIteratorFn(maybeIterable) {
var iteratorFn = maybeIterable && (
(ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL]) ||
maybeIterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
} | [
"function",
"getIteratorFn",
"(",
"maybeIterable",
")",
"{",
"var",
"iteratorFn",
"=",
"maybeIterable",
"&&",
"(",
"(",
"ITERATOR_SYMBOL",
"&&",
"maybeIterable",
"[",
"ITERATOR_SYMBOL",
"]",
")",
"||",
"maybeIterable",
"[",
"FAUX_ITERATOR_SYMBOL",
"]",
")",
";",
... | Before Symbol spec.
Returns the iterator method function contained on the iterable object.
Be sure to invoke the function with the iterable as context:
var iteratorFn = getIteratorFn(myIterable);
if (iteratorFn) {
var iterator = iteratorFn.call(myIterable);
...
}
@param {?object} maybeIterable
@return {?function} | [
"Before",
"Symbol",
"spec",
".",
"Returns",
"the",
"iterator",
"method",
"function",
"contained",
"on",
"the",
"iterable",
"object",
"."
] | b7586ae247615f2d4c4373f206e6c284d7931f81 | https://github.com/Lucifier129/react-lite/blob/b7586ae247615f2d4c4373f206e6c284d7931f81/addons/utils/getIteratorFn.js#L33-L41 | train |
Lucifier129/react-lite | addons/ReactStateSetters.js | function(component, funcReturningState) {
return function(a, b, c, d, e, f) {
var partialState = funcReturningState.call(component, a, b, c, d, e, f);
if (partialState) {
component.setState(partialState);
}
};
} | javascript | function(component, funcReturningState) {
return function(a, b, c, d, e, f) {
var partialState = funcReturningState.call(component, a, b, c, d, e, f);
if (partialState) {
component.setState(partialState);
}
};
} | [
"function",
"(",
"component",
",",
"funcReturningState",
")",
"{",
"return",
"function",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"f",
")",
"{",
"var",
"partialState",
"=",
"funcReturningState",
".",
"call",
"(",
"component",
",",
"a",
... | Returns a function that calls the provided function, and uses the result
of that to set the component's state.
@param {ReactCompositeComponent} component
@param {function} funcReturningState Returned callback uses this to
determine how to update state.
@return {function} callback that when invoked uses funcReturningSt... | [
"Returns",
"a",
"function",
"that",
"calls",
"the",
"provided",
"function",
"and",
"uses",
"the",
"result",
"of",
"that",
"to",
"set",
"the",
"component",
"s",
"state",
"."
] | b7586ae247615f2d4c4373f206e6c284d7931f81 | https://github.com/Lucifier129/react-lite/blob/b7586ae247615f2d4c4373f206e6c284d7931f81/addons/ReactStateSetters.js#L25-L32 | train | |
Lucifier129/react-lite | addons/ReactStateSetters.js | function(component, key) {
// Memoize the setters.
var cache = component.__keySetters || (component.__keySetters = {});
return cache[key] || (cache[key] = createStateKeySetter(component, key));
} | javascript | function(component, key) {
// Memoize the setters.
var cache = component.__keySetters || (component.__keySetters = {});
return cache[key] || (cache[key] = createStateKeySetter(component, key));
} | [
"function",
"(",
"component",
",",
"key",
")",
"{",
"// Memoize the setters.",
"var",
"cache",
"=",
"component",
".",
"__keySetters",
"||",
"(",
"component",
".",
"__keySetters",
"=",
"{",
"}",
")",
";",
"return",
"cache",
"[",
"key",
"]",
"||",
"(",
"ca... | Returns a single-argument callback that can be used to update a single
key in the component's state.
Note: this is memoized function, which makes it inexpensive to call.
@param {ReactCompositeComponent} component
@param {string} key The key in the state that you should update.
@return {function} callback of 1 argumen... | [
"Returns",
"a",
"single",
"-",
"argument",
"callback",
"that",
"can",
"be",
"used",
"to",
"update",
"a",
"single",
"key",
"in",
"the",
"component",
"s",
"state",
"."
] | b7586ae247615f2d4c4373f206e6c284d7931f81 | https://github.com/Lucifier129/react-lite/blob/b7586ae247615f2d4c4373f206e6c284d7931f81/addons/ReactStateSetters.js#L45-L49 | train | |
xmppjs/xmpp.js | server/index.js | kill | async function kill(pid) {
try {
process.kill(pid, 'SIGTERM')
} catch (err) {
if (err.code !== 'ESRCH') throw err
}
} | javascript | async function kill(pid) {
try {
process.kill(pid, 'SIGTERM')
} catch (err) {
if (err.code !== 'ESRCH') throw err
}
} | [
"async",
"function",
"kill",
"(",
"pid",
")",
"{",
"try",
"{",
"process",
".",
"kill",
"(",
"pid",
",",
"'SIGTERM'",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"err",
".",
"code",
"!==",
"'ESRCH'",
")",
"throw",
"err",
"}",
"}"
] | eslint-disable-next-line require-await | [
"eslint",
"-",
"disable",
"-",
"next",
"-",
"line",
"require",
"-",
"await"
] | 78f7a8fc220ce3dd013c60afacbf011400d23317 | https://github.com/xmppjs/xmpp.js/blob/78f7a8fc220ce3dd013c60afacbf011400d23317/server/index.js#L54-L60 | train |
PatrickJS/angular-websocket | src/angular-websocket.js | cancelableify | function cancelableify(promise) {
promise.cancel = cancel;
var then = promise.then;
promise.then = function() {
var newPromise = then.apply(this, arguments);
return cancelableify(newPromise);
};
return promise;
} | javascript | function cancelableify(promise) {
promise.cancel = cancel;
var then = promise.then;
promise.then = function() {
var newPromise = then.apply(this, arguments);
return cancelableify(newPromise);
};
return promise;
} | [
"function",
"cancelableify",
"(",
"promise",
")",
"{",
"promise",
".",
"cancel",
"=",
"cancel",
";",
"var",
"then",
"=",
"promise",
".",
"then",
";",
"promise",
".",
"then",
"=",
"function",
"(",
")",
"{",
"var",
"newPromise",
"=",
"then",
".",
"apply"... | Credit goes to @btford | [
"Credit",
"goes",
"to"
] | 1d3101e00cf396e1de436a26c6834f9b48529804 | https://github.com/PatrickJS/angular-websocket/blob/1d3101e00cf396e1de436a26c6834f9b48529804/src/angular-websocket.js#L286-L294 | train |
QuantumMechanics/NEM-sdk | src/crypto/cryptoHelpers.js | function(common, walletAccount, algo) {
// Errors
if(!common || !walletAccount || !algo) throw new Error('Missing argument !');
let r = undefined;
if (algo === "trezor") { // HW wallet
r = { 'priv': '' };
common.isHW = true;
} else if (!common.password) {
throw new Error('M... | javascript | function(common, walletAccount, algo) {
// Errors
if(!common || !walletAccount || !algo) throw new Error('Missing argument !');
let r = undefined;
if (algo === "trezor") { // HW wallet
r = { 'priv': '' };
common.isHW = true;
} else if (!common.password) {
throw new Error('M... | [
"function",
"(",
"common",
",",
"walletAccount",
",",
"algo",
")",
"{",
"// Errors",
"if",
"(",
"!",
"common",
"||",
"!",
"walletAccount",
"||",
"!",
"algo",
")",
"throw",
"new",
"Error",
"(",
"'Missing argument !'",
")",
";",
"let",
"r",
"=",
"undefined... | Reveal the private key of an account or derive it from the wallet password
@param {object} common- An object containing password and privateKey field
@param {object} walletAccount - A wallet account object
@param {string} algo - A wallet algorithm
@return {object|boolean} - The account private key in and object or fa... | [
"Reveal",
"the",
"private",
"key",
"of",
"an",
"account",
"or",
"derive",
"it",
"from",
"the",
"wallet",
"password"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/src/crypto/cryptoHelpers.js#L75-L133 | train | |
QuantumMechanics/NEM-sdk | src/crypto/cryptoHelpers.js | function(priv, network, _expectedAddress) {
// Errors
if (!priv || !network || !_expectedAddress) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(priv)) throw new Error('Private key is not valid !');
//Processing
let expectedAddress = _expectedAddress.toUpperCase().replace(/-/g... | javascript | function(priv, network, _expectedAddress) {
// Errors
if (!priv || !network || !_expectedAddress) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(priv)) throw new Error('Private key is not valid !');
//Processing
let expectedAddress = _expectedAddress.toUpperCase().replace(/-/g... | [
"function",
"(",
"priv",
",",
"network",
",",
"_expectedAddress",
")",
"{",
"// Errors",
"if",
"(",
"!",
"priv",
"||",
"!",
"network",
"||",
"!",
"_expectedAddress",
")",
"throw",
"new",
"Error",
"(",
"'Missing argument !'",
")",
";",
"if",
"(",
"!",
"He... | Check if a private key correspond to an account address
@param {string} priv - An account private key
@param {number} network - A network id
@param {string} _expectedAddress - The expected NEM address
@return {boolean} - True if valid, false otherwise | [
"Check",
"if",
"a",
"private",
"key",
"correspond",
"to",
"an",
"account",
"address"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/src/crypto/cryptoHelpers.js#L144-L154 | train | |
QuantumMechanics/NEM-sdk | src/crypto/cryptoHelpers.js | function(data, key) {
// Errors
if (!data || !key) throw new Error('Missing argument !');
// Processing
let iv = nacl.randomBytes(16)
let encKey = convert.ua2words(key, 32);
let encIv = {
iv: convert.ua2words(iv, 16)
};
let encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(... | javascript | function(data, key) {
// Errors
if (!data || !key) throw new Error('Missing argument !');
// Processing
let iv = nacl.randomBytes(16)
let encKey = convert.ua2words(key, 32);
let encIv = {
iv: convert.ua2words(iv, 16)
};
let encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Hex.parse(... | [
"function",
"(",
"data",
",",
"key",
")",
"{",
"// Errors",
"if",
"(",
"!",
"data",
"||",
"!",
"key",
")",
"throw",
"new",
"Error",
"(",
"'Missing argument !'",
")",
";",
"// Processing",
"let",
"iv",
"=",
"nacl",
".",
"randomBytes",
"(",
"16",
")",
... | Encrypt hex data using a key
@param {string} data - An hex string
@param {Uint8Array} key - An Uint8Array key
@return {object} - The encrypted data | [
"Encrypt",
"hex",
"data",
"using",
"a",
"key"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/src/crypto/cryptoHelpers.js#L193-L209 | train | |
QuantumMechanics/NEM-sdk | src/crypto/cryptoHelpers.js | function(privateKey, password) {
// Errors
if (!privateKey || !password) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(privateKey)) throw new Error('Private key is not valid !');
// Processing
let pass = derivePassSha(password, 20);
let r = encrypt(privateKey, convert.hex... | javascript | function(privateKey, password) {
// Errors
if (!privateKey || !password) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(privateKey)) throw new Error('Private key is not valid !');
// Processing
let pass = derivePassSha(password, 20);
let r = encrypt(privateKey, convert.hex... | [
"function",
"(",
"privateKey",
",",
"password",
")",
"{",
"// Errors",
"if",
"(",
"!",
"privateKey",
"||",
"!",
"password",
")",
"throw",
"new",
"Error",
"(",
"'Missing argument !'",
")",
";",
"if",
"(",
"!",
"Helpers",
".",
"isPrivateKeyValid",
"(",
"priv... | Encode a private key using a password
@param {string} privateKey - An hex private key
@param {string} password - A password
@return {object} - The encoded data | [
"Encode",
"a",
"private",
"key",
"using",
"a",
"password"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/src/crypto/cryptoHelpers.js#L238-L250 | train | |
QuantumMechanics/NEM-sdk | src/crypto/cryptoHelpers.js | function(senderPriv, recipientPub, msg) {
// Errors
if (!senderPriv || !recipientPub || !msg) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(senderPriv)) throw new Error('Private key is not valid !');
if (!Helpers.isPublicKeyValid(recipientPub)) throw new Error('Public key is not ... | javascript | function(senderPriv, recipientPub, msg) {
// Errors
if (!senderPriv || !recipientPub || !msg) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(senderPriv)) throw new Error('Private key is not valid !');
if (!Helpers.isPublicKeyValid(recipientPub)) throw new Error('Public key is not ... | [
"function",
"(",
"senderPriv",
",",
"recipientPub",
",",
"msg",
")",
"{",
"// Errors",
"if",
"(",
"!",
"senderPriv",
"||",
"!",
"recipientPub",
"||",
"!",
"msg",
")",
"throw",
"new",
"Error",
"(",
"'Missing argument !'",
")",
";",
"if",
"(",
"!",
"Helper... | Encode a message
@param {string} senderPriv - A sender private key
@param {string} recipientPub - A recipient public key
@param {string} msg - A text message
@return {string} - The encoded message | [
"Encode",
"a",
"message"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/src/crypto/cryptoHelpers.js#L292-L304 | train | |
QuantumMechanics/NEM-sdk | src/crypto/cryptoHelpers.js | function(recipientPrivate, senderPublic, _payload) {
// Errors
if(!recipientPrivate || !senderPublic || !_payload) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(recipientPrivate)) throw new Error('Private key is not valid !');
if (!Helpers.isPublicKeyValid(senderPublic)) throw ne... | javascript | function(recipientPrivate, senderPublic, _payload) {
// Errors
if(!recipientPrivate || !senderPublic || !_payload) throw new Error('Missing argument !');
if (!Helpers.isPrivateKeyValid(recipientPrivate)) throw new Error('Private key is not valid !');
if (!Helpers.isPublicKeyValid(senderPublic)) throw ne... | [
"function",
"(",
"recipientPrivate",
",",
"senderPublic",
",",
"_payload",
")",
"{",
"// Errors",
"if",
"(",
"!",
"recipientPrivate",
"||",
"!",
"senderPublic",
"||",
"!",
"_payload",
")",
"throw",
"new",
"Error",
"(",
"'Missing argument !'",
")",
";",
"if",
... | Decode an encrypted message payload
@param {string} recipientPrivate - A recipient private key
@param {string} senderPublic - A sender public key
@param {string} _payload - An encrypted message payload
@return {string} - The decoded payload as hex | [
"Decode",
"an",
"encrypted",
"message",
"payload"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/src/crypto/cryptoHelpers.js#L315-L340 | train | |
QuantumMechanics/NEM-sdk | examples/browser/transfer/script.js | updateFee | function updateFee() {
// Check for amount errors
if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');
// Set the cleaned amount into transfer transaction object
transferTransaction.amount = nem.utils.helpers.cleanTextAmount($("#amou... | javascript | function updateFee() {
// Check for amount errors
if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');
// Set the cleaned amount into transfer transaction object
transferTransaction.amount = nem.utils.helpers.cleanTextAmount($("#amou... | [
"function",
"updateFee",
"(",
")",
"{",
"// Check for amount errors",
"if",
"(",
"undefined",
"===",
"$",
"(",
"\"#amount\"",
")",
".",
"val",
"(",
")",
"||",
"!",
"nem",
".",
"utils",
".",
"helpers",
".",
"isTextAmountValid",
"(",
"$",
"(",
"\"#amount\"",... | Function to update our fee in the view | [
"Function",
"to",
"update",
"our",
"fee",
"in",
"the",
"view"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/examples/browser/transfer/script.js#L21-L39 | train |
QuantumMechanics/NEM-sdk | examples/browser/transfer/script.js | send | function send() {
// Check form for errors
if(!$("#privateKey").val() || !$("#recipient").val()) return alert('Missing parameter !');
if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');
if (!nem.model.address.isValid(nem.model.addres... | javascript | function send() {
// Check form for errors
if(!$("#privateKey").val() || !$("#recipient").val()) return alert('Missing parameter !');
if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');
if (!nem.model.address.isValid(nem.model.addres... | [
"function",
"send",
"(",
")",
"{",
"// Check form for errors",
"if",
"(",
"!",
"$",
"(",
"\"#privateKey\"",
")",
".",
"val",
"(",
")",
"||",
"!",
"$",
"(",
"\"#recipient\"",
")",
".",
"val",
"(",
")",
")",
"return",
"alert",
"(",
"'Missing parameter !'",... | Build transaction from form data and send | [
"Build",
"transaction",
"from",
"form",
"data",
"and",
"send"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/examples/browser/transfer/script.js#L44-L80 | train |
QuantumMechanics/NEM-sdk | examples/browser/offlineTransaction/create/script.js | create | function create() {
// Check form for errors
if(!$("#privateKey").val() || !$("#recipient").val()) return alert('Missing parameter !');
if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');
if (!nem.model.address.isValid(nem.model.addr... | javascript | function create() {
// Check form for errors
if(!$("#privateKey").val() || !$("#recipient").val()) return alert('Missing parameter !');
if(undefined === $("#amount").val() || !nem.utils.helpers.isTextAmountValid($("#amount").val())) return alert('Invalid amount !');
if (!nem.model.address.isValid(nem.model.addr... | [
"function",
"create",
"(",
")",
"{",
"// Check form for errors",
"if",
"(",
"!",
"$",
"(",
"\"#privateKey\"",
")",
".",
"val",
"(",
")",
"||",
"!",
"$",
"(",
"\"#recipient\"",
")",
".",
"val",
"(",
")",
")",
"return",
"alert",
"(",
"'Missing parameter !'... | Build transaction from form data | [
"Build",
"transaction",
"from",
"form",
"data"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/examples/browser/offlineTransaction/create/script.js#L41-L83 | train |
QuantumMechanics/NEM-sdk | examples/browser/monitor/script.js | showTransactions | function showTransactions(height) {
// Set the block height in modal title
$('#txsHeight').html(height);
// Get the transactions for that block
var txs = transactions[height];
// Reset the modal body
$('#txs').html('');
// Loop transactions
for(var i = 0; i < txs.length; i++) {
// Add stringified transaction ... | javascript | function showTransactions(height) {
// Set the block height in modal title
$('#txsHeight').html(height);
// Get the transactions for that block
var txs = transactions[height];
// Reset the modal body
$('#txs').html('');
// Loop transactions
for(var i = 0; i < txs.length; i++) {
// Add stringified transaction ... | [
"function",
"showTransactions",
"(",
"height",
")",
"{",
"// Set the block height in modal title",
"$",
"(",
"'#txsHeight'",
")",
".",
"html",
"(",
"height",
")",
";",
"// Get the transactions for that block",
"var",
"txs",
"=",
"transactions",
"[",
"height",
"]",
"... | Function to open modal and set transaction data into it | [
"Function",
"to",
"open",
"modal",
"and",
"set",
"transaction",
"data",
"into",
"it"
] | 4b0b60007c52ff4a89deeef84f9ca95b61c92fca | https://github.com/QuantumMechanics/NEM-sdk/blob/4b0b60007c52ff4a89deeef84f9ca95b61c92fca/examples/browser/monitor/script.js#L59-L73 | train |
angular-ui/ui-sortable | src/sortable.js | isFloating | function isFloating(item) {
return (
/left|right/.test(item.css('float')) ||
/inline|table-cell/.test(item.css('display'))
);
} | javascript | function isFloating(item) {
return (
/left|right/.test(item.css('float')) ||
/inline|table-cell/.test(item.css('display'))
);
} | [
"function",
"isFloating",
"(",
"item",
")",
"{",
"return",
"(",
"/",
"left|right",
"/",
".",
"test",
"(",
"item",
".",
"css",
"(",
"'float'",
")",
")",
"||",
"/",
"inline|table-cell",
"/",
".",
"test",
"(",
"item",
".",
"css",
"(",
"'display'",
")",
... | thanks jquery-ui | [
"thanks",
"jquery",
"-",
"ui"
] | e763b5765eea87743c8463ddf045a53015193c20 | https://github.com/angular-ui/ui-sortable/blob/e763b5765eea87743c8463ddf045a53015193c20/src/sortable.js#L268-L273 | train |
angular-ui/ui-sortable | demo/demo.js | function(e, ui) {
var logEntry = {
ID: $scope.sortingLog.length + 1,
Text: 'Moved element: ' + ui.item.scope().item.text
};
$scope.sortingLog.push(logEntry);
} | javascript | function(e, ui) {
var logEntry = {
ID: $scope.sortingLog.length + 1,
Text: 'Moved element: ' + ui.item.scope().item.text
};
$scope.sortingLog.push(logEntry);
} | [
"function",
"(",
"e",
",",
"ui",
")",
"{",
"var",
"logEntry",
"=",
"{",
"ID",
":",
"$scope",
".",
"sortingLog",
".",
"length",
"+",
"1",
",",
"Text",
":",
"'Moved element: '",
"+",
"ui",
".",
"item",
".",
"scope",
"(",
")",
".",
"item",
".",
"tex... | called after a node is dropped | [
"called",
"after",
"a",
"node",
"is",
"dropped"
] | e763b5765eea87743c8463ddf045a53015193c20 | https://github.com/angular-ui/ui-sortable/blob/e763b5765eea87743c8463ddf045a53015193c20/demo/demo.js#L25-L31 | train | |
angular-ui/ui-sortable | gruntFile.js | fakeTargetTask | function fakeTargetTask(prefix){
return function(){
if (this.args.length !== 1) {
return grunt.log.fail('Just give the name of the ' + prefix + ' you want like :\ngrunt ' + prefix + ':bower');
}
var done = this.async();
var spawn = require('child_process').spawn;
spawn('./nod... | javascript | function fakeTargetTask(prefix){
return function(){
if (this.args.length !== 1) {
return grunt.log.fail('Just give the name of the ' + prefix + ' you want like :\ngrunt ' + prefix + ':bower');
}
var done = this.async();
var spawn = require('child_process').spawn;
spawn('./nod... | [
"function",
"fakeTargetTask",
"(",
"prefix",
")",
"{",
"return",
"function",
"(",
")",
"{",
"if",
"(",
"this",
".",
"args",
".",
"length",
"!==",
"1",
")",
"{",
"return",
"grunt",
".",
"log",
".",
"fail",
"(",
"'Just give the name of the '",
"+",
"prefix... | HACK TO ACCESS TO THE COMPONENT PUBLISHER | [
"HACK",
"TO",
"ACCESS",
"TO",
"THE",
"COMPONENT",
"PUBLISHER"
] | e763b5765eea87743c8463ddf045a53015193c20 | https://github.com/angular-ui/ui-sortable/blob/e763b5765eea87743c8463ddf045a53015193c20/gruntFile.js#L19-L33 | train |
angular-ui/ui-sortable | gruntFile.js | function(configFile, customOptions) {
var options = { configFile: configFile, singleRun: true };
var travisOptions = process.env.TRAVIS && {
browsers: ['Chrome', 'Firefox'],
reporters: ['dots', 'coverage', 'coveralls'],
preprocessors: { 'src/*.js': ['coverage'] },
coverageReporter: {
... | javascript | function(configFile, customOptions) {
var options = { configFile: configFile, singleRun: true };
var travisOptions = process.env.TRAVIS && {
browsers: ['Chrome', 'Firefox'],
reporters: ['dots', 'coverage', 'coveralls'],
preprocessors: { 'src/*.js': ['coverage'] },
coverageReporter: {
... | [
"function",
"(",
"configFile",
",",
"customOptions",
")",
"{",
"var",
"options",
"=",
"{",
"configFile",
":",
"configFile",
",",
"singleRun",
":",
"true",
"}",
";",
"var",
"travisOptions",
"=",
"process",
".",
"env",
".",
"TRAVIS",
"&&",
"{",
"browsers",
... | HACK TO MAKE TRAVIS WORK | [
"HACK",
"TO",
"MAKE",
"TRAVIS",
"WORK"
] | e763b5765eea87743c8463ddf045a53015193c20 | https://github.com/angular-ui/ui-sortable/blob/e763b5765eea87743c8463ddf045a53015193c20/gruntFile.js#L41-L57 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(message, parsedLine, snippet, parsedFile){
this.rawMessage = message;
this.parsedLine = (parsedLine !== undefined) ? parsedLine : -1;
this.snippet = (snippet !== undefined) ? snippet : null;
this.parsedFile = (parsedFile !== undefined) ? parsedFile : null;
this.updateRepr();
this.message = mes... | javascript | function(message, parsedLine, snippet, parsedFile){
this.rawMessage = message;
this.parsedLine = (parsedLine !== undefined) ? parsedLine : -1;
this.snippet = (snippet !== undefined) ? snippet : null;
this.parsedFile = (parsedFile !== undefined) ? parsedFile : null;
this.updateRepr();
this.message = mes... | [
"function",
"(",
"message",
",",
"parsedLine",
",",
"snippet",
",",
"parsedFile",
")",
"{",
"this",
".",
"rawMessage",
"=",
"message",
";",
"this",
".",
"parsedLine",
"=",
"(",
"parsedLine",
"!==",
"undefined",
")",
"?",
"parsedLine",
":",
"-",
"1",
";",... | Exception class thrown when an error occurs during parsing.
@author Fabien Potencier <fabien@symfony.com>
@api
Constructor.
@param string message The error message
@param integer parsedLine The line where the error occurred
@param integer snippet The snippet of code near the problem
@param string parsedFile Th... | [
"Exception",
"class",
"thrown",
"when",
"an",
"error",
"occurs",
"during",
"parsing",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L40-L51 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(file /* String */, callback /* Function */)
{
if ( callback == null )
{
var input = this.getFileContents(file);
var ret = null;
try
{
ret = this.parse(input);
}
catch ( e )
{
if ( e instanceof YamlParseException ) {
e.setParsedFile(file);
}
throw e;
}
return... | javascript | function(file /* String */, callback /* Function */)
{
if ( callback == null )
{
var input = this.getFileContents(file);
var ret = null;
try
{
ret = this.parse(input);
}
catch ( e )
{
if ( e instanceof YamlParseException ) {
e.setParsedFile(file);
}
throw e;
}
return... | [
"function",
"(",
"file",
"/* String */",
",",
"callback",
"/* Function */",
")",
"{",
"if",
"(",
"callback",
"==",
"null",
")",
"{",
"var",
"input",
"=",
"this",
".",
"getFileContents",
"(",
"file",
")",
";",
"var",
"ret",
"=",
"null",
";",
"try",
"{",... | Parses YAML into a JS representation.
The parse method, when supplied with a YAML stream (file),
will do its best to convert YAML in a file into a JS representation.
Usage:
<code>
obj = yaml.parseFile('config.yml');
</code>
@param string input Path of YAML file
@return array The YAML converted to a JS representatio... | [
"Parses",
"YAML",
"into",
"a",
"JS",
"representation",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L193-L217 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(array, inline, spaces)
{
if ( inline == null ) inline = 2;
var yaml = new YamlDumper();
if (spaces) {
yaml.numSpacesForIndentation = spaces;
}
return yaml.dump(array, inline);
} | javascript | function(array, inline, spaces)
{
if ( inline == null ) inline = 2;
var yaml = new YamlDumper();
if (spaces) {
yaml.numSpacesForIndentation = spaces;
}
return yaml.dump(array, inline);
} | [
"function",
"(",
"array",
",",
"inline",
",",
"spaces",
")",
"{",
"if",
"(",
"inline",
"==",
"null",
")",
"inline",
"=",
"2",
";",
"var",
"yaml",
"=",
"new",
"YamlDumper",
"(",
")",
";",
"if",
"(",
"spaces",
")",
"{",
"yaml",
".",
"numSpacesForInde... | Dumps a JS representation to a YAML string.
The dump method, when supplied with an array, will do its best
to convert the array into friendly YAML.
@param array array JS representation
@param integer inline The level where you switch to inline YAML
@return string A YAML string representing the original JS represent... | [
"Dumps",
"a",
"JS",
"representation",
"to",
"a",
"YAML",
"string",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L256-L266 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
var result = null;
value = this.trim(value);
if ( 0 == value.length )
{
return '';
}
switch ( value.charAt(0) )
{
case '[':
result = this.parseSequence(value);
break;
case '{':
result = this.parseMapping(value);
break;
default:
result = this.parseScalar... | javascript | function(value)
{
var result = null;
value = this.trim(value);
if ( 0 == value.length )
{
return '';
}
switch ( value.charAt(0) )
{
case '[':
result = this.parseSequence(value);
break;
case '{':
result = this.parseMapping(value);
break;
default:
result = this.parseScalar... | [
"function",
"(",
"value",
")",
"{",
"var",
"result",
"=",
"null",
";",
"value",
"=",
"this",
".",
"trim",
"(",
"value",
")",
";",
"if",
"(",
"0",
"==",
"value",
".",
"length",
")",
"{",
"return",
"''",
";",
"}",
"switch",
"(",
"value",
".",
"ch... | Convert a YAML string to a JS object.
@param string value A YAML string
@return object A JS object representing the YAML string | [
"Convert",
"a",
"YAML",
"string",
"to",
"a",
"JS",
"object",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L410-L439 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
if ( undefined == value || null == value )
return 'null';
if ( value instanceof Date)
return value.toISOString();
if ( typeof(value) == 'object')
return this.dumpObject(value);
if ( typeof(value) == 'boolean' )
return value ? 'true' : 'false';
if ( /^\d+$/.test(value) )
retu... | javascript | function(value)
{
if ( undefined == value || null == value )
return 'null';
if ( value instanceof Date)
return value.toISOString();
if ( typeof(value) == 'object')
return this.dumpObject(value);
if ( typeof(value) == 'boolean' )
return value ? 'true' : 'false';
if ( /^\d+$/.test(value) )
retu... | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"undefined",
"==",
"value",
"||",
"null",
"==",
"value",
")",
"return",
"'null'",
";",
"if",
"(",
"value",
"instanceof",
"Date",
")",
"return",
"value",
".",
"toISOString",
"(",
")",
";",
"if",
"(",
"typ... | Dumps a given JS variable to a YAML string.
@param mixed value The JS variable to convert
@return string The YAML string representing the JS object | [
"Dumps",
"a",
"given",
"JS",
"variable",
"to",
"a",
"YAML",
"string",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L448-L477 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
var keys = this.getKeys(value);
var output = null;
var i;
var len = keys.length;
// array
if ( value instanceof Array )
/*( 1 == len && '0' == keys[0] )
||
( len > 1 && this.reduceArray(keys, function(v,w){return Math.floor(v+w);}, 0) == len * (len - 1) / 2) )*/
{
output = ... | javascript | function(value)
{
var keys = this.getKeys(value);
var output = null;
var i;
var len = keys.length;
// array
if ( value instanceof Array )
/*( 1 == len && '0' == keys[0] )
||
( len > 1 && this.reduceArray(keys, function(v,w){return Math.floor(v+w);}, 0) == len * (len - 1) / 2) )*/
{
output = ... | [
"function",
"(",
"value",
")",
"{",
"var",
"keys",
"=",
"this",
".",
"getKeys",
"(",
"value",
")",
";",
"var",
"output",
"=",
"null",
";",
"var",
"i",
";",
"var",
"len",
"=",
"keys",
".",
"length",
";",
"// array",
"if",
"(",
"value",
"instanceof",... | Dumps a JS object to a YAML string.
@param object value The JS array to dump
@return string The YAML string representing the JS object | [
"Dumps",
"a",
"JS",
"object",
"to",
"a",
"YAML",
"string",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L486-L516 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(scalar, delimiters, stringDelimiters, i, evaluate)
{
if ( delimiters == undefined ) delimiters = null;
if ( stringDelimiters == undefined ) stringDelimiters = ['"', "'"];
if ( i == undefined ) i = 0;
if ( evaluate == undefined ) evaluate = true;
var output = null;
var pos = null;
var matches ... | javascript | function(scalar, delimiters, stringDelimiters, i, evaluate)
{
if ( delimiters == undefined ) delimiters = null;
if ( stringDelimiters == undefined ) stringDelimiters = ['"', "'"];
if ( i == undefined ) i = 0;
if ( evaluate == undefined ) evaluate = true;
var output = null;
var pos = null;
var matches ... | [
"function",
"(",
"scalar",
",",
"delimiters",
",",
"stringDelimiters",
",",
"i",
",",
"evaluate",
")",
"{",
"if",
"(",
"delimiters",
"==",
"undefined",
")",
"delimiters",
"=",
"null",
";",
"if",
"(",
"stringDelimiters",
"==",
"undefined",
")",
"stringDelimit... | Parses a scalar to a YAML string.
@param scalar scalar
@param string delimiters
@param object stringDelimiters
@param integer i
@param boolean evaluate
@return string A YAML string
@throws YamlParseException When malformed inline YAML string is parsed | [
"Parses",
"a",
"scalar",
"to",
"a",
"YAML",
"string",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L531-L585 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(scalar, i)
{
var matches = null;
//var item = /^(.*?)['"]\s*(?:[,:]|[}\]]\s*,)/.exec((scalar+'').substring(i))[1];
if ( !(matches = new RegExp('^'+YamlInline.REGEX_QUOTED_STRING).exec((scalar+'').substring(i))) )
{
throw new YamlParseException('Malformed inline YAML string ('+(scalar+'').substri... | javascript | function(scalar, i)
{
var matches = null;
//var item = /^(.*?)['"]\s*(?:[,:]|[}\]]\s*,)/.exec((scalar+'').substring(i))[1];
if ( !(matches = new RegExp('^'+YamlInline.REGEX_QUOTED_STRING).exec((scalar+'').substring(i))) )
{
throw new YamlParseException('Malformed inline YAML string ('+(scalar+'').substri... | [
"function",
"(",
"scalar",
",",
"i",
")",
"{",
"var",
"matches",
"=",
"null",
";",
"//var item = /^(.*?)['\"]\\s*(?:[,:]|[}\\]]\\s*,)/.exec((scalar+'').substring(i))[1];",
"if",
"(",
"!",
"(",
"matches",
"=",
"new",
"RegExp",
"(",
"'^'",
"+",
"YamlInline",
".",
"R... | Parses a quoted scalar to YAML.
@param string scalar
@param integer i
@return string A YAML string
@throws YamlParseException When malformed inline YAML string is parsed | [
"Parses",
"a",
"quoted",
"scalar",
"to",
"YAML",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L597-L624 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(sequence, i)
{
if ( i == undefined ) i = 0;
var output = [];
var len = sequence.length;
i += 1;
// [foo, bar, ...]
while ( i < len )
{
switch ( sequence.charAt(i) )
{
case '[':
// nested sequence
output.push(this.parseSequence(sequence, i));
i = this.i;
break;
... | javascript | function(sequence, i)
{
if ( i == undefined ) i = 0;
var output = [];
var len = sequence.length;
i += 1;
// [foo, bar, ...]
while ( i < len )
{
switch ( sequence.charAt(i) )
{
case '[':
// nested sequence
output.push(this.parseSequence(sequence, i));
i = this.i;
break;
... | [
"function",
"(",
"sequence",
",",
"i",
")",
"{",
"if",
"(",
"i",
"==",
"undefined",
")",
"i",
"=",
"0",
";",
"var",
"output",
"=",
"[",
"]",
";",
"var",
"len",
"=",
"sequence",
".",
"length",
";",
"i",
"+=",
"1",
";",
"// [foo, bar, ...]",
"while... | Parses a sequence to a YAML string.
@param string sequence
@param integer i
@return string A YAML string
@throws YamlParseException When malformed inline YAML string is parsed | [
"Parses",
"a",
"sequence",
"to",
"a",
"YAML",
"string",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L636-L693 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(mapping, i)
{
if ( i == undefined ) i = 0;
var output = {};
var len = mapping.length;
i += 1;
var done = false;
var doContinue = false;
// {foo: bar, bar:foo, ...}
while ( i < len )
{
doContinue = false;
switch ( mapping.charAt(i) )
{
case ' ':
case ',':
i++;
... | javascript | function(mapping, i)
{
if ( i == undefined ) i = 0;
var output = {};
var len = mapping.length;
i += 1;
var done = false;
var doContinue = false;
// {foo: bar, bar:foo, ...}
while ( i < len )
{
doContinue = false;
switch ( mapping.charAt(i) )
{
case ' ':
case ',':
i++;
... | [
"function",
"(",
"mapping",
",",
"i",
")",
"{",
"if",
"(",
"i",
"==",
"undefined",
")",
"i",
"=",
"0",
";",
"var",
"output",
"=",
"{",
"}",
";",
"var",
"len",
"=",
"mapping",
".",
"length",
";",
"i",
"+=",
"1",
";",
"var",
"done",
"=",
"false... | Parses a mapping to a YAML string.
@param string mapping
@param integer i
@return string A YAML string
@throws YamlParseException When malformed inline YAML string is parsed | [
"Parses",
"a",
"mapping",
"to",
"a",
"YAML",
"string",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L705-L778 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(scalar)
{
scalar = this.trim(scalar);
var raw = null;
var cast = null;
if ( ( 'null' == scalar.toLowerCase() ) ||
( '' == scalar ) ||
( '~' == scalar ) )
return null;
if ( (scalar+'').indexOf('!str ') == 0 )
return (''+scalar).substring(5);
if ( (scalar+'').indexOf('! ') == 0 )
... | javascript | function(scalar)
{
scalar = this.trim(scalar);
var raw = null;
var cast = null;
if ( ( 'null' == scalar.toLowerCase() ) ||
( '' == scalar ) ||
( '~' == scalar ) )
return null;
if ( (scalar+'').indexOf('!str ') == 0 )
return (''+scalar).substring(5);
if ( (scalar+'').indexOf('! ') == 0 )
... | [
"function",
"(",
"scalar",
")",
"{",
"scalar",
"=",
"this",
".",
"trim",
"(",
"scalar",
")",
";",
"var",
"raw",
"=",
"null",
";",
"var",
"cast",
"=",
"null",
";",
"if",
"(",
"(",
"'null'",
"==",
"scalar",
".",
"toLowerCase",
"(",
")",
")",
"||",
... | Evaluates scalars and replaces magic values.
@param string scalar
@return string A YAML string | [
"Evaluates",
"scalars",
"and",
"replaces",
"magic",
"values",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L787-L826 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value /* String */)
{
this.currentLineNb = -1;
this.currentLine = '';
this.lines = this.cleanup(value).split("\n");
var data = null;
var context = null;
while ( this.moveToNextLine() )
{
if ( this.isCurrentLineEmpty() )
{
continue;
}
// tab?
if ( this.curre... | javascript | function(value /* String */)
{
this.currentLineNb = -1;
this.currentLine = '';
this.lines = this.cleanup(value).split("\n");
var data = null;
var context = null;
while ( this.moveToNextLine() )
{
if ( this.isCurrentLineEmpty() )
{
continue;
}
// tab?
if ( this.curre... | [
"function",
"(",
"value",
"/* String */",
")",
"{",
"this",
".",
"currentLineNb",
"=",
"-",
"1",
";",
"this",
".",
"currentLine",
"=",
"''",
";",
"this",
".",
"lines",
"=",
"this",
".",
"cleanup",
"(",
"value",
")",
".",
"split",
"(",
"\"\\n\"",
")",... | Parses a YAML string to a JS value.
@param String value A YAML string
@return mixed A JS value | [
"Parses",
"a",
"YAML",
"string",
"to",
"a",
"JS",
"value",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L976-L1239 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(indentation)
{
this.moveToNextLine();
var newIndent = null;
var indent = null;
if ( !this.isDefined(indentation) )
{
newIndent = this.getCurrentLineIndentation();
var unindentedEmbedBlock = this.isStringUnIndentedCollectionItem(this.currentLine);
if ( !this.isCurrentLineEmpty() && 0 =... | javascript | function(indentation)
{
this.moveToNextLine();
var newIndent = null;
var indent = null;
if ( !this.isDefined(indentation) )
{
newIndent = this.getCurrentLineIndentation();
var unindentedEmbedBlock = this.isStringUnIndentedCollectionItem(this.currentLine);
if ( !this.isCurrentLineEmpty() && 0 =... | [
"function",
"(",
"indentation",
")",
"{",
"this",
".",
"moveToNextLine",
"(",
")",
";",
"var",
"newIndent",
"=",
"null",
";",
"var",
"indent",
"=",
"null",
";",
"if",
"(",
"!",
"this",
".",
"isDefined",
"(",
"indentation",
")",
")",
"{",
"newIndent",
... | Returns the next embed block of YAML.
@param integer indentation The indent level at which the block is to be read, or null for default
@return string A YAML string
@throws YamlParseException When indentation problem are detected | [
"Returns",
"the",
"next",
"embed",
"block",
"of",
"YAML",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1270-L1343 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
if ( '*' == (value+'').charAt(0) )
{
if ( this.trim(value).charAt(0) == '#' )
{
value = (value+'').substr(1, value.indexOf('#') - 2);
}
else
{
value = (value+'').substr(1);
}
if ( this.refs[value] == undefined )
{
throw new YamlParseException('Reference "'+val... | javascript | function(value)
{
if ( '*' == (value+'').charAt(0) )
{
if ( this.trim(value).charAt(0) == '#' )
{
value = (value+'').substr(1, value.indexOf('#') - 2);
}
else
{
value = (value+'').substr(1);
}
if ( this.refs[value] == undefined )
{
throw new YamlParseException('Reference "'+val... | [
"function",
"(",
"value",
")",
"{",
"if",
"(",
"'*'",
"==",
"(",
"value",
"+",
"''",
")",
".",
"charAt",
"(",
"0",
")",
")",
"{",
"if",
"(",
"this",
".",
"trim",
"(",
"value",
")",
".",
"charAt",
"(",
"0",
")",
"==",
"'#'",
")",
"{",
"value... | Parses a YAML value.
@param string value A YAML value
@return mixed A JS value
@throws YamlParseException When reference does not exist | [
"Parses",
"a",
"YAML",
"value",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1381-L1418 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(separator, indicator, indentation)
{
if ( indicator == undefined ) indicator = '';
if ( indentation == undefined ) indentation = 0;
separator = '|' == separator ? "\n" : ' ';
var text = '';
var diff = null;
var notEOF = this.moveToNextLine();
while ( notEOF && this.isCurrentLineBlank() )
... | javascript | function(separator, indicator, indentation)
{
if ( indicator == undefined ) indicator = '';
if ( indentation == undefined ) indentation = 0;
separator = '|' == separator ? "\n" : ' ';
var text = '';
var diff = null;
var notEOF = this.moveToNextLine();
while ( notEOF && this.isCurrentLineBlank() )
... | [
"function",
"(",
"separator",
",",
"indicator",
",",
"indentation",
")",
"{",
"if",
"(",
"indicator",
"==",
"undefined",
")",
"indicator",
"=",
"''",
";",
"if",
"(",
"indentation",
"==",
"undefined",
")",
"indentation",
"=",
"0",
";",
"separator",
"=",
"... | Parses a folded scalar.
@param string separator The separator that was used to begin this folded scalar (| or >)
@param string indicator The indicator that was used to begin this folded scalar (+ or -)
@param integer indentation The indentation that was used to begin this folded scalar
@return string The text valu... | [
"Parses",
"a",
"folded",
"scalar",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1429-L1515 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
value = value.split("\r\n").join("\n").split("\r").join("\n");
if ( !/\n$/.test(value) )
{
value += "\n";
}
// strip YAML header
var count = 0;
var regex = /^\%YAML[: ][\d\.]+.*\n/;
while ( regex.test(value) )
{
value = value.replace(regex, '');
count++;
}
this.offset... | javascript | function(value)
{
value = value.split("\r\n").join("\n").split("\r").join("\n");
if ( !/\n$/.test(value) )
{
value += "\n";
}
// strip YAML header
var count = 0;
var regex = /^\%YAML[: ][\d\.]+.*\n/;
while ( regex.test(value) )
{
value = value.replace(regex, '');
count++;
}
this.offset... | [
"function",
"(",
"value",
")",
"{",
"value",
"=",
"value",
".",
"split",
"(",
"\"\\r\\n\"",
")",
".",
"join",
"(",
"\"\\n\"",
")",
".",
"split",
"(",
"\"\\r\"",
")",
".",
"join",
"(",
"\"\\n\"",
")",
";",
"if",
"(",
"!",
"/",
"\\n$",
"/",
".",
... | Cleanups a YAML string to be parsed.
@param string value The input YAML string
@return string A cleaned up YAML string | [
"Cleanups",
"a",
"YAML",
"string",
"to",
"be",
"parsed",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1587-L1632 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
value = value + '';
var len = YamlEscaper.escapees.length;
var maxlen = YamlEscaper.escaped.length;
var esc = YamlEscaper.escaped;
for (var i = 0; i < len; ++i)
if ( i >= maxlen ) esc.push('');
var ret = '';
ret = value.replace(new RegExp(YamlEscaper.escapees.join('|'),'g'), funct... | javascript | function(value)
{
value = value + '';
var len = YamlEscaper.escapees.length;
var maxlen = YamlEscaper.escaped.length;
var esc = YamlEscaper.escaped;
for (var i = 0; i < len; ++i)
if ( i >= maxlen ) esc.push('');
var ret = '';
ret = value.replace(new RegExp(YamlEscaper.escapees.join('|'),'g'), funct... | [
"function",
"(",
"value",
")",
"{",
"value",
"=",
"value",
"+",
"''",
";",
"var",
"len",
"=",
"YamlEscaper",
".",
"escapees",
".",
"length",
";",
"var",
"maxlen",
"=",
"YamlEscaper",
".",
"escaped",
".",
"length",
";",
"var",
"esc",
"=",
"YamlEscaper",... | Escapes and surrounds a JS value with double quotes.
@param string value A JS value
@return string The quoted, escaped string | [
"Escapes",
"and",
"surrounds",
"a",
"JS",
"value",
"with",
"double",
"quotes",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1787-L1804 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
var callback = function(m) {
return new YamlUnescaper().unescapeCharacter(m);
};
// evaluate the string
return value.replace(new RegExp(YamlUnescaper.REGEX_ESCAPED_CHARACTER, 'g'), callback);
} | javascript | function(value)
{
var callback = function(m) {
return new YamlUnescaper().unescapeCharacter(m);
};
// evaluate the string
return value.replace(new RegExp(YamlUnescaper.REGEX_ESCAPED_CHARACTER, 'g'), callback);
} | [
"function",
"(",
"value",
")",
"{",
"var",
"callback",
"=",
"function",
"(",
"m",
")",
"{",
"return",
"new",
"YamlUnescaper",
"(",
")",
".",
"unescapeCharacter",
"(",
"m",
")",
";",
"}",
";",
"// evaluate the string",
"return",
"value",
".",
"replace",
"... | Unescapes a double quoted string.
@param string value A double quoted string.
@return string The unescaped string. | [
"Unescapes",
"a",
"double",
"quoted",
"string",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1876-L1884 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(value)
{
switch (value.charAt(1)) {
case '0':
return String.fromCharCode(0);
case 'a':
return String.fromCharCode(7);
case 'b':
return String.fromCharCode(8);
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return String.fromCh... | javascript | function(value)
{
switch (value.charAt(1)) {
case '0':
return String.fromCharCode(0);
case 'a':
return String.fromCharCode(7);
case 'b':
return String.fromCharCode(8);
case 't':
return "\t";
case "\t":
return "\t";
case 'n':
return "\n";
case 'v':
return String.fromCh... | [
"function",
"(",
"value",
")",
"{",
"switch",
"(",
"value",
".",
"charAt",
"(",
"1",
")",
")",
"{",
"case",
"'0'",
":",
"return",
"String",
".",
"fromCharCode",
"(",
"0",
")",
";",
"case",
"'a'",
":",
"return",
"String",
".",
"fromCharCode",
"(",
"... | Unescapes a character that was found in a double-quoted string
@param string value An escaped character
@return string The unescaped character | [
"Unescapes",
"a",
"character",
"that",
"was",
"found",
"in",
"a",
"double",
"-",
"quoted",
"string"
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1893-L1943 | train | |
jeremyfa/yaml.js | dist/yaml.legacy.js | function(input, inline, indent)
{
if ( inline == null ) inline = 0;
if ( indent == null ) indent = 0;
var output = '';
var prefix = indent ? this.strRepeat(' ', indent) : '';
var yaml;
if (!this.numSpacesForIndentation) this.numSpacesForIndentation = 2;
if ( inline <= 0 || !this.isObject(input) || this.... | javascript | function(input, inline, indent)
{
if ( inline == null ) inline = 0;
if ( indent == null ) indent = 0;
var output = '';
var prefix = indent ? this.strRepeat(' ', indent) : '';
var yaml;
if (!this.numSpacesForIndentation) this.numSpacesForIndentation = 2;
if ( inline <= 0 || !this.isObject(input) || this.... | [
"function",
"(",
"input",
",",
"inline",
",",
"indent",
")",
"{",
"if",
"(",
"inline",
"==",
"null",
")",
"inline",
"=",
"0",
";",
"if",
"(",
"indent",
"==",
"null",
")",
"indent",
"=",
"0",
";",
"var",
"output",
"=",
"''",
";",
"var",
"prefix",
... | Dumps a JS value to YAML.
@param mixed input The JS value
@param integer inline The level where you switch to inline YAML
@param integer indent The level o indentation indentation (used internally)
@return string The YAML representation of the JS value | [
"Dumps",
"a",
"JS",
"value",
"to",
"YAML",
"."
] | 0b53177b26dfe0c2081465e3a496c9b4cb5b1c63 | https://github.com/jeremyfa/yaml.js/blob/0b53177b26dfe0c2081465e3a496c9b4cb5b1c63/dist/yaml.legacy.js#L1974-L2012 | train | |
d3fc/d3fc | packages/d3fc-site/builder/handlebars-helpers/escape.js | register | function register(handlebars) {
handlebars.registerHelper('escape', function(variable) {
return variable.replace(/['"]/g, '\\"').replace(/[\n]/g, '\\n');
});
} | javascript | function register(handlebars) {
handlebars.registerHelper('escape', function(variable) {
return variable.replace(/['"]/g, '\\"').replace(/[\n]/g, '\\n');
});
} | [
"function",
"register",
"(",
"handlebars",
")",
"{",
"handlebars",
".",
"registerHelper",
"(",
"'escape'",
",",
"function",
"(",
"variable",
")",
"{",
"return",
"variable",
".",
"replace",
"(",
"/",
"['\"]",
"/",
"g",
",",
"'\\\\\"'",
")",
".",
"replace",
... | escapes quotes and newline characters using a backslash | [
"escapes",
"quotes",
"and",
"newline",
"characters",
"using",
"a",
"backslash"
] | 170b25711ef1fedb3adbee5dbff94e66114b17ff | https://github.com/d3fc/d3fc/blob/170b25711ef1fedb3adbee5dbff94e66114b17ff/packages/d3fc-site/builder/handlebars-helpers/escape.js#L2-L6 | train |
d3fc/d3fc | packages/d3fc-sample/site/demo.js | strategyInterceptor | function strategyInterceptor(strategy) {
var interceptor = function(layout) {
var start = new Date().getMilliseconds();
var finalLayout = strategy(data);
var time = new Date().getMilliseconds() - start;
// record some statistics on this strategy
if (!interceptor.time) {
... | javascript | function strategyInterceptor(strategy) {
var interceptor = function(layout) {
var start = new Date().getMilliseconds();
var finalLayout = strategy(data);
var time = new Date().getMilliseconds() - start;
// record some statistics on this strategy
if (!interceptor.time) {
... | [
"function",
"strategyInterceptor",
"(",
"strategy",
")",
"{",
"var",
"interceptor",
"=",
"function",
"(",
"layout",
")",
"{",
"var",
"start",
"=",
"new",
"Date",
"(",
")",
".",
"getMilliseconds",
"(",
")",
";",
"var",
"finalLayout",
"=",
"strategy",
"(",
... | we intercept the strategy in order to capture the final layout and compute statistics | [
"we",
"intercept",
"the",
"strategy",
"in",
"order",
"to",
"capture",
"the",
"final",
"layout",
"and",
"compute",
"statistics"
] | 170b25711ef1fedb3adbee5dbff94e66114b17ff | https://github.com/d3fc/d3fc/blob/170b25711ef1fedb3adbee5dbff94e66114b17ff/packages/d3fc-sample/site/demo.js#L23-L42 | train |
mesosphere/reactjs-components | src/Util/Util.js | basePick | function basePick(object, props) {
object = Object(object);
const { length } = props;
const result = {};
let index = -1;
while (++index < length) {
const key = props[index];
if (key in object) {
result[key] = object[key];
}
}
return result;
} | javascript | function basePick(object, props) {
object = Object(object);
const { length } = props;
const result = {};
let index = -1;
while (++index < length) {
const key = props[index];
if (key in object) {
result[key] = object[key];
}
}
return result;
} | [
"function",
"basePick",
"(",
"object",
",",
"props",
")",
"{",
"object",
"=",
"Object",
"(",
"object",
")",
";",
"const",
"{",
"length",
"}",
"=",
"props",
";",
"const",
"result",
"=",
"{",
"}",
";",
"let",
"index",
"=",
"-",
"1",
";",
"while",
"... | Functions from lodash 4.0.0-pre
The base implementation of `_.pick` without support for individual
property names.
@private
@param {Object} object The source object.
@param {string[]} props The property names to pick.
@returns {Object} Returns the new object. | [
"Functions",
"from",
"lodash",
"4",
".",
"0",
".",
"0",
"-",
"pre",
"The",
"base",
"implementation",
"of",
"_",
".",
"pick",
"without",
"support",
"for",
"individual",
"property",
"names",
"."
] | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/src/Util/Util.js#L14-L29 | train |
mesosphere/reactjs-components | src/Util/Util.js | baseValues | function baseValues(object, props) {
const { length } = props;
const result = Array(length);
let index = -1;
while (++index < length) {
result[index] = object[props[index]];
}
return result;
} | javascript | function baseValues(object, props) {
const { length } = props;
const result = Array(length);
let index = -1;
while (++index < length) {
result[index] = object[props[index]];
}
return result;
} | [
"function",
"baseValues",
"(",
"object",
",",
"props",
")",
"{",
"const",
"{",
"length",
"}",
"=",
"props",
";",
"const",
"result",
"=",
"Array",
"(",
"length",
")",
";",
"let",
"index",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"index",
"<",
"length... | The base implementation of `_.values` and `_.valuesIn` which creates an
array of `object` property values corresponding to the property names
of `props`.
@private
@param {Object} object The object to query.
@param {Array} props The property names to get values for.
@returns {Object} Returns the array of property value... | [
"The",
"base",
"implementation",
"of",
"_",
".",
"values",
"and",
"_",
".",
"valuesIn",
"which",
"creates",
"an",
"array",
"of",
"object",
"property",
"values",
"corresponding",
"to",
"the",
"property",
"names",
"of",
"props",
"."
] | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/src/Util/Util.js#L41-L51 | train |
mesosphere/reactjs-components | src/Util/Util.js | isArrayLike | function isArrayLike(value) {
return (
value != null &&
value.length &&
!(
typeof value === "function" &&
Object.prototype.toString.call(value) === "[object Function]"
) &&
typeof value === "object"
);
} | javascript | function isArrayLike(value) {
return (
value != null &&
value.length &&
!(
typeof value === "function" &&
Object.prototype.toString.call(value) === "[object Function]"
) &&
typeof value === "object"
);
} | [
"function",
"isArrayLike",
"(",
"value",
")",
"{",
"return",
"(",
"value",
"!=",
"null",
"&&",
"value",
".",
"length",
"&&",
"!",
"(",
"typeof",
"value",
"===",
"\"function\"",
"&&",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"value",... | Checks if `value` is array-like. A value is considered array-like if it's
not a function and has a `value.length` that's an integer greater than or
equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
@static
@category Lang
@param {*} value The value to check.
@return {Boolean} Returns `true` if `value` i... | [
"Checks",
"if",
"value",
"is",
"array",
"-",
"like",
".",
"A",
"value",
"is",
"considered",
"array",
"-",
"like",
"if",
"it",
"s",
"not",
"a",
"function",
"and",
"has",
"a",
"value",
".",
"length",
"that",
"s",
"an",
"integer",
"greater",
"than",
"or... | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/src/Util/Util.js#L100-L110 | train |
mesosphere/reactjs-components | src/Util/Util.js | deepEq | function deepEq(a, b, aStack, bStack) {
// Compare `[[Class]]` names.
var className = Object.prototype.toString.call(a);
if (className !== Object.prototype.toString.call(b)) {
return false;
}
/* eslint-disable no-fallthrough */
switch (className) {
// Strings, numbers, regular expressions, dates, a... | javascript | function deepEq(a, b, aStack, bStack) {
// Compare `[[Class]]` names.
var className = Object.prototype.toString.call(a);
if (className !== Object.prototype.toString.call(b)) {
return false;
}
/* eslint-disable no-fallthrough */
switch (className) {
// Strings, numbers, regular expressions, dates, a... | [
"function",
"deepEq",
"(",
"a",
",",
"b",
",",
"aStack",
",",
"bStack",
")",
"{",
"// Compare `[[Class]]` names.",
"var",
"className",
"=",
"Object",
".",
"prototype",
".",
"toString",
".",
"call",
"(",
"a",
")",
";",
"if",
"(",
"className",
"!==",
"Obje... | Internal recursive comparison function for `isEqual`. | [
"Internal",
"recursive",
"comparison",
"function",
"for",
"isEqual",
"."
] | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/src/Util/Util.js#L237-L349 | train |
mesosphere/reactjs-components | src/Util/Util.js | clone | function clone(object) {
if (object === null || typeof object != "object") {
return object;
}
const copy = object.constructor();
for (const attr in object) {
if (Object.prototype.hasOwnProperty.call(object, attr)) {
copy[attr] = object[attr];
}
}
return copy;
} | javascript | function clone(object) {
if (object === null || typeof object != "object") {
return object;
}
const copy = object.constructor();
for (const attr in object) {
if (Object.prototype.hasOwnProperty.call(object, attr)) {
copy[attr] = object[attr];
}
}
return copy;
} | [
"function",
"clone",
"(",
"object",
")",
"{",
"if",
"(",
"object",
"===",
"null",
"||",
"typeof",
"object",
"!=",
"\"object\"",
")",
"{",
"return",
"object",
";",
"}",
"const",
"copy",
"=",
"object",
".",
"constructor",
"(",
")",
";",
"for",
"(",
"co... | Custom functions created for reactjs-components | [
"Custom",
"functions",
"created",
"for",
"reactjs",
"-",
"components"
] | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/src/Util/Util.js#L407-L419 | train |
mesosphere/reactjs-components | src/Util/Util.js | exclude | function exclude(object, props) {
const newObject = {};
Object.keys(object).forEach(function(prop) {
if (props.indexOf(prop) === -1) {
newObject[prop] = object[prop];
}
});
return newObject;
} | javascript | function exclude(object, props) {
const newObject = {};
Object.keys(object).forEach(function(prop) {
if (props.indexOf(prop) === -1) {
newObject[prop] = object[prop];
}
});
return newObject;
} | [
"function",
"exclude",
"(",
"object",
",",
"props",
")",
"{",
"const",
"newObject",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"object",
")",
".",
"forEach",
"(",
"function",
"(",
"prop",
")",
"{",
"if",
"(",
"props",
".",
"indexOf",
"(",
"pro... | Excludes given properties from object
@param {Object} object
@param {Array} props Array of properties to remove
@return {Object} New object without given props | [
"Excludes",
"given",
"properties",
"from",
"object"
] | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/src/Util/Util.js#L428-L438 | train |
mesosphere/reactjs-components | src/Form/Form.js | findFieldOption | function findFieldOption(options, field) {
const flattenedOptions = Util.flatten(options);
return Util.find(flattenedOptions, function(fieldOption) {
var isField = fieldOption.name === field;
if (fieldOption.fieldType === "object" && !isField) {
return findFieldOption(fieldOption.definition, field);
... | javascript | function findFieldOption(options, field) {
const flattenedOptions = Util.flatten(options);
return Util.find(flattenedOptions, function(fieldOption) {
var isField = fieldOption.name === field;
if (fieldOption.fieldType === "object" && !isField) {
return findFieldOption(fieldOption.definition, field);
... | [
"function",
"findFieldOption",
"(",
"options",
",",
"field",
")",
"{",
"const",
"flattenedOptions",
"=",
"Util",
".",
"flatten",
"(",
"options",
")",
";",
"return",
"Util",
".",
"find",
"(",
"flattenedOptions",
",",
"function",
"(",
"fieldOption",
")",
"{",
... | Find a the options for a particular field in the form. | [
"Find",
"a",
"the",
"options",
"for",
"a",
"particular",
"field",
"in",
"the",
"form",
"."
] | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/src/Form/Form.js#L10-L21 | train |
mesosphere/reactjs-components | docs/gulpTasks.js | eslintFn | function eslintFn() {
return gulp
.src([config.files.docs.srcJS])
.pipe(eslint())
.pipe(eslint.formatEach("stylish", process.stderr));
} | javascript | function eslintFn() {
return gulp
.src([config.files.docs.srcJS])
.pipe(eslint())
.pipe(eslint.formatEach("stylish", process.stderr));
} | [
"function",
"eslintFn",
"(",
")",
"{",
"return",
"gulp",
".",
"src",
"(",
"[",
"config",
".",
"files",
".",
"docs",
".",
"srcJS",
"]",
")",
".",
"pipe",
"(",
"eslint",
"(",
")",
")",
".",
"pipe",
"(",
"eslint",
".",
"formatEach",
"(",
"\"stylish\""... | Create a function so we can use it inside of webpack's watch function. | [
"Create",
"a",
"function",
"so",
"we",
"can",
"use",
"it",
"inside",
"of",
"webpack",
"s",
"watch",
"function",
"."
] | 363b189f17ce7891d3581a76a90cc39346f96cda | https://github.com/mesosphere/reactjs-components/blob/363b189f17ce7891d3581a76a90cc39346f96cda/docs/gulpTasks.js#L44-L49 | train |
bradzacher/eslint-plugin-typescript | lib/rules/no-inferrable-types.js | isInferrable | function isInferrable(node, init) {
if (node.type !== "TSTypeAnnotation" || !node.typeAnnotation) {
return false;
}
if (!init) {
return false;
}
const annotation = node.typeAnnotation;
if (annotation.type === "TSS... | javascript | function isInferrable(node, init) {
if (node.type !== "TSTypeAnnotation" || !node.typeAnnotation) {
return false;
}
if (!init) {
return false;
}
const annotation = node.typeAnnotation;
if (annotation.type === "TSS... | [
"function",
"isInferrable",
"(",
"node",
",",
"init",
")",
"{",
"if",
"(",
"node",
".",
"type",
"!==",
"\"TSTypeAnnotation\"",
"||",
"!",
"node",
".",
"typeAnnotation",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"init",
")",
"{",
"return",
... | Returns whether a node has an inferrable value or not
@param {ASTNode} node the node to check
@param {ASTNode} init the initializer
@returns {boolean} whether the node has an inferrable type | [
"Returns",
"whether",
"a",
"node",
"has",
"an",
"inferrable",
"value",
"or",
"not"
] | f689a73c171f33501aa11cd9f77bec2fc10128ae | https://github.com/bradzacher/eslint-plugin-typescript/blob/f689a73c171f33501aa11cd9f77bec2fc10128ae/lib/rules/no-inferrable-types.js#L60-L102 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.