_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q23200
canOverflow
train
function canOverflow(el, axis) { var overflowValue = w.getComputedStyle(el, null)['overflow' + axis]; return overflowValue === 'auto' || overflowValue === 'scroll'; }
javascript
{ "resource": "" }
q23201
isScrollable
train
function isScrollable(el) { var isScrollableY = hasScrollableSpace(el, 'Y') && canOverflow(el, 'Y'); var isScrollableX = hasScrollableSpace(el, 'X') && canOverflow(el, 'X'); return isScrollableY || isScrollableX; }
javascript
{ "resource": "" }
q23202
findScrollableParent
train
function findScrollableParent(el) { while (el !== d.body && isScrollable(el) === false) { el = el.parentNode || el.host; } return el; }
javascript
{ "resource": "" }
q23203
smoothScroll
train
function smoothScroll(el, x, y) { var scrollable; var startX; var startY; var method; var startTime = now(); // define scroll context if (el === d.body) { scrollable = w; startX = w.scrollX || w.pageXOffset; startY = w.scrollY || w.pageYOffset; method = original.scro...
javascript
{ "resource": "" }
q23204
defineReactive$$1
train
function defineReactive$$1 ( obj, key, val, customSetter, shallow ) { var dep = new Dep(); var property = Object.getOwnPropertyDescriptor(obj, key); if (property && property.configurable === false) { return } // cater for pre-defined getter/setters var getter = property && property.get; va...
javascript
{ "resource": "" }
q23205
queueWatcher
train
function queueWatcher (watcher) { var id = watcher.id; if (has[id] == null) { has[id] = true; if (!flushing) { queue.push(watcher); } else { // if already flushing, splice the watcher based on its id // if already past its id, it will be run next immediately. var i = queue.length...
javascript
{ "resource": "" }
q23206
getStyle
train
function getStyle (vnode, checkChild) { var res = {}; var styleData; if (checkChild) { var childNode = vnode; while (childNode.componentInstance) { childNode = childNode.componentInstance._vnode; if ( childNode && childNode.data && (styleData = normalizeStyleData(childNode.dat...
javascript
{ "resource": "" }
q23207
postTransformComponent
train
function postTransformComponent ( el, options ) { // $flow-disable-line (we know isReservedTag is there) if (!options.isReservedTag(el.tag) && el.tag !== 'cell-slot') { addAttr(el, RECYCLE_LIST_MARKER, 'true'); } }
javascript
{ "resource": "" }
q23208
registerComponentHook
train
function registerComponentHook ( componentId, type, // hook type, could be "lifecycle" or "instance" hook, // hook name fn ) { if (!document || !document.taskCenter) { warn("Can't find available \"document\" or \"taskCenter\"."); return } if (typeof document.taskCenter.registerHook === 'function')...
javascript
{ "resource": "" }
q23209
updateComponentData
train
function updateComponentData ( componentId, newData, callback ) { if (!document || !document.taskCenter) { warn("Can't find available \"document\" or \"taskCenter\"."); return } if (typeof document.taskCenter.updateData === 'function') { return document.taskCenter.updateData(componentId, newData...
javascript
{ "resource": "" }
q23210
initVirtualComponent
train
function initVirtualComponent (options) { if ( options === void 0 ) options = {}; var vm = this; var componentId = options.componentId; // virtual component uid vm._uid = "virtual-component-" + (uid$2++); // a flag to avoid this being observed vm._isVue = true; // merge options if (options && optio...
javascript
{ "resource": "" }
q23211
updateVirtualComponent
train
function updateVirtualComponent (vnode) { var vm = this; var componentId = vm.$options.componentId; if (vm._isMounted) { callHook(vm, 'beforeUpdate'); } vm._vnode = vnode; if (vm._isMounted && componentId) { // TODO: data should be filtered and without bindings var data = Object.assign({}, vm._d...
javascript
{ "resource": "" }
q23212
resolveVirtualComponent
train
function resolveVirtualComponent (vnode) { var BaseCtor = vnode.componentOptions.Ctor; var VirtualComponent = BaseCtor.extend({}); var cid = VirtualComponent.cid; VirtualComponent.prototype._init = initVirtualComponent; VirtualComponent.prototype._update = updateVirtualComponent; vnode.componentOptions.Cto...
javascript
{ "resource": "" }
q23213
createInstanceContext
train
function createInstanceContext ( instanceId, runtimeContext, data ) { if ( data === void 0 ) data = {}; var weex = runtimeContext.weex; var instance = instanceOptions[instanceId] = { instanceId: instanceId, config: weex.config, document: weex.document, data: data }; // Each instance ha...
javascript
{ "resource": "" }
q23214
getInstanceTimer
train
function getInstanceTimer ( instanceId, moduleGetter ) { var instance = instanceOptions[instanceId]; var timer = moduleGetter('timer'); var timerAPIs = { setTimeout: function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; var handler = functi...
javascript
{ "resource": "" }
q23215
applyModelTransform
train
function applyModelTransform (el, state) { if (el.directives) { for (var i = 0; i < el.directives.length; i++) { var dir = el.directives[i]; if (dir.name === 'model') { state.directives.model(el, dir, state.warn); // remove value for textarea as its converted to text if (el.tag...
javascript
{ "resource": "" }
q23216
isValidArrayIndex
train
function isValidArrayIndex (val) { const n = parseFloat(String(val)); return n >= 0 && Math.floor(n) === n && isFinite(val) }
javascript
{ "resource": "" }
q23217
makeMap
train
function makeMap ( str, expectsLowerCase ) { const map = Object.create(null); const list = str.split(','); for (let i = 0; i < list.length; i++) { map[list[i]] = true; } return expectsLowerCase ? val => map[val.toLowerCase()] : val => map[val] }
javascript
{ "resource": "" }
q23218
toArray
train
function toArray (list, start) { start = start || 0; let i = list.length - start; const ret = new Array(i); while (i--) { ret[i] = list[i + start]; } return ret }
javascript
{ "resource": "" }
q23219
cloneVNode
train
function cloneVNode (vnode) { const cloned = new VNode( vnode.tag, vnode.data, // #7975 // clone children array to avoid mutating original in case of cloning // a child. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentOptions, ...
javascript
{ "resource": "" }
q23220
normalizeProps
train
function normalizeProps (options, vm) { const props = options.props; if (!props) return const res = {}; let i, val, name; if (Array.isArray(props)) { i = props.length; while (i--) { val = props[i]; if (typeof val === 'string') { name = camelize(val); res[name] = { type: nul...
javascript
{ "resource": "" }
q23221
assertProp
train
function assertProp ( prop, name, value, vm, absent ) { if (prop.required && absent) { warn( 'Missing required prop: "' + name + '"', vm ); return } if (value == null && !prop.required) { return } let type = prop.type; let valid = !type || type === true; const expecte...
javascript
{ "resource": "" }
q23222
checkKeyCodes
train
function checkKeyCodes ( eventKeyCode, key, builtInKeyCode, eventKeyName, builtInKeyName ) { const mappedKeyCode = config.keyCodes[key] || builtInKeyCode; if (builtInKeyName && eventKeyName && !config.keyCodes[key]) { return isKeyNotMatch(builtInKeyName, eventKeyName) } else if (mappedKeyCode) { ...
javascript
{ "resource": "" }
q23223
markOnce
train
function markOnce ( tree, index, key ) { markStatic(tree, `__once__${index}${key ? `_${key}` : ``}`, true); return tree }
javascript
{ "resource": "" }
q23224
getOuterHTML
train
function getOuterHTML (el) { if (el.outerHTML) { return el.outerHTML } else { const container = document.createElement('div'); container.appendChild(el.cloneNode(true)); return container.innerHTML } }
javascript
{ "resource": "" }
q23225
mpify
train
function mpify (node, options) { var target = options.target; if ( target === void 0 ) target = 'wechat'; var imports = options.imports; if ( imports === void 0 ) imports = {}; var transformAssetUrls = options.transformAssetUrls; if ( transformAssetUrls === void 0 ) transformAssetUrls = {}; var scopeId = option...
javascript
{ "resource": "" }
q23226
isSupported
train
function isSupported() { // if not checked before, run check if (_supported === null) { var viewMan = Windows.UI.ViewManagement; _supported = (viewMan.StatusBar && viewMan.StatusBar.getForCurrentView); } return _supported; }
javascript
{ "resource": "" }
q23227
generateKey
train
function generateKey() { let result = ''; for(let i=0; i<16; i++) { let idx = Math.floor(Math.random() * CHARS.length); result += CHARS[idx]; } return result; }
javascript
{ "resource": "" }
q23228
mixin
train
function mixin(device, options) { if(device.capabilities.indexOf('sensor') < 0) { device.capabilities.push('sensor'); } device.capabilities.push(options.name); Object.defineProperty(device, options.name, { get: function() { return this.property(options.name); } }); }
javascript
{ "resource": "" }
q23229
getSnapOffset
train
function getSnapOffset(event, axis) { var context = event.context, shape = event.shape, gridSnappingContext = context.gridSnappingContext || {}, snapLocation = gridSnappingContext.snapLocation; if (!shape || !snapLocation) { return 0; } if (axis === 'x') { if (/left/.test(...
javascript
{ "resource": "" }
q23230
removeAttached
train
function removeAttached(elements) { var ids = groupBy(elements, 'id'); return filter(elements, function(element) { while (element) { // host in selection if (element.host && ids[element.host.id]) { return false; } element = element.parent; } return true; }); }
javascript
{ "resource": "" }
q23231
start
train
function start(event, element, activate, context) { if (isObject(activate)) { context = activate; activate = false; } // do not move connections or the root element if (element.waypoints || !element.parent) { return; } var referencePoint = mid(element); dragging.init(eve...
javascript
{ "resource": "" }
q23232
removeNested
train
function removeNested(elements) { var ids = groupBy(elements, 'id'); return filter(elements, function(element) { while ((element = element.parent)) { // parent in selection if (ids[element.id]) { return false; } } return true; }); }
javascript
{ "resource": "" }
q23233
setMarker
train
function setMarker(element, marker) { [ MARKER_ATTACH, MARKER_OK, MARKER_NOT_OK, MARKER_NEW_PARENT ].forEach(function(m) { if (m === marker) { canvas.addMarker(element, m); } else { canvas.removeMarker(element, m); } }); }
javascript
{ "resource": "" }
q23234
makeDraggable
train
function makeDraggable(context, element, addMarker) { previewSupport.addDragger(element, context.dragGroup); if (addMarker) { canvas.addMarker(element, MARKER_DRAGGING); } if (context.allDraggedElements) { context.allDraggedElements.push(element); } else { context.allDraggedElem...
javascript
{ "resource": "" }
q23235
constructOverlay
train
function constructOverlay(box) { var offset = 6; var w = box.width + offset * 2; var h = box.height + offset * 2; var styles = [ 'width: '+ w +'px', 'height: '+ h + 'px' ].join('; '); return { position: { bottom: h - offset, right: w - offset }, show: true, html: '<div...
javascript
{ "resource": "" }
q23236
createInnerTextNode
train
function createInnerTextNode(parentNode, tokens, template) { var text = createHtmlText(tokens); var childNode = domify(template); childNode.innerHTML = text; parentNode.appendChild(childNode); }
javascript
{ "resource": "" }
q23237
createHtmlText
train
function createHtmlText(tokens) { var htmlText = ''; tokens.forEach(function(t) { if (t.matched) { htmlText += '<strong class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + t.matched + '</strong>'; } else { htmlText += t.normal; } }); return htmlText !== '' ? htmlText : null; }
javascript
{ "resource": "" }
q23238
layoutNext
train
function layoutNext(lines, maxWidth, fakeText) { var originalLine = lines.shift(), fitLine = originalLine; var textBBox; for (;;) { textBBox = getTextBBox(fitLine, fakeText); textBBox.width = fitLine ? textBBox.width : 0; // try to fit if (fitLine === ' ' || fitLine === '' || textBBox.w...
javascript
{ "resource": "" }
q23239
semanticShorten
train
function semanticShorten(line, maxLength) { var parts = line.split(/(\s|-)/g), part, shortenedParts = [], length = 0; // try to shorten via spaces + hyphens if (parts.length > 1) { while ((part = parts.shift())) { if (part.length + length < maxLength) { shortenedParts.push(par...
javascript
{ "resource": "" }
q23240
getSimpleBendpoints
train
function getSimpleBendpoints(a, b, directions) { var xmid = round((b.x - a.x) / 2 + a.x), ymid = round((b.y - a.y) / 2 + a.y); // one point, right or left from a if (directions === 'h:v') { return [ { x: b.x, y: a.y } ]; } // one point, above or below a if (directions === 'v:h') { return [ ...
javascript
{ "resource": "" }
q23241
getBendpoints
train
function getBendpoints(a, b, directions) { directions = directions || 'h:h'; if (!isValidDirections(directions)) { throw new Error( 'unknown directions: <' + directions + '>: ' + 'must be specified as <start>:<end> ' + 'with start/end in { h,v,t,r,b,l }' ); } // compute explicit dire...
javascript
{ "resource": "" }
q23242
tryRepairConnectionStart
train
function tryRepairConnectionStart(moved, other, newDocking, points) { return _tryRepairConnectionSide(moved, other, newDocking, points); }
javascript
{ "resource": "" }
q23243
tryRepairConnectionEnd
train
function tryRepairConnectionEnd(moved, other, newDocking, points) { var waypoints = points.slice().reverse(); waypoints = _tryRepairConnectionSide(moved, other, newDocking, waypoints); return waypoints ? waypoints.reverse() : null; }
javascript
{ "resource": "" }
q23244
_tryRepairConnectionSide
train
function _tryRepairConnectionSide(moved, other, newDocking, points) { function needsRelayout(moved, other, points) { if (points.length < 3) { return true; } if (points.length > 4) { return false; } // relayout if two points overlap // this is most likely due to return !!fin...
javascript
{ "resource": "" }
q23245
createContainer
train
function createContainer(options) { options = assign({}, { width: '100%', height: '100%' }, options); var container = options.container || document.body; // create a <div> around the svg element with the respective size // this way we can always get the correct container size // (this is impossible for <sv...
javascript
{ "resource": "" }
q23246
handleMove
train
function handleMove(context, delta) { var shape = context.shape, direction = context.direction, resizeConstraints = context.resizeConstraints, newBounds; context.delta = delta; newBounds = resizeBounds(shape, direction, delta); // ensure constraints during resize context....
javascript
{ "resource": "" }
q23247
handleStart
train
function handleStart(context) { var resizeConstraints = context.resizeConstraints, // evaluate minBounds for backwards compatibility minBounds = context.minBounds; if (resizeConstraints !== undefined) { return; } if (minBounds === undefined) { minBounds = self.computeMinRe...
javascript
{ "resource": "" }
q23248
handleEnd
train
function handleEnd(context) { var shape = context.shape, canExecute = context.canExecute, newBounds = context.newBounds; if (canExecute) { // ensure we have actual pixel values for new bounds // (important when zoom level was > 1 during move) newBounds = roundBounds(newBounds)...
javascript
{ "resource": "" }
q23249
bootstrap
train
function bootstrap(bootstrapModules) { var modules = [], components = []; function hasModule(m) { return modules.indexOf(m) >= 0; } function addModule(m) { modules.push(m); } function visit(m) { if (hasModule(m)) { return; } (m.__depends__ || []).forEach(visit); if ...
javascript
{ "resource": "" }
q23250
createInjector
train
function createInjector(options) { options = options || {}; var configModule = { 'config': ['value', options] }; var modules = [ configModule, CoreModule ].concat(options.modules || []); return bootstrap(modules); }
javascript
{ "resource": "" }
q23251
trapClickAndEnd
train
function trapClickAndEnd(event) { var untrap; // trap the click in case we are part of an active // drag operation. This will effectively prevent // the ghost click that cannot be canceled otherwise. if (context.active) { untrap = installClickTrap(eventBus); // remove trap after mini...
javascript
{ "resource": "" }
q23252
cancel
train
function cancel(restore) { var previousContext; if (!context) { return; } var wasActive = context.active; if (wasActive) { fire('cancel'); } previousContext = cleanup(restore); if (wasActive) { // last event to be fired when all drag operations are done // at...
javascript
{ "resource": "" }
q23253
init
train
function init(event, relativeTo, prefix, options) { // only one drag operation may be active, at a time if (context) { cancel(false); } if (typeof relativeTo === 'string') { options = prefix; prefix = relativeTo; relativeTo = null; } options = assign({}, defaultOptions...
javascript
{ "resource": "" }
q23254
getDocking
train
function getDocking(point, referenceElement, moveAxis) { var referenceMid, inverseAxis; if (point.original) { return point.original; } else { referenceMid = getMid(referenceElement); inverseAxis = flipAxis(moveAxis); return axisSet(point, inverseAxis, referenceMid[inverseAxis]); } }
javascript
{ "resource": "" }
q23255
cropConnection
train
function cropConnection(connection, newWaypoints) { // crop connection, if docking service is provided only if (!connectionDocking) { return newWaypoints; } var oldWaypoints = connection.waypoints, croppedWaypoints; // temporary set new waypoints connection.waypoints = newWaypoi...
javascript
{ "resource": "" }
q23256
addClasses
train
function addClasses(el, classes) { var newClasses = convertToArray(classes); var classList; if (el.className instanceof SVGAnimatedString) { classList = convertToArray(el.className.baseVal); } else { classList = convertToArray(el.className); } newClasses.forEach(function (newClass) { if (class...
javascript
{ "resource": "" }
q23257
removeClasses
train
function removeClasses(el, classes) { var newClasses = convertToArray(classes); var classList; if (el.className instanceof SVGAnimatedString) { classList = convertToArray(el.className.baseVal); } else { classList = convertToArray(el.className); } newClasses.forEach(function (newClass) { var in...
javascript
{ "resource": "" }
q23258
Tooltip
train
function Tooltip(_reference, _options) { var _this = this; _classCallCheck(this, Tooltip); _defineProperty(this, "_events", []); _defineProperty(this, "_setTooltipNodeEvent", function (evt, reference, delay, options) { var relatedreference = evt.relatedreference || evt.toElement || evt.relatedT...
javascript
{ "resource": "" }
q23259
scrapeIt
train
function scrapeIt (url, opts, cb) { cb = assured(cb) req(url, (err, $, res, body) => { if (err) { return cb(err) } try { let scrapedData = scrapeIt.scrapeHTML($, opts) cb(null, { data: scrapedData, $, response: res, ...
javascript
{ "resource": "" }
q23260
measure
train
function measure(ref) { return new Promise(function (resolve) { ref.measure(function (x, y, width, height, pageX, pageY) { resolve({ x: pageX, y: pageY, width: width, height: height }); }); }); }
javascript
{ "resource": "" }
q23261
makeTouchable
train
function makeTouchable(TouchableComponent) { var Touchable = TouchableComponent || reactNative.Platform.select({ android: reactNative.TouchableNativeFeedback, ios: reactNative.TouchableHighlight, default: reactNative.TouchableHighlight }); var defaultTouchableProps = {}; if (Touchable...
javascript
{ "resource": "" }
q23262
iterator2array
train
function iterator2array(it) { // workaround around https://github.com/instea/react-native-popup-menu/issues/41#issuecomment-340290127 var arr = []; for (var next = it.next(); !next.done; next = it.next()) { arr.push(next.value); } return arr; }
javascript
{ "resource": "" }
q23263
deprecatedComponent
train
function deprecatedComponent(message) { var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; return function deprecatedComponentHOC(Component) { var _temp; return _temp = /*#__PURE__*/ function (_React$Component) { _inherits(DeprecatedComponent, ...
javascript
{ "resource": "" }
q23264
isAsyncMode
train
function isAsyncMode(object) { { if (!hasWarnedAboutDeprecatedIsAsyncMode) { hasWarnedAboutDeprecatedIsAsyncMode = true; lowPriorityWarning$1(false, 'The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMod...
javascript
{ "resource": "" }
q23265
makeMenuRegistry
train
function makeMenuRegistry() { var menus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Map(); /** * Subscribes menu instance. */ function subscribe(instance) { var name = instance.getName(); if (menus.get(name)) { console.warn("incorrect usage of po...
javascript
{ "resource": "" }
q23266
subscribe
train
function subscribe(instance) { var name = instance.getName(); if (menus.get(name)) { console.warn("incorrect usage of popup menu - menu with name ".concat(name, " already exists")); } menus.set(name, { name: name, instance: instance }); }
javascript
{ "resource": "" }
q23267
updateLayoutInfo
train
function updateLayoutInfo(name) { var layouts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; if (!menus.has(name)) { return; } var menu = Object.assign({}, menus.get(name)); if (layouts.hasOwnProperty('triggerLayout')) { menu.triggerLayout = la...
javascript
{ "resource": "" }
q23268
setTag
train
function setTag(key, value, obj) { if (!obj || !key) return var skey = removeInvalidChars(key) if (value) { value = String(value) } obj[skey] = value return obj }
javascript
{ "resource": "" }
q23269
train
function (successFn, errorFn) { successFn = successFn || emptyFn; errorFn = errorFn || emptyFn; RNBackgroundGeolocation.getStationaryLocation(successFn, errorFn); }
javascript
{ "resource": "" }
q23270
_validateProductStructure
train
function _validateProductStructure(product) { if (typeof product !== 'object') { throw new TypeError(product + ' is not an object.'); } if (Object.keys(product).length === 0 && product.constructor === Object) { throw new Error(product + ' is empty.'); } }
javascript
{ "resource": "" }
q23271
buildOptions
train
function buildOptions (provinceNodeElement, provinces) { var defaultValue = provinceNodeElement.getAttribute('data-default'); provinces.forEach(function (option) { var optionElement = document.createElement('option'); optionElement.value = option[0]; optionElement.textContent = option[1]; province...
javascript
{ "resource": "" }
q23272
buildProvince
train
function buildProvince (countryNodeElement, provinceNodeElement, selectedValue) { var selectedOption = getOption(countryNodeElement, selectedValue); var provinces = JSON.parse(selectedOption.getAttribute('data-provinces')); provinceNodeElement.options.length = 0; if (provinces.length) { buildOptions(provi...
javascript
{ "resource": "" }
q23273
appendApiUrlParam
train
function appendApiUrlParam(fullUrl, apiUrl) { let appendedUrl = fullUrl; if (typeof apiUrl === 'string') { if (fullUrl.indexOf('?') === -1) { appendedUrl += '?'; } else { appendedUrl += '&'; } appendedUrl += 'apiUrl='; // trim trailing slash from...
javascript
{ "resource": "" }
q23274
extractProtocolHost
train
function extractProtocolHost(url) { const urlNoQuery = url.split('?')[0]; const [protocol, hostAndPath] = urlNoQuery.split('//'); const host = hostAndPath.split('/')[0]; return `${protocol}//${host}`; }
javascript
{ "resource": "" }
q23275
setLoaderClass
train
function setLoaderClass(c, t) { timeouts.push( setTimeout(() => { loadbar.classList.add(c); }, t) ); }
javascript
{ "resource": "" }
q23276
findExtensionsYAMLFile
train
function findExtensionsYAMLFile() { for (var i = 0; i < paths.srcPaths.length; i++) { var srcPath = path.resolve(cwd, paths.srcPaths[i]); var extFile = path.resolve(srcPath, 'jenkins-js-extension.yaml'); if (fs.existsSync(extFile)) { return extFile; } } return un...
javascript
{ "resource": "" }
q23277
loadSource
train
function loadSource(sourcePath) { return new Promise((fulfil, reject) => { fs.readFile(sourcePath, 'utf8', (err, data) => { if (err) { reject(err); } else { fulfil(data); } }); }); }
javascript
{ "resource": "" }
q23278
saveSource
train
function saveSource(sourcePath, data) { return new Promise((fulfil, reject) => { fs.writeFile(sourcePath, data, 'utf8', err => { if (err) { reject(err); } else { fulfil(true); } }); }); }
javascript
{ "resource": "" }
q23279
getSourceFilesFromGlob
train
function getSourceFilesFromGlob(globPattern, ignoreGlobs) { return new Promise((fulfil, reject) => { glob(globPattern, { ignore: ignoreGlobs }, (err, files) => { if (err) { reject(err); } else { fulfil(files); } }); }); }
javascript
{ "resource": "" }
q23280
filterFiles
train
function filterFiles(files, validExtensions) { const accepted = []; for (const fileName of files) { if (accepted.indexOf(fileName) === -1 && fileMatchesExtension(fileName, validExtensions)) { accepted.push(fileName); } } return accepted; }
javascript
{ "resource": "" }
q23281
splitFilesIntoBatches
train
function splitFilesIntoBatches(files, config) { // We need to specifiy a different parser for TS files const configTS = Object.assign({}, config); configTS.parser = 'typescript'; const batches = []; batches.push({ files: files.filter(fileName => fileMatchesExtension(fileName, EXTENSIONS.js...
javascript
{ "resource": "" }
q23282
prettifyBatches
train
function prettifyBatches(batches) { return Promise.all(batches.map(({ files, config }) => prettifyFiles(files, config))); }
javascript
{ "resource": "" }
q23283
mergeBatchResults
train
function mergeBatchResults(batches) { let files = []; let unformattedFiles = []; let formattedFiles = []; let errors = []; batches.forEach(batch => { files.push(...batch.files); unformattedFiles.push(...batch.unformattedFiles); formattedFiles.push(...batch.formattedFiles); ...
javascript
{ "resource": "" }
q23284
showResults
train
function showResults(files, formattedFiles, unformattedFiles, errors) { const formattedCount = formattedFiles.length; const unformattedCount = unformattedFiles.length; const errorCount = errors.length; const filesCount = files.length; const okCount = filesCount - formattedCount - unformattedCount - ...
javascript
{ "resource": "" }
q23285
delayReject
train
function delayReject(delay = 1000) { const begin = time(); const promise = new Promise((resolve, reject) => { setTimeout(() => { if (promise.payload) { reject(promise.payload); } }, delay); }); return function proceed(error) { // if we ha...
javascript
{ "resource": "" }
q23286
sortByOrdinal
train
function sortByOrdinal(extensions, done) { const sorted = extensions.sort((a, b) => { if (a.ordinal || b.ordinal) { if (!a.ordinal) return 1; if (!b.ordinal) return -1; if (a.ordinal < b.ordinal) return -1; return 1; } return a.pluginId.localeC...
javascript
{ "resource": "" }
q23287
prepareOptions
train
function prepareOptions(body) { const fetchOptions = Object.assign({}, fetchOptionsCommon); if (body) { try { fetchOptions.body = JSON.stringify(body); } catch (e) { console.warn('The form body are not added. Could not extract data from the body element', body); }...
javascript
{ "resource": "" }
q23288
validateSourcePath
train
function validateSourcePath(sourcePath) { const materialPackageJSONPath = pathUtils.resolve(sourcePath, 'package.json'); return fs.readFileAsync(materialPackageJSONPath, { encoding: 'UTF8' }) .then(materialPackageJSONString => { const package = JSON.parse(materialPackageJSONString); ...
javascript
{ "resource": "" }
q23289
findSourceFiles
train
function findSourceFiles(sourceIconsRoot) { let visitedDirectories = []; let allSourceFiles = []; function recurseDir(dir, depth) { // Don't get in any loops if (visitedDirectories.indexOf(dir) !== -1) { return; } if (depth > 3) { throw new Error('fi...
javascript
{ "resource": "" }
q23290
train
function(a, epsilon) { if(epsilon == undefined) epsilon = EPSILON; let allSignsFlipped = false; if (e.length != a.length) expected(e, "to have the same length as", a); for (let i = 0; i < e.length; i++) { if (isNaN(e...
javascript
{ "resource": "" }
q23291
onDeleteSuccess
train
function onDeleteSuccess(model, params, result) { Flux.dispatch(actionTypes.API_DELETE_SUCCESS, { model: model, params: params, result: result, }) return result }
javascript
{ "resource": "" }
q23292
onDeleteFail
train
function onDeleteFail(model, params, reason) { Flux.dispatch(actionTypes.API_DELETE_FAIL, { model: model, params: params, reason: reason, }) return Promise.reject(reason) }
javascript
{ "resource": "" }
q23293
getFlattenedDeps
train
function getFlattenedDeps(getter, existing) { if (!existing) { existing = Immutable.Set() } const toAdd = Immutable.Set().withMutations(set => { if (!isGetter(getter)) { throw new Error('getFlattenedDeps must be passed a Getter') } getDeps(getter).forEach(dep => { if (isKeyPath(dep))...
javascript
{ "resource": "" }
q23294
createCacheEntry
train
function createCacheEntry(reactorState, getter) { // evaluate dependencies const args = getDeps(getter).map(dep => evaluate(reactorState, dep).result) const value = getComputeFn(getter).apply(null, args) const storeDeps = getStoreDeps(getter) const storeStates = toImmutable({}).withMutations(map => { sto...
javascript
{ "resource": "" }
q23295
setMessagesRead
train
function setMessagesRead(state, { threadID }) { return state.updateIn([threadID, 'messages'], messages => { return messages.map(msg => msg.set('isRead', true)) }) }
javascript
{ "resource": "" }
q23296
removeFsElement
train
function removeFsElement (element) { let index = fsElements.indexOf(element) if (index !== -1) { fsElements.splice(index, 1) } }
javascript
{ "resource": "" }
q23297
getTiming
train
function getTiming () { let nativeTiming let performance = window.performance if (performance && performance.timing) { nativeTiming = performance.timing.toJSON ? performance.timing.toJSON() : util.fn.extend({}, performance.timing) } else { nativeTiming = {} } return util.fn.extend(native...
javascript
{ "resource": "" }
q23298
recordTiming
train
function recordTiming (name, timing) { recorder[name] = parseInt(timing, 10) || Date.now() performanceEvent.trigger('update', getTiming()) }
javascript
{ "resource": "" }
q23299
lockFirstScreen
train
function lockFirstScreen () { // when is prerendering, iframe container display none, // all elements are not in viewport. if (prerender.isPrerendering) { return } let viewportRect = viewport.getRect() fsElements = fsElements.filter((element) => { if (prerender.isPrerendered) { return element....
javascript
{ "resource": "" }