_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q45600
contains
train
function contains(arr, v) { var nIndex, nLen = arr.length; for (nIndex = 0; nIndex < nLen; nIndex++) { if (arr[nIndex][1] === v) { return true; } } return false; }
javascript
{ "resource": "" }
q45601
unique
train
function unique(oldArray) { var nIndex, nLen = oldArray.length, aArr = []; for (nIndex = 0; nIndex < nLen; nIndex++) { if (!contains(aArr, oldArray[nIndex][1])) { aArr.push(oldArray[nIndex]); } } return aArr; }
javascript
{ "resource": "" }
q45602
_biDimensionalArrayToObject
train
function _biDimensionalArrayToObject(aArr) { var obj = {}, nIndex, nLen = aArr.length, oItem; for (nIndex = 0; nIndex < nLen; nIndex++) { oItem = aArr[nIndex]; obj[oItem[0]] = oItem[1]; } return obj; }
javascript
{ "resource": "" }
q45603
_getKeys
train
function _getKeys(json, aKeys) { var aKey, sKey, oItem; for (sKey in json) { if (json.hasOwnProperty(sKey)) { oItem = json[sKey]; if (_isObject(oItem) || _isArray(oItem)) { aKeys = aKeys.concat(unique(_getKeys(oItem, aKeys))); } if (isNaN(Number(sKey...
javascript
{ "resource": "" }
q45604
_compressArray
train
function _compressArray(json, aKeys) { var nIndex, nLenKeys; for (nIndex = 0, nLenKeys = json.length; nIndex < nLenKeys; nIndex++) { json[nIndex] = JSONC.compress(json[nIndex], aKeys); } }
javascript
{ "resource": "" }
q45605
_compressOther
train
function _compressOther(json, aKeys) { var oKeys, aKey, str, nLenKeys, nIndex, obj; aKeys = _getKeys(json, aKeys); aKeys = unique(aKeys); oKeys = _biDimensionalArrayToObject(aKeys); str = JSON.stringify(json); nLenKeys = aKeys.length; for (nIndex = 0; nIndex <...
javascript
{ "resource": "" }
q45606
_decompressArray
train
function _decompressArray(json) { var nIndex, nLenKeys; for (nIndex = 0, nLenKeys = json.length; nIndex < nLenKeys; nIndex++) { json[nIndex] = JSONC.decompress(json[nIndex]); } }
javascript
{ "resource": "" }
q45607
_decompressOther
train
function _decompressOther(jsonCopy) { var oKeys, str, sKey; oKeys = JSON.parse(JSON.stringify(jsonCopy._)); delete jsonCopy._; str = JSON.stringify(jsonCopy); for (sKey in oKeys) { if (oKeys.hasOwnProperty(sKey)) { str = str.replace(new RegExp('"' + sKey + '"', 'g'), '"' + oKeys[sKey]...
javascript
{ "resource": "" }
q45608
attr
train
function attr(loc, reference, attrName, value) { if (plainAttributes.indexOf(attrName) != -1) { return sourceNode(loc, [reference, '.', attrName, ' = ', value, ';']); } else { return sourceNode(loc, [reference, '.setAttribute(', esc(attrName), ', ', value, ');']); } }
javascript
{ "resource": "" }
q45609
transformArray
train
function transformArray(array, keys, i, options) { if (options) { var t = {__index__: i}; t[options.value] = array[i]; if (options.key) { t[options.key] = i; } return t; } else { return array[i]; } }
javascript
{ "resource": "" }
q45610
unsafe
train
function unsafe(root, nodes, html) { var node, j, i = nodes.length, element = document.createElement('div'); element.innerHTML = html; while (i --> 0) nodes[i].parentNode.removeChild(nodes.pop()); for (i = j = element.childNodes.length - 1; j >= 0; j--) nodes.push(element.childNodes[j]); ++i; if ...
javascript
{ "resource": "" }
q45611
task
train
function task(callback) { // spawn phantomas process var child = phantomas(url, options, function(err, data, results) { callback( null, // pass null even in case of an error to continue async.series processing (issue #380) [err, results] ); }); child.on('progress', function(progress, inc) { if (bar) { ...
javascript
{ "resource": "" }
q45612
train
function(node, callback, depth) { if (this.isSkipped(node)) { return; } var childNode, childNodes = node && node.childNodes || []; depth = (depth || 1); for (var n = 0, len = childNodes.length; n < len; n++) { childNode = childNodes[n]; // callback can return false to stop recursive ...
javascript
{ "resource": "" }
q45613
spyGlobalVar
train
function spyGlobalVar(varName, callback) { phantomas.log('spy: attaching to %s global variable', varName); window.__defineSetter__(varName, function(val) { phantomas.log('spy: %s global variable has been defined', varName); spiedGlobals[varName] = val; callback(val); }); window.__defineGetter...
javascript
{ "resource": "" }
q45614
pushToStack
train
function pushToStack(type, entry, check) { // no entry of given type if (typeof stack[type] === 'undefined') { stack[type] = entry; } // apply check function else if (check(stack[type], entry) === true) { stack[type] = entry; } }
javascript
{ "resource": "" }
q45615
train
function(name, value) { if (typeof metricsAvgStorage[name] === 'undefined') { metricsAvgStorage[name] = []; } metricsAvgStorage[name].push(value); this.setMetric(name, getAverage(metricsAvgStorage[name])); }
javascript
{ "resource": "" }
q45616
createHAR
train
function createHAR(page, creator) { // @see: https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/HAR/Overview.html var address = page.address; var title = page.title; var startTime = page.startTime; var resources = page.resources; var entries = []; resources.forEach(function(resource) { var request = resource....
javascript
{ "resource": "" }
q45617
lowerCaseHeaders
train
function lowerCaseHeaders(headers) { var res = {}; Object.keys(headers).forEach(headerName => { res[headerName.toLowerCase()] = headers[headerName]; }); return res; }
javascript
{ "resource": "" }
q45618
parseEntryUrl
train
function parseEntryUrl(entry) { const parseUrl = require('url').parse; var parsed; // asset type entry.type = 'other'; if (entry.url.indexOf('data:') !== 0) { // @see http://nodejs.org/api/url.html#url_url parsed = parseUrl(entry.url) || {}; entry.protocol = parsed.protocol.replace(':', ''); entry.domai...
javascript
{ "resource": "" }
q45619
addContentType
train
function addContentType(headerValue, entry) { var value = headerValue.split(';').shift().toLowerCase(); entry.contentType = value; switch(value) { case 'text/html': entry.type = 'html'; entry.isHTML = true; break; case 'text/xml': entry.type = 'xml'; entry.isXML = true; break; case 'text/c...
javascript
{ "resource": "" }
q45620
hasConfigSetting
train
function hasConfigSetting(pkg, setting) { return pkg.config && pkg.config[appName] && pkg.config[appName][setting]; }
javascript
{ "resource": "" }
q45621
getConfigSetting
train
function getConfigSetting(pkg, setting, ensureArray) { if (!hasConfigSetting(pkg, setting)) { return null; } const value = pkg.config[appName][setting]; if (ensureArray && !Array.isArray(value)) { return [value]; } return value; }
javascript
{ "resource": "" }
q45622
getConfigSettings
train
function getConfigSettings(packageJsonFile) { // Locate and read package.json const pkg = JSON.parse(fs.readFileSync(packageJsonFile)); return { searchDir: getConfigSetting(pkg, 'searchDir', true) || getDefaultValue('searchDir'), outputFile: getConfigSetting(pkg, 'outputFile') || getDefaultVa...
javascript
{ "resource": "" }
q45623
train
function (template, templateUrl) { var deferred = $q.defer(); if (template) { deferred.resolve(template); } else if (templateUrl) { $templateRequest(templateUrl, true) .then(function (...
javascript
{ "resource": "" }
q45624
train
function(ev) { if (!ev) { ev = w.event; } if (!ev) { ev = { name: "load" }; } if(impl.onloadfired) { return this; } impl.fireEvent("page_ready", ev); impl.onloadfired = true; return this; }
javascript
{ "resource": "" }
q45625
train
function() { var res, k, urls, url, startTime, data; function trimTiming(time, st) { // strip from microseconds to milliseconds only var timeMs = Math.round(time ? time : 0), startTimeMs = Math.round(st ? st : 0); timeMs = (timeMs === 0 ? 0 : (timeMs - startTimeMs)); return timeMs ? timeMs : "...
javascript
{ "resource": "" }
q45626
train
function() { var ti, p, source; if(this.navigationStart) { return; } // Get start time from WebTiming API see: // https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/NavigationTiming/Overview.html // http://blogs.msdn.com/b/ie/archive/2010/06/28/measuring-web-page-performance.aspx // http://blog.chromi...
javascript
{ "resource": "" }
q45627
train
function(t_now, data) { var t_done = t_now; // xhr beacon with detailed timing information if (data && data.timing && data.timing.loadEventEnd) { t_done = data.timing.loadEventEnd; } // Boomerang loaded late and... else if (BOOMR.loadedLate) { // We have navigation timing, if(w.performance && w.pe...
javascript
{ "resource": "" }
q45628
train
function(ename, data) { var t_start; if(ename==="xhr") { if(data && data.name && impl.timers[data.name]) { // For xhr timers, t_start is stored in impl.timers.xhr_{page group name} // and xhr.pg is set to {page group name} t_start = impl.timers[data.name].start; } else if(data && data.timing &&...
javascript
{ "resource": "" }
q45629
intersection
train
function intersection(sets) { let source = sets[0]; let rest = sets.slice(1); let keys = Object.keys(source); let keysLength = keys.length; let restLength = rest.length; let result = []; for (let keyIndex = 0; keyIndex < keysLength; keyIndex++) { let key = keys[keyIndex]; let matched = true; f...
javascript
{ "resource": "" }
q45630
publicAnimationContext
train
function publicAnimationContext(rt, versions) { let c = {}; addPublicVersion(c, 'new', versions[0]); if (versions[1]) { addPublicVersion(c, 'old', versions[1]); } c.older = versions.slice(2).map((v) => { let context = {}; addPublicVersion(context, null, v); return context; }); // Animatio...
javascript
{ "resource": "" }
q45631
train
function( index, callback ) { var scope = this; var shot = scope.shots[ index|0 ]; if( ! shot ) { throw new Error( "Shot number " + index + " not found" ); return; } return shot; }
javascript
{ "resource": "" }
q45632
train
function( shot, callback ) { var scope = this; if( typeof( shot ) === "number" ) { shot = scope.getShot( shot ); } if( shot.location ) { FS.readFile( shot.location, function( err, data ) { callback( err, data ); }); } e...
javascript
{ "resource": "" }
q45633
train
function( shot, callback ) { var scope = this; scope.getShotBuffer( shot, function( err, data ) { if( err ) { callback( err ); return; } var base64 = scope.getBase64FromBuffer( data ); callback( null, base64 ); ...
javascript
{ "resource": "" }
q45634
train
function( shotBuffer ) { var scope = this; var image = "data:image/" + scope.opts.output + ";base64," + new Buffer( shotBuffer ).toString( "base64" ); return image; }
javascript
{ "resource": "" }
q45635
train
function( callback ) { var scope = this; if( ! scope.shots.length ) { callback && callback( new Error( "Camera has no last shot" ) ); } scope.getBase64( scope.shots.length - 1, callback ); }
javascript
{ "resource": "" }
q45636
train
function(code, callback) { if (typeof code == 'function') { callback = code; this.promises.push(function onGenericStatusCode(done, utils) { done(null, callback(this.scraper.getStatusCode(), utils)); }); } else { this.promises.push(function onStatusCode(done, utils) { if (code === this.scraper.ge...
javascript
{ "resource": "" }
q45637
train
function(scrapeFn, callback) { var stackTrace = new Error().stack; var extraArguments = Array.prototype.slice.call(arguments, 2); callback = callback || function(result) { return result; }; this.promises.push(function scrape(done, utils) { this.scraper.scrape(scrapeFn, function(err, result) { if (e...
javascript
{ "resource": "" }
q45638
train
function(time, callback) { callback = callback || function() {}; this.promises.push(function delay(done, utils) { setTimeout(function() { done(null, callback(utils)); }, time); }); return this; }
javascript
{ "resource": "" }
q45639
train
function(callback) { this.promises.push(function then(done, utils) { done(null, callback(utils.lastReturn, utils)); }); return this; }
javascript
{ "resource": "" }
q45640
train
function(callback) { this.promises.push(function async(done, utils) { callback(utils.lastReturn, done, utils); }); return this; }
javascript
{ "resource": "" }
q45641
train
function(error) { var that = this, param = this.chainParameter, stopPointer = {}, utils = { stop: null, url: this.scraper.url, scraper: this, params: param, lastReturn: undefined }, keep = true; this.chainParameter = null; if (error) { this.errorCallback(error, utils); th...
javascript
{ "resource": "" }
q45642
train
function() { var instance = this.scraper.clone(), promise = new ScraperPromise(instance); promise._setPromises(this.promises); promise.done(this.doneCallback); promise.catch(this.errorCallback); return promise; }
javascript
{ "resource": "" }
q45643
train
function(path) { var callback; if (typeof path === 'function') { callback = path; } this.promises.push({ callback: callback ? function(url) { return callback(url); } : Router.pathMatcher(path), scraper: null, rqMethod: null }); return this.get(); }
javascript
{ "resource": "" }
q45644
train
function(url, callback) { var that = this, atLeastOne = false, stopFlag = {}, lastReturn; callback = callback || function() {}; async.eachSeries(this.promises, function(promiseObj, done) { var matcher = promiseObj.callback, scraper, reqMethod = promiseObj.rqMethod; var result = matcher(url...
javascript
{ "resource": "" }
q45645
train
function() { /** * The real PhantomJS instance. * * @type {?} * @private */ this.instance = null; /** * The PhantomJS instance is being created. * * @type {!boolean} * @private */ this.creating = false; /** * PhantomJS flags. * * @type {!string} * @private */ this.flags = ''; /** ...
javascript
{ "resource": "" }
q45646
train
function(callback) { if (this.instance) { this.instance.createPage(function(page) { callback(page); }); } else { var that = this; this._createInstance(function() { that.createPage(callback); }); } }
javascript
{ "resource": "" }
q45647
train
function(callback) { if (this.creating && callback) { this.waiting.push(callback); } else { var that = this; this.creating = true; phantom.create(this.flags, this.options, function(ph) { that.instance = ph; that.creating = false; that.waiting.forEach(function(callback) { callback(ph); ...
javascript
{ "resource": "" }
q45648
sendAll
train
function sendAll(requests, fnName, concurrency, callback) { if (typeof concurrency === 'function') { callback = concurrency; concurrency = 1; } var q = queue(concurrency); requests.forEach(function(req) { q.defer(function(next) { if (!req) return next(); req.on('compl...
javascript
{ "resource": "" }
q45649
Stringifier
train
function Stringifier() { var stringifier = new stream.Transform({ highWaterMark: 100 }); stringifier._writableState.objectMode = true; stringifier._readableState.objectMode = false; stringifier._transform = function(record, enc, callback) { var str = Dyno.serialize(record); this.push(str + '\n'); ...
javascript
{ "resource": "" }
q45650
Parser
train
function Parser() { var parser = new stream.Transform({ highWaterMark: 100 }); parser._writableState.objectMode = false; parser._readableState.objectMode = true; var firstline = true; parser._transform = function(record, enc, callback) { if (!record || record.length === 0) return; if (firstline) { ...
javascript
{ "resource": "" }
q45651
cleanDescription
train
function cleanDescription(desc) { var deleteAttributes = [ 'CreationDateTime', 'IndexSizeBytes', 'IndexStatus', 'ItemCount', 'NumberOfDecreasesToday', 'TableSizeBytes', 'TableStatus', 'LastDecreaseDateTime', 'LastIncreaseDateTime' ]; return JSON.stringify(desc.Table, function(...
javascript
{ "resource": "" }
q45652
Aggregator
train
function Aggregator(withTable) { var firstline = !!withTable; var aggregator = new stream.Transform({ objectMode: true, highWaterMark: 100 }); aggregator.records = []; aggregator._transform = function(record, enc, callback) { if (!record) return; if (firstline) { firstline = false; this.pu...
javascript
{ "resource": "" }
q45653
rpcDialogShift
train
function rpcDialogShift() { if (rpcDialogQueue.length === 0) { $dialogRpc.dialog('close'); return; } rpcDialogPending = true; const {daemon, cmd, params, callback} = rpcDialogQueue.shift(); const paramText = JSON.stringify(JSON.parse(JSON.stringify(params).replace(/{"explicitDouble...
javascript
{ "resource": "" }
q45654
create_extract_css_plugin
train
function create_extract_css_plugin(css_bundle_filename, useMiniCssExtractPlugin) { if (useMiniCssExtractPlugin) { const MiniCssExtractPlugin = require('mini-css-extract-plugin') return new MiniCssExtractPlugin ({ // Options similar to the same options in webpackOptions.output // both options are optional...
javascript
{ "resource": "" }
q45655
generate_extract_css_loaders
train
function generate_extract_css_loaders(after_style_loader, development, extract_css_plugin, useMiniCssExtractPlugin) { let extract_css_loaders if (useMiniCssExtractPlugin) { const MiniCssExtractPlugin = require('mini-css-extract-plugin') return [{ loader: MiniCssExtractPlugin.loader }, ...after_style_loa...
javascript
{ "resource": "" }
q45656
fill
train
function fill() { if (self.pgrid.filteredDataSource != null && self.dimensionsCount > 0) { var datasource = self.pgrid.filteredDataSource; if (datasource != null && utils.isArray(datasource) && datasource.length > 0) { for (var rowIndex = 0, dataLength = datasource.leng...
javascript
{ "resource": "" }
q45657
getUiInfo
train
function getUiInfo(depth, headers) { var infos = headers[headers.length - 1]; var parents = self.axe.root.depth === depth ? [null] : headers[self.axe.root.depth - depth - 1].filter(function(p) { return p.type !== uiheaders.HeaderType.SUB_TOTAL; }); for (...
javascript
{ "resource": "" }
q45658
train
function(identifier, parent) { var parts = identifier.split('.'); var i = 0; parent = parent || window; while (i < parts.length) { parent[parts[i]] = parent[parts[i]] || {}; parent = parent[parts[i]]; i++; } return parent; }
javascript
{ "resource": "" }
q45659
train
function(obj) { var arr = []; for (var prop in obj) { if (obj.hasOwnProperty(prop)) { arr.push(prop); } } return arr; }
javascript
{ "resource": "" }
q45660
train
function(array, predicate) { if (this.isArray(array) && predicate) { for (var i = 0; i < array.length; i++) { var item = array[i]; if (predicate(item)) { return item; } } } return undefined; }
javascript
{ "resource": "" }
q45661
train
function(obj, censorKeywords) { function censor(key, value) { return censorKeywords && censorKeywords.indexOf(key) > -1 ? undefined : value; } return JSON.stringify(obj, censor, 2); }
javascript
{ "resource": "" }
q45662
getUiInfo
train
function getUiInfo(infos, dimension) { if (dimension.values.length > 0) { var infosMaxIndex = infos.length - 1; var lastInfosArray = infos[infosMaxIndex]; var parent = lastInfosArray.length > 0 ? lastInfosArray[lastInfosArray.length - 1] : null; for (var valInde...
javascript
{ "resource": "" }
q45663
setTableWidths
train
function setTableWidths(tblObject, newWidthArray) { if (tblObject && tblObject.node) { // reset table width (tblObject.size = (tblObject.size || {})).width = 0; var tbl = tblObject.node; // for each row, set its cells width for (var rowIndex = 0; rowIndex < tbl.rows.length...
javascript
{ "resource": "" }
q45664
train
function(name, title, url, setupTemplate, setup, showDevTools){ // Check if the window already exists if(windowManager.windows[name]){ console.log('Window ' + name + ' already exists!'); // Move the focus on it windowManager.focusOn(name); return; } // The window unique...
javascript
{ "resource": "" }
q45665
train
function(name, setup){ if(!isObject(setup) || this.templates[name]) return false; this.templates[name] = setup; }
javascript
{ "resource": "" }
q45666
train
function(setup){ const screen = Electron.screen; const screenSize = screen.getPrimaryDisplay().workAreaSize; const position = setup.position; let x = 0; let y = 0; const positionMargin = 0; let windowWidth = setup.width; let windowHeight = setup.height; ...
javascript
{ "resource": "" }
q45667
train
function(config){ if(isString(config)){ this.config.appBase = config; }else if(isObject(config)){// If the config object is provided this.config = Object.assign(this.config, config); } // If the app base isn't provided if(!this.config.appBase){ ...
javascript
{ "resource": "" }
q45668
train
function(file){ const list = require(utils.getAppLocalPath() + file); if(!isObject(list)) return false; Object.keys(list).forEach(key => { let window = list[key]; this.createNew(key, window.title, window.url, window.setupTemplate, window.setup); }); }
javascript
{ "resource": "" }
q45669
train
function(name, title, url, setupTemplate, setup, showDevTools){ // Create the window instance const window = new Window(name, title, url, setupTemplate, setup, showDevTools); // If the window was created return (window == null || Object.keys(window).length === 0) ?false :window; }
javascript
{ "resource": "" }
q45670
train
function(name, title, content, setupTemplate, setup, showDevTools){ const window = this.createNew(name, title, content, setupTemplate, setup, showDevTools); if(window) window.open(); return window; }
javascript
{ "resource": "" }
q45671
train
function(name){ const window = this.get(name); if(!window) return; return this.createNew(false, false, false, false, this.setup); }
javascript
{ "resource": "" }
q45672
train
function(id) { let instance; Object.keys(this.windows).forEach(key => { let window = this.windows[key]; if(window.object.id === id){ instance = window; } }); return instance; }
javascript
{ "resource": "" }
q45673
train
function(){ Object.keys(this.windows).forEach(key => { let window = this.windows[key]; window.close(); }); }
javascript
{ "resource": "" }
q45674
train
function(name){ // Get all the windows const windows = BrowserWindow.getAllWindows(); // Get the window through the name const windowID = this.get(name).object.id; if(!windows.length || !windowID) return false; // Loop through the windows, close all of them and focus on...
javascript
{ "resource": "" }
q45675
train
function(event, callback){ let id = windowManager.eventEmitter.listenerCount(event); windowManager.eventEmitter.addListener(event, function(event){ callback.call(null, event.data, event.target, event.emittedBy); }); return windowManager.eventEmitter.lis...
javascript
{ "resource": "" }
q45676
getBrowserInformation
train
function getBrowserInformation(userAgent) { var browserInfo = _bowser2.default._detect(userAgent); for (var browser in prefixByBrowser) { if (browserInfo.hasOwnProperty(browser)) { var prefix = prefixByBrowser[browser]; browserInfo.jsPrefix = prefix; browserInfo.cssPrefix = '-' + prefix.toLo...
javascript
{ "resource": "" }
q45677
train
function(name) { var cookie = this.cookies[name] if (cookie && this.checkNotExpired(name)) { return this.cookies[name].value } return null }
javascript
{ "resource": "" }
q45678
train
function(name, value, options) { var cookie = typeof options == 'object' ? {value: value, expires: options.expires, secure: options.secure || false, new: options.new || false} : {value: value} if (this.checkNotExpired(name, cookie)) { this.cookies[name] = cookie } }
javascript
{ "resource": "" }
q45679
train
function(headers) { var cookies = headers['set-cookie'] if (cookies) { cookies.forEach(function(c) { var cookiesParams = c.split(';') var cookiePair = cookiesParams.shift().split('=') var options = {} cookiesParams.forEach(function(param) { param = param.trim() ...
javascript
{ "resource": "" }
q45680
Server
train
function Server(options, isSecure, onListening) { if (false === (this instanceof Server)) { return new Server(options, isSecure) } onListening = onListening || function() {} var that = this // If a string URI is passed in, converts to URI fields if (typeof options === 'string') { options = url.par...
javascript
{ "resource": "" }
q45681
Client
train
function Client(options, isSecure) { // Invokes with new if called without if (false === (this instanceof Client)) { return new Client(options, isSecure) } // If a string URI is passed in, converts to URI fields if (typeof options === 'string') { options = url.parse(options) options.host = optio...
javascript
{ "resource": "" }
q45682
getNamespace
train
async function getNamespace(namespaceName) { const cacheName = '_console_namespace_promise_cache_'; if (!window[cacheName]) { window[cacheName] = {}; } const cache = window[cacheName]; if (!cache[namespaceName]) { cache[namespaceName] = fetchFromKyma( `${k8sServerUrl}/api/v1/namespaces/${namespa...
javascript
{ "resource": "" }
q45683
train
function(scope, element, attrs, ngModel) { function read() { var html = element.html(); // When we clear the content editable the browser leaves a <br> behind // If strip-br attribute is provided then we strip this out if (a...
javascript
{ "resource": "" }
q45684
MetadataStore
train
function MetadataStore(config) { config = config || { }; assertConfig(config) .whereParam("namingConvention").isOptional().isInstanceOf(NamingConvention).withDefault(NamingConvention.defaultInstance) .whereParam("localQueryComparisonOptions").isOptional().isInstanceOf(LocalQueryComparisonOptions...
javascript
{ "resource": "" }
q45685
parseTypeNameWithSchema
train
function parseTypeNameWithSchema(entityTypeName, schema) { var result = parseTypeName(entityTypeName); if (schema && schema.cSpaceOSpaceMapping) { var ns = getNamespaceFor(result.shortTypeName, schema); if (ns) { result = makeTypeHash(result.shortTypeName, ns); } } return resul...
javascript
{ "resource": "" }
q45686
ComplexType
train
function ComplexType(config) { if (arguments.length > 1) { throw new Error("The ComplexType ctor has a single argument that is a configuration object."); } assertConfig(config) .whereParam("shortName").isNonEmptyString() .whereParam("namespace").isString().isOptional().withDefault("")...
javascript
{ "resource": "" }
q45687
parseTypeName
train
function parseTypeName(entityTypeName) { if (!entityTypeName) { return null; } var typeParts = entityTypeName.split(":#"); if (typeParts.length > 1) { return makeTypeHash(typeParts[0], typeParts[1]); } if (__stringStartsWith(entityTypeName, MetadataStore.ANONTYPE_PREFIX)) { var typeHash = make...
javascript
{ "resource": "" }
q45688
addProperties
train
function addProperties(entityType, propObj, ctor) { if (!propObj) return; if (Array.isArray(propObj)) { propObj.forEach(entityType._addPropertyCore.bind(entityType)); } else if (typeof (propObj) === 'object') { for (var key in propObj) { if (__hasOwnProperty(propObj, key)) { var value = pro...
javascript
{ "resource": "" }
q45689
__getOwnPropertyValues
train
function __getOwnPropertyValues(source) { var result = []; for (var name in source) { if (__hasOwnProperty(source, name)) { result.push(source[name]); } } return result; }
javascript
{ "resource": "" }
q45690
__toJSONSafe
train
function __toJSONSafe(obj, replacer) { if (obj !== Object(obj)) return obj; // primitive value if (obj._$visited) return undefined; replacer = replacer || __safeReplacer; if (obj.toJSON) { var newObj = obj.toJSON(); if (newObj !== Object(newObj)) return newObj; // primitive value if (newObj !== obj)...
javascript
{ "resource": "" }
q45691
__resolveProperties
train
function __resolveProperties(sources, propertyNames) { var r = {}; var length = sources.length; propertyNames.forEach(function (pn) { for (var i = 0; i < length; i++) { var src = sources[i]; if (src) { var val = src[pn]; if (val !== undefined) { r[pn] = val; bre...
javascript
{ "resource": "" }
q45692
__map
train
function __map(items, fn, includeNull) { // whether to return nulls in array of results; default = true; includeNull = includeNull == null ? true : includeNull; if (items == null) return items; var result; if (Array.isArray(items)) { result = []; items.forEach(function (v, ix) { var r = fn(v, ix...
javascript
{ "resource": "" }
q45693
__getArray
train
function __getArray(source, propName) { var arr = source[propName]; if (!arr) { arr = []; source[propName] = arr; } return arr; }
javascript
{ "resource": "" }
q45694
__requireLibCore
train
function __requireLibCore(libName) { var window = global.window; if (!window) return; // Must run in a browser. Todo: add commonjs support // get library from browser globals if we can var lib = window[libName]; if (lib) return lib; // if require exists, maybe require can get it. // This method is synch...
javascript
{ "resource": "" }
q45695
__isPrimitive
train
function __isPrimitive(obj) { if (obj == null) return false; // true for numbers, strings, booleans and null, false for objects if (obj != Object(obj)) return true; return __isDate(obj); }
javascript
{ "resource": "" }
q45696
__stringStartsWith
train
function __stringStartsWith(str, prefix) { // returns true for empty string or null prefix if ((!str)) return false; if (prefix == "" || prefix == null) return true; return str.indexOf(prefix, 0) === 0; }
javascript
{ "resource": "" }
q45697
Enum
train
function Enum(name, methodObj) { this.name = name; var prototype = new EnumSymbol(methodObj); prototype.parentEnum = this; this._symbolPrototype = prototype; if (methodObj) { Object.keys(methodObj).forEach(function (key) { prototype[key] = methodObj[key]; }); } }
javascript
{ "resource": "" }
q45698
EntityAspect
train
function EntityAspect(entity) { if (entity === null) { var nullInstance = EntityAspect._nullInstance; if (nullInstance) return nullInstance; EntityAspect._nullInstance = this; } else if (entity === undefined) { throw new Error("The EntityAspect ctor requires an entity as its only argumen...
javascript
{ "resource": "" }
q45699
validateTarget
train
function validateTarget(target, coIndex) { var ok = true; var stype = target.entityType || target.complexType; var aspect = target.entityAspect || target.complexAspect; var entityAspect = target.entityAspect || target.complexAspect.getEntityAspect(); var context = { entity: entityAspect.entity }; ...
javascript
{ "resource": "" }