_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q59900 | validation | function(start, len) {
if (_.isUndefined(start) || start === null)
return null;
if (start instanceof Range)
return start;
if (_.isObject(start) && 'start' in start && 'end' in start) {
len = start.end - start.start;
start = start.start;
}
return new Range(start, len);
} | javascript | {
"resource": ""
} | |
q59901 | validation | function(fn, options) {
this._list.push(_.extend({order: 0}, options || {}, {fn: fn}));
} | javascript | {
"resource": ""
} | |
q59902 | validation | function(fn) {
this._list = _.without(this._list, _.find(this._list, function(item) {
return item.fn === fn;
}));
} | javascript | {
"resource": ""
} | |
q59903 | validation | function(name) {
if (!name)
return null;
if (!(name in cache)) {
cache[name] = require('utils').deepMerge({}, systemSettings[name], userSettings[name]);
}
var data = cache[name], subsections = _.rest(arguments), key;
while (data && (key = subsections.shift())) {
if (key in data) {
... | javascript | {
"resource": ""
} | |
q59904 | validation | function(syntax, name, memo) {
if (!syntax || !name)
return null;
memo = memo || [];
var names = [name];
// create automatic aliases to properties with colons,
// e.g. pos-a == pos:a
if (~name.indexOf('-'))
names.push(name.replace(/\-/g, ':'));
var data = this.getSection(syntax)... | javascript | {
"resource": ""
} | |
q59905 | validation | function(syntax, name, minScore) {
minScore = minScore || 0.3;
var payload = this.getAllSnippets(syntax);
var sc = require('string-score');
name = normalizeName(name);
var scores = _.map(payload, function(value, key) {
return {
key: key,
score: sc.score(value.nk, name, 0.1)
};
... | javascript | {
"resource": ""
} | |
q59906 | validation | function(title, menu) {
var item = null;
_.find(menu || this.getMenu(), function(val) {
if (val.type == 'action') {
if (val.label == title || val.name == title) {
return item = val.name;
}
} else {
return item = this.getActionNameForMenuTitle(title, val.items);
}
}, this);
... | javascript | {
"resource": ""
} | |
q59907 | validation | function(name, syntax) {
if (!name && syntax) {
// search in user resources first
var profile = require('resources').findItem(syntax, 'profile');
if (profile) {
name = profile;
}
}
if (!name) {
return profiles.plain;
}
if (name instanceof OutputProfile) {
return name;... | javascript | {
"resource": ""
} | |
q59908 | validation | function(editor) {
var allowedSyntaxes = {'html': 1, 'xml': 1, 'xsl': 1};
var syntax = String(editor.getSyntax());
if (syntax in allowedSyntaxes) {
var content = String(editor.getContent());
var tag = require('htmlMatcher').find(content, editor.getCaretPos());
if (tag && tag.type == 'tag') {
... | javascript | {
"resource": ""
} | |
q59909 | validation | function(editor) {
var syntax = editor.getSyntax();
// get profile from syntax definition
var profile = require('resources').findItem(syntax, 'profile');
if (profile) {
return profile;
}
switch(syntax) {
case 'xml':
case 'xsl':
return 'xml';
case 'css':
if (this.isInl... | javascript | {
"resource": ""
} | |
q59910 | validation | function(editor) {
var content = String(editor.getContent());
var caretPos = editor.getCaretPos();
var tag = require('htmlMatcher').tag(content, caretPos);
return tag && tag.open.name.toLowerCase() == 'style'
&& tag.innerRange.cmp(caretPos, 'lte', 'gte');
} | javascript | {
"resource": ""
} | |
q59911 | validation | function(editor) {
var content = String(editor.getContent());
var caretPos = editor.getCaretPos();
var tree = require('xmlEditTree').parseFromPosition(content, caretPos, true);
if (tree) {
var attr = tree.itemFromPosition(caretPos, true);
return attr && attr.name().t... | javascript | {
"resource": ""
} | |
q59912 | validation | function(node) {
return (this.hasTagsInContent(node) && this.isBlock(node))
|| _.any(node.children, function(child) {
return this.isBlock(child);
}, this);
} | javascript | {
"resource": ""
} | |
q59913 | validation | function(input) {
var output = [];
var chr1, chr2, chr3, enc1, enc2, enc3, enc4, cdp1, cdp2, cdp3;
var i = 0, il = input.length, b64 = chars;
while (i < il) {
cdp1 = input.charCodeAt(i++);
cdp2 = input.charCodeAt(i++);
cdp3 = input.charCodeAt(i++);
chr1 = cdp1 & 0xff;
chr2 = cdp2 & 0x... | javascript | {
"resource": ""
} | |
q59914 | validation | function(data) {
var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, tmpArr = [];
var b64 = chars, il = data.length;
if (!data) {
return data;
}
data += '';
do { // unpack four hexets into three octets using index points in b64
h1 = b64.indexOf(data.charAt(i++));
h2 = b64.indexOf(data.... | javascript | {
"resource": ""
} | |
q59915 | createMatcher | validation | function createMatcher(text) {
var memo = {}, m;
return {
/**
* Test if given position matches opening tag
* @param {Number} i
* @returns {Object} Matched tag object
*/
open: function(i) {
var m = this.matches(i);
return m && m.type == 'open' ? m : null;
},
/**
* Test if ... | javascript | {
"resource": ""
} |
q59916 | validation | function(node, offset) {
var maxNum = 0;
var options = {
tabstop: function(data) {
var group = parseInt(data.group);
if (group > maxNum) maxNum = group;
if (data.placeholder)
return '${' + (group + offset) + ':' + data.placeholder + '}';
else
return '${' + (group + offse... | javascript | {
"resource": ""
} | |
q59917 | validation | function(name, value, description) {
var prefs = name;
if (_.isString(name)) {
prefs = {};
prefs[name] = {
value: value,
description: description
};
}
_.each(prefs, function(v, k) {
defaults[k] = isValueObj(v) ? v : {value: v};
});
} | javascript | {
"resource": ""
} | |
q59918 | validation | function(name) {
if (name in preferences)
return preferences[name];
if (name in defaults)
return defaults[name].value;
return void 0;
} | javascript | {
"resource": ""
} | |
q59919 | validation | function(name) {
var val = this.get(name);
if (_.isUndefined(val) || val === null || val === '') {
return null;
}
val = _.map(val.split(','), require('utils').trim);
if (!val.length) {
return null;
}
return val;
} | javascript | {
"resource": ""
} | |
q59920 | validation | function(name) {
var result = {};
_.each(this.getArray(name), function(val) {
var parts = val.split(':');
result[parts[0]] = parts[1];
});
return result;
} | javascript | {
"resource": ""
} | |
q59921 | validation | function(tree, filters, profile) {
var utils = require('utils');
profile = require('profile').get(profile);
_.each(list(filters), function(filter) {
var name = utils.trim(filter.toLowerCase());
if (name && name in registeredFilters) {
tree = registeredFilters[name](tree, profile);
}
});... | javascript | {
"resource": ""
} | |
q59922 | validation | function(syntax, profile, additionalFilters) {
profile = require('profile').get(profile);
var filters = list(profile.filters || require('resources').findItem(syntax, 'filters') || basicFilters);
if (profile.extraFilters) {
filters = filters.concat(list(profile.extraFilters));
}
if (additiona... | javascript | {
"resource": ""
} | |
q59923 | validation | function(value, start, end) {
// create modification range
var r = range(start, _.isUndefined(end) ? 0 : end - start);
var delta = value.length - r.length();
var update = function(obj) {
_.each(obj, function(v, k) {
if (v >= r.end)
obj[k] += delta;
});
};
// update affected ... | javascript | {
"resource": ""
} | |
q59924 | validation | function(name) {
if (_.isNumber(name))
return this.list()[name];
if (_.isString(name))
return _.find(this.list(), function(prop) {
return prop.name() === name;
});
return name;
} | javascript | {
"resource": ""
} | |
q59925 | validation | function(name) {
if (!_.isArray(name))
name = [name];
// split names and indexes
var names = [], indexes = [];
_.each(name, function(item) {
if (_.isString(item))
names.push(item);
else if (_.isNumber(item))
indexes.push(item);
});
return _.filter(this.list(), function(at... | javascript | {
"resource": ""
} | |
q59926 | validation | function(name, value, pos) {
var element = this.get(name);
if (element)
return element.value(value);
if (!_.isUndefined(value)) {
// no such element — create it
return this.add(name, value, pos);
}
} | javascript | {
"resource": ""
} | |
q59927 | validation | function(name) {
var element = this.get(name);
if (element) {
this._updateSource('', element.fullRange());
this._children = _.without(this._children, element);
}
} | javascript | {
"resource": ""
} | |
q59928 | validation | function(val) {
if (!_.isUndefined(val) && this._name !== (val = String(val))) {
this._updateSource(val, this._positions.name, this._positions.name + this._name.length);
this._name = val;
}
return this._name;
} | javascript | {
"resource": ""
} | |
q59929 | validation | function(pos, isAbsolute) {
return _.find(this.list(), function(elem) {
return elem.range(isAbsolute).inside(pos);
});
} | javascript | {
"resource": ""
} | |
q59930 | validation | function(val) {
if (!_.isUndefined(val) && this._value !== (val = String(val))) {
this.parent._updateSource(val, this.valueRange());
this._value = val;
}
return this._value;
} | javascript | {
"resource": ""
} | |
q59931 | validation | function(val) {
if (!_.isUndefined(val) && this._name !== (val = String(val))) {
this.parent._updateSource(val, this.nameRange());
this._name = val;
}
return this._name;
} | javascript | {
"resource": ""
} | |
q59932 | trimWhitespaceTokens | validation | function trimWhitespaceTokens(tokens, mask) {
mask = mask || (WHITESPACE_REMOVE_FROM_START | WHITESPACE_REMOVE_FROM_END);
var whitespace = ['white', 'line'];
if ((mask & WHITESPACE_REMOVE_FROM_END) == WHITESPACE_REMOVE_FROM_END)
while (tokens.length && _.include(whitespace, _.last(tokens).type)) {
token... | javascript | {
"resource": ""
} |
q59933 | findValueRange | validation | function findValueRange(it) {
// find value start position
var skipTokens = ['white', 'line', ':'];
var tokens = [], token, start, end;
it.nextUntil(function(tok) {
return !_.include(skipTokens, this.itemNext().type);
});
start = it.current().end;
// consume value
while (token = it.next()) {
... | javascript | {
"resource": ""
} |
q59934 | findParts | validation | function findParts(str) {
/** @type StringStream */
var stream = require('stringStream').create(str);
var ch;
var result = [];
var sep = /[\s\u00a0,]/;
var add = function() {
stream.next();
result.push(range(stream.start, stream.current()));
stream.start = stream.pos;
};
// skip whitespac... | javascript | {
"resource": ""
} |
q59935 | validation | function(isAbsolute) {
var parts = findParts(this.value());
if (isAbsolute) {
var offset = this.valuePosition(true);
_.each(parts, function(p) {
p.shift(offset);
});
}
return parts;
} | javascript | {
"resource": ""
} | |
q59936 | validation | function(content, pos, isBackward) {
var result = '';
var len = content.length;
var offset = pos;
var stopChars = '{}/\\<>\n\r';
var bracePos = -1, ch;
// search left until we find rule edge
while (offset >= 0) {
ch = content.charAt(offset);
if (ch == '{') {
bracePos = offset;
... | javascript | {
"resource": ""
} | |
q59937 | validation | function(name, value, pos) {
var list = this.list();
var start = this.nameRange().end;
var editTree = require('editTree');
var styles = _.pick(this.options, 'styleBefore', 'styleSeparator', 'styleQuote');
if (_.isUndefined(pos))
pos = list.length;
/** @type XMLEditAttribute */
var d... | javascript | {
"resource": ""
} | |
q59938 | validation | function(editor) {
/** @type Range */
var range = require('range').create(editor.getSelectionRange());
var content = String(editor.getContent());
if (range.length()) {
// abbreviation is selected by user
return range.substring(content);
}
// search for new abbreviation from current caret p... | javascript | {
"resource": ""
} | |
q59939 | validation | function(abbr, text, syntax, profile, contextNode) {
/** @type emmet.filters */
var filters = require('filters');
/** @type emmet.utils */
var utils = require('utils');
syntax = syntax || emmet.defaultSyntax();
profile = require('profile').get(profile, syntax);
require('tabStops').resetTabs... | javascript | {
"resource": ""
} | |
q59940 | toggleHTMLComment | validation | function toggleHTMLComment(editor) {
/** @type Range */
var range = require('range').create(editor.getSelectionRange());
var info = require('editorUtils').outputInfo(editor);
if (!range.length()) {
// no selection, find matching tag
var tag = require('htmlMatcher').tag(info.content, editor.getCaretPos... | javascript | {
"resource": ""
} |
q59941 | toggleCSSComment | validation | function toggleCSSComment(editor) {
/** @type Range */
var range = require('range').create(editor.getSelectionRange());
var info = require('editorUtils').outputInfo(editor);
if (!range.length()) {
// no selection, try to get current rule
/** @type CSSRule */
var rule = require('cssEditTree').parseF... | javascript | {
"resource": ""
} |
q59942 | genericCommentToggle | validation | function genericCommentToggle(editor, commentStart, commentEnd, range) {
var editorUtils = require('editorUtils');
var content = editorUtils.outputInfo(editor).content;
var caretPos = editor.getCaretPos();
var newContent = null;
var utils = require('utils');
/**
* Remove comment markers from strin... | javascript | {
"resource": ""
} |
q59943 | removeComment | validation | function removeComment(str) {
return str
.replace(new RegExp('^' + utils.escapeForRegexp(commentStart) + '\\s*'), function(str){
caretPos -= str.length;
return '';
}).replace(new RegExp('\\s*' + utils.escapeForRegexp(commentEnd) + '$'), '');
} | javascript | {
"resource": ""
} |
q59944 | makePossibleRangesHTML | validation | function makePossibleRangesHTML(source, tokens, offset) {
offset = offset || 0;
var range = require('range');
var result = [];
var attrStart = -1, attrName = '', attrValue = '', attrValueRange, tagName;
_.each(tokens, function(tok) {
switch (tok.type) {
case 'tag':
tagName = source.substring(tok.s... | javascript | {
"resource": ""
} |
q59945 | classNameRanges | validation | function classNameRanges(className, offset) {
offset = offset || 0;
var result = [];
/** @type StringStream */
var stream = require('stringStream').create(className);
var range = require('range');
// skip whitespace
stream.eatSpace();
stream.start = stream.pos;
var ch;
while (ch = stream.next(... | javascript | {
"resource": ""
} |
q59946 | makePossibleRangesCSS | validation | function makePossibleRangesCSS(property) {
// find all possible ranges, sorted by position and size
var valueRange = property.valueRange(true);
var result = [property.range(true), valueRange];
var stringStream = require('stringStream');
var cssEditTree = require('cssEditTree');
var range = require('range');... | javascript | {
"resource": ""
} |
q59947 | matchedRangeForCSSProperty | validation | function matchedRangeForCSSProperty(rule, selRange, isBackward) {
/** @type CSSProperty */
var property = null;
var possibleRanges, curRange = null, ix;
var list = rule.list();
var searchFn, nearestItemFn;
if (isBackward) {
list.reverse();
searchFn = function(p) {
return p.range(true).start <= ... | javascript | {
"resource": ""
} |
q59948 | matchPair | validation | function matchPair(editor, direction) {
direction = String((direction || 'out').toLowerCase());
var info = require('editorUtils').outputInfo(editor);
var range = require('range');
/** @type Range */
var sel = range.create(editor.getSelectionRange());
var content = info.content;
// validate previous ... | javascript | {
"resource": ""
} |
q59949 | getReflectedCSSName | validation | function getReflectedCSSName(name) {
name = require('cssEditTree').baseName(name);
var vendorPrefix = '^(?:\\-\\w+\\-)?', m;
if (name == 'opacity' || name == 'filter') {
return new RegExp(vendorPrefix + '(?:opacity|filter)$');
} else if (m = name.match(/^border-radius-(top|bottom)(left|right)/)) {
// M... | javascript | {
"resource": ""
} |
q59950 | decodeFromBase64 | validation | function decodeFromBase64(editor, data, pos) {
// ask user to enter path to file
var filePath = String(editor.prompt('Enter path to file (absolute or relative)'));
if (!filePath)
return false;
var file = require('file');
var absPath = file.createPath(editor.getFilePath(), filePath);
if (!absPath) {
... | javascript | {
"resource": ""
} |
q59951 | updateImageSizeCSS | validation | function updateImageSizeCSS(editor) {
var offset = editor.getCaretPos();
// find tag from current caret position
var info = require('editorUtils').outputInfo(editor);
var cssRule = require('cssEditTree').parseFromPosition(info.content, offset, true);
if (cssRule) {
// check if there is property with ima... | javascript | {
"resource": ""
} |
q59952 | getImageSizeForSource | validation | function getImageSizeForSource(editor, src, callback) {
var fileContent;
var au = require('actionUtils');
if (src) {
// check if it is data:url
if (/^data:/.test(src)) {
fileContent = require('base64').decode( src.replace(/^data\:.+?;.+?,/, '') );
return callback(au.getImageSize(fileContent));
}
... | javascript | {
"resource": ""
} |
q59953 | isSingleProperty | validation | function isSingleProperty(snippet) {
var utils = require('utils');
snippet = utils.trim(snippet);
// check if it doesn't contain a comment and a newline
if (~snippet.indexOf('/*') || /[\n\r]/.test(snippet)) {
return false;
}
// check if it's a valid snippet definition
if (!/^[a-z0-9\-]+\s*\:/i.te... | javascript | {
"resource": ""
} |
q59954 | normalizeValue | validation | function normalizeValue(value) {
if (value.charAt(0) == '-' && !/^\-[\.\d]/.test(value)) {
value = value.replace(/^\-+/, '');
}
if (value.charAt(0) == '#') {
return normalizeHexColor(value);
}
return getKeyword(value);
} | javascript | {
"resource": ""
} |
q59955 | findPrefixes | validation | function findPrefixes(property, noAutofill) {
var result = [];
_.each(vendorPrefixes, function(obj, prefix) {
if (hasPrefix(property, prefix)) {
result.push(prefix);
}
});
if (!result.length && !noAutofill) {
// add all non-obsolete prefixes
_.each(vendorPrefixes, function(obj, prefix) {
... | javascript | {
"resource": ""
} |
q59956 | parseList | validation | function parseList(list) {
var result = _.map((list || '').split(','), require('utils').trim);
return result.length ? result : null;
} | javascript | {
"resource": ""
} |
q59957 | validation | function(abbr, value, syntax) {
syntax = syntax || 'css';
var resources = require('resources');
var autoInsertPrefixes = prefs.get('css.autoInsertVendorPrefixes');
// check if snippet should be transformed to !important
var isImportant;
if (isImportant = /^(.+)\!$/.test(abbr)) {
abbr = RegExp.... | javascript | {
"resource": ""
} | |
q59958 | validation | function(snippet) {
var utils = require('utils');
snippet = utils.trim(snippet);
if (snippet.indexOf(':') == -1) {
return {
name: snippet,
value: defaultValue
};
}
var pair = snippet.split(':');
return {
name: utils.trim(pair.shift()),
// replace ${0} tabstop to produ... | javascript | {
"resource": ""
} | |
q59959 | parseLinearGradient | validation | function parseLinearGradient(gradient) {
var direction = defaultLinearDirections[0];
// extract tokens
/** @type StringStream */
var stream = require('stringStream').create(require('utils').trim(gradient));
var colorStops = [], ch;
while (ch = stream.next()) {
if (stream.peek() == ',') {
colorStop... | javascript | {
"resource": ""
} |
q59960 | fillImpliedPositions | validation | function fillImpliedPositions(colorStops) {
var from = 0;
_.each(colorStops, function(cs, i) {
// make sure that first and last positions are defined
if (!i)
return cs.position = cs.position || 0;
if (i == colorStops.length - 1 && !('position' in cs))
cs.position = 1;
if ('position' i... | javascript | {
"resource": ""
} |
q59961 | textualDirection | validation | function textualDirection(direction) {
var angle = parseFloat(direction);
if(!_.isNaN(angle)) {
switch(angle % 360) {
case 0: return 'left';
case 90: return 'bottom';
case 180: return 'right';
case 240: return 'top';
}
}
return direction;
} | javascript | {
"resource": ""
} |
q59962 | getPropertiesForGradient | validation | function getPropertiesForGradient(gradient, propertyName) {
var props = [];
var css = require('cssResolver');
if (prefs.get('css.gradient.fallback') && ~propertyName.toLowerCase().indexOf('background')) {
props.push({
name: 'background-color',
value: '${1:' + gradient.colorStops[0].color + '}'
})... | javascript | {
"resource": ""
} |
q59963 | findGradient | validation | function findGradient(cssProp) {
var value = cssProp.value();
var gradient = null;
var matchedPart = _.find(cssProp.valueParts(), function(part) {
return gradient = module.parse(part.substring(value));
});
if (matchedPart && gradient) {
return {
gradient: gradient,
valueRange: matchedPart
... | javascript | {
"resource": ""
} |
q59964 | expandGradientOutsideValue | validation | function expandGradientOutsideValue(editor, syntax) {
var propertyName = prefs.get('css.gradient.defaultProperty');
if (!propertyName)
return false;
// assuming that gradient definition is written on new line,
// do a simplified parsing
var content = String(editor.getContent());
/** @type Range */
... | javascript | {
"resource": ""
} |
q59965 | findGradientFromPosition | validation | function findGradientFromPosition(content, pos) {
var cssProp = null;
/** @type EditContainer */
var cssRule = require('cssEditTree').parseFromPosition(content, pos, true);
if (cssRule) {
cssProp = cssRule.itemFromPosition(pos, true);
if (!cssProp) {
// in case user just started writing CSS propert... | javascript | {
"resource": ""
} |
q59966 | validation | function(gradient) {
var result = null;
require('utils').trim(gradient).replace(/^([\w\-]+)\((.+?)\)$/, function(str, type, definition) {
// remove vendor prefix
type = type.toLowerCase().replace(/^\-[a-z]+\-/, '');
if (type == 'linear-gradient' || type == 'lg') {
result = parseLinearGradient(def... | javascript | {
"resource": ""
} | |
q59967 | validation | function(gradient) {
if (_.isString(gradient))
gradient = this.parse(gradient);
if (!gradient)
return null;
var colorStops = _.map(gradient.colorStops, _.clone);
// normalize color-stops position
_.each(colorStops, function(cs) {
if (!('position' in cs)) // implied position
r... | javascript | {
"resource": ""
} | |
q59968 | validation | function(gradient, prefix) {
if (gradient.type == 'linear') {
var fn = (prefix ? '-' + prefix + '-' : '') + 'linear-gradient';
// transform color-stops
var colorStops = _.map(gradient.colorStops, function(cs) {
return cs.color + ('position' in cs
? ' ' + cs.position + (cs.unit || '')
... | javascript | {
"resource": ""
} | |
q59969 | validation | function(name, collection) {
if (!elementTypes[collection])
elementTypes[collection] = [];
var col = this.getCollection(collection);
if (!_.include(col, name))
col.push(name);
} | javascript | {
"resource": ""
} | |
q59970 | validation | function(name, collection) {
if (collection in elementTypes) {
elementTypes[collection] = _.without(this.getCollection(collection), name);
}
} | javascript | {
"resource": ""
} | |
q59971 | processClassName | validation | function processClassName(name, item) {
name = transformClassName(name, item, 'element');
name = transformClassName(name, item, 'modifier');
// expand class name
// possible values:
// * block__element
// * block__element_modifier
// * block__element_modifier1_modifier2
// * block_modifier
var bloc... | javascript | {
"resource": ""
} |
q59972 | getIndentation | validation | function getIndentation(node) {
if (_.include(prefs.getArray('format.noIndentTags') || [], node.name())) {
return '';
}
return require('resources').getVariable('indentation');
} | javascript | {
"resource": ""
} |
q59973 | shouldBreakInsideInline | validation | function shouldBreakInsideInline(node, profile) {
var abbrUtils = require('abbreviationUtils');
var hasBlockElems = _.any(node.children, function(child) {
if (abbrUtils.isSnippet(child))
return false;
return !abbrUtils.isInline(child);
});
if (!hasBlockElems) {
return shouldFormatInline(node... | javascript | {
"resource": ""
} |
q59974 | makeAttributesString | validation | function makeAttributesString(tag, profile) {
var attrs = '';
var otherAttrs = [];
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
_.each(tag.attributeList(), function(a) {
var attrName = profile.attributeName(a.name);
switch (attrName.toLowerCase()) {
// use short notati... | javascript | {
"resource": ""
} |
q59975 | makeAttributesString | validation | function makeAttributesString(node, profile) {
var attrQuote = profile.attributeQuote();
var cursor = profile.cursor();
return _.map(node.attributeList(), function(a) {
var attrName = profile.attributeName(a.name);
return ' ' + attrName + '=' + attrQuote + (a.value || cursor) + attrQuote;
}).join('');
... | javascript | {
"resource": ""
} |
q59976 | validation | function(lang, data) {
if (_.isString(data)) {
data = {words: _.compact(data.split(' '))};
} else if (_.isArray(data)) {
data = {words: data};
}
langs[lang] = data;
} | javascript | {
"resource": ""
} | |
q59977 | validation | function (err, res) {
if (err) return sender.emit('transmissionError', err, data.channelURI);
sender.emit('transmitted', res, data.channelURI);
} | javascript | {
"resource": ""
} | |
q59978 | sanitize | validation | function sanitize(sender, data) {
data = _.defaults({}, {
client_id: sender.client_id, client_secret: sender.client_secret
}, data);
return _.reduce(data, function (acc, value, key) {
if (! _.isUndefined(value)) {
acc[key] = value;
}
return acc;
}, {});
} | javascript | {
"resource": ""
} |
q59979 | getMissingProps | validation | function getMissingProps(data) {
var containsKey = _.partial(_.contains, _.keys(data));
return _.filter(required, function (req) {
return !containsKey(req);
});
} | javascript | {
"resource": ""
} |
q59980 | sendRequiredErrors | validation | function sendRequiredErrors(sender, missingProps) {
_.forEach(missingProps, function (prop) {
sender.emit('error', prop + ' is missing');
});
} | javascript | {
"resource": ""
} |
q59981 | Sender | validation | function Sender(options) {
EventEmitter.call(this);
_.extend(this, _.defaults(options || {}, {
retries: 4
}));
} | javascript | {
"resource": ""
} |
q59982 | appendChild | validation | function appendChild(parent, childrens) {
if (childrens.length === undefined) childrens = [childrens];
var docFrag = document.createDocumentFragment(); //we used for loop instead of forEach because childrens can be array like object
for (var i = 0, ln = childrens.length; i < ln; i++) {
docFrag.appendChild(ch... | javascript | {
"resource": ""
} |
q59983 | getLogicalPartitions | validation | function getLogicalPartitions(disk, index, offset, extendedPartitionOffset, limit) {
return __awaiter(this, void 0, void 0, function* () {
if (extendedPartitionOffset === undefined) {
extendedPartitionOffset = offset;
}
if (limit === undefined) {
limit = Infinity;
... | javascript | {
"resource": ""
} |
q59984 | processTemplate | validation | function processTemplate(template, variables) {
for (let variableName of Object.keys(variables)) {
let value = variables[variableName];
template = replaceVariable(template, variableName, value);
}
template = evaluateConditions(template, variables);
return template;
} | javascript | {
"resource": ""
} |
q59985 | replaceVariable | validation | function replaceVariable(template, name, value) {
let key = `{${name}}`;
let reg = new RegExp(helper.escapeRegExp(key), 'g');
let encodedReg = new RegExp(helper.escapeRegExp(`{${name}|json}`), 'g');
let encodedValue = JSON.stringify(value).replace(/<\/script/gi, '<\\/script');
return template.replace(reg, va... | javascript | {
"resource": ""
} |
q59986 | evaluateConditions | validation | function evaluateConditions(template, variables) {
let source;
do {
source = template;
template = processSimpleConditions(template, variables);
template = processIfElseConditions(template, variables);
} while (source !== template);
return template;
} | javascript | {
"resource": ""
} |
q59987 | processCondition | validation | function processCondition(template, variables, matcher) {
// eslint-disable-next-line no-constant-condition
while (true) {
let matchedCondition = template.match(matcher);
if (!matchedCondition) {
break;
}
let fragment = matchedCondition[0];
let conditionCode = matchedCondition[1];
le... | javascript | {
"resource": ""
} |
q59988 | evaluateCondition | validation | function evaluateCondition(conditionCode, variables) {
let trimmedCondition = conditionCode.trim();
if ($Debug) {
if (!/^!?('[^']*'|"[^"]*")$/.test(trimmedCondition)) {
throw new Error('Invalid expected value: ' + trimmedCondition);
}
}
let negate = trimmedCondition.charAt(0) === '!';
let exp... | javascript | {
"resource": ""
} |
q59989 | defaultKeyGenerator | validation | function defaultKeyGenerator(request) {
let protocol = request.protocol;
let host = request.get('Host');
let url = request.originalUrl;
return protocol + ':' + host + url;
} | javascript | {
"resource": ""
} |
q59990 | getOrdersStatistics | validation | function getOrdersStatistics (metricKeys = ['item_sold_minecraft', 'prepaid_card_redeemed_minecraft']) {
return fetch(`${CORE_API}/orders/statistics`, {
method: 'POST',
body: JSON.stringify({metricKeys}),
headers: {
'user-agent': USER_AGENT,
'content-type': 'application/json',
'accept': ... | javascript | {
"resource": ""
} |
q59991 | signout | validation | function signout ({username, password}) {
return fetch(`${YGGDRASIL_API}/signout`, {
method: 'POST',
body: JSON.stringify({
username,
password
}),
headers: {
'user-agent': USER_AGENT,
'content-type': 'application/json',
'accept': 'application/json'
}
})
.then(ha... | javascript | {
"resource": ""
} |
q59992 | lookupProfiles | validation | function lookupProfiles (names, agent = 'minecraft') {
return fetch(`${CORE_API}/profiles/${agent}`, {
method: 'POST',
body: JSON.stringify(names),
headers: {
'user-agent': USER_AGENT,
'content-type': 'application/json',
'accept': 'application/json'
}
})
.then(handleErrors)
... | javascript | {
"resource": ""
} |
q59993 | getSession | validation | function getSession (profileId) {
return fetch(`${SESSION_API}/session/minecraft/profile/${profileId}`, {
headers: {
'user-agent': USER_AGENT,
'accept': 'application/json'
}
})
.then(handleErrors)
.then(res => {
if (res.status === 204) throw new Error('no such profile')
retur... | javascript | {
"resource": ""
} |
q59994 | uploadSkin | validation | function uploadSkin ({accessToken}, profileId, file, isSlim = false) {
const form = new FormData()
form.append('model', isSlim ? 'slim' : '')
form.append('file', file)
return fetch(`${CORE_API}/user/profile/${profileId}/skin`, {
method: 'PUT',
body: form,
headers: {
'user-agent': USER_AGENT,
... | javascript | {
"resource": ""
} |
q59995 | getUser | validation | function getUser ({accessToken}) {
return fetch(`${CORE_API}/user`, {
headers: {
'user-agent': USER_AGENT,
'authorization': `Bearer ${accessToken}`,
'accept': 'application/json'
}
})
.then(handleErrors)
.then(res => res.json())
} | javascript | {
"resource": ""
} |
q59996 | invalidate | validation | function invalidate ({accessToken, clientToken}) {
return fetch(`${YGGDRASIL_API}/invalidate`, {
method: 'POST',
body: JSON.stringify({
accessToken,
clientToken
}),
headers: {
'user-agent': USER_AGENT,
'content-type': 'application/json'
}
})
.then(handleErrors)
.t... | javascript | {
"resource": ""
} |
q59997 | getBlockedServers | validation | function getBlockedServers () {
return fetch(`${SESSION_API}/blockedservers`, {
headers: {
'user-agent': USER_AGENT
}
})
.then(handleErrors)
.then(res => res.text())
.then(text => text.split('\n').slice(0, -1))
} | javascript | {
"resource": ""
} |
q59998 | status | validation | function status () {
return fetch(`${STATUS_API}/check`, {
headers: {
'user-agent': USER_AGENT,
'accept': 'application/json'
}
})
.then(handleErrors) // NOTE I wonder how /check can fail
.then(res => res.json())
.then((sites) => sites.reduce((acc, val) => {
const hostname = Obj... | javascript | {
"resource": ""
} |
q59999 | getProfileHistory | validation | function getProfileHistory (profileId) {
// BASE/user/profile/:id/names also seems to provide the same endpoint
return fetch(`${CORE_API}/user/profiles/${profileId}/names`, {
headers: {
'user-agent': USER_AGENT,
'accept': 'application/json'
}
})
.then(handleErrors)
.then(res => {
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.