_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31700 | addStaticRoute | train | function addStaticRoute(routePath, targets) {
if (!Object.isArray(targets)) {
targets = [targets];
}
targets.forEach(function(target) {
if (target)
app.use(routePath, app.middleware.static(path.resolve(config.rootDir, target)));
});
} | javascript | {
"resource": ""
} |
q31701 | parseRoute | train | function parseRoute(route, target) {
var verbs, routePath, routeParts;
routeParts = route.split(' ');
if (routeParts.length === 1) {
verbs = ['all'];
routePath = routeParts[0];
} else {
verbs = routeParts[0].split(',');
verbs.map(function (verb) {
return verb.trim().toLowerCase();
});
rou... | javascript | {
"resource": ""
} |
q31702 | parseParameter | train | function parseParameter(spec, ctx, params) {
if (!spec || !isObject(spec)) return spec;
for (var i=0, n=PARSERS.length, p; i<n; ++i) {
p = PARSERS[i];
if (spec.hasOwnProperty(p.key)) {
return p.parse(spec, ctx, params);
}
}
return spec;
} | javascript | {
"resource": ""
} |
q31703 | getExpression | train | function getExpression(_, ctx, params) {
if (_.$params) { // parse expression parameters
parseParameters(_.$params, ctx, params);
}
var k = 'e:' + _.$expr + '_' + _.$name;
return ctx.fn[k]
|| (ctx.fn[k] = accessor(parameterExpression(_.$expr, ctx), _.$fields, _.$name));
} | javascript | {
"resource": ""
} |
q31704 | getKey | train | function getKey(_, ctx) {
var k = 'k:' + _.$key + '_' + (!!_.$flat);
return ctx.fn[k] || (ctx.fn[k] = key(_.$key, _.$flat));
} | javascript | {
"resource": ""
} |
q31705 | getField | train | function getField(_, ctx) {
if (!_.$field) return null;
var k = 'f:' + _.$field + '_' + _.$name;
return ctx.fn[k] || (ctx.fn[k] = field(_.$field, _.$name));
} | javascript | {
"resource": ""
} |
q31706 | getCompare | train | function getCompare(_, ctx) {
var k = 'c:' + _.$compare + '_' + _.$order,
c = array(_.$compare).map(function(_) {
return (_ && _.$tupleid) ? tupleid : _;
});
return ctx.fn[k] || (ctx.fn[k] = compare(c, _.$order));
} | javascript | {
"resource": ""
} |
q31707 | getEncode | train | function getEncode(_, ctx) {
var spec = _.$encode,
encode = {}, name, enc;
for (name in spec) {
enc = spec[name];
encode[name] = accessor(encodeExpression(enc.$expr, ctx), enc.$fields);
encode[name].output = enc.$output;
}
return encode;
} | javascript | {
"resource": ""
} |
q31708 | getSubflow | train | function getSubflow(_, ctx) {
var spec = _.$subflow;
return function(dataflow, key, parent) {
var subctx = parseDataflow(spec, ctx.fork()),
op = subctx.get(spec.operators[0].id),
p = subctx.signals.parent;
if (p) p.set(parent);
return op;
};
} | javascript | {
"resource": ""
} |
q31709 | start | train | function start() {
// Listen to the port
app.listen(hrsConfigs.port, function (err) {
if (err) {
info(err);
}
info('Running on http://%s:%s', hrsConfigs.address, hrsConfigs.port);
});
} | javascript | {
"resource": ""
} |
q31710 | train | function(args,next) {
// do nothing now but in 1 sec
setTimeout(function() {
// if i'm job id 10 or 20, let's add
// another job dynamicaly in the queue.
// It can be usefull for network operation (retry on timeout)
if (args._jobId==10||args._jobId==20) {
myQueueJ... | javascript | {
"resource": ""
} | |
q31711 | isVoidElement | train | function isVoidElement(elName) {
var result = false;
if (elName && elName.toLowerCase) {
result = VOID_HTML_ELEMENTS.hasOwnProperty(elName.toLowerCase());
}
return result;
} | javascript | {
"resource": ""
} |
q31712 | train | function (blockList) {
this.errors = [];
this.tree = new Node("file", null);
this.tree.content = [];
this._advance(blockList, 0, this.tree.content);
this._postProcessTree();
} | javascript | {
"resource": ""
} | |
q31713 | train | function (description, errdesc) {
//TODO: errdesc is a bit vague
var desc = {
description : description
};
if (errdesc) {
if (errdesc.line) { // Integers
desc.line = errdesc.line;
desc.column = errdesc.column;
}
... | javascript | {
"resource": ""
} | |
q31714 | train | function(expAst, attribute) {
//verify that an event handler is a function call
if (expAst && isEventHandlerAttr(attribute.name) && expAst.v !== '(') {
this._logError("Event handler attribute only support function expressions", attribute.value[0]);
}
} | javascript | {
"resource": ""
} | |
q31715 | train | function (blocks, startIndex, out, optEndFn) {
var block, type;
if (blocks) {
for (var i = startIndex; i < blocks.length; i++) {
block = blocks[i];
type = block.type;
if (optEndFn && optEndFn(type, block.name)) {
// we stop... | javascript | {
"resource": ""
} | |
q31716 | train | function() {
var nodes = this.tree.content;
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].type === "template") {
this._processNodeContent(nodes[i].content,nodes[i]);
}
}
} | javascript | {
"resource": ""
} | |
q31717 | train | function(nodeList, parent) {
// Ensure that {let} nodes are always at the beginning of a containter element
var node, contentFound = false; // true when a node different from let is found
for (var i = 0; i < nodeList.length; i++) {
node = nodeList[i];
//console.log(i+":"+... | javascript | {
"resource": ""
} | |
q31718 | train | function (index, blocks, out) {
var node = new Node("template");
var block = blocks[index];
var validationResults = this._processTemplateStart(block.attributes, block.closingBrace);
if (validationResults.errors.length > 0) {
this._logError("Invalid template declaration", {
... | javascript | {
"resource": ""
} | |
q31719 | train | function (index, blocks, out) {
var node = new Node("plaintext"), block = blocks[index];
node.value = block.value;
out.push(node);
return index;
} | javascript | {
"resource": ""
} | |
q31720 | train | function (index, blocks, out) {
var node = new Node("log"), block = blocks[index];
node.line = block.line;
node.column = block.column;
node.exprs = block.exprs;
out.push(node);
return index;
} | javascript | {
"resource": ""
} | |
q31721 | train | function (index, blocks, out) {
//creates the if node
var node = new Node("if"), block = blocks[index], lastValidIndex = index;
node.condition = {
"category": block.condition.category,
"value": block.condition.value,
"line": block.condition.line,
"... | javascript | {
"resource": ""
} | |
q31722 | train | function (index, blocks, out) {
//creates the foreach node
var node = new Node("foreach"), block = blocks[index];
node.item = block.item;
node.key = block.key;
node.collection = block.colref;
node.content = [];
out.push(node);
//fills node.content with t... | javascript | {
"resource": ""
} | |
q31723 | train | function (index, blocks, out) {
var block = blocks[index];
if (isVoidElement(block.name)) {
block.closed=true;
}
return this._elementOrComponent("element", index, blocks, out);
} | javascript | {
"resource": ""
} | |
q31724 | train | function (blockType, index, blocks, out) {
var node = new Node(blockType), block = blocks[index], blockValue, expAst;
node.name = block.name;
node.closed = block.closed;
if (block.ref) {
// only for components
node.ref = block.ref;
}
// Handle att... | javascript | {
"resource": ""
} | |
q31725 | train | function(ref) {
if (ref.category !== "objectref" || !ref.path || !ref.path.length || !ref.path.join) {
return null;
}
return ref.path.join(".");
} | javascript | {
"resource": ""
} | |
q31726 | train | function (index, blocks, out) {
// only called in case of error
var block = blocks[index];
var msg = "Invalid HTML element syntax";
if (block.code && block.code.match(/^<\/?@/)) {
//when it starts with <@ or </@
msg = "Invalid component attribute syntax";
... | javascript | {
"resource": ""
} | |
q31727 | train | function (index, blocks, out) {
// only called in case of error, i.e not digested by _elementOrComponent
var block = blocks[index], name = block.name;
if (isVoidElement(name)) {
this._logError("The end element </" + name + "> was rejected as <" + name + "> is a void HTML element and ca... | javascript | {
"resource": ""
} | |
q31728 | train | function (index, blocks, out) {
// only called in case of error, i.e not digested by _elementOrComponent
var block = blocks[index], path = this._getComponentPathAsString(block.ref) ;
this._logError("End component </#" + path + "> does not match any <#" + path + "> component", block);
ret... | javascript | {
"resource": ""
} | |
q31729 | Connector | train | function Connector(settings) {
this.mailgun = Mailgun({apiKey: settings.apikey, domain: settings.domain});
} | javascript | {
"resource": ""
} |
q31730 | callObservers | train | function callObservers(object, chgeset) {
var ln = object[OBSERVER_PROPERTY];
if (ln) {
var elt;
for (var i = 0, sz = ln.length; sz > i; i++) {
elt = ln[i];
if (elt.constructor === Function) {
elt(chgeset);
}
}
}
} | javascript | {
"resource": ""
} |
q31731 | train | function (object, property, value) {
if (object[OBSERVER_PROPERTY]) {
var existed = ownProperty.call(object, property), oldVal = object[property];
delete object[property];
if (existed) {
var chgset=[changeDesc(object, property, object[property], oldVal, "dele... | javascript | {
"resource": ""
} | |
q31732 | train | function (tplctxt, scopevars, ctlWrapper, ctlInitArgs, rootscope) {
var vs = rootscope ? Object.create(rootscope) : {}, nm, argNames = []; // array of argument names
if (scopevars) {
for (var i = 0, sz = scopevars.length; sz > i; i += 2) {
nm = scopevars[i];
v... | javascript | {
"resource": ""
} | |
q31733 | getGlobalRef | train | function getGlobalRef(name) {
var r=global[name];
if (r===undefined) {
r=null;
}
return r;
} | javascript | {
"resource": ""
} |
q31734 | _validate | train | function _validate (code, lineMap) {
var validationResult = jsv.validate(code);
var result = {isValid: validationResult.isValid};
if (!validationResult.isValid) {
// translate error line numbers
var error, lineNumber;
for (var i = 0; i < validationResult.errors.length; i++) {
... | javascript | {
"resource": ""
} |
q31735 | _getErrorScript | train | function _getErrorScript (errors, fileName) {
var result = '';
if (errors && errors.length) {
var err=errors[0];
var ctxt={
type:"error",
file:fileName,
code:err.code,
line:err.line,
column:err.column
};
var suberrors = ... | javascript | {
"resource": ""
} |
q31736 | _generateLineMap | train | function _generateLineMap (res, file) {
if (res.errors && res.errors.length) {
return;
}
var syntaxTree = res.syntaxTree, templates = [];
// identify the templates in the syntax tree
for (var i = 0; i < syntaxTree.length; i++) {
if (syntaxTree[i].type === 'template') {
te... | javascript | {
"resource": ""
} |
q31737 | train | function () {
json.unobserve(this.target, this.callback);
this.props=null;
this.callback=null;
this.target=null;
} | javascript | {
"resource": ""
} | |
q31738 | train | function (observer, property) {
if (!property)
property = ALL;
var arr = this.props[property];
if (!arr) {
// property is not observed yet
arr = [];
this.props[property] = arr;
}
arr.push(observer);
} | javascript | {
"resource": ""
} | |
q31739 | PropObserver_notifyChanges | train | function PropObserver_notifyChanges (chglist) {
var c;
for (var i = 0, sz = chglist.length; sz > i; i++) {
c = chglist[i];
if (!c)
continue;
// check if we listen to this property
if (this.props[c.name]) {
PropObserver_notifyChange(this, c, c.name);
... | javascript | {
"resource": ""
} |
q31740 | Naivebayes | train | function Naivebayes(options) {
// set options object
this.options = {};
if (typeof options !== 'undefined') {
if (!options || typeof options !== 'object' || Array.isArray(options)) {
throw TypeError(
`NaiveBayes got invalid 'options': ${options}'. Pass in an object.`
);
}
this.opti... | javascript | {
"resource": ""
} |
q31741 | train | function (listItemContainers, node) {
var isOrdered = node.nodeName === 'OL';
var startIndex = parseInt(node.getAttribute('start'), 10) || 1; // only applicable to ordered lists
var blocks = (listItemContainers || []).map((listItemContainer, listItemIndex) => {
var listItemElems = un... | javascript | {
"resource": ""
} | |
q31742 | train | function(name, eve){
// Bi-directional binding of value
m.addBinding(name, function(prop) {
if (typeof prop == "function") {
this.value = prop();
this[eve] = m.withAttr("value", prop);
} else {
this.value = prop;
}
}, true);
} | javascript | {
"resource": ""
} | |
q31743 | getTag | train | function getTag(el) {
return (el.firstChild === null) ? {'UL':'LI','DL':'DT','TR':'TD'}[el.tagName] || el.tagName : el.firstChild.tagName;
} | javascript | {
"resource": ""
} |
q31744 | wrap | train | function wrap(xhtml, tag) {
var e = document.createElement('div');
e.innerHTML = xhtml;
return e;
} | javascript | {
"resource": ""
} |
q31745 | train | function(o) {
var options = {};
"duration after easing".split(' ').forEach( function(p) {
if (props[p]) {
options[p] = props[p];
delete props[p];
}
});
return options;
} | javascript | {
"resource": ""
} | |
q31746 | train | function(props) {
var serialisedProps = [], key;
if (typeof props != string) {
for (key in props) {
serialisedProps.push(cssstyle(key) + ':' + props[key]);
}
serialisedProps = serialisedProps.join(';');
} else {
serialisedProps = props;
}
return se... | javascript | {
"resource": ""
} | |
q31747 | checkMax | train | function checkMax(value, max) {
if (max) {
if (max.charAt(0) === '-') {
if (value.charAt(0) !== '-')
return false;
return checkMax(max.substr(1), value.substr(1));
} else {
if (value.charAt(0) === '-')
return true;
}
var len = Math.max(value.length, max.length);
m... | javascript | {
"resource": ""
} |
q31748 | writeTopicConfig | train | function writeTopicConfig(client, topic, configs, callback) {
debug('writeTopicConfig: "%s", %j', topic, configs);
updateEntityConfig(client, getTopicConfigPath(topic), configs, callback);
} | javascript | {
"resource": ""
} |
q31749 | writeClientConfig | train | function writeClientConfig(client, clientId, configs, callback) {
debug('writeClientConfig: "%s", %j', clientId, configs);
updateEntityConfig(client, getClientConfigPath(clientId), configs, callback);
} | javascript | {
"resource": ""
} |
q31750 | createParentPath | train | function createParentPath(client, path, callback) {
var parentDir = path.substring(0, path.lastIndexOf('/'));
debug('createParentPath: "%s"', parentDir);
if (parentDir.length != 0) {
client.create(parentDir, function(err) {
if (err) {
if (err.code === NO_NODE) {
return createParentPa... | javascript | {
"resource": ""
} |
q31751 | createPersistentPath | train | function createPersistentPath(client, path, data, callback) {
debug('createPersistentPath: "%s" "%s"', path, data);
data = ensureBuffer(data);
client.create(path, data, function(err) {
if (err) {
if (err.code !== NO_NODE)
return callback(err);
createParentPath(client, path, function(err... | javascript | {
"resource": ""
} |
q31752 | updatePersistentPath | train | function updatePersistentPath(client, path, data, callback) {
debug('updatePersistentPath: "%s" "%s"', path, data);
data = ensureBuffer(data);
client.setData(path, data, function (err) {
if (err) {
if (err.code !== NO_NODE)
return callback(err);
createParentPath(client, path, function(e... | javascript | {
"resource": ""
} |
q31753 | train | function( id, callback ){
var ID = id;
// If the callback is the first parameter
if( typeof id == 'function' ){
ID = 'ID_' + this._ID;
callback = id;
}
this._callbacks[ID] = callback;
this._ID++;
return ID;
} | javascript | {
"resource": ""
} | |
q31754 | train | function( id, xStore ){
Object.defineProperty(xStore, '_dispatcher', {
value: this
});
return this.register( id, xStore.callback );
} | javascript | {
"resource": ""
} | |
q31755 | train | function( ids ) {
var promises = [],
i = 0
;
if( !Array.isArray( ids ) )
ids = [ ids ];
for(; i<ids.length; i++ ){
if( this._promises[ ids[i] ] )
promises.push( this._promises[ ids[i] ] );
}
if( !promises.length )
return this._Promise.resolve();
return this._Promise.all( promises );
} | javascript | {
"resource": ""
} | |
q31756 | train | function(){
var me = this,
dispatchArguments = arguments,
promises = []
;
this._promises = [];
// A closure is needed for the callback id
Object.keys( this._callbacks ).forEach( function( id ){
// All the promises must be set in me._promises before trying to resolve
// in order to make waitFor ... | javascript | {
"resource": ""
} | |
q31757 | commonEventHandler | train | function commonEventHandler(event, arg) {
// NOTE: send from renderer process always.
var successEventName = getSuccessEventName(arg.eventName, arg.id);
var failureEventName = getFailureEventName(arg.eventName, arg.id);
var onSuccess = function(result) {
// send success to ipc for renderer proces... | javascript | {
"resource": ""
} |
q31758 | on | train | function on(event, listener) {
// call from main process always.
// add listener to common event emitter for main process.
cee.on(event, function(id, data, ipcEvent) {
listener(data, ipcEvent)
.then(function(result) {
cee.emit(getSuccessEventName(event, id), result);
})
... | javascript | {
"resource": ""
} |
q31759 | installPeerDependencies | train | async function installPeerDependencies(cwd, installDir, options) {
const { data: pkg } = await joycon.load({
files: ['package.json'], cwd
})
const peers = pkg.peerDependencies || {}
const packages = []
for (const peer in peers) {
if (!options.peerFilter || options.peerFilter(peer, peers[peer])) {
... | javascript | {
"resource": ""
} |
q31760 | Robot | train | function Robot(opts) {
if (!(this instanceof Robot)) {
return new Robot(opts);
}
this.chains = opts.chains;
this.offset = opts.offset || [0, 0, 0];
if (!opts.orientation) {
opts.orientation = {};
}
this.orientation = {
pitch: opts.orientation.pitch || 0,
yaw: opts.orientation.yaw || 0... | javascript | {
"resource": ""
} |
q31761 | Chain | train | function Chain(opts) {
if (!(this instanceof Chain)) {
return new Chain(opts);
}
if (opts.constructor) {
this.devices = new opts.constructor(opts.actuators);
} else {
this.devices = opts.actuators;
}
this.chainType = opts.chainType;
this.links = opts.links;
this.origin = opts.origin || ... | javascript | {
"resource": ""
} |
q31762 | splitOnFirst | train | function splitOnFirst(str, splitter, callback) {
var parts = str.split(splitter);
var first = parts.shift();
return callback(first, parts.join(splitter));
} | javascript | {
"resource": ""
} |
q31763 | liteURL | train | function liteURL(str) {
// We first check if we have parsed this URL before, to avoid running the
// monster regex over and over (which is expensive!)
var uri = memo[str];
if (typeof uri !== 'undefined') {
return uri;
}
//parsed url
uri = uriParser(s... | javascript | {
"resource": ""
} |
q31764 | dateGetter | train | function dateGetter(name, size, offset, trim, negWrap) {
if (offset === void 0) { offset = 0; }
if (trim === void 0) { trim = false; }
if (negWrap === void 0) { negWrap = false; }
return function (date, locale) {
var /** @type {?} */ part = getDatePart(name, date, size);
if (offset > 0 |... | javascript | {
"resource": ""
} |
q31765 | getDateTranslation | train | function getDateTranslation(date, locale, name, width, form, extended) {
switch (name) {
case TranslationType.Months:
return getLocaleMonthNames(locale, form, width)[date.getMonth()];
case TranslationType.Days:
return getLocaleDayNames(locale, form, width)[date.getDay()];
... | javascript | {
"resource": ""
} |
q31766 | getRandomColors | train | function getRandomColors() {
var letters = '0123456789ABCDEF'.split('');
var _color = '#';
for (var i = 0; i < 6; i++) {
_color += letters[Math.floor(Math.random() * 16)];
}
return _color;
} | javascript | {
"resource": ""
} |
q31767 | getFirstAndLastName | train | function getFirstAndLastName(data) {
var names = data.split(" ");
if (names && names.length >= 2) {
var firstName = names[0];
var lastName = names[1];
if (firstName && lastName) {
var text = firstName.substr(0, 1) + lastName.substr(0, 1);
return text;
}
... | javascript | {
"resource": ""
} |
q31768 | wrap | train | function wrap(elements, options) {
elements = toArray(elements);
/* Don't wrap only a container in a container */
if (elements.length === 1 && isContainer(elements[0])) {
return elements[0];
}
var container = {
type: cardTypes.container,
items: elements
};
setOptions(... | javascript | {
"resource": ""
} |
q31769 | turndown | train | function turndown(input) {
if (!canConvert(input)) {
throw new TypeError(input + ' is not a string, or an element/document/fragment node.');
}
var cardElems = process.call(this, new RootNode(input));
return createCard(cardElems);
} | javascript | {
"resource": ""
} |
q31770 | replacementForNode | train | function replacementForNode(node) {
var rule = this.rules.forNode(node);
var content = process.call(this, node); // get's internal content of node
return rule.replacement(content, node);
} | javascript | {
"resource": ""
} |
q31771 | canConvert | train | function canConvert(input) {
return input != null && (typeof input === 'string' || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));
} | javascript | {
"resource": ""
} |
q31772 | prange | train | function prange(s) {
const set = new Set()
const subs = s
// correct things like AJs -A9s to AJs-A9s
.replace(
/([A,K,Q,J,T,2-9]{2}[o,s]?)\s*-\s*([A,K,Q,J,T,2-9]{2}[o,s]?)/g
, '$1-$2'
)
// correct AK + to AK+
.replace(
/([A,K,Q,J,T,2-9]{2}[o,s]?)\s\+/g
, '$1+'
)
... | javascript | {
"resource": ""
} |
q31773 | organizer | train | function organizer(flat, tags, treeDescriptor, leafDescriptor) {
var tree = {};
flat.forEach(function (song) {
var treePtr = tree;
var depth = 1;
// strPossibleKeys can be like "albumArtist|artist", or just "album" for instance
treeDescriptor.forEach(function (strPossibleKeys) {... | javascript | {
"resource": ""
} |
q31774 | load | train | function load() {
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
params = (0, _lodash.defaults)({}, params, {
locale: 'en_US'
});
return new Promise(function (resolve, reject) {
if (window.FB) {
return resolve(window.FB);
}
var src = '//connect.faceb... | javascript | {
"resource": ""
} |
q31775 | reverse | train | function reverse(combos) {
const { offsuit, suited, pairs } = sortOut(combos)
const ps = reversePairs(pairs)
const os = reverseNonPairs(offsuit, 'o')
const su = reverseNonPairs(suited, 's')
const nonpairs = unsuitWhenPossible(new Set(os), new Set(su))
return ps.concat(nonpairs).join(', ')
} | javascript | {
"resource": ""
} |
q31776 | showInvisibles | train | function showInvisibles(str) {
let ret = '';
for (let i = 0; i < str.length; i++) {
switch (str[i]) {
case ' ':
ret += '·'; // Middle Dot, \u00B7
break;
case '\n':
ret += '⏎'; // Return Symbol, \u23ce
break;
case '\t':
ret += '↹'; // Left Arrow To Bar Ov... | javascript | {
"resource": ""
} |
q31777 | generateDifferences | train | function generateDifferences(source, prettierSource) {
// fast-diff returns the differences between two texts as a series of
// INSERT, DELETE or EQUAL operations. The results occur only in these
// sequences:
// /-> INSERT -> EQUAL
// EQUAL | /-> EQUAL
// \-> DELETE |
// ... | javascript | {
"resource": ""
} |
q31778 | cast | train | function cast(value){
if(value === undefined) return undefined;
/*
* Integers: 344i
*/
if(value.match(/^\d+i$/m)){
value = value.slice(0, -1);
return parseInt(value);
}
/* boolean true
* t, T, true, True, or TRUE
*/
if(value.match(/^t$|^true$/im)){
re... | javascript | {
"resource": ""
} |
q31779 | loadEnforcer | train | function loadEnforcer(method) {
return function () {
for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
rest[_key] = arguments[_key];
}
var FB = (0, _getGlobalFB2.default)();
if (!FB) {
throw new Error('FB SDK Wrapper cannot call method ' + method.name ... | javascript | {
"resource": ""
} |
q31780 | rule | train | function rule() {
var ret = this.seq(rulename, defined_as, elements, c_nl);
var da = ret[2];
if (da === "=") {
return this.rules.addRule(ret[1], ret[3]);
}
if (da === "=/") {
return this.rules.addAlternate(ret[1], ret[3]);
}
return this.fail();
} | javascript | {
"resource": ""
} |
q31781 | train | function(bindingsString, bindingContext) {
try {
var viewModel = bindingContext['$data'],
scopes = (typeof viewModel == 'object' && viewModel != null) ? [viewModel, bindingContext] : [bindingContext],
bindingFunction = createBindingsStringEvaluatorViaC... | javascript | {
"resource": ""
} | |
q31782 | calculateEditDistanceMatrix | train | function calculateEditDistanceMatrix(oldArray, newArray, maxAllowedDistance) {
var distances = [];
for (var i = 0; i <= newArray.length; i++)
distances[i] = [];
// Top row - transform old array into empty array via deletions
for (var i = 0, j = Math.min(oldArray.length, maxA... | javascript | {
"resource": ""
} |
q31783 | log | train | function log(type, args, color){
pad();
var msg = format.apply(format, args);
if (color) msg = chalk[color](msg);
var pre = prefix();
console[type](pre, msg);
} | javascript | {
"resource": ""
} |
q31784 | decode | train | function decode (imageDataView, width, height, format) {
var result;
format = format ? format.toLowerCase() : 'dxt1';
if (format === decode.dxt1) {
result = decodeBC1(imageDataView, width, height);
} else if(format === decode.dxt2) {
result = decodeBC2(imageDataView, width, height, tru... | javascript | {
"resource": ""
} |
q31785 | lower | train | function lower(str, options, cb) {
// handle Handlebars or Lodash templates
if (typeof options === 'function') {
cb = options;
options = {};
}
cb(null, str.toLowerCase());
} | javascript | {
"resource": ""
} |
q31786 | extractParts | train | function extractParts (str, indexA, indexB) {
let part = str.substr(indexA, indexB);
part = part.replace(/</g, '<').replace(/>/g, '>');
part = part.replace(/\n/g, '<span class="invisible"> \u21A9</span>\n');
part = part.replace(/\t/g, '<span class="invisible tab">\u2192</span>');
return part;
} | javascript | {
"resource": ""
} |
q31787 | handleStream | train | function handleStream(remotePeerId, stream) {
if (opened[remotePeerId] !== true) {
stream.write("hello!")
stream.on("data", log)
}
function log(data) {
console.log("[PEER2]", remotePeerId, data)
}
} | javascript | {
"resource": ""
} |
q31788 | Logger | train | function Logger (options) {
if (!(this instanceof Logger)) return new Logger(options);
options = options || {};
debug('new logger v%s', pkg.version);
var router = Router();
router.on(function (sock, args, cb) {
debug('logger args.length %s', arguments.length);
try {
// "this" is the "socket"
... | javascript | {
"resource": ""
} |
q31789 | unlock | train | function unlock(isVerbose) {
if (isVerbose) {
console.log('Start unlocking ...');
}
// Load bower.json and make sure it is a locked bower.json file
var bowerConfigStr = fs.readFileSync('bower.json', {encoding: 'utf8'});
var bowerConfig = JSON.parse(bowerConfigStr);
if (!bowerConfig.bowe... | javascript | {
"resource": ""
} |
q31790 | Route | train | function Route(props) {
props = props ? merge({}, props) : {};
var path = props.path;
if (typeof path === 'string') {
path = path.replace(slashes, '');
}
delete props.path;
var view = props.view;
delete props.view;
var viewPromise = props.viewPromise;
delete props.viewPromise;
var name = p... | javascript | {
"resource": ""
} |
q31791 | postProcess | train | function postProcess(state) {
var i,
foundStart = false,
foundEnd = false,
delim,
token,
delimiters = state.delimiters,
max = state.delimiters.length;
for (i = 0; i < max; i++) {
delim = delimiters[i];
if (delim.marker === '->') {
foundStart =... | javascript | {
"resource": ""
} |
q31792 | procesArray | train | function procesArray(array) {
if (!array || !Array.isArray(array)) {
return array;
}
return array.map((item, index) => {
if (typeof item === "string") {
return localizeString(item);
}
return item;
});
} | javascript | {
"resource": ""
} |
q31793 | renderText | train | function renderText(args, that) {
if (isNewTextVersion) {
args[0] = { ...args[0], children: pseudoText(args[0].children) };
return defaultTextRender.apply(that, args);
} else {
const element = defaultTextRender.apply(that, args);
return React.cloneElement(element, {
children: pseudoText(elemen... | javascript | {
"resource": ""
} |
q31794 | render | train | function render() {
return function(...args) {
return (
<PseudoContext.Consumer>
{value => {
if (!value) {
return defaultTextRender.apply(this, args);
}
return renderText(args, this);
}}
</PseudoContext.Consumer>
);
};
} | javascript | {
"resource": ""
} |
q31795 | clean | train | function clean(post) {
return reject({
title: post.title,
contentFormat: post.contentFormat,
content: post.content,
tags: post.tags,
canonicalUrl: post.canonicalUrl,
publishStatus: post.publishStatus,
license: post.license
});
} | javascript | {
"resource": ""
} |
q31796 | fetchViews | train | function fetchViews(match) {
var activeTrace = match.activeTrace.map(fetchViewsStep);
return activeTrace.some(Promise.is) ?
Promise.all(activeTrace).then((activeTrace) => merge(match, {activeTrace})) :
Promise.resolve(merge(match, {activeTrace}));
} | javascript | {
"resource": ""
} |
q31797 | train | function (node) {
var key = node.property || node.key;
if (!node.computed && key.type === 'JSXIdentifier') {
return key.name;
}
// Delegate to original method.
return infer.propName.apply(infer, arguments);
} | javascript | {
"resource": ""
} | |
q31798 | train | function (node, scope) {
var finder = infer.typeFinder[node.type];
return finder ? finder(node, scope) : infer.ANull;
} | javascript | {
"resource": ""
} | |
q31799 | status | train | function status(isVerbose) {
// Load bower.json and make sure it is a locked bower.json file
var bowerConfigStr = fs.readFileSync('bower.json', {encoding: 'utf8'});
var bowerConfig = JSON.parse(bowerConfigStr);
var locked = bowerConfig.bowerLocker;
if (locked) {
var timeDiff = (new Date()).g... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.