Search is not available for this dataset
query
stringlengths
7
355k
document
stringlengths
9
341k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
TODO: emstricten & fix the typing here! `createWithBsPrefix...`
function createWithBsPrefix(prefix, _temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$displayName = _ref.displayName, displayName = _ref$displayName === void 0 ? pascalCase(prefix) : _ref$displayName, Component = _ref.Component, defaultProps = _ref.defaultProps; var BsComponent = react__WEBPACK_IMPORTED_MODULE_4___default.a.forwardRef(function (_ref2, ref) { var className = _ref2.className, bsPrefix = _ref2.bsPrefix, _ref2$as = _ref2.as, Tag = _ref2$as === void 0 ? Component || 'div' : _ref2$as, props = Object(_babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_1__["default"])(_ref2, ["className", "bsPrefix", "as"]); var resolvedPrefix = Object(_ThemeProvider__WEBPACK_IMPORTED_MODULE_5__["useBootstrapPrefix"])(bsPrefix, prefix); return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_4___default.a.createElement(Tag, Object(_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({ ref: ref, className: classnames__WEBPACK_IMPORTED_MODULE_2___default()(className, resolvedPrefix) }, props)); }); BsComponent.defaultProps = defaultProps; BsComponent.displayName = displayName; return BsComponent; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createWithBsPrefix(prefix, _temp) {\n var _ref = _temp === void 0 ? {} : _temp,\n _ref$displayName = _ref.displayName,\n displayName = _ref$displayName === void 0 ? pascalCase(prefix) : _ref$displayName,\n Component = _ref.Component,\n defaultProps = _ref.defaultProps;\n\n var BsComp...
[ "0.72567123", "0.72567123", "0.7242157", "0.722152", "0.72063273", "0.71576464", "0.56655985", "0.564259", "0.5450635", "0.5316197", "0.5272328", "0.51581407", "0.51556474", "0.51294714", "0.51221985", "0.51042974", "0.5082082", "0.5079216", "0.5079216", "0.5020319", "0.49993...
0.71808153
5
reading a dimension prop will cause the browser to recalculate, which will let our animations work
function triggerBrowserReflow(node) { // eslint-disable-next-line @typescript-eslint/no-unused-expressions node.offsetHeight; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get dimensions() { return this._dimensions; }", "function GetDimension()\n{\n\treturn m_dimension;\n}", "getDim() {\n var width, height;\n\n // If the particle only has a set size (not width/height)\n if (this.size) {\n width = this.size;\n height = this.size;\n } else {\n width = th...
[ "0.6696144", "0.66818684", "0.6676606", "0.6507382", "0.64850235", "0.64654666", "0.63174057", "0.6300187", "0.6299067", "0.6289369", "0.6270396", "0.6189207", "0.6172025", "0.6156513", "0.6149669", "0.61004347", "0.60715854", "0.6055112", "0.60541075", "0.5985734", "0.597465...
0.0
-1
by calls to these methods by a Babel plugin. In PROD (or in packages without access to React internals), they are left as they are instead.
function warn(format) { { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } printWarning('warn', format, args); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function resetIfUsingPreact() {\n if (window.preact !== undefined) {\n jsxLoader.compiler.pragma = 'React.createElement';\n jsxLoader.compiler.pragmaFrag = 'React.Fragment';\n }\n }", "react() {\n return;\n }", "function globalizeReact() {\n ...
[ "0.6232017", "0.5989827", "0.59513646", "0.5714014", "0.5714014", "0.5707565", "0.5690933", "0.5690933", "0.55861586", "0.5557413", "0.5545285", "0.5545285", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", ...
0.0
-1
During execution of guarded functions we will capture the first error which we will rethrow to be handled by the top level error handler.
function rethrowCaughtError() { if (hasRethrowError) { var error = rethrowError; hasRethrowError = false; rethrowError = null; throw error; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _tryEachErrorHandler(next, ctx) {\n if (ctx.ix >= ctx.steps.length) return next(ctx.err2 || ctx.err, 'done'); else { ctx.next = next; _tryStepContext(ctx, _tryNext); }\n }", "function rethrowCaughtError(){if(hasRethrowError){var error=rethrowError;hasRethrowError=false;rethrowError=null;throw ...
[ "0.6411594", "0.6345882", "0.6345882", "0.6345882", "0.6345882", "0.6345882", "0.6345882", "0.6345882", "0.63279694", "0.6323391", "0.6160426", "0.6152842", "0.6152842", "0.6152842", "0.6152842", "0.6152842", "0.6152842", "0.6152842", "0.6152842", "0.6152842", "0.6152842", ...
0.59499127
86
Standard/simple iteration through an event's collected dispatches.
function executeDispatchesInOrder(event) { var dispatchListeners = event._dispatchListeners; var dispatchInstances = event._dispatchInstances; { validateEventDispatches(event); } if (Array.isArray(dispatchListeners)) { for (var i = 0; i < dispatchListeners.length; i++) { if (event.isPropagationStopped()) { break; } // Listeners and Instances are two parallel arrays that are always in sync. executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); } } else if (dispatchListeners) { executeDispatch(event, dispatchListeners, dispatchInstances); } event._dispatchListeners = null; event._dispatchInstances = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function forEachEventDispatch(event,cb){var dispatchListeners=event._dispatchListeners;var dispatchIDs=event._dispatchIDs;if(\"production\"!==process.env.NODE_ENV){validateEventDispatches(event);}if(Array.isArray(dispatchListeners)){for(var i=0;i<dispatchListeners.length;i++){if(event.isPropagationStopped()){break...
[ "0.6340201", "0.6318283", "0.6216154", "0.6129209", "0.6122544", "0.6122544", "0.6122544", "0.6122544", "0.6122544", "0.6122544", "0.6122544", "0.6122544", "0.6119329", "0.6119329", "0.61154145", "0.60784554", "0.60784554", "0.60784554", "0.60784554", "0.60784554", "0.6078455...
0.0
-1
Recomputes the plugin list using the injected plugins and plugin ordering.
function recomputePluginOrdering() { if (!eventPluginOrder) { // Wait until an `eventPluginOrder` is injected. return; } for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName]; var pluginIndex = eventPluginOrder.indexOf(pluginName); if (!(pluginIndex > -1)) { { throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + pluginName + "`." ); } } if (plugins[pluginIndex]) { continue; } if (!pluginModule.extractEvents) { { throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not." ); } } plugins[pluginIndex] = pluginModule; var publishedEvents = pluginModule.eventTypes; for (var eventName in publishedEvents) { if (!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName)) { { throw Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + pluginName + "`." ); } } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "orderPlugins() {\r\n debug('orderPlugins:before', this.pluginNames);\r\n const runLast = this._plugins\r\n .filter(p => p.requirements.has('runLast'))\r\n .map(p => p.name);\r\n for (const name of runLast) {\r\n const index = this._plugins.findIndex(p => p.name...
[ "0.7994548", "0.74701035", "0.7169167", "0.71361053", "0.71361053", "0.71361053", "0.7128741", "0.7122665", "0.71187073", "0.7117351", "0.7117351", "0.7117351", "0.71010214", "0.71010214", "0.71010214", "0.709135", "0.709135", "0.709135", "0.709135", "0.709135", "0.709135", ...
0.0
-1
Get the value for a property on a node. Only used in DEV for SSR validation. The "expected" argument is used as a hint of what the expected value is. Some properties have multiple equivalent values.
function getValueForProperty(node, name, expected, propertyInfo) { { if (propertyInfo.mustUseProperty) { var propertyName = propertyInfo.propertyName; return node[propertyName]; } else { if ( propertyInfo.sanitizeURL) { // If we haven't fully disabled javascript: URLs, and if // the hydration is successful of a javascript: URL, we // still want to warn on the client. sanitizeURL('' + expected); } var attributeName = propertyInfo.attributeName; var stringValue = null; if (propertyInfo.type === OVERLOADED_BOOLEAN) { if (node.hasAttribute(attributeName)) { var value = node.getAttribute(attributeName); if (value === '') { return true; } if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { return value; } if (value === '' + expected) { return expected; } return value; } } else if (node.hasAttribute(attributeName)) { if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { // We had an attribute but shouldn't have had one, so read it // for the error message. return node.getAttribute(attributeName); } if (propertyInfo.type === BOOLEAN) { // If this was a boolean, it doesn't matter what the value is // the fact that we have it is the same as the expected. return expected; } // Even if this property uses a namespace we use getAttribute // because we assume its namespaced name is the same as our config. // To use getAttributeNS we need the local name which we don't have // in our config atm. stringValue = node.getAttribute(attributeName); } if (shouldRemoveAttribute(name, expected, propertyInfo, false)) { return stringValue === null ? expected : stringValue; } else if (stringValue === '' + expected) { return expected; } else { return stringValue; } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getValueForProperty(node,name,expected){{var propertyInfo=getPropertyInfo(name);if(propertyInfo){var mutationMethod=propertyInfo.mutationMethod;if(mutationMethod||propertyInfo.mustUseProperty){return node[propertyInfo.propertyName];}else{var attributeName=propertyInfo.attributeName;var stringValue=null;if...
[ "0.81585205", "0.81585205", "0.8143505", "0.8068335", "0.8068335", "0.8064425", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", "0.80600667", ...
0.78881687
72
Get the value for a attribute on a node. Only used in DEV for SSR validation. The third argument is used as a hint of what the expected value is. Some attributes have multiple equivalent values.
function getValueForAttribute(node, name, expected) { { if (!isAttributeNameSafe(name)) { return; } if (!node.hasAttribute(name)) { return expected === undefined ? undefined : null; } var value = node.getAttribute(name); if (value === '' + expected) { return expected; } return value; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getValueForAttribute(node,name,expected){{if(!isAttributeNameSafe(name)){return;}if(!node.hasAttribute(name)){return expected===undefined?undefined:null;}var value=node.getAttribute(name);if(value===''+expected){return expected;}return value;}}", "function getValueForAttribute(node,name,expected){{if(!i...
[ "0.7426143", "0.7426143", "0.7426143", "0.7426143", "0.7426143", "0.7426143", "0.7426143", "0.7426143", "0.7426143", "0.7426143", "0.7328788", "0.7328788", "0.73259443", "0.73224336", "0.73224336", "0.73224336", "0.73224336", "0.73224336", "0.73224336", "0.73224336", "0.73224...
0.0
-1
Flow does not allow string concatenation of most nonstring types. To work around this limitation, we use an opaque type that can only be obtained by passing the value through getToStringValue first.
function toString(value) { return '' + value; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function string(val) {\n return {value: val, type: 'string'};\n}", "get stringValue() {}", "function toString(value){return ''+value;}", "function toString(value){return''+value;}", "function toString(value){return''+value;}", "function toString(value){return''+value;}", "function toString(value){retu...
[ "0.6297387", "0.6282521", "0.625954", "0.62230176", "0.62230176", "0.62230176", "0.62230176", "0.62230176", "0.62230176", "0.6184894", "0.61484236", "0.6067506", "0.6067506", "0.6067506", "0.6067506", "0.6067506", "0.6067506", "0.6067506", "0.6067506", "0.6067506", "0.6067506...
0.6112809
71
Implements an host component that allows setting these optional props: `checked`, `value`, `defaultChecked`, and `defaultValue`. If `checked` or `value` are not supplied (or null/undefined), user actions that affect the checked state or value will trigger updates to the element. If they are supplied (and not null/undefined), the rendered element will not trigger updates to the element. Instead, the props must change in order for the rendered element to be updated. The rendered element will be initialized as unchecked (or `defaultChecked`) with an empty value (or `defaultValue`). See
function getHostProps(element, props) { var node = element; var checked = props.checked; var hostProps = _assign({}, props, { defaultChecked: undefined, defaultValue: undefined, value: undefined, checked: checked != null ? checked : node._wrapperState.initialChecked }); return hostProps; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "constructor(props) {\n super(props);\n this.value = props.value;\n this.id = RadioButton.idGenerator(this.value);\n this.groupName = props.groupName;\n this.optional = {};\n if (typeof props.onChangeCallback === 'function') {\n this.optional.onChangeCallback =\n...
[ "0.6890328", "0.67860484", "0.67860484", "0.67860484", "0.67860484", "0.67860484", "0.67860484", "0.67860484", "0.67860484", "0.67860484", "0.63885677", "0.62577355", "0.62111604", "0.6131694", "0.6131694", "0.6131694", "0.6131694", "0.6131694", "0.6131694", "0.6131694", "0.6...
0.0
-1
For number inputs, the display value loses trailing decimal points. For email inputs, Chrome raises "The specified value is not a valid email address". Here we check to see if the defaultValue has actually changed, avoiding these problems when the user is inputting text
function setDefaultValue(node, type, value) { if ( // Focused number inputs synchronize on blur. See ChangeEventPlugin.js type !== 'number' || node.ownerDocument.activeElement !== node) { if (value == null) { node.defaultValue = toString(node._wrapperState.initialValue); } else if (node.defaultValue !== toString(value)) { node.defaultValue = toString(value); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "shouldSetInputTextToDefaultValue (props) {\n let result = (this.previousDefaultValue != props.defaultValue) || (this.previousChangeIndicator != props.changeIndicator)\n return result\n }", "function setDefaultValue(node,type,value){if(// Focused number inputs synchronize on blur. See ChangeEventPlugin.js\...
[ "0.6748244", "0.6745956", "0.6745956", "0.668249", "0.668249", "0.668249", "0.668249", "0.668249", "0.66758955", "0.66758955", "0.6567232", "0.65263164", "0.6493208", "0.6483082", "0.6483082", "0.6483082", "0.6483082", "0.6460759", "0.6460759", "0.6460759", "0.6460759", "0....
0.63645613
89
Implements an host component that warns when `selected` is set.
function validateProps(element, props) { { // This mirrors the codepath above, but runs for hydration too. // Warn about invalid children here so that client and hydration are consistent. // TODO: this seems like it could cause a DEV-only throw for hydration // if children contains a non-element object. We should try to avoid that. if (typeof props.children === 'object' && props.children !== null) { React.Children.forEach(props.children, function (child) { if (child == null) { return; } if (typeof child === 'string' || typeof child === 'number') { return; } if (typeof child.type !== 'string') { return; } if (!didWarnInvalidChild) { didWarnInvalidChild = true; error('Only strings and numbers are supported as <option> children.'); } }); } // TODO: Remove support for `selected` in <option>. if (props.selected != null && !didWarnSelectedSetOnOption) { error('Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.'); didWarnSelectedSetOnOption = true; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get _shouldUpdateSelection(){return this.selected!=null;}", "get selected() { return this._selected; }", "get selected() { return this._selected; }", "get selected() { return this._selected; }", "get selected() { return this._selected; }", "get selected() { return this._selected; }", "get selected() { ...
[ "0.583788", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.57225657", "0.56584495", "0.55881727", "0.55775845", "0.5576491", "0.55629015", "0.55629015", "0.5547889", ...
0.0
-1
Validation function for `value` and `defaultValue`.
function checkSelectPropTypes(props) { { ReactControlledValuePropTypes.checkPropTypes('select', props); for (var i = 0; i < valuePropNames.length; i++) { var propName = valuePropNames[i]; if (props[propName] == null) { continue; } var isArray = Array.isArray(props[propName]); if (props.multiple && !isArray) { error('The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum()); } else if (!props.multiple && isArray) { error('The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum()); } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "'validateValue'(value) {}", "function checkValue(value, defaultValue) {\n return (value ? value : defaultValue)\n }", "function validateInput(\n value,\n { float, canBeNegative, canBeEmpty, defaultValue }\n) {\n if (`${value}`.length > 0) {\n const valueAsNumber = float ? parseFloat(value) : pa...
[ "0.7435683", "0.6854287", "0.6585061", "0.64306885", "0.64273626", "0.64273626", "0.6416209", "0.6416209", "0.6416209", "0.6315511", "0.62307525", "0.6194622", "0.616243", "0.6123072", "0.6049483", "0.6043338", "0.6035735", "0.5972668", "0.59355694", "0.5868073", "0.5864089",...
0.0
-1
Implements a host component that allows optionally setting the props `value` and `defaultValue`. If `multiple` is false, the prop must be a stringable. If `multiple` is true, the prop must be an array of stringables. If `value` is not supplied (or null/undefined), user actions that change the selected option will trigger updates to the rendered options. If it is supplied (and not null/undefined), the rendered options will not update in response to user actions. Instead, the `value` prop must change in order for the rendered options to update. If `defaultValue` is provided, any options with the supplied values will be selected.
function getHostProps$2(element, props) { return _assign({}, props, { value: undefined }); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function selectValueType(props,propName,componentName){if(props[propName]==null){return null;}if(props.multiple){if(!Array.isArray(props[propName])){return new Error(\"The `\"+propName+\"` prop supplied to <select> must be an array if \"+\"`multiple` is true.\");}}else {if(Array.isArray(props[propName])){return ne...
[ "0.6099009", "0.6063872", "0.5824494", "0.5824494", "0.5734369", "0.57118917", "0.570597", "0.570597", "0.570597", "0.570597", "0.570597", "0.5685921", "0.5680946", "0.56419384", "0.563298", "0.563298", "0.563298", "0.563298", "0.563298", "0.563298", "0.563298", "0.563298",...
0.0
-1
Implements a host component that allows setting `value`, and `defaultValue`. This differs from the traditional DOM API because value is usually set as PCDATA children. If `value` is not supplied (or null/undefined), user actions that affect the value will trigger updates to the element. If `value` is supplied (and not null/undefined), the rendered element will not trigger updates to the element. Instead, the `value` prop must change in order for the rendered element to be updated. The rendered element will be initialized with an empty value, the prop `defaultValue` if specified, or the children content (deprecated).
function getHostProps$3(element, props) { var node = element; if (!(props.dangerouslySetInnerHTML == null)) { { throw Error( "`dangerouslySetInnerHTML` does not make sense on <textarea>." ); } } // Always set children to the same thing. In IE9, the selection range will // get reset if `textContent` is mutated. We could add a check in setTextContent // to only set the value if/when the value differs from the node value (which would // completely solve this IE9 bug), but Sebastian+Sophie seemed to like this // solution. The value can be a boolean or object so that's why it's forced // to be a string. var hostProps = _assign({}, props, { value: undefined, defaultValue: undefined, children: toString(node._wrapperState.initialValue) }); return hostProps; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "set value(val) {\n if (this.#el) this.#el.value = val;\n else this.#value = val;\n }", "setValue(value){\n const thisWidget = this;\n const newValue = thisWidget.parseValue(value);\n \n /* TODO: Add validation */\n if(newValue !=thisWidget.value && thisWidget.isValid(newValue)){\n this...
[ "0.64184606", "0.59918016", "0.59759474", "0.59759474", "0.59759474", "0.59759474", "0.59759474", "0.59759474", "0.59759474", "0.5951113", "0.5926322", "0.5898258", "0.5878531", "0.5878531", "0.5878531", "0.5878531", "0.5878531", "0.5878531", "0.5878531", "0.58231217", "0.576...
0.0
-1
Assumes there is no parent namespace.
function getIntrinsicNamespace(type) { switch (type) { case 'svg': return SVG_NAMESPACE; case 'math': return MATH_NAMESPACE; default: return HTML_NAMESPACE; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getParentObject(){\r\n var obj = parent;\r\n if (namespace !== \"\") {\r\n for (var i = 0, ii = namespace.split(\".\"); i < ii.length; i++) {\r\n obj = obj[ii[i]];\r\n }\r\n }\r\n return obj.easyXDM;\r\n}", "function namespaceHTMLInternal() {\n instructionState.lF...
[ "0.59294087", "0.5788852", "0.5788852", "0.5788852", "0.5788852", "0.5788852", "0.5788852", "0.57438385", "0.56890935", "0.5673484", "0.56610936", "0.5640146", "0.5580239", "0.544239", "0.5442175", "0.5410278", "0.5397606", "0.53690296", "0.53592485", "0.5327534", "0.532705",...
0.0
-1
Do not use the below two methods directly! Instead use constants exported from DOMTopLevelEventTypes in ReactDOM. (It is the only module that is allowed to access these methods.)
function unsafeCastStringToDOMTopLevelType(topLevelType) { return topLevelType; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function handleTopLevel(topLevelType,targetInst,nativeEvent,nativeEventTarget){var events=extractEvents(topLevelType,targetInst,nativeEvent,nativeEventTarget);runEventQueueInBatch(events);}", "function handleTopLevel(topLevelType,targetInst,nativeEvent,nativeEventTarget){var events=extractEvents(topLevelType,tar...
[ "0.6492498", "0.6492498", "0.6492498", "0.62708116", "0.6237896", "0.62295246", "0.62265676", "0.62011015", "0.62011015", "0.62011015", "0.62011015", "0.62011015", "0.6125231", "0.60379905", "0.60379905", "0.5929177", "0.5902268", "0.5901559", "0.5901559", "0.5901559", "0.590...
0.0
-1
`ReactInstanceMap` maintains a mapping from a public facing stateful instance (key) and the internal representation (value). This allows public methods to accept the user facing instance as an argument and map them back to internal methods. Note that this module is currently shared and assumed to be stateless. If this becomes an actual Map, that will break.
function get(key) { return key._reactInternalFiber; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mapWrapper(key)\n{\n\tthis.key = key;\n}", "function Map() {\n\tthis.keys = [];\n\tthis.values = [];\n\n\t// add a key / value pair to map\n\tthis.add = function(key, value) {\n\t\tthis.keys.push(key);\n\t\tthis.values.push(value);\n\t}\n\n\t// get value from key\n\tthis.get = function(key) {\n\t\tretur...
[ "0.55530405", "0.5547857", "0.55443573", "0.5531664", "0.5357758", "0.5312821", "0.5214135", "0.5200113", "0.51929325", "0.51665306", "0.51311094", "0.51135135", "0.511133", "0.5057867", "0.5051099", "0.5049122", "0.5036898", "0.50143623", "0.50143623", "0.50143623", "0.50143...
0.0
-1
Find the deepest React component completely containing the root of the passedin instance (for use when entire React trees are nested within each other). If React trees are not nested, returns null.
function findRootContainerNode(inst) { if (inst.tag === HostRoot) { return inst.stateNode.containerInfo; } // TODO: It may be a good idea to cache this to prevent unnecessary DOM // traversal, but caching is difficult to do correctly without using a // mutation observer to listen for all DOM changes. while (inst.return) { inst = inst.return; } if (inst.tag !== HostRoot) { // This can happen if we're in a detached tree. return null; } return inst.stateNode.containerInfo; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findFirstReactDOMImpl(node) {\n // This node might be from another React instance, so we make sure not to\n // examine the node cache here\n for (; node && node.parentNode !== node; node = node.parentNode) {\n if (node.nodeType !== 1) {\n // Not a DOMElement, therefore not a React component\n ...
[ "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.68765056", "0.67980665", "0.67980665", "0.67980665", "0.67980665", "0.67980665", "0.67980665"...
0.0
-1
Hyphenates a camelcased CSS property name, for example: > hyphenateStyleName('backgroundColor') hyphenateStyleName('MozTransition') hyphenateStyleName('msTransition') < "mstransition" As Modernizr suggests ( an `ms` prefix is converted to `ms`.
function hyphenateStyleName(name) { return name.replace(uppercasePattern, '-$1').toLowerCase().replace(msPattern, '-ms-'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function hyphenateStyleName(name){return name.replace(uppercasePattern,'-$1').toLowerCase().replace(msPattern,'-ms-');}", "function hyphenateStyleName(name){return name.replace(uppercasePattern,'-$1').toLowerCase().replace(msPattern,'-ms-');}", "function hyphenateStyleName(name){return name.replace(uppercasePa...
[ "0.818741", "0.818741", "0.818741", "0.818741", "0.818741", "0.818741", "0.818741", "0.818741", "0.79492724" ]
0.7950082
97
Operations for dealing with CSS properties. This creates a string that is expected to be equivalent to the style attribute generated by serverside rendering. It bypasses warnings and security checks so it's not safe to use this value for anything other than comparison. It is only used in DEV for SSR validation.
function createDangerousStringForStyles(styles) { { var serialized = ''; var delimiter = ''; for (var styleName in styles) { if (!styles.hasOwnProperty(styleName)) { continue; } var styleValue = styles[styleName]; if (styleValue != null) { var isCustomProperty = styleName.indexOf('--') === 0; serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ':'; serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty); delimiter = ';'; } } return serialized || null; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static get styles () {\n return css`${unsafeCSS(style)}`\n }", "get cssText() {\n var properties = [];\n for (var i = 0, length = this.length; i < length; ++i) {\n var name = this[i];\n var value = this.getPropertyValue(name);\n var priority = this.getPropertyPriority(name);\n if (p...
[ "0.6745135", "0.661401", "0.6602852", "0.65247476", "0.65247476", "0.6436216", "0.64069366", "0.63674486", "0.6298139", "0.6198508", "0.618331", "0.6170014", "0.6170014", "0.6169674", "0.6165187", "0.6114536", "0.6075997", "0.6075997", "0.60752136", "0.60752136", "0.60752136"...
0.0
-1
SuspenseInstance. I.e. if its previous sibling is a Comment with SUSPENSE_x_START_DATA. Otherwise, null.
function getParentSuspenseInstance(targetInstance) { var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. // There might be nested nodes so we need to keep track of how // deep we are and only break out when we're back on top. var depth = 0; while (node) { if (node.nodeType === COMMENT_NODE) { var data = node.data; if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) { if (depth === 0) { return node; } else { depth--; } } else if (data === SUSPENSE_END_DATA) { depth++; } } node = node.previousSibling; } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getParentSuspenseInstance(targetInstance) {\n var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary.\n // There might be nested nodes so we need to keep track of how\n // deep we are and only break out when we're back on top....
[ "0.75222766", "0.74048257", "0.7396234", "0.7396234", "0.7396234", "0.7396234", "0.7396234", "0.7396234", "0.7396234", "0.7396234", "0.7396234", "0.7396234", "0.73667777", "0.7022139", "0.7022139", "0.7022139", "0.7022139", "0.7020779", "0.4663236", "0.4649656", "0.45708218",...
0.7283626
50
If the target node is part of a hydrated or not yet rendered subtree, then this may also return a SuspenseComponent or HostRoot to indicate that. Conceptually the HostRoot fiber is a child of the Container node. So if you pass the Container node as the targetNode, you will not actually get the HostRoot back. To get to the HostRoot, you need to pass a child of it. The same thing applies to Suspense boundaries.
function getClosestInstanceFromNode(targetNode) { var targetInst = targetNode[internalInstanceKey]; if (targetInst) { // Don't return HostRoot or SuspenseComponent here. return targetInst; } // If the direct event target isn't a React owned DOM node, we need to look // to see if one of its parents is a React owned DOM node. var parentNode = targetNode.parentNode; while (parentNode) { // We'll check if this is a container root that could include // React nodes in the future. We need to check this first because // if we're a child of a dehydrated container, we need to first // find that inner container before moving on to finding the parent // instance. Note that we don't check this field on the targetNode // itself because the fibers are conceptually between the container // node and the first child. It isn't surrounding the container node. // If it's not a container, we check if it's an instance. targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey]; if (targetInst) { // Since this wasn't the direct target of the event, we might have // stepped past dehydrated DOM nodes to get here. However they could // also have been non-React nodes. We need to answer which one. // If we the instance doesn't have any children, then there can't be // a nested suspense boundary within it. So we can use this as a fast // bailout. Most of the time, when people add non-React children to // the tree, it is using a ref to a child-less DOM node. // Normally we'd only need to check one of the fibers because if it // has ever gone from having children to deleting them or vice versa // it would have deleted the dehydrated boundary nested inside already. // However, since the HostRoot starts out with an alternate it might // have one on the alternate so we need to check in case this was a // root. var alternate = targetInst.alternate; if (targetInst.child !== null || alternate !== null && alternate.child !== null) { // Next we need to figure out if the node that skipped past is // nested within a dehydrated boundary and if so, which one. var suspenseInstance = getParentSuspenseInstance(targetNode); while (suspenseInstance !== null) { // We found a suspense instance. That means that we haven't // hydrated it yet. Even though we leave the comments in the // DOM after hydrating, and there are boundaries in the DOM // that could already be hydrated, we wouldn't have found them // through this pass since if the target is hydrated it would // have had an internalInstanceKey on it. // Let's get the fiber associated with the SuspenseComponent // as the deepest instance. var targetSuspenseInst = suspenseInstance[internalInstanceKey]; if (targetSuspenseInst) { return targetSuspenseInst; } // If we don't find a Fiber on the comment, it might be because // we haven't gotten to hydrate it yet. There might still be a // parent boundary that hasn't above this one so we need to find // the outer most that is known. suspenseInstance = getParentSuspenseInstance(suspenseInstance); // If we don't find one, then that should mean that the parent // host component also hasn't hydrated yet. We can return it // below since it will bail out on the isMounted check later. } } return targetInst; } targetNode = parentNode; parentNode = targetNode.parentNode; } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getClosestInstanceFromNode(targetNode) {\n var targetInst = targetNode[internalInstanceKey];\n\n if (targetInst) {\n // Don't return HostRoot or SuspenseComponent here.\n return targetInst;\n } // If the direct event target isn't a React...
[ "0.7508332", "0.74758923", "0.74758923", "0.74758923", "0.74758923", "0.74758923", "0.74758923", "0.74758923", "0.74758923", "0.74758923", "0.74758923", "0.74234617", "0.7420322", "0.7116136", "0.7116136", "0.7116136", "0.7116136", "0.7116136", "0.6096912", "0.6053429", "0.59...
0.73581517
48
Given a DOM node, return the ReactDOMComponent or ReactDOMTextComponent instance, or null if the node was not rendered by this React.
function getInstanceFromNode$1(node) { var inst = node[internalInstanceKey] || node[internalContainerInstanceKey]; if (inst) { if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) { return inst; } else { return null; } } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findDOMNode(node) {\n if (node instanceof HTMLElement) {\n return node;\n }\n if (node instanceof react__WEBPACK_IMPORTED_MODULE_0__.Component) {\n return react_dom__WEBPACK_IMPORTED_MODULE_1__.findDOMNode(node);\n }\n return null;\n}", "function findFirstReactDOMImpl(node) {\n\t\t // This n...
[ "0.75970024", "0.7380755", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7350377", "0.7330323", "0.7330323", "0.7330323", ...
0.0
-1
Given a ReactDOMComponent or ReactDOMTextComponent, return the corresponding DOM node.
function getNodeFromInstance$1(inst) { if (inst.tag === HostComponent || inst.tag === HostText) { // In Fiber this, is just the state node right now. We assume it will be // a host component or host text. return inst.stateNode; } // Without this first invariant, passing a non-DOM-component triggers the next // invariant for a missing parent, which is super confusing. { { throw Error( "getNodeFromInstance: Invalid argument." ); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function findFirstReactDOMImpl(node) {\n\t\t // This node might be from another React instance, so we make sure not to\n\t\t // examine the node cache here\n\t\t for (; node && node.parentNode !== node; node = node.parentNode) {\n\t\t if (node.nodeType !== 1) {\n\t\t // Not a DOMElement, therefore not a...
[ "0.6785746", "0.67787415", "0.67723036", "0.67672795", "0.67672795", "0.6752765", "0.6743338", "0.6741935", "0.6741935", "0.6741935", "0.6741935", "0.6741935", "0.6741935", "0.6741935", "0.6741386", "0.6741386", "0.6741386", "0.6741386", "0.6741386", "0.6741386", "0.6732813",...
0.0
-1
Return the lowest common ancestor of A and B, or null if they are in different trees.
function getLowestCommonAncestor(instA, instB) { var depthA = 0; for (var tempA = instA; tempA; tempA = getParent(tempA)) { depthA++; } var depthB = 0; for (var tempB = instB; tempB; tempB = getParent(tempB)) { depthB++; } // If A is deeper, crawl up. while (depthA - depthB > 0) { instA = getParent(instA); depthA--; } // If B is deeper, crawl up. while (depthB - depthA > 0) { instB = getParent(instB); depthB--; } // Walk in lockstep until we find a match. var depth = depthA; while (depth--) { if (instA === instB || instA === instB.alternate) { return instA; } instA = getParent(instA); instB = getParent(instB); } return null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getLowestCommonAncestor(instA, instB) {\n\t !('_nativeNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : invariant(false) : void 0;\n\t !('_nativeNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromIns...
[ "0.82776135", "0.82776135", "0.82776135", "0.8273172", "0.8273172", "0.8273172", "0.82548386", "0.82297623", "0.82297623", "0.82297623", "0.82297623", "0.82005364", "0.82000446", "0.8185067", "0.8185067", "0.8185067", "0.8185067", "0.8185067", "0.8185067", "0.8185067", "0.818...
0.81400025
66
Simulates the traversal of a twophase, capture/bubble event dispatch.
function traverseTwoPhase(inst, fn, arg) { var path = []; while (inst) { path.push(inst); inst = getParent(inst); } var i; for (i = path.length; i-- > 0;) { fn(path[i], 'captured', arg); } for (i = 0; i < path.length; i++) { fn(path[i], 'bubbled', arg); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function traverseTwoPhase(inst,fn,arg){var path=[];while(inst){path.push(inst);inst=getParent(inst);}var i;for(i=path.length;i-->0;){fn(path[i],'captured',arg);}for(i=0;i<path.length;i++){fn(path[i],'bubbled',arg);}}", "function traverseTwoPhase(inst,fn,arg){var path=[];while(inst){path.push(inst);inst=getParent...
[ "0.58791095", "0.58791095", "0.58791095", "0.58791095", "0.58791095", "0.58791095", "0.5860188", "0.58587825", "0.58587825", "0.58587825", "0.58587825", "0.5663513", "0.5630192", "0.5587722", "0.5569497", "0.5569497", "0.5562592", "0.5548963", "0.5548963", "0.5548963", "0.554...
0.5547185
49
Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that should would receive a `mouseEnter` or `mouseLeave` event. Does not invoke the callback on the nearest common ancestor because nothing "entered" or "left" that element.
function traverseEnterLeave(from, to, fn, argFrom, argTo) { var common = from && to ? getLowestCommonAncestor(from, to) : null; var pathFrom = []; while (true) { if (!from) { break; } if (from === common) { break; } var alternate = from.alternate; if (alternate !== null && alternate === common) { break; } pathFrom.push(from); from = getParent(from); } var pathTo = []; while (true) { if (!to) { break; } if (to === common) { break; } var _alternate = to.alternate; if (_alternate !== null && _alternate === common) { break; } pathTo.push(to); to = getParent(to); } for (var i = 0; i < pathFrom.length; i++) { fn(pathFrom[i], 'bubbled', argFrom); } for (var _i = pathTo.length; _i-- > 0;) { fn(pathTo[_i], 'captured', argTo); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_handleMouseEnter() {\n this._hovered.next(this);\n }", "_elementMouseEnterHandler() {\n const that = this;\n\n if (that.clickMode === 'hover' && !that.disabled && !that.readonly) {\n that._handleMouseInteraction();\n }\n }", "_elementMouseEnterHandler() {\n ...
[ "0.50959915", "0.49235275", "0.49235275", "0.48829064", "0.48785248", "0.48785248", "0.48690268", "0.48657742", "0.47983202", "0.47769547", "0.47343478", "0.47343478", "0.47343478", "0.47343478", "0.47343478", "0.47343478", "0.47343478", "0.47343478", "0.47343478", "0.47343478"...
0.0
-1
Some event types have a notion of different registration names for different "phases" of propagation. This finds listeners by a given phase.
function listenerAtPhase(inst, event, propagationPhase) { var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase]; return getListener(inst, registrationName); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function listenerAtPhase(inst, event, propagationPhase) {\n\t\t var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];\n\t\t return getListener(inst, registrationName);\n\t\t}", "function listenerAtPhase(inst, event, propagationPhase) {\n\t\t var registrationName = event.dispat...
[ "0.6932278", "0.6932278", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6931419", "0.6924929", "0.6924929", "0.69005185", "0.69005185", "0.69005185", "0.69005185",...
0.0
-1
A small set of propagation patterns, each of which will accept a small amount of information, and generate a set of "dispatch ready event objects" which are sets of events that have already been annotated with a set of dispatched listener functions/ids. The API is designed this way to discourage these propagation strategies from actually executing the dispatches, since we always want to collect the entire set of dispatches before executing even a single one. Tags a `SyntheticEvent` with dispatched listeners. Creating this function here, allows us to not have to bind or create functions for each event. Mutating the event's members allows us to not have to create a wrapping "dispatch" object that pairs the event with the listener.
function accumulateDirectionalDispatches(inst, phase, event) { { if (!inst) { error('Dispatching inst must not be null'); } } var listener = listenerAtPhase(inst, event, phase); if (listener) { event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function accumulateDirectionalDispatches(inst,upwards,event){if(process.env.NODE_ENV!=='production'){process.env.NODE_ENV!=='production'?warning(inst,'Dispatching inst must not be null'):void 0;}var phase=upwards?PropagationPhases.bubbled:PropagationPhases.captured;var listener=listenerAtPhase(inst,event,phase);if...
[ "0.6350786", "0.6350786", "0.6247749", "0.62328684", "0.60861367", "0.60861367", "0.60861367", "0.60861367", "0.60861367", "0.5958953", "0.5958953", "0.5952106", "0.5944571", "0.5944571", "0.5927643", "0.5927643", "0.59275264", "0.59275264", "0.59275264", "0.59275264", "0.592...
0.0
-1
Collect dispatches (must be entirely collected before dispatching see unit tests). Lazily allocate the array to conserve memory. We must loop through each event and perform the traversal for each one. We cannot perform a single traversal for the entire collection of events because each event may have a different target.
function accumulateTwoPhaseDispatchesSingle(event) { if (event && event.dispatchConfig.phasedRegistrationNames) { traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function executeDispatchesInOrder(event){var dispatchListeners=event._dispatchListeners;var dispatchInstances=event._dispatchInstances;{validateEventDispatches(event);}if(Array.isArray(dispatchListeners)){for(var i=0;i<dispatchListeners.length;i++){if(event.isPropagationStopped()){break;}// Listeners and Instances...
[ "0.60375905", "0.60375905", "0.60375905", "0.60375905", "0.60375905", "0.59032416", "0.58940375", "0.58940375", "0.58940375", "0.58940375", "0.5876829", "0.5833313", "0.5833313", "0.5833313", "0.5833313", "0.5833313", "0.5833313", "0.5833313", "0.5833313", "0.5833313", "0.579...
0.0
-1
Accumulates without regard to direction, does not look for phased registration names. Same as `accumulateDirectDispatchesSingle` but without requiring that the `dispatchMarker` be the same as the dispatched ID.
function accumulateDispatches(inst, ignoredDirection, event) { if (inst && event && event.dispatchConfig.registrationName) { var registrationName = event.dispatchConfig.registrationName; var listener = getListener(inst, registrationName); if (listener) { event._dispatchListeners = accumulateInto(event._dispatchListeners, listener); event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function accumulateDispatches(id, ignoredDirection, event) {\n\t if (event && event.dispatchConfig.registrationName) {\n\t var registrationName = event.dispatchConfig.registrationName;\n\t var listener = getListener(id, registrationName);\n\t if (listener) {\n\t event._dispatchListeners = accumulate...
[ "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "0.7465256", "...
0.0
-1
Return whether a native keypress event is assumed to be a command. This is required because Firefox fires `keypress` events for key commands (cut, copy, selectall, etc.) even though no character is inserted.
function isKeypressCommand(nativeEvent) { return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && // ctrlKey && altKey is equivalent to AltGr, and is not a command. !(nativeEvent.ctrlKey && nativeEvent.altKey); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isKeypressCommand(nativeEvent) {\n\t return (\n\t (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&\n\t // ctrlKey && altKey is equivalent to AltGr, and is not a command.\n\t !(nativeEvent.ctrlKey && nativeEvent.altKey)\n\t );\n\t}", "function isKeypressCommand(nativeEvent...
[ "0.8017686", "0.8017686", "0.8017686", "0.8017686", "0.8017686", "0.8017686", "0.8017686", "0.8009321", "0.80005544", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", "0.7999407", ...
0.0
-1
SECTION: handle `change` event
function shouldUseChangeEvent(elem) { var nodeName = elem.nodeName && elem.nodeName.toLowerCase(); return nodeName === 'select' || nodeName === 'input' && elem.type === 'file'; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "change(/*event*/) {\n this._super(...arguments);\n this._parse();\n }", "handleChange(event) {\n this.dispatchEvent(new CustomEvent('change', {detail: event.target.value}));\n }", "onchange() {}", "function onChange() {\n\t\t__debug_452( 'Received a change event.' );\n\t\tself.render();\n\t}...
[ "0.7854437", "0.77068484", "0.7598262", "0.7521723", "0.7511005", "0.7504069", "0.7448793", "0.7420877", "0.7401912", "0.7386296", "0.73666596", "0.73555636", "0.73510677", "0.73496395", "0.73438835", "0.7339759", "0.73381084", "0.73354316", "0.73326874", "0.7328343", "0.7321...
0.0
-1
(For IE <=9) Starts tracking propertychange events on the passedin element and override the value property so that we can distinguish user events from value changes in JS.
function startWatchingForValueChange(target, targetInst) { activeElement = target; activeElementInst = targetInst; activeElement.attachEvent('onpropertychange', handlePropertyChange); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startWatchingForValueChange(target,targetInst){activeElement=target;activeElementInst=targetInst;activeElement.attachEvent('onpropertychange',handlePropertyChange);}", "function startWatchingForValueChange(target,targetInst){activeElement=target;activeElementInst=targetInst;activeElement.attachEvent('on...
[ "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.74983156", "0.7280744", "0.7193553", "0.7193553", "0.7044979", "0.7032104", "0.70234615", "0.69343716", "0.69343716", "...
0.0
-1
(For IE <=9) Removes the event listeners from the currentlytracked element, if any exists.
function stopWatchingForValueChange() { if (!activeElement) { return; } activeElement.detachEvent('onpropertychange', handlePropertyChange); activeElement = null; activeElementInst = null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "_removeEventListeners() {\n this.currentEventListeners.forEach(listener => {\n this.domElement.removeEventListener(listener.event, listener.callBack);\n });\n this.currentEventListeners = null;\n }", "function removeListeners(useCapturing) {\r\r\n // get all div in list\r\r\...
[ "0.75090146", "0.71331996", "0.71023005", "0.70842665", "0.70842665", "0.70741224", "0.70538986", "0.7043368", "0.703842", "0.701261", "0.70032084", "0.69829243", "0.6975078", "0.6940694", "0.6921042", "0.69165057", "0.69119114", "0.6898251", "0.68628937", "0.6861496", "0.686...
0.0
-1
(For IE <=9) Handles a propertychange event, sending a `change` event if the value of the active element has changed.
function handlePropertyChange(nativeEvent) { if (nativeEvent.propertyName !== 'value') { return; } if (getInstIfValueChanged(activeElementInst)) { manualDispatchChangeEvent(nativeEvent); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function startWatchingForValueChange(target,targetInst){activeElement=target;activeElementInst=targetInst;activeElement.attachEvent('onpropertychange',handlePropertyChange);}", "function startWatchingForValueChange(target,targetInst){activeElement=target;activeElementInst=targetInst;activeElement.attachEvent('on...
[ "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.7169761", "0.6944031", "0.6840544", "0.6831867", "0.6744023", "0.6694922", "0.6694922", "0.6694922", "0.6694922", "0.6694922", "...
0.0
-1
SECTION: handle `click` event
function shouldUseClickEvent(elem) { // Use the `click` event to detect changes to checkbox and radio inputs. // This approach works across all browsers, whereas `change` does not fire // until `blur` in IE8. var nodeName = elem.nodeName; return nodeName && nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio'); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "handleClick( event ){ }", "handleClick() {}", "function handleClick(){\n console.log(\"clicked\");\n}", "function handleClick(event)\n{\n}", "click() { }", "function clickHandler(){\n console.log('I am clicked');\n}", "function clickHandler(event) {\n\tindexChangeSections(event);\n\ttabChangeSect...
[ "0.8123866", "0.7879277", "0.7531671", "0.7500634", "0.7475805", "0.7402668", "0.73915786", "0.7379595", "0.7379595", "0.7331232", "0.7330436", "0.7245654", "0.72390676", "0.72122186", "0.7116352", "0.7082111", "0.7062615", "0.7056091", "0.7017624", "0.7006748", "0.6982211", ...
0.0
-1
Older browsers (Safari <= 10, iOS Safari <= 10.2) do not support getModifierState. If getModifierState is not supported, we map it to a set of modifier keys exposed by the event. In this case, Lockkeys are not supported.
function modifierStateGetter(keyArg) { var syntheticEvent = this; var nativeEvent = syntheticEvent.nativeEvent; if (nativeEvent.getModifierState) { return nativeEvent.getModifierState(keyArg); } var keyProp = modifierKeyToProp[keyArg]; return keyProp ? !!nativeEvent[keyProp] : false; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getModifierState(event, mod) {\n return typeof event.getModifierState === \"function\"\n ? event.getModifierState(mod)\n : false;\n}", "function modifierStateGetter(keyArg){var syntheticEvent=this;var nativeEvent=syntheticEvent.nativeEvent;if(nativeEvent.getModifierState){return nativeE...
[ "0.7935699", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.7853291", "0.775467", "0.775467", "0.73879474", "0.7353126", "0.7353126", "0...
0.0
-1
inlined Object.is polyfill to avoid requiring consumers ship their own
function is(x, y) { return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare ; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function i(e){return!0===\n/*!\n * isobject <https://github.com/jonschlinkert/isobject>\n *\n * Copyright (c) 2014-2017, Jon Schlinkert.\n * Released under the MIT License.\n */\nfunction(e){return null!=e&&\"object\"==typeof e&&!1===Array.isArray(e)}(e)&&\"[object Object]\"===Object.prototype.toString.call(e)}", ...
[ "0.7044971", "0.6979962", "0.6857963", "0.68213487", "0.6803169", "0.6780778", "0.67303896", "0.67208385", "0.6709952", "0.66844535", "0.667722", "0.667722", "0.667722", "0.66489047", "0.6640121", "0.6640121", "0.6640121", "0.6640121", "0.66260475", "0.6623466", "0.6623466", ...
0.0
-1
Performs equality by iterating through keys on an object and returning false when any key has values which are not strictly equal between the arguments. Returns true when the values of all keys are strictly equal.
function shallowEqual(objA, objB) { if (objectIs(objA, objB)) { return true; } if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) { return false; } var keysA = Object.keys(objA); var keysB = Object.keys(objB); if (keysA.length !== keysB.length) { return false; } // Test for A's keys different from B. for (var i = 0; i < keysA.length; i++) { if (!hasOwnProperty$2.call(objB, keysA[i]) || !objectIs(objA[keysA[i]], objB[keysA[i]])) { return false; } } return true; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function equalForKeys(a, b, keys) {\n if (!angular.isArray(keys) && angular.isObject(keys)) {\n keys = protoKeys(keys, [\"$$keys\", \"$$values\", \"$$equals\", \"$$validates\", \"$$new\", \"$$parent\"]);\n }\n if (!keys) {\n keys = [];\n for (var n in a) keys.push(n)...
[ "0.65744436", "0.65744436", "0.6468666", "0.6456315", "0.643489", "0.6336228", "0.62963444", "0.6272564", "0.624131", "0.62243676", "0.6214185", "0.6183737", "0.6158076", "0.61295843", "0.6128047", "0.6075044", "0.6034758", "0.601491", "0.60053355", "0.5978394", "0.5977129", ...
0.0
-1
1 unit of expiration time represents 10ms.
function msToExpirationTime(ms) { // Always subtract from the offset so that we don't clash with the magic number for NoWork. return MAGIC_NUMBER_OFFSET - (ms / UNIT_SIZE | 0); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function msToExpirationTime(ms){// Always add an offset so that we don't clash with the magic number for NoWork.\nreturn(ms/UNIT_SIZE|0)+MAGIC_NUMBER_OFFSET;}", "function msToExpirationTime(ms){// Always add an offset so that we don't clash with the magic number for NoWork.\nreturn(ms/UNIT_SIZE|0)+MAGIC_NUMBER_O...
[ "0.69083685", "0.69083685", "0.69083685", "0.69083685", "0.68177795", "0.68177795", "0.68177795", "0.6728504", "0.66832036", "0.66832036", "0.66832036", "0.6663674", "0.66431606", "0.66385615", "0.65983444", "0.65983444", "0.65983444", "0.6567885", "0.65556103", "0.65173113", ...
0.0
-1
to be able to optimize each path individually by branching early. This needs a compiler or we can do it manually. Helpers that don't need this branching live outside of this function.
function ChildReconciler(shouldTrackSideEffects) { function deleteChild(returnFiber, childToDelete) { if (!shouldTrackSideEffects) { // Noop. return; } // Deletions are added in reversed order so we add it to the front. // At this point, the return fiber's effect list is empty except for // deletions, so we can just append the deletion to the list. The remaining // effects aren't added until the complete phase. Once we implement // resuming, this may not be true. var last = returnFiber.lastEffect; if (last !== null) { last.nextEffect = childToDelete; returnFiber.lastEffect = childToDelete; } else { returnFiber.firstEffect = returnFiber.lastEffect = childToDelete; } childToDelete.nextEffect = null; childToDelete.effectTag = Deletion; } function deleteRemainingChildren(returnFiber, currentFirstChild) { if (!shouldTrackSideEffects) { // Noop. return null; } // TODO: For the shouldClone case, this could be micro-optimized a bit by // assuming that after the first child we've already added everything. var childToDelete = currentFirstChild; while (childToDelete !== null) { deleteChild(returnFiber, childToDelete); childToDelete = childToDelete.sibling; } return null; } function mapRemainingChildren(returnFiber, currentFirstChild) { // Add the remaining children to a temporary map so that we can find them by // keys quickly. Implicit (null) keys get added to this set with their index // instead. var existingChildren = new Map(); var existingChild = currentFirstChild; while (existingChild !== null) { if (existingChild.key !== null) { existingChildren.set(existingChild.key, existingChild); } else { existingChildren.set(existingChild.index, existingChild); } existingChild = existingChild.sibling; } return existingChildren; } function useFiber(fiber, pendingProps) { // We currently set sibling to null and index to 0 here because it is easy // to forget to do before returning it. E.g. for the single child case. var clone = createWorkInProgress(fiber, pendingProps); clone.index = 0; clone.sibling = null; return clone; } function placeChild(newFiber, lastPlacedIndex, newIndex) { newFiber.index = newIndex; if (!shouldTrackSideEffects) { // Noop. return lastPlacedIndex; } var current = newFiber.alternate; if (current !== null) { var oldIndex = current.index; if (oldIndex < lastPlacedIndex) { // This is a move. newFiber.effectTag = Placement; return lastPlacedIndex; } else { // This item can stay in place. return oldIndex; } } else { // This is an insertion. newFiber.effectTag = Placement; return lastPlacedIndex; } } function placeSingleChild(newFiber) { // This is simpler for the single child case. We only need to do a // placement for inserting new children. if (shouldTrackSideEffects && newFiber.alternate === null) { newFiber.effectTag = Placement; } return newFiber; } function updateTextNode(returnFiber, current, textContent, expirationTime) { if (current === null || current.tag !== HostText) { // Insert var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); created.return = returnFiber; return created; } else { // Update var existing = useFiber(current, textContent); existing.return = returnFiber; return existing; } } function updateElement(returnFiber, current, element, expirationTime) { if (current !== null) { if (current.elementType === element.type || ( // Keep this check inline so it only runs on the false path: isCompatibleFamilyForHotReloading(current, element) )) { // Move based on index var existing = useFiber(current, element.props); existing.ref = coerceRef(returnFiber, current, element); existing.return = returnFiber; { existing._debugSource = element._source; existing._debugOwner = element._owner; } return existing; } } // Insert var created = createFiberFromElement(element, returnFiber.mode, expirationTime); created.ref = coerceRef(returnFiber, current, element); created.return = returnFiber; return created; } function updatePortal(returnFiber, current, portal, expirationTime) { if (current === null || current.tag !== HostPortal || current.stateNode.containerInfo !== portal.containerInfo || current.stateNode.implementation !== portal.implementation) { // Insert var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); created.return = returnFiber; return created; } else { // Update var existing = useFiber(current, portal.children || []); existing.return = returnFiber; return existing; } } function updateFragment(returnFiber, current, fragment, expirationTime, key) { if (current === null || current.tag !== Fragment) { // Insert var created = createFiberFromFragment(fragment, returnFiber.mode, expirationTime, key); created.return = returnFiber; return created; } else { // Update var existing = useFiber(current, fragment); existing.return = returnFiber; return existing; } } function createChild(returnFiber, newChild, expirationTime) { if (typeof newChild === 'string' || typeof newChild === 'number') { // Text nodes don't have keys. If the previous node is implicitly keyed // we can continue to replace it without aborting even if it is not a text // node. var created = createFiberFromText('' + newChild, returnFiber.mode, expirationTime); created.return = returnFiber; return created; } if (typeof newChild === 'object' && newChild !== null) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: { var _created = createFiberFromElement(newChild, returnFiber.mode, expirationTime); _created.ref = coerceRef(returnFiber, null, newChild); _created.return = returnFiber; return _created; } case REACT_PORTAL_TYPE: { var _created2 = createFiberFromPortal(newChild, returnFiber.mode, expirationTime); _created2.return = returnFiber; return _created2; } } if (isArray$1(newChild) || getIteratorFn(newChild)) { var _created3 = createFiberFromFragment(newChild, returnFiber.mode, expirationTime, null); _created3.return = returnFiber; return _created3; } throwOnInvalidObjectType(returnFiber, newChild); } { if (typeof newChild === 'function') { warnOnFunctionType(); } } return null; } function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { // Update the fiber if the keys match, otherwise return null. var key = oldFiber !== null ? oldFiber.key : null; if (typeof newChild === 'string' || typeof newChild === 'number') { // Text nodes don't have keys. If the previous node is implicitly keyed // we can continue to replace it without aborting even if it is not a text // node. if (key !== null) { return null; } return updateTextNode(returnFiber, oldFiber, '' + newChild, expirationTime); } if (typeof newChild === 'object' && newChild !== null) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: { if (newChild.key === key) { if (newChild.type === REACT_FRAGMENT_TYPE) { return updateFragment(returnFiber, oldFiber, newChild.props.children, expirationTime, key); } return updateElement(returnFiber, oldFiber, newChild, expirationTime); } else { return null; } } case REACT_PORTAL_TYPE: { if (newChild.key === key) { return updatePortal(returnFiber, oldFiber, newChild, expirationTime); } else { return null; } } } if (isArray$1(newChild) || getIteratorFn(newChild)) { if (key !== null) { return null; } return updateFragment(returnFiber, oldFiber, newChild, expirationTime, null); } throwOnInvalidObjectType(returnFiber, newChild); } { if (typeof newChild === 'function') { warnOnFunctionType(); } } return null; } function updateFromMap(existingChildren, returnFiber, newIdx, newChild, expirationTime) { if (typeof newChild === 'string' || typeof newChild === 'number') { // Text nodes don't have keys, so we neither have to check the old nor // new node for the key. If both are text nodes, they match. var matchedFiber = existingChildren.get(newIdx) || null; return updateTextNode(returnFiber, matchedFiber, '' + newChild, expirationTime); } if (typeof newChild === 'object' && newChild !== null) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: { var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; if (newChild.type === REACT_FRAGMENT_TYPE) { return updateFragment(returnFiber, _matchedFiber, newChild.props.children, expirationTime, newChild.key); } return updateElement(returnFiber, _matchedFiber, newChild, expirationTime); } case REACT_PORTAL_TYPE: { var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null; return updatePortal(returnFiber, _matchedFiber2, newChild, expirationTime); } } if (isArray$1(newChild) || getIteratorFn(newChild)) { var _matchedFiber3 = existingChildren.get(newIdx) || null; return updateFragment(returnFiber, _matchedFiber3, newChild, expirationTime, null); } throwOnInvalidObjectType(returnFiber, newChild); } { if (typeof newChild === 'function') { warnOnFunctionType(); } } return null; } /** * Warns if there is a duplicate or missing key */ function warnOnInvalidKey(child, knownKeys) { { if (typeof child !== 'object' || child === null) { return knownKeys; } switch (child.$$typeof) { case REACT_ELEMENT_TYPE: case REACT_PORTAL_TYPE: warnForMissingKey(child); var key = child.key; if (typeof key !== 'string') { break; } if (knownKeys === null) { knownKeys = new Set(); knownKeys.add(key); break; } if (!knownKeys.has(key)) { knownKeys.add(key); break; } error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key); break; } } return knownKeys; } function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, expirationTime) { // This algorithm can't optimize by searching from both ends since we // don't have backpointers on fibers. I'm trying to see how far we can get // with that model. If it ends up not being worth the tradeoffs, we can // add it later. // Even with a two ended optimization, we'd want to optimize for the case // where there are few changes and brute force the comparison instead of // going for the Map. It'd like to explore hitting that path first in // forward-only mode and only go for the Map once we notice that we need // lots of look ahead. This doesn't handle reversal as well as two ended // search but that's unusual. Besides, for the two ended optimization to // work on Iterables, we'd need to copy the whole set. // In this first iteration, we'll just live with hitting the bad case // (adding everything to a Map) in for every insert/move. // If you change this code, also update reconcileChildrenIterator() which // uses the same algorithm. { // First, validate keys. var knownKeys = null; for (var i = 0; i < newChildren.length; i++) { var child = newChildren[i]; knownKeys = warnOnInvalidKey(child, knownKeys); } } var resultingFirstChild = null; var previousNewFiber = null; var oldFiber = currentFirstChild; var lastPlacedIndex = 0; var newIdx = 0; var nextOldFiber = null; for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) { if (oldFiber.index > newIdx) { nextOldFiber = oldFiber; oldFiber = null; } else { nextOldFiber = oldFiber.sibling; } var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], expirationTime); if (newFiber === null) { // TODO: This breaks on empty slots like null children. That's // unfortunate because it triggers the slow path all the time. We need // a better way to communicate whether this was a miss or null, // boolean, undefined, etc. if (oldFiber === null) { oldFiber = nextOldFiber; } break; } if (shouldTrackSideEffects) { if (oldFiber && newFiber.alternate === null) { // We matched the slot, but we didn't reuse the existing fiber, so we // need to delete the existing child. deleteChild(returnFiber, oldFiber); } } lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); if (previousNewFiber === null) { // TODO: Move out of the loop. This only happens for the first run. resultingFirstChild = newFiber; } else { // TODO: Defer siblings if we're not at the right index for this slot. // I.e. if we had null values before, then we want to defer this // for each null value. However, we also don't want to call updateSlot // with the previous one. previousNewFiber.sibling = newFiber; } previousNewFiber = newFiber; oldFiber = nextOldFiber; } if (newIdx === newChildren.length) { // We've reached the end of the new children. We can delete the rest. deleteRemainingChildren(returnFiber, oldFiber); return resultingFirstChild; } if (oldFiber === null) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; newIdx < newChildren.length; newIdx++) { var _newFiber = createChild(returnFiber, newChildren[newIdx], expirationTime); if (_newFiber === null) { continue; } lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); if (previousNewFiber === null) { // TODO: Move out of the loop. This only happens for the first run. resultingFirstChild = _newFiber; } else { previousNewFiber.sibling = _newFiber; } previousNewFiber = _newFiber; } return resultingFirstChild; } // Add all children to a key map for quick lookups. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. for (; newIdx < newChildren.length; newIdx++) { var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], expirationTime); if (_newFiber2 !== null) { if (shouldTrackSideEffects) { if (_newFiber2.alternate !== null) { // The new fiber is a work in progress, but if there exists a // current, that means that we reused the fiber. We need to delete // it from the child list so that we don't add it to the deletion // list. existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key); } } lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx); if (previousNewFiber === null) { resultingFirstChild = _newFiber2; } else { previousNewFiber.sibling = _newFiber2; } previousNewFiber = _newFiber2; } } if (shouldTrackSideEffects) { // Any existing children that weren't consumed above were deleted. We need // to add them to the deletion list. existingChildren.forEach(function (child) { return deleteChild(returnFiber, child); }); } return resultingFirstChild; } function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, expirationTime) { // This is the same implementation as reconcileChildrenArray(), // but using the iterator instead. var iteratorFn = getIteratorFn(newChildrenIterable); if (!(typeof iteratorFn === 'function')) { { throw Error( "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." ); } } { // We don't support rendering Generators because it's a mutation. // See https://github.com/facebook/react/issues/12995 if (typeof Symbol === 'function' && // $FlowFixMe Flow doesn't know about toStringTag newChildrenIterable[Symbol.toStringTag] === 'Generator') { if (!didWarnAboutGenerators) { error('Using Generators as children is unsupported and will likely yield ' + 'unexpected results because enumerating a generator mutates it. ' + 'You may convert it to an array with `Array.from()` or the ' + '`[...spread]` operator before rendering. Keep in mind ' + 'you might need to polyfill these features for older browsers.'); } didWarnAboutGenerators = true; } // Warn about using Maps as children if (newChildrenIterable.entries === iteratorFn) { if (!didWarnAboutMaps) { error('Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.'); } didWarnAboutMaps = true; } // First, validate keys. // We'll get a different iterator later for the main pass. var _newChildren = iteratorFn.call(newChildrenIterable); if (_newChildren) { var knownKeys = null; var _step = _newChildren.next(); for (; !_step.done; _step = _newChildren.next()) { var child = _step.value; knownKeys = warnOnInvalidKey(child, knownKeys); } } } var newChildren = iteratorFn.call(newChildrenIterable); if (!(newChildren != null)) { { throw Error( "An iterable object provided no iterator." ); } } var resultingFirstChild = null; var previousNewFiber = null; var oldFiber = currentFirstChild; var lastPlacedIndex = 0; var newIdx = 0; var nextOldFiber = null; var step = newChildren.next(); for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) { if (oldFiber.index > newIdx) { nextOldFiber = oldFiber; oldFiber = null; } else { nextOldFiber = oldFiber.sibling; } var newFiber = updateSlot(returnFiber, oldFiber, step.value, expirationTime); if (newFiber === null) { // TODO: This breaks on empty slots like null children. That's // unfortunate because it triggers the slow path all the time. We need // a better way to communicate whether this was a miss or null, // boolean, undefined, etc. if (oldFiber === null) { oldFiber = nextOldFiber; } break; } if (shouldTrackSideEffects) { if (oldFiber && newFiber.alternate === null) { // We matched the slot, but we didn't reuse the existing fiber, so we // need to delete the existing child. deleteChild(returnFiber, oldFiber); } } lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx); if (previousNewFiber === null) { // TODO: Move out of the loop. This only happens for the first run. resultingFirstChild = newFiber; } else { // TODO: Defer siblings if we're not at the right index for this slot. // I.e. if we had null values before, then we want to defer this // for each null value. However, we also don't want to call updateSlot // with the previous one. previousNewFiber.sibling = newFiber; } previousNewFiber = newFiber; oldFiber = nextOldFiber; } if (step.done) { // We've reached the end of the new children. We can delete the rest. deleteRemainingChildren(returnFiber, oldFiber); return resultingFirstChild; } if (oldFiber === null) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; !step.done; newIdx++, step = newChildren.next()) { var _newFiber3 = createChild(returnFiber, step.value, expirationTime); if (_newFiber3 === null) { continue; } lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx); if (previousNewFiber === null) { // TODO: Move out of the loop. This only happens for the first run. resultingFirstChild = _newFiber3; } else { previousNewFiber.sibling = _newFiber3; } previousNewFiber = _newFiber3; } return resultingFirstChild; } // Add all children to a key map for quick lookups. var existingChildren = mapRemainingChildren(returnFiber, oldFiber); // Keep scanning and use the map to restore deleted items as moves. for (; !step.done; newIdx++, step = newChildren.next()) { var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, expirationTime); if (_newFiber4 !== null) { if (shouldTrackSideEffects) { if (_newFiber4.alternate !== null) { // The new fiber is a work in progress, but if there exists a // current, that means that we reused the fiber. We need to delete // it from the child list so that we don't add it to the deletion // list. existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key); } } lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx); if (previousNewFiber === null) { resultingFirstChild = _newFiber4; } else { previousNewFiber.sibling = _newFiber4; } previousNewFiber = _newFiber4; } } if (shouldTrackSideEffects) { // Any existing children that weren't consumed above were deleted. We need // to add them to the deletion list. existingChildren.forEach(function (child) { return deleteChild(returnFiber, child); }); } return resultingFirstChild; } function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, expirationTime) { // There's no need to check for keys on text nodes since we don't have a // way to define them. if (currentFirstChild !== null && currentFirstChild.tag === HostText) { // We already have an existing node so let's just update it and delete // the rest. deleteRemainingChildren(returnFiber, currentFirstChild.sibling); var existing = useFiber(currentFirstChild, textContent); existing.return = returnFiber; return existing; } // The existing first child is not a text node so we need to create one // and delete the existing ones. deleteRemainingChildren(returnFiber, currentFirstChild); var created = createFiberFromText(textContent, returnFiber.mode, expirationTime); created.return = returnFiber; return created; } function reconcileSingleElement(returnFiber, currentFirstChild, element, expirationTime) { var key = element.key; var child = currentFirstChild; while (child !== null) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { switch (child.tag) { case Fragment: { if (element.type === REACT_FRAGMENT_TYPE) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber(child, element.props.children); existing.return = returnFiber; { existing._debugSource = element._source; existing._debugOwner = element._owner; } return existing; } break; } case Block: // We intentionally fallthrough here if enableBlocksAPI is not on. // eslint-disable-next-lined no-fallthrough default: { if (child.elementType === element.type || ( // Keep this check inline so it only runs on the false path: isCompatibleFamilyForHotReloading(child, element) )) { deleteRemainingChildren(returnFiber, child.sibling); var _existing3 = useFiber(child, element.props); _existing3.ref = coerceRef(returnFiber, child, element); _existing3.return = returnFiber; { _existing3._debugSource = element._source; _existing3._debugOwner = element._owner; } return _existing3; } break; } } // Didn't match. deleteRemainingChildren(returnFiber, child); break; } else { deleteChild(returnFiber, child); } child = child.sibling; } if (element.type === REACT_FRAGMENT_TYPE) { var created = createFiberFromFragment(element.props.children, returnFiber.mode, expirationTime, element.key); created.return = returnFiber; return created; } else { var _created4 = createFiberFromElement(element, returnFiber.mode, expirationTime); _created4.ref = coerceRef(returnFiber, currentFirstChild, element); _created4.return = returnFiber; return _created4; } } function reconcileSinglePortal(returnFiber, currentFirstChild, portal, expirationTime) { var key = portal.key; var child = currentFirstChild; while (child !== null) { // TODO: If key === null and child.key === null, then this only applies to // the first item in the list. if (child.key === key) { if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber(child, portal.children || []); existing.return = returnFiber; return existing; } else { deleteRemainingChildren(returnFiber, child); break; } } else { deleteChild(returnFiber, child); } child = child.sibling; } var created = createFiberFromPortal(portal, returnFiber.mode, expirationTime); created.return = returnFiber; return created; } // This API will tag the children with the side-effect of the reconciliation // itself. They will be added to the side-effect list as we pass through the // children and the parent. function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) { // This function is not recursive. // If the top level item is an array, we treat it as a set of children, // not as a fragment. Nested arrays on the other hand will be treated as // fragment nodes. Recursion happens at the normal flow. // Handle top level unkeyed fragments as if they were arrays. // This leads to an ambiguity between <>{[...]}</> and <>...</>. // We treat the ambiguous cases above the same. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; if (isUnkeyedTopLevelFragment) { newChild = newChild.props.children; } // Handle object types var isObject = typeof newChild === 'object' && newChild !== null; if (isObject) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime)); case REACT_PORTAL_TYPE: return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime)); } } if (typeof newChild === 'string' || typeof newChild === 'number') { return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime)); } if (isArray$1(newChild)) { return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime); } if (getIteratorFn(newChild)) { return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime); } if (isObject) { throwOnInvalidObjectType(returnFiber, newChild); } { if (typeof newChild === 'function') { warnOnFunctionType(); } } if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { // If the new child is undefined, and the return fiber is a composite // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { case ClassComponent: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { // We allow auto-mocks to proceed as if they're returning null. break; } } } // Intentionally fall through to the next case, which handles both // functions and classes // eslint-disable-next-lined no-fallthrough case FunctionComponent: { var Component = returnFiber.type; { { throw Error( (Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); } } } } } // Remaining cases are all treated as empty. return deleteRemainingChildren(returnFiber, currentFirstChild); } return reconcileChildFibers; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "optimiseSetOperation(path, nextValue) {\n // console.log('optimiseSetOperation', path, nextValue)\n // If target value is not a plain value, unable to optimise\n if (typeof nextValue === 'object') {\n // console.log(\"Not optimisable because next value is object\")\n return false;\n } // Chec...
[ "0.56930166", "0.55992", "0.54393184", "0.5373869", "0.53721833", "0.5369765", "0.53634197", "0.5341836", "0.52746236", "0.5250546", "0.52375257", "0.52365315", "0.52195805", "0.5217819", "0.52080554", "0.52057695", "0.5189535", "0.51850003", "0.51837337", "0.5168765", "0.515...
0.0
-1
Warns if there is a duplicate or missing key
function warnOnInvalidKey(child, knownKeys) { { if (typeof child !== 'object' || child === null) { return knownKeys; } switch (child.$$typeof) { case REACT_ELEMENT_TYPE: case REACT_PORTAL_TYPE: warnForMissingKey(child); var key = child.key; if (typeof key !== 'string') { break; } if (knownKeys === null) { knownKeys = new Set(); knownKeys.add(key); break; } if (!knownKeys.has(key)) { knownKeys.add(key); break; } error('Encountered two children with the same key, `%s`. ' + 'Keys should be unique so that components maintain their identity ' + 'across updates. Non-unique keys may cause children to be ' + 'duplicated and/or omitted — the behavior is unsupported and ' + 'could change in a future version.', key); break; } } return knownKeys; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "checkDuplicates(error) {\n if (error.name === \"MongoError\" && error.code === 11000) {\n // check if the error from Mongodb is duplication error\n // eslint-disable-next-line no-useless-escape\n const regex = /index\\:\\ (?:.*\\.)?\\$?(?:([_a-z0-9]*)(?:_\\d*)|([_a-z0-9]*))\\s*dup key/i;\n c...
[ "0.64586234", "0.63743407", "0.62774295", "0.61566454", "0.61478174", "0.61425227", "0.61372644", "0.61251426", "0.61251426", "0.61219513", "0.6114083", "0.6114083", "0.6114083", "0.61133426", "0.61059004", "0.6096614", "0.60936666", "0.6082668", "0.5989997", "0.59782195", "0...
0.0
-1
itself. They will be added to the sideeffect list as we pass through the children and the parent.
function reconcileChildFibers(returnFiber, currentFirstChild, newChild, expirationTime) { // This function is not recursive. // If the top level item is an array, we treat it as a set of children, // not as a fragment. Nested arrays on the other hand will be treated as // fragment nodes. Recursion happens at the normal flow. // Handle top level unkeyed fragments as if they were arrays. // This leads to an ambiguity between <>{[...]}</> and <>...</>. // We treat the ambiguous cases above the same. var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null; if (isUnkeyedTopLevelFragment) { newChild = newChild.props.children; } // Handle object types var isObject = typeof newChild === 'object' && newChild !== null; if (isObject) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, expirationTime)); case REACT_PORTAL_TYPE: return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, expirationTime)); } } if (typeof newChild === 'string' || typeof newChild === 'number') { return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, '' + newChild, expirationTime)); } if (isArray$1(newChild)) { return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, expirationTime); } if (getIteratorFn(newChild)) { return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, expirationTime); } if (isObject) { throwOnInvalidObjectType(returnFiber, newChild); } { if (typeof newChild === 'function') { warnOnFunctionType(); } } if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) { // If the new child is undefined, and the return fiber is a composite // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { case ClassComponent: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { // We allow auto-mocks to proceed as if they're returning null. break; } } } // Intentionally fall through to the next case, which handles both // functions and classes // eslint-disable-next-lined no-fallthrough case FunctionComponent: { var Component = returnFiber.type; { { throw Error( (Component.displayName || Component.name || 'Component') + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." ); } } } } } // Remaining cases are all treated as empty. return deleteRemainingChildren(returnFiber, currentFirstChild); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ChildReconciler(shouldTrackSideEffects) {\n function deleteChild(returnFiber, childToDelete) {\n if (!shouldTrackSideEffects) // Noop.\n return;\n // Deletions are added in reversed order so we add it to the front.\n // At this point, the return fiber's ...
[ "0.6270072", "0.6207316", "0.6141961", "0.6140538", "0.614019", "0.614019", "0.614019", "0.6132489", "0.6132489", "0.6132489", "0.6132489", "0.61272436", "0.61272436", "0.61138624", "0.60833305", "0.60557294", "0.60557294", "0.60557294", "0.60557294", "0.60511166", "0.6039793...
0.0
-1
The first pass splits the children fibers into two sets. A head and tail. We first render the head. If anything is in fallback state, we do another pass through beginWork to rerender all children (including the tail) with the force suspend context. If the first render didn't have anything in in fallback state. Then we render each row in the tail onebyone. That happens in the completeWork phase without going back to beginWork.
function updateSuspenseListComponent(current, workInProgress, renderExpirationTime) { var nextProps = workInProgress.pendingProps; var revealOrder = nextProps.revealOrder; var tailMode = nextProps.tail; var newChildren = nextProps.children; validateRevealOrder(revealOrder); validateTailOptions(tailMode, revealOrder); validateSuspenseListChildren(newChildren, revealOrder); reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); var suspenseContext = suspenseStackCursor.current; var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback); if (shouldForceFallback) { suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback); workInProgress.effectTag |= DidCapture; } else { var didSuspendBefore = current !== null && (current.effectTag & DidCapture) !== NoEffect; if (didSuspendBefore) { // If we previously forced a fallback, we need to schedule work // on any nested boundaries to let them know to try to render // again. This is the same as context updating. propagateSuspenseContextChange(workInProgress, workInProgress.child, renderExpirationTime); } suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); } pushSuspenseContext(workInProgress, suspenseContext); if ((workInProgress.mode & BlockingMode) === NoMode) { // Outside of blocking mode, SuspenseList doesn't work so we just // use make it a noop by treating it as the default revealOrder. workInProgress.memoizedState = null; } else { switch (revealOrder) { case 'forwards': { var lastContentRow = findLastContentRow(workInProgress.child); var tail; if (lastContentRow === null) { // The whole list is part of the tail. // TODO: We could fast path by just rendering the tail now. tail = workInProgress.child; workInProgress.child = null; } else { // Disconnect the tail rows after the content row. // We're going to render them separately later. tail = lastContentRow.sibling; lastContentRow.sibling = null; } initSuspenseListRenderState(workInProgress, false, // isBackwards tail, lastContentRow, tailMode, workInProgress.lastEffect); break; } case 'backwards': { // We're going to find the first row that has existing content. // At the same time we're going to reverse the list of everything // we pass in the meantime. That's going to be our tail in reverse // order. var _tail = null; var row = workInProgress.child; workInProgress.child = null; while (row !== null) { var currentRow = row.alternate; // New rows can't be content rows. if (currentRow !== null && findFirstSuspended(currentRow) === null) { // This is the beginning of the main content. workInProgress.child = row; break; } var nextRow = row.sibling; row.sibling = _tail; _tail = row; row = nextRow; } // TODO: If workInProgress.child is null, we can continue on the tail immediately. initSuspenseListRenderState(workInProgress, true, // isBackwards _tail, null, // last tailMode, workInProgress.lastEffect); break; } case 'together': { initSuspenseListRenderState(workInProgress, false, // isBackwards null, // tail null, // last undefined, workInProgress.lastEffect); break; } default: { // The default reveal order is the same as not having // a boundary. workInProgress.memoizedState = null; } } } return workInProgress.child; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function updateSuspenseListComponent(current, workInProgress, renderLanes) {\n var nextProps = workInProgress.pendingProps;\n var revealOrder = nextProps.revealOrder;\n var tailMode = nextProps.tail;\n var newChildren = nextProps.children;\n validateRevealOrder(revealOrder);\n validat...
[ "0.5607003", "0.5607003", "0.5607003", "0.5607003", "0.5572906", "0.55432487", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "0.553137", "...
0.529154
58
Capture errors so they don't interrupt unmounting.
function safelyCallComponentWillUnmount(current, instance) { { invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current, instance); if (hasCaughtError()) { var unmountError = clearCaughtError(); captureCommitPhaseError(current, unmountError); } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "simulateUnmount() {\n this.volumeUnmountListener(this.volumeInfo_.volumeId);\n }", "function onerror(er){debug('onerror',er);unpipe();dest.removeListener('error',onerror);if(EElistenerCount(dest,'error')===0)errorOrDestroy(dest,er);}// Make sure our error handler is attached before userland ones.", "functi...
[ "0.6385105", "0.5921357", "0.5853079", "0.5853079", "0.5853079", "0.58470565", "0.58197415", "0.58197415", "0.58197415", "0.57672554", "0.5742686", "0.5742686", "0.5742686", "0.5742686", "0.5742686", "0.57321393", "0.57321393", "0.57321393", "0.5689659", "0.5689659", "0.56572...
0.0
-1
deletion, so don't let them throw. Hostoriginating errors should interrupt deletion, so it's okay
function commitUnmount(finishedRoot, current, renderPriorityLevel) { onCommitUnmount(current); switch (current.tag) { case FunctionComponent: case ForwardRef: case MemoComponent: case SimpleMemoComponent: case Block: { var updateQueue = current.updateQueue; if (updateQueue !== null) { var lastEffect = updateQueue.lastEffect; if (lastEffect !== null) { var firstEffect = lastEffect.next; { // When the owner fiber is deleted, the destroy function of a passive // effect hook is called during the synchronous commit phase. This is // a concession to implementation complexity. Calling it in the // passive effect phase (like they usually are, when dependencies // change during an update) would require either traversing the // children of the deleted fiber again, or including unmount effects // as part of the fiber effect list. // // Because this is during the sync commit phase, we need to change // the priority. // // TODO: Reconsider this implementation trade off. var priorityLevel = renderPriorityLevel > NormalPriority ? NormalPriority : renderPriorityLevel; runWithPriority$1(priorityLevel, function () { var effect = firstEffect; do { var _destroy = effect.destroy; if (_destroy !== undefined) { safelyCallDestroy(current, _destroy); } effect = effect.next; } while (effect !== firstEffect); }); } } } return; } case ClassComponent: { safelyDetachRef(current); var instance = current.stateNode; if (typeof instance.componentWillUnmount === 'function') { safelyCallComponentWillUnmount(current, instance); } return; } case HostComponent: { safelyDetachRef(current); return; } case HostPortal: { // TODO: this is recursive. // We are also not using this parent because // the portal will get pushed immediately. { unmountHostComponents(finishedRoot, current, renderPriorityLevel); } return; } case FundamentalComponent: { return; } case DehydratedFragment: { return; } case ScopeComponent: { return; } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function deleteErrHandler(error, result) {\n\tif (error) {\n\t\tlog(\"cannot delete data\")\n\t\tthrow error\n\t} else {\n\t\tlog(\"Delete Success\") \n\t}\n}", "remove () {\n // cleanup\n }", "delete() {}", "detach() {\n throw new Error('Not Implemented');\n }", "detach() {\n throw new Er...
[ "0.6554796", "0.63948", "0.6280085", "0.61541724", "0.61541724", "0.60908973", "0.60908973", "0.60649216", "0.6064013", "0.6064013", "0.59525937", "0.5948963", "0.5911195", "0.58756423", "0.58555824", "0.5828496", "0.58240736", "0.58115464", "0.58091253", "0.57978076", "0.578...
0.0
-1
This is split into a separate function so we can mark a fiber with pending work without treating it as a typical update that originates from an event; e.g. retrying a Suspense boundary isn't an update, but it does schedule work on a fiber.
function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { // Update the source fiber's expiration time if (fiber.expirationTime < expirationTime) { fiber.expirationTime = expirationTime; } var alternate = fiber.alternate; if (alternate !== null && alternate.expirationTime < expirationTime) { alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. var node = fiber.return; var root = null; if (node === null && fiber.tag === HostRoot) { root = fiber.stateNode; } else { while (node !== null) { alternate = node.alternate; if (node.childExpirationTime < expirationTime) { node.childExpirationTime = expirationTime; if (alternate !== null && alternate.childExpirationTime < expirationTime) { alternate.childExpirationTime = expirationTime; } } else if (alternate !== null && alternate.childExpirationTime < expirationTime) { alternate.childExpirationTime = expirationTime; } if (node.return === null && node.tag === HostRoot) { root = node.stateNode; break; } node = node.return; } } if (root !== null) { if (workInProgressRoot === root) { // Received an update to a tree that's in the middle of rendering. Mark // that's unprocessed work on this root. markUnprocessedUpdateTime(expirationTime); if (workInProgressRootExitStatus === RootSuspendedWithDelay) { // The root already suspended with a delay, which means this render // definitely won't finish. Since we have a new update, let's mark it as // suspended now, right before marking the incoming update. This has the // effect of interrupting the current render and switching to the update. // TODO: This happens to work when receiving an update during the render // phase, because of the trick inside computeExpirationForFiber to // subtract 1 from `renderExpirationTime` to move it into a // separate bucket. But we should probably model it with an exception, // using the same mechanism we use to force hydration of a subtree. // TODO: This does not account for low pri updates that were already // scheduled before the root started rendering. Need to track the next // pending expiration time (perhaps by backtracking the return path) and // then trigger a restart in the `renderDidSuspendDelayIfPossible` path. markRootSuspendedAtTime(root, renderExpirationTime$1); } } // Mark that the root has a pending update. markRootUpdatedAtTime(root, expirationTime); } return root; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function inc_busy()\n{\n background_jobs++;\n update_busy_indicator();\n}", "if (\n workInProgressSuspendedReason === SuspendedOnData &&\n workInProgressRoot === root\n ) {\n // Mark the root as ready to continue rendering.\n workInPr...
[ "0.59601957", "0.59122163", "0.5761843", "0.5743674", "0.57292473", "0.57292473", "0.5722173", "0.5722173", "0.56988746", "0.56988746", "0.56988746", "0.56653714", "0.56488705", "0.5599025", "0.5599025", "0.5599025", "0.5599025", "0.5599025", "0.5599025", "0.5599025", "0.5596...
0.5294241
89
root; if a task was already scheduled, we'll check to make sure the expiration time of the existing task is the same as the expiration time of the next level that the root has work on. This function is called on every update, and right before exiting a task.
function ensureRootIsScheduled(root) { var lastExpiredTime = root.lastExpiredTime; if (lastExpiredTime !== NoWork) { // Special case: Expired work should flush synchronously. root.callbackExpirationTime = Sync; root.callbackPriority = ImmediatePriority; root.callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); return; } var expirationTime = getNextRootExpirationTimeToWorkOn(root); var existingCallbackNode = root.callbackNode; if (expirationTime === NoWork) { // There's nothing to work on. if (existingCallbackNode !== null) { root.callbackNode = null; root.callbackExpirationTime = NoWork; root.callbackPriority = NoPriority; } return; } // TODO: If this is an update, we already read the current time. Pass the // time as an argument. var currentTime = requestCurrentTimeForUpdate(); var priorityLevel = inferPriorityFromExpirationTime(currentTime, expirationTime); // If there's an existing render task, confirm it has the correct priority and // expiration time. Otherwise, we'll cancel it and schedule a new one. if (existingCallbackNode !== null) { var existingCallbackPriority = root.callbackPriority; var existingCallbackExpirationTime = root.callbackExpirationTime; if ( // Callback must have the exact same expiration time. existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. existingCallbackPriority >= priorityLevel) { // Existing callback is sufficient. return; } // Need to schedule a new task. // TODO: Instead of scheduling a new task, we should be able to change the // priority of the existing one. cancelCallback(existingCallbackNode); } root.callbackExpirationTime = expirationTime; root.callbackPriority = priorityLevel; var callbackNode; if (expirationTime === Sync) { // Sync React callbacks are scheduled on a special internal queue callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); } else { callbackNode = scheduleCallback(priorityLevel, performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects // ordering because tasks are processed in timeout order. { timeout: expirationTimeToMs(expirationTime) - now() }); } root.callbackNode = callbackNode; } // This is the entry point for every concurrent task, i.e. anything that
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function ensureRootIsScheduled(root) {\n var lastExpiredTime = root.lastExpiredTime;\n\n if (lastExpiredTime !== NoWork) {\n // Special case: Expired work should flush synchronously.\n root.callbackExpirationTime = Sync;\n root.callbackPriority...
[ "0.7648706", "0.762972", "0.7614312", "0.7614312", "0.7614312", "0.7614312", "0.7614312", "0.7614312", "0.7473669", "0.7473669", "0.7473669", "0.7470245", "0.7470245", "0.744669", "0.744669", "0.744669", "0.744669", "0.6881808", "0.6881808", "0.6881808", "0.6881808", "0.685...
0.7457669
35
Returns false if we're not sure.
function renderHasNotSuspendedYet() { // If something errored or completed, we can't really be sure, // so those are false. return workInProgressRootExitStatus === RootIncomplete; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "isErr() {\n return false;\n }", "isValid() {\n return this.getSize() != 0\n }", "isValid() {\n return true;\n }", "isValid() {\n return true;\n }", "function checkState() {\n if (!this.isInitialized()) {\n this.throwSCORMError(301);\n return false;...
[ "0.6496123", "0.6381494", "0.63397324", "0.63397324", "0.6336614", "0.63218224", "0.62233114", "0.62097883", "0.62097883", "0.62097883", "0.62097883", "0.6199922", "0.6164317", "0.6131139", "0.61150736", "0.60781837", "0.6050852", "0.6050852", "0.6050852", "0.6050852", "0.604...
0.0
-1
The work loop is an extremely hot path. Tell Closure not to inline it.
function workLoopSync() { // Already timed out, so perform work without checking if we need to yield. while (workInProgress !== null) { workInProgress = performUnitOfWork(workInProgress); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "work() {}", "loop() {}", "loop() {}", "function TaskLoop() {\n\t\n}", "function test_infinite_loop() {\n\tfor(var i = 0; i < 10; i++)\n\t\tfoo->();\n\n\ttrace(i);\n}", "function test0() {\n var workItem = {\n increment: 1,\n isDone: false\n };\n\n var func0 = function () {\n workItem = {\n ...
[ "0.66703844", "0.6575251", "0.6575251", "0.63850766", "0.6347373", "0.6334354", "0.62879914", "0.62779045", "0.62119734", "0.62117994", "0.6125921", "0.6065775", "0.6065775", "0.6065775", "0.6065775", "0.6065775", "0.6065775", "0.6065775", "0.6057734", "0.6006106", "0.6006106...
0.5951011
52
The theory is that a person can't tell the difference between small differences in time. Therefore, if we wait a bit longer than necessary that won't translate to a noticeable difference in the experience. However, waiting for longer might mean that we can avoid showing an intermediate loading state. The longer we have already waited, the harder it is to tell small differences in time. Therefore, the longer we've already waited, the longer we can wait additionally. At some point we have to give up though. We pick a train model where the next boundary commits at a consistent schedule. These particular numbers are vague estimates. We expect to adjust them based on research.
function jnd(timeElapsed) { return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3000 ? 3000 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function estimatedWait(){\n\n // Get a list of the mentors who are online\n var mentors = mentorsOnline();\n\n // Get the currently active tickets\n var tickets = activeTickets();\n\n // Get the currently claimed tickets\n var openTickets = tickets.filter(function(t){return t.status === \"OPEN\"});\n var cl...
[ "0.57509995", "0.55477947", "0.55213755", "0.55071896", "0.54662967", "0.5431361", "0.5413336", "0.53732127", "0.5364698", "0.53614587", "0.5345891", "0.5305206", "0.5303939", "0.5261517", "0.52066517", "0.51738566", "0.5137689", "0.5123167", "0.5120703", "0.5078458", "0.5062...
0.0
-1
TODO Before we release concurrent mode, revisit this and decide whether a mocked scheduler is the actual recommendation. The alternative could be a testing build, a new lib, or whatever; we dunno just yet. This message is for early adopters to get their tests right.
function warnIfUnmockedScheduler(fiber) { { if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === undefined) { if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) { didWarnAboutUnmockedScheduler = true; error('In Concurrent or Sync modes, the "scheduler" module needs to be mocked ' + 'to guarantee consistent behaviour across tests and browsers. ' + 'For example, with jest: \n' + "jest.mock('scheduler', () => require('scheduler/unstable_mock'));\n\n" + 'For more info, visit https://fb.me/react-mock-scheduler'); } } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function RequestScheduler() {}", "function warnIfUnmockedScheduler(fiber){{if(didWarnAboutUnmockedScheduler===false&&Scheduler.unstable_flushAllWithoutAsserting===undefined){if(fiber.mode&BlockingMode||fiber.mode&ConcurrentMode){didWarnAboutUnmockedScheduler=true;error('In Concurrent or Sync modes, the \"schedul...
[ "0.70067215", "0.6966584", "0.6966584", "0.6966584", "0.6957233", "0.6957233", "0.6793626", "0.6793626", "0.6793626", "0.6793626", "0.6793626", "0.6793626", "0.67739815", "0.67504716", "0.67135215", "0.67135215", "0.67135215", "0.67135215", "0.67135215", "0.6634042", "0.66340...
0.66043025
43
AsyncMode should be deprecated
function isAsyncMode(object) { { if (!hasWarnedAboutDeprecatedIsAsyncMode) { hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.'); } } return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "setAsync(){\n this.async = true;\n }", "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 '+'ReactI...
[ "0.71772456", "0.71477026", "0.71477026", "0.71477026", "0.707457", "0.6901749", "0.6824169", "0.6809441", "0.6809441", "0.6793582", "0.6785743", "0.67846984", "0.6757779", "0.6750946", "0.6745032", "0.6745032", "0.67303115", "0.67276573", "0.67276573", "0.67276573", "0.67276...
0.0
-1
Copyright (c) 2013present, Facebook, Inc. This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.
function componentWillMount() { // Call this.constructor.gDSFP to support sub-classes. var state = this.constructor.getDerivedStateFromProps(this.props, this.state); if (state !== null && state !== undefined) { this.setState(state); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "componentDidMount() {\n // if this is the first time the home screen is loading\n // we must initialize Facebook\n if (!window.FB) {\n window.fbAsyncInit = function() {\n window.FB.init({\n appId : '280945375708713',\n cookie : true, // enable cookies to allow the s...
[ "0.58219624", "0.5635253", "0.55540663", "0.54881734", "0.53984666", "0.5383581", "0.5362973", "0.5326434", "0.5320985", "0.5315354", "0.5315354", "0.5291929", "0.52661246", "0.52162653", "0.51980376", "0.5190798", "0.51905507", "0.51553226", "0.5140691", "0.51319295", "0.512...
0.0
-1
Call this.constructor.gDSFP to support subclasses. Use the setState() updater to ensure state isn't stale in certain edge cases.
function updater(prevState) { var state = this.constructor.getDerivedStateFromProps(nextProps, prevState); return state !== null && state !== undefined ? state : null; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function componentWillMount(){// Call this.constructor.gDSFP to support sub-classes.\nvar state=this.constructor.getDerivedStateFromProps(this.props,this.state);if(state!==null&&state!==undefined){this.setState(state);}}", "function componentWillMount() {\n // Call this.constructor.gDSFP to support sub-...
[ "0.6140481", "0.5687273", "0.5580147", "0.55447936", "0.55447936", "0.55447936", "0.54360944", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", "0.53733814", ...
0.0
-1
Also exported as `` from `Dropdown`.
function DropdownMenu(_ref2) { var children = _ref2.children, options = Object(_babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_1__["default"])(_ref2, ["children"]); var args = useDropdownMenu(options); return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_3___default.a.Fragment, null, args.hasShown ? children(args) : null); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "DropDown() {}", "function McDropdownPanel() { }", "function Dropdown(parent_id, item = {}) {\n item.type = \"select\";\n item.id = item.id || \"{0}_{1}\".format(item.type, __SELECT++);\n item.label = item.label || item.id;\n item.needQuestion = (item.needQuestion == false) ? false : true;\n Tag....
[ "0.74632454", "0.74274856", "0.6800082", "0.65475297", "0.65286446", "0.6430284", "0.64301074", "0.642787", "0.642787", "0.6388088", "0.63669276", "0.63535553", "0.6343826", "0.631651", "0.631651", "0.6260205", "0.6259108", "0.6249347", "0.6229232", "0.6229232", "0.61744714",...
0.0
-1
Wires up Dropdown toggle functionality, returning a set a props to attach to the element that functions as the dropdown toggle (generally a button).
function useDropdownToggle() { var _ref = Object(react__WEBPACK_IMPORTED_MODULE_1__["useContext"])(_DropdownContext__WEBPACK_IMPORTED_MODULE_2__["default"]) || {}, _ref$show = _ref.show, show = _ref$show === void 0 ? false : _ref$show, _ref$toggle = _ref.toggle, toggle = _ref$toggle === void 0 ? noop : _ref$toggle, setToggle = _ref.setToggle; return [{ ref: setToggle || noop, 'aria-haspopup': true, 'aria-expanded': !!show }, { show: show, toggle: toggle }]; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function useDropdownToggle() {\n var _useContext = Object(react__WEBPACK_IMPORTED_MODULE_1__[\"useContext\"])(_DropdownContext__WEBPACK_IMPORTED_MODULE_2__[\"default\"]),\n show = _useContext.show,\n toggle = _useContext.toggle,\n setToggle = _useContext.setToggle;\n\n return [{\n ref: setToggl...
[ "0.6798174", "0.6798174", "0.66344637", "0.6545018", "0.6545018", "0.64776576", "0.6468173", "0.6418436", "0.64157796", "0.618097", "0.618097", "0.6168092", "0.61334395", "0.61244196", "0.6071357", "0.6071357", "0.5983467", "0.59641767", "0.5943793", "0.5943793", "0.59231424"...
0.6637921
3
Also exported as `` from `Dropdown`.
function DropdownToggle(_ref2) { var children = _ref2.children; var _useDropdownToggle = useDropdownToggle(), props = _useDropdownToggle[0], _useDropdownToggle$ = _useDropdownToggle[1], show = _useDropdownToggle$.show, toggle = _useDropdownToggle$.toggle; return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement(react__WEBPACK_IMPORTED_MODULE_1___default.a.Fragment, null, children({ show: show, toggle: toggle, props: props })); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "DropDown() {}", "function McDropdownPanel() { }", "function Dropdown(parent_id, item = {}) {\n item.type = \"select\";\n item.id = item.id || \"{0}_{1}\".format(item.type, __SELECT++);\n item.label = item.label || item.id;\n item.needQuestion = (item.needQuestion == false) ? false : true;\n Tag....
[ "0.74632454", "0.74274856", "0.6800082", "0.65475297", "0.65286446", "0.6430284", "0.64301074", "0.642787", "0.642787", "0.6388088", "0.63669276", "0.63535553", "0.6343826", "0.631651", "0.631651", "0.6260205", "0.6259108", "0.6249347", "0.6229232", "0.6229232", "0.61744714",...
0.0
-1
connect is a facade over connectAdvanced. It turns its args into a compatible selectorFactory, which has the signature: (dispatch, options) => (nextState, nextOwnProps) => nextFinalProps connect passes its args to connectAdvanced as options, which will in turn pass them to selectorFactory each time a Connect component instance is instantiated or hot reloaded. selectorFactory returns a final props selector from its mapStateToProps, mapStateToPropsFactories, mapDispatchToProps, mapDispatchToPropsFactories, mergeProps, mergePropsFactories, and pure args. The resulting final props selector is called by the Connect component instance whenever it receives new props or store state.
function match(arg, factories, name) { for (var i = factories.length - 1; i >= 0; i--) { var result = factories[i](arg); if (result) return result; } return function (dispatch, options) { throw new Error("Invalid value of type " + typeof arg + " for " + name + " argument when connecting component " + options.wrappedComponentName + "."); }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createConnect() {\n var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},\n _ref$connectHOC = _ref.connectHOC,\n connectHOC = _ref$connectHOC === undefined ? connectAdvanced : _ref$connectHOC,\n _ref$mapStateToPropsF = _ref.mapStateToPropsFactories,\n mapS...
[ "0.7502259", "0.7500511", "0.7419837", "0.7419837", "0.74169964", "0.7414397", "0.7373869", "0.7373869", "0.7373869", "0.7373869", "0.7373869", "0.7373869", "0.7373869", "0.7371583", "0.7371583", "0.7371583", "0.7371583", "0.73289824", "0.73289824", "0.73289824", "0.73289824"...
0.0
-1
different options opens up some testing and extensibility scenarios
function createConnect(_temp) { var _ref = _temp === void 0 ? {} : _temp, _ref$connectHOC = _ref.connectHOC, connectHOC = _ref$connectHOC === void 0 ? _components_connectAdvanced__WEBPACK_IMPORTED_MODULE_2__["default"] : _ref$connectHOC, _ref$mapStateToPropsF = _ref.mapStateToPropsFactories, mapStateToPropsFactories = _ref$mapStateToPropsF === void 0 ? _mapStateToProps__WEBPACK_IMPORTED_MODULE_5__["default"] : _ref$mapStateToPropsF, _ref$mapDispatchToPro = _ref.mapDispatchToPropsFactories, mapDispatchToPropsFactories = _ref$mapDispatchToPro === void 0 ? _mapDispatchToProps__WEBPACK_IMPORTED_MODULE_4__["default"] : _ref$mapDispatchToPro, _ref$mergePropsFactor = _ref.mergePropsFactories, mergePropsFactories = _ref$mergePropsFactor === void 0 ? _mergeProps__WEBPACK_IMPORTED_MODULE_6__["default"] : _ref$mergePropsFactor, _ref$selectorFactory = _ref.selectorFactory, selectorFactory = _ref$selectorFactory === void 0 ? _selectorFactory__WEBPACK_IMPORTED_MODULE_7__["default"] : _ref$selectorFactory; return function connect(mapStateToProps, mapDispatchToProps, mergeProps, _ref2) { if (_ref2 === void 0) { _ref2 = {}; } var _ref3 = _ref2, _ref3$pure = _ref3.pure, pure = _ref3$pure === void 0 ? true : _ref3$pure, _ref3$areStatesEqual = _ref3.areStatesEqual, areStatesEqual = _ref3$areStatesEqual === void 0 ? strictEqual : _ref3$areStatesEqual, _ref3$areOwnPropsEqua = _ref3.areOwnPropsEqual, areOwnPropsEqual = _ref3$areOwnPropsEqua === void 0 ? _utils_shallowEqual__WEBPACK_IMPORTED_MODULE_3__["default"] : _ref3$areOwnPropsEqua, _ref3$areStatePropsEq = _ref3.areStatePropsEqual, areStatePropsEqual = _ref3$areStatePropsEq === void 0 ? _utils_shallowEqual__WEBPACK_IMPORTED_MODULE_3__["default"] : _ref3$areStatePropsEq, _ref3$areMergedPropsE = _ref3.areMergedPropsEqual, areMergedPropsEqual = _ref3$areMergedPropsE === void 0 ? _utils_shallowEqual__WEBPACK_IMPORTED_MODULE_3__["default"] : _ref3$areMergedPropsE, extraOptions = Object(_babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_1__["default"])(_ref3, ["pure", "areStatesEqual", "areOwnPropsEqual", "areStatePropsEqual", "areMergedPropsEqual"]); var initMapStateToProps = match(mapStateToProps, mapStateToPropsFactories, 'mapStateToProps'); var initMapDispatchToProps = match(mapDispatchToProps, mapDispatchToPropsFactories, 'mapDispatchToProps'); var initMergeProps = match(mergeProps, mergePropsFactories, 'mergeProps'); return connectHOC(selectorFactory, Object(_babel_runtime_helpers_esm_extends__WEBPACK_IMPORTED_MODULE_0__["default"])({ // used in error messages methodName: 'connect', // used to compute Connect's displayName from the wrapped component's displayName. getDisplayName: function getDisplayName(name) { return "Connect(" + name + ")"; }, // if mapStateToProps is falsy, the Connect component doesn't subscribe to store state changes shouldHandleStateChanges: Boolean(mapStateToProps), // passed through to selectorFactory initMapStateToProps: initMapStateToProps, initMapDispatchToProps: initMapDispatchToProps, initMergeProps: initMergeProps, pure: pure, areStatesEqual: areStatesEqual, areOwnPropsEqual: areOwnPropsEqual, areStatePropsEqual: areStatePropsEqual, areMergedPropsEqual: areMergedPropsEqual }, extraOptions)); }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function testOptions ( options ) {\n\n\t\t// To prove a fix for #537, freeze options here.\n\t\t// If the object is modified, an error will be thrown.\n\t\t// Object.freeze(options);\n\n\t\tvar parsed = {\n\t\t\tmargin: 0,\n\t\t\tlimit: 0,\n\t\t\tpadding: 0,\n\t\t\tanimate: true,\n\t\t\tanimationDuration: 300,\n\t...
[ "0.6037481", "0.60318357", "0.60318357", "0.59998536", "0.5954973", "0.5954973", "0.5954973", "0.59449977", "0.59152806", "0.5906259", "0.5872966", "0.5872966", "0.58575654", "0.5854597", "0.5854597", "0.5834004", "0.5834004", "0.5827216", "0.5819405", "0.5818854", "0.5802200...
0.0
-1
If pure is true, the selector returned by selectorFactory will memoize its results, allowing connectAdvanced's shouldComponentUpdate to return false if final props have not changed. If false, the selector will always return a new object and shouldComponentUpdate will always return true.
function finalPropsSelectorFactory(dispatch, _ref2) { var initMapStateToProps = _ref2.initMapStateToProps, initMapDispatchToProps = _ref2.initMapDispatchToProps, initMergeProps = _ref2.initMergeProps, options = Object(_babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__["default"])(_ref2, ["initMapStateToProps", "initMapDispatchToProps", "initMergeProps"]); var mapStateToProps = initMapStateToProps(dispatch, options); var mapDispatchToProps = initMapDispatchToProps(dispatch, options); var mergeProps = initMergeProps(dispatch, options); if (true) { Object(_verifySubselectors__WEBPACK_IMPORTED_MODULE_1__["default"])(mapStateToProps, mapDispatchToProps, mergeProps, options.displayName); } var selectorFactory = options.pure ? pureFinalPropsSelectorFactory : impureFinalPropsSelectorFactory; return selectorFactory(mapStateToProps, mapDispatchToProps, mergeProps, dispatch, options); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function finalPropsSelectorFactory(dispatch, _ref2) {\n\t var initMapStateToProps = _ref2.initMapStateToProps,\n\t initMapDispatchToProps = _ref2.initMapDispatchToProps,\n\t initMergeProps = _ref2.initMergeProps,\n\t options = _objectWithoutProperties(_ref2, ['initMapStateToProps', 'initMapDispatch...
[ "0.5796509", "0.5796509", "0.57829297", "0.57829297", "0.57829297", "0.5782753", "0.5782753", "0.5782753", "0.5782753", "0.57683754", "0.57683754", "0.5764924", "0.5761992", "0.5761526", "0.5761526", "0.5761526", "0.5761526", "0.5761526", "0.5761526", "0.5761526", "0.5761526"...
0.5665696
94
to the mapToProps function being wrapped. It is also used by makePurePropsSelector to determine whether mapToProps needs to be invoked when props have changed. A length of one signals that mapToProps does not depend on props from the parent component. A length of zero is assumed to mean mapToProps is getting args via arguments or ...args and therefore not reporting its length accurately..
function getDependsOnOwnProps(mapToProps) { return mapToProps.dependsOnOwnProps !== null && mapToProps.dependsOnOwnProps !== undefined ? Boolean(mapToProps.dependsOnOwnProps) : mapToProps.length !== 1; } // Used by whenMapStateToPropsIsFunction and whenMapDispatchToPropsIsFunction,
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function mapToProps() {\n return {};\n}", "function mapToProps() {\n return {};\n}", "function wrapMapToPropsFunc(mapToProps,methodName){return function initProxySelector(dispatch,_ref){var displayName=_ref.displayName;var proxy=function mapToPropsProxy(stateOrDispatch,ownProps){return proxy.dependsOnOwn...
[ "0.64890414", "0.64890414", "0.6217227", "0.60623384", "0.5905007", "0.5816661", "0.58035856", "0.57989055", "0.5767383", "0.5767383", "0.5767383", "0.5767383", "0.5767383", "0.5762032", "0.5762032", "0.5762032", "0.5762032", "0.57457775", "0.57394403", "0.5733544", "0.573354...
0.0
-1
this function wraps mapToProps in a proxy function which does several things: Detects whether the mapToProps function being called depends on props, which is used by selectorFactory to decide if it should reinvoke on props changes. On first call, handles mapToProps if returns another function, and treats that new function as the true mapToProps for subsequent calls. On first call, verifies the first result is a plain object, in order to warn the developer that their mapToProps function is not returning a valid result.
function wrapMapToPropsFunc(mapToProps, methodName) { return function initProxySelector(dispatch, _ref) { var displayName = _ref.displayName; var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) { return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy.mapToProps(stateOrDispatch); }; // allow detectFactoryAndVerify to get ownProps proxy.dependsOnOwnProps = true; proxy.mapToProps = function detectFactoryAndVerify(stateOrDispatch, ownProps) { proxy.mapToProps = mapToProps; proxy.dependsOnOwnProps = getDependsOnOwnProps(mapToProps); var props = proxy(stateOrDispatch, ownProps); if (typeof props === 'function') { proxy.mapToProps = props; proxy.dependsOnOwnProps = getDependsOnOwnProps(props); props = proxy(stateOrDispatch, ownProps); } if (true) Object(_utils_verifyPlainObject__WEBPACK_IMPORTED_MODULE_0__["default"])(props, displayName, methodName); return props; }; return proxy; }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function wrapMapToPropsFunc(mapToProps, methodName) {\n return function initProxySelector(dispatch, _ref) {\n var displayName = _ref.displayName;\n\n var proxy = function mapToPropsProxy(stateOrDispatch, ownProps) {\n return proxy.dependsOnOwnProps ? proxy.mapToProps(stateOrDispatch, ownProps) : proxy....
[ "0.7835123", "0.7835123", "0.7835123", "0.7835123", "0.7835123", "0.780906", "0.7791362", "0.7778833", "0.77716106", "0.7768862", "0.7763944", "0.7763944", "0.7763944", "0.7763944", "0.7763944", "0.7763944", "0.7763944", "0.7735503", "0.77349806", "0.7729277", "0.7728167", ...
0.7669403
71
Name the function so it is clearer in the documentation
function noop() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function name() {}", "function NamedFunction() {\n\treturn \"I was called\";\n}", "function fuction() {\n\n}", "function name() {\u000b \n //code to be executed\u000b\n }", "api_name() {\n\n }", "function AnyName() {}", "function miFuncion (){}", "function myFunction(name){\n console.log(\...
[ "0.7609658", "0.69970065", "0.69560003", "0.68476486", "0.679216", "0.6732367", "0.6708296", "0.6707051", "0.6672726", "0.66425234", "0.66425234", "0.66425234", "0.66130847", "0.6609925", "0.6607837", "0.65959007", "0.65702367", "0.6567782", "0.65613097", "0.65542525", "0.654...
0.0
-1
by calls to these methods by a Babel plugin. In PROD (or in packages without access to React internals), they are left as they are instead.
function warn(format) { { for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } printWarning('warn', format, args); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function resetIfUsingPreact() {\n if (window.preact !== undefined) {\n jsxLoader.compiler.pragma = 'React.createElement';\n jsxLoader.compiler.pragmaFrag = 'React.Fragment';\n }\n }", "react() {\n return;\n }", "function globalizeReact() {\n ...
[ "0.6232017", "0.5989827", "0.59513646", "0.5714014", "0.5714014", "0.5707565", "0.5690933", "0.5690933", "0.55861586", "0.5557413", "0.5545285", "0.5545285", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", "0.5512178", ...
0.0
-1
Base class helpers for the updating state of a component.
function Component(props, context, updater) { this.props = props; this.context = context; // If a component has string refs, we will assign a different object later. this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the // renderer. this.updater = updater || ReactNoopUpdateQueue; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "update() {\n BaseState.update.call(this);\n }", "_update() {\n // Call subclass lifecycle method\n const stateNeedsUpdate = this.needsUpdate();\n // End lifecycle method\n debug(TRACE_UPDATE, this, stateNeedsUpdate);\n\n if (stateNeedsUpdate) {\n this._updateState();\n }\n }", "func...
[ "0.7217708", "0.6761068", "0.6674957", "0.6611355", "0.6540057", "0.65267175", "0.6489628", "0.6470186", "0.64590305", "0.6384313", "0.6354146", "0.6334614", "0.63050985", "0.63048834", "0.6271505", "0.62657493", "0.6216846", "0.62140334", "0.61935604", "0.6188305", "0.615828...
0.0
-1
Convenience component with default shallow equality check for sCU.
function PureComponent(props, context, updater) { this.props = props; this.context = context; // If a component has string refs, we will assign a different object later. this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function useStrictEquality(b, a) {\n return a === b;\n }", "get shallowCopy() {\n return this.shallowCopy$();\n }", "function defaultEqualityCheck(a, b) {\n return !a && !b || a === b;\n }", "equals() {\n return false;\n }", "equals() {\n return false;\n }", ...
[ "0.6083867", "0.579746", "0.5670586", "0.5658718", "0.5658718", "0.56325066", "0.5591085", "0.5591085", "0.55860513", "0.5547111", "0.5488236", "0.5485746", "0.5482598", "0.5482598", "0.5473519", "0.5473519", "0.5473519", "0.5453362", "0.5453362", "0.54406023", "0.54001933", ...
0.0
-1
an immutable object with a single mutable value
function createRef() { var refObject = { current: null }; { Object.seal(refObject); } return refObject; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function immutableObjectTest(){\n\nlet test= {'name': 'vishal', 'age':27};\n//Object.freeze(test);\nlet test2= test;\n\ntest.age = 26;\nconsole.log(test);\nconsole.log(test2);\nconsole.log(test === test2);\n\n\n\n\n}", "static set one(value) {}", "function makeImmutableObject(obj) {\n\t if (!globalConfig.us...
[ "0.6674448", "0.66609514", "0.6358345", "0.6347869", "0.6347869", "0.6263268", "0.6230736", "0.6136926", "0.61048114", "0.5915378", "0.5889688", "0.580687", "0.5776291", "0.5763881", "0.57248324", "0.56947106", "0.566211", "0.5636481", "0.56181127", "0.5606209", "0.5606209", ...
0.0
-1
Create and return a new ReactElement of the given type. See
function createElement(type, config, children) { var propName; // Reserved names are extracted var props = {}; var key = null; var ref = null; var self = null; var source = null; if (config != null) { if (hasValidRef(config)) { ref = config.ref; { warnIfStringRefCannotBeAutoConverted(config); } } if (hasValidKey(config)) { key = '' + config.key; } self = config.__self === undefined ? null : config.__self; source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object for (propName in config) { if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { props[propName] = config[propName]; } } } // Children can be more than one argument, and those are transferred onto // the newly allocated props object. var childrenLength = arguments.length - 2; if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2]; } { if (Object.freeze) { Object.freeze(childArray); } } props.children = childArray; } // Resolve default props if (type && type.defaultProps) { var defaultProps = type.defaultProps; for (propName in defaultProps) { if (props[propName] === undefined) { props[propName] = defaultProps[propName]; } } } { if (key || ref) { var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; if (key) { defineKeyPropWarningGetter(props, displayName); } if (ref) { defineRefPropWarningGetter(props, displayName); } } } return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function createElement(type,config,children){var propName;// Reserved names are extracted\nvar props={};var key=null;var ref=null;var self=null;var source=null;if(config!=null){if(hasValidRef(config)){ref=config.ref;{warnIfStringRefCannotBeAutoConverted(config);}}if(hasValidKey(config)){key=''+config.key;}self=con...
[ "0.68920434", "0.6835192", "0.6767826", "0.6757532", "0.6745889", "0.6745889", "0.6745889", "0.6745889", "0.6745889", "0.6745889", "0.6745889", "0.6745889", "0.6745889", "0.65640503", "0.65581757", "0.6406998", "0.6406998", "0.6406998", "0.6406998", "0.6406998", "0.63805515",...
0.0
-1
Clone and return a new ReactElement using element as the starting point. See
function cloneElement(element, config, children) { if (!!(element === null || element === undefined)) { { throw Error( "React.cloneElement(...): The argument must be a React element, but you passed " + element + "." ); } } var propName; // Original props are copied var props = _assign({}, element.props); // Reserved names are extracted var key = element.key; var ref = element.ref; // Self is preserved since the owner is preserved. var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a // transpiler, and the original source is probably a better indicator of the // true owner. var source = element._source; // Owner will be preserved, unless ref is overridden var owner = element._owner; if (config != null) { if (hasValidRef(config)) { // Silently steal the ref from the parent. ref = config.ref; owner = ReactCurrentOwner.current; } if (hasValidKey(config)) { key = '' + config.key; } // Remaining properties override existing props var defaultProps; if (element.type && element.type.defaultProps) { defaultProps = element.type.defaultProps; } for (propName in config) { if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { if (config[propName] === undefined && defaultProps !== undefined) { // Resolve default props props[propName] = defaultProps[propName]; } else { props[propName] = config[propName]; } } } } // Children can be more than one argument, and those are transferred onto // the newly allocated props object. var childrenLength = arguments.length - 2; if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2]; } props.children = childArray; } return ReactElement(element.type, key, ref, self, source, owner, props); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function cloneElement(element,config,children){if(!!(element===null||element===undefined)){{throw Error(\"React.cloneElement(...): The argument must be a React element, but you passed \"+element+\".\");}}var propName;// Original props are copied\nvar props=_assign({},element.props);// Reserved names are extracted\...
[ "0.6915212", "0.68927294", "0.6695613", "0.6695613", "0.66943395", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6647816", "0.6634648", "0.6615246", "0.6615246", ...
0.6612965
76
Flatten a children object (typically specified as `props.children`) and return an array with appropriately rekeyed children. See
function toArray(children) { var result = []; mapIntoWithKeyPrefixInternal(children, result, null, function (child) { return child; }); return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function toArrayChildren(children) {\n var ret = [];\n React__default.Children.forEach(children, function (child) {\n ret.push(child);\n });\n return ret;\n }", "function toArray(children){var result=[];mapIntoWithKeyPrefixInternal(children,result,null,function(child){return child;}...
[ "0.7753083", "0.75176793", "0.74334466", "0.74051267", "0.74051267", "0.74051267", "0.74051267", "0.74051267", "0.74051267", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.7397549", "0.73975...
0.0
-1
This is a dummy function to check if the function name has been altered by minification. If the function has been minified and NODE_ENV !== 'production', warn the user.
function isCrushed() {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function uglify(name) {\n console.log(\"Hello \" + name);\n}", "function keepNonMinified(file) {\n\tvar keep = true;\n\tif(file.path.match('.js$')) {\n\t\tvar minPath = file.path.replace('.js', '.min.js');\n\t\tkeep = !exists(minPath);\n\t}\n\treturn keep;\n}", "function markFuncFreeze(fun, opt_name) {\n /...
[ "0.6026162", "0.57766795", "0.5717173", "0.56829125", "0.56829125", "0.56371236", "0.56371236", "0.5623456", "0.55784535", "0.55485183", "0.55269253", "0.55227464", "0.55227464", "0.55227464", "0.55227464", "0.55227464", "0.55071455", "0.5493993", "0.5487601", "0.54814136", "...
0.0
-1
About 1.5x faster than the twoarg version of Arraysplice()
function spliceOne(list, index) { for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) { list[i] = list[k]; } list.pop(); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static fastSplice(arr, startIdx, removeCount) {\n let i, length = arr.length;\n if (startIdx >= length || removeCount === 0) {\n return;\n }\n removeCount = (startIdx + removeCount > length ? length - startIdx : removeCount);\n let len = length - removeCount;\n ...
[ "0.7447761", "0.707984", "0.7064555", "0.70439214", "0.68553483", "0.6749214", "0.6711499", "0.66870314", "0.66847533", "0.6684205", "0.6679297", "0.66641325", "0.6650311", "0.6631806", "0.66058284", "0.6588319", "0.65741193", "0.6562488", "0.6520138", "0.6509104", "0.6501042...
0.0
-1
This implementation is based heavily on node's url.parse
function resolvePathname(to, from) { if (from === undefined) from = ''; var toParts = (to && to.split('/')) || []; var fromParts = (from && from.split('/')) || []; var isToAbs = to && isAbsolute(to); var isFromAbs = from && isAbsolute(from); var mustEndAbs = isToAbs || isFromAbs; if (to && isAbsolute(to)) { // to is absolute fromParts = toParts; } else if (toParts.length) { // to is relative, drop the filename fromParts.pop(); fromParts = fromParts.concat(toParts); } if (!fromParts.length) return '/'; var hasTrailingSlash; if (fromParts.length) { var last = fromParts[fromParts.length - 1]; hasTrailingSlash = last === '.' || last === '..' || last === ''; } else { hasTrailingSlash = false; } var up = 0; for (var i = fromParts.length; i >= 0; i--) { var part = fromParts[i]; if (part === '.') { spliceOne(fromParts, i); } else if (part === '..') { spliceOne(fromParts, i); up++; } else if (up) { spliceOne(fromParts, i); up--; } } if (!mustEndAbs) for (; up--; up) fromParts.unshift('..'); if ( mustEndAbs && fromParts[0] !== '' && (!fromParts[0] || !isAbsolute(fromParts[0])) ) fromParts.unshift(''); var result = fromParts.join('/'); if (hasTrailingSlash && result.substr(-1) !== '/') result += '/'; return result; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseUrl(url) {\n\t const firstChar = url.charAt(0);\n\t if (firstChar === '~') {\n\t const secondChar = url.charAt(1);\n\t url = url.slice(secondChar === '/' ? 2 : 1);\n\t }\n\t return parseUriParts(url);\n\t}", "function parseURL(request, response){\n \tvar parseQuery = true...
[ "0.71804994", "0.7167736", "0.70781493", "0.70533544", "0.69422597", "0.68068653", "0.6711252", "0.67056453", "0.664349", "0.66432464", "0.6620269", "0.66057503", "0.6579839", "0.6572687", "0.6571172", "0.6571172", "0.6571172", "0.6571172", "0.6571172", "0.65536606", "0.65505...
0.0
-1
Array.prototype.find not available in IE.
function find(list, predicate) { for (var i = 0, length = list.length; i < length; i++) { if (predicate(list[i])) return list[i]; } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function find(arr, fn) {\n if (arr && 'length' in arr) {\n for (var i = 0, ii = arr.length; i < ii; i++) {\n var result = fn(arr[i], i);\n if (result) return result;\n }\n }\n\n return null;\n}", "function find() {}", "function find(arr, func) {\n return arr.find(f...
[ "0.7007406", "0.6930815", "0.68127745", "0.6794149", "0.6794149", "0.67534524", "0.67534524", "0.67534524", "0.67534524", "0.67512274", "0.6723627", "0.67182636", "0.65673363", "0.653245", "0.65095145", "0.65095145", "0.6492026", "0.6474983", "0.6474983", "0.6427573", "0.6412...
0.0
-1
An element is "untouchable" if it or one of its ancestors has `visibility: hidden` or `display: none`.
function UntouchabilityChecker(elementDocument) { this.doc = elementDocument; // Node cache must be refreshed on every check, in case // the content of the element has changed. The cache contains tuples // mapping nodes to their boolean result. this.cache = []; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function visible(element){var visibility=element.css(\"visibility\");while(visibility === \"inherit\") {element = element.parent();visibility = element.css(\"visibility\");}return visibility !== \"hidden\";}", "function visible(element){var visibility=element.css(\"visibility\");while(visibility===\"inherit\"){e...
[ "0.69815546", "0.6885399", "0.6885399", "0.6885399", "0.65720654", "0.6529043", "0.6451936", "0.64429814", "0.64204997", "0.6404728", "0.63581306", "0.6331091", "0.6331091", "0.6331091", "0.6331091", "0.6331091", "0.6331091", "0.6331091", "0.6331091", "0.6331091", "0.6331091"...
0.0
-1
Given a string or object, convert that input to RGB Possible string inputs: "red" "f00" or "f00" "ff0000" or "ff0000" "ff000000" or "ff000000" "rgb 255 0 0" or "rgb (255, 0, 0)" "rgb 1.0 0 0" or "rgb (1, 0, 0)" "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1" "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1" "hsl(0, 100%, 50%)" or "hsl 0 100% 50%" "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1" "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
function inputToRGB(color) { var rgb = { r: 0, g: 0, b: 0 }; var a = 1; var s = null; var v = null; var l = null; var ok = false; var format = false; if (typeof color == "string") { color = stringInputToObject(color); } if (typeof color == "object") { if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { s = convertToPercentage(color.s); v = convertToPercentage(color.v); rgb = hsvToRgb(color.h, s, v); ok = true; format = "hsv"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) { s = convertToPercentage(color.s); l = convertToPercentage(color.l); rgb = hslToRgb(color.h, s, l); ok = true; format = "hsl"; } if (color.hasOwnProperty("a")) { a = color.a; } } a = boundAlpha(a); return { ok: ok, format: color.format || format, r: mathMin(255, mathMax(rgb.r, 0)), g: mathMin(255, mathMax(rgb.g, 0)), b: mathMin(255, mathMax(rgb.b, 0)), a: a }; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function stringToRGB (theString) {\r // we assume a comma separated string, just because of course...\r var tmp = theString.split(\",\");\r var r = tmp[0]? tmp[0]:0;\r var g = tmp[1]? tmp[1]:0;\r var b = tmp[2]? tmp[2]:0;\r return [r/255,g/255,b/255];\r}", "function stringToRGB (theString) {\r ...
[ "0.76101536", "0.76101536", "0.7584859", "0.7551137", "0.753427", "0.7420546", "0.7363761", "0.7351614", "0.73077554", "0.7294883", "0.7293897", "0.7293897", "0.7293897", "0.7293897", "0.72887504", "0.7273011", "0.7273011", "0.72710276", "0.72638", "0.72638", "0.7235114", "...
0.7249848
50
`rgbToHex` Converts an RGB color to hex Assumes r, g, and b are contained in the set [0, 255] Returns a 3 or 6 character hex
function rgbToHex(r, g, b, allow3Char) { var hex = [ pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16)) ]; // Return a 3 character hex if possible if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) { return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0); } return hex.join(""); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function rgbToHex(r, g, b) {\n return '#' + componentToHex(r) + componentToHex(g) + componentToHex(b)\n}", "function rgbToHex(r, g, b) {\n return \"#\" + componentToHex(r) + componentToHex(g) + componentToHex(b);\n}", "function rgbToHex(r, g, b) {\n return \"#\" + componentToHex(r) + componentToHex(g) + c...
[ "0.8503501", "0.8486479", "0.84731126", "0.84731126", "0.84264696", "0.8352944", "0.83259827", "0.82644963", "0.82461166", "0.823947", "0.82267046", "0.8167519", "0.81094265", "0.80909735", "0.80686516", "0.8020955", "0.80175596", "0.8009066", "0.80053276", "0.79967576", "0.7...
0.7586019
95
`rgbaToHex` Converts an RGBA color plus alpha transparency to hex Assumes r, g, b are contained in the set [0, 255] and a in [0, 1]. Returns a 4 or 8 character rgba hex
function rgbaToHex(r, g, b, a, allow4Char) { var hex = [ pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16)), pad2(convertDecimalToHex(a)) ]; // Return a 4 character hex if possible if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) { return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0); } return hex.join(""); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function rgbaToHex(r, g, b, a) {\n\n var hex = [\n pad2(convertDecimalToHex(a)),\n pad2(mathRound(r).toString(16)),\n pad2(mathRound(g).toString(16)),\n pad2(mathRound(b).toString(16))\n ];\n\n return hex.join(\"\");\n}", "function rgbaToHex(r, g, b, a) {\n\n var h...
[ "0.81387776", "0.8120112", "0.8120112", "0.8120112", "0.8120112", "0.8120112", "0.8120112", "0.8066185", "0.8065866", "0.8065866", "0.7994703", "0.7994703", "0.7886135", "0.7877471", "0.7877471", "0.7877471", "0.7877471", "0.7877471", "0.7877471", "0.7877471", "0.7877471", ...
0.0
-1
`rgbaToArgbHex` Converts an RGBA color to an ARGB Hex8 string Rarely used, but required for "toFilter()"
function rgbaToArgbHex(r, g, b, a) { var hex = [ pad2(convertDecimalToHex(a)), pad2(mathRound(r).toString(16)), pad2(mathRound(g).toString(16)), pad2(mathRound(b).toString(16)) ]; return hex.join(""); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function rgb2hex(rgba) {\n let sep = rgba.indexOf(\",\") > -1 ? \",\" : \" \";\n rgba = rgba.substr(rgba.indexOf(\"(\")+1).split(\")\")[0].split(sep);\n\n let r = (+rgba[0]).toString(16),\n g = (+rgba[1]).toString(16),\n b = (+rgba[2]).toString(16),\n a = rgba[3] * 255;\n\n if (r.length == 1) ...
[ "0.8096237", "0.8031533", "0.8027", "0.8027", "0.80210817", "0.80176497", "0.8006354", "0.79695195", "0.79411036", "0.79411036", "0.7909123", "0.7909123", "0.7909123", "0.7909123", "0.7909123", "0.77834994", "0.77328616", "0.77181447", "0.7707203", "0.769005", "0.7573088", ...
0.7970098
32
Modification Functions Thanks to less.js for some of the basics here <
function desaturate(color, amount) { amount = (amount === 0) ? 0 : (amount || 10); var hsl = tinycolor(color).toHsl(); hsl.s -= amount / 100; hsl.s = clamp01(hsl.s); return tinycolor(hsl); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function lessContent(){\n\t//var less = document.getElementById(\"less\"); same concept of why not needed as last problem\n\tless.style.display = \"none\";\n\n\t//you could also do less.HTML = \"\"; or \n\t\n}", "function less(hljs) {\n var IDENT_RE = '[\\\\w-]+'; // yes, Less identifiers may begin with ...
[ "0.6211167", "0.6073777", "0.6073777", "0.60543406", "0.6041548", "0.6041548", "0.5771404", "0.56556684", "0.5642153", "0.56293935", "0.5623135", "0.56225723", "0.5603504", "0.5551451", "0.5365977", "0.5313776", "0.5303798", "0.52269864", "0.52080464", "0.5173901", "0.517376"...
0.0
-1
Spin takes a positive or negative amount within [360, 360] indicating the change of hue. Values outside of this range will be wrapped into this range.
function spin(color, amount) { var hsl = tinycolor(color).toHsl(); var hue = (hsl.h + amount) % 360; hsl.h = hue < 0 ? 360 + hue : hue; return tinycolor(hsl); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function _spin(color, amount) {\n var hsl = tinycolor(color).toHsl();\n var hue = (hsl.h + amount) % 360;\n hsl.h = hue < 0 ? 360 + hue : hue;\n return tinycolor(hsl);\n }", "function _spin(color, amount) {\n\t var hsl = ...
[ "0.7569416", "0.7567256", "0.7511435", "0.74026567", "0.74026567", "0.73911095", "0.73911095", "0.7389199", "0.73602784", "0.73437786", "0.7305738", "0.7286768", "0.7286768", "0.7286768", "0.7286768", "0.7286768", "0.6322526", "0.63052016", "0.61720943", "0.60072523", "0.5930...
0.73059875
35
Combination Functions Thanks to jQuery xColor for some of the ideas behind these <
function complement(color) { var hsl = tinycolor(color).toHsl(); hsl.h = (hsl.h + 180) % 360; return tinycolor(hsl); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function blendColors(c0, c1, p) {\n var f=parseInt(c0.slice(1),16),\n t=parseInt(c1.slice(1),16),\n R1=f>>16,\n G1=f>>8&0x00FF,\n B1=f&0x0000FF,\n R2=t>>16,\n G2=t>>8&0x00FF,\n B2=t&0x0000FF;\n return \"#\"+(0x1000000+(Math.round((R2-R1)*p)+R1)*0x10000\n +(Math.round((G2-G1)*p)+G1)*0x...
[ "0.6467974", "0.64331746", "0.6368882", "0.6324223", "0.62776595", "0.62546605", "0.61677694", "0.61373454", "0.61044", "0.60893404", "0.6024644", "0.6017669", "0.60097945", "0.599612", "0.59838575", "0.5972702", "0.59632844", "0.5948893", "0.59428334", "0.5942087", "0.594095...
0.0
-1
Return a valid alpha value [0,1] with all invalid values being set to 1
function boundAlpha(a) { a = parseFloat(a); if (isNaN(a) || a < 0 || a > 1) { a = 1; } return a; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "get Alpha0() {}", "set Alpha0(value) {}", "function boundAlpha(a) {\n a = parseFloat(a);\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n return a;\n }", "function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(...
[ "0.7021053", "0.698131", "0.68436676", "0.68300396", "0.6810301", "0.6782784", "0.6782784", "0.6782784", "0.6782784", "0.6782784", "0.6782784", "0.6782784", "0.6776724", "0.6739779", "0.6733091", "0.6706063", "0.6706063", "0.6706063", "0.6696229", "0.6649467", "0.6649467", ...
0.67187935
41
Take input from [0, n] and return it as [0, 1]
function bound01(n, max) { if (isOnePointZero(n)) { n = "100%"; } var processPercent = isPercentage(n); n = mathMin(max, mathMax(0, parseFloat(n))); // Automatically convert percentage into number if (processPercent) { n = parseInt(n * max, 10) / 100; } // Handle floating point rounding errors if ((Math.abs(n - max) < 0.000001)) { return 1; } // Convert into [0, 1] range if it isn't already return (n % max) / parseFloat(max); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function first(n){\n let arry = [];\n for(let i = 0; i < n; i++){\n arry[i] = i + 1;\n }\n return arry;\n}", "function nthElement(input, n = 0) {\n if (n == 0) {\n return input[0];\n } else if (n < 0) {\n return [];\n } else {\n if (n > input.length) {\n return input;\n }\n let newA...
[ "0.71773195", "0.6694955", "0.6603095", "0.65995866", "0.65072536", "0.6461666", "0.6460382", "0.6378593", "0.6347146", "0.6345456", "0.63361126", "0.632006", "0.62995267", "0.62973386", "0.6272909", "0.6226265", "0.6222668", "0.6214539", "0.6192041", "0.61815333", "0.6180363...
0.0
-1
Force a number between 0 and 1
function clamp01(val) { return mathMin(1, mathMax(0, val)); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function normalize(value) {\n\tif (value > 1) {\n\t\tvalue = 1;\n\t} else if (value < 0) {\n\t\tvalue = 0;\n\t}\n\treturn value;\n}", "function clamp01(val) {\n return Math.min(1, Math.max(0, val));\n }", "function clamp01(val) {\n return Math.min(1, Math.max(0, val));\n}", "function clamp...
[ "0.697331", "0.69500285", "0.6934323", "0.6934323", "0.6934323", "0.6934323", "0.6934323", "0.6934323", "0.6934323", "0.69342405", "0.68888277", "0.68779397", "0.68736076", "0.6842573", "0.6842573", "0.6842573", "0.6836512", "0.6836512", "0.6824807", "0.6824807", "0.6824807",...
0.68928826
41
Parse a base16 hex value into a base10 integer
function parseIntFromHex(val) { return parseInt(val, 16); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function parseIntFromHex(val) {\n return parseInt(val, 16);\n }", "function parseIntFromHex(val) {\n return parseInt(val, 16);\n }", "function parseIntFromHex(val) {\n return parseInt(val, 16);\n }", "function parseIntFromHex(val) {\n return ...
[ "0.74533725", "0.74018306", "0.7292385", "0.7292385", "0.7292385", "0.7292385", "0.7292385", "0.7292385", "0.72538525", "0.7246096", "0.72154737", "0.72154737", "0.72154737", "0.72154737", "0.72031677", "0.72031677", "0.72031677", "0.72031677", "0.7200139", "0.7143342", "0.71...
0.72455937
41
Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1 <
function isOnePointZero(n) { return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function getPositivePercentValue(val) { return val / currentSerie.maxRange * 100; }", "function unit (value) {\n\t return low.number(value) &&\n\t value >= 0.0 && value <= 1.0\n\t}", "function checkPercent(num1, num2){\n\n ans = (100 - (num1/num2)*100).toFixed(2);\n ...
[ "0.71113557", "0.67602676", "0.6753145", "0.6753145", "0.67486286", "0.67486286", "0.67486286", "0.67486286", "0.67486286", "0.67486286", "0.6707342", "0.6642832", "0.66188645", "0.66137123", "0.66105145", "0.65965676", "0.659426", "0.65884614", "0.65817165", "0.65817165", "0...
0.0
-1
Check to see if string passed in is a percentage
function isPercentage(n) { return typeof n === "string" && n.indexOf('%') != -1; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isPercentage(n) {\n return typeof n === 'string' && n.includes('%');\n }", "function isPercentage(n) {\n return typeof n === 'string' && n.includes('%');\n}", "function isPercentage(n) {\n\t return typeof n === 'string' && n.indexOf('%') !== -1;\n\t}", "function isPercentage(n)...
[ "0.8826205", "0.88141215", "0.8740373", "0.87375885", "0.87375885", "0.87375885", "0.87375885", "0.87375885", "0.87375885", "0.87375885", "0.8734519", "0.8724306", "0.8724306", "0.8724306", "0.8717392", "0.86989266", "0.8688172", "0.8688172", "0.8688172", "0.8688172", "0.8686...
0.8745909
29
Force a hex value to have 2 characters
function pad2(c) { return c.length == 1 ? '0' + c : '' + c; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function hex(val) {\n\t\t\tval = val.toString(16);\n\t\t\tif (val.length < 2) val = '0'+val;\n\t\t\treturn val;\n\t\t}", "function hex(val) {\n var hex_rep = val.toString(16);\n return (hex_rep.length === 1) ? '0' + hex_rep : hex_rep;\n}", "function twoCh (val) {\n val = '0' + String(val)\n return val....
[ "0.7199072", "0.718944", "0.67827487", "0.6780733", "0.6724398", "0.6659148", "0.6604266", "0.6589613", "0.658292", "0.65805215", "0.6560533", "0.6553308", "0.65487784", "0.65487784", "0.6537162", "0.65317774", "0.6530349", "0.65280503", "0.65211016", "0.651357", "0.651244", ...
0.0
-1
Replace a decimal with it's percentage value
function convertToPercentage(n) { if (n <= 1) { n = (n * 100) + "%"; } return n; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function pctChange(val){\r\n if(val > 0){\r\n return '' + val + '%';\r\n }else if(val < 0){\r\n return '' + val + '%';\r\n }\r\n return val;\r\n }", "function pctChange(val){\r\n if(val > 0){\r\n return '' + val + '%';\r\n }else if(val...
[ "0.7397558", "0.7397558", "0.7397558", "0.7397558", "0.7397558", "0.7397558", "0.73852247", "0.73460466", "0.7261995", "0.7165849", "0.7157337", "0.7123517", "0.7108929", "0.7013729", "0.7009938", "0.6997692", "0.6986538", "0.69737834", "0.6965283", "0.69514245", "0.6943916",...
0.68255436
68
Converts a decimal to a hex value
function convertDecimalToHex(d) { return Math.round(parseFloat(d) * 255).toString(16); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function convertDecimalToHex(d) {\n return Math.round(parseFloat(d) * 255).toString(16);\n }", "function convertDecimalToHex(d) {\n return Math.round(parseFloat(d) * 255).toString(16);\n }", "function convertDecimalToHex(d) {\n return Math.round(parseFloat(d) ...
[ "0.7570578", "0.75610775", "0.7552267", "0.74836814", "0.7474269", "0.7474269", "0.7474269", "0.7474269", "0.7474269", "0.7474269", "0.7462278", "0.7462278", "0.7453795", "0.7453795", "0.7453795", "0.7283163", "0.7283163", "0.72519004", "0.7245713", "0.72197133", "0.72148067"...
0.7564213
32
Converts a hex value to a decimal
function convertHexToDecimal(h) { return (parseIntFromHex(h) / 255); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function hexToDec (hex) {\n var sum = 0;\n var hexObj = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n \"A\": 10,\n \"B\": 11,\n \"C\": 12,\n \"D\": 13,\n \"E\": 14,\n \"F\": 15, \n };\n function inner(hex, i) {\n hex = hex.toUpperCase();\...
[ "0.7797104", "0.74350196", "0.74350196", "0.73822236", "0.73822236", "0.73822236", "0.73686624", "0.72295254", "0.72295254", "0.72295254", "0.72295254", "0.72295254", "0.72295254", "0.7214877", "0.7211179", "0.7211179", "0.7211179", "0.72073025", "0.7185375", "0.7175727", "0....
0.72933114
32
`isValidCSSUnit` Take in a single string / number and check to see if it looks like a CSS unit (see `matchers` above for definition).
function isValidCSSUnit(color) { return !!matchers.CSS_UNIT.exec(color); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "function isValidCSSUnit(color) {\n return !!matchers.CSS_UNIT.exec(color);\n } // `stringInputToObject`", "function isValidCSSUnit(color) {\n return !!matchers.CSS_UNIT.exec(color);\n } // `stringInputToObject`", "function isValidCSSUnit(color) {\n return Boolean(matchers.CSS_UNIT.exec(String(color)...
[ "0.8457542", "0.8457542", "0.82806295", "0.82806295", "0.82806295", "0.82806295", "0.82806295", "0.82806295", "0.82806295", "0.82757413", "0.81928056", "0.81815296", "0.8179173", "0.8157833", "0.8138045", "0.8138045", "0.5851657", "0.5585589", "0.5576022", "0.5466465", "0.546...
0.8276747
35
Copyright (c) 2013present, Facebook, Inc. All rights reserved. This source code is licensed under the BSDstyle license found in the LICENSE file in the root directory of this source tree. An additional grant of patent rights can be found in the PATENTS file in the same directory.
function canAcceptRef(component) { return !!component && (typeof component !== 'function' || component.prototype && component.prototype.isReactComponent); }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "componentDidMount() {\n // if this is the first time the home screen is loading\n // we must initialize Facebook\n if (!window.FB) {\n window.fbAsyncInit = function() {\n window.FB.init({\n appId : '280945375708713',\n cookie : true, // enable cookies to allow the s...
[ "0.56065136", "0.5405664", "0.5363121", "0.53545314", "0.5333756", "0.52918416", "0.52918416", "0.5231541", "0.5192295", "0.5186469", "0.51845247", "0.5152402", "0.51356876", "0.51134974", "0.5095628", "0.508052", "0.50637424", "0.5059554", "0.5037927", "0.50063604", "0.49586...
0.0
-1
update loop of the game
function update() { if (pauseState) { return; } else { totalDeaths(); coinRepetition(); game.clear(); obs.animate(); } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "static update()\n {\n // Update game timer if there's a current game\n if (RPM.game)\n {\n RPM.game.playTime.update();\n }\n\n // Update songs manager\n RPM.songsManager.update();\n\n // Repeat keypress as long as not blocking\n let continuePres...
[ "0.78576803", "0.785624", "0.78343886", "0.77977407", "0.7778103", "0.76732415", "0.76732415", "0.76285017", "0.7625629", "0.7615792", "0.7594556", "0.75583804", "0.75544626", "0.75434744", "0.7542098", "0.75411874", "0.7523506", "0.7520684", "0.75148255", "0.74919957", "0.74...
0.0
-1
Versione con scp con promise
function uploadWithPromise(host, user, file, remote) { var deferred = Q.defer(); var scp = setupSCP(host, user) scp.upload(file, remote, deferred.resolve); return deferred.promise; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async cloneVersion() {\n const cloneOpts = await this.putVersionOpts('/clone');\n this.tick(0, 'Cloning Service Config version', 'cloning version');\n return request(cloneOpts).then((r) => {\n this._version = r.number;\n this.tick(1, `Cloned Service Config Version ${r.number}`, `cloning version ...
[ "0.59213984", "0.57192713", "0.5506172", "0.548478", "0.52495", "0.5240451", "0.5233683", "0.5205542", "0.5194032", "0.51852715", "0.51653147", "0.5155067", "0.5071846", "0.5069637", "0.5047318", "0.50348073", "0.5028654", "0.5001386", "0.49853018", "0.49519834", "0.49511638"...
0.55999565
2
Versione con scp con promise
function downloadWithPromise(host, user, remoteFile, localDir) { var deferred = Q.defer(); var scp = setupSCP(host, user) scp.download(remoteFile, localDir, deferred.resolve); return deferred.promise; }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async cloneVersion() {\n const cloneOpts = await this.putVersionOpts('/clone');\n this.tick(0, 'Cloning Service Config version', 'cloning version');\n return request(cloneOpts).then((r) => {\n this._version = r.number;\n this.tick(1, `Cloned Service Config Version ${r.number}`, `cloning version ...
[ "0.59213984", "0.57192713", "0.55999565", "0.5506172", "0.548478", "0.5240451", "0.5233683", "0.5205542", "0.5194032", "0.51852715", "0.51653147", "0.5155067", "0.5071846", "0.5069637", "0.5047318", "0.50348073", "0.5028654", "0.5001386", "0.49853018", "0.49519834", "0.495116...
0.52495
5