_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q42400 | train | function(size) {
size = size || 1;
var numChunks = Math.ceil(this.length / size);
var result = new Array(numChunks);
for (var i = 0, index = 0; i < numChunks; i++) {
result[i] = chunkSlice(this, index, index += size);
}
return result;
} | javascript | {
"resource": ""
} | |
q42401 | train | function() {
var result = [];
for (var i = 0; i < this.length; i++) {
var value = this[i];
if (Array.isArray(value)) {
for (var j = 0; j < value.length; j++) {
result.push(value[j]);
}
} else {
result.push(value);
}
}
return result;
} | javascript | {
"resource": ""
} | |
q42402 | train | function() {
var remStartIndex = 0;
var numToRemove = 0;
for (var i = 0; i < this.length; i++) {
var removeCurrentIndex = false;
for (var j = 0; j < arguments.length; j++) {
if (this[i] === arguments[j]) {
removeCurrentIndex = true;
break;
}
}
i... | javascript | {
"resource": ""
} | |
q42403 | train | function(isSorted) {
var result = [];
var length = this.length;
if (!length) {
return result;
}
result[0] = this[0];
var i = 1;
if (isSorted) {
for (; i < length; i++) {
if (this[i] !== this[i - 1]) {
result.push(this[i]);
}
}
} else {
... | javascript | {
"resource": ""
} | |
q42404 | train | function() {
var result = [];
next: for (var i = 0; i < this.length; i++) {
for (var j = 0; j < arguments.length; j++) {
if (this[i] === arguments[j]) {
continue next;
}
}
result.push(this[i]);
}
return result;
} | javascript | {
"resource": ""
} | |
q42405 | flattenArray | train | function flattenArray(arrayToFlatten, arrayFlatten) {
// check if the arg is a array, if not a error is thrown
if(!Array.isArray(arrayToFlatten)) throw new Error('Only can flat arrays and you pass a ' + typeof arrayToFlatten)
// set the default value of arrayFlatten, this validation is used only in the firs... | javascript | {
"resource": ""
} |
q42406 | nextQuestion | train | function nextQuestion() {
if ( !hooks.length ) {
if ( !!options.onDone ) {
grunt.log.writeln( '' );
grunt.log.writeln( options.onDone.blue );
}
done();
} else {
var hookConfig = hooks.shift();
promptHook( hookConfig );
}
} | javascript | {
"resource": ""
} |
q42407 | actuallyInstallHook | train | function actuallyInstallHook(
hookToCopy,
whereToPutIt,
sourceCanonicalName
) {
mkpath.sync( path.join( './', path.dirname( whereToPutIt ) ) );
exec( 'cp ' + hookToCopy + ' ' + whereToPutIt );
grunt.log.writeln( [
'Installed ', sourceCanonicalName, ' hook in ', whereToPutIt
].join( '' ).green... | javascript | {
"resource": ""
} |
q42408 | train | function(e) {
var touch = e.touches[0]
// Make sure click doesn't fire
touchClientX = touch.clientX
touchClientY = touch.clientY
timestamp = Date.now()
} | javascript | {
"resource": ""
} | |
q42409 | login | train | function login(){
console.log('Login called');
var username = document.getElementById('login-username').value;
var password = document.getElementById('login-password').value;
// {username:username, password:password}
grout.login('google').then(function (loginInfo){
console.log('successful login:',... | javascript | {
"resource": ""
} |
q42410 | logout | train | function logout(){
console.log('Logout called');
grout.logout().then(function(){
console.log('successful logout');
setStatus();
}, function (err){
console.error('logout() : Error logging out:', err);
});
} | javascript | {
"resource": ""
} |
q42411 | signup | train | function signup(){
console.log('signup called');
var name = document.getElementById('signup-name').value;
var username = document.getElementById('signup-username').value;
var email = document.getElementById('signup-email').value;
var password = document.getElementById('signup-password').value;
... | javascript | {
"resource": ""
} |
q42412 | getProjects | train | function getProjects(){
console.log('getProjects called');
grout.Projects.get().then(function(appsList){
console.log('apps list loaded:', appsList);
var outHtml = '<h2>No app data</h2>';
if (appsList) {
outHtml = '<ul>';
appsList.forEach(function(app){
outHtml += '<li... | javascript | {
"resource": ""
} |
q42413 | getFile | train | function getFile() {
var file = grout.Project('test', 'scott').File({key: 'index.html', path: 'index.html'});
console.log('fbUrl', file.fbUrl);
console.log('fbRef', file.fbRef);
file.get().then(function(app){
console.log('file loaded:', app);
document.getElementById("output").innerHTML = JSO... | javascript | {
"resource": ""
} |
q42414 | getUsers | train | function getUsers(){
console.log('getUsers called');
grout.Users.get().then(function(app){
console.log('apps list loaded:', app);
document.getElementById("output").innerHTML = JSON.stringify(app);
}, function(err){
console.error('Error getting users:', err);
});
} | javascript | {
"resource": ""
} |
q42415 | searchUsers | train | function searchUsers(searchStr){
console.log('getUsers called');
if(!searchStr){
searchStr = document.getElementById('search').value;
}
grout.Users.search(searchStr).then(function(users){
console.log('search users loaded:', users);
document.getElementById("search-output").innerHTML = J... | javascript | {
"resource": ""
} |
q42416 | write | train | function write(msg, color, prefix) {
if (!prefix)
prefix = clc.cyan('[conquer]');
// Print each line of the message on its own line.
var messages = msg.split('\n');
for (var i = 0; i < messages.length; i++) {
var message = messages[i].replace(/(\s?$)|(\n?$)/gm, '');
if (message && message.length > 0)
cons... | javascript | {
"resource": ""
} |
q42417 | log | train | function log() {
var msg = util.format.apply(null, Array.prototype.slice.call(arguments, 0));
write(msg);
} | javascript | {
"resource": ""
} |
q42418 | warn | train | function warn() {
var msg = util.format.apply(null, Array.prototype.slice.call(arguments, 0));
write(msg, clc.yellow);
} | javascript | {
"resource": ""
} |
q42419 | error | train | function error() {
var msg = util.format.apply(null, Array.prototype.slice.call(arguments, 0));
write(msg, clc.red);
} | javascript | {
"resource": ""
} |
q42420 | scriptLog | train | function scriptLog(script, msg, isError) {
write(msg,
isError ? clc.red : null,
clc.yellow('[' + script + ']'));
} | javascript | {
"resource": ""
} |
q42421 | Plugin | train | function Plugin(element, options, jsonData) {
// same the DOM element.
this.element = element;
this.jsonData = jsonData;
// merge the options.
// the jQuery extend function, the later object will
// overwrite the former object.
this.options = $.extend({}, defaultO... | javascript | {
"resource": ""
} |
q42422 | train | function(options, jsonData) {
//console.log(jsonData);
var self = this;
// remove the existing one.
$('#' + self.attrId).empty();
// need merge the options with default options.
self.options = $.extend({}, defaultOptions, options);
se... | javascript | {
"resource": ""
} | |
q42423 | train | function() {
var self = this;
var bsExplanation = '';
if(self.options.explanationBuilder) {
// call customized explanation builder.
bsExplanation =
self.options.explanationBuilder(self.attrId);
} else {
... | javascript | {
"resource": ""
} | |
q42424 | train | function() {
var self = this;
// calculate the location and offset.
// the largest rectangle that can be inscribed in a
// circle is a square.
// calculate the offset for the center of the chart.
var offset = $('#' + self.getGenericId('svg')).... | javascript | {
"resource": ""
} | |
q42425 | train | function(p) {
var self = this;
if (p.depth > 1) p = p.parent;
// no children
if (!p.children) return;
//console.log("zoom in p.value = " + p.value);
//console.log("zoom in p.name = " + p.name);
self.updateExplanation(p.value, p.name)... | javascript | {
"resource": ""
} | |
q42426 | train | function(pageviews, name) {
var self = this;
$("#" + self.getGenericId('pageviews'))
.text(self.formatNumber(pageviews));
$("#" + self.getGenericId("group")).text(name);
var percentage = pageviews / self.totalValue;
$("#" + self.getGenericId(... | javascript | {
"resource": ""
} | |
q42427 | train | function(p) {
var self = this;
if (!p) return;
if (!p.parent) return;
//console.log("zoom out p.value = " + p.parent.value);
//console.log("zoom out p.name = " + p.parent.name);
//console.log(p.parent);
self.updateExplanation(p.paren... | javascript | {
"resource": ""
} | |
q42428 | onFile | train | function onFile(filePath, stat) {
if (filePath.match(ignore) || filePath.match(globalIgnore)) { return; }
var newTimestamp = updateTimestamp(stat.mtime);
if (manifest['CACHE'].insert(toUrl(cleanPath(filePath))) || newTimestamp) {
updateListener(manifest);
}
} | javascript | {
"resource": ""
} |
q42429 | filterPrompts | train | function filterPrompts( PromptAnswers, generator_prompts ) {
return filter(
generator_prompts,
function iteratee( prompt ) {
return typeof PromptAnswers.get( prompt.name ) === 'undefined';
}
);
} | javascript | {
"resource": ""
} |
q42430 | Through | train | function Through (options, transform, flush) {
var self = this
if (!(this instanceof Through)) {
return new Through(options, transform, flush)
}
if (typeof options === 'function') {
flush = transform
transform = options
options = {}
}
options = options || {}
Transform.call(this, options... | javascript | {
"resource": ""
} |
q42431 | finishSpec | train | function finishSpec(spec, opts, field) {
if (opts.unique) {
var keylength = parseInt(opts.unique, 10) ? opts.unique : undefined;
if (opts.unique === true && spec.sql.match(/^(text|blob)/i)) {
var msg = 'When adding a unique key to an unsized type (text or blob), unique must be set with a length e.g... | javascript | {
"resource": ""
} |
q42432 | pprintSEXP | train | function pprintSEXP(formJson, opts, indentLevel, priorNodeStr) {
opts = opts || {};
opts.lbracket = "(";
opts.rbracket = ")";
opts.separator = " ";
opts.bareSymbols = true;
return pprintJSON(formJson, opts, indentLevel, priorNodeStr);
} | javascript | {
"resource": ""
} |
q42433 | isQuotedString | train | function isQuotedString(str) {
var is = false;
if(typeof str === 'string') {
var firstChar = str.charAt(0);
is = (['"', "'", '`'].indexOf(firstChar) !== -1);
}
return is;
} | javascript | {
"resource": ""
} |
q42434 | stripQuotes | train | function stripQuotes(text) {
var sansquotes = text;
if(isQuotedString(text)) {
if(text.length === 2) {
sanquotes = ""; // empty string
}
else {
sansquotes = text.substring(1, text.length-1);
// DELETE? sansquotes = unescapeQuotes(sansquotes);
}
}
return sansquotes;
} | javascript | {
"resource": ""
} |
q42435 | addQuotes | train | function addQuotes(text, quoteChar) {
var withquotes = text;
if(!isQuotedString(text)) {
var delim = quoteChar && quoteChar.length === 1 ? quoteChar : '"';
withquotes = delim + text + delim;
}
return withquotes;
} | javascript | {
"resource": ""
} |
q42436 | getPixels | train | function getPixels(texture, opts) {
var gl = texture.gl
if (!gl)
throw new Error("must provide gl-texture2d object with a valid 'gl' context")
if (!fbo) {
var handle = gl.createFramebuffer()
fbo = {
handle: handle,
dispose: dispose,
gl: gl
... | javascript | {
"resource": ""
} |
q42437 | train | function(listsEnabled, lineAttributesEnabled) {
if ((!hasList() && !hasLineAttributes) || (!listsEnabled && !lineAttributesEnabled)) {
return {
lineAttributes: [],
inlineAttributeString: rawAttributeString,
inlinePlaintext: rawText
... | javascript | {
"resource": ""
} | |
q42438 | train | function( userID ) {
var id = curId;
curId++;
if( curId == Number.MAX_VALUE )
curId = Number.MIN_VALUE;
roomUsers[ id ] = [];
return this.setRoomData( id, {} )
.then( this.joinRoom.bind( this, userID, id ) )
.then( function() {
return id;
});
} | javascript | {
"resource": ""
} | |
q42439 | train | function( userID, roomID ) {
var userCount;
if( roomUsers[ roomID ] === undefined ) {
return promise.reject( 'No room with the id: ' + roomID );
} else {
var userIDX = roomUsers[ roomID ].indexOf( userID );
if( userIDX != -1 ) {
roomUsers[ roomID ].splice( userIDX, 1 );
userCount = roomUse... | javascript | {
"resource": ""
} | |
q42440 | train | function( roomID ) {
if( keys.length > 0 ) {
var randIdx = Math.round( Math.random() * ( keys.length - 1 ) ),
key = keys.splice( randIdx, 1 )[ 0 ];
keyToId[ key ] = roomID;
idToKey[ roomID ] = key;
return promise.resolve( key );
} else {
return promise.reject( 'Run out of keys' );
}
} | javascript | {
"resource": ""
} | |
q42441 | train | function( roomID, key ) {
return this.getRoomIdForKey( key )
.then( function( savedRoomId ) {
if( savedRoomId == roomID ) {
delete idToKey[ roomID ];
delete keyToId[ key ];
keys.push( key );
return promise.resolve();
} else {
return promise.reject( 'roomID and roomID for key do not m... | javascript | {
"resource": ""
} | |
q42442 | train | function( key ) {
var savedRoomId = keyToId[ key ];
if( savedRoomId ) {
return promise.resolve( savedRoomId );
} else {
return promise.reject();
}
} | javascript | {
"resource": ""
} | |
q42443 | train | function( roomID, key, value ) {
if( roomData[ roomID ] === undefined )
roomData[ roomID ] = {};
roomData[ roomID ][ key ] = value;
return promise.resolve( value );
} | javascript | {
"resource": ""
} | |
q42444 | train | function( roomID, key ) {
if( roomData[ roomID ] === undefined ) {
return promise.reject( 'There is no room by that id' );
} else {
return promise.resolve( roomData[ roomID ][ key ] );
}
} | javascript | {
"resource": ""
} | |
q42445 | train | function( roomID, key ) {
var oldVal;
if( roomData[ roomID ] === undefined ) {
return promise.reject( 'There is no room by that id' );
} else {
oldVal = roomData[ roomID ][ key ];
delete roomData[ roomID ][ key ];
return promise.resolve( oldVal );
}
} | javascript | {
"resource": ""
} | |
q42446 | Tag | train | function Tag(tagDict){
if(!(this instanceof Tag))
return new Tag(tagDict)
// Check tagDict has the required fields
checkType('String', 'tagDict.key', tagDict.key, {required: true});
checkType('String', 'tagDict.value', tagDict.value, {required: true});
// Init parent class
Tag.super_.call(this, tagDic... | javascript | {
"resource": ""
} |
q42447 | readJSON | train | function readJSON(filepath){
var buffer = {};
try{
buffer = JSON.parse(fs.readFileSync(filepath, { encoding:'utf8' }));
} catch(error){}
return buffer;
} | javascript | {
"resource": ""
} |
q42448 | readYAML | train | function readYAML(filepath){
var buffer = {};
try{
buffer = YAML.safeLoad(fs.readFileSync(filepath, { schema:YAML.DEFAULT_FULL_SCHEMA }));
}catch(error){
console.error(error);
}
return buffer;
} | javascript | {
"resource": ""
} |
q42449 | createMultitasks | train | function createMultitasks(gulp, aliases){
for(var task in aliases){
if(aliases.hasOwnProperty(task)){
var cmds = [];
aliases[task].forEach(function(cmd){
cmds.push(cmd);
});
gulp.task(task, cmds);
}
}
return aliases;
} | javascript | {
"resource": ""
} |
q42450 | filterFiles | train | function filterFiles(gulp, options, taskFile){
var ext = path.extname(taskFile);
if(/\.(js|coffee)$/i.test(ext)){
createTask(gulp, options, taskFile);
}else if(/\.(json)$/i.test(ext)){
createMultitasks(gulp, require(taskFile));
}else if(/\.(ya?ml)$/i.test(ext)){
createMultitasks(gulp, readYAML(taskFile));
}
... | javascript | {
"resource": ""
} |
q42451 | loadGulpConfig | train | function loadGulpConfig(gulp, options){
options = Object.assign({ data:{} }, options);
options.dirs = isObject(options.dirs) ? options.dirs : {};
options.configPath = isString(options.configPath) ? options.configPath : 'tasks';
glob.sync(options.configPath, { realpath:true }).forEach(filterFiles.bind(this, gulp, op... | javascript | {
"resource": ""
} |
q42452 | setAfter | train | function setAfter (pipes, ai, bi) {
// console.log(' move %s => %s', ai, bi);
var ap = pipes[ai];
pipes.splice(ai, 1);
pipes.splice(bi, 0, ap);
} | javascript | {
"resource": ""
} |
q42453 | setBefore | train | function setBefore (pipes, ai, bi) {
// console.log(' move %s => %s', ai, bi);
var ap = pipes[ai];
pipes.splice(ai, 1);
pipes.splice(bi, 0, ap);
} | javascript | {
"resource": ""
} |
q42454 | arity | train | function arity(cmd, args, info, sub) {
var subcommand = sub !== undefined;
// command validation decorated the info
var def = sub || info.command.def
, expected = def.arity
, first = def.first
, last = def.last
, step = def.step
, min = Math.abs(expected)
, max
// account for command,... | javascript | {
"resource": ""
} |
q42455 | createGenerateDocs | train | function createGenerateDocs(inPath, outPath) {
if (!inPath) {
throw new Error('Input path(s) argument is required');
}
if (!outPath) {
throw new Error('Output path argument is required');
}
const jsDocConfig = {
opts: {
destination: outPath,
},
};
... | javascript | {
"resource": ""
} |
q42456 | Feedsme | train | function Feedsme(opts) {
if (!this) new Feedsme(opts); // eslint-disable-line no-new
if (typeof opts === 'string') {
this.base = opts;
} else if (opts.protocol && opts.href) {
this.base = url.format(opts);
} else if (opts.url || opts.uri) {
this.base = opts.url || opts.uri;
} else {
throw new... | javascript | {
"resource": ""
} |
q42457 | validateBody | train | function validateBody(err, body) {
body = tryParse(body);
if (err || !body) {
return next(err || new Error('Unparsable response with statusCode ' + statusCode));
}
if (statusCode !== 200) {
return next(new Error(body.message || 'Invalid status code ' + statusCode));
}
... | javascript | {
"resource": ""
} |
q42458 | AsLate | train | function AsLate(arg, u, ments) {
this.args = arg + u + ments;
this.started = false;
} | javascript | {
"resource": ""
} |
q42459 | getObjectClassname | train | function getObjectClassname (listener) {
if (!listener) return DEFAULT_LISTENER;
if (typeof listener === 'string') return listener;
var constr = listener.constructor;
return constr.name || constr.toString().split(/ |\(/, 2)[1];
} | javascript | {
"resource": ""
} |
q42460 | SansServer | train | function SansServer(configuration) {
if (!(this instanceof SansServer)) return new SansServer(configuration);
const config = configuration && typeof configuration === 'object' ? Object.assign(configuration) : {};
config.logs = config.hasOwnProperty('logs') ? config.logs : true;
config.rejectable = conf... | javascript | {
"resource": ""
} |
q42461 | addHook | train | function addHook(hooks, type, weight, hook) {
const length = arguments.length;
let start = 2;
if (typeof type !== 'string') {
const err = Error('Expected first parameter to be a string. Received: ' + type);
err.code = 'ESHOOK';
throw err;
}
// handle variable input paramete... | javascript | {
"resource": ""
} |
q42462 | defineHookRunner | train | function defineHookRunner(runners, type) {
if (runners.types.hasOwnProperty(type)) {
const err = Error('There is already a hook runner defined for this type: ' + type);
err.code = 'ESHOOK';
throw err;
}
const s = Symbol(type);
runners.types[type] = s;
runners.symbols[s] = ty... | javascript | {
"resource": ""
} |
q42463 | request | train | function request(server, config, hooks, keys, request, callback) {
const start = Date.now();
if (typeof request === 'function' && typeof callback !== 'function') {
callback = request;
request = {};
}
// handle argument variations and get Request instance
const args = Array.from(arg... | javascript | {
"resource": ""
} |
q42464 | timeout | train | function timeout(seconds) {
return function timeoutSet(req, res, next) {
const timeoutId = setTimeout(() => {
if (!res.sent) res.sendStatus(504)
}, 1000 * seconds);
req.hook('response', Number.MAX_SAFE_INTEGER - 1000, function timeoutClear(req, res, next) {
clearTime... | javascript | {
"resource": ""
} |
q42465 | transform | train | function transform(req, res, next) {
const state = res.state;
const body = state.body;
const type = typeof body;
const isBuffer = body instanceof Buffer;
let contentType;
// error conversion
if (body instanceof Error) {
res.log('transform', 'Converting Error to response');
r... | javascript | {
"resource": ""
} |
q42466 | validMethod | train | function validMethod(req, res, next) {
if (httpMethods.indexOf(req.method) === -1) {
res.sendStatus(405);
} else {
next();
}
} | javascript | {
"resource": ""
} |
q42467 | train | function (name) {
if (!this.instances[name]) {
this.instances[name] = DevFixturesModel.create({name: name});
}
return this.instances[name];
} | javascript | {
"resource": ""
} | |
q42468 | sliceOf | train | function sliceOf(ars, i, parts) {
return ars.slice(
Math.floor(i/parts*ars.length),
Math.floor((i+1)/parts*ars.length));
} | javascript | {
"resource": ""
} |
q42469 | train | function(className, viewArgs) {
var self = this,
view = this.views[className],
dfd = $.Deferred();
if (view) {
view.undelegateEvents();
}
this.loader.load(className)
.then(function(Constructor) {
... | javascript | {
"resource": ""
} | |
q42470 | Directive | train | function Directive(filename, directiveArguments) {
this.filename = filename;
this.name = directiveArguments[0].value;
var directiveConfiguration = directiveArguments[1];
// Extract the last attribute of the array
if (directiveConfiguration.type === 'ArrayExpression' && directiveConfiguration.elements.length) ... | javascript | {
"resource": ""
} |
q42471 | parseAst | train | function parseAst(filename, ast) {
var directives = [];
esprimaHelper.traverse(ast, function (node) {
var calleeExpressionName = esprimaHelper.getCallExpressionName(node);
if (calleeExpressionName === 'directive') {
var directiveArguments = node['arguments'] || [];
if (directiveArguments.length ... | javascript | {
"resource": ""
} |
q42472 | parseFile | train | function parseFile(filename, code) {
if (/directive/.test(code)) {
return ngDirectiveParser.parseAst(filename, esprima.parse(code));
}
return [];
} | javascript | {
"resource": ""
} |
q42473 | connStr | train | function connStr(conn) {
var conf = mergeDefaults(conn);
var connString = conf.driver + '://' + conf.username + (conf.password ? ':' + conf.password : '') + '@' + conf.host
+ (conf.port ? ':' + conf.port : '') + '/' + conf.database;
return connString;
} | javascript | {
"resource": ""
} |
q42474 | createPool | train | function createPool(conn) {
var conf = connectionConfig[conn.app][conn.env];
conf.connStr = connStr(conn);
console.log('Creating pool to : ' + conf.connStr);
// Create the pool on the conf object for easy future access
conf.pool = anydb.createPool(conf.connStr, {
min: conf.min,
max: conf.max,
onCo... | javascript | {
"resource": ""
} |
q42475 | parseML | train | function parseML(memberLog, required) {
return memberLog.map(member => {
const cloned = clone(member);
const key = Reflect.ownKeys(cloned)[0];
const value = cloned[key];
cloned[key] = value.filter(elem => (elem !== required));
return cloned;
});
} | javascript | {
"resource": ""
} |
q42476 | addSourceInfoToML | train | function addSourceInfoToML(memberLog, source) {
let cloned = memberLog.slice();
for (const [key, value] of getIterableObjectEntries(source)) {
if (Talent.typeCheck(value)) {
cloned = addSourceInfoToML(cloned, value);
}
const foundAndCloned = clone(findWhereKey(cloned, key));
if (!foundAn... | javascript | {
"resource": ""
} |
q42477 | translate | train | function translate(content, langFile) {
return content.replace(templateRegEx, function (match, capture) {
return (0, _lodash2.default)(langMap.get(langFile), capture);
});
} | javascript | {
"resource": ""
} |
q42478 | train | function (promise) {
var targets = this._targets;
targets.push(promise);
promise['catch'](
function() {
return true;
}
).then(
function() {
targets.splice(targets.indexOf(promise), 1);... | javascript | {
"resource": ""
} | |
q42479 | train | function (type) {
var targets = this._targets.slice(),
known = {},
args = arguments.length > 1 && toArray(arguments, 1, true),
target, subs,
i, j, jlen, guid, callback;
// Add index 0 and 1 entries for use in Y.bind.apply(Y, a... | javascript | {
"resource": ""
} | |
q42480 | train | function(anchornode) {
var valid = (anchornode.get('tagName')==='A') && anchornode.getAttribute('data-pjax-mojit'),
attributes, i, parheader;
if (valid) {
attributes = {
'data-pjax-mojit': anchornode.getAttribute('data-pjax... | javascript | {
"resource": ""
} | |
q42481 | _getRef | train | function _getRef (refOrQuery) {
if (typeof refOrQuery.ref === 'function') {
refOrQuery = refOrQuery.ref()
} else if (typeof refOrQuery.ref === 'object') {
refOrQuery = refOrQuery.ref
}
return refOrQuery
} | javascript | {
"resource": ""
} |
q42482 | createRecord | train | function createRecord (snapshot) {
var value = snapshot.val()
var res = isObject(value)
? value
: { '.value': value }
res['.key'] = _getKey(snapshot)
return res
} | javascript | {
"resource": ""
} |
q42483 | indexForKey | train | function indexForKey (array, key) {
for (var i = 0; i < array.length; i++) {
if (array[i]['.key'] === key) {
return i
}
}
/* istanbul ignore next */
return -1
} | javascript | {
"resource": ""
} |
q42484 | bind | train | function bind (vm, key, source) {
var asObject = false
var cancelCallback = null
var readyCallback = null
// check { source, asArray, cancelCallback } syntax
if (isObject(source) && source.hasOwnProperty('source')) {
asObject = source.asObject
cancelCallback = source.cancelCallback
readyCallback =... | javascript | {
"resource": ""
} |
q42485 | defineReactive | train | function defineReactive (vm, key, val) {
if (key in vm) {
vm[key] = val
} else {
Vue.util.defineReactive(vm, key, val)
}
} | javascript | {
"resource": ""
} |
q42486 | bindAsArray | train | function bindAsArray (vm, key, source, cancelCallback) {
var array = []
defineReactive(vm, key, array)
var onAdd = source.on('child_added', function (snapshot, prevKey) {
var index = prevKey ? indexForKey(array, prevKey) + 1 : 0
array.splice(index, 0, createRecord(snapshot))
}, cancelCallback)
var o... | javascript | {
"resource": ""
} |
q42487 | bindAsObject | train | function bindAsObject (vm, key, source, cancelCallback) {
defineReactive(vm, key, {})
var cb = source.on('value', function (snapshot) {
vm[key] = createRecord(snapshot)
}, cancelCallback)
vm._wilddogListeners[key] = { value: cb }
} | javascript | {
"resource": ""
} |
q42488 | unbind | train | function unbind (vm, key) {
var source = vm._wilddogSources && vm._wilddogSources[key]
if (!source) {
throw new Error(
'VueWild: unbind failed: "' + key + '" is not bound to ' +
'a Wilddog reference.'
)
}
var listeners = vm._wilddogListeners[key]
for (var event in listeners) {
source.o... | javascript | {
"resource": ""
} |
q42489 | ensureRefs | train | function ensureRefs (vm) {
if (!vm.$wilddogRefs) {
vm.$wilddogRefs = Object.create(null)
vm._wilddogSources = Object.create(null)
vm._wilddogListeners = Object.create(null)
}
} | javascript | {
"resource": ""
} |
q42490 | getRequireNameForPackage | train | function getRequireNameForPackage(pkgName) {
if (this.options.rename[pkgName]) {
return this.options.rename[pkgName];
}
var requireName = pkgName.replace(this.options.replaceExp, '');
return this.options.camelize ? camelize(requireName) : requireName;
} | javascript | {
"resource": ""
} |
q42491 | ReadArray | train | function ReadArray (options, array) {
if (!(this instanceof ReadArray)) {
return new ReadArray(options, array)
}
if (Array.isArray(options)) {
array = options
options = {}
}
options = Object.assign({}, options)
Readable.call(this, options)
this._array = array || []
this._cnt = this._array... | javascript | {
"resource": ""
} |
q42492 | select | train | function select(rule, prefix) {
return rule.selectors && rule.selectors[0] && rule.selectors[0].indexOf(prefix) === 0;
} | javascript | {
"resource": ""
} |
q42493 | assertKeys | train | function assertKeys (routes) {
Object.keys(routes).forEach(function (route) {
assert.ok(meths.indexOf(route) !== -1, route + ' is an invalid method')
})
} | javascript | {
"resource": ""
} |
q42494 | getQueryResponse | train | function getQueryResponse(url) {
var response;
if (options.stopQueryParam) {
var parsedUrl = parseUrl(url, true);
if (parsedUrl.query && parsedUrl.query[options.stopQueryParam]) {
var queryResponse = parseInt(parsedUrl.query[options.stopQueryParam]);
if (queryResponse > 1) {
... | javascript | {
"resource": ""
} |
q42495 | engine | train | function engine(url) {
var ret;
var parts = /^(\w+):/.exec(url);
if (!parts) {
d.fatal("Invalid engine URI", url);
}
try {
var Engine = angular.injector(['ng', 'coa.store']).get('Engine' + parts[1].ucfirst());
r... | javascript | {
"resource": ""
} |
q42496 | getEngine | train | function getEngine(name) {
if (!dbconfig.has(name)) {
d.fatal("Trying to access data storage that is not configured:", name);
}
var conf = dbconfig.get(name);
if (!conf.engine) {
conf.engine = engine(conf.url);
}
ret... | javascript | {
"resource": ""
} |
q42497 | runDriver | train | function runDriver(location, driver, options) {
options.testComplete = options.testComplete || 'return window.TESTS_COMPLETE';
options.testPassed = options.testPassed || 'return window.TESTS_PASSED && !window.TESTS_FAILED';
var startTime = Date.now();
var jobInfo = {
name: options.name,
build: process.e... | javascript | {
"resource": ""
} |
q42498 | mergeAttributes | train | function mergeAttributes( target, source ) {
const propNames = Object.keys( source );
for ( let i = 0, numNames = propNames.length; i < numNames; i++ ) {
const name = propNames[i];
const attribute = source[name];
switch ( typeof attribute ) {
case "object" :
if ( attribute ) {
break;
}
// ... | javascript | {
"resource": ""
} |
q42499 | mergeComputeds | train | function mergeComputeds( target, source ) {
const propNames = Object.keys( source );
for ( let i = 0, numNames = propNames.length; i < numNames; i++ ) {
const name = propNames[i];
const computer = source[name];
switch ( typeof computer ) {
case "function" :
break;
default :
throw new TypeError(... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.