_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q35300
train
function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder ) { editor.addCommand( commandName, command ); // If the "menu" plugin is loaded, register the menu item. editor.addMenuItem( commandName,
javascript
{ "resource": "" }
q35301
handlePermissionUpdate
train
function handlePermissionUpdate() { permissionArea.find("form").submit(function (e) { e.preventDefault(); //console.log(e); var form = e.currentTarget; appendFormFields(form); Rocket.Util.submitFormAsync(form, function (response...
javascript
{ "resource": "" }
q35302
addManifest
train
function addManifest(file, options) { file = file || '/app.manifest'; var stream = new Transform({objectMode: true}); var domains = {}; var hostProtocols = {}; stream._transform = function (page, _, callback) { if (!(options && options.justManifests)) { if (page.statusCode !== 404 || url.resolve(pa...
javascript
{ "resource": "" }
q35303
report
train
function report(){ if(responses < 1) return; var dt = new Date - starttime; console.log( '%s invokes per second, avg request time: %s ms, worst: %s ms, best: %s ms, invokes without response in queue: %s', (responses/dt*1000).toFixed(2), (totaltime/responses).toFixed(2),
javascript
{ "resource": "" }
q35304
train
function (path) { 'use strict'; path = fs.realpathSync(path); var config = require(path);
javascript
{ "resource": "" }
q35305
train
function (path) { 'use strict'; path = fs.realpathSync(path); var updateConf = require(path);
javascript
{ "resource": "" }
q35306
train
function (key) { 'use strict'; var value = conf[key]; if (!isStr(key)) { throw new Error(confKeyStrMsg, 'config-manager'); } if (key.indexOf('.') !== -1) { value = getNestedValue(conf, key);
javascript
{ "resource": "" }
q35307
train
function (key, value) { 'use strict'; var obj; if (!isStr(key)) { throw new Error(confKeyStrMsg, 'config-manager'); } if (key.indexOf('.') === -1) { conf[key] =
javascript
{ "resource": "" }
q35308
formatStream
train
function formatStream(options) { if (!_.isObject(options)) { options = {}; } var statsOptions = options.verbose === true ? _.defaults(options, DEFAULT_VERBOSE_STATS_OPTIONS) : _.defaults(options, DEFAULT_STATS_OPTIONS); if (!gutil.colors.supportsColor) { statsOptions.colors = false; ...
javascript
{ "resource": "" }
q35309
parseString
train
function parseString(input) { var stripped = input.substring(1, input.length - 1); return stripped.replace(/\\(\w|\\)/gi, function(_, b) { switch (b) { case '\\r': return '\r'; case '\\n': return '\n'; case '\\t': return '\t';
javascript
{ "resource": "" }
q35310
parseSwitchType
train
function parseSwitchType(lex) { var start = lex.accept('switchtype'); if (!start) { return null; } var expr = parseExpression(lex); lex.assert('{'); var cases = []; var end; do { let c = parseSwitchTypeCase(lex);
javascript
{ "resource": "" }
q35311
parseSwitchTypeCase
train
function parseSwitchTypeCase(lex) { var start = lex.assert('case'); var type = parseType(lex); lex.assert('{'); var body = parseStatements(lex, '}', false); var end
javascript
{ "resource": "" }
q35312
parseStatement
train
function parseStatement(lex, isRoot = false) { return parseFunctionDeclaration(lex) || isRoot && parseOperatorStatement(lex) || isRoot && parseObjectDeclaration(lex) || parseIf(lex) ||
javascript
{ "resource": "" }
q35313
parseStatements
train
function parseStatements(lex, endTokens, isRoot) { endTokens = Array.isArray(endTokens) ? endTokens : [endTokens]; var statements = []; var temp = lex.peek(); while (endTokens.indexOf(temp) === -1 && (temp.type && endTokens.indexOf(temp.type) === -1)) { var statement = parseStatement(...
javascript
{ "resource": "" }
q35314
requestAsync
train
function requestAsync(resource, opts = {}) { const settings = { followRedirect: true, encoding: null, rejectUnauthorized: false }; if (opts.user && opts.pass) { settings.headers = {Authorization: 'Basic ' + token(opts.user, opts.pass)}; } return new Bluebird((resolve, reject) => { // Han...
javascript
{ "resource": "" }
q35315
readAsync
train
function readAsync(resource) { return fs.readFile(resource).then(body => { const mimeType = mime.getType(resource); debug('Fetched:', resource);
javascript
{ "resource": "" }
q35316
checkMissingDir
train
function checkMissingDir(destinationFile) { var filePath = path.dirname(destinationFile); var pathAbsolute = path.isAbsolute(filePath); var
javascript
{ "resource": "" }
q35317
generateCache
train
function generateCache(filePath) { var id = generateIdFromFilePath(filePath); Debug._l(id); fs.readFile(filePath, 'utf8', function (err, data) { if (err) { Debug._l("err: " + err);
javascript
{ "resource": "" }
q35318
train
function (options) { if (!options) { throw Error("Ajax options missing"); } var that = this, util = Rocket.Util;
javascript
{ "resource": "" }
q35319
train
function (msg, nodeId, ns, isShow) { ns = ns || Rocket.Plugin.currentPlugin.namespace; var node = $("#" + ns + "_" + nodeId), msgSpan = node.find("span.message"); isShow ? node.removeClass("hide") && node.css("display", "block") : node.addClass("hide"); if...
javascript
{ "resource": "" }
q35320
train
function (msg, nodeId, ns) { nodeId = nodeId || "errorFlash";
javascript
{ "resource": "" }
q35321
ErrorRenderer
train
function ErrorRenderer(err, req, res) { PageRenderer.call(this, req, res); Object.defineProperties(this, { err: {
javascript
{ "resource": "" }
q35322
Strategy
train
function Strategy (options, verify) { if (typeof options === 'function') { verify = options options = {} } else { if (options && options.log) { log = options.log } } if (!verify) { throw new Error('apikey authentication
javascript
{ "resource": "" }
q35323
CString
train
function CString(value, written, cond) { this.value = value || ''; this.written =
javascript
{ "resource": "" }
q35324
train
function( event ) { var keystroke = event && event.data.getKey(), isModifierKey = keystroke in modifierKeyCodes, isEditingKey = keystroke in editingKeyCodes, wasEditingKey = this.lastKeystroke in editingKeyCodes, sameAsLastEditingKey = isEditingKey && keystroke == this.lastKeystroke, // ...
javascript
{ "resource": "" }
q35325
train
function( onContentOnly, image, autoFireChange ) { var snapshots = this.snapshots; // Get a content image. if ( !image ) image = new Image( this.editor ); // Do nothing if it was not possible to retrieve an image. if ( image.contents === false ) return false; // Check if this ...
javascript
{ "resource": "" }
q35326
train
function( isUndo ) { var snapshots = this.snapshots, currentImage = this.currentImage, image, i; if ( currentImage ) { if ( isUndo ) { for ( i = this.index - 1 ; i >= 0 ; i-- ) { image = snapshots[ i ]; if ( !currentImage.equals( image, true ) ) { ...
javascript
{ "resource": "" }
q35327
train
function() { if ( this.undoable() ) { this.save( true ); var image = this.getNextImage( true ); if ( image ) return
javascript
{ "resource": "" }
q35328
train
function() { if ( this.redoable() ) { // Try to save. If no changes have been made, the redo stack // will not change, so it will still be redoable. this.save( true ); // If instead we had changes, we can't redo anymore. if ( this.redoable() ) { var
javascript
{ "resource": "" }
q35329
create
train
function create(type, constructor) { return function projection() { var p = constructor(); p.type = type; p.path = geoPath().projection(p); p.copy = p.copy || function() { var c = projection();
javascript
{ "resource": "" }
q35330
createObbFromRenderableShape
train
function createObbFromRenderableShape(params, physicsJob) { const halfRangeX = params.scale[0] / 2; const halfRangeY
javascript
{ "resource": "" }
q35331
createSphereFromRenderableShape
train
function createSphereFromRenderableShape(params, physicsJob) { const radius = params.radius
javascript
{ "resource": "" }
q35332
createCapsuleFromRenderableShape
train
function createCapsuleFromRenderableShape(params, physicsJob) { const scale = params.scale; const capsuleEndPointsDistance = params.capsuleEndPointsDistance; const isStationary = params.isStationary; let radius = params.radius; let halfDistance; // There are two modes: either we use scale, or we use radiu...
javascript
{ "resource": "" }
q35333
train
function( node, index ) { isNaN( index ) && ( index = this.children.length ); var previous = index > 0 ? this.children[ index - 1 ] : null; if ( previous ) { // If the block to be appended is following text, trim spaces at // the right of it. if ( node._.isBlockLike && previous.type ...
javascript
{ "resource": "" }
q35334
train
function( writer, filter ) { var isChildrenFiltered; this.filterChildren = function() { var writer = new CKEDITOR.htmlParser.basicWriter(); this.writeChildrenHtml.call( this, writer, filter, true ); var
javascript
{ "resource": "" }
q35335
train
function(constructorFn, args) { var newConstructorFn = function () { constructorFn.apply(this, args);
javascript
{ "resource": "" }
q35336
getMasterPillarRow
train
function getMasterPillarRow( table ) { var $rows = table.$.rows, maxCells = 0, cellsCount, $elected, $tr; for ( var i = 0, len = $rows.length ; i < len; i++ ) { $tr = $rows[ i ];
javascript
{ "resource": "" }
q35337
catchErrors
train
function catchErrors() { // don't use an arrow function, we need the `this` instance! return plumber(function(err) { if (!err.plugin) { err.plugin = 'gulp-task-maker' }
javascript
{ "resource": "" }
q35338
dirToListItems
train
function dirToListItems( list ) { var dir = list.getDirection(); if ( dir ) { for ( var i = 0, children = list.getChildren(), child; child = children.getItem( i ), i < children.count(); i++ ) { if ( child.type
javascript
{ "resource": "" }
q35339
Rorschach
train
function Rorschach(connectionString, options) { EventEmitter.call(this); options = options || {}; var retryPolicy = options.retryPolicy; if (retryPolicy instanceof RetryPolicy) { this.retryPolicy = retryPolicy; } else {
javascript
{ "resource": "" }
q35340
initZooKeeper
train
function initZooKeeper(rorschach, connectionString, options) { var error; var zk = zookeeper.createClient(connectionString, options); rorschach.zk = zk; zk.connect(); zk.on('connected', onconnected); zk.on('expired', setError); zk.on('authenticationFailed', setError); zk.on('disconnected', ondisconnec...
javascript
{ "resource": "" }
q35341
updateComponents
train
function updateComponents (address, node, state, diff, bindings, renderResult, relativeAddress, stateCallers, opts) { // TODO pull these out to top level const updateRecurse = ([ d, s ], k) => { // TODO in updateRecurse functions where k can be null, there must be a // nicer way t...
javascript
{ "resource": "" }
q35342
treeGet
train
function treeGet (address, tree) { return address.reduce((accum, val) => { return checkType(NODE,
javascript
{ "resource": "" }
q35343
treeSet
train
function treeSet (address, tree, value) { if (address.length === 0) { return value } else { const [ k, rest ] = head(address) return (typeof k === 'string' ? { ...tree, [k]: treeSet(rest, treeGet([ k ], tree), value) } :
javascript
{ "resource": "" }
q35344
treeSetMutable
train
function treeSetMutable (address, tree, value) { if (address.length === 0) { return value } else { const [ rest, last ] = tail(address) const parent = treeGet(rest, tree) if (checkType(NODE, parent))
javascript
{ "resource": "" }
q35345
diffWithModel
train
function diffWithModel (modelNode, state, lastState, address, triggeringAddress)
javascript
{ "resource": "" }
q35346
singleOrAll
train
function singleOrAll (modelNode, address, minTreeAr) { const getMin = indices => { if (indices.length === 0) { // If all elements in the array are null, return null. return null } else if (nonNullIndices.signals.length === 1) { // If there is a single value, return that tree, with an updated...
javascript
{ "resource": "" }
q35347
makeSignalsAPI
train
function makeSignalsAPI (signalNames, isCollection) { return fromPairs(signalNames.map(name
javascript
{ "resource": "" }
q35348
runSignalSetup
train
function runSignalSetup (component, address, stateCallers) { const signalsAPI = makeSignalsAPI(component.signalNames, false) const childSignalsAPI = makeChildSignalsAPI(component.model) const reducers = patchReducersWithState(address, component, stateCallers.callReducer) const signals = patchSignals(address, co...
javascript
{ "resource": "" }
q35349
makeCallSignal
train
function makeCallSignal (signals, opts) { return (address, signalName, arg) => { if (opts.verbose) { console.log('Called signal ' + signalName + ' at [' + address.join(', ') +
javascript
{ "resource": "" }
q35350
keyBy
train
function keyBy (arr, key) { var obj = {}
javascript
{ "resource": "" }
q35351
isText
train
function isText (o) { return (o && typeof o === 'object' &&
javascript
{ "resource": "" }
q35352
flattenElementsAr
train
function flattenElementsAr (ar) { return ar.reduce((acc, el) => { return isArray(el) ? [ ...acc, ...el ] :
javascript
{ "resource": "" }
q35353
redirect
train
function redirect(e) { if (e && e.preventDefault) e.preventDefault(); // // Assume that the value in the $control_input is uptodate. If not get the // value directly through the constructor. When the selectize is still // loading results the `getValue()` will return an empty value. This is why ...
javascript
{ "resource": "" }
q35354
load
train
function load(query, callback) { if (!query.length) return callback(); pagelet.complete(query, function complete(err, results) {
javascript
{ "resource": "" }
q35355
render
train
function render(item, escape) { return [ '<div class="completed">', '<strong class="name">'+ escape(item.name) +'</strong>', 'string' === typeof item.desc ? '<span
javascript
{ "resource": "" }
q35356
customLog
train
function customLog(message) { const trimmed = message.trim() const limit = trimmed.indexOf('\n') if (limit === -1) { fancyLog(trimmed) } else { const title = trimmed.slice(0, limit).trim()
javascript
{ "resource": "" }
q35357
toUniqueStrings
train
function toUniqueStrings(input) { const list = (Array.isArray(input) ? input : [input])
javascript
{ "resource": "" }
q35358
removeSelectedOptions
train
function removeSelectedOptions( combo ) { combo = getSelect( combo ); // Save the selected index var iSelectedIndex = getSelectedIndex( combo ); // Remove all selected options.
javascript
{ "resource": "" }
q35359
modifyOption
train
function modifyOption( combo, index, title, value ) { combo = getSelect( combo ); if ( index < 0 ) return false; var child = combo.getChild( index );
javascript
{ "resource": "" }
q35360
dir2TreeStr
train
function dir2TreeStr(){ argD = Type.isBoolean(argD) ? "./" : trimAndDelQuotes(argD); let dirJson,djOpt; try{ djOpt = { // preChars:{ // directory: ":open_file_folder: ", // file:":page_facing_up: " // }, exclude:{ ou...
javascript
{ "resource": "" }
q35361
VertexIterator
train
function VertexIterator(graph, startFrom) { if (graph === undefined) { throw new Error('Graph is required by VertexIterator');
javascript
{ "resource": "" }
q35362
CacheStore
train
function CacheStore(options) { if (!options.id) { throw new IdNotDefinedError(); } var storeType, _cache; function parseKey(key) { return key.replace(/[^a-z0-9]/gi, '_').replace(/^-+/, '').replace(/-+$/, '').toLowerCase(); } /** * Returns Cache Store object * @returns...
javascript
{ "resource": "" }
q35363
train
function(options) { "use strict"; stream.Transform.call(this, options); options = options || {}; this.probability = options.probability || 0; this.deviation = Math.abs(options.deviation || 0);
javascript
{ "resource": "" }
q35364
train
function(fileSrc, fileDst, probability, deviation, mode) { "use strict"; var rstream = fs.createReadStream(fileSrc); var woptions = mode ? { 'mode' : mode } : {}; var wstream = fs.createWriteStream(fileDst, woptions); var gstream = new
javascript
{ "resource": "" }
q35365
CInt
train
function CInt(base, offset, isSet) { this.base =
javascript
{ "resource": "" }
q35366
VText
train
function VText(text, config) { this.virtual = true; extend(this, config);
javascript
{ "resource": "" }
q35367
appendColorRow
train
function appendColorRow( rangeA, rangeB ) { for ( var i = rangeA ; i < rangeA + 3 ; i++ ) { var row = table.$.insertRow( -1 ); for ( var j = rangeB ; j < rangeB + 3 ; j++ ) { for ( var
javascript
{ "resource": "" }
q35368
CEntity
train
function CEntity(indexes, properties, states) { CArray.call(this, indexes, properties);
javascript
{ "resource": "" }
q35369
attachMenu
train
function attachMenu(item) { var menuType = item.find('a').hasClass(FOLDER_TYPE) ? "folderMenu" : "itemMenu"; item.contextMenu({ menu:menuType }, function (action, el, pos) { switch (action) { case ADD_SUBFOLDER_MENU_COMMAND: ...
javascript
{ "resource": "" }
q35370
injectStyle
train
function injectStyle(obj) { if (!obj) return '' var selectors = Object.keys(obj) var styles = selectors.map(function(key) { var selector =
javascript
{ "resource": "" }
q35371
fetchWithRetry
train
function fetchWithRetry(url, options) { async function fetchWrapper() { const response = await fetch(url, options); // don't retry if status is 4xx if (response.status >= 400 && response.status < 500) { const contentType = response.headers.get('content-type');
javascript
{ "resource": "" }
q35372
hydrateDates
train
function hydrateDates(body) { /** * Hydrates a string date to a Date object. Mutates input. * @param item object potentially containing a meta object */ function hydrateMeta(item) { const meta = item.meta; if (meta && meta.created) {
javascript
{ "resource": "" }
q35373
hydrateMeta
train
function hydrateMeta(item) { const meta = item.meta; if (meta && meta.created) { // parse ISO-8601 string to
javascript
{ "resource": "" }
q35374
LeaderElection
train
function LeaderElection(client, path, id) { EventEmitter.call(this); /** * Ref. to client. * * @type {Rorschach} */ this.client = client; /** * ZooKeeper path where participants' nodes exist. *
javascript
{ "resource": "" }
q35375
handleStateChange
train
function handleStateChange(election, state) { if (state === ConnectionState.RECONNECTED) { reset(election, afterReset); } else if (state === ConnectionState.SUSPENDED || state === ConnectionState.LOST) { setLeadership(election, false); }
javascript
{ "resource": "" }
q35376
fileUploaded
train
function fileUploaded( error, response ) { this.debug( 'File Uploaded' );
javascript
{ "resource": "" }
q35377
train
function( writer, filter ) { var text = this.value; if ( filter && !( text = filter.onText( text, this
javascript
{ "resource": "" }
q35378
checkCircular
train
function checkCircular(obj){ let isCcl = false; let cclKeysArr = []; travelJson(obj,function(k,v,kp,ts,cpl,cd,isCircular){ if(isCircular){ isCcl = true; cclKeysArr.push({ keyPath: kp, circularTo: v.slice(11,-1), key: k,
javascript
{ "resource": "" }
q35379
BufferView
train
function BufferView(buffer, byteOffset, byteLength) { if (typeof byteOffset === "undefined") byteOffset = 0; if (typeof byteLength
javascript
{ "resource": "" }
q35380
train
function (message, data) { var datastr = data === undefined ? "no-data" : inspect(data); logfn(format(" [EMIT]
javascript
{ "resource": "" }
q35381
train
function( evaluator ) { var next = this.$, retval; do { next = next.nextSibling; retval = next && new CKEDITOR.dom.node( next ); }
javascript
{ "resource": "" }
q35382
train
function( reference, includeSelf ) { var $ = this.$, name; if ( !includeSelf ) $ = $.parentNode; while ( $ ) { if ( $.nodeName && ( name = $.nodeName.toLowerCase(), ( typeof reference == 'string' ? name == reference : name
javascript
{ "resource": "" }
q35383
train
function( preserveChildren ) { var $ = this.$; var parent = $.parentNode; if ( parent ) { if ( preserveChildren ) { // Move all
javascript
{ "resource": "" }
q35384
train
function() { if ( cssIsLoaded && jsIsLoaded ) { // Mark the part as loaded. part._isLoaded = 1; // Call all pending callbacks.
javascript
{ "resource": "" }
q35385
train
function( skinName, skinDefinition ) { loaded[ skinName ] = skinDefinition; skinDefinition.skinPath = paths[ skinName ] || ( paths[ skinName ] =
javascript
{ "resource": "" }
q35386
train
function( editor, skinPart, callback ) { var skinName = editor.skinName, skinPath = editor.skinPath; if ( loaded[ skinName ] ) loadPart( editor, skinName, skinPart, callback ); else { paths[ skinName ]
javascript
{ "resource": "" }
q35387
forOwnDeep
train
function forOwnDeep(object, callback, prefix) { prefix = prefix ? prefix + '.' : ''; _.forOwn(object, function(value, key) { if (_.isString(value)) {
javascript
{ "resource": "" }
q35388
Lock
train
function Lock(client, basePath, lockName, lockDriver) { if (lockName instanceof LockDriver) { lockDriver = lockName; lockName = null; } if (!lockName) { lockName = Lock.LOCK_NAME; } if (!lockDriver) { lockDriver = new LockDriver(); } /** * Keep ref to client as all the low-level opera...
javascript
{ "resource": "" }
q35389
attemptLock
train
function attemptLock(lock, timeout, callback) { var lockPath; var sequenceNodeName; var timerId = null; var start = Date.now(); createNode(lock, afterCreate); function afterCreate(err, nodePath) { if (err) { return exit(err); } lockPath = nodePath; sequenceNodeName = nodePath.subst...
javascript
{ "resource": "" }
q35390
createNode
train
function createNode(lock, callback) { var nodePath = utils.join(lock.basePath, lock.lockName); var client = lock.client; client .create() .creatingParentsIfNeeded()
javascript
{ "resource": "" }
q35391
deleteNode
train
function deleteNode(lock, lockPath, callback) { lock.client .delete()
javascript
{ "resource": "" }
q35392
dupBuffer
train
function dupBuffer(buf){ var cloned = new Buffer(buf.length);
javascript
{ "resource": "" }
q35393
compare
train
function compare(buf1, buf2){ if (buf1.length !== buf2.length) return buf1.length - buf2.length; for (var i = 0; i < buf1.length; i++)
javascript
{ "resource": "" }
q35394
strongify
train
function strongify(o) { /** * Cloning object. */ var params = _.clone(o); /** * Returns all object data. * * @return {object} * @api public */ params.all = function() { return params = _.omit(params, ['all', 'only', 'except', 'require', 'merge']); } /** * Returns only listed...
javascript
{ "resource": "" }
q35395
saveFileChanges
train
function saveFileChanges(themeId, folderName, fileName, text) { io({ url:getURL("save") + "/" + themeId + "/" + folderName + "/" + fileName, data:{ content:encodeURI(text) },
javascript
{ "resource": "" }
q35396
initAceEditor
train
function initAceEditor(themeId, folderName, fileName, text, mode) { hideImageHolder(); $("#" + editorId).show(); var doc = new Document(text); var session = new EditSession(doc, "ace/mode/" + mode); session.setUndoManager(new UndoManager()); editor.setSession(session); ...
javascript
{ "resource": "" }
q35397
openFile
train
function openFile(themeId, folderName, fileName) { if (themeId && folderName && fileName) { //if image then display it if (folderName === "images") { showImage(themeId, folderName, fileName); return; } var options = { ...
javascript
{ "resource": "" }
q35398
renderThemeTree
train
function renderThemeTree(themeId, fileList, themeName) { var getTreeNodes = function (arr) { var ret = []; _.each(arr, function (fileName) { ret.push({title:fileName}); }); return ret; }; var css = {title:validTitleName[0], isFolder...
javascript
{ "resource": "" }
q35399
train
function (workingDirectory) { var gitPath = getClosestGitPath(workingDirectory); if (!gitPath) { throw new Error('git-hooks must be run inside a git repository'); } var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME); var pathToGitHooks = path.join(path.relative(ho...
javascript
{ "resource": "" }