_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q37700
interpolate
train
function interpolate(val, scope) { // if no scope or value with {{ then no interpolation and can just return translated if (!scope || !val || !val.match) { return val; } // first, we need to get all values with a {{ }} in the string var i18nVars = val.match(i18nVarExpr); // lo...
javascript
{ "resource": "" }
q37701
translate
train
function translate(val, scope, status) { var app = (scope && scope.appName) || context.get('app') || ''; var lang = (scope && scope.lang) || context.get('lang') || 'en'; var translated; // if just one character or is a number, don't do translation if (!val || val.length < 2 || !...
javascript
{ "resource": "" }
q37702
initialCheck
train
function initialCheck(attr_name) { var elements = document.querySelectorAll('[' + attr_name + ']'), element, value, i, l; for (i = 0; i < elements.length; i++) { element = elements[i]; value = element.getAttribute(attr_name); if (initial_seen.get(element)) { continue; } if (attrib...
javascript
{ "resource": "" }
q37703
checkChildren
train
function checkChildren(mutation, node, seen) { var attr, k, l; if (seen == null) { seen = initial_seen; } // Ignore text nodes if (node.nodeType === 3 || node.nodeType === 8) { return; } // Only check attributes for nodes that haven't been checked before if (!seen.get(node)) { // Indicate t...
javascript
{ "resource": "" }
q37704
SimplePool
train
function SimplePool() { var args; args = 1 <= arguments.length ? __slice.call(arguments, 0) : []; this.current = 0; this.pool = args.length === 1 && Array.isArray(args[0]) ? args[0] : args; }
javascript
{ "resource": "" }
q37705
createBaseTransport
train
function createBaseTransport(req, res) { // A transport object. var self = new events.EventEmitter(); // Because HTTP transport consists of multiple exchanges, an universally // unique identifier is required. self.id = uuid.v4(); // A flag to check the transport is opened. var opened = true;...
javascript
{ "resource": "" }
q37706
createStreamTransport
train
function createStreamTransport(req, res) { // A transport object. var self = createBaseTransport(req, res); // Any error on request-response should propagate to transport. req.on("error", function(error) { self.emit("error", error); }); res.on("error", function(error) { self.emit...
javascript
{ "resource": "" }
q37707
toJSON
train
function toJSON() { var obj = { message: this.message, stack: this.stack }, key; for (key in this) { if ( has.call(this, key) && 'function' !== typeof this[key] ) { obj[key] = this[key]; } } return obj; }
javascript
{ "resource": "" }
q37708
train
function(session) { if (session && session.user) { if (session.user.roles) return { roles: session.user.roles }; return { roles: "user" }; } return { roles: "public" }; }
javascript
{ "resource": "" }
q37709
on_write
train
function on_write (metric, enc, done) { var name = metric.name var values = metric.values var tags = metric.tags locals.batch.list[name] = locals.batch.list[name] || [] locals.batch.list[name].push([values, tags]) locals.batch.count = locals.batch.count + 1 var exceeded = locals.batch.count >= locals.ba...
javascript
{ "resource": "" }
q37710
importerSync
train
function importerSync(options, handler) { var modulePath, recursive = false, parent = ''; if (typeof options === 'string') { modulePath = options; } else { modulePath = options.path; recursive = options.recursive || recursive; parent = options.parent || parent; if (...
javascript
{ "resource": "" }
q37711
train
function (prototypes, force) { var instance, proto, names, l, i, replaceMap, protectedMap, name, nameInProto, finalName, propDescriptor, extraInfo; if (!prototypes) { return; } instance = this; // the Class proto = instance.prototype; names = Object.getOwnProp...
javascript
{ "resource": "" }
q37712
train
function (properties) { var proto = this.prototype, replaceMap = arguments[1] || REPLACE_CLASS_METHODS; // hidden feature, used by itags Array.isArray(properties) || (properties=[properties]); properties.forEach(function(prop) { prop = replaceMap[prop] || prop; ...
javascript
{ "resource": "" }
q37713
train
function(constructorFn, chainConstruct) { var instance = this; if (typeof constructorFn==='boolean') { chainConstruct = constructorFn; constructorFn = null; } (typeof chainConstruct === 'boolean') || (chainConstruct=DEFAULT_CHAIN_CONSTRUCT); instance.$$con...
javascript
{ "resource": "" }
q37714
train
function (constructor, prototypes, chainConstruct) { var instance = this, constructorClosure = {}, baseProt, proto, constrFn; if (typeof constructor === 'boolean') { constructor = null; prototypes = null; chainConstruct = constructor; ...
javascript
{ "resource": "" }
q37715
checkTransform3dSupport
train
function checkTransform3dSupport() { div.style[support.transform] = ''; div.style[support.transform] = 'rotateY(90deg)'; return div.style[support.transform] !== ''; }
javascript
{ "resource": "" }
q37716
train
function(elem, v) { var value = v; if (!(value instanceof Transform)) { value = new Transform(value); } // We've seen the 3D version of Scale() not work in Chrome when the // element being scaled extends outside of the viewport. Thus, we're // forcing Chrome to not use the...
javascript
{ "resource": "" }
q37717
train
function() { if (bound) { self.unbind(transitionEnd, cb); } if (i > 0) { self.each(function() { this.style[support.transition] = (oldTransitions[this] || null); }); } if (typeof callback === 'function') { callback.apply(self); } if (typeof nextCa...
javascript
{ "resource": "" }
q37718
train
function(next) { var i = 0; // Durations that are too slow will get transitions mixed up. // (Tested on Mac/FF 7.0.1) if ((support.transition === 'MozTransition') && (i < 25)) { i = 25; } window.setTimeout(function() { run(next); }, i); }
javascript
{ "resource": "" }
q37719
Millipede
train
function Millipede(size, options) { options = options || {}; this.size = size; this.reverse = options.reverse; this.horizontal = options.horizontal; this.position = options.position || 0; this.top = options.top || 0; this.left = options.left || 0; this.validate(); }
javascript
{ "resource": "" }
q37720
rawBundleFromFile
train
function rawBundleFromFile (dir, filename) { return readFilePromise(path.join(dir, filename)) .then(content => { return { dest: filename, raw: content }; }); }
javascript
{ "resource": "" }
q37721
defRoute
train
function defRoute(session, msg, context, cb) { const list = context.getServersByType(msg.serverType); if (!list || !list.length) { cb(new Error(`can not find server info for type:${msg.serverType}`)); return; } const uid = session ? (session.uid || '') : ''; const index = Math.abs(cr...
javascript
{ "resource": "" }
q37722
rdRoute
train
function rdRoute(client, serverType, msg, cb) { const servers = client._station.serversMap[serverType]; if (!servers || !servers.length) { utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`)); return; } const index = Math.floor(Math.random() * serve...
javascript
{ "resource": "" }
q37723
rrRoute
train
function rrRoute(client, serverType, msg, cb) { const servers = client._station.serversMap[serverType]; if (!servers || !servers.length) { utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`)); return; } let index; if (!client.rrParam) { ...
javascript
{ "resource": "" }
q37724
wrrRoute
train
function wrrRoute(client, serverType, msg, cb) { const servers = client._station.serversMap[serverType]; if (!servers || !servers.length) { utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`)); return; } let index; let weight; if (!client.wr...
javascript
{ "resource": "" }
q37725
laRoute
train
function laRoute(client, serverType, msg, cb) { const servers = client._station.serversMap[serverType]; if (!servers || !servers.length) { utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`)); return; } const actives = []; if (!client.laParam) {...
javascript
{ "resource": "" }
q37726
chRoute
train
function chRoute(client, serverType, msg, cb) { const servers = client._station.serversMap[serverType]; if (!servers || !servers.length) { utils.invokeCallback(cb, new Error(`rpc servers not exist with serverType: ${serverType}`)); return; } let con; if (!client.chParam) { cl...
javascript
{ "resource": "" }
q37727
isValid
train
function isValid(options, key) { var value = _.isFunction(options) ? options(key) : options[key]; if (typeof value === 'undefined') { return false; } if (value === null) { return false; } if (value === '') { return false; } if (_.isNaN(value)) { return...
javascript
{ "resource": "" }
q37728
train
function(user, stage, method){ switch (method) { case 'withinRooms': var room = user.getRoom(); if(stageCount(stage, room) == room.size) { console.log("Finished syncronising in " + room.name + ". Enough members in stage " + stage); // Once all members are present start experiment f...
javascript
{ "resource": "" }
q37729
train
function(stage, room) { i = 0; var stagemembers = (typeof room === 'undefined') ? members : _.pluck(room.getMembers(true), 'id'); for(var key in stagemembers) if(cloak.getUser(stagemembers[key]).data._stage == stage) i++; return i; }
javascript
{ "resource": "" }
q37730
train
function(url) { i = 0; for(var key in members) if(cloak.getUser(members[key]).data._load == url) i++; return i; }
javascript
{ "resource": "" }
q37731
train
function(user){ // First time nextStage() is called set the stage to zero. Otherwise keep track when continuing to the next stage user.data._stage = (typeof user.data._stage === 'undefined') ? 0 : user.data._stage+1; // Next stage is which type? var type = (typeof experiment.stages[user.data._stage].type ...
javascript
{ "resource": "" }
q37732
train
function(){ console.log("Last user has finished the experiment!"); var userdata = new Object(); for(var key in cloak.getUsers()) { cloak.getUsers()[key].data.device = parser.setUA(cloak.getUsers()[key].data._device).getResult(); // Parse the useragent before saving data. userdata[cloak.getUsers()[key].id...
javascript
{ "resource": "" }
q37733
train
function(ip) { var unique = true; for(var key in cloak.getLobby().getMembers()) { if(ip == cloak.getLobby().getMembers()[key].data.ip) unique = false; } return unique; }
javascript
{ "resource": "" }
q37734
start
train
function start(config, setDefaultREPLCommands, getAppInstance) { // Defines the IPC socket file path var socketAddr = path.join(process.cwd(), 'socket-ctl'); // Deletes the file if already exists if (fs.existsSync(socketAddr)) fs.unlinkSync(socketAddr); // Create and start the socket server socketServer ...
javascript
{ "resource": "" }
q37735
calculatePositionDiff
train
function calculatePositionDiff(position) { if (!_lastDiffPosition) { return _lastDiffPosition = position; } var dx, dy, p1, p2; p1 = position; p2 = _lastDiffPosition; dx = p2.x - p1.x; dy = p2.y - p1.y; _calcMoveDiffX += dx; _calcMoveDiffY += dy; _overallMoveDiffY += dy; _overallMoveDiffX += d...
javascript
{ "resource": "" }
q37736
train
function(req, res) { var packages = {}; var appJSON = require('../../package.json'); packages[appJSON.name] = appJSON; packages['onm'] = require('../onm/package.json'); res.send(packages); }
javascript
{ "resource": "" }
q37737
train
function(req, res) { var stores = []; for (key in onmStoreDictionary) { stores.push({ dataModel: onmStoreDictionary[key].model.jsonTag, storeKey: key }); } res.send(200, stores); }
javascript
{ "resource": "" }
q37738
train
function(req, res) { if (!req._body || (req.body == null) || !req.body) { res.send(400, "Invalid POST missing required request body."); return; } if ((req.body.model == null) || !req.body.model) { res.send(400, "Invalid POST missing 'mo...
javascript
{ "resource": "" }
q37739
train
function(req, res) { if (!req._body || (req.body == null) || !req.body) { res.send(400, "Invalid POST missing required request body."); return; } if ((req.body.store == null) || !req.body.store) { res.send(400, "Invalid POST mising 'sto...
javascript
{ "resource": "" }
q37740
train
function(req, res) { if (!req._body || (req.body == null) || !req.body) { res.send(400, "Invalid POST missing required request body."); return; } if ((req.body.store == null) || !req.body.store) { res.send(400, "Invalid POST mising 'sto...
javascript
{ "resource": "" }
q37741
train
function(req, res) { if (!req._body || (req.body == null) || !req.body) { res.send(400, "Invalid POST missing required request body."); return; } if ((req.body.store == null) || !req.body.store) { res.send(400, "Invalid POST missing 'st...
javascript
{ "resource": "" }
q37742
train
function(target, expectedInterface, ignoreExtra) { if (typeof target !== 'object' || target instanceof Array) { throw new Error('target object not specified, or is not valid (arg #1)'); } if (typeof expectedInterface !== 'object' || expectedInterface instanceof Array) { ...
javascript
{ "resource": "" }
q37743
train
function(ref, condition) { condition = condition || {}; utils.assert( condition.then || condition.otherwise , 'one of condition.then or condition.otherwise must be existed' ); utils.assert( !condition.then || (condition.then && condition.then.isOvt), 'condition.then must be a va...
javascript
{ "resource": "" }
q37744
getHref
train
function getHref() { return this.context.router.makeHref(this.props.to, this.props.params, this.props.query); }
javascript
{ "resource": "" }
q37745
makePath
train
function makePath(to, params, query) { return this.context.router.makePath(to, params, query); }
javascript
{ "resource": "" }
q37746
makeHref
train
function makeHref(to, params, query) { return this.context.router.makeHref(to, params, query); }
javascript
{ "resource": "" }
q37747
isActive
train
function isActive(to, params, query) { return this.context.router.isActive(to, params, query); }
javascript
{ "resource": "" }
q37748
appendChild
train
function appendChild(route) { invariant(route instanceof Route, 'route.appendChild must use a valid Route'); if (!this.childRoutes) this.childRoutes = []; this.childRoutes.push(route); }
javascript
{ "resource": "" }
q37749
makePath
train
function makePath(to, params, query) { var path; if (PathUtils.isAbsolute(to)) { path = to; } else { var route = to instanceof Route ? to : Router.namedRoutes[to]; invariant(route instanceof Route, 'Cannot find a route named "%s"', to); path = route.path...
javascript
{ "resource": "" }
q37750
makeHref
train
function makeHref(to, params, query) { var path = Router.makePath(to, params, query); return location === HashLocation ? '#' + path : path; }
javascript
{ "resource": "" }
q37751
goBack
train
function goBack() { if (History.length > 1 || location === RefreshLocation) { location.pop(); return true; } warning(false, 'goBack() was ignored because there is no router history'); return false; }
javascript
{ "resource": "" }
q37752
isActive
train
function isActive(to, params, query) { if (PathUtils.isAbsolute(to)) { return to === state.path; }return routeIsActive(state.routes, to) && paramsAreActive(state.params, params) && (query == null || queryIsActive(state.query, query)); }
javascript
{ "resource": "" }
q37753
extractParams
train
function extractParams(pattern, path) { var _compilePattern = compilePattern(pattern); var matcher = _compilePattern.matcher; var paramNames = _compilePattern.paramNames; var match = path.match(matcher); if (!match) { return null; }var params = {}; paramNames.forEach(function (para...
javascript
{ "resource": "" }
q37754
injectParams
train
function injectParams(pattern, params) { params = params || {}; var splatIndex = 0; return pattern.replace(paramInjectMatcher, function (match, paramName) { paramName = paramName || 'splat'; // If param is optional don't check for existence if (paramName.slice(-1) === '?') { par...
javascript
{ "resource": "" }
q37755
extractQuery
train
function extractQuery(path) { var match = path.match(queryMatcher); return match && qs.parse(match[1]); }
javascript
{ "resource": "" }
q37756
withQuery
train
function withQuery(path, query) { var existingQuery = PathUtils.extractQuery(path); if (existingQuery) query = query ? assign(existingQuery, query) : existingQuery; var queryString = qs.stringify(query, { arrayFormat: 'brackets' }); if (queryString) { return PathUtils.withoutQuery(path) + '?' +...
javascript
{ "resource": "" }
q37757
Transition
train
function Transition(path, retry) { this.path = path; this.abortReason = null; // TODO: Change this to router.retryTransition(transition) this.retry = retry.bind(this); }
javascript
{ "resource": "" }
q37758
findMatch
train
function findMatch(routes, path) { var pathname = PathUtils.withoutQuery(path); var query = PathUtils.extractQuery(path); var match = null; for (var i = 0, len = routes.length; match == null && i < len; ++i) match = deepSearch(routes[i], pathname, query); return match; }
javascript
{ "resource": "" }
q37759
bindAutoBindMethod
train
function bindAutoBindMethod(component, method) { var boundMethod = method.bind(component); if ("production" !== process.env.NODE_ENV) { boundMethod.__reactBoundContext = component; boundMethod.__reactBoundMethod = method; boundMethod.__reactBoundArguments = null; var componentName = component.constr...
javascript
{ "resource": "" }
q37760
train
function(type, key, ref, owner, context, props) { // Built-in properties that belong on the element this.type = type; this.key = key; this.ref = ref; // Record the component responsible for creating this element. this._owner = owner; // TODO: Deprecate withContext, and then the context becomes accessibl...
javascript
{ "resource": "" }
q37761
getName
train
function getName(instance) { var publicInstance = instance && instance.getPublicInstance(); if (!publicInstance) { return undefined; } var constructor = publicInstance.constructor; if (!constructor) { return undefined; } return constructor.displayName || constructor.name || undefined; }
javascript
{ "resource": "" }
q37762
validateExplicitKey
train
function validateExplicitKey(element, parentType) { if (element._store.validated || element.key != null) { return; } element._store.validated = true; warnAndMonitorForKeyUse( 'Each child in an array or iterator should have a unique "key" prop.', element, parentType ); }
javascript
{ "resource": "" }
q37763
validatePropertyKey
train
function validatePropertyKey(name, element, parentType) { if (!NUMERIC_PROPERTY_REGEX.test(name)) { return; } warnAndMonitorForKeyUse( 'Child objects should have non-numeric keys so ordering is preserved.', element, parentType ); }
javascript
{ "resource": "" }
q37764
warnAndMonitorForKeyUse
train
function warnAndMonitorForKeyUse(message, element, parentType) { var ownerName = getCurrentOwnerDisplayName(); var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; var useName = ownerName || parentName; var memoizer = ownerHasKeyUseWarning[message] || ( ...
javascript
{ "resource": "" }
q37765
validateChildKeys
train
function validateChildKeys(node, parentType) { if (Array.isArray(node)) { for (var i = 0; i < node.length; i++) { var child = node[i]; if (ReactElement.isValidElement(child)) { validateExplicitKey(child, parentType); } } } else if (ReactElement.isValidElement(node)) { // This e...
javascript
{ "resource": "" }
q37766
is
train
function is(a, b) { if (a !== a) { // NaN return b !== b; } if (a === 0 && b === 0) { // +-0 return 1 / a === 1 / b; } return a === b; }
javascript
{ "resource": "" }
q37767
isValidID
train
function isValidID(id) { return id === '' || ( id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR ); }
javascript
{ "resource": "" }
q37768
isAncestorIDOf
train
function isAncestorIDOf(ancestorID, descendantID) { return ( descendantID.indexOf(ancestorID) === 0 && isBoundary(descendantID, ancestorID.length) ); }
javascript
{ "resource": "" }
q37769
train
function(nextComponent, container) { ("production" !== process.env.NODE_ENV ? invariant( container && ( (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE) ), '_registerComponent(...): Target container is not a DOM element.' ) : invariant(container && ( ...
javascript
{ "resource": "" }
q37770
train
function( nextElement, container, shouldReuseMarkup ) { // Various parts of our code (such as ReactCompositeComponent's // _renderValidatedComponent) assume that calls to render aren't nested; // verify that that's the case. ("production" !== process.env.NODE_ENV ? warning( ReactCurr...
javascript
{ "resource": "" }
q37771
train
function(constructor, props, container) { var element = ReactElement.createElement(constructor, props); return ReactMount.render(element, container); }
javascript
{ "resource": "" }
q37772
train
function(id) { var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id); var container = containersByReactRootID[reactRootID]; if ("production" !== process.env.NODE_ENV) { var rootElement = rootElementsByReactRootID[reactRootID]; if (rootElement && rootElement.parentNode !== containe...
javascript
{ "resource": "" }
q37773
train
function(node) { if (node.nodeType !== 1) { // Not a DOMElement, therefore not a React component return false; } var id = ReactMount.getID(node); return id ? id.charAt(0) === SEPARATOR : false; }
javascript
{ "resource": "" }
q37774
train
function(node) { var current = node; while (current && current.parentNode !== current) { if (ReactMount.isRenderedByReact(current)) { return current; } current = current.parentNode; } return null; }
javascript
{ "resource": "" }
q37775
train
function(publicInstance, partialProps) { var internalInstance = getInternalInstanceReadyForUpdate( publicInstance, 'setProps' ); if (!internalInstance) { return; } ("production" !== process.env.NODE_ENV ? invariant( internalInstance._isTopLevel, 'setProps(...): You ca...
javascript
{ "resource": "" }
q37776
train
function(transaction, prevElement, nextElement, context) { assertValidProps(this._currentElement.props); this._updateDOMProperties(prevElement.props, transaction); this._updateDOMChildren(prevElement.props, transaction, context); }
javascript
{ "resource": "" }
q37777
isNode
train
function isNode(object) { return !!(object && ( ((typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string')) )); }
javascript
{ "resource": "" }
q37778
train
function(id, name, value) { var node = ReactMount.getNode(id); ("production" !== process.env.NODE_ENV ? invariant( !INVALID_PROPERTY_ERRORS.hasOwnProperty(name), 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name] ) : invariant(!INVALID_PROPERTY_ERRORS.hasOwnProperty(name))); ...
javascript
{ "resource": "" }
q37779
train
function(id, styles) { var node = ReactMount.getNode(id); CSSPropertyOperations.setValueForStyles(node, styles); }
javascript
{ "resource": "" }
q37780
train
function(id, content) { var node = ReactMount.getNode(id); DOMChildrenOperations.updateTextContent(node, content); }
javascript
{ "resource": "" }
q37781
insertChildAt
train
function insertChildAt(parentNode, childNode, index) { // By exploiting arrays returning `undefined` for an undefined index, we can // rely exclusively on `insertBefore(node, null)` instead of also using // `appendChild(node)`. However, using `undefined` is not allowed by all // browsers so we must replace it w...
javascript
{ "resource": "" }
q37782
findParent
train
function findParent(node) { // 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. var nodeID = ReactMount.getID(node); var rootID = ReactInstanceHandles.getReactRootIDFr...
javascript
{ "resource": "" }
q37783
train
function() { CallbackQueue.release(this.reactMountReady); this.reactMountReady = null; ReactPutListenerQueue.release(this.putListenerQueue); this.putListenerQueue = null; }
javascript
{ "resource": "" }
q37784
isInternalComponentType
train
function isInternalComponentType(type) { return ( typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function' ); }
javascript
{ "resource": "" }
q37785
enqueueMarkup
train
function enqueueMarkup(parentID, markup, toIndex) { // NOTE: Null values reduce hidden classes. updateQueue.push({ parentID: parentID, parentNode: null, type: ReactMultiChildUpdateTypes.INSERT_MARKUP, markupIndex: markupQueue.push(markup) - 1, textContent: null, fromIndex: null, toIndex:...
javascript
{ "resource": "" }
q37786
train
function(nextNestedChildren, transaction, context) { updateDepth++; var errorThrown = true; try { this._updateChildren(nextNestedChildren, transaction, context); errorThrown = false; } finally { updateDepth--; if (!updateDepth) { if (errorThrown) { ...
javascript
{ "resource": "" }
q37787
adler32
train
function adler32(data) { var a = 1; var b = 0; for (var i = 0; i < data.length; i++) { a = (a + data.charCodeAt(i)) % MOD; b = (b + a) % MOD; } return a | (b << 16); }
javascript
{ "resource": "" }
q37788
train
function(partialProps, callback) { // This is a deoptimized path. We optimize for always having an element. // This creates an extra internal element. var element = this._pendingElement || this._currentElement; this._pendingElement = ReactElement.cloneAndReplaceProps( element, assign({}, ele...
javascript
{ "resource": "" }
q37789
Graphics
train
function Graphics() { Container.call(this); /** * The alpha value used when filling the Graphics object. * * @member {number} * @default 1 */ this.fillAlpha = 1; /** * The width (thickness) of any lines drawn. * * @member {number} * @default 0 */ t...
javascript
{ "resource": "" }
q37790
train
function(opts) { EventEmitter.call(this); this.opts = opts; this.servers = {}; // remote server info map, key: server id, value: info this.serversMap = {}; // remote server info map, key: serverType, value: servers array this.onlines = {}; // remote server online map, key: server id, value: 0/offline 1/online...
javascript
{ "resource": "" }
q37791
couchdb
train
function couchdb (json) { return { prepareEndpoint (endpointOptions, sourceOptions) { return prepareEndpoint(json, endpointOptions, sourceOptions) }, async send (request) { return send(json, request) }, async serialize (data, request) { const serializedData = await serializeDat...
javascript
{ "resource": "" }
q37792
train
function(zip, callback) { var queryString = "?postalCode="+zip; httpGet(queryString, function(err, results) { callback(err, results); }); }
javascript
{ "resource": "" }
q37793
train
function(lat, lon, callback) { var queryString = "?latitude="+lat+"&longitude="+lon; httpGet(queryString, function(err, results) { callback(err, results); }); }
javascript
{ "resource": "" }
q37794
hasClass
train
function hasClass(element, className) { if (!hasClassNameProperty(element)) { return false; } return (' ' + element.className + ' ').indexOf(' ' + className + ' ') > -1; }
javascript
{ "resource": "" }
q37795
goToUrl
train
function goToUrl(url) { if (!url) { return; } if (_.isArray(url)) { url = url.join('/'); } var hasHttp = url.indexOf('http') === 0; if (!hasHttp && url.indexOf('/') !== 0) { url = '/' + url; } hasHttp ? $window.location.href = url : $loc...
javascript
{ "resource": "" }
q37796
getQueryParams
train
function getQueryParams(params) { params = params || {}; var url = $location.url(); var idx = url.indexOf('?'); // if there is a query string if (idx < 0) { return {}; } // get the query string and split the keyvals var query = url.substring(idx + 1); va...
javascript
{ "resource": "" }
q37797
save_config
train
function save_config(path, config) { debug.assert(path).is('string'); debug.assert(config).is('object'); return $Q.fcall(function stringify_json() { return JSON.stringify(config, null, 2); }).then(function write_to_file(data) { return FS.writeFile(path, data, {'encoding':'utf8'}); }); }
javascript
{ "resource": "" }
q37798
train
function (name) { var n = path.extname(name).length; return n === 0 ? name : name.slice(0, -n); }
javascript
{ "resource": "" }
q37799
walk
train
function walk(start, end, fn) { this.start = new Vec2(start); this.end = new Vec2(end); this.direction = calcDirection(this.start, this.end); // positive deltas go right and down this.cellStepDelta = { horizontal: 0, vertical: 0 } this.tMax = new Vec2(); this.tDelta = new Vec2(); this.curre...
javascript
{ "resource": "" }