_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q34200 | getServer | train | function getServer(inPath, { react, port, contentBase, configureApplication }) {
const server = new _webpackDevServer2.default((0, _webpack2.default)(_extends({}, getConfig(react), {
devtool: 'eval-source-map',
entry: [`webpack-dev-server/client?http://0.0.0.0:${port}`, 'webpack/hot/only-dev-server', 'babel-p... | javascript | {
"resource": ""
} |
q34201 | NixInlineJS | train | function NixInlineJS(args) {
/* Compose the NixInlineJS function's parameters */
var params = {};
if(typeof args.code == "function") {
params.codeIsFunction = true;
params.code = args.code.toString();
} else {
params.codeIsFunction = false;
params.code = args.code;
... | javascript | {
"resource": ""
} |
q34202 | getPayload | train | function getPayload(req, res, next) {
req.hasCallback = false;
req.payload = req.body.payload || [];
// Determines if the request is asynchronous or not
req.payload.forEach(function(arg, i) {
if (arg === '__clientCallback__') {
req.hasCallback = true;
req.clientCallbackIndex = i;
}
});
... | javascript | {
"resource": ""
} |
q34203 | callEntityMethod | train | function callEntityMethod(req, res, next) {
var payload = req.payload;
var method = req.serversideMethod;
if (req.hasCallback) {
debug('Transforming callback function');
payload[req.clientCallbackIndex] = function(err) {
if (err) {
return next(err);
}
var values = Array.protot... | javascript | {
"resource": ""
} |
q34204 | serve | train | function serve(req, res) {
var responseIsArray = Array.isArray(res.entityResponse);
util.invariant(responseIsArray, 'Response values are required.');
res.json({ values: res.entityResponse });
} | javascript | {
"resource": ""
} |
q34205 | nextPreHook | train | function nextPreHook() {
/**
* read the arguments from previous "hook" response
*/
const args = Array.prototype.slice.apply(arguments);
/**
* Check if the arguments contains an "__override" proper... | javascript | {
"resource": ""
} |
q34206 | nextPostHook | train | function nextPostHook(res) {
response = checkResponse(res, response);
if (currentPost + 1 < totalPost && self.__hooksEnabled !== false) {
currentPost += 1;
// Reference to current post hook
const currPost =... | javascript | {
"resource": ""
} |
q34207 | postHookErrorHandler | train | function postHookErrorHandler(err) {
/**
* Helper to add an error to an Object "errors" Symbol
*/
const addError = (obj) => {
obj[ERR_KEY] = obj[ERR_KEY] || [];
obj[ERR_KEY].push(err);
... | javascript | {
"resource": ""
} |
q34208 | renderInlines | train | function renderInlines(val, indent) {
const indentStr = Array(indent + 1).join(' ');
return '\n' + map(orderBy(val, first), (pair) =>
[
`${indentStr}${pair[0]} {
${exports.renderDefinition(pair[1], indent + 2)}
${indentStr}}`,
].join('\n')
).join('\n\n');
} | javascript | {
"resource": ""
} |
q34209 | renderDefinitionRhs | train | function renderDefinitionRhs(val, indent) {
indent = indent || 0;
const indentStr = Array(indent + 1).join(' ');
if (isUndefined(val)) {
throw new Error('Undefined value in definition RHS.');
}
if (isBoolean(val)) {
return val.toString();
}
if (isInteger(val)) {
return val;
}
if (isString... | javascript | {
"resource": ""
} |
q34210 | makePrefixMapReducer | train | function makePrefixMapReducer() {
for (var _len2 = arguments.length, reducers = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
reducers[_key2] = arguments[_key2];
}
if (reducers.some(function (r) {
return !_lodash2.default.isFunction(r);
})) {
throw new Error('all arguments must be a function')... | javascript | {
"resource": ""
} |
q34211 | NixIf | train | function NixIf(args) {
this.ifExpr = args.ifExpr;
this.thenExpr = args.thenExpr;
this.elseExpr = args.elseExpr;
} | javascript | {
"resource": ""
} |
q34212 | train | function (id, version, done, headers, config) {
if (!_.isNumber(parseInt(id, 10))) {
return done(new Error('id must be specified.'));
}
if (!_.isEmpty(version) && !_.isNumber(parseInt(version, 10))) {
return done(new Error('version must be a number.'));
}
thi... | javascript | {
"resource": ""
} | |
q34213 | DoubleDottedItem | train | function DoubleDottedItem(parameters) {
// An identifier is constructed from rule, dots, from and to
this.id = "DoubleDottedItem(" + parameters.rule.lhs + "->" +
parameters.rule.rhs + ", " + parameters.left_dot + ", " +
parameters.right_dot + ", " + parameters.from + ", " + parameters.to +")";
logger.de... | javascript | {
"resource": ""
} |
q34214 | EarleyItem | train | function EarleyItem(parameters) {
// A unique identifier is constructed from rule, dot and from
this.id = "Earley(" + parameters.rule.lhs + "->" + parameters.rule.rhs +
", " + parameters.dot + ", " + parameters.from + ", " + parameters.to +")";
logger.debug("EarleyItem: " + this.id);
this.name = parameters... | javascript | {
"resource": ""
} |
q34215 | _applyAnyStylesheet | train | function _applyAnyStylesheet(node) {
if (!doc.createStyleSheet) {
return;
}
if (_getHTMLNodeName(node) === 'style') {
// IE
var ss = doc.createStyleSheet(); // Create a stylesheet to actually do something useful
ss.cssText = node.cssText; // We continue to add the style tag, however
}
} | javascript | {
"resource": ""
} |
q34216 | _appendNode | train | function _appendNode(parent, child) {
var parentName = _getHTMLNodeName(parent);
var childName = _getHTMLNodeName(child);
if (doc.createStyleSheet) {
if (parentName === 'script') {
parent.text = child.nodeValue;
return;
}
if (parentName === 'style') {
parent.cssText = child.nodeVa... | javascript | {
"resource": ""
} |
q34217 | _addEvent | train | function _addEvent(el, type, handler, capturing) {
el.addEventListener(type, handler, !!capturing);
} | javascript | {
"resource": ""
} |
q34218 | _createSafeReference | train | function _createSafeReference(type, prefix, arg) {
// For security reasons related to innerHTML, we ensure this string only contains potential entity characters
if (!arg.match(/^\w+$/)) {
throw new TypeError('Bad ' + type);
}
var elContainer = doc.createElement('div'); // Todo: No workaround for XML?
el... | javascript | {
"resource": ""
} |
q34219 | glue | train | function glue(jmlArray, glu) {
return _toConsumableArray(jmlArray).reduce(function (arr, item) {
arr.push(item, glu);
return arr;
}, []).slice(0, -1);
} | javascript | {
"resource": ""
} |
q34220 | inputRecord | train | function inputRecord (type, record) {
const clone = {};
const recordTypes = this.recordTypes;
const primaryKey = this.keys.primary;
const isArrayKey = this.keys.isArray;
const generateId = this.options.generateId;
const fields = recordTypes[type];
// ID business.
const id = record[primaryKey];
clone[... | javascript | {
"resource": ""
} |
q34221 | parseHTML | train | function parseHTML(html) {
const dom = (0, _cheerio.load)(html),
{ children } = dom.root().toArray()[0];
return { dom, children };
} | javascript | {
"resource": ""
} |
q34222 | toJSXKey | train | function toJSXKey(key) {
return (0, _replace2.default)(/^-ms-/.test(key) ? key.substr(1) : key, /-(.)/g, (match, chr) => (0, _toUpper2.default)(chr));
} | javascript | {
"resource": ""
} |
q34223 | transformStyle | train | function transformStyle(object) {
if ((0, _has2.default)(object, 'style')) {
object.style = (0, _transform2.default)((0, _split2.default)(object.style, ';'), (result, style) => {
const firstColon = style.indexOf(':'),
key = (0, _trim2.default)(style.substr(0, firstColon));
if (key) {
... | javascript | {
"resource": ""
} |
q34224 | rename | train | function rename(object, fromKey, toKey) {
if ((0, _has2.default)(object, fromKey)) {
object[toKey] = object[fromKey];
delete object[fromKey];
}
} | javascript | {
"resource": ""
} |
q34225 | transformElement | train | function transformElement({ name: type, attribs: props, children: childElements }) {
transformStyle(props);
rename(props, 'for', 'htmlFor');
rename(props, 'class', 'className');
if ('input' === type) {
rename(props, 'checked', 'defaultChecked');
rename(props, 'value', 'defaultValue');
}
let children... | javascript | {
"resource": ""
} |
q34226 | flatten | train | function flatten(...args) {
return (0, _transform2.default)((0, _flattenDeep2.default)(args), (accumulator, value) => {
if (!value) {
return;
}
const lastIndex = accumulator.length - 1;
if ((0, _isString2.default)(value) && (0, _isString2.default)(accumulator[lastIndex])) {
accumulator[la... | javascript | {
"resource": ""
} |
q34227 | arrayToJSX | train | function arrayToJSX(arr = []) {
return (0, _map2.default)(arr, (el, key) => {
if ((0, _isString2.default)(el)) {
return el;
}
const { type, props, children } = el;
return (0, _react.createElement)(type, _extends({}, props, { key }), ...arrayToJSX(children));
});
} | javascript | {
"resource": ""
} |
q34228 | train | function (mine, their, strategy) {
this._doMerge(mine, their, function(key){
if (typeof their[key] === 'object') {
if (their[key] instanceof Array) {
mine[key] = [].concat(mine[key], their[key]);
} else {
mine[key] = this[strate... | javascript | {
"resource": ""
} | |
q34229 | train | function(line, curr_pos)
{
var ret = tokenizer.getBarLine(line, curr_pos);
if (ret.len === 0)
return [0,""];
if (ret.warn) {
warn(ret.warn, line, curr_pos);
return [ret.len,""];
}
// Now see if this is a repeated ending
// A repeated ending is all of the characters 1,2,3,4,5... | javascript | {
"resource": ""
} | |
q34230 | train | function(all, backslash, comment){
var spaces = " ";
var padding = comment ? spaces.substring(0, comment.length)... | javascript | {
"resource": ""
} | |
q34231 | train | function (attachment) {
// Define custom metadata properties for the file before saving
var customFileMetadata = {};
var parentItemId = model.getParentItemId();
if (parentItemId && parentItemId != '') customFileMetadata[scope.attachmentFilt... | javascript | {
"resource": ""
} | |
q34232 | Queue | train | function Queue(name, opts) {
// allow call as function
if (!(this instanceof Queue))
return new Queue(name, opts);
if (!name) {
throw new Error('queue name is required');
}
opts = opts || {};
// basic
this.name = name;
this.port = opts.port || 6379;
this.host = opts.host || '127.0.0.1';
// queue conf... | javascript | {
"resource": ""
} |
q34233 | pton4 | train | function pton4(addr, dest, index = 0) {
if (typeof addr !== 'string') {
throw new TypeError('Argument 1 should be a string.')
}
if (arguments.length >= 3) {
if (typeof index !== 'number') {
throw new TypeError('Argument 3 should be a Number.')
}
}
const isbuffer = Buffer.isBuffer(dest)
... | javascript | {
"resource": ""
} |
q34234 | BufferGeometry | train | function BufferGeometry() {
Object.defineProperty( this, 'id', { value: bufferGeometryId += 2 } );
this.uuid = _Math.generateUUID();
this.name = '';
this.type = 'BufferGeometry';
this.index = null;
this.attributes = {};
this.morphAttributes = {};
this.groups = [];
this.boundingBox = null;
this.bounding... | javascript | {
"resource": ""
} |
q34235 | getSingularSetter | train | function getSingularSetter( type ) {
switch ( type ) {
case 0x1406: return setValue1f; // FLOAT
case 0x8b50: return setValue2fv; // _VEC2
case 0x8b51: return setValue3fv; // _VEC3
case 0x8b52: return setValue4fv; // _VEC4
case 0x8b5a: return setValue2fm; // _MAT2
case 0x8b5b: return setValue3fm; // _MAT... | javascript | {
"resource": ""
} |
q34236 | setValue1fv | train | function setValue1fv( gl, v ) {
var cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform1fv( this.addr, v );
copyArray( cache, v );
} | javascript | {
"resource": ""
} |
q34237 | CubicInterpolant | train | function CubicInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );
this._weightPrev = - 0;
this._offsetPrev = - 0;
this._weightNext = - 0;
this._offsetNext = - 0;
} | javascript | {
"resource": ""
} |
q34238 | train | function () {
var valid = true;
var valueSize = this.getValueSize();
if ( valueSize - Math.floor( valueSize ) !== 0 ) {
console.error( 'THREE.KeyframeTrack: Invalid value size in track.', this );
valid = false;
}
var times = this.times,
values = this.values,
nKeys = times.length;
if ( nKe... | javascript | {
"resource": ""
} | |
q34239 | QuaternionLinearInterpolant | train | function QuaternionLinearInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) {
Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer );
} | javascript | {
"resource": ""
} |
q34240 | train | function ( animation, bones ) {
if ( ! animation ) {
console.error( 'THREE.AnimationClip: No animation in JSONLoader data.' );
return null;
}
var addNonemptyTrack = function ( trackType, trackName, animationKeys, propertyName, destTracks ) {
// only return track if there are actually keys.
if ( a... | javascript | {
"resource": ""
} | |
q34241 | train | function ( clip, optionalRoot ) {
var root = optionalRoot || this._root,
rootUuid = root.uuid,
clipObject = typeof clip === 'string' ?
AnimationClip.findByName( root, clip ) : clip,
clipUuid = clipObject ? clipObject.uuid : clip,
actionsForClip = this._actionsByClip[ clipUuid ];
if ( actionsFor... | javascript | {
"resource": ""
} | |
q34242 | train | function ( deltaTime ) {
deltaTime *= this.timeScale;
var actions = this._actions,
nActions = this._nActiveActions,
time = this.time += deltaTime,
timeDirection = Math.sign( deltaTime ),
accuIndex = this._accuIndex ^= 1;
// run active actions
for ( var i = 0; i !== nActions; ++ i ) {
var a... | javascript | {
"resource": ""
} | |
q34243 | checkConfig | train | function checkConfig(config) {
let requiredProps = ['algorithm', 'format'];
const errMsg = `Configuration isn't an object with the required properties: ${requiredProps.join(', ')}`;
if ((!config) || (typeof config !== 'object')) {
throw new Error(errMsg);
}
requiredProps.forEach(p => {
if (!config[p... | javascript | {
"resource": ""
} |
q34244 | train | function(arg) {
return /^f/.test(typeof arg) ? /c/.test(document.readyState) ? arg() : u._defInit.push(arg) : new Init(arg);
} | javascript | {
"resource": ""
} | |
q34245 | train | function(event, selector, handler, fn) {
if (/^f/.test(typeof selector)) {
handler = selector;
fn = handler;
}
else if (/^s/.test(typeof selector)) {
fn = handler;
handler = function(e) {
var element;
if (u(e.target).is(selector)) {
eleme... | javascript | {
"resource": ""
} | |
q34246 | train | function(event, selector, handler, fn) {
if (/^f/.test(typeof selector)) {
handler = selector;
}
fn = handler;
return this.each(function(index, el) {
var events = event.split(' ');
u.each(events, function(i, event, origEvent){
origEvent = u._events.remove(el, ev... | javascript | {
"resource": ""
} | |
q34247 | train | function(e, data, evt) {
if (/^f/.test(typeof CustomEvent)) {
evt = new CustomEvent(e, {
detail: data,
bubbles: true,
cancelable: false
});
}
else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent(e, true, false, data);
... | javascript | {
"resource": ""
} | |
q34248 | train | function(val) {
return val === undefined ? (this.length ? (this[0].scrollTop !== undefined ? this[0].scrollTop : (this[0].scrollY || this[0].pageYOffset)) : 0) : this.each(function(index, el) {
el.scrollTop === undefined || el.scrollTo !== undefined ? el.scrollTo(0, val) : el.scrollTop = val;
});
... | javascript | {
"resource": ""
} | |
q34249 | train | function(to, duration, callback) {
return this.each(function(index, el) {
var _el = u(el),
start = _el.scrollTop(),
change = to - start,
currentTime = 0,
increment = 20;
duration = duration || 1500;
function easing(t, b, c, d) {
t ... | javascript | {
"resource": ""
} | |
q34250 | train | function(duration, callback) {
return this.each(function(index, el) {
u(el).scrollTo(0, duration, callback);
});
} | javascript | {
"resource": ""
} | |
q34251 | train | function(val) {
return val === undefined ? (this.length ? this[0].clientWidth || this[0].innerWidth : 0) : this.each(function(index, el) {
el.style.width = val + 'px';
});
} | javascript | {
"resource": ""
} | |
q34252 | train | function(margin) {
if (!this.length) {
return 0;
}
return margin ? this[0].offsetWidth + parseInt(getComputedStyle(this[0]).marginLeft) + parseInt(getComputedStyle(this[0]).marginRight) : this[0].offsetWidth;
} | javascript | {
"resource": ""
} | |
q34253 | train | function(val) {
return val === undefined ? (this.length ? this[0].clientHeight || this[0].innerHeight : 0) : this.each(function(index, el) {
el.style.height = val + 'px';
});
} | javascript | {
"resource": ""
} | |
q34254 | train | function(margin) {
if (!this.length) {
return 0;
}
return margin ? this[0].offsetHeight + parseInt(getComputedStyle(this[0]).marginTop) + parseInt(getComputedStyle(this[0]).marginBottom) : this[0].offsetHeight;
} | javascript | {
"resource": ""
} | |
q34255 | train | function(attr, val) {
return val === undefined ? (this.length ? this[0].getAttribute(attr) : null) : this.each(function(index, el) {
el.setAttribute(attr, val);
});
} | javascript | {
"resource": ""
} | |
q34256 | train | function(prop, val) {
return val === undefined ? (this.length ? this[0][prop] : null) : this.each(function(index, el) {
el[prop] = val;
});
} | javascript | {
"resource": ""
} | |
q34257 | train | function(attr, val, el, index, obj, attrCamel) {
if (attr === undefined) {
if (!this.length) {
return {};
}
el = this[0];
obj = u.extend({}, el.dataset || {});
if ((index = el[u._id]) === undefined) {
el[u._id] = index = u._data.push(obj) - 1;
... | javascript | {
"resource": ""
} | |
q34258 | train | function(attr, index, attrCamel) {
return this.each(function(i, el) {
if (attr !== undefined) {
attrCamel = u.toCamel(u.toDash(attr));
if ((index = el[u._id]) !== undefined) {
el.dataset ? delete el.dataset[attrCamel] : el.removeAttribute('data-' + attr);
delete... | javascript | {
"resource": ""
} | |
q34259 | train | function(props, val) {
if (/^o/.test(typeof props)) {
for(var prop in props) {
var prefixed = u.prfx(prop);
if (props.hasOwnProperty(prop)) {
this.each(function(index, el) {
el.style[prefixed] = props[prop];
});
}
}
return... | javascript | {
"resource": ""
} | |
q34260 | train | function(child) {
return this.length ? (/^o/.test(typeof child) ? this[0] !== child[0] && this[0].contains(child[0]) : this[0].querySelector(child) !== null) : false;
} | javascript | {
"resource": ""
} | |
q34261 | train | function(filter) {
return u(array.filter.call(this, function(el, index) {
return /^f/.test(typeof filter) ? filter(index, el) : u(el).is(filter);
}));
} | javascript | {
"resource": ""
} | |
q34262 | train | function(sel) {
if (!this.length) {
return false;
}
var m = (this[0].matches || this[0].matchesSelector || this[0].msMatchesSelector || this[0].mozMatchesSelector || this[0].webkitMatchesSelector || this[0].oMatchesSelector || function(s) {
return [].indexOf.call(document.querySelector... | javascript | {
"resource": ""
} | |
q34263 | train | function(el) {
if (!el) {
return this[0] ? this.first().prevAll().length : -1;
}
if (''+el === el) {
return u.toArray(u(el)).indexOf(this[0]);
}
el = el.ujs ? el[0] : el;
return u.toArray(this).indexOf(el);
} | javascript | {
"resource": ""
} | |
q34264 | train | function(sel) {
if (!this.length) {
return this;
}
var matched = [],
el = this[0];
while (el = el.previousElementSibling) {
sel ?
(u(el).is(sel) && matched.push(el)) :
matched.push(el);
}
return u(matched);
} | javascript | {
"resource": ""
} | |
q34265 | train | function(sel) {
if (!this.length) {
return this;
}
var matched = [],
el = this[0];
while (el = el.nextElementSibling) {
sel ?
(u(el).is(sel) && matched.push(el)) :
matched.push(el);
}
return u(matched);
} | javascript | {
"resource": ""
} | |
q34266 | train | function(sel) {
if (!this.length) {
return this;
}
var el = this[0];
return u(array.filter.call(el.parentNode.children, function(child) {
return sel ? child !== el && u(child).is(sel) : child !== el;
}));
} | javascript | {
"resource": ""
} | |
q34267 | train | function(sel) {
if (!this.length) {
return this;
}
var parents = [],
finished = false,
currentElement = this[0];
while (!finished) {
currentElement = currentElement.parentNode;
if (currentElement) {
if (sel === undefined) {
paren... | javascript | {
"resource": ""
} | |
q34268 | train | function(val) {
return val === undefined ? (this.length ? this[0].textContent : null) : this.each(function(index, el) {
el.textContent = val;
});
} | javascript | {
"resource": ""
} | |
q34269 | train | function(val) {
return val === undefined ? (this.length ? this[0].innerHTML : null) : this.each(function(index, el) {
el.innerHTML = val;
});
} | javascript | {
"resource": ""
} | |
q34270 | train | function(val) {
return val === undefined ? (this.length ? this[0].outerHTML : null) : this.each(function(index, el) {
el.outerHTML = val;
});
} | javascript | {
"resource": ""
} | |
q34271 | train | function(val) {
return val === undefined ? (this.length ? this[0].value : null) : this.each(function(index, el) {
el.value = val;
});
} | javascript | {
"resource": ""
} | |
q34272 | train | function() {
var args = u.toArray(arguments);
args.unshift(u.fn);
return u.extend.apply(this, args);
} | javascript | {
"resource": ""
} | |
q34273 | train | function(params) {
This.lines[This.lineNum].staff[This.staffNum].voices[This.voiceNum] = [];
if (This.isFirstLine(This.lineNum)) {
if (params.name) {if (!This.lines[This.lineNum].staff[This.staffNum].title) This.lines[This.lineNum].staff[This.staffNum].title = [];This.lines[This.lineNum].staff[This.... | javascript | {
"resource": ""
} | |
q34274 | featureIsUnifiable | train | function featureIsUnifiable(feature) {
logger.debug('TypedFeatureStructure.unifiable: checking feature: ' + feature + fs2.features[feature]);
if (fs1.features[feature]) {
// If feature of fs2 is a back pointer we want it to overrule feature
// of the fs1.
if (newStackb.inde... | javascript | {
"resource": ""
} |
q34275 | prettyPrint0 | train | function prettyPrint0(fs, indent) {
logger.debug('prettyPrint0: ' + fs);
var result = '';
if (fs) {
if (Object.keys(fs.incoming).length > 1) {
if (fs.printed) {
// Return the label
return (fs.getLabel());
}
else {
// Print the label
resu... | javascript | {
"resource": ""
} |
q34276 | livereload | train | function livereload() {
if (!reloadFn) {
const lr = (0, _tinyLr2.default)();
lr.listen(LIVERELOAD_PORT);
reloadFn = (file = '*') => {
lr.changed({ body: { files: [file] } });
};
}
return reloadFn;
} | javascript | {
"resource": ""
} |
q34277 | train | function(fullUrl, body, key, signature) {
var data = fullUrl + sortPostParameters(body);
var expected = getHash(data, key);
return expected === signature;
} | javascript | {
"resource": ""
} | |
q34278 | train | function(body) {
body = Object(body);
var sortedKeys = Object.keys(body).sort();
return sortedKeys.reduce(function(signature, key) {
return signature + key + body[key];
}, '');
} | javascript | {
"resource": ""
} | |
q34279 | train | function(req, res, next) {
var signature = req.headers[MANDRILL_SIGNATURE_HEADER];
var fullUrl = options.domain + req.url;
var isValid = validator(fullUrl, req.body, signature);
var respondWith = responder(res);
if (!signature) {
respondWith(401, NOT_AUTHORIZED);
}else if (... | javascript | {
"resource": ""
} | |
q34280 | Column | train | function Column({ size, ...props }) {
const staticStyles = {
display: 'flex',
flexDirection: 'column',
}
const dynamicStyles = {
flex: `0 0 ${size / 12 * 100}`,
}
return createStyledElement('div', props)(staticStyles, dynamicStyles)
} | javascript | {
"resource": ""
} |
q34281 | Slack | train | function Slack(options) {
var suppliedOptions = options ? options : {};
if (!suppliedOptions.webhook || typeof suppliedOptions.webhook !== 'string') {
throw new Error('Invalid webhook parameter');
}
this.name = 'slack';
this.webhook = suppliedOptions.webhook;
this.customFormatter = suppliedOptions.custo... | javascript | {
"resource": ""
} |
q34282 | send | train | function send(message, callback) {
const suppliedCallback = callback || function () {};
if (!message) {
return suppliedCallback(new Error('No message'));
}
const requestParams = {
url: this.webhook,
body: extend(this.options, { text: message }),
json: true
};
return request.post(requestParam... | javascript | {
"resource": ""
} |
q34283 | tokenize_sentence | train | function tokenize_sentence(sentence) {
var tokenized = tokenizer.tokenize(sentence);
logger.info("tokenize_sentence: " + tokenized);
return(tokenized);
} | javascript | {
"resource": ""
} |
q34284 | stem_sentence | train | function stem_sentence(sentence) {
for (var i = 0; i < sentence.length; i++) {
sentence[i] = natural.PorterStemmer.stem(sentence[i]);
}
logger.info("stem_sentence: " + sentence);
return(sentence);
} | javascript | {
"resource": ""
} |
q34285 | Type | train | function Type(name, super_types, fs) {
this.super_types = [];
this.name = name;
if (super_types) {
this.super_types = super_types;
}
this.fs = fs;
} | javascript | {
"resource": ""
} |
q34286 | NixFunction | train | function NixFunction(args) {
if(args.argSpec === null) {
throw "Cannot derivate function argument specification from a null reference";
} else if(typeof args.argSpec == "string" || typeof args.argSpec == "object") {
this.argSpec = args.argSpec;
this.body = args.body;
} else {
... | javascript | {
"resource": ""
} |
q34287 | train | function(req, res, next) {
var requestTokenUrl = 'https://api.twitter.com/oauth/request_token';
var accessTokenUrl = 'https://api.twitter.com/oauth/access_token';
var authenticateUrl = 'https://api.twitter.com/oauth/authenticate';
// Step 2. Redirect to the authorization screen.
if (!req.query.oaut... | javascript | {
"resource": ""
} | |
q34288 | train | function (req, res, next) {
var prifile = req.profile;
var filter = { or: [{ twitter: profile.user_id }, { email: profile.email }] };
User.find({ where: filter }, function(err, users) {
var user = users[0];
if (user) {
if (!user.twitter) {
user.twitter = profile.user_id;
... | javascript | {
"resource": ""
} | |
q34289 | train | function (req, res, next) {
var profileUrl = 'https://api.foursquare.com/v2/users/self';
var params = {
v: '20140806',
oauth_token: req.accessToken
};
request.get({ url: profileUrl, qs: params, json: true }, function(err, response, profile) {
if (err) {
res.status(500).send(er... | javascript | {
"resource": ""
} | |
q34290 | getAugmentedOptionsObject | train | function getAugmentedOptionsObject (initialObject) {
// jshint validthis:true
const thisIsLateralus = isLateralus(this);
const augmentedOptions = _.extend(initialObject || {}, {
lateralus: thisIsLateralus ? this : this.lateralus
});
if (!thisIsLateralus) {
augmentedOptions.component = this.component ... | javascript | {
"resource": ""
} |
q34291 | formatLine | train | function formatLine(message, file, line, column) {
const { yellow, cyan, magenta } = consoleStyles;
return ['"', yellow(message), '" in ', cyan((0, _path.relative)('', file)), ' on ', magenta(line), ':', magenta(column)];
} | javascript | {
"resource": ""
} |
q34292 | formatErrorMarker | train | function formatErrorMarker(message = 'Error') {
const { bold, bgRed, white } = consoleStyles;
return bgRed(bold(white(message)));
} | javascript | {
"resource": ""
} |
q34293 | log | train | function log(...messages) {
const { message, styles } = new Message({ ansi: ['', ''], css: '' }).addMessages(messages);
console.log(message, ...styles);
} | javascript | {
"resource": ""
} |
q34294 | logPostCSSWarnings | train | function logPostCSSWarnings(warnings) {
(0, _forEach2.default)(warnings, ({ text, plugin, node: { source: { input: { file } } }, line, column }) => {
log(formatErrorMarker('Warning'), ': ', ...formatLine(`${text}(${plugin})`, file, line, column));
});
log('PostCSS warnings: ', warnings.length);
} | javascript | {
"resource": ""
} |
q34295 | logSASSError | train | function logSASSError({ message, file, line, column }) {
log(formatErrorMarker('SASS error'), ': ', ...formatLine(message, file, line, column));
} | javascript | {
"resource": ""
} |
q34296 | logLintingErrors | train | function logLintingErrors(errors, prefix = null) {
(0, _forEach2.default)(errors, ({ message, rule, file, line, column }) => {
log(formatErrorMarker(), ': ', ...formatLine(`${message}${rule ? ` (${rule})` : ''}`, file, line, column));
});
log(prefix ? `${prefix} l` : 'L', 'inting errors: ', errors.length);
} | javascript | {
"resource": ""
} |
q34297 | ProductionRule | train | function ProductionRule(lhs, rhs, head) {
this.lhs = lhs;
this.rhs = rhs;
this.head = head;
// feature structure of the constraints specified with the rule
this.fs = null;
} | javascript | {
"resource": ""
} |
q34298 | parseMethodsFromRust | train | function parseMethodsFromRust (source) {
// Matching the custom `rpc` attribute with it's doc comment
const attributePattern = /((?:\s*\/\/\/.*$)*)\s*#\[rpc\(([^)]+)\)]/gm;
const commentPattern = /\s*\/\/\/\s*/g;
const separatorPattern = /\s*,\s*/g;
const assignPattern = /([\S]+)\s*=\s*"([^"]*)"/;
const ign... | javascript | {
"resource": ""
} |
q34299 | getMethodsFromRustTraits | train | function getMethodsFromRustTraits () {
const traitsDir = path.join(__dirname, '../../.parity/rpc/src/v1/traits');
return fs
.readdirSync(traitsDir)
.filter((name) => name !== 'mod.rs' && /\.rs$/.test(name))
.map((name) => fs.readFileSync(path.join(traitsDir, name)))
.map(parseMethodsFromRust)
.... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.