_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q40100 | reduceBundles | train | function reduceBundles(bundles, dependencies, maxBundles) {
while (anyMainExceedsMaxBundles(bundles, maxBundles)) {
var merge = findLeastCostMerge(bundles, dependencies, maxBundles);
mergeBundles(merge.bundle1Name, merge.bundle2Name, bundles);
}
return bundles;
} | javascript | {
"resource": ""
} |
q40101 | resolve | train | function resolve(files, opts) {
var fn = opts.filter || function(fp) {
return true;
};
if (opts.realpath === true) {
return files.filter(fn);
}
var len = files.length;
var idx = -1;
var res = [];
while (++idx < len) {
var fp = path.resolve(opts.cwd, files[idx]);
if (!fn(fp) || ~res.in... | javascript | {
"resource": ""
} |
q40102 | getPsInfo | train | function getPsInfo(param, callback) {
if (process.platform === 'windows') return;
var pid = param.pid;
var cmd = "ps auxw | grep " + pid + " | grep -v 'grep'";
//var cmd = "ps auxw | grep -E '.+?\\s+" + pid + "\\s+'" ;
exec(cmd, function(err, output) {
if (!!err) {
if (err.code === 1) {
console.... | javascript | {
"resource": ""
} |
q40103 | browserifyTransform | train | function browserifyTransform(file) {
var chunks = [];
var write = function(buffer) {
chunks.push(buffer);
};
var end = function() {
var content = Buffer.concat(chunks).toString('utf8');
// convention fileName == key for shim options
var fileName = file.match(/([^\/]+)(?=\.\w+$)... | javascript | {
"resource": ""
} |
q40104 | train | function (cwd, filename, options, customizeEngine) {
var helpers = customizeEngine.engine.helpers
var code = helpers.example(path.join(cwd, filename), {
hash: {
snippet: true
}
})
var result = helpers.exec(`node ${filename}`, {
hash: {
cwd: cwd,
lang: 'raw'
... | javascript | {
"resource": ""
} | |
q40105 | NetworkServer | train | function NetworkServer(server) {
this.server = server;
function connection(socket) {
server.connection(socket, this);
}
this.on('connection', connection);
} | javascript | {
"resource": ""
} |
q40106 | listen | train | function listen(file, perm) {
var args = [file]
, perm = perm || 0700
, server = this;
this.file = file;
this.name = path.basename(file);
if(this.name === file) {
file = path.join(process.cwd(), file);
}
function onListen() {
try {
fs.chmodSync(file, perm);
}catch(e){}
log.n... | javascript | {
"resource": ""
} |
q40107 | close | train | function close() {
log.notice('removing the unix socket file')
try {
fs.unlinkSync(file);
}catch(e){} // nothing to do at this point
Server.prototype.close.call(this);
} | javascript | {
"resource": ""
} |
q40108 | train | function (next) {
request(url, function (err, res, body) {
if (err) {
return next(err);
}
next(null, body);
});
} | javascript | {
"resource": ""
} | |
q40109 | train | function (body, next) {
fs.writeFile(out + "/" + path.basename(url), body, function (err) {
if (err) {
return next(err);
}
next(null, body);
});
} | javascript | {
"resource": ""
} | |
q40110 | train | function (body, next) {
parseString(body, function (err, json) {
if (err) {
return next(err);
}
next(null, json);
});
} | javascript | {
"resource": ""
} | |
q40111 | train | function(json, next) {
fs.writeFile(out + "/" + path.basename(url).replace('.xml', '.json'), JSON.stringify(json), function (err) {
if (err) {
return next(err);
}
next(null, json);
});
} | javascript | {
"resource": ""
} | |
q40112 | Knack | train | function Knack({ concurrency = 5, interval = 500, onDone = () => {} }={}) {
const q = new Queue(concurrency, interval, onDone)
/**
* @func knack
* @template T
* @param {function(...args): Promise<T>} func
* @returns {function(...args): Promise<T>}
*/
const knack = function(func, {
priority = 50... | javascript | {
"resource": ""
} |
q40113 | train | function(file) {
var filePath = path.resolve(file);
if (filePath && fs.existsSync(filePath)) {
return filePath;
}
return false;
} | javascript | {
"resource": ""
} | |
q40114 | train | function(file) {
var filePath = path.resolve(file);
if (filePath) {
if (!fs.existsSync(filePath)) {
fse.ensureFileSync(filePath);
}
return filePath;
}
return false;
} | javascript | {
"resource": ""
} | |
q40115 | Quad | train | function Quad(gl)
{
/*
* the current WebGL drawing context
*
* @member {WebGLRenderingContext}
*/
this.gl = gl;
// this.textures = new TextureUvs();
/**
* An array of vertices
*
* @member {Float32Array}
*/
this.vertices = new Float32Array([
0,0,
... | javascript | {
"resource": ""
} |
q40116 | train | function(moduleRegex) {
var self = this;
moduleRegex = moduleRegex || /^(.+)\.js$/;
return function(req, res, next) {
var match = req.url.match(moduleRegex);
if(!match) return next();
var module= match[1];
self.bundle(module, function(err, src)... | javascript | {
"resource": ""
} | |
q40117 | _same_set | train | function _same_set(set1, set2){
var h1 = {};
var h2 = {};
for( var h1i = 0; h1i < set1.length; h1i++ ){ h1[set1[h1i]] = 1; }
for( var h2i = 0; h2i < set2.length; h2i++ ){ h2[set2[h2i]] = 1; }
return _same_hash(h1, h2);
} | javascript | {
"resource": ""
} |
q40118 | _is_same | train | function _is_same(a, b){
//bark('typeof(a, b): ' + typeof(a) + ',' + typeof(b));
var ret = false;
if( a == b ){ // atoms, incl. null and 'string'
//bark('true on equal atoms: ' + a + '<>' + b);
ret = true;
}else{ // is list or obj (ignore func)
if( typeof(a) === 'object' && typeof(b) === 'object' ){... | javascript | {
"resource": ""
} |
q40119 | _in_list | train | function _in_list(in_item, list, comparator){
var retval = false;
for(var li = 0; li < list.length; li++ ){
var list_item = list[li];
if( comparator ){
var comp_op = comparator(in_item, list_item);
if( comp_op && comp_op == true ){
retval = true;
}
}else{
if( in_item == list_item ){
... | javascript | {
"resource": ""
} |
q40120 | _is_string_embedded | train | function _is_string_embedded(target_str, base_str, add_str){
// Walk through all of ways of splitting base_str and add
// add_str in there to see if we get the target_str.
var retval = false;
for(var si = 0; si <= base_str.length; si++ ){
var car = base_str.substr(0, si);
var cdr = base_str.substr(... | javascript | {
"resource": ""
} |
q40121 | rec_up | train | function rec_up(nid){
//print('rec_up on: ' + nid);
var results = new Array();
var new_parent_edges = anchor.get_parent_edges(nid, pid);
// Capture edge list for later adding.
for( var e = 0; e < new_parent_edges.length; e++ ){
seen_edge_list.push(new_parent_edges[e]);
}
// Pull extant nodes fro... | javascript | {
"resource": ""
} |
q40122 | order_cohort | train | function order_cohort(in_brackets){
// Push into global cohort list list.
for( var i = 0; i < in_brackets.length; i++ ){
var bracket_item = in_brackets[i];
//
//_kvetch(' order_cohort: i: ' + i);
//_kvetch(' order_cohort: lvl: ' + bracket_item.level);
cohort_list[bracket_item.level - 1].push(br... | javascript | {
"resource": ""
} |
q40123 | _new_node_at | train | function _new_node_at(bnode, level){
ll("adding " + bnode.id() + " at level " + level + "!");
// Create new vertex and add to set.
var new_vertex = new bbop.layout.sugiyama.simple_vertex(bnode.id());
new_vertex.level = level;
vertex_set[ new_vertex.id() ] = new_vertex;
// Check the node in to the 'seen' refer... | javascript | {
"resource": ""
} |
q40124 | getSubjectBarycenter | train | function getSubjectBarycenter(subject){
var weighted_number_of_edges = 0;
var number_of_edges = 0;
for( var o = 1; o <= object_vector.length; o++ ){
if( relation_matrix[object_vector[o -1].id()] &&
relation_matrix[object_vector[o -1].id()][subject.id()]){
weighted_number_of_edges += o;
number_of_edges++;... | javascript | {
"resource": ""
} |
q40125 | on_error | train | function on_error(e) {
console.log('problem with request: ' + e.message);
var response = new anchor._response_handler(null);
response.okay(false);
response.message(e.message);
response.message_type('error');
anchor.apply_callbacks('error', [response, anchor]);
} | javascript | {
"resource": ""
} |
q40126 | on_error | train | function on_error(xhr, status, error) {
var response = new anchor._response_handler(null);
response.okay(false);
response.message(error);
response.message_type(status);
anchor.apply_callbacks('error', [response, anchor]);
} | javascript | {
"resource": ""
} |
q40127 | _full_delete | train | function _full_delete(hash, key1, key2){
if( key1 && key2 && hash &&
hash[key1] && hash[key1][key2] ){
delete hash[key1][key2];
}
if( bbop.core.is_empty(hash[key1]) ){
delete hash[key1];
}
} | javascript | {
"resource": ""
} |
q40128 | _lock_map | train | function _lock_map(field, id_list){
var fixed_list = [];
bbop.core.each(id_list,
function(item){
fixed_list.push(bbop.core.ensure(item, '"'));
});
var base_id_list = '(' + fixed_list.join(' OR ') + ')';
var ret_query = field + ':' + base_id_list;
return ret_query;
} | javascript | {
"resource": ""
} |
q40129 | _create_select_box | train | function _create_select_box(val, id, name){
if( ! is_defined(name) ){
name = select_item_name;
}
var input_attrs = {
'value': val,
'name': name,
'type': 'checkbox'
};
if( is_defined(id) ){
input_attrs['id'] = id;
}
var input = new bbop.html.input(input_attrs);
return input;
} | javascript | {
"resource": ""
} |
q40130 | _ignorable_event | train | function _ignorable_event(event){
var retval = false;
if( event ){
var kc = event.keyCode;
if( kc ){
if( kc == 39 || // right
kc == 37 || // left
kc == 32 || // space
kc == 20 || // ctl?
kc == 17 || // ctl?
... | javascript | {
"resource": ""
} |
q40131 | _nothing_to_see_here | train | function _nothing_to_see_here(in_field){
var section_id = filter_accordion_widget.get_section_id(in_field);
jQuery('#' + section_id).empty();
jQuery('#' + section_id).append('Nothing to filter.');
} | javascript | {
"resource": ""
} |
q40132 | draw_shield | train | function draw_shield(resp){
// ll("shield what: " + bbop.core.what_is(resp));
// ll("shield resp: " + bbop.core.dump(resp));
// First, extract the fields from the
// minimal response.
var fina = call_time_field_name;
var flist = resp.facet_field(call_time_field_name);
... | javascript | {
"resource": ""
} |
q40133 | train | function(layout_level){
loop(layout_level, // for every item at this level
function(level_item){
var nid = level_item[0];
var lbl = level_item[1];
var rel = level_item[2];
// For various sections, decide to run image
// (img) or text code depending on whether
// or n... | javascript | {
"resource": ""
} | |
q40134 | train | function(request_data, response_hook) {
anchor.jq_vars['success'] = function(json_data){
var retlist = [];
var resp = new bbop.golr.response(json_data);
// Reset the last return; remember: tri-state.
result_count = null;
return_count = null;
if( resp.success() ){
// Get best shot at document c... | javascript | {
"resource": ""
} | |
q40135 | train | function(event, ui){
// Prevent default selection input filling action (from
// jQuery UI) when non-default marked.
if( ! anchor._fill_p ){
event.preventDefault();
}
var doc_to_apply = null;
if( ui.item ){
doc_to_apply = ui.item.document;
}
// Only do the callback if it ... | javascript | {
"resource": ""
} | |
q40136 | _draw_local_doc | train | function _draw_local_doc(doc){
//ll(doc['id']);
var personality = anchor.get_personality();
var cclass = golr_conf_obj.get_class(personality);
var txt = 'Nothing here...';
if( doc && cclass ){
var tbl = new bbop.html.table();
var results_order = cclass.field_order_by_weight('result');
var each ... | javascript | {
"resource": ""
} |
q40137 | _get_selected | train | function _get_selected(){
var ret_list = [];
var selected_strings =
jQuery('#'+ sul_id).sortable('toArray', {'attribute': 'value'});
each(selected_strings,
function(in_thing){
if( in_thing && in_thing != '' ){
ret_list.push(in_thing);
}
});
return ret_list;
} | javascript | {
"resource": ""
} |
q40138 | _button_wrapper | train | function _button_wrapper(str, title){
var b = new bbop.widget.display.text_button_sim(str, title, '');
return b.to_string();
} | javascript | {
"resource": ""
} |
q40139 | _initial_runner | train | function _initial_runner(response, manager){
// I can't just remove the callback from the register
// after the first run because it would be reconstituted
// every time it was reset (established).
if( anchor.initial_reset_p ){
anchor.initial_reset_p = false;
anchor.initial_reset_callback(respon... | javascript | {
"resource": ""
} |
q40140 | _draw_table_or_something | train | 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>');
... | javascript | {
"resource": ""
} |
q40141 | read_cli | train | 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())... | javascript | {
"resource": ""
} |
q40142 | read_buffer | train | 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 | {
"resource": ""
} |
q40143 | gather_list_from_hash | train | 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 | {
"resource": ""
} |
q40144 | get_connections | train | 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... | javascript | {
"resource": ""
} |
q40145 | train | 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.... | javascript | {
"resource": ""
} | |
q40146 | dblclick_event_handler | train | 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 < subtre... | javascript | {
"resource": ""
} |
q40147 | _generate_element | train | 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(... | javascript | {
"resource": ""
} |
q40148 | train | 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.s... | javascript | {
"resource": ""
} | |
q40149 | make_query_maker | train | 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 {Stri... | javascript | {
"resource": ""
} |
q40150 | query_with | train | function query_with(client, cypher_query, parameters) {
parameters = parameters || {};
return make_promise(client.query.bind(client, cypher_query, parameters));
} | javascript | {
"resource": ""
} |
q40151 | get_client | train | 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 | {
"resource": ""
} |
q40152 | BlurYTintFilter | train | 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:... | javascript | {
"resource": ""
} |
q40153 | train | 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 | {
"resource": ""
} | |
q40154 | train | 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 | {
"resource": ""
} | |
q40155 | train | 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... | javascript | {
"resource": ""
} | |
q40156 | indento | train | function indento(input, width, char) {
char = typeof char !== "string" ? " " : char;
return String(input).replace(/^/gm, char.repeat(width));
} | javascript | {
"resource": ""
} |
q40157 | request | train | 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-Leng... | javascript | {
"resource": ""
} |
q40158 | GENERATE_CLASSES | train | 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)) ... | javascript | {
"resource": ""
} |
q40159 | GENERATE_METHOD | train | 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 | {
"resource": ""
} |
q40160 | GENERATE_PARAMS | train | function GENERATE_PARAMS(spec) {
return _.map(spec, function(paramSpec, paramName) {
return paramName + ': ' + paramSpec.type;
}).join(', ');
} | javascript | {
"resource": ""
} |
q40161 | extend_if_promise | train | 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 s... | javascript | {
"resource": ""
} |
q40162 | train | 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)... | javascript | {
"resource": ""
} | |
q40163 | splatND | train | 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.a... | javascript | {
"resource": ""
} |
q40164 | fireOnLoad | train | function fireOnLoad() {
var args = arguments, i;
for(i = 0, len = addOnLoadHandler.stack.length; i<len; i++) {
addOnLoadHandler.stack[i].apply(null, args);
}
} | javascript | {
"resource": ""
} |
q40165 | findHash | train | 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 | {
"resource": ""
} |
q40166 | scriptLoader | train | 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 == "... | javascript | {
"resource": ""
} |
q40167 | _getMongoDbName | train | 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... | javascript | {
"resource": ""
} |
q40168 | _getSafeFileName | train | 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(... | javascript | {
"resource": ""
} |
q40169 | _getOutputFileName | train | 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;
}
... | javascript | {
"resource": ""
} |
q40170 | _setTimeLimit | train | 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.ex... | javascript | {
"resource": ""
} |
q40171 | _stopTimer | train | function _stopTimer(timer, options) {
if (timer) {
options.timeLimit = _getTimeLeft(timer);
clearTimeout(timer);
}
} | javascript | {
"resource": ""
} |
q40172 | _echoPidToFile | train | function _echoPidToFile(options) {
var command = '';
if (options && options.pidFile) {
command = ' & echo $! > ' + options.pidFile;
}
return command;
} | javascript | {
"resource": ""
} |
q40173 | _getTimeLeft | train | function _getTimeLeft(timeout) {
return Math.ceil(timeout._idleStart + timeout._idleTimeout - Date.now());
} | javascript | {
"resource": ""
} |
q40174 | hide | train | function hide(element) {
if (!element || !element.style || typeof element.style.display !== 'string') {
return;
}
element.style.display = "";
} | javascript | {
"resource": ""
} |
q40175 | train | 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 | {
"resource": ""
} | |
q40176 | train | 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;
... | javascript | {
"resource": ""
} | |
q40177 | train | 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;
... | javascript | {
"resource": ""
} | |
q40178 | Preprocessor | train | 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 =... | javascript | {
"resource": ""
} |
q40179 | train | 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]);
}
/... | javascript | {
"resource": ""
} | |
q40180 | train | 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... | javascript | {
"resource": ""
} | |
q40181 | train | 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.extractValidat... | javascript | {
"resource": ""
} | |
q40182 | train | 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 con... | javascript | {
"resource": ""
} | |
q40183 | train | 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)... | javascript | {
"resource": ""
} | |
q40184 | train | function(value, options){
if(validate.isObject(options) && options.onlyCoercePrimitives && !validateParams.isPrimitive(value)){
return value;
}
if(validate.isEmpty(value)) return '';
return String(value);
} | javascript | {
"resource": ""
} | |
q40185 | train | 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' |... | javascript | {
"resource": ""
} | |
q40186 | min | train | 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 | {
"resource": ""
} |
q40187 | isBooleanBinaryExpression | train | function isBooleanBinaryExpression(node) {
return node.kind === ts.SyntaxKind.BinaryExpression && binaryBooleanExpressionKind(node) !== undefined;
} | javascript | {
"resource": ""
} |
q40188 | prop | train | function prop(v, w) { return {
value: v, writable: w, enumerable: true, configurable: false
}} | javascript | {
"resource": ""
} |
q40189 | execute | train | function execute(req, res) {
ScriptManager.eval(req, res, '' + req.args[0], req.args.slice(1));
} | javascript | {
"resource": ""
} |
q40190 | Parser | train | 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,
writabl... | javascript | {
"resource": ""
} |
q40191 | authenticate | train | 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));
... | javascript | {
"resource": ""
} |
q40192 | train | function( string ){
if( string[ string.length -1 ] !== $this.slash.get()) string = string + $this.slash.get();
return string;
} | javascript | {
"resource": ""
} | |
q40193 | train | 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 | {
"resource": ""
} | |
q40194 | to_map | train | 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 | {
"resource": ""
} |
q40195 | train | 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 | {
"resource": ""
} | |
q40196 | train | 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 | {
"resource": ""
} | |
q40197 | train | 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 | {
"resource": ""
} | |
q40198 | train | 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 | {
"resource": ""
} | |
q40199 | train | 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, attrib... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.