_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q24700
getDirectoryContents
train
function getDirectoryContents(remotePath, options) { const getOptions = merge(baseOptions, options || {}); return directoryContents.getDirectoryContents(remotePath, getOptions); }
javascript
{ "resource": "" }
q24701
getFileContents
train
function getFileContents(remoteFilename, options) { const getOptions = merge(baseOptions, options || {}); getOptions.format = getOptions.format || "binary"; if (["binary", "text"].indexOf(getOptions.format) < 0) { throw new Error("Unknown format: " + getOptions.format...
javascript
{ "resource": "" }
q24702
getFileDownloadLink
train
function getFileDownloadLink(remoteFilename, options) { const getOptions = merge(baseOptions, options || {}); return getFile.getFileLink(remoteFilename, getOptions); }
javascript
{ "resource": "" }
q24703
getFileUploadLink
train
function getFileUploadLink(remoteFilename, options) { var putOptions = merge(baseOptions, options || {}); return putFile.getFileUploadLink(remoteFilename, putOptions); }
javascript
{ "resource": "" }
q24704
moveFile
train
function moveFile(remotePath, targetRemotePath, options) { const moveOptions = merge(baseOptions, options || {}); return move.moveFile(remotePath, targetRemotePath, moveOptions); }
javascript
{ "resource": "" }
q24705
putFileContents
train
function putFileContents(remoteFilename, data, options) { const putOptions = merge(baseOptions, options || {}); return putFile.putFileContents(remoteFilename, data, putOptions); }
javascript
{ "resource": "" }
q24706
stat
train
function stat(remotePath, options) { const getOptions = merge(baseOptions, options || {}); return stats.getStat(remotePath, getOptions); }
javascript
{ "resource": "" }
q24707
encodePath
train
function encodePath(path) { const replaced = path.replace(/\//g, SEP_PATH_POSIX).replace(/\\\\/g, SEP_PATH_WINDOWS); const formatted = encodeURIComponent(replaced); return formatted .split(SEP_PATH_WINDOWS) .join("\\\\") .split(SEP_PATH_POSIX) .join("/"); }
javascript
{ "resource": "" }
q24708
callApi
train
function callApi() { vm.pageInfiniteScroll++; vm.loadingInfiniteScroll = true; return $http .get( 'https://randomuser.me/api/?results=10&seed=lumapps&page=' + vm.pageInfiniteScroll ) .then(function(response) { ...
javascript
{ "resource": "" }
q24709
reComputeElementsPosition
train
function reComputeElementsPosition() { var baseOffset = 0; for (var idx = notificationList.length -1; idx >= 0; idx--) { notificationList[idx].height = getElementHeight(notificationList[idx].elem[0]); notificationList[idx].margin = baseOffset;...
javascript
{ "resource": "" }
q24710
buildDialogActions
train
function buildDialogActions(_buttons, _callback, _unbind) { var $compile = $injector.get('$compile'); var dialogActions = angular.element('<div/>', { class: 'dialog__footer' }); var dialogLastBtn = angular.element('<button/>', ...
javascript
{ "resource": "" }
q24711
_closePanes
train
function _closePanes() { toggledPanes = {}; if (lxSelect.choicesViewSize === 'large') { if (angular.isDefined(lxSelect.choices) && lxSelect.choices !== null) { lxSelect.panes = [lxSelect.choices]; } else { lxSelect.panes = ...
javascript
{ "resource": "" }
q24712
_findIndex
train
function _findIndex(haystack, needle) { if (angular.isUndefined(haystack) || haystack.length === 0) { return -1; } for (var i = 0, len = haystack.length; i < len; i++) { if (haystack[i] === needle) { return i; } ...
javascript
{ "resource": "" }
q24713
_getLongestMatchingPath
train
function _getLongestMatchingPath(containing) { if (angular.isUndefined(lxSelect.matchingPaths) || lxSelect.matchingPaths.length === 0) { return undefined; } containing = containing || lxSelect.matchingPaths[0]; var longest = lxSelect.matchingPaths[0]; ...
javascript
{ "resource": "" }
q24714
_keyLeft
train
function _keyLeft() { if (lxSelect.choicesViewMode !== 'panes' || lxSelect.panes.length < 2) { return; } var previousPaneIndex = lxSelect.panes.length - 2; lxSelect.activeChoiceIndex = ( Object.keys(lxSelect.panes[previousPaneIndex]) || [...
javascript
{ "resource": "" }
q24715
_keyRight
train
function _keyRight() { if (lxSelect.choicesViewMode !== 'panes' || lxSelect.activeChoiceIndex === -1) { return; } var paneOpened = _openPane((lxSelect.panes.length - 1), lxSelect.activeChoiceIndex, true); if (paneOpened) { lxSelect.active...
javascript
{ "resource": "" }
q24716
_keySelect
train
function _keySelect() { var filteredChoices; if (lxSelect.choicesViewMode === 'panes') { filteredChoices = lxSelect.panes[(lxSelect.panes.length - 1)]; if (!lxSelect.isLeaf(filteredChoices[lxSelect.activeChoiceIndex])) { return; ...
javascript
{ "resource": "" }
q24717
_openPane
train
function _openPane(parentIndex, indexOrKey, checkIsLeaf) { if (angular.isDefined(toggledPanes[parentIndex])) { return false; } var pane = pane || lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex]; if (...
javascript
{ "resource": "" }
q24718
_searchPath
train
function _searchPath(container, regexp, previousKey, limitToFields) { limitToFields = limitToFields || []; limitToFields = (angular.isArray(limitToFields)) ? limitToFields : [limitToFields]; var results = []; angular.forEach(container, function forEachItemsInContainer(i...
javascript
{ "resource": "" }
q24719
isLeaf
train
function isLeaf(obj) { if (angular.isUndefined(obj)) { return false; } if (angular.isArray(obj)) { return false; } if (!angular.isObject(obj)) { return true; } if (obj.isLeaf) { ...
javascript
{ "resource": "" }
q24720
isPaneToggled
train
function isPaneToggled(parentIndex, indexOrKey) { var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex]; if (angular.isUndefined(pane)) { return false; } var key = indexOrKey; if (an...
javascript
{ "resource": "" }
q24721
isMatchingPath
train
function isMatchingPath(parentIndex, indexOrKey) { var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex]; if (angular.isUndefined(pane)) { return; } var key = indexOrKey; if (angular...
javascript
{ "resource": "" }
q24722
keyEvent
train
function keyEvent(evt) { if (evt.keyCode !== 8) { lxSelect.activeSelectedIndex = -1; } if (!LxDropdownService.isOpen('dropdown-' + lxSelect.uuid)) { lxSelect.activeChoiceIndex = -1; } switch (evt.keyCode) { cas...
javascript
{ "resource": "" }
q24723
toggleChoice
train
function toggleChoice(choice, evt) { if (lxSelect.multiple && !lxSelect.autocomplete && angular.isDefined(evt)) { evt.stopPropagation(); } if (lxSelect.areChoicesOpened() && lxSelect.multiple) { var dropdownElement = angular.element(angular.element(ev...
javascript
{ "resource": "" }
q24724
togglePane
train
function togglePane(evt, parentIndex, indexOrKey, selectLeaf) { selectLeaf = (angular.isUndefined(selectLeaf)) ? true : selectLeaf; var pane = lxSelect.choicesViewSize === 'large' ? lxSelect.panes[parentIndex] : lxSelect.openedPanes[parentIndex]; if (angular.isUndefined(pane)) { ...
javascript
{ "resource": "" }
q24725
updateFilter
train
function updateFilter() { if (angular.isFunction(lxSelect.resetDropdownSize)) { lxSelect.resetDropdownSize(); } if (angular.isDefined(lxSelect.filter)) { lxSelect.matchingPaths = lxSelect.filter({ newValue: lxSelect.filterModel ...
javascript
{ "resource": "" }
q24726
searchPath
train
function searchPath(newValue) { if (!newValue || newValue.length < 2) { return undefined; } var regexp = new RegExp(LxUtils.escapeRegexp(newValue), 'ig'); return _searchPath(lxSelect.choices, regexp); }
javascript
{ "resource": "" }
q24727
createEnterARButton
train
function createEnterARButton (clickHandler) { var arButton; // Create elements. arButton = document.createElement('button'); arButton.className = ENTER_AR_BTN_CLASS; arButton.setAttribute('title', 'Enter AR mode.'); arButton.setAttribute('aframe-injected', ''); arButton.addEventListener('click', functio...
javascript
{ "resource": "" }
q24728
LocationLinks
train
function LocationLinks(props) { const elements = props.locations.map((location, index, locations) => { let buildingName; if (location.match(/\d+\s*$/i)) { buildingName = location.replace(/\d+\s*$/i, ''); } else { buildingName = location; } let optionalComma = null; if (index !== l...
javascript
{ "resource": "" }
q24729
setCookie
train
function setCookie(pr_name, exdays) { var d = new Date(); d = (d.getTime() + (exdays*24*60*60*1000)); document.cookie = pr_name+"="+d + ";" + ";path=/"; }
javascript
{ "resource": "" }
q24730
getCookie
train
function getCookie(pr_name) { var name = pr_name + "="; var ca = document.cookie.split(';'); for(var i = 0; i < ca.length; i++) { var c = ca[i]; c = c.trim(); if (c.indexOf(pr_name+"=") === 0) { return c.substring(name.length, c.length); ...
javascript
{ "resource": "" }
q24731
App
train
function App(options) { this.clientId = options.clientId; this.clientSecret = options.clientSecret || null; this.redirectUri = options.redirectUri || null; this.scope = options.scope || 'default'; this.asanaBaseUrl = options.asanaBaseUrl || 'https://app.asana.com/'; }
javascript
{ "resource": "" }
q24732
ChromeExtensionFlow
train
function ChromeExtensionFlow(options) { BaseBrowserFlow.call(this, options); this._authorizationPromise = null; this._receiverUrl = chrome.runtime.getURL( options.receiverPath || 'asana_oauth_receiver.html'); }
javascript
{ "resource": "" }
q24733
NativeFlow
train
function NativeFlow(options) { this.app = options.app; this.instructions = options.instructions || defaultInstructions; this.prompt = options.prompt || defaultPrompt; this.redirectUri = oauthUtil.NATIVE_REDIRECT_URI; }
javascript
{ "resource": "" }
q24734
Collection
train
function Collection(response, dispatcher, dispatchOptions) { if (!Collection.isCollectionResponse(response)) { throw new Error( 'Cannot create Collection from response that does not have resources'); } this.data = response.data; this._response = response; this._dispatcher = dispatcher; this._di...
javascript
{ "resource": "" }
q24735
ResourceStream
train
function ResourceStream(collection) { var me = this; BufferedReadable.call(me, { objectMode: true }); // @type {Collection} The collection whose data was last pushed into the // stream, such that if we have to go back for more, we should fetch // its `nextPage`. me._collection = collection; ...
javascript
{ "resource": "" }
q24736
OauthAuthenticator
train
function OauthAuthenticator(options) { Authenticator.call(this); if (typeof(options.credentials) === 'string') { this.credentials = { 'access_token': options.credentials }; } else { this.credentials = options.credentials || null; } this.flow = options.flow || null; this.app = options.app; ...
javascript
{ "resource": "" }
q24737
Client
train
function Client(dispatcher, options) { options = options || {}; /** * The internal dispatcher. This is mostly used by the resources but provided * for custom requests to the API or API features that have not yet been added * to the client. * @type {Dispatcher} */ this.dispatcher = dispatcher; /**...
javascript
{ "resource": "" }
q24738
browserTask
train
function browserTask(minify) { return function() { var task = browserify( { entries: [index], standalone: 'Asana' }) .bundle() .pipe(vinylSourceStream('asana' + (minify ? '-min' : '') + '.js')); if (minify) { task = task .pipe(vinylBuffer()) ...
javascript
{ "resource": "" }
q24739
autoDetect
train
function autoDetect(env) { env = env || defaultEnvironment(); if (typeof(env.chrome) !== 'undefined' && env.chrome.runtime && env.chrome.runtime.id) { if (env.chrome.tabs && env.chrome.tabs.create) { return ChromeExtensionFlow; } else { // Chrome packaged app, not supported yet. return...
javascript
{ "resource": "" }
q24740
createClient
train
function createClient() { return Asana.Client.create({ clientId: clientId, clientSecret: clientSecret, redirectUri: 'http://localhost:' + port + '/oauth_callback' }); }
javascript
{ "resource": "" }
q24741
parseOauthResultFromUrl
train
function parseOauthResultFromUrl(currentUrl) { var oauthUrl = url.parse(currentUrl); return oauthUrl.hash ? querystring.parse(oauthUrl.hash.substr(1)) : null; }
javascript
{ "resource": "" }
q24742
removeOauthResultFromCurrentUrl
train
function removeOauthResultFromCurrentUrl() { if (window.history && window.history.replaceState) { var url = window.location.href; var hashIndex = url.indexOf('#'); window.history.replaceState({}, document.title, url.substring(0, hashIndex)); } else { window.location.hash = ''; } }
javascript
{ "resource": "" }
q24743
stringSource
train
function stringSource(s) { var i=0; return function() { return i < s.length ? s.charCodeAt(i++) : null; }; }
javascript
{ "resource": "" }
q24744
stringDestination
train
function stringDestination() { var cs = [], ps = []; return function() { if (arguments.length === 0) return ps.join('')+stringFromCharCode.apply(String, cs); if (cs.length + arguments.length > 1024) ps.push(stringFromCharCode.apply(String, cs)), ...
javascript
{ "resource": "" }
q24745
assertLong
train
function assertLong(value, unsigned) { if (typeof value === 'number') { return Long.fromNumber(value, unsigned); } else if (typeof value === 'string') { return Long.fromString(value, unsigned); } else if (value && value instanceof Long) { if (typeof unsigned !== 'undefined') { ...
javascript
{ "resource": "" }
q24746
assertOffset
train
function assertOffset(offset, min, cap, size) { if (typeof offset !== 'number' || offset % 1 !== 0) throw TypeError("Illegal offset: "+offset+" (not an integer)"); offset = offset | 0; if (offset < min || offset > cap-size) throw RangeError("Illegal offset: "+min+" <= "+value+" <= "+cap+"-"+...
javascript
{ "resource": "" }
q24747
assertRange
train
function assertRange(begin, end, min, cap) { if (typeof begin !== 'number' || begin % 1 !== 0) throw TypeError("Illegal begin: "+begin+" (not a number)"); begin = begin | 0; if (typeof end !== 'number' || end % 1 !== 0) throw TypeError("Illegal end: "+range[1]+" (not a number)"); end = e...
javascript
{ "resource": "" }
q24748
train
function(controller) { /** * Plugin controller. */ this.controller = controller; /** * IMA SDK AdDisplayContainer. */ this.adDisplayContainer = null; /** * True if the AdDisplayContainer has been initialized. False otherwise. */ this.adDisplayContainerInitialized = false; /** * IMA...
javascript
{ "resource": "" }
q24749
train
function(player, options) { /** * Stores user-provided settings. * @type {Object} */ this.settings = {}; /** * Content and ads ended listeners passed by the publisher to the plugin. * These will be called when the plugin detects that content *and all * ads* have completed. This differs from the...
javascript
{ "resource": "" }
q24750
train
function (geofences, success, error) { if (!Array.isArray(geofences)) { geofences = [geofences]; } geofences.forEach(coerceProperties); if (isIOS) { return addOrUpdateIOS(geofences, success, error); } return execPromise(success, error, "Geofence...
javascript
{ "resource": "" }
q24751
train
function (ids, success, error) { if (!Array.isArray(ids)) { ids = [ids]; } return execPromise(success, error, "GeofencePlugin", "remove", ids); }
javascript
{ "resource": "" }
q24752
newClientStub
train
function newClientStub() { // First create the appropriate TLS certs with dgraph cert: // $ dgraph cert // $ dgraph cert -n localhost // $ dgraph cert -c user const rootCaCert = fs.readFileSync(path.join(__dirname, 'tls', 'ca.crt')); const clientCertKey = fs.readFileSync(path.join(__...
javascript
{ "resource": "" }
q24753
dropAll
train
async function dropAll(dgraphClient) { const op = new dgraph.Operation(); op.setDropAll(true); await dgraphClient.alter(op); }
javascript
{ "resource": "" }
q24754
createData
train
async function createData(dgraphClient) { // Create a new transaction. const txn = dgraphClient.newTxn(); try { // Create data. const p = { name: "Alice", age: 26, married: true, loc: { type: "Point", coordinates...
javascript
{ "resource": "" }
q24755
yyyymmddDateFromMonthDayYearDate
train
function yyyymmddDateFromMonthDayYearDate(monthDayYearDate) { var yyyy = monthDayYearDate.split(',')[1].trim(); var dd = monthDayYearDate.split(' ')[1].split(',')[0]; var mm = ''; switch (monthDayYearDate.split(' ')[0]) { case 'January': mm = '01'; break; case 'February': mm = '02'; break; case '...
javascript
{ "resource": "" }
q24756
getTitleFromChartItem
train
function getTitleFromChartItem(chartItem) { var title; try { title = chartItem.children[1].children[5].children[1].children[1].children[1].children[0].data.replace(/\n/g, ''); } catch (e) { title = ''; } return title; }
javascript
{ "resource": "" }
q24757
getArtistFromChartItem
train
function getArtistFromChartItem(chartItem) { var artist; try { artist = chartItem.children[1].children[5].children[1].children[3].children[0].data.replace(/\n/g, ''); } catch (e) { artist = ''; } if (artist.trim().length < 1) { try { artist = chartItem.children[1].children[5].children[1].children[3].child...
javascript
{ "resource": "" }
q24758
getPositionLastWeekFromChartItem
train
function getPositionLastWeekFromChartItem(chartItem) { var positionLastWeek; try { if (chartItem.children[3].children.length > 5) { positionLastWeek = chartItem.children[3].children[5].children[3].children[3].children[0].data } else { positionLastWeek = chartItem.children[3].children[3].children[1].children...
javascript
{ "resource": "" }
q24759
getPeakPositionFromChartItem
train
function getPeakPositionFromChartItem(chartItem) { var peakPosition; try { if (chartItem.children[3].children.length > 5) { peakPosition = chartItem.children[3].children[5].children[5].children[3].children[0].data; } else { peakPosition = chartItem.children[3].children[3].children[3].children[3].children[0]...
javascript
{ "resource": "" }
q24760
getWeeksOnChartFromChartItem
train
function getWeeksOnChartFromChartItem(chartItem) { var weeksOnChart; try { if (chartItem.children[3].children.length > 5) { weeksOnChart = chartItem.children[3].children[5].children[7].children[3].children[0].data; } else { weeksOnChart = chartItem.children[3].children[3].children[5].children[3].children[0]...
javascript
{ "resource": "" }
q24761
getNeighboringChart
train
function getNeighboringChart(chartItem, neighboringWeek) { if (neighboringWeek == NeighboringWeek.Previous) { if (chartItem[0].attribs.class.indexOf('dropdown__date-selector-option--disabled') == -1) { return { url: BILLBOARD_BASE_URL + chartItem[0].children[1].attribs.href, date: chartItem[0].children[1]...
javascript
{ "resource": "" }
q24762
getChart
train
function getChart(chartName, date, cb) { // check if chart was specified if (typeof chartName === 'function') { // if chartName not specified, default to hot-100 chart for current week, // and set callback method accordingly cb = chartName; chartName = 'hot-100'; date = ''; } // check if date was specifi...
javascript
{ "resource": "" }
q24763
listCharts
train
function listCharts(cb) { if (typeof cb !== 'function') { cb('Specified callback is not a function.', null); return; } request(BILLBOARD_CHARTS_URL, function completedRequest(error, response, html) { if (error) { cb(error, null); return; } var $ = cheerio.load(html); /** * A chart * @typedef ...
javascript
{ "resource": "" }
q24764
WooCommerceAPI
train
function WooCommerceAPI(opt) { if (!(this instanceof WooCommerceAPI)) { return new WooCommerceAPI(opt); } opt = opt || {}; if (!(opt.url)) { throw new Error('url is required'); } if (!(opt.consumerKey)) { throw new Error('consumerKey is required'); } if (!(opt.consumerSecret)) { thro...
javascript
{ "resource": "" }
q24765
resolveExternalPath
train
function resolveExternalPath(importPath, options) { let baseIndex = importPath[0] === '@' ? importPath.indexOf('/') + 1 : 0; let addonName = importPath.substring(0, importPath.indexOf('/', baseIndex)); let addon = options.parent.addons.find(addon => addon.name === addonName); if (!addon) { throw new Error(...
javascript
{ "resource": "" }
q24766
isStage1ClassDescriptor
train
function isStage1ClassDescriptor(possibleDesc) { let [target] = possibleDesc; return ( possibleDesc.length === 1 && typeof target === 'function' && 'prototype' in target && !target.__isComputedDecorator ); }
javascript
{ "resource": "" }
q24767
train
function() { this.inner.setAttribute('tabindex', 0); this.inner.addEventListener('keyup', (e) => { if (e.target !== this.inner) { return; } switch(e.keyCode) { case 13: this.mediator.trigger("block:create", 'Text', null, this.el, { autoFocus: true }); break; case...
javascript
{ "resource": "" }
q24768
train
function(){ var dataObj = {}; var content = this.getTextBlock().html(); if (content.length > 0) { dataObj.text = SirTrevor.toMarkdown(content, this.type); } this.setData(dataObj); }
javascript
{ "resource": "" }
q24769
removeWrappingParagraphForFirefox
train
function removeWrappingParagraphForFirefox(value) { var fakeContent = document.createElement('div'); fakeContent.innerHTML = value; if (fakeContent.childNodes.length === 1) { var node = [].slice.call(fakeContent.childNodes)[0]; if (node && node.nodeName === "P") { value = node.innerHTML; } } ...
javascript
{ "resource": "" }
q24770
eachObj
train
function eachObj(obj, iteratee, context) { for (var key in obj) { if (obj.hasOwnProperty(key)) { iteratee.call(context || obj, key, obj[key]); } } }
javascript
{ "resource": "" }
q24771
jsxTagName
train
function jsxTagName(tagName) { var name = tagName.toLowerCase(); if (ELEMENT_TAG_NAME_MAPPING.hasOwnProperty(name)) { name = ELEMENT_TAG_NAME_MAPPING[name]; } return name; }
javascript
{ "resource": "" }
q24772
trimEnd
train
function trimEnd(haystack, needle) { return endsWith(haystack, needle) ? haystack.slice(0, -needle.length) : haystack; }
javascript
{ "resource": "" }
q24773
isNumeric
train
function isNumeric(input) { return input !== undefined && input !== null && (typeof input === 'number' || parseInt(input, 10) == input); }
javascript
{ "resource": "" }
q24774
train
function (html) { this.reset(); var containerEl = createElement('div'); containerEl.innerHTML = '\n' + this._cleanInput(html) + '\n'; if (this.config.createClass) { if (this.config.outputClassName) { this.output = 'var ' + this.config.outputClassName + ' = React.createClass({\n'; }...
javascript
{ "resource": "" }
q24775
train
function (containerEl) { // Only a single child element if ( containerEl.childNodes.length === 1 && containerEl.childNodes[0].nodeType === NODE_TYPE.ELEMENT ) { return true; } // Only one element, and all other children are whitespace var foundElement = false; for (var i = ...
javascript
{ "resource": "" }
q24776
train
function (node) { this.level++; for (var i = 0, count = node.childNodes.length; i < count; i++) { this._visit(node.childNodes[i]); } this.level--; }
javascript
{ "resource": "" }
q24777
train
function (node) { switch (node.nodeType) { case NODE_TYPE.ELEMENT: this._beginVisitElement(node); break; case NODE_TYPE.TEXT: this._visitText(node); break; case NODE_TYPE.COMMENT: this._visitComment(node); break; default: console.war...
javascript
{ "resource": "" }
q24778
train
function (node) { switch (node.nodeType) { case NODE_TYPE.ELEMENT: this._endVisitElement(node); break; // No ending tags required for these types case NODE_TYPE.TEXT: case NODE_TYPE.COMMENT: break; } }
javascript
{ "resource": "" }
q24779
train
function (node) { var tagName = jsxTagName(node.tagName); var attributes = []; for (var i = 0, count = node.attributes.length; i < count; i++) { attributes.push(this._getElementAttribute(node, node.attributes[i])); } if (tagName === 'textarea') { // Hax: textareas need their inner text ...
javascript
{ "resource": "" }
q24780
train
function (node) { var tagName = jsxTagName(node.tagName); // De-indent a bit // TODO: It's inefficient to do it this way :/ this.output = trimEnd(this.output, this.config.indent); if (this._isSelfClosing(node)) { this.output += ' />'; } else { this.output += '</' + tagName + '>'; ...
javascript
{ "resource": "" }
q24781
train
function (node) { var parentTag = node.parentNode && jsxTagName(node.parentNode.tagName); if (parentTag === 'textarea' || parentTag === 'style') { // Ignore text content of textareas and styles, as it will have already been moved // to a "defaultValue" attribute and "dangerouslySetInnerHTML" attribu...
javascript
{ "resource": "" }
q24782
train
function (node, attribute) { switch (attribute.name) { case 'style': return this._getStyleAttribute(attribute.value); default: var tagName = jsxTagName(node.tagName); var name = (ELEMENT_ATTRIBUTE_MAPPING[tagName] && ELEMENT_ATTRIBUTE_MAPPING[tagName][attrib...
javascript
{ "resource": "" }
q24783
train
function (output, indent) { var classIndention = new RegExp('\\n' + indent + indent + indent, 'g'); return output.replace(classIndention, '\n'); }
javascript
{ "resource": "" }
q24784
train
function (rawStyle) { this.styles = {}; rawStyle.split(';').forEach(function (style) { style = style.trim(); var firstColon = style.indexOf(':'); var key = style.substr(0, firstColon); var value = style.substr(firstColon + 1).trim(); if (key !== '') { // Style key should be...
javascript
{ "resource": "" }
q24785
train
function () { var output = []; eachObj(this.styles, function (key, value) { output.push(this.toJSXKey(key) + ': ' + this.toJSXValue(value)); }, this); return output.join(', '); }
javascript
{ "resource": "" }
q24786
train
function (value) { if (isNumeric(value)) { return value } else if (value.startsWith("'") || value.startsWith("\"")) { return value } else { return '\'' + value.replace(/'/g, '"') + '\''; } }
javascript
{ "resource": "" }
q24787
imageToImageData
train
function imageToImageData ( image ) { if ( image instanceof HTMLImageElement ) { // http://stackoverflow.com/a/3016076/229189 if ( ! image.naturalWidth || ! image.naturalHeight || image.complete === false ) { throw new Error( "This this image hasn't finished loading: " + image.src ); } const canvas = new C...
javascript
{ "resource": "" }
q24788
transferAnnotations
train
function transferAnnotations (doc, path, offset, newPath, newOffset) { var index = doc.getIndex('annotations') var annotations = index.get(path, offset) for (let i = 0; i < annotations.length; i++) { let a = annotations[i] var isInside = (offset > a.start.offset && offset < a.end.offset) var start = a...
javascript
{ "resource": "" }
q24789
_disconnect
train
function _disconnect (context) { /* eslint-disable no-invalid-this */ // Remove all connections to the context forEach(this.__events__, (bindings, event) => { for (let i = bindings.length - 1; i >= 0; i--) { // bindings[i] may have been removed by the previous steps // so check it still exists ...
javascript
{ "resource": "" }
q24790
_create
train
function _create (state, vel) { let comp = vel._comp console.assert(!comp, 'Component instance should not exist when this method is used.') let parent = vel.parent._comp // making sure the parent components have been instantiated if (!parent) { parent = _create(state, vel.parent) } // TODO: probably w...
javascript
{ "resource": "" }
q24791
compressPubKey
train
function compressPubKey (pubKey) { const x = pubKey.substring(2, 66) const y = pubKey.substring(66, 130) const even = parseInt(y.substring(62, 64), 16) % 2 === 0 const prefix = even ? '02' : '03' return prefix + x }
javascript
{ "resource": "" }
q24792
pubKeyToAddress
train
function pubKeyToAddress (pubKey, network, type) { pubKey = ensureBuffer(pubKey) const pubKeyHash = hash160(pubKey) const addr = pubKeyHashToAddress(pubKeyHash, network, type) return addr }
javascript
{ "resource": "" }
q24793
pubKeyHashToAddress
train
function pubKeyHashToAddress (pubKeyHash, network, type) { pubKeyHash = ensureBuffer(pubKeyHash) const prefixHash = Buffer.concat([Buffer.from(networks[network][type], 'hex'), pubKeyHash]) const checksum = Buffer.from(sha256(sha256(prefixHash)).slice(0, 8), 'hex') const addr = base58.encode(Buffer.concat([prefi...
javascript
{ "resource": "" }
q24794
getAddressNetwork
train
function getAddressNetwork (address) { const prefix = base58.decode(address).toString('hex').substring(0, 2).toUpperCase() const networkKey = findKey(networks, network => [network.pubKeyHash, network.scriptHash].includes(prefix)) return networks[networkKey] }
javascript
{ "resource": "" }
q24795
ensureBuffer
train
function ensureBuffer (message) { if (Buffer.isBuffer(message)) return message switch (typeof message) { case 'string': message = isHex(message) ? Buffer.from(message, 'hex') : Buffer.from(message) break case 'object': message = Buffer.from(JSON.stringify(message)) break } retu...
javascript
{ "resource": "" }
q24796
padHexStart
train
function padHexStart (hex, length) { let len = length || hex.length len += len % 2 return hex.padStart(len, '0') }
javascript
{ "resource": "" }
q24797
runApp
train
function runApp (appDir, appName) { var binPath = path.join(appDir, 'Contents', 'MacOS', appName); events.emit('log', 'Starting: ' + binPath); return spawn(binPath); }
javascript
{ "resource": "" }
q24798
isReactClass
train
function isReactClass (node) { if (!node || !t.isCallExpression(node)) return false // not _createClass call if (!node.callee || node.callee.name !== '_createClass') return false // no call arguments const args = node.arguments if (!args || args.length !== 2) return false if (!t.isIdentifi...
javascript
{ "resource": "" }
q24799
isRenderMethod
train
function isRenderMethod (props) { return props.some((prop) => { return prop.key.name === 'key' && prop.value.value === 'render' }) && props.some((prop) => { return prop.key.name === 'value' && t.isFunctionExpression(prop.value) }) }
javascript
{ "resource": "" }