_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q45700
ComplexAspect
train
function ComplexAspect(complexObject, parent, parentProperty) { if (!complexObject) { throw new Error("The ComplexAspect ctor requires an entity as its only argument."); } if (complexObject.complexAspect) { return complexObject.complexAspect; } // if called without new if (!(this in...
javascript
{ "resource": "" }
q45701
EntityKey
train
function EntityKey(entityType, keyValues) { assertParam(entityType, "entityType").isInstanceOf(EntityType).check(); var subtypes = entityType.getSelfAndSubtypes(); if (subtypes.length > 1) { this._subtypes = subtypes.filter(function (st) { return st.isAbstract === false; }); } i...
javascript
{ "resource": "" }
q45702
JsonResultsAdapter
train
function JsonResultsAdapter(config) { if (arguments.length !== 1) { throw new Error("The JsonResultsAdapter ctor should be called with a single argument that is a configuration object."); } assertConfig(config) .whereParam("name").isNonEmptyString() .whereParam("extractResults").i...
javascript
{ "resource": "" }
q45703
LocalQueryComparisonOptions
train
function LocalQueryComparisonOptions(config) { assertConfig(config || {}) .whereParam("name").isOptional().isString() .whereParam("isCaseSensitive").isOptional().isBoolean() .whereParam("usesSql92CompliantStringComparison").isBoolean() .applyAll(this); if (!this.name) { thi...
javascript
{ "resource": "" }
q45704
NamingConvention
train
function NamingConvention(config) { assertConfig(config || {}) .whereParam("name").isOptional().isString() .whereParam("serverPropertyNameToClient").isFunction() .whereParam("clientPropertyNameToServer").isFunction() .applyAll(this); if (!this.name) { this.name = __getUuid(...
javascript
{ "resource": "" }
q45705
train
function () { // empty ctor is used by all subclasses. if (arguments.length === 0) return; if (arguments.length === 1) { // 3 possibilities: // Predicate(aPredicate) // Predicate([ aPredicate ]) // Predicate(["freight", ">", 100"]) // Predica...
javascript
{ "resource": "" }
q45706
getPropertyPathValue
train
function getPropertyPathValue(obj, propertyPath) { var properties = Array.isArray(propertyPath) ? propertyPath : propertyPath.split("."); if (properties.length === 1) { return obj.getProperty(propertyPath); } else { var nextValue = obj; // hack use of some to perform mapFirst operation. properties...
javascript
{ "resource": "" }
q45707
EntityManager
train
function EntityManager(config) { if (arguments.length > 1) { throw new Error("The EntityManager ctor has a single optional argument that is either a 'serviceName' or a configuration object."); } if (arguments.length === 0) { config = { serviceName: "" }; } else if (typeof config === 'string...
javascript
{ "resource": "" }
q45708
checkEntityTypes
train
function checkEntityTypes(em, entityTypes) { assertParam(entityTypes, "entityTypes").isString().isOptional().or().isNonEmptyArray().isString() .or().isInstanceOf(EntityType).or().isNonEmptyArray().isInstanceOf(EntityType).check(); if (typeof entityTypes === "string") { entityTypes = em.metadataSto...
javascript
{ "resource": "" }
q45709
mergeEntity
train
function mergeEntity(mc, node, meta) { node._$meta = meta; var em = mc.entityManager; var entityType = meta.entityType; if (typeof (entityType) === 'string') { entityType = mc.metadataStore._getEntityType(entityType, false); } node.entityType = entityType; var mergeStrategy = mc.merg...
javascript
{ "resource": "" }
q45710
DefaultChangeRequestInterceptor
train
function DefaultChangeRequestInterceptor(saveContext, saveBundle) { /** Prepare and return the save data for an entity change-set. The adapter calls this method for each entity in the change-set, after it has prepared a "change request" for that object. The method can do anything to the reques...
javascript
{ "resource": "" }
q45711
toQueryString
train
function toQueryString(obj) { var parts = []; for (var i in obj) { if (obj.hasOwnProperty(i)) { parts.push(encodeURIComponent(i) + "=" + encodeURIComponent(obj[i])); } } return parts.join("&"); }
javascript
{ "resource": "" }
q45712
movePropDefsToProto
train
function movePropDefsToProto(proto) { var stype = proto.entityType || proto.complexType; var extra = stype._extra; var alreadyWrapped = extra.alreadyWrappedProps || {}; stype.getProperties().forEach(function (prop) { var propName = prop.name; // we only want to wrap props that haven't alre...
javascript
{ "resource": "" }
q45713
movePropsToBackingStore
train
function movePropsToBackingStore(instance) { var bs = getBackingStore(instance); var proto = Object.getPrototypeOf(instance); var stype = proto.entityType || proto.complexType; stype.getProperties().forEach(function (prop) { var propName = prop.name; if (prop.isUnmapped) { // insure...
javascript
{ "resource": "" }
q45714
getPendingBackingStore
train
function getPendingBackingStore(instance) { var proto = Object.getPrototypeOf(instance); var pendingStores = proto._pendingBackingStores; var pending = core.arrayFirst(pendingStores, function (pending) { return pending.entity === instance; }); if (pending) return pending.backingStore; var ...
javascript
{ "resource": "" }
q45715
font
train
function font() { return src([`${svgDir}/*.svg`]) .pipe( iconfontCss({ fontName: config.name, path: template, targetPath: '../src/index.less', normalize: true, firstGlyph: 0xf000, cssClass: fontName // this is a trick to pass fontName to template }) ...
javascript
{ "resource": "" }
q45716
train
function(imageData, options, success, error) { exec( success, error, 'OpenALPR', 'scan', [imageData, validateOptions(options)] ) }
javascript
{ "resource": "" }
q45717
validateOptions
train
function validateOptions(options) { //Check if options is set and is an object. if(! options || ! typeof options === 'object') { return { country: DEFAULT_COUNTRY, amount: DEFAULT_AMOUNT } } //Check if country property is set. if (! options.hasOwnProperty('country')) { options.country = DEFAULT_COUNTR...
javascript
{ "resource": "" }
q45718
deserialize
train
function deserialize (rawData) { return JSON.parse(rawData, function (k, v) { if (k === '$$date') { return new Date(v); } if (typeof v === 'string' || typeof v === 'number' || typeof v === 'boolean' || v === null) { return v; } if (v && v.$$date) { return v.$$date; } if (v && v.$$regex) { return deser...
javascript
{ "resource": "" }
q45719
compoundCompareThings
train
function compoundCompareThings (fields) { return function (a, b) { var i, len, comparison; // undefined if (a === undefined) { return b === undefined ? 0 : -1; } if (b === undefined) { return a === undefined ? 0 : 1; } // null if (a === null) { return b === null ? 0 : -1; } if (b === nul...
javascript
{ "resource": "" }
q45720
modify
train
function modify (obj, updateQuery) { var keys = Object.keys(updateQuery) , firstChars = _.map(keys, function (item) { return item[0]; }) , dollarFirstChars = _.filter(firstChars, function (c) { return c === '$'; }) , newDoc, modifiers ; if ((keys.indexOf('_id') !== -1) && (updateQuery._id !== obj._...
javascript
{ "resource": "" }
q45721
match
train
function match (obj, query) { var queryKeys, queryKey, queryValue, i; // Primitive query against a primitive type // This is a bit of a hack since we construct an object with an arbitrary key only to dereference it later // But I don't have time for a cleaner implementation now if (isPrimitiveType(obj) || is...
javascript
{ "resource": "" }
q45722
projectForUnique
train
function projectForUnique (elt) { if (elt === null) { return '$null'; } if (typeof elt === 'string') { return '$string' + elt; } if (typeof elt === 'boolean') { return '$boolean' + elt; } if (typeof elt === 'number') { return '$number' + elt; } if (util.isArray(elt)) { return '$date' + elt.getTime(); } r...
javascript
{ "resource": "" }
q45723
getDotValues
train
function getDotValues (doc, fields) { var field, key, i, len; if (util.isArray(fields)) { key = {}; for (i = 0, len = fields.length; i < len; i++) { field = fields[i]; key[field] = document.getDotValue(doc, field); } return key; } else { return document.getDotValue(doc, fields); ...
javascript
{ "resource": "" }
q45724
Model
train
function Model (name, schema, options) { if (typeof(name) != "string") throw "model name must be provided and a string"; if (arguments.length==1) { options = {}; schema = {} }; if (arguments.length==2) { options = schema; schema = {} }; var self = function Document(raw) { return document.Document.call(this, se...
javascript
{ "resource": "" }
q45725
updated
train
function updated(docs) { // Refresh if any of the objects: have an ID which is in our results OR they match our query (this.query) var shouldRefresh = false; docs.forEach(function(doc) { // Avoid using .some since it would stop iterating after first match and we need to set _prefetched var interested ...
javascript
{ "resource": "" }
q45726
isCheckedOut
train
async function isCheckedOut(dir, ref) { let oidCurrent; return git.resolveRef({ dir, ref: 'HEAD' }) .then((oid) => { oidCurrent = oid; return git.resolveRef({ dir, ref }); }) .then(oid => oidCurrent === oid) .catch(() => false); }
javascript
{ "resource": "" }
q45727
resolveCommit
train
async function resolveCommit(dir, ref) { return git.resolveRef({ dir, ref }) .catch(async (err) => { if (err.code === 'ResolveRefError') { // fallback: is ref a shortened oid prefix? const oid = await git.expandOid({ dir, oid: ref }).catch(() => { throw err; }); return git.resolveRef...
javascript
{ "resource": "" }
q45728
resolveBlob
train
async function resolveBlob(dir, ref, pathName, includeUncommitted) { const commitSha = await resolveCommit(dir, ref); // project-helix/#150: check for uncommitted local changes // project-helix/#183: serve newly created uncommitted files // project-helix/#187: only serve uncommitted content if currently // ...
javascript
{ "resource": "" }
q45729
getRawContent
train
async function getRawContent(dir, ref, pathName, includeUncommitted) { return resolveBlob(dir, ref, pathName, includeUncommitted) .then(oid => git.readObject({ dir, oid, format: 'content' }).object); }
javascript
{ "resource": "" }
q45730
createBlobReadStream
train
async function createBlobReadStream(dir, oid) { const { object: content } = await git.readObject({ dir, oid }); const stream = new PassThrough(); stream.end(content); return stream; }
javascript
{ "resource": "" }
q45731
isValidSha
train
function isValidSha(str) { if (typeof str === 'string' && str.length === 40) { const res = str.match(/[0-9a-f]/g); return res && res.length === 40; } return false; }
javascript
{ "resource": "" }
q45732
commitLog
train
async function commitLog(dir, ref, path) { return git.log({ dir, ref, path }) .catch(async (err) => { if (err.code === 'ResolveRefError') { // fallback: is ref a shortened oid prefix? const oid = await git.expandOid({ dir, oid: ref }); return git.log({ dir, ref: oid, path }); }...
javascript
{ "resource": "" }
q45733
randomFileOrFolderName
train
function randomFileOrFolderName(len = 32) { if (Number.isFinite(len)) { return crypto.randomBytes(Math.ceil(len / 2)).toString('hex').slice(0, len); } throw new Error(`illegal argument: ${len}`); }
javascript
{ "resource": "" }
q45734
resolveRepositoryPath
train
function resolveRepositoryPath(options, owner, repo) { let repPath = path.resolve(options.repoRoot, owner, repo); if (options.virtualRepos[owner] && options.virtualRepos[owner][repo]) { repPath = path.resolve(options.virtualRepos[owner][repo].path); } return repPath; }
javascript
{ "resource": "" }
q45735
promiseResult
train
function promiseResult (options, data) { log(`promiseResult: data ${data}`); return new Promise((resolve, reject) => { /* Check cache to avoid I/O. */ const cacheHit = checkCache(config, pattern); if (cacheHit !== RESPONSE_UNKNOWN) { log(`Cache hit: ${cacheHit}`); return resolve(cacheHit); } ...
javascript
{ "resource": "" }
q45736
collectionLookup
train
function collectionLookup (collection, query) { const id = createID(query.pattern, query.language); log(`collectionLookup: querying for ${id}`); return collection.find({_id: id}, {result: 1}).toArray() .then( (docs) => { log(`collectionLookup: Got ${docs.length} docs`); if (docs.length === 0) { log...
javascript
{ "resource": "" }
q45737
reportResult
train
function reportResult (body) { // Reject invalid reports. if (!body) { log(`reportResult: no body`); return Promise.resolve(PATTERN_INVALID); } // Required fields. let isInvalid = false; ['pattern', 'language', 'result'].forEach((f) => { if (!body.hasOwnProperty(f) || body[f] === null) { isInvalid = tru...
javascript
{ "resource": "" }
q45738
collectionUpdate
train
function collectionUpdate (collection, result) { result._id = createID(result.pattern, result.language); return collection.insertOne(result) .catch((e) => { // May fail due to concurrent update on the same value. log(`collectionUpdate: error: ${e}`); return Promise.resolve(PATTERN_INVALID); }); }
javascript
{ "resource": "" }
q45739
runPicturefill
train
function runPicturefill() { picturefill(); var intervalId = setInterval( function(){ // When the document has finished loading, stop checking for new images // https://github.com/ded/domready/blob/master/ready.js#L15 w.picturefill(); if ( /^loaded|^i|^c/.test( doc.readyState ) ) { ...
javascript
{ "resource": "" }
q45740
train
function(engine) { if (typeof GFX_ENGINES[engine] === 'undefined') { return grunt.fail.warn('Invalid render engine specified'); } grunt.verbose.ok('Using render engine: ' + GFX_ENGINES[engine].name); if (engine === 'im') { return gm.subClass({ imageMagick: (engine === 'im') }); } r...
javascript
{ "resource": "" }
q45741
train
function(properties, options) { var widthUnit = '', heightUnit = ''; // name takes precedence if (properties.name) { return properties.name; } else { // figure out the units for width and height (they can be different) widthUnit = ((properties.width || 0).toString().indexOf('%')...
javascript
{ "resource": "" }
q45742
train
function(obj, keys, remove) { var i = 0, l = keys.length; for (i = 0; i < l; i++) { if (obj[keys[i]] && obj[keys[i]].toString().indexOf(remove) > -1) { obj[keys[i]] = obj[keys[i]].toString().replace(remove, ''); } } return obj; }
javascript
{ "resource": "" }
q45743
train
function(error, engine) { if (error.message.indexOf('ENOENT') > -1) { grunt.log.error(error.message); grunt.fail.warn('\nPlease ensure ' + GFX_ENGINES[engine].name + ' is installed correctly.\n' + '`brew install ' + GFX_ENGINES[engine].brewurl + '` or see ' + GFX_ENGINES[engine].url + ' for more...
javascript
{ "resource": "" }
q45744
train
function(count, name) { if (count) { grunt.log.writeln('Resized ' + count.toString().cyan + ' ' + grunt.util.pluralize(count, 'file/files') + ' for ' + name); } }
javascript
{ "resource": "" }
q45745
train
function(srcPath, dstPath, sizeOptions, customDest, origCwd) { var baseName = '', dirName = '', extName = ''; extName = path.extname(dstPath); baseName = path.basename(dstPath, extName); // filename without extension if (customDest) { sizeOptions.path = srcPath.replace(new RegExp(or...
javascript
{ "resource": "" }
q45746
onMouse
train
function onMouse(touchType) { return function(ev) { // prevent mouse events if (ev.which !== 1) { return; } // The EventTarget on which the touch point started when it was first placed on the surface, // even if the touch point has since moved outside the interactive area of that element. ...
javascript
{ "resource": "" }
q45747
triggerTouch
train
function triggerTouch(eventName, mouseEv) { var touchEvent = document.createEvent('Event'); touchEvent.initEvent(eventName, true, true); touchEvent.altKey = mouseEv.altKey; touchEvent.ctrlKey = mouseEv.ctrlKey; touchEvent.metaKey = mouseEv.metaKey; touchEvent.shiftKey = mouseEv.shiftKey; touchEvent.touc...
javascript
{ "resource": "" }
q45748
start
train
function start(autoExec) { debouncedEmit = debounce(emit, 1); win[ADD_EVENT_LISTENER](POPSTATE, debouncedEmit); win[ADD_EVENT_LISTENER](HASHCHANGE, debouncedEmit); doc[ADD_EVENT_LISTENER](clickEvent, click); if (autoExec) { emit(true); } }
javascript
{ "resource": "" }
q45749
train
function(a, b, retArr) { if (retArr) { return [a, b, a + b]; } return a + b; }
javascript
{ "resource": "" }
q45750
createServer
train
function createServer() { function app(req, res, next) { app.handle(req, res, next); } app.method = '*'; merge(app, proto); merge(app, EventEmitter.prototype); app.stack = []; app.params = []; app._cachedEvents = [] ; app.routedMethods = {} ; app.locals = Object.create(null); for (var i = 0; i...
javascript
{ "resource": "" }
q45751
Callback
train
function Callback (retType, argTypes, abi, func) { debug('creating new Callback'); if (typeof abi === 'function') { func = abi; abi = undefined; } // check args assert(!!retType, 'expected a return "type" object as the first argument'); assert(Array.isArray(argTypes), 'expected Array of arg "type"...
javascript
{ "resource": "" }
q45752
variadic_function_generator
train
function variadic_function_generator () { debug('variadic_function_generator invoked'); // first get the types of variadic args we are working with const argTypes = fixedArgTypes.slice(); let key = fixedKey.slice(); for (let i = 0; i < arguments.length; i++) { const type = ref.coerceType(arg...
javascript
{ "resource": "" }
q45753
ForeignFunction
train
function ForeignFunction (funcPtr, returnType, argTypes, abi) { debug('creating new ForeignFunction', funcPtr); // check args assert(Buffer.isBuffer(funcPtr), 'expected Buffer as first argument'); assert(!!returnType, 'expected a return "type" object as the second argument'); assert(Array.isArray(argTypes), ...
javascript
{ "resource": "" }
q45754
train
function () { debug('invoking proxy function'); if (arguments.length !== numArgs) { throw new TypeError('Expected ' + numArgs + ' arguments, got ' + arguments.length); } // storage buffers for input arguments and the return value const result = Buffer.alloc(resultSize); const a...
javascript
{ "resource": "" }
q45755
Function
train
function Function (retType, argTypes, abi) { if (!(this instanceof Function)) { return new Function(retType, argTypes, abi); } debug('creating new FunctionType'); // check args assert(!!retType, 'expected a return "type" object as the first argument'); assert(Array.isArray(argTypes), 'expected Array o...
javascript
{ "resource": "" }
q45756
replaceTableNames
train
function replaceTableNames(sql, identifiers, sequelize) { const {queryInterface} = sequelize; _.forIn(identifiers, (model, identifier) => { const tableName = model.getTableName(); sql = sql.replace( new RegExp(`\\*${identifier}(?![a-zA-Z0-9_])`, 'g'), tableName.schema ? tableName.toString() : queryInterface...
javascript
{ "resource": "" }
q45757
addOptions
train
function addOptions(queryOptions, options) { const {transaction, logging} = options; if (transaction !== undefined) queryOptions.transaction = transaction; if (logging !== undefined) queryOptions.logging = logging; return queryOptions; }
javascript
{ "resource": "" }
q45758
inFields
train
function inFields(fieldName, options) { const {fields} = options; if (!fields) return true; return fields.includes(fieldName); }
javascript
{ "resource": "" }
q45759
valueFilteredByFields
train
function valueFilteredByFields(fieldName, item, options) { if (!inFields(fieldName, options)) return null; return item.dataValues[fieldName]; }
javascript
{ "resource": "" }
q45760
addToFields
train
function addToFields(fieldName, options) { if (inFields(fieldName, options)) return; options.fields = options.fields.concat([fieldName]); }
javascript
{ "resource": "" }
q45761
guid
train
function guid(moduleId) { var S4 = function() { return (((1+Math.random())*0x10000)|0).toString(16).substring(1); }; return moduleId + '@' + (S4()+S4()); }
javascript
{ "resource": "" }
q45762
w3cTouchConvert
train
function w3cTouchConvert(touchList) { var canvasOffset = display._getCanvasOffset(); var tList = []; for (var i = 0; i < touchList.length; i++) { var touchEvent = touchList.item(i); tList.push({ identifier: touchEvent.identifier, pos: [touchEvent.clientX - can...
javascript
{ "resource": "" }
q45763
train
function(dimensions) { var simplex = new gamejs.math.noise.Simplex(Math); var surfaceData = []; for (var i=0;i<dimensions[0];i++) { surfaceData[i] = []; for (var j=0;j<dimensions[1];j++) { var val = simplex.get(i/50, j/50) * 255; surfaceData[i][j] = val; } } return sur...
javascript
{ "resource": "" }
q45764
colorForTouch
train
function colorForTouch(touch) { var id = touch.identifier + (100 * Math.random()); var r = Math.floor(id % 16); var g = Math.floor(id / 3) % 16; var b = Math.floor(id / 7) % 16; r = r.toString(16); g = g.toString(16); b = b.toString(16); var color = "#" + r + g + b; gamejs.logging.log(color) return...
javascript
{ "resource": "" }
q45765
train
function(actual, expected, maxDifference, message) { var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference; QUnit.push(passes, actual, expected, message); }
javascript
{ "resource": "" }
q45766
train
function(actual, expected, minDifference, message) { var passes = Math.abs(actual - expected) > minDifference; ok(passes); QUnit.push(passes, actual, expected, message); }
javascript
{ "resource": "" }
q45767
Ball
train
function Ball(center) { this.center = center; this.growPerSec = Ball.GROW_PER_SEC; this.radius = this.growPerSec * 2; this.color = 0; return this; }
javascript
{ "resource": "" }
q45768
train
function(event) { var wrapper = getCanvas(); wrapper.requestFullScreen = wrapper.requestFullScreen || wrapper.mozRequestFullScreen || wrapper.webkitRequestFullScreen; if (!wrapper.requestFullScreen) { return false; } // @xbrowser chrome allows keboard input onl if ask for it (why oh why?) if (El...
javascript
{ "resource": "" }
q45769
train
function (name, func, context, a, b, c, d, e, f) { invokeGuardedCallback$1.apply(ReactErrorUtils, arguments); }
javascript
{ "resource": "" }
q45770
accumulateTwoPhaseDispatchesSingleSkipTarget
train
function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { if (event && event.dispatchConfig.phasedRegistrationNames) { var targetInst = event._targetInst; var parentInst = targetInst ? getParentInstance(targetInst) : null; traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); } }
javascript
{ "resource": "" }
q45771
getPooledWarningPropertyDefinition
train
function getPooledWarningPropertyDefinition(propName, getVal) { var isFunction = typeof getVal === 'function'; return { configurable: true, set: set, get: get }; function set(val) { var action = isFunction ? 'setting the method' : 'setting the property'; warn(action, 'This is effectively a ...
javascript
{ "resource": "" }
q45772
isEventSupported
train
function isEventSupported(eventNameSuffix, capture) { if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) { return false; } var eventName = 'on' + eventNameSuffix; var isSupported = eventName in document; if (!isSupported) { var element = document.createElement('div'...
javascript
{ "resource": "" }
q45773
train
function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { if (topLevelType === 'topMouseOver' && (nativeEvent.relatedTarget || nativeEvent.fromElement)) { return null; } if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') { // Must not be a mouse in or mouse out - ...
javascript
{ "resource": "" }
q45774
trapBubbledEvent
train
function trapBubbledEvent(topLevelType, handlerBaseName, element) { if (!element) { return null; } var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent; addEventBubbleListener(element, handlerBaseName, // Check if interactive and wrap in interactiveUpdate...
javascript
{ "resource": "" }
q45775
trapCapturedEvent
train
function trapCapturedEvent(topLevelType, handlerBaseName, element) { if (!element) { return null; } var dispatch = isInteractiveTopLevelEventType(topLevelType) ? dispatchInteractiveEvent : dispatchEvent; addEventCaptureListener(element, handlerBaseName, // Check if interactive and wrap in interactiveUpda...
javascript
{ "resource": "" }
q45776
computeUniqueAsyncExpiration
train
function computeUniqueAsyncExpiration() { var currentTime = recalculateCurrentTime(); var result = computeAsyncExpiration(currentTime); if (result <= lastUniqueAsyncExpiration) { // Since we assume the current time monotonically increases, we only hit // this branch when computeUniqueAsyncExpira...
javascript
{ "resource": "" }
q45777
train
function (config) { var getPublicInstance = config.getPublicInstance; var _ReactFiberScheduler = ReactFiberScheduler(config), computeUniqueAsyncExpiration = _ReactFiberScheduler.computeUniqueAsyncExpiration, recalculateCurrentTime = _ReactFiberScheduler.recalculateCurrentTime, computeExpirationFo...
javascript
{ "resource": "" }
q45778
validateFragmentProps
train
function validateFragmentProps(fragment) { currentlyValidatingElement = fragment; var keys = Object.keys(fragment.props); for (var i = 0; i < keys.length; i++) { var key = keys[i]; if (!VALID_FRAGMENT_PROPS.has(key)) { warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragm...
javascript
{ "resource": "" }
q45779
show
train
function show(options) { if (!options.message) { return; } prepare_(); let notify = null; const time = options.time || 8000; switch (options.type) { case 'confirm': notify = draw.confirm(options); break; case 'prompt': notify = draw.prompt(options);...
javascript
{ "resource": "" }
q45780
init
train
function init(options) { setting = options || {}; if (!setting.googleApiKey && !setting.yandexApiKey) { console.warn(constant.ERROR.MISSING_TOKEN); return false; } else if (setting.yandexApiKey) { serviceType = constant.YANDEX_NAME; translateSrv = require('./service/yandex.js'); } else { service...
javascript
{ "resource": "" }
q45781
train
function (x) { return (Mexp.math.isDegree ? 180 / Math.PI * Math.acos(x) : Math.acos(x)) }
javascript
{ "resource": "" }
q45782
StorageHandle
train
function StorageHandle() { this.storageSupport = storageSupportAnalyse(); switch (this.storageSupport) { case 0: var exec = require('cordova/exec'); this.storageHandlerDelegate = exec; break; case 1: var localStorageHandle = require('./LocalStorageHandle'); this.storageHandlerD...
javascript
{ "resource": "" }
q45783
getFuzzyLocalTimeFromPoint
train
function getFuzzyLocalTimeFromPoint(timestamp, point) { var tile = tilebelt.pointToTile(point[0], point[1], z).join('/'); var locale = tiles[tile]; if (locale) return moment.tz(new Date(timestamp), locale); else return undefined; }
javascript
{ "resource": "" }
q45784
getFuzzyTimezoneFromTile
train
function getFuzzyTimezoneFromTile(tile) { if (tile[2] === z) { var key = tile.join('/'); if (key in tiles) return tiles[key]; else throw new Error('tile not found'); } else if (tile[2] > z) { // higher zoom level (9, 10, 11, ...) key = _getParent(tile).join('/'); if (key in tiles) return ti...
javascript
{ "resource": "" }
q45785
isReadableStream
train
function isReadableStream (stream) { return stream !== null && typeof (stream) === 'object' && typeof (stream.pipe) === 'function' && typeof (stream._read) === 'function' && typeof (stream._readableState) === 'object' && stream.readable !== false }
javascript
{ "resource": "" }
q45786
wait
train
function wait() { var isDone = false; var start = new Date().getTime(); var interval = setInterval(() => { var now = new Date().getTime(); if ((now - start) >= _retryInterval){ clearInterval(interval); isDone = true; } ...
javascript
{ "resource": "" }
q45787
train
function(elms, clickParent) { var elm = elms && elms.length > 0 ? elms[0] : null; if (!elm) { return; } /*global document*/ var clck_ev = document.createEvent('MouseEvent'); clck_ev.initEvent('click', true, true); if (clickParent) { elm.par...
javascript
{ "resource": "" }
q45788
convertRequest
train
function convertRequest(request, functionName, config) { var url = ''; var result; if (!request.url) { if (!request._unboundRequest && !request.collection) { ErrorHelper.parameterCheck(request.collection, 'DynamicsWebApi.' + functionName, "request.collection"); } if (requ...
javascript
{ "resource": "" }
q45789
findCollectionName
train
function findCollectionName(entityName) { var xrmInternal = Utility.getXrmInternal(); if (!Utility.isNull(xrmInternal)) { return xrmInternal.getEntitySetName(entityName) || entityName; } var collectionName = null; if (!Utility.isNull(_entityNames)) { collectionName = _entityNames[e...
javascript
{ "resource": "" }
q45790
sendRequest
train
function sendRequest(method, path, config, data, additionalHeaders, responseParams, successCallback, errorCallback, isBatch, isAsync) { additionalHeaders = additionalHeaders || {}; responseParams = responseParams || {}; //add response parameters to parse responseParseParams.push(responseParams); ...
javascript
{ "resource": "" }
q45791
getSerializedType
train
function getSerializedType(value, descriptor) { if (value instanceof SerializedVariable) { return 'SerializedVariable'; } else if (descriptor) { return descriptor.type; } else if (value instanceof Date) { return 'Date'; } else if (typeof value === 'object') { retu...
javascript
{ "resource": "" }
q45792
createAuth
train
function createAuth(type, token) { if (!type) { throw new Error('<type> required'); } if (!token) { throw new Error('<token> required'); } /** * Actual middleware that appends a `Authorization: "${type} ${token}"` * header to the request options. */ return function(worker) { const w...
javascript
{ "resource": "" }
q45793
Worker
train
function Worker(baseUrl, opts = {}) { if (!(this instanceof Worker)) { return new Worker(baseUrl, opts); } // inheritance Emitter.call(this); this.options = extend({ workerId: uuid.v4() }, defaultOptions, opts); this.subscriptions = {}; this.state = STATE_NEW; // apply extensions if (t...
javascript
{ "resource": "" }
q45794
createBasicAuth
train
function createBasicAuth(username, password) { if (!username) { throw new Error('<username> required'); } if (typeof password === 'undefined') { throw new Error('<password> required'); } const token = base64encode(`${username}:${password}`); return auth('Basic', token); }
javascript
{ "resource": "" }
q45795
Logger
train
function Logger(worker) { forEach([ 'start', 'stop', 'reschedule', 'error', 'poll', 'poll:done', 'poll:error', 'fetchTasks', 'fetchTasks:failed', 'fetchTasks:success', 'worker:register', 'worker:remove', 'executeTask', 'executeTask:complete', 'executeTask:c...
javascript
{ "resource": "" }
q45796
Metric
train
function Metric(worker) { var tasksExecutedCount = 0; var pollCount = 0; var executionTime = 0; var pollTime = 0; var idleTime = 0; var activeTasks = 0; worker.on('executeTask', function() { activeTasks++; }); worker.on('executeTask:done', function(task, durationMs) { tasksExecutedCount++...
javascript
{ "resource": "" }
q45797
Capture
train
function Capture (deviceIndex, displayMode, pixelFormat) { this.deviceIndex = deviceIndex; this.displayMode = displayMode; this.pixelFormat = pixelFormat; this.emergencyBrake = null; if (arguments.length !== 3 || typeof deviceIndex !== 'number' || typeof displayMode !== 'number' || typeof pixelFormat !=...
javascript
{ "resource": "" }
q45798
Playback
train
function Playback (deviceIndex, displayMode, pixelFormat) { this.index = 0; this.deviceIndex = deviceIndex; this.displayMode = displayMode; this.pixelFormat = pixelFormat; this.running = true; this.emergencyBrake = null; if (arguments.length !== 3 || typeof deviceIndex !== 'number' || typeof display...
javascript
{ "resource": "" }
q45799
parseJSON
train
function parseJSON(cmd) { try { var json = JSON.parse(cmd.rest); } catch (e) { return false; } // Ensure it's an array. if (!Array.isArray(json)) { return false; } // Ensure every entry in the array is a string. if (!json.every(function (entry) { ret...
javascript
{ "resource": "" }