id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
sequence | docstring
stringlengths 4
11.8k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
53,000 | HenriJ/careless | vendor/browser-transforms.js | createSourceCodeErrorMessage | function createSourceCodeErrorMessage(code, e) {
var sourceLines = code.split('\n');
var erroneousLine = sourceLines[e.lineNumber - 1];
// Removes any leading indenting spaces and gets the number of
// chars indenting the `erroneousLine`
var indentation = 0;
erroneousLine = erroneousLine.replace(/^\s+/, function(leadingSpaces) {
indentation = leadingSpaces.length;
return '';
});
// Defines the number of characters that are going to show
// before and after the erroneous code
var LIMIT = 30;
var errorColumn = e.column - indentation;
if (errorColumn > LIMIT) {
erroneousLine = '... ' + erroneousLine.slice(errorColumn - LIMIT);
errorColumn = 4 + LIMIT;
}
if (erroneousLine.length - errorColumn > LIMIT) {
erroneousLine = erroneousLine.slice(0, errorColumn + LIMIT) + ' ...';
}
var message = '\n\n' + erroneousLine + '\n';
message += new Array(errorColumn - 1).join(' ') + '^';
return message;
} | javascript | function createSourceCodeErrorMessage(code, e) {
var sourceLines = code.split('\n');
var erroneousLine = sourceLines[e.lineNumber - 1];
// Removes any leading indenting spaces and gets the number of
// chars indenting the `erroneousLine`
var indentation = 0;
erroneousLine = erroneousLine.replace(/^\s+/, function(leadingSpaces) {
indentation = leadingSpaces.length;
return '';
});
// Defines the number of characters that are going to show
// before and after the erroneous code
var LIMIT = 30;
var errorColumn = e.column - indentation;
if (errorColumn > LIMIT) {
erroneousLine = '... ' + erroneousLine.slice(errorColumn - LIMIT);
errorColumn = 4 + LIMIT;
}
if (erroneousLine.length - errorColumn > LIMIT) {
erroneousLine = erroneousLine.slice(0, errorColumn + LIMIT) + ' ...';
}
var message = '\n\n' + erroneousLine + '\n';
message += new Array(errorColumn - 1).join(' ') + '^';
return message;
} | [
"function",
"createSourceCodeErrorMessage",
"(",
"code",
",",
"e",
")",
"{",
"var",
"sourceLines",
"=",
"code",
".",
"split",
"(",
"'\\n'",
")",
";",
"var",
"erroneousLine",
"=",
"sourceLines",
"[",
"e",
".",
"lineNumber",
"-",
"1",
"]",
";",
"// Removes any leading indenting spaces and gets the number of",
"// chars indenting the `erroneousLine`",
"var",
"indentation",
"=",
"0",
";",
"erroneousLine",
"=",
"erroneousLine",
".",
"replace",
"(",
"/",
"^\\s+",
"/",
",",
"function",
"(",
"leadingSpaces",
")",
"{",
"indentation",
"=",
"leadingSpaces",
".",
"length",
";",
"return",
"''",
";",
"}",
")",
";",
"// Defines the number of characters that are going to show",
"// before and after the erroneous code",
"var",
"LIMIT",
"=",
"30",
";",
"var",
"errorColumn",
"=",
"e",
".",
"column",
"-",
"indentation",
";",
"if",
"(",
"errorColumn",
">",
"LIMIT",
")",
"{",
"erroneousLine",
"=",
"'... '",
"+",
"erroneousLine",
".",
"slice",
"(",
"errorColumn",
"-",
"LIMIT",
")",
";",
"errorColumn",
"=",
"4",
"+",
"LIMIT",
";",
"}",
"if",
"(",
"erroneousLine",
".",
"length",
"-",
"errorColumn",
">",
"LIMIT",
")",
"{",
"erroneousLine",
"=",
"erroneousLine",
".",
"slice",
"(",
"0",
",",
"errorColumn",
"+",
"LIMIT",
")",
"+",
"' ...'",
";",
"}",
"var",
"message",
"=",
"'\\n\\n'",
"+",
"erroneousLine",
"+",
"'\\n'",
";",
"message",
"+=",
"new",
"Array",
"(",
"errorColumn",
"-",
"1",
")",
".",
"join",
"(",
"' '",
")",
"+",
"'^'",
";",
"return",
"message",
";",
"}"
] | This method returns a nicely formated line of code pointing to the exact
location of the error `e`. The line is limited in size so big lines of code
are also shown in a readable way.
Example:
... x', overflow:'scroll'}} id={} onScroll={this.scroll} class=" ...
^
@param {string} code The full string of code
@param {Error} e The error being thrown
@return {string} formatted message
@internal | [
"This",
"method",
"returns",
"a",
"nicely",
"formated",
"line",
"of",
"code",
"pointing",
"to",
"the",
"exact",
"location",
"of",
"the",
"error",
"e",
".",
"The",
"line",
"is",
"limited",
"in",
"size",
"so",
"big",
"lines",
"of",
"code",
"are",
"also",
"shown",
"in",
"a",
"readable",
"way",
"."
] | 7dea2384b412bf2a03e111dae22055dd9bdf95fe | https://github.com/HenriJ/careless/blob/7dea2384b412bf2a03e111dae22055dd9bdf95fe/vendor/browser-transforms.js#L83-L110 |
53,001 | borntorun/grunt-release-build | tasks/releasebuild.js | verifyTasks | function verifyTasks() {
if ( options.tasks.build ) {
if ( isTypeString(options.tasks.build) ) {
options.tasks.build = [options.tasks.build];
}
if ( util.isArray(options.tasks.build) ) {
options.tasks.build.forEach(function( item ) {
if ( !isTypeString(item) ) {
errorOption('tasks.build', JSON.stringify(item));
}
});
}
else {
errorOption('tasks.build', options.tasks.build);
}
}
else {
options.tasks.build = [];
}
} | javascript | function verifyTasks() {
if ( options.tasks.build ) {
if ( isTypeString(options.tasks.build) ) {
options.tasks.build = [options.tasks.build];
}
if ( util.isArray(options.tasks.build) ) {
options.tasks.build.forEach(function( item ) {
if ( !isTypeString(item) ) {
errorOption('tasks.build', JSON.stringify(item));
}
});
}
else {
errorOption('tasks.build', options.tasks.build);
}
}
else {
options.tasks.build = [];
}
} | [
"function",
"verifyTasks",
"(",
")",
"{",
"if",
"(",
"options",
".",
"tasks",
".",
"build",
")",
"{",
"if",
"(",
"isTypeString",
"(",
"options",
".",
"tasks",
".",
"build",
")",
")",
"{",
"options",
".",
"tasks",
".",
"build",
"=",
"[",
"options",
".",
"tasks",
".",
"build",
"]",
";",
"}",
"if",
"(",
"util",
".",
"isArray",
"(",
"options",
".",
"tasks",
".",
"build",
")",
")",
"{",
"options",
".",
"tasks",
".",
"build",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"isTypeString",
"(",
"item",
")",
")",
"{",
"errorOption",
"(",
"'tasks.build'",
",",
"JSON",
".",
"stringify",
"(",
"item",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"errorOption",
"(",
"'tasks.build'",
",",
"options",
".",
"tasks",
".",
"build",
")",
";",
"}",
"}",
"else",
"{",
"options",
".",
"tasks",
".",
"build",
"=",
"[",
"]",
";",
"}",
"}"
] | Test tasks.build option | [
"Test",
"tasks",
".",
"build",
"option"
] | 9f0a72c88a5e134f92766f4b9ef2b7906a791215 | https://github.com/borntorun/grunt-release-build/blob/9f0a72c88a5e134f92766f4b9ef2b7906a791215/tasks/releasebuild.js#L137-L156 |
53,002 | borntorun/grunt-release-build | tasks/releasebuild.js | verifyOthers | function verifyOthers() {
if ( !isTypeString(options.commit) ) {
errorOption('commit', options.commit);
}
if ( !isTypeString(options.tag) ) {
errorOption('tag', options.tag);
}
} | javascript | function verifyOthers() {
if ( !isTypeString(options.commit) ) {
errorOption('commit', options.commit);
}
if ( !isTypeString(options.tag) ) {
errorOption('tag', options.tag);
}
} | [
"function",
"verifyOthers",
"(",
")",
"{",
"if",
"(",
"!",
"isTypeString",
"(",
"options",
".",
"commit",
")",
")",
"{",
"errorOption",
"(",
"'commit'",
",",
"options",
".",
"commit",
")",
";",
"}",
"if",
"(",
"!",
"isTypeString",
"(",
"options",
".",
"tag",
")",
")",
"{",
"errorOption",
"(",
"'tag'",
",",
"options",
".",
"tag",
")",
";",
"}",
"}"
] | Test other options | [
"Test",
"other",
"options"
] | 9f0a72c88a5e134f92766f4b9ef2b7906a791215 | https://github.com/borntorun/grunt-release-build/blob/9f0a72c88a5e134f92766f4b9ef2b7906a791215/tasks/releasebuild.js#L161-L168 |
53,003 | borntorun/grunt-release-build | tasks/releasebuild.js | isCurrentBranch | function isCurrentBranch( branch ) {
return function() {
var deferred = Q.defer();
Q.fcall(command('git symbolic-ref --short -q HEAD', 'Get current branch'))
.then(function( data ) {
//console.log('data=',data);
if ( data && data.trim() === branch ) {
deferred.resolve(true);
}
else {
throw new Error(format('Error. Branch [%s] is not the current branch. Output:[%s]', branch, data.trim()));
}
})
.catch(function( err ) {
console.log('err=',err);
deferred.reject(err);
});
return deferred.promise;
};
} | javascript | function isCurrentBranch( branch ) {
return function() {
var deferred = Q.defer();
Q.fcall(command('git symbolic-ref --short -q HEAD', 'Get current branch'))
.then(function( data ) {
//console.log('data=',data);
if ( data && data.trim() === branch ) {
deferred.resolve(true);
}
else {
throw new Error(format('Error. Branch [%s] is not the current branch. Output:[%s]', branch, data.trim()));
}
})
.catch(function( err ) {
console.log('err=',err);
deferred.reject(err);
});
return deferred.promise;
};
} | [
"function",
"isCurrentBranch",
"(",
"branch",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"Q",
".",
"fcall",
"(",
"command",
"(",
"'git symbolic-ref --short -q HEAD'",
",",
"'Get current branch'",
")",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"//console.log('data=',data);",
"if",
"(",
"data",
"&&",
"data",
".",
"trim",
"(",
")",
"===",
"branch",
")",
"{",
"deferred",
".",
"resolve",
"(",
"true",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"format",
"(",
"'Error. Branch [%s] is not the current branch. Output:[%s]'",
",",
"branch",
",",
"data",
".",
"trim",
"(",
")",
")",
")",
";",
"}",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"console",
".",
"log",
"(",
"'err='",
",",
"err",
")",
";",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}",
";",
"}"
] | Test if a brach is the current one
@param branch
@returns {Function} | [
"Test",
"if",
"a",
"brach",
"is",
"the",
"current",
"one"
] | 9f0a72c88a5e134f92766f4b9ef2b7906a791215 | https://github.com/borntorun/grunt-release-build/blob/9f0a72c88a5e134f92766f4b9ef2b7906a791215/tasks/releasebuild.js#L175-L195 |
53,004 | borntorun/grunt-release-build | tasks/releasebuild.js | runBuildTasks | function runBuildTasks() {
return (function() {
if ( options.tasks.build.length > 0 ) {
var aToRun = [];
options.tasks.build.forEach(function( item ) {
aToRun.push(command('grunt ' + item, 'Task:' + item));
});
return aToRun.reduce(function( accum, cur ) { //tks to http://stackoverflow.com/a/24262233/854575
return accum.then(cur);
}, Q());
}
}());
} | javascript | function runBuildTasks() {
return (function() {
if ( options.tasks.build.length > 0 ) {
var aToRun = [];
options.tasks.build.forEach(function( item ) {
aToRun.push(command('grunt ' + item, 'Task:' + item));
});
return aToRun.reduce(function( accum, cur ) { //tks to http://stackoverflow.com/a/24262233/854575
return accum.then(cur);
}, Q());
}
}());
} | [
"function",
"runBuildTasks",
"(",
")",
"{",
"return",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"options",
".",
"tasks",
".",
"build",
".",
"length",
">",
"0",
")",
"{",
"var",
"aToRun",
"=",
"[",
"]",
";",
"options",
".",
"tasks",
".",
"build",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"aToRun",
".",
"push",
"(",
"command",
"(",
"'grunt '",
"+",
"item",
",",
"'Task:'",
"+",
"item",
")",
")",
";",
"}",
")",
";",
"return",
"aToRun",
".",
"reduce",
"(",
"function",
"(",
"accum",
",",
"cur",
")",
"{",
"//tks to http://stackoverflow.com/a/24262233/854575",
"return",
"accum",
".",
"then",
"(",
"cur",
")",
";",
"}",
",",
"Q",
"(",
")",
")",
";",
"}",
"}",
"(",
")",
")",
";",
"}"
] | Run build tasks | [
"Run",
"build",
"tasks"
] | 9f0a72c88a5e134f92766f4b9ef2b7906a791215 | https://github.com/borntorun/grunt-release-build/blob/9f0a72c88a5e134f92766f4b9ef2b7906a791215/tasks/releasebuild.js#L298-L312 |
53,005 | borntorun/grunt-release-build | tasks/releasebuild.js | gitTag | function gitTag() {
return function() {
var deferred = Q.defer();
if (!grunt.option('version')) {
throw new Error('Error in step [Git tag]. Version is not defined.');
}
Q.fcall(command(format('git tag -a v%s -m \'%s\'', grunt.option('version'), options.tag.replace('%v', grunt.option('version'))), 'Git tag'))
//Q.fcall(command(format('echo "git tag -a v%s -m \'%s\'"', grunt.option('version'), options.tag.replace('%v', grunt.option('version'))), 'Git tag', false))//TODO:temp
.then(function( data ) {
deferred.resolve(data);
})
.catch(function( err ) {
deferred.reject(err);
});
return deferred.promise;
};
} | javascript | function gitTag() {
return function() {
var deferred = Q.defer();
if (!grunt.option('version')) {
throw new Error('Error in step [Git tag]. Version is not defined.');
}
Q.fcall(command(format('git tag -a v%s -m \'%s\'', grunt.option('version'), options.tag.replace('%v', grunt.option('version'))), 'Git tag'))
//Q.fcall(command(format('echo "git tag -a v%s -m \'%s\'"', grunt.option('version'), options.tag.replace('%v', grunt.option('version'))), 'Git tag', false))//TODO:temp
.then(function( data ) {
deferred.resolve(data);
})
.catch(function( err ) {
deferred.reject(err);
});
return deferred.promise;
};
} | [
"function",
"gitTag",
"(",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"if",
"(",
"!",
"grunt",
".",
"option",
"(",
"'version'",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Error in step [Git tag]. Version is not defined.'",
")",
";",
"}",
"Q",
".",
"fcall",
"(",
"command",
"(",
"format",
"(",
"'git tag -a v%s -m \\'%s\\''",
",",
"grunt",
".",
"option",
"(",
"'version'",
")",
",",
"options",
".",
"tag",
".",
"replace",
"(",
"'%v'",
",",
"grunt",
".",
"option",
"(",
"'version'",
")",
")",
")",
",",
"'Git tag'",
")",
")",
"//Q.fcall(command(format('echo \"git tag -a v%s -m \\'%s\\'\"', grunt.option('version'), options.tag.replace('%v', grunt.option('version'))), 'Git tag', false))//TODO:temp",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"deferred",
".",
"resolve",
"(",
"data",
")",
";",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}",
";",
"}"
] | Tag the new version
@returns {Function} | [
"Tag",
"the",
"new",
"version"
] | 9f0a72c88a5e134f92766f4b9ef2b7906a791215 | https://github.com/borntorun/grunt-release-build/blob/9f0a72c88a5e134f92766f4b9ef2b7906a791215/tasks/releasebuild.js#L359-L376 |
53,006 | borntorun/grunt-release-build | tasks/releasebuild.js | gitRemote | function gitRemote() {
return function() {
var deferred = Q.defer();
Q.fcall(command('git remote', 'Git remote'))
.then(function( data ) {
if ( !data || !data.trim() ) {
deferred.reject(new Error('Error in step [Git remote]. No remotes founds.'));
}
var remotes = data.trim().split('\n');
if ( remotes.length == 1 ) {
grunt.option('remote', remotes[0]);
deferred.resolve(grunt.option('remote'));
}
else {
remotes.forEach(function( item, index, list ) {
list[index] = format('[%s]-%s', index + 1, item);
});
var resp = 0;
grunt.log.writeln(format('%s ', '\n\nThere are more than 1 remote associate with this repo, please choose the one to push into.\n\n' + remotes.join('\n')));
while ( isNaN(resp) || resp === 0 || resp > remotes.length ) {
resp = readlinesync.question('\nYour choice?');
if ( resp === '' ) {
grunt.option('remote', undefined);
throw new Error('Error in step [Git remote]. No response from user.');
}
resp = parseInt(resp);
}
grunt.option('remote', data.trim().split('\n')[resp-1]);//using original output
deferred.resolve(grunt.option('remote'));
}
})
.catch(function( err ) {
grunt.option('remote', undefined);
deferred.reject(err);
});
return deferred.promise;
};
} | javascript | function gitRemote() {
return function() {
var deferred = Q.defer();
Q.fcall(command('git remote', 'Git remote'))
.then(function( data ) {
if ( !data || !data.trim() ) {
deferred.reject(new Error('Error in step [Git remote]. No remotes founds.'));
}
var remotes = data.trim().split('\n');
if ( remotes.length == 1 ) {
grunt.option('remote', remotes[0]);
deferred.resolve(grunt.option('remote'));
}
else {
remotes.forEach(function( item, index, list ) {
list[index] = format('[%s]-%s', index + 1, item);
});
var resp = 0;
grunt.log.writeln(format('%s ', '\n\nThere are more than 1 remote associate with this repo, please choose the one to push into.\n\n' + remotes.join('\n')));
while ( isNaN(resp) || resp === 0 || resp > remotes.length ) {
resp = readlinesync.question('\nYour choice?');
if ( resp === '' ) {
grunt.option('remote', undefined);
throw new Error('Error in step [Git remote]. No response from user.');
}
resp = parseInt(resp);
}
grunt.option('remote', data.trim().split('\n')[resp-1]);//using original output
deferred.resolve(grunt.option('remote'));
}
})
.catch(function( err ) {
grunt.option('remote', undefined);
deferred.reject(err);
});
return deferred.promise;
};
} | [
"function",
"gitRemote",
"(",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"Q",
".",
"fcall",
"(",
"command",
"(",
"'git remote'",
",",
"'Git remote'",
")",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"if",
"(",
"!",
"data",
"||",
"!",
"data",
".",
"trim",
"(",
")",
")",
"{",
"deferred",
".",
"reject",
"(",
"new",
"Error",
"(",
"'Error in step [Git remote]. No remotes founds.'",
")",
")",
";",
"}",
"var",
"remotes",
"=",
"data",
".",
"trim",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
";",
"if",
"(",
"remotes",
".",
"length",
"==",
"1",
")",
"{",
"grunt",
".",
"option",
"(",
"'remote'",
",",
"remotes",
"[",
"0",
"]",
")",
";",
"deferred",
".",
"resolve",
"(",
"grunt",
".",
"option",
"(",
"'remote'",
")",
")",
";",
"}",
"else",
"{",
"remotes",
".",
"forEach",
"(",
"function",
"(",
"item",
",",
"index",
",",
"list",
")",
"{",
"list",
"[",
"index",
"]",
"=",
"format",
"(",
"'[%s]-%s'",
",",
"index",
"+",
"1",
",",
"item",
")",
";",
"}",
")",
";",
"var",
"resp",
"=",
"0",
";",
"grunt",
".",
"log",
".",
"writeln",
"(",
"format",
"(",
"'%s '",
",",
"'\\n\\nThere are more than 1 remote associate with this repo, please choose the one to push into.\\n\\n'",
"+",
"remotes",
".",
"join",
"(",
"'\\n'",
")",
")",
")",
";",
"while",
"(",
"isNaN",
"(",
"resp",
")",
"||",
"resp",
"===",
"0",
"||",
"resp",
">",
"remotes",
".",
"length",
")",
"{",
"resp",
"=",
"readlinesync",
".",
"question",
"(",
"'\\nYour choice?'",
")",
";",
"if",
"(",
"resp",
"===",
"''",
")",
"{",
"grunt",
".",
"option",
"(",
"'remote'",
",",
"undefined",
")",
";",
"throw",
"new",
"Error",
"(",
"'Error in step [Git remote]. No response from user.'",
")",
";",
"}",
"resp",
"=",
"parseInt",
"(",
"resp",
")",
";",
"}",
"grunt",
".",
"option",
"(",
"'remote'",
",",
"data",
".",
"trim",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
"[",
"resp",
"-",
"1",
"]",
")",
";",
"//using original output",
"deferred",
".",
"resolve",
"(",
"grunt",
".",
"option",
"(",
"'remote'",
")",
")",
";",
"}",
"}",
")",
".",
"catch",
"(",
"function",
"(",
"err",
")",
"{",
"grunt",
".",
"option",
"(",
"'remote'",
",",
"undefined",
")",
";",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}",
";",
"}"
] | Retrieve the remote name
@returns {Function} | [
"Retrieve",
"the",
"remote",
"name"
] | 9f0a72c88a5e134f92766f4b9ef2b7906a791215 | https://github.com/borntorun/grunt-release-build/blob/9f0a72c88a5e134f92766f4b9ef2b7906a791215/tasks/releasebuild.js#L382-L420 |
53,007 | tolokoban/ToloFrameWork | ker/mod/squire2/squire-raw.js | function ( range, root ) {
var container = range.startContainer,
block;
// If inline, get the containing block.
if ( isInline( container ) ) {
block = getPreviousBlock( container, root );
} else if ( container !== root && isBlock( container ) ) {
block = container;
} else {
block = getNodeBefore( container, range.startOffset );
block = getNextBlock( block, root );
}
// Check the block actually intersects the range
return block && isNodeContainedInRange( range, block, true ) ? block : null;
} | javascript | function ( range, root ) {
var container = range.startContainer,
block;
// If inline, get the containing block.
if ( isInline( container ) ) {
block = getPreviousBlock( container, root );
} else if ( container !== root && isBlock( container ) ) {
block = container;
} else {
block = getNodeBefore( container, range.startOffset );
block = getNextBlock( block, root );
}
// Check the block actually intersects the range
return block && isNodeContainedInRange( range, block, true ) ? block : null;
} | [
"function",
"(",
"range",
",",
"root",
")",
"{",
"var",
"container",
"=",
"range",
".",
"startContainer",
",",
"block",
";",
"// If inline, get the containing block.",
"if",
"(",
"isInline",
"(",
"container",
")",
")",
"{",
"block",
"=",
"getPreviousBlock",
"(",
"container",
",",
"root",
")",
";",
"}",
"else",
"if",
"(",
"container",
"!==",
"root",
"&&",
"isBlock",
"(",
"container",
")",
")",
"{",
"block",
"=",
"container",
";",
"}",
"else",
"{",
"block",
"=",
"getNodeBefore",
"(",
"container",
",",
"range",
".",
"startOffset",
")",
";",
"block",
"=",
"getNextBlock",
"(",
"block",
",",
"root",
")",
";",
"}",
"// Check the block actually intersects the range",
"return",
"block",
"&&",
"isNodeContainedInRange",
"(",
"range",
",",
"block",
",",
"true",
")",
"?",
"block",
":",
"null",
";",
"}"
] | Returns the first block at least partially contained by the range, or null if no block is contained by the range. | [
"Returns",
"the",
"first",
"block",
"at",
"least",
"partially",
"contained",
"by",
"the",
"range",
"or",
"null",
"if",
"no",
"block",
"is",
"contained",
"by",
"the",
"range",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/squire2/squire-raw.js#L1142-L1157 |
|
53,008 | tolokoban/ToloFrameWork | ker/mod/squire2/squire-raw.js | function ( event ) {
var types = event.dataTransfer.types;
var l = types.length;
var hasPlain = false;
var hasHTML = false;
while ( l-- ) {
switch ( types[l] ) {
case 'text/plain':
hasPlain = true;
break;
case 'text/html':
hasHTML = true;
break;
default:
return;
}
}
if ( hasHTML || hasPlain ) {
this.saveUndoState();
}
} | javascript | function ( event ) {
var types = event.dataTransfer.types;
var l = types.length;
var hasPlain = false;
var hasHTML = false;
while ( l-- ) {
switch ( types[l] ) {
case 'text/plain':
hasPlain = true;
break;
case 'text/html':
hasHTML = true;
break;
default:
return;
}
}
if ( hasHTML || hasPlain ) {
this.saveUndoState();
}
} | [
"function",
"(",
"event",
")",
"{",
"var",
"types",
"=",
"event",
".",
"dataTransfer",
".",
"types",
";",
"var",
"l",
"=",
"types",
".",
"length",
";",
"var",
"hasPlain",
"=",
"false",
";",
"var",
"hasHTML",
"=",
"false",
";",
"while",
"(",
"l",
"--",
")",
"{",
"switch",
"(",
"types",
"[",
"l",
"]",
")",
"{",
"case",
"'text/plain'",
":",
"hasPlain",
"=",
"true",
";",
"break",
";",
"case",
"'text/html'",
":",
"hasHTML",
"=",
"true",
";",
"break",
";",
"default",
":",
"return",
";",
"}",
"}",
"if",
"(",
"hasHTML",
"||",
"hasPlain",
")",
"{",
"this",
".",
"saveUndoState",
"(",
")",
";",
"}",
"}"
] | On Windows you can drag an drop text. We can't handle this ourselves, because as far as I can see, there's no way to get the drop insertion point. So just save an undo state and hope for the best. | [
"On",
"Windows",
"you",
"can",
"drag",
"an",
"drop",
"text",
".",
"We",
"can",
"t",
"handle",
"this",
"ourselves",
"because",
"as",
"far",
"as",
"I",
"can",
"see",
"there",
"s",
"no",
"way",
"to",
"get",
"the",
"drop",
"insertion",
"point",
".",
"So",
"just",
"save",
"an",
"undo",
"state",
"and",
"hope",
"for",
"the",
"best",
"."
] | 730845a833a9660ebfdb60ad027ebaab5ac871b6 | https://github.com/tolokoban/ToloFrameWork/blob/730845a833a9660ebfdb60ad027ebaab5ac871b6/ker/mod/squire2/squire-raw.js#L2417-L2437 |
|
53,009 | gethuman/pancakes-angular | lib/ngapp/page.settings.js | updateHead | function updateHead(title, description) {
updateTitle(title);
description = (description || '').replace(/"/g, '');
var metaDesc = angular.element($rootElement.find('meta[name=description]')[0]);
metaDesc.attr('content', description);
} | javascript | function updateHead(title, description) {
updateTitle(title);
description = (description || '').replace(/"/g, '');
var metaDesc = angular.element($rootElement.find('meta[name=description]')[0]);
metaDesc.attr('content', description);
} | [
"function",
"updateHead",
"(",
"title",
",",
"description",
")",
"{",
"updateTitle",
"(",
"title",
")",
";",
"description",
"=",
"(",
"description",
"||",
"''",
")",
".",
"replace",
"(",
"/",
"\"",
"/",
"g",
",",
"''",
")",
";",
"var",
"metaDesc",
"=",
"angular",
".",
"element",
"(",
"$rootElement",
".",
"find",
"(",
"'meta[name=description]'",
")",
"[",
"0",
"]",
")",
";",
"metaDesc",
".",
"attr",
"(",
"'content'",
",",
"description",
")",
";",
"}"
] | Set the page title and description
@param title
@param description | [
"Set",
"the",
"page",
"title",
"and",
"description"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/page.settings.js#L22-L27 |
53,010 | gethuman/pancakes-angular | lib/ngapp/page.settings.js | updatePageStyle | function updatePageStyle(pageName) {
var pageCssId = 'gh-' + pageName.replace('.', '-');
var elem = $rootElement.find('.maincontent');
if (elem && elem.length) {
elem = angular.element(elem[0]);
elem.attr('id', pageCssId);
}
} | javascript | function updatePageStyle(pageName) {
var pageCssId = 'gh-' + pageName.replace('.', '-');
var elem = $rootElement.find('.maincontent');
if (elem && elem.length) {
elem = angular.element(elem[0]);
elem.attr('id', pageCssId);
}
} | [
"function",
"updatePageStyle",
"(",
"pageName",
")",
"{",
"var",
"pageCssId",
"=",
"'gh-'",
"+",
"pageName",
".",
"replace",
"(",
"'.'",
",",
"'-'",
")",
";",
"var",
"elem",
"=",
"$rootElement",
".",
"find",
"(",
"'.maincontent'",
")",
";",
"if",
"(",
"elem",
"&&",
"elem",
".",
"length",
")",
"{",
"elem",
"=",
"angular",
".",
"element",
"(",
"elem",
"[",
"0",
"]",
")",
";",
"elem",
".",
"attr",
"(",
"'id'",
",",
"pageCssId",
")",
";",
"}",
"}"
] | Update the class name used to key off all styles on the page
@param pageName | [
"Update",
"the",
"class",
"name",
"used",
"to",
"key",
"off",
"all",
"styles",
"on",
"the",
"page"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/page.settings.js#L33-L41 |
53,011 | lautr3k/lw.canvas-filters | src/canvas-filters.js | canvasFilters | function canvasFilters(canvas, settings) {
settings = Object.assign({}, {
smoothing : false, // Smoothing [true|fale]
brightness : 0, // Image brightness [-255 to +255]
contrast : 0, // Image contrast [-255 to +255]
gamma : 0, // Image gamma correction [0.01 to 7.99]
grayscale : 'none', // Graysale algorithm [average, luma, luma-601, luma-709, luma-240, desaturation, decomposition-[min|max], [red|green|blue]-chanel]
shadesOfGray: 256, // Number of shades of gray [2-256]
invertColor : false // Invert color...
}, settings || {})
// Get canvas 2d context
let context = canvas.getContext('2d')
// Smoothing
if (context.imageSmoothingEnabled !== undefined) {
context.imageSmoothingEnabled = settings.smoothing
}
else {
context.mozImageSmoothingEnabled = settings.smoothing
context.webkitImageSmoothingEnabled = settings.smoothing
context.msImageSmoothingEnabled = settings.smoothing
context.oImageSmoothingEnabled = settings.smoothing
}
// Get image data
let imageData = context.getImageData(0, 0, canvas.width, canvas.height)
let data = imageData.data
let contrastFactor, brightnessOffset, gammaCorrection, shadesOfGrayFactor
if (settings.contrast !== 0) {
contrastFactor = (259 * (settings.contrast + 255)) / (255 * (259 - settings.contrast))
}
if (settings.brightness !== 0) {
brightnessOffset = settings.brightness
}
if (settings.gamma !== 0) {
gammaCorrection = 1 / settings.gamma
}
// Shades of gray
if (settings.shadesOfGray > 1 && settings.shadesOfGray < 256) {
shadesOfGrayFactor = 255 / (settings.shadesOfGray - 1)
}
// For each pixel
for (let i = 0, il = data.length; i < il; i += 4) {
// Apply filters
invertColor(data, i, settings.invertColor)
brightness(data, i, brightnessOffset)
contrast(data, i, contrastFactor)
gamma(data, i, gammaCorrection)
grayscale(data, i, settings.grayscale, shadesOfGrayFactor)
}
// Write new image data on the context
context.putImageData(imageData, 0, 0)
} | javascript | function canvasFilters(canvas, settings) {
settings = Object.assign({}, {
smoothing : false, // Smoothing [true|fale]
brightness : 0, // Image brightness [-255 to +255]
contrast : 0, // Image contrast [-255 to +255]
gamma : 0, // Image gamma correction [0.01 to 7.99]
grayscale : 'none', // Graysale algorithm [average, luma, luma-601, luma-709, luma-240, desaturation, decomposition-[min|max], [red|green|blue]-chanel]
shadesOfGray: 256, // Number of shades of gray [2-256]
invertColor : false // Invert color...
}, settings || {})
// Get canvas 2d context
let context = canvas.getContext('2d')
// Smoothing
if (context.imageSmoothingEnabled !== undefined) {
context.imageSmoothingEnabled = settings.smoothing
}
else {
context.mozImageSmoothingEnabled = settings.smoothing
context.webkitImageSmoothingEnabled = settings.smoothing
context.msImageSmoothingEnabled = settings.smoothing
context.oImageSmoothingEnabled = settings.smoothing
}
// Get image data
let imageData = context.getImageData(0, 0, canvas.width, canvas.height)
let data = imageData.data
let contrastFactor, brightnessOffset, gammaCorrection, shadesOfGrayFactor
if (settings.contrast !== 0) {
contrastFactor = (259 * (settings.contrast + 255)) / (255 * (259 - settings.contrast))
}
if (settings.brightness !== 0) {
brightnessOffset = settings.brightness
}
if (settings.gamma !== 0) {
gammaCorrection = 1 / settings.gamma
}
// Shades of gray
if (settings.shadesOfGray > 1 && settings.shadesOfGray < 256) {
shadesOfGrayFactor = 255 / (settings.shadesOfGray - 1)
}
// For each pixel
for (let i = 0, il = data.length; i < il; i += 4) {
// Apply filters
invertColor(data, i, settings.invertColor)
brightness(data, i, brightnessOffset)
contrast(data, i, contrastFactor)
gamma(data, i, gammaCorrection)
grayscale(data, i, settings.grayscale, shadesOfGrayFactor)
}
// Write new image data on the context
context.putImageData(imageData, 0, 0)
} | [
"function",
"canvasFilters",
"(",
"canvas",
",",
"settings",
")",
"{",
"settings",
"=",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"{",
"smoothing",
":",
"false",
",",
"// Smoothing [true|fale]",
"brightness",
":",
"0",
",",
"// Image brightness [-255 to +255]",
"contrast",
":",
"0",
",",
"// Image contrast [-255 to +255]",
"gamma",
":",
"0",
",",
"// Image gamma correction [0.01 to 7.99]",
"grayscale",
":",
"'none'",
",",
"// Graysale algorithm [average, luma, luma-601, luma-709, luma-240, desaturation, decomposition-[min|max], [red|green|blue]-chanel]",
"shadesOfGray",
":",
"256",
",",
"// Number of shades of gray [2-256]",
"invertColor",
":",
"false",
"// Invert color...",
"}",
",",
"settings",
"||",
"{",
"}",
")",
"// Get canvas 2d context",
"let",
"context",
"=",
"canvas",
".",
"getContext",
"(",
"'2d'",
")",
"// Smoothing",
"if",
"(",
"context",
".",
"imageSmoothingEnabled",
"!==",
"undefined",
")",
"{",
"context",
".",
"imageSmoothingEnabled",
"=",
"settings",
".",
"smoothing",
"}",
"else",
"{",
"context",
".",
"mozImageSmoothingEnabled",
"=",
"settings",
".",
"smoothing",
"context",
".",
"webkitImageSmoothingEnabled",
"=",
"settings",
".",
"smoothing",
"context",
".",
"msImageSmoothingEnabled",
"=",
"settings",
".",
"smoothing",
"context",
".",
"oImageSmoothingEnabled",
"=",
"settings",
".",
"smoothing",
"}",
"// Get image data",
"let",
"imageData",
"=",
"context",
".",
"getImageData",
"(",
"0",
",",
"0",
",",
"canvas",
".",
"width",
",",
"canvas",
".",
"height",
")",
"let",
"data",
"=",
"imageData",
".",
"data",
"let",
"contrastFactor",
",",
"brightnessOffset",
",",
"gammaCorrection",
",",
"shadesOfGrayFactor",
"if",
"(",
"settings",
".",
"contrast",
"!==",
"0",
")",
"{",
"contrastFactor",
"=",
"(",
"259",
"*",
"(",
"settings",
".",
"contrast",
"+",
"255",
")",
")",
"/",
"(",
"255",
"*",
"(",
"259",
"-",
"settings",
".",
"contrast",
")",
")",
"}",
"if",
"(",
"settings",
".",
"brightness",
"!==",
"0",
")",
"{",
"brightnessOffset",
"=",
"settings",
".",
"brightness",
"}",
"if",
"(",
"settings",
".",
"gamma",
"!==",
"0",
")",
"{",
"gammaCorrection",
"=",
"1",
"/",
"settings",
".",
"gamma",
"}",
"// Shades of gray",
"if",
"(",
"settings",
".",
"shadesOfGray",
">",
"1",
"&&",
"settings",
".",
"shadesOfGray",
"<",
"256",
")",
"{",
"shadesOfGrayFactor",
"=",
"255",
"/",
"(",
"settings",
".",
"shadesOfGray",
"-",
"1",
")",
"}",
"// For each pixel",
"for",
"(",
"let",
"i",
"=",
"0",
",",
"il",
"=",
"data",
".",
"length",
";",
"i",
"<",
"il",
";",
"i",
"+=",
"4",
")",
"{",
"// Apply filters",
"invertColor",
"(",
"data",
",",
"i",
",",
"settings",
".",
"invertColor",
")",
"brightness",
"(",
"data",
",",
"i",
",",
"brightnessOffset",
")",
"contrast",
"(",
"data",
",",
"i",
",",
"contrastFactor",
")",
"gamma",
"(",
"data",
",",
"i",
",",
"gammaCorrection",
")",
"grayscale",
"(",
"data",
",",
"i",
",",
"settings",
".",
"grayscale",
",",
"shadesOfGrayFactor",
")",
"}",
"// Write new image data on the context",
"context",
".",
"putImageData",
"(",
"imageData",
",",
"0",
",",
"0",
")",
"}"
] | Apply filters on provided canvas | [
"Apply",
"filters",
"on",
"provided",
"canvas"
] | b2766e5d4d306d6fa17016d0fb00365887065c20 | https://github.com/lautr3k/lw.canvas-filters/blob/b2766e5d4d306d6fa17016d0fb00365887065c20/src/canvas-filters.js#L130-L190 |
53,012 | MostlyJS/mostly-poplarjs-rest | src/wrappers.js | getHandler | function getHandler (method, trans, version) {
return function (req, res, next) {
res.setHeader('Allow', Object.values(allowedMethods).join(','));
let service = req.params.__service;
let id = req.params.__id;
let action = req.params.__action;
let path = '/' + service +
(id? '/' + id : '') +
(action? '/' + action : '');
// guess whether id is an action?
if (id && !action) {
if (!(validator.isNumeric(id) || validator.isMongoId(id))) {
action = id;
}
}
service += (action? '.' + action : '');
debug(`REST handler calling service \'${service}\'`);
debug(` => cmd \'${method}\'`);
debug(` => path \'${path}\'`);
debug(` => version \'${version}\'`);
// The service success callback which sets res.data or calls next() with the error
const callback = function (err, data) {
debug(' => service response:', err, data);
if (err) return next(err.cause || err);
res.data = data;
if (!data) {
debug(`No content returned for '${req.url}'`);
res.status(statusCodes.noContent);
} else if (method === 'post') {
res.status(statusCodes.created);
}
return next();
};
trans.act({
topic: `poplar.${service}`,
cmd: method,
path: path,
version: version,
headers: req.headers || {},
query: req.query || {},
body: req.body || {}
}, callback);
};
} | javascript | function getHandler (method, trans, version) {
return function (req, res, next) {
res.setHeader('Allow', Object.values(allowedMethods).join(','));
let service = req.params.__service;
let id = req.params.__id;
let action = req.params.__action;
let path = '/' + service +
(id? '/' + id : '') +
(action? '/' + action : '');
// guess whether id is an action?
if (id && !action) {
if (!(validator.isNumeric(id) || validator.isMongoId(id))) {
action = id;
}
}
service += (action? '.' + action : '');
debug(`REST handler calling service \'${service}\'`);
debug(` => cmd \'${method}\'`);
debug(` => path \'${path}\'`);
debug(` => version \'${version}\'`);
// The service success callback which sets res.data or calls next() with the error
const callback = function (err, data) {
debug(' => service response:', err, data);
if (err) return next(err.cause || err);
res.data = data;
if (!data) {
debug(`No content returned for '${req.url}'`);
res.status(statusCodes.noContent);
} else if (method === 'post') {
res.status(statusCodes.created);
}
return next();
};
trans.act({
topic: `poplar.${service}`,
cmd: method,
path: path,
version: version,
headers: req.headers || {},
query: req.query || {},
body: req.body || {}
}, callback);
};
} | [
"function",
"getHandler",
"(",
"method",
",",
"trans",
",",
"version",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"res",
".",
"setHeader",
"(",
"'Allow'",
",",
"Object",
".",
"values",
"(",
"allowedMethods",
")",
".",
"join",
"(",
"','",
")",
")",
";",
"let",
"service",
"=",
"req",
".",
"params",
".",
"__service",
";",
"let",
"id",
"=",
"req",
".",
"params",
".",
"__id",
";",
"let",
"action",
"=",
"req",
".",
"params",
".",
"__action",
";",
"let",
"path",
"=",
"'/'",
"+",
"service",
"+",
"(",
"id",
"?",
"'/'",
"+",
"id",
":",
"''",
")",
"+",
"(",
"action",
"?",
"'/'",
"+",
"action",
":",
"''",
")",
";",
"// guess whether id is an action?",
"if",
"(",
"id",
"&&",
"!",
"action",
")",
"{",
"if",
"(",
"!",
"(",
"validator",
".",
"isNumeric",
"(",
"id",
")",
"||",
"validator",
".",
"isMongoId",
"(",
"id",
")",
")",
")",
"{",
"action",
"=",
"id",
";",
"}",
"}",
"service",
"+=",
"(",
"action",
"?",
"'.'",
"+",
"action",
":",
"''",
")",
";",
"debug",
"(",
"`",
"\\'",
"${",
"service",
"}",
"\\'",
"`",
")",
";",
"debug",
"(",
"`",
"\\'",
"${",
"method",
"}",
"\\'",
"`",
")",
";",
"debug",
"(",
"`",
"\\'",
"${",
"path",
"}",
"\\'",
"`",
")",
";",
"debug",
"(",
"`",
"\\'",
"${",
"version",
"}",
"\\'",
"`",
")",
";",
"// The service success callback which sets res.data or calls next() with the error",
"const",
"callback",
"=",
"function",
"(",
"err",
",",
"data",
")",
"{",
"debug",
"(",
"' => service response:'",
",",
"err",
",",
"data",
")",
";",
"if",
"(",
"err",
")",
"return",
"next",
"(",
"err",
".",
"cause",
"||",
"err",
")",
";",
"res",
".",
"data",
"=",
"data",
";",
"if",
"(",
"!",
"data",
")",
"{",
"debug",
"(",
"`",
"${",
"req",
".",
"url",
"}",
"`",
")",
";",
"res",
".",
"status",
"(",
"statusCodes",
".",
"noContent",
")",
";",
"}",
"else",
"if",
"(",
"method",
"===",
"'post'",
")",
"{",
"res",
".",
"status",
"(",
"statusCodes",
".",
"created",
")",
";",
"}",
"return",
"next",
"(",
")",
";",
"}",
";",
"trans",
".",
"act",
"(",
"{",
"topic",
":",
"`",
"${",
"service",
"}",
"`",
",",
"cmd",
":",
"method",
",",
"path",
":",
"path",
",",
"version",
":",
"version",
",",
"headers",
":",
"req",
".",
"headers",
"||",
"{",
"}",
",",
"query",
":",
"req",
".",
"query",
"||",
"{",
"}",
",",
"body",
":",
"req",
".",
"body",
"||",
"{",
"}",
"}",
",",
"callback",
")",
";",
"}",
";",
"}"
] | A function that returns the middleware for a given method | [
"A",
"function",
"that",
"returns",
"the",
"middleware",
"for",
"a",
"given",
"method"
] | 0acd6ebe93e3d7dd9c08cd6e31d2b194d0a87e54 | https://github.com/MostlyJS/mostly-poplarjs-rest/blob/0acd6ebe93e3d7dd9c08cd6e31d2b194d0a87e54/src/wrappers.js#L21-L72 |
53,013 | jaycetde/is-validation | lib/chain.js | Chain | function Chain(val, name) {
if (!(this instanceof Chain)) return new Chain(val, name);
this._val = val;
this._name = name;
this.clear();
return this;
} | javascript | function Chain(val, name) {
if (!(this instanceof Chain)) return new Chain(val, name);
this._val = val;
this._name = name;
this.clear();
return this;
} | [
"function",
"Chain",
"(",
"val",
",",
"name",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Chain",
")",
")",
"return",
"new",
"Chain",
"(",
"val",
",",
"name",
")",
";",
"this",
".",
"_val",
"=",
"val",
";",
"this",
".",
"_name",
"=",
"name",
";",
"this",
".",
"clear",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Creates a chain instance
@constructor
@this {Chain}
@param {!Object} val The value the chain is focused on
@param {string} name A human-readable name of the value | [
"Creates",
"a",
"chain",
"instance"
] | 6dc9ddb830480f4bd680f904163126a9c247fa98 | https://github.com/jaycetde/is-validation/blob/6dc9ddb830480f4bd680f904163126a9c247fa98/lib/chain.js#L23-L33 |
53,014 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/RGraph/RGraph.modaldialog.js | function (id, width)
{
ModalDialog.id = id;
ModalDialog.width = width;
ModalDialog.ShowBackground();
ModalDialog.ShowDialog();
// Install the event handlers
window.onresize = ModalDialog.Resize;
// Call them initially
ModalDialog.Resize();
if (typeof(ModalDialog.onmodaldialog) == 'function') {
ModalDialog.onmodaldialog();
}
ModalDialog.FireCustomEvent('onmodaldialog');
} | javascript | function (id, width)
{
ModalDialog.id = id;
ModalDialog.width = width;
ModalDialog.ShowBackground();
ModalDialog.ShowDialog();
// Install the event handlers
window.onresize = ModalDialog.Resize;
// Call them initially
ModalDialog.Resize();
if (typeof(ModalDialog.onmodaldialog) == 'function') {
ModalDialog.onmodaldialog();
}
ModalDialog.FireCustomEvent('onmodaldialog');
} | [
"function",
"(",
"id",
",",
"width",
")",
"{",
"ModalDialog",
".",
"id",
"=",
"id",
";",
"ModalDialog",
".",
"width",
"=",
"width",
";",
"ModalDialog",
".",
"ShowBackground",
"(",
")",
";",
"ModalDialog",
".",
"ShowDialog",
"(",
")",
";",
"// Install the event handlers",
"window",
".",
"onresize",
"=",
"ModalDialog",
".",
"Resize",
";",
"// Call them initially",
"ModalDialog",
".",
"Resize",
"(",
")",
";",
"if",
"(",
"typeof",
"(",
"ModalDialog",
".",
"onmodaldialog",
")",
"==",
"'function'",
")",
"{",
"ModalDialog",
".",
"onmodaldialog",
"(",
")",
";",
"}",
"ModalDialog",
".",
"FireCustomEvent",
"(",
"'onmodaldialog'",
")",
";",
"}"
] | Shows the dialog with the supplied DIV acting as the contents
@param string id The ID of the DIV to use as the dialogs contents
@param int width The width of the dialog | [
"Shows",
"the",
"dialog",
"with",
"the",
"supplied",
"DIV",
"acting",
"as",
"the",
"contents"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.modaldialog.js#L32-L51 |
|
53,015 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/RGraph/RGraph.modaldialog.js | function ()
{
// Create the background if neccessary
ModalDialog.background = document.createElement('DIV');
ModalDialog.background.className = 'ModalDialog_background';
ModalDialog.background.style.position = 'fixed';
ModalDialog.background.style.top = 0;
ModalDialog.background.style.left = 0;
ModalDialog.background.style.width = (screen.width + 100) + 'px';
ModalDialog.background.style.height = (screen.height + 100) + 'px';
ModalDialog.background.style.backgroundColor = 'rgb(204,204,204)';
ModalDialog.background.style.opacity = 0;
ModalDialog.background.style.zIndex = 3276;
ModalDialog.background.style.filter = "Alpha(opacity=50)";
document.body.appendChild(ModalDialog.background);
ModalDialog.background.style.visibility = 'visible';
} | javascript | function ()
{
// Create the background if neccessary
ModalDialog.background = document.createElement('DIV');
ModalDialog.background.className = 'ModalDialog_background';
ModalDialog.background.style.position = 'fixed';
ModalDialog.background.style.top = 0;
ModalDialog.background.style.left = 0;
ModalDialog.background.style.width = (screen.width + 100) + 'px';
ModalDialog.background.style.height = (screen.height + 100) + 'px';
ModalDialog.background.style.backgroundColor = 'rgb(204,204,204)';
ModalDialog.background.style.opacity = 0;
ModalDialog.background.style.zIndex = 3276;
ModalDialog.background.style.filter = "Alpha(opacity=50)";
document.body.appendChild(ModalDialog.background);
ModalDialog.background.style.visibility = 'visible';
} | [
"function",
"(",
")",
"{",
"// Create the background if neccessary",
"ModalDialog",
".",
"background",
"=",
"document",
".",
"createElement",
"(",
"'DIV'",
")",
";",
"ModalDialog",
".",
"background",
".",
"className",
"=",
"'ModalDialog_background'",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"position",
"=",
"'fixed'",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"top",
"=",
"0",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"left",
"=",
"0",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"width",
"=",
"(",
"screen",
".",
"width",
"+",
"100",
")",
"+",
"'px'",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"height",
"=",
"(",
"screen",
".",
"height",
"+",
"100",
")",
"+",
"'px'",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"backgroundColor",
"=",
"'rgb(204,204,204)'",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"opacity",
"=",
"0",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"zIndex",
"=",
"3276",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"filter",
"=",
"\"Alpha(opacity=50)\"",
";",
"document",
".",
"body",
".",
"appendChild",
"(",
"ModalDialog",
".",
"background",
")",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"visibility",
"=",
"'visible'",
";",
"}"
] | Shows the background semi-transparent darkened DIV | [
"Shows",
"the",
"background",
"semi",
"-",
"transparent",
"darkened",
"DIV"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.modaldialog.js#L59-L77 |
|
53,016 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/RGraph/RGraph.modaldialog.js | function ()
{
if (ModalDialog.dialog) {
ModalDialog.dialog.style.left = (document.body.offsetWidth / 2) - (ModalDialog.dialog.offsetWidth / 2) + 'px';
}
ModalDialog.background.style.width = '2500px';
ModalDialog.background.style.height = '2500px';
} | javascript | function ()
{
if (ModalDialog.dialog) {
ModalDialog.dialog.style.left = (document.body.offsetWidth / 2) - (ModalDialog.dialog.offsetWidth / 2) + 'px';
}
ModalDialog.background.style.width = '2500px';
ModalDialog.background.style.height = '2500px';
} | [
"function",
"(",
")",
"{",
"if",
"(",
"ModalDialog",
".",
"dialog",
")",
"{",
"ModalDialog",
".",
"dialog",
".",
"style",
".",
"left",
"=",
"(",
"document",
".",
"body",
".",
"offsetWidth",
"/",
"2",
")",
"-",
"(",
"ModalDialog",
".",
"dialog",
".",
"offsetWidth",
"/",
"2",
")",
"+",
"'px'",
";",
"}",
"ModalDialog",
".",
"background",
".",
"style",
".",
"width",
"=",
"'2500px'",
";",
"ModalDialog",
".",
"background",
".",
"style",
".",
"height",
"=",
"'2500px'",
";",
"}"
] | Accommodate the window being resized | [
"Accommodate",
"the",
"window",
"being",
"resized"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.modaldialog.js#L224-L232 |
|
53,017 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/RGraph/RGraph.modaldialog.js | function (name, func)
{
if (typeof(ModalDialog.events) == 'undefined') {
ModalDialog.events = [];
}
ModalDialog.events.push([name, func]);
} | javascript | function (name, func)
{
if (typeof(ModalDialog.events) == 'undefined') {
ModalDialog.events = [];
}
ModalDialog.events.push([name, func]);
} | [
"function",
"(",
"name",
",",
"func",
")",
"{",
"if",
"(",
"typeof",
"(",
"ModalDialog",
".",
"events",
")",
"==",
"'undefined'",
")",
"{",
"ModalDialog",
".",
"events",
"=",
"[",
"]",
";",
"}",
"ModalDialog",
".",
"events",
".",
"push",
"(",
"[",
"name",
",",
"func",
"]",
")",
";",
"}"
] | Returns the page height
@return int The page height | [
"Returns",
"the",
"page",
"height"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.modaldialog.js#L242-L249 |
|
53,018 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/RGraph/RGraph.modaldialog.js | function (name)
{
for (var i=0; i<ModalDialog.events.length; ++i) {
if (typeof(ModalDialog.events[i][0]) == 'string' && ModalDialog.events[i][0] == name && typeof(ModalDialog.events[i][1]) == 'function') {
ModalDialog.events[i][1]();
}
}
} | javascript | function (name)
{
for (var i=0; i<ModalDialog.events.length; ++i) {
if (typeof(ModalDialog.events[i][0]) == 'string' && ModalDialog.events[i][0] == name && typeof(ModalDialog.events[i][1]) == 'function') {
ModalDialog.events[i][1]();
}
}
} | [
"function",
"(",
"name",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"ModalDialog",
".",
"events",
".",
"length",
";",
"++",
"i",
")",
"{",
"if",
"(",
"typeof",
"(",
"ModalDialog",
".",
"events",
"[",
"i",
"]",
"[",
"0",
"]",
")",
"==",
"'string'",
"&&",
"ModalDialog",
".",
"events",
"[",
"i",
"]",
"[",
"0",
"]",
"==",
"name",
"&&",
"typeof",
"(",
"ModalDialog",
".",
"events",
"[",
"i",
"]",
"[",
"1",
"]",
")",
"==",
"'function'",
")",
"{",
"ModalDialog",
".",
"events",
"[",
"i",
"]",
"[",
"1",
"]",
"(",
")",
";",
"}",
"}",
"}"
] | Used to fire the ModalDialog custom event
@param object obj The graph object that fires the event
@param string event The name of the event to fire | [
"Used",
"to",
"fire",
"the",
"ModalDialog",
"custom",
"event"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/RGraph/RGraph.modaldialog.js#L260-L267 |
|
53,019 | yefremov/aggregatejs | median.js | median | function median(array) {
var length = array.length;
if (length === 0) {
throw new RangeError("Error");
}
array.sort(function(a, b) {
return a - b;
});
var middle = Math.floor(length / 2);
return length % 2 ? array[middle] : (array[middle] + array[middle - 1]) / 2;
} | javascript | function median(array) {
var length = array.length;
if (length === 0) {
throw new RangeError("Error");
}
array.sort(function(a, b) {
return a - b;
});
var middle = Math.floor(length / 2);
return length % 2 ? array[middle] : (array[middle] + array[middle - 1]) / 2;
} | [
"function",
"median",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"RangeError",
"(",
"\"Error\"",
")",
";",
"}",
"array",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"return",
"a",
"-",
"b",
";",
"}",
")",
";",
"var",
"middle",
"=",
"Math",
".",
"floor",
"(",
"length",
"/",
"2",
")",
";",
"return",
"length",
"%",
"2",
"?",
"array",
"[",
"middle",
"]",
":",
"(",
"array",
"[",
"middle",
"]",
"+",
"array",
"[",
"middle",
"-",
"1",
"]",
")",
"/",
"2",
";",
"}"
] | Returns the median of the numbers in `array`.
@param {Array} array Range of numbers to get the median.
@return {number}
@example
median([100, -100, 150, -50, 100, 250]);
// => 100 | [
"Returns",
"the",
"median",
"of",
"the",
"numbers",
"in",
"array",
"."
] | 932b28a15a5707135e7095950000a838db409511 | https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/median.js#L19-L33 |
53,020 | sendanor/nor-db | lib/mysql/Connection.js | Connection | function Connection(conn) {
if(!(this instanceof Connection)) {
return new Connection(conn);
}
var self = this;
if(!conn) { throw new TypeError("no connection set"); }
self._connection = conn;
self._connect = Q.nfbind(self._connection.connect.bind(self._connection));
self._query = Q.nfbind(self._connection.query.bind(self._connection));
// These do not have callbacks when PoolConnection is used
//self._end = Q.nfbind(self._connection.end.bind(self._connection));
//self._release = Q.nfbind(self._connection.release.bind(self._connection));
self._changeUser = Q.nfbind(self._connection.changeUser.bind(self._connection));
db.Connection.call(self, conn);
} | javascript | function Connection(conn) {
if(!(this instanceof Connection)) {
return new Connection(conn);
}
var self = this;
if(!conn) { throw new TypeError("no connection set"); }
self._connection = conn;
self._connect = Q.nfbind(self._connection.connect.bind(self._connection));
self._query = Q.nfbind(self._connection.query.bind(self._connection));
// These do not have callbacks when PoolConnection is used
//self._end = Q.nfbind(self._connection.end.bind(self._connection));
//self._release = Q.nfbind(self._connection.release.bind(self._connection));
self._changeUser = Q.nfbind(self._connection.changeUser.bind(self._connection));
db.Connection.call(self, conn);
} | [
"function",
"Connection",
"(",
"conn",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Connection",
")",
")",
"{",
"return",
"new",
"Connection",
"(",
"conn",
")",
";",
"}",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"!",
"conn",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"\"no connection set\"",
")",
";",
"}",
"self",
".",
"_connection",
"=",
"conn",
";",
"self",
".",
"_connect",
"=",
"Q",
".",
"nfbind",
"(",
"self",
".",
"_connection",
".",
"connect",
".",
"bind",
"(",
"self",
".",
"_connection",
")",
")",
";",
"self",
".",
"_query",
"=",
"Q",
".",
"nfbind",
"(",
"self",
".",
"_connection",
".",
"query",
".",
"bind",
"(",
"self",
".",
"_connection",
")",
")",
";",
"// These do not have callbacks when PoolConnection is used",
"//self._end = Q.nfbind(self._connection.end.bind(self._connection));",
"//self._release = Q.nfbind(self._connection.release.bind(self._connection));",
"self",
".",
"_changeUser",
"=",
"Q",
".",
"nfbind",
"(",
"self",
".",
"_connection",
".",
"changeUser",
".",
"bind",
"(",
"self",
".",
"_connection",
")",
")",
";",
"db",
".",
"Connection",
".",
"call",
"(",
"self",
",",
"conn",
")",
";",
"}"
] | Create MySQL connection object | [
"Create",
"MySQL",
"connection",
"object"
] | db4b78691956a49370fc9d9a4eed27e7d3720aeb | https://github.com/sendanor/nor-db/blob/db4b78691956a49370fc9d9a4eed27e7d3720aeb/lib/mysql/Connection.js#L10-L26 |
53,021 | MeldCE/skemer | src/spec/lib/builder.js | mapFalseInputs | function mapFalseInputs(suite, input, p) {
if (p === undefined) {
p = 0;
}
for (p; p < input.length; p++) {
if (input[p] === false) {
var i, newInput = [];
for (i in suite[map[p]]) {
var mapped, cloned = input.slice(0);
cloned[p] = i;
if ((mapped = mapFalseInputs(suite, cloned, p + 1)) !== true) {
newInput = newInput.concat(mapped);
} else {
newInput.push(cloned);
}
}
return newInput;
}
}
return true;
} | javascript | function mapFalseInputs(suite, input, p) {
if (p === undefined) {
p = 0;
}
for (p; p < input.length; p++) {
if (input[p] === false) {
var i, newInput = [];
for (i in suite[map[p]]) {
var mapped, cloned = input.slice(0);
cloned[p] = i;
if ((mapped = mapFalseInputs(suite, cloned, p + 1)) !== true) {
newInput = newInput.concat(mapped);
} else {
newInput.push(cloned);
}
}
return newInput;
}
}
return true;
} | [
"function",
"mapFalseInputs",
"(",
"suite",
",",
"input",
",",
"p",
")",
"{",
"if",
"(",
"p",
"===",
"undefined",
")",
"{",
"p",
"=",
"0",
";",
"}",
"for",
"(",
"p",
";",
"p",
"<",
"input",
".",
"length",
";",
"p",
"++",
")",
"{",
"if",
"(",
"input",
"[",
"p",
"]",
"===",
"false",
")",
"{",
"var",
"i",
",",
"newInput",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"in",
"suite",
"[",
"map",
"[",
"p",
"]",
"]",
")",
"{",
"var",
"mapped",
",",
"cloned",
"=",
"input",
".",
"slice",
"(",
"0",
")",
";",
"cloned",
"[",
"p",
"]",
"=",
"i",
";",
"if",
"(",
"(",
"mapped",
"=",
"mapFalseInputs",
"(",
"suite",
",",
"cloned",
",",
"p",
"+",
"1",
")",
")",
"!==",
"true",
")",
"{",
"newInput",
"=",
"newInput",
".",
"concat",
"(",
"mapped",
")",
";",
"}",
"else",
"{",
"newInput",
".",
"push",
"(",
"cloned",
")",
";",
"}",
"}",
"return",
"newInput",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Expands tests containing false to repeat over all the available values
@param {Obect} suite Test suite of test array to expand
@param {Array} input Test to expand
@param {number} p Last test element expanded
@returns {Array|true} New expanded array or true if no expansion required | [
"Expands",
"tests",
"containing",
"false",
"to",
"repeat",
"over",
"all",
"the",
"available",
"values"
] | 9ef7b00c7c96db5d13c368180b2f660e571de44c | https://github.com/MeldCE/skemer/blob/9ef7b00c7c96db5d13c368180b2f660e571de44c/src/spec/lib/builder.js#L15-L38 |
53,022 | icelab/attache-upload.js | src/index.js | presignRequest | function presignRequest (presignUrl, token) {
return new Promise((resolve, reject) => {
request
.post(presignUrl)
.set({
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRF-Token': token
})
.end((err, res) => {
// throw a custom error message
if (err) return reject(customError('presignRequest', err))
resolve(res)
})
})
} | javascript | function presignRequest (presignUrl, token) {
return new Promise((resolve, reject) => {
request
.post(presignUrl)
.set({
'Accept': 'application/json',
'Content-Type': 'application/json',
'X-CSRF-Token': token
})
.end((err, res) => {
// throw a custom error message
if (err) return reject(customError('presignRequest', err))
resolve(res)
})
})
} | [
"function",
"presignRequest",
"(",
"presignUrl",
",",
"token",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"request",
".",
"post",
"(",
"presignUrl",
")",
".",
"set",
"(",
"{",
"'Accept'",
":",
"'application/json'",
",",
"'Content-Type'",
":",
"'application/json'",
",",
"'X-CSRF-Token'",
":",
"token",
"}",
")",
".",
"end",
"(",
"(",
"err",
",",
"res",
")",
"=>",
"{",
"// throw a custom error message",
"if",
"(",
"err",
")",
"return",
"reject",
"(",
"customError",
"(",
"'presignRequest'",
",",
"err",
")",
")",
"resolve",
"(",
"res",
")",
"}",
")",
"}",
")",
"}"
] | presignRequest
Perform an XHR request and Resolve or Reject
@param {String} presignUrl
@param {String} token
@param {Promise} | [
"presignRequest",
"Perform",
"an",
"XHR",
"request",
"and",
"Resolve",
"or",
"Reject"
] | ff40a9d8caa45c53e147c810dc7449de685fcaf4 | https://github.com/icelab/attache-upload.js/blob/ff40a9d8caa45c53e147c810dc7449de685fcaf4/src/index.js#L197-L212 |
53,023 | icelab/attache-upload.js | src/index.js | presign | function presign (presignUrl, token, fn = presignRequest) {
return new Promise((resolve, reject) => {
fn(presignUrl, token)
.then(responseStatus)
.then(parseJSON)
.then((res) => {
resolve(res)
})
.catch((err) => {
reject(err)
})
})
} | javascript | function presign (presignUrl, token, fn = presignRequest) {
return new Promise((resolve, reject) => {
fn(presignUrl, token)
.then(responseStatus)
.then(parseJSON)
.then((res) => {
resolve(res)
})
.catch((err) => {
reject(err)
})
})
} | [
"function",
"presign",
"(",
"presignUrl",
",",
"token",
",",
"fn",
"=",
"presignRequest",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"fn",
"(",
"presignUrl",
",",
"token",
")",
".",
"then",
"(",
"responseStatus",
")",
".",
"then",
"(",
"parseJSON",
")",
".",
"then",
"(",
"(",
"res",
")",
"=>",
"{",
"resolve",
"(",
"res",
")",
"}",
")",
".",
"catch",
"(",
"(",
"err",
")",
"=>",
"{",
"reject",
"(",
"err",
")",
"}",
")",
"}",
")",
"}"
] | presign
Take a url and optional token
return a Promise
@param {String} presignUrl
@param {String} token
@param {Function} defaults to presignRequest()
@param {Promise} | [
"presign",
"Take",
"a",
"url",
"and",
"optional",
"token",
"return",
"a",
"Promise"
] | ff40a9d8caa45c53e147c810dc7449de685fcaf4 | https://github.com/icelab/attache-upload.js/blob/ff40a9d8caa45c53e147c810dc7449de685fcaf4/src/index.js#L224-L236 |
53,024 | sumanjs/suman-inquirer-directory | index.js | Prompt | function Prompt () {
Base.apply(this, arguments);
if (!this.opt.basePath) {
this.throwParamError('basePath');
}
this.pathIndexHash = {};
this.originalBaseDir = this.currentPath =
path.normalize(path.isAbsolute(this.opt.basePath) ?
path.resolve(this.opt.basePath) : path.resolve(process.cwd(), this.opt.basePath));
if (String(this.currentPath).endsWith(path.sep)) {
this.currentPath = String(this.currentPath).slice(0, -1);
}
this.onlyOneFile = !!this.opt.onlyOneFile;
this.opt.choices = new Choices(this.createChoices(this.currentPath), this.answers);
this.selected = 0;
if (this.opt.filterItems) {
assert(typeof this.opt.filterItems === 'function', ' "filterItems" option property must be a function.');
}
this.firstRender = true;
// Make sure no default is set (so it won't be printed)
this.opt.default = null;
this.searchTerm = '';
this.paginator = new Paginator();
} | javascript | function Prompt () {
Base.apply(this, arguments);
if (!this.opt.basePath) {
this.throwParamError('basePath');
}
this.pathIndexHash = {};
this.originalBaseDir = this.currentPath =
path.normalize(path.isAbsolute(this.opt.basePath) ?
path.resolve(this.opt.basePath) : path.resolve(process.cwd(), this.opt.basePath));
if (String(this.currentPath).endsWith(path.sep)) {
this.currentPath = String(this.currentPath).slice(0, -1);
}
this.onlyOneFile = !!this.opt.onlyOneFile;
this.opt.choices = new Choices(this.createChoices(this.currentPath), this.answers);
this.selected = 0;
if (this.opt.filterItems) {
assert(typeof this.opt.filterItems === 'function', ' "filterItems" option property must be a function.');
}
this.firstRender = true;
// Make sure no default is set (so it won't be printed)
this.opt.default = null;
this.searchTerm = '';
this.paginator = new Paginator();
} | [
"function",
"Prompt",
"(",
")",
"{",
"Base",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"!",
"this",
".",
"opt",
".",
"basePath",
")",
"{",
"this",
".",
"throwParamError",
"(",
"'basePath'",
")",
";",
"}",
"this",
".",
"pathIndexHash",
"=",
"{",
"}",
";",
"this",
".",
"originalBaseDir",
"=",
"this",
".",
"currentPath",
"=",
"path",
".",
"normalize",
"(",
"path",
".",
"isAbsolute",
"(",
"this",
".",
"opt",
".",
"basePath",
")",
"?",
"path",
".",
"resolve",
"(",
"this",
".",
"opt",
".",
"basePath",
")",
":",
"path",
".",
"resolve",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"this",
".",
"opt",
".",
"basePath",
")",
")",
";",
"if",
"(",
"String",
"(",
"this",
".",
"currentPath",
")",
".",
"endsWith",
"(",
"path",
".",
"sep",
")",
")",
"{",
"this",
".",
"currentPath",
"=",
"String",
"(",
"this",
".",
"currentPath",
")",
".",
"slice",
"(",
"0",
",",
"-",
"1",
")",
";",
"}",
"this",
".",
"onlyOneFile",
"=",
"!",
"!",
"this",
".",
"opt",
".",
"onlyOneFile",
";",
"this",
".",
"opt",
".",
"choices",
"=",
"new",
"Choices",
"(",
"this",
".",
"createChoices",
"(",
"this",
".",
"currentPath",
")",
",",
"this",
".",
"answers",
")",
";",
"this",
".",
"selected",
"=",
"0",
";",
"if",
"(",
"this",
".",
"opt",
".",
"filterItems",
")",
"{",
"assert",
"(",
"typeof",
"this",
".",
"opt",
".",
"filterItems",
"===",
"'function'",
",",
"' \"filterItems\" option property must be a function.'",
")",
";",
"}",
"this",
".",
"firstRender",
"=",
"true",
";",
"// Make sure no default is set (so it won't be printed)",
"this",
".",
"opt",
".",
"default",
"=",
"null",
";",
"this",
".",
"searchTerm",
"=",
"''",
";",
"this",
".",
"paginator",
"=",
"new",
"Paginator",
"(",
")",
";",
"}"
] | stores what index to use for a path if you go back a directory
Constructor | [
"stores",
"what",
"index",
"to",
"use",
"for",
"a",
"path",
"if",
"you",
"go",
"back",
"a",
"directory",
"Constructor"
] | 6ecc706476ed0644ebf8442593884906df1c6faa | https://github.com/sumanjs/suman-inquirer-directory/blob/6ecc706476ed0644ebf8442593884906df1c6faa/index.js#L44-L75 |
53,025 | taoyuan/wide | lib/transports/file.js | createAndFlush | function createAndFlush(size) {
if (self._stream) {
self._stream.end();
self._stream.destroySoon();
}
self._size = size;
self.filename = target;
self._stream = fs.createWriteStream(fullname, self.options);
//
// We need to listen for drain events when
// write() returns false. This can make node
// mad at times.
//
self._stream.setMaxListeners(Infinity);
//
// When the current stream has finished flushing
// then we can be sure we have finished opening
// and thus can emit the `open` event.
//
self.once('flush', function () {
// Because "flush" event is based on native stream "drain" event,
// logs could be written inbetween "self.flush()" and here
// Therefore, we need to flush again to make sure everything is flushed
self.flush();
self.opening = false;
self.emit('open', fullname);
});
//
// Remark: It is possible that in the time it has taken to find the
// next logfile to be written more data than `maxsize` has been buffered,
// but for sensible limits (10s - 100s of MB) this seems unlikely in less
// than one second.
//
self.flush();
} | javascript | function createAndFlush(size) {
if (self._stream) {
self._stream.end();
self._stream.destroySoon();
}
self._size = size;
self.filename = target;
self._stream = fs.createWriteStream(fullname, self.options);
//
// We need to listen for drain events when
// write() returns false. This can make node
// mad at times.
//
self._stream.setMaxListeners(Infinity);
//
// When the current stream has finished flushing
// then we can be sure we have finished opening
// and thus can emit the `open` event.
//
self.once('flush', function () {
// Because "flush" event is based on native stream "drain" event,
// logs could be written inbetween "self.flush()" and here
// Therefore, we need to flush again to make sure everything is flushed
self.flush();
self.opening = false;
self.emit('open', fullname);
});
//
// Remark: It is possible that in the time it has taken to find the
// next logfile to be written more data than `maxsize` has been buffered,
// but for sensible limits (10s - 100s of MB) this seems unlikely in less
// than one second.
//
self.flush();
} | [
"function",
"createAndFlush",
"(",
"size",
")",
"{",
"if",
"(",
"self",
".",
"_stream",
")",
"{",
"self",
".",
"_stream",
".",
"end",
"(",
")",
";",
"self",
".",
"_stream",
".",
"destroySoon",
"(",
")",
";",
"}",
"self",
".",
"_size",
"=",
"size",
";",
"self",
".",
"filename",
"=",
"target",
";",
"self",
".",
"_stream",
"=",
"fs",
".",
"createWriteStream",
"(",
"fullname",
",",
"self",
".",
"options",
")",
";",
"//",
"// We need to listen for drain events when",
"// write() returns false. This can make node",
"// mad at times.",
"//",
"self",
".",
"_stream",
".",
"setMaxListeners",
"(",
"Infinity",
")",
";",
"//",
"// When the current stream has finished flushing",
"// then we can be sure we have finished opening",
"// and thus can emit the `open` event.",
"//",
"self",
".",
"once",
"(",
"'flush'",
",",
"function",
"(",
")",
"{",
"// Because \"flush\" event is based on native stream \"drain\" event,",
"// logs could be written inbetween \"self.flush()\" and here",
"// Therefore, we need to flush again to make sure everything is flushed",
"self",
".",
"flush",
"(",
")",
";",
"self",
".",
"opening",
"=",
"false",
";",
"self",
".",
"emit",
"(",
"'open'",
",",
"fullname",
")",
";",
"}",
")",
";",
"//",
"// Remark: It is possible that in the time it has taken to find the",
"// next logfile to be written more data than `maxsize` has been buffered,",
"// but for sensible limits (10s - 100s of MB) this seems unlikely in less",
"// than one second.",
"//",
"self",
".",
"flush",
"(",
")",
";",
"}"
] | Creates the `WriteStream` and then flushes any buffered messages. | [
"Creates",
"the",
"WriteStream",
"and",
"then",
"flushes",
"any",
"buffered",
"messages",
"."
] | a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6 | https://github.com/taoyuan/wide/blob/a3bc92580f43c56001d8a6d72b45b0e44ba3a7c6/lib/transports/file.js#L417-L456 |
53,026 | nbrownus/ppunit | lib/Suite.js | function (title) {
Suite.super_.call(this)
this.title = title
this.suites = []
this.exclusivity = Suite.EXCLUSIVITY.NONE
this.testExclusivity = undefined
this.parent = undefined
this.nextTests = []
this.globalTests = []
this.testContainer = false
this.testDependencies = []
this.hasOnlyTest = false
this._only = false
this._skip = false
this._timeout = undefined
this._prepared = false
this._nonExclusives = []
this._context = undefined
this.tests = {
beforeAll: []
, beforeEach: []
, normal: []
, afterEach: []
, afterAll: []
}
} | javascript | function (title) {
Suite.super_.call(this)
this.title = title
this.suites = []
this.exclusivity = Suite.EXCLUSIVITY.NONE
this.testExclusivity = undefined
this.parent = undefined
this.nextTests = []
this.globalTests = []
this.testContainer = false
this.testDependencies = []
this.hasOnlyTest = false
this._only = false
this._skip = false
this._timeout = undefined
this._prepared = false
this._nonExclusives = []
this._context = undefined
this.tests = {
beforeAll: []
, beforeEach: []
, normal: []
, afterEach: []
, afterAll: []
}
} | [
"function",
"(",
"title",
")",
"{",
"Suite",
".",
"super_",
".",
"call",
"(",
"this",
")",
"this",
".",
"title",
"=",
"title",
"this",
".",
"suites",
"=",
"[",
"]",
"this",
".",
"exclusivity",
"=",
"Suite",
".",
"EXCLUSIVITY",
".",
"NONE",
"this",
".",
"testExclusivity",
"=",
"undefined",
"this",
".",
"parent",
"=",
"undefined",
"this",
".",
"nextTests",
"=",
"[",
"]",
"this",
".",
"globalTests",
"=",
"[",
"]",
"this",
".",
"testContainer",
"=",
"false",
"this",
".",
"testDependencies",
"=",
"[",
"]",
"this",
".",
"hasOnlyTest",
"=",
"false",
"this",
".",
"_only",
"=",
"false",
"this",
".",
"_skip",
"=",
"false",
"this",
".",
"_timeout",
"=",
"undefined",
"this",
".",
"_prepared",
"=",
"false",
"this",
".",
"_nonExclusives",
"=",
"[",
"]",
"this",
".",
"_context",
"=",
"undefined",
"this",
".",
"tests",
"=",
"{",
"beforeAll",
":",
"[",
"]",
",",
"beforeEach",
":",
"[",
"]",
",",
"normal",
":",
"[",
"]",
",",
"afterEach",
":",
"[",
"]",
",",
"afterAll",
":",
"[",
"]",
"}",
"}"
] | Contains a set of tests and children suites
@param {String} title Title for the suite
@constructor | [
"Contains",
"a",
"set",
"of",
"tests",
"and",
"children",
"suites"
] | dcce602497d9548ce9085a8db115e65561dcc3de | https://github.com/nbrownus/ppunit/blob/dcce602497d9548ce9085a8db115e65561dcc3de/lib/Suite.js#L12-L41 |
|
53,027 | origin1tech/chek | dist/modules/is.js | isArray | function isArray(val) {
/* istanbul ignore if */
if (!Array.isArray)
return constant_1.toStr.call(val) === '[object Array]';
return Array.isArray(val);
} | javascript | function isArray(val) {
/* istanbul ignore if */
if (!Array.isArray)
return constant_1.toStr.call(val) === '[object Array]';
return Array.isArray(val);
} | [
"function",
"isArray",
"(",
"val",
")",
"{",
"/* istanbul ignore if */",
"if",
"(",
"!",
"Array",
".",
"isArray",
")",
"return",
"constant_1",
".",
"toStr",
".",
"call",
"(",
"val",
")",
"===",
"'[object Array]'",
";",
"return",
"Array",
".",
"isArray",
"(",
"val",
")",
";",
"}"
] | Is Array
Check if value is an array.
@param val the value to test if is array. | [
"Is",
"Array",
"Check",
"if",
"value",
"is",
"an",
"array",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L20-L25 |
53,028 | origin1tech/chek | dist/modules/is.js | isBrowser | function isBrowser(override) {
// Enables checking a process.env key while
// in Node.
if (override)
return typeof process !== 'undefined' &&
function_1.tryWrap(to_1.toBoolean, process.env &&
process.env[override])(false) === true;
// Otherwise just return NOT Node.
return !isNode();
} | javascript | function isBrowser(override) {
// Enables checking a process.env key while
// in Node.
if (override)
return typeof process !== 'undefined' &&
function_1.tryWrap(to_1.toBoolean, process.env &&
process.env[override])(false) === true;
// Otherwise just return NOT Node.
return !isNode();
} | [
"function",
"isBrowser",
"(",
"override",
")",
"{",
"// Enables checking a process.env key while",
"// in Node.",
"if",
"(",
"override",
")",
"return",
"typeof",
"process",
"!==",
"'undefined'",
"&&",
"function_1",
".",
"tryWrap",
"(",
"to_1",
".",
"toBoolean",
",",
"process",
".",
"env",
"&&",
"process",
".",
"env",
"[",
"override",
"]",
")",
"(",
"false",
")",
"===",
"true",
";",
"// Otherwise just return NOT Node.",
"return",
"!",
"isNode",
"(",
")",
";",
"}"
] | Is Browser
Checks if script is running in browser.
@param override an optional key to inspect on process.env. | [
"Is",
"Browser",
"Checks",
"if",
"script",
"is",
"running",
"in",
"browser",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L42-L51 |
53,029 | origin1tech/chek | dist/modules/is.js | isDebug | function isDebug(debugging) {
// If manually passed just return.
if (isValue(debugging))
return debugging;
var eargv = process && process.execArgv;
function chkDebug() {
return (eargv.filter(function (v) { return /^(--debug|--inspect)/.test(v); }).length ||
isValue(v8debug));
}
return function_1.tryWrap(chkDebug)(false);
} | javascript | function isDebug(debugging) {
// If manually passed just return.
if (isValue(debugging))
return debugging;
var eargv = process && process.execArgv;
function chkDebug() {
return (eargv.filter(function (v) { return /^(--debug|--inspect)/.test(v); }).length ||
isValue(v8debug));
}
return function_1.tryWrap(chkDebug)(false);
} | [
"function",
"isDebug",
"(",
"debugging",
")",
"{",
"// If manually passed just return.",
"if",
"(",
"isValue",
"(",
"debugging",
")",
")",
"return",
"debugging",
";",
"var",
"eargv",
"=",
"process",
"&&",
"process",
".",
"execArgv",
";",
"function",
"chkDebug",
"(",
")",
"{",
"return",
"(",
"eargv",
".",
"filter",
"(",
"function",
"(",
"v",
")",
"{",
"return",
"/",
"^(--debug|--inspect)",
"/",
".",
"test",
"(",
"v",
")",
";",
"}",
")",
".",
"length",
"||",
"isValue",
"(",
"v8debug",
")",
")",
";",
"}",
"return",
"function_1",
".",
"tryWrap",
"(",
"chkDebug",
")",
"(",
"false",
")",
";",
"}"
] | Indicates if app is in debug mode.
@param debugging a manual flag to denote debugging. | [
"Indicates",
"if",
"app",
"is",
"in",
"debug",
"mode",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L81-L91 |
53,030 | origin1tech/chek | dist/modules/is.js | isEmpty | function isEmpty(val) {
return (isUndefined(val) ||
isNull(val) ||
(isString(val) && val.length === 0) ||
(isNumber(val) && isNaN(val)) ||
(isPlainObject(val) && !array_1.keys(val).length) ||
(isArray(val) && !val.length));
} | javascript | function isEmpty(val) {
return (isUndefined(val) ||
isNull(val) ||
(isString(val) && val.length === 0) ||
(isNumber(val) && isNaN(val)) ||
(isPlainObject(val) && !array_1.keys(val).length) ||
(isArray(val) && !val.length));
} | [
"function",
"isEmpty",
"(",
"val",
")",
"{",
"return",
"(",
"isUndefined",
"(",
"val",
")",
"||",
"isNull",
"(",
"val",
")",
"||",
"(",
"isString",
"(",
"val",
")",
"&&",
"val",
".",
"length",
"===",
"0",
")",
"||",
"(",
"isNumber",
"(",
"val",
")",
"&&",
"isNaN",
"(",
"val",
")",
")",
"||",
"(",
"isPlainObject",
"(",
"val",
")",
"&&",
"!",
"array_1",
".",
"keys",
"(",
"val",
")",
".",
"length",
")",
"||",
"(",
"isArray",
"(",
"val",
")",
"&&",
"!",
"val",
".",
"length",
")",
")",
";",
"}"
] | Is Empty
Test if value provided is empty.
Note 0 would be empty.
@param val value to be inspected. | [
"Is",
"Empty",
"Test",
"if",
"value",
"provided",
"is",
"empty",
".",
"Note",
"0",
"would",
"be",
"empty",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L100-L107 |
53,031 | origin1tech/chek | dist/modules/is.js | isEqual | function isEqual(val, comp, loose) {
if (isDate(val) && isDate(comp))
return to_1.toEpoch(val) === to_1.toEpoch(comp);
if (loose)
return val == comp;
return val === comp;
} | javascript | function isEqual(val, comp, loose) {
if (isDate(val) && isDate(comp))
return to_1.toEpoch(val) === to_1.toEpoch(comp);
if (loose)
return val == comp;
return val === comp;
} | [
"function",
"isEqual",
"(",
"val",
",",
"comp",
",",
"loose",
")",
"{",
"if",
"(",
"isDate",
"(",
"val",
")",
"&&",
"isDate",
"(",
"comp",
")",
")",
"return",
"to_1",
".",
"toEpoch",
"(",
"val",
")",
"===",
"to_1",
".",
"toEpoch",
"(",
"comp",
")",
";",
"if",
"(",
"loose",
")",
"return",
"val",
"==",
"comp",
";",
"return",
"val",
"===",
"comp",
";",
"}"
] | Is Equal
Tests if two values are equal.
Does not support "deep equal".
@param val the value to be compared.
@param comp the comparer value.
@param loose when true == is used instead of ===. | [
"Is",
"Equal",
"Tests",
"if",
"two",
"values",
"are",
"equal",
".",
"Does",
"not",
"support",
"deep",
"equal",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L118-L124 |
53,032 | origin1tech/chek | dist/modules/is.js | isError | function isError(val, prop) {
if (!isValue(val) || !isObject(val))
return false;
var type = constant_1.toStr.call(val).toLowerCase();
return type === '[object error]' || type === '[object domexception]' || !isEmpty(val[prop]);
} | javascript | function isError(val, prop) {
if (!isValue(val) || !isObject(val))
return false;
var type = constant_1.toStr.call(val).toLowerCase();
return type === '[object error]' || type === '[object domexception]' || !isEmpty(val[prop]);
} | [
"function",
"isError",
"(",
"val",
",",
"prop",
")",
"{",
"if",
"(",
"!",
"isValue",
"(",
"val",
")",
"||",
"!",
"isObject",
"(",
"val",
")",
")",
"return",
"false",
";",
"var",
"type",
"=",
"constant_1",
".",
"toStr",
".",
"call",
"(",
"val",
")",
".",
"toLowerCase",
"(",
")",
";",
"return",
"type",
"===",
"'[object error]'",
"||",
"type",
"===",
"'[object domexception]'",
"||",
"!",
"isEmpty",
"(",
"val",
"[",
"prop",
"]",
")",
";",
"}"
] | Is Error
Checks if value is an error. Allows custom error property
which can be useful in certain scenarios to flag an object
as an error.
@param val the value/object to be inspected.
@param prop a custom property to check if exists indicating is error. | [
"Is",
"Error",
"Checks",
"if",
"value",
"is",
"an",
"error",
".",
"Allows",
"custom",
"error",
"property",
"which",
"can",
"be",
"useful",
"in",
"certain",
"scenarios",
"to",
"flag",
"an",
"object",
"as",
"an",
"error",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L135-L140 |
53,033 | origin1tech/chek | dist/modules/is.js | isDocker | function isDocker() {
if (!isNode())
return false;
var hasEnv = function_1.tryWrap(function () {
statSync('/.dockerenv');
return true;
})(false);
var hasGroup = function_1.tryWrap(function () {
return ~readFileSync('/proc/self/cgroup', 'utf8').indexOf('docker');
})(false);
return hasEnv || hasGroup;
} | javascript | function isDocker() {
if (!isNode())
return false;
var hasEnv = function_1.tryWrap(function () {
statSync('/.dockerenv');
return true;
})(false);
var hasGroup = function_1.tryWrap(function () {
return ~readFileSync('/proc/self/cgroup', 'utf8').indexOf('docker');
})(false);
return hasEnv || hasGroup;
} | [
"function",
"isDocker",
"(",
")",
"{",
"if",
"(",
"!",
"isNode",
"(",
")",
")",
"return",
"false",
";",
"var",
"hasEnv",
"=",
"function_1",
".",
"tryWrap",
"(",
"function",
"(",
")",
"{",
"statSync",
"(",
"'/.dockerenv'",
")",
";",
"return",
"true",
";",
"}",
")",
"(",
"false",
")",
";",
"var",
"hasGroup",
"=",
"function_1",
".",
"tryWrap",
"(",
"function",
"(",
")",
"{",
"return",
"~",
"readFileSync",
"(",
"'/proc/self/cgroup'",
",",
"'utf8'",
")",
".",
"indexOf",
"(",
"'docker'",
")",
";",
"}",
")",
"(",
"false",
")",
";",
"return",
"hasEnv",
"||",
"hasGroup",
";",
"}"
] | Is Docker
Checks if running inside Docker container. | [
"Is",
"Docker",
"Checks",
"if",
"running",
"inside",
"Docker",
"container",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L172-L183 |
53,034 | origin1tech/chek | dist/modules/is.js | isObject | function isObject(val) {
return (!isUndefined(val) &&
!isNull(val) &&
((val && val.constructor === Object) || typeof val === 'function' || typeof val === 'object'));
} | javascript | function isObject(val) {
return (!isUndefined(val) &&
!isNull(val) &&
((val && val.constructor === Object) || typeof val === 'function' || typeof val === 'object'));
} | [
"function",
"isObject",
"(",
"val",
")",
"{",
"return",
"(",
"!",
"isUndefined",
"(",
"val",
")",
"&&",
"!",
"isNull",
"(",
"val",
")",
"&&",
"(",
"(",
"val",
"&&",
"val",
".",
"constructor",
"===",
"Object",
")",
"||",
"typeof",
"val",
"===",
"'function'",
"||",
"typeof",
"val",
"===",
"'object'",
")",
")",
";",
"}"
] | Is Object
Checks if value is an object.
@param val the value to inspect. | [
"Is",
"Object",
"Checks",
"if",
"value",
"is",
"an",
"object",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L288-L292 |
53,035 | origin1tech/chek | dist/modules/is.js | isPromise | function isPromise(val, name) {
name = name || 'Promise';
return (!isEmpty(val) &&
val.constructor &&
val.constructor.name === name);
} | javascript | function isPromise(val, name) {
name = name || 'Promise';
return (!isEmpty(val) &&
val.constructor &&
val.constructor.name === name);
} | [
"function",
"isPromise",
"(",
"val",
",",
"name",
")",
"{",
"name",
"=",
"name",
"||",
"'Promise'",
";",
"return",
"(",
"!",
"isEmpty",
"(",
"val",
")",
"&&",
"val",
".",
"constructor",
"&&",
"val",
".",
"constructor",
".",
"name",
"===",
"name",
")",
";",
"}"
] | Is Promise
Checks if value is a Promise.
@param val the value to inspect.
@param name optional constructor name for promise defaults to Promise. | [
"Is",
"Promise",
"Checks",
"if",
"value",
"is",
"a",
"Promise",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/is.js#L311-L316 |
53,036 | rowanmanning/mocha-srv | lib/app.js | renderTmpl | function renderTmpl (path, vars, callback) {
fs.readFile(path, 'utf8', function (err, file) {
if (err) {
return callback(err);
}
var out = file.replace(/\{\{([a-z]+)\}\}/ig, function (all, name) {
return vars[name];
});
callback(null, out);
});
} | javascript | function renderTmpl (path, vars, callback) {
fs.readFile(path, 'utf8', function (err, file) {
if (err) {
return callback(err);
}
var out = file.replace(/\{\{([a-z]+)\}\}/ig, function (all, name) {
return vars[name];
});
callback(null, out);
});
} | [
"function",
"renderTmpl",
"(",
"path",
",",
"vars",
",",
"callback",
")",
"{",
"fs",
".",
"readFile",
"(",
"path",
",",
"'utf8'",
",",
"function",
"(",
"err",
",",
"file",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"var",
"out",
"=",
"file",
".",
"replace",
"(",
"/",
"\\{\\{([a-z]+)\\}\\}",
"/",
"ig",
",",
"function",
"(",
"all",
",",
"name",
")",
"{",
"return",
"vars",
"[",
"name",
"]",
";",
"}",
")",
";",
"callback",
"(",
"null",
",",
"out",
")",
";",
"}",
")",
";",
"}"
] | Poor-man's mustache | [
"Poor",
"-",
"man",
"s",
"mustache"
] | 47af5e5bc91bb37ba5ccdb0ea7cf1771748fdff2 | https://github.com/rowanmanning/mocha-srv/blob/47af5e5bc91bb37ba5ccdb0ea7cf1771748fdff2/lib/app.js#L55-L65 |
53,037 | sendanor/nor-nopg | src/schema/v0032.js | function(db) {
var methods_uuid = uuid();
debug.assert(methods_uuid).is('uuid');
return db.query('CREATE SEQUENCE methods_seq')
.query(['CREATE TABLE IF NOT EXISTS methods (',
" id uuid PRIMARY KEY NOT NULL default uuid_generate_v5('"+methods_uuid+"', nextval('methods_seq'::regclass)::text),",
' types_id uuid REFERENCES types,',
' type text NOT NULL,',
' name text NOT NULL,',
' body text NOT NULL,',
' meta json NOT NULL,',
' active BOOLEAN DEFAULT TRUE,',
' created timestamptz NOT NULL default now(),',
' modified timestamptz NOT NULL default now(),',
' CONSTRAINT active_not_false CHECK(active != false)',
')'
].join('\n'))
.query('ALTER SEQUENCE methods_seq OWNED BY methods.id')
.query('CREATE INDEX methods_types_id ON methods (types_id)')
.query('CREATE INDEX methods_types_id_name ON methods (types_id,name)')
.query('CREATE INDEX methods_type ON methods (type)')
.query('CREATE INDEX methods_type_name ON methods (type,name)')
.query('CREATE UNIQUE INDEX ON methods USING btree(types_id, name, active nulls LAST);')
.query('CREATE TRIGGER methods_modified BEFORE UPDATE ON methods FOR EACH ROW EXECUTE PROCEDURE moddatetime (modified)')
.query(
[
'CREATE OR REPLACE FUNCTION ensure_only_one_active_row_trigger()',
'RETURNS trigger',
'AS $function$',
'BEGIN',
// Disable the currently enabled row
" IF (TG_OP = 'UPDATE') THEN",
// Nothing to do if updating the row currently enabled'
" IF (OLD.active = true AND OLD.name = NEW.name) THEN",
' RETURN NEW;',
' END IF;',
" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, OLD.name);",
" IF (OLD.name != NEW.name) THEN",
" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, NEW.name);",
' END IF;',
' ELSE',
" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, NEW.name);",
' END IF;',
// Enable new row
' NEW.active := true;',
' RETURN NEW;',
'END;',
'$function$',
'LANGUAGE plpgsql'
].join('\n')
)
.query('CREATE TRIGGER methods_only_one_active_row'+
' BEFORE INSERT OR UPDATE OF active ON methods'+
' FOR EACH ROW WHEN (NEW.active = true)'+
' EXECUTE PROCEDURE ensure_only_one_active_row_trigger()'
);
} | javascript | function(db) {
var methods_uuid = uuid();
debug.assert(methods_uuid).is('uuid');
return db.query('CREATE SEQUENCE methods_seq')
.query(['CREATE TABLE IF NOT EXISTS methods (',
" id uuid PRIMARY KEY NOT NULL default uuid_generate_v5('"+methods_uuid+"', nextval('methods_seq'::regclass)::text),",
' types_id uuid REFERENCES types,',
' type text NOT NULL,',
' name text NOT NULL,',
' body text NOT NULL,',
' meta json NOT NULL,',
' active BOOLEAN DEFAULT TRUE,',
' created timestamptz NOT NULL default now(),',
' modified timestamptz NOT NULL default now(),',
' CONSTRAINT active_not_false CHECK(active != false)',
')'
].join('\n'))
.query('ALTER SEQUENCE methods_seq OWNED BY methods.id')
.query('CREATE INDEX methods_types_id ON methods (types_id)')
.query('CREATE INDEX methods_types_id_name ON methods (types_id,name)')
.query('CREATE INDEX methods_type ON methods (type)')
.query('CREATE INDEX methods_type_name ON methods (type,name)')
.query('CREATE UNIQUE INDEX ON methods USING btree(types_id, name, active nulls LAST);')
.query('CREATE TRIGGER methods_modified BEFORE UPDATE ON methods FOR EACH ROW EXECUTE PROCEDURE moddatetime (modified)')
.query(
[
'CREATE OR REPLACE FUNCTION ensure_only_one_active_row_trigger()',
'RETURNS trigger',
'AS $function$',
'BEGIN',
// Disable the currently enabled row
" IF (TG_OP = 'UPDATE') THEN",
// Nothing to do if updating the row currently enabled'
" IF (OLD.active = true AND OLD.name = NEW.name) THEN",
' RETURN NEW;',
' END IF;',
" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, OLD.name);",
" IF (OLD.name != NEW.name) THEN",
" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, NEW.name);",
' END IF;',
' ELSE',
" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, NEW.name);",
' END IF;',
// Enable new row
' NEW.active := true;',
' RETURN NEW;',
'END;',
'$function$',
'LANGUAGE plpgsql'
].join('\n')
)
.query('CREATE TRIGGER methods_only_one_active_row'+
' BEFORE INSERT OR UPDATE OF active ON methods'+
' FOR EACH ROW WHEN (NEW.active = true)'+
' EXECUTE PROCEDURE ensure_only_one_active_row_trigger()'
);
} | [
"function",
"(",
"db",
")",
"{",
"var",
"methods_uuid",
"=",
"uuid",
"(",
")",
";",
"debug",
".",
"assert",
"(",
"methods_uuid",
")",
".",
"is",
"(",
"'uuid'",
")",
";",
"return",
"db",
".",
"query",
"(",
"'CREATE SEQUENCE methods_seq'",
")",
".",
"query",
"(",
"[",
"'CREATE TABLE IF NOT EXISTS methods ('",
",",
"\"\tid uuid PRIMARY KEY NOT NULL default uuid_generate_v5('\"",
"+",
"methods_uuid",
"+",
"\"', nextval('methods_seq'::regclass)::text),\"",
",",
"'\ttypes_id uuid REFERENCES types,'",
",",
"'\ttype text NOT NULL,'",
",",
"'\tname text NOT NULL,'",
",",
"'\tbody text NOT NULL,'",
",",
"'\tmeta json NOT NULL,'",
",",
"'\tactive BOOLEAN DEFAULT TRUE,'",
",",
"'\tcreated timestamptz NOT NULL default now(),'",
",",
"'\tmodified timestamptz NOT NULL default now(),'",
",",
"'\tCONSTRAINT active_not_false CHECK(active != false)'",
",",
"')'",
"]",
".",
"join",
"(",
"'\\n'",
")",
")",
".",
"query",
"(",
"'ALTER SEQUENCE methods_seq OWNED BY methods.id'",
")",
".",
"query",
"(",
"'CREATE INDEX methods_types_id ON methods (types_id)'",
")",
".",
"query",
"(",
"'CREATE INDEX methods_types_id_name ON methods (types_id,name)'",
")",
".",
"query",
"(",
"'CREATE INDEX methods_type ON methods (type)'",
")",
".",
"query",
"(",
"'CREATE INDEX methods_type_name ON methods (type,name)'",
")",
".",
"query",
"(",
"'CREATE UNIQUE INDEX ON methods USING btree(types_id, name, active nulls LAST);'",
")",
".",
"query",
"(",
"'CREATE TRIGGER methods_modified BEFORE UPDATE ON methods FOR EACH ROW EXECUTE PROCEDURE moddatetime (modified)'",
")",
".",
"query",
"(",
"[",
"'CREATE OR REPLACE FUNCTION ensure_only_one_active_row_trigger()'",
",",
"'RETURNS trigger'",
",",
"'AS $function$'",
",",
"'BEGIN'",
",",
"// Disable the currently enabled row",
"\" IF (TG_OP = 'UPDATE') THEN\"",
",",
"// Nothing to do if updating the row currently enabled'",
"\" IF (OLD.active = true AND OLD.name = NEW.name) THEN\"",
",",
"' RETURN NEW;'",
",",
"' END IF;'",
",",
"\" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, OLD.name);\"",
",",
"\" IF (OLD.name != NEW.name) THEN\"",
",",
"\" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, NEW.name);\"",
",",
"' END IF;'",
",",
"' ELSE'",
",",
"\" EXECUTE format('UPDATE %I.%I SET active = null WHERE active = true AND name = %L;', TG_TABLE_SCHEMA, TG_TABLE_NAME, NEW.name);\"",
",",
"' END IF;'",
",",
"// Enable new row",
"' NEW.active := true;'",
",",
"' RETURN NEW;'",
",",
"'END;'",
",",
"'$function$'",
",",
"'LANGUAGE plpgsql'",
"]",
".",
"join",
"(",
"'\\n'",
")",
")",
".",
"query",
"(",
"'CREATE TRIGGER methods_only_one_active_row'",
"+",
"' BEFORE INSERT OR UPDATE OF active ON methods'",
"+",
"' FOR EACH ROW WHEN (NEW.active = true)'",
"+",
"' EXECUTE PROCEDURE ensure_only_one_active_row_trigger()'",
")",
";",
"}"
] | The methods table | [
"The",
"methods",
"table"
] | 0d99b86c1a1996b5828b56de8de23700df8bbc0c | https://github.com/sendanor/nor-nopg/blob/0d99b86c1a1996b5828b56de8de23700df8bbc0c/src/schema/v0032.js#L10-L67 |
|
53,038 | jokeyrhyme/jqlint | jqlint.js | isInstance | function isInstance(node) {
if (node.type === 'Identifier') {
if (currentOptions.angular) {
if (instanceVarsRegExp.angular.test(node.name)) {
return true;
}
} else {
if (instanceVarsRegExp.noangular.test(node.name)) {
return true;
}
}
}
if (node.type === 'CallExpression') {
if (isConstructor(node.callee)) {
return true;
}
if (node.callee.type === 'MemberExpression') {
if (isInstance(node.callee.object)) {
if (node.callee.property.type === 'Identifier' &&
constants.METHODS.CHAIN.indexOf(node.callee.property.name) !== -1) {
return true;
}
}
}
}
return false;
} | javascript | function isInstance(node) {
if (node.type === 'Identifier') {
if (currentOptions.angular) {
if (instanceVarsRegExp.angular.test(node.name)) {
return true;
}
} else {
if (instanceVarsRegExp.noangular.test(node.name)) {
return true;
}
}
}
if (node.type === 'CallExpression') {
if (isConstructor(node.callee)) {
return true;
}
if (node.callee.type === 'MemberExpression') {
if (isInstance(node.callee.object)) {
if (node.callee.property.type === 'Identifier' &&
constants.METHODS.CHAIN.indexOf(node.callee.property.name) !== -1) {
return true;
}
}
}
}
return false;
} | [
"function",
"isInstance",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"type",
"===",
"'Identifier'",
")",
"{",
"if",
"(",
"currentOptions",
".",
"angular",
")",
"{",
"if",
"(",
"instanceVarsRegExp",
".",
"angular",
".",
"test",
"(",
"node",
".",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"instanceVarsRegExp",
".",
"noangular",
".",
"test",
"(",
"node",
".",
"name",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"node",
".",
"type",
"===",
"'CallExpression'",
")",
"{",
"if",
"(",
"isConstructor",
"(",
"node",
".",
"callee",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"node",
".",
"callee",
".",
"type",
"===",
"'MemberExpression'",
")",
"{",
"if",
"(",
"isInstance",
"(",
"node",
".",
"callee",
".",
"object",
")",
")",
"{",
"if",
"(",
"node",
".",
"callee",
".",
"property",
".",
"type",
"===",
"'Identifier'",
"&&",
"constants",
".",
"METHODS",
".",
"CHAIN",
".",
"indexOf",
"(",
"node",
".",
"callee",
".",
"property",
".",
"name",
")",
"!==",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | determine if a syntax node a jQuery-wrapped element list
@param node
@returns {boolean} | [
"determine",
"if",
"a",
"syntax",
"node",
"a",
"jQuery",
"-",
"wrapped",
"element",
"list"
] | 23989825abb0afe5b92cea31c9334d385ca93afb | https://github.com/jokeyrhyme/jqlint/blob/23989825abb0afe5b92cea31c9334d385ca93afb/jqlint.js#L64-L90 |
53,039 | meltmedia/node-usher | lib/decider/poller.js | DecisionPoller | function DecisionPoller(name, domain, options) {
if (!(this instanceof DecisionPoller)) {
return new DecisionPoller(name, domain, options);
}
if (!_.isString(name)) {
throw new Error('A `name` is required');
}
if (!_.isString(domain)) {
throw new Error('A `domain` is required');
}
this.name = name;
this.domain = domain;
this.options = options || {};
// Make sure taskList is an object of { name: '' }
if (this.options.taskList && _.isString(this.options.taskList)) {
this.options.taskList = { name: this.options.taskList };
}
// Set default taskList if not defined
if (!this.options.taskList) {
this.options.taskList = { name: this.name + '-tasklist' };
}
/** @private */
this._registrations = [];
this._workflows = [];
this._poller = undefined;
} | javascript | function DecisionPoller(name, domain, options) {
if (!(this instanceof DecisionPoller)) {
return new DecisionPoller(name, domain, options);
}
if (!_.isString(name)) {
throw new Error('A `name` is required');
}
if (!_.isString(domain)) {
throw new Error('A `domain` is required');
}
this.name = name;
this.domain = domain;
this.options = options || {};
// Make sure taskList is an object of { name: '' }
if (this.options.taskList && _.isString(this.options.taskList)) {
this.options.taskList = { name: this.options.taskList };
}
// Set default taskList if not defined
if (!this.options.taskList) {
this.options.taskList = { name: this.name + '-tasklist' };
}
/** @private */
this._registrations = [];
this._workflows = [];
this._poller = undefined;
} | [
"function",
"DecisionPoller",
"(",
"name",
",",
"domain",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"DecisionPoller",
")",
")",
"{",
"return",
"new",
"DecisionPoller",
"(",
"name",
",",
"domain",
",",
"options",
")",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'A `name` is required'",
")",
";",
"}",
"if",
"(",
"!",
"_",
".",
"isString",
"(",
"domain",
")",
")",
"{",
"throw",
"new",
"Error",
"(",
"'A `domain` is required'",
")",
";",
"}",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"domain",
"=",
"domain",
";",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// Make sure taskList is an object of { name: '' }",
"if",
"(",
"this",
".",
"options",
".",
"taskList",
"&&",
"_",
".",
"isString",
"(",
"this",
".",
"options",
".",
"taskList",
")",
")",
"{",
"this",
".",
"options",
".",
"taskList",
"=",
"{",
"name",
":",
"this",
".",
"options",
".",
"taskList",
"}",
";",
"}",
"// Set default taskList if not defined",
"if",
"(",
"!",
"this",
".",
"options",
".",
"taskList",
")",
"{",
"this",
".",
"options",
".",
"taskList",
"=",
"{",
"name",
":",
"this",
".",
"name",
"+",
"'-tasklist'",
"}",
";",
"}",
"/** @private */",
"this",
".",
"_registrations",
"=",
"[",
"]",
";",
"this",
".",
"_workflows",
"=",
"[",
"]",
";",
"this",
".",
"_poller",
"=",
"undefined",
";",
"}"
] | Represents a single, named decision poller, where all workflow versions can be created. Tasks will automaticly be
routed to the first workflow that satisfies the version requested. If no valid workflow is found, the task will
be marked as a failure.
@constructor
@param {string} name - The name of the workflow.
@param {string} domain - The AWS SWF domain name to use when listening for decision tasks.
@param {object} [options] - Additional SWF options used when creating and executing this workflow
(taskList, tagList, childPolicy, executionStartToCloseTimeout, taskStartToCloseTimeout) | [
"Represents",
"a",
"single",
"named",
"decision",
"poller",
"where",
"all",
"workflow",
"versions",
"can",
"be",
"created",
".",
"Tasks",
"will",
"automaticly",
"be",
"routed",
"to",
"the",
"first",
"workflow",
"that",
"satisfies",
"the",
"version",
"requested",
".",
"If",
"no",
"valid",
"workflow",
"is",
"found",
"the",
"task",
"will",
"be",
"marked",
"as",
"a",
"failure",
"."
] | fe6183bf7097f84bef935e8d9c19463accc08ad6 | https://github.com/meltmedia/node-usher/blob/fe6183bf7097f84bef935e8d9c19463accc08ad6/lib/decider/poller.js#L33-L64 |
53,040 | sorensen/configs | index.js | getInfo | function getInfo(d) {
var p = path.join(d, 'package.json')
return exists(p) ? require(p) : false
} | javascript | function getInfo(d) {
var p = path.join(d, 'package.json')
return exists(p) ? require(p) : false
} | [
"function",
"getInfo",
"(",
"d",
")",
"{",
"var",
"p",
"=",
"path",
".",
"join",
"(",
"d",
",",
"'package.json'",
")",
"return",
"exists",
"(",
"p",
")",
"?",
"require",
"(",
"p",
")",
":",
"false",
"}"
] | Find and load the `package.json` of the parent
@param {String} target directory
@returns {Object} package info | [
"Find",
"and",
"load",
"the",
"package",
".",
"json",
"of",
"the",
"parent"
] | 579d15081f47188749f4cf5efc527417809aeecb | https://github.com/sorensen/configs/blob/579d15081f47188749f4cf5efc527417809aeecb/index.js#L31-L34 |
53,041 | sorensen/configs | index.js | getPath | function getPath() {
var p = info && info.config ? info.config : './config'
if (p.charAt(0) === '/') return p
return path.join(base, p)
} | javascript | function getPath() {
var p = info && info.config ? info.config : './config'
if (p.charAt(0) === '/') return p
return path.join(base, p)
} | [
"function",
"getPath",
"(",
")",
"{",
"var",
"p",
"=",
"info",
"&&",
"info",
".",
"config",
"?",
"info",
".",
"config",
":",
"'./config'",
"if",
"(",
"p",
".",
"charAt",
"(",
"0",
")",
"===",
"'/'",
")",
"return",
"p",
"return",
"path",
".",
"join",
"(",
"base",
",",
"p",
")",
"}"
] | Determine the directory config from `package.info`, can
be relative to the project base or an absolute path
@returns {String} directory | [
"Determine",
"the",
"directory",
"config",
"from",
"package",
".",
"info",
"can",
"be",
"relative",
"to",
"the",
"project",
"base",
"or",
"an",
"absolute",
"path"
] | 579d15081f47188749f4cf5efc527417809aeecb | https://github.com/sorensen/configs/blob/579d15081f47188749f4cf5efc527417809aeecb/index.js#L43-L47 |
53,042 | sorensen/configs | index.js | pathExtend | function pathExtend(p) {
if (!exists(p)) return false
loaded.push(p)
return extend(config, require(p))
} | javascript | function pathExtend(p) {
if (!exists(p)) return false
loaded.push(p)
return extend(config, require(p))
} | [
"function",
"pathExtend",
"(",
"p",
")",
"{",
"if",
"(",
"!",
"exists",
"(",
"p",
")",
")",
"return",
"false",
"loaded",
".",
"push",
"(",
"p",
")",
"return",
"extend",
"(",
"config",
",",
"require",
"(",
"p",
")",
")",
"}"
] | Check if a path exists and extend the config if so
@param {String} path
@returns {Object} extened config | [
"Check",
"if",
"a",
"path",
"exists",
"and",
"extend",
"the",
"config",
"if",
"so"
] | 579d15081f47188749f4cf5efc527417809aeecb | https://github.com/sorensen/configs/blob/579d15081f47188749f4cf5efc527417809aeecb/index.js#L56-L60 |
53,043 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function(options, methods){
options = options || {};
// Wrap yes/no methods with a success method
options['success'] = function(result){
if ( methods['isValidResult'](result) ){
if (typeof methods['yes'] === "function") methods['yes'](result);
} else {
if (typeof methods['no'] === "function") methods['no'](result);
}
};
// Set default error method if one is not provided
if ( !options['error'] && (typeof methods['error'] === "function") ) {
options['error'] = methods['error'];
}
return options;
} | javascript | function(options, methods){
options = options || {};
// Wrap yes/no methods with a success method
options['success'] = function(result){
if ( methods['isValidResult'](result) ){
if (typeof methods['yes'] === "function") methods['yes'](result);
} else {
if (typeof methods['no'] === "function") methods['no'](result);
}
};
// Set default error method if one is not provided
if ( !options['error'] && (typeof methods['error'] === "function") ) {
options['error'] = methods['error'];
}
return options;
} | [
"function",
"(",
"options",
",",
"methods",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// Wrap yes/no methods with a success method",
"options",
"[",
"'success'",
"]",
"=",
"function",
"(",
"result",
")",
"{",
"if",
"(",
"methods",
"[",
"'isValidResult'",
"]",
"(",
"result",
")",
")",
"{",
"if",
"(",
"typeof",
"methods",
"[",
"'yes'",
"]",
"===",
"\"function\"",
")",
"methods",
"[",
"'yes'",
"]",
"(",
"result",
")",
";",
"}",
"else",
"{",
"if",
"(",
"typeof",
"methods",
"[",
"'no'",
"]",
"===",
"\"function\"",
")",
"methods",
"[",
"'no'",
"]",
"(",
"result",
")",
";",
"}",
"}",
";",
"// Set default error method if one is not provided",
"if",
"(",
"!",
"options",
"[",
"'error'",
"]",
"&&",
"(",
"typeof",
"methods",
"[",
"'error'",
"]",
"===",
"\"function\"",
")",
")",
"{",
"options",
"[",
"'error'",
"]",
"=",
"methods",
"[",
"'error'",
"]",
";",
"}",
"return",
"options",
";",
"}"
] | Helper method to allow altering callback methods | [
"Helper",
"method",
"to",
"allow",
"altering",
"callback",
"methods"
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L127-L145 |
|
53,044 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function(username, options) {
if ( this._containsCallbacks(options, ['yes', 'no']) ){
options = this._generateCallbacks(options, {
'isValidResult': function(result) {
return result == username;
},
'yes': options['yes'],
'no': options['no'],
'error': options['no']
});
this.hasValidOAuth(options);
} else {
return username == this.getLoggedInUser(options);
}
} | javascript | function(username, options) {
if ( this._containsCallbacks(options, ['yes', 'no']) ){
options = this._generateCallbacks(options, {
'isValidResult': function(result) {
return result == username;
},
'yes': options['yes'],
'no': options['no'],
'error': options['no']
});
this.hasValidOAuth(options);
} else {
return username == this.getLoggedInUser(options);
}
} | [
"function",
"(",
"username",
",",
"options",
")",
"{",
"if",
"(",
"this",
".",
"_containsCallbacks",
"(",
"options",
",",
"[",
"'yes'",
",",
"'no'",
"]",
")",
")",
"{",
"options",
"=",
"this",
".",
"_generateCallbacks",
"(",
"options",
",",
"{",
"'isValidResult'",
":",
"function",
"(",
"result",
")",
"{",
"return",
"result",
"==",
"username",
";",
"}",
",",
"'yes'",
":",
"options",
"[",
"'yes'",
"]",
",",
"'no'",
":",
"options",
"[",
"'no'",
"]",
",",
"'error'",
":",
"options",
"[",
"'no'",
"]",
"}",
")",
";",
"this",
".",
"hasValidOAuth",
"(",
"options",
")",
";",
"}",
"else",
"{",
"return",
"username",
"==",
"this",
".",
"getLoggedInUser",
"(",
"options",
")",
";",
"}",
"}"
] | Without specifying the 'options' argument, this is a "dumb" method in that simply checks if the given `username` is that of the logged in user without asking the server.
Optionally accepts asynchronous callback methods in the options object. When provided, this method will renew the refresh token if required. | [
"Without",
"specifying",
"the",
"options",
"argument",
"this",
"is",
"a",
"dumb",
"method",
"in",
"that",
"simply",
"checks",
"if",
"the",
"given",
"username",
"is",
"that",
"of",
"the",
"logged",
"in",
"user",
"without",
"asking",
"the",
"server",
"."
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L196-L210 |
|
53,045 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function() {
if( StackMob['useRelativePathForAjax'] ){
// Build "relative path" (also used for OAuth signing)
return StackMob.apiDomain ? StackMob.apiDomain : (this.getHostname() + (this.getPort() ? ':' + this.getPort() : '')) + '/';
} else {
// Use absolute path and operate through CORS
return StackMob.apiDomain ? StackMob.apiDomain : (StackMob['API_SERVER'] + '/');
}
} | javascript | function() {
if( StackMob['useRelativePathForAjax'] ){
// Build "relative path" (also used for OAuth signing)
return StackMob.apiDomain ? StackMob.apiDomain : (this.getHostname() + (this.getPort() ? ':' + this.getPort() : '')) + '/';
} else {
// Use absolute path and operate through CORS
return StackMob.apiDomain ? StackMob.apiDomain : (StackMob['API_SERVER'] + '/');
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"StackMob",
"[",
"'useRelativePathForAjax'",
"]",
")",
"{",
"// Build \"relative path\" (also used for OAuth signing)",
"return",
"StackMob",
".",
"apiDomain",
"?",
"StackMob",
".",
"apiDomain",
":",
"(",
"this",
".",
"getHostname",
"(",
")",
"+",
"(",
"this",
".",
"getPort",
"(",
")",
"?",
"':'",
"+",
"this",
".",
"getPort",
"(",
")",
":",
"''",
")",
")",
"+",
"'/'",
";",
"}",
"else",
"{",
"// Use absolute path and operate through CORS",
"return",
"StackMob",
".",
"apiDomain",
"?",
"StackMob",
".",
"apiDomain",
":",
"(",
"StackMob",
"[",
"'API_SERVER'",
"]",
"+",
"'/'",
")",
";",
"}",
"}"
] | This is an internally used method to get the API URL no matter what the context - development, production, etc. This envelopes `getDevAPIBase` and `getProdAPIBase` in that this method is smart enough to choose which of the URLs to use. | [
"This",
"is",
"an",
"internally",
"used",
"method",
"to",
"get",
"the",
"API",
"URL",
"no",
"matter",
"what",
"the",
"context",
"-",
"development",
"production",
"etc",
".",
"This",
"envelopes",
"getDevAPIBase",
"and",
"getProdAPIBase",
"in",
"that",
"this",
"method",
"is",
"smart",
"enough",
"to",
"choose",
"which",
"of",
"the",
"URLs",
"to",
"use",
"."
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L234-L242 |
|
53,046 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function(options) {
options = options || {};
//If we aren't running in OAuth 2.0 mode, then kick out early.
if(!this.isOAuth2Mode()){
if (options && options['error'])
options['error']();
return false;
}
//Check to see if we have all the necessary OAuth 2.0 credentials locally AND if the credentials have expired.
var creds = this.getOAuthCredentials();
var expires = (creds && creds['oauth2.expires']) || 0;
//If no accesstoken, mackey, or expires..
if ( !_.all([creds['oauth2.accessToken'], creds['oauth2.macKey'], expires], _.identity) ){
if (options && options['success']) options['success'](undefined);
return false;
}
if ( !StackMob.hasExpiredOAuth() ) {
//If not expired
if (options && options['success'] ){
options['success']( this.Storage.retrieve('oauth2.user') );
}
return this.Storage.retrieve('oauth2.user');
} else if ( options && options['success']) {
//If expired and async
var originalSuccess = options['success'];
options['success'] = function(input){
var creds = StackMob.getOAuthCredentials();
var loginField = (creds['oauth2.userSchemaInfo'] && creds['oauth2.userSchemaInfo']['loginField']) ?
creds['oauth2.userSchemaInfo']['loginField'] : this['loginField'];
originalSuccess( input[loginField]);
};
this.initiateRefreshSessionCall(options);
} else {
//If expired and sync
return false;
}
} | javascript | function(options) {
options = options || {};
//If we aren't running in OAuth 2.0 mode, then kick out early.
if(!this.isOAuth2Mode()){
if (options && options['error'])
options['error']();
return false;
}
//Check to see if we have all the necessary OAuth 2.0 credentials locally AND if the credentials have expired.
var creds = this.getOAuthCredentials();
var expires = (creds && creds['oauth2.expires']) || 0;
//If no accesstoken, mackey, or expires..
if ( !_.all([creds['oauth2.accessToken'], creds['oauth2.macKey'], expires], _.identity) ){
if (options && options['success']) options['success'](undefined);
return false;
}
if ( !StackMob.hasExpiredOAuth() ) {
//If not expired
if (options && options['success'] ){
options['success']( this.Storage.retrieve('oauth2.user') );
}
return this.Storage.retrieve('oauth2.user');
} else if ( options && options['success']) {
//If expired and async
var originalSuccess = options['success'];
options['success'] = function(input){
var creds = StackMob.getOAuthCredentials();
var loginField = (creds['oauth2.userSchemaInfo'] && creds['oauth2.userSchemaInfo']['loginField']) ?
creds['oauth2.userSchemaInfo']['loginField'] : this['loginField'];
originalSuccess( input[loginField]);
};
this.initiateRefreshSessionCall(options);
} else {
//If expired and sync
return false;
}
} | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"//If we aren't running in OAuth 2.0 mode, then kick out early.",
"if",
"(",
"!",
"this",
".",
"isOAuth2Mode",
"(",
")",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
"[",
"'error'",
"]",
")",
"options",
"[",
"'error'",
"]",
"(",
")",
";",
"return",
"false",
";",
"}",
"//Check to see if we have all the necessary OAuth 2.0 credentials locally AND if the credentials have expired.",
"var",
"creds",
"=",
"this",
".",
"getOAuthCredentials",
"(",
")",
";",
"var",
"expires",
"=",
"(",
"creds",
"&&",
"creds",
"[",
"'oauth2.expires'",
"]",
")",
"||",
"0",
";",
"//If no accesstoken, mackey, or expires..",
"if",
"(",
"!",
"_",
".",
"all",
"(",
"[",
"creds",
"[",
"'oauth2.accessToken'",
"]",
",",
"creds",
"[",
"'oauth2.macKey'",
"]",
",",
"expires",
"]",
",",
"_",
".",
"identity",
")",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
"[",
"'success'",
"]",
")",
"options",
"[",
"'success'",
"]",
"(",
"undefined",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"StackMob",
".",
"hasExpiredOAuth",
"(",
")",
")",
"{",
"//If not expired",
"if",
"(",
"options",
"&&",
"options",
"[",
"'success'",
"]",
")",
"{",
"options",
"[",
"'success'",
"]",
"(",
"this",
".",
"Storage",
".",
"retrieve",
"(",
"'oauth2.user'",
")",
")",
";",
"}",
"return",
"this",
".",
"Storage",
".",
"retrieve",
"(",
"'oauth2.user'",
")",
";",
"}",
"else",
"if",
"(",
"options",
"&&",
"options",
"[",
"'success'",
"]",
")",
"{",
"//If expired and async",
"var",
"originalSuccess",
"=",
"options",
"[",
"'success'",
"]",
";",
"options",
"[",
"'success'",
"]",
"=",
"function",
"(",
"input",
")",
"{",
"var",
"creds",
"=",
"StackMob",
".",
"getOAuthCredentials",
"(",
")",
";",
"var",
"loginField",
"=",
"(",
"creds",
"[",
"'oauth2.userSchemaInfo'",
"]",
"&&",
"creds",
"[",
"'oauth2.userSchemaInfo'",
"]",
"[",
"'loginField'",
"]",
")",
"?",
"creds",
"[",
"'oauth2.userSchemaInfo'",
"]",
"[",
"'loginField'",
"]",
":",
"this",
"[",
"'loginField'",
"]",
";",
"originalSuccess",
"(",
"input",
"[",
"loginField",
"]",
")",
";",
"}",
";",
"this",
".",
"initiateRefreshSessionCall",
"(",
"options",
")",
";",
"}",
"else",
"{",
"//If expired and sync",
"return",
"false",
";",
"}",
"}"
] | StackMob validates OAuth 2.0 credentials upon each request and will send back a error message if the credentials have expired. To save the trip, developers can check to see if their user has valid OAuth 2.0 credentials that indicate the user is logged in. | [
"StackMob",
"validates",
"OAuth",
"2",
".",
"0",
"credentials",
"upon",
"each",
"request",
"and",
"will",
"send",
"back",
"a",
"error",
"message",
"if",
"the",
"credentials",
"have",
"expired",
".",
"To",
"save",
"the",
"trip",
"developers",
"can",
"check",
"to",
"see",
"if",
"their",
"user",
"has",
"valid",
"OAuth",
"2",
".",
"0",
"credentials",
"that",
"indicate",
"the",
"user",
"is",
"logged",
"in",
"."
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L298-L340 |
|
53,047 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function() {
var oauth_accessToken = StackMob.Storage.retrieve('oauth2.accessToken');
var oauth_macKey = StackMob.Storage.retrieve('oauth2.macKey');
var oauth_expires = StackMob.Storage.retrieve('oauth2.expires');
var oauth_refreshToken = StackMob.Storage.retrieve(StackMob.REFRESH_TOKEN_KEY);
var userSchemaInfo = StackMob.Storage.retrieve('oauth2.userSchemaInfo');
var oauth_schema = null;
try {
oauth_schema = JSON.parse(userSchemaInfo);
} catch (e) { /* Harmless if this fails (in theory!)*/ }
if (_.every([oauth_accessToken, oauth_macKey, oauth_expires, oauth_refreshToken, oauth_schema])) {
var creds = {
'oauth2.accessToken' : oauth_accessToken,
'oauth2.macKey' : oauth_macKey,
'oauth2.expires' : oauth_expires,
'oauth2.userSchemaInfo' : oauth_schema
};
creds[StackMob.REFRESH_TOKEN_KEY] = oauth_refreshToken;
return creds;
} else {
return {};
}
} | javascript | function() {
var oauth_accessToken = StackMob.Storage.retrieve('oauth2.accessToken');
var oauth_macKey = StackMob.Storage.retrieve('oauth2.macKey');
var oauth_expires = StackMob.Storage.retrieve('oauth2.expires');
var oauth_refreshToken = StackMob.Storage.retrieve(StackMob.REFRESH_TOKEN_KEY);
var userSchemaInfo = StackMob.Storage.retrieve('oauth2.userSchemaInfo');
var oauth_schema = null;
try {
oauth_schema = JSON.parse(userSchemaInfo);
} catch (e) { /* Harmless if this fails (in theory!)*/ }
if (_.every([oauth_accessToken, oauth_macKey, oauth_expires, oauth_refreshToken, oauth_schema])) {
var creds = {
'oauth2.accessToken' : oauth_accessToken,
'oauth2.macKey' : oauth_macKey,
'oauth2.expires' : oauth_expires,
'oauth2.userSchemaInfo' : oauth_schema
};
creds[StackMob.REFRESH_TOKEN_KEY] = oauth_refreshToken;
return creds;
} else {
return {};
}
} | [
"function",
"(",
")",
"{",
"var",
"oauth_accessToken",
"=",
"StackMob",
".",
"Storage",
".",
"retrieve",
"(",
"'oauth2.accessToken'",
")",
";",
"var",
"oauth_macKey",
"=",
"StackMob",
".",
"Storage",
".",
"retrieve",
"(",
"'oauth2.macKey'",
")",
";",
"var",
"oauth_expires",
"=",
"StackMob",
".",
"Storage",
".",
"retrieve",
"(",
"'oauth2.expires'",
")",
";",
"var",
"oauth_refreshToken",
"=",
"StackMob",
".",
"Storage",
".",
"retrieve",
"(",
"StackMob",
".",
"REFRESH_TOKEN_KEY",
")",
";",
"var",
"userSchemaInfo",
"=",
"StackMob",
".",
"Storage",
".",
"retrieve",
"(",
"'oauth2.userSchemaInfo'",
")",
";",
"var",
"oauth_schema",
"=",
"null",
";",
"try",
"{",
"oauth_schema",
"=",
"JSON",
".",
"parse",
"(",
"userSchemaInfo",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"/* Harmless if this fails (in theory!)*/",
"}",
"if",
"(",
"_",
".",
"every",
"(",
"[",
"oauth_accessToken",
",",
"oauth_macKey",
",",
"oauth_expires",
",",
"oauth_refreshToken",
",",
"oauth_schema",
"]",
")",
")",
"{",
"var",
"creds",
"=",
"{",
"'oauth2.accessToken'",
":",
"oauth_accessToken",
",",
"'oauth2.macKey'",
":",
"oauth_macKey",
",",
"'oauth2.expires'",
":",
"oauth_expires",
",",
"'oauth2.userSchemaInfo'",
":",
"oauth_schema",
"}",
";",
"creds",
"[",
"StackMob",
".",
"REFRESH_TOKEN_KEY",
"]",
"=",
"oauth_refreshToken",
";",
"return",
"creds",
";",
"}",
"else",
"{",
"return",
"{",
"}",
";",
"}",
"}"
] | Retrieve the OAuth 2.0 credentials from client storage. | [
"Retrieve",
"the",
"OAuth",
"2",
".",
"0",
"credentials",
"from",
"client",
"storage",
"."
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L376-L402 |
|
53,048 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function(options) {
options = options || {};
// Run stuff before StackMob is initialized.
this.initStart(options);
/* DEPRECATED METHODS BELOW */
this.userSchema = options['userSchema']; // DEPRECATED: Use StackMob.User.extend({ schemaName: 'customschemaname' });
this.loginField = options['loginField']; // DEPRECATED: Use StackMob.User.extend({ loginField: 'customloginfield' });
this.passwordField = options['passwordField']; // DEPRECATED: Use StackMob.User.extend({ passwordField: 'custompasswordfield' });
/* DEPRECATED METHODS ABOVE */
this.newPasswordField = 'new_password';
this.publicKey = options['publicKey'];
this.apiVersion = options['apiVersion'] || this.DEFAULT_API_VERSION;
/*
* apiURL (DEPRECATED) - Advaanced Users Only. Use apiDomain instead.
* Used to redirect SDK requests to a different URL.
*
*/
if (typeof options['apiURL'] !== "undefined")
throw new Error("Error: apiURL is no longer supported. The API URL is now automatically set for PhoneGap users.");
/*
* apiDomain - Advanced Users Only. Only set apiDomain to redirect SDK
* requests to a different domain.
*
* Init variable 'apiDomain' should not contain a URL scheme (http:// or https://).
* Scheme will be prepended according to 'secure' init setting.
*/
var apiDomain = options['apiDomain'];
if (typeof apiDomain === "string"){
if (apiDomain.indexOf('http') === 0){
throw new Error("Error: apiDomain should not specify url scheme (http/https). For example, specify api.stackmob.com instead of http://api.stackmob.com. URL Scheme is determined by the 'secure' init variable.");
} else {
if (apiDomain.indexOf('/') == apiDomain.length - 1){
this.apiDomain = apiDomain;
} else {
this.apiDomain = apiDomain + '/';
}
}
}
/*
* useRelativePathForAjax - Advanced Users Only. Use to redirect SDK requests to a
* path relative to the current URL. Will only work for StackMob Hosts that can
* properly proxy requests to api.stackmob.com
*
* HTML5 apps hosted on stackmobapp.com will be set to `true` and use a relative path
* automatically.
*/
var isSMHosted = (this.getHostname().indexOf('.stackmobapp.com') > 0);
this.useRelativePathForAjax = (typeof options['useRelativePathForAjax'] === "boolean") ? options['useRelativePathForAjax'] : isSMHosted;
/*
* secure - Determine which requests should be done over SSL.
* Default the security mode to match the current URL scheme.
*
* If current page is HTTPS, set to SECURE_ALWAYS.
* If current page is HTTP, set to SECURE_NEVER.
* Otherwise, set to SECURE_MIXED.
* Can be overridden by manually specifying a security mode in init().
*/
if (options['secure']) {
this.secure = options['secure'];
} else if (this.getProtocol().indexOf("https:") == 0) {
this.secure = this.SECURE_ALWAYS;
} else if (this.getProtocol().indexOf("http:") == 0) {
this.secure = this.SECURE_NEVER;
} else {
this.secure = this.SECURE_MIXED;
}
this.ajax = options['ajax'] || this.ajax;
this.initEnd(options);
return this;
} | javascript | function(options) {
options = options || {};
// Run stuff before StackMob is initialized.
this.initStart(options);
/* DEPRECATED METHODS BELOW */
this.userSchema = options['userSchema']; // DEPRECATED: Use StackMob.User.extend({ schemaName: 'customschemaname' });
this.loginField = options['loginField']; // DEPRECATED: Use StackMob.User.extend({ loginField: 'customloginfield' });
this.passwordField = options['passwordField']; // DEPRECATED: Use StackMob.User.extend({ passwordField: 'custompasswordfield' });
/* DEPRECATED METHODS ABOVE */
this.newPasswordField = 'new_password';
this.publicKey = options['publicKey'];
this.apiVersion = options['apiVersion'] || this.DEFAULT_API_VERSION;
/*
* apiURL (DEPRECATED) - Advaanced Users Only. Use apiDomain instead.
* Used to redirect SDK requests to a different URL.
*
*/
if (typeof options['apiURL'] !== "undefined")
throw new Error("Error: apiURL is no longer supported. The API URL is now automatically set for PhoneGap users.");
/*
* apiDomain - Advanced Users Only. Only set apiDomain to redirect SDK
* requests to a different domain.
*
* Init variable 'apiDomain' should not contain a URL scheme (http:// or https://).
* Scheme will be prepended according to 'secure' init setting.
*/
var apiDomain = options['apiDomain'];
if (typeof apiDomain === "string"){
if (apiDomain.indexOf('http') === 0){
throw new Error("Error: apiDomain should not specify url scheme (http/https). For example, specify api.stackmob.com instead of http://api.stackmob.com. URL Scheme is determined by the 'secure' init variable.");
} else {
if (apiDomain.indexOf('/') == apiDomain.length - 1){
this.apiDomain = apiDomain;
} else {
this.apiDomain = apiDomain + '/';
}
}
}
/*
* useRelativePathForAjax - Advanced Users Only. Use to redirect SDK requests to a
* path relative to the current URL. Will only work for StackMob Hosts that can
* properly proxy requests to api.stackmob.com
*
* HTML5 apps hosted on stackmobapp.com will be set to `true` and use a relative path
* automatically.
*/
var isSMHosted = (this.getHostname().indexOf('.stackmobapp.com') > 0);
this.useRelativePathForAjax = (typeof options['useRelativePathForAjax'] === "boolean") ? options['useRelativePathForAjax'] : isSMHosted;
/*
* secure - Determine which requests should be done over SSL.
* Default the security mode to match the current URL scheme.
*
* If current page is HTTPS, set to SECURE_ALWAYS.
* If current page is HTTP, set to SECURE_NEVER.
* Otherwise, set to SECURE_MIXED.
* Can be overridden by manually specifying a security mode in init().
*/
if (options['secure']) {
this.secure = options['secure'];
} else if (this.getProtocol().indexOf("https:") == 0) {
this.secure = this.SECURE_ALWAYS;
} else if (this.getProtocol().indexOf("http:") == 0) {
this.secure = this.SECURE_NEVER;
} else {
this.secure = this.SECURE_MIXED;
}
this.ajax = options['ajax'] || this.ajax;
this.initEnd(options);
return this;
} | [
"function",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"// Run stuff before StackMob is initialized.",
"this",
".",
"initStart",
"(",
"options",
")",
";",
"/* DEPRECATED METHODS BELOW */",
"this",
".",
"userSchema",
"=",
"options",
"[",
"'userSchema'",
"]",
";",
"// DEPRECATED: Use StackMob.User.extend({ schemaName: 'customschemaname' });",
"this",
".",
"loginField",
"=",
"options",
"[",
"'loginField'",
"]",
";",
"// DEPRECATED: Use StackMob.User.extend({ loginField: 'customloginfield' });",
"this",
".",
"passwordField",
"=",
"options",
"[",
"'passwordField'",
"]",
";",
"// DEPRECATED: Use StackMob.User.extend({ passwordField: 'custompasswordfield' });",
"/* DEPRECATED METHODS ABOVE */",
"this",
".",
"newPasswordField",
"=",
"'new_password'",
";",
"this",
".",
"publicKey",
"=",
"options",
"[",
"'publicKey'",
"]",
";",
"this",
".",
"apiVersion",
"=",
"options",
"[",
"'apiVersion'",
"]",
"||",
"this",
".",
"DEFAULT_API_VERSION",
";",
"/*\n * apiURL (DEPRECATED) - Advaanced Users Only. Use apiDomain instead.\n * Used to redirect SDK requests to a different URL.\n *\n */",
"if",
"(",
"typeof",
"options",
"[",
"'apiURL'",
"]",
"!==",
"\"undefined\"",
")",
"throw",
"new",
"Error",
"(",
"\"Error: apiURL is no longer supported. The API URL is now automatically set for PhoneGap users.\"",
")",
";",
"/*\n * apiDomain - Advanced Users Only. Only set apiDomain to redirect SDK\n * requests to a different domain.\n *\n * Init variable 'apiDomain' should not contain a URL scheme (http:// or https://).\n * Scheme will be prepended according to 'secure' init setting.\n */",
"var",
"apiDomain",
"=",
"options",
"[",
"'apiDomain'",
"]",
";",
"if",
"(",
"typeof",
"apiDomain",
"===",
"\"string\"",
")",
"{",
"if",
"(",
"apiDomain",
".",
"indexOf",
"(",
"'http'",
")",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Error: apiDomain should not specify url scheme (http/https). For example, specify api.stackmob.com instead of http://api.stackmob.com. URL Scheme is determined by the 'secure' init variable.\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"apiDomain",
".",
"indexOf",
"(",
"'/'",
")",
"==",
"apiDomain",
".",
"length",
"-",
"1",
")",
"{",
"this",
".",
"apiDomain",
"=",
"apiDomain",
";",
"}",
"else",
"{",
"this",
".",
"apiDomain",
"=",
"apiDomain",
"+",
"'/'",
";",
"}",
"}",
"}",
"/*\n * useRelativePathForAjax - Advanced Users Only. Use to redirect SDK requests to a\n * path relative to the current URL. Will only work for StackMob Hosts that can\n * properly proxy requests to api.stackmob.com\n *\n * HTML5 apps hosted on stackmobapp.com will be set to `true` and use a relative path\n * automatically.\n */",
"var",
"isSMHosted",
"=",
"(",
"this",
".",
"getHostname",
"(",
")",
".",
"indexOf",
"(",
"'.stackmobapp.com'",
")",
">",
"0",
")",
";",
"this",
".",
"useRelativePathForAjax",
"=",
"(",
"typeof",
"options",
"[",
"'useRelativePathForAjax'",
"]",
"===",
"\"boolean\"",
")",
"?",
"options",
"[",
"'useRelativePathForAjax'",
"]",
":",
"isSMHosted",
";",
"/*\n * secure - Determine which requests should be done over SSL.\n * Default the security mode to match the current URL scheme.\n *\n * If current page is HTTPS, set to SECURE_ALWAYS.\n * If current page is HTTP, set to SECURE_NEVER.\n * Otherwise, set to SECURE_MIXED.\n * Can be overridden by manually specifying a security mode in init().\n */",
"if",
"(",
"options",
"[",
"'secure'",
"]",
")",
"{",
"this",
".",
"secure",
"=",
"options",
"[",
"'secure'",
"]",
";",
"}",
"else",
"if",
"(",
"this",
".",
"getProtocol",
"(",
")",
".",
"indexOf",
"(",
"\"https:\"",
")",
"==",
"0",
")",
"{",
"this",
".",
"secure",
"=",
"this",
".",
"SECURE_ALWAYS",
";",
"}",
"else",
"if",
"(",
"this",
".",
"getProtocol",
"(",
")",
".",
"indexOf",
"(",
"\"http:\"",
")",
"==",
"0",
")",
"{",
"this",
".",
"secure",
"=",
"this",
".",
"SECURE_NEVER",
";",
"}",
"else",
"{",
"this",
".",
"secure",
"=",
"this",
".",
"SECURE_MIXED",
";",
"}",
"this",
".",
"ajax",
"=",
"options",
"[",
"'ajax'",
"]",
"||",
"this",
".",
"ajax",
";",
"this",
".",
"initEnd",
"(",
"options",
")",
";",
"return",
"this",
";",
"}"
] | Externally called by user to initialize their StackMob config. | [
"Externally",
"called",
"by",
"user",
"to",
"initialize",
"their",
"StackMob",
"config",
"."
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L455-L537 |
|
53,049 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function(facebookAccessToken, options) {
options = options || {};
options['data'] = options['data'] || {};
_.extend(options['data'], {
"fb_at" : facebookAccessToken,
"token_type" : "mac"
});
(this.sync || Backbone.sync).call(this, "linkUserWithFacebook", this, options);
} | javascript | function(facebookAccessToken, options) {
options = options || {};
options['data'] = options['data'] || {};
_.extend(options['data'], {
"fb_at" : facebookAccessToken,
"token_type" : "mac"
});
(this.sync || Backbone.sync).call(this, "linkUserWithFacebook", this, options);
} | [
"function",
"(",
"facebookAccessToken",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"options",
"[",
"'data'",
"]",
"=",
"options",
"[",
"'data'",
"]",
"||",
"{",
"}",
";",
"_",
".",
"extend",
"(",
"options",
"[",
"'data'",
"]",
",",
"{",
"\"fb_at\"",
":",
"facebookAccessToken",
",",
"\"token_type\"",
":",
"\"mac\"",
"}",
")",
";",
"(",
"this",
".",
"sync",
"||",
"Backbone",
".",
"sync",
")",
".",
"call",
"(",
"this",
",",
"\"linkUserWithFacebook\"",
",",
"this",
",",
"options",
")",
";",
"}"
] | Use after a user has logged in with a regular user account and you want to add Facebook to their account | [
"Use",
"after",
"a",
"user",
"has",
"logged",
"in",
"with",
"a",
"regular",
"user",
"account",
"and",
"you",
"want",
"to",
"add",
"Facebook",
"to",
"their",
"account"
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L1516-L1525 |
|
53,050 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function(b){
/*
* Naming convention: A.or(B)
*/
if (typeof this.orId == "undefined"){
/*
* If A is a normal AND query:
* Clone A into newQuery
* Clear newQuery's params
* Assign OR Group# (1)
* Prefix A params with and[#+1]
* Prefix B params with and[#+1]
* Prefix all params with or[#]
* Set all of the above as newQuery.params
* Return newQuery
*/
var a = this;
var newQuery = this.clone();
newQuery['params'] = {}; // Reset params that will be populated below
newQuery['orId'] = 1; // Only allowed one OR, otherwise orCount++;
newQuery['andCount'] = 1; // And counts are per or-clause
var andCounter, keys, parsedAndString;
// Determine [and#] prefix for A
keys = _.keys(a.params);
parsedAndString = "";
if (keys.length > 1) {
andCounter = newQuery['andCount']++;
parsedAndString = andString(andCounter);
}
// Copy A's params to newQuery
for (var key in a['params']){
var newKey = orString(newQuery['orId']) + parsedAndString + key;
newQuery['params'][newKey] = a['params'][key];
}
// Determine [and#] prefix for B
keys = _.keys(b.params);
parsedAndString = "";
if (keys.length > 1) {
andCounter = newQuery['andCount']++;
parsedAndString = andString(andCounter);
}
// Copy B's params to newQuery
for (key in b['params']){
var newKey = orString(newQuery['orId']) + parsedAndString + key;
if (typeof newQuery['params'][newKey] !== "undefined") {
throw new Error("Error: You are attempting to OR two or more values for the same field. You should use an mustBeOneOf method instead.");
} else {
newQuery['params'][newKey] = b['params'][key];
}
}
return newQuery;
} else {
/*
* If A is already an OR query:
* Clone A into newQuery
* Prefix B with and[#+1]
* Prefix B with or[A.orId]
* Add B's params to newQuery
* Return newQuery
*/
var a = this;
var newQuery = this.clone();
// Determine [and#] prefix for B
keys = _.keys(b.params);
parsedAndString = "";
if (keys.length > 1) {
andCounter = newQuery['andCount']++;
parsedAndString = andString(andCounter)
}
// Copy B's params to newQuery
for (key in b['params']){
var newKey = orString(newQuery['orId']) + parsedAndString + key;
if (typeof newQuery['params'][newKey] !== "undefined") {
throw new Error("Error: You are attempting to OR two or more values for the same field. You should use an mustBeOneOf method instead.");
} else {
newQuery['params'][newKey] = b['params'][key];
}
}
return newQuery;
}
} | javascript | function(b){
/*
* Naming convention: A.or(B)
*/
if (typeof this.orId == "undefined"){
/*
* If A is a normal AND query:
* Clone A into newQuery
* Clear newQuery's params
* Assign OR Group# (1)
* Prefix A params with and[#+1]
* Prefix B params with and[#+1]
* Prefix all params with or[#]
* Set all of the above as newQuery.params
* Return newQuery
*/
var a = this;
var newQuery = this.clone();
newQuery['params'] = {}; // Reset params that will be populated below
newQuery['orId'] = 1; // Only allowed one OR, otherwise orCount++;
newQuery['andCount'] = 1; // And counts are per or-clause
var andCounter, keys, parsedAndString;
// Determine [and#] prefix for A
keys = _.keys(a.params);
parsedAndString = "";
if (keys.length > 1) {
andCounter = newQuery['andCount']++;
parsedAndString = andString(andCounter);
}
// Copy A's params to newQuery
for (var key in a['params']){
var newKey = orString(newQuery['orId']) + parsedAndString + key;
newQuery['params'][newKey] = a['params'][key];
}
// Determine [and#] prefix for B
keys = _.keys(b.params);
parsedAndString = "";
if (keys.length > 1) {
andCounter = newQuery['andCount']++;
parsedAndString = andString(andCounter);
}
// Copy B's params to newQuery
for (key in b['params']){
var newKey = orString(newQuery['orId']) + parsedAndString + key;
if (typeof newQuery['params'][newKey] !== "undefined") {
throw new Error("Error: You are attempting to OR two or more values for the same field. You should use an mustBeOneOf method instead.");
} else {
newQuery['params'][newKey] = b['params'][key];
}
}
return newQuery;
} else {
/*
* If A is already an OR query:
* Clone A into newQuery
* Prefix B with and[#+1]
* Prefix B with or[A.orId]
* Add B's params to newQuery
* Return newQuery
*/
var a = this;
var newQuery = this.clone();
// Determine [and#] prefix for B
keys = _.keys(b.params);
parsedAndString = "";
if (keys.length > 1) {
andCounter = newQuery['andCount']++;
parsedAndString = andString(andCounter)
}
// Copy B's params to newQuery
for (key in b['params']){
var newKey = orString(newQuery['orId']) + parsedAndString + key;
if (typeof newQuery['params'][newKey] !== "undefined") {
throw new Error("Error: You are attempting to OR two or more values for the same field. You should use an mustBeOneOf method instead.");
} else {
newQuery['params'][newKey] = b['params'][key];
}
}
return newQuery;
}
} | [
"function",
"(",
"b",
")",
"{",
"/*\n * Naming convention: A.or(B)\n */",
"if",
"(",
"typeof",
"this",
".",
"orId",
"==",
"\"undefined\"",
")",
"{",
"/*\n * If A is a normal AND query:\n * Clone A into newQuery\n * Clear newQuery's params\n * Assign OR Group# (1)\n * Prefix A params with and[#+1]\n * Prefix B params with and[#+1]\n * Prefix all params with or[#]\n * Set all of the above as newQuery.params\n * Return newQuery\n */",
"var",
"a",
"=",
"this",
";",
"var",
"newQuery",
"=",
"this",
".",
"clone",
"(",
")",
";",
"newQuery",
"[",
"'params'",
"]",
"=",
"{",
"}",
";",
"// Reset params that will be populated below",
"newQuery",
"[",
"'orId'",
"]",
"=",
"1",
";",
"// Only allowed one OR, otherwise orCount++;",
"newQuery",
"[",
"'andCount'",
"]",
"=",
"1",
";",
"// And counts are per or-clause",
"var",
"andCounter",
",",
"keys",
",",
"parsedAndString",
";",
"// Determine [and#] prefix for A",
"keys",
"=",
"_",
".",
"keys",
"(",
"a",
".",
"params",
")",
";",
"parsedAndString",
"=",
"\"\"",
";",
"if",
"(",
"keys",
".",
"length",
">",
"1",
")",
"{",
"andCounter",
"=",
"newQuery",
"[",
"'andCount'",
"]",
"++",
";",
"parsedAndString",
"=",
"andString",
"(",
"andCounter",
")",
";",
"}",
"// Copy A's params to newQuery",
"for",
"(",
"var",
"key",
"in",
"a",
"[",
"'params'",
"]",
")",
"{",
"var",
"newKey",
"=",
"orString",
"(",
"newQuery",
"[",
"'orId'",
"]",
")",
"+",
"parsedAndString",
"+",
"key",
";",
"newQuery",
"[",
"'params'",
"]",
"[",
"newKey",
"]",
"=",
"a",
"[",
"'params'",
"]",
"[",
"key",
"]",
";",
"}",
"// Determine [and#] prefix for B",
"keys",
"=",
"_",
".",
"keys",
"(",
"b",
".",
"params",
")",
";",
"parsedAndString",
"=",
"\"\"",
";",
"if",
"(",
"keys",
".",
"length",
">",
"1",
")",
"{",
"andCounter",
"=",
"newQuery",
"[",
"'andCount'",
"]",
"++",
";",
"parsedAndString",
"=",
"andString",
"(",
"andCounter",
")",
";",
"}",
"// Copy B's params to newQuery",
"for",
"(",
"key",
"in",
"b",
"[",
"'params'",
"]",
")",
"{",
"var",
"newKey",
"=",
"orString",
"(",
"newQuery",
"[",
"'orId'",
"]",
")",
"+",
"parsedAndString",
"+",
"key",
";",
"if",
"(",
"typeof",
"newQuery",
"[",
"'params'",
"]",
"[",
"newKey",
"]",
"!==",
"\"undefined\"",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Error: You are attempting to OR two or more values for the same field. You should use an mustBeOneOf method instead.\"",
")",
";",
"}",
"else",
"{",
"newQuery",
"[",
"'params'",
"]",
"[",
"newKey",
"]",
"=",
"b",
"[",
"'params'",
"]",
"[",
"key",
"]",
";",
"}",
"}",
"return",
"newQuery",
";",
"}",
"else",
"{",
"/*\n * If A is already an OR query:\n * Clone A into newQuery\n * Prefix B with and[#+1]\n * Prefix B with or[A.orId]\n * Add B's params to newQuery\n * Return newQuery\n */",
"var",
"a",
"=",
"this",
";",
"var",
"newQuery",
"=",
"this",
".",
"clone",
"(",
")",
";",
"// Determine [and#] prefix for B",
"keys",
"=",
"_",
".",
"keys",
"(",
"b",
".",
"params",
")",
";",
"parsedAndString",
"=",
"\"\"",
";",
"if",
"(",
"keys",
".",
"length",
">",
"1",
")",
"{",
"andCounter",
"=",
"newQuery",
"[",
"'andCount'",
"]",
"++",
";",
"parsedAndString",
"=",
"andString",
"(",
"andCounter",
")",
"}",
"// Copy B's params to newQuery",
"for",
"(",
"key",
"in",
"b",
"[",
"'params'",
"]",
")",
"{",
"var",
"newKey",
"=",
"orString",
"(",
"newQuery",
"[",
"'orId'",
"]",
")",
"+",
"parsedAndString",
"+",
"key",
";",
"if",
"(",
"typeof",
"newQuery",
"[",
"'params'",
"]",
"[",
"newKey",
"]",
"!==",
"\"undefined\"",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"Error: You are attempting to OR two or more values for the same field. You should use an mustBeOneOf method instead.\"",
")",
";",
"}",
"else",
"{",
"newQuery",
"[",
"'params'",
"]",
"[",
"newKey",
"]",
"=",
"b",
"[",
"'params'",
"]",
"[",
"key",
"]",
";",
"}",
"}",
"return",
"newQuery",
";",
"}",
"}"
] | Combine a Query with an OR operator between it and
the current Query object.
Example:
var isAged = new StackMob.Collection.Query().equals("age", "25");
var isNYC = new StackMob.Collection.Query().equals("location", "NYC");
var notJohn = new StackMob.Collection.Query().notEquals("name", "john");
var notMary = new StackMob.Collection.Query().equals("location", "SF").notEquals("name", "mary");
var isLA = new StackMob.Collection.Query().equals("location", "LA");
isAged.and( notJohn.or(notMary).or(isLA) );
@param {StackMob.Collection.Query} b - A query object to OR with this object
@return {StackMob.Collection.Query} A new query equivalent to A OR B, where A is the object this method is called on and B is the parameter. | [
"Combine",
"a",
"Query",
"with",
"an",
"OR",
"operator",
"between",
"it",
"and",
"the",
"current",
"Query",
"object",
"."
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L1660-L1755 |
|
53,051 | ClinicalSoftwareSolutions/stackmob-client | stackmob-js-0.9.2.js | function(b){
/*
* Naming convention: A.or(B)
*
* Combine all params of a and b into one object
*/
var a = this;
var newQuery = this.clone();
for (var key in b['params']){
newQuery['params'][key] = b['params'][key];
}
return newQuery;
} | javascript | function(b){
/*
* Naming convention: A.or(B)
*
* Combine all params of a and b into one object
*/
var a = this;
var newQuery = this.clone();
for (var key in b['params']){
newQuery['params'][key] = b['params'][key];
}
return newQuery;
} | [
"function",
"(",
"b",
")",
"{",
"/*\n * Naming convention: A.or(B)\n *\n * Combine all params of a and b into one object\n */",
"var",
"a",
"=",
"this",
";",
"var",
"newQuery",
"=",
"this",
".",
"clone",
"(",
")",
";",
"for",
"(",
"var",
"key",
"in",
"b",
"[",
"'params'",
"]",
")",
"{",
"newQuery",
"[",
"'params'",
"]",
"[",
"key",
"]",
"=",
"b",
"[",
"'params'",
"]",
"[",
"key",
"]",
";",
"}",
"return",
"newQuery",
";",
"}"
] | Combine a Query with an AND operator between it and
the current Query object.
Example:
var isAged = new StackMob.Collection.Query().equals("age", "25");
var isNYC = new StackMob.Collection.Query().equals("location", "NYC");
var notJohn = new StackMob.Collection.Query().notEquals("name", "john");
var notMary = new StackMob.Collection.Query().equals("location", "SF").notEquals("name", "mary");
var isLA = new StackMob.Collection.Query().equals("location", "LA");
isAged.and( notJohn.or(notMary).or(isLA) );
@param {StackMob.Collection.Query} b - A query object to OR with this object
@return {StackMob.Collection.Query} A new query equivalent to A AND B, where A is the object this method is called on and B is the parameter. | [
"Combine",
"a",
"Query",
"with",
"an",
"AND",
"operator",
"between",
"it",
"and",
"the",
"current",
"Query",
"object",
"."
] | 9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a | https://github.com/ClinicalSoftwareSolutions/stackmob-client/blob/9ee3ddbdf4172b4ed826283bb7d855b6ee22f67a/stackmob-js-0.9.2.js#L1772-L1787 |
|
53,052 | Lindurion/closure-pro-build | lib/js-builder.js | build | function build(
projectOptions, buildOptions, outDirsAsync, cssRenamingFileAsync) {
var inputFilesAsync = resolveInputsAsync(projectOptions);
return outDirsAsync.then(function(outDirs) {
var transitiveClosureDepsAsync =
closureDepCalculator.calcDeps(projectOptions, buildOptions, outDirs);
return kew.all([inputFilesAsync, transitiveClosureDepsAsync])
.then(function(results) {
var inputFiles = results[0];
var transitiveClosureDeps = results[1];
var resolvedProjectOptions =
resolveProjectOptions(projectOptions, inputFiles);
var jsModules = jsModuleManager.calcInputFiles(
resolvedProjectOptions, transitiveClosureDeps);
return compileAndOutputJs(resolvedProjectOptions, buildOptions,
outDirs, cssRenamingFileAsync, jsModules);
});
});
} | javascript | function build(
projectOptions, buildOptions, outDirsAsync, cssRenamingFileAsync) {
var inputFilesAsync = resolveInputsAsync(projectOptions);
return outDirsAsync.then(function(outDirs) {
var transitiveClosureDepsAsync =
closureDepCalculator.calcDeps(projectOptions, buildOptions, outDirs);
return kew.all([inputFilesAsync, transitiveClosureDepsAsync])
.then(function(results) {
var inputFiles = results[0];
var transitiveClosureDeps = results[1];
var resolvedProjectOptions =
resolveProjectOptions(projectOptions, inputFiles);
var jsModules = jsModuleManager.calcInputFiles(
resolvedProjectOptions, transitiveClosureDeps);
return compileAndOutputJs(resolvedProjectOptions, buildOptions,
outDirs, cssRenamingFileAsync, jsModules);
});
});
} | [
"function",
"build",
"(",
"projectOptions",
",",
"buildOptions",
",",
"outDirsAsync",
",",
"cssRenamingFileAsync",
")",
"{",
"var",
"inputFilesAsync",
"=",
"resolveInputsAsync",
"(",
"projectOptions",
")",
";",
"return",
"outDirsAsync",
".",
"then",
"(",
"function",
"(",
"outDirs",
")",
"{",
"var",
"transitiveClosureDepsAsync",
"=",
"closureDepCalculator",
".",
"calcDeps",
"(",
"projectOptions",
",",
"buildOptions",
",",
"outDirs",
")",
";",
"return",
"kew",
".",
"all",
"(",
"[",
"inputFilesAsync",
",",
"transitiveClosureDepsAsync",
"]",
")",
".",
"then",
"(",
"function",
"(",
"results",
")",
"{",
"var",
"inputFiles",
"=",
"results",
"[",
"0",
"]",
";",
"var",
"transitiveClosureDeps",
"=",
"results",
"[",
"1",
"]",
";",
"var",
"resolvedProjectOptions",
"=",
"resolveProjectOptions",
"(",
"projectOptions",
",",
"inputFiles",
")",
";",
"var",
"jsModules",
"=",
"jsModuleManager",
".",
"calcInputFiles",
"(",
"resolvedProjectOptions",
",",
"transitiveClosureDeps",
")",
";",
"return",
"compileAndOutputJs",
"(",
"resolvedProjectOptions",
",",
"buildOptions",
",",
"outDirs",
",",
"cssRenamingFileAsync",
",",
"jsModules",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | Builds project JS as specified in the given options, using Closure JS
Compiler if required and assembling final output JS files.
@param {!Object} projectOptions Specifies the project input files; see
README.md for option documentation.
@param {!Object} buildOptions Specifies options specific to this build (like
debug/release); see README.md for option documentation.
@param {!Promise.<!OutputDirs>} outDirsAsync
@param {!Promise.<?string>} cssRenamingFileAsync
@return {!Promise} Tracks success/failure. | [
"Builds",
"project",
"JS",
"as",
"specified",
"in",
"the",
"given",
"options",
"using",
"Closure",
"JS",
"Compiler",
"if",
"required",
"and",
"assembling",
"final",
"output",
"JS",
"files",
"."
] | c279d0fcc3a65969d2fe965f55e627b074792f1a | https://github.com/Lindurion/closure-pro-build/blob/c279d0fcc3a65969d2fe965f55e627b074792f1a/lib/js-builder.js#L43-L63 |
53,053 | melnikov-s/anvoy | src/template.js | getNodesMetaData | function getNodesMetaData(rootEl) {
let elMeta = [];
let toVisit = [rootEl];
let current = {el: rootEl, path: [], isPre: $.tag(rootEl) === 'PRE'};
//generate paths for comment and text nodes. There's no way to quickly retrieve them
//need to deeply traverse the DOM tree
while (current) {
let {el, isPre, path} = current;
let childNodes = $.childNodes(el);
for (let i = 0; i < childNodes.length; i++) {
let childNode = childNodes[i];
if ($.isText(childNode)) {
let {meta, delta} = getTextMetaData(rootEl, i, childNode, path, !isPre);
elMeta.push(...meta);
i += delta;
} else if ($.isElement(childNode)) {
let name = $.getAttr(childNode, ATTR);
if (name && $.tag(childNode) === 'SCRIPT') {
let {meta, delta} = getContainerMetaData(rootEl, i, childNode, path, name);
elMeta.push(...meta);
i += delta;
} else {
toVisit.push({
el: childNode,
path: path.concat(i),
isPre: current.isPre || $.tag(childNode) === 'PRE'
});
}
}
}
toVisit.shift();
current = toVisit[0];
}
let elementMeta = getElementsMetaData(rootEl);
elMeta.push(...elementMeta);
//we need to sort the elements in order of their depth, so that they can be updated
//from bottom up when ultimately passed to a component.
return elMeta.sort((a, b) => b.depth - a.depth);
} | javascript | function getNodesMetaData(rootEl) {
let elMeta = [];
let toVisit = [rootEl];
let current = {el: rootEl, path: [], isPre: $.tag(rootEl) === 'PRE'};
//generate paths for comment and text nodes. There's no way to quickly retrieve them
//need to deeply traverse the DOM tree
while (current) {
let {el, isPre, path} = current;
let childNodes = $.childNodes(el);
for (let i = 0; i < childNodes.length; i++) {
let childNode = childNodes[i];
if ($.isText(childNode)) {
let {meta, delta} = getTextMetaData(rootEl, i, childNode, path, !isPre);
elMeta.push(...meta);
i += delta;
} else if ($.isElement(childNode)) {
let name = $.getAttr(childNode, ATTR);
if (name && $.tag(childNode) === 'SCRIPT') {
let {meta, delta} = getContainerMetaData(rootEl, i, childNode, path, name);
elMeta.push(...meta);
i += delta;
} else {
toVisit.push({
el: childNode,
path: path.concat(i),
isPre: current.isPre || $.tag(childNode) === 'PRE'
});
}
}
}
toVisit.shift();
current = toVisit[0];
}
let elementMeta = getElementsMetaData(rootEl);
elMeta.push(...elementMeta);
//we need to sort the elements in order of their depth, so that they can be updated
//from bottom up when ultimately passed to a component.
return elMeta.sort((a, b) => b.depth - a.depth);
} | [
"function",
"getNodesMetaData",
"(",
"rootEl",
")",
"{",
"let",
"elMeta",
"=",
"[",
"]",
";",
"let",
"toVisit",
"=",
"[",
"rootEl",
"]",
";",
"let",
"current",
"=",
"{",
"el",
":",
"rootEl",
",",
"path",
":",
"[",
"]",
",",
"isPre",
":",
"$",
".",
"tag",
"(",
"rootEl",
")",
"===",
"'PRE'",
"}",
";",
"//generate paths for comment and text nodes. There's no way to quickly retrieve them",
"//need to deeply traverse the DOM tree",
"while",
"(",
"current",
")",
"{",
"let",
"{",
"el",
",",
"isPre",
",",
"path",
"}",
"=",
"current",
";",
"let",
"childNodes",
"=",
"$",
".",
"childNodes",
"(",
"el",
")",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"childNodes",
".",
"length",
";",
"i",
"++",
")",
"{",
"let",
"childNode",
"=",
"childNodes",
"[",
"i",
"]",
";",
"if",
"(",
"$",
".",
"isText",
"(",
"childNode",
")",
")",
"{",
"let",
"{",
"meta",
",",
"delta",
"}",
"=",
"getTextMetaData",
"(",
"rootEl",
",",
"i",
",",
"childNode",
",",
"path",
",",
"!",
"isPre",
")",
";",
"elMeta",
".",
"push",
"(",
"...",
"meta",
")",
";",
"i",
"+=",
"delta",
";",
"}",
"else",
"if",
"(",
"$",
".",
"isElement",
"(",
"childNode",
")",
")",
"{",
"let",
"name",
"=",
"$",
".",
"getAttr",
"(",
"childNode",
",",
"ATTR",
")",
";",
"if",
"(",
"name",
"&&",
"$",
".",
"tag",
"(",
"childNode",
")",
"===",
"'SCRIPT'",
")",
"{",
"let",
"{",
"meta",
",",
"delta",
"}",
"=",
"getContainerMetaData",
"(",
"rootEl",
",",
"i",
",",
"childNode",
",",
"path",
",",
"name",
")",
";",
"elMeta",
".",
"push",
"(",
"...",
"meta",
")",
";",
"i",
"+=",
"delta",
";",
"}",
"else",
"{",
"toVisit",
".",
"push",
"(",
"{",
"el",
":",
"childNode",
",",
"path",
":",
"path",
".",
"concat",
"(",
"i",
")",
",",
"isPre",
":",
"current",
".",
"isPre",
"||",
"$",
".",
"tag",
"(",
"childNode",
")",
"===",
"'PRE'",
"}",
")",
";",
"}",
"}",
"}",
"toVisit",
".",
"shift",
"(",
")",
";",
"current",
"=",
"toVisit",
"[",
"0",
"]",
";",
"}",
"let",
"elementMeta",
"=",
"getElementsMetaData",
"(",
"rootEl",
")",
";",
"elMeta",
".",
"push",
"(",
"...",
"elementMeta",
")",
";",
"//we need to sort the elements in order of their depth, so that they can be updated",
"//from bottom up when ultimately passed to a component.",
"return",
"elMeta",
".",
"sort",
"(",
"(",
"a",
",",
"b",
")",
"=>",
"b",
".",
"depth",
"-",
"a",
".",
"depth",
")",
";",
"}"
] | gather meta data from a DOM element template. Only runs once per template and the resulting data can be applied to any cloned template. Primarly used to generate paths to non-static nodes within a cloned template. | [
"gather",
"meta",
"data",
"from",
"a",
"DOM",
"element",
"template",
".",
"Only",
"runs",
"once",
"per",
"template",
"and",
"the",
"resulting",
"data",
"can",
"be",
"applied",
"to",
"any",
"cloned",
"template",
".",
"Primarly",
"used",
"to",
"generate",
"paths",
"to",
"non",
"-",
"static",
"nodes",
"within",
"a",
"cloned",
"template",
"."
] | c0c5ff2a409004721a26bb9815d7cc7706b6c4e0 | https://github.com/melnikov-s/anvoy/blob/c0c5ff2a409004721a26bb9815d7cc7706b6c4e0/src/template.js#L141-L186 |
53,054 | cli-kit/cli-mid-parser | index.js | getParserConfiguration | function getParserConfiguration(target, config) {
target = target || this;
config = config || {alias: {}, flags: [], options: []};
var k, arg, key
, conf = this.configure();
var no = /^\[?no\]?/, nor = /(\[no-?\]-?)/;
for(k in target._options) {
arg = target._options[k];
// misconfigured option, not a valid instance
if(typeof arg.isArgument !== 'function') continue;
if(!arg.isFlag() && !arg.isOption()) {
continue;
}
var names = arg.names().slice(0);
names.forEach(function(nm, index, arr) {
arr[index] = nm.replace(nor, '');
})
key = arg.key();
//console.log('key: %s', key);
if(no.test(key)) {
// this works around an issue with args such as --noop
// without the charAt test the id is *op*
// ensuring the first character is uppercase is akin to
// checking the declaration was '[no]-'
if(/^[A-Z]$/.test(key.charAt(2))) {
key = key.replace(no, '');
key = key.charAt(0).toLowerCase() + key.slice(1);
}
//console.log('final key: %s', key);
}
config.alias[names.join(' ')] = key;
if(arg.isFlag()) {
config.flags = config.flags.concat(names);
}else{
config.options = config.options.concat(names);
}
}
// TODO: sometimes child options have the same keys
// TODO: as top-level options, these duplicates can be removed
for(k in target._commands) {
getParserConfiguration.call(this, target._commands[k], config);
}
if(conf.variables && conf.variables.prefix) {
config.vars = {variables: conf.variables.prefix};
}
return config;
} | javascript | function getParserConfiguration(target, config) {
target = target || this;
config = config || {alias: {}, flags: [], options: []};
var k, arg, key
, conf = this.configure();
var no = /^\[?no\]?/, nor = /(\[no-?\]-?)/;
for(k in target._options) {
arg = target._options[k];
// misconfigured option, not a valid instance
if(typeof arg.isArgument !== 'function') continue;
if(!arg.isFlag() && !arg.isOption()) {
continue;
}
var names = arg.names().slice(0);
names.forEach(function(nm, index, arr) {
arr[index] = nm.replace(nor, '');
})
key = arg.key();
//console.log('key: %s', key);
if(no.test(key)) {
// this works around an issue with args such as --noop
// without the charAt test the id is *op*
// ensuring the first character is uppercase is akin to
// checking the declaration was '[no]-'
if(/^[A-Z]$/.test(key.charAt(2))) {
key = key.replace(no, '');
key = key.charAt(0).toLowerCase() + key.slice(1);
}
//console.log('final key: %s', key);
}
config.alias[names.join(' ')] = key;
if(arg.isFlag()) {
config.flags = config.flags.concat(names);
}else{
config.options = config.options.concat(names);
}
}
// TODO: sometimes child options have the same keys
// TODO: as top-level options, these duplicates can be removed
for(k in target._commands) {
getParserConfiguration.call(this, target._commands[k], config);
}
if(conf.variables && conf.variables.prefix) {
config.vars = {variables: conf.variables.prefix};
}
return config;
} | [
"function",
"getParserConfiguration",
"(",
"target",
",",
"config",
")",
"{",
"target",
"=",
"target",
"||",
"this",
";",
"config",
"=",
"config",
"||",
"{",
"alias",
":",
"{",
"}",
",",
"flags",
":",
"[",
"]",
",",
"options",
":",
"[",
"]",
"}",
";",
"var",
"k",
",",
"arg",
",",
"key",
",",
"conf",
"=",
"this",
".",
"configure",
"(",
")",
";",
"var",
"no",
"=",
"/",
"^\\[?no\\]?",
"/",
",",
"nor",
"=",
"/",
"(\\[no-?\\]-?)",
"/",
";",
"for",
"(",
"k",
"in",
"target",
".",
"_options",
")",
"{",
"arg",
"=",
"target",
".",
"_options",
"[",
"k",
"]",
";",
"// misconfigured option, not a valid instance",
"if",
"(",
"typeof",
"arg",
".",
"isArgument",
"!==",
"'function'",
")",
"continue",
";",
"if",
"(",
"!",
"arg",
".",
"isFlag",
"(",
")",
"&&",
"!",
"arg",
".",
"isOption",
"(",
")",
")",
"{",
"continue",
";",
"}",
"var",
"names",
"=",
"arg",
".",
"names",
"(",
")",
".",
"slice",
"(",
"0",
")",
";",
"names",
".",
"forEach",
"(",
"function",
"(",
"nm",
",",
"index",
",",
"arr",
")",
"{",
"arr",
"[",
"index",
"]",
"=",
"nm",
".",
"replace",
"(",
"nor",
",",
"''",
")",
";",
"}",
")",
"key",
"=",
"arg",
".",
"key",
"(",
")",
";",
"//console.log('key: %s', key);",
"if",
"(",
"no",
".",
"test",
"(",
"key",
")",
")",
"{",
"// this works around an issue with args such as --noop",
"// without the charAt test the id is *op*",
"// ensuring the first character is uppercase is akin to",
"// checking the declaration was '[no]-'",
"if",
"(",
"/",
"^[A-Z]$",
"/",
".",
"test",
"(",
"key",
".",
"charAt",
"(",
"2",
")",
")",
")",
"{",
"key",
"=",
"key",
".",
"replace",
"(",
"no",
",",
"''",
")",
";",
"key",
"=",
"key",
".",
"charAt",
"(",
"0",
")",
".",
"toLowerCase",
"(",
")",
"+",
"key",
".",
"slice",
"(",
"1",
")",
";",
"}",
"//console.log('final key: %s', key);",
"}",
"config",
".",
"alias",
"[",
"names",
".",
"join",
"(",
"' '",
")",
"]",
"=",
"key",
";",
"if",
"(",
"arg",
".",
"isFlag",
"(",
")",
")",
"{",
"config",
".",
"flags",
"=",
"config",
".",
"flags",
".",
"concat",
"(",
"names",
")",
";",
"}",
"else",
"{",
"config",
".",
"options",
"=",
"config",
".",
"options",
".",
"concat",
"(",
"names",
")",
";",
"}",
"}",
"// TODO: sometimes child options have the same keys",
"// TODO: as top-level options, these duplicates can be removed",
"for",
"(",
"k",
"in",
"target",
".",
"_commands",
")",
"{",
"getParserConfiguration",
".",
"call",
"(",
"this",
",",
"target",
".",
"_commands",
"[",
"k",
"]",
",",
"config",
")",
";",
"}",
"if",
"(",
"conf",
".",
"variables",
"&&",
"conf",
".",
"variables",
".",
"prefix",
")",
"{",
"config",
".",
"vars",
"=",
"{",
"variables",
":",
"conf",
".",
"variables",
".",
"prefix",
"}",
";",
"}",
"return",
"config",
";",
"}"
] | Retrieve a configuration suitable for passing to
the arguments parser. | [
"Retrieve",
"a",
"configuration",
"suitable",
"for",
"passing",
"to",
"the",
"arguments",
"parser",
"."
] | cfd6300eeb5cc69a33370c9b1a0978bbdce250bf | https://github.com/cli-kit/cli-mid-parser/blob/cfd6300eeb5cc69a33370c9b1a0978bbdce250bf/index.js#L8-L59 |
53,055 | uxter/fluxter | src/fluxter.js | next | function next(actionData) {
index++;
if(index === store.middlewares.length) {
done(actionData);
} else {
store.middlewares[index](store, actionName, actionData, next);
}
} | javascript | function next(actionData) {
index++;
if(index === store.middlewares.length) {
done(actionData);
} else {
store.middlewares[index](store, actionName, actionData, next);
}
} | [
"function",
"next",
"(",
"actionData",
")",
"{",
"index",
"++",
";",
"if",
"(",
"index",
"===",
"store",
".",
"middlewares",
".",
"length",
")",
"{",
"done",
"(",
"actionData",
")",
";",
"}",
"else",
"{",
"store",
".",
"middlewares",
"[",
"index",
"]",
"(",
"store",
",",
"actionName",
",",
"actionData",
",",
"next",
")",
";",
"}",
"}"
] | Call next middleware or done
@function next
@param {*} actionData - An action data | [
"Call",
"next",
"middleware",
"or",
"done"
] | f3a878c92ec3b3bab609515aca3ae8982d044ecd | https://github.com/uxter/fluxter/blob/f3a878c92ec3b3bab609515aca3ae8982d044ecd/src/fluxter.js#L158-L165 |
53,056 | uxter/fluxter | src/fluxter.js | checkArgumentType | function checkArgumentType(argument, position, type) {
let wrongTypeOf = typeof argument !== type;
let isCheckObject = type === 'object';
let n = isCheckObject ? 'n' : '';
if (isCheckObject && (wrongTypeOf || argument.constructor !== Object) || wrongTypeOf) {
throw new TypeError('A ' + position + ' argument must be a' + n + ' ' + type + '.');
}
} | javascript | function checkArgumentType(argument, position, type) {
let wrongTypeOf = typeof argument !== type;
let isCheckObject = type === 'object';
let n = isCheckObject ? 'n' : '';
if (isCheckObject && (wrongTypeOf || argument.constructor !== Object) || wrongTypeOf) {
throw new TypeError('A ' + position + ' argument must be a' + n + ' ' + type + '.');
}
} | [
"function",
"checkArgumentType",
"(",
"argument",
",",
"position",
",",
"type",
")",
"{",
"let",
"wrongTypeOf",
"=",
"typeof",
"argument",
"!==",
"type",
";",
"let",
"isCheckObject",
"=",
"type",
"===",
"'object'",
";",
"let",
"n",
"=",
"isCheckObject",
"?",
"'n'",
":",
"''",
";",
"if",
"(",
"isCheckObject",
"&&",
"(",
"wrongTypeOf",
"||",
"argument",
".",
"constructor",
"!==",
"Object",
")",
"||",
"wrongTypeOf",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'A '",
"+",
"position",
"+",
"' argument must be a'",
"+",
"n",
"+",
"' '",
"+",
"type",
"+",
"'.'",
")",
";",
"}",
"}"
] | Check type of argument
@function checkArgumentType
@param {*} argument
@param {String} position - first, second, ...
@param {String} type - string, function, ...
@throws {TypeError}
@private | [
"Check",
"type",
"of",
"argument"
] | f3a878c92ec3b3bab609515aca3ae8982d044ecd | https://github.com/uxter/fluxter/blob/f3a878c92ec3b3bab609515aca3ae8982d044ecd/src/fluxter.js#L200-L207 |
53,057 | N4SJAMK/jarmo-express | index.js | onResponseFinished | function onResponseFinished() {
// Resolve the payload from the 'request' and 'response' objects,
// and send it to the Jarmo server, catching any errors.
var payload = config.resolve(req, res, Date.now() - start);
if(!payload) {
// If the payload is falsy we don't send the data. This allows
// for some ad hoc filtering with custom resolve functions.
return removeListeners();
}
return send(config.host, config.port, payload, function(err) {
if(err) {
config.error(err);
}
return removeListeners();
});
} | javascript | function onResponseFinished() {
// Resolve the payload from the 'request' and 'response' objects,
// and send it to the Jarmo server, catching any errors.
var payload = config.resolve(req, res, Date.now() - start);
if(!payload) {
// If the payload is falsy we don't send the data. This allows
// for some ad hoc filtering with custom resolve functions.
return removeListeners();
}
return send(config.host, config.port, payload, function(err) {
if(err) {
config.error(err);
}
return removeListeners();
});
} | [
"function",
"onResponseFinished",
"(",
")",
"{",
"// Resolve the payload from the 'request' and 'response' objects,",
"// and send it to the Jarmo server, catching any errors.",
"var",
"payload",
"=",
"config",
".",
"resolve",
"(",
"req",
",",
"res",
",",
"Date",
".",
"now",
"(",
")",
"-",
"start",
")",
";",
"if",
"(",
"!",
"payload",
")",
"{",
"// If the payload is falsy we don't send the data. This allows",
"// for some ad hoc filtering with custom resolve functions.",
"return",
"removeListeners",
"(",
")",
";",
"}",
"return",
"send",
"(",
"config",
".",
"host",
",",
"config",
".",
"port",
",",
"payload",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"config",
".",
"error",
"(",
"err",
")",
";",
"}",
"return",
"removeListeners",
"(",
")",
";",
"}",
")",
";",
"}"
] | Get the data out of the request and response and send it to the
configured server. Also make sure to remove listeners when done. | [
"Get",
"the",
"data",
"out",
"of",
"the",
"request",
"and",
"response",
"and",
"send",
"it",
"to",
"the",
"configured",
"server",
".",
"Also",
"make",
"sure",
"to",
"remove",
"listeners",
"when",
"done",
"."
] | 42808d93ef29922f6a9a68fd3507d280c2a45a0f | https://github.com/N4SJAMK/jarmo-express/blob/42808d93ef29922f6a9a68fd3507d280c2a45a0f/index.js#L61-L78 |
53,058 | N4SJAMK/jarmo-express | index.js | removeListeners | function removeListeners() {
res.removeListener('error', removeListeners);
res.removeListener('close', removeListeners);
res.removeListener('finish', onResponseFinished);
} | javascript | function removeListeners() {
res.removeListener('error', removeListeners);
res.removeListener('close', removeListeners);
res.removeListener('finish', onResponseFinished);
} | [
"function",
"removeListeners",
"(",
")",
"{",
"res",
".",
"removeListener",
"(",
"'error'",
",",
"removeListeners",
")",
";",
"res",
".",
"removeListener",
"(",
"'close'",
",",
"removeListeners",
")",
";",
"res",
".",
"removeListener",
"(",
"'finish'",
",",
"onResponseFinished",
")",
";",
"}"
] | Clean up listeners to prevent any memory shenanigans. | [
"Clean",
"up",
"listeners",
"to",
"prevent",
"any",
"memory",
"shenanigans",
"."
] | 42808d93ef29922f6a9a68fd3507d280c2a45a0f | https://github.com/N4SJAMK/jarmo-express/blob/42808d93ef29922f6a9a68fd3507d280c2a45a0f/index.js#L83-L87 |
53,059 | N4SJAMK/jarmo-express | index.js | send | function send(host, port, payload, callback) {
// Create a Buffer of the JSON stringified payload, so we can send it.
var data = new Buffer(JSON.stringify(payload));
// Resolve or reject the promise once the we have at least attempted to
// send the payload. Should we add some sort of a retry on error?
return client.send(data, 0, data.length, port, host, callback);
} | javascript | function send(host, port, payload, callback) {
// Create a Buffer of the JSON stringified payload, so we can send it.
var data = new Buffer(JSON.stringify(payload));
// Resolve or reject the promise once the we have at least attempted to
// send the payload. Should we add some sort of a retry on error?
return client.send(data, 0, data.length, port, host, callback);
} | [
"function",
"send",
"(",
"host",
",",
"port",
",",
"payload",
",",
"callback",
")",
"{",
"// Create a Buffer of the JSON stringified payload, so we can send it.",
"var",
"data",
"=",
"new",
"Buffer",
"(",
"JSON",
".",
"stringify",
"(",
"payload",
")",
")",
";",
"// Resolve or reject the promise once the we have at least attempted to",
"// send the payload. Should we add some sort of a retry on error?",
"return",
"client",
".",
"send",
"(",
"data",
",",
"0",
",",
"data",
".",
"length",
",",
"port",
",",
"host",
",",
"callback",
")",
";",
"}"
] | Send data via UDP to the target server.
@param {string} host Server host.
@param {string} port Server port.
@param {object} payload Payload object, that will be made into a string,
and sent to the server.
@return {Promise} Promise for sending the payload. | [
"Send",
"data",
"via",
"UDP",
"to",
"the",
"target",
"server",
"."
] | 42808d93ef29922f6a9a68fd3507d280c2a45a0f | https://github.com/N4SJAMK/jarmo-express/blob/42808d93ef29922f6a9a68fd3507d280c2a45a0f/index.js#L127-L134 |
53,060 | micro-node/amqp | lib/amqp.js | assetQueue | function assetQueue(addr, queue, options) {
return createChannel(addr).then(data => {
let ch = data[1];
return ch.assertQueue(queue, options).then(q => [ch, q]);
});
} | javascript | function assetQueue(addr, queue, options) {
return createChannel(addr).then(data => {
let ch = data[1];
return ch.assertQueue(queue, options).then(q => [ch, q]);
});
} | [
"function",
"assetQueue",
"(",
"addr",
",",
"queue",
",",
"options",
")",
"{",
"return",
"createChannel",
"(",
"addr",
")",
".",
"then",
"(",
"data",
"=>",
"{",
"let",
"ch",
"=",
"data",
"[",
"1",
"]",
";",
"return",
"ch",
".",
"assertQueue",
"(",
"queue",
",",
"options",
")",
".",
"then",
"(",
"q",
"=>",
"[",
"ch",
",",
"q",
"]",
")",
";",
"}",
")",
";",
"}"
] | asset queue helper | [
"asset",
"queue",
"helper"
] | 40e12b04a4426f51b790284c13ebef9fd91a6733 | https://github.com/micro-node/amqp/blob/40e12b04a4426f51b790284c13ebef9fd91a6733/lib/amqp.js#L183-L189 |
53,061 | micro-node/amqp | lib/amqp.js | createChannel | function createChannel(addr) {
return amqp.connect(genAddr(addr)).then(conn => {
return conn.createChannel().then(ch => {
connections.push(conn);
return [conn, ch];
});
}, debugError);
} | javascript | function createChannel(addr) {
return amqp.connect(genAddr(addr)).then(conn => {
return conn.createChannel().then(ch => {
connections.push(conn);
return [conn, ch];
});
}, debugError);
} | [
"function",
"createChannel",
"(",
"addr",
")",
"{",
"return",
"amqp",
".",
"connect",
"(",
"genAddr",
"(",
"addr",
")",
")",
".",
"then",
"(",
"conn",
"=>",
"{",
"return",
"conn",
".",
"createChannel",
"(",
")",
".",
"then",
"(",
"ch",
"=>",
"{",
"connections",
".",
"push",
"(",
"conn",
")",
";",
"return",
"[",
"conn",
",",
"ch",
"]",
";",
"}",
")",
";",
"}",
",",
"debugError",
")",
";",
"}"
] | create channel helper | [
"create",
"channel",
"helper"
] | 40e12b04a4426f51b790284c13ebef9fd91a6733 | https://github.com/micro-node/amqp/blob/40e12b04a4426f51b790284c13ebef9fd91a6733/lib/amqp.js#L192-L200 |
53,062 | iuap-design/compox | dist/compox.js | SubClass | function SubClass() {
var ret;
// Call the parent constructor.
parent.apply(this, arguments);
// Only call initialize in self constructor.
if(this.constructor === SubClass && this.initialize) {
ret = this.initialize.apply(this, arguments);
}
return ret ? ret : this;
} | javascript | function SubClass() {
var ret;
// Call the parent constructor.
parent.apply(this, arguments);
// Only call initialize in self constructor.
if(this.constructor === SubClass && this.initialize) {
ret = this.initialize.apply(this, arguments);
}
return ret ? ret : this;
} | [
"function",
"SubClass",
"(",
")",
"{",
"var",
"ret",
";",
"// Call the parent constructor.",
"parent",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"// Only call initialize in self constructor.",
"if",
"(",
"this",
".",
"constructor",
"===",
"SubClass",
"&&",
"this",
".",
"initialize",
")",
"{",
"ret",
"=",
"this",
".",
"initialize",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"}",
"return",
"ret",
"?",
"ret",
":",
"this",
";",
"}"
] | The created class constructor | [
"The",
"created",
"class",
"constructor"
] | 79b6a6d24a64f072134cc7385b6cdd29a2e310ac | https://github.com/iuap-design/compox/blob/79b6a6d24a64f072134cc7385b6cdd29a2e310ac/dist/compox.js#L537-L547 |
53,063 | iuap-design/compox | dist/compox.js | function (event) {
//event = $.event.fix(event); // jQuery event normalization.
var element = this;//event.target;
// @ TextNode -> nodeType == 3
element = (element.nodeType == 3) ? element.parentNode : element;
if (opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
var target = element;//$(element);
if (target.tagName == "INPUT" || target.tagName == "TEXTAREA") {
return;
}
}
var code = event.which,
type = event.type,
character = String.fromCharCode(code).toLowerCase(),
special = that.special_keys[code],
shift = event.shiftKey,
ctrl = event.ctrlKey,
alt = event.altKey,
propagate = true, // default behaivour
mapPoint = null;
// in opera + safari, the event.target is unpredictable.
// for example: 'keydown' might be associated with HtmlBodyElement
// or the element where you last clicked with your mouse.
if (opt.checkParent) {
// while (!that.all[element] && element.parentNode){
while (!element['hotkeys'] && element.parentNode) {
element = element.parentNode;
}
}
// var cbMap = that.all[element].events[type].callbackMap;
var cbMap = element['hotkeys'].events[type].callbackMap;
if (!shift && !ctrl && !alt) { // No Modifiers
mapPoint = cbMap[special] || cbMap[character];
}
// deals with combinaitons (alt|ctrl|shift+anything)
else {
var modif = '';
if (alt) modif += 'alt+';
if (ctrl) modif += 'ctrl+';
if (shift) modif += 'shift+';
// modifiers + special keys or modifiers + characters or modifiers + shift characters
mapPoint = cbMap[modif + special] || cbMap[modif + character] || cbMap[modif + that.shift_nums[character]];
}
if (mapPoint) {
mapPoint.cb(event);
if (!mapPoint.propagate) {
event.stopPropagation();
event.preventDefault();
return false;
}
}
} | javascript | function (event) {
//event = $.event.fix(event); // jQuery event normalization.
var element = this;//event.target;
// @ TextNode -> nodeType == 3
element = (element.nodeType == 3) ? element.parentNode : element;
if (opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
var target = element;//$(element);
if (target.tagName == "INPUT" || target.tagName == "TEXTAREA") {
return;
}
}
var code = event.which,
type = event.type,
character = String.fromCharCode(code).toLowerCase(),
special = that.special_keys[code],
shift = event.shiftKey,
ctrl = event.ctrlKey,
alt = event.altKey,
propagate = true, // default behaivour
mapPoint = null;
// in opera + safari, the event.target is unpredictable.
// for example: 'keydown' might be associated with HtmlBodyElement
// or the element where you last clicked with your mouse.
if (opt.checkParent) {
// while (!that.all[element] && element.parentNode){
while (!element['hotkeys'] && element.parentNode) {
element = element.parentNode;
}
}
// var cbMap = that.all[element].events[type].callbackMap;
var cbMap = element['hotkeys'].events[type].callbackMap;
if (!shift && !ctrl && !alt) { // No Modifiers
mapPoint = cbMap[special] || cbMap[character];
}
// deals with combinaitons (alt|ctrl|shift+anything)
else {
var modif = '';
if (alt) modif += 'alt+';
if (ctrl) modif += 'ctrl+';
if (shift) modif += 'shift+';
// modifiers + special keys or modifiers + characters or modifiers + shift characters
mapPoint = cbMap[modif + special] || cbMap[modif + character] || cbMap[modif + that.shift_nums[character]];
}
if (mapPoint) {
mapPoint.cb(event);
if (!mapPoint.propagate) {
event.stopPropagation();
event.preventDefault();
return false;
}
}
} | [
"function",
"(",
"event",
")",
"{",
"//event = $.event.fix(event); // jQuery event normalization.",
"var",
"element",
"=",
"this",
";",
"//event.target;",
"// @ TextNode -> nodeType == 3",
"element",
"=",
"(",
"element",
".",
"nodeType",
"==",
"3",
")",
"?",
"element",
".",
"parentNode",
":",
"element",
";",
"if",
"(",
"opt",
"[",
"'disableInInput'",
"]",
")",
"{",
"// Disable shortcut keys in Input, Textarea fields",
"var",
"target",
"=",
"element",
";",
"//$(element);",
"if",
"(",
"target",
".",
"tagName",
"==",
"\"INPUT\"",
"||",
"target",
".",
"tagName",
"==",
"\"TEXTAREA\"",
")",
"{",
"return",
";",
"}",
"}",
"var",
"code",
"=",
"event",
".",
"which",
",",
"type",
"=",
"event",
".",
"type",
",",
"character",
"=",
"String",
".",
"fromCharCode",
"(",
"code",
")",
".",
"toLowerCase",
"(",
")",
",",
"special",
"=",
"that",
".",
"special_keys",
"[",
"code",
"]",
",",
"shift",
"=",
"event",
".",
"shiftKey",
",",
"ctrl",
"=",
"event",
".",
"ctrlKey",
",",
"alt",
"=",
"event",
".",
"altKey",
",",
"propagate",
"=",
"true",
",",
"// default behaivour",
"mapPoint",
"=",
"null",
";",
"// in opera + safari, the event.target is unpredictable.",
"// for example: 'keydown' might be associated with HtmlBodyElement",
"// or the element where you last clicked with your mouse.",
"if",
"(",
"opt",
".",
"checkParent",
")",
"{",
"// while (!that.all[element] && element.parentNode){",
"while",
"(",
"!",
"element",
"[",
"'hotkeys'",
"]",
"&&",
"element",
".",
"parentNode",
")",
"{",
"element",
"=",
"element",
".",
"parentNode",
";",
"}",
"}",
"// var cbMap = that.all[element].events[type].callbackMap;",
"var",
"cbMap",
"=",
"element",
"[",
"'hotkeys'",
"]",
".",
"events",
"[",
"type",
"]",
".",
"callbackMap",
";",
"if",
"(",
"!",
"shift",
"&&",
"!",
"ctrl",
"&&",
"!",
"alt",
")",
"{",
"// No Modifiers",
"mapPoint",
"=",
"cbMap",
"[",
"special",
"]",
"||",
"cbMap",
"[",
"character",
"]",
";",
"}",
"// deals with combinaitons (alt|ctrl|shift+anything)",
"else",
"{",
"var",
"modif",
"=",
"''",
";",
"if",
"(",
"alt",
")",
"modif",
"+=",
"'alt+'",
";",
"if",
"(",
"ctrl",
")",
"modif",
"+=",
"'ctrl+'",
";",
"if",
"(",
"shift",
")",
"modif",
"+=",
"'shift+'",
";",
"// modifiers + special keys or modifiers + characters or modifiers + shift characters",
"mapPoint",
"=",
"cbMap",
"[",
"modif",
"+",
"special",
"]",
"||",
"cbMap",
"[",
"modif",
"+",
"character",
"]",
"||",
"cbMap",
"[",
"modif",
"+",
"that",
".",
"shift_nums",
"[",
"character",
"]",
"]",
";",
"}",
"if",
"(",
"mapPoint",
")",
"{",
"mapPoint",
".",
"cb",
"(",
"event",
")",
";",
"if",
"(",
"!",
"mapPoint",
".",
"propagate",
")",
"{",
"event",
".",
"stopPropagation",
"(",
")",
";",
"event",
".",
"preventDefault",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"}"
] | inspect if keystroke matches | [
"inspect",
"if",
"keystroke",
"matches"
] | 79b6a6d24a64f072134cc7385b6cdd29a2e310ac | https://github.com/iuap-design/compox/blob/79b6a6d24a64f072134cc7385b6cdd29a2e310ac/dist/compox.js#L712-L766 |
|
53,064 | gethuman/pancakes-recipe | utils/active.user.js | init | function init() {
return user.initComplete ?
Q.when(user) :
userService.findMe()
.then(function setUserLocal(me) {
me = me || {};
// pull out the user
_.extend(user, me.user);
// return the user and notify init complete
user.initComplete = true;
eventBus.emit('user.init');
return user;
});
} | javascript | function init() {
return user.initComplete ?
Q.when(user) :
userService.findMe()
.then(function setUserLocal(me) {
me = me || {};
// pull out the user
_.extend(user, me.user);
// return the user and notify init complete
user.initComplete = true;
eventBus.emit('user.init');
return user;
});
} | [
"function",
"init",
"(",
")",
"{",
"return",
"user",
".",
"initComplete",
"?",
"Q",
".",
"when",
"(",
"user",
")",
":",
"userService",
".",
"findMe",
"(",
")",
".",
"then",
"(",
"function",
"setUserLocal",
"(",
"me",
")",
"{",
"me",
"=",
"me",
"||",
"{",
"}",
";",
"// pull out the user",
"_",
".",
"extend",
"(",
"user",
",",
"me",
".",
"user",
")",
";",
"// return the user and notify init complete",
"user",
".",
"initComplete",
"=",
"true",
";",
"eventBus",
".",
"emit",
"(",
"'user.init'",
")",
";",
"return",
"user",
";",
"}",
")",
";",
"}"
] | If user already loaded, use that, otherwise get it from the API
@returns {*} | [
"If",
"user",
"already",
"loaded",
"use",
"that",
"otherwise",
"get",
"it",
"from",
"the",
"API"
] | ea3feb8839e2edaf1b4577c052b8958953db4498 | https://github.com/gethuman/pancakes-recipe/blob/ea3feb8839e2edaf1b4577c052b8958953db4498/utils/active.user.js#L18-L34 |
53,065 | Postmedia/timbits | lib/timbits.js | filteredFiles | function filteredFiles(folder, pattern) {
var files = [];
if (fs.existsSync(folder)){
fs.readdirSync(folder).forEach(function(file) {
if (file.match(pattern) != null)
files.push(file);
});
}
return files;
} | javascript | function filteredFiles(folder, pattern) {
var files = [];
if (fs.existsSync(folder)){
fs.readdirSync(folder).forEach(function(file) {
if (file.match(pattern) != null)
files.push(file);
});
}
return files;
} | [
"function",
"filteredFiles",
"(",
"folder",
",",
"pattern",
")",
"{",
"var",
"files",
"=",
"[",
"]",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"folder",
")",
")",
"{",
"fs",
".",
"readdirSync",
"(",
"folder",
")",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"if",
"(",
"file",
".",
"match",
"(",
"pattern",
")",
"!=",
"null",
")",
"files",
".",
"push",
"(",
"file",
")",
";",
"}",
")",
";",
"}",
"return",
"files",
";",
"}"
] | retrieve list of matching files in a folder | [
"retrieve",
"list",
"of",
"matching",
"files",
"in",
"a",
"folder"
] | 0213593db6cf94bb35679a4fad01588b19f7fe62 | https://github.com/Postmedia/timbits/blob/0213593db6cf94bb35679a4fad01588b19f7fe62/lib/timbits.js#L28-L38 |
53,066 | Postmedia/timbits | lib/timbits.js | loadViews | function loadViews(timbit) {
timbit.views = [];
var pattern = new RegExp('\.' + timbits.app.settings['view engine'] + '$')
, folder = path.join(config.home, 'views', timbit.viewBase);
if (fs.existsSync(folder)) {
var files = fs.readdirSync(folder);
files.forEach(function(file) {
timbit.views.push(file.replace(pattern, ''));
});
}
// We will attempt the default view anyway and hope the timbit knows what it is doing.
if (timbit.views.length === 0) timbit.views.push(timbit.defaultView);
} | javascript | function loadViews(timbit) {
timbit.views = [];
var pattern = new RegExp('\.' + timbits.app.settings['view engine'] + '$')
, folder = path.join(config.home, 'views', timbit.viewBase);
if (fs.existsSync(folder)) {
var files = fs.readdirSync(folder);
files.forEach(function(file) {
timbit.views.push(file.replace(pattern, ''));
});
}
// We will attempt the default view anyway and hope the timbit knows what it is doing.
if (timbit.views.length === 0) timbit.views.push(timbit.defaultView);
} | [
"function",
"loadViews",
"(",
"timbit",
")",
"{",
"timbit",
".",
"views",
"=",
"[",
"]",
";",
"var",
"pattern",
"=",
"new",
"RegExp",
"(",
"'\\.'",
"+",
"timbits",
".",
"app",
".",
"settings",
"[",
"'view engine'",
"]",
"+",
"'$'",
")",
",",
"folder",
"=",
"path",
".",
"join",
"(",
"config",
".",
"home",
",",
"'views'",
",",
"timbit",
".",
"viewBase",
")",
";",
"if",
"(",
"fs",
".",
"existsSync",
"(",
"folder",
")",
")",
"{",
"var",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"folder",
")",
";",
"files",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"timbit",
".",
"views",
".",
"push",
"(",
"file",
".",
"replace",
"(",
"pattern",
",",
"''",
")",
")",
";",
"}",
")",
";",
"}",
"// We will attempt the default view anyway and hope the timbit knows what it is doing.",
"if",
"(",
"timbit",
".",
"views",
".",
"length",
"===",
"0",
")",
"timbit",
".",
"views",
".",
"push",
"(",
"timbit",
".",
"defaultView",
")",
";",
"}"
] | automagically load views for a given timbit | [
"automagically",
"load",
"views",
"for",
"a",
"given",
"timbit"
] | 0213593db6cf94bb35679a4fad01588b19f7fe62 | https://github.com/Postmedia/timbits/blob/0213593db6cf94bb35679a4fad01588b19f7fe62/lib/timbits.js#L57-L72 |
53,067 | Postmedia/timbits | lib/timbits.js | compileTemplate | function compileTemplate(name) {
var filename = path.join(__dirname, "templates", name + '.hjs');
var contents = fs.readFileSync(filename);
return hogan.compile(contents.toString());
} | javascript | function compileTemplate(name) {
var filename = path.join(__dirname, "templates", name + '.hjs');
var contents = fs.readFileSync(filename);
return hogan.compile(contents.toString());
} | [
"function",
"compileTemplate",
"(",
"name",
")",
"{",
"var",
"filename",
"=",
"path",
".",
"join",
"(",
"__dirname",
",",
"\"templates\"",
",",
"name",
"+",
"'.hjs'",
")",
";",
"var",
"contents",
"=",
"fs",
".",
"readFileSync",
"(",
"filename",
")",
";",
"return",
"hogan",
".",
"compile",
"(",
"contents",
".",
"toString",
"(",
")",
")",
";",
"}"
] | compile built in templates | [
"compile",
"built",
"in",
"templates"
] | 0213593db6cf94bb35679a4fad01588b19f7fe62 | https://github.com/Postmedia/timbits/blob/0213593db6cf94bb35679a4fad01588b19f7fe62/lib/timbits.js#L87-L91 |
53,068 | Postmedia/timbits | lib/timbits.js | allowedMethods | function allowedMethods(methods) {
// default values
var methodsAllowed = { 'GET': true, 'POST': false, 'PUT': false, 'HEAD': false, 'DELETE': false };
// check and override if one of the default methods
for (var key in methods) {
var newKey = key.toUpperCase();
if ( methodsAllowed[newKey]!=undefined) {
methodsAllowed[newKey] = Boolean(methods[key]);
}
}
return methodsAllowed;
} | javascript | function allowedMethods(methods) {
// default values
var methodsAllowed = { 'GET': true, 'POST': false, 'PUT': false, 'HEAD': false, 'DELETE': false };
// check and override if one of the default methods
for (var key in methods) {
var newKey = key.toUpperCase();
if ( methodsAllowed[newKey]!=undefined) {
methodsAllowed[newKey] = Boolean(methods[key]);
}
}
return methodsAllowed;
} | [
"function",
"allowedMethods",
"(",
"methods",
")",
"{",
"// default values",
"var",
"methodsAllowed",
"=",
"{",
"'GET'",
":",
"true",
",",
"'POST'",
":",
"false",
",",
"'PUT'",
":",
"false",
",",
"'HEAD'",
":",
"false",
",",
"'DELETE'",
":",
"false",
"}",
";",
"// check and override if one of the default methods",
"for",
"(",
"var",
"key",
"in",
"methods",
")",
"{",
"var",
"newKey",
"=",
"key",
".",
"toUpperCase",
"(",
")",
";",
"if",
"(",
"methodsAllowed",
"[",
"newKey",
"]",
"!=",
"undefined",
")",
"{",
"methodsAllowed",
"[",
"newKey",
"]",
"=",
"Boolean",
"(",
"methods",
"[",
"key",
"]",
")",
";",
"}",
"}",
"return",
"methodsAllowed",
";",
"}"
] | generates the allowed methods | [
"generates",
"the",
"allowed",
"methods"
] | 0213593db6cf94bb35679a4fad01588b19f7fe62 | https://github.com/Postmedia/timbits/blob/0213593db6cf94bb35679a4fad01588b19f7fe62/lib/timbits.js#L94-L105 |
53,069 | bigpipe/parsifal | index.js | text | function text(element) {
var type = element.nodeType
, value = '';
if (1 === type || 9 === type || 11 === type) {
//
// Use `textContent` instead of `innerText` as it's inconsistent with new
// lines.
//
if ('string' === typeof element.textContent) return element.textContent;
for (element = element.firstChild; element; element = element.nextSibling) {
value += text(element);
}
}
return 3 === type || 4 === type
? element.nodeValue
: value;
} | javascript | function text(element) {
var type = element.nodeType
, value = '';
if (1 === type || 9 === type || 11 === type) {
//
// Use `textContent` instead of `innerText` as it's inconsistent with new
// lines.
//
if ('string' === typeof element.textContent) return element.textContent;
for (element = element.firstChild; element; element = element.nextSibling) {
value += text(element);
}
}
return 3 === type || 4 === type
? element.nodeValue
: value;
} | [
"function",
"text",
"(",
"element",
")",
"{",
"var",
"type",
"=",
"element",
".",
"nodeType",
",",
"value",
"=",
"''",
";",
"if",
"(",
"1",
"===",
"type",
"||",
"9",
"===",
"type",
"||",
"11",
"===",
"type",
")",
"{",
"//",
"// Use `textContent` instead of `innerText` as it's inconsistent with new",
"// lines.",
"//",
"if",
"(",
"'string'",
"===",
"typeof",
"element",
".",
"textContent",
")",
"return",
"element",
".",
"textContent",
";",
"for",
"(",
"element",
"=",
"element",
".",
"firstChild",
";",
"element",
";",
"element",
"=",
"element",
".",
"nextSibling",
")",
"{",
"value",
"+=",
"text",
"(",
"element",
")",
";",
"}",
"}",
"return",
"3",
"===",
"type",
"||",
"4",
"===",
"type",
"?",
"element",
".",
"nodeValue",
":",
"value",
";",
"}"
] | Get the text or inner text from a given element.
@param {Element} element
@returns {String} text
@api public | [
"Get",
"the",
"text",
"or",
"inner",
"text",
"from",
"a",
"given",
"element",
"."
] | 4b35938c62b72810c4117cda5d57123cb8a9a318 | https://github.com/bigpipe/parsifal/blob/4b35938c62b72810c4117cda5d57123cb8a9a318/index.js#L58-L77 |
53,070 | bigpipe/parsifal | index.js | attribute | function attribute(element, name, val) {
return supports.attributes || !supports.html
? element.getAttribute(name)
: (val = element.getAttributeNode(name)) && val.specified ? val.value : '';
} | javascript | function attribute(element, name, val) {
return supports.attributes || !supports.html
? element.getAttribute(name)
: (val = element.getAttributeNode(name)) && val.specified ? val.value : '';
} | [
"function",
"attribute",
"(",
"element",
",",
"name",
",",
"val",
")",
"{",
"return",
"supports",
".",
"attributes",
"||",
"!",
"supports",
".",
"html",
"?",
"element",
".",
"getAttribute",
"(",
"name",
")",
":",
"(",
"val",
"=",
"element",
".",
"getAttributeNode",
"(",
"name",
")",
")",
"&&",
"val",
".",
"specified",
"?",
"val",
".",
"value",
":",
"''",
";",
"}"
] | Find the attribute.
@param {Element} element
@returns {String} The `.value` of the element.
@api private | [
"Find",
"the",
"attribute",
"."
] | 4b35938c62b72810c4117cda5d57123cb8a9a318 | https://github.com/bigpipe/parsifal/blob/4b35938c62b72810c4117cda5d57123cb8a9a318/index.js#L97-L101 |
53,071 | bigpipe/parsifal | index.js | get | function get(element) {
var name = element.nodeName.toLowerCase()
, value;
if (get.parser[element.type] && hasOwn.call(get.parser, element.type)) {
value = get.parser[element.type](element);
} else if (get.parser[name] && hasOwn.call(get.parser, name)) {
value = get.parser[name](element);
}
if (value !== undefined) return value;
value = element.value;
return 'string' === typeof value
? value.replace(/\r/g, '')
: value === null ? '' : value;
} | javascript | function get(element) {
var name = element.nodeName.toLowerCase()
, value;
if (get.parser[element.type] && hasOwn.call(get.parser, element.type)) {
value = get.parser[element.type](element);
} else if (get.parser[name] && hasOwn.call(get.parser, name)) {
value = get.parser[name](element);
}
if (value !== undefined) return value;
value = element.value;
return 'string' === typeof value
? value.replace(/\r/g, '')
: value === null ? '' : value;
} | [
"function",
"get",
"(",
"element",
")",
"{",
"var",
"name",
"=",
"element",
".",
"nodeName",
".",
"toLowerCase",
"(",
")",
",",
"value",
";",
"if",
"(",
"get",
".",
"parser",
"[",
"element",
".",
"type",
"]",
"&&",
"hasOwn",
".",
"call",
"(",
"get",
".",
"parser",
",",
"element",
".",
"type",
")",
")",
"{",
"value",
"=",
"get",
".",
"parser",
"[",
"element",
".",
"type",
"]",
"(",
"element",
")",
";",
"}",
"else",
"if",
"(",
"get",
".",
"parser",
"[",
"name",
"]",
"&&",
"hasOwn",
".",
"call",
"(",
"get",
".",
"parser",
",",
"name",
")",
")",
"{",
"value",
"=",
"get",
".",
"parser",
"[",
"name",
"]",
"(",
"element",
")",
";",
"}",
"if",
"(",
"value",
"!==",
"undefined",
")",
"return",
"value",
";",
"value",
"=",
"element",
".",
"value",
";",
"return",
"'string'",
"===",
"typeof",
"value",
"?",
"value",
".",
"replace",
"(",
"/",
"\\r",
"/",
"g",
",",
"''",
")",
":",
"value",
"===",
"null",
"?",
"''",
":",
"value",
";",
"}"
] | Get the value from a given element.
@param {Element} element The HTML element we need to extract the value from.
@returns {Mixed} The value of the element.
@api public | [
"Get",
"the",
"value",
"from",
"a",
"given",
"element",
"."
] | 4b35938c62b72810c4117cda5d57123cb8a9a318 | https://github.com/bigpipe/parsifal/blob/4b35938c62b72810c4117cda5d57123cb8a9a318/index.js#L110-L127 |
53,072 | redisjs/jsr-server | lib/command/server/monitor.js | execute | function execute(req, res) {
req.conn.monitor(this);
res.send(null, Constants.OK);
} | javascript | function execute(req, res) {
req.conn.monitor(this);
res.send(null, Constants.OK);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"req",
".",
"conn",
".",
"monitor",
"(",
"this",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"Constants",
".",
"OK",
")",
";",
"}"
] | Respond to the MONITOR command. | [
"Respond",
"to",
"the",
"MONITOR",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/server/monitor.js#L17-L20 |
53,073 | chanoch/simple-react-router | src/route/RouteConfiguration.js | routeMatcher | function routeMatcher(keys) {
return match => {
const parseParams = paramsParser(keys);
if(match) {
const params = parseParams(match);
return {
match,
keys,
params,
}
}
}
} | javascript | function routeMatcher(keys) {
return match => {
const parseParams = paramsParser(keys);
if(match) {
const params = parseParams(match);
return {
match,
keys,
params,
}
}
}
} | [
"function",
"routeMatcher",
"(",
"keys",
")",
"{",
"return",
"match",
"=>",
"{",
"const",
"parseParams",
"=",
"paramsParser",
"(",
"keys",
")",
";",
"if",
"(",
"match",
")",
"{",
"const",
"params",
"=",
"parseParams",
"(",
"match",
")",
";",
"return",
"{",
"match",
",",
"keys",
",",
"params",
",",
"}",
"}",
"}",
"}"
] | A route match instance which parses for URL params based on the specific location
passed into it.
@param {RegExpExecArray} pathMatch - an array of tokens based on the regexp execution
@param {*} keys - the list of parameter keys (:param) to extract from the URI | [
"A",
"route",
"match",
"instance",
"which",
"parses",
"for",
"URL",
"params",
"based",
"on",
"the",
"specific",
"location",
"passed",
"into",
"it",
"."
] | 3c71feeeb039111f33c934257732e2ea6ddde9ff | https://github.com/chanoch/simple-react-router/blob/3c71feeeb039111f33c934257732e2ea6ddde9ff/src/route/RouteConfiguration.js#L35-L47 |
53,074 | cafjs/caf_iot | lib/plug_iot_queue.js | function(msg, code, errorStr, cb1) {
return function(error, data) {
if (error) {
error = json_rpc.newSysError(msg, code, errorStr,
error);
}
cb1(error, data);
};
} | javascript | function(msg, code, errorStr, cb1) {
return function(error, data) {
if (error) {
error = json_rpc.newSysError(msg, code, errorStr,
error);
}
cb1(error, data);
};
} | [
"function",
"(",
"msg",
",",
"code",
",",
"errorStr",
",",
"cb1",
")",
"{",
"return",
"function",
"(",
"error",
",",
"data",
")",
"{",
"if",
"(",
"error",
")",
"{",
"error",
"=",
"json_rpc",
".",
"newSysError",
"(",
"msg",
",",
"code",
",",
"errorStr",
",",
"error",
")",
";",
"}",
"cb1",
"(",
"error",
",",
"data",
")",
";",
"}",
";",
"}"
] | Wraps error into a SystemError | [
"Wraps",
"error",
"into",
"a",
"SystemError"
] | 12e4042c354d966be2736cb7e00d0fae64875788 | https://github.com/cafjs/caf_iot/blob/12e4042c354d966be2736cb7e00d0fae64875788/lib/plug_iot_queue.js#L50-L58 |
|
53,075 | vkiding/judpack-lib | src/plugman/platforms/android.js | function(project_dir) {
var mDoc = xml_helpers.parseElementtreeSync(path.join(project_dir, 'AndroidManifest.xml'));
return mDoc._root.attrib['package'];
} | javascript | function(project_dir) {
var mDoc = xml_helpers.parseElementtreeSync(path.join(project_dir, 'AndroidManifest.xml'));
return mDoc._root.attrib['package'];
} | [
"function",
"(",
"project_dir",
")",
"{",
"var",
"mDoc",
"=",
"xml_helpers",
".",
"parseElementtreeSync",
"(",
"path",
".",
"join",
"(",
"project_dir",
",",
"'AndroidManifest.xml'",
")",
")",
";",
"return",
"mDoc",
".",
"_root",
".",
"attrib",
"[",
"'package'",
"]",
";",
"}"
] | reads the package name out of the Android Manifest file @param string project_dir the absolute path to the directory containing the project @return string the name of the package | [
"reads",
"the",
"package",
"name",
"out",
"of",
"the",
"Android",
"Manifest",
"file"
] | 8657cecfec68221109279106adca8dbc81f430f4 | https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/plugman/platforms/android.js#L61-L65 |
|
53,076 | origin1tech/chek | dist/modules/function.js | tryWrap | function tryWrap(fn) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return function (def) {
try {
return fn.apply(void 0, args);
}
catch (ex) {
if (is_1.isFunction(def))
return def(ex);
return to_1.toDefault(def);
}
};
} | javascript | function tryWrap(fn) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
return function (def) {
try {
return fn.apply(void 0, args);
}
catch (ex) {
if (is_1.isFunction(def))
return def(ex);
return to_1.toDefault(def);
}
};
} | [
"function",
"tryWrap",
"(",
"fn",
")",
"{",
"var",
"args",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"_i",
"=",
"1",
";",
"_i",
"<",
"arguments",
".",
"length",
";",
"_i",
"++",
")",
"{",
"args",
"[",
"_i",
"-",
"1",
"]",
"=",
"arguments",
"[",
"_i",
"]",
";",
"}",
"return",
"function",
"(",
"def",
")",
"{",
"try",
"{",
"return",
"fn",
".",
"apply",
"(",
"void",
"0",
",",
"args",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"if",
"(",
"is_1",
".",
"isFunction",
"(",
"def",
")",
")",
"return",
"def",
"(",
"ex",
")",
";",
"return",
"to_1",
".",
"toDefault",
"(",
"def",
")",
";",
"}",
"}",
";",
"}"
] | Try Wrap
Generic helper for calling try catch on a method.
If a default method is provided it will return in on error
otherwise it will return null.
@example
function func(val: any) { return isString(val); }
const result = tryWrap(func)();
With params
tryWrap(JSON.stringify, { name: 'Adele', age: 30 }, null, 2)()
With default
tryWrap(Number, '30')(35);
Where '35' is the default value on error.
@param fn the parse method to be called in try/parse block.
@param args arguments to pass to above method. | [
"Try",
"Wrap",
"Generic",
"helper",
"for",
"calling",
"try",
"catch",
"on",
"a",
"method",
".",
"If",
"a",
"default",
"method",
"is",
"provided",
"it",
"will",
"return",
"in",
"on",
"error",
"otherwise",
"it",
"will",
"return",
"null",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/function.js#L46-L61 |
53,077 | origin1tech/chek | dist/modules/function.js | tryRequire | function tryRequire(name, def, isRoot) {
function _require() {
if (!is_1.isNode())
/* istanbul ignore next */
return to_1.toDefault(null, def);
if (isRoot)
return require.main.require(name);
return require(name);
}
return tryWrap(_require)(def);
} | javascript | function tryRequire(name, def, isRoot) {
function _require() {
if (!is_1.isNode())
/* istanbul ignore next */
return to_1.toDefault(null, def);
if (isRoot)
return require.main.require(name);
return require(name);
}
return tryWrap(_require)(def);
} | [
"function",
"tryRequire",
"(",
"name",
",",
"def",
",",
"isRoot",
")",
"{",
"function",
"_require",
"(",
")",
"{",
"if",
"(",
"!",
"is_1",
".",
"isNode",
"(",
")",
")",
"/* istanbul ignore next */",
"return",
"to_1",
".",
"toDefault",
"(",
"null",
",",
"def",
")",
";",
"if",
"(",
"isRoot",
")",
"return",
"require",
".",
"main",
".",
"require",
"(",
"name",
")",
";",
"return",
"require",
"(",
"name",
")",
";",
"}",
"return",
"tryWrap",
"(",
"_require",
")",
"(",
"def",
")",
";",
"}"
] | Try Require
Tries to require a module returns null
if cannot require or empty object.
@param name the name of module to try and require.
@param def optional default value on null.
@param isRoot used internally by tryRootRequire to require root modules. | [
"Try",
"Require",
"Tries",
"to",
"require",
"a",
"module",
"returns",
"null",
"if",
"cannot",
"require",
"or",
"empty",
"object",
"."
] | 6bc3ab0ac36126cc7918a244a606009749897b2e | https://github.com/origin1tech/chek/blob/6bc3ab0ac36126cc7918a244a606009749897b2e/dist/modules/function.js#L72-L82 |
53,078 | gethuman/pancakes-angular | lib/ngapp/state.loader.js | getPascalCase | function getPascalCase(val) {
var parts = val.split('.');
var newVal = '';
for (var i = 0; i < parts.length; i++) {
newVal += parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1);
}
return newVal;
} | javascript | function getPascalCase(val) {
var parts = val.split('.');
var newVal = '';
for (var i = 0; i < parts.length; i++) {
newVal += parts[i].substring(0, 1).toUpperCase() + parts[i].substring(1);
}
return newVal;
} | [
"function",
"getPascalCase",
"(",
"val",
")",
"{",
"var",
"parts",
"=",
"val",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"newVal",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"parts",
".",
"length",
";",
"i",
"++",
")",
"{",
"newVal",
"+=",
"parts",
"[",
"i",
"]",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toUpperCase",
"(",
")",
"+",
"parts",
"[",
"i",
"]",
".",
"substring",
"(",
"1",
")",
";",
"}",
"return",
"newVal",
";",
"}"
] | Helper function to get pascal case of a route name
@param val
@returns {string} | [
"Helper",
"function",
"to",
"get",
"pascal",
"case",
"of",
"a",
"route",
"name"
] | 9589b7ba09619843e271293088005c62ed23f355 | https://github.com/gethuman/pancakes-angular/blob/9589b7ba09619843e271293088005c62ed23f355/lib/ngapp/state.loader.js#L17-L26 |
53,079 | palantus/mscp-browserlibs | www/js/jquery.longpress.js | mouseup_callback | function mouseup_callback(e) {
var press_time = new Date().getTime() - mouse_down_time;
if (press_time < duration) {
// cancel the timeout
clearTimeout(timeout);
// call the shortCallback if provided
if (typeof shortCallback === "function") {
shortCallback.call($(this), e);
} else if (typeof shortCallback === "undefined") {
;
} else {
$.error('Optional callback for short press should be a function.');
}
}
} | javascript | function mouseup_callback(e) {
var press_time = new Date().getTime() - mouse_down_time;
if (press_time < duration) {
// cancel the timeout
clearTimeout(timeout);
// call the shortCallback if provided
if (typeof shortCallback === "function") {
shortCallback.call($(this), e);
} else if (typeof shortCallback === "undefined") {
;
} else {
$.error('Optional callback for short press should be a function.');
}
}
} | [
"function",
"mouseup_callback",
"(",
"e",
")",
"{",
"var",
"press_time",
"=",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
"-",
"mouse_down_time",
";",
"if",
"(",
"press_time",
"<",
"duration",
")",
"{",
"// cancel the timeout",
"clearTimeout",
"(",
"timeout",
")",
";",
"// call the shortCallback if provided",
"if",
"(",
"typeof",
"shortCallback",
"===",
"\"function\"",
")",
"{",
"shortCallback",
".",
"call",
"(",
"$",
"(",
"this",
")",
",",
"e",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"shortCallback",
"===",
"\"undefined\"",
")",
"{",
";",
"}",
"else",
"{",
"$",
".",
"error",
"(",
"'Optional callback for short press should be a function.'",
")",
";",
"}",
"}",
"}"
] | mouseup or touchend callback | [
"mouseup",
"or",
"touchend",
"callback"
] | d8344639697e137af767d04b5111120890579556 | https://github.com/palantus/mscp-browserlibs/blob/d8344639697e137af767d04b5111120890579556/www/js/jquery.longpress.js#L46-L61 |
53,080 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/treemap.src.js | function () {
var series = this,
points = series.points,
options,
level,
dataLabelsGroup = this.dataLabelsGroup,
dataLabels;
each(points, function (point) {
if (point.node.isVisible) {
level = series.levelMap[point.level];
if (!point.isLeaf || level) {
options = undefined;
// If not a leaf, then label should be disabled as default
if (!point.isLeaf) {
options = {enabled: false};
}
if (level) {
dataLabels = level.dataLabels;
if (dataLabels) {
options = merge(options, dataLabels);
series._hasPointLabels = true;
}
}
options = merge(options, point.options.dataLabels);
point.dlOptions = options;
} else {
delete point.dlOptions;
}
}
});
this.dataLabelsGroup = this.group;
Series.prototype.drawDataLabels.call(this);
this.dataLabelsGroup = dataLabelsGroup;
} | javascript | function () {
var series = this,
points = series.points,
options,
level,
dataLabelsGroup = this.dataLabelsGroup,
dataLabels;
each(points, function (point) {
if (point.node.isVisible) {
level = series.levelMap[point.level];
if (!point.isLeaf || level) {
options = undefined;
// If not a leaf, then label should be disabled as default
if (!point.isLeaf) {
options = {enabled: false};
}
if (level) {
dataLabels = level.dataLabels;
if (dataLabels) {
options = merge(options, dataLabels);
series._hasPointLabels = true;
}
}
options = merge(options, point.options.dataLabels);
point.dlOptions = options;
} else {
delete point.dlOptions;
}
}
});
this.dataLabelsGroup = this.group;
Series.prototype.drawDataLabels.call(this);
this.dataLabelsGroup = dataLabelsGroup;
} | [
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
",",
"points",
"=",
"series",
".",
"points",
",",
"options",
",",
"level",
",",
"dataLabelsGroup",
"=",
"this",
".",
"dataLabelsGroup",
",",
"dataLabels",
";",
"each",
"(",
"points",
",",
"function",
"(",
"point",
")",
"{",
"if",
"(",
"point",
".",
"node",
".",
"isVisible",
")",
"{",
"level",
"=",
"series",
".",
"levelMap",
"[",
"point",
".",
"level",
"]",
";",
"if",
"(",
"!",
"point",
".",
"isLeaf",
"||",
"level",
")",
"{",
"options",
"=",
"undefined",
";",
"// If not a leaf, then label should be disabled as default",
"if",
"(",
"!",
"point",
".",
"isLeaf",
")",
"{",
"options",
"=",
"{",
"enabled",
":",
"false",
"}",
";",
"}",
"if",
"(",
"level",
")",
"{",
"dataLabels",
"=",
"level",
".",
"dataLabels",
";",
"if",
"(",
"dataLabels",
")",
"{",
"options",
"=",
"merge",
"(",
"options",
",",
"dataLabels",
")",
";",
"series",
".",
"_hasPointLabels",
"=",
"true",
";",
"}",
"}",
"options",
"=",
"merge",
"(",
"options",
",",
"point",
".",
"options",
".",
"dataLabels",
")",
";",
"point",
".",
"dlOptions",
"=",
"options",
";",
"}",
"else",
"{",
"delete",
"point",
".",
"dlOptions",
";",
"}",
"}",
"}",
")",
";",
"this",
".",
"dataLabelsGroup",
"=",
"this",
".",
"group",
";",
"Series",
".",
"prototype",
".",
"drawDataLabels",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"dataLabelsGroup",
"=",
"dataLabelsGroup",
";",
"}"
] | Extend drawDataLabels with logic to handle the levels option | [
"Extend",
"drawDataLabels",
"with",
"logic",
"to",
"handle",
"the",
"levels",
"option"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/treemap.src.js#L567-L600 |
|
53,081 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/treemap.src.js | function () {
var series = this,
points = series.points,
seriesOptions = series.options,
attr,
hover,
level;
each(points, function (point) {
if (point.node.isVisible) {
level = series.levelMap[point.level];
attr = {
stroke: seriesOptions.borderColor,
'stroke-width': seriesOptions.borderWidth,
dashstyle: seriesOptions.borderDashStyle,
r: 0, // borderRadius gives wrong size relations and should always be disabled
fill: pick(point.color, series.color)
};
// Overwrite standard series options with level options
if (level) {
attr.stroke = level.borderColor || attr.stroke;
attr['stroke-width'] = level.borderWidth || attr['stroke-width'];
attr.dashstyle = level.borderDashStyle || attr.dashstyle;
}
// Merge with point attributes
attr.stroke = point.borderColor || attr.stroke;
attr['stroke-width'] = point.borderWidth || attr['stroke-width'];
attr.dashstyle = point.borderDashStyle || attr.dashstyle;
attr.zIndex = (1000 - (point.level * 2));
// Make a copy to prevent overwriting individual props
point.pointAttr = merge(point.pointAttr);
hover = point.pointAttr.hover;
hover.zIndex = 1001;
hover.fill = Color(attr.fill).brighten(seriesOptions.states.hover.brightness).get();
// If not a leaf, then remove fill
if (!point.isLeaf) {
if (pick(seriesOptions.interactByLeaf, !seriesOptions.allowDrillToNode)) {
attr.fill = 'none';
delete hover.fill;
} else {
// TODO: let users set the opacity
attr.fill = Color(attr.fill).setOpacity(0.15).get();
hover.fill = Color(hover.fill).setOpacity(0.75).get();
}
}
if (point.node.level <= series.nodeMap[series.rootNode].level) {
attr.fill = 'none';
attr.zIndex = 0;
delete hover.fill;
}
point.pointAttr[''] = H.extend(point.pointAttr[''], attr);
if (point.dataLabel) {
point.dataLabel.attr({ zIndex: (point.pointAttr[''].zIndex + 1) });
}
}
});
// Call standard drawPoints
seriesTypes.column.prototype.drawPoints.call(this);
each(points, function (point) {
if (point.graphic) {
point.graphic.attr(point.pointAttr['']);
}
});
// Set click events on points
if (seriesOptions.allowDrillToNode) {
series.drillTo();
}
} | javascript | function () {
var series = this,
points = series.points,
seriesOptions = series.options,
attr,
hover,
level;
each(points, function (point) {
if (point.node.isVisible) {
level = series.levelMap[point.level];
attr = {
stroke: seriesOptions.borderColor,
'stroke-width': seriesOptions.borderWidth,
dashstyle: seriesOptions.borderDashStyle,
r: 0, // borderRadius gives wrong size relations and should always be disabled
fill: pick(point.color, series.color)
};
// Overwrite standard series options with level options
if (level) {
attr.stroke = level.borderColor || attr.stroke;
attr['stroke-width'] = level.borderWidth || attr['stroke-width'];
attr.dashstyle = level.borderDashStyle || attr.dashstyle;
}
// Merge with point attributes
attr.stroke = point.borderColor || attr.stroke;
attr['stroke-width'] = point.borderWidth || attr['stroke-width'];
attr.dashstyle = point.borderDashStyle || attr.dashstyle;
attr.zIndex = (1000 - (point.level * 2));
// Make a copy to prevent overwriting individual props
point.pointAttr = merge(point.pointAttr);
hover = point.pointAttr.hover;
hover.zIndex = 1001;
hover.fill = Color(attr.fill).brighten(seriesOptions.states.hover.brightness).get();
// If not a leaf, then remove fill
if (!point.isLeaf) {
if (pick(seriesOptions.interactByLeaf, !seriesOptions.allowDrillToNode)) {
attr.fill = 'none';
delete hover.fill;
} else {
// TODO: let users set the opacity
attr.fill = Color(attr.fill).setOpacity(0.15).get();
hover.fill = Color(hover.fill).setOpacity(0.75).get();
}
}
if (point.node.level <= series.nodeMap[series.rootNode].level) {
attr.fill = 'none';
attr.zIndex = 0;
delete hover.fill;
}
point.pointAttr[''] = H.extend(point.pointAttr[''], attr);
if (point.dataLabel) {
point.dataLabel.attr({ zIndex: (point.pointAttr[''].zIndex + 1) });
}
}
});
// Call standard drawPoints
seriesTypes.column.prototype.drawPoints.call(this);
each(points, function (point) {
if (point.graphic) {
point.graphic.attr(point.pointAttr['']);
}
});
// Set click events on points
if (seriesOptions.allowDrillToNode) {
series.drillTo();
}
} | [
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
",",
"points",
"=",
"series",
".",
"points",
",",
"seriesOptions",
"=",
"series",
".",
"options",
",",
"attr",
",",
"hover",
",",
"level",
";",
"each",
"(",
"points",
",",
"function",
"(",
"point",
")",
"{",
"if",
"(",
"point",
".",
"node",
".",
"isVisible",
")",
"{",
"level",
"=",
"series",
".",
"levelMap",
"[",
"point",
".",
"level",
"]",
";",
"attr",
"=",
"{",
"stroke",
":",
"seriesOptions",
".",
"borderColor",
",",
"'stroke-width'",
":",
"seriesOptions",
".",
"borderWidth",
",",
"dashstyle",
":",
"seriesOptions",
".",
"borderDashStyle",
",",
"r",
":",
"0",
",",
"// borderRadius gives wrong size relations and should always be disabled",
"fill",
":",
"pick",
"(",
"point",
".",
"color",
",",
"series",
".",
"color",
")",
"}",
";",
"// Overwrite standard series options with level options\t\t\t",
"if",
"(",
"level",
")",
"{",
"attr",
".",
"stroke",
"=",
"level",
".",
"borderColor",
"||",
"attr",
".",
"stroke",
";",
"attr",
"[",
"'stroke-width'",
"]",
"=",
"level",
".",
"borderWidth",
"||",
"attr",
"[",
"'stroke-width'",
"]",
";",
"attr",
".",
"dashstyle",
"=",
"level",
".",
"borderDashStyle",
"||",
"attr",
".",
"dashstyle",
";",
"}",
"// Merge with point attributes",
"attr",
".",
"stroke",
"=",
"point",
".",
"borderColor",
"||",
"attr",
".",
"stroke",
";",
"attr",
"[",
"'stroke-width'",
"]",
"=",
"point",
".",
"borderWidth",
"||",
"attr",
"[",
"'stroke-width'",
"]",
";",
"attr",
".",
"dashstyle",
"=",
"point",
".",
"borderDashStyle",
"||",
"attr",
".",
"dashstyle",
";",
"attr",
".",
"zIndex",
"=",
"(",
"1000",
"-",
"(",
"point",
".",
"level",
"*",
"2",
")",
")",
";",
"// Make a copy to prevent overwriting individual props",
"point",
".",
"pointAttr",
"=",
"merge",
"(",
"point",
".",
"pointAttr",
")",
";",
"hover",
"=",
"point",
".",
"pointAttr",
".",
"hover",
";",
"hover",
".",
"zIndex",
"=",
"1001",
";",
"hover",
".",
"fill",
"=",
"Color",
"(",
"attr",
".",
"fill",
")",
".",
"brighten",
"(",
"seriesOptions",
".",
"states",
".",
"hover",
".",
"brightness",
")",
".",
"get",
"(",
")",
";",
"// If not a leaf, then remove fill",
"if",
"(",
"!",
"point",
".",
"isLeaf",
")",
"{",
"if",
"(",
"pick",
"(",
"seriesOptions",
".",
"interactByLeaf",
",",
"!",
"seriesOptions",
".",
"allowDrillToNode",
")",
")",
"{",
"attr",
".",
"fill",
"=",
"'none'",
";",
"delete",
"hover",
".",
"fill",
";",
"}",
"else",
"{",
"// TODO: let users set the opacity",
"attr",
".",
"fill",
"=",
"Color",
"(",
"attr",
".",
"fill",
")",
".",
"setOpacity",
"(",
"0.15",
")",
".",
"get",
"(",
")",
";",
"hover",
".",
"fill",
"=",
"Color",
"(",
"hover",
".",
"fill",
")",
".",
"setOpacity",
"(",
"0.75",
")",
".",
"get",
"(",
")",
";",
"}",
"}",
"if",
"(",
"point",
".",
"node",
".",
"level",
"<=",
"series",
".",
"nodeMap",
"[",
"series",
".",
"rootNode",
"]",
".",
"level",
")",
"{",
"attr",
".",
"fill",
"=",
"'none'",
";",
"attr",
".",
"zIndex",
"=",
"0",
";",
"delete",
"hover",
".",
"fill",
";",
"}",
"point",
".",
"pointAttr",
"[",
"''",
"]",
"=",
"H",
".",
"extend",
"(",
"point",
".",
"pointAttr",
"[",
"''",
"]",
",",
"attr",
")",
";",
"if",
"(",
"point",
".",
"dataLabel",
")",
"{",
"point",
".",
"dataLabel",
".",
"attr",
"(",
"{",
"zIndex",
":",
"(",
"point",
".",
"pointAttr",
"[",
"''",
"]",
".",
"zIndex",
"+",
"1",
")",
"}",
")",
";",
"}",
"}",
"}",
")",
";",
"// Call standard drawPoints",
"seriesTypes",
".",
"column",
".",
"prototype",
".",
"drawPoints",
".",
"call",
"(",
"this",
")",
";",
"each",
"(",
"points",
",",
"function",
"(",
"point",
")",
"{",
"if",
"(",
"point",
".",
"graphic",
")",
"{",
"point",
".",
"graphic",
".",
"attr",
"(",
"point",
".",
"pointAttr",
"[",
"''",
"]",
")",
";",
"}",
"}",
")",
";",
"// Set click events on points ",
"if",
"(",
"seriesOptions",
".",
"allowDrillToNode",
")",
"{",
"series",
".",
"drillTo",
"(",
")",
";",
"}",
"}"
] | Extending ColumnSeries drawPoints | [
"Extending",
"ColumnSeries",
"drawPoints"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/treemap.src.js#L605-L674 |
|
53,082 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/treemap.src.js | function () {
var series = this,
points = series.points;
each(points, function (point) {
var drillId,
drillName;
if (point.node.isVisible) {
H.removeEvent(point, 'click');
if (point.graphic) {
point.graphic.css({ cursor: 'default' });
}
// Get the drill to id
if (series.options.interactByLeaf) {
drillId = series.drillToByLeaf(point);
} else {
drillId = series.drillToByGroup(point);
}
// If a drill id is returned, add click event and cursor.
if (drillId) {
drillName = series.nodeMap[series.rootNode].name || series.rootNode;
if (point.graphic) {
point.graphic.css({ cursor: 'pointer' });
}
H.addEvent(point, 'click', function () {
point.setState(''); // Remove hover
series.drillToNode(drillId);
series.showDrillUpButton(drillName);
});
}
}
});
} | javascript | function () {
var series = this,
points = series.points;
each(points, function (point) {
var drillId,
drillName;
if (point.node.isVisible) {
H.removeEvent(point, 'click');
if (point.graphic) {
point.graphic.css({ cursor: 'default' });
}
// Get the drill to id
if (series.options.interactByLeaf) {
drillId = series.drillToByLeaf(point);
} else {
drillId = series.drillToByGroup(point);
}
// If a drill id is returned, add click event and cursor.
if (drillId) {
drillName = series.nodeMap[series.rootNode].name || series.rootNode;
if (point.graphic) {
point.graphic.css({ cursor: 'pointer' });
}
H.addEvent(point, 'click', function () {
point.setState(''); // Remove hover
series.drillToNode(drillId);
series.showDrillUpButton(drillName);
});
}
}
});
} | [
"function",
"(",
")",
"{",
"var",
"series",
"=",
"this",
",",
"points",
"=",
"series",
".",
"points",
";",
"each",
"(",
"points",
",",
"function",
"(",
"point",
")",
"{",
"var",
"drillId",
",",
"drillName",
";",
"if",
"(",
"point",
".",
"node",
".",
"isVisible",
")",
"{",
"H",
".",
"removeEvent",
"(",
"point",
",",
"'click'",
")",
";",
"if",
"(",
"point",
".",
"graphic",
")",
"{",
"point",
".",
"graphic",
".",
"css",
"(",
"{",
"cursor",
":",
"'default'",
"}",
")",
";",
"}",
"// Get the drill to id",
"if",
"(",
"series",
".",
"options",
".",
"interactByLeaf",
")",
"{",
"drillId",
"=",
"series",
".",
"drillToByLeaf",
"(",
"point",
")",
";",
"}",
"else",
"{",
"drillId",
"=",
"series",
".",
"drillToByGroup",
"(",
"point",
")",
";",
"}",
"// If a drill id is returned, add click event and cursor. ",
"if",
"(",
"drillId",
")",
"{",
"drillName",
"=",
"series",
".",
"nodeMap",
"[",
"series",
".",
"rootNode",
"]",
".",
"name",
"||",
"series",
".",
"rootNode",
";",
"if",
"(",
"point",
".",
"graphic",
")",
"{",
"point",
".",
"graphic",
".",
"css",
"(",
"{",
"cursor",
":",
"'pointer'",
"}",
")",
";",
"}",
"H",
".",
"addEvent",
"(",
"point",
",",
"'click'",
",",
"function",
"(",
")",
"{",
"point",
".",
"setState",
"(",
"''",
")",
";",
"// Remove hover",
"series",
".",
"drillToNode",
"(",
"drillId",
")",
";",
"series",
".",
"showDrillUpButton",
"(",
"drillName",
")",
";",
"}",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Add drilling on the suitable points | [
"Add",
"drilling",
"on",
"the",
"suitable",
"points"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/treemap.src.js#L678-L711 |
|
53,083 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/treemap.src.js | function (point) {
var series = this,
drillId = false;
if ((point.node.level - series.nodeMap[series.rootNode].level) === 1 && !point.isLeaf) {
drillId = point.id;
}
return drillId;
} | javascript | function (point) {
var series = this,
drillId = false;
if ((point.node.level - series.nodeMap[series.rootNode].level) === 1 && !point.isLeaf) {
drillId = point.id;
}
return drillId;
} | [
"function",
"(",
"point",
")",
"{",
"var",
"series",
"=",
"this",
",",
"drillId",
"=",
"false",
";",
"if",
"(",
"(",
"point",
".",
"node",
".",
"level",
"-",
"series",
".",
"nodeMap",
"[",
"series",
".",
"rootNode",
"]",
".",
"level",
")",
"===",
"1",
"&&",
"!",
"point",
".",
"isLeaf",
")",
"{",
"drillId",
"=",
"point",
".",
"id",
";",
"}",
"return",
"drillId",
";",
"}"
] | Finds the drill id for a parent node.
Returns false if point should not have a click event
@param {Object} point
@return {string || boolean} Drill to id or false when point should not have a click event | [
"Finds",
"the",
"drill",
"id",
"for",
"a",
"parent",
"node",
".",
"Returns",
"false",
"if",
"point",
"should",
"not",
"have",
"a",
"click",
"event"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/treemap.src.js#L718-L725 |
|
53,084 | MakerCollider/node-red-contrib-smartnode-hook | html/scripts/highchart/modules/treemap.src.js | function (point) {
var series = this,
drillId = false,
nodeParent;
if ((point.node.parent !== series.rootNode) && (point.isLeaf)) {
nodeParent = point.node;
while (!drillId) {
nodeParent = series.nodeMap[nodeParent.parent];
if (nodeParent.parent === series.rootNode) {
drillId = nodeParent.id;
}
}
}
return drillId;
} | javascript | function (point) {
var series = this,
drillId = false,
nodeParent;
if ((point.node.parent !== series.rootNode) && (point.isLeaf)) {
nodeParent = point.node;
while (!drillId) {
nodeParent = series.nodeMap[nodeParent.parent];
if (nodeParent.parent === series.rootNode) {
drillId = nodeParent.id;
}
}
}
return drillId;
} | [
"function",
"(",
"point",
")",
"{",
"var",
"series",
"=",
"this",
",",
"drillId",
"=",
"false",
",",
"nodeParent",
";",
"if",
"(",
"(",
"point",
".",
"node",
".",
"parent",
"!==",
"series",
".",
"rootNode",
")",
"&&",
"(",
"point",
".",
"isLeaf",
")",
")",
"{",
"nodeParent",
"=",
"point",
".",
"node",
";",
"while",
"(",
"!",
"drillId",
")",
"{",
"nodeParent",
"=",
"series",
".",
"nodeMap",
"[",
"nodeParent",
".",
"parent",
"]",
";",
"if",
"(",
"nodeParent",
".",
"parent",
"===",
"series",
".",
"rootNode",
")",
"{",
"drillId",
"=",
"nodeParent",
".",
"id",
";",
"}",
"}",
"}",
"return",
"drillId",
";",
"}"
] | Finds the drill id for a leaf node.
Returns false if point should not have a click event
@param {Object} point
@return {string || boolean} Drill to id or false when point should not have a click event | [
"Finds",
"the",
"drill",
"id",
"for",
"a",
"leaf",
"node",
".",
"Returns",
"false",
"if",
"point",
"should",
"not",
"have",
"a",
"click",
"event"
] | 245c267e832968bad880ca009929043e82c7bc25 | https://github.com/MakerCollider/node-red-contrib-smartnode-hook/blob/245c267e832968bad880ca009929043e82c7bc25/html/scripts/highchart/modules/treemap.src.js#L732-L746 |
|
53,085 | wunderbyte/grunt-spiritual-edbml | tasks/things/formatter.js | simplified | function simplified(js) {
var is = false;
var go = false;
var here = 'out.html += '; // hardcoced
var gone = ' '; // hardcoded to equal length
var fixes = [];
var lines = js.split('\n').map(function(line, index) {
go = line.trim().startsWith(here);
if (is && go) {
line = line.replace(here, gone);
fixes.push(index - 1);
}
is = go;
return line;
});
fixes.forEach(function(index) {
if (index > -1) {
var line = lines[index];
lines[index] = line.replace(/;$/, ' +');
}
});
return lines.join('\n');
} | javascript | function simplified(js) {
var is = false;
var go = false;
var here = 'out.html += '; // hardcoced
var gone = ' '; // hardcoded to equal length
var fixes = [];
var lines = js.split('\n').map(function(line, index) {
go = line.trim().startsWith(here);
if (is && go) {
line = line.replace(here, gone);
fixes.push(index - 1);
}
is = go;
return line;
});
fixes.forEach(function(index) {
if (index > -1) {
var line = lines[index];
lines[index] = line.replace(/;$/, ' +');
}
});
return lines.join('\n');
} | [
"function",
"simplified",
"(",
"js",
")",
"{",
"var",
"is",
"=",
"false",
";",
"var",
"go",
"=",
"false",
";",
"var",
"here",
"=",
"'out.html += '",
";",
"// hardcoced",
"var",
"gone",
"=",
"' '",
";",
"// hardcoded to equal length",
"var",
"fixes",
"=",
"[",
"]",
";",
"var",
"lines",
"=",
"js",
".",
"split",
"(",
"'\\n'",
")",
".",
"map",
"(",
"function",
"(",
"line",
",",
"index",
")",
"{",
"go",
"=",
"line",
".",
"trim",
"(",
")",
".",
"startsWith",
"(",
"here",
")",
";",
"if",
"(",
"is",
"&&",
"go",
")",
"{",
"line",
"=",
"line",
".",
"replace",
"(",
"here",
",",
"gone",
")",
";",
"fixes",
".",
"push",
"(",
"index",
"-",
"1",
")",
";",
"}",
"is",
"=",
"go",
";",
"return",
"line",
";",
"}",
")",
";",
"fixes",
".",
"forEach",
"(",
"function",
"(",
"index",
")",
"{",
"if",
"(",
"index",
">",
"-",
"1",
")",
"{",
"var",
"line",
"=",
"lines",
"[",
"index",
"]",
";",
"lines",
"[",
"index",
"]",
"=",
"line",
".",
"replace",
"(",
"/",
";$",
"/",
",",
"' +'",
")",
";",
"}",
"}",
")",
";",
"return",
"lines",
".",
"join",
"(",
"'\\n'",
")",
";",
"}"
] | Substiture repeated lines of `out.html +=` with simple
`+` concatenation. Watch out for hardcoded strings here.
@param {string} js
@returns {string} | [
"Substiture",
"repeated",
"lines",
"of",
"out",
".",
"html",
"+",
"=",
"with",
"simple",
"+",
"concatenation",
".",
"Watch",
"out",
"for",
"hardcoded",
"strings",
"here",
"."
] | 2ba0aa8042eceee917f1ee48c7881345df3bce46 | https://github.com/wunderbyte/grunt-spiritual-edbml/blob/2ba0aa8042eceee917f1ee48c7881345df3bce46/tasks/things/formatter.js#L76-L98 |
53,086 | ashleydavis/routey | route_init.js | function (params) {
//
// Close the route once it has been handled.
//
var closeRoute = function () {
that._closeRoute(dir, req, res, params);
};
var async = new Async(closeRoute);
routeConfig.handler(req, res, params, async);
if (!async.started()) {
// No async operation was started.
// Close the route immediately.
closeRoute();
}
} | javascript | function (params) {
//
// Close the route once it has been handled.
//
var closeRoute = function () {
that._closeRoute(dir, req, res, params);
};
var async = new Async(closeRoute);
routeConfig.handler(req, res, params, async);
if (!async.started()) {
// No async operation was started.
// Close the route immediately.
closeRoute();
}
} | [
"function",
"(",
"params",
")",
"{",
"// ",
"// Close the route once it has been handled.",
"//",
"var",
"closeRoute",
"=",
"function",
"(",
")",
"{",
"that",
".",
"_closeRoute",
"(",
"dir",
",",
"req",
",",
"res",
",",
"params",
")",
";",
"}",
";",
"var",
"async",
"=",
"new",
"Async",
"(",
"closeRoute",
")",
";",
"routeConfig",
".",
"handler",
"(",
"req",
",",
"res",
",",
"params",
",",
"async",
")",
";",
"if",
"(",
"!",
"async",
".",
"started",
"(",
")",
")",
"{",
"// No async operation was started.",
"// Close the route immediately.",
"closeRoute",
"(",
")",
";",
"}",
"}"
] | When the route has been opened, invoke the route handler. | [
"When",
"the",
"route",
"has",
"been",
"opened",
"invoke",
"the",
"route",
"handler",
"."
] | dd5e797603f6f0b584d6712165e9b73c7d8efc78 | https://github.com/ashleydavis/routey/blob/dd5e797603f6f0b584d6712165e9b73c7d8efc78/route_init.js#L158-L174 |
|
53,087 | semantic-math/math-traverse | lib/replace.js | replace | function replace(node, {enter, leave}) {
let rep = (enter && enter(node)) || node
switch (rep.type) {
// regular non-leaf nodes
case 'Apply':
for (let i = 0; i < rep.args.length; i++) {
const arg = rep.args[i]
rep.args[i] = replace(arg, {enter, leave})
}
break
// Skip leaf nodes because they're handled by the enter/leave calls at
// the start/end of replace.
case 'Identifier':
case 'Number':
case 'Ellipsis':
break
// irregular non-leaf nodes
case 'Parentheses':
rep.body = replace(rep.body, {enter, leave})
break
case 'List':
case 'Sequence':
for (let i = 0; i < rep.items.length; i++) {
const item = rep.items[i]
rep.items[i] = replace(item, {enter, leave})
}
break
case 'System':
for (let i = 0; i < rep.relations.length; i++) {
const rel = rep.relations[i]
rep.relations[i] = replace(rel, {enter, leave})
}
break
case 'Placeholder':
// TODO(kevinb) handle children of the placeholder
// e.g. we there might #a_0 could match x_0, y_0, z_0, etc.
break
default:
throw new Error('unrecognized node')
}
return (leave && leave(rep)) || rep
} | javascript | function replace(node, {enter, leave}) {
let rep = (enter && enter(node)) || node
switch (rep.type) {
// regular non-leaf nodes
case 'Apply':
for (let i = 0; i < rep.args.length; i++) {
const arg = rep.args[i]
rep.args[i] = replace(arg, {enter, leave})
}
break
// Skip leaf nodes because they're handled by the enter/leave calls at
// the start/end of replace.
case 'Identifier':
case 'Number':
case 'Ellipsis':
break
// irregular non-leaf nodes
case 'Parentheses':
rep.body = replace(rep.body, {enter, leave})
break
case 'List':
case 'Sequence':
for (let i = 0; i < rep.items.length; i++) {
const item = rep.items[i]
rep.items[i] = replace(item, {enter, leave})
}
break
case 'System':
for (let i = 0; i < rep.relations.length; i++) {
const rel = rep.relations[i]
rep.relations[i] = replace(rel, {enter, leave})
}
break
case 'Placeholder':
// TODO(kevinb) handle children of the placeholder
// e.g. we there might #a_0 could match x_0, y_0, z_0, etc.
break
default:
throw new Error('unrecognized node')
}
return (leave && leave(rep)) || rep
} | [
"function",
"replace",
"(",
"node",
",",
"{",
"enter",
",",
"leave",
"}",
")",
"{",
"let",
"rep",
"=",
"(",
"enter",
"&&",
"enter",
"(",
"node",
")",
")",
"||",
"node",
"switch",
"(",
"rep",
".",
"type",
")",
"{",
"// regular non-leaf nodes",
"case",
"'Apply'",
":",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"rep",
".",
"args",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"arg",
"=",
"rep",
".",
"args",
"[",
"i",
"]",
"rep",
".",
"args",
"[",
"i",
"]",
"=",
"replace",
"(",
"arg",
",",
"{",
"enter",
",",
"leave",
"}",
")",
"}",
"break",
"// Skip leaf nodes because they're handled by the enter/leave calls at",
"// the start/end of replace.",
"case",
"'Identifier'",
":",
"case",
"'Number'",
":",
"case",
"'Ellipsis'",
":",
"break",
"// irregular non-leaf nodes",
"case",
"'Parentheses'",
":",
"rep",
".",
"body",
"=",
"replace",
"(",
"rep",
".",
"body",
",",
"{",
"enter",
",",
"leave",
"}",
")",
"break",
"case",
"'List'",
":",
"case",
"'Sequence'",
":",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"rep",
".",
"items",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"item",
"=",
"rep",
".",
"items",
"[",
"i",
"]",
"rep",
".",
"items",
"[",
"i",
"]",
"=",
"replace",
"(",
"item",
",",
"{",
"enter",
",",
"leave",
"}",
")",
"}",
"break",
"case",
"'System'",
":",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"rep",
".",
"relations",
".",
"length",
";",
"i",
"++",
")",
"{",
"const",
"rel",
"=",
"rep",
".",
"relations",
"[",
"i",
"]",
"rep",
".",
"relations",
"[",
"i",
"]",
"=",
"replace",
"(",
"rel",
",",
"{",
"enter",
",",
"leave",
"}",
")",
"}",
"break",
"case",
"'Placeholder'",
":",
"// TODO(kevinb) handle children of the placeholder",
"// e.g. we there might #a_0 could match x_0, y_0, z_0, etc.",
"break",
"default",
":",
"throw",
"new",
"Error",
"(",
"'unrecognized node'",
")",
"}",
"return",
"(",
"leave",
"&&",
"leave",
"(",
"rep",
")",
")",
"||",
"rep",
"}"
] | replace - visit all nodes in the tree with the ability to replace them.
This function may modify the node passed in and/or any of its descendants.
If neither 'enter' nor 'leave' return a value, the node is unchanged.
If 'enter' returns a new node, the children of the new node will be traversed
instead of the old one. If both 'enter' and 'leave' return values, the
value returned by 'leave' is the node that will end up in the new AST. | [
"replace",
"-",
"visit",
"all",
"nodes",
"in",
"the",
"tree",
"with",
"the",
"ability",
"to",
"replace",
"them",
"."
] | 251430b4a984200fb1b3fd373fde2da50a78830c | https://github.com/semantic-math/math-traverse/blob/251430b4a984200fb1b3fd373fde2da50a78830c/lib/replace.js#L12-L61 |
53,088 | ottojs/otto-errors | lib/bad_request.error.js | ErrorBadRequest | function ErrorBadRequest (message) {
Error.call(this);
// Add Information
this.name = 'ErrorBadRequest';
this.type = 'client';
this.status = 400;
if (message) {
this.message = message;
}
} | javascript | function ErrorBadRequest (message) {
Error.call(this);
// Add Information
this.name = 'ErrorBadRequest';
this.type = 'client';
this.status = 400;
if (message) {
this.message = message;
}
} | [
"function",
"ErrorBadRequest",
"(",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"// Add Information",
"this",
".",
"name",
"=",
"'ErrorBadRequest'",
";",
"this",
".",
"type",
"=",
"'client'",
";",
"this",
".",
"status",
"=",
"400",
";",
"if",
"(",
"message",
")",
"{",
"this",
".",
"message",
"=",
"message",
";",
"}",
"}"
] | Error - ErrorBadRequest | [
"Error",
"-",
"ErrorBadRequest"
] | a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9 | https://github.com/ottojs/otto-errors/blob/a3c6d98fd5d35ce3c136ed7e1edd2f800af268d9/lib/bad_request.error.js#L8-L20 |
53,089 | Objectway/bower-rhodecode-resolver | index.js | function (source) {
packageUrl = source;
if (source && source.indexOf(bower.config.rhodecode.repo) != -1) {
return true;
}
return Q.nfcall(registryClient.lookup.bind(registryClient), source)
.then(function (entry) {
if (entry && entry.url && entry.url.indexOf(bower.config.rhodecode.repo) != -1) {
packageUrl = entry.url;
return true
}
return false;
});
} | javascript | function (source) {
packageUrl = source;
if (source && source.indexOf(bower.config.rhodecode.repo) != -1) {
return true;
}
return Q.nfcall(registryClient.lookup.bind(registryClient), source)
.then(function (entry) {
if (entry && entry.url && entry.url.indexOf(bower.config.rhodecode.repo) != -1) {
packageUrl = entry.url;
return true
}
return false;
});
} | [
"function",
"(",
"source",
")",
"{",
"packageUrl",
"=",
"source",
";",
"if",
"(",
"source",
"&&",
"source",
".",
"indexOf",
"(",
"bower",
".",
"config",
".",
"rhodecode",
".",
"repo",
")",
"!=",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"return",
"Q",
".",
"nfcall",
"(",
"registryClient",
".",
"lookup",
".",
"bind",
"(",
"registryClient",
")",
",",
"source",
")",
".",
"then",
"(",
"function",
"(",
"entry",
")",
"{",
"if",
"(",
"entry",
"&&",
"entry",
".",
"url",
"&&",
"entry",
".",
"url",
".",
"indexOf",
"(",
"bower",
".",
"config",
".",
"rhodecode",
".",
"repo",
")",
"!=",
"-",
"1",
")",
"{",
"packageUrl",
"=",
"entry",
".",
"url",
";",
"return",
"true",
"}",
"return",
"false",
";",
"}",
")",
";",
"}"
] | Match method tells whether resolver supports given source It can return either boolean or promise of boolean | [
"Match",
"method",
"tells",
"whether",
"resolver",
"supports",
"given",
"source",
"It",
"can",
"return",
"either",
"boolean",
"or",
"promise",
"of",
"boolean"
] | b5e563c7aecc2b45bf904785a714a110769109cb | https://github.com/Objectway/bower-rhodecode-resolver/blob/b5e563c7aecc2b45bf904785a714a110769109cb/index.js#L32-L50 |
|
53,090 | Objectway/bower-rhodecode-resolver | index.js | function (endpoint) {
var deferred = Q.defer(),
tmpDir = tmp.dirSync().name,
target = endpoint.target == '*' ? 'tip' : endpoint.target,
url = endpoint.source + '/archive/' + target + '.zip?auth_token=' + bower.config.rhodecode.token,
filePath = tmpDir + '/' + endpoint.name;
bower.logger.debug('rhodecode: repo url', url);
request.get(url)
.pipe(fs.createWriteStream(filePath))
.on('close', function () {
try {
var buffer = readChunk.sync(filePath, 0, 262),
fileType = FileType(buffer),
fileExt = (fileType ? fileType.ext : 'txt'),
newFilePath = filePath + '.' + fileExt;
fs.renameSync(filePath, newFilePath);
if (fileExt === 'zip') {
var zip = new AdmZip(newFilePath),
extractedDir;
zip.getEntries().forEach(function (zipEntry) {
zip.extractEntryTo(zipEntry.entryName, tmpDir, true, true);
if (typeof extractedDir == 'undefined') {
extractedDir = tmpDir + path.sep + zipEntry.entryName.replace(/(^[^\\\/]+).*/, '$1')
}
});
fs.unlink(newFilePath, function () {
deferred.resolve({
tempPath: extractedDir,
removeIgnores: true
});
});
} else {
deferred.reject("Invalid file, check on this link", url);
}
} catch (err) {
deferred.reject(err);
}
})
.on('error', function (err) {
deferred.reject(err);
});
return deferred.promise;
} | javascript | function (endpoint) {
var deferred = Q.defer(),
tmpDir = tmp.dirSync().name,
target = endpoint.target == '*' ? 'tip' : endpoint.target,
url = endpoint.source + '/archive/' + target + '.zip?auth_token=' + bower.config.rhodecode.token,
filePath = tmpDir + '/' + endpoint.name;
bower.logger.debug('rhodecode: repo url', url);
request.get(url)
.pipe(fs.createWriteStream(filePath))
.on('close', function () {
try {
var buffer = readChunk.sync(filePath, 0, 262),
fileType = FileType(buffer),
fileExt = (fileType ? fileType.ext : 'txt'),
newFilePath = filePath + '.' + fileExt;
fs.renameSync(filePath, newFilePath);
if (fileExt === 'zip') {
var zip = new AdmZip(newFilePath),
extractedDir;
zip.getEntries().forEach(function (zipEntry) {
zip.extractEntryTo(zipEntry.entryName, tmpDir, true, true);
if (typeof extractedDir == 'undefined') {
extractedDir = tmpDir + path.sep + zipEntry.entryName.replace(/(^[^\\\/]+).*/, '$1')
}
});
fs.unlink(newFilePath, function () {
deferred.resolve({
tempPath: extractedDir,
removeIgnores: true
});
});
} else {
deferred.reject("Invalid file, check on this link", url);
}
} catch (err) {
deferred.reject(err);
}
})
.on('error', function (err) {
deferred.reject(err);
});
return deferred.promise;
} | [
"function",
"(",
"endpoint",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
",",
"tmpDir",
"=",
"tmp",
".",
"dirSync",
"(",
")",
".",
"name",
",",
"target",
"=",
"endpoint",
".",
"target",
"==",
"'*'",
"?",
"'tip'",
":",
"endpoint",
".",
"target",
",",
"url",
"=",
"endpoint",
".",
"source",
"+",
"'/archive/'",
"+",
"target",
"+",
"'.zip?auth_token='",
"+",
"bower",
".",
"config",
".",
"rhodecode",
".",
"token",
",",
"filePath",
"=",
"tmpDir",
"+",
"'/'",
"+",
"endpoint",
".",
"name",
";",
"bower",
".",
"logger",
".",
"debug",
"(",
"'rhodecode: repo url'",
",",
"url",
")",
";",
"request",
".",
"get",
"(",
"url",
")",
".",
"pipe",
"(",
"fs",
".",
"createWriteStream",
"(",
"filePath",
")",
")",
".",
"on",
"(",
"'close'",
",",
"function",
"(",
")",
"{",
"try",
"{",
"var",
"buffer",
"=",
"readChunk",
".",
"sync",
"(",
"filePath",
",",
"0",
",",
"262",
")",
",",
"fileType",
"=",
"FileType",
"(",
"buffer",
")",
",",
"fileExt",
"=",
"(",
"fileType",
"?",
"fileType",
".",
"ext",
":",
"'txt'",
")",
",",
"newFilePath",
"=",
"filePath",
"+",
"'.'",
"+",
"fileExt",
";",
"fs",
".",
"renameSync",
"(",
"filePath",
",",
"newFilePath",
")",
";",
"if",
"(",
"fileExt",
"===",
"'zip'",
")",
"{",
"var",
"zip",
"=",
"new",
"AdmZip",
"(",
"newFilePath",
")",
",",
"extractedDir",
";",
"zip",
".",
"getEntries",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"zipEntry",
")",
"{",
"zip",
".",
"extractEntryTo",
"(",
"zipEntry",
".",
"entryName",
",",
"tmpDir",
",",
"true",
",",
"true",
")",
";",
"if",
"(",
"typeof",
"extractedDir",
"==",
"'undefined'",
")",
"{",
"extractedDir",
"=",
"tmpDir",
"+",
"path",
".",
"sep",
"+",
"zipEntry",
".",
"entryName",
".",
"replace",
"(",
"/",
"(^[^\\\\\\/]+).*",
"/",
",",
"'$1'",
")",
"}",
"}",
")",
";",
"fs",
".",
"unlink",
"(",
"newFilePath",
",",
"function",
"(",
")",
"{",
"deferred",
".",
"resolve",
"(",
"{",
"tempPath",
":",
"extractedDir",
",",
"removeIgnores",
":",
"true",
"}",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"deferred",
".",
"reject",
"(",
"\"Invalid file, check on this link\"",
",",
"url",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
"}",
")",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] | It downloads package and extracts it to temporary directory You can use npm's "tmp" package to tmp directories See the "Resolver API" section for details on this method | [
"It",
"downloads",
"package",
"and",
"extracts",
"it",
"to",
"temporary",
"directory",
"You",
"can",
"use",
"npm",
"s",
"tmp",
"package",
"to",
"tmp",
"directories",
"See",
"the",
"Resolver",
"API",
"section",
"for",
"details",
"on",
"this",
"method"
] | b5e563c7aecc2b45bf904785a714a110769109cb | https://github.com/Objectway/bower-rhodecode-resolver/blob/b5e563c7aecc2b45bf904785a714a110769109cb/index.js#L96-L150 |
|
53,091 | polo2ro/restitute | src/service.js | listItemsService | function listItemsService(app) {
apiService.call(this);
this.setApp(app);
var service = this;
/**
* Default function used to resolve a result set
*
* @param {Error} err mongoose error
* @param {Array} docs an array of mongoose documents or an array of objects
*/
this.mongOutcome = function(err, docs) {
if (service.handleMongoError(err))
{
service.outcome.success = true;
service.deferred.resolve(docs);
}
};
/**
* Resolve a mongoose query, paginated or not
* This method can be used by the service to resolve a mongoose query
* The paginate parameter is optional, if not provided, all documents will be resolved to the service promise.
* the function to use for pagination is the 2nd argument of the getResultPromise() method
* @see listItemsService.getResultPromise()
*
* @param {Query} find
* @param {function} [paginate] (controller optional function to paginate result)
* @param {function} [mongOutcome] optional function to customise resultset before resolving
*/
this.resolveQuery = function(find, paginate, mongOutcome) {
if (!mongOutcome) {
mongOutcome = this.mongOutcome;
}
find.exec(function(err, docs) {
if (!err && typeof paginate === 'function') {
return paginate(docs.length, find).exec(mongOutcome);
}
return mongOutcome(err, docs);
});
};
/**
* Services instances must implement
* this method to resolve or reject the service promise
* list items services have an additional parameter "paginate", this function will be given as parameter
* by the controller
*
* @see listItemsController.paginate()
*
* @param {Object} params
* @param {function} paginate
*
* @return {Promise}
*/
this.getResultPromise = function(params, paginate) {
console.log('Not implemented');
return this.deferred.promise;
};
} | javascript | function listItemsService(app) {
apiService.call(this);
this.setApp(app);
var service = this;
/**
* Default function used to resolve a result set
*
* @param {Error} err mongoose error
* @param {Array} docs an array of mongoose documents or an array of objects
*/
this.mongOutcome = function(err, docs) {
if (service.handleMongoError(err))
{
service.outcome.success = true;
service.deferred.resolve(docs);
}
};
/**
* Resolve a mongoose query, paginated or not
* This method can be used by the service to resolve a mongoose query
* The paginate parameter is optional, if not provided, all documents will be resolved to the service promise.
* the function to use for pagination is the 2nd argument of the getResultPromise() method
* @see listItemsService.getResultPromise()
*
* @param {Query} find
* @param {function} [paginate] (controller optional function to paginate result)
* @param {function} [mongOutcome] optional function to customise resultset before resolving
*/
this.resolveQuery = function(find, paginate, mongOutcome) {
if (!mongOutcome) {
mongOutcome = this.mongOutcome;
}
find.exec(function(err, docs) {
if (!err && typeof paginate === 'function') {
return paginate(docs.length, find).exec(mongOutcome);
}
return mongOutcome(err, docs);
});
};
/**
* Services instances must implement
* this method to resolve or reject the service promise
* list items services have an additional parameter "paginate", this function will be given as parameter
* by the controller
*
* @see listItemsController.paginate()
*
* @param {Object} params
* @param {function} paginate
*
* @return {Promise}
*/
this.getResultPromise = function(params, paginate) {
console.log('Not implemented');
return this.deferred.promise;
};
} | [
"function",
"listItemsService",
"(",
"app",
")",
"{",
"apiService",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"setApp",
"(",
"app",
")",
";",
"var",
"service",
"=",
"this",
";",
"/**\n * Default function used to resolve a result set\n *\n * @param {Error} err mongoose error\n * @param {Array} docs an array of mongoose documents or an array of objects\n */",
"this",
".",
"mongOutcome",
"=",
"function",
"(",
"err",
",",
"docs",
")",
"{",
"if",
"(",
"service",
".",
"handleMongoError",
"(",
"err",
")",
")",
"{",
"service",
".",
"outcome",
".",
"success",
"=",
"true",
";",
"service",
".",
"deferred",
".",
"resolve",
"(",
"docs",
")",
";",
"}",
"}",
";",
"/**\n * Resolve a mongoose query, paginated or not\n * This method can be used by the service to resolve a mongoose query\n * The paginate parameter is optional, if not provided, all documents will be resolved to the service promise.\n * the function to use for pagination is the 2nd argument of the getResultPromise() method\n * @see listItemsService.getResultPromise()\n *\n * @param {Query} find\n * @param {function} [paginate] (controller optional function to paginate result)\n * @param {function} [mongOutcome] optional function to customise resultset before resolving\n */",
"this",
".",
"resolveQuery",
"=",
"function",
"(",
"find",
",",
"paginate",
",",
"mongOutcome",
")",
"{",
"if",
"(",
"!",
"mongOutcome",
")",
"{",
"mongOutcome",
"=",
"this",
".",
"mongOutcome",
";",
"}",
"find",
".",
"exec",
"(",
"function",
"(",
"err",
",",
"docs",
")",
"{",
"if",
"(",
"!",
"err",
"&&",
"typeof",
"paginate",
"===",
"'function'",
")",
"{",
"return",
"paginate",
"(",
"docs",
".",
"length",
",",
"find",
")",
".",
"exec",
"(",
"mongOutcome",
")",
";",
"}",
"return",
"mongOutcome",
"(",
"err",
",",
"docs",
")",
";",
"}",
")",
";",
"}",
";",
"/**\n * Services instances must implement\n * this method to resolve or reject the service promise\n * list items services have an additional parameter \"paginate\", this function will be given as parameter\n * by the controller\n *\n * @see listItemsController.paginate()\n *\n * @param {Object} params\n * @param {function} paginate\n *\n * @return {Promise}\n */",
"this",
".",
"getResultPromise",
"=",
"function",
"(",
"params",
",",
"paginate",
")",
"{",
"console",
".",
"log",
"(",
"'Not implemented'",
")",
";",
"return",
"this",
".",
"deferred",
".",
"promise",
";",
"}",
";",
"}"
] | Service to get a list of items
output a resultset | [
"Service",
"to",
"get",
"a",
"list",
"of",
"items",
"output",
"a",
"resultset"
] | 532f10b01469f76b8a60f5be624ebf562ebfcf55 | https://github.com/polo2ro/restitute/blob/532f10b01469f76b8a60f5be624ebf562ebfcf55/src/service.js#L333-L400 |
53,092 | derdesign/protos | middleware/logger/transport-redis.js | initRedis | function initRedis(config, callback) {
var self = this;
protos.util.checkLocalPort(config.port, function(err) {
if (err) {
app.log("RedisTransport [%s:%s] %s", config.host, config.port, err.code);
} else {
// Set redis client
self.client = redis.createClient(config.port, config.host, self.options);
// Handle error event
self.client.on('error', function(err) {
callback.call(self, err);
});
// Authenticate if password provided
if (typeof config.password == 'string') {
self.client.auth(config.password, function(err, res) {
if (err) {
app.log("RedisTransport: [%s:%s] %s", config.host, config.port, err.code);
} else if (typeof config.db == 'number' && config.db !== 0) {
self.client.select(config.db, function(err, res) {
if (err) callback.call(self, err);
else callback.call(self, null);
});
} else {
callback.call(self, null);
}
});
} else if (typeof config.db == 'number' && config.db !== 0) {
self.client.select(config.db, function(err, res) {
callback.call(self, err);
});
} else {
callback.call(self, null);
}
}
});
} | javascript | function initRedis(config, callback) {
var self = this;
protos.util.checkLocalPort(config.port, function(err) {
if (err) {
app.log("RedisTransport [%s:%s] %s", config.host, config.port, err.code);
} else {
// Set redis client
self.client = redis.createClient(config.port, config.host, self.options);
// Handle error event
self.client.on('error', function(err) {
callback.call(self, err);
});
// Authenticate if password provided
if (typeof config.password == 'string') {
self.client.auth(config.password, function(err, res) {
if (err) {
app.log("RedisTransport: [%s:%s] %s", config.host, config.port, err.code);
} else if (typeof config.db == 'number' && config.db !== 0) {
self.client.select(config.db, function(err, res) {
if (err) callback.call(self, err);
else callback.call(self, null);
});
} else {
callback.call(self, null);
}
});
} else if (typeof config.db == 'number' && config.db !== 0) {
self.client.select(config.db, function(err, res) {
callback.call(self, err);
});
} else {
callback.call(self, null);
}
}
});
} | [
"function",
"initRedis",
"(",
"config",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"protos",
".",
"util",
".",
"checkLocalPort",
"(",
"config",
".",
"port",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"app",
".",
"log",
"(",
"\"RedisTransport [%s:%s] %s\"",
",",
"config",
".",
"host",
",",
"config",
".",
"port",
",",
"err",
".",
"code",
")",
";",
"}",
"else",
"{",
"// Set redis client",
"self",
".",
"client",
"=",
"redis",
".",
"createClient",
"(",
"config",
".",
"port",
",",
"config",
".",
"host",
",",
"self",
".",
"options",
")",
";",
"// Handle error event",
"self",
".",
"client",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"callback",
".",
"call",
"(",
"self",
",",
"err",
")",
";",
"}",
")",
";",
"// Authenticate if password provided",
"if",
"(",
"typeof",
"config",
".",
"password",
"==",
"'string'",
")",
"{",
"self",
".",
"client",
".",
"auth",
"(",
"config",
".",
"password",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"{",
"app",
".",
"log",
"(",
"\"RedisTransport: [%s:%s] %s\"",
",",
"config",
".",
"host",
",",
"config",
".",
"port",
",",
"err",
".",
"code",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"config",
".",
"db",
"==",
"'number'",
"&&",
"config",
".",
"db",
"!==",
"0",
")",
"{",
"self",
".",
"client",
".",
"select",
"(",
"config",
".",
"db",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"callback",
".",
"call",
"(",
"self",
",",
"err",
")",
";",
"else",
"callback",
".",
"call",
"(",
"self",
",",
"null",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"callback",
".",
"call",
"(",
"self",
",",
"null",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"if",
"(",
"typeof",
"config",
".",
"db",
"==",
"'number'",
"&&",
"config",
".",
"db",
"!==",
"0",
")",
"{",
"self",
".",
"client",
".",
"select",
"(",
"config",
".",
"db",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"callback",
".",
"call",
"(",
"self",
",",
"err",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"callback",
".",
"call",
"(",
"self",
",",
"null",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Initializes the redis client
@param {object} config
@param {function} callback
@private | [
"Initializes",
"the",
"redis",
"client"
] | 0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9 | https://github.com/derdesign/protos/blob/0b679b2a7581dfbb5d065fd4b0914436ef4ef2c9/middleware/logger/transport-redis.js#L124-L167 |
53,093 | tjmehta/mongooseware | lib/method-lists/list-instance-methods.js | listInstanceMethods | function listInstanceMethods (Model) {
var classMethods = Object.keys(Model.schema.methods);
for (var method in ModelPrototype) {
if (!isPrivateMethod(method) && isFunction(ModelPrototype[method])) {
classMethods.push(method);
}
}
return classMethods;
} | javascript | function listInstanceMethods (Model) {
var classMethods = Object.keys(Model.schema.methods);
for (var method in ModelPrototype) {
if (!isPrivateMethod(method) && isFunction(ModelPrototype[method])) {
classMethods.push(method);
}
}
return classMethods;
} | [
"function",
"listInstanceMethods",
"(",
"Model",
")",
"{",
"var",
"classMethods",
"=",
"Object",
".",
"keys",
"(",
"Model",
".",
"schema",
".",
"methods",
")",
";",
"for",
"(",
"var",
"method",
"in",
"ModelPrototype",
")",
"{",
"if",
"(",
"!",
"isPrivateMethod",
"(",
"method",
")",
"&&",
"isFunction",
"(",
"ModelPrototype",
"[",
"method",
"]",
")",
")",
"{",
"classMethods",
".",
"push",
"(",
"method",
")",
";",
"}",
"}",
"return",
"classMethods",
";",
"}"
] | Return list of all instance methods when supplied a Model constructor
@param {Object} Model
@return {Array} | [
"Return",
"list",
"of",
"all",
"instance",
"methods",
"when",
"supplied",
"a",
"Model",
"constructor"
] | c62ce0bac82880826b3528231e08f5e5b3efdb83 | https://github.com/tjmehta/mongooseware/blob/c62ce0bac82880826b3528231e08f5e5b3efdb83/lib/method-lists/list-instance-methods.js#L19-L27 |
53,094 | BlueSilverCat/bsc-utilities | lib/utility.js | circulationSearch | function circulationSearch(array, current, direction, func) {
let start = 0;
let end = array.length - 1;
if (direction === -1) {
start = array.length - 1;
end = 0;
}
for (let i = current; i * direction <= end * direction; i += direction) {
if (func(array[i])) {
return i;
}
}
for (let i = start; i * direction < current * direction; i += direction) {
if (func(array[i])) {
return i;
}
}
return -1;
} | javascript | function circulationSearch(array, current, direction, func) {
let start = 0;
let end = array.length - 1;
if (direction === -1) {
start = array.length - 1;
end = 0;
}
for (let i = current; i * direction <= end * direction; i += direction) {
if (func(array[i])) {
return i;
}
}
for (let i = start; i * direction < current * direction; i += direction) {
if (func(array[i])) {
return i;
}
}
return -1;
} | [
"function",
"circulationSearch",
"(",
"array",
",",
"current",
",",
"direction",
",",
"func",
")",
"{",
"let",
"start",
"=",
"0",
";",
"let",
"end",
"=",
"array",
".",
"length",
"-",
"1",
";",
"if",
"(",
"direction",
"===",
"-",
"1",
")",
"{",
"start",
"=",
"array",
".",
"length",
"-",
"1",
";",
"end",
"=",
"0",
";",
"}",
"for",
"(",
"let",
"i",
"=",
"current",
";",
"i",
"*",
"direction",
"<=",
"end",
"*",
"direction",
";",
"i",
"+=",
"direction",
")",
"{",
"if",
"(",
"func",
"(",
"array",
"[",
"i",
"]",
")",
")",
"{",
"return",
"i",
";",
"}",
"}",
"for",
"(",
"let",
"i",
"=",
"start",
";",
"i",
"*",
"direction",
"<",
"current",
"*",
"direction",
";",
"i",
"+=",
"direction",
")",
"{",
"if",
"(",
"func",
"(",
"array",
"[",
"i",
"]",
")",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
] | direction 1, -1 need test | [
"direction",
"1",
"-",
"1",
"need",
"test"
] | 51315321b9a260987689c50cf8acfb53eb758c7a | https://github.com/BlueSilverCat/bsc-utilities/blob/51315321b9a260987689c50cf8acfb53eb758c7a/lib/utility.js#L377-L397 |
53,095 | redisjs/jsr-server | lib/command/database/zset/zincrby.js | execute | function execute(req, res) {
// store returns a number but we need to send
// a bulk string reply
var reply = req.exec.proxy(req, res);
res.send(null, '' + reply);
} | javascript | function execute(req, res) {
// store returns a number but we need to send
// a bulk string reply
var reply = req.exec.proxy(req, res);
res.send(null, '' + reply);
} | [
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"// store returns a number but we need to send",
"// a bulk string reply",
"var",
"reply",
"=",
"req",
".",
"exec",
".",
"proxy",
"(",
"req",
",",
"res",
")",
";",
"res",
".",
"send",
"(",
"null",
",",
"''",
"+",
"reply",
")",
";",
"}"
] | Respond to the ZINCRBY command. | [
"Respond",
"to",
"the",
"ZINCRBY",
"command",
"."
] | 49413052d3039524fbdd2ade0ef9bae26cb4d647 | https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/zset/zincrby.js#L17-L22 |
53,096 | bucharest-gold/unifiedpush-admin-client | lib/applications.js | find | function find (client) {
return function find (pushAppId) {
const req = {
url: pushAppId ? `${client.baseUrl}/rest/applications/${pushAppId}` : `${client.baseUrl}/rest/applications/`
};
return request(client, req)
.then((response) => {
if (response.resp.statusCode !== 200) {
return Promise.reject(response.body);
}
return Promise.resolve(response.body);
});
};
} | javascript | function find (client) {
return function find (pushAppId) {
const req = {
url: pushAppId ? `${client.baseUrl}/rest/applications/${pushAppId}` : `${client.baseUrl}/rest/applications/`
};
return request(client, req)
.then((response) => {
if (response.resp.statusCode !== 200) {
return Promise.reject(response.body);
}
return Promise.resolve(response.body);
});
};
} | [
"function",
"find",
"(",
"client",
")",
"{",
"return",
"function",
"find",
"(",
"pushAppId",
")",
"{",
"const",
"req",
"=",
"{",
"url",
":",
"pushAppId",
"?",
"`",
"${",
"client",
".",
"baseUrl",
"}",
"${",
"pushAppId",
"}",
"`",
":",
"`",
"${",
"client",
".",
"baseUrl",
"}",
"`",
"}",
";",
"return",
"request",
"(",
"client",
",",
"req",
")",
".",
"then",
"(",
"(",
"response",
")",
"=>",
"{",
"if",
"(",
"response",
".",
"resp",
".",
"statusCode",
"!==",
"200",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"response",
".",
"body",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
"response",
".",
"body",
")",
";",
"}",
")",
";",
"}",
";",
"}"
] | A function to get all the push applications or just 1 push application
@param {string} [pushAppId] - The id of the push application
@returns {Promise} A promise that will resolve with the Array of application objects or if a pushAppId is specified, just the application object
@example
adminClient(baseUrl, settings)
.then((client) => {
client.applications.find()
.then((applications) => {
console.log(applications) // [{...},{...}, ...]
})
}) | [
"A",
"function",
"to",
"get",
"all",
"the",
"push",
"applications",
"or",
"just",
"1",
"push",
"application"
] | a39c98c9a383d7f87cb5cbbc25c4371ea1ad049e | https://github.com/bucharest-gold/unifiedpush-admin-client/blob/a39c98c9a383d7f87cb5cbbc25c4371ea1ad049e/lib/applications.js#L32-L47 |
53,097 | bucharest-gold/unifiedpush-admin-client | lib/applications.js | update | function update (client) {
return function update (pushApp) {
const req = {
url: `${client.baseUrl}/rest/applications/${pushApp.pushApplicationID}`,
body: pushApp,
method: 'PUT'
};
return request(client, req)
.then((response) => {
if (response.resp.statusCode !== 204) {
return Promise.reject(response.body);
}
return Promise.resolve(response.body);
});
};
} | javascript | function update (client) {
return function update (pushApp) {
const req = {
url: `${client.baseUrl}/rest/applications/${pushApp.pushApplicationID}`,
body: pushApp,
method: 'PUT'
};
return request(client, req)
.then((response) => {
if (response.resp.statusCode !== 204) {
return Promise.reject(response.body);
}
return Promise.resolve(response.body);
});
};
} | [
"function",
"update",
"(",
"client",
")",
"{",
"return",
"function",
"update",
"(",
"pushApp",
")",
"{",
"const",
"req",
"=",
"{",
"url",
":",
"`",
"${",
"client",
".",
"baseUrl",
"}",
"${",
"pushApp",
".",
"pushApplicationID",
"}",
"`",
",",
"body",
":",
"pushApp",
",",
"method",
":",
"'PUT'",
"}",
";",
"return",
"request",
"(",
"client",
",",
"req",
")",
".",
"then",
"(",
"(",
"response",
")",
"=>",
"{",
"if",
"(",
"response",
".",
"resp",
".",
"statusCode",
"!==",
"204",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"response",
".",
"body",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
"response",
".",
"body",
")",
";",
"}",
")",
";",
"}",
";",
"}"
] | A function to update an existing Push Application
@param {object} pushApp - The JSON representation of the push application to update. pushApp.pushApplicationID and pushApp.name is required. ATM, it looks like the only fields that are updatable are name and description
@returns {Promise} A promise that resolves with No Content
@example
adminClient(baseUrl, settings)
.then((client) => {
client.applications.update(pushApplication)
.then(() => {
console.log('success')
})
}) | [
"A",
"function",
"to",
"update",
"an",
"existing",
"Push",
"Application"
] | a39c98c9a383d7f87cb5cbbc25c4371ea1ad049e | https://github.com/bucharest-gold/unifiedpush-admin-client/blob/a39c98c9a383d7f87cb5cbbc25c4371ea1ad049e/lib/applications.js#L94-L111 |
53,098 | bucharest-gold/unifiedpush-admin-client | lib/applications.js | bootstrap | function bootstrap (client) {
return function bootstrap (pushApp) {
const req = {
url: `${client.baseUrl}/rest/applications/bootstrap`,
method: 'POST'
};
const data = pushApp;
// If they send in a string, then lets assume that is the location of the cert file
// Otherwise, we will assume it is a Stream or Buffer and can just pass it along
if (data.iosVariantName) {
if (typeof data.iosCertificate === 'string') {
data.iosCertificate = fs.createReadStream(data.iosCertificate);
}
data.iosProduction = data.iosProduction ? 'true' : 'false';
}
req.formData = data;
return request(client, req)
.then((response) => {
if (response.resp.statusCode !== 201) {
return Promise.reject(response.body);
}
return Promise.resolve(response.body);
});
};
} | javascript | function bootstrap (client) {
return function bootstrap (pushApp) {
const req = {
url: `${client.baseUrl}/rest/applications/bootstrap`,
method: 'POST'
};
const data = pushApp;
// If they send in a string, then lets assume that is the location of the cert file
// Otherwise, we will assume it is a Stream or Buffer and can just pass it along
if (data.iosVariantName) {
if (typeof data.iosCertificate === 'string') {
data.iosCertificate = fs.createReadStream(data.iosCertificate);
}
data.iosProduction = data.iosProduction ? 'true' : 'false';
}
req.formData = data;
return request(client, req)
.then((response) => {
if (response.resp.statusCode !== 201) {
return Promise.reject(response.body);
}
return Promise.resolve(response.body);
});
};
} | [
"function",
"bootstrap",
"(",
"client",
")",
"{",
"return",
"function",
"bootstrap",
"(",
"pushApp",
")",
"{",
"const",
"req",
"=",
"{",
"url",
":",
"`",
"${",
"client",
".",
"baseUrl",
"}",
"`",
",",
"method",
":",
"'POST'",
"}",
";",
"const",
"data",
"=",
"pushApp",
";",
"// If they send in a string, then lets assume that is the location of the cert file",
"// Otherwise, we will assume it is a Stream or Buffer and can just pass it along",
"if",
"(",
"data",
".",
"iosVariantName",
")",
"{",
"if",
"(",
"typeof",
"data",
".",
"iosCertificate",
"===",
"'string'",
")",
"{",
"data",
".",
"iosCertificate",
"=",
"fs",
".",
"createReadStream",
"(",
"data",
".",
"iosCertificate",
")",
";",
"}",
"data",
".",
"iosProduction",
"=",
"data",
".",
"iosProduction",
"?",
"'true'",
":",
"'false'",
";",
"}",
"req",
".",
"formData",
"=",
"data",
";",
"return",
"request",
"(",
"client",
",",
"req",
")",
".",
"then",
"(",
"(",
"response",
")",
"=>",
"{",
"if",
"(",
"response",
".",
"resp",
".",
"statusCode",
"!==",
"201",
")",
"{",
"return",
"Promise",
".",
"reject",
"(",
"response",
".",
"body",
")",
";",
"}",
"return",
"Promise",
".",
"resolve",
"(",
"response",
".",
"body",
")",
";",
"}",
")",
";",
"}",
";",
"}"
] | A Convenience function to create a complete Push Application with a set of variants
@param {object} pushApp - The push application object
@param {string} pushApp.pushApplicationName - The name of the Push Application
@param {string} [pushApp.androidVariantName] - Android Variant Name
@param {string} [pushApp.androidGoogleKey] - The Google Cloud Messaging Key. Required For Android
@param {string} [pushApp.androidProjectNumber] - The Google Project Number
@param {string} [pushApp.iosVariantName] - iOS Variant Name
@param {string} [pushApp.iosProduction] - defaults to false - flag to indicate if a connection to Apples production or sandbox APNS server
@param {string} [pushApp.iosPassphrase] - The APNs passphrase that is needed to establish a connection to any of Apple's APNs Push Servers.
@param {string|Buffer|Stream} [pushApp.iosCertificate] - the full location of the APNs certificate that is needed to establish a connection to any of Apple's APNs Push Servers.
@param {string} [pushApp.windowsType] - mpns or wns
@param {string} [pushApp.windowsVariantName] - Windows Variant Name
@param {string} [pushApp.windowsSid] - *for wns only* - (Package security identifier) used to connect to the windows push notification services
@param {string} [pushApp.windowsClientSecret] - *for wns only* - The client secret (password) to connect to the windows push notification services
@param {string} [pushApp.simplePushVariantName] - SimplePush Variant Name
@param {string} [pushApp.admVariantName] - Amazon Variant Name
@param {string} [pushApp.admClientId] - The client id to connect to the Amazon Device Messaging services
@param {string} [pushApp.admClientSecret] - The client secret (password) to connect to the Amazon Device Messaging services
@returns {Promise} A promise that resolves with the update Push Application
@example
adminClient(baseUrl, settings)
.then((client) => {
client.applications.boostrap(pushApp)
.then((pushApplicaiton) => {
console.log(pushApplication); // {...}
})
}) | [
"A",
"Convenience",
"function",
"to",
"create",
"a",
"complete",
"Push",
"Application",
"with",
"a",
"set",
"of",
"variants"
] | a39c98c9a383d7f87cb5cbbc25c4371ea1ad049e | https://github.com/bucharest-gold/unifiedpush-admin-client/blob/a39c98c9a383d7f87cb5cbbc25c4371ea1ad049e/lib/applications.js#L204-L234 |
53,099 | API-Load-Testing/http-request-hook | http-request-hook.js | function () {
var res = arguments[0];
userOptions.emit('response', req, res);
if (callback && userOptions.resCallback) callback.apply(this, arguments);
res.on('end', function() {
userOptions.emit('afterResponse', req, res);
});
} | javascript | function () {
var res = arguments[0];
userOptions.emit('response', req, res);
if (callback && userOptions.resCallback) callback.apply(this, arguments);
res.on('end', function() {
userOptions.emit('afterResponse', req, res);
});
} | [
"function",
"(",
")",
"{",
"var",
"res",
"=",
"arguments",
"[",
"0",
"]",
";",
"userOptions",
".",
"emit",
"(",
"'response'",
",",
"req",
",",
"res",
")",
";",
"if",
"(",
"callback",
"&&",
"userOptions",
".",
"resCallback",
")",
"callback",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"res",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"userOptions",
".",
"emit",
"(",
"'afterResponse'",
",",
"req",
",",
"res",
")",
";",
"}",
")",
";",
"}"
] | Create the callback function for response | [
"Create",
"the",
"callback",
"function",
"for",
"response"
] | 660c115f298613fc1556d6a40ac78f1c2c322fa4 | https://github.com/API-Load-Testing/http-request-hook/blob/660c115f298613fc1556d6a40ac78f1c2c322fa4/http-request-hook.js#L124-L136 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.