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
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
|---|---|---|---|---|---|---|---|---|---|---|---|
52,500
|
berkeleybop/bbopx-js
|
external/bbop.js
|
_draw_table_or_something
|
function _draw_table_or_something(resp, manager){
// Wipe interface.
jQuery('#' + interface_id).empty();
// Vary by what we got.
if( ! resp.success() || resp.total_documents() === 0 ){
jQuery('#' + interface_id).append('<em>No results given your input and search fields. Please refine and try again.</em>');
last_response = null;
}else{
last_response = resp;
// Render the buttons.
//console.log('user_buttons: ', user_buttons);
if( user_buttons && user_buttons.length && user_buttons.length > 0 ){
// Ensure we have somewhere to put our buttons. If not
// supplied with an injection id, make our own and use
// it.
var insert_div_id = user_buttons_div_id;
if( ! user_buttons_div_id ){
// Generate new dic and add it to the display.
var ubt_attrs = {
'generate_id': true
};
var ubt = new bbop.html.tag('div', ubt_attrs);
jQuery('#' + interface_id).append(ubt.to_string());
// Ensure the id.
insert_div_id = ubt.get_id();
}
// Add all of the defined buttons after the spacing.
_draw_user_buttons(user_buttons, insert_div_id);
}
// Display results.
var bwd = bbop.widget.display;
results_table =
new bwd.results_table_by_class_conf_b3(conf_class, resp, linker,
handler, interface_id,
selectable_p,
select_column_id,
select_item_name);
}
}
|
javascript
|
function _draw_table_or_something(resp, manager){
// Wipe interface.
jQuery('#' + interface_id).empty();
// Vary by what we got.
if( ! resp.success() || resp.total_documents() === 0 ){
jQuery('#' + interface_id).append('<em>No results given your input and search fields. Please refine and try again.</em>');
last_response = null;
}else{
last_response = resp;
// Render the buttons.
//console.log('user_buttons: ', user_buttons);
if( user_buttons && user_buttons.length && user_buttons.length > 0 ){
// Ensure we have somewhere to put our buttons. If not
// supplied with an injection id, make our own and use
// it.
var insert_div_id = user_buttons_div_id;
if( ! user_buttons_div_id ){
// Generate new dic and add it to the display.
var ubt_attrs = {
'generate_id': true
};
var ubt = new bbop.html.tag('div', ubt_attrs);
jQuery('#' + interface_id).append(ubt.to_string());
// Ensure the id.
insert_div_id = ubt.get_id();
}
// Add all of the defined buttons after the spacing.
_draw_user_buttons(user_buttons, insert_div_id);
}
// Display results.
var bwd = bbop.widget.display;
results_table =
new bwd.results_table_by_class_conf_b3(conf_class, resp, linker,
handler, interface_id,
selectable_p,
select_column_id,
select_item_name);
}
}
|
[
"function",
"_draw_table_or_something",
"(",
"resp",
",",
"manager",
")",
"{",
"// Wipe interface.",
"jQuery",
"(",
"'#'",
"+",
"interface_id",
")",
".",
"empty",
"(",
")",
";",
"// Vary by what we got.",
"if",
"(",
"!",
"resp",
".",
"success",
"(",
")",
"||",
"resp",
".",
"total_documents",
"(",
")",
"===",
"0",
")",
"{",
"jQuery",
"(",
"'#'",
"+",
"interface_id",
")",
".",
"append",
"(",
"'<em>No results given your input and search fields. Please refine and try again.</em>'",
")",
";",
"last_response",
"=",
"null",
";",
"}",
"else",
"{",
"last_response",
"=",
"resp",
";",
"// Render the buttons.",
"//console.log('user_buttons: ', user_buttons);",
"if",
"(",
"user_buttons",
"&&",
"user_buttons",
".",
"length",
"&&",
"user_buttons",
".",
"length",
">",
"0",
")",
"{",
"// Ensure we have somewhere to put our buttons. If not",
"// supplied with an injection id, make our own and use",
"// it.",
"var",
"insert_div_id",
"=",
"user_buttons_div_id",
";",
"if",
"(",
"!",
"user_buttons_div_id",
")",
"{",
"// Generate new dic and add it to the display.",
"var",
"ubt_attrs",
"=",
"{",
"'generate_id'",
":",
"true",
"}",
";",
"var",
"ubt",
"=",
"new",
"bbop",
".",
"html",
".",
"tag",
"(",
"'div'",
",",
"ubt_attrs",
")",
";",
"jQuery",
"(",
"'#'",
"+",
"interface_id",
")",
".",
"append",
"(",
"ubt",
".",
"to_string",
"(",
")",
")",
";",
"// Ensure the id.",
"insert_div_id",
"=",
"ubt",
".",
"get_id",
"(",
")",
";",
"}",
"// Add all of the defined buttons after the spacing.",
"_draw_user_buttons",
"(",
"user_buttons",
",",
"insert_div_id",
")",
";",
"}",
"// Display results.",
"var",
"bwd",
"=",
"bbop",
".",
"widget",
".",
"display",
";",
"results_table",
"=",
"new",
"bwd",
".",
"results_table_by_class_conf_b3",
"(",
"conf_class",
",",
"resp",
",",
"linker",
",",
"handler",
",",
"interface_id",
",",
"selectable_p",
",",
"select_column_id",
",",
"select_item_name",
")",
";",
"}",
"}"
] |
Draw a table at the right place or an error message.
|
[
"Draw",
"a",
"table",
"at",
"the",
"right",
"place",
"or",
"an",
"error",
"message",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L20968-L21014
|
52,501
|
berkeleybop/bbopx-js
|
external/bbop.js
|
read_cli
|
function read_cli(event){
var which = event.which;
var ctrl_p = event.ctrlKey;
//log('cli: ' + which + ', ' + ctrl_p);
if ( which == 13 ) { // return
// Stop events.
event.preventDefault();
// Get and ensure nice JS, wipe CLI clean.
var to_eval = jQuery('#' + command_line.get_id()).val();
if( to_eval != '' ){
jQuery('#' + command_line.get_id()).val('');
// Enter the new command into our history and bump the
// index to the last thing pushed on.
history_list.pop(); // pop the empty ''
history_list.push(to_eval);
history_list.push(''); // push new empty ''
history_pointer = history_list.length -1;
//log('// history: '+history_pointer+', '+history_list.length);
// Log, eval, log.
to_eval = bbop.core.ensure(to_eval, ';', 'back');
log(to_eval);
var evals = _evaluate(to_eval);
log('// ' + evals[1]);
_advance_log_to_bottom();
return false;
}
}else if( ctrl_p && which == 38 ){ // ctrl + up
// Stop stuff?
event.preventDefault();
if( history_pointer == 0 ){
_update_cli();
}else if( history_pointer > 0 ){
history_pointer--;
_update_cli();
}
return false;
}else if( ctrl_p && which == 40 ){ // ctrl + down
// Stop stuff?
event.preventDefault();
if( history_pointer < history_list.length -1 ){
history_pointer++;
_update_cli();
}
return false;
}
return true;
}
|
javascript
|
function read_cli(event){
var which = event.which;
var ctrl_p = event.ctrlKey;
//log('cli: ' + which + ', ' + ctrl_p);
if ( which == 13 ) { // return
// Stop events.
event.preventDefault();
// Get and ensure nice JS, wipe CLI clean.
var to_eval = jQuery('#' + command_line.get_id()).val();
if( to_eval != '' ){
jQuery('#' + command_line.get_id()).val('');
// Enter the new command into our history and bump the
// index to the last thing pushed on.
history_list.pop(); // pop the empty ''
history_list.push(to_eval);
history_list.push(''); // push new empty ''
history_pointer = history_list.length -1;
//log('// history: '+history_pointer+', '+history_list.length);
// Log, eval, log.
to_eval = bbop.core.ensure(to_eval, ';', 'back');
log(to_eval);
var evals = _evaluate(to_eval);
log('// ' + evals[1]);
_advance_log_to_bottom();
return false;
}
}else if( ctrl_p && which == 38 ){ // ctrl + up
// Stop stuff?
event.preventDefault();
if( history_pointer == 0 ){
_update_cli();
}else if( history_pointer > 0 ){
history_pointer--;
_update_cli();
}
return false;
}else if( ctrl_p && which == 40 ){ // ctrl + down
// Stop stuff?
event.preventDefault();
if( history_pointer < history_list.length -1 ){
history_pointer++;
_update_cli();
}
return false;
}
return true;
}
|
[
"function",
"read_cli",
"(",
"event",
")",
"{",
"var",
"which",
"=",
"event",
".",
"which",
";",
"var",
"ctrl_p",
"=",
"event",
".",
"ctrlKey",
";",
"//log('cli: ' + which + ', ' + ctrl_p);",
"if",
"(",
"which",
"==",
"13",
")",
"{",
"// return",
"// Stop events.",
"event",
".",
"preventDefault",
"(",
")",
";",
"// Get and ensure nice JS, wipe CLI clean.",
"var",
"to_eval",
"=",
"jQuery",
"(",
"'#'",
"+",
"command_line",
".",
"get_id",
"(",
")",
")",
".",
"val",
"(",
")",
";",
"if",
"(",
"to_eval",
"!=",
"''",
")",
"{",
"jQuery",
"(",
"'#'",
"+",
"command_line",
".",
"get_id",
"(",
")",
")",
".",
"val",
"(",
"''",
")",
";",
"// Enter the new command into our history and bump the",
"// index to the last thing pushed on.",
"history_list",
".",
"pop",
"(",
")",
";",
"// pop the empty ''",
"history_list",
".",
"push",
"(",
"to_eval",
")",
";",
"history_list",
".",
"push",
"(",
"''",
")",
";",
"// push new empty ''",
"history_pointer",
"=",
"history_list",
".",
"length",
"-",
"1",
";",
"//log('// history: '+history_pointer+', '+history_list.length);",
"// Log, eval, log.",
"to_eval",
"=",
"bbop",
".",
"core",
".",
"ensure",
"(",
"to_eval",
",",
"';'",
",",
"'back'",
")",
";",
"log",
"(",
"to_eval",
")",
";",
"var",
"evals",
"=",
"_evaluate",
"(",
"to_eval",
")",
";",
"log",
"(",
"'// '",
"+",
"evals",
"[",
"1",
"]",
")",
";",
"_advance_log_to_bottom",
"(",
")",
";",
"return",
"false",
";",
"}",
"}",
"else",
"if",
"(",
"ctrl_p",
"&&",
"which",
"==",
"38",
")",
"{",
"// ctrl + up",
"// Stop stuff?",
"event",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"history_pointer",
"==",
"0",
")",
"{",
"_update_cli",
"(",
")",
";",
"}",
"else",
"if",
"(",
"history_pointer",
">",
"0",
")",
"{",
"history_pointer",
"--",
";",
"_update_cli",
"(",
")",
";",
"}",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"ctrl_p",
"&&",
"which",
"==",
"40",
")",
"{",
"// ctrl + down",
"// Stop stuff?",
"event",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"history_pointer",
"<",
"history_list",
".",
"length",
"-",
"1",
")",
"{",
"history_pointer",
"++",
";",
"_update_cli",
"(",
")",
";",
"}",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
A lot of cases for button presses when reading from the command line.
|
[
"A",
"lot",
"of",
"cases",
"for",
"button",
"presses",
"when",
"reading",
"from",
"the",
"command",
"line",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L21346-L21407
|
52,502
|
berkeleybop/bbopx-js
|
external/bbop.js
|
read_buffer
|
function read_buffer(){
var to_eval = jQuery('#' + command_buffer.get_id()).val();
if( to_eval != '' ){
log('// Evaluating buffer...');
var evals = _evaluate(to_eval);
log('// ' + evals[1]);
_advance_log_to_bottom();
}
}
|
javascript
|
function read_buffer(){
var to_eval = jQuery('#' + command_buffer.get_id()).val();
if( to_eval != '' ){
log('// Evaluating buffer...');
var evals = _evaluate(to_eval);
log('// ' + evals[1]);
_advance_log_to_bottom();
}
}
|
[
"function",
"read_buffer",
"(",
")",
"{",
"var",
"to_eval",
"=",
"jQuery",
"(",
"'#'",
"+",
"command_buffer",
".",
"get_id",
"(",
")",
")",
".",
"val",
"(",
")",
";",
"if",
"(",
"to_eval",
"!=",
"''",
")",
"{",
"log",
"(",
"'// Evaluating buffer...'",
")",
";",
"var",
"evals",
"=",
"_evaluate",
"(",
"to_eval",
")",
";",
"log",
"(",
"'// '",
"+",
"evals",
"[",
"1",
"]",
")",
";",
"_advance_log_to_bottom",
"(",
")",
";",
"}",
"}"
] |
Bind buffer eval.
|
[
"Bind",
"buffer",
"eval",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L21411-L21419
|
52,503
|
berkeleybop/bbopx-js
|
external/bbop.js
|
gather_list_from_hash
|
function gather_list_from_hash(nid, hash){
var retlist = new Array();
retlist.push(nid);
// Get all nodes cribbing from distances.
for( vt in hash[nid] ){
//ll("id: " + id + ", v: " + ct);
retlist.push(vt);
}
return retlist;
}
|
javascript
|
function gather_list_from_hash(nid, hash){
var retlist = new Array();
retlist.push(nid);
// Get all nodes cribbing from distances.
for( vt in hash[nid] ){
//ll("id: " + id + ", v: " + ct);
retlist.push(vt);
}
return retlist;
}
|
[
"function",
"gather_list_from_hash",
"(",
"nid",
",",
"hash",
")",
"{",
"var",
"retlist",
"=",
"new",
"Array",
"(",
")",
";",
"retlist",
".",
"push",
"(",
"nid",
")",
";",
"// Get all nodes cribbing from distances.",
"for",
"(",
"vt",
"in",
"hash",
"[",
"nid",
"]",
")",
"{",
"//ll(\"id: \" + id + \", v: \" + ct);",
"retlist",
".",
"push",
"(",
"vt",
")",
";",
"}",
"return",
"retlist",
";",
"}"
] |
Subtree list, including self.
|
[
"Subtree",
"list",
"including",
"self",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L22185-L22194
|
52,504
|
berkeleybop/bbopx-js
|
external/bbop.js
|
get_connections
|
function get_connections(phynode_id, phynode_getter, conn_hash){
var retlist = new Array();
// Fish in the connection ancestor hash for edges.
var tmp_phynodes = phynode_getter(phynode_id);
for( var si = 0; si < tmp_phynodes.length; si++ ){
var tshp = tmp_phynodes[si];
var tnid = phynode_id_to_node_id[tshp.id];
if( tnid && conn_hash[tnid] ){
for( var anid in conn_hash[tnid] ){
var conn_index = conn_hash[tnid][anid];
var conn = connections[conn_index];
ll('get_conn: found: [' + conn_index +
'] ' + anid + ' <=> ' + tnid +
' ... ' + conn);
retlist.push(conn);
}
}
}
return retlist;
}
|
javascript
|
function get_connections(phynode_id, phynode_getter, conn_hash){
var retlist = new Array();
// Fish in the connection ancestor hash for edges.
var tmp_phynodes = phynode_getter(phynode_id);
for( var si = 0; si < tmp_phynodes.length; si++ ){
var tshp = tmp_phynodes[si];
var tnid = phynode_id_to_node_id[tshp.id];
if( tnid && conn_hash[tnid] ){
for( var anid in conn_hash[tnid] ){
var conn_index = conn_hash[tnid][anid];
var conn = connections[conn_index];
ll('get_conn: found: [' + conn_index +
'] ' + anid + ' <=> ' + tnid +
' ... ' + conn);
retlist.push(conn);
}
}
}
return retlist;
}
|
[
"function",
"get_connections",
"(",
"phynode_id",
",",
"phynode_getter",
",",
"conn_hash",
")",
"{",
"var",
"retlist",
"=",
"new",
"Array",
"(",
")",
";",
"// Fish in the connection ancestor hash for edges.",
"var",
"tmp_phynodes",
"=",
"phynode_getter",
"(",
"phynode_id",
")",
";",
"for",
"(",
"var",
"si",
"=",
"0",
";",
"si",
"<",
"tmp_phynodes",
".",
"length",
";",
"si",
"++",
")",
"{",
"var",
"tshp",
"=",
"tmp_phynodes",
"[",
"si",
"]",
";",
"var",
"tnid",
"=",
"phynode_id_to_node_id",
"[",
"tshp",
".",
"id",
"]",
";",
"if",
"(",
"tnid",
"&&",
"conn_hash",
"[",
"tnid",
"]",
")",
"{",
"for",
"(",
"var",
"anid",
"in",
"conn_hash",
"[",
"tnid",
"]",
")",
"{",
"var",
"conn_index",
"=",
"conn_hash",
"[",
"tnid",
"]",
"[",
"anid",
"]",
";",
"var",
"conn",
"=",
"connections",
"[",
"conn_index",
"]",
";",
"ll",
"(",
"'get_conn: found: ['",
"+",
"conn_index",
"+",
"'] '",
"+",
"anid",
"+",
"' <=> '",
"+",
"tnid",
"+",
"' ... '",
"+",
"conn",
")",
";",
"retlist",
".",
"push",
"(",
"conn",
")",
";",
"}",
"}",
"}",
"return",
"retlist",
";",
"}"
] |
General func.
|
[
"General",
"func",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L22238-L22259
|
52,505
|
berkeleybop/bbopx-js
|
external/bbop.js
|
function () {
var phynode_id = this.id;
// Fade boxes.
var assoc_phynodes = get_descendant_phynodes(phynode_id);
for( var si = 0; si < assoc_phynodes.length; si++ ){
var mshp = assoc_phynodes[si];
mshp.update();
}
// Update connections; bring them all back to normal.
for (var i = connections.length; i--;) {
connections[i].update();
}
paper.safari();
}
|
javascript
|
function () {
var phynode_id = this.id;
// Fade boxes.
var assoc_phynodes = get_descendant_phynodes(phynode_id);
for( var si = 0; si < assoc_phynodes.length; si++ ){
var mshp = assoc_phynodes[si];
mshp.update();
}
// Update connections; bring them all back to normal.
for (var i = connections.length; i--;) {
connections[i].update();
}
paper.safari();
}
|
[
"function",
"(",
")",
"{",
"var",
"phynode_id",
"=",
"this",
".",
"id",
";",
"// Fade boxes.",
"var",
"assoc_phynodes",
"=",
"get_descendant_phynodes",
"(",
"phynode_id",
")",
";",
"for",
"(",
"var",
"si",
"=",
"0",
";",
"si",
"<",
"assoc_phynodes",
".",
"length",
";",
"si",
"++",
")",
"{",
"var",
"mshp",
"=",
"assoc_phynodes",
"[",
"si",
"]",
";",
"mshp",
".",
"update",
"(",
")",
";",
"}",
"// Update connections; bring them all back to normal.",
"for",
"(",
"var",
"i",
"=",
"connections",
".",
"length",
";",
"i",
"--",
";",
")",
"{",
"connections",
"[",
"i",
"]",
".",
"update",
"(",
")",
";",
"}",
"paper",
".",
"safari",
"(",
")",
";",
"}"
] |
Undrag animation.
|
[
"Undrag",
"animation",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L22335-L22351
|
|
52,506
|
berkeleybop/bbopx-js
|
external/bbop.js
|
dblclick_event_handler
|
function dblclick_event_handler(event){
var phynode_id = this.id;
// If this is the first double click here...
var pn = get_pnode_from_phynode_id(phynode_id);
if( pn.open == true ){
// "Vanish" edges.
var subtree_edges = get_descendant_connections(phynode_id);
for( var se = 0; se < subtree_edges.length; se++ ){
var ste = subtree_edges[se];
ste.visible = false;
ste.update();
}
// "Vanish" nodes and text; not this node though...
var subtree_nodes = get_descendant_phynodes(phynode_id);
for( var sn = 0; sn < subtree_nodes.length; sn++ ){
var stn = subtree_nodes[sn];
if( stn.id != phynode_id ){
// Turn of visibilty for children.
stn.visible = false;
}else{
// Mark self as closed.
stn.open = false;
}
stn.update();
}
}else{ //Otherwise...
// Reestablish edges.
var subtree_edges = get_descendant_connections(phynode_id);
for( var se = 0; se < subtree_edges.length; se++ ){
var ste = subtree_edges[se];
ste.visible = true;
ste.update();
}
// Restablish pnodes; clear all history.
var subtree_nodes = get_descendant_phynodes(phynode_id);
for( var sn = 0; sn < subtree_nodes.length; sn++ ){
var stn = subtree_nodes[sn];
stn.open = true;
stn.visible = true;
stn.update();
}
}
}
|
javascript
|
function dblclick_event_handler(event){
var phynode_id = this.id;
// If this is the first double click here...
var pn = get_pnode_from_phynode_id(phynode_id);
if( pn.open == true ){
// "Vanish" edges.
var subtree_edges = get_descendant_connections(phynode_id);
for( var se = 0; se < subtree_edges.length; se++ ){
var ste = subtree_edges[se];
ste.visible = false;
ste.update();
}
// "Vanish" nodes and text; not this node though...
var subtree_nodes = get_descendant_phynodes(phynode_id);
for( var sn = 0; sn < subtree_nodes.length; sn++ ){
var stn = subtree_nodes[sn];
if( stn.id != phynode_id ){
// Turn of visibilty for children.
stn.visible = false;
}else{
// Mark self as closed.
stn.open = false;
}
stn.update();
}
}else{ //Otherwise...
// Reestablish edges.
var subtree_edges = get_descendant_connections(phynode_id);
for( var se = 0; se < subtree_edges.length; se++ ){
var ste = subtree_edges[se];
ste.visible = true;
ste.update();
}
// Restablish pnodes; clear all history.
var subtree_nodes = get_descendant_phynodes(phynode_id);
for( var sn = 0; sn < subtree_nodes.length; sn++ ){
var stn = subtree_nodes[sn];
stn.open = true;
stn.visible = true;
stn.update();
}
}
}
|
[
"function",
"dblclick_event_handler",
"(",
"event",
")",
"{",
"var",
"phynode_id",
"=",
"this",
".",
"id",
";",
"// If this is the first double click here...",
"var",
"pn",
"=",
"get_pnode_from_phynode_id",
"(",
"phynode_id",
")",
";",
"if",
"(",
"pn",
".",
"open",
"==",
"true",
")",
"{",
"// \"Vanish\" edges.",
"var",
"subtree_edges",
"=",
"get_descendant_connections",
"(",
"phynode_id",
")",
";",
"for",
"(",
"var",
"se",
"=",
"0",
";",
"se",
"<",
"subtree_edges",
".",
"length",
";",
"se",
"++",
")",
"{",
"var",
"ste",
"=",
"subtree_edges",
"[",
"se",
"]",
";",
"ste",
".",
"visible",
"=",
"false",
";",
"ste",
".",
"update",
"(",
")",
";",
"}",
"// \"Vanish\" nodes and text; not this node though...",
"var",
"subtree_nodes",
"=",
"get_descendant_phynodes",
"(",
"phynode_id",
")",
";",
"for",
"(",
"var",
"sn",
"=",
"0",
";",
"sn",
"<",
"subtree_nodes",
".",
"length",
";",
"sn",
"++",
")",
"{",
"var",
"stn",
"=",
"subtree_nodes",
"[",
"sn",
"]",
";",
"if",
"(",
"stn",
".",
"id",
"!=",
"phynode_id",
")",
"{",
"// Turn of visibilty for children.",
"stn",
".",
"visible",
"=",
"false",
";",
"}",
"else",
"{",
"// Mark self as closed.",
"stn",
".",
"open",
"=",
"false",
";",
"}",
"stn",
".",
"update",
"(",
")",
";",
"}",
"}",
"else",
"{",
"//Otherwise...",
"// Reestablish edges.",
"var",
"subtree_edges",
"=",
"get_descendant_connections",
"(",
"phynode_id",
")",
";",
"for",
"(",
"var",
"se",
"=",
"0",
";",
"se",
"<",
"subtree_edges",
".",
"length",
";",
"se",
"++",
")",
"{",
"var",
"ste",
"=",
"subtree_edges",
"[",
"se",
"]",
";",
"ste",
".",
"visible",
"=",
"true",
";",
"ste",
".",
"update",
"(",
")",
";",
"}",
"// Restablish pnodes; clear all history.",
"var",
"subtree_nodes",
"=",
"get_descendant_phynodes",
"(",
"phynode_id",
")",
";",
"for",
"(",
"var",
"sn",
"=",
"0",
";",
"sn",
"<",
"subtree_nodes",
".",
"length",
";",
"sn",
"++",
")",
"{",
"var",
"stn",
"=",
"subtree_nodes",
"[",
"sn",
"]",
";",
"stn",
".",
"open",
"=",
"true",
";",
"stn",
".",
"visible",
"=",
"true",
";",
"stn",
".",
"update",
"(",
")",
";",
"}",
"}",
"}"
] |
Experiment with double click.
|
[
"Experiment",
"with",
"double",
"click",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L22354-L22402
|
52,507
|
berkeleybop/bbopx-js
|
external/bbop.js
|
_generate_element
|
function _generate_element(ctype, str){
var message_classes = ['bbop-js-message',
'bbop-js-message-' + ctype];
var message_elt =
new bbop.html.tag('div',
{'generate_id': true,
'class': message_classes.join(' ')},
'<h2>' + str + '</h2>');
jQuery("body").append(jQuery(message_elt.to_string()).hide());
// jQuery-ify the element.
var elt = jQuery('#' + message_elt.get_id());
return elt;
}
|
javascript
|
function _generate_element(ctype, str){
var message_classes = ['bbop-js-message',
'bbop-js-message-' + ctype];
var message_elt =
new bbop.html.tag('div',
{'generate_id': true,
'class': message_classes.join(' ')},
'<h2>' + str + '</h2>');
jQuery("body").append(jQuery(message_elt.to_string()).hide());
// jQuery-ify the element.
var elt = jQuery('#' + message_elt.get_id());
return elt;
}
|
[
"function",
"_generate_element",
"(",
"ctype",
",",
"str",
")",
"{",
"var",
"message_classes",
"=",
"[",
"'bbop-js-message'",
",",
"'bbop-js-message-'",
"+",
"ctype",
"]",
";",
"var",
"message_elt",
"=",
"new",
"bbop",
".",
"html",
".",
"tag",
"(",
"'div'",
",",
"{",
"'generate_id'",
":",
"true",
",",
"'class'",
":",
"message_classes",
".",
"join",
"(",
"' '",
")",
"}",
",",
"'<h2>'",
"+",
"str",
"+",
"'</h2>'",
")",
";",
"jQuery",
"(",
"\"body\"",
")",
".",
"append",
"(",
"jQuery",
"(",
"message_elt",
".",
"to_string",
"(",
")",
")",
".",
"hide",
"(",
")",
")",
";",
"// jQuery-ify the element.",
"var",
"elt",
"=",
"jQuery",
"(",
"'#'",
"+",
"message_elt",
".",
"get_id",
"(",
")",
")",
";",
"return",
"elt",
";",
"}"
] |
Generate tags.
|
[
"Generate",
"tags",
"."
] |
847d87f5980f144c19c4caef3786044930fe51db
|
https://github.com/berkeleybop/bbopx-js/blob/847d87f5980f144c19c4caef3786044930fe51db/external/bbop.js#L24584-L24600
|
52,508
|
briancsparks/run-anywhere
|
ra.js
|
function(dirname) {
var result;
if (!fs.test('-d', dirname)) { return result; }
result = {};
_.each(sg.fs.ls(dirname), (name_) => {
const name = path.basename(name_, '.js');
const filename = path.join(dirname, name);
if (!fs.test('-f', `${filename}.js`)) { return; } // skip
if (name.startsWith('helper')) { return; } // skip helper(s).js
result[name] = result[name] || {};
_.extend(result[name], libRa.middlewareify(safeRequire(filename)));
});
return result;
}
|
javascript
|
function(dirname) {
var result;
if (!fs.test('-d', dirname)) { return result; }
result = {};
_.each(sg.fs.ls(dirname), (name_) => {
const name = path.basename(name_, '.js');
const filename = path.join(dirname, name);
if (!fs.test('-f', `${filename}.js`)) { return; } // skip
if (name.startsWith('helper')) { return; } // skip helper(s).js
result[name] = result[name] || {};
_.extend(result[name], libRa.middlewareify(safeRequire(filename)));
});
return result;
}
|
[
"function",
"(",
"dirname",
")",
"{",
"var",
"result",
";",
"if",
"(",
"!",
"fs",
".",
"test",
"(",
"'-d'",
",",
"dirname",
")",
")",
"{",
"return",
"result",
";",
"}",
"result",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"sg",
".",
"fs",
".",
"ls",
"(",
"dirname",
")",
",",
"(",
"name_",
")",
"=>",
"{",
"const",
"name",
"=",
"path",
".",
"basename",
"(",
"name_",
",",
"'.js'",
")",
";",
"const",
"filename",
"=",
"path",
".",
"join",
"(",
"dirname",
",",
"name",
")",
";",
"if",
"(",
"!",
"fs",
".",
"test",
"(",
"'-f'",
",",
"`",
"${",
"filename",
"}",
"`",
")",
")",
"{",
"return",
";",
"}",
"// skip",
"if",
"(",
"name",
".",
"startsWith",
"(",
"'helper'",
")",
")",
"{",
"return",
";",
"}",
"// skip helper(s).js",
"result",
"[",
"name",
"]",
"=",
"result",
"[",
"name",
"]",
"||",
"{",
"}",
";",
"_",
".",
"extend",
"(",
"result",
"[",
"name",
"]",
",",
"libRa",
".",
"middlewareify",
"(",
"safeRequire",
"(",
"filename",
")",
")",
")",
";",
"}",
")",
";",
"return",
"result",
";",
"}"
] |
Loads all the scripts in a dir.
|
[
"Loads",
"all",
"the",
"scripts",
"in",
"a",
"dir",
"."
] |
b73d170dc86cc00e6562ca8544fceb3478d51e20
|
https://github.com/briancsparks/run-anywhere/blob/b73d170dc86cc00e6562ca8544fceb3478d51e20/ra.js#L269-L286
|
|
52,509
|
RangerMauve/cypher-promise
|
index.js
|
make_query_maker
|
function make_query_maker(connection_string, connection_opts) {
connection_string = connection_string || "http://localhost:7474";
connection_opts = connection_opts || {};
var client_cache = null;
return {
query: query,
multi: multi
};
/**
* Makes a cypher query and resolves to the result
* @param {String} cypher_query The CQL code to execute
* @param {Object} [parameters] The parameters to pass to the query
* @return {Promise} Resolves to the result of the query
*/
function query(cypher_query, parameters) {
return get_client()
.then(rpar(query_with, cypher_query, parameters));
}
/**
* Make a new object for batching queries. Call multi.query multiple times,
* and then call multi.exec() to get a promise of whether everything succeeded
* or not.
* @return {Multi} Returns a multi object with `query` and `exec` methods
*/
function multi() {
var multi = get_client().then(function (client) {
return client.multi();
});
return {
query: query,
exec: exec
};
function query(cypher_query, parameters) {
return multi.then(function (multi) {
return query_with(multi, cypher_query, parameters);
});
}
function exec() {
return multi.then(function (multi) {
return make_promise(multi.exec.bind(multi));
});
}
}
// Makes a query with a given client and returns a promise
function query_with(client, cypher_query, parameters) {
parameters = parameters || {};
return make_promise(client.query.bind(client, cypher_query, parameters));
}
// Creates a new client or returns a cached one
function get_client() {
if (client_cache) return Promise.resolve(client_cache);
return make_promise(
cypher.createClient.bind(cypher, connection_string, connection_opts)
).then(cache_client);
}
// Caches a client for later use
function cache_client(client) {
client_cache = client;
return client;
}
}
|
javascript
|
function make_query_maker(connection_string, connection_opts) {
connection_string = connection_string || "http://localhost:7474";
connection_opts = connection_opts || {};
var client_cache = null;
return {
query: query,
multi: multi
};
/**
* Makes a cypher query and resolves to the result
* @param {String} cypher_query The CQL code to execute
* @param {Object} [parameters] The parameters to pass to the query
* @return {Promise} Resolves to the result of the query
*/
function query(cypher_query, parameters) {
return get_client()
.then(rpar(query_with, cypher_query, parameters));
}
/**
* Make a new object for batching queries. Call multi.query multiple times,
* and then call multi.exec() to get a promise of whether everything succeeded
* or not.
* @return {Multi} Returns a multi object with `query` and `exec` methods
*/
function multi() {
var multi = get_client().then(function (client) {
return client.multi();
});
return {
query: query,
exec: exec
};
function query(cypher_query, parameters) {
return multi.then(function (multi) {
return query_with(multi, cypher_query, parameters);
});
}
function exec() {
return multi.then(function (multi) {
return make_promise(multi.exec.bind(multi));
});
}
}
// Makes a query with a given client and returns a promise
function query_with(client, cypher_query, parameters) {
parameters = parameters || {};
return make_promise(client.query.bind(client, cypher_query, parameters));
}
// Creates a new client or returns a cached one
function get_client() {
if (client_cache) return Promise.resolve(client_cache);
return make_promise(
cypher.createClient.bind(cypher, connection_string, connection_opts)
).then(cache_client);
}
// Caches a client for later use
function cache_client(client) {
client_cache = client;
return client;
}
}
|
[
"function",
"make_query_maker",
"(",
"connection_string",
",",
"connection_opts",
")",
"{",
"connection_string",
"=",
"connection_string",
"||",
"\"http://localhost:7474\"",
";",
"connection_opts",
"=",
"connection_opts",
"||",
"{",
"}",
";",
"var",
"client_cache",
"=",
"null",
";",
"return",
"{",
"query",
":",
"query",
",",
"multi",
":",
"multi",
"}",
";",
"/**\n\t * Makes a cypher query and resolves to the result\n\t * @param {String} cypher_query The CQL code to execute\n\t * @param {Object} [parameters] The parameters to pass to the query\n\t * @return {Promise} Resolves to the result of the query\n\t */",
"function",
"query",
"(",
"cypher_query",
",",
"parameters",
")",
"{",
"return",
"get_client",
"(",
")",
".",
"then",
"(",
"rpar",
"(",
"query_with",
",",
"cypher_query",
",",
"parameters",
")",
")",
";",
"}",
"/**\n\t * Make a new object for batching queries. Call multi.query multiple times,\n\t * and then call multi.exec() to get a promise of whether everything succeeded\n\t * or not.\n\t * @return {Multi} Returns a multi object with `query` and `exec` methods\n\t */",
"function",
"multi",
"(",
")",
"{",
"var",
"multi",
"=",
"get_client",
"(",
")",
".",
"then",
"(",
"function",
"(",
"client",
")",
"{",
"return",
"client",
".",
"multi",
"(",
")",
";",
"}",
")",
";",
"return",
"{",
"query",
":",
"query",
",",
"exec",
":",
"exec",
"}",
";",
"function",
"query",
"(",
"cypher_query",
",",
"parameters",
")",
"{",
"return",
"multi",
".",
"then",
"(",
"function",
"(",
"multi",
")",
"{",
"return",
"query_with",
"(",
"multi",
",",
"cypher_query",
",",
"parameters",
")",
";",
"}",
")",
";",
"}",
"function",
"exec",
"(",
")",
"{",
"return",
"multi",
".",
"then",
"(",
"function",
"(",
"multi",
")",
"{",
"return",
"make_promise",
"(",
"multi",
".",
"exec",
".",
"bind",
"(",
"multi",
")",
")",
";",
"}",
")",
";",
"}",
"}",
"// Makes a query with a given client and returns a promise",
"function",
"query_with",
"(",
"client",
",",
"cypher_query",
",",
"parameters",
")",
"{",
"parameters",
"=",
"parameters",
"||",
"{",
"}",
";",
"return",
"make_promise",
"(",
"client",
".",
"query",
".",
"bind",
"(",
"client",
",",
"cypher_query",
",",
"parameters",
")",
")",
";",
"}",
"// Creates a new client or returns a cached one",
"function",
"get_client",
"(",
")",
"{",
"if",
"(",
"client_cache",
")",
"return",
"Promise",
".",
"resolve",
"(",
"client_cache",
")",
";",
"return",
"make_promise",
"(",
"cypher",
".",
"createClient",
".",
"bind",
"(",
"cypher",
",",
"connection_string",
",",
"connection_opts",
")",
")",
".",
"then",
"(",
"cache_client",
")",
";",
"}",
"// Caches a client for later use",
"function",
"cache_client",
"(",
"client",
")",
"{",
"client_cache",
"=",
"client",
";",
"return",
"client",
";",
"}",
"}"
] |
Creates a new client for making cypher queries
@param {String} connection_string The url of the Neo4j server
@param {Object} [connection_opts] Options for node-cypher
@return {Cypher} Returns a new Cypher client
|
[
"Creates",
"a",
"new",
"client",
"for",
"making",
"cypher",
"queries"
] |
cc2bdc95fce6525427a76a891d174afcfc5bcd8e
|
https://github.com/RangerMauve/cypher-promise/blob/cc2bdc95fce6525427a76a891d174afcfc5bcd8e/index.js#L15-L84
|
52,510
|
RangerMauve/cypher-promise
|
index.js
|
query_with
|
function query_with(client, cypher_query, parameters) {
parameters = parameters || {};
return make_promise(client.query.bind(client, cypher_query, parameters));
}
|
javascript
|
function query_with(client, cypher_query, parameters) {
parameters = parameters || {};
return make_promise(client.query.bind(client, cypher_query, parameters));
}
|
[
"function",
"query_with",
"(",
"client",
",",
"cypher_query",
",",
"parameters",
")",
"{",
"parameters",
"=",
"parameters",
"||",
"{",
"}",
";",
"return",
"make_promise",
"(",
"client",
".",
"query",
".",
"bind",
"(",
"client",
",",
"cypher_query",
",",
"parameters",
")",
")",
";",
"}"
] |
Makes a query with a given client and returns a promise
|
[
"Makes",
"a",
"query",
"with",
"a",
"given",
"client",
"and",
"returns",
"a",
"promise"
] |
cc2bdc95fce6525427a76a891d174afcfc5bcd8e
|
https://github.com/RangerMauve/cypher-promise/blob/cc2bdc95fce6525427a76a891d174afcfc5bcd8e/index.js#L66-L69
|
52,511
|
RangerMauve/cypher-promise
|
index.js
|
get_client
|
function get_client() {
if (client_cache) return Promise.resolve(client_cache);
return make_promise(
cypher.createClient.bind(cypher, connection_string, connection_opts)
).then(cache_client);
}
|
javascript
|
function get_client() {
if (client_cache) return Promise.resolve(client_cache);
return make_promise(
cypher.createClient.bind(cypher, connection_string, connection_opts)
).then(cache_client);
}
|
[
"function",
"get_client",
"(",
")",
"{",
"if",
"(",
"client_cache",
")",
"return",
"Promise",
".",
"resolve",
"(",
"client_cache",
")",
";",
"return",
"make_promise",
"(",
"cypher",
".",
"createClient",
".",
"bind",
"(",
"cypher",
",",
"connection_string",
",",
"connection_opts",
")",
")",
".",
"then",
"(",
"cache_client",
")",
";",
"}"
] |
Creates a new client or returns a cached one
|
[
"Creates",
"a",
"new",
"client",
"or",
"returns",
"a",
"cached",
"one"
] |
cc2bdc95fce6525427a76a891d174afcfc5bcd8e
|
https://github.com/RangerMauve/cypher-promise/blob/cc2bdc95fce6525427a76a891d174afcfc5bcd8e/index.js#L72-L77
|
52,512
|
Nazariglez/perenquen
|
lib/pixi/src/filters/dropshadow/BlurYTintFilter.js
|
BlurYTintFilter
|
function BlurYTintFilter()
{
core.AbstractFilter.call(this,
// vertex shader
fs.readFileSync(__dirname + '/blurYTint.vert', 'utf8'),
// fragment shader
fs.readFileSync(__dirname + '/blurYTint.frag', 'utf8'),
// set the uniforms
{
blur: { type: '1f', value: 1 / 512 },
color: { type: 'c', value: [0,0,0]},
alpha: { type: '1f', value: 0.7 },
offset: { type: '2f', value:[5, 5]},
strength: { type: '1f', value:1}
}
);
this.passes = 1;
this.strength = 4;
}
|
javascript
|
function BlurYTintFilter()
{
core.AbstractFilter.call(this,
// vertex shader
fs.readFileSync(__dirname + '/blurYTint.vert', 'utf8'),
// fragment shader
fs.readFileSync(__dirname + '/blurYTint.frag', 'utf8'),
// set the uniforms
{
blur: { type: '1f', value: 1 / 512 },
color: { type: 'c', value: [0,0,0]},
alpha: { type: '1f', value: 0.7 },
offset: { type: '2f', value:[5, 5]},
strength: { type: '1f', value:1}
}
);
this.passes = 1;
this.strength = 4;
}
|
[
"function",
"BlurYTintFilter",
"(",
")",
"{",
"core",
".",
"AbstractFilter",
".",
"call",
"(",
"this",
",",
"// vertex shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/blurYTint.vert'",
",",
"'utf8'",
")",
",",
"// fragment shader",
"fs",
".",
"readFileSync",
"(",
"__dirname",
"+",
"'/blurYTint.frag'",
",",
"'utf8'",
")",
",",
"// set the uniforms",
"{",
"blur",
":",
"{",
"type",
":",
"'1f'",
",",
"value",
":",
"1",
"/",
"512",
"}",
",",
"color",
":",
"{",
"type",
":",
"'c'",
",",
"value",
":",
"[",
"0",
",",
"0",
",",
"0",
"]",
"}",
",",
"alpha",
":",
"{",
"type",
":",
"'1f'",
",",
"value",
":",
"0.7",
"}",
",",
"offset",
":",
"{",
"type",
":",
"'2f'",
",",
"value",
":",
"[",
"5",
",",
"5",
"]",
"}",
",",
"strength",
":",
"{",
"type",
":",
"'1f'",
",",
"value",
":",
"1",
"}",
"}",
")",
";",
"this",
".",
"passes",
"=",
"1",
";",
"this",
".",
"strength",
"=",
"4",
";",
"}"
] |
The BlurYTintFilter applies a vertical Gaussian blur to an object.
@class
@extends AbstractFilter
@memberof PIXI.filters
|
[
"The",
"BlurYTintFilter",
"applies",
"a",
"vertical",
"Gaussian",
"blur",
"to",
"an",
"object",
"."
] |
e023964d05afeefebdcac4e2044819fdfa3899ae
|
https://github.com/Nazariglez/perenquen/blob/e023964d05afeefebdcac4e2044819fdfa3899ae/lib/pixi/src/filters/dropshadow/BlurYTintFilter.js#L13-L32
|
52,513
|
wunderbyte/grunt-spiritual-dox
|
src/js/guidox@wunderbyte.com/spirits/output/dox.DocsOutputSpirit.js
|
function ( src ) {
var cuts = src.split ( "/" );
var name = cuts.pop ();
var dots = src.split ( "." );
var type = dots.pop ();
new gui.Request(src).acceptText().get().then(function(status, data) {
this._output(name, type, data);
}, this);
}
|
javascript
|
function ( src ) {
var cuts = src.split ( "/" );
var name = cuts.pop ();
var dots = src.split ( "." );
var type = dots.pop ();
new gui.Request(src).acceptText().get().then(function(status, data) {
this._output(name, type, data);
}, this);
}
|
[
"function",
"(",
"src",
")",
"{",
"var",
"cuts",
"=",
"src",
".",
"split",
"(",
"\"/\"",
")",
";",
"var",
"name",
"=",
"cuts",
".",
"pop",
"(",
")",
";",
"var",
"dots",
"=",
"src",
".",
"split",
"(",
"\".\"",
")",
";",
"var",
"type",
"=",
"dots",
".",
"pop",
"(",
")",
";",
"new",
"gui",
".",
"Request",
"(",
"src",
")",
".",
"acceptText",
"(",
")",
".",
"get",
"(",
")",
".",
"then",
"(",
"function",
"(",
"status",
",",
"data",
")",
"{",
"this",
".",
"_output",
"(",
"name",
",",
"type",
",",
"data",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] |
Fetch file from server.
@return {String} src
|
[
"Fetch",
"file",
"from",
"server",
"."
] |
5afcfe31ddbf7d654166aa15b938553b61de5811
|
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/output/dox.DocsOutputSpirit.js#L37-L45
|
|
52,514
|
wunderbyte/grunt-spiritual-dox
|
src/js/guidox@wunderbyte.com/spirits/output/dox.DocsOutputSpirit.js
|
function ( text, type ) {
switch ( type ) {
case "js" :
return new dox.JSDoc ({
title : document.title,
chapters : this._chapters ( text )
});
case "md" :
return new dox.MDDoc ({
title : document.title,
markup : this._markup ( text )
});
}
}
|
javascript
|
function ( text, type ) {
switch ( type ) {
case "js" :
return new dox.JSDoc ({
title : document.title,
chapters : this._chapters ( text )
});
case "md" :
return new dox.MDDoc ({
title : document.title,
markup : this._markup ( text )
});
}
}
|
[
"function",
"(",
"text",
",",
"type",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"\"js\"",
":",
"return",
"new",
"dox",
".",
"JSDoc",
"(",
"{",
"title",
":",
"document",
".",
"title",
",",
"chapters",
":",
"this",
".",
"_chapters",
"(",
"text",
")",
"}",
")",
";",
"case",
"\"md\"",
":",
"return",
"new",
"dox",
".",
"MDDoc",
"(",
"{",
"title",
":",
"document",
".",
"title",
",",
"markup",
":",
"this",
".",
"_markup",
"(",
"text",
")",
"}",
")",
";",
"}",
"}"
] |
Compute Doc object for file text.
@param {String} text File text
@param {String} type File type
@returns {dox.JSDoc|dox.MDDoc}
|
[
"Compute",
"Doc",
"object",
"for",
"file",
"text",
"."
] |
5afcfe31ddbf7d654166aa15b938553b61de5811
|
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/output/dox.DocsOutputSpirit.js#L66-L79
|
|
52,515
|
wunderbyte/grunt-spiritual-dox
|
src/js/guidox@wunderbyte.com/spirits/output/dox.DocsOutputSpirit.js
|
function ( source ) {
var comment = false;
var chapters = [];
var chapter = null;
var sections = [];
var section = null;
var marker = new Showdown.converter ();
function nextchapter ( title ) {
if ( chapter ) {
chapter.sections = sections.map ( function ( section, i ) {
section.desc = marker.makeHtml ( section.desc );
return section;
});
chapters.push ( chapter );
}
chapter = new dox.Chapter ({
title : title || null
});
sections = [];
}
function nextsection ( line ) {
if ( section && section.code ) {
sections.push ( section );
}
section = new dox.Block ({
line : line || 0,
tags : [],
desc : "",
code : ""
});
}
nextsection ();
nextchapter ();
source.split ( "\n" ).forEach ( function ( line, index ) {
var md, trim = line.trim ();
if ( comment ) {
if ( trim.startsWith ( "*/" )) {
comment = false;
} else {
if ( trim === "*" ) {
section.desc += "\n\n";
} else {
md = line.replace ( this._GUTTER, "" );
switch ( md [ 0 ]) {
case "@" :
section.tags.push ( new dox.Tag ({
text : this._encode ( md )
}));
break;
case "#" :
//chapter.title = md.replace ( this._HEADER, "" );
section.desc += "\n" + md + "\n\n";
break;
default :
if ( !md.match ( this._LETTER )) {
section.desc += "\n";
}
section.desc += this._encode ( md );
break;
}
}
}
} else {
if ( line.match ( this._CHAPTER )) {
var title = this._TITLE.exec ( line );
nextsection ( index );
nextchapter ( title ? title [ 0 ] : null );
section.code += this._HELLO.exec ( line );
} else {
if ( trim.startsWith ( "/**" )) {
comment = true;
nextsection ( index );
} else {
section.code += line + "\n";
}
}
}
}, this );
nextsection ();
nextchapter ();
return chapters;
}
|
javascript
|
function ( source ) {
var comment = false;
var chapters = [];
var chapter = null;
var sections = [];
var section = null;
var marker = new Showdown.converter ();
function nextchapter ( title ) {
if ( chapter ) {
chapter.sections = sections.map ( function ( section, i ) {
section.desc = marker.makeHtml ( section.desc );
return section;
});
chapters.push ( chapter );
}
chapter = new dox.Chapter ({
title : title || null
});
sections = [];
}
function nextsection ( line ) {
if ( section && section.code ) {
sections.push ( section );
}
section = new dox.Block ({
line : line || 0,
tags : [],
desc : "",
code : ""
});
}
nextsection ();
nextchapter ();
source.split ( "\n" ).forEach ( function ( line, index ) {
var md, trim = line.trim ();
if ( comment ) {
if ( trim.startsWith ( "*/" )) {
comment = false;
} else {
if ( trim === "*" ) {
section.desc += "\n\n";
} else {
md = line.replace ( this._GUTTER, "" );
switch ( md [ 0 ]) {
case "@" :
section.tags.push ( new dox.Tag ({
text : this._encode ( md )
}));
break;
case "#" :
//chapter.title = md.replace ( this._HEADER, "" );
section.desc += "\n" + md + "\n\n";
break;
default :
if ( !md.match ( this._LETTER )) {
section.desc += "\n";
}
section.desc += this._encode ( md );
break;
}
}
}
} else {
if ( line.match ( this._CHAPTER )) {
var title = this._TITLE.exec ( line );
nextsection ( index );
nextchapter ( title ? title [ 0 ] : null );
section.code += this._HELLO.exec ( line );
} else {
if ( trim.startsWith ( "/**" )) {
comment = true;
nextsection ( index );
} else {
section.code += line + "\n";
}
}
}
}, this );
nextsection ();
nextchapter ();
return chapters;
}
|
[
"function",
"(",
"source",
")",
"{",
"var",
"comment",
"=",
"false",
";",
"var",
"chapters",
"=",
"[",
"]",
";",
"var",
"chapter",
"=",
"null",
";",
"var",
"sections",
"=",
"[",
"]",
";",
"var",
"section",
"=",
"null",
";",
"var",
"marker",
"=",
"new",
"Showdown",
".",
"converter",
"(",
")",
";",
"function",
"nextchapter",
"(",
"title",
")",
"{",
"if",
"(",
"chapter",
")",
"{",
"chapter",
".",
"sections",
"=",
"sections",
".",
"map",
"(",
"function",
"(",
"section",
",",
"i",
")",
"{",
"section",
".",
"desc",
"=",
"marker",
".",
"makeHtml",
"(",
"section",
".",
"desc",
")",
";",
"return",
"section",
";",
"}",
")",
";",
"chapters",
".",
"push",
"(",
"chapter",
")",
";",
"}",
"chapter",
"=",
"new",
"dox",
".",
"Chapter",
"(",
"{",
"title",
":",
"title",
"||",
"null",
"}",
")",
";",
"sections",
"=",
"[",
"]",
";",
"}",
"function",
"nextsection",
"(",
"line",
")",
"{",
"if",
"(",
"section",
"&&",
"section",
".",
"code",
")",
"{",
"sections",
".",
"push",
"(",
"section",
")",
";",
"}",
"section",
"=",
"new",
"dox",
".",
"Block",
"(",
"{",
"line",
":",
"line",
"||",
"0",
",",
"tags",
":",
"[",
"]",
",",
"desc",
":",
"\"\"",
",",
"code",
":",
"\"\"",
"}",
")",
";",
"}",
"nextsection",
"(",
")",
";",
"nextchapter",
"(",
")",
";",
"source",
".",
"split",
"(",
"\"\\n\"",
")",
".",
"forEach",
"(",
"function",
"(",
"line",
",",
"index",
")",
"{",
"var",
"md",
",",
"trim",
"=",
"line",
".",
"trim",
"(",
")",
";",
"if",
"(",
"comment",
")",
"{",
"if",
"(",
"trim",
".",
"startsWith",
"(",
"\"*/\"",
")",
")",
"{",
"comment",
"=",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"trim",
"===",
"\"*\"",
")",
"{",
"section",
".",
"desc",
"+=",
"\"\\n\\n\"",
";",
"}",
"else",
"{",
"md",
"=",
"line",
".",
"replace",
"(",
"this",
".",
"_GUTTER",
",",
"\"\"",
")",
";",
"switch",
"(",
"md",
"[",
"0",
"]",
")",
"{",
"case",
"\"@\"",
":",
"section",
".",
"tags",
".",
"push",
"(",
"new",
"dox",
".",
"Tag",
"(",
"{",
"text",
":",
"this",
".",
"_encode",
"(",
"md",
")",
"}",
")",
")",
";",
"break",
";",
"case",
"\"#\"",
":",
"//chapter.title = md.replace ( this._HEADER, \"\" );",
"section",
".",
"desc",
"+=",
"\"\\n\"",
"+",
"md",
"+",
"\"\\n\\n\"",
";",
"break",
";",
"default",
":",
"if",
"(",
"!",
"md",
".",
"match",
"(",
"this",
".",
"_LETTER",
")",
")",
"{",
"section",
".",
"desc",
"+=",
"\"\\n\"",
";",
"}",
"section",
".",
"desc",
"+=",
"this",
".",
"_encode",
"(",
"md",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"line",
".",
"match",
"(",
"this",
".",
"_CHAPTER",
")",
")",
"{",
"var",
"title",
"=",
"this",
".",
"_TITLE",
".",
"exec",
"(",
"line",
")",
";",
"nextsection",
"(",
"index",
")",
";",
"nextchapter",
"(",
"title",
"?",
"title",
"[",
"0",
"]",
":",
"null",
")",
";",
"section",
".",
"code",
"+=",
"this",
".",
"_HELLO",
".",
"exec",
"(",
"line",
")",
";",
"}",
"else",
"{",
"if",
"(",
"trim",
".",
"startsWith",
"(",
"\"/**\"",
")",
")",
"{",
"comment",
"=",
"true",
";",
"nextsection",
"(",
"index",
")",
";",
"}",
"else",
"{",
"section",
".",
"code",
"+=",
"line",
"+",
"\"\\n\"",
";",
"}",
"}",
"}",
"}",
",",
"this",
")",
";",
"nextsection",
"(",
")",
";",
"nextchapter",
"(",
")",
";",
"return",
"chapters",
";",
"}"
] |
Parse source code to chapters.
@param {String} source
@return {Array<dox.Chapter>}
|
[
"Parse",
"source",
"code",
"to",
"chapters",
"."
] |
5afcfe31ddbf7d654166aa15b938553b61de5811
|
https://github.com/wunderbyte/grunt-spiritual-dox/blob/5afcfe31ddbf7d654166aa15b938553b61de5811/src/js/guidox@wunderbyte.com/spirits/output/dox.DocsOutputSpirit.js#L86-L171
|
|
52,516
|
IonicaBizau/indento
|
lib/index.js
|
indento
|
function indento(input, width, char) {
char = typeof char !== "string" ? " " : char;
return String(input).replace(/^/gm, char.repeat(width));
}
|
javascript
|
function indento(input, width, char) {
char = typeof char !== "string" ? " " : char;
return String(input).replace(/^/gm, char.repeat(width));
}
|
[
"function",
"indento",
"(",
"input",
",",
"width",
",",
"char",
")",
"{",
"char",
"=",
"typeof",
"char",
"!==",
"\"string\"",
"?",
"\" \"",
":",
"char",
";",
"return",
"String",
"(",
"input",
")",
".",
"replace",
"(",
"/",
"^",
"/",
"gm",
",",
"char",
".",
"repeat",
"(",
"width",
")",
")",
";",
"}"
] |
indento
Indents the input string.
@name indento
@function
@param {String} input The input string.
@param {Number} width The indent width.
@param {String} char The character to use for indentation (default: `" "`).
@return {String} The indented string.
|
[
"indento",
"Indents",
"the",
"input",
"string",
"."
] |
8d1a2745ff03bd92484e115eb28c473c09e52c02
|
https://github.com/IonicaBizau/indento/blob/8d1a2745ff03bd92484e115eb28c473c09e52c02/lib/index.js#L12-L15
|
52,517
|
Jonjump/trakter
|
index.js
|
request
|
function request (suppliedOptions,data,next)
{
var options = makeOptions(suppliedOptions);
switch (options.method ? options.method.toUpperCase() : "BADMETHOD") {
case "PUT":
case "POST":
var dataString = JSON.stringify(data);
options.headers['Content-Length'] = dataString.length;
var req = https.request(options,requestDone);
req.end(dataString);
break;
case "GET":
case "DELETE":
var req = https.request(options,requestDone);
req.end();
break;
case "BADMETHOD":
default:
var e = new Error('trakter: invalid method or not specified');
e.name = 'TrakterBadMethod';
e.code = 97;
next (e);
break;
}
function requestDone(res) {
res.setEncoding('utf8');
var responseString = '';
res.on('error', function(err) {
next (err,null);
});
res.on('data', function(data) {
responseString += data;
});
res.on('end', function() {
var err = checkError(options.method,res);
if ( err !== null) {
next (err);
} else {
next (null,JSON.parse(responseString));
}
});
}
}
|
javascript
|
function request (suppliedOptions,data,next)
{
var options = makeOptions(suppliedOptions);
switch (options.method ? options.method.toUpperCase() : "BADMETHOD") {
case "PUT":
case "POST":
var dataString = JSON.stringify(data);
options.headers['Content-Length'] = dataString.length;
var req = https.request(options,requestDone);
req.end(dataString);
break;
case "GET":
case "DELETE":
var req = https.request(options,requestDone);
req.end();
break;
case "BADMETHOD":
default:
var e = new Error('trakter: invalid method or not specified');
e.name = 'TrakterBadMethod';
e.code = 97;
next (e);
break;
}
function requestDone(res) {
res.setEncoding('utf8');
var responseString = '';
res.on('error', function(err) {
next (err,null);
});
res.on('data', function(data) {
responseString += data;
});
res.on('end', function() {
var err = checkError(options.method,res);
if ( err !== null) {
next (err);
} else {
next (null,JSON.parse(responseString));
}
});
}
}
|
[
"function",
"request",
"(",
"suppliedOptions",
",",
"data",
",",
"next",
")",
"{",
"var",
"options",
"=",
"makeOptions",
"(",
"suppliedOptions",
")",
";",
"switch",
"(",
"options",
".",
"method",
"?",
"options",
".",
"method",
".",
"toUpperCase",
"(",
")",
":",
"\"BADMETHOD\"",
")",
"{",
"case",
"\"PUT\"",
":",
"case",
"\"POST\"",
":",
"var",
"dataString",
"=",
"JSON",
".",
"stringify",
"(",
"data",
")",
";",
"options",
".",
"headers",
"[",
"'Content-Length'",
"]",
"=",
"dataString",
".",
"length",
";",
"var",
"req",
"=",
"https",
".",
"request",
"(",
"options",
",",
"requestDone",
")",
";",
"req",
".",
"end",
"(",
"dataString",
")",
";",
"break",
";",
"case",
"\"GET\"",
":",
"case",
"\"DELETE\"",
":",
"var",
"req",
"=",
"https",
".",
"request",
"(",
"options",
",",
"requestDone",
")",
";",
"req",
".",
"end",
"(",
")",
";",
"break",
";",
"case",
"\"BADMETHOD\"",
":",
"default",
":",
"var",
"e",
"=",
"new",
"Error",
"(",
"'trakter: invalid method or not specified'",
")",
";",
"e",
".",
"name",
"=",
"'TrakterBadMethod'",
";",
"e",
".",
"code",
"=",
"97",
";",
"next",
"(",
"e",
")",
";",
"break",
";",
"}",
"function",
"requestDone",
"(",
"res",
")",
"{",
"res",
".",
"setEncoding",
"(",
"'utf8'",
")",
";",
"var",
"responseString",
"=",
"''",
";",
"res",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"err",
")",
"{",
"next",
"(",
"err",
",",
"null",
")",
";",
"}",
")",
";",
"res",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"data",
")",
"{",
"responseString",
"+=",
"data",
";",
"}",
")",
";",
"res",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"var",
"err",
"=",
"checkError",
"(",
"options",
".",
"method",
",",
"res",
")",
";",
"if",
"(",
"err",
"!==",
"null",
")",
"{",
"next",
"(",
"err",
")",
";",
"}",
"else",
"{",
"next",
"(",
"null",
",",
"JSON",
".",
"parse",
"(",
"responseString",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] |
make a request to Trakt.tv
@method request
@param {Object} options The options for the call
@param {Object} data The data for the call, or null
@param {Function} next(err,traktResponseString)
@example
trakter.request(options,data,next )
|
[
"make",
"a",
"request",
"to",
"Trakt",
".",
"tv"
] |
637c73bd67c3507660e3057570c726420553c9f2
|
https://github.com/Jonjump/trakter/blob/637c73bd67c3507660e3057570c726420553c9f2/index.js#L95-L139
|
52,518
|
MakerCollider/upm_mc
|
doxy/node/generators/ternjs/generator.js
|
GENERATE_CLASSES
|
function GENERATE_CLASSES(classes) {
var docs = {};
_.each(classes, function(classSpec, parentClass) {
var constructor = classSpec.methods[parentClass];
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
if (_.has(docs, parentClass)) {
_.each(classSpec.enums, function(enumSpec, enumName) {
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
});
docs[parentClass].prototype = {};
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
});
_.each(classSpec.variables, function(variableSpec, variableName) {
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
});
}
});
return docs;
}
|
javascript
|
function GENERATE_CLASSES(classes) {
var docs = {};
_.each(classes, function(classSpec, parentClass) {
var constructor = classSpec.methods[parentClass];
_.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
if (_.has(docs, parentClass)) {
_.each(classSpec.enums, function(enumSpec, enumName) {
_.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
});
docs[parentClass].prototype = {};
_.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
_.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
});
_.each(classSpec.variables, function(variableSpec, variableName) {
_.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
});
}
});
return docs;
}
|
[
"function",
"GENERATE_CLASSES",
"(",
"classes",
")",
"{",
"var",
"docs",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"classes",
",",
"function",
"(",
"classSpec",
",",
"parentClass",
")",
"{",
"var",
"constructor",
"=",
"classSpec",
".",
"methods",
"[",
"parentClass",
"]",
";",
"_",
".",
"extend",
"(",
"docs",
",",
"GENERATE_METHOD",
"(",
"parentClass",
",",
"constructor",
"?",
"constructor",
":",
"{",
"params",
":",
"{",
"}",
",",
"return",
":",
"{",
"}",
",",
"description",
":",
"''",
"}",
")",
")",
";",
"if",
"(",
"_",
".",
"has",
"(",
"docs",
",",
"parentClass",
")",
")",
"{",
"_",
".",
"each",
"(",
"classSpec",
".",
"enums",
",",
"function",
"(",
"enumSpec",
",",
"enumName",
")",
"{",
"_",
".",
"extend",
"(",
"docs",
"[",
"parentClass",
"]",
",",
"GENERATE_ENUM",
"(",
"enumName",
",",
"enumSpec",
")",
")",
";",
"}",
")",
";",
"docs",
"[",
"parentClass",
"]",
".",
"prototype",
"=",
"{",
"}",
";",
"_",
".",
"each",
"(",
"_",
".",
"omit",
"(",
"classSpec",
".",
"methods",
",",
"parentClass",
")",
",",
"function",
"(",
"methodSpec",
",",
"methodName",
")",
"{",
"_",
".",
"extend",
"(",
"docs",
"[",
"parentClass",
"]",
".",
"prototype",
",",
"GENERATE_METHOD",
"(",
"methodName",
",",
"methodSpec",
")",
")",
";",
"}",
")",
";",
"_",
".",
"each",
"(",
"classSpec",
".",
"variables",
",",
"function",
"(",
"variableSpec",
",",
"variableName",
")",
"{",
"_",
".",
"extend",
"(",
"docs",
"[",
"parentClass",
"]",
".",
"prototype",
",",
"GENERATE_VARIABLE",
"(",
"variableName",
",",
"variableSpec",
")",
")",
";",
"}",
")",
";",
"}",
"}",
")",
";",
"return",
"docs",
";",
"}"
] |
generate the spec for the given list of classes
|
[
"generate",
"the",
"spec",
"for",
"the",
"given",
"list",
"of",
"classes"
] |
525e775a17b85c30716c00435a2acb26bb198c12
|
https://github.com/MakerCollider/upm_mc/blob/525e775a17b85c30716c00435a2acb26bb198c12/doxy/node/generators/ternjs/generator.js#L69-L88
|
52,519
|
MakerCollider/upm_mc
|
doxy/node/generators/ternjs/generator.js
|
GENERATE_METHOD
|
function GENERATE_METHOD(name, spec) {
var doc = {};
doc[name] = {
'!type': 'fn(' + GENERATE_PARAMS(spec.params) + ')' + GENERATE_RETURN(spec.return),
'!doc': spec.description
}
return doc;
}
|
javascript
|
function GENERATE_METHOD(name, spec) {
var doc = {};
doc[name] = {
'!type': 'fn(' + GENERATE_PARAMS(spec.params) + ')' + GENERATE_RETURN(spec.return),
'!doc': spec.description
}
return doc;
}
|
[
"function",
"GENERATE_METHOD",
"(",
"name",
",",
"spec",
")",
"{",
"var",
"doc",
"=",
"{",
"}",
";",
"doc",
"[",
"name",
"]",
"=",
"{",
"'!type'",
":",
"'fn('",
"+",
"GENERATE_PARAMS",
"(",
"spec",
".",
"params",
")",
"+",
"')'",
"+",
"GENERATE_RETURN",
"(",
"spec",
".",
"return",
")",
",",
"'!doc'",
":",
"spec",
".",
"description",
"}",
"return",
"doc",
";",
"}"
] |
generate method spec
|
[
"generate",
"method",
"spec"
] |
525e775a17b85c30716c00435a2acb26bb198c12
|
https://github.com/MakerCollider/upm_mc/blob/525e775a17b85c30716c00435a2acb26bb198c12/doxy/node/generators/ternjs/generator.js#L92-L99
|
52,520
|
MakerCollider/upm_mc
|
doxy/node/generators/ternjs/generator.js
|
GENERATE_PARAMS
|
function GENERATE_PARAMS(spec) {
return _.map(spec, function(paramSpec, paramName) {
return paramName + ': ' + paramSpec.type;
}).join(', ');
}
|
javascript
|
function GENERATE_PARAMS(spec) {
return _.map(spec, function(paramSpec, paramName) {
return paramName + ': ' + paramSpec.type;
}).join(', ');
}
|
[
"function",
"GENERATE_PARAMS",
"(",
"spec",
")",
"{",
"return",
"_",
".",
"map",
"(",
"spec",
",",
"function",
"(",
"paramSpec",
",",
"paramName",
")",
"{",
"return",
"paramName",
"+",
"': '",
"+",
"paramSpec",
".",
"type",
";",
"}",
")",
".",
"join",
"(",
"', '",
")",
";",
"}"
] |
generate parameter signatures for method
|
[
"generate",
"parameter",
"signatures",
"for",
"method"
] |
525e775a17b85c30716c00435a2acb26bb198c12
|
https://github.com/MakerCollider/upm_mc/blob/525e775a17b85c30716c00435a2acb26bb198c12/doxy/node/generators/ternjs/generator.js#L103-L107
|
52,521
|
sendanor/nor-db
|
orig/2013-08-21/extend.js
|
extend_if_promise
|
function extend_if_promise(methods, ret) {
if(ret && ret.then) { // Check if return value is promise compatible
return extend.promise(methods, ret); // ..and if so, extend it, too.
}
return ret; // ..and if not, return the same value.
}
|
javascript
|
function extend_if_promise(methods, ret) {
if(ret && ret.then) { // Check if return value is promise compatible
return extend.promise(methods, ret); // ..and if so, extend it, too.
}
return ret; // ..and if not, return the same value.
}
|
[
"function",
"extend_if_promise",
"(",
"methods",
",",
"ret",
")",
"{",
"if",
"(",
"ret",
"&&",
"ret",
".",
"then",
")",
"{",
"// Check if return value is promise compatible",
"return",
"extend",
".",
"promise",
"(",
"methods",
",",
"ret",
")",
";",
"// ..and if so, extend it, too.",
"}",
"return",
"ret",
";",
"// ..and if not, return the same value.",
"}"
] |
original extend_promise Extend the value if it's a promise, otherwise just return it instead.
@returns the extended promise or the value itself.
|
[
"original",
"extend_promise",
"Extend",
"the",
"value",
"if",
"it",
"s",
"a",
"promise",
"otherwise",
"just",
"return",
"it",
"instead",
"."
] |
db4b78691956a49370fc9d9a4eed27e7d3720aeb
|
https://github.com/sendanor/nor-db/blob/db4b78691956a49370fc9d9a4eed27e7d3720aeb/orig/2013-08-21/extend.js#L52-L57
|
52,522
|
node-ci/nci-projects-reloader
|
lib/index.js
|
function(filename, fileInfo) {
var projectName = path.relative(
app.config.paths.projects,
path.dirname(filename)
);
if (app.projects.get(projectName)) {
logger.log('Unload project: "' + projectName + '"');
app.projects.unload({name: projectName});
}
// on add or change (info is falsy on unlink)
if (fileInfo) {
logger.log('Load project "' + projectName + '" on change');
app.projects.load({name: projectName}, function(err) {
if (err) {
return logger.error(
'Error during load project "' + projectName + '": ',
err.stack || err
);
}
logger.log(
'Project "' + projectName + '" loaded:',
JSON.stringify(app.projects.get(projectName), null, 4)
);
});
}
}
|
javascript
|
function(filename, fileInfo) {
var projectName = path.relative(
app.config.paths.projects,
path.dirname(filename)
);
if (app.projects.get(projectName)) {
logger.log('Unload project: "' + projectName + '"');
app.projects.unload({name: projectName});
}
// on add or change (info is falsy on unlink)
if (fileInfo) {
logger.log('Load project "' + projectName + '" on change');
app.projects.load({name: projectName}, function(err) {
if (err) {
return logger.error(
'Error during load project "' + projectName + '": ',
err.stack || err
);
}
logger.log(
'Project "' + projectName + '" loaded:',
JSON.stringify(app.projects.get(projectName), null, 4)
);
});
}
}
|
[
"function",
"(",
"filename",
",",
"fileInfo",
")",
"{",
"var",
"projectName",
"=",
"path",
".",
"relative",
"(",
"app",
".",
"config",
".",
"paths",
".",
"projects",
",",
"path",
".",
"dirname",
"(",
"filename",
")",
")",
";",
"if",
"(",
"app",
".",
"projects",
".",
"get",
"(",
"projectName",
")",
")",
"{",
"logger",
".",
"log",
"(",
"'Unload project: \"'",
"+",
"projectName",
"+",
"'\"'",
")",
";",
"app",
".",
"projects",
".",
"unload",
"(",
"{",
"name",
":",
"projectName",
"}",
")",
";",
"}",
"// on add or change (info is falsy on unlink)",
"if",
"(",
"fileInfo",
")",
"{",
"logger",
".",
"log",
"(",
"'Load project \"'",
"+",
"projectName",
"+",
"'\" on change'",
")",
";",
"app",
".",
"projects",
".",
"load",
"(",
"{",
"name",
":",
"projectName",
"}",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"logger",
".",
"error",
"(",
"'Error during load project \"'",
"+",
"projectName",
"+",
"'\": '",
",",
"err",
".",
"stack",
"||",
"err",
")",
";",
"}",
"logger",
".",
"log",
"(",
"'Project \"'",
"+",
"projectName",
"+",
"'\" loaded:'",
",",
"JSON",
".",
"stringify",
"(",
"app",
".",
"projects",
".",
"get",
"(",
"projectName",
")",
",",
"null",
",",
"4",
")",
")",
";",
"}",
")",
";",
"}",
"}"
] |
start file watcher for reloading projects on change
|
[
"start",
"file",
"watcher",
"for",
"reloading",
"projects",
"on",
"change"
] |
25f125a5135853e9cffd4db62246e0a6984d0fc3
|
https://github.com/node-ci/nci-projects-reloader/blob/25f125a5135853e9cffd4db62246e0a6984d0fc3/lib/index.js#L10-L37
|
|
52,523
|
mikolalysenko/splat-points
|
splat.js
|
splatND
|
function splatND(out, points, weights, radius) {
var n = points.shape[0]
var d = points.shape[1]
var lo = new Array(d)
var hi = new Array(d)
var bounds = out.shape
var coord = new Array(d+1)
var w = 1.0
function splatRec(k) {
if(k < 0) {
coord[d] = out.get.apply(out, coord) + w
out.set.apply(out, coord)
return
}
var wprev = w
var x = points.get(i, k)
for(coord[k]=lo[k]; coord[k]<hi[k]; ++coord[k]) {
w = wprev * dirichlet(bounds[k], coord[k] - x)
splatRec(k-1)
}
w = wprev
}
for(var i=0; i<=d; ++i) {
coord[i] = 0
}
for(var i=0; i<n; ++i) {
for(var j=0; j<d; ++j) {
var x = points.get(i,j)
lo[j] = Math.max(x-radius, 0)
hi[j] = Math.min(x+radius, bounds[j]-1)
}
w = weights.get(i)
splatRec(d-1)
}
}
|
javascript
|
function splatND(out, points, weights, radius) {
var n = points.shape[0]
var d = points.shape[1]
var lo = new Array(d)
var hi = new Array(d)
var bounds = out.shape
var coord = new Array(d+1)
var w = 1.0
function splatRec(k) {
if(k < 0) {
coord[d] = out.get.apply(out, coord) + w
out.set.apply(out, coord)
return
}
var wprev = w
var x = points.get(i, k)
for(coord[k]=lo[k]; coord[k]<hi[k]; ++coord[k]) {
w = wprev * dirichlet(bounds[k], coord[k] - x)
splatRec(k-1)
}
w = wprev
}
for(var i=0; i<=d; ++i) {
coord[i] = 0
}
for(var i=0; i<n; ++i) {
for(var j=0; j<d; ++j) {
var x = points.get(i,j)
lo[j] = Math.max(x-radius, 0)
hi[j] = Math.min(x+radius, bounds[j]-1)
}
w = weights.get(i)
splatRec(d-1)
}
}
|
[
"function",
"splatND",
"(",
"out",
",",
"points",
",",
"weights",
",",
"radius",
")",
"{",
"var",
"n",
"=",
"points",
".",
"shape",
"[",
"0",
"]",
"var",
"d",
"=",
"points",
".",
"shape",
"[",
"1",
"]",
"var",
"lo",
"=",
"new",
"Array",
"(",
"d",
")",
"var",
"hi",
"=",
"new",
"Array",
"(",
"d",
")",
"var",
"bounds",
"=",
"out",
".",
"shape",
"var",
"coord",
"=",
"new",
"Array",
"(",
"d",
"+",
"1",
")",
"var",
"w",
"=",
"1.0",
"function",
"splatRec",
"(",
"k",
")",
"{",
"if",
"(",
"k",
"<",
"0",
")",
"{",
"coord",
"[",
"d",
"]",
"=",
"out",
".",
"get",
".",
"apply",
"(",
"out",
",",
"coord",
")",
"+",
"w",
"out",
".",
"set",
".",
"apply",
"(",
"out",
",",
"coord",
")",
"return",
"}",
"var",
"wprev",
"=",
"w",
"var",
"x",
"=",
"points",
".",
"get",
"(",
"i",
",",
"k",
")",
"for",
"(",
"coord",
"[",
"k",
"]",
"=",
"lo",
"[",
"k",
"]",
";",
"coord",
"[",
"k",
"]",
"<",
"hi",
"[",
"k",
"]",
";",
"++",
"coord",
"[",
"k",
"]",
")",
"{",
"w",
"=",
"wprev",
"*",
"dirichlet",
"(",
"bounds",
"[",
"k",
"]",
",",
"coord",
"[",
"k",
"]",
"-",
"x",
")",
"splatRec",
"(",
"k",
"-",
"1",
")",
"}",
"w",
"=",
"wprev",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<=",
"d",
";",
"++",
"i",
")",
"{",
"coord",
"[",
"i",
"]",
"=",
"0",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"d",
";",
"++",
"j",
")",
"{",
"var",
"x",
"=",
"points",
".",
"get",
"(",
"i",
",",
"j",
")",
"lo",
"[",
"j",
"]",
"=",
"Math",
".",
"max",
"(",
"x",
"-",
"radius",
",",
"0",
")",
"hi",
"[",
"j",
"]",
"=",
"Math",
".",
"min",
"(",
"x",
"+",
"radius",
",",
"bounds",
"[",
"j",
"]",
"-",
"1",
")",
"}",
"w",
"=",
"weights",
".",
"get",
"(",
"i",
")",
"splatRec",
"(",
"d",
"-",
"1",
")",
"}",
"}"
] |
Slow generic routine
|
[
"Slow",
"generic",
"routine"
] |
d89e439d27795130ee9f4f597670ef0376f13b39
|
https://github.com/mikolalysenko/splat-points/blob/d89e439d27795130ee9f4f597670ef0376f13b39/splat.js#L14-L50
|
52,524
|
novadiscovery/nway
|
lib/templates/loader.js
|
fireOnLoad
|
function fireOnLoad() {
var args = arguments, i;
for(i = 0, len = addOnLoadHandler.stack.length; i<len; i++) {
addOnLoadHandler.stack[i].apply(null, args);
}
}
|
javascript
|
function fireOnLoad() {
var args = arguments, i;
for(i = 0, len = addOnLoadHandler.stack.length; i<len; i++) {
addOnLoadHandler.stack[i].apply(null, args);
}
}
|
[
"function",
"fireOnLoad",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
",",
"i",
";",
"for",
"(",
"i",
"=",
"0",
",",
"len",
"=",
"addOnLoadHandler",
".",
"stack",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"addOnLoadHandler",
".",
"stack",
"[",
"i",
"]",
".",
"apply",
"(",
"null",
",",
"args",
")",
";",
"}",
"}"
] |
Call on load handlers
|
[
"Call",
"on",
"load",
"handlers"
] |
fa31c6fe56f2305721e581ac25e8ac9a87e15dda
|
https://github.com/novadiscovery/nway/blob/fa31c6fe56f2305721e581ac25e8ac9a87e15dda/lib/templates/loader.js#L23-L28
|
52,525
|
novadiscovery/nway
|
lib/templates/loader.js
|
findHash
|
function findHash(path) {
var h, m, len;
for(h in config.map) {
var modules = config.map[h];
for(m = 0, len = modules.length; m < len; m++ ) {
if(modules[m] === path) return h
}
}
return null;
}
|
javascript
|
function findHash(path) {
var h, m, len;
for(h in config.map) {
var modules = config.map[h];
for(m = 0, len = modules.length; m < len; m++ ) {
if(modules[m] === path) return h
}
}
return null;
}
|
[
"function",
"findHash",
"(",
"path",
")",
"{",
"var",
"h",
",",
"m",
",",
"len",
";",
"for",
"(",
"h",
"in",
"config",
".",
"map",
")",
"{",
"var",
"modules",
"=",
"config",
".",
"map",
"[",
"h",
"]",
";",
"for",
"(",
"m",
"=",
"0",
",",
"len",
"=",
"modules",
".",
"length",
";",
"m",
"<",
"len",
";",
"m",
"++",
")",
"{",
"if",
"(",
"modules",
"[",
"m",
"]",
"===",
"path",
")",
"return",
"h",
"}",
"}",
"return",
"null",
";",
"}"
] |
Find the pack hash for the given path
@param {string} path The path to resolve
@return {string} The hash for the path
@api private
|
[
"Find",
"the",
"pack",
"hash",
"for",
"the",
"given",
"path"
] |
fa31c6fe56f2305721e581ac25e8ac9a87e15dda
|
https://github.com/novadiscovery/nway/blob/fa31c6fe56f2305721e581ac25e8ac9a87e15dda/lib/templates/loader.js#L52-L61
|
52,526
|
novadiscovery/nway
|
lib/templates/loader.js
|
scriptLoader
|
function scriptLoader(url, callback) {
var doc = document, s = doc.createElement("script")
, head = doc.getElementsByTagName("head")[0]
, node
, done = false;
;
// On success listener
function onScriptLoad() {
if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") )
{
done = true;
callback();
}
}
// On failure listener (callback receive an error false)
function onScriptError() {
callback(new Error("Packet loading error for " + url));
}
// Create the script tag
node = document.createElement('script')
node.type = config.scriptType || 'text/javascript';
node.charset = 'utf-8';
node.async = true;
// Listen to the onload event
if (node.attachEvent &&
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0)) {
node.attachEvent('onreadystatechange', onScriptLoad);
} else {
node.addEventListener('load', onScriptLoad, false);
node.addEventListener('error', onScriptError, false);
}
// Set the src value with the packed script url
node.src = url;
// Start loading by adding the script tag in the head
head.appendChild(node);
}
|
javascript
|
function scriptLoader(url, callback) {
var doc = document, s = doc.createElement("script")
, head = doc.getElementsByTagName("head")[0]
, node
, done = false;
;
// On success listener
function onScriptLoad() {
if ( !done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete") )
{
done = true;
callback();
}
}
// On failure listener (callback receive an error false)
function onScriptError() {
callback(new Error("Packet loading error for " + url));
}
// Create the script tag
node = document.createElement('script')
node.type = config.scriptType || 'text/javascript';
node.charset = 'utf-8';
node.async = true;
// Listen to the onload event
if (node.attachEvent &&
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0)) {
node.attachEvent('onreadystatechange', onScriptLoad);
} else {
node.addEventListener('load', onScriptLoad, false);
node.addEventListener('error', onScriptError, false);
}
// Set the src value with the packed script url
node.src = url;
// Start loading by adding the script tag in the head
head.appendChild(node);
}
|
[
"function",
"scriptLoader",
"(",
"url",
",",
"callback",
")",
"{",
"var",
"doc",
"=",
"document",
",",
"s",
"=",
"doc",
".",
"createElement",
"(",
"\"script\"",
")",
",",
"head",
"=",
"doc",
".",
"getElementsByTagName",
"(",
"\"head\"",
")",
"[",
"0",
"]",
",",
"node",
",",
"done",
"=",
"false",
";",
";",
"// On success listener",
"function",
"onScriptLoad",
"(",
")",
"{",
"if",
"(",
"!",
"done",
"&&",
"(",
"!",
"this",
".",
"readyState",
"||",
"this",
".",
"readyState",
"==",
"\"loaded\"",
"||",
"this",
".",
"readyState",
"==",
"\"complete\"",
")",
")",
"{",
"done",
"=",
"true",
";",
"callback",
"(",
")",
";",
"}",
"}",
"// On failure listener (callback receive an error false)",
"function",
"onScriptError",
"(",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"\"Packet loading error for \"",
"+",
"url",
")",
")",
";",
"}",
"// Create the script tag",
"node",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
"node",
".",
"type",
"=",
"config",
".",
"scriptType",
"||",
"'text/javascript'",
";",
"node",
".",
"charset",
"=",
"'utf-8'",
";",
"node",
".",
"async",
"=",
"true",
";",
"// Listen to the onload event",
"if",
"(",
"node",
".",
"attachEvent",
"&&",
"!",
"(",
"node",
".",
"attachEvent",
".",
"toString",
"&&",
"node",
".",
"attachEvent",
".",
"toString",
"(",
")",
".",
"indexOf",
"(",
"'[native code'",
")",
"<",
"0",
")",
")",
"{",
"node",
".",
"attachEvent",
"(",
"'onreadystatechange'",
",",
"onScriptLoad",
")",
";",
"}",
"else",
"{",
"node",
".",
"addEventListener",
"(",
"'load'",
",",
"onScriptLoad",
",",
"false",
")",
";",
"node",
".",
"addEventListener",
"(",
"'error'",
",",
"onScriptError",
",",
"false",
")",
";",
"}",
"// Set the src value with the packed script url",
"node",
".",
"src",
"=",
"url",
";",
"// Start loading by adding the script tag in the head",
"head",
".",
"appendChild",
"(",
"node",
")",
";",
"}"
] |
The script loader
Load a packed script and return to the callback the resulting
value
@param {string} url The packed script url
@param {Function} callback A callback function that receive and error object
|
[
"The",
"script",
"loader"
] |
fa31c6fe56f2305721e581ac25e8ac9a87e15dda
|
https://github.com/novadiscovery/nway/blob/fa31c6fe56f2305721e581ac25e8ac9a87e15dda/lib/templates/loader.js#L73-L116
|
52,527
|
RaphaelDeLaGhetto/gebo-utils
|
index.js
|
_getMongoDbName
|
function _getMongoDbName(str) {
if (!/[/\. "*<>:|?@]/.test(str)) {
return str;
}
str = str.replace(/\//g, exports.constants.slash);
str = str.replace(/\\/g, exports.constants.backslash);
str = str.replace(/\./g, exports.constants.dot);
str = str.replace(/ /g, exports.constants.space);
str = str.replace(/"/g, exports.constants.doubleQuotes);
str = str.replace(/\*/g, exports.constants.star);
str = str.replace(/</g, exports.constants.lessThan);
str = str.replace(/>/g, exports.constants.greaterThan);
str = str.replace(/:/g, exports.constants.colon);
str = str.replace(/\|/g, exports.constants.pipe);
str = str.replace(/\?/g, exports.constants.questionMark);
str = str.replace(/@/g, exports.constants.at);
return str;
}
|
javascript
|
function _getMongoDbName(str) {
if (!/[/\. "*<>:|?@]/.test(str)) {
return str;
}
str = str.replace(/\//g, exports.constants.slash);
str = str.replace(/\\/g, exports.constants.backslash);
str = str.replace(/\./g, exports.constants.dot);
str = str.replace(/ /g, exports.constants.space);
str = str.replace(/"/g, exports.constants.doubleQuotes);
str = str.replace(/\*/g, exports.constants.star);
str = str.replace(/</g, exports.constants.lessThan);
str = str.replace(/>/g, exports.constants.greaterThan);
str = str.replace(/:/g, exports.constants.colon);
str = str.replace(/\|/g, exports.constants.pipe);
str = str.replace(/\?/g, exports.constants.questionMark);
str = str.replace(/@/g, exports.constants.at);
return str;
}
|
[
"function",
"_getMongoDbName",
"(",
"str",
")",
"{",
"if",
"(",
"!",
"/",
"[/\\. \"*<>:|?@]",
"/",
".",
"test",
"(",
"str",
")",
")",
"{",
"return",
"str",
";",
"}",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"slash",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"backslash",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"dot",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
" ",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"space",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\"",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"doubleQuotes",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\*",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"star",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"<",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"lessThan",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
">",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"greaterThan",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
":",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"colon",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\|",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"pipe",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"\\?",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"questionMark",
")",
";",
"str",
"=",
"str",
".",
"replace",
"(",
"/",
"@",
"/",
"g",
",",
"exports",
".",
"constants",
".",
"at",
")",
";",
"return",
"str",
";",
"}"
] |
Make the gebo user's email address suitable for naming
a database... and more!
Mongo does not allow these characters: /\. "*<>:|?
(http://docs.mongodb.org/manual/reference/limits/)
This function sanitizes @s as well, though it is not
required by Mongo.
@param string
@return string
|
[
"Make",
"the",
"gebo",
"user",
"s",
"email",
"address",
"suitable",
"for",
"naming",
"a",
"database",
"...",
"and",
"more!"
] |
338bc15f8a94621f145eb378f0b42123548ca545
|
https://github.com/RaphaelDeLaGhetto/gebo-utils/blob/338bc15f8a94621f145eb378f0b42123548ca545/index.js#L94-L113
|
52,528
|
RaphaelDeLaGhetto/gebo-utils
|
index.js
|
_getSafeFileName
|
function _getSafeFileName(filename, directory) {
var deferred = q.defer();
fs.readdir(directory, function(err, files) {
if(err) {
// This means the directory doesn't exist
if (err.errno === 34 && err.code === 'ENOENT') {
deferred.resolve(filename);
}
else {
deferred.reject(err);
}
}
else {
var index = files.indexOf(filename);
if (index > -1) {
// Get filename and extension (if it has one)
var name, extension;
var splitString = filename.split('.');
// Has extension
if (splitString.length > 1) {
extension = splitString.pop();
name = splitString.join('.');
// Wait! Is this a hidden file?
if (!name) {
name = '.' + extension;
extension = '';
}
}
// No extension
else {
name = filename;
extension = '';
}
// Get the copy number appended to the name and increment, if any
var matches = name.match(/\((\d+)\)$/);
if (matches) {
var copyNumber = Number(matches[1]) + 1;
name = name.replace(/\((\d+)\)$/, '(' + copyNumber + ')');
}
else {
name += '(1)';
}
// Assemble new filename
if (extension) {
filename = name + '.' + extension;
}
else {
filename = name;
}
deferred.resolve(_getSafeFileName(filename, directory));
}
else {
deferred.resolve(filename);
}
}
});
return deferred.promise;
}
|
javascript
|
function _getSafeFileName(filename, directory) {
var deferred = q.defer();
fs.readdir(directory, function(err, files) {
if(err) {
// This means the directory doesn't exist
if (err.errno === 34 && err.code === 'ENOENT') {
deferred.resolve(filename);
}
else {
deferred.reject(err);
}
}
else {
var index = files.indexOf(filename);
if (index > -1) {
// Get filename and extension (if it has one)
var name, extension;
var splitString = filename.split('.');
// Has extension
if (splitString.length > 1) {
extension = splitString.pop();
name = splitString.join('.');
// Wait! Is this a hidden file?
if (!name) {
name = '.' + extension;
extension = '';
}
}
// No extension
else {
name = filename;
extension = '';
}
// Get the copy number appended to the name and increment, if any
var matches = name.match(/\((\d+)\)$/);
if (matches) {
var copyNumber = Number(matches[1]) + 1;
name = name.replace(/\((\d+)\)$/, '(' + copyNumber + ')');
}
else {
name += '(1)';
}
// Assemble new filename
if (extension) {
filename = name + '.' + extension;
}
else {
filename = name;
}
deferred.resolve(_getSafeFileName(filename, directory));
}
else {
deferred.resolve(filename);
}
}
});
return deferred.promise;
}
|
[
"function",
"_getSafeFileName",
"(",
"filename",
",",
"directory",
")",
"{",
"var",
"deferred",
"=",
"q",
".",
"defer",
"(",
")",
";",
"fs",
".",
"readdir",
"(",
"directory",
",",
"function",
"(",
"err",
",",
"files",
")",
"{",
"if",
"(",
"err",
")",
"{",
"// This means the directory doesn't exist",
"if",
"(",
"err",
".",
"errno",
"===",
"34",
"&&",
"err",
".",
"code",
"===",
"'ENOENT'",
")",
"{",
"deferred",
".",
"resolve",
"(",
"filename",
")",
";",
"}",
"else",
"{",
"deferred",
".",
"reject",
"(",
"err",
")",
";",
"}",
"}",
"else",
"{",
"var",
"index",
"=",
"files",
".",
"indexOf",
"(",
"filename",
")",
";",
"if",
"(",
"index",
">",
"-",
"1",
")",
"{",
"// Get filename and extension (if it has one)",
"var",
"name",
",",
"extension",
";",
"var",
"splitString",
"=",
"filename",
".",
"split",
"(",
"'.'",
")",
";",
"// Has extension",
"if",
"(",
"splitString",
".",
"length",
">",
"1",
")",
"{",
"extension",
"=",
"splitString",
".",
"pop",
"(",
")",
";",
"name",
"=",
"splitString",
".",
"join",
"(",
"'.'",
")",
";",
"// Wait! Is this a hidden file?",
"if",
"(",
"!",
"name",
")",
"{",
"name",
"=",
"'.'",
"+",
"extension",
";",
"extension",
"=",
"''",
";",
"}",
"}",
"// No extension",
"else",
"{",
"name",
"=",
"filename",
";",
"extension",
"=",
"''",
";",
"}",
"// Get the copy number appended to the name and increment, if any",
"var",
"matches",
"=",
"name",
".",
"match",
"(",
"/",
"\\((\\d+)\\)$",
"/",
")",
";",
"if",
"(",
"matches",
")",
"{",
"var",
"copyNumber",
"=",
"Number",
"(",
"matches",
"[",
"1",
"]",
")",
"+",
"1",
";",
"name",
"=",
"name",
".",
"replace",
"(",
"/",
"\\((\\d+)\\)$",
"/",
",",
"'('",
"+",
"copyNumber",
"+",
"')'",
")",
";",
"}",
"else",
"{",
"name",
"+=",
"'(1)'",
";",
"}",
"// Assemble new filename",
"if",
"(",
"extension",
")",
"{",
"filename",
"=",
"name",
"+",
"'.'",
"+",
"extension",
";",
"}",
"else",
"{",
"filename",
"=",
"name",
";",
"}",
"deferred",
".",
"resolve",
"(",
"_getSafeFileName",
"(",
"filename",
",",
"directory",
")",
")",
";",
"}",
"else",
"{",
"deferred",
".",
"resolve",
"(",
"filename",
")",
";",
"}",
"}",
"}",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] |
Append a copy number to a filename if a
file by that same name already exists
@param string
@param string
@return promise
|
[
"Append",
"a",
"copy",
"number",
"to",
"a",
"filename",
"if",
"a",
"file",
"by",
"that",
"same",
"name",
"already",
"exists"
] |
338bc15f8a94621f145eb378f0b42123548ca545
|
https://github.com/RaphaelDeLaGhetto/gebo-utils/blob/338bc15f8a94621f145eb378f0b42123548ca545/index.js#L209-L274
|
52,529
|
RaphaelDeLaGhetto/gebo-utils
|
index.js
|
_getOutputFileName
|
function _getOutputFileName(path, extension) {
var filename = path.split('/');
filename = filename[filename.length - 1];
filename = filename.split('.');
// No extension found
if (filename.length === 1) {
return filename[0] + '.' + extension;
}
// Hidden file
if (filename[0] === '') {
filename = filename.slice(1);
filename[0] = '.' + filename[0];
if (filename.length === 1) {
return filename[0] + '.' + extension;
}
}
filename = filename.slice(0, -1);
return filename + '.' + extension;
}
|
javascript
|
function _getOutputFileName(path, extension) {
var filename = path.split('/');
filename = filename[filename.length - 1];
filename = filename.split('.');
// No extension found
if (filename.length === 1) {
return filename[0] + '.' + extension;
}
// Hidden file
if (filename[0] === '') {
filename = filename.slice(1);
filename[0] = '.' + filename[0];
if (filename.length === 1) {
return filename[0] + '.' + extension;
}
}
filename = filename.slice(0, -1);
return filename + '.' + extension;
}
|
[
"function",
"_getOutputFileName",
"(",
"path",
",",
"extension",
")",
"{",
"var",
"filename",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
";",
"filename",
"=",
"filename",
"[",
"filename",
".",
"length",
"-",
"1",
"]",
";",
"filename",
"=",
"filename",
".",
"split",
"(",
"'.'",
")",
";",
"// No extension found",
"if",
"(",
"filename",
".",
"length",
"===",
"1",
")",
"{",
"return",
"filename",
"[",
"0",
"]",
"+",
"'.'",
"+",
"extension",
";",
"}",
"// Hidden file",
"if",
"(",
"filename",
"[",
"0",
"]",
"===",
"''",
")",
"{",
"filename",
"=",
"filename",
".",
"slice",
"(",
"1",
")",
";",
"filename",
"[",
"0",
"]",
"=",
"'.'",
"+",
"filename",
"[",
"0",
"]",
";",
"if",
"(",
"filename",
".",
"length",
"===",
"1",
")",
"{",
"return",
"filename",
"[",
"0",
"]",
"+",
"'.'",
"+",
"extension",
";",
"}",
"}",
"filename",
"=",
"filename",
".",
"slice",
"(",
"0",
",",
"-",
"1",
")",
";",
"return",
"filename",
"+",
"'.'",
"+",
"extension",
";",
"}"
] |
Take the incoming filename and its extension
and return the hypothetical output filename
@param string
@param string
@return string
|
[
"Take",
"the",
"incoming",
"filename",
"and",
"its",
"extension",
"and",
"return",
"the",
"hypothetical",
"output",
"filename"
] |
338bc15f8a94621f145eb378f0b42123548ca545
|
https://github.com/RaphaelDeLaGhetto/gebo-utils/blob/338bc15f8a94621f145eb378f0b42123548ca545/index.js#L334-L356
|
52,530
|
RaphaelDeLaGhetto/gebo-utils
|
index.js
|
_setTimeLimit
|
function _setTimeLimit(options, done) {
if (options && options.timeLimit && options.pidFile) {
var timeout = setTimeout(function() {
var kill = 'kill $(cat ' + options.pidFile + ')';
if (logLevel === 'trace') logger.warn('process', kill);
childProcess.exec(kill, function(err, stdout, stderr) {
if (err) {
if (logLevel === 'trace') logger.error('process', 'timeout', err);
}
if (stderr) {
if (logLevel === 'trace') logger.warn('process', 'timeout', stderr);
}
if (stdout) {
if (logLevel === 'trace') logger.info('process', 'timeout', stdout);
}
options.returnNow = 'Sorry, that file took too long to process';
});
}, options.timeLimit);
done(timeout);
}
else {
done(false);
}
}
|
javascript
|
function _setTimeLimit(options, done) {
if (options && options.timeLimit && options.pidFile) {
var timeout = setTimeout(function() {
var kill = 'kill $(cat ' + options.pidFile + ')';
if (logLevel === 'trace') logger.warn('process', kill);
childProcess.exec(kill, function(err, stdout, stderr) {
if (err) {
if (logLevel === 'trace') logger.error('process', 'timeout', err);
}
if (stderr) {
if (logLevel === 'trace') logger.warn('process', 'timeout', stderr);
}
if (stdout) {
if (logLevel === 'trace') logger.info('process', 'timeout', stdout);
}
options.returnNow = 'Sorry, that file took too long to process';
});
}, options.timeLimit);
done(timeout);
}
else {
done(false);
}
}
|
[
"function",
"_setTimeLimit",
"(",
"options",
",",
"done",
")",
"{",
"if",
"(",
"options",
"&&",
"options",
".",
"timeLimit",
"&&",
"options",
".",
"pidFile",
")",
"{",
"var",
"timeout",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"var",
"kill",
"=",
"'kill $(cat '",
"+",
"options",
".",
"pidFile",
"+",
"')'",
";",
"if",
"(",
"logLevel",
"===",
"'trace'",
")",
"logger",
".",
"warn",
"(",
"'process'",
",",
"kill",
")",
";",
"childProcess",
".",
"exec",
"(",
"kill",
",",
"function",
"(",
"err",
",",
"stdout",
",",
"stderr",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"logLevel",
"===",
"'trace'",
")",
"logger",
".",
"error",
"(",
"'process'",
",",
"'timeout'",
",",
"err",
")",
";",
"}",
"if",
"(",
"stderr",
")",
"{",
"if",
"(",
"logLevel",
"===",
"'trace'",
")",
"logger",
".",
"warn",
"(",
"'process'",
",",
"'timeout'",
",",
"stderr",
")",
";",
"}",
"if",
"(",
"stdout",
")",
"{",
"if",
"(",
"logLevel",
"===",
"'trace'",
")",
"logger",
".",
"info",
"(",
"'process'",
",",
"'timeout'",
",",
"stdout",
")",
";",
"}",
"options",
".",
"returnNow",
"=",
"'Sorry, that file took too long to process'",
";",
"}",
")",
";",
"}",
",",
"options",
".",
"timeLimit",
")",
";",
"done",
"(",
"timeout",
")",
";",
"}",
"else",
"{",
"done",
"(",
"false",
")",
";",
"}",
"}"
] |
Set time limit on operating system process
@param object
@param function
@return timeoutObject
|
[
"Set",
"time",
"limit",
"on",
"operating",
"system",
"process"
] |
338bc15f8a94621f145eb378f0b42123548ca545
|
https://github.com/RaphaelDeLaGhetto/gebo-utils/blob/338bc15f8a94621f145eb378f0b42123548ca545/index.js#L367-L390
|
52,531
|
RaphaelDeLaGhetto/gebo-utils
|
index.js
|
_stopTimer
|
function _stopTimer(timer, options) {
if (timer) {
options.timeLimit = _getTimeLeft(timer);
clearTimeout(timer);
}
}
|
javascript
|
function _stopTimer(timer, options) {
if (timer) {
options.timeLimit = _getTimeLeft(timer);
clearTimeout(timer);
}
}
|
[
"function",
"_stopTimer",
"(",
"timer",
",",
"options",
")",
"{",
"if",
"(",
"timer",
")",
"{",
"options",
".",
"timeLimit",
"=",
"_getTimeLeft",
"(",
"timer",
")",
";",
"clearTimeout",
"(",
"timer",
")",
";",
"}",
"}"
] |
Clear the timer and record the time remaining
@param timeoutObject
@param object
|
[
"Clear",
"the",
"timer",
"and",
"record",
"the",
"time",
"remaining"
] |
338bc15f8a94621f145eb378f0b42123548ca545
|
https://github.com/RaphaelDeLaGhetto/gebo-utils/blob/338bc15f8a94621f145eb378f0b42123548ca545/index.js#L399-L404
|
52,532
|
RaphaelDeLaGhetto/gebo-utils
|
index.js
|
_echoPidToFile
|
function _echoPidToFile(options) {
var command = '';
if (options && options.pidFile) {
command = ' & echo $! > ' + options.pidFile;
}
return command;
}
|
javascript
|
function _echoPidToFile(options) {
var command = '';
if (options && options.pidFile) {
command = ' & echo $! > ' + options.pidFile;
}
return command;
}
|
[
"function",
"_echoPidToFile",
"(",
"options",
")",
"{",
"var",
"command",
"=",
"''",
";",
"if",
"(",
"options",
"&&",
"options",
".",
"pidFile",
")",
"{",
"command",
"=",
"' & echo $! > '",
"+",
"options",
".",
"pidFile",
";",
"}",
"return",
"command",
";",
"}"
] |
Format the echo-to-PID-file command string
@param object
@return string
|
[
"Format",
"the",
"echo",
"-",
"to",
"-",
"PID",
"-",
"file",
"command",
"string"
] |
338bc15f8a94621f145eb378f0b42123548ca545
|
https://github.com/RaphaelDeLaGhetto/gebo-utils/blob/338bc15f8a94621f145eb378f0b42123548ca545/index.js#L414-L420
|
52,533
|
RaphaelDeLaGhetto/gebo-utils
|
index.js
|
_getTimeLeft
|
function _getTimeLeft(timeout) {
return Math.ceil(timeout._idleStart + timeout._idleTimeout - Date.now());
}
|
javascript
|
function _getTimeLeft(timeout) {
return Math.ceil(timeout._idleStart + timeout._idleTimeout - Date.now());
}
|
[
"function",
"_getTimeLeft",
"(",
"timeout",
")",
"{",
"return",
"Math",
".",
"ceil",
"(",
"timeout",
".",
"_idleStart",
"+",
"timeout",
".",
"_idleTimeout",
"-",
"Date",
".",
"now",
"(",
")",
")",
";",
"}"
] |
Get time left
2014-11-6
http://stackoverflow.com/questions/3144711/javascript-find-the-time-left-in-a-settimeout
Courtesy of Fluffy
@param timeoutObject
@return integer
|
[
"Get",
"time",
"left"
] |
338bc15f8a94621f145eb378f0b42123548ca545
|
https://github.com/RaphaelDeLaGhetto/gebo-utils/blob/338bc15f8a94621f145eb378f0b42123548ca545/index.js#L434-L436
|
52,534
|
emiljohansson/captn
|
captn.dom.show/index.js
|
hide
|
function hide(element) {
if (!element || !element.style || typeof element.style.display !== 'string') {
return;
}
element.style.display = "";
}
|
javascript
|
function hide(element) {
if (!element || !element.style || typeof element.style.display !== 'string') {
return;
}
element.style.display = "";
}
|
[
"function",
"hide",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
"||",
"!",
"element",
".",
"style",
"||",
"typeof",
"element",
".",
"style",
".",
"display",
"!==",
"'string'",
")",
"{",
"return",
";",
"}",
"element",
".",
"style",
".",
"display",
"=",
"\"\"",
";",
"}"
] |
Hides an element.
@static
@param {DOMElement} element The DOM element to be modified.
@example
hide(el);
el.style
// => display: "";
|
[
"Hides",
"an",
"element",
"."
] |
dae7520116dc2148b4de06af7e1d7a47a3a3ac37
|
https://github.com/emiljohansson/captn/blob/dae7520116dc2148b4de06af7e1d7a47a3a3ac37/captn.dom.show/index.js#L15-L20
|
52,535
|
base/base-scaffold
|
index.js
|
function(name, config) {
if (!config && typeof name === 'string' || utils.isObject(name)) {
return this.getScaffold(name);
}
this.setScaffold.apply(this, arguments);
if (typeof name === 'string') {
return this.getScaffold(name);
}
return this;
}
|
javascript
|
function(name, config) {
if (!config && typeof name === 'string' || utils.isObject(name)) {
return this.getScaffold(name);
}
this.setScaffold.apply(this, arguments);
if (typeof name === 'string') {
return this.getScaffold(name);
}
return this;
}
|
[
"function",
"(",
"name",
",",
"config",
")",
"{",
"if",
"(",
"!",
"config",
"&&",
"typeof",
"name",
"===",
"'string'",
"||",
"utils",
".",
"isObject",
"(",
"name",
")",
")",
"{",
"return",
"this",
".",
"getScaffold",
"(",
"name",
")",
";",
"}",
"this",
".",
"setScaffold",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"return",
"this",
".",
"getScaffold",
"(",
"name",
")",
";",
"}",
"return",
"this",
";",
"}"
] |
Get scaffold `name` from `app.scaffolds`, or set scaffold `name` with the given
`config`.
```js
app.scaffold('foo', {
docs: {
options: {},
files: {
src: ['*'],
dest: 'foo'
}
}
});
// or
var scaffold = app.scaffold('foo');
```
@name .scaffold
@param {String|Object|Function} `name`
@param {Object|Fucntion} `config`
@return {Object} Returns the app instance when setting a scaffold, or the scaffold instance when getting a scaffold.
@api public
|
[
"Get",
"scaffold",
"name",
"from",
"app",
".",
"scaffolds",
"or",
"set",
"scaffold",
"name",
"with",
"the",
"given",
"config",
"."
] |
d03b0f4a7ba7a1b44be8b1708a2bce613be1c4e1
|
https://github.com/base/base-scaffold/blob/d03b0f4a7ba7a1b44be8b1708a2bce613be1c4e1/index.js#L77-L87
|
|
52,536
|
base/base-scaffold
|
index.js
|
function(name, config) {
if (typeof name !== 'string') {
throw new TypeError('expected the first argument to be a string');
}
if (utils.isObject(config)) {
config.name = name;
}
this.emit('scaffold.set', name, config);
this.scaffolds[name] = config;
return this;
}
|
javascript
|
function(name, config) {
if (typeof name !== 'string') {
throw new TypeError('expected the first argument to be a string');
}
if (utils.isObject(config)) {
config.name = name;
}
this.emit('scaffold.set', name, config);
this.scaffolds[name] = config;
return this;
}
|
[
"function",
"(",
"name",
",",
"config",
")",
"{",
"if",
"(",
"typeof",
"name",
"!==",
"'string'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'expected the first argument to be a string'",
")",
";",
"}",
"if",
"(",
"utils",
".",
"isObject",
"(",
"config",
")",
")",
"{",
"config",
".",
"name",
"=",
"name",
";",
"}",
"this",
".",
"emit",
"(",
"'scaffold.set'",
",",
"name",
",",
"config",
")",
";",
"this",
".",
"scaffolds",
"[",
"name",
"]",
"=",
"config",
";",
"return",
"this",
";",
"}"
] |
Add scaffold `name` to `app.scaffolds`.
```js
app.addScaffold('foo', {
docs: {
options: {},
files: {
src: ['*'],
dest: 'foo'
}
}
});
```
@param {String} `name`
@param {Object|Function} `config`
@api public
|
[
"Add",
"scaffold",
"name",
"to",
"app",
".",
"scaffolds",
"."
] |
d03b0f4a7ba7a1b44be8b1708a2bce613be1c4e1
|
https://github.com/base/base-scaffold/blob/d03b0f4a7ba7a1b44be8b1708a2bce613be1c4e1/index.js#L108-L118
|
|
52,537
|
base/base-scaffold
|
index.js
|
function(name, options) {
var opts = utils.merge({}, this.options, options);
var config;
switch (utils.typeOf(name)) {
case 'function':
config = name;
break;
case 'object':
config = name;
name = config.name;
break;
case 'string':
default: {
opts.name = name;
config = this.scaffolds[name];
if (typeof config === 'undefined') {
throw new Error(`scaffold "${name}" is not registered`);
}
break;
}
}
if (typeof config === 'function') {
config = config(opts);
}
if (!utils.isObject(config)) {
throw new TypeError('expected config to be an object');
}
// if `config` is not an instance of Scaffold, make it one
if (!this.isScaffold(config)) {
var Scaffold = this.get('Scaffold');
var scaffold = new Scaffold(opts);
scaffold.options = utils.merge({}, this.options, scaffold.options, options);
if (typeof name === 'string') {
scaffold.name = name;
}
if (typeof this.run === 'function') {
this.run(scaffold);
}
this.emit('scaffold', scaffold);
scaffold.on('target', this.emit.bind(this, 'target'));
config = scaffold.addTargets(config);
}
// otherwise, ensure options are merged onto the scaffold,
// and all targets are emitted
else {
config.options = utils.merge({}, this.options, config.options, options);
if (typeof name === 'string') {
config.name = name;
}
if (typeof this.run === 'function') {
this.run(config);
}
for (var key in config.targets) {
if (config.targets.hasOwnProperty(key)) {
this.emit('target', config.targets[key]);
}
}
config.on('target', this.emit.bind(this, 'target'));
this.emit('scaffold', config);
}
return config;
}
|
javascript
|
function(name, options) {
var opts = utils.merge({}, this.options, options);
var config;
switch (utils.typeOf(name)) {
case 'function':
config = name;
break;
case 'object':
config = name;
name = config.name;
break;
case 'string':
default: {
opts.name = name;
config = this.scaffolds[name];
if (typeof config === 'undefined') {
throw new Error(`scaffold "${name}" is not registered`);
}
break;
}
}
if (typeof config === 'function') {
config = config(opts);
}
if (!utils.isObject(config)) {
throw new TypeError('expected config to be an object');
}
// if `config` is not an instance of Scaffold, make it one
if (!this.isScaffold(config)) {
var Scaffold = this.get('Scaffold');
var scaffold = new Scaffold(opts);
scaffold.options = utils.merge({}, this.options, scaffold.options, options);
if (typeof name === 'string') {
scaffold.name = name;
}
if (typeof this.run === 'function') {
this.run(scaffold);
}
this.emit('scaffold', scaffold);
scaffold.on('target', this.emit.bind(this, 'target'));
config = scaffold.addTargets(config);
}
// otherwise, ensure options are merged onto the scaffold,
// and all targets are emitted
else {
config.options = utils.merge({}, this.options, config.options, options);
if (typeof name === 'string') {
config.name = name;
}
if (typeof this.run === 'function') {
this.run(config);
}
for (var key in config.targets) {
if (config.targets.hasOwnProperty(key)) {
this.emit('target', config.targets[key]);
}
}
config.on('target', this.emit.bind(this, 'target'));
this.emit('scaffold', config);
}
return config;
}
|
[
"function",
"(",
"name",
",",
"options",
")",
"{",
"var",
"opts",
"=",
"utils",
".",
"merge",
"(",
"{",
"}",
",",
"this",
".",
"options",
",",
"options",
")",
";",
"var",
"config",
";",
"switch",
"(",
"utils",
".",
"typeOf",
"(",
"name",
")",
")",
"{",
"case",
"'function'",
":",
"config",
"=",
"name",
";",
"break",
";",
"case",
"'object'",
":",
"config",
"=",
"name",
";",
"name",
"=",
"config",
".",
"name",
";",
"break",
";",
"case",
"'string'",
":",
"default",
":",
"{",
"opts",
".",
"name",
"=",
"name",
";",
"config",
"=",
"this",
".",
"scaffolds",
"[",
"name",
"]",
";",
"if",
"(",
"typeof",
"config",
"===",
"'undefined'",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"name",
"}",
"`",
")",
";",
"}",
"break",
";",
"}",
"}",
"if",
"(",
"typeof",
"config",
"===",
"'function'",
")",
"{",
"config",
"=",
"config",
"(",
"opts",
")",
";",
"}",
"if",
"(",
"!",
"utils",
".",
"isObject",
"(",
"config",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'expected config to be an object'",
")",
";",
"}",
"// if `config` is not an instance of Scaffold, make it one",
"if",
"(",
"!",
"this",
".",
"isScaffold",
"(",
"config",
")",
")",
"{",
"var",
"Scaffold",
"=",
"this",
".",
"get",
"(",
"'Scaffold'",
")",
";",
"var",
"scaffold",
"=",
"new",
"Scaffold",
"(",
"opts",
")",
";",
"scaffold",
".",
"options",
"=",
"utils",
".",
"merge",
"(",
"{",
"}",
",",
"this",
".",
"options",
",",
"scaffold",
".",
"options",
",",
"options",
")",
";",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"scaffold",
".",
"name",
"=",
"name",
";",
"}",
"if",
"(",
"typeof",
"this",
".",
"run",
"===",
"'function'",
")",
"{",
"this",
".",
"run",
"(",
"scaffold",
")",
";",
"}",
"this",
".",
"emit",
"(",
"'scaffold'",
",",
"scaffold",
")",
";",
"scaffold",
".",
"on",
"(",
"'target'",
",",
"this",
".",
"emit",
".",
"bind",
"(",
"this",
",",
"'target'",
")",
")",
";",
"config",
"=",
"scaffold",
".",
"addTargets",
"(",
"config",
")",
";",
"}",
"// otherwise, ensure options are merged onto the scaffold,",
"// and all targets are emitted",
"else",
"{",
"config",
".",
"options",
"=",
"utils",
".",
"merge",
"(",
"{",
"}",
",",
"this",
".",
"options",
",",
"config",
".",
"options",
",",
"options",
")",
";",
"if",
"(",
"typeof",
"name",
"===",
"'string'",
")",
"{",
"config",
".",
"name",
"=",
"name",
";",
"}",
"if",
"(",
"typeof",
"this",
".",
"run",
"===",
"'function'",
")",
"{",
"this",
".",
"run",
"(",
"config",
")",
";",
"}",
"for",
"(",
"var",
"key",
"in",
"config",
".",
"targets",
")",
"{",
"if",
"(",
"config",
".",
"targets",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"this",
".",
"emit",
"(",
"'target'",
",",
"config",
".",
"targets",
"[",
"key",
"]",
")",
";",
"}",
"}",
"config",
".",
"on",
"(",
"'target'",
",",
"this",
".",
"emit",
".",
"bind",
"(",
"this",
",",
"'target'",
")",
")",
";",
"this",
".",
"emit",
"(",
"'scaffold'",
",",
"config",
")",
";",
"}",
"return",
"config",
";",
"}"
] |
Get scaffold `name` from `app.scaffolds`, or return a normalized
instance of `Scaffold` if an object or function is passed.
```js
var scaffold = app.getScaffold('foo');
// or create an instance of `Scaffold` using the given object
var scaffold = app.getScaffold({
docs: {
options: {},
files: {
src: ['*'],
dest: 'foo'
}
}
});
```
@param {String} `name`
@param {Object} `options`
@api public
|
[
"Get",
"scaffold",
"name",
"from",
"app",
".",
"scaffolds",
"or",
"return",
"a",
"normalized",
"instance",
"of",
"Scaffold",
"if",
"an",
"object",
"or",
"function",
"is",
"passed",
"."
] |
d03b0f4a7ba7a1b44be8b1708a2bce613be1c4e1
|
https://github.com/base/base-scaffold/blob/d03b0f4a7ba7a1b44be8b1708a2bce613be1c4e1/index.js#L143-L209
|
|
52,538
|
nashdot/Preprocessor.js
|
Preprocessor.js
|
Preprocessor
|
function Preprocessor(source, baseDirOrIncludes, preserveLineNumbers) {
/**
* Source code to pre-process.
* @type {string}
* @expose
*/
this.source = '' + source;
/**
* Source base directory.
* @type {string}
* @expose
*/
this.baseDir = typeof baseDirOrIncludes === 'string' ? baseDirOrIncludes : '.';
/**
* Included sources by filename.
* @type {Object.<string, string>}
*/
this.includes = typeof baseDirOrIncludes === 'object' ? baseDirOrIncludes : {};
/**
* Preserve line numbers when removing blocks of code
* @type {boolean}
*/
this.preserveLineNumbers = typeof preserveLineNumbers === 'boolean' ? preserveLineNumbers : false;
/**
* Whether running inside of node.js or not.
* @type {boolean}
* @expose
*/
this.isNode = (typeof window === 'undefined' || !window.window) && typeof require === 'function';
/**
* Error reporting source ahead length.
* @type {number}
* @expose
*/
this.errorSourceAhead = 50;
/**
* Runtime defines.
* @type {Array.<string>}
*/
this.defines = [];
}
|
javascript
|
function Preprocessor(source, baseDirOrIncludes, preserveLineNumbers) {
/**
* Source code to pre-process.
* @type {string}
* @expose
*/
this.source = '' + source;
/**
* Source base directory.
* @type {string}
* @expose
*/
this.baseDir = typeof baseDirOrIncludes === 'string' ? baseDirOrIncludes : '.';
/**
* Included sources by filename.
* @type {Object.<string, string>}
*/
this.includes = typeof baseDirOrIncludes === 'object' ? baseDirOrIncludes : {};
/**
* Preserve line numbers when removing blocks of code
* @type {boolean}
*/
this.preserveLineNumbers = typeof preserveLineNumbers === 'boolean' ? preserveLineNumbers : false;
/**
* Whether running inside of node.js or not.
* @type {boolean}
* @expose
*/
this.isNode = (typeof window === 'undefined' || !window.window) && typeof require === 'function';
/**
* Error reporting source ahead length.
* @type {number}
* @expose
*/
this.errorSourceAhead = 50;
/**
* Runtime defines.
* @type {Array.<string>}
*/
this.defines = [];
}
|
[
"function",
"Preprocessor",
"(",
"source",
",",
"baseDirOrIncludes",
",",
"preserveLineNumbers",
")",
"{",
"/**\n * Source code to pre-process.\n * @type {string}\n * @expose\n */",
"this",
".",
"source",
"=",
"''",
"+",
"source",
";",
"/**\n * Source base directory.\n * @type {string}\n * @expose\n */",
"this",
".",
"baseDir",
"=",
"typeof",
"baseDirOrIncludes",
"===",
"'string'",
"?",
"baseDirOrIncludes",
":",
"'.'",
";",
"/**\n * Included sources by filename.\n * @type {Object.<string, string>}\n */",
"this",
".",
"includes",
"=",
"typeof",
"baseDirOrIncludes",
"===",
"'object'",
"?",
"baseDirOrIncludes",
":",
"{",
"}",
";",
"/**\n * Preserve line numbers when removing blocks of code\n * @type {boolean}\n */",
"this",
".",
"preserveLineNumbers",
"=",
"typeof",
"preserveLineNumbers",
"===",
"'boolean'",
"?",
"preserveLineNumbers",
":",
"false",
";",
"/**\n * Whether running inside of node.js or not.\n * @type {boolean}\n * @expose\n */",
"this",
".",
"isNode",
"=",
"(",
"typeof",
"window",
"===",
"'undefined'",
"||",
"!",
"window",
".",
"window",
")",
"&&",
"typeof",
"require",
"===",
"'function'",
";",
"/**\n * Error reporting source ahead length.\n * @type {number}\n * @expose\n */",
"this",
".",
"errorSourceAhead",
"=",
"50",
";",
"/**\n * Runtime defines.\n * @type {Array.<string>}\n */",
"this",
".",
"defines",
"=",
"[",
"]",
";",
"}"
] |
Constructs a new Preprocessor.
@exports Preprocessor
@class Provides pre-processing of JavaScript source files, e.g. to build different versions of a library.
@param {string} source Source to process
@param {string|Object.<string,string>=} baseDirOrIncludes Source base directory used for includes (node.js only)
or an object containing all the included sources by filename. Defaults to the current working directory.
@param {boolean} preserveLineNumbers When removing blocks of code, replace the block with blank lines so that
line numbers are preserved, as long as #include is not used
@constructor
|
[
"Constructs",
"a",
"new",
"Preprocessor",
"."
] |
3c4c285e335acf096eb3df4beaaa2def6fe135e0
|
https://github.com/nashdot/Preprocessor.js/blob/3c4c285e335acf096eb3df4beaaa2def6fe135e0/Preprocessor.js#L46-L92
|
52,539
|
bbusschots-mu/validateParams.js
|
validateParams.js
|
function(mCons, vCons, k){
var nCons = {}; // the final nested constraints
// if there are per-key constraints for k, add them all
if(validate.isObject(mCons[k])){
nCons = validateParams.extendObject({}, mCons[k]);
}
// loop through each universal constraint and merge as appropraite
if(vCons){
Object.keys(vCons).forEach(function(vn){
// only add non-clashing universal constraints
if(!nCons[vn]){
nCons[vn] = vCons[vn];
}
});
}
// return the merged constraints
return nCons;
}
|
javascript
|
function(mCons, vCons, k){
var nCons = {}; // the final nested constraints
// if there are per-key constraints for k, add them all
if(validate.isObject(mCons[k])){
nCons = validateParams.extendObject({}, mCons[k]);
}
// loop through each universal constraint and merge as appropraite
if(vCons){
Object.keys(vCons).forEach(function(vn){
// only add non-clashing universal constraints
if(!nCons[vn]){
nCons[vn] = vCons[vn];
}
});
}
// return the merged constraints
return nCons;
}
|
[
"function",
"(",
"mCons",
",",
"vCons",
",",
"k",
")",
"{",
"var",
"nCons",
"=",
"{",
"}",
";",
"// the final nested constraints",
"// if there are per-key constraints for k, add them all",
"if",
"(",
"validate",
".",
"isObject",
"(",
"mCons",
"[",
"k",
"]",
")",
")",
"{",
"nCons",
"=",
"validateParams",
".",
"extendObject",
"(",
"{",
"}",
",",
"mCons",
"[",
"k",
"]",
")",
";",
"}",
"// loop through each universal constraint and merge as appropraite",
"if",
"(",
"vCons",
")",
"{",
"Object",
".",
"keys",
"(",
"vCons",
")",
".",
"forEach",
"(",
"function",
"(",
"vn",
")",
"{",
"// only add non-clashing universal constraints",
"if",
"(",
"!",
"nCons",
"[",
"vn",
"]",
")",
"{",
"nCons",
"[",
"vn",
"]",
"=",
"vCons",
"[",
"vn",
"]",
";",
"}",
"}",
")",
";",
"}",
"// return the merged constraints",
"return",
"nCons",
";",
"}"
] |
a private inner function for merging per-key and universal constraints
|
[
"a",
"private",
"inner",
"function",
"for",
"merging",
"per",
"-",
"key",
"and",
"universal",
"constraints"
] |
6952ebeaff09892933c4095396dff00595029ab5
|
https://github.com/bbusschots-mu/validateParams.js/blob/6952ebeaff09892933c4095396dff00595029ab5/validateParams.js#L613-L633
|
|
52,540
|
bbusschots-mu/validateParams.js
|
validateParams.js
|
function(cName){
if(validate.isEmpty(cName)){
validateParams._warn('ignoring invalid coercion name: ' + cName);
}
if(validate.isFunction(validateParams.coercions[cName])){
return validateParams.coercions[cName];
}else{
validateParams._warn("no coercion named '" + cName + "' defined - ignoring");
}
return undefined;
}
|
javascript
|
function(cName){
if(validate.isEmpty(cName)){
validateParams._warn('ignoring invalid coercion name: ' + cName);
}
if(validate.isFunction(validateParams.coercions[cName])){
return validateParams.coercions[cName];
}else{
validateParams._warn("no coercion named '" + cName + "' defined - ignoring");
}
return undefined;
}
|
[
"function",
"(",
"cName",
")",
"{",
"if",
"(",
"validate",
".",
"isEmpty",
"(",
"cName",
")",
")",
"{",
"validateParams",
".",
"_warn",
"(",
"'ignoring invalid coercion name: '",
"+",
"cName",
")",
";",
"}",
"if",
"(",
"validate",
".",
"isFunction",
"(",
"validateParams",
".",
"coercions",
"[",
"cName",
"]",
")",
")",
"{",
"return",
"validateParams",
".",
"coercions",
"[",
"cName",
"]",
";",
"}",
"else",
"{",
"validateParams",
".",
"_warn",
"(",
"\"no coercion named '\"",
"+",
"cName",
"+",
"\"' defined - ignoring\"",
")",
";",
"}",
"return",
"undefined",
";",
"}"
] |
make sure there's always an options object local function for resolving coersion names to functions
|
[
"make",
"sure",
"there",
"s",
"always",
"an",
"options",
"object",
"local",
"function",
"for",
"resolving",
"coersion",
"names",
"to",
"functions"
] |
6952ebeaff09892933c4095396dff00595029ab5
|
https://github.com/bbusschots-mu/validateParams.js/blob/6952ebeaff09892933c4095396dff00595029ab5/validateParams.js#L854-L864
|
|
52,541
|
bbusschots-mu/validateParams.js
|
validateParams.js
|
function(value, options){
// make sure the default options object exists
if(typeof this.options !== 'object') this.options = {};
// build up a base config from the pre-defined defaults
var config = { rejectUndefined: true };
config.message = validateParams.extractValidatorMessage(this, options);
// interpret the passed value
if(typeof options === 'boolean'){
// false prevents the validator from being run, so must have be true
config.rejectUndefined = true;
}else if(validate.isObject(options)){
if(options.rejectUndefined) config.rejectUndefined = true;
if(validate.isString(options.message)) config.message = options.message;
}else{
throw new Error('invalid options passed - must be true or a plain object');
}
// do the actual validation
var errors = [];
if(config.rejectUndefined && typeof value === 'undefined'){
errors.push('cannot be undefined');
}
// return as appropriate
if(errors.length > 0){
return config.message ? config.message : errors;
}
return undefined;
}
|
javascript
|
function(value, options){
// make sure the default options object exists
if(typeof this.options !== 'object') this.options = {};
// build up a base config from the pre-defined defaults
var config = { rejectUndefined: true };
config.message = validateParams.extractValidatorMessage(this, options);
// interpret the passed value
if(typeof options === 'boolean'){
// false prevents the validator from being run, so must have be true
config.rejectUndefined = true;
}else if(validate.isObject(options)){
if(options.rejectUndefined) config.rejectUndefined = true;
if(validate.isString(options.message)) config.message = options.message;
}else{
throw new Error('invalid options passed - must be true or a plain object');
}
// do the actual validation
var errors = [];
if(config.rejectUndefined && typeof value === 'undefined'){
errors.push('cannot be undefined');
}
// return as appropriate
if(errors.length > 0){
return config.message ? config.message : errors;
}
return undefined;
}
|
[
"function",
"(",
"value",
",",
"options",
")",
"{",
"// make sure the default options object exists",
"if",
"(",
"typeof",
"this",
".",
"options",
"!==",
"'object'",
")",
"this",
".",
"options",
"=",
"{",
"}",
";",
"// build up a base config from the pre-defined defaults",
"var",
"config",
"=",
"{",
"rejectUndefined",
":",
"true",
"}",
";",
"config",
".",
"message",
"=",
"validateParams",
".",
"extractValidatorMessage",
"(",
"this",
",",
"options",
")",
";",
"// interpret the passed value",
"if",
"(",
"typeof",
"options",
"===",
"'boolean'",
")",
"{",
"// false prevents the validator from being run, so must have be true",
"config",
".",
"rejectUndefined",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"validate",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"if",
"(",
"options",
".",
"rejectUndefined",
")",
"config",
".",
"rejectUndefined",
"=",
"true",
";",
"if",
"(",
"validate",
".",
"isString",
"(",
"options",
".",
"message",
")",
")",
"config",
".",
"message",
"=",
"options",
".",
"message",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'invalid options passed - must be true or a plain object'",
")",
";",
"}",
"// do the actual validation",
"var",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"config",
".",
"rejectUndefined",
"&&",
"typeof",
"value",
"===",
"'undefined'",
")",
"{",
"errors",
".",
"push",
"(",
"'cannot be undefined'",
")",
";",
"}",
"// return as appropriate",
"if",
"(",
"errors",
".",
"length",
">",
"0",
")",
"{",
"return",
"config",
".",
"message",
"?",
"config",
".",
"message",
":",
"errors",
";",
"}",
"return",
"undefined",
";",
"}"
] |
A validator for rejecting undefined values. Effectively a stricter
version of the `presence` validator bundled with validate.js.
This validator supports the following options in addition to the standard
`message` option:
* `rejectUndefined` - a truthy value will reject undefined values, all
all other values will accpet any value, including `undefined`.
When used in a constraint, this validator supports the following values:
* A plain object specifying options.
* `true` - a shortcut for `{ rejectUndefined: true }`
@member
@type {Validator}
@see [The Presence Validator from validate.js]{@link https://validatejs.org/#validators-presence}
@since version 1.1.1
@example <caption>A single required first parameter that can have any value</caption>
validateParams.assert(arguments, [{defined: true}]);
@example <caption>A single required first parameter that can have any value with a custom message</caption>
validateParams.assert(arguments, [{
defined: {
rejectUndefined: true,
message: 'is absolutely required'
}
}]);
|
[
"A",
"validator",
"for",
"rejecting",
"undefined",
"values",
".",
"Effectively",
"a",
"stricter",
"version",
"of",
"the",
"presence",
"validator",
"bundled",
"with",
"validate",
".",
"js",
"."
] |
6952ebeaff09892933c4095396dff00595029ab5
|
https://github.com/bbusschots-mu/validateParams.js/blob/6952ebeaff09892933c4095396dff00595029ab5/validateParams.js#L2014-L2044
|
|
52,542
|
bbusschots-mu/validateParams.js
|
validateParams.js
|
function(value, options){
// implicitly pass undefined
var valType = typeof value;
if(valType === 'undefined') return undefined;
// make sure the default options object exists
if(typeof this.options !== 'object') this.options = {};
// build up a base config from the pre-defined defaults
var config = {};
config.types = validate.isArray(this.options.types) ? this.options.types : [];
config.inverseMatch = this.options.inverseMatch ? true : false;
config.message = validateParams.extractValidatorMessage(this, options);
// interpret the passed value
if(typeof options === 'string'){
config.types.push(options);
}else if(validate.isArray(options)){
config.types = config.types.concat(options);
}else if(validate.isObject(options)){
if(validate.isArray(options.types)){
config.types = config.types.concat(options.types);
}
if(options.inverseMatch) config.inverseMatch = true;
if(validate.isString(options.message)) config.message = options.message;
}else{
throw new Error('invalid options passed - must be a string, an array of strings, or a plain object');
}
// validate the passed types
var typeList = [];
config.types.forEach(function(t){
if(validateParams.isTypeofString(t) && t !== 'undefined'){
typeList.push(t);
}else{
validateParams._warn('ignoring invalid type: ' + String(t));
}
});
if(typeList.length === 0){
throw new Error('no valid types specified');
}
// do the actual validation
var errors = [];
if(config.inverseMatch){
// do a reverse match
typeList.forEach(function(t){
if(valType === t){
errors.push("can't have type '" + t + "'");
}
});
}else{
// do a regular forward match
var matched = false;
typeList.forEach(function(t){
if(valType === t){
matched = true;
}
});
if(!matched){
errors.push("must have one of the following types: " + humanJoin(typeList) + "'");
}
}
// return as appropriate
if(errors.length > 0){
return config.message ? config.message : errors;
}
return undefined;
}
|
javascript
|
function(value, options){
// implicitly pass undefined
var valType = typeof value;
if(valType === 'undefined') return undefined;
// make sure the default options object exists
if(typeof this.options !== 'object') this.options = {};
// build up a base config from the pre-defined defaults
var config = {};
config.types = validate.isArray(this.options.types) ? this.options.types : [];
config.inverseMatch = this.options.inverseMatch ? true : false;
config.message = validateParams.extractValidatorMessage(this, options);
// interpret the passed value
if(typeof options === 'string'){
config.types.push(options);
}else if(validate.isArray(options)){
config.types = config.types.concat(options);
}else if(validate.isObject(options)){
if(validate.isArray(options.types)){
config.types = config.types.concat(options.types);
}
if(options.inverseMatch) config.inverseMatch = true;
if(validate.isString(options.message)) config.message = options.message;
}else{
throw new Error('invalid options passed - must be a string, an array of strings, or a plain object');
}
// validate the passed types
var typeList = [];
config.types.forEach(function(t){
if(validateParams.isTypeofString(t) && t !== 'undefined'){
typeList.push(t);
}else{
validateParams._warn('ignoring invalid type: ' + String(t));
}
});
if(typeList.length === 0){
throw new Error('no valid types specified');
}
// do the actual validation
var errors = [];
if(config.inverseMatch){
// do a reverse match
typeList.forEach(function(t){
if(valType === t){
errors.push("can't have type '" + t + "'");
}
});
}else{
// do a regular forward match
var matched = false;
typeList.forEach(function(t){
if(valType === t){
matched = true;
}
});
if(!matched){
errors.push("must have one of the following types: " + humanJoin(typeList) + "'");
}
}
// return as appropriate
if(errors.length > 0){
return config.message ? config.message : errors;
}
return undefined;
}
|
[
"function",
"(",
"value",
",",
"options",
")",
"{",
"// implicitly pass undefined",
"var",
"valType",
"=",
"typeof",
"value",
";",
"if",
"(",
"valType",
"===",
"'undefined'",
")",
"return",
"undefined",
";",
"// make sure the default options object exists",
"if",
"(",
"typeof",
"this",
".",
"options",
"!==",
"'object'",
")",
"this",
".",
"options",
"=",
"{",
"}",
";",
"// build up a base config from the pre-defined defaults",
"var",
"config",
"=",
"{",
"}",
";",
"config",
".",
"types",
"=",
"validate",
".",
"isArray",
"(",
"this",
".",
"options",
".",
"types",
")",
"?",
"this",
".",
"options",
".",
"types",
":",
"[",
"]",
";",
"config",
".",
"inverseMatch",
"=",
"this",
".",
"options",
".",
"inverseMatch",
"?",
"true",
":",
"false",
";",
"config",
".",
"message",
"=",
"validateParams",
".",
"extractValidatorMessage",
"(",
"this",
",",
"options",
")",
";",
"// interpret the passed value",
"if",
"(",
"typeof",
"options",
"===",
"'string'",
")",
"{",
"config",
".",
"types",
".",
"push",
"(",
"options",
")",
";",
"}",
"else",
"if",
"(",
"validate",
".",
"isArray",
"(",
"options",
")",
")",
"{",
"config",
".",
"types",
"=",
"config",
".",
"types",
".",
"concat",
"(",
"options",
")",
";",
"}",
"else",
"if",
"(",
"validate",
".",
"isObject",
"(",
"options",
")",
")",
"{",
"if",
"(",
"validate",
".",
"isArray",
"(",
"options",
".",
"types",
")",
")",
"{",
"config",
".",
"types",
"=",
"config",
".",
"types",
".",
"concat",
"(",
"options",
".",
"types",
")",
";",
"}",
"if",
"(",
"options",
".",
"inverseMatch",
")",
"config",
".",
"inverseMatch",
"=",
"true",
";",
"if",
"(",
"validate",
".",
"isString",
"(",
"options",
".",
"message",
")",
")",
"config",
".",
"message",
"=",
"options",
".",
"message",
";",
"}",
"else",
"{",
"throw",
"new",
"Error",
"(",
"'invalid options passed - must be a string, an array of strings, or a plain object'",
")",
";",
"}",
"// validate the passed types",
"var",
"typeList",
"=",
"[",
"]",
";",
"config",
".",
"types",
".",
"forEach",
"(",
"function",
"(",
"t",
")",
"{",
"if",
"(",
"validateParams",
".",
"isTypeofString",
"(",
"t",
")",
"&&",
"t",
"!==",
"'undefined'",
")",
"{",
"typeList",
".",
"push",
"(",
"t",
")",
";",
"}",
"else",
"{",
"validateParams",
".",
"_warn",
"(",
"'ignoring invalid type: '",
"+",
"String",
"(",
"t",
")",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"typeList",
".",
"length",
"===",
"0",
")",
"{",
"throw",
"new",
"Error",
"(",
"'no valid types specified'",
")",
";",
"}",
"// do the actual validation",
"var",
"errors",
"=",
"[",
"]",
";",
"if",
"(",
"config",
".",
"inverseMatch",
")",
"{",
"// do a reverse match",
"typeList",
".",
"forEach",
"(",
"function",
"(",
"t",
")",
"{",
"if",
"(",
"valType",
"===",
"t",
")",
"{",
"errors",
".",
"push",
"(",
"\"can't have type '\"",
"+",
"t",
"+",
"\"'\"",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"// do a regular forward match",
"var",
"matched",
"=",
"false",
";",
"typeList",
".",
"forEach",
"(",
"function",
"(",
"t",
")",
"{",
"if",
"(",
"valType",
"===",
"t",
")",
"{",
"matched",
"=",
"true",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"matched",
")",
"{",
"errors",
".",
"push",
"(",
"\"must have one of the following types: \"",
"+",
"humanJoin",
"(",
"typeList",
")",
"+",
"\"'\"",
")",
";",
"}",
"}",
"// return as appropriate",
"if",
"(",
"errors",
".",
"length",
">",
"0",
")",
"{",
"return",
"config",
".",
"message",
"?",
"config",
".",
"message",
":",
"errors",
";",
"}",
"return",
"undefined",
";",
"}"
] |
A validator for filtering values by the result of applying the `typeof`
operator to them.
This validator supports the following options in addition to the standard
`message` option:
* `types` - an array of one or more types as strings
* `inverseMatch` - a truthy value to invert the search, accepting all
types except those listed.
When used in a constraint, this validator supports the following values:
* A plain object specifying options.
* An array of strings - a shortcut for `{ types: THE_ARRAY }`, i.e. the
type must be one of the strings in the array.
* A string - a shortcut for `{ types: ['THE_STRING'] }`, i.e. the type
must be the given string.
@member
@type {Validator}
@see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof}
@example <caption>An optional first parameter that must be a callback if present</caption>
validateParams.assert(arguments, [{hasTypeof: 'function'}]);
@example <caption>A required first parameter that must be a string or a number</caption>
validateParams(arguments, [
{
defined: true,
hasTypeof: ['string', 'number']
}
]);
@example <caption>An optional first parameter that can be anything but a function</caption>
validateParams(arguments, [{
hasTypeof: {
types: ['function'],
inverseMatch: true
}
}]);
|
[
"A",
"validator",
"for",
"filtering",
"values",
"by",
"the",
"result",
"of",
"applying",
"the",
"typeof",
"operator",
"to",
"them",
"."
] |
6952ebeaff09892933c4095396dff00595029ab5
|
https://github.com/bbusschots-mu/validateParams.js/blob/6952ebeaff09892933c4095396dff00595029ab5/validateParams.js#L2084-L2153
|
|
52,543
|
bbusschots-mu/validateParams.js
|
validateParams.js
|
function(value, options){
if(!validate.isObject(options)) options = {};
// deal with undefined
if(options.ignoreUndefined && typeof value === 'undefined'){
return undefined;
}
// cast to boolean as appropriate
if(options.nativeTruthinessOnly){
return Boolean(value);
}
return Boolean(value) && !validate.isEmpty(value) ? true : false;
}
|
javascript
|
function(value, options){
if(!validate.isObject(options)) options = {};
// deal with undefined
if(options.ignoreUndefined && typeof value === 'undefined'){
return undefined;
}
// cast to boolean as appropriate
if(options.nativeTruthinessOnly){
return Boolean(value);
}
return Boolean(value) && !validate.isEmpty(value) ? true : false;
}
|
[
"function",
"(",
"value",
",",
"options",
")",
"{",
"if",
"(",
"!",
"validate",
".",
"isObject",
"(",
"options",
")",
")",
"options",
"=",
"{",
"}",
";",
"// deal with undefined",
"if",
"(",
"options",
".",
"ignoreUndefined",
"&&",
"typeof",
"value",
"===",
"'undefined'",
")",
"{",
"return",
"undefined",
";",
"}",
"// cast to boolean as appropriate",
"if",
"(",
"options",
".",
"nativeTruthinessOnly",
")",
"{",
"return",
"Boolean",
"(",
"value",
")",
";",
"}",
"return",
"Boolean",
"(",
"value",
")",
"&&",
"!",
"validate",
".",
"isEmpty",
"(",
"value",
")",
"?",
"true",
":",
"false",
";",
"}"
] |
A coercion for converting any arbitrary value to a boolean.
By default, and value that is either natively falsey, like `0`, or that's
considered empty by the [validate.isEmpty()]{@link external:isEmpty}
function from validate.js will be coerced to `false`. Setting the
coersion option `nativeTruthinessOnly` to a truthy value will cause the
coercion to use only JavaScript's native casting to boolean.
By default `undefined` is coerced to `false`, but this behaviour can be
suppressed by setting the coercion option `ignoreUndefined` to a truthy
value. Doing so will result in `undefined` being passed through the
coercion un-altered. Note that setting both `nativeTruthiness=true` and
`ignoreUndefined` will still result in `undefined` being passed
unaltered.
@member
@type {CoercionCallback}
|
[
"A",
"coercion",
"for",
"converting",
"any",
"arbitrary",
"value",
"to",
"a",
"boolean",
"."
] |
6952ebeaff09892933c4095396dff00595029ab5
|
https://github.com/bbusschots-mu/validateParams.js/blob/6952ebeaff09892933c4095396dff00595029ab5/validateParams.js#L2604-L2617
|
|
52,544
|
bbusschots-mu/validateParams.js
|
validateParams.js
|
function(value, options){
if(validate.isObject(options) && options.onlyCoercePrimitives && !validateParams.isPrimitive(value)){
return value;
}
if(validate.isEmpty(value)) return '';
return String(value);
}
|
javascript
|
function(value, options){
if(validate.isObject(options) && options.onlyCoercePrimitives && !validateParams.isPrimitive(value)){
return value;
}
if(validate.isEmpty(value)) return '';
return String(value);
}
|
[
"function",
"(",
"value",
",",
"options",
")",
"{",
"if",
"(",
"validate",
".",
"isObject",
"(",
"options",
")",
"&&",
"options",
".",
"onlyCoercePrimitives",
"&&",
"!",
"validateParams",
".",
"isPrimitive",
"(",
"value",
")",
")",
"{",
"return",
"value",
";",
"}",
"if",
"(",
"validate",
".",
"isEmpty",
"(",
"value",
")",
")",
"return",
"''",
";",
"return",
"String",
"(",
"value",
")",
";",
"}"
] |
A coercion for converting any arbitrary value to a string.
Empty values, as per the [validate.isEmpty()]{@link external:isEmpty}
function from validate.js will be coerced to an empty string, other
values will be cast to a string using JavaScript's `String()` function.
It's possible to ristrict the coercion to primitive types only by setting
the coercion option `onlyCoercePrimitives` to a truthy value. In this
case, all vales with a `typeof` other than `string`, `boolean` or
`number` will be passed through un-altered.
@member
@type {CoercionCallback}
|
[
"A",
"coercion",
"for",
"converting",
"any",
"arbitrary",
"value",
"to",
"a",
"string",
"."
] |
6952ebeaff09892933c4095396dff00595029ab5
|
https://github.com/bbusschots-mu/validateParams.js/blob/6952ebeaff09892933c4095396dff00595029ab5/validateParams.js#L2634-L2640
|
|
52,545
|
bbusschots-mu/validateParams.js
|
validateParams.js
|
function(value, options){
var typeVal = typeof value;
// if we already have a number that's not NaN, return it unaltered
if(typeVal === 'number' && !isNaN(value)) return value;
// otherwise, try do a conversion
var numVal = NaN;
if(typeVal === 'string' || typeVal === 'boolean'){
numVal = Number(value);
}
// return as appropriate, perhaps converting NaN to zero
if(validate.isObject(options) && options.NaNToZero && isNaN(numVal)){
return 0;
}
return numVal;
}
|
javascript
|
function(value, options){
var typeVal = typeof value;
// if we already have a number that's not NaN, return it unaltered
if(typeVal === 'number' && !isNaN(value)) return value;
// otherwise, try do a conversion
var numVal = NaN;
if(typeVal === 'string' || typeVal === 'boolean'){
numVal = Number(value);
}
// return as appropriate, perhaps converting NaN to zero
if(validate.isObject(options) && options.NaNToZero && isNaN(numVal)){
return 0;
}
return numVal;
}
|
[
"function",
"(",
"value",
",",
"options",
")",
"{",
"var",
"typeVal",
"=",
"typeof",
"value",
";",
"// if we already have a number that's not NaN, return it unaltered",
"if",
"(",
"typeVal",
"===",
"'number'",
"&&",
"!",
"isNaN",
"(",
"value",
")",
")",
"return",
"value",
";",
"// otherwise, try do a conversion",
"var",
"numVal",
"=",
"NaN",
";",
"if",
"(",
"typeVal",
"===",
"'string'",
"||",
"typeVal",
"===",
"'boolean'",
")",
"{",
"numVal",
"=",
"Number",
"(",
"value",
")",
";",
"}",
"// return as appropriate, perhaps converting NaN to zero",
"if",
"(",
"validate",
".",
"isObject",
"(",
"options",
")",
"&&",
"options",
".",
"NaNToZero",
"&&",
"isNaN",
"(",
"numVal",
")",
")",
"{",
"return",
"0",
";",
"}",
"return",
"numVal",
";",
"}"
] |
A coercion for converting any arbitrary value to a number.
If a given value already is a number it is passed un-altered. Otherwise,
if it has a `typeof` of `string` or `boolean` an attempt will be made
to convert the value to a number with JavaScript's `Number()` function.
Other values are converted to `NaN`.
If the coercion option `NaNToZero` is set to a truthy value, then `0`
will be returned instead of `NaN` if the returned value would otherwise
be `NaN`.
@member
@type {CoercionCallback}
|
[
"A",
"coercion",
"for",
"converting",
"any",
"arbitrary",
"value",
"to",
"a",
"number",
"."
] |
6952ebeaff09892933c4095396dff00595029ab5
|
https://github.com/bbusschots-mu/validateParams.js/blob/6952ebeaff09892933c4095396dff00595029ab5/validateParams.js#L2657-L2674
|
|
52,546
|
yefremov/aggregatejs
|
min.js
|
min
|
function min(array) {
var length = array.length;
if (length === 0) {
return 0;
}
var index = -1;
var result = array[++index];
while (++index < length) {
if (array[index] < result) {
result = array[index];
}
}
return result;
}
|
javascript
|
function min(array) {
var length = array.length;
if (length === 0) {
return 0;
}
var index = -1;
var result = array[++index];
while (++index < length) {
if (array[index] < result) {
result = array[index];
}
}
return result;
}
|
[
"function",
"min",
"(",
"array",
")",
"{",
"var",
"length",
"=",
"array",
".",
"length",
";",
"if",
"(",
"length",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"var",
"index",
"=",
"-",
"1",
";",
"var",
"result",
"=",
"array",
"[",
"++",
"index",
"]",
";",
"while",
"(",
"++",
"index",
"<",
"length",
")",
"{",
"if",
"(",
"array",
"[",
"index",
"]",
"<",
"result",
")",
"{",
"result",
"=",
"array",
"[",
"index",
"]",
";",
"}",
"}",
"return",
"result",
";",
"}"
] |
Returns the smallest number in `array`.
@param {Array} array Range of numbers to get minimum.
@return {number}
@example
min([100, -100, 150, -50, 250, 100]);
// => -100
|
[
"Returns",
"the",
"smallest",
"number",
"in",
"array",
"."
] |
932b28a15a5707135e7095950000a838db409511
|
https://github.com/yefremov/aggregatejs/blob/932b28a15a5707135e7095950000a838db409511/min.js#L19-L36
|
52,547
|
wwwouter/tslint-contrib
|
noPromiseAsBooleanRule.js
|
isBooleanBinaryExpression
|
function isBooleanBinaryExpression(node) {
return node.kind === ts.SyntaxKind.BinaryExpression && binaryBooleanExpressionKind(node) !== undefined;
}
|
javascript
|
function isBooleanBinaryExpression(node) {
return node.kind === ts.SyntaxKind.BinaryExpression && binaryBooleanExpressionKind(node) !== undefined;
}
|
[
"function",
"isBooleanBinaryExpression",
"(",
"node",
")",
"{",
"return",
"node",
".",
"kind",
"===",
"ts",
".",
"SyntaxKind",
".",
"BinaryExpression",
"&&",
"binaryBooleanExpressionKind",
"(",
"node",
")",
"!==",
"undefined",
";",
"}"
] |
Matches `&&` and `||` operators.
|
[
"Matches",
"&&",
"and",
"||",
"operators",
"."
] |
fdf83c7e65fcd5dbc5dbe39bb5d081561a339be9
|
https://github.com/wwwouter/tslint-contrib/blob/fdf83c7e65fcd5dbc5dbe39bb5d081561a339be9/noPromiseAsBooleanRule.js#L85-L87
|
52,548
|
elidoran/node-stating
|
examples/strings/counter/index.js
|
prop
|
function prop(v, w) { return {
value: v, writable: w, enumerable: true, configurable: false
}}
|
javascript
|
function prop(v, w) { return {
value: v, writable: w, enumerable: true, configurable: false
}}
|
[
"function",
"prop",
"(",
"v",
",",
"w",
")",
"{",
"return",
"{",
"value",
":",
"v",
",",
"writable",
":",
"w",
",",
"enumerable",
":",
"true",
",",
"configurable",
":",
"false",
"}",
"}"
] |
build an "executor" which will accept strings and use the specified context. the context has a custom `reset` function, and default values for the properties used.
|
[
"build",
"an",
"executor",
"which",
"will",
"accept",
"strings",
"and",
"use",
"the",
"specified",
"context",
".",
"the",
"context",
"has",
"a",
"custom",
"reset",
"function",
"and",
"default",
"values",
"for",
"the",
"properties",
"used",
"."
] |
557facf637dafb3747183b8f3e165a4e27e045db
|
https://github.com/elidoran/node-stating/blob/557facf637dafb3747183b8f3e165a4e27e045db/examples/strings/counter/index.js#L75-L77
|
52,549
|
redisjs/jsr-server
|
lib/command/script/eval.js
|
execute
|
function execute(req, res) {
ScriptManager.eval(req, res, '' + req.args[0], req.args.slice(1));
}
|
javascript
|
function execute(req, res) {
ScriptManager.eval(req, res, '' + req.args[0], req.args.slice(1));
}
|
[
"function",
"execute",
"(",
"req",
",",
"res",
")",
"{",
"ScriptManager",
".",
"eval",
"(",
"req",
",",
"res",
",",
"''",
"+",
"req",
".",
"args",
"[",
"0",
"]",
",",
"req",
".",
"args",
".",
"slice",
"(",
"1",
")",
")",
";",
"}"
] |
Respond to the EVAL command.
|
[
"Respond",
"to",
"the",
"EVAL",
"command",
"."
] |
49413052d3039524fbdd2ade0ef9bae26cb4d647
|
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/script/eval.js#L20-L22
|
52,550
|
vkiding/judpack-lib
|
src/cordova/metadata/parser.js
|
Parser
|
function Parser (platform, projectPath) {
this.platform = platform || '';
this.path = projectPath || '';
// Extend with a ParserHelper instance
Object.defineProperty(this, 'helper', {
value: new ParserHelper(this.platform),
enumerable: true,
configurable: false,
writable: false
});
}
|
javascript
|
function Parser (platform, projectPath) {
this.platform = platform || '';
this.path = projectPath || '';
// Extend with a ParserHelper instance
Object.defineProperty(this, 'helper', {
value: new ParserHelper(this.platform),
enumerable: true,
configurable: false,
writable: false
});
}
|
[
"function",
"Parser",
"(",
"platform",
",",
"projectPath",
")",
"{",
"this",
".",
"platform",
"=",
"platform",
"||",
"''",
";",
"this",
".",
"path",
"=",
"projectPath",
"||",
"''",
";",
"// Extend with a ParserHelper instance",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'helper'",
",",
"{",
"value",
":",
"new",
"ParserHelper",
"(",
"this",
".",
"platform",
")",
",",
"enumerable",
":",
"true",
",",
"configurable",
":",
"false",
",",
"writable",
":",
"false",
"}",
")",
";",
"}"
] |
Base module for platform parsers
@param {String} [platform] Platform name (e.g. android)
@param {String} [projectPath] path/to/platform/project
|
[
"Base",
"module",
"for",
"platform",
"parsers"
] |
8657cecfec68221109279106adca8dbc81f430f4
|
https://github.com/vkiding/judpack-lib/blob/8657cecfec68221109279106adca8dbc81f430f4/src/cordova/metadata/parser.js#L32-L45
|
52,551
|
copress/copress-component-oauth2
|
lib/resource-server.js
|
authenticate
|
function authenticate(options) {
options = options || {};
var authenticators = [
passport.authenticate(['copress-oauth2-bearer', 'copress-oauth2-mac'],
options)];
if (options.scopes || options.scope) {
authenticators.push(scopeValidator(options));
}
authenticators.push(oauth2Provider.errorHandler());
return authenticators;
}
|
javascript
|
function authenticate(options) {
options = options || {};
var authenticators = [
passport.authenticate(['copress-oauth2-bearer', 'copress-oauth2-mac'],
options)];
if (options.scopes || options.scope) {
authenticators.push(scopeValidator(options));
}
authenticators.push(oauth2Provider.errorHandler());
return authenticators;
}
|
[
"function",
"authenticate",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"authenticators",
"=",
"[",
"passport",
".",
"authenticate",
"(",
"[",
"'copress-oauth2-bearer'",
",",
"'copress-oauth2-mac'",
"]",
",",
"options",
")",
"]",
";",
"if",
"(",
"options",
".",
"scopes",
"||",
"options",
".",
"scope",
")",
"{",
"authenticators",
".",
"push",
"(",
"scopeValidator",
"(",
"options",
")",
")",
";",
"}",
"authenticators",
".",
"push",
"(",
"oauth2Provider",
".",
"errorHandler",
"(",
")",
")",
";",
"return",
"authenticators",
";",
"}"
] |
Return the middleware chain to enforce oAuth 2.0 authentication and
authorization
@param {Object} [options] Options object
- scope
- jwt
|
[
"Return",
"the",
"middleware",
"chain",
"to",
"enforce",
"oAuth",
"2",
".",
"0",
"authentication",
"and",
"authorization"
] |
4819f379a0d42753bfd51e237c5c3aaddee37544
|
https://github.com/copress/copress-component-oauth2/blob/4819f379a0d42753bfd51e237c5c3aaddee37544/lib/resource-server.js#L159-L170
|
52,552
|
joshuamurray/storage.json
|
lib/Path.js
|
function( string ){
if( string[ string.length -1 ] !== $this.slash.get()) string = string + $this.slash.get();
return string;
}
|
javascript
|
function( string ){
if( string[ string.length -1 ] !== $this.slash.get()) string = string + $this.slash.get();
return string;
}
|
[
"function",
"(",
"string",
")",
"{",
"if",
"(",
"string",
"[",
"string",
".",
"length",
"-",
"1",
"]",
"!==",
"$this",
".",
"slash",
".",
"get",
"(",
")",
")",
"string",
"=",
"string",
"+",
"$this",
".",
"slash",
".",
"get",
"(",
")",
";",
"return",
"string",
";",
"}"
] |
Adds the value of "slash.string" to the end of the provided string,
unless the last character is already the value of "slash.string".
@param {string} string
@returns {string}
|
[
"Adds",
"the",
"value",
"of",
"slash",
".",
"string",
"to",
"the",
"end",
"of",
"the",
"provided",
"string",
"unless",
"the",
"last",
"character",
"is",
"already",
"the",
"value",
"of",
"slash",
".",
"string",
"."
] |
9ed7ecbb6882e14be31635facba2b80f89456531
|
https://github.com/joshuamurray/storage.json/blob/9ed7ecbb6882e14be31635facba2b80f89456531/lib/Path.js#L72-L76
|
|
52,553
|
joshuamurray/storage.json
|
lib/Path.js
|
function( string ){
string = $this.slash.clean( string );
if( string[ 0 ] === $this.slash.get()) string = string.substr( 1 );
if( string[ string.length -1 ] === $this.slash.get()) string = string.substr( 0, string.length -1 );
return string;
}
|
javascript
|
function( string ){
string = $this.slash.clean( string );
if( string[ 0 ] === $this.slash.get()) string = string.substr( 1 );
if( string[ string.length -1 ] === $this.slash.get()) string = string.substr( 0, string.length -1 );
return string;
}
|
[
"function",
"(",
"string",
")",
"{",
"string",
"=",
"$this",
".",
"slash",
".",
"clean",
"(",
"string",
")",
";",
"if",
"(",
"string",
"[",
"0",
"]",
"===",
"$this",
".",
"slash",
".",
"get",
"(",
")",
")",
"string",
"=",
"string",
".",
"substr",
"(",
"1",
")",
";",
"if",
"(",
"string",
"[",
"string",
".",
"length",
"-",
"1",
"]",
"===",
"$this",
".",
"slash",
".",
"get",
"(",
")",
")",
"string",
"=",
"string",
".",
"substr",
"(",
"0",
",",
"string",
".",
"length",
"-",
"1",
")",
";",
"return",
"string",
";",
"}"
] |
Removes the value of "slash.string" from the start AND end of the provided string,
unless the first AND last characters do not match the value of "slash.string".
@param {string} string
@returns {string}
|
[
"Removes",
"the",
"value",
"of",
"slash",
".",
"string",
"from",
"the",
"start",
"AND",
"end",
"of",
"the",
"provided",
"string",
"unless",
"the",
"first",
"AND",
"last",
"characters",
"do",
"not",
"match",
"the",
"value",
"of",
"slash",
".",
"string",
"."
] |
9ed7ecbb6882e14be31635facba2b80f89456531
|
https://github.com/joshuamurray/storage.json/blob/9ed7ecbb6882e14be31635facba2b80f89456531/lib/Path.js#L94-L101
|
|
52,554
|
taoyuan/path-rewriter
|
lib/rewriter.js
|
to_map
|
function to_map(params) {
var map = {};
params.forEach(function (param, i) {
param.index = i;
map[param.name] = param;
});
map.length = params.length;
return map;
}
|
javascript
|
function to_map(params) {
var map = {};
params.forEach(function (param, i) {
param.index = i;
map[param.name] = param;
});
map.length = params.length;
return map;
}
|
[
"function",
"to_map",
"(",
"params",
")",
"{",
"var",
"map",
"=",
"{",
"}",
";",
"params",
".",
"forEach",
"(",
"function",
"(",
"param",
",",
"i",
")",
"{",
"param",
".",
"index",
"=",
"i",
";",
"map",
"[",
"param",
".",
"name",
"]",
"=",
"param",
";",
"}",
")",
";",
"map",
".",
"length",
"=",
"params",
".",
"length",
";",
"return",
"map",
";",
"}"
] |
Turn params array into a map for quick lookup.
@param {Array} params
@return {Object}
@api private
|
[
"Turn",
"params",
"array",
"into",
"a",
"map",
"for",
"quick",
"lookup",
"."
] |
8dc82918e09af399006f8d6b0158399414470032
|
https://github.com/taoyuan/path-rewriter/blob/8dc82918e09af399006f8d6b0158399414470032/lib/rewriter.js#L140-L151
|
52,555
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this._existsCb.bind(this, selector, hash));
return this;
}
|
javascript
|
function (selector, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this._existsCb.bind(this, selector, hash));
return this;
}
|
[
"function",
"(",
"selector",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_existsCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if an element exists
@method exists
@param {string} selector Selector expression to find the element
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"if",
"an",
"element",
"exists"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L49-L53
|
|
52,556
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.displayed.bind(this.webdriverClient, selector));
this.actionQueue.push(this._visibleCb.bind(this, selector, hash));
return this;
}
|
javascript
|
function (selector, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.displayed.bind(this.webdriverClient, selector));
this.actionQueue.push(this._visibleCb.bind(this, selector, hash));
return this;
}
|
[
"function",
"(",
"selector",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"displayed",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_visibleCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if an element is visible
@method visible
@param {string} selector Selector expression to find the element
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"if",
"an",
"element",
"is",
"visible"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L82-L87
|
|
52,557
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.text.bind(this.webdriverClient, selector));
this.actionQueue.push(this._textCb.bind(this, selector, hash, expected));
return this;
}
|
javascript
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.text.bind(this.webdriverClient, selector));
this.actionQueue.push(this._textCb.bind(this, selector, hash, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"text",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_textCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if an element has the expected text
@method text
@param {string} selector Selector expression to find the element
@param {string} expected The expected text content
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"if",
"an",
"element",
"has",
"the",
"expected",
"text"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L117-L122
|
|
52,558
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.size.bind(this.webdriverClient));
this.actionQueue.push(this._widthCb.bind(this, selector, hash, expected));
return this;
}
|
javascript
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.size.bind(this.webdriverClient));
this.actionQueue.push(this._widthCb.bind(this, selector, hash, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"size",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_widthCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks th width of an element
@method width
@param {string} selector Selector expression to find the element
@param {string} expected The expected width value
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"th",
"width",
"of",
"an",
"element"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L191-L196
|
|
52,559
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, attribute, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.getAttribute.bind(this.webdriverClient, attribute));
this.actionQueue.push(this._attributeCb.bind(this, selector, hash, attribute, expected));
return this;
}
|
javascript
|
function (selector, attribute, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.getAttribute.bind(this.webdriverClient, attribute));
this.actionQueue.push(this._attributeCb.bind(this, selector, hash, attribute, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"attribute",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"getAttribute",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"attribute",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_attributeCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"attribute",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if an element has an attribute with the expected value
@method attribute
@param {string} selector Selector expression to find the element
@param {string} attribute The attribute that should be checked
@param {string} expected The expected text content
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"if",
"an",
"element",
"has",
"an",
"attribute",
"with",
"the",
"expected",
"value"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L264-L269
|
|
52,560
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.getAttribute.bind(this.webdriverClient, 'value'));
this.actionQueue.push(this._valCb.bind(this, selector, hash, expected));
return this;
}
|
javascript
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.getAttribute.bind(this.webdriverClient, 'value'));
this.actionQueue.push(this._valCb.bind(this, selector, hash, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"getAttribute",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"'value'",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_valCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if an element has the expected value
@method val
@param {string} selector Selector expression to find the element
@param {string} expected The expected content
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"if",
"an",
"element",
"has",
"the",
"expected",
"value"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L301-L306
|
|
52,561
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.selected.bind(this.webdriverClient));
this.actionQueue.push(this._selectedCb.bind(this, selector, hash, expected));
return this;
}
|
javascript
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.selected.bind(this.webdriverClient));
this.actionQueue.push(this._selectedCb.bind(this, selector, hash, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"selected",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_selectedCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if an element is selected
@method selected
@param {string} selector Selector expression to find the element
@param {string} expected The expected content
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"if",
"an",
"element",
"is",
"selected"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L337-L342
|
|
52,562
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.enabled.bind(this.webdriverClient));
this.actionQueue.push(this._enabledCb.bind(this, selector, hash, expected));
return this;
}
|
javascript
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.enabled.bind(this.webdriverClient));
this.actionQueue.push(this._enabledCb.bind(this, selector, hash, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"enabled",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_enabledCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks if an element is enabled
@method enabled
@param {string} selector Selector expression to find the element
@param {string} expected The expected content
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"if",
"an",
"element",
"is",
"enabled"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L373-L378
|
|
52,563
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, hash, uuid) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.submit.bind(this.webdriverClient));
this.actionQueue.push(this._submitCb.bind(this, selector, hash, uuid));
return this;
}
|
javascript
|
function (selector, hash, uuid) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector));
this.actionQueue.push(this.webdriverClient.submit.bind(this.webdriverClient));
this.actionQueue.push(this._submitCb.bind(this, selector, hash, uuid));
return this;
}
|
[
"function",
"(",
"selector",
",",
"hash",
",",
"uuid",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"submit",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_submitCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"uuid",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Submits a form
@method submit
@param {string} selector Selector expression to find the element
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@chainable
|
[
"Submits",
"a",
"form"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L409-L414
|
|
52,564
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, hash, uuid) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'submit', value: selector, uuid: uuid, hash: hash});
deferred.resolve();
return deferred.promise;
}
|
javascript
|
function (selector, hash, uuid) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'submit', value: selector, uuid: uuid, hash: hash});
deferred.resolve();
return deferred.promise;
}
|
[
"function",
"(",
"selector",
",",
"hash",
",",
"uuid",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'submit'",
",",
"value",
":",
"selector",
",",
"uuid",
":",
"uuid",
",",
"hash",
":",
"hash",
"}",
")",
";",
"deferred",
".",
"resolve",
"(",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] |
Sends out an event with the results of the `submit` call
@method _submitCb
@param {string} selector Selector expression to find the element
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@return {object} promise Click promise
@private
|
[
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"submit",
"call"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L427-L432
|
|
52,565
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, options, hash, uuid) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector, options));
this.actionQueue.push(this.webdriverClient.scroll.bind(this.webdriverClient));
this.actionQueue.push(this._clickCb.bind(this, selector, options, hash, uuid));
return this;
}
|
javascript
|
function (selector, options, hash, uuid) {
this.actionQueue.push(this.webdriverClient.element.bind(this.webdriverClient, selector, options));
this.actionQueue.push(this.webdriverClient.scroll.bind(this.webdriverClient));
this.actionQueue.push(this._clickCb.bind(this, selector, options, hash, uuid));
return this;
}
|
[
"function",
"(",
"selector",
",",
"options",
",",
"hash",
",",
"uuid",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"element",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
",",
"options",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"scroll",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_clickCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"options",
",",
"hash",
",",
"uuid",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Scrolls from an element to a location defined in pixels
@method scroll
@param {string} selector Selector expression to find the element
@param {object} options X offset, Y offset, Speed
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@chainable
|
[
"Scrolls",
"from",
"an",
"element",
"to",
"a",
"location",
"defined",
"in",
"pixels"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L480-L485
|
|
52,566
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, timeout, hash, uuid) {
this.actionQueue.push(this.webdriverClient.implicitWait.bind(this.webdriverClient, timeout));
this.actionQueue.push(this._waitForElementCb.bind(this, selector, hash, uuid));
return this;
}
|
javascript
|
function (selector, timeout, hash, uuid) {
this.actionQueue.push(this.webdriverClient.implicitWait.bind(this.webdriverClient, timeout));
this.actionQueue.push(this._waitForElementCb.bind(this, selector, hash, uuid));
return this;
}
|
[
"function",
"(",
"selector",
",",
"timeout",
",",
"hash",
",",
"uuid",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"implicitWait",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"timeout",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_waitForElementCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"uuid",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Wait for an element for a specific amount of time
@method waitForElement
@param {string} selector Selector expression to find the element
@param {integer} timeout Time to wait in ms
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@chainable
|
[
"Wait",
"for",
"an",
"element",
"for",
"a",
"specific",
"amount",
"of",
"time"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L584-L588
|
|
52,567
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.elements.bind(this.webdriverClient, selector));
this.actionQueue.push(this._getNumberOfElementsCb.bind(this, selector, hash, expected));
return this;
}
|
javascript
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.elements.bind(this.webdriverClient, selector));
this.actionQueue.push(this._getNumberOfElementsCb.bind(this, selector, hash, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"elements",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_getNumberOfElementsCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Returns the number of elements matched by the selector
@method getNumberOfElements
@param {string} selector Selector expression to find the elements
@param {integer} expected Expected number of matched elements
@param {string} uuid Unique hash of that fn call
@chainable
|
[
"Returns",
"the",
"number",
"of",
"elements",
"matched",
"by",
"the",
"selector"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L618-L622
|
|
52,568
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.elements.bind(this.webdriverClient, selector));
this.actionQueue.push(function (result) {
var deferred = Q.defer();
var res = JSON.parse(result);
var resLength = res.value.length;
var curLength = 0;
var visibleElement = [];
res.value.forEach(function (element) {
var fakeResponse = JSON.stringify({sessionId: res.sessionId, status: 0, value: element.ELEMENT});
this.webdriverClient.options.id = element.ELEMENT;
this.webdriverClient.displayed.bind(this.webdriverClient, selector)(fakeResponse).then(function (visRes) {
curLength++;
if (JSON.parse(visRes).value === true) {
visibleElement.push(element);
}
if (curLength === resLength) {
deferred.resolve(JSON.stringify({sessionId: res.sessionId, status: 0, value: visibleElement}));
}
});
}.bind(this));
return deferred.promise;
}.bind(this));
this.actionQueue.push(this._getNumberOfVisibleElementsCb.bind(this, selector, hash, expected));
return this;
}
|
javascript
|
function (selector, expected, hash) {
this.actionQueue.push(this.webdriverClient.elements.bind(this.webdriverClient, selector));
this.actionQueue.push(function (result) {
var deferred = Q.defer();
var res = JSON.parse(result);
var resLength = res.value.length;
var curLength = 0;
var visibleElement = [];
res.value.forEach(function (element) {
var fakeResponse = JSON.stringify({sessionId: res.sessionId, status: 0, value: element.ELEMENT});
this.webdriverClient.options.id = element.ELEMENT;
this.webdriverClient.displayed.bind(this.webdriverClient, selector)(fakeResponse).then(function (visRes) {
curLength++;
if (JSON.parse(visRes).value === true) {
visibleElement.push(element);
}
if (curLength === resLength) {
deferred.resolve(JSON.stringify({sessionId: res.sessionId, status: 0, value: visibleElement}));
}
});
}.bind(this));
return deferred.promise;
}.bind(this));
this.actionQueue.push(this._getNumberOfVisibleElementsCb.bind(this, selector, hash, expected));
return this;
}
|
[
"function",
"(",
"selector",
",",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"elements",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"function",
"(",
"result",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"res",
"=",
"JSON",
".",
"parse",
"(",
"result",
")",
";",
"var",
"resLength",
"=",
"res",
".",
"value",
".",
"length",
";",
"var",
"curLength",
"=",
"0",
";",
"var",
"visibleElement",
"=",
"[",
"]",
";",
"res",
".",
"value",
".",
"forEach",
"(",
"function",
"(",
"element",
")",
"{",
"var",
"fakeResponse",
"=",
"JSON",
".",
"stringify",
"(",
"{",
"sessionId",
":",
"res",
".",
"sessionId",
",",
"status",
":",
"0",
",",
"value",
":",
"element",
".",
"ELEMENT",
"}",
")",
";",
"this",
".",
"webdriverClient",
".",
"options",
".",
"id",
"=",
"element",
".",
"ELEMENT",
";",
"this",
".",
"webdriverClient",
".",
"displayed",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"selector",
")",
"(",
"fakeResponse",
")",
".",
"then",
"(",
"function",
"(",
"visRes",
")",
"{",
"curLength",
"++",
";",
"if",
"(",
"JSON",
".",
"parse",
"(",
"visRes",
")",
".",
"value",
"===",
"true",
")",
"{",
"visibleElement",
".",
"push",
"(",
"element",
")",
";",
"}",
"if",
"(",
"curLength",
"===",
"resLength",
")",
"{",
"deferred",
".",
"resolve",
"(",
"JSON",
".",
"stringify",
"(",
"{",
"sessionId",
":",
"res",
".",
"sessionId",
",",
"status",
":",
"0",
",",
"value",
":",
"visibleElement",
"}",
")",
")",
";",
"}",
"}",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_getNumberOfVisibleElementsCb",
".",
"bind",
"(",
"this",
",",
"selector",
",",
"hash",
",",
"expected",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Returns the number of visible elements matched by the selector
@method getNumberOfVisibleElements
@param {string} selector Selector expression to find the elements
@param {integer} expected Expected number of matched elements
@param {string} uuid Unique hash of that fn call
@chainable
|
[
"Returns",
"the",
"number",
"of",
"visible",
"elements",
"matched",
"by",
"the",
"selector"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L661-L688
|
|
52,569
|
dalekjs/dalek-driver-sauce
|
lib/commands/element.js
|
function (selector, hash, expected, res) {
var deferred = Q.defer();
var result = JSON.parse(res);
// check if the expression matched any element
if (result.value === -1) {
this.events.emit('driver:message', {key: 'numberOfVisibleElements', hash: hash, selector: selector, expected: expected, value: 0});
} else {
this.events.emit('driver:message', {key: 'numberOfVisibleElements', selector: selector, expected: expected, hash: hash, value: result.value.length});
}
deferred.resolve();
return deferred.promise;
}
|
javascript
|
function (selector, hash, expected, res) {
var deferred = Q.defer();
var result = JSON.parse(res);
// check if the expression matched any element
if (result.value === -1) {
this.events.emit('driver:message', {key: 'numberOfVisibleElements', hash: hash, selector: selector, expected: expected, value: 0});
} else {
this.events.emit('driver:message', {key: 'numberOfVisibleElements', selector: selector, expected: expected, hash: hash, value: result.value.length});
}
deferred.resolve();
return deferred.promise;
}
|
[
"function",
"(",
"selector",
",",
"hash",
",",
"expected",
",",
"res",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"var",
"result",
"=",
"JSON",
".",
"parse",
"(",
"res",
")",
";",
"// check if the expression matched any element",
"if",
"(",
"result",
".",
"value",
"===",
"-",
"1",
")",
"{",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'numberOfVisibleElements'",
",",
"hash",
":",
"hash",
",",
"selector",
":",
"selector",
",",
"expected",
":",
"expected",
",",
"value",
":",
"0",
"}",
")",
";",
"}",
"else",
"{",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'numberOfVisibleElements'",
",",
"selector",
":",
"selector",
",",
"expected",
":",
"expected",
",",
"hash",
":",
"hash",
",",
"value",
":",
"result",
".",
"value",
".",
"length",
"}",
")",
";",
"}",
"deferred",
".",
"resolve",
"(",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] |
Sends out an event with the results of the `getNumberOfVisibleElements` call
@method _getNumberOfElementsCb
@param {string} selector Selector expression to find the element
@param {string} hash Unique hash of that fn call
@param {integer} expected Expected number of matched elements
@param {string} res Serialized JSON with the results of the getNumberOfVisibleElements call
@return {object} promise GetNumberOfElements promise
@private
|
[
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"getNumberOfVisibleElements",
"call"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/element.js#L702-L715
|
|
52,570
|
mobilehero-archive/aplus-underscore
|
aplus-underscore.js
|
replace_content
|
function replace_content(fullpath) {
var source = fs.readFileSync(fullpath, 'utf8');
var regex = /(require\s*\(\s*['"]alloy\/underscore['"]\s*\))._/g
var test = regex.test(source);
if(test) {
logger.trace("Fixing file: " + fullpath);
source = source.replace(regex, "$1");
fs.writeFileSync(fullpath, source);
}
}
|
javascript
|
function replace_content(fullpath) {
var source = fs.readFileSync(fullpath, 'utf8');
var regex = /(require\s*\(\s*['"]alloy\/underscore['"]\s*\))._/g
var test = regex.test(source);
if(test) {
logger.trace("Fixing file: " + fullpath);
source = source.replace(regex, "$1");
fs.writeFileSync(fullpath, source);
}
}
|
[
"function",
"replace_content",
"(",
"fullpath",
")",
"{",
"var",
"source",
"=",
"fs",
".",
"readFileSync",
"(",
"fullpath",
",",
"'utf8'",
")",
";",
"var",
"regex",
"=",
"/",
"(require\\s*\\(\\s*['\"]alloy\\/underscore['\"]\\s*\\))._",
"/",
"g",
"var",
"test",
"=",
"regex",
".",
"test",
"(",
"source",
")",
";",
"if",
"(",
"test",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Fixing file: \"",
"+",
"fullpath",
")",
";",
"source",
"=",
"source",
".",
"replace",
"(",
"regex",
",",
"\"$1\"",
")",
";",
"fs",
".",
"writeFileSync",
"(",
"fullpath",
",",
"source",
")",
";",
"}",
"}"
] |
Remove invalid underscore calls from a file
@param {string} fullpath
|
[
"Remove",
"invalid",
"underscore",
"calls",
"from",
"a",
"file"
] |
bb518fec188b04053131225b28d8fe36becd1d41
|
https://github.com/mobilehero-archive/aplus-underscore/blob/bb518fec188b04053131225b28d8fe36becd1d41/aplus-underscore.js#L39-L48
|
52,571
|
mobilehero-archive/aplus-underscore
|
aplus-underscore.js
|
plugin
|
function plugin(params) {
logger = params.logger;
params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform;
logger.trace("fixing underscore in directory: " + params.dirname);
replace_content(path.join(params.dirname, "alloy.js"))
replace_content(path.join(params.dirname, "alloy", "sync", "properties.js"))
replace_content(path.join(params.dirname, "alloy", "sync", "sql.js"))
}
|
javascript
|
function plugin(params) {
logger = params.logger;
params.dirname = params.dirname ? _.template(params.dirname)(params) : params.event.dir.resourcesPlatform;
logger.trace("fixing underscore in directory: " + params.dirname);
replace_content(path.join(params.dirname, "alloy.js"))
replace_content(path.join(params.dirname, "alloy", "sync", "properties.js"))
replace_content(path.join(params.dirname, "alloy", "sync", "sql.js"))
}
|
[
"function",
"plugin",
"(",
"params",
")",
"{",
"logger",
"=",
"params",
".",
"logger",
";",
"params",
".",
"dirname",
"=",
"params",
".",
"dirname",
"?",
"_",
".",
"template",
"(",
"params",
".",
"dirname",
")",
"(",
"params",
")",
":",
"params",
".",
"event",
".",
"dir",
".",
"resourcesPlatform",
";",
"logger",
".",
"trace",
"(",
"\"fixing underscore in directory: \"",
"+",
"params",
".",
"dirname",
")",
";",
"replace_content",
"(",
"path",
".",
"join",
"(",
"params",
".",
"dirname",
",",
"\"alloy.js\"",
")",
")",
"replace_content",
"(",
"path",
".",
"join",
"(",
"params",
".",
"dirname",
",",
"\"alloy\"",
",",
"\"sync\"",
",",
"\"properties.js\"",
")",
")",
"replace_content",
"(",
"path",
".",
"join",
"(",
"params",
".",
"dirname",
",",
"\"alloy\"",
",",
"\"sync\"",
",",
"\"sql.js\"",
")",
")",
"}"
] |
Fix certain usages of underscore.js in Alloy source code
@param {object} params
|
[
"Fix",
"certain",
"usages",
"of",
"underscore",
".",
"js",
"in",
"Alloy",
"source",
"code"
] |
bb518fec188b04053131225b28d8fe36becd1d41
|
https://github.com/mobilehero-archive/aplus-underscore/blob/bb518fec188b04053131225b28d8fe36becd1d41/aplus-underscore.js#L55-L63
|
52,572
|
Crafity/crafity-core
|
lib/modules/crafity.query.js
|
Enumerator
|
function Enumerator(getCurrent, moveNext, reset) {
var index = 0,
self = this;
/**
* Get the current index of the enumerator
*/
this.getIndex = function getIndexEnumeratorInternal() {
return index;
};
/**
* Function that retrieves the current value
* @function
* @returns {Object} The current item
*/
this.getCurrent = function getCurrentInternal() {
return getCurrent(self);
};
this.overrideGetCurrent = function overrideGetCurrentInternal(getCurrent) {
self.getCurrent = function () {
return getCurrent(self.getCurrent());
};
return self;
};
/**
* Function that moves to the next item and returns true if there was a next item, otherwise false
* @function
* @returns {Boolean} True if moved to the next item, otherwise false
*/
this.moveNext = function moveNextInternal() {
index = index + 1;
return moveNext(self);
};
/**
* Function that moves to the next item and returns true if there was a next item, otherwise false
* @function
* @returns {Boolean} True if moved to the next item, otherwise false
*/
this.reset = function resetInternal() {
index = 0;
return reset(self);
};
}
|
javascript
|
function Enumerator(getCurrent, moveNext, reset) {
var index = 0,
self = this;
/**
* Get the current index of the enumerator
*/
this.getIndex = function getIndexEnumeratorInternal() {
return index;
};
/**
* Function that retrieves the current value
* @function
* @returns {Object} The current item
*/
this.getCurrent = function getCurrentInternal() {
return getCurrent(self);
};
this.overrideGetCurrent = function overrideGetCurrentInternal(getCurrent) {
self.getCurrent = function () {
return getCurrent(self.getCurrent());
};
return self;
};
/**
* Function that moves to the next item and returns true if there was a next item, otherwise false
* @function
* @returns {Boolean} True if moved to the next item, otherwise false
*/
this.moveNext = function moveNextInternal() {
index = index + 1;
return moveNext(self);
};
/**
* Function that moves to the next item and returns true if there was a next item, otherwise false
* @function
* @returns {Boolean} True if moved to the next item, otherwise false
*/
this.reset = function resetInternal() {
index = 0;
return reset(self);
};
}
|
[
"function",
"Enumerator",
"(",
"getCurrent",
",",
"moveNext",
",",
"reset",
")",
"{",
"var",
"index",
"=",
"0",
",",
"self",
"=",
"this",
";",
"/**\n * Get the current index of the enumerator\n */",
"this",
".",
"getIndex",
"=",
"function",
"getIndexEnumeratorInternal",
"(",
")",
"{",
"return",
"index",
";",
"}",
";",
"/**\n * Function that retrieves the current value\n * @function\n * @returns {Object} The current item\n */",
"this",
".",
"getCurrent",
"=",
"function",
"getCurrentInternal",
"(",
")",
"{",
"return",
"getCurrent",
"(",
"self",
")",
";",
"}",
";",
"this",
".",
"overrideGetCurrent",
"=",
"function",
"overrideGetCurrentInternal",
"(",
"getCurrent",
")",
"{",
"self",
".",
"getCurrent",
"=",
"function",
"(",
")",
"{",
"return",
"getCurrent",
"(",
"self",
".",
"getCurrent",
"(",
")",
")",
";",
"}",
";",
"return",
"self",
";",
"}",
";",
"/**\n * Function that moves to the next item and returns true if there was a next item, otherwise false\n * @function\n * @returns {Boolean} True if moved to the next item, otherwise false\n */",
"this",
".",
"moveNext",
"=",
"function",
"moveNextInternal",
"(",
")",
"{",
"index",
"=",
"index",
"+",
"1",
";",
"return",
"moveNext",
"(",
"self",
")",
";",
"}",
";",
"/**\n * Function that moves to the next item and returns true if there was a next item, otherwise false\n * @function\n * @returns {Boolean} True if moved to the next item, otherwise false\n */",
"this",
".",
"reset",
"=",
"function",
"resetInternal",
"(",
")",
"{",
"index",
"=",
"0",
";",
"return",
"reset",
"(",
"self",
")",
";",
"}",
";",
"}"
] |
The Enumerator base class
@class Enumerator
@param {Function} getCurrent Function that retrieves the current value
@param {Function} moveNext Function that moves to the next item and returns true if there was a next item, otherwise false
@param {Function} reset Function that resets the enumerator to the beginning of the enumerable
|
[
"The",
"Enumerator",
"base",
"class"
] |
c0f2271fa6f9c1164450928b2b480f397c9ec20b
|
https://github.com/Crafity/crafity-core/blob/c0f2271fa6f9c1164450928b2b480f397c9ec20b/lib/modules/crafity.query.js#L84-L127
|
52,573
|
svbatalov/ractive-component-iscroll
|
index.js
|
function (t) {
var self = this;
this.node = t.node;
var userOpts = this.get('opts');
this.opts = extend(defaultOpts, userOpts);
setTimeout(function () {
self.s = new IScroll(t.node, self.opts);
t.complete();
}, 0);
}
|
javascript
|
function (t) {
var self = this;
this.node = t.node;
var userOpts = this.get('opts');
this.opts = extend(defaultOpts, userOpts);
setTimeout(function () {
self.s = new IScroll(t.node, self.opts);
t.complete();
}, 0);
}
|
[
"function",
"(",
"t",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"node",
"=",
"t",
".",
"node",
";",
"var",
"userOpts",
"=",
"this",
".",
"get",
"(",
"'opts'",
")",
";",
"this",
".",
"opts",
"=",
"extend",
"(",
"defaultOpts",
",",
"userOpts",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"s",
"=",
"new",
"IScroll",
"(",
"t",
".",
"node",
",",
"self",
".",
"opts",
")",
";",
"t",
".",
"complete",
"(",
")",
";",
"}",
",",
"0",
")",
";",
"}"
] |
Use intro transition to determine when wrapped template has finished animations and to get actual DOM node.
|
[
"Use",
"intro",
"transition",
"to",
"determine",
"when",
"wrapped",
"template",
"has",
"finished",
"animations",
"and",
"to",
"get",
"actual",
"DOM",
"node",
"."
] |
ab378a53b2b047b1d9fa494ac76f3bdcc716a2d0
|
https://github.com/svbatalov/ractive-component-iscroll/blob/ab378a53b2b047b1d9fa494ac76f3bdcc716a2d0/index.js#L55-L65
|
|
52,574
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (message, hash) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'noop', uuid: hash, hash: hash, value: message});
deferred.resolve();
return deferred.promise;
}
|
javascript
|
function (message, hash) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'noop', uuid: hash, hash: hash, value: message});
deferred.resolve();
return deferred.promise;
}
|
[
"function",
"(",
"message",
",",
"hash",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'noop'",
",",
"uuid",
":",
"hash",
",",
"hash",
":",
"hash",
",",
"value",
":",
"message",
"}",
")",
";",
"deferred",
".",
"resolve",
"(",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] |
Sends out an event with the results of the `noop` call
@method _noopCb
@param {mixed} message Whatever yu like
@param {string} hash Unique hash of that fn call
@return {object} Promise
@private
|
[
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"noop",
"call"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L64-L69
|
|
52,575
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (hash) {
this.actionQueue.push(this.webdriverClient.source.bind(this.webdriverClient));
this.actionQueue.push(this._sourceCb.bind(this, hash));
return this;
}
|
javascript
|
function (hash) {
this.actionQueue.push(this.webdriverClient.source.bind(this.webdriverClient));
this.actionQueue.push(this._sourceCb.bind(this, hash));
return this;
}
|
[
"function",
"(",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"source",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_sourceCb",
".",
"bind",
"(",
"this",
",",
"hash",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Gets the HTML source of a page
@method source
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Gets",
"the",
"HTML",
"source",
"of",
"a",
"page"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L79-L83
|
|
52,576
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (hash, source) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'source', uuid: hash, hash: hash, value: JSON.parse(source).value});
deferred.resolve();
return deferred.promise;
}
|
javascript
|
function (hash, source) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'source', uuid: hash, hash: hash, value: JSON.parse(source).value});
deferred.resolve();
return deferred.promise;
}
|
[
"function",
"(",
"hash",
",",
"source",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'source'",
",",
"uuid",
":",
"hash",
",",
"hash",
":",
"hash",
",",
"value",
":",
"JSON",
".",
"parse",
"(",
"source",
")",
".",
"value",
"}",
")",
";",
"deferred",
".",
"resolve",
"(",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] |
Sends out an event with the results of the `source` call
@method _sourceCb
@param {string} hash Unique hash of that fn call
@param {string} source Serialized JSON with the results of the source call
@return {object} Promise
@private
|
[
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"source",
"call"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L95-L100
|
|
52,577
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (expected, hash) {
this.actionQueue.push(this.webdriverClient.title.bind(this.webdriverClient));
this.actionQueue.push(this._titleCb.bind(this, expected, hash));
return this;
}
|
javascript
|
function (expected, hash) {
this.actionQueue.push(this.webdriverClient.title.bind(this.webdriverClient));
this.actionQueue.push(this._titleCb.bind(this, expected, hash));
return this;
}
|
[
"function",
"(",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"title",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_titleCb",
".",
"bind",
"(",
"this",
",",
"expected",
",",
"hash",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks the document title of a page
@method title
@param {string} expected Expected page title
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"the",
"document",
"title",
"of",
"a",
"page"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L111-L115
|
|
52,578
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (expected, hash, title) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'title', expected: expected, hash: hash, value: JSON.parse(title).value});
deferred.resolve();
return deferred.promise;
}
|
javascript
|
function (expected, hash, title) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'title', expected: expected, hash: hash, value: JSON.parse(title).value});
deferred.resolve();
return deferred.promise;
}
|
[
"function",
"(",
"expected",
",",
"hash",
",",
"title",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'title'",
",",
"expected",
":",
"expected",
",",
"hash",
":",
"hash",
",",
"value",
":",
"JSON",
".",
"parse",
"(",
"title",
")",
".",
"value",
"}",
")",
";",
"deferred",
".",
"resolve",
"(",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] |
Sends out an event with the results of the `title` call
@method _titleCb
@param {string} expected Expected page title
@param {string} hash Unique hash of that fn call
@param {string} title Serialized JSON with the results of the title call
@return {object} promise Title promise
@private
|
[
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"title",
"call"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L128-L133
|
|
52,579
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (expected, hash) {
this.actionQueue.push(this.webdriverClient.alertText.bind(this.webdriverClient));
this.actionQueue.push(this._alertTextCb.bind(this, expected, hash));
return this;
}
|
javascript
|
function (expected, hash) {
this.actionQueue.push(this.webdriverClient.alertText.bind(this.webdriverClient));
this.actionQueue.push(this._alertTextCb.bind(this, expected, hash));
return this;
}
|
[
"function",
"(",
"expected",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"alertText",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_alertTextCb",
".",
"bind",
"(",
"this",
",",
"expected",
",",
"hash",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Checks the text of an alaert, prompt or confirm dialog
@method alertText
@param {string} expected Expected alert text
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Checks",
"the",
"text",
"of",
"an",
"alaert",
"prompt",
"or",
"confirm",
"dialog"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L144-L148
|
|
52,580
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (text, hash) {
this.actionQueue.push(this.webdriverClient.promptText.bind(this.webdriverClient, text));
this.actionQueue.push(this._promptTextCb.bind(this, text, hash));
return this;
}
|
javascript
|
function (text, hash) {
this.actionQueue.push(this.webdriverClient.promptText.bind(this.webdriverClient, text));
this.actionQueue.push(this._promptTextCb.bind(this, text, hash));
return this;
}
|
[
"function",
"(",
"text",
",",
"hash",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"promptText",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"text",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_promptTextCb",
".",
"bind",
"(",
"this",
",",
"text",
",",
"hash",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Sends text to a javascript prompt dialog box
@method promptText
@param {object} dimensions New window width & height
@param {string} hash Unique hash of that fn call
@chainable
|
[
"Sends",
"text",
"to",
"a",
"javascript",
"prompt",
"dialog",
"box"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L177-L181
|
|
52,581
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (timeout, hash, uuid) {
this.actionQueue.push(this.webdriverClient.implicitWait.bind(this.webdriverClient, timeout));
this.actionQueue.push(this._waitCb.bind(this, timeout, hash, uuid));
return this;
}
|
javascript
|
function (timeout, hash, uuid) {
this.actionQueue.push(this.webdriverClient.implicitWait.bind(this.webdriverClient, timeout));
this.actionQueue.push(this._waitCb.bind(this, timeout, hash, uuid));
return this;
}
|
[
"function",
"(",
"timeout",
",",
"hash",
",",
"uuid",
")",
"{",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"webdriverClient",
".",
"implicitWait",
".",
"bind",
"(",
"this",
".",
"webdriverClient",
",",
"timeout",
")",
")",
";",
"this",
".",
"actionQueue",
".",
"push",
"(",
"this",
".",
"_waitCb",
".",
"bind",
"(",
"this",
",",
"timeout",
",",
"hash",
",",
"uuid",
")",
")",
";",
"return",
"this",
";",
"}"
] |
Wait for a specific amount of time
@method wait
@param {integer} timeout Time to wait in ms
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@chainable
|
[
"Wait",
"for",
"a",
"specific",
"amount",
"of",
"time"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L273-L277
|
|
52,582
|
dalekjs/dalek-driver-sauce
|
lib/commands/page.js
|
function (timeout, hash, uuid) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'wait', timeout: timeout, uuid: uuid, hash: hash, value: timeout + ' ms'});
setTimeout(function () {
deferred.resolve();
}.bind(this), timeout);
return deferred.promise;
}
|
javascript
|
function (timeout, hash, uuid) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'wait', timeout: timeout, uuid: uuid, hash: hash, value: timeout + ' ms'});
setTimeout(function () {
deferred.resolve();
}.bind(this), timeout);
return deferred.promise;
}
|
[
"function",
"(",
"timeout",
",",
"hash",
",",
"uuid",
")",
"{",
"var",
"deferred",
"=",
"Q",
".",
"defer",
"(",
")",
";",
"this",
".",
"events",
".",
"emit",
"(",
"'driver:message'",
",",
"{",
"key",
":",
"'wait'",
",",
"timeout",
":",
"timeout",
",",
"uuid",
":",
"uuid",
",",
"hash",
":",
"hash",
",",
"value",
":",
"timeout",
"+",
"' ms'",
"}",
")",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"deferred",
".",
"resolve",
"(",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
",",
"timeout",
")",
";",
"return",
"deferred",
".",
"promise",
";",
"}"
] |
Sends out an event with the results of the `wait` call
@method _waitCb
@param {integer} timeout Time to wait in ms
@param {string} hash Unique hash of that fn call
@param {string} uuid Unique hash of that fn call
@return {object} promise WaitForElement promise
@private
|
[
"Sends",
"out",
"an",
"event",
"with",
"the",
"results",
"of",
"the",
"wait",
"call"
] |
4b3ef87a0c35a91db8456d074b0d47a3e0df58f7
|
https://github.com/dalekjs/dalek-driver-sauce/blob/4b3ef87a0c35a91db8456d074b0d47a3e0df58f7/lib/commands/page.js#L290-L297
|
|
52,583
|
psalaets/pie-slice
|
lib/pie.js
|
function(referencePoint, otherPoint) {
if (this.yDown) {
if (otherPoint.y > referencePoint.y) {
otherPoint = {
x: otherPoint.x,
y: referencePoint.y - (otherPoint.y - referencePoint.y)
}
} else if (otherPoint.y < referencePoint.y) {
otherPoint = {
x: otherPoint.x,
y: referencePoint.y + (referencePoint.y - otherPoint.y)
}
}
}
var delta = vec2d(otherPoint).minus(vec2d(referencePoint))
var weird = radiansToWeird(delta.angle())
var compass = weirdToCompass(weird)
for (var i = 0; i < this.slices.length; i++) {
if (this.slices[i].contains(compass)) {
return this.slices[i].number
}
}
}
|
javascript
|
function(referencePoint, otherPoint) {
if (this.yDown) {
if (otherPoint.y > referencePoint.y) {
otherPoint = {
x: otherPoint.x,
y: referencePoint.y - (otherPoint.y - referencePoint.y)
}
} else if (otherPoint.y < referencePoint.y) {
otherPoint = {
x: otherPoint.x,
y: referencePoint.y + (referencePoint.y - otherPoint.y)
}
}
}
var delta = vec2d(otherPoint).minus(vec2d(referencePoint))
var weird = radiansToWeird(delta.angle())
var compass = weirdToCompass(weird)
for (var i = 0; i < this.slices.length; i++) {
if (this.slices[i].contains(compass)) {
return this.slices[i].number
}
}
}
|
[
"function",
"(",
"referencePoint",
",",
"otherPoint",
")",
"{",
"if",
"(",
"this",
".",
"yDown",
")",
"{",
"if",
"(",
"otherPoint",
".",
"y",
">",
"referencePoint",
".",
"y",
")",
"{",
"otherPoint",
"=",
"{",
"x",
":",
"otherPoint",
".",
"x",
",",
"y",
":",
"referencePoint",
".",
"y",
"-",
"(",
"otherPoint",
".",
"y",
"-",
"referencePoint",
".",
"y",
")",
"}",
"}",
"else",
"if",
"(",
"otherPoint",
".",
"y",
"<",
"referencePoint",
".",
"y",
")",
"{",
"otherPoint",
"=",
"{",
"x",
":",
"otherPoint",
".",
"x",
",",
"y",
":",
"referencePoint",
".",
"y",
"+",
"(",
"referencePoint",
".",
"y",
"-",
"otherPoint",
".",
"y",
")",
"}",
"}",
"}",
"var",
"delta",
"=",
"vec2d",
"(",
"otherPoint",
")",
".",
"minus",
"(",
"vec2d",
"(",
"referencePoint",
")",
")",
"var",
"weird",
"=",
"radiansToWeird",
"(",
"delta",
".",
"angle",
"(",
")",
")",
"var",
"compass",
"=",
"weirdToCompass",
"(",
"weird",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"slices",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"slices",
"[",
"i",
"]",
".",
"contains",
"(",
"compass",
")",
")",
"{",
"return",
"this",
".",
"slices",
"[",
"i",
"]",
".",
"number",
"}",
"}",
"}"
] |
Tells what slice some point is in relative to a reference point.
@param referencePoint Object with x and y properties
@param otherPoint Object with x and y properties
@return zero based slice number
|
[
"Tells",
"what",
"slice",
"some",
"point",
"is",
"in",
"relative",
"to",
"a",
"reference",
"point",
"."
] |
ca119bb63ccefc09cc66ebfdf0bc19ebce364b88
|
https://github.com/psalaets/pie-slice/blob/ca119bb63ccefc09cc66ebfdf0bc19ebce364b88/lib/pie.js#L13-L37
|
|
52,584
|
redisjs/jsr-server
|
lib/command/database/string/getbit.js
|
validate
|
function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var offset = parseInt('' + args[1]);
if(isNaN(offset) || offset < 0 || offset > Constants.MAX_BIT_LEN) {
throw IntegerRange;
}
args[1] = offset;
}
|
javascript
|
function validate(cmd, args, info) {
AbstractCommand.prototype.validate.apply(this, arguments);
var offset = parseInt('' + args[1]);
if(isNaN(offset) || offset < 0 || offset > Constants.MAX_BIT_LEN) {
throw IntegerRange;
}
args[1] = offset;
}
|
[
"function",
"validate",
"(",
"cmd",
",",
"args",
",",
"info",
")",
"{",
"AbstractCommand",
".",
"prototype",
".",
"validate",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"var",
"offset",
"=",
"parseInt",
"(",
"''",
"+",
"args",
"[",
"1",
"]",
")",
";",
"if",
"(",
"isNaN",
"(",
"offset",
")",
"||",
"offset",
"<",
"0",
"||",
"offset",
">",
"Constants",
".",
"MAX_BIT_LEN",
")",
"{",
"throw",
"IntegerRange",
";",
"}",
"args",
"[",
"1",
"]",
"=",
"offset",
";",
"}"
] |
Validate the GETBIT command.
|
[
"Validate",
"the",
"GETBIT",
"command",
"."
] |
49413052d3039524fbdd2ade0ef9bae26cb4d647
|
https://github.com/redisjs/jsr-server/blob/49413052d3039524fbdd2ade0ef9bae26cb4d647/lib/command/database/string/getbit.js#L19-L26
|
52,585
|
buzzin0609/tagbuildr
|
src/handleClassesAndId.js
|
handleClassesAndId
|
function handleClassesAndId(str) {
return str.replace(/(.*?)([\.|#].[^|]*)(.*)/, function (fullStr, tag, classAndIds, end) {
if (classAndIds[0] === '|') {
return fullStr;
}
const clsIdArr = classAndIds.split(/(\..[^\.|#]*)/).filter(Boolean);
const returnArr = [];
let i = clsIdArr.length;
while (i--) {
returnArr.push(`|${attrType[clsIdArr[i][0]]}=${clsIdArr[i].substr(1)}`);
}
return tag + returnArr.join('') + end;
});
}
|
javascript
|
function handleClassesAndId(str) {
return str.replace(/(.*?)([\.|#].[^|]*)(.*)/, function (fullStr, tag, classAndIds, end) {
if (classAndIds[0] === '|') {
return fullStr;
}
const clsIdArr = classAndIds.split(/(\..[^\.|#]*)/).filter(Boolean);
const returnArr = [];
let i = clsIdArr.length;
while (i--) {
returnArr.push(`|${attrType[clsIdArr[i][0]]}=${clsIdArr[i].substr(1)}`);
}
return tag + returnArr.join('') + end;
});
}
|
[
"function",
"handleClassesAndId",
"(",
"str",
")",
"{",
"return",
"str",
".",
"replace",
"(",
"/",
"(.*?)([\\.|#].[^|]*)(.*)",
"/",
",",
"function",
"(",
"fullStr",
",",
"tag",
",",
"classAndIds",
",",
"end",
")",
"{",
"if",
"(",
"classAndIds",
"[",
"0",
"]",
"===",
"'|'",
")",
"{",
"return",
"fullStr",
";",
"}",
"const",
"clsIdArr",
"=",
"classAndIds",
".",
"split",
"(",
"/",
"(\\..[^\\.|#]*)",
"/",
")",
".",
"filter",
"(",
"Boolean",
")",
";",
"const",
"returnArr",
"=",
"[",
"]",
";",
"let",
"i",
"=",
"clsIdArr",
".",
"length",
";",
"while",
"(",
"i",
"--",
")",
"{",
"returnArr",
".",
"push",
"(",
"`",
"${",
"attrType",
"[",
"clsIdArr",
"[",
"i",
"]",
"[",
"0",
"]",
"]",
"}",
"${",
"clsIdArr",
"[",
"i",
"]",
".",
"substr",
"(",
"1",
")",
"}",
"`",
")",
";",
"}",
"return",
"tag",
"+",
"returnArr",
".",
"join",
"(",
"''",
")",
"+",
"end",
";",
"}",
")",
";",
"}"
] |
Remove the css style classes and ids then replace them with tagbuildr attribute strings to use later on
@private
@param {string} str
@return {string} reformatted tagString
|
[
"Remove",
"the",
"css",
"style",
"classes",
"and",
"ids",
"then",
"replace",
"them",
"with",
"tagbuildr",
"attribute",
"strings",
"to",
"use",
"later",
"on"
] |
9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542
|
https://github.com/buzzin0609/tagbuildr/blob/9d6a52ad51c0fc3230de2da1e8e3f63f95a6e542/src/handleClassesAndId.js#L13-L27
|
52,586
|
mathieudutour/nplint
|
lib/config.js
|
readConfigFromFile
|
function readConfigFromFile(filePath) {
var config = {};
if (isFilePath(filePath)) {
try {
config = yaml.safeLoad(stripComments(fs.readFileSync(filePath, 'utf8'))) || {};
} catch (e) {
e.message = 'Cannot read config file: ' + filePath + '\nError: ' + e.message;
throw e;
}
if (path.basename(filePath) === PACKAGE_CONFIG_FILENAME) {
config = config[PACKAGE_CONFIG_FIELD_NAME] || {};
}
} else {
// it's a package
if (filePath.charAt(0) === '@') {
// it's a scoped package
// package name is 'nplint-config', or just a username
var scopedPackageShortcutRegex = /^(@[^\/]+)(?:\/(?:eslint-config)?)?$/;
if (scopedPackageShortcutRegex.test(filePath)) {
filePath = filePath.replace(scopedPackageShortcutRegex, '$1/nplint-config');
} else if (filePath.split('/')[1].indexOf('eslint-config-') !== 0) {
// for scoped packages, insert the eslint-config after the first /
filePath = filePath.replace(/^@([^\/]+)\/(.*)$/, '@$1/nplint-config-$2');
}
} else if (filePath.indexOf('nplint-config-') !== 0) {
filePath = 'nplint-config-' + filePath;
}
config = util.mergeConfigs(config, require(filePath));
}
return config;
}
|
javascript
|
function readConfigFromFile(filePath) {
var config = {};
if (isFilePath(filePath)) {
try {
config = yaml.safeLoad(stripComments(fs.readFileSync(filePath, 'utf8'))) || {};
} catch (e) {
e.message = 'Cannot read config file: ' + filePath + '\nError: ' + e.message;
throw e;
}
if (path.basename(filePath) === PACKAGE_CONFIG_FILENAME) {
config = config[PACKAGE_CONFIG_FIELD_NAME] || {};
}
} else {
// it's a package
if (filePath.charAt(0) === '@') {
// it's a scoped package
// package name is 'nplint-config', or just a username
var scopedPackageShortcutRegex = /^(@[^\/]+)(?:\/(?:eslint-config)?)?$/;
if (scopedPackageShortcutRegex.test(filePath)) {
filePath = filePath.replace(scopedPackageShortcutRegex, '$1/nplint-config');
} else if (filePath.split('/')[1].indexOf('eslint-config-') !== 0) {
// for scoped packages, insert the eslint-config after the first /
filePath = filePath.replace(/^@([^\/]+)\/(.*)$/, '@$1/nplint-config-$2');
}
} else if (filePath.indexOf('nplint-config-') !== 0) {
filePath = 'nplint-config-' + filePath;
}
config = util.mergeConfigs(config, require(filePath));
}
return config;
}
|
[
"function",
"readConfigFromFile",
"(",
"filePath",
")",
"{",
"var",
"config",
"=",
"{",
"}",
";",
"if",
"(",
"isFilePath",
"(",
"filePath",
")",
")",
"{",
"try",
"{",
"config",
"=",
"yaml",
".",
"safeLoad",
"(",
"stripComments",
"(",
"fs",
".",
"readFileSync",
"(",
"filePath",
",",
"'utf8'",
")",
")",
")",
"||",
"{",
"}",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"e",
".",
"message",
"=",
"'Cannot read config file: '",
"+",
"filePath",
"+",
"'\\nError: '",
"+",
"e",
".",
"message",
";",
"throw",
"e",
";",
"}",
"if",
"(",
"path",
".",
"basename",
"(",
"filePath",
")",
"===",
"PACKAGE_CONFIG_FILENAME",
")",
"{",
"config",
"=",
"config",
"[",
"PACKAGE_CONFIG_FIELD_NAME",
"]",
"||",
"{",
"}",
";",
"}",
"}",
"else",
"{",
"// it's a package",
"if",
"(",
"filePath",
".",
"charAt",
"(",
"0",
")",
"===",
"'@'",
")",
"{",
"// it's a scoped package",
"// package name is 'nplint-config', or just a username",
"var",
"scopedPackageShortcutRegex",
"=",
"/",
"^(@[^\\/]+)(?:\\/(?:eslint-config)?)?$",
"/",
";",
"if",
"(",
"scopedPackageShortcutRegex",
".",
"test",
"(",
"filePath",
")",
")",
"{",
"filePath",
"=",
"filePath",
".",
"replace",
"(",
"scopedPackageShortcutRegex",
",",
"'$1/nplint-config'",
")",
";",
"}",
"else",
"if",
"(",
"filePath",
".",
"split",
"(",
"'/'",
")",
"[",
"1",
"]",
".",
"indexOf",
"(",
"'eslint-config-'",
")",
"!==",
"0",
")",
"{",
"// for scoped packages, insert the eslint-config after the first /",
"filePath",
"=",
"filePath",
".",
"replace",
"(",
"/",
"^@([^\\/]+)\\/(.*)$",
"/",
",",
"'@$1/nplint-config-$2'",
")",
";",
"}",
"}",
"else",
"if",
"(",
"filePath",
".",
"indexOf",
"(",
"'nplint-config-'",
")",
"!==",
"0",
")",
"{",
"filePath",
"=",
"'nplint-config-'",
"+",
"filePath",
";",
"}",
"config",
"=",
"util",
".",
"mergeConfigs",
"(",
"config",
",",
"require",
"(",
"filePath",
")",
")",
";",
"}",
"return",
"config",
";",
"}"
] |
Read the config from the config JSON file
@param {string} filePath the path to the JSON config file
@returns {Object} config object
@private
|
[
"Read",
"the",
"config",
"from",
"the",
"config",
"JSON",
"file"
] |
ef444abcc6dd08fb61d5fc8ce618598d4455e08e
|
https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/config.js#L51-L88
|
52,587
|
mathieudutour/nplint
|
lib/config.js
|
loadConfig
|
function loadConfig(configToLoad) {
var config = {};
var filePath = '';
if (configToLoad) {
if (isObject(configToLoad)) {
config = configToLoad;
} else {
filePath = configToLoad;
config = readConfigFromFile(filePath);
}
if (!config.rules) {
config.rules = {};
}
config.rules = Object.keys(config.rules).reduce(function(obj, ruleId) {
if (!Array.isArray(config.rules[ruleId])) {
obj[ruleId] = [config.rules[ruleId]];
}
return obj;
}, {});
validator.validate(config, filePath);
// If an `extends` property is defined, it represents a configuration file to use as
// a 'parent'. Load the referenced file and merge the configuration recursively.
if (config.extends) {
var configExtends = config.extends;
if (!Array.isArray(config.extends)) {
configExtends = [config.extends];
}
// Make the last element in an array take the highest precedence
config = configExtends.reduceRight(function(previousValue, parentPath) {
if (parentPath === 'nplint:recommended') {
// Add an explicit substitution for eslint:recommended to conf/eslint.json
// this lets us use the eslint.json file as the recommended rules
parentPath = path.resolve(__dirname, '../conf/nplint.json');
} else if (isFilePath(parentPath)) {
// If the `extends` path is relative, use the directory of the current configuration
// file as the reference point. Otherwise, use as-is.
parentPath = (!isAbsolutePath(parentPath) ?
path.join(path.dirname(filePath), parentPath) :
parentPath
);
}
try {
return util.mergeConfigs(loadConfig(parentPath), previousValue);
} catch (e) {
// If the file referenced by `extends` failed to load, add the path to the
// configuration file that referenced it to the error message so the user is
// able to see where it was referenced from, then re-throw
e.message += '\nReferenced from: ' + filePath;
throw e;
}
}, config);
}
}
return config;
}
|
javascript
|
function loadConfig(configToLoad) {
var config = {};
var filePath = '';
if (configToLoad) {
if (isObject(configToLoad)) {
config = configToLoad;
} else {
filePath = configToLoad;
config = readConfigFromFile(filePath);
}
if (!config.rules) {
config.rules = {};
}
config.rules = Object.keys(config.rules).reduce(function(obj, ruleId) {
if (!Array.isArray(config.rules[ruleId])) {
obj[ruleId] = [config.rules[ruleId]];
}
return obj;
}, {});
validator.validate(config, filePath);
// If an `extends` property is defined, it represents a configuration file to use as
// a 'parent'. Load the referenced file and merge the configuration recursively.
if (config.extends) {
var configExtends = config.extends;
if (!Array.isArray(config.extends)) {
configExtends = [config.extends];
}
// Make the last element in an array take the highest precedence
config = configExtends.reduceRight(function(previousValue, parentPath) {
if (parentPath === 'nplint:recommended') {
// Add an explicit substitution for eslint:recommended to conf/eslint.json
// this lets us use the eslint.json file as the recommended rules
parentPath = path.resolve(__dirname, '../conf/nplint.json');
} else if (isFilePath(parentPath)) {
// If the `extends` path is relative, use the directory of the current configuration
// file as the reference point. Otherwise, use as-is.
parentPath = (!isAbsolutePath(parentPath) ?
path.join(path.dirname(filePath), parentPath) :
parentPath
);
}
try {
return util.mergeConfigs(loadConfig(parentPath), previousValue);
} catch (e) {
// If the file referenced by `extends` failed to load, add the path to the
// configuration file that referenced it to the error message so the user is
// able to see where it was referenced from, then re-throw
e.message += '\nReferenced from: ' + filePath;
throw e;
}
}, config);
}
}
return config;
}
|
[
"function",
"loadConfig",
"(",
"configToLoad",
")",
"{",
"var",
"config",
"=",
"{",
"}",
";",
"var",
"filePath",
"=",
"''",
";",
"if",
"(",
"configToLoad",
")",
"{",
"if",
"(",
"isObject",
"(",
"configToLoad",
")",
")",
"{",
"config",
"=",
"configToLoad",
";",
"}",
"else",
"{",
"filePath",
"=",
"configToLoad",
";",
"config",
"=",
"readConfigFromFile",
"(",
"filePath",
")",
";",
"}",
"if",
"(",
"!",
"config",
".",
"rules",
")",
"{",
"config",
".",
"rules",
"=",
"{",
"}",
";",
"}",
"config",
".",
"rules",
"=",
"Object",
".",
"keys",
"(",
"config",
".",
"rules",
")",
".",
"reduce",
"(",
"function",
"(",
"obj",
",",
"ruleId",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"config",
".",
"rules",
"[",
"ruleId",
"]",
")",
")",
"{",
"obj",
"[",
"ruleId",
"]",
"=",
"[",
"config",
".",
"rules",
"[",
"ruleId",
"]",
"]",
";",
"}",
"return",
"obj",
";",
"}",
",",
"{",
"}",
")",
";",
"validator",
".",
"validate",
"(",
"config",
",",
"filePath",
")",
";",
"// If an `extends` property is defined, it represents a configuration file to use as",
"// a 'parent'. Load the referenced file and merge the configuration recursively.",
"if",
"(",
"config",
".",
"extends",
")",
"{",
"var",
"configExtends",
"=",
"config",
".",
"extends",
";",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"config",
".",
"extends",
")",
")",
"{",
"configExtends",
"=",
"[",
"config",
".",
"extends",
"]",
";",
"}",
"// Make the last element in an array take the highest precedence",
"config",
"=",
"configExtends",
".",
"reduceRight",
"(",
"function",
"(",
"previousValue",
",",
"parentPath",
")",
"{",
"if",
"(",
"parentPath",
"===",
"'nplint:recommended'",
")",
"{",
"// Add an explicit substitution for eslint:recommended to conf/eslint.json",
"// this lets us use the eslint.json file as the recommended rules",
"parentPath",
"=",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"'../conf/nplint.json'",
")",
";",
"}",
"else",
"if",
"(",
"isFilePath",
"(",
"parentPath",
")",
")",
"{",
"// If the `extends` path is relative, use the directory of the current configuration",
"// file as the reference point. Otherwise, use as-is.",
"parentPath",
"=",
"(",
"!",
"isAbsolutePath",
"(",
"parentPath",
")",
"?",
"path",
".",
"join",
"(",
"path",
".",
"dirname",
"(",
"filePath",
")",
",",
"parentPath",
")",
":",
"parentPath",
")",
";",
"}",
"try",
"{",
"return",
"util",
".",
"mergeConfigs",
"(",
"loadConfig",
"(",
"parentPath",
")",
",",
"previousValue",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"// If the file referenced by `extends` failed to load, add the path to the",
"// configuration file that referenced it to the error message so the user is",
"// able to see where it was referenced from, then re-throw",
"e",
".",
"message",
"+=",
"'\\nReferenced from: '",
"+",
"filePath",
";",
"throw",
"e",
";",
"}",
"}",
",",
"config",
")",
";",
"}",
"}",
"return",
"config",
";",
"}"
] |
Load and parse a JSON config object from a file.
@param {string|Object} configToLoad the path to the JSON config file or the config object itself.
@returns {Object} the parsed config object (empty object if there was a parse error)
@private
|
[
"Load",
"and",
"parse",
"a",
"JSON",
"config",
"object",
"from",
"a",
"file",
"."
] |
ef444abcc6dd08fb61d5fc8ce618598d4455e08e
|
https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/config.js#L96-L163
|
52,588
|
mathieudutour/nplint
|
lib/config.js
|
getPluginsConfig
|
function getPluginsConfig(pluginNames) {
var pluginConfig = {};
pluginNames.forEach(function(pluginName) {
var pluginNamespace = util.getNamespace(pluginName),
pluginNameWithoutNamespace = util.removeNameSpace(pluginName),
pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace),
plugin = {},
rules = {};
if (!loadedPlugins[pluginNameWithoutPrefix]) {
try {
plugin = require(pluginNamespace + util.PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix);
loadedPlugins[pluginNameWithoutPrefix] = plugin;
} catch (err) {
plugin = { rulesConfig: {}};
}
} else {
plugin = loadedPlugins[pluginNameWithoutPrefix];
}
if (!plugin.rulesConfig) {
plugin.rulesConfig = {};
}
Object.keys(plugin.rulesConfig).forEach(function(item) {
rules[pluginNameWithoutPrefix + '/' + item] = plugin.rulesConfig[item];
});
pluginConfig = util.mergeConfigs(pluginConfig, rules);
});
return {rules: pluginConfig};
}
|
javascript
|
function getPluginsConfig(pluginNames) {
var pluginConfig = {};
pluginNames.forEach(function(pluginName) {
var pluginNamespace = util.getNamespace(pluginName),
pluginNameWithoutNamespace = util.removeNameSpace(pluginName),
pluginNameWithoutPrefix = util.removePluginPrefix(pluginNameWithoutNamespace),
plugin = {},
rules = {};
if (!loadedPlugins[pluginNameWithoutPrefix]) {
try {
plugin = require(pluginNamespace + util.PLUGIN_NAME_PREFIX + pluginNameWithoutPrefix);
loadedPlugins[pluginNameWithoutPrefix] = plugin;
} catch (err) {
plugin = { rulesConfig: {}};
}
} else {
plugin = loadedPlugins[pluginNameWithoutPrefix];
}
if (!plugin.rulesConfig) {
plugin.rulesConfig = {};
}
Object.keys(plugin.rulesConfig).forEach(function(item) {
rules[pluginNameWithoutPrefix + '/' + item] = plugin.rulesConfig[item];
});
pluginConfig = util.mergeConfigs(pluginConfig, rules);
});
return {rules: pluginConfig};
}
|
[
"function",
"getPluginsConfig",
"(",
"pluginNames",
")",
"{",
"var",
"pluginConfig",
"=",
"{",
"}",
";",
"pluginNames",
".",
"forEach",
"(",
"function",
"(",
"pluginName",
")",
"{",
"var",
"pluginNamespace",
"=",
"util",
".",
"getNamespace",
"(",
"pluginName",
")",
",",
"pluginNameWithoutNamespace",
"=",
"util",
".",
"removeNameSpace",
"(",
"pluginName",
")",
",",
"pluginNameWithoutPrefix",
"=",
"util",
".",
"removePluginPrefix",
"(",
"pluginNameWithoutNamespace",
")",
",",
"plugin",
"=",
"{",
"}",
",",
"rules",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"loadedPlugins",
"[",
"pluginNameWithoutPrefix",
"]",
")",
"{",
"try",
"{",
"plugin",
"=",
"require",
"(",
"pluginNamespace",
"+",
"util",
".",
"PLUGIN_NAME_PREFIX",
"+",
"pluginNameWithoutPrefix",
")",
";",
"loadedPlugins",
"[",
"pluginNameWithoutPrefix",
"]",
"=",
"plugin",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"plugin",
"=",
"{",
"rulesConfig",
":",
"{",
"}",
"}",
";",
"}",
"}",
"else",
"{",
"plugin",
"=",
"loadedPlugins",
"[",
"pluginNameWithoutPrefix",
"]",
";",
"}",
"if",
"(",
"!",
"plugin",
".",
"rulesConfig",
")",
"{",
"plugin",
".",
"rulesConfig",
"=",
"{",
"}",
";",
"}",
"Object",
".",
"keys",
"(",
"plugin",
".",
"rulesConfig",
")",
".",
"forEach",
"(",
"function",
"(",
"item",
")",
"{",
"rules",
"[",
"pluginNameWithoutPrefix",
"+",
"'/'",
"+",
"item",
"]",
"=",
"plugin",
".",
"rulesConfig",
"[",
"item",
"]",
";",
"}",
")",
";",
"pluginConfig",
"=",
"util",
".",
"mergeConfigs",
"(",
"pluginConfig",
",",
"rules",
")",
";",
"}",
")",
";",
"return",
"{",
"rules",
":",
"pluginConfig",
"}",
";",
"}"
] |
Load configuration for all plugins provided.
@param {string[]} pluginNames An array of plugin names which should be loaded.
@returns {Object} all plugin configurations merged together
|
[
"Load",
"configuration",
"for",
"all",
"plugins",
"provided",
"."
] |
ef444abcc6dd08fb61d5fc8ce618598d4455e08e
|
https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/config.js#L170-L203
|
52,589
|
mathieudutour/nplint
|
lib/config.js
|
getLocalConfig
|
function getLocalConfig(thisConfig, directory) {
var found,
i,
localConfig,
localConfigFile,
config = {},
localConfigFiles = thisConfig.findLocalConfigFiles(directory),
numFiles = localConfigFiles.length,
rootPath,
projectConfigPath = path.join(process.cwd(), LOCAL_CONFIG_FILENAME);
for (i = 0; i < numFiles; i++) {
localConfigFile = localConfigFiles[i];
// Don't consider the personal config file in the home directory,
// except if the home directory is the same as the current working directory
if (localConfigFile === PERSONAL_CONFIG_PATH && localConfigFile !== projectConfigPath) {
continue;
}
// If root flag is set, don't consider file if it is above root
if (rootPath && !pathIsInside(path.dirname(localConfigFile), rootPath)) {
continue;
}
localConfig = loadConfig(localConfigFile);
// Don't consider a local config file found if the config is empty.
if (!Object.keys(localConfig).length) {
continue;
}
// Check for root flag
if (localConfig.root === true) {
rootPath = path.dirname(localConfigFile);
}
found = true;
config = util.mergeConfigs(localConfig, config);
}
// Use the personal config file if there are no other local config files found.
return found ? config : util.mergeConfigs(config, getPersonalConfig());
}
|
javascript
|
function getLocalConfig(thisConfig, directory) {
var found,
i,
localConfig,
localConfigFile,
config = {},
localConfigFiles = thisConfig.findLocalConfigFiles(directory),
numFiles = localConfigFiles.length,
rootPath,
projectConfigPath = path.join(process.cwd(), LOCAL_CONFIG_FILENAME);
for (i = 0; i < numFiles; i++) {
localConfigFile = localConfigFiles[i];
// Don't consider the personal config file in the home directory,
// except if the home directory is the same as the current working directory
if (localConfigFile === PERSONAL_CONFIG_PATH && localConfigFile !== projectConfigPath) {
continue;
}
// If root flag is set, don't consider file if it is above root
if (rootPath && !pathIsInside(path.dirname(localConfigFile), rootPath)) {
continue;
}
localConfig = loadConfig(localConfigFile);
// Don't consider a local config file found if the config is empty.
if (!Object.keys(localConfig).length) {
continue;
}
// Check for root flag
if (localConfig.root === true) {
rootPath = path.dirname(localConfigFile);
}
found = true;
config = util.mergeConfigs(localConfig, config);
}
// Use the personal config file if there are no other local config files found.
return found ? config : util.mergeConfigs(config, getPersonalConfig());
}
|
[
"function",
"getLocalConfig",
"(",
"thisConfig",
",",
"directory",
")",
"{",
"var",
"found",
",",
"i",
",",
"localConfig",
",",
"localConfigFile",
",",
"config",
"=",
"{",
"}",
",",
"localConfigFiles",
"=",
"thisConfig",
".",
"findLocalConfigFiles",
"(",
"directory",
")",
",",
"numFiles",
"=",
"localConfigFiles",
".",
"length",
",",
"rootPath",
",",
"projectConfigPath",
"=",
"path",
".",
"join",
"(",
"process",
".",
"cwd",
"(",
")",
",",
"LOCAL_CONFIG_FILENAME",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"numFiles",
";",
"i",
"++",
")",
"{",
"localConfigFile",
"=",
"localConfigFiles",
"[",
"i",
"]",
";",
"// Don't consider the personal config file in the home directory,",
"// except if the home directory is the same as the current working directory",
"if",
"(",
"localConfigFile",
"===",
"PERSONAL_CONFIG_PATH",
"&&",
"localConfigFile",
"!==",
"projectConfigPath",
")",
"{",
"continue",
";",
"}",
"// If root flag is set, don't consider file if it is above root",
"if",
"(",
"rootPath",
"&&",
"!",
"pathIsInside",
"(",
"path",
".",
"dirname",
"(",
"localConfigFile",
")",
",",
"rootPath",
")",
")",
"{",
"continue",
";",
"}",
"localConfig",
"=",
"loadConfig",
"(",
"localConfigFile",
")",
";",
"// Don't consider a local config file found if the config is empty.",
"if",
"(",
"!",
"Object",
".",
"keys",
"(",
"localConfig",
")",
".",
"length",
")",
"{",
"continue",
";",
"}",
"// Check for root flag",
"if",
"(",
"localConfig",
".",
"root",
"===",
"true",
")",
"{",
"rootPath",
"=",
"path",
".",
"dirname",
"(",
"localConfigFile",
")",
";",
"}",
"found",
"=",
"true",
";",
"config",
"=",
"util",
".",
"mergeConfigs",
"(",
"localConfig",
",",
"config",
")",
";",
"}",
"// Use the personal config file if there are no other local config files found.",
"return",
"found",
"?",
"config",
":",
"util",
".",
"mergeConfigs",
"(",
"config",
",",
"getPersonalConfig",
"(",
")",
")",
";",
"}"
] |
Get a local config object.
@param {Object} thisConfig A Config object.
@param {string} directory The directory to start looking in for a local config file.
@returns {Object} The local config object, or an empty object if there is no local config.
|
[
"Get",
"a",
"local",
"config",
"object",
"."
] |
ef444abcc6dd08fb61d5fc8ce618598d4455e08e
|
https://github.com/mathieudutour/nplint/blob/ef444abcc6dd08fb61d5fc8ce618598d4455e08e/lib/config.js#L226-L270
|
52,590
|
vkiding/jud-vue-render
|
src/render/browser/extend/components/neighbor/index.js
|
SliderNeighbor
|
function SliderNeighbor (data) {
this.autoPlay = false // default value is false.
this.interval = DEFAULT_INTERVAL
this.direction = 'row' // 'column' is not temporarily supported.
this.slides = []
this.isPageShow = true
this.isDomRendering = true
this.currentIndex = 0
this.neighborSpace = DEFAULT_NEIGHBOR_SPACE
this.neighborAlpha = DEFAULT_NEIGHBOR_ALPHA
this.neighborScale = DEFAULT_NEIGHBOR_SCALE
// bind event 'pageshow', 'pagehide' and 'visibilitychange' on window.
idleWhenPageDisappear(this)
// bind event 'renderBegin' and 'renderEnd' on window.
idleWhenDomRendering(this)
Component.call(this, data)
}
|
javascript
|
function SliderNeighbor (data) {
this.autoPlay = false // default value is false.
this.interval = DEFAULT_INTERVAL
this.direction = 'row' // 'column' is not temporarily supported.
this.slides = []
this.isPageShow = true
this.isDomRendering = true
this.currentIndex = 0
this.neighborSpace = DEFAULT_NEIGHBOR_SPACE
this.neighborAlpha = DEFAULT_NEIGHBOR_ALPHA
this.neighborScale = DEFAULT_NEIGHBOR_SCALE
// bind event 'pageshow', 'pagehide' and 'visibilitychange' on window.
idleWhenPageDisappear(this)
// bind event 'renderBegin' and 'renderEnd' on window.
idleWhenDomRendering(this)
Component.call(this, data)
}
|
[
"function",
"SliderNeighbor",
"(",
"data",
")",
"{",
"this",
".",
"autoPlay",
"=",
"false",
"// default value is false.",
"this",
".",
"interval",
"=",
"DEFAULT_INTERVAL",
"this",
".",
"direction",
"=",
"'row'",
"// 'column' is not temporarily supported.",
"this",
".",
"slides",
"=",
"[",
"]",
"this",
".",
"isPageShow",
"=",
"true",
"this",
".",
"isDomRendering",
"=",
"true",
"this",
".",
"currentIndex",
"=",
"0",
"this",
".",
"neighborSpace",
"=",
"DEFAULT_NEIGHBOR_SPACE",
"this",
".",
"neighborAlpha",
"=",
"DEFAULT_NEIGHBOR_ALPHA",
"this",
".",
"neighborScale",
"=",
"DEFAULT_NEIGHBOR_SCALE",
"// bind event 'pageshow', 'pagehide' and 'visibilitychange' on window.",
"idleWhenPageDisappear",
"(",
"this",
")",
"// bind event 'renderBegin' and 'renderEnd' on window.",
"idleWhenDomRendering",
"(",
"this",
")",
"Component",
".",
"call",
"(",
"this",
",",
"data",
")",
"}"
] |
data.attr
support slider's attributes and three
@param {number} neighbor-space 0 - 375, the exposing width of slides on both other sides.
@param {number} neighbor-alpha 0 - 1, opacity of both other sides of slides, default is 0.6.
@param {number} neighbor-scale 0 - 1, the scale of both other sides of slides, default is 0.8.
|
[
"data",
".",
"attr",
"support",
"slider",
"s",
"attributes",
"and",
"three"
] |
07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47
|
https://github.com/vkiding/jud-vue-render/blob/07d8ab08d0ef86cf2819e5f2bf1f4b06381f4d47/src/render/browser/extend/components/neighbor/index.js#L610-L629
|
52,591
|
wenwuwu/array-es5
|
lib/arrays.js
|
function (key, array, index, fnEqual) {
var idx = Arrays.indexOf(key, array, index, fnEqual);
if (idx >= 0)
array.splice(idx, 1);
return idx;
}
|
javascript
|
function (key, array, index, fnEqual) {
var idx = Arrays.indexOf(key, array, index, fnEqual);
if (idx >= 0)
array.splice(idx, 1);
return idx;
}
|
[
"function",
"(",
"key",
",",
"array",
",",
"index",
",",
"fnEqual",
")",
"{",
"var",
"idx",
"=",
"Arrays",
".",
"indexOf",
"(",
"key",
",",
"array",
",",
"index",
",",
"fnEqual",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"array",
".",
"splice",
"(",
"idx",
",",
"1",
")",
";",
"return",
"idx",
";",
"}"
] |
Removes an item from an Array. The search for the item is
left-to-right. This method returns the index position at which
the item was found.
@param key {Object}
@param array {Array}
@param index {Number or String} Optional.
@param fnEqual {Function} Optional. The function to use to compare "key"
with each item within the list.
@returns {Number} Integer. The index position of the removed item,
or -1 if the array was not modified.
|
[
"Removes",
"an",
"item",
"from",
"an",
"Array",
".",
"The",
"search",
"for",
"the",
"item",
"is",
"left",
"-",
"to",
"-",
"right",
".",
"This",
"method",
"returns",
"the",
"index",
"position",
"at",
"which",
"the",
"item",
"was",
"found",
"."
] |
5331feed7e779534989f20919764a8224073ead2
|
https://github.com/wenwuwu/array-es5/blob/5331feed7e779534989f20919764a8224073ead2/lib/arrays.js#L636-L641
|
|
52,592
|
wenwuwu/array-es5
|
lib/arrays.js
|
function (key, array, index) {
var idx = Arrays.lastIndexOf(key, array, index);
if (idx >= 0)
array.splice(idx, 1);
return idx;
}
|
javascript
|
function (key, array, index) {
var idx = Arrays.lastIndexOf(key, array, index);
if (idx >= 0)
array.splice(idx, 1);
return idx;
}
|
[
"function",
"(",
"key",
",",
"array",
",",
"index",
")",
"{",
"var",
"idx",
"=",
"Arrays",
".",
"lastIndexOf",
"(",
"key",
",",
"array",
",",
"index",
")",
";",
"if",
"(",
"idx",
">=",
"0",
")",
"array",
".",
"splice",
"(",
"idx",
",",
"1",
")",
";",
"return",
"idx",
";",
"}"
] |
Removes an item from an Array. The search for the item is
right-to-left. This method returns the index position at which
the item was found.
@param key {Object}
@param array {Array}
@param index {Number or String} optional
@returns {Number} Integer. The index position of the removed item,
or -1 if the array was not modified.
|
[
"Removes",
"an",
"item",
"from",
"an",
"Array",
".",
"The",
"search",
"for",
"the",
"item",
"is",
"right",
"-",
"to",
"-",
"left",
".",
"This",
"method",
"returns",
"the",
"index",
"position",
"at",
"which",
"the",
"item",
"was",
"found",
"."
] |
5331feed7e779534989f20919764a8224073ead2
|
https://github.com/wenwuwu/array-es5/blob/5331feed7e779534989f20919764a8224073ead2/lib/arrays.js#L653-L658
|
|
52,593
|
wenwuwu/array-es5
|
lib/arrays.js
|
function (items, array, index) {
// There might be some optimization to be made here.
// Right now, I'm just going for a simple solution.
if ( !(items instanceof Array)
|| !(array instanceof Array) )
throw "IllegalArgumentException: items and array must both be Array objects.";
var numRemoved = 0;
for (var i = 0, len = items.length; i < len; i++) {
if (Arrays.remove(items[i], array, index) >= 0)
numRemoved++;
}
return numRemoved;
}
|
javascript
|
function (items, array, index) {
// There might be some optimization to be made here.
// Right now, I'm just going for a simple solution.
if ( !(items instanceof Array)
|| !(array instanceof Array) )
throw "IllegalArgumentException: items and array must both be Array objects.";
var numRemoved = 0;
for (var i = 0, len = items.length; i < len; i++) {
if (Arrays.remove(items[i], array, index) >= 0)
numRemoved++;
}
return numRemoved;
}
|
[
"function",
"(",
"items",
",",
"array",
",",
"index",
")",
"{",
"// There might be some optimization to be made here.\r",
"// Right now, I'm just going for a simple solution.\r",
"if",
"(",
"!",
"(",
"items",
"instanceof",
"Array",
")",
"||",
"!",
"(",
"array",
"instanceof",
"Array",
")",
")",
"throw",
"\"IllegalArgumentException: items and array must both be Array objects.\"",
";",
"var",
"numRemoved",
"=",
"0",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"items",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"Arrays",
".",
"remove",
"(",
"items",
"[",
"i",
"]",
",",
"array",
",",
"index",
")",
">=",
"0",
")",
"numRemoved",
"++",
";",
"}",
"return",
"numRemoved",
";",
"}"
] |
Removes a list of items from an Array.
@param items {Array} Items to be removed
@param array {Array} Array from which to remove the items.
@param index {Number or String} optional
@returns {Number} The number of successfully removed items.
|
[
"Removes",
"a",
"list",
"of",
"items",
"from",
"an",
"Array",
"."
] |
5331feed7e779534989f20919764a8224073ead2
|
https://github.com/wenwuwu/array-es5/blob/5331feed7e779534989f20919764a8224073ead2/lib/arrays.js#L667-L683
|
|
52,594
|
redisjs/jsr-resp
|
lib/interpreter.js
|
Interpreter
|
function Interpreter(options) {
options = options || {};
this.quote = typeof options.quote === 'boolean' ? options.quote : true;
}
|
javascript
|
function Interpreter(options) {
options = options || {};
this.quote = typeof options.quote === 'boolean' ? options.quote : true;
}
|
[
"function",
"Interpreter",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"quote",
"=",
"typeof",
"options",
".",
"quote",
"===",
"'boolean'",
"?",
"options",
".",
"quote",
":",
"true",
";",
"}"
] |
Interprets a single string value into a command string
and corresponding arguments.
Typically used to recieve input from stdin and create a command
that may be sent to a server.
Arguments are coerced to strings or integers.
The values `null`, `true` and `false` are interpreted as strings.
Quotes (single or double) may be used to include whitespace in a string.
Expanded quoted strings are joined on a single space character so tabs
or newlines will be lost.
Quote expansion can be disabled by setting the `quote` option to `false`.
|
[
"Interprets",
"a",
"single",
"string",
"value",
"into",
"a",
"command",
"string",
"and",
"corresponding",
"arguments",
"."
] |
9f998fc65a4494a358fca296adfe37fc5fb3f03c
|
https://github.com/redisjs/jsr-resp/blob/9f998fc65a4494a358fca296adfe37fc5fb3f03c/lib/interpreter.js#L20-L23
|
52,595
|
redisjs/jsr-resp
|
lib/interpreter.js
|
interpret
|
function interpret(input) {
var cli = []
, exp = null
, i
, s
, q
, e
, sre = /^("|').*/
, ere = /.*("|')$/;
assert(
typeof input === 'string' || input instanceof String,
'interpret invalid input: must be a string');
input = '' + input;
assert(
input && !/^\s+$/.test(input),
'interpret invalid input: empty string');
input = input.replace(/^\s+/, '').replace(/\s+$/, '');
cli = input.split(/\s+/);
cli = cli.map(function(str) {
var num = parseInt(str);
if(!isNaN(num)) {
return num;
}
return str;
})
// expand quoted values
if(this.quote) {
exp = [];
for(i = 0;i < cli.length;i++) {
s = cli[i];
if(sre.test(s)) {
// string is self-closed no whitespace: ie: "dbsize" || 'dbsize'
if(ere.test(s)) {
s = s.substr(1, s.length - 2);
exp.push(s);
// find terminating string
}else{
assert(i < cli.length -1, 'invalid argument(s)');
e = s.replace(sre, "$1");
q = s;
while(++i < cli.length) {
s = cli[i];
q += ' ' + s;
if(s.substr(-1) === e) {
exp.push(q.substr(1, q.length - 2));
break;
}
// no terminating match found
assert(false, 'invalid argument(s)');
}
}
}else{
exp.push(s);
}
}
cli = exp;
}
//console.error('interpret got input %s', input);
//console.error('interpret returning %j', cli);
return cli;
}
|
javascript
|
function interpret(input) {
var cli = []
, exp = null
, i
, s
, q
, e
, sre = /^("|').*/
, ere = /.*("|')$/;
assert(
typeof input === 'string' || input instanceof String,
'interpret invalid input: must be a string');
input = '' + input;
assert(
input && !/^\s+$/.test(input),
'interpret invalid input: empty string');
input = input.replace(/^\s+/, '').replace(/\s+$/, '');
cli = input.split(/\s+/);
cli = cli.map(function(str) {
var num = parseInt(str);
if(!isNaN(num)) {
return num;
}
return str;
})
// expand quoted values
if(this.quote) {
exp = [];
for(i = 0;i < cli.length;i++) {
s = cli[i];
if(sre.test(s)) {
// string is self-closed no whitespace: ie: "dbsize" || 'dbsize'
if(ere.test(s)) {
s = s.substr(1, s.length - 2);
exp.push(s);
// find terminating string
}else{
assert(i < cli.length -1, 'invalid argument(s)');
e = s.replace(sre, "$1");
q = s;
while(++i < cli.length) {
s = cli[i];
q += ' ' + s;
if(s.substr(-1) === e) {
exp.push(q.substr(1, q.length - 2));
break;
}
// no terminating match found
assert(false, 'invalid argument(s)');
}
}
}else{
exp.push(s);
}
}
cli = exp;
}
//console.error('interpret got input %s', input);
//console.error('interpret returning %j', cli);
return cli;
}
|
[
"function",
"interpret",
"(",
"input",
")",
"{",
"var",
"cli",
"=",
"[",
"]",
",",
"exp",
"=",
"null",
",",
"i",
",",
"s",
",",
"q",
",",
"e",
",",
"sre",
"=",
"/",
"^(\"|').*",
"/",
",",
"ere",
"=",
"/",
".*(\"|')$",
"/",
";",
"assert",
"(",
"typeof",
"input",
"===",
"'string'",
"||",
"input",
"instanceof",
"String",
",",
"'interpret invalid input: must be a string'",
")",
";",
"input",
"=",
"''",
"+",
"input",
";",
"assert",
"(",
"input",
"&&",
"!",
"/",
"^\\s+$",
"/",
".",
"test",
"(",
"input",
")",
",",
"'interpret invalid input: empty string'",
")",
";",
"input",
"=",
"input",
".",
"replace",
"(",
"/",
"^\\s+",
"/",
",",
"''",
")",
".",
"replace",
"(",
"/",
"\\s+$",
"/",
",",
"''",
")",
";",
"cli",
"=",
"input",
".",
"split",
"(",
"/",
"\\s+",
"/",
")",
";",
"cli",
"=",
"cli",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"var",
"num",
"=",
"parseInt",
"(",
"str",
")",
";",
"if",
"(",
"!",
"isNaN",
"(",
"num",
")",
")",
"{",
"return",
"num",
";",
"}",
"return",
"str",
";",
"}",
")",
"// expand quoted values",
"if",
"(",
"this",
".",
"quote",
")",
"{",
"exp",
"=",
"[",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"cli",
".",
"length",
";",
"i",
"++",
")",
"{",
"s",
"=",
"cli",
"[",
"i",
"]",
";",
"if",
"(",
"sre",
".",
"test",
"(",
"s",
")",
")",
"{",
"// string is self-closed no whitespace: ie: \"dbsize\" || 'dbsize'",
"if",
"(",
"ere",
".",
"test",
"(",
"s",
")",
")",
"{",
"s",
"=",
"s",
".",
"substr",
"(",
"1",
",",
"s",
".",
"length",
"-",
"2",
")",
";",
"exp",
".",
"push",
"(",
"s",
")",
";",
"// find terminating string",
"}",
"else",
"{",
"assert",
"(",
"i",
"<",
"cli",
".",
"length",
"-",
"1",
",",
"'invalid argument(s)'",
")",
";",
"e",
"=",
"s",
".",
"replace",
"(",
"sre",
",",
"\"$1\"",
")",
";",
"q",
"=",
"s",
";",
"while",
"(",
"++",
"i",
"<",
"cli",
".",
"length",
")",
"{",
"s",
"=",
"cli",
"[",
"i",
"]",
";",
"q",
"+=",
"' '",
"+",
"s",
";",
"if",
"(",
"s",
".",
"substr",
"(",
"-",
"1",
")",
"===",
"e",
")",
"{",
"exp",
".",
"push",
"(",
"q",
".",
"substr",
"(",
"1",
",",
"q",
".",
"length",
"-",
"2",
")",
")",
";",
"break",
";",
"}",
"// no terminating match found",
"assert",
"(",
"false",
",",
"'invalid argument(s)'",
")",
";",
"}",
"}",
"}",
"else",
"{",
"exp",
".",
"push",
"(",
"s",
")",
";",
"}",
"}",
"cli",
"=",
"exp",
";",
"}",
"//console.error('interpret got input %s', input);",
"//console.error('interpret returning %j', cli);",
"return",
"cli",
";",
"}"
] |
Interpret a string value into a command
and arguments.
@param input The input string.
@return An array containing a command and arguments.
|
[
"Interpret",
"a",
"string",
"value",
"into",
"a",
"command",
"and",
"arguments",
"."
] |
9f998fc65a4494a358fca296adfe37fc5fb3f03c
|
https://github.com/redisjs/jsr-resp/blob/9f998fc65a4494a358fca296adfe37fc5fb3f03c/lib/interpreter.js#L33-L102
|
52,596
|
nbrownus/ppunit
|
lib/writers/FileWriter.js
|
function (options) {
if (!options.path) {
throw new Error('A path must be supplied to write to')
}
this.path = options.path
this.useColors = options.useColors || false
mkdirp.sync(path.dirname(this.path))
this.fd = fs.openSync(this.path, 'w', options.mode || 0644)
}
|
javascript
|
function (options) {
if (!options.path) {
throw new Error('A path must be supplied to write to')
}
this.path = options.path
this.useColors = options.useColors || false
mkdirp.sync(path.dirname(this.path))
this.fd = fs.openSync(this.path, 'w', options.mode || 0644)
}
|
[
"function",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"options",
".",
"path",
")",
"{",
"throw",
"new",
"Error",
"(",
"'A path must be supplied to write to'",
")",
"}",
"this",
".",
"path",
"=",
"options",
".",
"path",
"this",
".",
"useColors",
"=",
"options",
".",
"useColors",
"||",
"false",
"mkdirp",
".",
"sync",
"(",
"path",
".",
"dirname",
"(",
"this",
".",
"path",
")",
")",
"this",
".",
"fd",
"=",
"fs",
".",
"openSync",
"(",
"this",
".",
"path",
",",
"'w'",
",",
"options",
".",
"mode",
"||",
"0644",
")",
"}"
] |
Handles writing output to a file
@param {Object} options An object containing options pertaining to this writer
@param {String} options.path An absolute or relative path to write output to
@param {String} [options.useColors=false] Whether or not to use colors
@param {String} [options.mode=0644] A file mode to create the file with
@constructor
|
[
"Handles",
"writing",
"output",
"to",
"a",
"file"
] |
dcce602497d9548ce9085a8db115e65561dcc3de
|
https://github.com/nbrownus/ppunit/blob/dcce602497d9548ce9085a8db115e65561dcc3de/lib/writers/FileWriter.js#L17-L28
|
|
52,597
|
interlockjs/plugins
|
packages/css/src/gen-css-bundles.js
|
replaceCssModules
|
function replaceCssModules (bundles, cssBundles, originBundleCssBundleMap, moduleClassnameMaps) {
const cssBundlesStats = moduleClassnameMaps && cssBundles.map(bundle => {
const moduleClassnames = bundle.modules.map(module => moduleClassnameMaps[module.path]);
const combinedJson = assign(...[{}].concat(moduleClassnames));
return {
type: "css-stats",
dest: `${bundle.dest}.json`,
moduleHashes: [],
raw: JSON.stringify(combinedJson)
};
}) || [];
return bundles.map((bundle, bIdx) => {
if (!(bIdx in originBundleCssBundleMap)) { return bundle; }
const cssBundle = cssBundles[originBundleCssBundleMap[bIdx]];
return assign({}, bundle, { modules: bundle.modules.map(module => {
if (module.type !== "css") { return module; }
const exportValue = moduleClassnameMaps && moduleClassnameMaps[module.path] ?
fromObject(assign(
{},
moduleClassnameMaps[module.path],
{ _path: cssBundle.dest }
)) :
t.stringLiteral(cssBundle.dest);
return assign({}, module, {
type: "javascript",
ast: exportObjTmpl({ EXPORT_VALUE: exportValue })
});
})});
}).concat(cssBundles, cssBundlesStats);
}
|
javascript
|
function replaceCssModules (bundles, cssBundles, originBundleCssBundleMap, moduleClassnameMaps) {
const cssBundlesStats = moduleClassnameMaps && cssBundles.map(bundle => {
const moduleClassnames = bundle.modules.map(module => moduleClassnameMaps[module.path]);
const combinedJson = assign(...[{}].concat(moduleClassnames));
return {
type: "css-stats",
dest: `${bundle.dest}.json`,
moduleHashes: [],
raw: JSON.stringify(combinedJson)
};
}) || [];
return bundles.map((bundle, bIdx) => {
if (!(bIdx in originBundleCssBundleMap)) { return bundle; }
const cssBundle = cssBundles[originBundleCssBundleMap[bIdx]];
return assign({}, bundle, { modules: bundle.modules.map(module => {
if (module.type !== "css") { return module; }
const exportValue = moduleClassnameMaps && moduleClassnameMaps[module.path] ?
fromObject(assign(
{},
moduleClassnameMaps[module.path],
{ _path: cssBundle.dest }
)) :
t.stringLiteral(cssBundle.dest);
return assign({}, module, {
type: "javascript",
ast: exportObjTmpl({ EXPORT_VALUE: exportValue })
});
})});
}).concat(cssBundles, cssBundlesStats);
}
|
[
"function",
"replaceCssModules",
"(",
"bundles",
",",
"cssBundles",
",",
"originBundleCssBundleMap",
",",
"moduleClassnameMaps",
")",
"{",
"const",
"cssBundlesStats",
"=",
"moduleClassnameMaps",
"&&",
"cssBundles",
".",
"map",
"(",
"bundle",
"=>",
"{",
"const",
"moduleClassnames",
"=",
"bundle",
".",
"modules",
".",
"map",
"(",
"module",
"=>",
"moduleClassnameMaps",
"[",
"module",
".",
"path",
"]",
")",
";",
"const",
"combinedJson",
"=",
"assign",
"(",
"...",
"[",
"{",
"}",
"]",
".",
"concat",
"(",
"moduleClassnames",
")",
")",
";",
"return",
"{",
"type",
":",
"\"css-stats\"",
",",
"dest",
":",
"`",
"${",
"bundle",
".",
"dest",
"}",
"`",
",",
"moduleHashes",
":",
"[",
"]",
",",
"raw",
":",
"JSON",
".",
"stringify",
"(",
"combinedJson",
")",
"}",
";",
"}",
")",
"||",
"[",
"]",
";",
"return",
"bundles",
".",
"map",
"(",
"(",
"bundle",
",",
"bIdx",
")",
"=>",
"{",
"if",
"(",
"!",
"(",
"bIdx",
"in",
"originBundleCssBundleMap",
")",
")",
"{",
"return",
"bundle",
";",
"}",
"const",
"cssBundle",
"=",
"cssBundles",
"[",
"originBundleCssBundleMap",
"[",
"bIdx",
"]",
"]",
";",
"return",
"assign",
"(",
"{",
"}",
",",
"bundle",
",",
"{",
"modules",
":",
"bundle",
".",
"modules",
".",
"map",
"(",
"module",
"=>",
"{",
"if",
"(",
"module",
".",
"type",
"!==",
"\"css\"",
")",
"{",
"return",
"module",
";",
"}",
"const",
"exportValue",
"=",
"moduleClassnameMaps",
"&&",
"moduleClassnameMaps",
"[",
"module",
".",
"path",
"]",
"?",
"fromObject",
"(",
"assign",
"(",
"{",
"}",
",",
"moduleClassnameMaps",
"[",
"module",
".",
"path",
"]",
",",
"{",
"_path",
":",
"cssBundle",
".",
"dest",
"}",
")",
")",
":",
"t",
".",
"stringLiteral",
"(",
"cssBundle",
".",
"dest",
")",
";",
"return",
"assign",
"(",
"{",
"}",
",",
"module",
",",
"{",
"type",
":",
"\"javascript\"",
",",
"ast",
":",
"exportObjTmpl",
"(",
"{",
"EXPORT_VALUE",
":",
"exportValue",
"}",
")",
"}",
")",
";",
"}",
")",
"}",
")",
";",
"}",
")",
".",
"concat",
"(",
"cssBundles",
",",
"cssBundlesStats",
")",
";",
"}"
] |
Replace CSS modules with JavaScript modules which reference the CSS
output bundle destination.
@param {Array} bundles Original bundles array.
@param {Array} cssBundles New CSS bundles.
@param {Object} originBundleCssBundleMap Mapping of origin bundle to sibling
CSS bundle.
@param {Object} moduleClassnameMaps Mapping of filename to friendly/module
classname maps.
@return {Array} Original bundles plus CSS bundles.
|
[
"Replace",
"CSS",
"modules",
"with",
"JavaScript",
"modules",
"which",
"reference",
"the",
"CSS",
"output",
"bundle",
"destination",
"."
] |
05197e4511b64d269260fe3c701ceff864897ab3
|
https://github.com/interlockjs/plugins/blob/05197e4511b64d269260fe3c701ceff864897ab3/packages/css/src/gen-css-bundles.js#L25-L60
|
52,598
|
mountain/miniweb
|
miniweb/environment.js
|
visitEntry
|
function visitEntry (pkey, context, callback) {
_(context).chain().keys().each(function (key) {
var entry = context[key], curkey = pkey?(pkey + '.' + key):key;
if(_.isFunction(entry) || _.isString(entry) || _.isBoolean(entry) ||
_.isArray(entry) || _.isNumber(entry) || _.isRegExp(entry)) {//entry is a leaf node
callback(curkey, entry);
} else {//entry is not a leaf node
visitEntry (curkey, entry, callback)
}
});
}
|
javascript
|
function visitEntry (pkey, context, callback) {
_(context).chain().keys().each(function (key) {
var entry = context[key], curkey = pkey?(pkey + '.' + key):key;
if(_.isFunction(entry) || _.isString(entry) || _.isBoolean(entry) ||
_.isArray(entry) || _.isNumber(entry) || _.isRegExp(entry)) {//entry is a leaf node
callback(curkey, entry);
} else {//entry is not a leaf node
visitEntry (curkey, entry, callback)
}
});
}
|
[
"function",
"visitEntry",
"(",
"pkey",
",",
"context",
",",
"callback",
")",
"{",
"_",
"(",
"context",
")",
".",
"chain",
"(",
")",
".",
"keys",
"(",
")",
".",
"each",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"entry",
"=",
"context",
"[",
"key",
"]",
",",
"curkey",
"=",
"pkey",
"?",
"(",
"pkey",
"+",
"'.'",
"+",
"key",
")",
":",
"key",
";",
"if",
"(",
"_",
".",
"isFunction",
"(",
"entry",
")",
"||",
"_",
".",
"isString",
"(",
"entry",
")",
"||",
"_",
".",
"isBoolean",
"(",
"entry",
")",
"||",
"_",
".",
"isArray",
"(",
"entry",
")",
"||",
"_",
".",
"isNumber",
"(",
"entry",
")",
"||",
"_",
".",
"isRegExp",
"(",
"entry",
")",
")",
"{",
"//entry is a leaf node",
"callback",
"(",
"curkey",
",",
"entry",
")",
";",
"}",
"else",
"{",
"//entry is not a leaf node",
"visitEntry",
"(",
"curkey",
",",
"entry",
",",
"callback",
")",
"}",
"}",
")",
";",
"}"
] |
Visit object hierachy structure
|
[
"Visit",
"object",
"hierachy",
"structure"
] |
8d06fd298cb2236a99d8a71b4b2486d27e607f04
|
https://github.com/mountain/miniweb/blob/8d06fd298cb2236a99d8a71b4b2486d27e607f04/miniweb/environment.js#L53-L63
|
52,599
|
mountain/miniweb
|
miniweb/environment.js
|
accessEntry
|
function accessEntry (context, keys) {
_.each(keys, function (key) {
if (context) {
context = context[key];
}
});
return context;
}
|
javascript
|
function accessEntry (context, keys) {
_.each(keys, function (key) {
if (context) {
context = context[key];
}
});
return context;
}
|
[
"function",
"accessEntry",
"(",
"context",
",",
"keys",
")",
"{",
"_",
".",
"each",
"(",
"keys",
",",
"function",
"(",
"key",
")",
"{",
"if",
"(",
"context",
")",
"{",
"context",
"=",
"context",
"[",
"key",
"]",
";",
"}",
"}",
")",
";",
"return",
"context",
";",
"}"
] |
Access object hierachy structure
|
[
"Access",
"object",
"hierachy",
"structure"
] |
8d06fd298cb2236a99d8a71b4b2486d27e607f04
|
https://github.com/mountain/miniweb/blob/8d06fd298cb2236a99d8a71b4b2486d27e607f04/miniweb/environment.js#L74-L81
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.