_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q48100 | preprocessorcery | train | function preprocessorcery(infile, info, callback) {
applicable(infile, info, (err, preprocessors) => {
if (err) return callback(err);
const q = queue(1);
preprocessors.forEach((preprocessor) => {
const outfile = newfile(infile);
q.defer((next) => {
preprocessor(infile, outfile, (err) ... | javascript | {
"resource": ""
} |
q48101 | copy | train | function copy(finished) {
fs.createReadStream(infile)
.once('error', callback)
.pipe(fs.createWriteStream(outfile))
.once('error', callback)
.on('finish', finished);
} | javascript | {
"resource": ""
} |
q48102 | cleanUpNodeJSDoc | train | function cleanUpNodeJSDoc(
node,
JSDocCommentValue = getJSDocCommentValue(node),
) {
t.removeComments(node);
t.addComment(node, 'leading', createJSDocCommentValue(JSDocCommentValue));
} | javascript | {
"resource": ""
} |
q48103 | renderHtmlAst | train | function renderHtmlAst(node, { components }) {
if (node.type === 'root') {
// NOTE: wrap children with React.Fragment, to avoid div wrapper from `hast-to-hyperscript`
node = {
type: 'element',
tagName: Fragment,
properties: {},
children: node.children,
};
}
function h(name, pr... | javascript | {
"resource": ""
} |
q48104 | train | function(value) {
if (!arguments.length) return mimeType;
mimeType = value == null ? null : value + "";
return request;
} | javascript | {
"resource": ""
} | |
q48105 | train | function(method, data, callback) {
xhr.open(method, url, true, user, password);
if (mimeType != null && !headers.has("accept")) headers.set("accept", mimeType + ",*/*");
if (xhr.setRequestHeader) headers.each(function(value, name) { xhr.setRequestHeader(name, value); });
if (mimeType != null && ... | javascript | {
"resource": ""
} | |
q48106 | load_ipython_extension | train | function load_ipython_extension() {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(181), __webpack_require__(178), __webpack_require__(179), __webpack_require__(180), __webpack_require__(560), __webpack_require__(182), __webpack_require__(216), __webpack_require__(349), __webpack_require__(504)], __WEBPACK_AMD... | javascript | {
"resource": ""
} |
q48107 | diagonal | train | function diagonal(s, d) {
if (s.dy == undefined) {
s.dy = 0;
}
if (d.dy == undefined) {
d.dy = 0;
}
let path = `M ${s.x} ${(s.y + s.dy)}
C ${(s.x + d.x) / 2} ${(s.y + s.dy)},
${(s.x + d.x) / 2} ${(d.y + d.dy)},
${d.x} ${(d.y + d.dy)}`;
return pat... | javascript | {
"resource": ""
} |
q48108 | register_renderer | train | function register_renderer(notebook, trial, history, utils, d3_selection) {
/* Get an instance of output_area from a CodeCell instance */
var _notebook$get_cells$r = notebook.get_cells().reduce(function (result, cell) {
return cell.output_area ? cell : result;
}, {}),
output_area = _notebook$get_cells$r... | javascript | {
"resource": ""
} |
q48109 | linkCss | train | function linkCss(component) {
const destination = path.join(demo, component);
process.chdir(destination);
const dist = path.join(packages, component, 'dist');
const source = path.relative(destination, dist);
fs.readdirSync(source).forEach(file => {
fs.symlinkSync(path.join(source, file), file);
});
... | javascript | {
"resource": ""
} |
q48110 | updateDemo | train | function updateDemo(component) {
const source = path.join(packages, component, 'demo');
const destination = path.join(demo, component);
ncp(source, destination, error => {
if (error) {
console.log(chalk.red('error'), error);
} else {
rimraf(source, () => {
console.log(chalk.green('suc... | javascript | {
"resource": ""
} |
q48111 | addComponent | train | function addComponent(name) {
const source = path.join(packages, '.template');
const destination = path.join(packages, name);
if (fs.existsSync(destination)) {
console.log(chalk.red('error'), 'Component package exists');
} else {
ncp(source, destination, error => {
if (error) {
console.lo... | javascript | {
"resource": ""
} |
q48112 | toProperties | train | function toProperties(variables) {
const categories = Object.keys(variables);
const valueOf = (category, value) => {
let retVal;
if (category === 'color') {
retVal = `rgb(${value.r}, ${value.g}, ${value.b})`;
} else if (category === 'font-family') {
retVal = value
.map(font => {
... | javascript | {
"resource": ""
} |
q48113 | train | function (/*Date*/date, /*String*/interval, /*int*/amount) {
var res = addTransform(interval, date, amount || 0);
amount = res[0];
var property = res[1];
var sum = new Date(+date);
var fixOvershoot = res[2];
if (property) {
... | javascript | {
"resource": ""
} | |
q48114 | train | function (/*Date*/date1, /*Date?*/date2, /*String*/interval, utc) {
date2 = date2 || new Date();
interval = interval || "day";
return differenceTransform(interval, date1, date2, utc);
} | javascript | {
"resource": ""
} | |
q48115 | train | function (leftContext, rightContext) {
var leftMatch = leftContext.match,
fh = leftMatch.factHash,
alias = this.__alias,
rightFact = rightContext.fact;
fh[alias] = rightFact.object;
var ret = this.constraint.assert(fh);
fh[a... | javascript | {
"resource": ""
} | |
q48116 | getSeverity | train | function getSeverity(config, ruleId) {
const rules = config && config.rules
const ruleOptions = rules && rules[ruleId]
const severity = Array.isArray(ruleOptions) ? ruleOptions[0] : ruleOptions
switch (severity) {
case 2:
case "error":
return 2
case 1:
case ... | javascript | {
"resource": ""
} |
q48117 | getCommentAt | train | function getCommentAt(message, sourceCode) {
if (sourceCode != null) {
const loc = { line: message.line, column: message.column - 1 }
const index = sourceCode.getIndexFromLoc(loc)
const options = { includeComments: true }
const comment = sourceCode.getTokenByRangeStart(index, options... | javascript | {
"resource": ""
} |
q48118 | format | train | function format(text) {
const lintResult = linter.executeOnText(text)
return lintResult.results[0].output || text
} | javascript | {
"resource": ""
} |
q48119 | createIndex | train | function createIndex(dirPath) {
const dirName = path.basename(dirPath)
return format(`/** DON'T EDIT THIS FILE; was created by scripts. */
"use strict"
module.exports = {
${fs
.readdirSync(dirPath)
.map(file => path.basename(file, ".js"))
.map(id => `"${id}":... | javascript | {
"resource": ""
} |
q48120 | operative | train | function operative(module, dependencies) {
var getBase = operative.getBaseURL;
var getSelf = operative.getSelfURL;
var OperativeContext = operative.hasWorkerSupport ? operative.Operative.BrowserWorker : operative.Operative.Iframe;
if (typeof module == 'function') {
// Allow a single function to be passed.... | javascript | {
"resource": ""
} |
q48121 | train | function(input, onlyPrimitives, options) {
if (
typeof input === 'boolean' ||
typeof input === 'number' ||
typeof input === 'function' ||
input === null ||
input instanceof Date
) {
return true;
}
if (typeof input === 'string' && input.indexOf('\n') === -1) {
return true;
}
if (... | javascript | {
"resource": ""
} | |
q48122 | _handleCommandResult | train | function _handleCommandResult(result) {
// if we're running via the cli, we can print human-friendly responses
// otherwise we return proper JSON
logger.info('handling command result');
if (result.result) {
logger.debug(result.result);
} else if (result.error) {
logger.error(result.error);
}
if (... | javascript | {
"resource": ""
} |
q48123 | train | function(opts) {
this.name = opts.name;
this.path = opts.path;
this.workspace = opts.workspace;
this.subscription = opts.subscription;
this.origin = opts.origin;
this.username = opts.username;
this.password = opts.password;
this.accessToken = opts.accessToken;
this.refreshToken = opts.refreshToken;
... | javascript | {
"resource": ""
} | |
q48124 | _loadCmds | train | function _loadCmds(dirpath) {
if (fs.existsSync(dirpath) && fs.statSync(dirpath).isDirectory()) {
var commandFiles = util.walkSync(dirpath);
_.each(commandFiles, function(cf) {
_require(cf);
});
} else {
logger.debug('Directory not found '+dirpath);
throw new Error('Command... | javascript | {
"resource": ""
} |
q48125 | _findProjectPathById | train | function _findProjectPathById(id) {
logger.debug('_findProjectPathById');
logger.debug(id);
var projectPathToReturn;
var workspaces = config.get('mm_workspace');
if (!_.isArray(workspaces)) {
workspaces = [workspaces];
}
logger.silly(workspaces);
_.each(workspaces, function(workspacePath) {
// /... | javascript | {
"resource": ""
} |
q48126 | IndexService | train | function IndexService(opts) {
util.applyProperties(this, opts);
if (this.project) {
this.metadataHelper = new MetadataHelper({ sfdcClient : this.project.sfdcClient });
this.sfdcClient = this.project.sfdcClient;
} else if (this.sfdcClient) {
this.metadataHelper = new MetadataHelper({ sfdcClient : this.... | javascript | {
"resource": ""
} |
q48127 | LI | train | function LI(props) {
return (
<MenuItem
style={{cursor: 'pointer', userSelect: 'none'}}
highlightedStyle={{background: 'gray'}}
onItemChosen={e => {
console.log(`selected ${props.children}, byKeyboard: ${String(e.byKeyboard)}`);
}}
{...props}
/>
);
} | javascript | {
"resource": ""
} |
q48128 | train | function (src, callback, context) {
/*eslint max-statements: [2, 32]*/
var setup;
if (callback && typeof callback !== "function") {
context = callback.context || context;
setup = callback.setup;
callback = callback.callback;
}
var script = document.createElement("script");
va... | javascript | {
"resource": ""
} | |
q48129 | imageCompression | train | async function imageCompression (file, options) {
let compressedFile
options.maxSizeMB = options.maxSizeMB || Number.POSITIVE_INFINITY
options.useWebWorker = typeof options.useWebWorker === 'boolean' ? options.useWebWorker : true
if (!(file instanceof Blob || file instanceof File)) {
throw new Error('The... | javascript | {
"resource": ""
} |
q48130 | sign | train | function sign(x) {
// eslint-disable-next-line no-self-compare
return typeof x === "number" ? x ? x < 0 ? -1 : 1 : x === x ? x : NaN : NaN;
} | javascript | {
"resource": ""
} |
q48131 | findPhraseInDirection | train | function findPhraseInDirection(node, index, parent, offset) {
var children = parent.children
var nodes = []
var stems = []
var words = []
var queue = []
var child
while (children[(index += offset)]) {
child = children[index]
if (child.type === 'WhiteSpaceNode') {
queue.push(child)
} el... | javascript | {
"resource": ""
} |
q48132 | getKeyphrases | train | function getKeyphrases(results, maximum) {
var stemmedPhrases = {}
var initialWords = []
var stemmedPhrase
var index
var length
var otherIndex
var keyword
var matches
var phrase
var stems
var score
var first
var match
// Iterate over all grouped important words...
for (keyword in results)... | javascript | {
"resource": ""
} |
q48133 | filterResults | train | function filterResults(results, maximum) {
var filteredResults = []
var indices = []
var matrix = {}
var column
var key
var score
var interpolated
var index
var otherIndex
var maxScore
for (key in results) {
score = results[key].score
if (!matrix[score]) {
matrix[score] = []
... | javascript | {
"resource": ""
} |
q48134 | merge | train | function merge(prev, current, next) {
return prev
.concat()
.reverse()
.concat([current], next)
} | javascript | {
"resource": ""
} |
q48135 | findPhrase | train | function findPhrase(match) {
var node = match.node
var prev = findPhraseInDirection(node, match.index, match.parent, -1)
var next = findPhraseInDirection(node, match.index, match.parent, 1)
var stems = merge(prev.stems, stemNode(node), next.stems)
return {
stems: stems,
value: stems.join(' '),
no... | javascript | {
"resource": ""
} |
q48136 | getImportantWords | train | function getImportantWords(node) {
var words = {}
visit(node, 'WordNode', visitor)
return words
function visitor(word, index, parent) {
var match
var stem
if (isImportant(word)) {
stem = stemNode(word)
match = {
node: word,
index: index,
parent: parent
}... | javascript | {
"resource": ""
} |
q48137 | cloneMatches | train | function cloneMatches(words) {
var result = {}
var key
var match
for (key in words) {
match = words[key]
result[key] = {
matches: match.matches,
stem: match.stem,
score: match.score
}
}
return result
} | javascript | {
"resource": ""
} |
q48138 | isImportant | train | function isImportant(node) {
return (
node &&
node.data &&
node.data.partOfSpeech &&
(node.data.partOfSpeech.indexOf('N') === 0 ||
(node.data.partOfSpeech === 'JJ' &&
isUpperCase(nlcstToString(node).charAt(0))))
)
} | javascript | {
"resource": ""
} |
q48139 | postScreenshot | train | function postScreenshot (options) {
options.hash = _private.getDevHash(options.secret);
return _private.makeRequest(_getUploadOptions(options), 'Unable to upload document');
} | javascript | {
"resource": ""
} |
q48140 | postFile | train | function postFile (options) {
options.hash = _private.getDevHash(options.secret);
return _private.makeRequest(_getUploadOptions(options),
'Unable to upload document');
} | javascript | {
"resource": ""
} |
q48141 | getLanguages | train | function getLanguages(options) {
options.hash = _private.getDevHash(options.secret);
return _private.makeRequest(_getLink(options), 'Unable to fetch project languages');
} | javascript | {
"resource": ""
} |
q48142 | createRows | train | function createRows(items, columns, columnNames, paddingChr) {
return items.map(item => {
let row = []
let numLines = 0
columnNames.forEach(columnName => {
numLines = Math.max(numLines, item[columnName].length)
})
// combine matching lines of each rows
for (let i = 0; i < numLines; i++) ... | javascript | {
"resource": ""
} |
q48143 | endsWith | train | function endsWith(target, searchString, position) {
position = position || target.length;
position = position - searchString.length;
let lastIndex = target.lastIndexOf(searchString);
return lastIndex !== -1 && lastIndex === position;
} | javascript | {
"resource": ""
} |
q48144 | repeatString | train | function repeatString(str, len) {
return Array.apply(null, {length: len + 1}).join(str).slice(0, len)
} | javascript | {
"resource": ""
} |
q48145 | padRight | train | function padRight(str, max, chr) {
str = str != null ? str : ''
str = String(str)
var length = max - wcwidth(str)
if (length <= 0) return str
return str + repeatString(chr || ' ', length)
} | javascript | {
"resource": ""
} |
q48146 | padCenter | train | function padCenter(str, max, chr) {
str = str != null ? str : ''
str = String(str)
var length = max - wcwidth(str)
if (length <= 0) return str
var lengthLeft = Math.floor(length/2)
var lengthRight = length - lengthLeft
return repeatString(chr || ' ', lengthLeft) + str + repeatString(chr || ' ', lengthRigh... | javascript | {
"resource": ""
} |
q48147 | splitIntoLines | train | function splitIntoLines(str, max) {
function _splitIntoLines(str, max) {
return str.trim().split(' ').reduce(function(lines, word) {
var line = lines[lines.length - 1]
if (line && wcwidth(line.join(' ')) + wcwidth(word) < max) {
lines[lines.length - 1].push(word) // add to line
}
e... | javascript | {
"resource": ""
} |
q48148 | splitLongWords | train | function splitLongWords(str, max, truncationChar) {
str = str.trim()
var result = []
var words = str.split(' ')
var remainder = ''
var truncationWidth = wcwidth(truncationChar)
while (remainder || words.length) {
if (remainder) {
var word = remainder
remainder = ''
} else {
var w... | javascript | {
"resource": ""
} |
q48149 | truncateString | train | function truncateString(str, max) {
str = str != null ? str : ''
str = String(str)
if(max == Infinity) return str
var i = 0
var wwidth = 0
while (i < str.length) {
var w = wcwidth(str.charAt(i))
if(w + wwidth > max)
break
wwidth += w
++i
}
return str.slice(0, i)
} | javascript | {
"resource": ""
} |
q48150 | initTranslate | train | function initTranslate(props) {
const element = props.element,
elementStyle = props.elementStyle,
curPosition = getBBox(element), // Get BBox before change style.
RESTORE_PROPS = ['display', 'marginTop', 'marginBottom', 'width', 'height'];
RESTORE_PROPS.unshift(cssPropTransform);
// Reset `transition... | javascript | {
"resource": ""
} |
q48151 | validPPValue | train | function validPPValue(value) {
// Get PPValue from string (all `/s` were already removed)
function string2PPValue(inString) {
var matches = /^(.+?)(%)?$/.exec(inString);
var value = void 0,
isRatio = void 0;
return matches && isFinite(value = parseFloat(matches[1])) ? { value: (isRatio = !!(mat... | javascript | {
"resource": ""
} |
q48152 | validPPBBox | train | function validPPBBox(bBox) {
if (!isObject(bBox)) {
return null;
}
var ppValue = void 0;
if ((ppValue = validPPValue(bBox.left)) || (ppValue = validPPValue(bBox.x))) {
bBox.left = bBox.x = ppValue;
} else {
return null;
}
if ((ppValue = validPPValue(bBox.top)) || (ppValue = validPPValue(bBox.y... | javascript | {
"resource": ""
} |
q48153 | resolvePPBBox | train | function resolvePPBBox(ppBBox, baseBBox) {
var prop2Axis = { left: 'x', right: 'x', x: 'x', width: 'x',
top: 'y', bottom: 'y', y: 'y', height: 'y' },
baseOriginXY = { x: baseBBox.left, y: baseBBox.top },
baseSizeXY = { x: baseBBox.width, y: baseBBox.height };
return validBBox(Object.keys(ppBBox).red... | javascript | {
"resource": ""
} |
q48154 | initAnim | train | function initAnim(element, gpuTrigger) {
var style = element.style;
style.webkitTapHighlightColor = 'transparent';
// Only when it has no shadow
var cssPropBoxShadow = CSSPrefix.getName('boxShadow'),
boxShadow = window.getComputedStyle(element, '')[cssPropBoxShadow];
if (!boxShadow || boxShadow === 'no... | javascript | {
"resource": ""
} |
q48155 | moveTranslate | train | function moveTranslate(props, position) {
var elementBBox = props.elementBBox;
if (position.left !== elementBBox.left || position.top !== elementBBox.top) {
var offset = props.htmlOffset;
props.elementStyle[cssPropTransform] = 'translate(' + (position.left + offset.left) + 'px, ' + (position.top + offset.to... | javascript | {
"resource": ""
} |
q48156 | move | train | function move(props, position, cbCheck) {
var elementBBox = props.elementBBox;
function fix() {
if (props.minLeft >= props.maxLeft) {
// Disabled
position.left = elementBBox.left;
} else if (position.left < props.minLeft) {
position.left = props.minLeft;
} else if (position.left > pro... | javascript | {
"resource": ""
} |
q48157 | train | function (options) {
return qfs.listTree('.', function (filePath) {
var file = path.basename(filePath)
// Do not traverse into the node_modules directory
if (file === 'node_modules' || file === '.git') {
return null
}
// Collect all files "credits.md"
if (file === 'credit... | javascript | {
"resource": ""
} | |
q48158 | createPartialTree | train | function createPartialTree (currentFile, partials, visitedFiles) {
if (visitedFiles[currentFile.name]) {
return {
label: '*' + currentFile.name + '*',
name: currentFile.name
}
}
visitedFiles[currentFile.name] = true
var result = {
label: currentFile.name,
name: currentFile.name,
... | javascript | {
"resource": ""
} |
q48159 | train | function(target) {
var undef;
each(arguments, function(arg, i) {
if (i > 0) {
each(arg, function(value, key) {
if (value !== undef) {
if (typeOf(target[key]) === typeOf(value) && !!~inArray(typeOf(value), ['array', 'object'])) {
extend(target[key], value);
} else {
target[key]... | javascript | {
"resource": ""
} | |
q48160 | train | function(obj) {
var prop;
if (!obj || typeOf(obj) !== 'object') {
return true;
}
for (prop in obj) {
return false;
}
return true;
} | javascript | {
"resource": ""
} | |
q48161 | train | function(str) {
if (!str) {
return str;
}
return String.prototype.trim ? String.prototype.trim.call(str) : str.toString().replace(/^\s*/, '').replace(/\s*$/, '');
} | javascript | {
"resource": ""
} | |
q48162 | train | function(size) {
if (typeof(size) !== 'string') {
return size;
}
var muls = {
t: 1099511627776,
g: 1073741824,
m: 1048576,
k: 1024
},
mul;
size = /^([0-9]+)([mgk]?)$/.exec(size.toLowerCase().replace(/[^0-9mkg]/g, ''));
mul = size[2];
size = +size[1];
if (muls.hasOwnProperty... | javascript | {
"resource": ""
} | |
q48163 | train | function(type, fn, priority, scope) {
var self = this, list;
type = Basic.trim(type);
if (/\s/.test(type)) {
// multiple event types were passed for one handler
Basic.each(type.split(/\s+/), function(type) {
self.addEventListener(type, fn, priority, scope);
});
return;
... | javascript | {
"resource": ""
} | |
q48164 | train | function(type, fn) {
type = type.toLowerCase();
var list = eventpool[this.uid] && eventpool[this.uid][type], i;
if (list) {
if (fn) {
for (i = list.length - 1; i >= 0; i--) {
if (list[i].fn === fn) {
list.splice(i, 1);
break;
}
}
} else {
list = ... | javascript | {
"resource": ""
} | |
q48165 | train | function(type) {
var uid, list, args, tmpEvt, evt = {}, result = true, undef;
if (Basic.typeOf(type) !== 'string') {
// we can't use original object directly (because of Silverlight)
tmpEvt = type;
if (Basic.typeOf(tmpEvt.type) === 'string') {
type = tmpEvt.type;
if (tmpEvt.tot... | javascript | {
"resource": ""
} | |
q48166 | train | function() {
var container, shimContainer = Dom.get(this.shimid);
// if no container for shim, create one
if (!shimContainer) {
container = this.options.container ? Dom.get(this.options.container) : document.body;
// create shim container and insert it at an absolute position into the outer cont... | javascript | {
"resource": ""
} | |
q48167 | train | function(data) {
if (this.ruid) {
this.getRuntime().exec.call(this, 'Blob', 'destroy');
this.disconnectRuntime();
this.ruid = null;
}
data = data || '';
// if dataUrl, convert to binary string
var matches = data.match(/^data:([^;]*);base64,/);
if (matches) {
this.type = mat... | javascript | {
"resource": ""
} | |
q48168 | train | function() {
self.convertEventPropsToHandlers(dispatches);
self.bind('RuntimeInit', function(e, runtime) {
self.ruid = runtime.uid;
self.shimid = runtime.shimid;
self.bind("Ready", function() {
self.trigger("Refresh");
}, 999);
self.bind("Change", function() {
var files =... | javascript | {
"resource": ""
} | |
q48169 | train | function(state) {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'disable', Basic.typeOf(state) === 'undefined' ? true : state);
}
} | javascript | {
"resource": ""
} | |
q48170 | train | function() {
var runtime = this.getRuntime();
if (runtime) {
runtime.exec.call(this, 'FileInput', 'destroy');
this.disconnectRuntime();
}
if (Basic.typeOf(this.files) === 'array') {
// no sense in leaving associated files behind
Basic.each(this.files, function(file) {
file.des... | javascript | {
"resource": ""
} | |
q48171 | train | function() {
this.result = null;
if (Basic.inArray(this.readyState, [FileReader.EMPTY, FileReader.DONE]) !== -1) {
return;
} else if (this.readyState === FileReader.LOADING) {
this.readyState = FileReader.DONE;
}
if (_fr) {
_fr.getRuntime().exec.call(this, 'FileReader', 'abort')... | javascript | {
"resource": ""
} | |
q48172 | train | function() {
this.abort();
if (_fr) {
_fr.getRuntime().exec.call(this, 'FileReader', 'destroy');
_fr.disconnectRuntime();
}
self = _fr = null;
} | javascript | {
"resource": ""
} | |
q48173 | train | function(url) {
var ports = { // we ignore default ports
http: 80,
https: 443
}
, urlp = parseUrl(url)
;
return urlp.scheme + '://' + urlp.host + (urlp.port !== ports[urlp.scheme] ? ':' + urlp.port : '') + urlp.path + (urlp.query ? urlp.query : '');
} | javascript | {
"resource": ""
} | |
q48174 | train | function (inside, before, insert, root) {
root = root || _.languages;
var grammar = root[inside];
var ret = {};
for (var token in grammar) {
if (grammar.hasOwnProperty(token)) {
if (token == before) {
for (var newToken in insert) {
if (insert.hasOwnProperty(... | javascript | {
"resource": ""
} | |
q48175 | updateMetrics | train | function updateMetrics() {
var dprM;
isVwDirty = false;
DPR = window.devicePixelRatio;
cssCache = {};
sizeLengthCache = {};
dprM = (DPR || 1) * cfg.xQuant;
if(!cfg.uT){
cfg.maxX = Math.max(1.3, cfg.maxX);
dprM = Math.min( dprM, cfg.maxX );
ri.DPR = dprM;
}
units.width = Math.max(window.i... | javascript | {
"resource": ""
} |
q48176 | getIndex | train | function getIndex(increment) {
var
max = $related.length,
newIndex = (index + increment) % max;
return (newIndex < 0) ? max + newIndex : newIndex;
} | javascript | {
"resource": ""
} |
q48177 | appendHTML | train | function appendHTML() {
if (!$box && document.body) {
init = false;
$window = $(window);
$box = $tag(div).attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''}).hide();
$overlay = $tag(div, "Overlay", isIE6 ? 'position:absolute' : '').hide();
$wrap = $tag(div, "Wrapper");
$conte... | javascript | {
"resource": ""
} |
q48178 | addBindings | train | function addBindings() {
if ($box) {
if (!init) {
init = true;
// Cache values needed for size calculations
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
interfaceWidth = $leftBorder.width() + $rightBord... | javascript | {
"resource": ""
} |
q48179 | train | function(layouts) {
var currentLayout;
layouts = layouts.slice(0);
currentLayout = self.compile(str, layoutFile);
layouts.push(currentLayout);
if (useCache) {
self.cache[layoutFile] = layouts.slice(0);
}
cb(null, layouts);
} | javascript | {
"resource": ""
} | |
q48180 | parseLayout | train | function parseLayout(str, filename, cb) {
var layoutFile = self.declaredLayoutFile(str, filename);
if (layoutFile) {
self.cacheLayout(layoutFile, options.cache, cb);
} else {
cb(null, null);
}
} | javascript | {
"resource": ""
} |
q48181 | renderTemplate | train | function renderTemplate(template, locals, cb) {
var res;
try {
var localTemplateOptions = self.getLocalTemplateOptions(locals);
var localsClone = _.extend({}, locals);
self.updateLocalTemplateOptions(localsClone, undefined);
res = template(localsClone, _.merge({}, self._options.template... | javascript | {
"resource": ""
} |
q48182 | render | train | function render(template, locals, layoutTemplates, cb) {
if (!layoutTemplates) layoutTemplates = [];
// We'll render templates from bottom to top of the stack, each template
// being passed the rendered string of the previous ones as `body`
var i = layoutTemplates.length - 1;
var _stackRenderer = ... | javascript | {
"resource": ""
} |
q48183 | loadBeautify | train | function loadBeautify() {
if (!self.beautify) {
self.beautify = require('js-beautify').html;
var rc = path.join(process.cwd(), '.jsbeautifyrc');
if (fs.existsSync(rc)) {
self.beautifyrc = JSON.parse(fs.readFileSync(rc, 'utf8'));
}
}
} | javascript | {
"resource": ""
} |
q48184 | getSourceTemplate | train | function getSourceTemplate(cb) {
if (options.cache) {
var info = self.cache[filename];
if (info) {
return cb(null, info.source, info.template);
}
}
fs.readFile(filename, 'utf8', function(err, source) {
if (err) return cb(err);
var template = self.compile(source, filen... | javascript | {
"resource": ""
} |
q48185 | compileFile | train | function compileFile(locals, cb) {
getSourceTemplate(function(err, source, template) {
if (err) return cb(err);
// Try to get the layout
parseLayout(source, filename, function(err, layoutTemplates) {
if (err) return cb(err);
function renderIt(layoutTemplates) {
if (self... | javascript | {
"resource": ""
} |
q48186 | toBuffer | train | function toBuffer(value, encoding) {
if( typeof value === 'string') {
encoding = encoding || 'hex';
if( !re.test(encoding) ) {
throw new Error('[toBuffer] bad encoding. Must be: utf8|ascii|binary|hex|utf16le|ucs2|base64');
}
try {
return Bu... | javascript | {
"resource": ""
} |
q48187 | raiseOnUnsafeCSS | train | function raiseOnUnsafeCSS() {
var css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var foundInName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '\'not provided\'';
css = new _cleanCss2.default({
shorthandCompacting: false
}).minify(css).styles... | javascript | {
"resource": ""
} |
q48188 | sortTags | train | function sortTags(tagA, tagB) {
if ((tagA[0] === tagA[0].toUpperCase()) && (tagB[0] !== tagB[0].toUpperCase())) {
return 1;
}
else if ((tagA[0] !== tagA[0].toUpperCase()) && (tagB[0] === tagB[0].toUpperCase())) {
return -1;
}
else {
return tagA < tagB;
}
} | javascript | {
"resource": ""
} |
q48189 | Encoder | train | function Encoder (opts) {
if (!(this instanceof Encoder)) {
return new Encoder(opts);
}
Transform.call(this, opts);
// lame malloc()s the "gfp" buffer
this.gfp = binding.lame_init();
// set default options
if (!opts) opts = {};
if (null == opts.channels) opts.channels = 2;
if (null == opts.bitDe... | javascript | {
"resource": ""
} |
q48190 | Decoder | train | function Decoder (opts) {
if (!(this instanceof Decoder)) {
return new Decoder(opts);
}
Transform.call(this, opts);
var ret;
ret = binding.mpg123_new(opts ? opts.decoder : null);
if (Buffer.isBuffer(ret)) {
this.mh = ret;
} else {
throw new Error('mpg123_new() failed: ' + ret);
}
ret = b... | javascript | {
"resource": ""
} |
q48191 | train | function() {
if (bodiesCount === 0) return true; // TODO: This will never fire 'stable'
var lastMove = physicsSimulator.step();
// Save the movement in case if someone wants to query it in the step
// callback.
api.lastMove = lastMove;
// Allow listeners to perform low-level actio... | javascript | {
"resource": ""
} | |
q48192 | train | function (nodeId) {
var body = getInitializedBody(nodeId);
body.setPosition.apply(body, Array.prototype.slice.call(arguments, 1));
physicsSimulator.invalidateBBox();
} | javascript | {
"resource": ""
} | |
q48193 | isNodeOriginallyPinned | train | function isNodeOriginallyPinned(node) {
return (node && (node.isPinned || (node.data && node.data.isPinned)));
} | javascript | {
"resource": ""
} |
q48194 | toRawDoc | train | function toRawDoc(typeInfo, obj) {
obj = extend(true, {}, obj);
var doc = {};
if (obj.rev) {
doc._rev = obj.rev;
delete obj.rev;
}
if (obj.attachments) {
doc._attachments = obj.attachments;
delete obj.attachments;
}
var id = obj.id || uuid();
delete obj.id;
... | javascript | {
"resource": ""
} |
q48195 | fromRawDoc | train | function fromRawDoc(pouchDoc) {
var obj = pouchDoc.data;
obj.id = deserialize(pouchDoc._id);
obj.rev = pouchDoc._rev;
if (pouchDoc._attachments) {
obj.attachments = pouchDoc._attachments;
}
return obj;
} | javascript | {
"resource": ""
} |
q48196 | isDeleted | train | function isDeleted(type, id) {
var typeInfo = getTypeInfo(type);
return db.get(serialize(typeInfo.documentType, id))
.then(function (doc) { return !!doc._deleted; })
.catch(function (err) { return err.reason === "deleted" ? true : null; });
} | javascript | {
"resource": ""
} |
q48197 | initKarmaParallelizer | train | function initKarmaParallelizer(root, karma, shardIndexInfoMap) {
var idParamExtractor = /(\?|&)id=(\d+)(&|$)/;
var matches = idParamExtractor.exec(parent.location.search);
var id = (matches && matches[2]) || null;
if (
!id ||
!shardIndexInfoMap.hasOwnProperty(id) ||
!shardIndexInfoMap[id].shouldSha... | javascript | {
"resource": ""
} |
q48198 | wrap | train | function wrap(fn, isFocus, isDescription, isSpec) {
if (!fn) return fn;
return function(name, def) {
if (isDescription && depth === 0) {
// Reset isFaking on top-level descriptions
isFaking = !shouldUseDescription(name, def);
}
hasOwnSpecs = hasOwnSpecs || (isSpec && !isFaking... | javascript | {
"resource": ""
} |
q48199 | wrapWithDispatch | train | function wrapWithDispatch(asyncItems) {
return asyncItems.map((item) => {
const { key } = item;
if (!key) return item;
return {
...item,
promise: (options) => {
const { store: { dispatch } } = options;
const next = item.promise(options);
// NOTE: possibly refactor thi... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.