_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q6000
inferSettings
train
function inferSettings(graph) { var order = graph.order; return { barnesHutOptimize: order > 2000, strongGravityMode: true, gravity: 0.05, scalingRatio: 10, slowDown: 1 + Math.log(order) }; }
javascript
{ "resource": "" }
q6001
Page
train
function Page(path, ctx) { events.EventEmitter.call(this); this.path = path; this.context = ctx; this._isOpen = false; }
javascript
{ "resource": "" }
q6002
dispatch
train
function dispatch(req, done) { var site = req.site , path = upath.join(site.path || '', req.path) , parent = site.parent; while (parent) { path = upath.join(parent.path || '', path); parent = parent.parent; } console.log('# ' + path); var page ...
javascript
{ "resource": "" }
q6003
rewrite_code
train
function rewrite_code(code, node, replacement_string) { return code.substr(0, node.start.pos) + replacement_string + code.substr(node.end.endpos); }
javascript
{ "resource": "" }
q6004
generateData
train
function generateData( filepath ) { var dataObj = new datauri( filepath ); return { data: dataObj.content, path: filepath }; }
javascript
{ "resource": "" }
q6005
generateCss
train
function generateCss( filepath, data ) { var filetype = filepath.split( '.' ).pop().toLowerCase(); var className; var template; className = options.classPrefix + path.basename( data.path ).split( '.' )[0] + options.classSuffix; filetype = options.usePlaceholder ? filetype : filetype + '_no'; ...
javascript
{ "resource": "" }
q6006
getHistory
train
function getHistory(callback) { if (_.isUndefined(callback)) { } else { var u = config.baseUrl + ((api_version == "v1") ? "v1.1" : api_version) + "/history", tokenData = this.getAuthToken(); if (tokenData.type != "bearer") { throw new Error("Invalid token type. Must use a token of ...
javascript
{ "resource": "" }
q6007
getUserProfile
train
function getUserProfile(callback) { if (_.isUndefined(callback)) { } else { var u = baseUrl + "/me"; var tokenData = this.getAuthToken(); if (tokenData.type != "bearer") { throw new Error("Invalid token type. Must use a token of type bearer."); } return helper.get(tokenData...
javascript
{ "resource": "" }
q6008
train
function() { return new Promise(function(resolve, reject) { exec("find . ! -name '" + __filename.split('/').pop() + "' -iname '*\.js' | xargs grep 'CRUD.Entity.call(this);' -isl", { timeout: 3000, cwd: process.cwd() }, function(err, stdout, stdin) { ...
javascript
{ "resource": "" }
q6009
train
function() { return new Promise(function(resolve, reject) { exec("find . ! -name '" + __filename.split('/').pop() + "' -iname '*\.js' | xargs grep 'CRUD.Entity.call(this);' -isl", { timeout: 3000, cwd: process.cwd() }, function(err, stdout, stdin) { ...
javascript
{ "resource": "" }
q6010
Group
train
function Group(props) { var children = React.Children.toArray(props.children).filter(Boolean); if (children.length === 1) { return children; } // Insert separators var separator = props.separator; var separatorIsElement = React.isValidElement(separator); var items = [children.shift()]; children.forEach(funct...
javascript
{ "resource": "" }
q6011
createSite
train
function createSite() { function app(page) { app.handle(page); } mixin(app, EventEmitter.prototype, false); mixin(app, proto, false); app.init(); return app; }
javascript
{ "resource": "" }
q6012
invalidResponseError
train
function invalidResponseError(result, host) { const message = !!result && !!result.error && !!result.error.message ? `[ethjs-provider-http] ${result.error.message}` : `[ethjs-provider-http] Invalid JSON RPC response from host provider ${host}: ${JSON.stringify(result, null, 2)}`; return new Error(message); }
javascript
{ "resource": "" }
q6013
HttpProvider
train
function HttpProvider(host, timeout) { if (!(this instanceof HttpProvider)) { throw new Error('[ethjs-provider-http] the HttpProvider instance requires the "new" flag in order to function normally (e.g. `const eth = new Eth(new HttpProvider());`).'); } if (typeof host !== 'string') { throw new Error('[ethjs-provide...
javascript
{ "resource": "" }
q6014
train
function(ip) { this.connectionparams = { host: ip, port: 23, timeout: 1000, // The RESPONSE should be sent within 200ms of receiving the request COMMAND. (plus network delay) sendTimeout: 1200, negotiationMandatory: false, ors: '\r', // Set outbound record separator ...
javascript
{ "resource": "" }
q6015
sendKeys
train
function sendKeys(element, str) { return str.split('').reduce(function (promise, char) { return promise.then(function () { return element.sendKeys(char); }); }, element.getAttribute('value')); // better to create a resolved promise here but ... don't know how with protractor; }
javascript
{ "resource": "" }
q6016
insertQuerySuccess
train
function insertQuerySuccess(resultSet) { resultSet.Action = 'inserted'; resultSet.ID = resultSet.rs.insertId; CRUD.stats.writesExecuted++; return resultSet; }
javascript
{ "resource": "" }
q6017
insertQueryError
train
function insertQueryError(err, tx) { CRUD.stats.writesExecuted++; console.error("Insert query error: ", err); return err; }
javascript
{ "resource": "" }
q6018
parseSchemaInfo
train
function parseSchemaInfo(resultset) { for (var i = 0; i < resultset.rs.rows.length; i++) { var row = resultset.rs.rows.item(i); if (row.name.indexOf('sqlite_autoindex') > -1 || row.name == '__WebKitDatabaseInfoTable__') continue; if (row.type == 'table') { ...
javascript
{ "resource": "" }
q6019
createTables
train
function createTables() { return Promise.all(Object.keys(CRUD.EntityManager.entities).map(function(entityName) { var entity = CRUD.EntityManager.entities[entityName]; if (tables.indexOf(entity.table) == -1) { if (!entity.createStatement) { ...
javascript
{ "resource": "" }
q6020
createIndexes
train
function createIndexes() { // create listed indexes if they don't already exist. return Promise.all(Object.keys(CRUD.EntityManager.entities).map(function(entityName) { var entity = CRUD.EntityManager.entities[entityName]; if (('indexes' in entity)) { ...
javascript
{ "resource": "" }
q6021
createFixtures
train
function createFixtures(entity) { return new Promise(function(resolve, reject) { if (!entity.fixtures) return resolve(); return Promise.all(entity.fixtures.map(function(fixture) { CRUD.fromCache(entity.getType(), fixture).Persist(true); })).then(resolve, rejec...
javascript
{ "resource": "" }
q6022
train
function(field, def) { var ret; if (field in this.__dirtyValues__) { ret = this.__dirtyValues__[field]; } else if (field in this.__values__) { ret = this.__values__[field]; } else if (CRUD.EntityManager.entities[this.getType()].fields.indexOf(field) > -1) { ...
javascript
{ "resource": "" }
q6023
Route
train
function Route(path, fns, options) { options = options || {}; this.path = path; this.fns = fns; this.regexp = pathRegexp(path, this.keys = [], options); }
javascript
{ "resource": "" }
q6024
buildFile
train
function buildFile() { var reader = readline.createInterface({ input: fs.createReadStream(path.resolve("./src/assets/template.html")) }); var lines = []; reader.on("line", line => lines.push(line)); return new Promise(resolve => { reader.on("close", () => resolve(buildJsFileCon...
javascript
{ "resource": "" }
q6025
train
function(moveBack) { return new Promise(function(resolve, reject) { exec(resolve, reject, APP_PLUGIN_NAME, "minimizeApp", [moveBack || false]); }); }
javascript
{ "resource": "" }
q6026
train
function(packageName, componentName) { return new Promise(function(resolve, reject) { exec(resolve, reject, APP_PLUGIN_NAME, "startApp", [packageName, componentName]); }); }
javascript
{ "resource": "" }
q6027
promisePrompt
train
function promisePrompt(questions) { return new Promise(function(resolve, reject) { inquirer.prompt(questions, function(results) { resolve(results); }); }); }
javascript
{ "resource": "" }
q6028
buildJsFileContent
train
function buildJsFileContent(lines) { var ls = lines .map(l => l // remove space at beginning of line .replace(/^\s*/g, "") // remove space at end of line .replace(/\s*$/g, "") // convert \ to \\ .replace(/\\/g, "\\\\") // co...
javascript
{ "resource": "" }
q6029
train
function(done, promise, expectedState, expectedData, isNegative) { function verify(promiseState) { return function(data) { var test = verifyState(promiseState, expectedState); if (test.pass) { test = verifyData(data, expectedData); } if (!test.pass && !isNegative) {...
javascript
{ "resource": "" }
q6030
train
function(class_data, path) { var implements_source = this._sources[path], name, references_offset; if (Lava.schema.DEBUG) { if (!implements_source) Lava.t('Implements: class not found - "' + path + '"'); for (name in implements_source.shared) Lava.t("Implements: unable to use a class with Shared as m...
javascript
{ "resource": "" }
q6031
train
function(class_data, source_object, is_root) { var name, skeleton = {}, value, type, skeleton_value; for (name in source_object) { if (is_root && (this._reserved_members.indexOf(name) != -1 || (name in class_data.shared))) { continue; } value = source_object[name]; type = Firestorm...
javascript
{ "resource": "" }
q6032
train
function(skeleton, class_data, padding, serialized_properties) { var name, serialized_value, uses_references = false, object_properties; for (name in skeleton) { switch (skeleton[name].type) { case this.MEMBER_TYPES.STRING: serialized_value = Firestorm.String.quote(skeleton[name].value); ...
javascript
{ "resource": "" }
q6033
train
function(path_segments) { var namespace, segment_name, count = path_segments.length, i = 1; if (!count) Lava.t("ClassManager: class names must include a namespace, even for global classes."); if (!(path_segments[0] in this._root)) Lava.t("[ClassManager] namespace is not registered: " + path_segments[0]...
javascript
{ "resource": "" }
q6034
train
function(class_path, default_namespace) { if (!(class_path in this.constructors) && default_namespace) { class_path = default_namespace + '.' + class_path; } return this.constructors[class_path]; }
javascript
{ "resource": "" }
q6035
train
function(data) { var tempResult = [], i = 0, count = data.length, type, value; for (; i < count; i++) { type = Firestorm.getType(data[i]); switch (type) { case 'string': value = Firestorm.String.quote(data[i]); break; case 'null': case 'undefined': case 'boolean': ...
javascript
{ "resource": "" }
q6036
train
function(class_data) { var skeleton = class_data.skeleton, name, serialized_value, serialized_actions = [], is_polymorphic = !class_data.is_monomorphic; for (name in skeleton) { switch (skeleton[name].type) { case this.MEMBER_TYPES.REGEXP: case this.MEMBER_TYPES.FUNCTION: serialized_v...
javascript
{ "resource": "" }
q6037
train
function(class_datas) { for (var i = 0, count = class_datas.length; i <count; i++) { this.loadClass(class_datas[i]); } }
javascript
{ "resource": "" }
q6038
train
function(class_data) { var class_path = class_data.path, namespace_path, class_name, namespace; if ((class_path in this._sources) || (class_path in this.constructors)) Lava.t("Class is already defined: " + class_path); this._sources[class_path] = class_data; if (class_data.constructor) { namespa...
javascript
{ "resource": "" }
q6039
train
function(base_path, suffix) { if (Lava.schema.DEBUG && !(base_path in this._sources)) Lava.t("[getPackageConstructor] Class not found: " + base_path); var path, current_class = this._sources[base_path], result = null; do { path = current_class.path + suffix; if (path in this.constructors) { r...
javascript
{ "resource": "" }
q6040
$$core$$ResolveLocale
train
function /* 9.2.5 */$$core$$ResolveLocale (availableLocales, requestedLocales, options, relevantExtensionKeys, localeData) { if (availableLocales.length === 0) { throw new ReferenceError('No locale data has been provided for this object yet.'); } // The following steps are taken: ...
javascript
{ "resource": "" }
q6041
$$core$$GetOption
train
function /*9.2.9 */$$core$$GetOption (options, property, type, values, fallback) { var // 1. Let value be the result of calling the [[Get]] internal method of // options with argument property. value = options[property]; // 2. If value is not undefined, then ...
javascript
{ "resource": "" }
q6042
$$core$$GetNumberOption
train
function /* 9.2.10 */$$core$$GetNumberOption (options, property, minimum, maximum, fallback) { var // 1. Let value be the result of calling the [[Get]] internal method of // options with argument property. value = options[property]; // 2. If value is not undefined...
javascript
{ "resource": "" }
q6043
$$core$$calculateScore
train
function $$core$$calculateScore (options, formats, bestFit) { var // Additional penalty type when bestFit === true diffDataTypePenalty = 8, // 1. Let removalPenalty be 120. removalPenalty = 120, // 2. Let additionPenalty be 20. additionPenalty = 20, ...
javascript
{ "resource": "" }
q6044
$$core$$resolveDateString
train
function $$core$$resolveDateString(data, ca, component, width, key) { // From http://www.unicode.org/reports/tr35/tr35.html#Multiple_Inheritance: // 'In clearly specified instances, resources may inherit from within the same locale. // For example, ... the Buddhist calendar inherits from the Gr...
javascript
{ "resource": "" }
q6045
$$core$$createRegExpRestore
train
function $$core$$createRegExpRestore () { var esc = /[.?*+^$[\]\\(){}|-]/g, lm = RegExp.lastMatch || '', ml = RegExp.multiline ? 'm' : '', ret = { input: RegExp.input }, reg = new $$core$$List(), has = false, cap = {}; // Create ...
javascript
{ "resource": "" }
q6046
$$core$$toLatinUpperCase
train
function $$core$$toLatinUpperCase (str) { var i = str.length; while (i--) { var ch = str.charAt(i); if (ch >= "a" && ch <= "z") str = str.slice(0, i) + ch.toUpperCase() + str.slice(i+1); } return str; }
javascript
{ "resource": "" }
q6047
PersistInNode
train
function PersistInNode(n) { RED.nodes.createNode(this,n); var node = this; node.name = n.name; node.storageNode = RED.nodes.getNode(n.storageNode); node.on("input", function(msg) { node.storageNode.store(node.name, msg); }); }
javascript
{ "resource": "" }
q6048
PersistOutNode
train
function PersistOutNode(n) { RED.nodes.createNode(this,n); var node = this; node.name = n.name; node.storageNode = RED.nodes.getNode(n.storageNode); node.restore = function() { var msg = node.storageNode.getMessage(node.name); node.send(msg); }; ...
javascript
{ "resource": "" }
q6049
isMethodCall
train
function isMethodCall(node) { var nodeParentType = node.parent.type, nodeParentParentParentType = node.parent.parent.parent.type; if (nodeParentType === "CallExpression" && nodeParentParentParentType === "BlockStatement" && !variable) { ...
javascript
{ "resource": "" }
q6050
broadcast
train
function broadcast (subscriptions, type) { return value => { subscriptions.forEach(s => { if (typeof s.emit[type] === 'function') { s.emit[type](value) } }) } }
javascript
{ "resource": "" }
q6051
train
function (){ var outputPropertyName, callback, inputPropertyNames, inputs, output; if(arguments.length === 0){ return configurationProperty(); } else if(arguments.length === 1){ if(typeof arguments[0] === "object"){ // The invocation is of the form mode...
javascript
{ "resource": "" }
q6052
addProperty
train
function addProperty(propertyName, defaultValue){ if(model[propertyName]){ throw new Error("The property \"" + propertyName + "\" is already defined."); } var property = ReactiveProperty(defaultValue); property.propertyName = propertyName; model[propertyName] = property; lastPropertyAdde...
javascript
{ "resource": "" }
q6053
expose
train
function expose(){ // TODO test this // if(!isDefined(defaultValue)){ // throw new Error("model.addPublicProperty() is being " + // "invoked with an undefined default value. Default values for exposed properties " + // "must be defined, to guarantee predictable behavior. For exposed properti...
javascript
{ "resource": "" }
q6054
destroy
train
function destroy(){ // Destroy reactive functions. reactiveFunctions.forEach(invoke("destroy")); if(configurationReactiveFunction){ configurationReactiveFunction.destroy(); } // Destroy properties (removes listeners). Object.keys(model).forEach(function (propertyName){ var ...
javascript
{ "resource": "" }
q6055
tiler
train
function tiler(root, options) { this.root = root; options = options || {}; options.packSize = options.packSize || 128; if (!options.storageFormat) { options.storageFormat = guessStorageFormat(root); } this.options = options; }
javascript
{ "resource": "" }
q6056
train
function (id, type) { if (this.state.sourcePageID !== id) { var selectedPage; this.state.pages.forEach(function (page) { if (parseInt(page.id, 10) === parseInt(id, 10)) { selectedPage = page; } }); if (!selectedPage) { console.warn('Page not found.'); ...
javascript
{ "resource": "" }
q6057
appendDirEnd
train
function appendDirEnd(str, struct) { if (!struct.block) { return str; } const [rightSpace] = rightWSRgxp.exec(str); str = str.replace(rightPartRgxp, ''); const s = alb + lb, e = rb; let tmp; if (needSpace) { tmp = `${struct.trim.right ? '' : eol}${endDirInit ? '' : `${s}__&+__${e}`}${struct.trim.right...
javascript
{ "resource": "" }
q6058
train
function() { var fonts = ["Roboto", "Bitter", "Pacifico"]; var options = fonts.map(name => { // setting style on an <option> does not work in WebView... return <option key={name} value={name}>{name}</option>; }); return <select className="select" valueLink={this.linkState('fontFamily')}>{ op...
javascript
{ "resource": "" }
q6059
callback
train
function callback(fn, context, event) { //window.setTimeout(function(){ event.target = context; (typeof context[fn] === "function") && context[fn].apply(context, [event]); //}, 1); }
javascript
{ "resource": "" }
q6060
polyfill
train
function polyfill() { if (navigator.userAgent.match(/MSIE/) || navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/Edge/)) { // Internet Explorer's native IndexedDB does not support compound keys compoundKeyPolyfill(); } }
javascript
{ "resource": "" }
q6061
readBlobAsDataURL
train
function readBlobAsDataURL(blob, path) { var reader = new FileReader(); reader.onloadend = function(loadedEvent) { var dataURL = loadedEvent.target.result; var blobtype = 'Blob'; if (blob instanceof File...
javascript
{ "resource": "" }
q6062
updateEncodedBlob
train
function updateEncodedBlob(dataURL, path, blobtype) { var encoded = queuedObjects.indexOf(path); path = path.replace('$','derezObj'); eval(path+'.$enc="'+dataURL+'"'); eval(path+'.$type="'+blobtype+'"'); queuedObjec...
javascript
{ "resource": "" }
q6063
dataURLToBlob
train
function dataURLToBlob(dataURL) { var BASE64_MARKER = ';base64,', contentType, parts, raw; if (dataURL.indexOf(BASE64_MARKER) === -1) { parts = dataURL.split(','); ...
javascript
{ "resource": "" }
q6064
train
function(key) { var key32 = Math.abs(key).toString(32); // Get the index of the decimal. var decimalIndex = key32.indexOf("."); // Remove the decimal. key32 = (decimalIndex !== -1) ? key32.replace(".", "") : key32; // ...
javascript
{ "resource": "" }
q6065
train
function(key) { var sign = +key.substr(2, 1); var exponent = key.substr(3, 2); var mantissa = key.substr(5, 11); switch (signValues[sign]) { case "negativeInfinity": return -Infinity; ...
javascript
{ "resource": "" }
q6066
flipBase32
train
function flipBase32(encoded) { var flipped = ""; for (var i = 0; i < encoded.length; i++) { flipped += (31 - parseInt(encoded[i], 32)).toString(32); } return flipped; }
javascript
{ "resource": "" }
q6067
validate
train
function validate(key) { var type = getType(key); if (type === "array") { for (var i = 0; i < key.length; i++) { validate(key[i]); } } else if (!types[type] || (type !== "string" && isNaN(key))) { throw idbModules.util.createDOM...
javascript
{ "resource": "" }
q6068
getValue
train
function getValue(source, keyPath) { try { if (keyPath instanceof Array) { var arrayValue = []; for (var i = 0; i < keyPath.length; i++) { arrayValue.push(eval("source." + keyPath[i])); } return arrayValue; ...
javascript
{ "resource": "" }
q6069
setValue
train
function setValue(source, keyPath, value) { var props = keyPath.split('.'); for (var i = 0; i < props.length - 1; i++) { var prop = props[i]; source = source[prop] = source[prop] || {}; } source[props[props.length - 1]] = value; }
javascript
{ "resource": "" }
q6070
isMultiEntryMatch
train
function isMultiEntryMatch(encodedEntry, encodedKey) { var keyType = collations[encodedKey.substring(0, 1)]; if (keyType === "array") { return encodedKey.indexOf(encodedEntry) > 1; } else { return encodedKey === encodedEntry; } }
javascript
{ "resource": "" }
q6071
createNativeEvent
train
function createNativeEvent(type, debug) { var event = new Event(type); event.debug = debug; // Make the "target" writable Object.defineProperty(event, 'target', { writable: true }); return event; }
javascript
{ "resource": "" }
q6072
ShimEvent
train
function ShimEvent(type, debug) { this.type = type; this.debug = debug; this.bubbles = false; this.cancelable = false; this.eventPhase = 0; this.timeStamp = new Date().valueOf(); }
javascript
{ "resource": "" }
q6073
createNativeDOMException
train
function createNativeDOMException(name, message) { var e = new DOMException.prototype.constructor(0, message); e.name = name || 'DOMException'; e.message = message; return e; }
javascript
{ "resource": "" }
q6074
createNativeDOMError
train
function createNativeDOMError(name, message) { name = name || 'DOMError'; var e = new DOMError(name, message); e.name === name || (e.name = name); e.message === message || (e.message = message); return e; }
javascript
{ "resource": "" }
q6075
createError
train
function createError(name, message) { var e = new Error(message); e.name = name || 'DOMException'; e.message = message; return e; }
javascript
{ "resource": "" }
q6076
createSysDB
train
function createSysDB(success, failure) { function sysDbCreateError(tx, err) { err = idbModules.util.findError(arguments); idbModules.DEBUG && console.log("Error in sysdb transaction - when creating dbVersions", err); failure(err); } if (sysdb) { ...
javascript
{ "resource": "" }
q6077
train
function(args) { if (!args.src) { ret = new Error('metalsmith-convert: "src" arg is required'); return; } if (!args.target) { // use source-format for target in convertFile args.target = '__source__'; } var ext = args.extension || '.' + args.target; if (!arg...
javascript
{ "resource": "" }
q6078
timedLog
train
function timedLog(msg) { console.log(Date.now() + ":" + window.performance.now() + ": " + msg); }
javascript
{ "resource": "" }
q6079
train
function(evt) { evt.preventDefault(); evt.stopPropagation(); // Calculate actual height of element so we can calculate bounds properly positionable.rect = positionable.refs.styleWrapper.getBoundingClientRect(); if (debug) { timedLog("startmark"); } if(!evt.touches || ev...
javascript
{ "resource": "" }
q6080
train
function(evt) { if (debug) { timedLog("endmark"); } if(evt.touches && evt.touches.length > 0) { if (handlers.endSecondFinger(evt)) { return; } } if (debug) { timedLog("endmark - continued"); } mark = copy(positionable.state); var modified =...
javascript
{ "resource": "" }
q6081
train
function(evt) { evt.preventDefault(); evt.stopPropagation(); if (debug) { timedLog("secondFinger"); } if (evt.touches.length < 2) { return; } // we need to rebind finger 1, because it may have moved! transform.x1 = evt.touches[0].pageX; transform...
javascript
{ "resource": "" }
q6082
train
function(evt) { evt.preventDefault(); evt.stopPropagation(); if (debug) { timedLog("endSecondFinger"); } if (evt.touches.length > 1) { if (debug) { timedLog("endSecondFinger - capped"); } return true; } if (debug) { timedLog("endSecondFinger - continue...
javascript
{ "resource": "" }
q6083
tryFormat
train
function tryFormat(body) { try { const parsed = typeof body === 'string' ? JSON.parse(body) : body return JSON.stringify(parsed, null, 2) } catch (err) { return body } }
javascript
{ "resource": "" }
q6084
formatReport
train
function formatReport() { // eslint-disable-line no-unused-vars const lineCoverage = new LineCoverage(2, 2, [ new LineData(6, 2, 'PF4Rz2r7RTliO9u6bZ7h6g'), new LineData(7, 2, 'yGMB6FhEEAd8OyASe3Ni1w') ]); const record = new Record('/home/cedx/lcov.js/fixture.js', { functions: new FunctionCoverage(1, ...
javascript
{ "resource": "" }
q6085
parseReport
train
async function parseReport() { // eslint-disable-line no-unused-vars try { const coverage = await promises.readFile('lcov.info', 'utf8'); const report = Report.fromCoverage(coverage); console.log(`The coverage report contains ${report.records.length} records:`); console.log(report.toJSON()); } ca...
javascript
{ "resource": "" }
q6086
range
train
function range(from, to) { // TODO: make this inlined. const list = new Array(to - from + 1); for (let i = 0; i < list.length; i += 1) { list[i] = from + i; } return list; }
javascript
{ "resource": "" }
q6087
setupBrowserStorage
train
function setupBrowserStorage(){ if(browser || storageMock){ if(storageMock){ store = storageMock; storageKey = 'cache-module-storage-mock'; } else{ var storageType = (config.storage === 'local' || config.storage === 'session') ? config.storage : null; store = (stora...
javascript
{ "resource": "" }
q6088
overwriteBrowserStorage
train
function overwriteBrowserStorage(){ if((browser && store) || storageMock){ var db = cache; try { db = JSON.stringify(db); store.setItem(storageKey, db); } catch (err) { /* Do nothing */ } } }
javascript
{ "resource": "" }
q6089
handleRefreshResponse
train
function handleRefreshResponse (key, data, err, response) { if(!err) { this.set(key, response, (data.lifeSpan / 1000), data.refresh, function(){}); } }
javascript
{ "resource": "" }
q6090
log
train
function log(isError, message, data){ if(self.verbose || isError){ if(data) console.log(self.type + ': ' + message, data); else console.log(self.type + message); } }
javascript
{ "resource": "" }
q6091
WebRequest
train
function WebRequest (options, callback) { request(options, function (err, response, body) { if (err) { return callback(err); } callback(null, body); }); }
javascript
{ "resource": "" }
q6092
train
function(options) { var out = this.formatEmpty(), data = [], rels; this.init(); options = (options)? options : {}; this.mergeOptions(options); this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ this.errors.push(this.noCon...
javascript
{ "resource": "" }
q6093
train
function(node, options) { this.init(); options = (options)? options : {}; if(node){ return this.getParentTreeWalk(node, options); }else{ this.errors.push(this.noContentErr); return this.formatError(); } }
javascript
{ "resource": "" }
q6094
train
function( options ) { var out = {}, items, classItems, x, i; this.init(); options = (options)? options : {}; this.getDOMContext( options ); // if we do not have any context create error if(!this.rootNode || !this.document){ return {'errors': [this.noContentErr]}; }else{ i...
javascript
{ "resource": "" }
q6095
train
function( node, options ) { var classes, i; if(!node){ return false; } // if documemt gets topmost node node = modules.domUtils.getTopMostNode( node ); // look for h-* microformats classes = this.getUfClassNames(node); if(options && options.filters && modules.utils.isArray(options.fil...
javascript
{ "resource": "" }
q6096
train
function( node, options ) { var items, i; if(!node){ return false; } // if browser based documemt get topmost node node = modules.domUtils.getTopMostNode( node ); // returns all microformat roots items = this.findRootNodes( node, true ); if(options && options.filters && modules.utils....
javascript
{ "resource": "" }
q6097
train
function( maps ){ maps.forEach(function(map){ if(map && map.root && map.name && map.properties){ modules.maps[map.name] = JSON.parse(JSON.stringify(map)); } }); }
javascript
{ "resource": "" }
q6098
train
function (node, options, recursive) { options = (options)? options : {}; // recursive calls if (recursive === undefined) { if (node.parentNode && node.nodeName !== 'HTML'){ return this.getParentTreeWalk(node.parentNode, options, true); }else{ return this.formatEmpt...
javascript
{ "resource": "" }
q6099
train
function( options ){ var baseTag, href; // use current document to define baseUrl, try/catch needed for IE10+ error try { if (!options.baseUrl && this.document && this.document.location) { this.options.baseUrl = this.document.location.href; ...
javascript
{ "resource": "" }