_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q22100
onMouseUp
train
function onMouseUp(e) { // Cancel the timeout preventing the click event from triggering clearTimeout(preventClickTimeout); let eventType = EVENTS.MOUSE_UP; if (isClickEvent) { eventType = EVENTS.MOUSE_CLICK; } // Calculate our current points in page and image coordinates const curr...
javascript
{ "resource": "" }
q22101
removeFromList
train
function removeFromList(imageIdIndex) { const index = stackPrefetch.indicesToRequest.indexOf(imageIdIndex); if (index > -1) { // Don't remove last element if imageIdIndex not found stackPrefetch.indicesToRequest.splice(index, 1); } }
javascript
{ "resource": "" }
q22102
clearImageIdSpecificToolStateManager
train
function clearImageIdSpecificToolStateManager(element) { const enabledElement = external.cornerstone.getEnabledElement(element); if ( !enabledElement.image || toolState.hasOwnProperty(enabledElement.image.imageId) === false ) { return; } delete toolState[enabledElement.image.imag...
javascript
{ "resource": "" }
q22103
stopClip
train
function stopClip(element) { const playClipToolData = getToolState(element, toolType); if ( !playClipToolData || !playClipToolData.data || !playClipToolData.data.length ) { return; } stopClipWithData(playClipToolData.data[0]); }
javascript
{ "resource": "" }
q22104
removeEnabledElementCallback
train
function removeEnabledElementCallback(enabledElement) { if (!external.cornerstone) { return; } const cornerstoneEnabledElement = external.cornerstone.getEnabledElement( enabledElement ); const enabledElementUID = cornerstoneEnabledElement.uuid; const colormap = external.cornerstone.colors.getColor...
javascript
{ "resource": "" }
q22105
_getNextColorPair
train
function _getNextColorPair() { const indexPair = [colorPairIndex]; if (colorPairIndex < distinctColors.length - 1) { colorPairIndex++; indexPair.push(colorPairIndex); } else { colorPairIndex = 0; indexPair.push(colorPairIndex); } return indexPair; }
javascript
{ "resource": "" }
q22106
train
function(enabledElement) { // Note: We may want to `setToolDisabled` before removing from store // Or take other action to remove any lingering eventListeners/state store.state.tools = store.state.tools.filter( tool => tool.element !== enabledElement ); }
javascript
{ "resource": "" }
q22107
train
function(enabledElement) { if (store.modules) { _cleanModulesOnElement(enabledElement); } const foundElementIndex = store.state.enabledElements.findIndex( element => element === enabledElement ); if (foundElementIndex > -1) { store.state.enabledElements.splice(foundElementIndex, 1); } else { ...
javascript
{ "resource": "" }
q22108
_cleanModulesOnElement
train
function _cleanModulesOnElement(enabledElement) { const modules = store.modules; Object.keys(modules).forEach(function(key) { if (typeof modules[key].removeEnabledElementCallback === 'function') { modules[key].removeEnabledElementCallback(enabledElement); } }); }
javascript
{ "resource": "" }
q22109
_drawImageBitmap
train
function _drawImageBitmap(evt, imageBitmap, alwaysVisible) { const eventData = evt.detail; const context = getNewContext(eventData.canvasContext.canvas); const canvasTopLeft = external.cornerstone.pixelToCanvas(eventData.element, { x: 0, y: 0, }); const canvasTopRight = external.cornerstone.pixelToC...
javascript
{ "resource": "" }
q22110
getDefaultFreehandSculpterMouseToolConfiguration
train
function getDefaultFreehandSculpterMouseToolConfiguration() { return { mouseLocation: { handles: { start: { highlight: true, active: true, }, }, }, minSpacing: 1, currentTool: null, dragColor: toolColors.getActiveColor(), hoverColor: toolColors.g...
javascript
{ "resource": "" }
q22111
setToolCursor
train
function setToolCursor(element, svgCursor) { if (!globalConfiguration.state.showSVGCursors) { return; } // TODO: (state vs options) Exit if cursor wasn't updated // TODO: Exit if invalid options to create cursor // Note: Max size of an SVG cursor is 128x128, default is 32x32. const cursorBlob = svgCurs...
javascript
{ "resource": "" }
q22112
_getEllipseImageCoordinates
train
function _getEllipseImageCoordinates(startHandle, endHandle) { return { left: Math.round(Math.min(startHandle.x, endHandle.x)), top: Math.round(Math.min(startHandle.y, endHandle.y)), width: Math.round(Math.abs(startHandle.x - endHandle.x)), height: Math.round(Math.abs(startHandle.y - endHandle.y)), ...
javascript
{ "resource": "" }
q22113
train
function(enabledElement) { store.state.enabledElements.push(enabledElement); if (store.modules) { _initModulesOnElement(enabledElement); } _addGlobalToolsToElement(enabledElement); _repeatGlobalToolHistory(enabledElement); }
javascript
{ "resource": "" }
q22114
_initModulesOnElement
train
function _initModulesOnElement(enabledElement) { const modules = store.modules; Object.keys(modules).forEach(function(key) { if (typeof modules[key].enabledElementCallback === 'function') { modules[key].enabledElementCallback(enabledElement); } }); }
javascript
{ "resource": "" }
q22115
_addGlobalToolsToElement
train
function _addGlobalToolsToElement(enabledElement) { if (!store.modules.globalConfiguration.state.globalToolSyncEnabled) { return; } Object.keys(store.state.globalTools).forEach(function(key) { const { tool, configuration } = store.state.globalTools[key]; addToolForElement(enabledElement, tool, confi...
javascript
{ "resource": "" }
q22116
_repeatGlobalToolHistory
train
function _repeatGlobalToolHistory(enabledElement) { if (!store.modules.globalConfiguration.state.globalToolSyncEnabled) { return; } const setToolModeFns = { active: setToolActiveForElement, passive: setToolPassiveForElement, enabled: setToolEnabledForElement, disabled: setToolDisabledForEleme...
javascript
{ "resource": "" }
q22117
fireEvent
train
function fireEvent(sourceElement, eventData) { const isDisabled = !that.enabled; const noElements = !sourceElements.length || !targetElements.length; if (isDisabled || noElements) { return; } ignoreFiredEvents = true; targetElements.forEach(function(targetElement) { const targetInd...
javascript
{ "resource": "" }
q22118
onEvent
train
function onEvent(e) { const eventData = e.detail; if (ignoreFiredEvents === true) { return; } fireEvent(e.currentTarget, eventData); }
javascript
{ "resource": "" }
q22119
disableHandler
train
function disableHandler(e) { const element = e.detail.element; that.remove(element); clearToolOptionsByElement(element); }
javascript
{ "resource": "" }
q22120
createVisualization
train
function createVisualization(data) { var json = buildHierarchy(data); // Basic setup of page elements. initializeBreadcrumbTrail(); // Bounding circle underneath the sunburst, to make it easier to detect // when the mouse leaves the parent g. vis.append("svg:circle") .attr("r", radius) .style(...
javascript
{ "resource": "" }
q22121
mouseover
train
function mouseover(d) { var percentage = (100 * d.value / totalSize).toPrecision(3); var percentageString = percentage + "%"; if (percentage < 0.1) { percentageString = "< 0.1%"; } d3.select("#percentage") .text(percentageString); d3.select("#explanation") .style("visibility", ""); var...
javascript
{ "resource": "" }
q22122
mouseleave
train
function mouseleave(d) { // Hide the breadcrumb trail d3.select("#trail") .style("visibility", "hidden"); // Deactivate all segments during transition. d3.selectAll("path").on("mouseover", null); // Transition each segment to full opacity and then reactivate it. d3.selectAll("path") .transiti...
javascript
{ "resource": "" }
q22123
getAncestors
train
function getAncestors(node) { var path = []; var current = node; while (current.parent) { path.unshift(current); current = current.parent; } return path; }
javascript
{ "resource": "" }
q22124
breadcrumbPoints
train
function breadcrumbPoints(d, i) { var points = []; points.push("0,0"); points.push(b.w + ",0"); points.push(b.w + b.t + "," + (b.h / 2)); points.push(b.w + "," + b.h); points.push("0," + b.h); if (i > 0) { // Leftmost breadcrumb; don't include 6th vertex. points.push(b.t + "," + (b.h / 2)); } retu...
javascript
{ "resource": "" }
q22125
updateBreadcrumbs
train
function updateBreadcrumbs(nodeArray, percentageString) { // Data join; key function combines name and depth (= position in sequence). var g = d3.select("#trail") .selectAll("g") .data(nodeArray, function(d) { return d.name + d.depth; }); // Add breadcrumb and label for entering nodes. var enterin...
javascript
{ "resource": "" }
q22126
buildHierarchy
train
function buildHierarchy(csv) { var root = {"name": "root", "children": []}; for (var i = 0; i < csv.length; i++) { var sequence = csv[i][0]; var size = +csv[i][1]; if (isNaN(size)) { // e.g. if this is a header row continue; } var parts = sequence.split("/"); var currentNode = root; ...
javascript
{ "resource": "" }
q22127
queryResource
train
function queryResource (req, res, next, dataStore) { let resource = new Resource(req.path); dataStore.get(resource, (err, result) => { if (err) { next(err); } else if (!result) { let defaultValue = getDefaultValue(res); if (defaultValue === undefined) { util.debug("ERROR! 404...
javascript
{ "resource": "" }
q22128
createMiddleware
train
function createMiddleware (swagger, router, callback) { // Shift args if needed if (util.isExpressRouter(swagger)) { router = swagger; swagger = callback = undefined; } else if (!util.isExpressRouter(router)) { callback = router; router = undefined; } let middleware = new module.exports.Mid...
javascript
{ "resource": "" }
q22129
mergeResource
train
function mergeResource (req, res, next, dataStore) { let resource = createResource(req); // Save/Update the resource util.debug("Saving data at %s", resource.toString()); dataStore.save(resource, sendResponse(req, res, next, dataStore)); }
javascript
{ "resource": "" }
q22130
overwriteResource
train
function overwriteResource (req, res, next, dataStore) { let resource = createResource(req); // Delete the existing resource, if any dataStore.delete(resource, (err) => { if (err) { next(err); } else { // Save the new resource util.debug("Saving data at %s", resource.toString()); ...
javascript
{ "resource": "" }
q22131
deleteResource
train
function deleteResource (req, res, next, dataStore) { // jshint ignore:line let resource = createResource(req); // Delete the resource dataStore.delete(resource, (err, deletedResource) => { // Respond with the deleted resource, if possible; otherwise, use the empty resource we just created. sendResponse(...
javascript
{ "resource": "" }
q22132
Middleware
train
function Middleware (sharedRouter) { sharedRouter = util.isExpressRouter(sharedRouter) ? sharedRouter : undefined; let self = this; let context = new MiddlewareContext(sharedRouter); /** * Initializes the middleware with the given Swagger API. * This method can be called again to re-initialize with a ne...
javascript
{ "resource": "" }
q22133
Resource
train
function Resource (path, name, data) { switch (arguments.length) { case 0: this.collection = ""; this.name = "/"; this.data = undefined; break; case 1: this.collection = getCollectionFromPath(path); this.name = getNameFromPath(path); this.data = undefined; break...
javascript
{ "resource": "" }
q22134
getCollectionFromPath
train
function getCollectionFromPath (path) { path = _(path).toString(); let lastSlash = path.substring(0, path.length - 1).lastIndexOf("/"); if (lastSlash === -1) { return ""; } else { return normalizeCollection(path.substring(0, lastSlash)); } }
javascript
{ "resource": "" }
q22135
getNameFromPath
train
function getNameFromPath (path) { path = _(path).toString(); let lastSlash = path.substring(0, path.length - 1).lastIndexOf("/"); if (lastSlash === -1) { return normalizeName(path); } else { return normalizeName(path.substring(lastSlash)); } }
javascript
{ "resource": "" }
q22136
normalizeCollection
train
function normalizeCollection (collection) { // Normalize the root path as an empty string collection = _(collection).toString(); if (_.isEmpty(collection) || collection === "/" || collection === "//") { return ""; } // Add a leading slash if (!_.startsWith(collection, "/")) { collection = "/" + col...
javascript
{ "resource": "" }
q22137
normalizeName
train
function normalizeName (name) { // Normalize directories as a single slash name = _(name).toString(); if (_.isEmpty(name) || name === "/" || name === "//") { return "/"; } // Add a leading slash if (!_.startsWith(name, "/")) { name = "/" + name; } // Don't allow slashes in the middle if (_.i...
javascript
{ "resource": "" }
q22138
save
train
function save (dataStore, collectionName, resources, callback) { // Open the data store dataStore.__openDataStore(collectionName, (err, existingResources) => { if (err) { return callback(err); } resources.forEach((resource) => { // Set the timestamp properties let now = Date.now(); ...
javascript
{ "resource": "" }
q22139
remove
train
function remove (dataStore, collectionName, resources, callback) { // Open the data store dataStore.__openDataStore(collectionName, (err, existingResources) => { if (err) { return callback(err); } // Remove the resources from the existing resources let removedResources = []; resources.for...
javascript
{ "resource": "" }
q22140
openCollection
train
function openCollection (dataStore, collection, callback) { if (_.isString(collection)) { collection = new Resource(collection, "", ""); } else if (!(collection instanceof Resource)) { throw ono("Expected a string or Resource object. Got a %s instead.", typeof (collection)); } // Normalize the collec...
javascript
{ "resource": "" }
q22141
doCallback
train
function doCallback (callback, err, arg) { if (_.isFunction(callback)) { callback(err, arg); } }
javascript
{ "resource": "" }
q22142
parseSimpleParams
train
function parseSimpleParams (req, res, next) { let params = getParams(req); if (params.length > 0) { util.debug("Parsing %d request parameters...", params.length); params.forEach((param) => { // Get the raw value of the parameter switch (param.in) { case "query": util.debug(' ...
javascript
{ "resource": "" }
q22143
parseFormDataParams
train
function parseFormDataParams (req, res, next) { getParams(req).forEach((param) => { if (param.in === "formData") { util.debug(' Parsing the "%s" form-data parameter', param.name); if (param.type === "file") { // Validate the file (min/max size, etc.) req.files[param.name] = parsePa...
javascript
{ "resource": "" }
q22144
parseBodyParam
train
function parseBodyParam (req, res, next) { let params = getParams(req); params.some((param) => { if (param.in === "body") { util.debug(' Parsing the "%s" body parameter', param.name); if (_.isPlainObject(req.body) && _.isEmpty(req.body)) { if (param.type === "string" || (param.schema &&...
javascript
{ "resource": "" }
q22145
parseParameter
train
function parseParameter (param, value, schema) { if (value === undefined) { if (param.required) { // The parameter is required, but was not provided, so throw a 400 error let errCode = 400; if (param.in === "header" && param.name.toLowerCase() === "content-length") { // Special case for...
javascript
{ "resource": "" }
q22146
getParams
train
function getParams (req) { if (req.swagger && req.swagger.params) { return req.swagger.params; } return []; }
javascript
{ "resource": "" }
q22147
getDirectory
train
function getDirectory (baseDir, collection) { let dir = collection.substring(0, collection.lastIndexOf("/")); dir = dir.toLowerCase(); return path.normalize(path.join(baseDir, dir)); }
javascript
{ "resource": "" }
q22148
getFilePath
train
function getFilePath (baseDir, collection) { let directory = getDirectory(baseDir, collection); let fileName = collection.substring(collection.lastIndexOf("/") + 1) + ".json"; fileName = fileName.toLowerCase(); return path.join(directory, fileName); }
javascript
{ "resource": "" }
q22149
requestValidator
train
function requestValidator (context) { return [http500, http401, http404, http405, http406, http413, http415]; /** * Throws an HTTP 500 error if the Swagger API is invalid. * Calling {@link Middleware#init} again with a valid Swagger API will clear the error. */ function http500 (req, res, next) { if...
javascript
{ "resource": "" }
q22150
queryCollection
train
function queryCollection (req, res, next, dataStore) { dataStore.getCollection(req.path, (err, resources) => { if (!err) { resources = filter(resources, req); if (resources.length === 0) { // There is no data, so use the current date/time as the "last-modified" header res.swagger.last...
javascript
{ "resource": "" }
q22151
deleteCollection
train
function deleteCollection (req, res, next, dataStore) { dataStore.getCollection(req.path, (err, resources) => { if (err) { next(err); } else { // Determine which resources to delete, based on query params let resourcesToDelete = filter(resources, req); if (resourcesToDelete.length...
javascript
{ "resource": "" }
q22152
sendResponse
train
function sendResponse (err, resources) { // Extract the "data" of each Resource resources = _.map(resources, "data"); // Use the current date/time as the "last-modified" header res.swagger.lastModified = new Date(); // Set the response body (unless it's already been set by other middleware) if...
javascript
{ "resource": "" }
q22153
setDeepProperty
train
function setDeepProperty (obj, propName, propValue) { propName = propName.split("."); for (let i = 0; i < propName.length - 1; i++) { obj = obj[propName[i]] = obj[propName[i]] || {}; } obj[propName[propName.length - 1]] = propValue; }
javascript
{ "resource": "" }
q22154
swaggerApiMetadata
train
function swaggerApiMetadata (req, res, next) { // Only set req.swagger.api if the request is under the API's basePath if (context.api) { let basePath = util.normalizePath(context.api.basePath, router); let reqPath = util.normalizePath(req.path, router); if (_.startsWith(reqPath, basePath)) { ...
javascript
{ "resource": "" }
q22155
swaggerPathMetadata
train
function swaggerPathMetadata (req, res, next) { if (req.swagger.api) { let relPath = getRelativePath(req); let relPathNormalized = util.normalizePath(relPath, router); // Search for a matching path Object.keys(req.swagger.api.paths).some((swaggerPath) => { let swaggerPathNormalized ...
javascript
{ "resource": "" }
q22156
swaggerMetadata
train
function swaggerMetadata (req, res, next) { /** * The Swagger Metadata that is added to each HTTP request. * This object is exposed as `req.swagger`. * * @name Request#swagger */ req.swagger = { /** * The complete Swagger API object. * (see https://github.com/swagger-api/swagger-spec/bl...
javascript
{ "resource": "" }
q22157
swaggerOperationMetadata
train
function swaggerOperationMetadata (req, res, next) { if (req.swagger.path) { let method = req.method.toLowerCase(); if (method in req.swagger.path) { req.swagger.operation = req.swagger.path[method]; } else { util.warn("WARNING! Unable to find a Swagger operation that matches %s %s", req....
javascript
{ "resource": "" }
q22158
swaggerParamsMetadata
train
function swaggerParamsMetadata (req, res, next) { req.swagger.params = util.getParameters(req.swagger.path, req.swagger.operation); next(); }
javascript
{ "resource": "" }
q22159
swaggerSecurityMetadata
train
function swaggerSecurityMetadata (req, res, next) { if (req.swagger.operation) { // Get the security requirements for this operation (or the global API security) req.swagger.security = req.swagger.operation.security || req.swagger.api.security || []; } else if (req.swagger.api) { // Get the global sec...
javascript
{ "resource": "" }
q22160
getRelativePath
train
function getRelativePath (req) { if (!req.swagger.api.basePath) { return req.path; } else { return req.path.substr(req.swagger.api.basePath.length); } }
javascript
{ "resource": "" }
q22161
pathMatches
train
function pathMatches (path, swaggerPath) { // Convert the Swagger path to a RegExp let pathPattern = swaggerPath.replace(util.swaggerParamRegExp, (match, paramName) => { return "([^/]+)"; }); // NOTE: This checks for an EXACT, case-sensitive match let pathRegExp = new RegExp("^" + pathPattern + "$"); ...
javascript
{ "resource": "" }
q22162
corsHeaders
train
function corsHeaders (req, res, next) { // Get the default CORS response headers as specified in the Swagger API let responseHeaders = getResponseHeaders(req); // Set each CORS header _.each(accessControl, (header) => { if (responseHeaders[header] !== undefined) { // Set the header to the default val...
javascript
{ "resource": "" }
q22163
corsPreflight
train
function corsPreflight (req, res, next) { if (req.method === "OPTIONS") { util.debug("OPTIONS %s is a CORS preflight request. Sending HTTP 200 response.", req.path); res.send(); } else { next(); } }
javascript
{ "resource": "" }
q22164
getResponseHeaders
train
function getResponseHeaders (req) { let corsHeaders = {}; if (req.swagger) { let headers = []; if (req.method !== "OPTIONS") { // This isn't a preflight request, so the operation's response headers take precedence over the OPTIONS headers headers = getOperationResponseHeaders(req.swagger.operat...
javascript
{ "resource": "" }
q22165
JsonSchema
train
function JsonSchema (schema) { if (!schema) { throw ono({ status: 500 }, "Missing JSON schema"); } if (schema.type !== undefined && dataTypes.indexOf(schema.type) === -1) { throw ono({ status: 500 }, "Invalid JSON schema type: %s", schema.type); } this.schema = schema; }
javascript
{ "resource": "" }
q22166
getValueToValidate
train
function getValueToValidate (schema, value) { // Is the value empty? if (value === undefined || value === "" || (schema.type === "object" && _.isObject(value) && _.isEmpty(value))) { // It's blank, so return the default/example value (if there is one) if (schema.default !== undefined) { value = s...
javascript
{ "resource": "" }
q22167
registerPathParamMiddleware
train
function registerPathParamMiddleware () { let pathParams = getAllPathParamNames(); pathParams.forEach((param) => { if (!alreadyRegistered(param)) { router.param(param, pathParamMiddleware); } }); }
javascript
{ "resource": "" }
q22168
getAllPathParamNames
train
function getAllPathParamNames () { let params = []; function addParam (param) { if (param.in === "path") { params.push(param.name); } } if (context.api) { _.each(context.api.paths, (path) => { // Add each path parameter _.each(path.parameters, addParam); ...
javascript
{ "resource": "" }
q22169
alreadyRegistered
train
function alreadyRegistered (paramName) { let params = router.params; if (!params && router._router) { params = router._router.params; } return params && params[paramName] && (params[paramName].indexOf(pathParamMiddleware) >= 0); }
javascript
{ "resource": "" }
q22170
serveDereferencedSwaggerFile
train
function serveDereferencedSwaggerFile (req, res, next) { if (req.method === "GET" || req.method === "HEAD") { let configPath = getConfiguredPath(options.apiPath); configPath = util.normalizePath(configPath, router); let reqPath = util.normalizePath(req.path, router); if (reqPath === configP...
javascript
{ "resource": "" }
q22171
getConfiguredPath
train
function getConfiguredPath (path) { if (options.useBasePath && context.api && context.api.basePath) { return context.api.basePath + path; } else { return path; } }
javascript
{ "resource": "" }
q22172
mockImplementation
train
function mockImplementation (req, res, next) { if (res.swagger) { // Determine the semantics of this request let request = new SemanticRequest(req); // Determine which mock to run let mock; if (request.isCollection) { mock = queryCollection[req.method] || editCollectio...
javascript
{ "resource": "" }
q22173
mockResponseHeaders
train
function mockResponseHeaders (req, res, next) { if (res.swagger) { util.debug("Setting %d response headers...", _.keys(res.swagger.headers).length); if (res.swagger.headers) { _.forEach(res.swagger.headers, (header, name) => { // Set all HTTP headers that are defined in the Swagger API. ...
javascript
{ "resource": "" }
q22174
mockResponseBody
train
function mockResponseBody (req, res, next) { if (res.swagger) { if (res.swagger.isEmpty) { // There is no response schema, so send an empty response util.debug("%s %s does not have a response schema. Sending an empty response", req.method, req.path); res.send(); } else { //...
javascript
{ "resource": "" }
q22175
sendText
train
function sendText (req, res, next, data) { setContentType(req, res, ["text", "html", "text/*", "application/*"], // allow these types ["json", "*/json", "+json", "application/octet-stream"]); // don't allow these types util.debug("Serializing the response as a string"); res.send(_(...
javascript
{ "resource": "" }
q22176
setContentType
train
function setContentType (req, res, supported, excluded) { // Get the MIME types that this operation produces let produces = req.swagger.operation.produces || req.swagger.api.produces || []; if (produces.length === 0) { // No MIME types were specified, so just use the first one util.debug('No "produ...
javascript
{ "resource": "" }
q22177
isCollectionRequest
train
function isCollectionRequest (req) { let isCollection = responseIsCollection(req); if (isCollection === undefined) { isCollection = !lastPathSegmentIsAParameter(req); } return isCollection; }
javascript
{ "resource": "" }
q22178
responseIsCollection
train
function responseIsCollection (req) { let getter = req.swagger.path.get || req.swagger.path.head; if (getter) { let responses = util.getResponsesBetween(getter, 200, 299); if (responses.length > 0) { let response = new SemanticResponse(responses[0].api, req.swagger.path); if (!response.isEmpty) ...
javascript
{ "resource": "" }
q22179
lastPathSegmentIsAParameter
train
function lastPathSegmentIsAParameter (req) { let lastSlash = req.swagger.pathName.lastIndexOf("/"); let lastParam = req.swagger.pathName.lastIndexOf("{"); return (lastParam > lastSlash); }
javascript
{ "resource": "" }
q22180
SemanticResponse
train
function SemanticResponse (response, path) { /** * The JSON schema of the response * @type {object|null} */ this.schema = response.schema || null; /** * The response headers, from the Swagger API * @type {object|null} */ this.headers = response.headers || null; /** * If true, then an em...
javascript
{ "resource": "" }
q22181
getResourceSchemas
train
function getResourceSchemas (path) { let schemas = []; ["post", "put", "patch"].forEach((operation) => { if (path[operation]) { schemas.push(util.getRequestSchema(path, path[operation])); } }); return schemas; }
javascript
{ "resource": "" }
q22182
schemasMatch
train
function schemasMatch (schemasToMatch, schemaToTest) { let propertiesToTest = 0; if (schemaToTest.properties) { propertiesToTest = Object.keys(schemaToTest.properties).length; } return schemasToMatch.some((schemaToMatch) => { let propertiesToMatch = 0; if (schemaToMatch.properties) { properti...
javascript
{ "resource": "" }
q22183
mergeCollection
train
function mergeCollection (req, res, next, dataStore) { let collection = req.path; let resources = createResources(req); // Set the "Location" HTTP header. // If the operation allows saving multiple resources, then use the collection path. // If the operation only saves a single resource, then use the resourc...
javascript
{ "resource": "" }
q22184
getResourceName
train
function getResourceName (data, schema) { // Try to find the "name" property using several different methods let propInfo = getResourceNameByValue(data, schema) || getResourceNameByName(data, schema) || getResourceNameByRequired(data, schema) || getResourceNameByFile(data, schema); ...
javascript
{ "resource": "" }
q22185
getResourceNameByName
train
function getResourceNameByName (data, schema) { /** @name PropertyInfo */ let propInfo = { name: "", schema: { type: "" }, value: undefined }; // Get a list of all existing and possible properties of the resource let propNames = _.union(_.keys(schema.properties), _.keys(data)); // Lo...
javascript
{ "resource": "" }
q22186
getResourceNameByRequired
train
function getResourceNameByRequired (data, schema) { let propInfo = { name: "", schema: { type: "" }, value: undefined }; let foundMatch = _.some(schema.required, (propName) => { propInfo.name = propName; propInfo.schema = schema.properties[propName]; propInfo.value = data[propNa...
javascript
{ "resource": "" }
q22187
round
train
function round(value, digits) { if (! digits) { digits = 0; } var scale = Math.pow(10, digits); return Math.round(value * scale) / scale; }
javascript
{ "resource": "" }
q22188
fibonacciretracement
train
function fibonacciretracement(start, end) { let levels = [0, 23.6, 38.2, 50, 61.8, 78.6, 100, 127.2, 161.8, 261.8, 423.6]; let retracements; if (start < end) { retracements = levels.map(function (level) { let calculated = end - Math.abs(start - end) * (level) / 100; return ca...
javascript
{ "resource": "" }
q22189
train
function (x, y, w, h) { this.gl.viewport(x, y, w, h); }
javascript
{ "resource": "" }
q22190
train
function (unit, image, filter, repeat, w, h, b, premultipliedAlpha) { var gl = this.gl; repeat = repeat || "no-repeat"; var isPOT = me.Math.isPowerOfTwo(w || image.width) && me.Math.isPowerOfTwo(h || image.height); var texture = gl.createTexture(); var rs = ...
javascript
{ "resource": "" }
q22191
train
function () { var indices = [ 0, 1, 2, 2, 1, 3 ]; // ~384KB index buffer var data = new Array(MAX_LENGTH * INDICES_PER_QUAD); for (var i = 0; i < data.length; i++) { data[i] = indices[i % INDICES_PER_QUAD] + ...
javascript
{ "resource": "" }
q22192
train
function () { this.sbSize <<= 1; var stream = new Float32Array(this.sbSize * ELEMENT_SIZE * ELEMENTS_PER_QUAD); stream.set(this.stream); this.stream = stream; }
javascript
{ "resource": "" }
q22193
train
function () { if (this.length) { var gl = this.gl; // Copy data into stream buffer var len = this.length * ELEMENT_SIZE * ELEMENTS_PER_QUAD; gl.bufferData( gl.ARRAY_BUFFER, this.stream.subarray(0, len), ...
javascript
{ "resource": "" }
q22194
train
function (col, opaque) { this.save(); this.resetTransform(); this.backBufferContext2D.globalCompositeOperation = opaque ? "copy" : "source-over"; this.backBufferContext2D.fillStyle = (col instanceof me.Color) ? col.toRGBA() : col; this.fillRect(0, 0, this.back...
javascript
{ "resource": "" }
q22195
train
function (image, sx, sy, sw, sh, dx, dy, dw, dh) { if (this.backBufferContext2D.globalAlpha < 1 / 255) { // Fast path: don't draw fully transparent return; } if (typeof sw === "undefined") { sw = dw = image.width; sh = ...
javascript
{ "resource": "" }
q22196
train
function (x, y, w, h) { this.strokeEllipse(x, y, w, h, true); }
javascript
{ "resource": "" }
q22197
train
function (poly, fill) { var context = this.backBufferContext2D; if (context.globalAlpha < 1 / 255) { // Fast path: don't draw fully transparent return; } this.translate(poly.pos.x, poly.pos.y); context.beginPath(); ...
javascript
{ "resource": "" }
q22198
train
function (x, y) { if (this.settings.subPixel === false) { this.backBufferContext2D.translate(~~x, ~~y); } else { this.backBufferContext2D.translate(x, y); } }
javascript
{ "resource": "" }
q22199
train
function (renderer, dx, dy, tmxTile) { // check if any transformation is required if (tmxTile.flipped) { renderer.save(); // apply the tile current transform renderer.translate(dx, dy); renderer.transform(tmxTile.currentTransform);...
javascript
{ "resource": "" }