_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q26100
injectReporter
train
function injectReporter() { page.evaluate(function (script) { function print(msg) { console.log(msg); } function onComplete(passed) { window.callPhantom(passed); } eval(script); var reporter = new ConsoleReporter(); reporter.setOptions({ print: print, printDeprec...
javascript
{ "resource": "" }
q26101
removeRipple
train
function removeRipple(e, el, ripple) { // Check if the ripple still exist if (!ripple) { return; } ripple.classList.remove('waves-rippling'); var relativeX = ripple.getAttribute('data-x'); var relativeY = ripple.getAttribute('data-y'); var scale ...
javascript
{ "resource": "" }
q26102
winwheelStopAnimation
train
function winwheelStopAnimation(canCallback) { // When the animation is stopped if canCallback is not false then try to call the callback. // false can be passed in to stop the after happening if the animation has been stopped before it ended normally. if (canCallback != false) { let callback = winwh...
javascript
{ "resource": "" }
q26103
aaObtainFurthestBlock
train
function aaObtainFurthestBlock(p, formattingElementEntry) { let furthestBlock = null; for (let i = p.openElements.stackTop; i >= 0; i--) { const element = p.openElements.items[i]; if (element === formattingElementEntry.element) { break; } if (p._isSpecialElement(el...
javascript
{ "resource": "" }
q26104
aaInnerLoop
train
function aaInnerLoop(p, furthestBlock, formattingElement) { let lastElement = furthestBlock; let nextElement = p.openElements.getCommonAncestor(furthestBlock); for (let i = 0, element = nextElement; element !== formattingElement; i++, element = nextElement) { //NOTE: store next element for the next...
javascript
{ "resource": "" }
q26105
aaRecreateElementFromEntry
train
function aaRecreateElementFromEntry(p, elementEntry) { const ns = p.treeAdapter.getNamespaceURI(elementEntry.element); const newElement = p.treeAdapter.createElement(elementEntry.token.tagName, ns, elementEntry.token.attrs); p.openElements.replace(elementEntry.element, newElement); elementEntry.element...
javascript
{ "resource": "" }
q26106
aaInsertLastNodeInCommonAncestor
train
function aaInsertLastNodeInCommonAncestor(p, commonAncestor, lastElement) { if (p._isElementCausesFosterParenting(commonAncestor)) { p._fosterParentElement(lastElement); } else { const tn = p.treeAdapter.getTagName(commonAncestor); const ns = p.treeAdapter.getNamespaceURI(commonAncestor)...
javascript
{ "resource": "" }
q26107
aaReplaceFormattingElement
train
function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) { const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element); const token = formattingElementEntry.token; const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs); p._adoptNodes(furthestBlo...
javascript
{ "resource": "" }
q26108
train
function(errors, options) { errors = v.pruneEmptyErrors(errors, options); errors = v.expandMultipleErrors(errors, options); errors = v.convertErrorMessages(errors, options); var format = options.format || "grouped"; if (typeof v.formatters[format] === 'function') { errors = v.for...
javascript
{ "resource": "" }
q26109
train
function(attributes, constraints, options) { options = v.extend({}, v.async.options, options); var WrapErrors = options.wrapErrors || function(errors) { return errors; }; // Removes unknown attributes if (options.cleanAttributes !== false) { attributes = v.cleanAttributes...
javascript
{ "resource": "" }
q26110
train
function(results) { // Create a sequence of all the results starting with a resolved promise. return results.reduce(function(memo, result) { // If this result isn't a promise skip it in the sequence. if (!v.isPromise(result.error)) { return memo; } return memo.then...
javascript
{ "resource": "" }
q26111
train
function(value) { return v.isObject(value) && !v.isArray(value) && !v.isFunction(value); }
javascript
{ "resource": "" }
q26112
train
function(errors, options) { options = options || {}; var ret = [] , prettify = options.prettify || v.prettify; errors.forEach(function(errorInfo) { var error = v.result(errorInfo.error, errorInfo.value, errorInfo.attribute, errorInfo.options, ...
javascript
{ "resource": "" }
q26113
train
function(value, options) { options = v.extend({}, this.options, options); if (options.allowEmpty !== false ? !v.isDefined(value) : v.isEmpty(value)) { return options.message || this.message || "can't be blank"; } }
javascript
{ "resource": "" }
q26114
train
function(value, options) { if (!v.isDefined(value)) { return; } options = v.extend({}, this.options, options); var message = options.message || this.message || "is not a valid url" , schemes = options.schemes || this.schemes || ['http', 'https'] , allowLocal = options.a...
javascript
{ "resource": "" }
q26115
getRgbAColor
train
function getRgbAColor(color, opacity) { const id = color + '&' + opacity; if (colorCache[id]) { return colorCache[id]; } const div = document.createElement('div'); div.style.background = color; document.body.appendChild(div); const computedColor = window.getComputedStyle(div).backgroundColor; docum...
javascript
{ "resource": "" }
q26116
createTipDom
train
function createTipDom(h, context, type, tip) { const stage = context.vuescroll.state[`${type}Stage`]; let dom = null; // Return user specified animation dom /* istanbul ignore if */ if ((dom = context.$slots[`${type}-${stage}`])) { return dom; } switch (stage) { // The dom will show at deactive sta...
javascript
{ "resource": "" }
q26117
configValidator
train
function configValidator(ops) { let renderError = false; const { vuescroll } = ops; // validate modes if (!~modes.indexOf(vuescroll.mode)) { error( `Unknown mode: ${ vuescroll.mode },the vuescroll's option "mode" should be one of the ${modes}` ); renderError = true; } retur...
javascript
{ "resource": "" }
q26118
BatchOperation
train
function BatchOperation(name, options) { if (!options) { options = {}; } this.name = name; this.logger = options.logger || new Logger(Logger.LogLevels.INFO); this.operationMemoryUsage = options.operationMemoryUsage || DEFAULT_OPERATION_MEMORY_USAGE; this.callbackInOrder = options.callbackInOrder === tr...
javascript
{ "resource": "" }
q26119
RestOperation
train
function RestOperation(serviceClient, operation) { this.status = OperationState.Inited; this.operationId = -1; this._callbackArguments = null; // setup callback and args this._userCallback = arguments[arguments.length - 1]; var sliceEnd = arguments.length; if(azureutil.objectIsFunction(this._userCallback...
javascript
{ "resource": "" }
q26120
CommonOperation
train
function CommonOperation(operationFunc, callback) { this.status = OperationState.Inited; this.operationId = -1; this._callbackArguments = null; var sliceStart = 2; if (azureutil.objectIsFunction(callback)) { this._userCallback = callback; } else { this._userCallback = null; sliceStart = 1; } ...
javascript
{ "resource": "" }
q26121
FileRangeStream
train
function FileRangeStream(fileServiceClient, share, directory, file, options) { FileRangeStream['super_'].call(this, fileServiceClient, null, null, options); this._lengthHeader = Constants.HeaderConstants.FILE_CONTENT_LENGTH; if (options.minRangeSize) { this._minRangeSize = options.minRangeSize; } else ...
javascript
{ "resource": "" }
q26122
train
function () { var options = { publicAccessLevel: BlobUtilities.BlobContainerPublicAccessType.CONTAINER }; blobService.setContainerAcl(container, signedIdentifiers, options, function(error) { if (error) { console.log(error); } else { console.log('Uploaded the permissions for the conta...
javascript
{ "resource": "" }
q26123
setRetries
train
function setRetries() { console.log('Starting Sample 1 - setRetries.'); // By default, no retry will be performed with all kinds of services created // by Azure storage client library for Node.js. var blobServiceWithoutRetry = azure.createBlobService(); console.log('BlobService instance created, no retry wil...
javascript
{ "resource": "" }
q26124
setCustomRetryPolicy
train
function setCustomRetryPolicy() { console.log('Starting Sample 2 - setCustomRetryPolicy.'); // Step 1 : Set the retry policy to customized retry policy which will // not retry on any failing status code other than the excepted one. var retryOnContainerBeingDeleted = new RetryPolicyFilter(); retryOnContainerB...
javascript
{ "resource": "" }
q26125
FileReadStream
train
function FileReadStream(path, options) { stream.Stream.call(this); this.readable = true; if(!options) { options = {}; } this._destroyed = false; this._streamEnded = false; this._fd = null; this._fileName = undefined; this._highWaterMark = options.highWaterMark || bufferSize; this._offset = 0; ...
javascript
{ "resource": "" }
q26126
toHumanReadableSize
train
function toHumanReadableSize(size, len) { if(!size) return '0B'; if (!len || len <= 0) { len = 2; } var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; var i = Math.floor( Math.log(size) / Math.log(1024)); return (size/Math.pow(1024, i)).toFixed(len) + units[i]; }
javascript
{ "resource": "" }
q26127
StorageServiceSettings
train
function StorageServiceSettings(name, key, sasToken, blobEndpoint, queueEndpoint, tableEndpoint, fileEndpoint, usePathStyleUri, token) { this._name = name; this._key = key; if (sasToken && sasToken[0] === '?') { this._sasToken = sasToken.slice(1); } else { this._sasToken = sasToken; } this._blobEn...
javascript
{ "resource": "" }
q26128
BatchResult
train
function BatchResult(tableService, table, operations) { this.tableService = tableService; this.table = table; this.operations = operations; this.batchBoundary = 'batch_' + BatchResult._getBoundary(); this.changesetBoundary = 'changeset_' + BatchResult._getBoundary(); }
javascript
{ "resource": "" }
q26129
StorageServiceClient
train
function StorageServiceClient(storageAccount, storageAccessKey, host, usePathStyleUri, sas, token) { StorageServiceClient['super_'].call(this); if(storageAccount && storageAccessKey) { // account and key this.storageAccount = storageAccount; this.storageAccessKey = storageAccessKey; this.storageCre...
javascript
{ "resource": "" }
q26130
train
function (postPostRequestOptions, parentFilterCallback) { // The parentFilterNext is the filter next to the merged filter. // For 2 filters, that'd be the actual operation. parentFilterNext(postPostRequestOptions, function (responseObject, responseCallback, finalCallback) { ...
javascript
{ "resource": "" }
q26131
parseXObject
train
function parseXObject(xObject) { const objectId = xObject.getObjectID(); const pdfStreamInput = cpyCxtParser.parseNewObject(objectId); const xObjectDictionary = pdfStreamInput.getDictionary().toJSObject(); if (xObjectDictionary.Subtype.value === 'Image') { // Create a hash of the compressed stream...
javascript
{ "resource": "" }
q26132
parseFont
train
function parseFont(fontObject) { const pdfStreamInput = cpyCxtParser.parseNewObject(fontObject.getObjectID()); const fontDictionary = pdfStreamInput.toJSObject(); // See "Introduction to Font Data Structures" from PDF specification if (fontDictionary.Subtype.value === 'Type0') { // TODO: properly ...
javascript
{ "resource": "" }
q26133
getReferences
train
function getReferences(path, variableName) { const bindings = path.scope.getBinding(variableName); const references = bindings.referencePaths; return references; }
javascript
{ "resource": "" }
q26134
getIdentifierVariableName
train
function getIdentifierVariableName(path) { if ( path.isIdentifier() && path.parentPath.isCallExpression() && path.parentPath.parentPath.isVariableDeclarator() ) { const variableName = path.parentPath.parentPath.node.id.name; return variableName; } return ''; }
javascript
{ "resource": "" }
q26135
getPackageName
train
function getPackageName(content, pluginLookup, identifierPath) { let memberPath = identifierPath.parentPath; while (memberPath.isMemberExpression()) { const code = content.slice(identifierPath.node.end, memberPath.node.end); const pluginName = pluginLookup[code]; if (pluginName) { return pluginNam...
javascript
{ "resource": "" }
q26136
check
train
function check(content, deps, path) { if ( // Pattern: import plugins from 'gulp-load-plugins', $ = plugins(), $.jshint() importDetector(path.node)[0] === 'gulp-load-plugins' && path.isImportDeclaration() && path.get('specifiers')[0] && path.get('specifiers')[0].isImportDefaultSpecifier() && p...
javascript
{ "resource": "" }
q26137
Manifold
train
function Manifold() { this.type; this.localNormal = Vec2.zero(); this.localPoint = Vec2.zero(); this.points = [ new ManifoldPoint(), new ManifoldPoint() ]; this.pointCount = 0; }
javascript
{ "resource": "" }
q26138
getPointStates
train
function getPointStates(state1, state2, manifold1, manifold2) { // for (var i = 0; i < Settings.maxManifoldPoints; ++i) { // state1[i] = PointState.nullState; // state2[i] = PointState.nullState; // } // Detect persists and removes. for (var i = 0; i < manifold1.pointCount; ++i) { var id = manifold1.po...
javascript
{ "resource": "" }
q26139
clipSegmentToLine
train
function clipSegmentToLine(vOut, vIn, normal, offset, vertexIndexA) { // Start with no output points var numOut = 0; // Calculate the distance of end points to the line var distance0 = Vec2.dot(normal, vIn[0].v) - offset; var distance1 = Vec2.dot(normal, vIn[1].v) - offset; // If the points are behind the...
javascript
{ "resource": "" }
q26140
MotorJoint
train
function MotorJoint(def, bodyA, bodyB) { if (!(this instanceof MotorJoint)) { return new MotorJoint(def, bodyA, bodyB); } def = options(def, DEFAULTS); Joint.call(this, def, bodyA, bodyB); bodyA = this.m_bodyA; bodyB = this.m_bodyB; this.m_type = MotorJoint.TYPE; this.m_linearOffset = def.linearO...
javascript
{ "resource": "" }
q26141
WeldJoint
train
function WeldJoint(def, bodyA, bodyB, anchor) { if (!(this instanceof WeldJoint)) { return new WeldJoint(def, bodyA, bodyB, anchor); } def = options(def, DEFAULTS); Joint.call(this, def, bodyA, bodyB); bodyA = this.m_bodyA; bodyB = this.m_bodyB; this.m_type = WeldJoint.TYPE; this.m_localAnchorA =...
javascript
{ "resource": "" }
q26142
Mat33
train
function Mat33(a, b, c) { if (typeof a === 'object' && a !== null) { this.ex = Vec3.clone(a); this.ey = Vec3.clone(b); this.ez = Vec3.clone(c); } else { this.ex = Vec3(); this.ey = Vec3(); this.ez = Vec3(); } }
javascript
{ "resource": "" }
q26143
Mat22
train
function Mat22(a, b, c, d) { if (typeof a === 'object' && a !== null) { this.ex = Vec2.clone(a); this.ey = Vec2.clone(b); } else if (typeof a === 'number') { this.ex = Vec2.neo(a, c); this.ey = Vec2.neo(b, d) } else { this.ex = Vec2.zero(); this.ey = Vec2.zero() } }
javascript
{ "resource": "" }
q26144
RopeJoint
train
function RopeJoint(def, bodyA, bodyB, anchor) { if (!(this instanceof RopeJoint)) { return new RopeJoint(def, bodyA, bodyB, anchor); } def = options(def, DEFAULTS); Joint.call(this, def, bodyA, bodyB); bodyA = this.m_bodyA; bodyB = this.m_bodyB; this.m_type = RopeJoint.TYPE; this.m_localAnchorA = ...
javascript
{ "resource": "" }
q26145
FindMaxSeparation
train
function FindMaxSeparation(poly1, xf1, poly2, xf2) { var count1 = poly1.m_count; var count2 = poly2.m_count; var n1s = poly1.m_normals; var v1s = poly1.m_vertices; var v2s = poly2.m_vertices; var xf = Transform.mulTXf(xf2, xf1); var bestIndex = 0; var maxSeparation = -Infinity; for (var i = 0; i < co...
javascript
{ "resource": "" }
q26146
PolygonShape
train
function PolygonShape(vertices) { if (!(this instanceof PolygonShape)) { return new PolygonShape(vertices); } PolygonShape._super.call(this); this.m_type = PolygonShape.TYPE; this.m_radius = Settings.polygonRadius; this.m_centroid = Vec2.zero(); this.m_vertices = []; // Vec2[Settings.maxPolygonVerti...
javascript
{ "resource": "" }
q26147
RevoluteJoint
train
function RevoluteJoint(def, bodyA, bodyB, anchor) { if (!(this instanceof RevoluteJoint)) { return new RevoluteJoint(def, bodyA, bodyB, anchor); } def = options(def, DEFAULTS); Joint.call(this, def, bodyA, bodyB); bodyA = this.m_bodyA; bodyB = this.m_bodyB; this.m_type = RevoluteJoint.TYPE; this....
javascript
{ "resource": "" }
q26148
DistanceInput
train
function DistanceInput() { this.proxyA = new DistanceProxy(); this.proxyB = new DistanceProxy(); this.transformA = null; this.transformB = null; this.useRadii = false; }
javascript
{ "resource": "" }
q26149
Joint
train
function Joint(def, bodyA, bodyB) { bodyA = def.bodyA || bodyA; bodyB = def.bodyB || bodyB; _ASSERT && common.assert(bodyA); _ASSERT && common.assert(bodyB); _ASSERT && common.assert(bodyA != bodyB); this.m_type = 'unknown-joint'; this.m_bodyA = bodyA; this.m_bodyB = bodyB; this.m_index = 0; thi...
javascript
{ "resource": "" }
q26150
ChainShape
train
function ChainShape(vertices, loop) { if (!(this instanceof ChainShape)) { return new ChainShape(vertices, loop); } ChainShape._super.call(this); this.m_type = ChainShape.TYPE; this.m_radius = Settings.polygonRadius; this.m_vertices = []; this.m_count = 0; this.m_prevVertex = null; this.m_nextVe...
javascript
{ "resource": "" }
q26151
TOIInput
train
function TOIInput() { this.proxyA = new DistanceProxy(); this.proxyB = new DistanceProxy(); this.sweepA = new Sweep(); this.sweepB = new Sweep(); this.tMax; }
javascript
{ "resource": "" }
q26152
BoxShape
train
function BoxShape(hx, hy, center, angle) { if (!(this instanceof BoxShape)) { return new BoxShape(hx, hy, center, angle); } BoxShape._super.call(this); this._setAsBox(hx, hy, center, angle); }
javascript
{ "resource": "" }
q26153
addAsteroids
train
function addAsteroids() { while (asteroidBodies.length) { var asteroidBody = asteroidBodies.shift(); world.destroyBody(asteroidBody); // asteroidBody.uiRemove(); } for (var i = 0; i < level; i++) { var shipPosition = shipBody.getPosition(); var x = shipPosition.x; var y ...
javascript
{ "resource": "" }
q26154
wrap
train
function wrap(body) { var p = body.getPosition(); p.x = wrapNumber(p.x, -SPACE_WIDTH / 2, SPACE_WIDTH / 2); p.y = wrapNumber(p.y, -SPACE_HEIGHT / 2, SPACE_HEIGHT / 2); body.setPosition(p); }
javascript
{ "resource": "" }
q26155
DistanceJoint
train
function DistanceJoint(def, bodyA, bodyB, anchorA, anchorB) { if (!(this instanceof DistanceJoint)) { return new DistanceJoint(def, bodyA, bodyB, anchorA, anchorB); } // order of constructor arguments is changed in v0.2 if (bodyB && anchorA && ('m_type' in anchorA) && ('x' in bodyB) && ('y' in bodyB)) { ...
javascript
{ "resource": "" }
q26156
FrictionJoint
train
function FrictionJoint(def, bodyA, bodyB, anchor) { if (!(this instanceof FrictionJoint)) { return new FrictionJoint(def, bodyA, bodyB, anchor); } def = options(def, DEFAULTS); Joint.call(this, def, bodyA, bodyB); bodyA = this.m_bodyA; bodyB = this.m_bodyB; this.m_type = FrictionJoint.TYPE; this....
javascript
{ "resource": "" }
q26157
MouseJoint
train
function MouseJoint(def, bodyA, bodyB, target) { if (!(this instanceof MouseJoint)) { return new MouseJoint(def, bodyA, bodyB, target); } def = options(def, DEFAULTS); Joint.call(this, def, bodyA, bodyB); bodyA = this.m_bodyA; bodyB = this.m_bodyB; this.m_type = MouseJoint.TYPE; _ASSERT && common...
javascript
{ "resource": "" }
q26158
FixtureProxy
train
function FixtureProxy(fixture, childIndex) { this.aabb = new AABB(); this.fixture = fixture; this.childIndex = childIndex; this.proxyId; }
javascript
{ "resource": "" }
q26159
Fixture
train
function Fixture(body, shape, def) { if (shape.shape) { def = shape; shape = shape.shape; } else if (typeof def === 'number') { def = {density : def}; } def = options(def, FixtureDef); this.m_body = body; this.m_friction = def.friction; this.m_restitution = def.restitution; this.m_densit...
javascript
{ "resource": "" }
q26160
ReferenceFace
train
function ReferenceFace() { this.i1, this.i2; // int this.v1, this.v2; // v this.normal = Vec2.zero(); this.sideNormal1 = Vec2.zero(); this.sideOffset1; // float this.sideNormal2 = Vec2.zero(); this.sideOffset2; // float }
javascript
{ "resource": "" }
q26161
TreeNode
train
function TreeNode(id) { this.id = id; this.aabb = new AABB(); this.userData = null; this.parent = null; this.child1 = null; this.child2 = null; this.height = -1; this.toString = function() { return this.id + ": " + this.userData; } }
javascript
{ "resource": "" }
q26162
train
function(name) { name = (name || '').toLowerCase(); if (name in elementMap) return this.getMapping(name); if (this.isInlineLevel(name)) return 'span'; return 'div'; }
javascript
{ "resource": "" }
q26163
train
function(name, collection) { if (!elementTypes[collection]) elementTypes[collection] = []; var col = this.getCollection(collection); if (!~col.indexOf(name)) { col.push(name); } }
javascript
{ "resource": "" }
q26164
train
function(name, collection) { if (collection in elementTypes) { elementTypes[collection] = utils.without(this.getCollection(collection), name); } }
javascript
{ "resource": "" }
q26165
addComments
train
function addComments(node, templateBefore, templateAfter) { // check if comments should be added var trigger = prefs.get('filter.commentTrigger'); if (trigger != '*') { var shouldAdd = utils.find(trigger.split(','), function(name) { return !!node.attribute(utils.trim(name)); }); if (!shouldAdd) { ...
javascript
{ "resource": "" }
q26166
resolveNodeNames
train
function resolveNodeNames(tree) { tree.children.forEach(function(node) { if (node.hasImplicitName() || node.data('forceNameResolving')) { node._name = tagName.resolve(node.parent.name()); node.data('nameResolved', true); } resolveNodeNames(node); }); return tree; }
javascript
{ "resource": "" }
q26167
isSingleProperty
train
function isSingleProperty(snippet) { snippet = utils.trim(snippet); // check if it doesn't contain a comment and a newline if (/\/\*|\n|\r/.test(snippet)) { return false; } // check if it's a valid snippet definition if (!/^[a-z0-9\-]+\s*\:/i.test(snippet)) { return false; } return snippe...
javascript
{ "resource": "" }
q26168
normalizeValue
train
function normalizeValue(value) { if (value.charAt(0) == '-' && !/^\-[\.\d]/.test(value)) { value = value.replace(/^\-+/, ''); } var ch = value.charAt(0); if (ch == '#') { return normalizeHexColor(value); } if (ch == '$') { return utils.escapeText(value); } return getKeyword(value); }
javascript
{ "resource": "" }
q26169
toRgba
train
function toRgba(color, opacity) { var r = parseInt(color.substr(0, 2), 16); var g = parseInt(color.substr(2, 2), 16); var b = parseInt(color.substr(4, 2), 16); return 'rgba(' + [r, g, b, opacity].join(', ') + ')'; }
javascript
{ "resource": "" }
q26170
hasPrefix
train
function hasPrefix(property, prefix) { var info = vendorPrefixes[prefix]; if (!info) info = utils.find(vendorPrefixes, function(data) { return data.prefix == prefix; }); return info && info.supports(property); }
javascript
{ "resource": "" }
q26171
findVendorPrefixes
train
function findVendorPrefixes(property) { var prefixes = ciu.resolvePrefixes(property); if (!prefixes) { // Can I Use database is disabled or prefixes are not // available for this property prefixes = []; Object.keys(vendorPrefixes).forEach(function(key) { if (hasPrefix(property, key)) { prefixes...
javascript
{ "resource": "" }
q26172
findInternalPrefixes
train
function findInternalPrefixes(property, noAutofill) { var result = []; var prefixes = findVendorPrefixes(property); if (prefixes) { var prefixMap = {}; Object.keys(vendorPrefixes).forEach(function(key) { prefixMap[vendorPrefixes[key].prefix] = key; }); result = prefixes.map(function(prefix) { ...
javascript
{ "resource": "" }
q26173
formatProperty
train
function formatProperty(property, syntax) { var ix = property.indexOf(':'); property = property.substring(0, ix).replace(/\s+$/, '') + getSyntaxPreference('valueSeparator', syntax) + utils.trim(property.substring(ix + 1)); return property.replace(/\s*;\s*$/, getSyntaxPreference('propertyEnd', syntax)); ...
javascript
{ "resource": "" }
q26174
resolvePrefixedValues
train
function resolvePrefixedValues(snippetObj, isImportant, syntax) { var prefixes = []; var lookup = {}; var parts = cssEditTree.findParts(snippetObj.value); parts.reverse(); parts.forEach(function(p) { var partValue = p.substring(snippetObj.value); (findVendorPrefixes(partValue) || []).forEach(function(p...
javascript
{ "resource": "" }
q26175
train
function(abbr) { if (abbr.charAt(0) != '-') { return { property: abbr, prefixes: null }; } // abbreviation may either contain sequence of one-character prefixes // or just dash, meaning that user wants to produce all possible // prefixed properties var i = 1, il = abbr.length, ch...
javascript
{ "resource": "" }
q26176
train
function(abbr, syntax) { syntax = syntax || 'css'; var i = 0, il = abbr.length, value = '', ch; while (i < il) { ch = abbr.charAt(i); if (isNumeric(ch) || ch == '#' || ch == '$' || (ch == '-' && isNumeric(abbr.charAt(i + 1)))) { value = abbr.substring(i); break; } i++; } ...
javascript
{ "resource": "" }
q26177
train
function(abbr) { // search for value start var abbrValues = this.findValuesInAbbreviation(abbr); if (!abbrValues) { return { property: abbr, values: null }; } return { property: abbr.substring(0, abbr.length - abbrValues.length).replace(/-$/, ''), values: this.parseValues(ab...
javascript
{ "resource": "" }
q26178
train
function(value, property) { property = (property || '').toLowerCase(); var unitlessProps = prefs.getArray('css.unitlessProperties'); return value.replace(/^(\-?[0-9\.]+)([a-z]*)$/, function(str, val, unit) { if (!unit && (val == '0' || ~unitlessProps.indexOf(property))) return val; if (!unit)...
javascript
{ "resource": "" }
q26179
train
function() { if (this._name === null) { var range = this.nameRange(); if (range) { this._name = range.substring(this.source()); } } return this._name; }
javascript
{ "resource": "" }
q26180
train
function() { var out = []; if (this.parent) { // add current range if it is not root node out.push(this.range); } this.children.forEach(function(child) { out = out.concat(child.allRanges()); }); return out; }
javascript
{ "resource": "" }
q26181
train
function(content, pos, sanitize) { if (sanitize) { content = this.sanitize(content); } var stream = stringStream(content); stream.start = stream.pos = pos; var stack = [], ranges = []; var ch; while (ch = stream.next()) { if (ch == '{') { stack.push(stream.pos - 1); } else if (ch ...
javascript
{ "resource": "" }
q26182
train
function(content, pos, sanitize) { if (sanitize) { content = this.sanitize(content); } var skipString = function() { var quote = content.charAt(pos); if (quote == '"' || quote == "'") { while (--pos >= 0) { if (content.charAt(pos) == quote && content.charAt(pos - 1) != '\\') { br...
javascript
{ "resource": "" }
q26183
train
function(content, pos, isBackward) { // possible case: editor reported that current syntax is // CSS, but it’s actually a HTML document (either `style` tag or attribute) var offset = 0; var subrange = this.styleTagRange(content, pos); if (subrange) { offset = subrange.start; pos -= subrange.start...
javascript
{ "resource": "" }
q26184
train
function(range, ctx) { while (ctx && ctx.range) { if (ctx.range.contains(range)) { return ctx.addChild(range); } ctx = ctx.parent; } // if we are here then given range is a top-level section return root.addChild(range); }
javascript
{ "resource": "" }
q26185
train
function(rule) { var offset = rule.valueRange(true).start; var nestedSections = this.findAllRules(rule.valueRange().substring(rule.source)); nestedSections.forEach(function(section) { section.start += offset; section.end += offset; section._selectorEnd += offset; section._contentStart += offset...
javascript
{ "resource": "" }
q26186
train
function(name, factory) { var that = this; factories[name] = function() { var elem = factory.apply(that, arguments); if (elem) elem.type = name; return elem; }; }
javascript
{ "resource": "" }
q26187
train
function(name) { var args = [].slice.call(arguments, 1); var factory = this.get(name); return factory ? factory.apply(this, args) : null; }
javascript
{ "resource": "" }
q26188
train
function(name, value, description) { var prefs = name; if (typeof name === 'string') { prefs = {}; prefs[name] = { value: value, description: description }; } Object.keys(prefs).forEach(function(k) { var v = prefs[k]; defaults[k] = isValueObj(v) ? v : {value: v}; }); }
javascript
{ "resource": "" }
q26189
train
function(name) { var val = this.get(name); if (typeof val === 'undefined' || val === null || val === '') { return null; } val = val.split(',').map(utils.trim); if (!val.length) { return null; } return val; }
javascript
{ "resource": "" }
q26190
train
function(name) { var result = {}; this.getArray(name).forEach(function(val) { var parts = val.split(':'); result[parts[0]] = parts[1]; }); return result; }
javascript
{ "resource": "" }
q26191
train
function() { return Object.keys(defaults).sort().map(function(key) { return { name: key, value: this.get(key), type: typeof defaults[key].value, description: defaults[key].description }; }, this); }
javascript
{ "resource": "" }
q26192
train
function(json) { Object.keys(json).forEach(function(key) { this.set(key, json[key]); }, this); }
javascript
{ "resource": "" }
q26193
insertPastedContent
train
function insertPastedContent(node, content, overwrite) { var nodesWithPlaceholders = node.findAll(function(item) { return hasOutputPlaceholder(item); }); if (hasOutputPlaceholder(node)) nodesWithPlaceholders.unshift(node); if (nodesWithPlaceholders.length) { nodesWithPlaceholders.forEach(function...
javascript
{ "resource": "" }
q26194
shouldAddLineBreak
train
function shouldAddLineBreak(node, profile) { if (profile.tag_nl === true || abbrUtils.isBlock(node)) return true; if (!node.parent || !profile.inline_break) return false; // check if there are required amount of adjacent inline element return shouldFormatInline(node.parent, profile); }
javascript
{ "resource": "" }
q26195
shouldBreakInsideInline
train
function shouldBreakInsideInline(node, profile) { var hasBlockElems = node.children.some(function(child) { if (abbrUtils.isSnippet(child)) return false; return !abbrUtils.isInline(child); }); if (!hasBlockElems) { return shouldFormatInline(node, profile); } return true; }
javascript
{ "resource": "" }
q26196
intLength
train
function intLength(num) { num = num.replace(/^\-/, ''); if (~num.indexOf('.')) { return num.split('.')[0].length; } return num.length; }
javascript
{ "resource": "" }
q26197
consumeSingleProperty
train
function consumeSingleProperty(it, text) { var name, value, end; var token = it.current(); if (!token) { return null; } // skip whitespace var ws = {'white': 1, 'line': 1, 'comment': 1}; while ((token = it.current())) { if (!(token.type in ws)) { break; } it.next(); } if (!it.hasNex...
javascript
{ "resource": "" }
q26198
findParts
train
function findParts(str) { /** @type StringStream */ var stream = stringStream.create(str); var ch; var result = []; var sep = /[\s\u00a0,;]/; var add = function() { stream.next(); result.push(range(stream.start, stream.current())); stream.start = stream.pos; }; // skip whitespace stream...
javascript
{ "resource": "" }
q26199
consumeProperties
train
function consumeProperties(node, source, offset) { var list = extractPropertiesFromSource(source, offset); list.forEach(function(property) { node._children.push(new CSSEditElement(node, editTree.createToken(property.name.start, property.nameText), editTree.createToken(property.value.start, property.valu...
javascript
{ "resource": "" }