_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q52900
train
function(code){ this.obj.should.have.property('statusCode'); var status = this.obj.statusCode; this.assert( code == status , function(){ return 'expected response code of ' + code + ' ' + i(statusCodes[code]) + ', but got ' + status
javascript
{ "resource": "" }
q52901
addToPrefiltersOrTransports
train
function addToPrefiltersOrTransports( structure ) { // dataTypeExpression is optional and defaults to "*" return function( dataTypeExpression, func ) { if ( typeof dataTypeExpression !== "string" ) { func = dataTypeExpression; dataTypeExpression = "*"; } var dataType, list, placeBefore, dataTypes = ...
javascript
{ "resource": "" }
q52902
appendDecorations
train
function appendDecorations(basePos, sourceCode, langHandler, out) { if (!sourceCode) { return; } var job = { sourceCode: sourceCode,
javascript
{ "resource": "" }
q52903
isWindow
train
function isWindow(obj) { return obj && obj.document
javascript
{ "resource": "" }
q52904
shallowCopy
train
function shallowCopy(src, dst) { dst = dst || {}; for(var key in src) { if (src.hasOwnProperty(key) && key.substr(0, 2) !==
javascript
{ "resource": "" }
q52905
train
function(key, value) { var array = this[key = hashKey(key)];
javascript
{ "resource": "" }
q52906
train
function(key) { var array = this[key = hashKey(key)]; if (array) { if (array.length == 1) { delete this[key];
javascript
{ "resource": "" }
q52907
train
function(key, fn) { var attrs = this, $$observers = (attrs.$$observers || (attrs.$$observers = {})), listeners = ($$observers[key] || ($$observers[key] = [])); listeners.push(fn); $rootScope.$evalAsync(function() { if (!listeners.$$inter) {
javascript
{ "resource": "" }
q52908
$SnifferProvider
train
function $SnifferProvider() { this.$get = ['$window', function($window) { var eventSupport = {}, android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]); return { // Android has history.pushState, but it does not update location correctly // so let's not use...
javascript
{ "resource": "" }
q52909
headersGetter
train
function headersGetter(headers) { var headersObj = isObject(headers) ? headers : undefined; return function(name) { if (!headersObj) headersObj = parseHeaders(headers); if (name)
javascript
{ "resource": "" }
q52910
toggleValidCss
train
function toggleValidCss(isValid, validationErrorKey) { validationErrorKey = validationErrorKey ? '-' + snake_case(validationErrorKey, '-') : ''; $element. removeClass((isValid ? INVALID_CLASS :
javascript
{ "resource": "" }
q52911
isES5DataProperty
train
function isES5DataProperty(object, key) { var result = false; // make sure this works in older browsers without error if (Object.getOwnPropertyDescriptor && object.hasOwnProperty(key)) { var descriptor =
javascript
{ "resource": "" }
q52912
train
function(methods) { var object = {}; for (var i = 0, len = methods.length; i < len; i++) {
javascript
{ "resource": "" }
q52913
nestedPath
train
function nestedPath (obj, path, val) { if (typeof obj !== 'object') { return obj } var keys = path.split('.') if (keys.length > 1) { path = keys.shift()
javascript
{ "resource": "" }
q52914
dataToObjects
train
function dataToObjects (data) { if (!data) return null if (data instanceof Array)
javascript
{ "resource": "" }
q52915
dropDatabase
train
function dropDatabase (db, fn) { db.connection.db.executeDbCommand({ dropDatabase: 1 },
javascript
{ "resource": "" }
q52916
dropCollections
train
function dropCollections (db, each, fn) { if (each && !fn) { fn = each; each = null } var conn = db.connection , cols = Object.keys(conn.collections) cols.forEach(function (name, k) { console.log('name: ', name, k) conn.collections[name].drop(function (err)
javascript
{ "resource": "" }
q52917
step5a
train
function step5a(token) { var m = measure(token); if((m > 1 && token.substr(-1) == 'e') || (m == 1 && !(categorizeChars(token).substr(-4, 3) == 'CVC' &&
javascript
{ "resource": "" }
q52918
step5b
train
function step5b(token) { if(measure(token) > 1) { if(endsWithDoublCons(token) &&
javascript
{ "resource": "" }
q52919
normalizeTokens
train
function normalizeTokens(relative, tokens) { var _index = 0; // Force as an array if (!_.isArray(tokens)) tokens = [tokens]; return _.map(tokens, function(subtoken) { if (_.isNull(subtoken)) return null; if (_.isString(subtoken)) { subtoken = { value: subtok...
javascript
{ "resource": "" }
q52920
encrypt
train
function encrypt (str) { var cipher = crypto.createCipher(algorithm, key) , crypted
javascript
{ "resource": "" }
q52921
decrypt
train
function decrypt (str) { var decipher = crypto.createDecipher(algorithm, key) , dec
javascript
{ "resource": "" }
q52922
encode
train
function encode (schema, doc, toEncrypt) { if (!doc) return false var method = (toEncrypt) ? encrypt : decrypt , obj = (doc.toObject) ? doc.toObject() : doc // Traverse through all schema paths schema.eachPath(function (name, path) { var val = nestedPath(doc, name) // ObjectID paths ...
javascript
{ "resource": "" }
q52923
getDirectionPositionForRange
train
function getDirectionPositionForRange (value, min, max, orientation) { return isVertical(orientation) ? ( // as upper value is used to calculate `top`; Math.round(((max -
javascript
{ "resource": "" }
q52924
isInActiveRange
train
function isInActiveRange (stepValue, value, isRangeType) { if (isRangeType) { return stepValue > value[0]
javascript
{ "resource": "" }
q52925
getSteps
train
function getSteps (props) { const { step, min, max, value, isRangeType, orientation } = props; const steps = []; const totalSteps = ((max - min) / step) + 1; for (let i = 0; i < totalSteps; i++) { let position = getPositionInPercentage(i * step, min,
javascript
{ "resource": "" }
q52926
train
function (validator) { EventEmitter.apply(this); this._validator = validator || Parser.defaultValidator; this._configuration = new Configuration(); this._tokenizer
javascript
{ "resource": "" }
q52927
reverse
train
function reverse (data, callback) { if (Math.random() > 0.9) {
javascript
{ "resource": "" }
q52928
createDirectory
train
function createDirectory(options) { return new Promise(function(resolve, reject) { mkdirp( options.directory, function (err) { if(err && err.code !== 'EEXIST') {
javascript
{ "resource": "" }
q52929
writeHTMLFile
train
function writeHTMLFile(options) { return new Promise(function(resolve, reject) { var templateFile = path.join(__dirname, '../template/cli.html'); // read our template file fs.readFile(templateFile, 'utf8', function (err,data) { if (err) { reject(err); } // insert the generated ...
javascript
{ "resource": "" }
q52930
describe
train
function describe(metaData) { if (item.stack) { describeRouterRoute(item, metaData);
javascript
{ "resource": "" }
q52931
compile
train
function compile() { ensureInitialised('compile'); if (state.app.name === 'router') { state.app = { _router: state.app }; } if (!state.app._router) { throw new Error("app._router was null, either your app is
javascript
{ "resource": "" }
q52932
addTag
train
function addTag(tag, options) { addToCommon({ schemaKey: schemaIds.tag, object: tag,
javascript
{ "resource": "" }
q52933
addBodyParameter
train
function addBodyParameter(body, options) { addToCommon({ schemaKey: schemaIds.parameter.body, in: 'body',
javascript
{ "resource": "" }
q52934
addResponse
train
function addResponse(response, options) { addToCommon({ schemaKey: schemaIds.response, object: response,
javascript
{ "resource": "" }
q52935
addModel
train
function addModel(model, inputOptions) { var options = { schemaKey: schemaIds.schema, object: model, targetObject: state.common.models, displayName: 'Model', deleteNameFromCommon: true }; applyDefaults(options, inputOptions); ensureObjectExists(options); clone...
javascript
{ "resource": "" }
q52936
generateCommentFromOptions
train
function generateCommentFromOptions(options, callback) { console.info('\t\tGenerating comments for', options.paramName, '...'); async.waterfall([ async.apply(loadSchema, options), derefSchema, generateComment, addGeneratedComment ], function (err) {
javascript
{ "resource": "" }
q52937
getErrorMessage
train
function getErrorMessage(errors) { var fullMessage = ''; errors.forEach(function (err) { var message = ajv.errorsText([err]); if (message.indexOf('should NOT have additional properties') < 0) { fullMessage += message + os.EOL; }
javascript
{ "resource": "" }
q52938
objToRule
train
function objToRule(obj, clonedRule) { var rule = clonedRule || postcss.rule(); var skipKeys = ['selector', 'selectors', 'source']; if (obj.selector) rule.selector = obj.selector; else if (obj.selectors) rule.selectors = obj.selectors; if (obj.source) rule.source = obj.source; for (var k in ob...
javascript
{ "resource": "" }
q52939
start
train
function start (inp) { var res = parseArgumentList(inp.skipWs()); // If there is any leftover, we have input that did not match our grammar, // so throw a generic
javascript
{ "resource": "" }
q52940
parsePattern
train
function parsePattern (inp) { return parseWildcard(inp) || parseNullLiteral(inp) || parseUndefinedLiteral(inp) || parseBooleanLiteral(inp) || parseNumberLiteral(inp) || parseStringLiteral(inp) || parseClassPattern(inp)
javascript
{ "resource": "" }
q52941
parseExtractor
train
function parseExtractor (inp) { var match = inp.takeAPeek(EXTRACTOR); if (match) return wrapped("(", ")", parsePattern, extractorRes, inp) || nodeExtractor(match[1]);
javascript
{ "resource": "" }
q52942
parseObjectPattern
train
function parseObjectPattern (inp) { var res = parseKey(inp); if (res) { if (inp.skipWs().takeAPeek(":")) { var patt = parsePattern(inp.skipWs());
javascript
{ "resource": "" }
q52943
parseKey
train
function parseKey (inp) { var res = parseString(inp); if (res) return res;
javascript
{ "resource": "" }
q52944
parseIdentPattern
train
function parseIdentPattern (inp) { var match = inp.takeAPeek(IDENT); if (match) { if (inp.takeAPeek("@")) { var patt = parseBinderPattern(inp);
javascript
{ "resource": "" }
q52945
wrapped
train
function wrapped (del1, del2, pattFn, nodeFn, inp) { if (inp.takeAPeek(del1)) { var res = pattFn(inp.skipWs()); if
javascript
{ "resource": "" }
q52946
nodeClass
train
function nodeClass (name, res) { var patt = name; if (res) { patt += res.type === "array" ? "(" + res.pattern.substring(1, res.pattern.length - 1) + ")"
javascript
{ "resource": "" }
q52947
compileRest
train
function compileRest (argName, node) { var source = []; var retInit = []; // Count the number of identifiers we will need to stash. var i = 0, len = countIdentifiers(node); for (; i < len; i++) retInit.push('[]'); var retName = argName + '_ret'; var loopName = argName + '_loop...
javascript
{ "resource": "" }
q52948
hasRest
train
function hasRest (node) { for (var i = 0, child; (child = node.children[i]); i++) { if
javascript
{ "resource": "" }
q52949
countIdentifiers
train
function countIdentifiers (node) { if (!node.children) return 0; var count = 0, i = 0, len = node.children.length, type; for (; i < len; i++) { type = node.children[i].type;
javascript
{ "resource": "" }
q52950
getOrCompile
train
function getOrCompile (patternStr) { var tree, fn; if (!patterns.hasOwnProperty(patternStr)) { tree = parse(patternStr); if (!normalized.hasOwnProperty(tree.pattern)) {
javascript
{ "resource": "" }
q52951
pattern
train
function pattern () { var targ0 = typeof arguments[0]; var targ1 = typeof arguments[1]; var targ2 = typeof arguments[2]; // Shared vars var matcherFn, patternObj, patternFn, patternStr, successFn, chain, tree, last; // pattern(matcherFn, chain) if (targ0 == "function" && (targ1 == "und...
javascript
{ "resource": "" }
q52952
matcher
train
function matcher (patternFn, successFn, chain) { var matcherObj = new Matcher(patternFn, successFn); // If a chain was provided, add the new matcher to the end of the chain. if (chain) { chain.last().next = matcherObj; } else { chain = matcherObj; } var fn = function () { ...
javascript
{ "resource": "" }
q52953
caseOf
train
function caseOf (/* ...args, matcher */) { var args = slice.call(arguments, 0, -1); var matcher = arguments[arguments.length - 1]; var context = this === exports ? null : this; if (typeof matcher === "function") {
javascript
{ "resource": "" }
q52954
extract
train
function extract (/* pattern, ...args */) { var args = slice.call(arguments, 1); var context =
javascript
{ "resource": "" }
q52955
hash
train
function hash() { var i = 0, args = arguments, length = args.length, obj = {}; for (; i
javascript
{ "resource": "" }
q52956
pad
train
function pad(number, length) { // Create an array of the remaining length +1 and join it with 0's return new
javascript
{ "resource": "" }
q52957
wrap
train
function wrap(obj, method, func) { var proceed = obj[method]; obj[method] = function () { var args = Array.prototype.slice.call(arguments);
javascript
{ "resource": "" }
q52958
format
train
function format(str, ctx) { var splitter = '{', isInside = false, segment, valueAndFormat, path, i, len, ret = [], val, index; while ((index = str.indexOf(splitter)) !== -1) { segment = str.slice(0, index); if (isInside) { // we're on the closing bracket looking back valueAndFormat =...
javascript
{ "resource": "" }
q52959
getMagnitude
train
function getMagnitude(num) { return
javascript
{ "resource": "" }
q52960
destroyObjectProperties
train
function destroyObjectProperties(obj, except) { var n; for (n in obj) { // If the object is non-null and destroy is defined if (obj[n] && obj[n] !== except && obj[n].destroy) { // Invoke the
javascript
{ "resource": "" }
q52961
discardElement
train
function discardElement(element) { // create a garbage bin element, not part of the DOM if (!garbageBin) { garbageBin = createElement(DIV); } // move the node and empty bin
javascript
{ "resource": "" }
q52962
error
train
function error(code, stop) { var msg = 'Highcharts error #' + code + ': www.highcharts.com/errors/' + code; if (stop) { throw
javascript
{ "resource": "" }
q52963
train
function (elem, fromD, toD) { fromD = fromD || ''; var shift = elem.shift, bezier = fromD.indexOf('C') > -1, numParams = bezier ? 7 : 3, endLength, slice, i, start = fromD.split(' '), end = [].concat(toD), // copy startBaseLine, endBaseLine, sixify = function (arr) { // in splines make...
javascript
{ "resource": "" }
q52964
train
function (el, eventType, handler) { // workaround for jQuery issue with unbinding custom events: // http://forum.jQuery.com/topic/javascript-error-when-unbinding-a-custom-event-using-jQuery-1-4-2 var func = doc.removeEventListener ? 'removeEventListener'
javascript
{ "resource": "" }
q52965
train
function (el, type, eventArguments, defaultFunction) { var event = $.Event(type), detachedType = 'detached' + type, defaultPrevented; // Remove warnings in Chrome when accessing layerX and layerY. Although Highcharts // never uses these properties, Chrome includes them in the default click event and ...
javascript
{ "resource": "" }
q52966
train
function (e) { var ret = e.originalEvent || e; // computed by jQuery, needed by
javascript
{ "resource": "" }
q52967
train
function (renderer, nodeName) { var wrapper = this; wrapper.element = nodeName === 'span' ? createElement(nodeName) : doc.createElementNS(SVG_NS, nodeName); wrapper.renderer = renderer; /** * A collection of attribute setters. These methods, if defined, are called right before a certain * attribute
javascript
{ "resource": "" }
q52968
train
function (params, options, complete) { var animOptions = pick(options, globalAnimation, true); stop(this); // stop regardless of animation actually running, or reverting to .attr (#607) if (animOptions) { animOptions = merge(animOptions); if (complete) { // allows using a callback
javascript
{ "resource": "" }
q52969
train
function (className) { var element = this.element, currentClassName = attr(element, 'class') || ''; if (currentClassName.indexOf(className) === -1)
javascript
{ "resource": "" }
q52970
train
function (styles) { /*jslint unparam: true*//* allow unused param a in the regexp function below */ var elemWrapper = this, elem = elemWrapper.element, textWidth = styles && styles.width && elem.nodeName.toLowerCase() === 'text', n, serializedCss = '', hyphenate = function (a, b) { return '-' + b.toL...
javascript
{ "resource": "" }
q52971
train
function (styles) { var wrapper = this, element = wrapper.element, textWidth = styles && element.tagName === 'SPAN' && styles.width; if (textWidth) { delete styles.width; wrapper.textWidth = textWidth; wrapper.updateTransform();
javascript
{ "resource": "" }
q52972
train
function (path) { var attr = { fill: NONE }; if (isArray(path)) { attr.d = path; } else if (isObject(path)) { //
javascript
{ "resource": "" }
q52973
train
function (src, x, y, width, height) { var attribs = { preserveAspectRatio: NONE }, elemWrapper; // optional properties if (arguments.length > 1) { extend(attribs, { x: x, y: y, width: width, height: height }); } elemWrapper = this.createElement('image').attr(attribs); // s...
javascript
{ "resource": "" }
q52974
updateTextPadding
train
function updateTextPadding() { var styles = wrapper.styles, textAlign = styles && styles.textAlign, x = paddingLeft + padding * (1 - alignFactor), y; // determin y based on the baseline y = baseline ? 0 : baselineOffset; // compensate for alignment if (defined(width) && (textAlign === 'cent...
javascript
{ "resource": "" }
q52975
boxAttr
train
function boxAttr(key, value) { if (box) { box.attr(key, value); } else {
javascript
{ "resource": "" }
q52976
train
function (styles) { if (styles) { var textStyles = {}; styles = merge(styles); // create a copy to avoid altering the original object (#537) each(['fontSize', 'fontWeight', 'fontFamily', 'color', 'lineHeight', 'width', 'textDecoration', 'textShadow'], function (prop) { if (styles[prop] !== UNDE...
javascript
{ "resource": "" }
q52977
train
function () { return { width: bBox.width + 2 * padding,
javascript
{ "resource": "" }
q52978
train
function (value) { // convert paths var i = value.length, path = [], clockwise; while (i--) { // Multiply by 10 to allow subpixel precision. // Substracting half a pixel seems to make the coordinates // align with SVG, but this hasn't been tested thoroughly if (isNumber(value[i])) { path[i...
javascript
{ "resource": "" }
q52979
train
function (path, length) { var len; path = path.split(/[ ,]/); len = path.length; if (len === 9 || len === 11) { path[len - 4] =
javascript
{ "resource": "" }
q52980
train
function (path) { var attr = { // subpixel precision down to 0.1 (width and height = 1px) coordsize: '10 10' }; if (isArray(path)) { attr.d = path; } else if (isObject(path)) { // attributes
javascript
{ "resource": "" }
q52981
drawDeferred
train
function drawDeferred() { var callLength = deferredRenderCalls.length, callIndex; // Draw all pending render calls
javascript
{ "resource": "" }
q52982
train
function () { var label = this.label, axis = this.axis; return
javascript
{ "resource": "" }
q52983
train
function (horiz, pos, tickmarkOffset, old) { var axis = this.axis, chart = axis.chart, cHeight = (old && chart.oldChartHeight) || chart.chartHeight; return { x: horiz ? axis.translate(pos + tickmarkOffset, null, null, old)
javascript
{ "resource": "" }
q52984
train
function (x, y, tickLength, tickWidth, horiz, renderer) { return renderer.crispLine([ M, x, y,
javascript
{ "resource": "" }
q52985
train
function (newOptions, redraw) { var chart = this.chart; newOptions = chart.options[this.xOrY + 'Axis'][this.options.index] = merge(this.userOptions, newOptions); this.destroy(true); this._addedPlotLB = this.userMin = this.userMax = UNDEFINED; // #1611, #2306
javascript
{ "resource": "" }
q52986
train
function (redraw) { var chart = this.chart, key = this.xOrY + 'Axis'; // xAxis or yAxis // Remove associated series each(this.series, function (series) { series.remove(false); }); // Remove the axis erase(chart.axes, this); erase(chart[key], this); chart.options[key].splice(this.options.index, 1...
javascript
{ "resource": "" }
q52987
train
function (value, paneCoordinates) { return this.translate(value,
javascript
{ "resource": "" }
q52988
train
function (from, to) { var toPath = this.getPlotLinePath(to), path = this.getPlotLinePath(from); if (path && toPath) { path.push( toPath[4], toPath[5],
javascript
{ "resource": "" }
q52989
train
function (interval, min, max, minor) { var axis = this, options = axis.options, axisLength = axis.len, // Since we use this method for both major and minor ticks, // use a local variable and return the result positions = []; // Reset if (!minor) { axis._minorAutoInterval = null; } // ...
javascript
{ "resource": "" }
q52990
train
function () { var axis = this, options = axis.options, tickPositions = axis.tickPositions, minorTickInterval = axis.minorTickInterval, minorTickPositions = [], pos, i, len; if (axis.isLog) { len = tickPositions.length; for (i = 1; i < len; i++) { minorTickPositions = minorTickPosit...
javascript
{ "resource": "" }
q52991
train
function () { var axis = this, options = axis.options, min = axis.min, max = axis.max, zoomOffset, spaceAvailable = axis.dataMax - axis.dataMin >= axis.minRange, closestDataRange, i, distance, xData, loopLength, minArgs, maxArgs; // Set the automatic minimum range based on the c...
javascript
{ "resource": "" }
q52992
train
function (saveOld) { var axis = this, range = axis.max - axis.min, pointRange = 0, closestPointRange, minPointOffset = 0, pointRangePadding = 0, linkedParent = axis.linkedParent, ordinalCorrection, transA = axis.transA; // adjust translation for padding if (axis.isXAxis) { if (linkedPa...
javascript
{ "resource": "" }
q52993
train
function () { var chart = this.chart, options = this.options, offsetLeft = options.offsetLeft || 0, offsetRight = options.offsetRight || 0, horiz = this.horiz, width, height, top, left; // Expose basic values to use in Series object and navigator this.left = left = pick(options.left, char...
javascript
{ "resource": "" }
q52994
train
function (rotation) { var ret, angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360; if (angle > 15 && angle < 165) { ret = 'right'; } else if
javascript
{ "resource": "" }
q52995
train
function (lineWidth) { var chart = this.chart, opposite = this.opposite, offset = this.offset, horiz = this.horiz, lineLeft = this.left + (opposite ? this.width : 0) + offset, lineTop = chart.chartHeight - this.bottom - (opposite ? this.height : 0) + offset; if (opposite) { lineWidth *= -1; //...
javascript
{ "resource": "" }
q52996
train
function () { // compute anchor points for each of the title align options var horiz = this.horiz, axisLeft = this.left, axisTop = this.top, axisLength = this.len, axisTitleOptions = this.options.title, margin = horiz ? axisLeft : axisTop, opposite = this.opposite, offset = this.offset, f...
javascript
{ "resource": "" }
q52997
train
function () { var series = this.series, i = series.length; if (!this.isXAxis) { while (i--) { series[i].setStackedPoints(); } // Loop up again to compute percent stack
javascript
{ "resource": "" }
q52998
train
function (points, mouseEvent) { var ret, chart = this.chart, inverted = chart.inverted, plotTop = chart.plotTop, plotX = 0, plotY = 0, yAxis; points = splat(points); // Pie uses a special tooltipPos ret = points[0].tooltipPos; // When tooltip follows mouse, relate the position to th...
javascript
{ "resource": "" }
q52999
train
function (point) { var chart = this.chart, label = this.label, pos = (this.options.positioner || this.getPosition).call( this,
javascript
{ "resource": "" }