_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q59100
initMatic
validation
function initMatic() { if (!matic) { matic = new Matic({ maticProvider: process.env.MATIC_PROVIDER, parentProvider: process.env.PARENT_PROVIDER, rootChainAddress: process.env.ROOTCHAIN_ADDRESS, maticWethAddress: process.env.MATIC_WETH_ADDRESS, syncerUrl: process.env.SYNCER_URL, ...
javascript
{ "resource": "" }
q59101
matchPath
validation
function matchPath(pathname, options = {}) { if (typeof options === 'string') options = { path: options }; const { path, exact = false, strict = false, sensitive = false } = options; const paths = [].concat(path); return paths.reduce((matched, p) => { if (matched) return matched; const { regexp...
javascript
{ "resource": "" }
q59102
Redirect
validation
function Redirect({ computedMatch, to, push = false }) { return ( <RouterContext.Consumer> {(context) => { invariant(context, 'You should not use <Redirect> outside a <Router>'); const { history, staticContext } = context; const method = push ? history.push : history.replace; ...
javascript
{ "resource": "" }
q59103
entities
validation
function entities(state = { users: {}, repos: {} }, action) { if (action.response && action.response.entities) { return merge({}, state, action.response.entities) } return state }
javascript
{ "resource": "" }
q59104
errorMessage
validation
function errorMessage(state = null, action) { const { type, error } = action if (type === ActionTypes.RESET_ERROR_MESSAGE) { return null } else if (error) { return action.error } return state }
javascript
{ "resource": "" }
q59105
cancelMain
validation
function cancelMain() { if (mainTask.isRunning && !mainTask.isCancelled) { mainTask.isCancelled = true next(TASK_CANCEL) } }
javascript
{ "resource": "" }
q59106
currCb
validation
function currCb(res, isErr) { if (effectSettled) { return } effectSettled = true cb.cancel = noop // defensive measure if (sagaMonitor) { isErr ? sagaMonitor.effectRejected(effectId, res) : sagaMonitor.effectResolved(effectId, res) } cb(res, isErr) }
javascript
{ "resource": "" }
q59107
updateAttributes
validation
function updateAttributes(el, prevProps, props) { var propName; if (!props || prevProps === props) { return; } // Set attributes. for (propName in props) { if (!filterNonEntityPropNames(propName)) { continue; } doSetAttribute(el, props, propName); } // See if attributes were remov...
javascript
{ "resource": "" }
q59108
componentDidUpdate
validation
function componentDidUpdate(prevProps, prevState) { var el = this.el; var props = this.props; // Update events. updateEventListeners(el, prevProps.events, props.events); // Update entity. if (options.runSetAttributeOnUpdates) { updateAttributes(el, prevProps, props); ...
javascript
{ "resource": "" }
q59109
updateEventListeners
validation
function updateEventListeners(el, prevEvents, events) { var eventName; if (!prevEvents || !events || prevEvents === events) { return; } for (eventName in events) { // Didn't change. if (prevEvents[eventName] === events[eventName]) { continue; } // If changed, remove old previous eve...
javascript
{ "resource": "" }
q59110
addEventListeners
validation
function addEventListeners(el, eventName, handlers) { var handler; var i; if (!handlers) { return; } // Convert to array. if (handlers.constructor === Function) { handlers = [handlers]; } // Register. for (i = 0; i < handlers.length; i++) { el.addEventListener(eventName, handlers[i]); ...
javascript
{ "resource": "" }
q59111
removeEventListeners
validation
function removeEventListeners(el, eventName, handlers) { var handler; var i; if (!handlers) { return; } // Convert to array. if (handlers.constructor === Function) { handlers = [handlers]; } // Unregister. for (i = 0; i < handlers.length; i++) { el.removeEventListener(eventName, handler...
javascript
{ "resource": "" }
q59112
makeHooksSafe
validation
function makeHooksSafe(routes, store) { if (Array.isArray(routes)) { return routes.map(route => makeHooksSafe(route, store)); } const onEnter = routes.onEnter; if (onEnter) { routes.onEnter = function safeOnEnter(...args) { try { store.getState(); } catch (err) { if (onEnte...
javascript
{ "resource": "" }
q59113
auth
validation
function auth (req) { if (!req) { throw new TypeError('argument req is required') } if (typeof req !== 'object') { throw new TypeError('argument req is required to be an object') } // get header var header = getAuthorization(req) // parse header return parse(header) }
javascript
{ "resource": "" }
q59114
getAuthorization
validation
function getAuthorization (req) { if (!req.headers || typeof req.headers !== 'object') { throw new TypeError('argument req is required to have headers property') } return req.headers.authorization }
javascript
{ "resource": "" }
q59115
parse
validation
function parse (string) { if (typeof string !== 'string') { return undefined } // parse header var match = CREDENTIALS_REGEXP.exec(string) if (!match) { return undefined } // decode user pass var userPass = USER_PASS_REGEXP.exec(decodeBase64(match[1])) if (!userPass) { return undefined...
javascript
{ "resource": "" }
q59116
install
validation
function install(cef_version) { downloadCef(cef_version,function(err){ if(err) { util.log('Failed to add dependencies','error'); throw err; } copyDllWrapper(function(err) { if (err) { util.log('Failed to copy dll_wrapper.gyp'); throw err; } util.log('Done!...
javascript
{ "resource": "" }
q59117
download
validation
function download(url,onError) { var request = require('request'); util.log('Downloading cef tarball for '+platform+'-'+arch+'...'); var requestOpts = { uri: url, onResponse: true } // basic support for a proxy server var proxyUrl = process.env.http_proxy || pr...
javascript
{ "resource": "" }
q59118
checkGlob
validation
function checkGlob(filename, globs) { // PostCSS turns relative paths into absolute paths filename = path.relative(process.cwd(), filename); return minimatchList(filename, globs); }
javascript
{ "resource": "" }
q59119
getCORSRequest
validation
function getCORSRequest() { var xhr = new root.XMLHttpRequest(); if ('withCredentials' in xhr) { xhr.withCredentials = this.withCredentials ? true : false; return xhr; } else if (!!root.XDomainRequest) { return new XDomainRequest(); } else { throw new Error('CORS is not supported by your browser...
javascript
{ "resource": "" }
q59120
getReplyMethod
validation
function getReplyMethod(request) { let target = findTargetFromParentInfo(request); if (target) { return (...a) => { if ('isDestroyed' in target && target.isDestroyed()) return; target.send(...a); }; } else { d("Using reply to main process"); return (...a) => ipc.send(...a); } }
javascript
{ "resource": "" }
q59121
listenToIpc
validation
function listenToIpc(channel) { return Observable.create((subj) => { let listener = (event, ...args) => { d(`Got an event for ${channel}: ${JSON.stringify(args)}`); subj.next(args); }; d(`Setting up listener! ${channel}`); ipc.on(channel, listener); return new Subscription(() => ...
javascript
{ "resource": "" }
q59122
getSendMethod
validation
function getSendMethod(windowOrWebView) { if (!windowOrWebView) return (...a) => ipc.send(...a); if ('webContents' in windowOrWebView) { return (...a) => { d(`webContents send: ${JSON.stringify(a)}`); if (!windowOrWebView.webContents.isDestroyed()) { windowOrWebView.webContents.send(...a); ...
javascript
{ "resource": "" }
q59123
listenerForId
validation
function listenerForId(id, timeout) { return listenToIpc(responseChannel) .do(([x]) => d(`Got IPC! ${x.id} === ${id}; ${JSON.stringify(x)}`)) .filter(([receive]) => receive.id === id && id) .take(1) .mergeMap(([receive]) => { if (receive.error) { let e = new Error(receive.error.message);...
javascript
{ "resource": "" }
q59124
objectAndParentGivenPath
validation
function objectAndParentGivenPath(path) { let obj = global || window; let parent = obj; for (let part of path.split('.')) { parent = obj; obj = obj[part]; } d(`parent: ${parent}, obj: ${obj}`); if (typeof(parent) !== 'object') { throw new Error(`Couldn't access part of the object window.${path...
javascript
{ "resource": "" }
q59125
executeMainProcessMethod
validation
function executeMainProcessMethod(moduleName, methodChain, args) { const theModule = electron[moduleName]; const path = methodChain.join('.'); return get(theModule, path).apply(theModule, args); }
javascript
{ "resource": "" }
q59126
validation
function(str, gga) { if (gga.length !== 16) { throw new Error('Invalid GGA length: ' + str); } /* 11 1 2 3 4 5 6 7 8 9 10 | 12 13 14 15 | | | | | | | | | | | | | | | $--GGA,hhmmss.ss,llll.ll,a,yyyyy.yy,a,...
javascript
{ "resource": "" }
q59127
validation
function(str, gsa) { if (gsa.length !== 19 && gsa.length !== 20) { throw new Error('Invalid GSA length: ' + str); } /* eg1. $GPGSA,A,3,,,,,,16,18,,22,24,,,3.6,2.1,2.2*3C eg2. $GPGSA,A,3,19,28,14,18,27,22,31,39,,,,,1.7,1.0,1.3*35 1 = Mode: M=Manu...
javascript
{ "resource": "" }
q59128
validation
function(str, rmc) { if (rmc.length !== 13 && rmc.length !== 14 && rmc.length !== 15) { throw new Error('Invalid RMC length: ' + str); } /* $GPRMC,hhmmss.ss,A,llll.ll,a,yyyyy.yy,a,x.x,x.x,ddmmyy,x.x,a*hh RMC = Recommended Minimum Specific GPS/TRANSIT Data 1 =...
javascript
{ "resource": "" }
q59129
validation
function(str, gsv) { if (gsv.length % 4 % 3 === 0) { throw new Error('Invalid GSV length: ' + str); } /* $GPGSV,1,1,13,02,02,213,,03,-3,000,,11,00,121,,14,13,172,05*67 1 = Total number of messages of this type in this cycle 2 = Message number 3 = ...
javascript
{ "resource": "" }
q59130
computeIndexChunks
validation
function computeIndexChunks(buffer) { var BLOCK_SIZE = 65536; var view = new jDataView(buffer, 0, buffer.byteLength, true /* little endian */); var minBlockIndex = Infinity; var contigStartOffsets = []; view.getInt32(); // magic var n_ref = view.getInt32(); for (var j = 0; j < n_ref; j++) { contigSt...
javascript
{ "resource": "" }
q59131
validation
function (el) { var genericCloseButton; if ($(el).data('popupoptions').closebuttonmarkup) { genericCloseButton = $(options.closebuttonmarkup).addClass(el.id + '_close'); } else { genericCloseButton = '<button class="popup_close ' + el.id + '_clo...
javascript
{ "resource": "" }
q59132
validation
function (el, ordinal, func) { var options = $(el).data('popupoptions'); var openelement; var elementclicked; if (typeof options === 'undefined') return; openelement = options.openelement ? options.openelement : ('.' + el.id + opensuffix); elementclicked = $(openel...
javascript
{ "resource": "" }
q59133
validation
function (el) { var bounding = el.getBoundingClientRect(); return ( bounding.top >= 0 && bounding.left >= 0 && bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) && bounding.right <= (window.innerWidth || document.docume...
javascript
{ "resource": "" }
q59134
main
validation
function main() { var app = new App(); function intentHandler(url) { Auth0Cordova.onRedirectUri(url); } window.handleOpenURL = intentHandler; app.run('#app'); }
javascript
{ "resource": "" }
q59135
WebView
validation
function WebView() { this.tab = null; this.handler = null; this.open = this.open.bind(this); this.handleFirstLoadEnd = this.handleFirstLoadEnd.bind(this); this.handleLoadError = this.handleLoadError.bind(this); this.handleExit = this.handleExit.bind(this); this.clearEvents = this.clearEvents.bind(this); ...
javascript
{ "resource": "" }
q59136
processProps
validation
function processProps(props) { const { title, label, key, value } = props; const cloneProps = { ...props }; // Warning user not to use deprecated label prop. if (label && !title) { if (!warnDeprecatedLabel) { warning(false, "'label' in treeData is deprecated. Please use 'title' instead."); warn...
javascript
{ "resource": "" }
q59137
writeHeaders
validation
function writeHeaders(file, headers, only = null) { for (let name in headers) { let value = headers[name]; if (only && !match(name, only)) continue; if (Array.isArray(value)) for (let item of value) file.write(`${name}: ${item}\n`); else file.write(`${name}: ${value}\n`); }...
javascript
{ "resource": "" }
q59138
match
validation
function match(name, regexps){ for (let regexp of regexps) if (regexp.test(name)) return true; return false; }
javascript
{ "resource": "" }
q59139
showHelpAndDie
validation
function showHelpAndDie(message) { if (message) { console.error(message); } console.error(commander.helpInformation()); process.exit(1); }
javascript
{ "resource": "" }
q59140
robohydraHeadType
validation
function robohydraHeadType(settings) { var parentClass = settings.parentClass || RoboHydraHead; var newConstructorFunction = function(props) { if (!props && settings.defaultProps) { deprecationWarning("deprecated 'defaultProps', please use 'defaultPropertyObject' instead"); prop...
javascript
{ "resource": "" }
q59141
proxyRequest
validation
function proxyRequest(req, res, proxyTo, opts) { opts = opts || {}; var httpRequestFunction = opts.httpRequestFunction || http.request; var httpsRequestFunction = opts.httpsRequestFunction || https.request; var setHostHeader = opts.setHostHeader; var proxyUrl = proxyTo; ...
javascript
{ "resource": "" }
q59142
BigIq50LicenseProvider
validation
function BigIq50LicenseProvider(bigIp, options) { const injectedLogger = options ? options.logger : undefined; let loggerOptions = options ? options.loggerOptions : undefined; if (injectedLogger) { this.logger = injectedLogger; util.setLogger(injectedLogger); } else { loggerOpti...
javascript
{ "resource": "" }
q59143
listPrivateKey
validation
function listPrivateKey(keyType, folder, name, noRetry) { let privateKeyName; // Try with .key suffix first. If unsuccessful, retry without the .key suffix if (noRetry) { // If present, remove '.key' suffix privateKeyName = name.replace(REG_EXPS.KEY_SUFFIX, ''); } else { // Appe...
javascript
{ "resource": "" }
q59144
createTrafficGroup
validation
function createTrafficGroup(bigIp, trafficGroup) { let createGroup = true; bigIp.list('/tm/cm/traffic-group') .then((response) => { response.forEach((group) => { if (group.name === trafficGroup) { createGroup = false; ...
javascript
{ "resource": "" }
q59145
becomeMaster
validation
function becomeMaster(provider, bigIp, options) { let hasUcs = false; logger.info('Becoming master.'); logger.info('Checking for backup UCS.'); return provider.getStoredUcs() .then((response) => { if (response) { hasUcs = true; ...
javascript
{ "resource": "" }
q59146
getAutoscaleProcessCount
validation
function getAutoscaleProcessCount() { const actions = 'cluster-action update|-c update|cluster-action join|-c join'; const grepCommand = `grep autoscale.js | grep -E '${actions}' | grep -v 'grep autoscale.js'`; return util.getProcessCount(grepCommand) .then((response) => { ...
javascript
{ "resource": "" }
q59147
initEncryption
validation
function initEncryption(provider, bigIp) { const PRIVATE_KEY_OUT_FILE = '/tmp/tempPrivateKey.pem'; let passphrase; if (provider.hasFeature(CloudProvider.FEATURE_ENCRYPTION)) { logger.debug('Generating public/private keys for autoscaling.'); return cryptoUtil.generateRan...
javascript
{ "resource": "" }
q59148
getMasterInstance
validation
function getMasterInstance(instances) { let instanceId; const instanceIds = Object.keys(instances); for (let i = 0; i < instanceIds.length; i++) { instanceId = instanceIds[i]; if (instances[instanceId].isMaster) { return { id: instance...
javascript
{ "resource": "" }
q59149
markVersions
validation
function markVersions(instances) { let highestVersion = '0.0.0'; let instance; Object.keys(instances).forEach((instanceId) => { instance = instances[instanceId]; if (instance.version && util.versionCompare(instance.version, highestVersion) > 0) { highestV...
javascript
{ "resource": "" }
q59150
isMasterExternalValueOk
validation
function isMasterExternalValueOk(masterId, instances) { const instanceIds = Object.keys(instances); let instance; let hasExternal; for (let i = 0; i < instanceIds.length; i++) { instance = instances[instanceIds[i]]; if (instance.external) { hasExt...
javascript
{ "resource": "" }
q59151
getDataFromPropPath
validation
function getDataFromPropPath(pathArray, obj) { if (pathArray.length === 0) { return undefined; } return pathArray.reduce((result, prop) => { if (typeof result !== 'object' || result === null) { return {}; } if (prop === '') { return result; } ...
javascript
{ "resource": "" }
q59152
checkTask
validation
function checkTask(taskPath, taskIdToCheck, options) { const func = function () { const deferred = q.defer(); this.list(`${taskPath}/${taskIdToCheck}`, undefined, util.NO_RETRY) .then((response) => { const statusAttribute = (options && options.statusAttribute) ...
javascript
{ "resource": "" }
q59153
BigIq54LicenseProvider
validation
function BigIq54LicenseProvider(bigIp, options) { const injectedLogger = options ? options.logger : undefined; let loggerOptions = options ? options.loggerOptions : undefined; this.constructorOptions = {}; if (options) { Object.keys(options).forEach((option) => { this.constructorOpt...
javascript
{ "resource": "" }
q59154
encrypt
validation
function encrypt(publicKeyDataOrFile, data) { const deferred = q.defer(); let publicKeyPromise; const getPublicKey = function getPublicKey(publicKeyFile) { const publicKeyDeferred = q.defer(); fs.readFile(publicKeyFile, (err, publicKey) => { if (err) { ...
javascript
{ "resource": "" }
q59155
getLabel
validation
function getLabel(logLevel, moduleLogging, verboseLabel) { let parts; let label = ''; if (moduleLogging) { if (logLevel === 'debug' || logLevel === 'silly' || verboseLabel) { parts = moduleLogging.filename.split('/'); label = `${parts[parts.length - 2]}/${parts.pop()}`; ...
javascript
{ "resource": "" }
q59156
getLicenseProvider
validation
function getLicenseProvider(poolName, options) { const methodOptions = {}; Object.assign(methodOptions, options); const factoryOptions = {}; Object.assign(factoryOptions, this.constructorOptions); let licenseProvider; if (methodOptions.autoApiType) { return getApiType.call(this, poolNa...
javascript
{ "resource": "" }
q59157
forceResetUserPassword
validation
function forceResetUserPassword(user) { const deferred = q.defer(); cryptoUtil.generateRandomBytes(24, 'hex') .then((randomBytes) => { util.runShellCommand(`echo -e "${randomBytes}\n${randomBytes}" | passwd ${user}`); deferred.resolve(randomBytes); }) .catch((err...
javascript
{ "resource": "" }
q59158
jscoverage_endLengthyOperation
validation
function jscoverage_endLengthyOperation() { var progressBar = document.getElementById('progressBar'); ProgressBar.setPercentage(progressBar, 100); setTimeout(function() { jscoverage_inLengthyOperation = false; progressBar.style.visibility = 'hidden'; var progressLabel = document.getElementById('...
javascript
{ "resource": "" }
q59159
jscoverage_initTabContents
validation
function jscoverage_initTabContents(queryString) { var showMissingColumn = false; var url = null; var windowURL = null; var parameters, parameter, i, index, name, value; if (queryString.length > 0) { // chop off the question mark queryString = queryString.substring(1); parameters = querySt...
javascript
{ "resource": "" }
q59160
jscoverage_recalculateSourceTab
validation
function jscoverage_recalculateSourceTab() { if (! jscoverage_currentFile) { jscoverage_endLengthyOperation(); return; } var progressLabel = document.getElementById('progressLabel'); progressLabel.innerHTML = 'Calculating coverage ...'; var progressBar = document.getElementById('progressBar'); ...
javascript
{ "resource": "" }
q59161
jscoverage_selectTab
validation
function jscoverage_selectTab(tab) { if (typeof tab !== 'number') { tab = jscoverage_tabIndexOf(tab); } var tabs = document.getElementById('tabs'); var tabPages = document.getElementById('tabPages'); var nodeList; var tabNum; var i; var node; nodeList = tabs.childNodes; tabNum = 0; ...
javascript
{ "resource": "" }
q59162
compareAscending
validation
function compareAscending(a, b) { var ac = a.criteria, bc = b.criteria; // ensure a stable sort in V8 and other engines // http://code.google.com/p/v8/issues/detail?id=90 if (ac !== bc) { if (ac > bc || typeof ac == 'undefined') { return 1; } if (ac < bc || typeof bc =...
javascript
{ "resource": "" }
q59163
baseFlatten
validation
function baseFlatten(array, isShallow, isArgArrays, fromIndex) { var index = (fromIndex || 0) - 1, length = array ? array.length : 0, result = []; while (++index < length) { var value = array[index]; if (value && typeof value == 'object' && typeof value.length == 'numbe...
javascript
{ "resource": "" }
q59164
pluck
validation
function pluck(collection, property) { var index = -1, length = collection ? collection.length : 0; if (typeof length == 'number') { var result = Array(length); while (++index < length) { result[index] = collection[index][property]; } } return result ...
javascript
{ "resource": "" }
q59165
reduceRight
validation
function reduceRight(collection, callback, accumulator, thisArg) { var noaccum = arguments.length < 3; callback = baseCreateCallback(callback, thisArg, 4); forEachRight(collection, function(value, index, collection) { accumulator = noaccum ? (noaccum = false, value) : callb...
javascript
{ "resource": "" }
q59166
sample
validation
function sample(collection, n, guard) { var length = collection ? collection.length : 0; if (typeof length != 'number') { collection = values(collection); } if (n == null || guard) { return collection ? collection[random(length - 1)] : undefined; } var result = shuffl...
javascript
{ "resource": "" }
q59167
bind
validation
function bind(func, thisArg) { return arguments.length > 2 ? createBound(func, 17, nativeSlice.call(arguments, 2), null, thisArg) : createBound(func, 1, null, null, thisArg); }
javascript
{ "resource": "" }
q59168
bindAll
validation
function bindAll(object) { var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object), index = -1, length = funcs.length; while (++index < length) { var key = funcs[index]; object[key] = createBound(object[key], 1, null, null, object); ...
javascript
{ "resource": "" }
q59169
curry
validation
function curry(func, arity) { arity = typeof arity == 'number' ? arity : (+arity || func.length); return createBound(func, 4, null, null, null, arity); }
javascript
{ "resource": "" }
q59170
wrap
validation
function wrap(value, wrapper) { if (!isFunction(wrapper)) { throw new TypeError; } return function() { var args = [value]; push.apply(args, arguments); return wrapper.apply(this, args); }; }
javascript
{ "resource": "" }
q59171
mixin
validation
function mixin(object, source) { var ctor = object, isFunc = !source || isFunction(ctor); if (!source) { ctor = lodashWrapper; source = object; object = lodash; } forEach(functions(source), function(methodName) { var func = object[methodName] = source[m...
javascript
{ "resource": "" }
q59172
validation
function() { var target = arguments[0]; for (var i = 1, l = arguments.length; i < l; i++) { var extension = arguments[i]; // Only functions and objects can be mixined. if ((Object(extensi...
javascript
{ "resource": "" }
q59173
validation
function(args) { return _.template('<filter><feGaussianBlur in="SourceAlpha" stdDeviation="${blur}"/><feOffset dx="${dx}" dy="${dy}" result="offsetblur"/><feFlood flood-color="${color}"/><feComposite in2="offsetblur" operator="in"/><feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/...
javascript
{ "resource": "" }
q59174
validation
function(args) { var amount = _.isFinite(args.amount) ? args.amount : 1; return _.template('<filter><feColorMatrix type="matrix" values="${a} ${b} ${c} 0 0 ${d} ${e} ${f} 0 0 ${g} ${b} ${h} 0 0 0 0 0 1 0"/></filter>', { a: 0.2126 + 0.7874 * (1 - amou...
javascript
{ "resource": "" }
q59175
validation
function(args) { var amount = _.isFinite(args.amount) ? args.amount : 1; return _.template('<filter><feColorMatrix type="saturate" values="${amount}"/></filter>', { amount: 1 - amount }); }
javascript
{ "resource": "" }
q59176
validation
function(sx, sy) { sy = (typeof sy === 'undefined') ? sx : sy; var transformAttr = this.attr('transform') || '', transform = parseTransformString(transformAttr); // Is it a getter? if (typeof sx === 'undefined') { return trans...
javascript
{ "resource": "" }
q59177
validation
function(withoutTransformations, target) { // If the element is not in the live DOM, it does not have a bounding box defined and // so fall back to 'zero' dimension element. if (!this.node.ownerSVGElement) return { x: 0, y: 0, width: 0, height: 0 }; var box;...
javascript
{ "resource": "" }
q59178
validation
function(x, y) { var svg = this.svg().node; var p = svg.createSVGPoint(); p.x = x; p.y = y; try { var globalPoint = p.matrixTransform(svg.getScreenCTM().inverse()); var globalToLocalMatrix = this.node.getTransformToElement(svg).inverse(); } ...
javascript
{ "resource": "" }
q59179
validation
function(o) { o = (o && point(o)) || point(0,0); var x = this.x; var y = this.y; this.x = sqrt((x-o.x)*(x-o.x) + (y-o.y)*(y-o.y)); // r this.y = toRad(o.theta(point(x,y))); return this; }
javascript
{ "resource": "" }
q59180
validation
function(o, angle) { angle = (angle + 360) % 360; this.toPolar(o); this.y += toRad(angle); var p = point.fromPolar(this.x, this.y, o); this.x = p.x; this.y = p.y; return this; }
javascript
{ "resource": "" }
q59181
validation
function(ref, distance) { var theta = toRad(point(ref).theta(this)); return this.offset(cos(theta) * distance, -sin(theta) * distance); }
javascript
{ "resource": "" }
q59182
validation
function(p, angle) { p = point(p); var center = point(this.x + this.width/2, this.y + this.height/2); var result; if (angle) p.rotate(center, angle); // (clockwise, starting from the top side) var sides = [ line(this.origin(), this.topRight()), ...
javascript
{ "resource": "" }
q59183
validation
function(r) { this.x += r.x; this.y += r.y; this.width += r.width; this.height += r.height; return this; }
javascript
{ "resource": "" }
q59184
validation
function(p, angle) { p = point(p); if (angle) p.rotate(point(this.x, this.y), angle); var dx = p.x - this.x; var dy = p.y - this.y; var result; if (dx === 0) { result = this.bbox().pointNearestToPoint(p); if (angle) return result.rotate(point(t...
javascript
{ "resource": "" }
q59185
validation
function(knots) { var firstControlPoints = []; var secondControlPoints = []; var n = knots.length - 1; var i; // Special case: Bezier curve should be a straight line. if (n == 1) { // 3P1 = 2P0 + P3 firstControlPoints[0] = point...
javascript
{ "resource": "" }
q59186
validation
function(model, opt) { opt = opt || {}; if (_.isUndefined(opt.inbound) && _.isUndefined(opt.outbound)) { opt.inbound = opt.outbound = true; } var links = []; this.each(function(cell) { var source = cell.get('source'); var target = ...
javascript
{ "resource": "" }
q59187
validation
function(model) { _.each(this.getConnectedLinks(model), function(link) { link.set(link.get('source').id === model.id ? 'source' : 'target', g.point(0, 0)); }); }
javascript
{ "resource": "" }
q59188
validation
function(attrs, value, opt) { var currentAttrs = this.get('attrs'); var delim = '/'; if (_.isString(attrs)) { // Get/set an attribute by a special path syntax that delimits // nested objects by the colon character. if (value) { var ...
javascript
{ "resource": "" }
q59189
validation
function(el) { var $el = this.$(el); if ($el.length === 0 || $el[0] === this.el) { // If the overall cell has set `magnet === false`, then return `undefined` to // announce there is no magnet found for this cell. // This is especially useful to set on cells that ha...
javascript
{ "resource": "" }
q59190
validation
function(el, selector) { if (el === this.el) { return selector; } var index = $(el).index(); selector = el.tagName + ':nth-child(' + (index + 1) + ')' + ' ' + (selector || ''); return this.getSelector($(el).parent()[0], selector + ' '); }
javascript
{ "resource": "" }
q59191
validation
function() { var markup = this.model.markup || this.model.get('markup'); if (markup) { var nodes = V(markup); V(this.el).append(nodes); } else { throw new Error('properties.markup is missing while the default render() implementation is...
javascript
{ "resource": "" }
q59192
validation
function(idx, value) { idx = idx || 0; var labels = this.get('labels') || []; // Is it a getter? if (arguments.length === 0 || arguments.length === 1) { return labels[idx]; } var newValue = _.merge({}, labels[idx], value); ...
javascript
{ "resource": "" }
q59193
validation
function(endType) { function watchEnd(link, end) { end = end || {}; var previousEnd = link.previous(endType) || {}; // Pick updateMethod this._sourceBboxUpdate or this._targetBboxUpdate. var updateEndFunction = this['_' + endType + 'BBoxUpdate']; ...
javascript
{ "resource": "" }
q59194
validation
function(vertex) { this.model.set('attrs', this.model.get('attrs') || {}); var attrs = this.model.get('attrs'); // As it is very hard to find a correct index of the newly created vertex, // a little heuristics is taking place here. // The heuristics checks if length of ...
javascript
{ "resource": "" }
q59195
findMiddleVertex
validation
function findMiddleVertex(p1, p2, preferredDirection) { var direction = bestDirection(p1, p2, preferredDirection); if (direction === 'down' || direction === 'up') { return { x: p1.x, y: p2.y, d: direction }; } return { x: p2.x, y: p1.y, d: dir...
javascript
{ "resource": "" }
q59196
validation
function(cell) { var id = _.isString(cell) ? cell : cell.id; var $view = this.$('[model-id="' + id + '"]'); if ($view.length) { return $view.data('view'); } return undefined; }
javascript
{ "resource": "" }
q59197
validation
function(p) { p = g.point(p); var views = _.map(this.model.getElements(), this.findViewByModel); return _.filter(views, function(view) { return g.rect(V(view.el).bbox(false, this.viewport)).containsPoint(p); }, this); }
javascript
{ "resource": "" }
q59198
validation
function(r) { r = g.rect(r); var views = _.map(this.model.getElements(), this.findViewByModel); return _.filter(views, function(view) { return r.intersect(g.rect(V(view.el).bbox(false, this.viewport))); }, this); }
javascript
{ "resource": "" }
q59199
validation
function(command) { return _.isArray(command) ? _.find(command, function(singleCmd) { return !this._validateCommand(singleCmd); }, this) : this._validateCommand(command); }
javascript
{ "resource": "" }