_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q25300 | train | function (name, value) {
if (DOMProperty.isReservedProp(name)) {
return false;
}
if ((name[0] === 'o' || name[0] === 'O') && (name[1] === 'n' || name[1] === 'N')) {
return false;
}
if (value === null) {
return true;
}
switch (typeof value) {
case 'boolean':
re... | javascript | {
"resource": ""
} | |
q25301 | getTopLevelCallbackBookKeeping | train | function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) {
if (callbackBookkeepingPool.length) {
var instance = callbackBookkeepingPool.pop();
instance.topLevelType = topLevelType;
instance.nativeEvent = nativeEvent;
instance.targetInst = targetInst;
return instance;
}
re... | javascript | {
"resource": ""
} |
q25302 | getVendorPrefixedEventName | train | function getVendorPrefixedEventName(eventName) {
if (prefixedEventNames[eventName]) {
return prefixedEventNames[eventName];
} else if (!vendorPrefixes[eventName]) {
return eventName;
}
var prefixMap = vendorPrefixes[eventName];
for (var styleProp in prefixMap) {
if (prefixMap.hasOwnProperty(styl... | javascript | {
"resource": ""
} |
q25303 | train | function (styles) {
{
var serialized = '';
var delimiter = '';
for (var styleName in styles) {
if (!styles.hasOwnProperty(styleName)) {
continue;
}
var styleValue = styles[styleName];
if (styleValue != null) {
var isCustomProperty = styleName.ind... | javascript | {
"resource": ""
} | |
q25304 | train | function (node, name, expected) {
{
var propertyInfo = DOMProperty_1.getPropertyInfo(name);
if (propertyInfo) {
var mutationMethod = propertyInfo.mutationMethod;
if (mutationMethod || propertyInfo.mustUseProperty) {
return node[propertyInfo.propertyName];
} else {
... | javascript | {
"resource": ""
} | |
q25305 | train | function (node, name, expected) {
{
if (!isAttributeNameSafe(name)) {
return;
}
if (!node.hasAttribute(name)) {
return expected === undefined ? undefined : null;
}
var value = node.getAttribute(name);
if (value === '' + expected) {
return expected;
}... | javascript | {
"resource": ""
} | |
q25306 | train | function (parent, html) {
if (!testDocument) {
testDocument = document.implementation.createHTMLDocument();
}
var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? testDocument.createElement(parent.tagName) : testDocument.createElementNS(parent.namespaceURI, parent.tagName);
testElement.inn... | javascript | {
"resource": ""
} | |
q25307 | findInsertionPosition | train | function findInsertionPosition(queue, update) {
var priorityLevel = update.priorityLevel;
var insertAfter = null;
var insertBefore = null;
if (queue.last !== null && comparePriority(queue.last.priorityLevel, priorityLevel) <= 0) {
// Fast path for the common case where the update should be inserted at
/... | javascript | {
"resource": ""
} |
q25308 | train | function (fn) {
!(showDialog === defaultShowDialog) ? invariant(false, 'The custom dialog was already injected.') : void 0;
!(typeof fn === 'function') ? invariant(false, 'Injected showDialog() must be a function.') : void 0;
showDialog = fn;
} | javascript | {
"resource": ""
} | |
q25309 | safelyCallComponentWillUnmount | train | function safelyCallComponentWillUnmount(current, instance) {
{
invokeGuardedCallback$2(null, callComponentWillUnmountWithTimerInDev, null, current, instance);
if (hasCaughtError$1()) {
var unmountError = clearCaughtError$1();
captureError(current, unmountError);
}
}
} | javascript | {
"resource": ""
} |
q25310 | resetNextUnitOfWork | train | function resetNextUnitOfWork() {
// Clear out roots with no more work on them, or if they have uncaught errors
while (nextScheduledRoot !== null && nextScheduledRoot.current.pendingWorkPriority === NoWork$2) {
// Unschedule this root.
nextScheduledRoot.isScheduled = false;
// Read the next poi... | javascript | {
"resource": ""
} |
q25311 | getSiblingNode | train | function getSiblingNode(node) {
while (node) {
if (node.nextSibling) {
return node.nextSibling;
}
node = node.parentNode;
}
} | javascript | {
"resource": ""
} |
q25312 | getNodeForCharacterOffset | train | function getNodeForCharacterOffset(root, offset) {
var node = getLeafNode(root);
var nodeStart = 0;
var nodeEnd = 0;
while (node) {
if (node.nodeType === TEXT_NODE$3) {
nodeEnd = nodeStart + node.textContent.length;
if (nodeStart <= offset && nodeEnd >= offset) {
return {
nod... | javascript | {
"resource": ""
} |
q25313 | traverseEnterLeave | train | function traverseEnterLeave(from, to, fn, argFrom, argTo) {
var common = from && to ? getLowestCommonAncestor(from, to) : null;
var pathFrom = [];
while (from && from !== common) {
pathFrom.push(from);
from = getParent(from);
}
var pathTo = [];
while (to && to !== common) {
pathTo.push(to);
... | javascript | {
"resource": ""
} |
q25314 | listenerAtPhase | train | function listenerAtPhase(inst, event, propagationPhase) {
var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
return getListener(inst, registrationName);
} | javascript | {
"resource": ""
} |
q25315 | accumulateDirectDispatchesSingle | train | function accumulateDirectDispatchesSingle(event) {
if (event && event.dispatchConfig.registrationName) {
accumulateDispatches(event._targetInst, null, event);
}
} | javascript | {
"resource": ""
} |
q25316 | isPresto | train | function isPresto() {
var opera = window.opera;
return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12;
} | javascript | {
"resource": ""
} |
q25317 | isFallbackCompositionEnd | train | function isFallbackCompositionEnd(topLevelType, nativeEvent) {
switch (topLevelType) {
case 'topKeyUp':
// Command keys insert or clear IME input.
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
case 'topKeyDown':
// Expect IME keyCode on each keydown. If we get any other
// c... | javascript | {
"resource": ""
} |
q25318 | extractBeforeInputEvent | train | function extractBeforeInputEvent(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
var chars;
if (canUseTextInputEvent) {
chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
} else {
chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
}
// If no characters are being i... | javascript | {
"resource": ""
} |
q25319 | modifierStateGetter | train | function modifierStateGetter(keyArg) {
var syntheticEvent = this;
var nativeEvent = syntheticEvent.nativeEvent;
if (nativeEvent.getModifierState) {
return nativeEvent.getModifierState(keyArg);
}
var keyProp = modifierKeyToProp[keyArg];
return keyProp ? !!nativeEvent[keyProp] : false;
} | javascript | {
"resource": ""
} |
q25320 | isValidContainer | train | function isValidContainer(node) {
return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === ' react-mount-point-unstable '));
} | javascript | {
"resource": ""
} |
q25321 | finish | train | function finish(e) {
if (e && e.target !== node) {
return;
}
clearTimeout(timer);
if (removeListeners) removeListeners();
(0, _removeClass2.default)(node, className);
(0, _removeClass2.default)(node, activeClassName);
if (removeListeners) removeListeners();
//... | javascript | {
"resource": ""
} |
q25322 | getChildMapping | train | function getChildMapping(children) {
if (!children) {
return children;
}
var result = {};
_react.Children.map(children, function (child) {
return child;
}).forEach(function (child) {
result[child.key] = child;
});
return result;
} | javascript | {
"resource": ""
} |
q25323 | escape | train | function escape(key) {
var escapeRegex = /[=:]/g;
var escaperLookup = {
'=': '=0',
':': '=2'
};
var escapedString = ('' + key).replace(escapeRegex, function (match) {
return escaperLookup[match];
});
return '$' + escapedString;
} | javascript | {
"resource": ""
} |
q25324 | getComponentKey | train | function getComponentKey(component, index) {
// Do some typechecking here since we call this blindly. We want to ensure
// that we don't block potential future ES APIs.
if (typeof component === 'object' && component !== null && component.key != null) {
// Explicit key
return escape(component.key);
}
/... | javascript | {
"resource": ""
} |
q25325 | triggerGlobal | train | function triggerGlobal(settings, context, eventName, data) {
if (settings.global)
return triggerAndReturn(context || document, eventName, data);
} | javascript | {
"resource": ""
} |
q25326 | ajaxBeforeSend | train | function ajaxBeforeSend(xhr, settings) {
var context = settings.context;
if (settings.beforeSend.call(context, xhr, settings) === false || triggerGlobal(settings, context, 'ajaxBeforeSend', [
xhr,
settings
]) === false)
return false;
trigg... | javascript | {
"resource": ""
} |
q25327 | train | function (e) {
if (e.targetTouches.length < 2) return 1;
var x1 = e.targetTouches[0].pageX,
y1 = e.targetTouches[0].pageY,
x2 = e.targetTouches[1].pageX,
y2 = e.targetTouches[1].pageY;
var distance = Math.sqrt(Ma... | javascript | {
"resource": ""
} | |
q25328 | invokeToneAsync | train | function invokeToneAsync(assistantPayload, toneAnalyzer) {
return new Promise(function(resolve, reject) {
toneAnalyzer.tone({ text: assistantPayload.input.text }, function(error, data) {
if (error) {
reject(error);
} else {
resolve(data);
}
});
});
} | javascript | {
"resource": ""
} |
q25329 | updateTone | train | function updateTone(user, tones, maintainHistory) {
var maxScore = 0.0;
var primaryTone = null;
var primaryToneScore = null;
tones.forEach(function(tone) {
if (tone.score > maxScore) {
maxScore = tone.score;
primaryTone = tone.tone_name.toLowerCase();
primaryToneScore = tone.score;
}
... | javascript | {
"resource": ""
} |
q25330 | onEvent | train | function onEvent(name, event) {
console.log(name, JSON.stringify(event, null, 2));
} | javascript | {
"resource": ""
} |
q25331 | compileHistory | train | function compileHistory(resultingArrayOfCommits) {
var lastSha;
if (historyCommits.length > 0) {
lastSha = historyCommits[historyCommits.length - 1].commit.sha();
if (
resultingArrayOfCommits.length == 1 &&
resultingArrayOfCommits[0].commit.sha() == lastSha
) {
return;
}
}
res... | javascript | {
"resource": ""
} |
q25332 | walk | train | function walk() {
return revWalk.next().then(function(oid) {
if (!oid) {
return;
}
return repo.getCommit(oid).then(function(commit) {
console.log("Commit:", commit.toString());
return walk();
});
});
} | javascript | {
"resource": ""
} |
q25333 | performRebase | train | function performRebase(
repository,
rebase,
signature,
beforeNextFn,
beforeFinishFn
) {
var beforeNextFnResult;
/* In the case of FF merges and a beforeFinishFn, this will fail
* when looking for 'rewritten' so we need to handle that case.
*/
function readRebaseMetadataFile(fileName, continueOnEr... | javascript | {
"resource": ""
} |
q25334 | lastHunkStagedPromise | train | function lastHunkStagedPromise(result) {
return NodeGit.Diff.indexToWorkdir(repo, index, {
flags:
NodeGit.Diff.OPTION.SHOW_UNTRACKED_CONTENT |
NodeGit.Diff.OPTION.RECURSE_UNTRACKED_DIRS |
(additionalDiffOptions || 0)
})
.then(function(diff) {
return diff.patches();
})... | javascript | {
"resource": ""
} |
q25335 | lookupWrapper | train | function lookupWrapper(objectType, lookupFunction) {
lookupFunction = lookupFunction || objectType.lookup;
return function(repo, id, callback) {
if (id instanceof objectType) {
return Promise.resolve(id).then(function(obj) {
obj.repo = repo;
if (typeof callback === "function") {
... | javascript | {
"resource": ""
} |
q25336 | computeBuffer | train | function computeBuffer() {
this._buffer = map.layerPointToLatLng(new L.Point(0,0)).lat -
map.layerPointToLatLng(new L.Point(this.options.snapDistance, 0)).lat;
} | javascript | {
"resource": ""
} |
q25337 | train | function(matrix) {
var skew = this._skew;
if (!skew) {
skew = this._createElement('skew');
this._container.appendChild(skew);
skew.style.behavior = 'url(#default#VML)';
this._skew = skew;
}
// handle skew/translate separately, cause it's broken
var mt = ma... | javascript | {
"resource": ""
} | |
q25338 | train | function(e) {
if ((this.dragging && this.dragging.moved()) ||
(this._map.dragging && this._map.dragging.moved())) {
return;
}
this._fireMouseEvent(e);
} | javascript | {
"resource": ""
} | |
q25339 | train | function(matrix) {
var path = this._path;
var i, len, latlng;
var px = L.point(matrix[4], matrix[5]);
var crs = path._map.options.crs;
var transformation = crs.transformation;
var scale = crs.scale(path._map.getZoom());
var projection = crs.projection;
var diff = transformation.untran... | javascript | {
"resource": ""
} | |
q25340 | train | function(evt) {
var poly = this._shape || this._poly;
var marker = evt.target;
poly.fire('mousedown', L.Util.extend(evt, {
containerPoint: L.DomUtil.getPosition(marker._icon)
.add(poly._map._getMapPanePos())
}));
} | javascript | {
"resource": ""
} | |
q25341 | train | function (obj) { // (LatLng) or (LatLngBounds)
if (!obj) { return this; }
var latLng = L.latLng(obj);
if (latLng !== null) {
obj = latLng;
} else {
obj = L.latLngBounds(obj);
}
if (obj instanceof L.LatLng) {
if (!this._southWest && !this._northEast) {
this._southWest = new L.LatLng(obj.lat, o... | javascript | {
"resource": ""
} | |
q25342 | train | function (center, zoom) {
zoom = zoom === undefined ? this.getZoom() : zoom;
this._resetView(L.latLng(center), this._limitZoom(zoom));
return this;
} | javascript | {
"resource": ""
} | |
q25343 | train | function (offset, bounds) {
if (!bounds) { return offset; }
var viewBounds = this.getPixelBounds(),
newBounds = new L.Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset));
return offset.add(this._getBoundsOffset(newBounds, bounds));
} | javascript | {
"resource": ""
} | |
q25344 | train | function (points, sqTolerance) {
var reducedPoints = [points[0]];
for (var i = 1, prev = 0, len = points.length; i < len; i++) {
if (this._sqDist(points[i], points[prev]) > sqTolerance) {
reducedPoints.push(points[i]);
prev = i;
}
}
if (prev < len - 1) {
reducedPoints.push(points[len - 1]);
... | javascript | {
"resource": ""
} | |
q25345 | train | function (a, b, bounds, useLastCode) {
var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),
codeB = this._getBitCode(b, bounds),
codeOut, p, newCode;
// save 2nd code to avoid calculating it on the next segment
this._lastCode = codeB;
while (true) {
// if a,b is inside the c... | javascript | {
"resource": ""
} | |
q25346 | train | function (p, p1, p2, sqDist) {
var x = p1.x,
y = p1.y,
dx = p2.x - x,
dy = p2.y - y,
dot = dx * dx + dy * dy,
t;
if (dot > 0) {
t = ((p.x - x) * dx + (p.y - y) * dy) / dot;
if (t > 1) {
x = p2.x;
y = p2.y;
} else if (t > 0) {
x += dx * t;
y += dy * t;
}
... | javascript | {
"resource": ""
} | |
q25347 | bundleFiles | train | function bundleFiles(files, copy, version) {
var node = new SourceNode(null, null, null, '');
node.add(new SourceNode(null, null, null, copy + '(function (window, document, undefined) {'));
for (var i = 0, len = files.length; i < len; i++) {
var contents = fs.readFileSync(files[i], 'utf8');
... | javascript | {
"resource": ""
} |
q25348 | calculateVersion | train | function calculateVersion(officialRelease, callback) {
var version = require('./package.json').version;
if (officialRelease) {
callback(version);
} else {
git.short(function (str) {
callback(version + '+' + str);
});
}
} | javascript | {
"resource": ""
} |
q25349 | bind | train | function bind(func, obj) {
var slice = Array.prototype.slice;
var args = slice.call(arguments, 2);
return function () {
return func.apply(obj, args.concat(slice.call(arguments)));
};
} | javascript | {
"resource": ""
} |
q25350 | parseURL | train | function parseURL(url) {
const endpoint = {};
const purl = urlParser.parse(url, true);
if (purl.protocol && purl.protocol.startsWith('http')) {
endpoint.protocol = purl.protocol.slice(0, -1);
if (purl.hostname) {
endpoint.hostname = purl.hostname;
if (purl.port) {
endpoint.port = parseInt(purl.port... | javascript | {
"resource": ""
} |
q25351 | makeRealPem | train | function makeRealPem(pem) {
let result = null;
if (typeof pem === 'string') {
result = pem.replace(/-----BEGIN -----/, '-----BEGIN CERTIFICATE-----');
result = result.replace(/-----END -----/, '-----END CERTIFICATE-----');
result = result.replace(/-----([^-]+) ECDSA ([^-]+)-----([^-]*)-----([^-]+) ECDSA ([^-]+)... | javascript | {
"resource": ""
} |
q25352 | verifyTransactionName | train | function verifyTransactionName(name) {
if (typeof name !== 'string' || name.length === 0) {
const msg = util.format('Transaction name must be a non-empty string: %j', name);
logger.error('verifyTransactionName:', msg);
throw new Error(msg);
}
} | javascript | {
"resource": ""
} |
q25353 | verifyNamespace | train | function verifyNamespace(namespace) {
if (namespace && typeof namespace !== 'string') {
const msg = util.format('Namespace must be a non-empty string: %j', namespace);
logger.error('verifyNamespace:', msg);
throw new Error(msg);
}
} | javascript | {
"resource": ""
} |
q25354 | verifyArguments | train | function verifyArguments(args) {
const isInvalid = args.some((arg) => typeof arg !== 'string');
if (isInvalid) {
const argsString = args.map((arg) => util.format('%j', arg)).join(', ');
const msg = util.format('Transaction arguments must be strings: %s', argsString);
logger.error('verifyArguments:', msg);
thr... | javascript | {
"resource": ""
} |
q25355 | _stringToSignature | train | function _stringToSignature(string_signatures) {
const signatures = [];
for (let signature of string_signatures) {
// check for properties rather than object type
if (signature && signature.signature_header && signature.signature) {
logger.debug('_stringToSignature - signature is protobuf');
} else {
logg... | javascript | {
"resource": ""
} |
q25356 | _getNetworkConfig | train | function _getNetworkConfig(loadConfig, client) {
let network_config = null;
let network_data = null;
let network_config_loc = null;
if (typeof loadConfig === 'string') {
network_config_loc = path.resolve(loadConfig);
logger.debug('%s - looking at absolute path of ==>%s<==', '_getNetworkConfig', network_config_l... | javascript | {
"resource": ""
} |
q25357 | _getProposalResponseResults | train | function _getProposalResponseResults(proposal_response) {
if (!proposal_response.payload) {
throw new Error('Parameter must be a ProposalResponse Object');
}
const payload = _responseProto.ProposalResponsePayload.decode(proposal_response.payload);
const extension = _proposalProto.ChaincodeAction.decode(payload.ex... | javascript | {
"resource": ""
} |
q25358 | printDebugWithCode | train | function printDebugWithCode(msg, code) {
// eslint-disable-next-line no-console
console.log(`\n\n${msg}:\n`);
// eslint-disable-next-line no-console
console.log(`${highlightFn(code)}\n`);
} | javascript | {
"resource": ""
} |
q25359 | Polygon | train | function Polygon( sides, x, y, tileSize, ctx, num, analyser, streamData, tiles, fgRotation ){
this.analyser = analyser;
this.sides = sides;
this.tileSize = tileSize;
this.ctx = ctx;
this.tiles = tiles;
this.fgRotation = fgRotation;
/*
The number of the tile, starting at 0
*/
this.num = num;
/*
The highes... | javascript | {
"resource": ""
} |
q25360 | Star | train | function Star( x, y, starSize, ctx, fgCanvas, analyser, streamData ){
this.x = x;
this.y = y;
this.angle = Math.atan( Math.abs(y) / Math.abs(x) );
this.starSize = starSize;
this.ctx = ctx;
this.high = 0;
this.fgCanvas = fgCanvas;
this.analyser = analyser;
this.streamData = streamData;
} | javascript | {
"resource": ""
} |
q25361 | train | function(stream, state) {
if (stream.match(settings.leftDelimiter, true)) {
if (stream.eat("*")) {
return helpers.chain(stream, state, parsers.inBlock("comment", "*" + settings.rightDelimiter));
} else {
// Smarty 3 allows { and } surrounded by whitespace to NOT slip into Smart... | javascript | {
"resource": ""
} | |
q25362 | jsbinShowEdit | train | function jsbinShowEdit(options) {
'use strict';
if (window.location.hash === '#noedit') {return;}
var moveTimer, over,
doc = document,
aEL = 'addEventListener',
path = options.root + window.location.pathname,
style = doc.createElement('link'),
btn = doc.createElement('a');
// Add button:
btn.id = ... | javascript | {
"resource": ""
} |
q25363 | normal | train | function normal(source, setState) {
if (source.eatWhile(whiteCharRE)) {
return null;
}
var ch = source.next();
if (specialRE.test(ch)) {
if (ch == '{' && source.eat('-')) {
var t = "comment";
if (source.eat('#')) {
t = "meta";
}
return switchState(s... | javascript | {
"resource": ""
} |
q25364 | train | function (err, req, res, next) {
err = this.coerceError(err);
if (err instanceof errors.NotFound && req.accepts('html')) {
if (err instanceof errors.BinNotFound) {
if (req.editor) {
return (new BinHandler(this.sandbox)).notFound(req, res, next);
}
}
return this.rend... | javascript | {
"resource": ""
} | |
q25365 | train | function (req, res) {
var error = new errors.NotFound('Page Does Not Exist');
if (req.accepts('html') && (req.url.indexOf('/api/') !== 0)) {
this.renderErrorPage('404', error, req, res);
} else {
this.renderError(error, req, res);
}
} | javascript | {
"resource": ""
} | |
q25366 | train | function (err, req, res) {
console.error('uncaughtError', req.method + ' ' + req.url);
this.sendErrorReport(err, req);
if (req.accepts('html')) {
this.renderErrorPage('error', err, req, res);
} else {
var error = new errors.HTTPError(500, 'Internal Server Error');
this.renderError(err... | javascript | {
"resource": ""
} | |
q25367 | train | function (err) {
var status = typeof err === 'number' ? err : err.status;
if (!(err instanceof errors.HTTPError) && status) {
return errors.create(status, err.message);
}
return err;
} | javascript | {
"resource": ""
} | |
q25368 | formData | train | function formData(form) {
var length = form.length;
var data = {};
var value;
var el;
var type;
var name;
var append = function (data, name, value) {
if (data[name] === undefined) {
data[name] = value;
} else {
if (typeof data[name] === 'string') {
data... | javascript | {
"resource": ""
} |
q25369 | train | function() {
var htmlState = htmlMode.startState();
var rubyState = rubyMode.startState();
return {
htmlState: htmlState,
rubyState: rubyState,
indented: 0,
previousToken: { style: null, indented: 0},
tokenize: html
};
} | javascript | {
"resource": ""
} | |
q25370 | htmlDispatch | train | function htmlDispatch(stream, state) {
if (stream.match(scriptStartRegex, false)) {
state.token=scriptingDispatch;
return scriptingMode.token(stream, state.scriptState);
}
else
return htmlMixedMode.token(stream, state.htmlState);
} | javascript | {
"resource": ""
} |
q25371 | train | function(cm, key) {
var command;
var vim = maybeInitVimState(cm);
var macroModeState = vimGlobalState.macroModeState;
if (macroModeState.enteredMacroMode) {
if (key == 'q') {
actions.exitMacroRecordMode();
vim.inputState = new InputState();
r... | javascript | {
"resource": ""
} | |
q25372 | InputState | train | function InputState() {
this.prefixRepeat = [];
this.motionRepeat = [];
this.operator = null;
this.operatorArgs = null;
this.motion = null;
this.motionArgs = null;
this.keyBuffer = []; // For matching multi-key commands.
this.registerName = null; // Defaults to the uname... | javascript | {
"resource": ""
} |
q25373 | train | function(name) {
if (!this.isValidRegister(name)) {
return this.unamedRegister;
}
name = name.toLowerCase();
if (!this.registers[name]) {
this.registers[name] = new Register();
}
return this.registers[name];
} | javascript | {
"resource": ""
} | |
q25374 | getFullyMatchedCommandOrNull | train | function getFullyMatchedCommandOrNull(command) {
if (keys.length < command.keys.length) {
// Matches part of a multi-key command. Buffer and wait for next
// stroke.
inputState.keyBuffer.push(key);
return null;
} else {
if (command.keys[key... | javascript | {
"resource": ""
} |
q25375 | train | function(cm, operatorArgs, _vim, curStart, curEnd) {
// If the ending line is past the last line, inclusive, instead of
// including the trailing \n, include the \n before the starting line
if (operatorArgs.linewise &&
curEnd.line > cm.lastLine() && curStart.line > cm.firstLine()) {
... | javascript | {
"resource": ""
} | |
q25376 | isInRange | train | function isInRange(pos, start, end) {
if (typeof pos != 'number') {
// Assume it is a cursor position. Get the line number.
pos = pos.line;
}
if (start instanceof Array) {
return inArray(pos, start);
} else {
if (end) {
return (pos >= start && pos <= end... | javascript | {
"resource": ""
} |
q25377 | buildVimKeyMap | train | function buildVimKeyMap() {
/**
* Handle the raw key event from CodeMirror. Translate the
* Shift + key modifier to the resulting letter, while preserving other
* modifers.
*/
// TODO: Figure out a way to catch capslock.
function cmKeyToVimKey(key, modifier) {
var v... | javascript | {
"resource": ""
} |
q25378 | onChange | train | function onChange(_cm, changeObj) {
var macroModeState = vimGlobalState.macroModeState;
var lastChange = macroModeState.lastInsertModeChanges;
while (changeObj) {
lastChange.expectCursorActivityForChange = true;
if (changeObj.origin == '+input' || changeObj.origin == 'paste'
... | javascript | {
"resource": ""
} |
q25379 | onCursorActivity | train | function onCursorActivity() {
var macroModeState = vimGlobalState.macroModeState;
var lastChange = macroModeState.lastInsertModeChanges;
if (lastChange.expectCursorActivityForChange) {
lastChange.expectCursorActivityForChange = false;
} else {
// Cursor moved outside the context ... | javascript | {
"resource": ""
} |
q25380 | onKeyEventTargetKeyDown | train | function onKeyEventTargetKeyDown(e) {
var macroModeState = vimGlobalState.macroModeState;
var lastChange = macroModeState.lastInsertModeChanges;
var keyName = CodeMirror.keyName(e);
function onKeyFound() {
lastChange.changes.push(new InsertModeKey(keyName));
return true;
}
... | javascript | {
"resource": ""
} |
q25381 | repeatLastEdit | train | function repeatLastEdit(cm, vim, repeat, repeatForInsert) {
var macroModeState = vimGlobalState.macroModeState;
macroModeState.inReplay = true;
var isAction = !!vim.lastEditActionCommand;
var cachedInputState = vim.inputState;
function repeatCommand() {
if (isAction) {
co... | javascript | {
"resource": ""
} |
q25382 | prettyDate | train | function prettyDate(time){
'use strict';
// Remy Sharp edit: July 13, 2014 specific to JS Bin
// Need to replace Z in ISO8601 timestamp with +0000 so prettyDate() doesn't
// completely remove it (and parse the date using the local timezone).
var date = new Date((time || '').replace('Z', '+0000').replace(/-/... | javascript | {
"resource": ""
} |
q25383 | train | function(name, file) {
if (!ternLoaded[name]) {
$.ajax({
url: file,
dataType: 'json',
success: function(data) {
addTernDefinition(data);
ternLoaded[name] = true;
}
});
}
} | javascript | {
"resource": ""
} | |
q25384 | train | function(name, file) {
if (!ternLoaded[name]) {
$.ajax({
url: file,
dataType: 'script',
success: function(data) {
ternServer.server.addFile(name, data);
ternLoaded[name] = true;
}
});
}
} | javascript | {
"resource": ""
} | |
q25385 | train | function (data, fn) {
this.store.generateBinId(data.length, 0, function generateBinId(err, id) {
if (err) {
return fn(err);
}
data.url = id;
data.revision = 1;
data.latest = true;
data.streamingKey = this.createStreamingKey(id, data.revision);
this.store.setBin(dat... | javascript | {
"resource": ""
} | |
q25386 | train | function (data, fn) {
data.streamingKey = this.createStreamingKey(data.url, data.revision);
this.store.setBin(data, function (err, id) {
data.id = id;
fn(err || null, err ? undefined : data);
});
} | javascript | {
"resource": ""
} | |
q25387 | train | function (req, res, next) {
// Check request's accepts header for event-stream. Move on if it doesn't
// support it.
if (!req.headers.accept || req.headers.accept.indexOf('text/event-stream') === -1) {
return next();
}
// Restore or create a session for the bin
var session = utils.sessio... | javascript | {
"resource": ""
} | |
q25388 | train | function (bin) {
var session = utils.sessionForBin(bin);
if (session) {
session.res.forEach(function (res) {
res.write('event: reload\ndata: 0\n\n');
if (res.ajax) {
res.end(); // lets older browsers finish their xhr request
res.req.emit('close');
}
});
... | javascript | {
"resource": ""
} | |
q25389 | train | function (oldBin, newBin) {
if (!newBin || !newBin.url) {
// FIXME this is just patching a problem, the source of which I'm not sure
console.error('spike/index.js#bump-revision - missing newBin', newBin);
return;
}
var oldSession = utils.sessionForBin(oldBin),
oldKey = utils.keyF... | javascript | {
"resource": ""
} | |
q25390 | train | function (bin, data, statsRequest) {
var id = bin.id,
delayTrigger = 500;
if (!pending[id]) {
pending[id] = {};
}
pending[id].bin = bin;
pending[id][data.panelId] = utils.process(data, bin.settings);
// Clear the previous ping
clearTimeout(pending[id].timer);
// NOTE: t... | javascript | {
"resource": ""
} | |
q25391 | train | function () {
return function (req, res, next) {
var headers = req.header('Access-Control-Request-Headers');
var origin = req.header('Origin');
// TODO should this check if the request is via the API?
if (req.method === 'OPTIONS' || (req.method === 'GET' && req.headers.origin)) {
re... | javascript | {
"resource": ""
} | |
q25392 | train | function (options) {
var ignore = options.ignore || [],
csrf = csurf(options),
always = {OPTIONS: 1, GET: 1, HEAD: 1};
return function (req, res, next) {
if (always[req.method]) {
return csrf(req, res, next);
} else {
var url = parse(req.url);
var skipCSRF = ... | javascript | {
"resource": ""
} | |
q25393 | train | function () {
return function (req, res, next) {
var apphost = config.url.host,
outputHost = undefsafe(config, 'security.preview'),
host = req.header('Host', ''),
offset = host.indexOf(apphost);
if (host === outputHost) {
offset = host.indexOf(outputHost);
}
... | javascript | {
"resource": ""
} | |
q25394 | train | function (options) {
// Parse a string representing a file size and convert it into bytes.
// A number on it's own will be assumed to be bytes. A multiple such as
// "k" or "m" can be appended to the string to handle larger numbers. This
// is case insensitive and uses powers of 1024 rather than (1000).... | javascript | {
"resource": ""
} | |
q25395 | train | function () {
return function (req, res, next) {
var userModel = models.user;
if (req.url.indexOf('/api') === 0) {
req.isApi = true;
// Make the API requests stateless by removin the cookie set by middleware cookieSession
onHeaders(res, () => res.removeHeader('Set-Cookie'));
... | javascript | {
"resource": ""
} | |
q25396 | train | function (cmd, cb) {
var internalCmd = internalCommand(cmd);
if (internalCmd) {
return cb(['info', internalCmd]);
}
$document.trigger('console:run', cmd);
} | javascript | {
"resource": ""
} | |
q25397 | train | function (cmd, blind, response) {
var toecho = '';
if (typeof cmd !== 'string') {
toecho = cmd.echo;
blind = cmd.blind;
response = cmd.response;
cmd = cmd.cmd;
} else {
toecho = cmd;
}
cmd = trim(cmd);
// Add the command to the user's history – unless this was blind
if (!blind) {
... | javascript | {
"resource": ""
} | |
q25398 | train | function (response) {
// order so it appears at the top
var el = document.createElement('div'),
li = document.createElement('li'),
span = document.createElement('span'),
parent = output.parentNode;
historyPosition = history.length;
if (typeof response === 'undefined') return;
el.classNam... | javascript | {
"resource": ""
} | |
q25399 | getMostPowerful | train | function getMostPowerful(state) {
var context = state.cmdState;
for (var i = context.length - 1; i >= 0; i--) {
var plug = context[i];
if (plug.name == "DEFAULT") {
continue;
}
return plug;
}
return { styleIdentifier: functi... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.