_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q51500
train
function(forceRefresh) { if (cachedProjectData && !forceRefresh) { Logger.debug('ProjectsService: returning cached project data'); return $q.when(cachedProjectData); } Logger.debug('ProjectsService: listing projects, force refresh', forceRefresh); ...
javascript
{ "resource": "" }
q51501
train
function(params, stateData) { // Handle an error response from the OAuth server if (params.error) { authLogger.log("RedirectLoginService.finish(), error", params.error, params.error_description, params.error_uri); return $q.reject({ error: params.error, ...
javascript
{ "resource": "" }
q51502
train
function (notification) { if (!notification.id) { return false; } return _.some(notifications, function(next) { return !next.hidden && notification.id === next.id; }); }
javascript
{ "resource": "" }
q51503
_factoryDomInit
train
function _factoryDomInit() { // Add class to sliding elements slidingElements.forEach( function( item ) { addClass( item, slidingElementsClass ); }); // DOM Fallbacks when CSS transform 3d not available if ( !has3d ) {...
javascript
{ "resource": "" }
q51504
train
function( el, options ) { // Get length of instantiated Offsides array var offsideId = instantiatedOffsides.length || 0, // Instantiate new Offside instance offsideInstance = createOffsideInstance( el, options, offsideId ); ...
javascript
{ "resource": "" }
q51505
train
function ( el, options ) { /* * When Offside is called for the first time, * inject a singleton-factory object * as a static method in "offside.factory". * * Offside factory serves the following purposes: * ...
javascript
{ "resource": "" }
q51506
start
train
async function start() { const numDimensions = 100; const numPoints = 10000; const data = generateData(numDimensions, numPoints); const coordinates = await computeEmbedding(data, numPoints); showEmbedding(coordinates); }
javascript
{ "resource": "" }
q51507
showEmbedding
train
function showEmbedding(data) { const margin = {top: 20, right: 15, bottom: 60, left: 60}; const width = 800 - margin.left - margin.right; const height = 800 - margin.top - margin.bottom; const x = d3.scaleLinear().domain([0, 1]).range([0, width]); const y = d3.scaleLinear().domain([0, 1]).range([height, 0]);...
javascript
{ "resource": "" }
q51508
extractEventHandlers
train
function extractEventHandlers(props) { let result = { eventHandlers: {}, options: {} }; for (let key in props) { if (ReactBrowserEventEmitter.registrationNameModules.hasOwnProperty(key)) { result.eventHandlers[key] = props[key]; } else { result.options...
javascript
{ "resource": "" }
q51509
render
train
function render(element) { // Is the given element valid? invariant( ReactElement.isValidElement(element), 'render(): You must pass a valid ReactElement.' ); const id = ReactInstanceHandles.createReactRootID(); // Creating a root id & creating the screen const component = instantiat...
javascript
{ "resource": "" }
q51510
train
function(max) { // gives a number between 0 (inclusive) and max (exclusive) var rand = crypto.randomBytes(1)[0]; while (rand >= 256 - (256 % max)) { rand = crypto.randomBytes(1)[0]; } return rand % max; }
javascript
{ "resource": "" }
q51511
onComment
train
function onComment(isBlock, text, _s, _e, sLoc, eLoc) { var tRegex = /test\s*>\s*(.*)/i; var aRegex = /#\s*(.*)/i; var isTest = R.test(tRegex); var extractTest = R.pipe(R.match(tRegex), R.last(), R.trim()); var isAssertion = R.test(aRegex); var extractAssertion = R.pipe(R.match(aRegex), R.last(), R.trim())...
javascript
{ "resource": "" }
q51512
charCode
train
function charCode(chr) { var esc = /^\\[xu](.+)/.exec(chr); return esc ? dec(esc[1]) : chr.charCodeAt(chr.charAt(0) === '\\' ? 1 : 0); }
javascript
{ "resource": "" }
q51513
invertBmp
train
function invertBmp(range) { var output = ''; var lastEnd = -1; XRegExp.forEach( range, /(\\x..|\\u....|\\?[\s\S])(?:-(\\x..|\\u....|\\?[\s\S]))?/, function(m) { var start = charCode(m[1]); if (start > (lastEnd + 1)) { ...
javascript
{ "resource": "" }
q51514
cacheInvertedBmp
train
function cacheInvertedBmp(slug) { var prop = 'b!'; return ( unicode[slug][prop] || (unicode[slug][prop] = invertBmp(unicode[slug].bmp)) ); }
javascript
{ "resource": "" }
q51515
augment
train
function augment(regex, captureNames, xSource, xFlags, isInternalOnly) { var p; regex[REGEX_DATA] = { captureNames: captureNames }; if (isInternalOnly) { return regex; } // Can't auto-inherit these since the XRegExp constructor returns a nonprimitive value if (regex.__prot...
javascript
{ "resource": "" }
q51516
getNativeFlags
train
function getNativeFlags(regex) { return hasFlagsProp ? regex.flags : // Explicitly using `RegExp.prototype.toString` (rather than e.g. `String` or concatenation // with an empty string) allows this to continue working predictably when // `XRegExp.proptotype.toString` is overridden ...
javascript
{ "resource": "" }
q51517
runTokens
train
function runTokens(pattern, flags, pos, scope, context) { var i = tokens.length, leadChar = pattern.charAt(pos), result = null, match, t; // Run in reverse insertion order while (i--) { t = tokens[i]; if ( (t.leadChar && t.leadChar !== leadChar) |...
javascript
{ "resource": "" }
q51518
setNatives
train
function setNatives(on) { RegExp.prototype.exec = (on ? fixed : nativ).exec; RegExp.prototype.test = (on ? fixed : nativ).test; String.prototype.match = (on ? fixed : nativ).match; String.prototype.replace = (on ? fixed : nativ).replace; String.prototype.split = (on ? fixed : nativ).split; feat...
javascript
{ "resource": "" }
q51519
hoistFunctionDeclaration
train
function hoistFunctionDeclaration(ast, hoisteredFunctions) { var key, child, startIndex = 0; if (ast.body) { var newBody = []; if (ast.body.length > 0) { // do not hoister function declaration before J$.Fe or J$.Se if (ast.body[0].type === 'ExpressionStatement') {...
javascript
{ "resource": "" }
q51520
transformString
train
function transformString(code, visitorsPost, visitorsPre) { // StatCollector.resumeTimer("parse"); // console.time("parse") // var newAst = esprima.parse(code, {loc:true, range:true}); var newAst = acorn.parse(code, {locations: true, ecmaVersion: 6 }); // console.timeEnd("parse") //...
javascript
{ "resource": "" }
q51521
instrumentCode
train
function instrumentCode(options) { var aret, skip = false; var isEval = options.isEval, code = options.code, thisIid = options.thisIid, inlineSource = options.inlineSource, url = options.url; iidSourceInfo = {}; initializeIIDCounters(isEval); instCodeFileName = optio...
javascript
{ "resource": "" }
q51522
R
train
function R(iid, name, val, flags) { var aret; var bFlags = decodeBitPattern(flags, 2); // [isGlobal, isScriptLocal] if (sandbox.analysis && sandbox.analysis.read) { aret = sandbox.analysis.read(iid, name, val, bFlags[0], bFlags[1]); if (aret) { val = aret...
javascript
{ "resource": "" }
q51523
A
train
function A(iid, base, offset, op, flags) { var bFlags = decodeBitPattern(flags, 1); // [isComputed] // avoid iid collision: make sure that iid+2 has the same source map as iid (@todo) var oprnd1 = G(iid+2, base, offset, createBitPattern(bFlags[0], true, false)); return function (oprnd2) ...
javascript
{ "resource": "" }
q51524
C2
train
function C2(iid, right) { var aret, result; // avoid iid collision; iid may not have a map in the sourcemap result = B(iid+1, "===", switchLeft, right, createBitPattern(false, false, true)); if (sandbox.analysis && sandbox.analysis.conditional) { aret = sandbox.analysis.con...
javascript
{ "resource": "" }
q51525
C
train
function C(iid, left) { var aret; if (sandbox.analysis && sandbox.analysis.conditional) { aret = sandbox.analysis.conditional(iid, left); if (aret) { left = aret.result; } } lastVal = left; return (lastComputedValue = left); ...
javascript
{ "resource": "" }
q51526
accumulateData
train
function accumulateData(chunk, enc, cb) { this.data = this.data == null ? chunk : Buffer.concat([this.data,chunk]);; cb(); }
javascript
{ "resource": "" }
q51527
includedFile
train
function includedFile(fileName) { var relativePath = fileName.substring(appDir.length + 1); var result = false; for (var i = 0; i < onlyIncludeList.length; i++) { var prefix = onlyIncludeList[i]; if (relativePath.indexOf(prefix) === 0) { ...
javascript
{ "resource": "" }
q51528
train
function () { var outputDir = path.join(copyDir, jalangiRuntimeDir); mkdirp.sync(outputDir); var copyFile = function (srcFile) { if (jalangiRoot) { srcFile = path.join(jalangiRoot, srcFile); } var outputFile = path.j...
javascript
{ "resource": "" }
q51529
setupConfig
train
function setupConfig(instHandler) { var conf = J$.Config; conf.INSTR_READ = instHandler.instrRead; conf.INSTR_WRITE = instHandler.instrWrite; conf.INSTR_GETFIELD = instHandler.instrGetfield; conf.INSTR_PUTFIELD = instHandler.instrPutfield; conf.INSTR_BINARY = instHandler.instrBinary; conf.IN...
javascript
{ "resource": "" }
q51530
clearConfig
train
function clearConfig() { var conf = J$.Config; conf.INSTR_READ = null; conf.INSTR_WRITE = null; conf.INSTR_GETFIELD = null; conf.INSTR_PUTFIELD = null; conf.INSTR_BINARY = null; conf.INSTR_PROPERTY_BINARY_ASSIGNMENT = null; conf.INSTR_UNARY = null; conf.INSTR_LITERAL = null; conf...
javascript
{ "resource": "" }
q51531
runChildAndCaptureOutput
train
function runChildAndCaptureOutput(forkedProcess) { var stdout_parts = [], stdoutLength = 0, stderr_parts = [], stderrLength = 0, deferred = Q.defer(); forkedProcess.stdout.on('data', function (data) { stdout_parts.push(data); stdoutLength += data.length; }); forkedProcess.stderr....
javascript
{ "resource": "" }
q51532
analyze
train
function analyze(script, clientAnalyses, initParam) { var directJSScript = path.resolve(__dirname, "../commands/direct.js"); var cliArgs = []; if (!script) { throw new Error("must provide a script to analyze"); } if (!clientAnalyses) { throw new Error("must provide an analysis to run...
javascript
{ "resource": "" }
q51533
tryRemoteLog2
train
function tryRemoteLog2() { trying = false; remoteBuffer.shift(); if (remoteBuffer.length === 0) { if (cb) { cb(); cb = undefined; } } tryRemoteLog(); }
javascript
{ "resource": "" }
q51534
serialize
train
function serialize(root) { // Stores a pointer to the most-recently encountered node representing a function or a // top-level script. We need this stored pointer since a function expression or declaration // has no associated IID, but we'd like to have the ASTs as entries in the table. Instea...
javascript
{ "resource": "" }
q51535
computeTopLevelExpressions
train
function computeTopLevelExpressions(ast) { var exprDepth = 0; var exprDepthStack = []; var topLevelExprs = []; var visitorIdentifyTopLevelExprPre = { "CallExpression":function (node) { if (node.callee.type === 'MemberExpression' && node.cal...
javascript
{ "resource": "" }
q51536
createFilenameForScript
train
function createFilenameForScript(url) { // TODO make this much more robust console.log("url:" + url); var parsed = urlParser.parse(url); if (inlineRegexp.test(url)) { return parsed.hash.substring(1) + ".js"; } else { return parsed.pathname.substring(parsed.pathname.lastIndexOf("/") +...
javascript
{ "resource": "" }
q51537
train
function(uri) { var original_segments = window.location.pathname.split('/'); var route_segments = uri.split('/'); var route_length = route_segments.length; var params = {}; for (var i = 1; i < route_length; i++) { if (route_segments[i].indexOf('{') !== -1) { ...
javascript
{ "resource": "" }
q51538
train
function(uri) { if (this._routes[uri] !== undefined) { return uri; } for (var route in this._routes) { if (this.is(route, uri)) { return route; } } return false; }
javascript
{ "resource": "" }
q51539
train
function(uri) { if (this.defined(uri)) { history.pushState(null, null, uri); var event = new CustomEvent('onRouteChange'); event.route = uri; document.dispatchEvent(event, uri); } else { console.error('Route "' + uri + '" is not defined.'); ...
javascript
{ "resource": "" }
q51540
iteratorFor
train
function iteratorFor(items) { var iterator = { next: function next() { var value = items.shift(); return { done: value === undefined, value: value }; } }; if (support.iterable) { iterator[Symbol.iterator] = function () { return iterator; }; } return ...
javascript
{ "resource": "" }
q51541
addEventOnce
train
function addEventOnce(element, eventName, eventListener) { var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500; var timeout = 0; return addEvent(element, eventName, function (e) { clearTimeout(timeout); timeout = setTimeout(function () { eventListener(e); }, dela...
javascript
{ "resource": "" }
q51542
addEventKeyNavigation
train
function addEventKeyNavigation(element, items, itemSelectCallback) { var itemSwitchCallback = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; var currentItemIndex = null; for (var k = 0; k < items.length; k++) { if (items[k].hasAttribute('aria-selected')) { currentItemIndex =...
javascript
{ "resource": "" }
q51543
checkPromise
train
function checkPromise(index) { var res = cb(callbacks[index]); // actually calling callback if (res instanceof Promise) { res.then(function (cbRes) { if (cbRes !== false) { // keep going if (index > 0) { checkPromise(index - 1); } ...
javascript
{ "resource": "" }
q51544
rgbaToColorMatrix
train
function rgbaToColorMatrix(red, green, blue) { var alpha = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0; var decToFloat = function decToFloat(value) { return Math.round(value / 255 * 10) / 10; }; var redFloat = decToFloat(red); var greenFloat = decToFloat(green); var blueFloat ...
javascript
{ "resource": "" }
q51545
syncUI
train
function syncUI(customSelect, defaultValue, isMultiple) { var _this2 = this; console.log(defaultValue, isMultiple); var menuItems = this.getMenuItems(customSelect); var tglBtn = this.getToggleBtn(customSelect); var hasSelected = false; [].forEach.call(menuItems, function (menuItem) { if (...
javascript
{ "resource": "" }
q51546
getDefaultValue
train
function getDefaultValue(customSelect) { var val = customSelect.getAttribute('value'); if (val === null) { return ''; } var firstChar = val[0]; if (firstChar === undefined) { return ''; } else if (firstChar === '[') { return JSON.parse(val); } return val; }
javascript
{ "resource": "" }
q51547
getSelectedValue
train
function getSelectedValue(customSelect) { var hiddenSelect = this.UI.getHiddenSelect(customSelect); if (this.isMultiple(customSelect)) { var selectedOptions = []; [].forEach.call(hiddenSelect.options, function (option) { if (option.selected) { selectedOptions.push(option.value); ...
javascript
{ "resource": "" }
q51548
_attachChangeAndDefaultFileEvent
train
function _attachChangeAndDefaultFileEvent(form_id) { var _this = this; var elements = this._collection[form_id].getInputs(); [].forEach.call(elements, function (form_control) { _this.__attachSingleChangeEvent(form_id, form_control); _this.__observeSingleValueChange(form...
javascript
{ "resource": "" }
q51549
_parseFormControl
train
function _parseFormControl(form_id, form_control) { var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; var type = this._collection[form_id].getInputType(form_control); console.log(type); // check if parser for specific input type exists and call...
javascript
{ "resource": "" }
q51550
download
train
function download(URL) { var convert_to_blob = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; var request = new XMLHttpRequest(); var p = new Promise(function (success, fail) { request.onload = function () { if (request.status === 200) { ...
javascript
{ "resource": "" }
q51551
base64ToBlob
train
function base64ToBlob(base64) { // convert base64 to raw binary data held in a string // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this var byteString = atob(base64.split(',')[1]); // separate out the mime component var mimeString = base64.sp...
javascript
{ "resource": "" }
q51552
blobToBase64
train
function blobToBase64(blob) { var reader = new FileReader(); var p = new Promise(function (success, fail) { reader.onloadend = function () { var base64 = reader.result; success(base64); }; reader.onerror = function (e) { ...
javascript
{ "resource": "" }
q51553
getBlobLocalURL
train
function getBlobLocalURL(blob) { if (!(blob instanceof Blob || blob instanceof File)) { throw new TypeError('Argument in BunnyFile.getBlobLocalURL() is not a Blob or File object'); } return URL.createObjectURL(blob); }
javascript
{ "resource": "" }
q51554
scrollTo
train
function scrollTo(target) { var duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500; var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; var rootElement = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : window; return ne...
javascript
{ "resource": "" }
q51555
_bn_getFile
train
function _bn_getFile(input) { // if there is custom file upload logic, for example, images are resized client-side // generated Blobs should be assigned to fileInput._file // and can be sent via ajax with FormData // if file was deleted, custom field can be set to an empty string // Bunny Validati...
javascript
{ "resource": "" }
q51556
image
train
function image(input) { return new Promise(function (valid, invalid) { if (input.getAttribute('type') === 'file' && input.getAttribute('accept').indexOf('image') > -1 && _bn_getFile(input) !== false) { BunnyFile.getSignature(_bn_getFile(input)).then(function (signature) { ...
javascript
{ "resource": "" }
q51557
createErrorNode
train
function createErrorNode() { var el = document.createElement(this.config.tagNameError); el.classList.add(this.config.classError); return el; }
javascript
{ "resource": "" }
q51558
removeErrorNode
train
function removeErrorNode(inputGroup) { var el = this.getErrorNode(inputGroup); if (el) { el.parentNode.removeChild(el); this.toggleErrorClass(inputGroup); } }
javascript
{ "resource": "" }
q51559
removeErrorNodesFromSection
train
function removeErrorNodesFromSection(section) { var _this = this; [].forEach.call(this.getInputGroupsInSection(section), function (inputGroup) { _this.removeErrorNode(inputGroup); }); }
javascript
{ "resource": "" }
q51560
setErrorMessage
train
function setErrorMessage(inputGroup, message) { var errorNode = this.getErrorNode(inputGroup); if (errorNode === false) { // container for error message doesn't exists, create new errorNode = this.createErrorNode(); this.toggleErrorClass(inputGroup); this....
javascript
{ "resource": "" }
q51561
getInputGroup
train
function getInputGroup(input) { var el = input; while ((el = el.parentNode) && !el.classList.contains(this.config.classInputGroup)) {} return el; }
javascript
{ "resource": "" }
q51562
getInputsInSection
train
function getInputsInSection(node) { var resolving = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var inputGroups = this.getInputGroupsInSection(node); var inputs = void 0; if (resolving) { inputs = { inputs: {}, i...
javascript
{ "resource": "" }
q51563
getCurrentBranch
train
function getCurrentBranch(verbose) { return Promise.resolve() .then(execCmd.bind(null, 'git', ['symbolic-ref', 'HEAD', '-q'], 'problem getting current branch', verbose )) .catch(function() { return ''; }) .then(function(result) { return result.replace(new RegExp...
javascript
{ "resource": "" }
q51564
computeTextRadius
train
function computeTextRadius(lines) { var textRadius = 0; for (var i = 0, n = lines.length; i < n; ++i) { var dx = lines[i].width / 2; var dy = (Math.abs(i - n / 2 + 0.5) + 0.5) * DEFAULT_CANVAS_LINE_HEIGHT; textRadius = Math.max(textRadius, Math.sqrt(dx * dx + dy * dy)); } retur...
javascript
{ "resource": "" }
q51565
computeWords
train
function computeWords(text) { var words = text.split(/\s+/g); // To hyphenate: /\s+|(?<=-)/ if (!words[words.length - 1]) words.pop(); if (!words[0]) words.shift(); return words; }
javascript
{ "resource": "" }
q51566
checkHtmlComponents
train
function checkHtmlComponents() { var graphHTMLContainer = d3.select("#" + graph.containerId); var taxonomyHTMLContainer = d3.select("#" + taxonomy.containerId); var queryHTMLContainer = d3.select("#" + queryviewer.containerId); var cypherHTMLContainer = d3.select("#" + cypherviewer.containerId); var...
javascript
{ "resource": "" }
q51567
train
function (link) { if (link.type === graph.link.LinkTypes.VALUE) { // Links between node and list of values. if (provider.node.isTextDisplayed(link.target)) { // Don't display text on link if text is displayed on target node. return ""; } else ...
javascript
{ "resource": "" }
q51568
train
function (link, element, attribute) { if (link.type === graph.link.LinkTypes.VALUE) { return "#525863"; } else { var colorId = link.source.label + link.label + link.target.label; var color = provider.colorScale(colorId); if (attribute === "stroke") { ...
javascript
{ "resource": "" }
q51569
train
function (node) { if (node.type === graph.node.NodeTypes.VALUE) { return provider.node.getColor(node.parent); } else { var parentLabel = ""; if (node.hasOwnProperty("parent")) { parentLabel = node.parent.label } ...
javascript
{ "resource": "" }
q51570
train
function (node, element) { var labelAsCSSName = node.label.replace(/[^0-9a-z\-_]/gi, ''); var cssClass = "ppt-node__" + element; if (node.type === graph.node.NodeTypes.ROOT) { cssClass = cssClass + "--root"; } if (node.type === graph.node.Nod...
javascript
{ "resource": "" }
q51571
train
function (node) { var text = ""; var displayAttr = provider.node.getDisplayAttribute(node.label); if (node.type === graph.node.NodeTypes.VALUE) { if (displayAttr === query.NEO4J_INTERNAL_ID) { text = "" + node.internalID; } else { ...
javascript
{ "resource": "" }
q51572
train
function (node) { var size = provider.node.getSize(node); return [ { "d": "M 0, 0 m -" + size + ", 0 a " + size + "," + size + " 0 1,0 " + 2 * size + ",0 a " + size + "," + size + " 0 1,0 -" + 2 * size + ",0", "fill": "transparent", ...
javascript
{ "resource": "" }
q51573
getTransitionContainer
train
function getTransitionContainer(show) { if (document.body.scrollHeight <= window.innerHeight) { return lightboxTransitionContainer; } return document.body; }
javascript
{ "resource": "" }
q51574
loadLargerImgSrc
train
function loadLargerImgSrc(img, largerSize) { if (img._preloaded) { return; } const dummyImg = new Image(); dummyImg.srcset = img.srcset; dummyImg.sizes = largerSize; img._preloaded = true; }
javascript
{ "resource": "" }
q51575
upperBound
train
function upperBound(value, arr) { let i = 0; let j = arr.length - 1; while (i < j) { const m = (i + j) >> 1; if (arr[m] > value) { j = m; } else { i = m + 1; } } return arr[i]; }
javascript
{ "resource": "" }
q51576
sort
train
function sort(values, boxes, indices, left, right) { if (left >= right) return; const pivot = values[(left + right) >> 1]; let i = left - 1; let j = right + 1; while (true) { do i++; while (values[i] < pivot); do j--; while (values[j] > pivot); if (i >= j) break; sw...
javascript
{ "resource": "" }
q51577
swap
train
function swap(values, boxes, indices, i, j) { const temp = values[i]; values[i] = values[j]; values[j] = temp; const k = 4 * i; const m = 4 * j; const a = boxes[k]; const b = boxes[k + 1]; const c = boxes[k + 2]; const d = boxes[k + 3]; boxes[k] = boxes[m]; boxes[k + 1] = b...
javascript
{ "resource": "" }
q51578
Scaffold
train
function Scaffold(options) { if (!(this instanceof Scaffold)) { return new Scaffold(options); } Base.call(this); this.use(utils.plugins()); this.is('scaffold'); options = options || {}; this.options = options; this.targets = {}; if (Scaffold.isScaffold(options)) { this.options = {}; fow...
javascript
{ "resource": "" }
q51579
foward
train
function foward(app, options) { if (typeof options.name === 'string') { app.name = options.name; delete options.name; } Scaffold.emit('scaffold', app); emit('target', app, Scaffold); emit('files', app, Scaffold); }
javascript
{ "resource": "" }
q51580
emit
train
function emit(name, a, b) { a.on(name, b.emit.bind(b, name)); }
javascript
{ "resource": "" }
q51581
sendTab
train
function sendTab(opt_shiftKey) { var ev = null; try { ev = new KeyboardEvent('keydown', { keyCode: 9, which: 9, key: 'Tab', code: 'Tab', keyIdentifier: 'U+0009', shiftKey: !!opt_shiftKey, bubbles: true }); } catch (e) { try { ...
javascript
{ "resource": "" }
q51582
train
function( vert, frag, prefix ){ this.ready = false; prefix = ( prefix === undefined ) ? '' : prefix+'\n'; var gl = this.gl; if( !( compileShader( gl, this.fShader, prefix + frag ) && compileShader( gl, this.vShader, prefix + vert ) ) ) { return false; } gl.linkProgram(this...
javascript
{ "resource": "" }
q51583
train
function() { if( this.gl !== null ){ this.gl.deleteProgram( this.program ); this.gl.deleteShader( this.fShader ); this.gl.deleteShader( this.vShader ); this.gl = null; } }
javascript
{ "resource": "" }
q51584
train
function( format, type, internal ){ this.format = format || this.gl.RGB; this.internal = internal || this.format; this.type = type || this.gl.UNSIGNED_BYTE; }
javascript
{ "resource": "" }
q51585
train
function( img ){ var gl = this.gl; this.width = img.width; this.height = img.height; gl.bindTexture( T2D, this.id ); gl.texImage2D( T2D, 0, this.internal, this.format, this.type, img ); }
javascript
{ "resource": "" }
q51586
train
function( unit ){ var gl = this.gl; if( unit !== undefined ){ gl.activeTexture( gl.TEXTURE0 + (0|unit) ); } gl.bindTexture( T2D, this.id ); }
javascript
{ "resource": "" }
q51587
train
function( array ){ var gl = this.gl; gl.bindBuffer( TGT, this.buffer ); gl.bufferData( TGT, array, this.usage ); gl.bindBuffer( TGT, null ); this.byteLength = ( array.byteLength === undefined ) ? array : array.byteLength; this._computeLength(); }
javascript
{ "resource": "" }
q51588
train
function( format, type, internal ){ var t = new Texture( this.gl, format, type, internal ); return this.attach( 0x8CE0, t ); }
javascript
{ "resource": "" }
q51589
train
function( w, h ){ if( this.width !== w || this.height !== h ) { this.width = w|0; this.height = h|0; this._allocate(); } }
javascript
{ "resource": "" }
q51590
_watchRuleFile
train
function _watchRuleFile(file, callback){ fs.watchFile(file, function(curr, prev){ log.warn('The rule file has been modified!'); callback(); }); }
javascript
{ "resource": "" }
q51591
_loadResponderList
train
function _loadResponderList(responderListFilePath){ var filePath = responderListFilePath; if(typeof filePath !== 'string'){ return null; } if(!fs.existsSync(responderListFilePath)){ throw new Error('File doesn\'t exist!'); } if(!utils.isAbsolutePath(responderListFilePath)){ filePath = path.jo...
javascript
{ "resource": "" }
q51592
_loadFile
train
function _loadFile(filename){ var module = require(filename); delete require.cache[require.resolve(filename)]; return module; }
javascript
{ "resource": "" }
q51593
nproxy
train
function nproxy(port, options){ var nm; if(typeof options.timeout === 'number'){ utils.reqTimeout = options.timeout; utils.resTimeout = options.timeout; } if(typeof options.debug === 'boolean'){ log.isDebug = options.debug; } nm = require('./middlewares'); //nproxy middles port = typeof po...
javascript
{ "resource": "" }
q51594
proxyHttps
train
function proxyHttps(){ httpServer.on('connect', function(req, socket, upgradeHead){ var hostname = req.url.split(':')[0]; log.debug('Create internal https server for ' + hostname); createInternalHttpsServer(hostname, function (err, httpsServerPort) { if (err) { log.error('Failed to create in...
javascript
{ "resource": "" }
q51595
getAgentByUrl
train
function getAgentByUrl (requestUrl) { if (!requestUrl) { return null; } var parsedRequestUrl = url.parse(requestUrl); var proxyUrl = getSystemProxyByUrl(parsedRequestUrl); if (!proxyUrl) { log.debug('No system proxy'); return null; } log.debug('Detect system proxy Url: ' + proxyUrl); var pa...
javascript
{ "resource": "" }
q51596
_checkRootCA
train
function _checkRootCA () { var caKeyFilePath = path.join(certDir, 'ca.key'); var caCrtFilePath = path.join(certDir, 'ca.crt'); var keysDir = path.join(__dirname, '..', 'keys'); if (!fs.existsSync(caKeyFilePath) || !fs.existsSync(caCrtFilePath)) { log.debug('CA files do not exist'); log.debug('Copy CA ...
javascript
{ "resource": "" }
q51597
forward
train
function forward(){ return function forward(req, res, next){ var url = utils.processUrl(req); var options = { url: url, method: req.method, headers: req.headers } var buffers = []; log.debug('forward: ' + url); if(req.method === 'POST'){ req.on('data', function(c...
javascript
{ "resource": "" }
q51598
respondFromCombo
train
function respondFromCombo(options, req, res, next){ var dir; var src; if(typeof options !== 'object' || typeof options === null){ log.warn('Options are invalid when responding from combo!'); next(); } dir = typeof options.dir === 'undefined' ? null : options.dir; src = Array.isArray(options.src) ?...
javascript
{ "resource": "" }
q51599
responseTime
train
function responseTime (options) { var opts = options || {} if (typeof options === 'number') { // back-compat single number argument deprecate('number argument: use {digits: ' + JSON.stringify(options) + '} instead') opts = { digits: options } } // get the function to invoke var fn = typeof opts ...
javascript
{ "resource": "" }