_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
27
233k
language
stringclasses
1 value
meta_information
dict
q31100
train
function(arr) { return new stats.init(arguments.length > 1 ?
javascript
{ "resource": "" }
q31101
train
function(fn) { var arr = this.arr; if (arr.length === undefined) { // The wrapped array is a JSON object for (var key in arr) { this.arr[key] = fn.call(arr[key], arr[key], key, arr); } } else { // The wrapped array is an array for (var i = 0,
javascript
{ "resource": "" }
q31102
train
function(attr) { var newArr = []; if (this.arr.length === undefined) { // The wrapped array is a JSON object for (var key in arr) {
javascript
{ "resource": "" }
q31103
train
function(attr) { // Get the numbers var arr = this.arr; // Go through each of the numbers and find the minimum var minimum = attr == null ? arr[0] : arr[0][attr];
javascript
{ "resource": "" }
q31104
train
function(attr) { // Get the numbers var arr = this.arr; // Go through each of the numbers and find the maximum var maximum = attr == null ? arr[0] : arr[0][attr];
javascript
{ "resource": "" }
q31105
train
function() { // Sort the numbers var arr = this.clone().sort().toArray(); if (arr.length % 2 === 0) { // There are an even number of elements in the array; the median // is the average of the middle two return (arr[arr.length / 2 - 1] + arr[arr.length / 2]) / 2; } else {
javascript
{ "resource": "" }
q31106
train
function() { // Handle the single element case if (this.length == 1) { return this.arr[0]; } // Sort the numbers var nums = this.clone().sort(); // The third quartile is the
javascript
{ "resource": "" }
q31107
train
function() { // Get the mean var mean = this.mean(); // Get a new stats object to work with var nums = this.clone(); // Map each element of nums to the square of the element minus the // mean
javascript
{ "resource": "" }
q31108
train
function() { // Get the x and y coordinates var xCoords = this.pluck('x'); var yCoords = this.pluck('y'); // Get the means for the x and y coordinates var meanX = xCoords.mean(); var meanY = yCoords.mean(); // Get the standard deviations for the x and y coordinates var stdDevX = xCoo...
javascript
{ "resource": "" }
q31109
train
function() { // Get the x and y coordinates var xCoords = this.pluck('x'); var yCoords = this.pluck('y'); // Get the means for the x and y coordinates var meanX = xCoords.mean(); var meanY = yCoords.mean(); // Get the standard deviations for the x and y coordinates var stdDevX = xCoo...
javascript
{ "resource": "" }
q31110
train
function() { // Get y coordinates var yCoords = this.pluck('y'); // Do a semi-log transformation of the coordinates yCoords.map(function(num) { return Math.log(num); }); // Get a new stats object to work with that has the transformed data var nums = this.clone().map(function(coord, ...
javascript
{ "resource": "" }
q31111
train
function() { // Get y coordinates var xCoords = this.pluck('x'); var yCoords = this.pluck('y'); // Do a log-log transformation of the coordinates xCoords.map(function(num) { return Math.log(num); }); yCoords.map(function(num) { return Math.log(num); }); // Get a new sta...
javascript
{ "resource": "" }
q31112
train
function() { // Create a new stats object to work with var nums = this.clone(); // Go through each element and make the element the gcd of it // and the element to its left for (var i = 1; i < nums.size(); i++)
javascript
{ "resource": "" }
q31113
train
function() { // Create a new stats object to work with var nums = this.clone(); // Go through each element and make the element the lcm of it // and the element to its left for (var i = 1; i < nums.size(); i++)
javascript
{ "resource": "" }
q31114
gcd
train
function gcd(a, b) { if (b === 0) { return
javascript
{ "resource": "" }
q31115
lcm
train
function lcm(a, b) { // The least common multiple is the absolute value of the product of // the numbers divided by
javascript
{ "resource": "" }
q31116
train
function (win) { if (win == null) { return null; } while ((win.API == null) && (win.parent != null) && (win.parent != win)) { findAPITries++;
javascript
{ "resource": "" }
q31117
dequeue
train
function dequeue(queue, item) { queue[SIZE] -= 1 let done = false item.action(() => { if (done) { return } done = true if (item.next) {
javascript
{ "resource": "" }
q31118
_stdNormDensity
train
function _stdNormDensity(x) { return Math.pow(Math.E, -1 * Math.pow(x, 2)
javascript
{ "resource": "" }
q31119
getDelta
train
function getDelta(s, k, t, v, r, callPut) { if(callPut === "call") {
javascript
{ "resource": "" }
q31120
_callDelta
train
function _callDelta(s, k, t, v, r) { var w = bs.getW(s, k, t, v, r); var delta = null; if(!isFinite(w)) { delta = (s > k) ? 1
javascript
{ "resource": "" }
q31121
_putDelta
train
function _putDelta(s, k, t, v, r) { var delta = _callDelta(s, k, t, v, r) - 1; return
javascript
{ "resource": "" }
q31122
getRho
train
function getRho(s, k, t, v, r, callPut, scale) { scale = scale || 100; if(callPut === "call") { return _callRho(s, k, t, v, r) / scale;
javascript
{ "resource": "" }
q31123
_putRho
train
function _putRho(s, k, t, v, r) { var w = bs.getW(s, k, t, v, r); if(!isNaN(w)) { return -1 * k * t * Math.pow(Math.E, -1 * r * t)
javascript
{ "resource": "" }
q31124
getVega
train
function getVega(s, k, t, v, r) { var w = bs.getW(s, k, t, v, r); return (isFinite(w)) ? (s *
javascript
{ "resource": "" }
q31125
getTheta
train
function getTheta(s, k, t, v, r, callPut, scale) { scale = scale || 365; if(callPut === "call") { return _callTheta(s, k, t, v, r) / scale;
javascript
{ "resource": "" }
q31126
_callTheta
train
function _callTheta(s, k, t, v, r) { var w = bs.getW(s, k, t, v, r); if(isFinite(w)) { return -1 * v
javascript
{ "resource": "" }
q31127
train
function() { var sitemap = sm.createSitemap({ cacheTime: 600000, hostname: url.resolve(this.config.get('pluginsConfig.sitemap.hostname'), '/'), urls: urls });
javascript
{ "resource": "" }
q31128
Connection
train
function Connection (gridModule) { try { Connection.super_.apply(this, arguments); RbnUtil.__copyProperties(this, gridModule); this.validate(); this.connectionStub = '/' +
javascript
{ "resource": "" }
q31129
train
function (spaceIdentifier, params) { var path = this.constructPath(constants.SPACES,
javascript
{ "resource": "" }
q31130
train
function (spaceIdentifier, data) { var path; if (data) { path = this.constructPath(constants.SPACES, spaceIdentifier); return this.Core.PATCH(path, data); } else {
javascript
{ "resource": "" }
q31131
train
function (spaceIdentifier, deviceIdentifier, params) { var path; if (spaceIdentifier) { path = this.constructPath(constants.SPACES, spaceIdentifier,
javascript
{ "resource": "" }
q31132
train
function (spaceIdentifier, data) { var path; if (spaceIdentifier && data) { path = this.constructPath(constants.SPACES, spaceIdentifier, constants.DEVICES); return this.Core.POST(path, data);
javascript
{ "resource": "" }
q31133
train
function (spaceIdentifier, params) { var path; if (spaceIdentifier) { path = this.constructPath(constants.SPACES, spaceIdentifier, constants.PRESENCE); return this.Core.GET(path, params);
javascript
{ "resource": "" }
q31134
train
function (html) { var sep = '----------------------------------------------------------'; console.log('\n' + sep); console.log('markedejs: HTML OUT (markedejs.DEBUG = false to silence)');
javascript
{ "resource": "" }
q31135
ifIsectAddToOutput
train
function ifIsectAddToOutput(ring0, edge0, ring1, edge1) { var start0 = coord[ring0][edge0]; var end0 = coord[ring0][edge0+1]; var start1 = coord[ring1][edge1]; var end1 = coord[ring1][edge1+1]; var isect = intersect(start0, end0, start1, end1); if (isect == null) return; // discard parallels a...
javascript
{ "resource": "" }
q31136
rbushTreeItem
train
function rbushTreeItem(ring, edge) { var start = coord[ring][edge]; var end = coord[ring][edge+1]; if (start[0] < end[0]) { var minX = start[0], maxX = end[0]; } else { var minX = end[0], maxX = start[0]; }; if (start[1] < end[1]) { var
javascript
{ "resource": "" }
q31137
padEnd
train
function padEnd(str, length) { /* istanbul ignore next */ if (str.length >= length) return str;
javascript
{ "resource": "" }
q31138
tableDimensions
train
function tableDimensions(metrics) { const pointPad = UNIT.length + 2; let name = 6; let point = 5; for (let i = 0; i < metrics.length; i++) { const metric = metrics[i]; name = Math.max(name,
javascript
{ "resource": "" }
q31139
divider
train
function divider(dimensions, type) { let left = BORDER_RUD; let right = BORDER_LUD; let line = BORDER_HORZ; let joint = BORDER_LRUD; switch (type) { case 'top': left = BORDER_RD; right = BORDER_LD; joint = BORDER_LRD; break; case 'bottom': left = BORDER_RU; right ...
javascript
{ "resource": "" }
q31140
header
train
function header(dimensions) { return divider(dimensions, 'top') + BORDER_VERT + BOLD + padEnd(' NAME', dimensions.name) + RESET + BORDER_VERT + BOLD + padEnd(' AVG', dimensions.avg) + RESET + BORDER_VERT + BOLD
javascript
{ "resource": "" }
q31141
row
train
function row(metric, dimensions, isTarget) { let left = ''; let right = ''; if (isTarget) { left = HIGHLIGHT; right = RESET; } return BORDER_VERT + left + padEnd(' ' + metric.label, dimensions.name) + right + BORDER_VERT + left + padEnd(' ' + metric.avg + UNIT, dimensions.avg) + right ...
javascript
{ "resource": "" }
q31142
report
train
function report(stream, metrics, thresholds) { const target = (!elv(thresholds)) ? -1 : thresholds.target; const dimensions = tableDimensions(metrics); const border = divider(dimensions); let value = header(dimensions); for (let i = 0; i < metrics.length; i++) { if (i > 0) value += border; const metr...
javascript
{ "resource": "" }
q31143
findMany
train
function findMany(repository, options) { const entityColumns = repository.metadata.columns.map((columnMetadata) => columnMetadata.propertyName); const entityManyToOneRelationColumns = repository .metadata .relations .filter((relationMetadata) => relationMetadata.relationType === 'many-to...
javascript
{ "resource": "" }
q31144
train
function (data) { var path; if (data) { path = this.constructPath(constants.EVENTS); return this.Places.POST(path, data); } else {
javascript
{ "resource": "" }
q31145
listenEmpty
train
function listenEmpty( handler, isFunction, emitter ){ const errors = []; if( isFunction ){ try { handler.call( emitter ); } catch( error ){ errors.push( error ); } } else { const length = handler.length, listeners = handler.slice(); ...
javascript
{ "resource": "" }
q31146
toEmitter
train
function toEmitter( selection, target ){ // Apply the entire Emitter API if( selection === API ){ asEmitter.call( target ); // Apply only the selected API methods } else { let index, key, mapping, names, value; if( typeof selection === 'string' ){ n...
javascript
{ "resource": "" }
q31147
train
function (identifier, params) { var path = this.constructPath(constants.DEVICE_MANIFESTS,
javascript
{ "resource": "" }
q31148
train
function (data) { var path; if (data) { path = this.constructPath(constants.DEVICE_MANIFESTS); return this.Core.POST(path, data); } else {
javascript
{ "resource": "" }
q31149
train
function (identifier, data) { var path; if (identifier && data) { path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.PATCH(path, data); } else {
javascript
{ "resource": "" }
q31150
train
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, identifier); return this.Core.DELETE(path); } else {
javascript
{ "resource": "" }
q31151
train
function (deviceManifestIdentifier, feedIdentifier, params) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS,
javascript
{ "resource": "" }
q31152
train
function (deviceManifestIdentifier, data) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS); return this.Core.POST(path, data);
javascript
{ "resource": "" }
q31153
train
function (deviceManifestIdentifier, feedIdentifier, data) { var path, rejectMsg; if (deviceManifestIdentifier && feedIdentifier && data) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier,
javascript
{ "resource": "" }
q31154
train
function (deviceManifestIdentifier, feedIdentifier) { var path; if (deviceManifestIdentifier && feedIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.FEEDS,
javascript
{ "resource": "" }
q31155
train
function (deviceManifestIdentifier, deviceIdentifier, params) { var path; if (deviceManifestIdentifier) { path = this.constructPath(constants.DEVICE_MANIFESTS, deviceManifestIdentifier, constants.DEVICES,
javascript
{ "resource": "" }
q31156
train
function (identifier, params) { var path = this.constructPath(constants.DEVICES, identifier);
javascript
{ "resource": "" }
q31157
train
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.DEVICES, identifier); return this.Core.DELETE(path); } else {
javascript
{ "resource": "" }
q31158
train
function (deviceIdentifier, identifierURN, params) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier,
javascript
{ "resource": "" }
q31159
train
function (deviceIdentifier, data) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS); return this.Core.POST(path, data);
javascript
{ "resource": "" }
q31160
train
function (deviceIdentifier, identifierUrn, data) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierUrn);
javascript
{ "resource": "" }
q31161
train
function (deviceIdentifier, identifierUrn) { var path; if (deviceIdentifier && identifierUrn) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.IDENTIFIERS, identifierUrn); return this.Core.DELETE(path);
javascript
{ "resource": "" }
q31162
train
function (deviceIdentifier, channelIdentifier, params) { var path; if (deviceIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier,
javascript
{ "resource": "" }
q31163
train
function (deviceIdentifier, channelIdentifier, data) { var path, rejectMsg; if (deviceIdentifier && channelIdentifier && data) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS,
javascript
{ "resource": "" }
q31164
train
function (deviceIdentifier, channelIdentifier) { var path; if (deviceIdentifier && channelIdentifier) { path = this.constructPath(constants.DEVICES, deviceIdentifier, constants.CHANNELS, channelIdentifier); return this.Core.DELETE(path);
javascript
{ "resource": "" }
q31165
train
function (identifier, params) { var path = this.constructPath(constants.CHANNELS, identifier);
javascript
{ "resource": "" }
q31166
train
function (data) { var path; if (data) { path = this.constructPath(constants.CHANNELS); return this.Core.POST(path, data); } else {
javascript
{ "resource": "" }
q31167
train
function (identifier) { var path; if (identifier) { path = this.constructPath(constants.CHANNELS, identifier); return this.Core.DELETE(path); } else {
javascript
{ "resource": "" }
q31168
train
function (channelIdentifier, dataIdentifier, params) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.DATA, dataIdentifier); return this.Core.GET(path, params);
javascript
{ "resource": "" }
q31169
train
function (channelIdentifier, dataIdentifier) { var path; if (channelIdentifier && dataIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.DATA, dataIdentifier); return this.Core.DELETE(path);
javascript
{ "resource": "" }
q31170
train
function (channelIdentifier, triggerIdentifier, params) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier,
javascript
{ "resource": "" }
q31171
train
function (channelIdentifier, data) { var path; if (channelIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS); return this.Core.POST(path, data);
javascript
{ "resource": "" }
q31172
train
function (channelIdentifier, triggerIdentifier, data) { var path, rejectMsg; if (channelIdentifier && triggerIdentifier && data) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS,
javascript
{ "resource": "" }
q31173
train
function (channelIdentifier, triggerIdentifier) { var path; if (channelIdentifier && triggerIdentifier) { path = this.constructPath(constants.CHANNELS, channelIdentifier, constants.TRIGGERS, triggerIdentifier); return this.Core.DELETE(path);
javascript
{ "resource": "" }
q31174
train
function (orgIdOrSlug, params) { var path = this.constructPath(constants.ORGANIZATIONS,
javascript
{ "resource": "" }
q31175
train
function (orgIdOrSlug, data) { var path; if (orgIdOrSlug && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.PATCH(path, data); } else {
javascript
{ "resource": "" }
q31176
train
function (orgIdOrSlug) { var path; if (orgIdOrSlug) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug); return this.Core.DELETE(path); } else {
javascript
{ "resource": "" }
q31177
train
function (orgIdOrSlug, userId, params) { var path; if (orgIdOrSlug) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS, userId); return this.Core.GET(path);
javascript
{ "resource": "" }
q31178
train
function (orgIdOrSlug, userId, data) { var path, rejectMsg; if (orgIdOrSlug && userId && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS,
javascript
{ "resource": "" }
q31179
train
function (orgIdOrSlug, data) { var path, rejectMsg; if (orgIdOrSlug && data) { path = this.constructPath(constants.ORGANIZATIONS, orgIdOrSlug, constants.USERS);
javascript
{ "resource": "" }
q31180
_bytes
train
function _bytes (n, fn) { assert(!this._parserCallback, 'there is already a "callback" set!'); assert(isFinite(n) && n > 0, 'can only buffer a finite number of bytes > 0, got "' + n + '"'); if (!this._parserInit) init(this);
javascript
{ "resource": "" }
q31181
_skipBytes
train
function _skipBytes (n, fn) { assert(!this._parserCallback, 'there is already a "callback" set!'); assert(n > 0, 'can only skip > 0 bytes, got "' + n + '"'); if (!this._parserInit) init(this); debug('skipping %o
javascript
{ "resource": "" }
q31182
_passthrough
train
function _passthrough (n, fn) { assert(!this._parserCallback, 'There is already a "callback" set!'); assert(n > 0, 'can only pass through > 0 bytes, got "' + n + '"'); if (!this._parserInit) init(this); debug('passing through
javascript
{ "resource": "" }
q31183
process
train
function process (stream, chunk, output, fn) { stream._parserBytesLeft -= chunk.length; debug('%o bytes left for stream piece', stream._parserBytesLeft); if (stream._parserState === BUFFERING) { // buffer stream._parserBuffers.push(chunk); stream._parserBuffered += chunk.length; } else if (stream._...
javascript
{ "resource": "" }
q31184
trampoline
train
function trampoline (fn) { return function () { var result = fn.apply(this, arguments); while ('function' ==
javascript
{ "resource": "" }
q31185
RobinApi
train
function RobinApi (accessToken, coreUrl, placesUrl) { if (accessToken) { RobinApi.super_.apply(this, arguments); this.setAccessToken(accessToken); this.setupCore(coreUrl); this.setupPlaces(placesUrl);
javascript
{ "resource": "" }
q31186
train
function (appIdOrSlug, params) { var path = this.constructPath(constants.APPS,
javascript
{ "resource": "" }
q31187
train
function (appIdOrSlug, data) { var path; if (appIdOrSlug && data) { path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.POST(path, data); } else {
javascript
{ "resource": "" }
q31188
train
function (appIdOrSlug) { var path; if (appIdOrSlug) { path = this.constructPath(constants.APPS, appIdOrSlug); return this.Core.DELETE(path); } else {
javascript
{ "resource": "" }
q31189
getType
train
function getType (val) { if (val === null) { return 'null' } else if (val === void 0) { return 'undefined'
javascript
{ "resource": "" }
q31190
Value
train
function Value (val, parent, opts) { var obj = Object.create(Value.prototype) opts = opts || {} obj.value = val obj.parent = parent obj.type = getType(val) obj.key = opts.key
javascript
{ "resource": "" }
q31191
traverse
train
function traverse (value, v) { var state = {} var visitor = v.visitor var seen = [] /** * Recursively walk the value, dispatching visitor methods as values are encountered. * * @param {*} val Value * @param {Value|null} parent Parent value * @param {object} [opts] Additional options */ func...
javascript
{ "resource": "" }
q31192
prettyPrintVisitor
train
function prettyPrintVisitor (pp, spaces) { var visitor = {} visitor.pre = function (state) { state.result = '' state.depth = 0 } visitor.visitor = { arrayEnter: function (val, state) { if (val.key !== undefined) { state.result += repeat(state.depth * spaces, ' ') if (val.parent...
javascript
{ "resource": "" }
q31193
createStringifier
train
function createStringifier (pp, spaces) { return function stringify (value) { var visitor = prettyPrintVisitor(pp,
javascript
{ "resource": "" }
q31194
isDiffable
train
function isDiffable (val) { switch (getType(val)) { case 'array': case 'object': return true case 'string': return val.length >= 40
javascript
{ "resource": "" }
q31195
lpad
train
function lpad (str, width) { while (String(str).length
javascript
{ "resource": "" }
q31196
unifiedDiff
train
function unifiedDiff (actual, expected, formatAdd, formatRem) { return [ formatAdd('+ expected'), formatRem('- actual'), '' ] .concat( diff.createPatch('string', actual, expected) .split('\n') .slice(4) .filter(function (line) {
javascript
{ "resource": "" }
q31197
formatLinesWith
train
function formatLinesWith (formatter, str) { return str .split('\n') .map(function (line) {
javascript
{ "resource": "" }
q31198
inlineDiff
train
function inlineDiff (actual, expected, formatAdd, formatRem) { var result = diff.diffWordsWithSpace(actual, expected) .map(function (line, idx) { if (line.added) { return formatLinesWith(formatAdd, line.value) } return line.removed ? formatLinesWith(formatRem, line.value) : line.value ...
javascript
{ "resource": "" }
q31199
Mql
train
function Mql(query, values){ var self = this; if(dynamicMatch){ var mql = dynamicMatch.call(window, query); this.matches = mql.matches; this.media = mql.media; // TODO: is there a time it makes sense to remove this listener? mql.addListener(update); } else { this.matches = staticMatch(quer...
javascript
{ "resource": "" }