_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q62500 | getTicks | test | function getTicks(ticks) {
if (typeof ticks !== 'number'|| ticks >= _ticksInMs) {
_ticks++;
if (_ticks >= _ticksInMs) {
_ticks = 0;
}
ticks = _ticks;
}
return ticks;
} | javascript | {
"resource": ""
} |
q62501 | getTimeWithTicks | test | function getTimeWithTicks(date, ticks) {
if (!(date instanceof Date) || isNaN(date.getTime())) {
// time with ticks for the current time
date = new Date();
const time = date.getTime();
_ticksForCurrentTime++;
if(_ticksForCurrentTime > _ticksInMs || time > _lastTimestamp) {
_ticksForCurrentTi... | javascript | {
"resource": ""
} |
q62502 | generateBuffer | test | function generateBuffer(date, ticks, nodeId, clockId) {
const timeWithTicks = getTimeWithTicks(date, ticks);
nodeId = getNodeId(nodeId);
clockId = getClockId(clockId);
const buffer = utils.allocBufferUnsafe(16);
//Positions 0-7 Timestamp
writeTime(buffer, timeWithTicks.time, timeWithTicks.ticks);
//Positi... | javascript | {
"resource": ""
} |
q62503 | Encoder | test | function Encoder(protocolVersion, options) {
this.encodingOptions = options.encoding || utils.emptyObject;
defineInstanceMembers.call(this);
this.setProtocolVersion(protocolVersion);
setEncoders.call(this);
if (this.encodingOptions.copyBuffer) {
this.handleBuffer = handleBufferCopy;
}
else {
this.... | javascript | {
"resource": ""
} |
q62504 | numberOfLeadingZeros | test | function numberOfLeadingZeros(value) {
if (value.equals(Long.ZERO)) {
return 64;
}
let n = 1;
let x = value.getHighBits();
if (x === 0) {
n += 32;
x = value.getLowBits();
}
if (x >>> 16 === 0) {
n += 16;
x <<= 16;
}
if (x >>> 24 === 0) {
n += 8;
... | javascript | {
"resource": ""
} |
q62505 | Index | test | function Index(name, target, kind, options) {
/**
* Name of the index.
* @type {String}
*/
this.name = name;
/**
* Target of the index.
* @type {String}
*/
this.target = target;
/**
* A numeric value representing index kind (0: custom, 1: keys, 2: composite);
* @type {Number}
*/
t... | javascript | {
"resource": ""
} |
q62506 | test | function (key) {
return _.sortBy(files, function (el) {
return Number($(el).find('span[data-lint]').attr(key)) * -1;
});
} | javascript | {
"resource": ""
} | |
q62507 | loadMode | test | function loadMode(cm) {
var doc = cm.view.doc;
cm.view.mode = CodeMirror.getMode(cm.options, cm.options.mode);
doc.iter(0, doc.size, function(line) { line.stateAfter = null; });
cm.view.frontier = 0;
startWorker(cm, 100);
} | javascript | {
"resource": ""
} |
q62508 | updateScrollbars | test | function updateScrollbars(d /* display */, docHeight) {
var totalHeight = docHeight + 2 * paddingTop(d);
d.sizer.style.minHeight = d.heightForcer.style.top = totalHeight + "px";
var scrollHeight = Math.max(totalHeight, d.scroller.scrollHeight);
var needsH = d.scroller.scrollWidth > d.scroller.clientWidt... | javascript | {
"resource": ""
} |
q62509 | restartBlink | test | function restartBlink(cm) {
var display = cm.display;
clearInterval(display.blinker);
var on = true;
display.cursor.style.visibility = display.otherCursor.style.visibility = "";
display.blinker = setInterval(function() {
if (!display.cursor.offsetHeight) return;
display.cursor.style.visi... | javascript | {
"resource": ""
} |
q62510 | coordsChar | test | function coordsChar(cm, x, y) {
var doc = cm.view.doc;
y += cm.display.viewOffset;
if (y < 0) return {line: 0, ch: 0, outside: true};
var lineNo = lineAtHeight(doc, y);
if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc, doc.size - 1).text.length};
if (x < 0) x = 0;
for (;;... | javascript | {
"resource": ""
} |
q62511 | updateDoc | test | function updateDoc(cm, from, to, newText, selUpdate, origin) {
// Possibly split or suppress the update based on the presence
// of read-only spans in its range.
var split = sawReadOnlySpans &&
removeReadOnlyRanges(cm.view.doc, from, to);
if (split) {
for (var i = split.length - 1; i >= 1; -... | javascript | {
"resource": ""
} |
q62512 | setSelection | test | function setSelection(cm, anchor, head, bias, checkAtomic) {
cm.view.goalColumn = null;
var sel = cm.view.sel;
// Skip over atomic spans.
if (checkAtomic || !posEq(anchor, sel.anchor))
anchor = skipAtomic(cm, anchor, bias, checkAtomic != "push");
if (checkAtomic || !posEq(head, sel.head))
... | javascript | {
"resource": ""
} |
q62513 | highlightLine | test | function highlightLine(cm, line, state) {
var mode = cm.view.mode, flattenSpans = cm.options.flattenSpans;
var changed = !line.styles, pos = 0, curText = "", curStyle = null;
var stream = new StringStream(line.text, cm.options.tabSize), st = line.styles || (line.styles = []);
if (line.text == "" && mode... | javascript | {
"resource": ""
} |
q62514 | e_prop | test | function e_prop(e, prop) {
var overridden = e.override && e.override.hasOwnProperty(prop);
return overridden ? e.override[prop] : e[prop];
} | javascript | {
"resource": ""
} |
q62515 | Flow | test | function Flow(opts) {
/**
* Supported by browser?
* @type {boolean}
*/
this.support = (
typeof File !== 'undefined' &&
typeof Blob !== 'undefined' &&
typeof FileList !== 'undefined' &&
(
!!Blob.prototype.slice || !!Blob.prototype.webkitSlice || !!Blob.pro... | javascript | {
"resource": ""
} |
q62516 | test | function (event, fn) {
if (event !== undefined) {
event = event.toLowerCase();
if (fn !== undefined) {
if (this.events.hasOwnProperty(event)) {
arrayRemove(this.events[event], fn);
}
} else {
delete this.events[event];
}
} else {
... | javascript | {
"resource": ""
} | |
q62517 | test | function (event, args) {
// `arguments` is an object, not array, in FF, so:
args = Array.prototype.slice.call(arguments);
event = event.toLowerCase();
var preventDefault = false;
if (this.events.hasOwnProperty(event)) {
each(this.events[event], function (callback) {
preve... | javascript | {
"resource": ""
} | |
q62518 | test | function (event) {
var $ = this;
var queue = event.dataTransfer.items.length;
var files = [];
each(event.dataTransfer.items, function (item) {
var entry = item.webkitGetAsEntry();
if (!entry) {
decrement();
return ;
}
if (entry.isFile) {
... | javascript | {
"resource": ""
} | |
q62519 | test | function (file) {
var custom = this.opts.generateUniqueIdentifier;
if (typeof custom === 'function') {
return custom(file);
}
// Some confusion in different versions of Firefox
var relativePath = file.relativePath || file.webkitRelativePath || file.fileName || file.name;
retu... | javascript | {
"resource": ""
} | |
q62520 | test | function (preventEvents) {
// In some cases (such as videos) it's really handy to upload the first
// and last chunk of a file quickly; this let's the server check the file's
// metadata and determine if there's even a point in continuing.
var found = false;
if (this.opts.prioritizeFirstAn... | javascript | {
"resource": ""
} | |
q62521 | test | function (domNodes, isDirectory, singleFile, attributes) {
if (domNodes instanceof Element) {
domNodes = [domNodes];
}
each(domNodes, function (domNode) {
var input;
if (domNode.tagName === 'INPUT' && domNode.type === 'file') {
input = domNode;
} else {
... | javascript | {
"resource": ""
} | |
q62522 | test | function (domNodes) {
if (typeof domNodes.length === 'undefined') {
domNodes = [domNodes];
}
each(domNodes, function (domNode) {
domNode.addEventListener('dragover', this.preventEvent, false);
domNode.addEventListener('dragenter', this.preventEvent, false);
domNode.addE... | javascript | {
"resource": ""
} | |
q62523 | test | function (domNodes) {
if (typeof domNodes.length === 'undefined') {
domNodes = [domNodes];
}
each(domNodes, function (domNode) {
domNode.removeEventListener('dragover', this.preventEvent);
domNode.removeEventListener('dragenter', this.preventEvent);
domNode.removeEventL... | javascript | {
"resource": ""
} | |
q62524 | test | function () {
var uploading = false;
each(this.files, function (file) {
if (file.isUploading()) {
uploading = true;
return false;
}
});
return uploading;
} | javascript | {
"resource": ""
} | |
q62525 | test | function () {
var num = 0;
var should = true;
var simultaneousUploads = this.opts.simultaneousUploads;
each(this.files, function (file) {
each(file.chunks, function(chunk) {
if (chunk.status() === 'uploading') {
num++;
if (num >= simultaneousUploads) {
... | javascript | {
"resource": ""
} | |
q62526 | test | function () {
// Make sure we don't start too many uploads at once
var ret = this._shouldUploadNext();
if (ret === false) {
return;
}
// Kick off the queue
this.fire('uploadStart');
var started = false;
for (var num = 1; num <= this.opts.simultaneousUploads - ret;... | javascript | {
"resource": ""
} | |
q62527 | test | function (fileList, event) {
var files = [];
each(fileList, function (file) {
// https://github.com/flowjs/flow.js/issues/55
if ((!ie10plus || ie10plus && file.size > 0) && !(file.size % 4096 === 0 && (file.name === '.' || file.fileName === '.'))) {
var uniqueIdentifier = this.gene... | javascript | {
"resource": ""
} | |
q62528 | test | function (file) {
for (var i = this.files.length - 1; i >= 0; i--) {
if (this.files[i] === file) {
this.files.splice(i, 1);
file.abort();
this.fire('fileRemoved', file);
}
}
} | javascript | {
"resource": ""
} | |
q62529 | test | function (uniqueIdentifier) {
var ret = false;
each(this.files, function (file) {
if (file.uniqueIdentifier === uniqueIdentifier) {
ret = file;
}
});
return ret;
} | javascript | {
"resource": ""
} | |
q62530 | test | function () {
var sizeDelta = 0;
var averageSpeed = 0;
each(this.files, function (file) {
if (!file.paused && !file.error) {
sizeDelta += file.size - file.sizeUploaded();
averageSpeed += file.averageSpeed;
}
});
if (sizeDelta && !averageSpeed) {
... | javascript | {
"resource": ""
} | |
q62531 | test | function () {
var timeSpan = Date.now() - this._lastProgressCallback;
if (!timeSpan) {
return ;
}
var smoothingFactor = this.flowObj.opts.speedSmoothingFactor;
var uploaded = this.sizeUploaded();
// Prevent negative upload speed after file upload resume
this.currentSpee... | javascript | {
"resource": ""
} | |
q62532 | test | function (chunk, event, message) {
switch (event) {
case 'progress':
if (Date.now() - this._lastProgressCallback <
this.flowObj.opts.progressCallbacksInterval) {
break;
}
this.measureSpeed();
this.flowObj.fire('fileProgress', this, chunk);
... | javascript | {
"resource": ""
} | |
q62533 | test | function (reset) {
this.currentSpeed = 0;
this.averageSpeed = 0;
var chunks = this.chunks;
if (reset) {
this.chunks = [];
}
each(chunks, function (c) {
if (c.status() === 'uploading') {
c.abort();
this.flowObj.uploadNextChunk();
}
}, ... | javascript | {
"resource": ""
} | |
q62534 | test | function () {
if (typeof this.flowObj.opts.initFileFn === "function") {
this.flowObj.opts.initFileFn(this);
}
this.abort(true);
this.error = false;
// Rebuild stack of chunks from file
this._prevProgress = 0;
var round = this.flowObj.opts.forceChunkSize ? Math.ceil : M... | javascript | {
"resource": ""
} | |
q62535 | test | function () {
if (this.error) {
return 1;
}
if (this.chunks.length === 1) {
this._prevProgress = Math.max(this._prevProgress, this.chunks[0].progress());
return this._prevProgress;
}
// Sum up progress across everything
var bytesLoaded = 0;
each(this.chu... | javascript | {
"resource": ""
} | |
q62536 | test | function () {
var outstanding = false;
each(this.chunks, function (chunk) {
var status = chunk.status();
if (status === 'pending' || status === 'uploading' || status === 'reading' || chunk.preprocessState === 1 || chunk.readState === 1) {
outstanding = true;
return false;... | javascript | {
"resource": ""
} | |
q62537 | test | function () {
if (this.paused || this.error) {
return 0;
}
var delta = this.size - this.sizeUploaded();
if (delta && !this.averageSpeed) {
return Number.POSITIVE_INFINITY;
}
if (!delta && !this.averageSpeed) {
return 0;
}
return Math.floor(delta / ... | javascript | {
"resource": ""
} | |
q62538 | webAPIFileRead | test | function webAPIFileRead(fileObj, startByte, endByte, fileType, chunk) {
var function_name = 'slice';
if (fileObj.file.slice)
function_name = 'slice';
else if (fileObj.file.mozSlice)
function_name = 'mozSlice';
else if (fileObj.file.webkitSlice)
function_name = 'webkitSlice';
chu... | javascript | {
"resource": ""
} |
q62539 | test | function () {
// Set up request and listen for event
this.xhr = new XMLHttpRequest();
this.xhr.addEventListener("load", this.testHandler, false);
this.xhr.addEventListener("error", this.testHandler, false);
var testMethod = evalOpts(this.flowObj.opts.testMethod, this.fileObj, this);
... | javascript | {
"resource": ""
} | |
q62540 | test | function () {
var preprocess = this.flowObj.opts.preprocess;
var read = this.flowObj.opts.readFileFn;
if (typeof preprocess === 'function') {
switch (this.preprocessState) {
case 0:
this.preprocessState = 1;
preprocess(this);
return;
case... | javascript | {
"resource": ""
} | |
q62541 | test | function (isTest) {
if (this.readState === 1) {
return 'reading';
} else if (this.pendingRetry || this.preprocessState === 1) {
// if pending retry then that's effectively the same as actively uploading,
// there might just be a slight delay before the retry starts
return 'up... | javascript | {
"resource": ""
} | |
q62542 | test | function(method, isTest, paramsMethod, blob) {
// Add data from the query options
var query = evalOpts(this.flowObj.opts.query, this.fileObj, this, isTest);
query = extend(query || {}, this.getParams());
var target = evalOpts(this.flowObj.opts.target, this.fileObj, this, isTest);
var data... | javascript | {
"resource": ""
} | |
q62543 | evalOpts | test | function evalOpts(data, args) {
if (typeof data === "function") {
// `arguments` is an object, not array, in FF, so:
args = Array.prototype.slice.call(arguments);
data = data.apply(null, args.slice(1));
}
return data;
} | javascript | {
"resource": ""
} |
q62544 | each | test | function each(obj, callback, context) {
if (!obj) {
return ;
}
var key;
// Is Array?
// Array.isArray won't work, not only arrays can be iterated by index https://github.com/flowjs/ng-flow/issues/236#
if (typeof(obj.length) !== 'undefined') {
for (key = 0; key < obj.length; key++) {
... | javascript | {
"resource": ""
} |
q62545 | createTable | test | function createTable() {
tableName = arguments[0];
var fname = '';
var callback;
if (arguments.length === 2) {
callback = arguments[1];
fname = path.join(userData, tableName + '.json');
} else if (arguments.length === 3) {
fname = path.join(arguments[1], arguments[0] + '.jso... | javascript | {
"resource": ""
} |
q62546 | valid | test | function valid() {
var fName = ''
if (arguments.length == 2) {
// Given the database name and location
const dbName = arguments[0]
const dbLocation = arguments[1]
var fName = path.join(dbLocation, dbName + '.json')
} else if (arguments.length == 1) {
const dbName = ar... | javascript | {
"resource": ""
} |
q62547 | insertTableContent | test | function insertTableContent() {
let tableName = arguments[0];
var fname = '';
var callback;
var tableRow;
if (arguments.length === 3) {
callback = arguments[2];
fname = path.join(userData, arguments[0] + '.json');
tableRow = arguments[1];
} else if (arguments.length === 4... | javascript | {
"resource": ""
} |
q62548 | count | test | function count() {
let tableName = arguments[0]
let callback
if (arguments.length === 2) {
callback = arguments[1]
getAll(tableName, (succ, data) => {
if (succ) {
callback(true, data.length)
return
} else {
callback(fals... | javascript | {
"resource": ""
} |
q62549 | updateRow | test | function updateRow() {
let tableName = arguments[0];
var fname = '';
var where;
var set;
var callback;
if (arguments.length === 4) {
fname = path.join(userData, tableName + '.json');
where = arguments[1];
set = arguments[2];
callback = arguments[3];
} else if... | javascript | {
"resource": ""
} |
q62550 | createHeaderGetter | test | function createHeaderGetter (str) {
var name = str.toLowerCase()
return function (req, res) {
// set appropriate Vary header
vary(res, str)
// get header
var header = req.headers[name]
if (!header) {
return undefined
}
// multiple headers get joined with comma by node.js core
... | javascript | {
"resource": ""
} |
q62551 | Param | test | function Param(name, shortName, process) {
if (process == null) {
process = cloudinary.Util.identity;
}
/**
* The name of the parameter in snake_case
* @member {string} Param#name
*/
this.name = name;
/**
* The name of the serialized form of the parame... | javascript | {
"resource": ""
} |
q62552 | ArrayParam | test | function ArrayParam(name, shortName, sep, process) {
if (sep == null) {
sep = '.';
}
this.sep = sep;
ArrayParam.__super__.constructor.call(this, name, shortName, process);
} | javascript | {
"resource": ""
} |
q62553 | TransformationParam | test | function TransformationParam(name, shortName, sep, process) {
if (shortName == null) {
shortName = "t";
}
if (sep == null) {
sep = '.';
}
this.sep = sep;
TransformationParam.__super__.constructor.call(this, name, shortName, process);
} | javascript | {
"resource": ""
} |
q62554 | RangeParam | test | function RangeParam(name, shortName, process) {
if (process == null) {
process = this.norm_range_value;
}
RangeParam.__super__.constructor.call(this, name, shortName, process);
} | javascript | {
"resource": ""
} |
q62555 | Configuration | test | function Configuration(options) {
if (options == null) {
options = {};
}
this.configuration = Util.cloneDeep(options);
Util.defaults(this.configuration, DEFAULT_CONFIGURATION_PARAMS);
} | javascript | {
"resource": ""
} |
q62556 | Cloudinary | test | function Cloudinary(options) {
var configuration;
this.devicePixelRatioCache = {};
this.responsiveConfig = {};
this.responsiveResizeInitialized = false;
configuration = new Configuration(options);
this.config = function(newConfig, newValue) {
return configuration.config(newCo... | javascript | {
"resource": ""
} |
q62557 | getMode | test | function getMode(env, argv) {
// When running from parallel-webpack, grab the cli parameters
argv = Object.keys(argv).length ? argv : require('minimist')(process.argv.slice(2));
var isProd = (argv.mode || env.mode) === 'production' || env === 'prod' || env.prod;
return isProd ? 'production' : 'development';
} | javascript | {
"resource": ""
} |
q62558 | resolveLodash | test | function resolveLodash(context, request, callback) {
if (/^lodash\//.test(request)) {
callback(null, {
commonjs: request,
commonjs2: request,
amd: request,
root: ['_', request.split('/')[1]]
});
} else {
callback();
}
} | javascript | {
"resource": ""
} |
q62559 | baseConfig | test | function baseConfig(name, mode) {
const config = {
name: `${name}-${mode}`,
mode,
output: {
library: 'cloudinary',
libraryTarget: 'umd',
globalObject: "this",
pathinfo: false
},
optimization: {
concatenateModules: true,
moduleIds: 'named',
usedExports: tru... | javascript | {
"resource": ""
} |
q62560 | finalizeResourceType | test | function finalizeResourceType(resourceType = "image", type = "upload", urlSuffix, useRootPath, shorten) {
var options;
resourceType = resourceType == null ? "image" : resourceType;
type = type == null ? "upload" : type;
if (isPlainObject(resourceType)) {
options = resourceType;
resourceType = options.re... | javascript | {
"resource": ""
} |
q62561 | Drag | test | function Drag(parent, options) {
_classCallCheck(this, Drag);
options = options || {};
var _this = _possibleConstructorReturn(this, (Drag.__proto__ || Object.getPrototypeOf(Drag)).call(this, parent));
_this.moved = false;
_this.wheelActive = utils.defaults(options.wheel, true)... | javascript | {
"resource": ""
} |
q62562 | each | test | function each(object, fn) {
keys(object).forEach(function (key) {
return fn(object[key], key);
});
} | javascript | {
"resource": ""
} |
q62563 | reduce | test | function reduce(object, fn) {
var initial = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
return keys(object).reduce(function (accum, key) {
return fn(accum, object[key], key);
}, initial);
} | javascript | {
"resource": ""
} |
q62564 | isPlain | test | function isPlain(value) {
return isObject(value) && toString.call(value) === '[object Object]' && value.constructor === Object;
} | javascript | {
"resource": ""
} |
q62565 | logByType | test | function logByType(type, args) {
var stringify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !!IE_VERSION && IE_VERSION < 11;
var lvl = log.levels[level];
var lvlRegExp = new RegExp('^(' + lvl + ')$');
if (type !== 'log') {
// Add the type to the front of the message when it's not... | javascript | {
"resource": ""
} |
q62566 | createEl | test | function createEl() {
var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'div';
var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var content = arguments... | javascript | {
"resource": ""
} |
q62567 | addClass | test | function addClass(element, classToAdd) {
if (element.classList) {
element.classList.add(classToAdd);
// Don't need to `throwIfWhitespace` here because `hasElClass` will do it
// in the case of classList not being supported.
} else if (!hasClass(element, classToAdd)) {
element.className = (element.c... | javascript | {
"resource": ""
} |
q62568 | toggleClass | test | function toggleClass(element, classToToggle, predicate) {
// This CANNOT use `classList` internally because IE does not support the
// second parameter to the `classList.toggle()` method! Which is fine because
// `classList` will be used by the add/remove functions.
var has = hasClass(element, classToToggle);
... | javascript | {
"resource": ""
} |
q62569 | getPointerPosition | test | function getPointerPosition(el, event) {
var position = {};
var box = findPosition(el);
var boxW = el.offsetWidth;
var boxH = el.offsetHeight;
var boxY = box.top;
var boxX = box.left;
var pageY = event.pageY;
var pageX = event.pageX;
if (event.changedTouches) {
pageX = event.changedTouches[0].pa... | javascript | {
"resource": ""
} |
q62570 | appendContent | test | function appendContent(el, content) {
normalizeContent(content).forEach(function (node) {
return el.appendChild(node);
});
return el;
} | javascript | {
"resource": ""
} |
q62571 | getData | test | function getData(el) {
var id = el[elIdAttr];
if (!id) {
id = el[elIdAttr] = newGUID();
}
if (!elData[id]) {
elData[id] = {};
}
return elData[id];
} | javascript | {
"resource": ""
} |
q62572 | hasData | test | function hasData(el) {
var id = el[elIdAttr];
if (!id) {
return false;
}
return !!Object.getOwnPropertyNames(elData[id]).length;
} | javascript | {
"resource": ""
} |
q62573 | removeData | test | function removeData(el) {
var id = el[elIdAttr];
if (!id) {
return;
}
// Remove all stored data
delete elData[id];
// Remove the elIdAttr property from the DOM node
try {
delete el[elIdAttr];
} catch (e) {
if (el.removeAttribute) {
el.removeAttribute(elIdAttr);
} else {
//... | javascript | {
"resource": ""
} |
q62574 | _handleMultipleEvents | test | function _handleMultipleEvents(fn, elem, types, callback) {
types.forEach(function (type) {
// Call the event method for each one of the types
fn(elem, type, callback);
});
} | javascript | {
"resource": ""
} |
q62575 | off | test | function off(elem, type, fn) {
// Don't want to add a cache object through getElData if not needed
if (!hasData(elem)) {
return;
}
var data = getData(elem);
// If no events exist, nothing to unbind
if (!data.handlers) {
return;
}
if (Array.isArray(type)) {
return _handleMultipleEvents(off... | javascript | {
"resource": ""
} |
q62576 | one | test | function one(elem, type, fn) {
if (Array.isArray(type)) {
return _handleMultipleEvents(one, elem, type, fn);
}
var func = function func() {
off(elem, type, func);
fn.apply(this, arguments);
};
// copy the guid to the new function so it can removed using the original function's ID
func.guid = fn... | javascript | {
"resource": ""
} |
q62577 | autoSetup | test | function autoSetup() {
// Protect against breakage in non-browser environments.
if (!isReal()) {
return;
}
// One day, when we stop supporting IE8, go back to this, but in the meantime...*hack hack hack*
// var vids = Array.prototype.slice.call(document.getElementsByTagName('video'));
// var audios = ... | javascript | {
"resource": ""
} |
q62578 | autoSetupTimeout | test | function autoSetupTimeout(wait, vjs) {
if (vjs) {
videojs$2 = vjs;
}
window.setTimeout(autoSetup, wait);
} | javascript | {
"resource": ""
} |
q62579 | setTextContent | test | function setTextContent(el, content) {
if (el.styleSheet) {
el.styleSheet.cssText = content;
} else {
el.textContent = content;
}
} | javascript | {
"resource": ""
} |
q62580 | throttle | test | function throttle(fn, wait) {
var last = Date.now();
var throttled = function throttled() {
var now = Date.now();
if (now - last >= wait) {
fn.apply(undefined, arguments);
last = now;
}
};
return throttled;
} | javascript | {
"resource": ""
} |
q62581 | isValidEventType | test | function isValidEventType(type) {
return (
// The regex here verifies that the `type` contains at least one non-
// whitespace character.
typeof type === 'string' && /\S/.test(type) || Array.isArray(type) && !!type.length
);
} | javascript | {
"resource": ""
} |
q62582 | Component | test | function Component(player, options, ready) {
classCallCheck(this, Component);
// The component might be the player itself and we can't pass `this` to super
if (!player && this.play) {
this.player_ = player = this; // eslint-disable-line
} else {
this.player_ = player;
}
// Make a ... | javascript | {
"resource": ""
} |
q62583 | rangeCheck | test | function rangeCheck(fnName, index, maxIndex) {
if (typeof index !== 'number' || index < 0 || index > maxIndex) {
throw new Error('Failed to execute \'' + fnName + '\' on \'TimeRanges\': The index provided (' + index + ') is non-numeric or out of bounds (0-' + maxIndex + ').');
}
} | javascript | {
"resource": ""
} |
q62584 | getRange | test | function getRange(fnName, valueIndex, ranges, rangeIndex) {
rangeCheck(fnName, rangeIndex, ranges.length - 1);
return ranges[rangeIndex][valueIndex];
} | javascript | {
"resource": ""
} |
q62585 | createTimeRangesObj | test | function createTimeRangesObj(ranges) {
if (ranges === undefined || ranges.length === 0) {
return {
length: 0,
start: function start() {
throw new Error('This TimeRanges object is empty');
},
end: function end() {
throw new Error('This TimeRanges object is empty');
}
... | javascript | {
"resource": ""
} |
q62586 | createTimeRanges | test | function createTimeRanges(start, end) {
if (Array.isArray(start)) {
return createTimeRangesObj(start);
} else if (start === undefined || end === undefined) {
return createTimeRangesObj();
}
return createTimeRangesObj([[start, end]]);
} | javascript | {
"resource": ""
} |
q62587 | TextTrackCueList | test | function TextTrackCueList(cues) {
classCallCheck(this, TextTrackCueList);
var list = this; // eslint-disable-line
if (IS_IE8) {
list = document.createElement('custom');
for (var prop in TextTrackCueList.prototype) {
if (prop !== 'constructor') {
list[prop] = TextTrackCueList... | javascript | {
"resource": ""
} |
q62588 | getFileExtension | test | function getFileExtension(path) {
if (typeof path === 'string') {
var splitPathRe = /^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i;
var pathParts = splitPathRe.exec(path);
if (pathParts) {
return pathParts.pop().toLowerCase();
}
}
return '';
} | javascript | {
"resource": ""
} |
q62589 | loadTrack | test | function loadTrack(src, track) {
var opts = {
uri: src
};
var crossOrigin = isCrossOrigin(src);
if (crossOrigin) {
opts.cors = crossOrigin;
}
xhr(opts, bind(this, function (err, response, responseBody) {
if (err) {
return log$1.error(err, response);
}
track.loaded_ = true;
... | javascript | {
"resource": ""
} |
q62590 | constructColor | test | function constructColor(color, opacity) {
return 'rgba(' +
// color looks like "#f0e"
parseInt(color[1] + color[1], 16) + ',' + parseInt(color[2] + color[2], 16) + ',' + parseInt(color[3] + color[3], 16) + ',' + opacity + ')';
} | javascript | {
"resource": ""
} |
q62591 | checkVolumeSupport | test | function checkVolumeSupport(self, player) {
// hide volume controls when they're not supported by the current tech
if (player.tech_ && !player.tech_.featuresVolumeControl) {
self.addClass('vjs-hidden');
}
self.on(player, 'loadstart', function () {
if (!player.tech_.featuresVolumeControl) {
self.a... | javascript | {
"resource": ""
} |
q62592 | parseOptionValue | test | function parseOptionValue(value, parser) {
if (parser) {
value = parser(value);
}
if (value && value !== 'none') {
return value;
}
} | javascript | {
"resource": ""
} |
q62593 | checkProgress | test | function checkProgress() {
if (_this3.el_.currentTime > 0) {
// Trigger durationchange for genuinely live video
if (_this3.el_.duration === Infinity) {
_this3.trigger('durationchange');
}
_this3.off('timeupdate', checkProgress);
}
} | javascript | {
"resource": ""
} |
q62594 | findFirstPassingTechSourcePair | test | function findFirstPassingTechSourcePair(outerArray, innerArray, tester) {
var found = void 0;
outerArray.some(function (outerChoice) {
return innerArray.some(function (innerChoice) {
found = tester(outerChoice, innerChoice);
if (found) {
return true;
}
... | javascript | {
"resource": ""
} |
q62595 | markPluginAsActive | test | function markPluginAsActive(player, name) {
player[PLUGIN_CACHE_KEY] = player[PLUGIN_CACHE_KEY] || {};
player[PLUGIN_CACHE_KEY][name] = true;
} | javascript | {
"resource": ""
} |
q62596 | triggerSetupEvent | test | function triggerSetupEvent(player, hash, before) {
var eventName = (before ? 'before' : '') + 'pluginsetup';
player.trigger(eventName, hash);
player.trigger(eventName + ':' + hash.name, hash);
} | javascript | {
"resource": ""
} |
q62597 | createBasicPlugin | test | function createBasicPlugin(name, plugin) {
var basicPluginWrapper = function basicPluginWrapper() {
// We trigger the "beforepluginsetup" and "pluginsetup" events on the player
// regardless, but we want the hash to be consistent with the hash provided
// for advanced plugins.
//
// The only pote... | javascript | {
"resource": ""
} |
q62598 | createPluginFactory | test | function createPluginFactory(name, PluginSubClass) {
// Add a `name` property to the plugin prototype so that each plugin can
// refer to itself by name.
PluginSubClass.prototype.name = name;
return function () {
triggerSetupEvent(this, { name: name, plugin: PluginSubClass, instance: null }, true);
f... | javascript | {
"resource": ""
} |
q62599 | videojs | test | function videojs(id, options, ready) {
var tag = void 0;
// Allow for element or ID to be passed in
// String ID
if (typeof id === 'string') {
var players = videojs.getPlayers();
// Adjust for jQuery ID syntax
if (id.indexOf('#') === 0) {
id = id.slice(1);
}
// If a player instance ... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.