_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q34600
UI
train
function UI(options) { if (!(this instanceof UI)) { var ui = Object.create(UI.prototype); UI.apply(ui, arguments); return ui; } debug('initializing from <%s>', __filename); this.options = utils.createOptions(options); this.appendedLines = 0; this.height = 0; this.initInterface(); }
javascript
{ "resource": "" }
q34601
train
function(crontab) { let _config = this[$EXTRA]; _config.logger.info(`Setting up cron schedule ${crontab}`); _config.job = new CronJob({ cronTime: crontab, onTick: _.bind(co.wrap(this._cronCallback), this), start: true, }); /* calculate and save time between runs */ ...
javascript
{ "resource": "" }
q34602
arraysAppendUniqueAdapter
train
function arraysAppendUniqueAdapter(to, from, merge) { // transfer actual values from.reduce(function(target, value) { // append only if new element isn't present yet if (target.indexOf(value) == -1) { target.push(merge(undefined, value)); } return target; }, to); return to; }
javascript
{ "resource": "" }
q34603
fieldPicker
train
function fieldPicker(fields) { var map = {}; if (fields instanceof Array) { fields.forEach(function(f) { map[f] = f; }); } else if (typeof fields === 'object') { for (var key in fields) { map[key] = fields[key]; } } return function(input, output) { var target = output || input; for...
javascript
{ "resource": "" }
q34604
splitOnce
train
function splitOnce(str, character) { const i = str.indexOf(character); return [ str.slice(0, i), str.slice(i+1) ]; }
javascript
{ "resource": "" }
q34605
getRndColor
train
function getRndColor() { const r = (255 * Math.random()) | 0, g = (255 * Math.random()) | 0, b = (255 * Math.random()) | 0; return "rgb(" + r + "," + g + "," + b + ")"; }
javascript
{ "resource": "" }
q34606
getDependencies
train
function getDependencies(component, Prism) { // Cast require to an Array const deps = [].concat(component.require || []); if (Prism) { return deps.filter( dep => // Remove dependencies that are already loaded !Prism.languages[dep] ); } ret...
javascript
{ "resource": "" }
q34607
clean
train
function clean(done) { var del = require('del'); del(cfg.destination).then(function () { if (typeof done === 'function') done(); else process.exit(); }); }
javascript
{ "resource": "" }
q34608
serve
train
function serve() { var browserSync = require('browser-sync'); browserSync({ server: { baseDir: cfg.destination }, ui: false, online: false, open: false, minify: false }); gulp.watch(['*'], {cwd: cfg.destination}).on('change', browserSync.reload); }
javascript
{ "resource": "" }
q34609
train
function(type, obj) { switch (type) { case 'greet': var name = _.get(obj, 'profile.displayName') || _.get(obj, 'username', '') || obj; return _.get(name, 'length') ? name : 'Hey'; break; } return obj; }
javascript
{ "resource": "" }
q34610
createSlicer
train
function createSlicer(version) { if (version !== undefined) { // For invalidation. var currentVersion = localStorage.getItem(LS_VERSION_KEY); if (version > currentVersion) { localStorage.removeItem('redux'); localStorage.setItem(LS_VERSION_KEY, version); } } return function (paths) { ...
javascript
{ "resource": "" }
q34611
idx2pos
train
function idx2pos(idx, prelen, linelen) { prelen = prelen || 0; linelen = linelen || 50; idx = Number(idx); return Math.max(0, idx - prelen - Math.floor((idx - prelen)/(linelen + 1))) + 1; }
javascript
{ "resource": "" }
q34612
string2Boolean
train
function string2Boolean (string, defaultTrue) { // console.log('2bool:', String(string).toLowerCase()); switch (String(string).toLowerCase()) { case '': return (defaultTrue === undefined) ? false : defaultTrue; case 'true': case '1': case 'yes': case 'y': return true; case 'false...
javascript
{ "resource": "" }
q34613
calculateUpdate
train
function calculateUpdate(currentSelection, currentValue, newValue) { var currentCursor = currentSelection.start, newCursor = currentCursor, diff = newValue.length - currentValue.length, idx; var lengthDelta = newValue.length - currentValue.length; var currentTail = currentValue.substring(curr...
javascript
{ "resource": "" }
q34614
buildNativeCoClientBuilder
train
function buildNativeCoClientBuilder(clientBuilder) { return function nativeCoClientBuilder(config) { var connection = clientBuilder(config); connection.connectAsync = promissory(connection.connect); connection.queryAsync = promissory(connection.query); // for backwards compatibility connection.connectPromi...
javascript
{ "resource": "" }
q34615
BuildbotPoller
train
function BuildbotPoller(options, interval) { Poller.call(this, 'buildbot', options, interval); this._host = this._options['host']; this._port = this._options['port']; this._username = this._options['username']; this._password = this._options['password']; this._numBuilds = this._options['num_builds']; th...
javascript
{ "resource": "" }
q34616
MongoStore
train
function MongoStore(options) { options = options || {}; for (var property in defaultOptions) { if (defaultOptions.hasOwnProperty(property)) { if (!options.hasOwnProperty(property) || (typeof defaultOptions[property] !== typeof options[property])) options[...
javascript
{ "resource": "" }
q34617
train
function(e) { var stack = e.stacktrace; var lines = stack.split('\n'), ANON = '{anonymous}', lineRE = /.*line (\d+), column (\d+) in ((<anonymous function\:?\s*(\S+))|([^\(]+)\([^\)]*\))(?: in )?(.*)\s*$/i, i, j, len; for (i = 2, j = 0, len = lines.length; i < len - 2; i++) { if (lin...
javascript
{ "resource": "" }
q34618
train
function(e) { var lines = e.message.split('\n'), ANON = '{anonymous}', lineRE = /Line\s+(\d+).*script\s+(http\S+)(?:.*in\s+function\s+(\S+))?/i, i, j, len; for (i = 4, j = 0, len = lines.length; i < len; i += 2) { //TODO: RegExp.exec() would probably be cleaner here if (lineRE.t...
javascript
{ "resource": "" }
q34619
train
function(curr) { var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], fn, args, maxStackSize = 10; while (curr && stack.length < maxStackSize) { fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON; args = Array.prototype.slice.call(curr['arguments']...
javascript
{ "resource": "" }
q34620
train
function(args) { for (var i = 0; i < args.length; ++i) { var arg = args[i]; if (arg === undefined) { args[i] = 'undefined'; } else if (arg === null) { args[i] = 'null'; } else if (arg.constructor) { if (arg.construct...
javascript
{ "resource": "" }
q34621
arrayHasValue
train
function arrayHasValue(arr, value) { var idx = arr.indexOf(value); if (idx !== -1) { return true; } return false; }
javascript
{ "resource": "" }
q34622
getTextNodes
train
function getTextNodes(el) { el = el || document.body var doc = el.ownerDocument || document , walker = doc.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false) , textNodes = [] , node while (node = walker.nextNode()) { textNodes.push(node) } return textNodes }
javascript
{ "resource": "" }
q34623
rangesIntersect
train
function rangesIntersect(rangeA, rangeB) { return rangeA.compareBoundaryPoints(Range.END_TO_START, rangeB) === -1 && rangeA.compareBoundaryPoints(Range.START_TO_END, rangeB) === 1 }
javascript
{ "resource": "" }
q34624
createRangeFromNode
train
function createRangeFromNode(node) { var range = node.ownerDocument.createRange() try { range.selectNode(node) } catch (e) { range.selectNodeContents(node) } return range }
javascript
{ "resource": "" }
q34625
rangeIntersectsNode
train
function rangeIntersectsNode(range, node) { if (range.intersectsNode) { return range.intersectsNode(node) } else { return rangesIntersect(range, createRangeFromNode(node)) } }
javascript
{ "resource": "" }
q34626
getRangeTextNodes
train
function getRangeTextNodes(range) { var container = range.commonAncestorContainer , nodes = getTextNodes(container.parentNode || container) return nodes.filter(function (node) { return rangeIntersectsNode(range, node) && isNonEmptyTextNode(node) }) }
javascript
{ "resource": "" }
q34627
replaceNode
train
function replaceNode(replacementNode, node) { remove(replacementNode) node.parentNode.insertBefore(replacementNode, node) remove(node) }
javascript
{ "resource": "" }
q34628
unwrap
train
function unwrap(el) { var range = document.createRange() range.selectNodeContents(el) replaceNode(range.extractContents(), el) }
javascript
{ "resource": "" }
q34629
undo
train
function undo(nodes) { nodes.forEach(function (node) { var parent = node.parentNode unwrap(node) parent.normalize() }) }
javascript
{ "resource": "" }
q34630
createWrapperFunction
train
function createWrapperFunction(wrapperEl, range) { var startNode = range.startContainer , endNode = range.endContainer , startOffset = range.startOffset , endOffset = range.endOffset return function wrapNode(node) { var currentRange = document.createRange() , currentWrapper = wrapperE...
javascript
{ "resource": "" }
q34631
Message
train
function Message(data, source){ source = source || {} this.data = data this.key = source.key this.sourceChannel = source.name }
javascript
{ "resource": "" }
q34632
train
function(options, content, res) { return function (/*function*/ callback) { // create the post data to send to the User Modeling service var post_data = { 'contentItems' : [{ 'userid' : 'dummy', 'id' : 'dummyUuid', 'sourceid' : 'freetext', 'contenttype' : 'text/plain', ...
javascript
{ "resource": "" }
q34633
train
function(name) { try { debug(`Loading ${name} configuration`); return waigo.load(`config/${name}`); } catch (e) { debug(`Error loading config: ${name}`); debug(e); return null; } }
javascript
{ "resource": "" }
q34634
train
function (destPath, srcPaths, options) { let stream, b, finalPaths = []; return new Promise(function (resolve, reject) { _.each(srcPaths, function (path) { // deal with file globs if (glob.hasMagic(path)) { glob.sync(path).forEach((p) => { ...
javascript
{ "resource": "" }
q34635
train
function (stream, destPath) { let data = ''; return new Promise(function (resolve, reject) { stream.on('error', reject); stream.on('data', function (d) { data += d.toString(); }); stream.on('end', function () { fs.outputFile(destPath, data, function (err) ...
javascript
{ "resource": "" }
q34636
fillMatrix
train
function fillMatrix(id, t, l, w, h) { for (var y = t; y < t + h;) { for (var x = l; x < l + w;) { matrix[y + '-' + x] = id; ++x > maxX && (maxX = x); } ++y > maxY && (maxY = y); } ...
javascript
{ "resource": "" }
q34637
json2jison
train
function json2jison (grammar, options) { options = options || {}; var s = ""; s += genDecls(grammar, options); s += genBNF(grammar.bnf, options); return s; }
javascript
{ "resource": "" }
q34638
genLex
train
function genLex (lex) { var s = []; if (lex.macros) { for (var macro in lex.macros) if (lex.macros.hasOwnProperty(macro)) { s.push(macro, ' ', lex.macros[macro], '\n'); } } if (lex.actionInclude) { s.push('\n%{\n', lex.actionInclude, '\n%}\n'); } s.pu...
javascript
{ "resource": "" }
q34639
fsReaddirSync
train
function fsReaddirSync(root, files, fp) { if (typeof root !== 'string') { throw new TypeError('fsReaddir.sync: expect `root` to be string'); } fp = fp || ''; files = files || []; var dir = path.join(root, fp); if (fs.statSync(dir).isDirectory()) { fs.readdirSync(dir).forEach(function(name) { ...
javascript
{ "resource": "" }
q34640
copyFileIntoDirectory
train
function copyFileIntoDirectory(srcPath, destPath) { return ensureDestinationDirectory(destPath).then(function () { return new Promise(function (resolve, reject) { fs.readFile(srcPath, 'utf8', function (err, contents) { if (!err) { resolve()...
javascript
{ "resource": "" }
q34641
copyFile
train
function copyFile(srcPath, destPath) { let srcFileInfo = path.parse(srcPath) || {}; if (!path.extname(destPath) && srcFileInfo.ext) { // destination is a directory! return copyFileIntoDirectory(srcPath, destPath); } else { return new Promise(function (resolve,...
javascript
{ "resource": "" }
q34642
getSourceDestinationPath
train
function getSourceDestinationPath (srcPath) { let dests = _.keys(options.files); return _.find(dests, function (destPath) { let paths = options.files[destPath]; return _.find(paths, function (p) { return p === srcPath || srcPath.indexOf(p) !== -1; }); ...
javascript
{ "resource": "" }
q34643
train
function (tx) { var outs = []; tx.outputs.forEach(function (o) { outs.push(new TransactionOutput(o.satoshis,o.script.toBuffer())); }); return outs; }
javascript
{ "resource": "" }
q34644
filterTitle
train
function filterTitle(posts) { var reTitle = title.map(function makeRE(word) { return new RegExp(word, 'i'); }); return posts.filter(function filterPosts(post) { return reTitle.every(function checkRE(regex) { return regex.test(post.title) || regex.test(post.slug); });...
javascript
{ "resource": "" }
q34645
filterFolder
train
function filterFolder(posts) { var reFolder = new RegExp(folder); return posts.filter(function filterPosts(post) { return reFolder.test(post.source.substr(0, post.source.lastIndexOf(path.sep))); }); }
javascript
{ "resource": "" }
q34646
filterTag
train
function filterTag(posts) { var reTag = new RegExp(tag); return posts.filter(function filterPosts(post) { return post.tags.data.some(function checkRe(postTag) { return reTag.test(postTag.name); }); }); }
javascript
{ "resource": "" }
q34647
filterCategory
train
function filterCategory(posts) { var reCat = new RegExp(cat); return posts.filter(function filterPosts(post) { return post.categories.data.some(function checkRe(postCat) { return reCat.test(postCat.name); }); }); }
javascript
{ "resource": "" }
q34648
filterLayout
train
function filterLayout(posts) { var reLayout = new RegExp(layout, 'i'); return posts.filter(function filterPosts(post) { return reLayout.test(post.layout); }); }
javascript
{ "resource": "" }
q34649
filterBefore
train
function filterBefore(posts) { before = moment(before.replace(/\//g, '-'), 'MM-DD-YYYY', true); if (!before.isValid()) { console.log(chalk.red('Before date is not valid (expecting `MM-DD-YYYY`), ignoring argument.')); return posts; } return posts.filter(function filterPosts(post...
javascript
{ "resource": "" }
q34650
filterAfter
train
function filterAfter(posts) { after = moment(after.replace(/\//g, '-'), 'MM-DD-YYYY', true); if (!after.isValid()) { console.log(chalk.red('After date is not valid (expecting `MM-DD-YYYY`), ignoring argument.')); return posts; } return posts.filter(function filterPosts(post) { ...
javascript
{ "resource": "" }
q34651
openFile
train
function openFile(file) { var edit; if (!editor || gui) { open(file); } else { edit = spawn(editor, [file], {stdio: 'inherit'}); edit.on('exit', process.exit); } }
javascript
{ "resource": "" }
q34652
Bitid
train
function Bitid(params) { params = params || {}; var self = this; this._nonce = params.nonce; this.callback = url.parse(params.callback, true); this.signature = params.signature; this.address = params.address; this.unsecure = params.unsecure; this._uri = !params.uri ? buildURI() : url.parse(params.uri, ...
javascript
{ "resource": "" }
q34653
getPresetsString
train
function getPresetsString(presetArray) { if (!presetArray.includes("react-app")) { presetArray.push("react-app"); } return presetArray.map(attachRequestResolve("preset")).join(","); }
javascript
{ "resource": "" }
q34654
connect
train
function connect(obj, cb) { if (obj.db) { return cb(); } if (obj.pending) { return setImmediate(function () { connect(obj, cb); }); } obj.pending = true; var url = constructMongoLink(obj.config.name, obj.config.prefix, obj.config.servers, obj.config.URLParam,...
javascript
{ "resource": "" }
q34655
_SubRange
train
function _SubRange(low, high) { this.low = low; this.high = high; this.length = 1 + high - low; }
javascript
{ "resource": "" }
q34656
manageNginx
train
function manageNginx (action, callback) { // TODO: research if sending signals is better // i.e. sudo nginx -s stop|quit|reload exec(`sudo service nginx ${action}`, (err, stdout, stderr) => { if (err) return callback(err) return callback() }) }
javascript
{ "resource": "" }
q34657
Project
train
function Project(path) { path = path || PWD; this.root = ''; this.storage = ''; this.ignore = []; this.resolvePaths(path); }
javascript
{ "resource": "" }
q34658
train
function (module_name, module_folder) { var module_path = path.resolve(module_folder); // load current keystore let keystored = {}; const filename = ".iotdb/keystore.json"; _.cfg.load.json([ filename ], docd => keystored = _.d.compose.deep(keystored, docd.doc)); // change it _.d.set(keysto...
javascript
{ "resource": "" }
q34659
train
function (module_name, module_folder) { var iotdb_dir = path.join(process.cwd(), module_folder, "node_modules", "iotdb"); console.log("- cleanup"); console.log(" path:", iotdb_dir); try { _rmdirSync(iotdb_dir); } catch (x) { } }
javascript
{ "resource": "" }
q34660
train
function (module_name, module_folder, callback) { var module_folder = path.resolve(module_folder) var module_packaged = _load_package(module_folder); var module_dependencies = _.d.get(module_packaged, "/dependencies"); if (!module_dependencies) { return callback(); } module_dependencie...
javascript
{ "resource": "" }
q34661
train
function() { try { var statbuf = fs.statSync(folder); if (statbuf.isDirectory()) { return; } } catch (x) { } try { fs.mkdirSync("node_modules"); } catch (x) { } statbuf = fs.statSync(folder); if (statbuf.isDirectory()) { return; ...
javascript
{ "resource": "" }
q34662
readFile
train
function readFile(path, callback) { nodeFs.readFile(path, function (err, binary) { if (err) { if (err.code === "ENOENT") return callback(); return callback(err); } return callback(null, binary); }); }
javascript
{ "resource": "" }
q34663
readChunk
train
function readChunk(path, start, end, callback) { if (end < 0) { return readLastChunk(path, start, end, callback); } var stream = nodeFs.createReadStream(path, { start: start, end: end - 1 }); var chunks = []; stream.on("readable", function () { var chunk = stream.read(); if (chunk === nu...
javascript
{ "resource": "" }
q34664
readLastChunk
train
function readLastChunk(path, start, end, callback) { nodeFs.open(path, "r", function (err, fd) { if (err) { if (err.code === "EACCES") return callback(); return callback(err); } var buffer = new Buffer(4096); var length = 0; read(); // Only the first read needs to seek. // All ...
javascript
{ "resource": "" }
q34665
writeFile
train
function writeFile(path, binary, callback) { mkdirp(nodePath.dirname(path), function (err) { if (err) return callback(err); nodeFs.writeFile(path, binary, callback); }); }
javascript
{ "resource": "" }
q34666
rename
train
function rename(oldPath, newPath, callback) { var oldBase = nodePath.dirname(oldPath); var newBase = nodePath.dirname(newPath); if (oldBase === newBase) { return nodeFs.rename(oldPath, newPath, callback); } mkdirp(nodePath.dirname(path), function (err) { if (err) return callback(err); nodeFs.renam...
javascript
{ "resource": "" }
q34667
emojiLogger
train
function emojiLogger(msg, type, override) { // Get the type var _type = emojiLogger.types[type || "info"]; if (!_type) { throw new Err(`There is no such logger type: ${type}`, "NO_SUCH_LOGGER_TYPE"); } emojiLogger.log(msg, _type, override); }
javascript
{ "resource": "" }
q34668
train
function (targetFilePath, abspaths) { // Change 'assets/mdeditor.min.js' to 'assets/' and 'mdeditor.min.js' var pathFilename = _splitPathAndFilename(targetFilePath); var targetPath = pathFilename[0]; var targetFilename = pathFilename[1]; // bug fix: assets/xxxxxxxx.mdeditor.min.js, xxxxxxxx can't c...
javascript
{ "resource": "" }
q34669
findPosSubword
train
function findPosSubword(doc, start, dir) { if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1)); var line = doc.getLine(start.line); if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0)); var state = "start", type; for (var pos = start.ch, e = dir < 0 ? ...
javascript
{ "resource": "" }
q34670
Task
train
function Task(task) { _.extend(this, task); if (task != undefined) this.createId(); // Short id this.__defineGetter__('id', function () { return this.__uuid__.substr(0, 8).toString(); }); // Keyword this.__defineGetter__('keyword', function () { return this.labels[0].replace('#', '').toUpperCase...
javascript
{ "resource": "" }
q34671
train
function (v, paramd) { var nd = {}; var _add = function(v) { if (!_.is.String(v)) { return false; } var vmatch = v.match(/^([-a-z0-9]*):.+/); if (!vmatch) { return false; } var nshort = vmatch[1]; var nurl = _namespace[ns...
javascript
{ "resource": "" }
q34672
train
function () { // eslint-disable-line object-shorthand // Inits helper helper.init(this); // Check cli args for output format, and override on existance of string. if (typeof pluginBuildFlag === 'string' || pluginBuildFlag instanceof String) { helper.config.format = pluginBuildFlag; } // Fill sum...
javascript
{ "resource": "" }
q34673
train
function () { // eslint-disable-line object-shorthand const self = this; const outputPath = helper.getOutput(); // Render template. const rawContent = helper.renderTemp({summary: helper.summary}); // Create output dir. mkdirp.sync(path.parse(outputPath).dir); // Compile rendered main file ret...
javascript
{ "resource": "" }
q34674
train
function (page) { // eslint-disable-line object-shorthand // Fill summary with compiled page content helper.summary.forEach((article, i, array) => { if (article.path === page.path) { array[i].content = page.content; } }); // Returns unchanged page. return page; }
javascript
{ "resource": "" }
q34675
sendJson
train
function sendJson(data, options, callback) { var jsonData = JSON.stringify(data); return this.send(jsonData, options, callback); }
javascript
{ "resource": "" }
q34676
find_props
train
function find_props(schema) { var props = _(schema.paths).keys().without('_id', 'id') // transform the schema tree into an array for filtering .map(function(key) { return { name : key, value : _.get(schema.tree, key) }; }) // remove paths that are annotated with csv: false .filter...
javascript
{ "resource": "" }
q34677
prop_to_csv
train
function prop_to_csv(prop) { var val = String(prop); if (val === 'undefined') val = ''; return '"' + val.toString().replace(/"/g, '""') + '"'; }
javascript
{ "resource": "" }
q34678
train
function(view_config, raw_hash) { for (var name in raw_hash) { if (Lava.schema.DEBUG && this._allowed_hash_options.indexOf(name) == -1) Lava.t("Hash option is not supported: " + name); if (name in this._view_config_property_setters) { this[this._view_config_property_setters[name]](view_config, raw_hash[na...
javascript
{ "resource": "" }
q34679
train
function(result, raw_expression) { if (raw_expression.arguments.length != 1) Lava.t("Expression block requires exactly one argument"); var config = { type: 'view', "class": 'Expression', argument: raw_expression.arguments[0] }; if (raw_expression.prefix == '$') { config.container = {type: 'Morph...
javascript
{ "resource": "" }
q34680
train
function(result, tag) { var is_void = Lava.isVoidTag(tag.name), tag_start_text = "<" + tag.name + this.renderTagAttributes(tag.attributes) + (is_void ? '/>' : '>'), inner_template, count; this. _compileString(result, tag_start_text); if (Lava.schema.DEBUG && is_void && tag.content) Lava.t("Voi...
javascript
{ "resource": "" }
q34681
train
function(raw_tag) { var container_config = { type: 'Element', tag_name: raw_tag.name }; if ('attributes' in raw_tag) this._parseContainerStaticAttributes(container_config, raw_tag.attributes); if ('x' in raw_tag) this._parseContainerControlAttributes(container_config, raw_tag.x); return /** @type ...
javascript
{ "resource": "" }
q34682
train
function(container_config, x) { var i, count, name; if ('event' in x) { if (typeof(x.event) != 'object') Lava.t("Malformed x:event attribute"); container_config.events = {}; for (name in x.event) { container_config.events[name] = Lava.parsers.Common.parseTargets(x.event[name]); } } ...
javascript
{ "resource": "" }
q34683
train
function(blocks, view_config) { var current_block, result = [], type, i = 0, count = blocks.length, x; for (; i < count; i++) { current_block = blocks[i]; type = (typeof(current_block) == 'string') ? 'string' : current_block.type; if (type == 'tag') { x = current_block.x; if (x...
javascript
{ "resource": "" }
q34684
train
function(raw_blocks) { var result = this.asBlocks(this.compileTemplate(raw_blocks)); if (result.length != 1) Lava.t("Expected: exactly one view, got either several or none."); if (result[0].type != 'view' && result[0].type != 'widget') Lava.t("Expected: view, got: " + result[0].type); return result[0]; }
javascript
{ "resource": "" }
q34685
train
function(template) { var i = 0, count = template.length, result = []; for (; i < count; i++) { if (typeof(template[i]) == 'string') { if (!Lava.EMPTY_REGEX.test(template[i])) Lava.t("Text between tags is not allowed in this context. You may want to use a lava-style comment ({* ... *})"); } else...
javascript
{ "resource": "" }
q34686
train
function() { return { type: 'widget', "class": Lava.schema.widget.DEFAULT_EXTENSION_GATEWAY, extender_type: Lava.schema.widget.DEFAULT_EXTENDER } }
javascript
{ "resource": "" }
q34687
train
function(raw_string) { var map = Firestorm.String.quote_escape_map, result; try { result = eval("(" + raw_string.replace(this.UNQUOTE_ESCAPE_REGEX, function (a) { var c = map[a]; return typeof c == 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + ")"); } catch (e) ...
javascript
{ "resource": "" }
q34688
train
function(raw_directive, view_config, is_top_directive) { var directive_name = raw_directive.name, config = this._directives_schema[directive_name]; if (!config) Lava.t("Unknown directive: " + directive_name); if (config.view_config_presence) { if (view_config && !config.view_config_presence) Lava.t('Dire...
javascript
{ "resource": "" }
q34689
train
function(destination, source, name_list) { for (var i = 0, count = name_list.length; i < count; i++) { var name = name_list[i]; if (name in source) destination[name] = source[name]; } }
javascript
{ "resource": "" }
q34690
train
function(raw_tag) { if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1 || raw_tag.content[0] == '')) Lava.t("Malformed resources options tag"); return { type: 'options', value: Lava.parseOptions(raw_tag.content[0]) }; }
javascript
{ "resource": "" }
q34691
train
function(raw_tag) { if (Lava.schema.DEBUG && raw_tag.content && raw_tag.content.length != 1) Lava.t("Malformed resources string tag"); var result = { type: 'string', value: raw_tag.content ? raw_tag.content[0].trim() : '' }; if (raw_tag.attributes.description) result.description = raw_tag.attributes.de...
javascript
{ "resource": "" }
q34692
train
function(raw_tag) { if (Lava.schema.DEBUG && (!raw_tag.content)) Lava.t("Malformed resources plural string tag"); var plural_tags = Lava.parsers.Common.asBlockType(raw_tag.content, 'tag'), i = 0, count = plural_tags.length, plurals = [], result; if (Lava.schema.DEBUG && count == 0) Lava.t("Malforme...
javascript
{ "resource": "" }
q34693
train
function(raw_directive) { if (Lava.schema.DEBUG) { if (!raw_directive.attributes || !raw_directive.attributes.title) Lava.t("define: missing 'title' attribute"); if (raw_directive.attributes.title.indexOf(' ') != -1) Lava.t("Widget title must not contain spaces"); if ('resource_id' in raw_directive.attribut...
javascript
{ "resource": "" }
q34694
train
function(raw_directive) { var widget_config = this._parseWidgetDefinition(raw_directive); if (Lava.schema.DEBUG && ('sugar' in widget_config)) Lava.t("Inline widgets must not have sugar"); if (Lava.schema.DEBUG && !widget_config['class'] && !widget_config['extends']) Lava.t("x:define: widget definition is missi...
javascript
{ "resource": "" }
q34695
train
function(config, raw_tag, config_property_name) { if (Lava.schema.DEBUG && !('attributes' in raw_tag)) Lava.t("option: missing attributes"); if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1)) Lava.t("Malformed option: " + raw_tag.attributes.name); var option_type = raw_tag.attributes.ty...
javascript
{ "resource": "" }
q34696
train
function(config, name, raw_tag) { if (Lava.schema.DEBUG && (name in config)) Lava.t("Object already exists: " + name + ". Ensure, that x:options and x:properties directives appear before x:option and x:property."); if (Lava.schema.DEBUG && (!raw_tag.content || raw_tag.content.length != 1)) Lava.t("Malformed direct...
javascript
{ "resource": "" }
q34697
train
function(widget_config, raw_directive, config_property_name) { if (Lava.schema.DEBUG && !('attributes' in raw_directive)) Lava.t("option: missing attributes"); if (Lava.schema.DEBUG && (!raw_directive.content || raw_directive.content.length != 1)) Lava.t("Malformed property: " + raw_directive.attributes.name); L...
javascript
{ "resource": "" }
q34698
train
function(raw_directive) { if (Lava.schema.DEBUG && (!raw_directive.attributes || !raw_directive.attributes['locale'] || !raw_directive.attributes['for'])) Lava.t("Malformed x:resources definition. 'locale' and 'for' are required"); Lava.resources.addWidgetResource( raw_directive.attributes['for'], raw_di...
javascript
{ "resource": "" }
q34699
train
function(raw_directive) { if (Lava.schema.DEBUG && !raw_directive.content) Lava.t("empty attach_directives"); var blocks = Lava.parsers.Common.asBlocks(raw_directive.content), sugar = blocks[0], directives = blocks.slice(1), i, count; if (Lava.schema.DEBUG) { if (sugar.type != 'tag' || sugar.con...
javascript
{ "resource": "" }