_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q40200
train
function (selector, expected, hash) { this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector)); this.actionQueue.push(this.webdriverClient.getAttribute.bind(this.webdriverClient, 'value')); this.actionQueue.push(this._valCb.bind(this, selector, hash, expected)); return th...
javascript
{ "resource": "" }
q40201
train
function (selector, expected, hash) { this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector)); this.actionQueue.push(this.webdriverClient.selected.bind(this.webdriverClient)); this.actionQueue.push(this._selectedCb.bind(this, selector, hash, expected)); return this; }
javascript
{ "resource": "" }
q40202
train
function (selector, expected, hash) { this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector)); this.actionQueue.push(this.webdriverClient.enabled.bind(this.webdriverClient)); this.actionQueue.push(this._enabledCb.bind(this, selector, hash, expected)); return this; }
javascript
{ "resource": "" }
q40203
train
function (selector, hash, uuid) { this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector)); this.actionQueue.push(this.webdriverClient.submit.bind(this.webdriverClient)); this.actionQueue.push(this._submitCb.bind(this, selector, hash, uuid)); return this; }
javascript
{ "resource": "" }
q40204
train
function (selector, hash, uuid) { var deferred = Q.defer(); this.events.emit('driver:message', {key: 'submit', value: selector, uuid: uuid, hash: hash}); deferred.resolve(); return deferred.promise; }
javascript
{ "resource": "" }
q40205
train
function (selector, options, hash, uuid) { this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector, options)); this.actionQueue.push(this.webdriverClient.scroll.bind(this.webdriverClient)); this.actionQueue.push(this._clickCb.bind(this, selector, options, hash, uuid)); ret...
javascript
{ "resource": "" }
q40206
train
function (selector, timeout, hash, uuid) { this.actionQueue.push(this.webdriverClient.implicitWait.bind(this.webdriverClient, timeout)); this.actionQueue.push(this._waitForElementCb.bind(this, selector, hash, uuid)); return this; }
javascript
{ "resource": "" }
q40207
train
function (selector, expected, hash) { this.actionQueue.push(this.webdriverClient.elements.bind(this.webdriverClient, selector)); this.actionQueue.push(this._getNumberOfElementsCb.bind(this, selector, hash, expected)); return this; }
javascript
{ "resource": "" }
q40208
train
function (selector, expected, hash) { this.actionQueue.push(this.webdriverClient.elements.bind(this.webdriverClient, selector)); this.actionQueue.push(function (result) { var deferred = Q.defer(); var res = JSON.parse(result); var resLength = res.value.length; var curLength = 0; va...
javascript
{ "resource": "" }
q40209
train
function (selector, hash, expected, res) { var deferred = Q.defer(); var result = JSON.parse(res); // check if the expression matched any element if (result.value === -1) { this.events.emit('driver:message', {key: 'numberOfVisibleElements', hash: hash, selector: selector, expected: expected, valu...
javascript
{ "resource": "" }
q40210
replace_content
train
function replace_content(fullpath) { var source = fs.readFileSync(fullpath, 'utf8'); var regex = /(require\s*\(\s*['"]alloy\/underscore['"]\s*\))._/g var test = regex.test(source); if(test) { logger.trace("Fixing file: " + fullpath); source = source.replace(regex, "$1"); fs.writeFileSync(fullpath, source); }...
javascript
{ "resource": "" }
q40211
plugin
train
function plugin(params) { logger = params.logger; params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform; logger.trace("fixing underscore in directory: " + params.dirname); replace_content(path.join(params.dirname, "alloy.js")) replace_content(path.join(params.di...
javascript
{ "resource": "" }
q40212
Enumerator
train
function Enumerator(getCurrent, moveNext, reset) { var index = 0, self = this; /** * Get the current index of the enumerator */ this.getIndex = function getIndexEnumeratorInternal() { return index; }; /** * Function that retrieves the current value * @function * @returns {Object} The c...
javascript
{ "resource": "" }
q40213
train
function (t) { var self = this; this.node = t.node; var userOpts = this.get('opts'); this.opts = extend(defaultOpts, userOpts); setTimeout(function () { self.s = new IScroll(t.node, self.opts); t.complete(); }, 0); }
javascript
{ "resource": "" }
q40214
train
function (message, hash) { var deferred = Q.defer(); this.events.emit('driver:message', {key: 'noop', uuid: hash, hash: hash, value: message}); deferred.resolve(); return deferred.promise; }
javascript
{ "resource": "" }
q40215
train
function (hash) { this.actionQueue.push(this.webdriverClient.source.bind(this.webdriverClient)); this.actionQueue.push(this._sourceCb.bind(this, hash)); return this; }
javascript
{ "resource": "" }
q40216
train
function (hash, source) { var deferred = Q.defer(); this.events.emit('driver:message', {key: 'source', uuid: hash, hash: hash, value: JSON.parse(source).value}); deferred.resolve(); return deferred.promise; }
javascript
{ "resource": "" }
q40217
train
function (expected, hash) { this.actionQueue.push(this.webdriverClient.title.bind(this.webdriverClient)); this.actionQueue.push(this._titleCb.bind(this, expected, hash)); return this; }
javascript
{ "resource": "" }
q40218
train
function (expected, hash, title) { var deferred = Q.defer(); this.events.emit('driver:message', {key: 'title', expected: expected, hash: hash, value: JSON.parse(title).value}); deferred.resolve(); return deferred.promise; }
javascript
{ "resource": "" }
q40219
train
function (expected, hash) { this.actionQueue.push(this.webdriverClient.alertText.bind(this.webdriverClient)); this.actionQueue.push(this._alertTextCb.bind(this, expected, hash)); return this; }
javascript
{ "resource": "" }
q40220
train
function (text, hash) { this.actionQueue.push(this.webdriverClient.promptText.bind(this.webdriverClient, text)); this.actionQueue.push(this._promptTextCb.bind(this, text, hash)); return this; }
javascript
{ "resource": "" }
q40221
train
function (timeout, hash, uuid) { this.actionQueue.push(this.webdriverClient.implicitWait.bind(this.webdriverClient, timeout)); this.actionQueue.push(this._waitCb.bind(this, timeout, hash, uuid)); return this; }
javascript
{ "resource": "" }
q40222
train
function (timeout, hash, uuid) { var deferred = Q.defer(); this.events.emit('driver:message', {key: 'wait', timeout: timeout, uuid: uuid, hash: hash, value: timeout + ' ms'}); setTimeout(function () { deferred.resolve(); }.bind(this), timeout); return deferred.promise; }
javascript
{ "resource": "" }
q40223
train
function(referencePoint, otherPoint) { if (this.yDown) { if (otherPoint.y > referencePoint.y) { otherPoint = { x: otherPoint.x, y: referencePoint.y - (otherPoint.y - referencePoint.y) } } else if (otherPoint.y < referencePoint.y) { otherPoint = { x: ...
javascript
{ "resource": "" }
q40224
validate
train
function validate(cmd, args, info) { AbstractCommand.prototype.validate.apply(this, arguments); var offset = parseInt('' + args[1]); if(isNaN(offset) || offset < 0 || offset > Constants.MAX_BIT_LEN) { throw IntegerRange; } args[1] = offset; }
javascript
{ "resource": "" }
q40225
handleClassesAndId
train
function handleClassesAndId(str) { return str.replace(/(.*?)([\.|#].[^|]*)(.*)/, function (fullStr, tag, classAndIds, end) { if (classAndIds[0] === '|') { return fullStr; } const clsIdArr = classAndIds.split(/(\..[^\.|#]*)/).filter(Boolean); const returnArr = []; let i = clsIdArr.length; while (i--) { ...
javascript
{ "resource": "" }
q40226
readConfigFromFile
train
function readConfigFromFile(filePath) { var config = {}; if (isFilePath(filePath)) { try { config = yaml.safeLoad(stripComments(fs.readFileSync(filePath, 'utf8'))) || {}; } catch (e) { e.message = 'Cannot read config file: ' + filePath + '\nError: ' + e.message; throw e; } if (pa...
javascript
{ "resource": "" }
q40227
loadConfig
train
function loadConfig(configToLoad) { var config = {}; var filePath = ''; if (configToLoad) { if (isObject(configToLoad)) { config = configToLoad; } else { filePath = configToLoad; config = readConfigFromFile(filePath); } if (!config.rules) { config.rules = {}; } c...
javascript
{ "resource": "" }
q40228
getPluginsConfig
train
function getPluginsConfig(pluginNames) { var pluginConfig = {}; pluginNames.forEach(function(pluginName) { var pluginNamespace = util.getNamespace(pluginName), pluginNameWithoutNamespace = util.removeNameSpace(pluginName), pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace...
javascript
{ "resource": "" }
q40229
getLocalConfig
train
function getLocalConfig(thisConfig, directory) { var found, i, localConfig, localConfigFile, config = {}, localConfigFiles = thisConfig.findLocalConfigFiles(directory), numFiles = localConfigFiles.length, rootPath, projectConfigPath = path.join(process.cwd(), LOCAL_CONFIG_FILENAME); ...
javascript
{ "resource": "" }
q40230
SliderNeighbor
train
function SliderNeighbor (data) { this.autoPlay = false // default value is false. this.interval = DEFAULT_INTERVAL this.direction = 'row' // 'column' is not temporarily supported. this.slides = [] this.isPageShow = true this.isDomRendering = true this.currentIndex = 0 this.neighborSpac...
javascript
{ "resource": "" }
q40231
train
function (key, array, index, fnEqual) { var idx = Arrays.indexOf(key, array, index, fnEqual); if (idx >= 0) array.splice(idx, 1); return idx; }
javascript
{ "resource": "" }
q40232
train
function (key, array, index) { var idx = Arrays.lastIndexOf(key, array, index); if (idx >= 0) array.splice(idx, 1); return idx; }
javascript
{ "resource": "" }
q40233
train
function (items, array, index) { // There might be some optimization to be made here. // Right now, I'm just going for a simple solution. if ( !(items instanceof Array) || !(array instanceof Array) ) throw "IllegalArgumentException: items and ar...
javascript
{ "resource": "" }
q40234
Interpreter
train
function Interpreter(options) { options = options || {}; this.quote = typeof options.quote === 'boolean' ? options.quote : true; }
javascript
{ "resource": "" }
q40235
interpret
train
function interpret(input) { var cli = [] , exp = null , i , s , q , e , sre = /^("|').*/ , ere = /.*("|')$/; assert( typeof input === 'string' || input instanceof String, 'interpret invalid input: must be a string'); input = '' + input; assert( input && !/^\s+$/.test(i...
javascript
{ "resource": "" }
q40236
train
function (options) { if (!options.path) { throw new Error('A path must be supplied to write to') } this.path = options.path this.useColors = options.useColors || false mkdirp.sync(path.dirname(this.path)) this.fd = fs.openSync(this.path, 'w', options.mode || 0644) }
javascript
{ "resource": "" }
q40237
replaceCssModules
train
function replaceCssModules (bundles, cssBundles, originBundleCssBundleMap, moduleClassnameMaps) { const cssBundlesStats = moduleClassnameMaps && cssBundles.map(bundle => { const moduleClassnames = bundle.modules.map(module => moduleClassnameMaps[module.path]); const combinedJson = assign(...[{}].concat(modul...
javascript
{ "resource": "" }
q40238
visitEntry
train
function visitEntry (pkey, context, callback) { _(context).chain().keys().each(function (key) { var entry = context[key], curkey = pkey?(pkey + '.' + key):key; if(_.isFunction(entry) || _.isString(entry) || _.isBoolean(entry) || _.isArray(entry) || _.isNumber(entry) || _.isRegExp(entry)) ...
javascript
{ "resource": "" }
q40239
accessEntry
train
function accessEntry (context, keys) { _.each(keys, function (key) { if (context) { context = context[key]; } }); return context; }
javascript
{ "resource": "" }
q40240
Get
train
function Get(url) { //Initialize the output var out = {"path": "", "file": "", "ext": "", "query": {}, "hashtag": ""}; //Save the file path out.path = url; //Find if exists a ? or # var p1 = out.path.indexOf('?'); var p2 = out.path.indexOf('#'); //Check for hashtag if(p2 != -1) { //Get the ha...
javascript
{ "resource": "" }
q40241
_directoryToFile
train
function _directoryToFile (directory, target, separator, callback) { if ("undefined" === typeof directory) { throw new ReferenceError("missing \"directory\" argument"); } else if ("string" !== typeof directory) { throw new TypeError("\"directory\" argument is not a string"); } else if ("" ==...
javascript
{ "resource": "" }
q40242
deepFreeze
train
function deepFreeze(obj) { // if it's already frozen, don't bother going deep into it... if (obj === null || typeof obj === 'undefined' || typeof obj.toJS === 'function' || typeof obj !== 'object') { return obj; } // Retrieve the property names defined on obj let propNames = Object.getOwnPr...
javascript
{ "resource": "" }
q40243
getCombination
train
function getCombination (dateFilter, resolutionFilter, dataTypeFilter) { var c = { date: getFilter(date, dateFilter), resolution: getFilter(resolution, resolutionFilter), dataType: getFilter(dataType, dataTypeFilter), searchParameters: getSearchParameters(dateFilter, resolutionFilter, dataTypeFilter) ...
javascript
{ "resource": "" }
q40244
getAllCombinations
train
function getAllCombinations () { var combinations = []; date.forEach(function (tf) { resolution.forEach(function (rf) { dataType.forEach(function (sf) { combinations.push(getCombination(tf, rf, sf)); }); }); }); return combinations; }
javascript
{ "resource": "" }
q40245
WhileLoop
train
function WhileLoop(name, deps, fragment, doneFn, options) { if (!(this instanceof WhileLoop)) { return new WhileLoop(name, deps, fragment, doneFn, options); } Task.apply(this, Array.prototype.slice.call(arguments)); this.fragment = fragment; if (!_.isFunction(doneFn)) { throw new Error('You must pr...
javascript
{ "resource": "" }
q40246
readStream
train
function readStream(stream) { return new Promise(function(resolve) { stream.pipe(concat(function(data) { resolve(data.toString().trim()); })); }); }
javascript
{ "resource": "" }
q40247
createGitCmdPromise
train
function createGitCmdPromise(args) { return new Promise(function(resolve, reject) { //Remove null values from the final git arguments args = args.filter(function(arg) { /*jshint eqnull:true */ return arg != null; }); /** * @name git#command * @event * @param {String} Strin...
javascript
{ "resource": "" }
q40248
spawnGit
train
function spawnGit(args) { //don't bother with throws, they are catched by promises gitCmd = gitCmd || which('git'); assert.ok(args, 'arguments to git is mandatory'); executionCount++; if (executionPromise) { executionPromise = executionPromise.then( createGitCmdPromise.bind(null, args), c...
javascript
{ "resource": "" }
q40249
decorator
train
function decorator(fn, options, cb) { if (typeof options === 'function') { cb = options; options = null; } return resolvable(options) .then(fn) .nodeify(cb); }
javascript
{ "resource": "" }
q40250
train
function(projection, map) { Dispatcher.dispatch({ type: Constants.MAP_PROJECTION, projection: projection, map: map }); }
javascript
{ "resource": "" }
q40251
buildFonts
train
function buildFonts(conf, undertaker) { const fontSrc = path.join(conf.themeConfig.root, conf.themeConfig.fonts.src, '**', '*.{eot,ttf,woff,woff2,otf,svg}'); const fontDest = path.join(conf.themeConfig.root, conf.themeConfig.fonts.dest); return undertaker.src(fontSrc) .pipe(undertaker.dest(fontDest)); }
javascript
{ "resource": "" }
q40252
chain
train
function chain() { let arg = Array.from(arguments), pipe = arg.length > 0 ? arg.shift() : stream => stream; return function() { let writer = through.obj(); return duplexer( {objectMode: true}, writer, pipe.apply(null, [writer].concat(merge(arguments, arg))) ); }; }
javascript
{ "resource": "" }
q40253
coordinates
train
function coordinates(index, source) { if (!index || !source) return void 0; var lines = source .slice(0, index) .split('\n'); return lines.length + ':' + lines.pop().length; }
javascript
{ "resource": "" }
q40254
iterator
train
function iterator () { // Begin by clearing the canvas RG.clear(obj.canvas, color); obj.context.save(); // First draw the circle and clip to it obj.context.beginPath(); obj.context.arc(centerx, centery, currentRadius, 0, RG.TWO...
javascript
{ "resource": "" }
q40255
Tufu
train
function Tufu(src){ if(!(this instanceof Tufu)){ return new Tufu(src); } this.src = src; var bufferData = fs.readFileSync(this.src); this.codec = Tufu.adaptCodec(bufferData); this.imageData = this.codec.decode(bufferData); //set image quality 100% this.quality = 100; }
javascript
{ "resource": "" }
q40256
castArgument
train
function castArgument(arg) { if (isNumber(arg)) { return parseFloat(arg); } if (helpers.isFraction(arg)) { arg = arg.split('/'); return arg[0] / arg[1]; } if (arg === 'false' || arg === 'true') { return arg === 'true'; } return arg.length ? arg : undefined; }
javascript
{ "resource": "" }
q40257
getArguments
train
function getArguments(name, mixin, obj) { let named = obj.named, ordered = obj.ordered, args = [], parameters; // Cache function parameter names if (! mixinArguments[name]) { mixinArguments[name] = mixin.toString() // Strip out quoted strings (stripping possible commas from parameters) .repla...
javascript
{ "resource": "" }
q40258
ApiclientAdapter
train
function ApiclientAdapter(resource) { this.admin = admin; this.resource = resource || {}; // loop through API interface for resource to get methods to expose var me = this; _.each(resource.api, function (methodInfo, httpMethod) { _.each(methodInfo, function (operation, path) { m...
javascript
{ "resource": "" }
q40259
init
train
function init(config) { var tokenConfig = config.security.token || {}; var privateKey = tokenConfig.privateKey; var decryptedToken = { _id: tokenConfig.webserverId, authToken: tokenConfig.webserverToken }; var jwt = jsonwebtoken.sign(decryptedToken, privateKey); headers = { 'Aut...
javascript
{ "resource": "" }
q40260
send
train
function send(httpMethod, path, req) { req = req || {}; httpMethod = httpMethod.toUpperCase(); var deferred = Q.defer(); var url = baseUrl + path; var data = req.data || {}; // separate out data from request delete req.data; var isAdmin = req.caller && req.caller.role === 'admin';...
javascript
{ "resource": "" }
q40261
train
function(object, getters, property) { _.each(getters, function(getter, name) { object.__addGetter(property, name, getter); }); }
javascript
{ "resource": "" }
q40262
_flatten
train
function _flatten(_ref) { var _ref2 = _toArray(_ref); var first = _ref2[0]; var rest = _ref2.slice(1); if (first === undefined) { return []; } else if (!Array.isArray(first)) { return [first].concat(_toConsumableArray(_flatten(rest))); } else { return [].concat(_toConsumableArray(_flatten(fir...
javascript
{ "resource": "" }
q40263
serialize
train
function serialize(val) { if (val == null) { return 'NULL' } else if (typeof val == 'string') { return "'" + val.replace(/(\\)/g, '\\$1').replace(/(')/g, '\\$1') + "'"; } else if (typeof val == 'number') { if (isNaN(val)) { return 'NULL'; } else { return val.toString(); } } else if ([true, false...
javascript
{ "resource": "" }
q40264
parseSQLVal
train
function parseSQLVal(type, val) { if (val == 'NULL') { return null; } switch (type) { case 'datetime': case 'timestamp': if (val == 'CURRENT_TIMESTAMP') { return val; } else if (val == '0000-00-00 00:00:00') { // HACK(arlen): Not sure if this is correct, but constructing ...
javascript
{ "resource": "" }
q40265
microStorage
train
function microStorage ( namespace ) { list[namespace] = list[namespace] || {}; localStorage.setItem(packageName, JSON.stringify(list)); /** * Get or set value from storage * @param {String} name key * @param {AnyType} value value * @return {AnyType} value */ function storage ( name...
javascript
{ "resource": "" }
q40266
storage
train
function storage ( name, value ) { if (arguments.length == 0) { return; } if (arguments.length == 1) { let result = JSON.parse(localStorage.getItem(`${ namespace }.${ name }`)); return result ? result.$ : result; } localStorage.setItem(`${ name...
javascript
{ "resource": "" }
q40267
isLoggingConfigured
train
function isLoggingConfigured(target) { return target && isBoolean(target.warnEnabled) && isBoolean(target.infoEnabled) && isBoolean(target.debugEnabled) && isBoolean(target.traceEnabled) && typeof target.error === 'function' && typeof target.warn === 'function' && typeof target.info === 'function' && typeof t...
javascript
{ "resource": "" }
q40268
isValidLogLevel
train
function isValidLogLevel(logLevel) { const level = cleanLogLevel(logLevel); switch (level) { case LogLevel.ERROR: case LogLevel.WARN: case LogLevel.INFO: case LogLevel.DEBUG: case LogLevel.TRACE: return true; default: return false; } }
javascript
{ "resource": "" }
q40269
prepareResults
train
function prepareResults(contentTypes) { var results = _.reduce(contentTypes, function (result, contentType, key) { // If content type is string, treat is as content type id if(_.isString(contentType)){ var id = contentType; contentType = { id: id } } contentType.name = key; ...
javascript
{ "resource": "" }
q40270
fetchEntries
train
function fetchEntries(contentTypes) { return when.map(contentTypes, function (contentType) { if (!contentType.id) { return when.reject('Content type `' + contentType.name + '` is missing an `id` value'); } var filters = _.merge({}, contentType.filters, {content_type: contentType.id}); return cli...
javascript
{ "resource": "" }
q40271
train
function(properties, cls, superClass, options) { var opts = _.defaults({}, options, { wrap: true }); if (opts.wrap) { var prototype = cls.prototype; if (superClass) { // combine the cls prototype with the superClass prototype, but do so // using a new prototype chain to avoid copying (and invoki...
javascript
{ "resource": "" }
q40272
train
function(model, options) { options = options ? _.clone(options) : {}; if (!(model = this._prepareModel(model, options))) return false; if (!options.wait) this.add(model, options); return this._callAdapter('addToIndex', options, model); }
javascript
{ "resource": "" }
q40273
train
function(options) { options = options ? _.clone(options) : {}; options.indexKeys = this.indexKeys || options.indexKeys; options.unionKey = this.unionKey || options.unionKey; if (this.indexKey) options.indexKeys.push(this.indexKey); var args = [this, options]; return nodefn.apply(_.bind(this.inde...
javascript
{ "resource": "" }
q40274
train
function(models, options) { if(!models) return false; this.remove(models, options); var singular = !_.isArray(models); models = singular ? [models] : _.clone(models); return this._callAdapter('removeFromIndex', options, models); }
javascript
{ "resource": "" }
q40275
_isDirectory
train
function _isDirectory (directory, callback) { if ("undefined" === typeof directory) { throw new ReferenceError("missing \"directory\" argument"); } else if ("string" !== typeof directory) { throw new TypeError("\"directory\" argument is not a string"); } else if ("" === directory.trim()) { ...
javascript
{ "resource": "" }
q40276
traverse
train
function traverse(node, {enter = () => {}, leave = () => {}}, path = []) { switch (node.type) { // regular non-leaf nodes case 'Apply': enter(node, path) node.args.forEach((arg, index) => traverse(arg, {enter, leave}, [...path, 'args', index])) lea...
javascript
{ "resource": "" }
q40277
validate
train
function validate(values) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var s = this; var _tv4$validateMultiple = tv4.validateMultiple(values, s), valid = _tv4$validateMultiple.valid, errors = _tv4$validateMultiple.errors; if (valid) { re...
javascript
{ "resource": "" }
q40278
validateToThrow
train
function validateToThrow() { var s = this; var error = s.validate.apply(s, arguments); if (error) { throw error; } }
javascript
{ "resource": "" }
q40279
set
train
function set(values) { var s = this; if (arguments.length === 2) { values = {}; var key = arguments[0]; values[key] = arguments[1]; } Object.assign(s, values); return s; }
javascript
{ "resource": "" }
q40280
toJSON
train
function toJSON() { var s = this; var values = Object.assign({}, s.schema); Object.keys(values).forEach(function (key) { var isFunc = iftype.isFunction(values[key]); if (isFunc) { delete values[key]; } }); return values; }
javascript
{ "resource": "" }
q40281
expandFileGlobs
train
function expandFileGlobs(filesAndPatterns, rootDir, callbackFn) { fileMatcher.resolveAnyGlobPatternsAsync(filesAndPatterns, rootDir) .then(function(result) { callbackFn(null, result); }) .fail(callbackFn); }
javascript
{ "resource": "" }
q40282
train
function(selector, context) { var results = []; if (typeof(selector) === 'string') { var idSelector = detectIdSelectors.exec(selector); context = context || document; if (idSelector && idSelector[1]) { var element = context.getElementById(idSelector[1]); if (element) results....
javascript
{ "resource": "" }
q40283
nodeListToArray
train
function nodeListToArray (nodes) { if ($.env.name !== 'IE' || $.env.version > 9) { return prototypeSlice.call(nodes); } // IE 9 and below call use Array.prototype.slice.call against // a NodeList, hence the following var array = []; for (var i=0, num=nodes.length; i<num; ++i) { arr...
javascript
{ "resource": "" }
q40284
versionGEThan
train
function versionGEThan (otherVersion) { if (otherVersion === version) return true; if (typeof(otherVersion) === 'number' && typeof(version) === 'number') { return otherVersion > version; } // The versions have multiple components (i.e. 0.10.30) and // must be compared piecewise. ...
javascript
{ "resource": "" }
q40285
executeListenersAsyncronously
train
function executeListenersAsyncronously(name, args, defaultAction) { var listeners = api.events[name]; if (!listeners || listeners.length === 0) return; var listenerAcks = listeners.length; $.forEach(listeners, function(listener) { // , index function filterHandlers(_listener)...
javascript
{ "resource": "" }
q40286
executeListenersSyncronously
train
function executeListenersSyncronously(name, args) { // defaultAction is not used var listeners = api.events[name]; if (!listeners || listeners.length === 0) return; $.forEach(listeners, function(listener) { // index (listener.closure || listener.handler).apply(listener.context || null...
javascript
{ "resource": "" }
q40287
appendToLogs
train
function appendToLogs(level, args) { if (!args) return; var message = toDebugString(args); if (message.length <= 2) return; _logs.push( [level, formatDateStamp(), message] ); }
javascript
{ "resource": "" }
q40288
train
function (name, callback) { capabilities[name] = function() { var result = callback(); capabilities[name] = function() { return result; }; return result; }; }
javascript
{ "resource": "" }
q40289
shim
train
function shim () { if (!Function.prototype.bind) { Function.prototype.bind = function (oThis) { if (typeof this !== 'function') { // closest thing possible to the ECMAScript 5 internal IsCallable function throw new TypeError('Function.prototype.bind - what is trying to be bound is ...
javascript
{ "resource": "" }
q40290
train
function (options, completion) { var Proto = function PluginProxy() {}, api = new Proto(), waitForReadySignal = pluginEventingBehaviour(api); refCountBehaviour(api); // Assign +plugin+ to this object and setup all the public // accessors that relate to the DOM Object. // var se...
javascript
{ "resource": "" }
q40291
setPlugin
train
function setPlugin (plugin) { if (plugin) { api._ = plugin; api.parentElement = plugin.parentElement; api.$ = $(plugin); } else { api._ = null; api.parentElement = null; api.$ = $(); } }
javascript
{ "resource": "" }
q40292
makeMediaCapturerProxy
train
function makeMediaCapturerProxy (api) { api.selectSources = function() { return api._.selectSources.apply(api._, arguments); }; return api; }
javascript
{ "resource": "" }
q40293
makeMediaPeerProxy
train
function makeMediaPeerProxy (api) { api.setStream = function(stream, completion) { api._.setStream(stream); if (completion) { if (stream.hasVideo()) { // FIX ME renderingStarted currently doesn't first // api.once('renderingStarted', completion); var verifyStream =...
javascript
{ "resource": "" }
q40294
versionGreaterThan
train
function versionGreaterThan (version1, version2) { if (version1 === version2) return false; if (version1 === -1) return version2; if (version2 === -1) return version1; if (version1.indexOf('.') === -1 && version2.indexOf('.') === -1) { return version1 > version2; } // The v...
javascript
{ "resource": "" }
q40295
_getUserMedia
train
function _getUserMedia(mediaConstraints, success, error) { PluginProxies.createMediaPeer(function(err, plugin) { if (err) { error.call(OTPlugin, err); return; } plugin._.getUserMedia(mediaConstraints.toHash(), function(streamJson) { success.call(OTPlugin, MediaStream.fromJ...
javascript
{ "resource": "" }
q40296
measureUploadBandwidth
train
function measureUploadBandwidth(url, payload) { var xhr = new XMLHttpRequest(), resultPromise = new OT.$.RSVP.Promise(function(resolve, reject) { var startTs, lastTs, lastLoaded; xhr.upload.addEventListener('progress', function(evt) { if (!startTs) ...
javascript
{ "resource": "" }
q40297
getMLineIndex
train
function getMLineIndex(sdpLines, mediaType) { var targetMLine = 'm=' + mediaType; // Find the index of the media line for +type+ return OT.$.findIndex(sdpLines, function(line) { if (line.indexOf(targetMLine) !== -1) { return true; } return false; }); }
javascript
{ "resource": "" }
q40298
getMLinePayloadTypes
train
function getMLinePayloadTypes (mediaLine, mediaType) { var mLineSelector = new RegExp('^m=' + mediaType + ' \\d+(/\\d+)? [a-zA-Z0-9/]+(( [a-zA-Z0-9/]+)+)$', 'i'); // Get all payload types that the line supports var payloadTypes = mediaLine.match(mLineSelector); if (!...
javascript
{ "resource": "" }
q40299
removeMediaEncoding
train
function removeMediaEncoding (sdp, mediaType, encodingName) { var sdpLines = sdp.split('\r\n'), mLineIndex = SDPHelpers.getMLineIndex(sdpLines, mediaType), mLine = mLineIndex > -1 ? sdpLines[mLineIndex] : void 0, typesToRemove = [], payloadTypes, match; if ...
javascript
{ "resource": "" }