_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q61500
validation
function(command) { if (selection.isCollapsed()) selection.select(selection.getNode()); execNativeCommand(command); selection.collapse(FALSE); }
javascript
{ "resource": "" }
q61501
validation
function(command) { var listElm, listParent; execNativeCommand(command); // WebKit produces lists within block elements so we need to split them // we will replace the native list creation logic to custom logic later on // TODO: Remove this when the list creation logic is removed listElm = dom.getParent(selection.getNode(), 'ol,ul'); if (listElm) { listParent = listElm.parentNode; // If list is within a text block then split that block if (/^(H[1-6]|P|ADDRESS|PRE)$/.test(listParent.nodeName)) { storeSelection(); dom.split(listParent, listElm); restoreSelection(); } } }
javascript
{ "resource": "" }
q61502
validation
function(command) { var name = 'align' + command.substring(7); var nodes = selection.isCollapsed() ? [dom.getParent(selection.getNode(), dom.isBlock)] : selection.getSelectedBlocks(); var matches = tinymce.map(nodes, function(node) { return !!formatter.matchNode(node, name); }); return tinymce.inArray(matches, TRUE) !== -1; }
javascript
{ "resource": "" }
q61503
removeCaretContainer
validation
function removeCaretContainer(node, move_caret) { var child, rng; if (!node) { node = getParentCaretContainer(selection.getStart()); if (!node) { while (node = dom.get(caretContainerId)) { removeCaretContainer(node, false); } } } else { rng = selection.getRng(true); if (isCaretContainerEmpty(node)) { if (move_caret !== false) { rng.setStartBefore(node); rng.setEndBefore(node); } dom.remove(node); } else { child = findFirstTextNode(node); if (child.nodeValue.charAt(0) === INVISIBLE_CHAR) { child = child.deleteData(0, 1); } dom.remove(node, 1); } selection.setRng(rng); } }
javascript
{ "resource": "" }
q61504
unmarkBogusCaretParents
validation
function unmarkBogusCaretParents() { var i, caretContainer, node; caretContainer = getParentCaretContainer(selection.getStart()); if (caretContainer && !dom.isEmpty(caretContainer)) { tinymce.walk(caretContainer, function(node) { if (node.nodeType == 1 && node.id !== caretContainerId && !dom.isEmpty(node)) { dom.setAttrib(node, 'data-mce-bogus', null); } }, 'childNodes'); } }
javascript
{ "resource": "" }
q61505
renderBlockOnIE
validation
function renderBlockOnIE(block) { var oldRng; if (tinymce.isIE && dom.isBlock(block)) { oldRng = selection.getRng(); block.appendChild(dom.create('span', null, '\u00a0')); selection.select(block); block.lastChild.outerHTML = ''; selection.setRng(oldRng); } }
javascript
{ "resource": "" }
q61506
moveToCaretPosition
validation
function moveToCaretPosition(root) { var walker, node, rng, y, viewPort, lastNode = root, tempElm; rng = dom.createRng(); if (root.hasChildNodes()) { walker = new TreeWalker(root, root); while (node = walker.current()) { if (node.nodeType == 3) { rng.setStart(node, 0); rng.setEnd(node, 0); break; } if (nonEmptyElementsMap[node.nodeName.toLowerCase()]) { rng.setStartBefore(node); rng.setEndBefore(node); break; } lastNode = node; node = walker.next(); } if (!node) { rng.setStart(lastNode, 0); rng.setEnd(lastNode, 0); } } else { if (root.nodeName == 'BR') { if (root.nextSibling && dom.isBlock(root.nextSibling)) { // Trick on older IE versions to render the caret before the BR between two lists if (!documentMode || documentMode < 9) { tempElm = dom.create('br'); root.parentNode.insertBefore(tempElm, root); } rng.setStartBefore(root); rng.setEndBefore(root); } else { rng.setStartAfter(root); rng.setEndAfter(root); } } else { rng.setStart(root, 0); rng.setEnd(root, 0); } } selection.setRng(rng); // Remove tempElm created for old IE:s dom.remove(tempElm); viewPort = dom.getViewPort(editor.getWin()); // scrollIntoView seems to scroll the parent window in most browsers now including FF 3.0b4 so it's time to stop using it and do it our selfs y = dom.getPos(root).y; if (y < viewPort.y || y + 25 > viewPort.y + viewPort.h) { editor.getWin().scrollTo(0, y < viewPort.y ? y : y - viewPort.h + 25); // Needs to be hardcoded to roughly one line of text if a huge text block is broken into two blocks } }
javascript
{ "resource": "" }
q61507
createNewBlock
validation
function createNewBlock(name) { var node = container, block, clonedNode, caretNode; block = name || parentBlockName == "TABLE" ? dom.create(name || newBlockName) : parentBlock.cloneNode(false); caretNode = block; // Clone any parent styles if (settings.keep_styles !== false) { do { if (/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(node.nodeName)) { // Never clone a caret containers if (node.id == '_mce_caret') { continue; } clonedNode = node.cloneNode(false); dom.setAttrib(clonedNode, 'id', ''); // Remove ID since it needs to be document unique if (block.hasChildNodes()) { clonedNode.appendChild(block.firstChild); block.appendChild(clonedNode); } else { caretNode = clonedNode; block.appendChild(clonedNode); } } } while (node = node.parentNode); } // BR is needed in empty blocks on non IE browsers if (!tinymce.isIE) { caretNode.innerHTML = '<br data-mce-bogus="1">'; } return block; }
javascript
{ "resource": "" }
q61508
wrapSelfAndSiblingsInDefaultBlock
validation
function wrapSelfAndSiblingsInDefaultBlock(container, offset) { var newBlock, parentBlock, startNode, node, next, blockName = newBlockName || 'P'; // Not in a block element or in a table cell or caption parentBlock = dom.getParent(container, dom.isBlock); if (!parentBlock || !canSplitBlock(parentBlock)) { parentBlock = parentBlock || editableRoot; if (!parentBlock.hasChildNodes()) { newBlock = dom.create(blockName); parentBlock.appendChild(newBlock); rng.setStart(newBlock, 0); rng.setEnd(newBlock, 0); return newBlock; } // Find parent that is the first child of parentBlock node = container; while (node.parentNode != parentBlock) { node = node.parentNode; } // Loop left to find start node start wrapping at while (node && !dom.isBlock(node)) { startNode = node; node = node.previousSibling; } if (startNode) { newBlock = dom.create(blockName); startNode.parentNode.insertBefore(newBlock, startNode); // Start wrapping until we hit a block node = startNode; while (node && !dom.isBlock(node)) { next = node.nextSibling; newBlock.appendChild(node); node = next; } // Restore range to it's past location rng.setStart(container, offset); rng.setEnd(container, offset); } } return container; }
javascript
{ "resource": "" }
q61509
hasRightSideBr
validation
function hasRightSideBr() { var walker = new TreeWalker(container, parentBlock), node; while (node = walker.current()) { if (node.nodeName == 'BR') { return true; } node = walker.next(); } }
javascript
{ "resource": "" }
q61510
insertBr
validation
function insertBr() { var brElm, extraBr, marker; if (container && container.nodeType == 3 && offset >= container.nodeValue.length) { // Insert extra BR element at the end block elements if (!tinymce.isIE && !hasRightSideBr()) { brElm = dom.create('br'); rng.insertNode(brElm); rng.setStartAfter(brElm); rng.setEndAfter(brElm); extraBr = true; } } brElm = dom.create('br'); rng.insertNode(brElm); // Rendering modes below IE8 doesn't display BR elements in PRE unless we have a \n before it if (tinymce.isIE && parentBlockName == 'PRE' && (!documentMode || documentMode < 8)) { brElm.parentNode.insertBefore(dom.doc.createTextNode('\r'), brElm); } // Insert temp marker and scroll to that marker = dom.create('span', {}, '&nbsp;'); brElm.parentNode.insertBefore(marker, brElm); selection.scrollIntoView(marker); dom.remove(marker); if (!extraBr) { rng.setStartAfter(brElm); rng.setEndAfter(brElm); } else { rng.setStartBefore(brElm); rng.setEndBefore(brElm); } selection.setRng(rng); undoManager.add(); }
javascript
{ "resource": "" }
q61511
validation
function(el, prefix) { var me = this, sandboxPrefix = ''; el = Ext.getDom(el, true) || {}; if (el === document) { el.id = me.documentId; } else if (el === window) { el.id = me.windowId; } if (!el.id) { if (me.isSandboxed) { sandboxPrefix = Ext.sandboxName.toLowerCase() + '-'; } el.id = sandboxPrefix + (prefix || "ext-gen") + (++Ext.idSeed); } return el.id; }
javascript
{ "resource": "" }
q61512
validation
function(callback, scope, args, delay){ if(Ext.isFunction(callback)){ args = args || []; scope = scope || window; if (delay) { Ext.defer(callback, delay, scope, args); } else { callback.apply(scope, args); } } }
javascript
{ "resource": "" }
q61513
validation
function(dest, source, names, usePrototypeKeys){ if(typeof names == 'string'){ names = names.split(/[,;\s]/); } var n, nLen = names? names.length : 0, name; for(n = 0; n < nLen; n++) { name = names[n]; if(usePrototypeKeys || source.hasOwnProperty(name)){ dest[name] = source[name]; } } return dest; }
javascript
{ "resource": "" }
q61514
validation
function(o){ for (var i = 1, a = arguments, len = a.length; i < len; i++) { Ext.destroy(o[a[i]]); delete o[a[i]]; } }
javascript
{ "resource": "" }
q61515
validation
function(arr, methodName){ var ret = [], args = Array.prototype.slice.call(arguments, 2), a, v, aLen = arr.length; for (a = 0; a < aLen; a++) { v = arr[a]; if (v && typeof v[methodName] == 'function') { ret.push(v[methodName].apply(v, args)); } else { ret.push(undefined); } } return ret; }
javascript
{ "resource": "" }
q61516
validation
function(){ var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }), arrs = parts[0], fn = parts[1][0], len = Ext.max(Ext.pluck(arrs, "length")), ret = [], i, j, aLen; for (i = 0; i < len; i++) { ret[i] = []; if(fn){ ret[i] = fn.apply(fn, Ext.pluck(arrs, i)); }else{ for (j = 0, aLen = arrs.length; j < aLen; j++){ ret[i].push( arrs[j][i] ); } } } return ret; }
javascript
{ "resource": "" }
q61517
report
validation
function report(node, needed, gotten, loc, isLastNodeCheck) { var msgContext = { needed: needed, type: indentType, characters: needed === 1 ? "character" : "characters", gotten: gotten }; var indentChar = indentType === "space" ? " " : "\t"; /** * Responsible for fixing the indentation issue fix * @returns {Function} function to be executed by the fixer * @private */ function getFixerFunction() { var rangeToFix = []; if (needed > gotten) { var spaces = "" + new Array(needed - gotten + 1).join(indentChar); // replace with repeat in future if (isLastNodeCheck === true) { rangeToFix = [ node.range[1] - 1, node.range[1] - 1 ]; } else { rangeToFix = [ node.range[0], node.range[0] ]; } return function(fixer) { return fixer.insertTextBeforeRange(rangeToFix, spaces); }; } else { if (isLastNodeCheck === true) { rangeToFix = [ node.range[1] - (gotten - needed) - 1, node.range[1] - 1 ]; } else { rangeToFix = [ node.range[0] - (gotten - needed), node.range[0] ]; } return function(fixer) { return fixer.removeRange(rangeToFix); }; } } if (loc) { context.report({ node: node, loc: loc, message: MESSAGE, data: msgContext, fix: getFixerFunction() }); } else { context.report({ node: node, message: MESSAGE, data: msgContext, fix: getFixerFunction() }); } }
javascript
{ "resource": "" }
q61518
getFixerFunction
validation
function getFixerFunction() { var rangeToFix = []; if (needed > gotten) { var spaces = "" + new Array(needed - gotten + 1).join(indentChar); // replace with repeat in future if (isLastNodeCheck === true) { rangeToFix = [ node.range[1] - 1, node.range[1] - 1 ]; } else { rangeToFix = [ node.range[0], node.range[0] ]; } return function(fixer) { return fixer.insertTextBeforeRange(rangeToFix, spaces); }; } else { if (isLastNodeCheck === true) { rangeToFix = [ node.range[1] - (gotten - needed) - 1, node.range[1] - 1 ]; } else { rangeToFix = [ node.range[0] - (gotten - needed), node.range[0] ]; } return function(fixer) { return fixer.removeRange(rangeToFix); }; } }
javascript
{ "resource": "" }
q61519
getNodeIndent
validation
function getNodeIndent(node, byLastLine, excludeCommas) { var token = byLastLine ? context.getLastToken(node) : context.getFirstToken(node); var src = context.getSource(token, token.loc.start.column); var regExp = excludeCommas ? indentPattern.excludeCommas : indentPattern.normal; var indent = regExp.exec(src); return indent ? indent[0].length : 0; }
javascript
{ "resource": "" }
q61520
isNodeFirstInLine
validation
function isNodeFirstInLine(node, byEndLocation) { var firstToken = byEndLocation === true ? context.getLastToken(node, 1) : context.getTokenBefore(node), startLine = byEndLocation === true ? node.loc.end.line : node.loc.start.line, endLine = firstToken ? firstToken.loc.end.line : -1; return startLine !== endLine; }
javascript
{ "resource": "" }
q61521
isNodeFirstArgument
validation
function isNodeFirstArgument(node) { if (!node.parent.arguments) { return false; } return equal(node, node.parent.arguments[0]); // var firstToken = context.getTokenBefore(node), // startLine = node.loc.start.line, // endLine = firstToken ? firstToken.loc.end.line : -1; // // var previous = findNodeOfInterest(firstToken); // // if (previous === undefined || getCallee(node.parent) === undefined) { // debugger; // } // // if (equal(previous, getCallee(node.parent))) { // return true; // } // // return startLine !== endLine; }
javascript
{ "resource": "" }
q61522
checkNodeIndent
validation
function checkNodeIndent(node, indent, excludeCommas) { var nodeIndent = getNodeIndent(node, false, excludeCommas); if ( node.type !== "ArrayExpression" && node.type !== "ObjectExpression" && nodeIndent !== indent && isNodeFirstInLine(node) ) { report(node, indent, nodeIndent); } }
javascript
{ "resource": "" }
q61523
checkNodesIndent
validation
function checkNodesIndent(nodes, indent, excludeCommas) { nodes.forEach(function(node) { if (node.type === "IfStatement" && node.alternate) { var elseToken = context.getTokenBefore(node.alternate); checkNodeIndent(elseToken, indent, excludeCommas); } checkNodeIndent(node, indent, excludeCommas); }); }
javascript
{ "resource": "" }
q61524
checkLastNodeLineIndent
validation
function checkLastNodeLineIndent(node, lastLineIndent) { var lastToken = context.getLastToken(node); var endIndent = getNodeIndent(lastToken, true); if (endIndent !== lastLineIndent && isNodeFirstInLine(node, true)) { report( node, lastLineIndent, endIndent, { line: lastToken.loc.start.line, column: lastToken.loc.start.column }, true ); } }
javascript
{ "resource": "" }
q61525
checkFirstNodeLineIndent
validation
function checkFirstNodeLineIndent(node, firstLineIndent) { var startIndent = getNodeIndent(node, false); if (startIndent !== firstLineIndent && isNodeFirstInLine(node)) { report( node, firstLineIndent, startIndent, {line: node.loc.start.line, column: node.loc.start.column} ); } }
javascript
{ "resource": "" }
q61526
getVariableDeclaratorNode
validation
function getVariableDeclaratorNode(node) { var parent = node.parent; while (parent.type !== "VariableDeclarator" && parent.type !== "Program") { parent = parent.parent; } return parent.type === "VariableDeclarator" ? parent : null; }
javascript
{ "resource": "" }
q61527
checkIndentInFunctionBlock
validation
function checkIndentInFunctionBlock(node) { // Search first caller in chain. // Ex.: // // Models <- Identifier // .User // .find() // .exec(function() { // // function body // }); // // Looks for 'Models' var calleeNode = node.parent; // FunctionExpression var indent; if (calleeNode.parent && (calleeNode.parent.type === "Property" || calleeNode.parent.type === "ArrayExpression")) { // If function is part of array or object, comma can be put at left indent = getNodeIndent(calleeNode, false, false); } else { // If function is standalone, simple calculate indent indent = getNodeIndent(calleeNode); } if (calleeNode.parent.type === "CallExpression") { var calleeParent = calleeNode.parent; if (calleeNode.type !== "FunctionExpression" && calleeNode.type !== "ArrowFunctionExpression") { if (calleeParent && calleeParent.loc.start.line < node.loc.start.line) { indent = getNodeIndent(calleeParent); } } else { if (isArgBeforeCalleeNodeMultiline(calleeNode) && calleeParent.callee.loc.start.line === calleeParent.callee.loc.end.line && !isNodeFirstInLine(calleeNode)) { indent = getNodeIndent(calleeParent); } } } // function body indent should be indent + indent size indent += indentSize; // check if the node is inside a variable var parentVarNode = getVariableDeclaratorNode(node); if (parentVarNode && isNodeInVarOnTop(node, parentVarNode)) { indent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind]; } if (node.body.length > 0) { checkNodesIndent(node.body, indent); } checkLastNodeLineIndent(node, indent - indentSize); }
javascript
{ "resource": "" }
q61528
isSingleLineNode
validation
function isSingleLineNode(node) { var lastToken = context.getLastToken(node), startLine = node.loc.start.line, endLine = lastToken.loc.end.line; return startLine === endLine; }
javascript
{ "resource": "" }
q61529
isFirstArrayElementOnSameLine
validation
function isFirstArrayElementOnSameLine(node) { if (node.type === "ArrayExpression" && node.elements[0]) { return node.elements[0].loc.start.line === node.loc.start.line && node.elements[0].type === "ObjectExpression"; } else { return false; } }
javascript
{ "resource": "" }
q61530
checkIndentInArrayOrObjectBlock
validation
function checkIndentInArrayOrObjectBlock(node) { // Skip inline if (isSingleLineNode(node)) { return; } var elements = (node.type === "ArrayExpression") ? node.elements : node.properties; // filter out empty elements example would be [ , 2] so remove first element as espree considers it as null elements = elements.filter(function(elem) { return elem !== null; }); // Skip if first element is in same line with this node if (elements.length > 0 && elements[0].loc.start.line === node.loc.start.line) { return; } var nodeIndent; var elementsIndent; var parentVarNode = getVariableDeclaratorNode(node); // TODO - come up with a better strategy in future if (isNodeFirstInLine(node)) { var parent = node.parent; var effectiveParent = parent; if (parent.type === "MemberExpression") { if (isNodeFirstInLine(parent)) { effectiveParent = parent.parent.parent; } else { effectiveParent = parent.parent; } } nodeIndent = getNodeIndent(effectiveParent); if (parentVarNode && parentVarNode.loc.start.line !== node.loc.start.line) { if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) { if (parentVarNode.loc.start.line === effectiveParent.loc.start.line) { nodeIndent = nodeIndent + (indentSize * options.VariableDeclarator[parentVarNode.parent.kind]); } else if ( parent.type === "ObjectExpression" || parent.type === "ArrayExpression" || parent.type === "CallExpression" || parent.type === "ArrowFunctionExpression" || parent.type === "NewExpression" ) { nodeIndent = nodeIndent + indentSize; } } } else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && effectiveParent.type !== "MemberExpression" && effectiveParent.type !== "ExpressionStatement" && effectiveParent.type !== "AssignmentExpression" && effectiveParent.type !== "Property") { nodeIndent = nodeIndent + indentSize; } elementsIndent = nodeIndent + indentSize; checkFirstNodeLineIndent(node, nodeIndent); } else { nodeIndent = getNodeIndent(node); elementsIndent = nodeIndent + indentSize; } // check if the node is a multiple variable declaration, if yes then make sure indentation takes into account // variable indentation concept if (isNodeInVarOnTop(node, parentVarNode)) { elementsIndent += indentSize * options.VariableDeclarator[parentVarNode.parent.kind]; } if (node.parent && node.parent.type === "CallExpression" && node.parent.arguments.length > 1 && isNodeFirstArgument(node) && isNodeOnSameLineAsPrevious(node) && isNextArgumentOnNextLine(node)) { elementsIndent += indentSize; } // Comma can be placed before property name checkNodesIndent(elements, elementsIndent, true); if (elements.length > 0) { // Skip last block line check if last item in same line if (elements[elements.length - 1].loc.end.line === node.loc.end.line) { return; } } var lastIndent = elementsIndent - indentSize; checkLastNodeLineIndent(node, lastIndent); }
javascript
{ "resource": "" }
q61531
isNodeBodyBlock
validation
function isNodeBodyBlock(node) { return node.type === "BlockStatement" || (node.body && node.body.type === "BlockStatement") || (node.consequent && node.consequent.type === "BlockStatement"); }
javascript
{ "resource": "" }
q61532
blockIndentationCheck
validation
function blockIndentationCheck(node) { // Skip inline blocks if (isSingleLineNode(node)) { return; } if (node.parent && ( node.parent.type === "FunctionExpression" || node.parent.type === "FunctionDeclaration" || node.parent.type === "ArrowFunctionExpression" )) { checkIndentInFunctionBlock(node); return; } var indent; var nodesToCheck = []; // For this statements we should check indent from statement begin // (not from block begin) var statementsWithProperties = [ "IfStatement", "WhileStatement", "ForStatement", "ForInStatement", "ForOfStatement", "DoWhileStatement" ]; if (node.parent && statementsWithProperties.indexOf(node.parent.type) !== -1 && isNodeBodyBlock(node)) { indent = getNodeIndent(node.parent); } else { indent = getNodeIndent(node); } if (node.type === "IfStatement" && node.consequent.type !== "BlockStatement") { nodesToCheck = [node.consequent]; } else if (util.isArray(node.body)) { nodesToCheck = node.body; } else { nodesToCheck = [node.body]; } if (nodesToCheck.length > 0) { checkNodesIndent(nodesToCheck, indent + indentSize); } if (node.type === "BlockStatement") { checkLastNodeLineIndent(node, indent); } }
javascript
{ "resource": "" }
q61533
checkIndentInVariableDeclarations
validation
function checkIndentInVariableDeclarations(node) { var elements = filterOutSameLineVars(node); var nodeIndent = getNodeIndent(node); var lastElement = elements[elements.length - 1]; var elementsIndent = nodeIndent + indentSize * options.VariableDeclarator[node.kind]; // Comma can be placed before declaration checkNodesIndent(elements, elementsIndent, true); // Only check the last line if there is any token after the last item if (context.getLastToken(node).loc.end.line <= lastElement.loc.end.line) { return; } var tokenBeforeLastElement = context.getTokenBefore(lastElement); if (tokenBeforeLastElement.value === ",") { // Special case for comma-first syntax where the semicolon is indented checkLastNodeLineIndent(node, getNodeIndent(tokenBeforeLastElement)); } else { checkLastNodeLineIndent(node, elementsIndent - indentSize); } }
javascript
{ "resource": "" }
q61534
expectedCaseIndent
validation
function expectedCaseIndent(node, switchIndent) { var switchNode = (node.type === "SwitchStatement") ? node : node.parent; var caseIndent; if (caseIndentStore[switchNode.loc.start.line]) { return caseIndentStore[switchNode.loc.start.line]; } else { if (typeof switchIndent === "undefined") { switchIndent = getNodeIndent(switchNode); } if (switchNode.cases.length > 0 && options.SwitchCase === 0) { caseIndent = switchIndent; } else { caseIndent = switchIndent + (indentSize * options.SwitchCase); } caseIndentStore[switchNode.loc.start.line] = caseIndent; return caseIndent; } }
javascript
{ "resource": "" }
q61535
factory
validation
function factory(name, attrs, fn) { if (arguments.length === 2) { fn = attrs; attrs = null; } factories.get(name).create(attrs, fn); }
javascript
{ "resource": "" }
q61536
define
validation
function define(type, Model) { if (arguments.length === 1) { Model = type; type = Model.prototype.__type || Model.modelName; } var factory = new Factory(Model); factories.set(type, factory) return factory; }
javascript
{ "resource": "" }
q61537
list
validation
function list(type, num, fn) { var records = []; var bail = false; var created = function(err, record) { if (bail) return; if (err) { bail = true; return fn(err); } records.push(record); if (records.length === num) { fn(null, records); } }; for (var i = 0; i < num; i++) { factory(type, created); } }
javascript
{ "resource": "" }
q61538
validation
function(size, units) { // Most common case first: Size is set to a number if (typeof size == 'number') { return size + (units || this.defaultUnit || 'px'); } // Size set to a value which means "auto" if (size === "" || size == "auto" || size === undefined || size === null) { return size || ''; } // Otherwise, warn if it's not a valid CSS measurement if (!this.unitRe.test(size)) { //<debug> if (Ext.isDefined(Ext.global.console)) { Ext.global.console.warn("Warning, size detected as NaN on Element.addUnits."); } //</debug> return size || ''; } return size; }
javascript
{ "resource": "" }
q61539
validation
function() { return Math.max(!Ext.isStrict ? document.body.scrollHeight : document.documentElement.scrollHeight, this.getViewportHeight()); }
javascript
{ "resource": "" }
q61540
validation
function ( iterable = null ) { this.front = null ; this.back = null ; this.length = 0 ; if ( iterable !== null ) { for ( let value of iterable ) this.push( value ) ; } }
javascript
{ "resource": "" }
q61541
LoaderCache
validation
function LoaderCache(options) { if (!(this instanceof LoaderCache)) { return new LoaderCache(options); } this.options = options || {}; this.defaultType = this.options.defaultType || 'sync'; this.types = []; this.decorate('resolve'); this.decorate('get'); }
javascript
{ "resource": "" }
q61542
validation
function(type, options, fn) { if (arguments.length === 1) { return this[type].iterator.fn; } if (typeof options === 'function') { fn = options; options = {}; } this[type] = new LoaderType(options, fn.bind(this)); this.setLoaderType(type); return this; }
javascript
{ "resource": "" }
q61543
validation
function(name/*, options, fns*/) { var args = utils.slice(arguments, 1); var opts = args.shift(); var type = this.getLoaderType(opts); this[type].set(name, this[type].resolve(args)); return this; }
javascript
{ "resource": "" }
q61544
validation
function(name, options, stack) { var args = utils.slice(arguments); var opts = {}; name = args.shift(); if (!utils.isLoader(options) && lazy.isObject(options)) { opts = args.shift(); } opts = opts || {}; var type = this.getLoaderType(opts); opts.loaderType = type; var inst = this[type]; var iterator = this.iterator(type); stack = inst.resolve(inst.get(name).concat(args)); var ctx = { app: this }; ctx.options = opts; ctx.iterator = inst.iterator; ctx.loaders = inst; return function () { var args = [].slice.call(arguments).filter(Boolean); var len = args.length, loaders = []; while (len-- > 1) { var arg = args[len]; if (!utils.isLoader(arg)) break; loaders.unshift(args.pop()); } // combine the `create` and collection stacks loaders = stack.concat(inst.resolve(loaders)); // if loading is async, move the done function to args if (type === 'async') { args.push(loaders.pop()); } loaders = inst.resolve(loaders); if (loaders.length === 0) { loaders = inst.resolve(opts.defaultLoader || []); } var wrapped = loaders.map(opts.wrap || utils.identity); // create the actual `load` function var load = iterator.call(this, wrapped); var res = load.apply(ctx, args); return res; }.bind(this); }
javascript
{ "resource": "" }
q61545
validation
function(cmp) { var me = this, newGroup = cmp, oldGroup; if(Ext.isString(cmp)) { newGroup = Ext.getCmp(newGroup); } if (newGroup === me.activeGroup) { return true; } oldGroup = me.activeGroup; if (me.fireEvent('beforegroupchange', me, newGroup, oldGroup) !== false) { me.activeGroup = newGroup; me.fireEvent('groupchange', me, newGroup, oldGroup); } else { return false; } return true; }
javascript
{ "resource": "" }
q61546
validation
function() { var me = this, delimiter = me.delimiter, val = me.getValue(); return Ext.isString(delimiter) ? val.join(delimiter) : val; }
javascript
{ "resource": "" }
q61547
compile
validation
function compile(content, options) { options = merge({ outputLanguage: 'es5', modules: 'commonjs', filename: '<unknown file>', sourceMap: false, cwd: process.cwd(), moduleName: false }, options || {}); var moduleName = options.moduleName; traceurOptions.reset(); merge(traceurOptions, options); var errorReporter = new ErrorReporter(); var sourceFile = new SourceFile(options.filename, content); var parser = new Parser(sourceFile, errorReporter); var tree = parser.parseModule(); var transformer; if (moduleName === true || options.modules == 'register' || options.modules == 'inline') { moduleName = options.filename.replace(/\.js$/, ''); moduleName = path.relative(options.cwd, moduleName).replace(/\\/g,'/'); } if (moduleName) { transformer = new AttachModuleNameTransformer(moduleName); tree = transformer.transformAny(tree); } if (options.outputLanguage.toLowerCase() === 'es6') { transformer = new PureES6Transformer(errorReporter); } else { transformer = new FromOptionsTransformer(errorReporter); } var transformedTree = transformer.transform(tree); if (errorReporter.hadError()) { return { js: null, errors: errorReporter.errors, sourceMap: null }; } var treeWriterOptions = {}; if (options.sourceMap) { treeWriterOptions.sourceMapGenerator = new SourceMapGenerator({ file: options.filename, sourceRoot: null }); } return { js: TreeWriter.write(transformedTree, treeWriterOptions), errors: errorReporter.errors, sourceMap: treeWriterOptions.sourceMap || null }; }
javascript
{ "resource": "" }
q61548
validation
function() { var me = this, value = me.textField.getValue(); if (value === '') { return null; } if (!me.regExpMode) { value = value.replace(me.regExpProtect, function(m) { return '\\' + m; }); } else { try { new RegExp(value); } catch (error) { me.statusBar.setStatus({ text: error.message, iconCls: 'x-status-error' }); return null; } // this is stupid if (value === '^' || value === '$') { return null; } } return value; }
javascript
{ "resource": "" }
q61549
validation
function() { var me = this, count = 0; me.view.refresh(); // reset the statusbar me.statusBar.setStatus({ text: me.defaultStatusText, iconCls: '' }); me.searchValue = me.getSearchValue(); me.indexes = []; me.currentIndex = null; if (me.searchValue !== null) { me.searchRegExp = new RegExp(me.searchValue, 'g' + (me.caseSensitive ? '' : 'i')); me.store.each(function(record, idx) { var td = Ext.fly(me.view.getNode(idx)).down('td'), cell, matches, cellHTML; while(td) { cell = td.down('.x-grid-cell-inner'); matches = cell.dom.innerHTML.match(me.tagsRe); cellHTML = cell.dom.innerHTML.replace(me.tagsRe, me.tagsProtect); // populate indexes array, set currentIndex, and replace wrap matched string in a span cellHTML = cellHTML.replace(me.searchRegExp, function(m) { count += 1; if (Ext.Array.indexOf(me.indexes, idx) === -1) { me.indexes.push(idx); } if (me.currentIndex === null) { me.currentIndex = idx; } return '<span class="' + me.matchCls + '">' + m + '</span>'; }); // restore protected tags Ext.each(matches, function(match) { cellHTML = cellHTML.replace(me.tagsProtect, match); }); // update cell html cell.dom.innerHTML = cellHTML; td = td.next(); } }, me); // results found if (me.currentIndex !== null) { me.getSelectionModel().select(me.currentIndex); me.statusBar.setStatus({ text: count + ' matche(s) found.', iconCls: 'x-status-valid' }); } } // no results found if (me.currentIndex === null) { me.getSelectionModel().deselectAll(); } // force textfield focus me.textField.focus(); }
javascript
{ "resource": "" }
q61550
validation
function() { var me = this, idx; if ((idx = Ext.Array.indexOf(me.indexes, me.currentIndex)) !== -1) { me.currentIndex = me.indexes[idx - 1] || me.indexes[me.indexes.length - 1]; me.getSelectionModel().select(me.currentIndex); } }
javascript
{ "resource": "" }
q61551
makeCtor
validation
function makeCtor (className) { function constructor () { // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61. return this.constructor.apply(this, arguments) || null; } //<debug> if (className) { constructor.displayName = className; } //</debug> return constructor; }
javascript
{ "resource": "" }
q61552
validation
function(config, existingEl) { config = config || {}; var me = this, dh = Ext.DomHelper, cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body, hm = config.hideMode, cls = Ext.baseCSSPrefix + (config.fixed && !(Ext.isIE6 || Ext.isIEQuirks) ? 'fixed-layer' : 'layer'); // set an "el" property that references "this". This allows // Ext.util.Positionable methods to operate on this.el.dom since it // gets mixed into both Element and Component me.el = me; if (existingEl) { me.dom = Ext.getDom(existingEl); } if (!me.dom) { me.dom = dh.append(pel, config.dh || { tag: 'div', cls: cls // primarily to give el 'position:absolute' or, if fixed, 'position:fixed' }); } else { me.addCls(cls); if (!me.dom.parentNode) { pel.appendChild(me.dom); } } if (config.id) { me.id = me.dom.id = config.id; } else { me.id = Ext.id(me.dom); } Ext.Element.addToCache(me); if (config.cls) { me.addCls(config.cls); } me.constrain = config.constrain !== false; // Allow Components to pass their hide mode down to the Layer if they are floating. // Otherwise, allow useDisplay to override the default hiding method which is visibility. // TODO: Have ExtJS's Element implement visibilityMode by using classes as in Mobile. if (hm) { me.setVisibilityMode(Ext.Element[hm.toUpperCase()]); if (me.visibilityMode == Ext.Element.ASCLASS) { me.visibilityCls = config.visibilityCls; } } else if (config.useDisplay) { me.setVisibilityMode(Ext.Element.DISPLAY); } else { me.setVisibilityMode(Ext.Element.VISIBILITY); } if (config.shadow) { me.shadowOffset = config.shadowOffset || 4; me.shadow = new Ext.Shadow({ offset: me.shadowOffset, mode: config.shadow, fixed: config.fixed }); me.disableShadow(); } else { me.shadowOffset = 0; } me.useShim = config.shim !== false && Ext.useShims; if (config.hidden === true) { me.hide(); } else { me.show(); } }
javascript
{ "resource": "" }
q61553
validation
function(err) { if(err) { defer.reject(err); } else { //remove the error object, send the info onwards [].shift.call(arguments); //now we have to do something funky here //if you expect more than one argument, we have to send in the argument object //and you pick out the appropriate arguments //if it's just one, we send the one argument like normal //this is the behavior chosen if(arguments.length > 1) defer.resolve(arguments); else defer.resolve.apply(defer, arguments); } }
javascript
{ "resource": "" }
q61554
readAnalyserConfig
validation
function readAnalyserConfig(analyserPath) { var filePath = path.join(analyserPath, 'config.json'); return readFile(filePath, {encoding: 'utf8'}) .then(function(fileContents){ try { return doResolve(JSON.parse(jsonWithComments(fileContents))); } catch(err){ return doReject(`Unable to parse config file for analyser '${analyserPath}'`, err); } }, function(err){ return doReject(`Unable to read config file for analyser '${analyserPath}'`, err); }); }
javascript
{ "resource": "" }
q61555
build
validation
function build(mode, system, cdef, out, cb) { var cmd = cdef.specific.processBuild || cdef.specific.build; var branch = ''; logger.info('building'); out.stdout('building'); if (!cmd) { return cb(null, {}); } if (!cdef.specific.repositoryUrl) { return cb(new Error('missing repositoryUrl'), {}); } //var parsed = parseGitUrl(cdef.specific.repositoryUrl).branch; var parsed = parseGitUrl(cdef.specific.repositoryUrl); if (parsed.branch) { branch = parsed.branch; } if (cdef.specific.commit) { var synchCommand = [ [ ' ( ' + 'test `git show-ref --hash refs/heads/' + branch +'` = ' + cdef.specific.commit, ' && ', 'git checkout -q ' + branch, ' ) ', ' || ', 'git checkout -q ' + cdef.specific.commit ].join(' '), 'echo checked out ' + cdef.specific.commit, ].join(' && '); executor.exec(mode, synchCommand, pathFromRepoUrl(system, cdef), out, function(err) { if (err) { return cb(err); } executor.exec(mode, cmd, pathFromRepoUrl(system, cdef), out, cb); }); } else { executor.exec(mode, cmd, pathFromRepoUrl(system, cdef), out, cb); } }
javascript
{ "resource": "" }
q61556
start
validation
function start(mode, target, system, containerDef, container, out, cb) { proc.start(mode, target, system, containerDef, container, out, cb); }
javascript
{ "resource": "" }
q61557
isIllegalArguments
validation
function isIllegalArguments(_ref) { var fn = _ref.fn; var cb = _ref.cb; var matcher = _ref.matcher; if (typeof fn !== 'function') { return Promise.reject(new Error('Expected fn to be a Function')); } if (typeof cb !== 'undefined' && typeof cb !== 'function') { return Promise.reject(new Error('Expected cb to be a Function')); } if (!(matcher instanceof RegExp) && ['function', 'string'].indexOf(typeof matcher === 'undefined' ? 'undefined' : _typeof(matcher)) === -1 && matcher.constructor !== Error.constructor) { return Promise.reject(new Error(UNRECOGNISED_MATCHER_ERR)); } return Promise.resolve(); }
javascript
{ "resource": "" }
q61558
catchAndMatch
validation
function catchAndMatch(fn, matcher, cb) { return isIllegalArguments({ fn: fn, matcher: matcher, cb: cb }).then(fn, function (err) { throw err; }).then(function () { // If we got here the function did not throw an error var error = new Error('No error thrown'); if (cb) cb(error); return Promise.reject(error); }, function (err) { // Error was thrown - check that it satisfies the matcher if (doesMatch({ matcher: matcher, err: err })) { if (cb) cb(); return Promise.resolve(); } var error = new Error('Error does not satisfy matcher'); if (cb) cb(error); return Promise.reject(error); }); }
javascript
{ "resource": "" }
q61559
exec
validation
function exec(cmd) { return new Promise( function (resolve, reject) { child_process.exec(cmd, function (error, stdout, stderr) { if (error) { reject(stderr.trim()); } else { resolve(stdout.trim()); } }); } ); }
javascript
{ "resource": "" }
q61560
listen
validation
function listen(name, callBack) { function f() { try { callBack.apply(this, arguments); } catch (e) { console.error(e); // eslint-disable-line no-console } } callbacks[callBack] = f; messageBus.bind(name, f); }
javascript
{ "resource": "" }
q61561
ImageDimensions
validation
function ImageDimensions (assetPath, registeredAssets, callback) { sassUtils.assertType(assetPath, "string"); sassUtils.assertType(registeredAssets, "map"); var self = this; var getPath = self.checkImagePath(assetPath.getValue(), registeredAssets); getPath.then(function (success) { var imageDimensions = self.getDimensions(success); imageDimensions.then(function (dimensions) { callback(null, dimensions); }, function (err) { callback(err, null); }); }, function (err) { callback(err, null); }); }
javascript
{ "resource": "" }
q61562
clientReadyMessage
validation
function clientReadyMessage (cookies, user, pass) { return { type: 'connected', user: user, sessionID: cookies.sessionID, pass: pass } }
javascript
{ "resource": "" }
q61563
CouchDBCache
validation
function CouchDBCache(options) { var self = this; options = options || {}; this.expireAfterSeconds = options.expireAfterSeconds || 60; this.connection = Promise.resolve() .then(function () { return options.auth ? this.auth(options.auth.username, options.auth.password) : null; }) .then(function (cookie) { return nano({ url: options.url || (options.protocol + '://' + options.host + ':' + options.port), cookie: cookie }); }); // create database if it doesn't exist this.db = this.connection.then(function (connection) { var dbName = options.db || 'openamagent'; return Promise.promisify(connection.db.create.bind(connection.db))(dbName) .catch(function () { // ignore }) .then(function () { return connection.use(dbName); }); }); }
javascript
{ "resource": "" }
q61564
validation
function (obj) { var res = {}, i; for (i in obj) { res[i] = obj[i]; } return res; }
javascript
{ "resource": "" }
q61565
validation
function (rootPath) { // public properties this.plugins = {}; this.mainTree = {}; this.groups = {}; this.resolved = false; if (rootPath) { if (typeof rootPath !== 'string') { throw new Error( 'Invalid rootPath parameter creating tree' ); } this.rootPath = rootPath; } else { // no argument passed this.rootPath = '.'; } }
javascript
{ "resource": "" }
q61566
configure
validation
function configure(pkg, env, target) { const isModule = target === 'module'; const input = `src/index.js`; const deps = [] .concat(pkg.dependencies ? Object.keys(pkg.dependencies) : []) .concat(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : []); const plugins = [ // Allow Rollup to resolve modules from `node_modules`, since it only // resolves local modules by default. resolve({ browser: true }), // Convert JSON imports to ES6 modules. json(), // Replace `process.env.NODE_ENV` with its value, which enables some modules // like React and Slate to use their production variant. replace({ 'process.env.NODE_ENV': JSON.stringify(env) }), // Register Node.js builtins for browserify compatibility. builtins(), // Use Babel to transpile the result, limiting it to the source code. babel({ include: [`src/**`] }), // Register Node.js globals for browserify compatibility. globals() ].filter(Boolean); if (isModule) { return { plugins, input, output: [ { file: `${pkg.module}`, format: 'es', sourcemap: true }, { file: `${pkg.main}`, format: 'cjs', exports: 'named', sourcemap: true } ], // We need to explicitly state which modules are external, meaning that // they are present at runtime. In the case of non-UMD configs, this means // all non-Slate packages. external: id => !!deps.find(dep => dep === id || id.startsWith(`${dep}/`)) }; } return undefined; }
javascript
{ "resource": "" }
q61567
validation
function () { var requiredRules = [ // This one comes out of the box with parsley 'required', // These ones were added with this library 'requiredIf', 'requiredUnless', 'requiredWith', 'requiredWithAll', 'requiredWithout', 'requiredWithoutAll' ]; var requiredRulesFound = []; // Loop over the list to check if they're defined on the field. requiredRules.forEach(function (rule) { if ('undefined' !== typeof this.constraintsByName[rule]) { requiredRulesFound.push(rule); } }, this); // If there's not one required rule, return false if (requiredRulesFound.length == 0) return false; // If parsley's on required rule was found if (requiredRulesFound.indexOf('required') >= 0) { // Check if the flag is set to true return false !== this.constraintsByName.required.requirements; } return true; }
javascript
{ "resource": "" }
q61568
validation
function(headers, callback) { // setup all variables var xhr = new XMLHttpRequest(), url = options.url, type = options.type, async = options.async || true, // blob or arraybuffer. Default is blob dataType = options.responseType || "blob", data = options.data || null, username = options.username || null, password = options.password || null; xhr.addEventListener('load', function() { var data = {}; data[options.dataType] = xhr.response; // make callback and send data callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders()); }); xhr.addEventListener('error', function() { var data = {}; data[options.dataType] = xhr.response; // make callback and send data callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders()); }); xhr.open(type, url, async, username, password); // setup custom headers for (var i in headers) { xhr.setRequestHeader(i, headers[i]); } xhr.responseType = dataType; xhr.send(data); }
javascript
{ "resource": "" }
q61569
compose
validation
function compose (/* [func,] */) { var args = argsToArray(arguments); return function (arg0) { return args.reduceRight(function (value, arg){ return arg(value); }, arg0); }; }
javascript
{ "resource": "" }
q61570
curryN
validation
function curryN (fn, executeArity) { var curriedArgs = restArgs(arguments, 2); return function () { var args = argsToArray(arguments), concatedArgs = replacePlaceHolders(curriedArgs, args), placeHolders = concatedArgs.filter(isPlaceholder), canBeCalled = (concatedArgs.length - placeHolders.length >= executeArity) || !executeArity; return !canBeCalled ? curryN.apply(null, [fn, executeArity].concat(concatedArgs)) : fn.apply(null, concatedArgs); }; }
javascript
{ "resource": "" }
q61571
replacePlaceHolders
validation
function replacePlaceHolders (array, args) { var out = array.map(function (element) { return ! (element instanceof PlaceHolder) ? element : (args.length > 0 ? args.shift() : element); }); return args.length > 0 ? out.concat(args) : out; }
javascript
{ "resource": "" }
q61572
classOf
validation
function classOf (value) { var retVal, valueType, toString; if (typeof value === _undefined) { retVal = _Undefined; } else if (value === null) { retVal = _Null; } else { toString = value.toString.name === 'toString' ? Object.prototype.toString : value.toString; valueType = toString.call(value); retVal = valueType.substring(8, valueType.length - 1); if (retVal === _Number && isNaN(value)) { retVal = 'NaN'; } } return retVal; }
javascript
{ "resource": "" }
q61573
forEach
validation
function forEach (arrayLike, callback, context) { var classOfArrayLike = sjl.classOf(arrayLike); switch (classOfArrayLike) { case _Array: case 'Set': case 'SjlSet': case 'SjlMap': case 'Map': arrayLike.forEach(callback, context); break; case _Object: forEachInObj(arrayLike, callback, context); break; default: throw new TypeError('sjl.forEach takes only ' + '`Array`, `Object`, `Map`, `Set`, `SjlSet`, and `SjlMap` objects. ' + 'Type passed in: `' + classOfArrayLike + '`.'); } }
javascript
{ "resource": "" }
q61574
classOfIsMulti
validation
function classOfIsMulti (value, type /**[,type...] **/) { return (sjl.restArgs(arguments, 1)).some(function (_type) { return classOfIs(value, _type); }); }
javascript
{ "resource": "" }
q61575
isEmpty
validation
function isEmpty(value) { var classOfValue = classOf(value), retVal; // If value is an array or a string if (classOfValue === _Array || classOfValue === _String) { retVal = value.length === 0; } else if ((classOfValue === _Number && value !== 0) || (classOfValue === _Function)) { retVal = false; } else if (classOfValue === _Object) { retVal = isEmptyObj(value); } // If value is `0`, `false`, or is not set (!isset) then `value` is empty. else { retVal = !isset(value) || value === 0 || value === false; } return retVal; }
javascript
{ "resource": "" }
q61576
implode
validation
function implode (list, separator) { var retVal = '', prototypeOfList = Object.getPrototypeOf(list); if (isArray(list)) { retVal = list.join(separator); } else if (prototypeOfList.constructor.name === 'Set' || prototypeOfList.constructor.name === 'SjlSet') { retVal = []; list.forEach(function (value) { retVal.push(value); }); retVal = retVal.join(separator); } return retVal; }
javascript
{ "resource": "" }
q61577
searchObj
validation
function searchObj (ns_string, objToSearch) { var parts = ns_string.split('.'), parent = objToSearch, classOfObj = classOf(objToSearch), i; throwTypeErrorIfNotOfType('sjl.searchObj', 'ns_string', ns_string, String); if (classOfObj !== _Object && objToSearch instanceof Function === false) { throw new TypeError ('sjl.searchObj expects `objToSearch` to be of type object ' + 'or an instance of `Function`. Type received: ' + classOfObj); } for (i = 0; i < parts.length; i += 1) { if (parts[i] in parent === false || isUndefined(parent[parts[i]])) { parent = undefined; break; } parent = parent[parts[i]]; } return parent; }
javascript
{ "resource": "" }
q61578
extend
validation
function extend(o, p, deep) { // If `o` or `p` are not set bail if (!o || !p) { return o; } // Merge all props from `p` to `o` Object.keys(p).forEach(function (prop) { // For all props in p. // If property is present on target (o) and is not writable, skip iteration var propDescription = Object.getOwnPropertyDescriptor(o, prop); if (propDescription && !(isset(propDescription.get) && isset(propDescription.set)) && !propDescription.writable) { return; } if (deep === true) { if (isObject(p[prop]) && isObject(o[prop]) && !isEmptyObj(p[prop])) { extend(o[prop], p[prop], deep); } else { o[prop] = p[prop]; } } else { o[prop] = p[prop]; } }); return o; }
javascript
{ "resource": "" }
q61579
extendMulti
validation
function extendMulti () { var args = argsToArray(arguments), deep = extractBoolFromArrayStart(args), arg0 = args.shift(); // Extend object `0` with other objects args.forEach(function (arg) { // Extend `arg0` if `arg` is an object if (isObject(arg)) { extend(arg0, arg, deep); } }); return arg0; }
javascript
{ "resource": "" }
q61580
normalizeArgsForDefineSubClass
validation
function normalizeArgsForDefineSubClass (superClass, constructor, methods, statics) { superClass = superClass || Object.create(Object.prototype); // Snatched statics var _statics; // Should extract statics? if (isFunction(superClass)) { // Extract statics _statics = Object.keys(superClass).reduce(function (agg, key) { if (key === 'extend' || key === 'extendWith') { return agg; } agg[key] = superClass[key]; return agg; }, {}); } // Re-arrange args if constructor is object if (isObject(constructor)) { statics = methods; methods = clone(constructor); constructor = ! isFunction(methods.constructor) ? standInConstructor(superClass) : methods.constructor; unset(methods, 'constructor'); } // Ensure constructor constructor = isset(constructor) ? constructor : standInConstructor(superClass); // Returned normalized args return { constructor: constructor, methods: methods, statics: extend(_statics || {}, statics || {}, true), superClass: superClass }; }
javascript
{ "resource": "" }
q61581
makeExtendableConstructor
validation
function makeExtendableConstructor (constructor) { var extender = function (constructor_, methods_, statics_) { return defineSubClass(constructor, constructor_, methods_, statics_); }; /** * Extends a new copy of self with passed in parameters. * @memberof class:sjl.stdlib.Extendable * @static sjl.stdlib.Extendable.extend * @param constructor {Function|Object} - Required. Note: if is an object, then other params shift over by 1 (`methods` becomes `statics` and this param becomes `methods`). * @param methods {Object|undefined} - Methods. Optional. Note: If `constructor` param is an object, this gets cast as `statics` param. Also for overriding * @param statics {Object|undefined} - Static methods. Optional. Note: If `constructor` param is an object, it is not used. */ constructor.extend = constructor.extendWith = extender; // Return constructor return constructor; }
javascript
{ "resource": "" }
q61582
defineSubClassPure
validation
function defineSubClassPure (superClass, constructor, methods, statics) { var normalizedArgs = normalizeArgsForDefineSubClass.apply(null, arguments), _superClass = normalizedArgs.superClass, _statics = normalizedArgs.statics, _constructor = normalizedArgs.constructor, _methods = normalizedArgs.methods; // Set prototype _constructor.prototype = Object.create(_superClass.prototype); // Define constructor Object.defineProperty(_constructor.prototype, 'constructor', {value: _constructor}); // Extend constructor extend(_constructor.prototype, _methods); extend(_constructor, _statics, true); // Return constructor return _constructor; }
javascript
{ "resource": "" }
q61583
throwTypeErrorIfEmpty
validation
function throwTypeErrorIfEmpty (prefix, paramName, value, type, suffix) { throwTypeErrorIfEmptyOrNotOfType (prefix, paramName, value, type, suffix); }
javascript
{ "resource": "" }
q61584
valueOrDefault
validation
function valueOrDefault (value, defaultValue, type) { defaultValue = typeof defaultValue === _undefined ? null : defaultValue; var retVal; if (isset(type)) { retVal = issetAndOfType.apply(null, [value].concat(sjl.restArgs(arguments, 2))) ? value : defaultValue; } else { retVal = isset(value) ? value : defaultValue; } return retVal; }
javascript
{ "resource": "" }
q61585
defineEnumProp
validation
function defineEnumProp(obj, key, value) { Object.defineProperty(obj, key, { value: value, enumerable: true }); }
javascript
{ "resource": "" }
q61586
unConfigurableNamespace
validation
function unConfigurableNamespace(ns_string, objToSearch, valueToSet) { var parent = objToSearch, shouldSetValue = typeof valueToSet !== _undefined, hasOwnProperty; ns_string.split('.').forEach(function (key, i, parts) { hasOwnProperty = parent.hasOwnProperty(key); if (i === parts.length - 1 && shouldSetValue && !hasOwnProperty) { defineEnumProp(parent, key, valueToSet); } else if (typeof parent[key] === _undefined && !hasOwnProperty) { defineEnumProp(parent, key, {}); } parent = parent[key]; }); return parent; }
javascript
{ "resource": "" }
q61587
changeCaseOfFirstChar
validation
function changeCaseOfFirstChar(str, func, thisFuncsName) { var search, char, right, left; // If typeof `str` is not of type "String" then bail throwTypeErrorIfNotOfType(thisFuncsName, 'str', str, _String); // Search for first alpha char search = str.search(/[a-z]/i); // If alpha char if (isNumber(search) && search > -1) { // Make it lower case char = str.substr(search, 1)[func](); // Get string from `char`'s index right = str.substr(search + 1, str.length - 1); // Get string upto `char`'s index left = search !== 0 ? str.substr(0, search) : ''; // Concatenate original string with lower case char in it str = left + char + right; } return str; }
javascript
{ "resource": "" }
q61588
extractBoolFromArray
validation
function extractBoolFromArray(array, startOrEndBln) { var extractedValue = extractFromArrayAt( array, startOrEndBln ? 0 : array.length - 1, _Boolean, false )[0]; return isBoolean(extractedValue) ? extractedValue : false; }
javascript
{ "resource": "" }
q61589
mergeOnPropsMulti
validation
function mergeOnPropsMulti (obj1, obj2) { var args = argsToArray(arguments), deep = extractBoolFromArrayStart(args), arg0 = args.shift(); // Extend object `0` with other objects args.forEach(function (arg) { if (!isObject(arg)) { return; } // Extend `arg0` with `arg` mergeOnProps(arg0, arg, deep); }); return arg0; }
javascript
{ "resource": "" }
q61590
validation
function (keyOrNsKey, value) { var self = this; if (sjl.isObject(keyOrNsKey)) { sjl.extend.apply(sjl, [true, self].concat(sjl.argsToArray(arguments))); } else if (sjl.isString(keyOrNsKey)) { sjl.autoNamespace(keyOrNsKey, self, value); } else if (sjl.isset(keyOrNsKey)) { throw new TypeError(contextName + '.set only allows strings or objects as it\'s first parameter. ' + 'Param type received: `' + sjl.classOf(keyOrNsKey) + '`.'); } return self; }
javascript
{ "resource": "" }
q61591
validation
function () { var self = this; return self.valid() ? { done: false, value: self._values[self.pointer] } : { done: true }; }
javascript
{ "resource": "" }
q61592
validation
function (callback, context) { var self = this, values = self._values; context = context || self; self._keys.forEach(function (key, index, keys) { callback.call(context, values[index], key, keys); }); return this; }
javascript
{ "resource": "" }
q61593
validation
function (value) { var _index = this._values.indexOf(value); if (_index > -1 && _index <= this._values.length) { this._values.splice(_index, 1); } return this; }
javascript
{ "resource": "" }
q61594
validation
function (key) { if (this.has(key)) { var _index = this._keys.indexOf(key); this._values.splice(_index, 1); this._keys.splice(_index, 1); } return this; }
javascript
{ "resource": "" }
q61595
validation
function (key, value) { var index = this._keys.indexOf(key); if (index > -1) { this._keys[index] = key; this._values[index] = value; } else { this._keys.push(key); this._values.push(value); } return this; }
javascript
{ "resource": "" }
q61596
validation
function (object) { sjl.throwTypeErrorIfNotOfType(SjlMap.name, 'object', object, 'Object', 'Only `Object` types allowed.'); var self = this, entry, objectIt = new ObjectIterator(object); while (objectIt.valid()) { entry = objectIt.next(); self.set(entry.value[0], entry.value[1]); } return self; }
javascript
{ "resource": "" }
q61597
validation
function () { var self = this, out = {}; this._keys.forEach(function (key, i) { out[key] = self._values[i]; }); return out; }
javascript
{ "resource": "" }
q61598
validation
function () { var next = Iterator.prototype.next.call(this); if (!next.done && this.wrapItems) { next.value = next.value.value; } return next; }
javascript
{ "resource": "" }
q61599
validation
function () { return this.sort().wrapItems ? new ObjectIterator(this._keys, this._values.map(function (item) { return item.value; })) : new SjlMap.prototype.entries.call(this.sort()); }
javascript
{ "resource": "" }