_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q37900 | clear | train | function clear(options, cb) {
if (typeof options === 'function') { cb = options; options = {}; }
debug('clear ' + key);
connect();
redis.del(key, cb);
} | javascript | {
"resource": ""
} |
q37901 | runHelp | train | function runHelp(){
var messageHelp = "Usage: titanium-jsduck [command] [parameters]\n\n";
messageHelp += "Commands:\n\tinstall \n\t\t- Installs JSDuck inside a Titanium Mobile Project.";
messageHelp += "\n\topen \n\t\t- Opens Documentation in Safari Browser";
messageHelp += "\n\topen firefox \n\t\t- Opens ... | javascript | {
"resource": ""
} |
q37902 | file | train | function file( path, content ) {
try {
if ( typeof content === 'undefined' ) {
if ( !FS.existsSync( path ) ) return null;
return FS.readFileSync( path );
}
const dir = Path.dirname( path );
mkdir( dir );
FS.writeFileSync( path, content );
retur... | javascript | {
"resource": ""
} |
q37903 | touch | train | function touch( path ) {
if ( FS.existsSync( path ) ) {
const content = FS.readFileSync( path );
FS.writeFileSync( path, content );
console.log( `File has been touched: ${path.yellow} (${(size(path) * BYTES_TO_KB).toFixed(1)} kb)` );
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q37904 | invokeArrayArg | train | function invokeArrayArg(arg, fn, context) {
if (Array.isArray(arg)) {
arg.forEach(context[fn], context);
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q37905 | prefixed | train | function prefixed(obj, property) {
var prefix;
var prop;
var camelProp = property[0].toUpperCase() + property.slice(1);
var i = 0;
while (i < VENDOR_PREFIXES.length) {
prefix = VENDOR_PREFIXES[i];
prop = (prefix) ? prefix + camelProp : property;
if (prop in obj) {
return prop;
}
i+... | javascript | {
"resource": ""
} |
q37906 | computeInputData | train | function computeInputData(manager, input) {
var session = manager.session;
var pointers = input.pointers;
var pointersLength = pointers.length;
// store the first input to calculate the distance and direction
if (!session.firstInput) {
session.firstInput = simpleCloneInputData(input);
}
// to comput... | javascript | {
"resource": ""
} |
q37907 | getDirection | train | function getDirection(x, y) {
if (x === y) {
return DIRECTION_NONE;
}
if (abs(x) >= abs(y)) {
return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
}
return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
} | javascript | {
"resource": ""
} |
q37908 | getDistance | train | function getDistance(p1, p2, props) {
if (!props) {
props = PROPS_XY;
}
var x = p2[props[0]] - p1[props[0]];
var y = p2[props[1]] - p1[props[1]];
return Math.sqrt((x * x) + (y * y));
} | javascript | {
"resource": ""
} |
q37909 | getRotation | train | function getRotation(start, end) {
return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
} | javascript | {
"resource": ""
} |
q37910 | TouchMouseInput | train | function TouchMouseInput() {
Input.apply(this, arguments);
var handler = this.handler.bind(this);
this.touch = new TouchInput(this.manager, handler);
this.mouse = new MouseInput(this.manager, handler);
} | javascript | {
"resource": ""
} |
q37911 | TMEhandler | train | function TMEhandler(manager, inputEvent, inputData) {
var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH);
var isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
// when we're in a touch event, so block all upcoming mouse events
// most mobile browser also emit mouseevents, right after touch... | javascript | {
"resource": ""
} |
q37912 | train | function (value) {
// find out the touch-action by the event handlers
if (value == TOUCH_ACTION_COMPUTE) {
value = this.compute();
}
if (NATIVE_TOUCH_ACTION) {
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
}
this.actions = value.toLowerCase().trim();
} | javascript | {
"resource": ""
} | |
q37913 | train | function () {
var actions = [];
this.manager.recognizers.forEach(function (recognizer) {
if (boolOrFn(recognizer.options.enable, [recognizer])) {
actions = actions.concat(recognizer.getTouchAction());
}
});
return cleanTouchActions(actions.join(' '));
} | javascript | {
"resource": ""
} | |
q37914 | train | function (input) {
// not needed with native support for the touchAction property
if (NATIVE_TOUCH_ACTION) {
return;
}
var srcEvent = input.srcEvent;
var direction = input.offsetDirection;
// if the touch action did prevented once this session
if (this.manager.session.prevented) {
... | javascript | {
"resource": ""
} | |
q37915 | Mallet | train | function Mallet(element, options) {
options = options || {};
options.recognizers = ifUndefined(options.recognizers, Mallet.defaults.preset);
return new Manager(element, options);
} | javascript | {
"resource": ""
} |
q37916 | train | function () {
'use strict';
// default options for pattern-importer
var options = {
environment: {
config: {
server: {
baseDir: './app'
},
host: 'localhost',
port: 8001,
debugInfo: false,
open: true
}
},
showConsoleLog: true,
... | javascript | {
"resource": ""
} | |
q37917 | BloomFilter | train | function BloomFilter()
{
core.AbstractFilter.call(this);
this.blurXFilter = new BlurXFilter();
this.blurYFilter = new BlurYFilter();
this.defaultFilter = new core.AbstractFilter();
} | javascript | {
"resource": ""
} |
q37918 | on | train | function on(ev, fn, context){
var arg = arguments;
var slice = [].slice;
var evs = ev.split(',');
var i = 0;
var evt = '';
var __fn = fn;
fn = function wrapOn(e){
context = context || this;
__fn.apply(context, [e].concat(slice.call(arg, 3)));
};
while(evs[i]){
evt ... | javascript | {
"resource": ""
} |
q37919 | isSandhanganWyanjana | train | function isSandhanganWyanjana(position, input) {
var chr = input.charAt(position),
length = input.length,
prevChr = input.charAt(position - 1),
nextChr;
// pacar = false
if (position == length - 1) {
return false;
}
// paras = false
if (isSwara(prevChr)) {
... | javascript | {
"resource": ""
} |
q37920 | isMovedError | train | function isMovedError(error) {
// Check if error message contains something like: "MOVED 14190 127.0.0.1:6379"
return !!isInstanceOf(error, ReplyError) && error.message && error.message.startsWith('MOVED ');
} | javascript | {
"resource": ""
} |
q37921 | resolveHostAndPortFromMovedError | train | function resolveHostAndPortFromMovedError(movedError) {
// Attempt to resolve the new host & port from the error message
if (isMovedError(movedError)) {
return movedError.message.substring(movedError.message.lastIndexOf(' ') + 1).split(':');
}
throw new Error(`Unexpected ioredis client "moved" ReplyError - ... | javascript | {
"resource": ""
} |
q37922 | train | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q37923 | train | function(name, pa){
var pa = pa || name;
if (!this.isExist(name)){
var realPath = path.join(_pluginBase, pa, 'main.js');
var pluginReg;
if (!fs.existsSync(realPath)) {
pluginReg = require(pa);
} else {
pluginReg = require(f... | javascript | {
"resource": ""
} | |
q37924 | train | function(name){
for (var i = 0, len = _pluginList.length ; i < len ; i++){
var plugin = _pluginList[i];
if (name === plugin.name) {
_pluginList.splice(i, 1);
return;
}
}
} | javascript | {
"resource": ""
} | |
q37925 | train | function(plugins, pluginBase){
var _this = this;
if (typeof pluginBase === 'string') {
_pluginBase = pluginBase;
}
plugins.forEach(function(plugin, index){
var name;
var path;
if (typeof plugin === 'string'){
name =... | javascript | {
"resource": ""
} | |
q37926 | callbackOnce | train | function callbackOnce(err, arg) {
var cb = callback;
callback = null;
if (cb) { cb(err, arg); }
} | javascript | {
"resource": ""
} |
q37927 | createErrorHandler | train | function createErrorHandler(verb) {
return function(err) {
if (!callback) { return; }
grunt.verbose.error();
grunt.fail.warn("Failed to " + verb + ": " + err.message);
callbackOnce(err);
};
} | javascript | {
"resource": ""
} |
q37928 | getStyle | train | function getStyle(element, key, isComputed, isolateUnits) {
assertType(element, Node, false, 'Invalid element specified');
if (typeof isComputed !== 'boolean') isComputed = false;
if (typeof isolateUnits !== 'boolean') isolateUnits = false;
let value = (isComputed) ? window.getComputedStyle(element, null).getP... | javascript | {
"resource": ""
} |
q37929 | Embdr | train | function Embdr(key) {
if (!(this instanceof Embdr)) {
return new Embdr(key);
}
this._api = {
'auth': null,
'host': Embdr.DEFAULT_HOST,
'port': Embdr.DEFAULT_PORT,
'basePath': Embdr.DEFAULT_BASE_PATH,
'protocol': Embdr.DEFAULT_PROTOCOL
};
this.setApiK... | javascript | {
"resource": ""
} |
q37930 | train | function (a, b, c, d, e, ...args) {
return [a, b, c, d, e].concat(args);
} | javascript | {
"resource": ""
} | |
q37931 | flat | train | function flat(current, name, object, separator) {
var data = {}
// iterate object
for (var x in object) {
var key = [name, x].join(separator)
data[key] = object[x]
}
// iterate through data
for (var i in data) {
if (typeof data[i] !== "object") {
current[i] =... | javascript | {
"resource": ""
} |
q37932 | train | function(data, pattern) {
var result = {}
// iterate thorough data
for (var i in data) {
// create context data
var _data = data[i]
// if key match with pattern
if (i.match(pattern)) {
// add matched data
result[i] = _data
}
// if va... | javascript | {
"resource": ""
} | |
q37933 | VersionIterable | train | function VersionIterable(task) {
var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var name = _ref.name;
var _ref$range = _ref.range;
var range = _ref$range === undefined ? '*' : _ref$range;
var _ref$dir = _ref.dir;
var dir = _ref$dir ==... | javascript | {
"resource": ""
} |
q37934 | splatPoints | train | function splatPoints(out, points, weights, radius) {
doSplat(
points.hi(points.shape[0], 1),
ndarray(weights.data,
[weights.shape[0], 1],
[weights.stride[0], 0],
weights.offset),
out,
radius,
dirichlet)
} | javascript | {
"resource": ""
} |
q37935 | functionWrapperFunction | train | function functionWrapperFunction () {
// call original function - catching errors for logging
try {
var res = functionObj.apply(this, arguments)
}
catch (error) {
var err = error
}
// if log client then do logging
if (options.logClient) {
... | javascript | {
"resource": ""
} |
q37936 | train | function () {
'use strict';
// default options for doxx gulp task
var options = {
config: {
title: 'Project Title',
urlPrefix: null,
template: path.join(__dirname, '../templates/doxx.template.jade')
},
src: [
'!./node_modules/**/*',
'./**/*.js'
],
dest: './docs'... | javascript | {
"resource": ""
} | |
q37937 | train | function(v, o) {
if (re.test(v)) {
o[k] = v; // Set params to be returned when matching
return true;
} else {
return false;
}
} | javascript | {
"resource": ""
} | |
q37938 | Widget | train | function Widget(options) {
this.__data = {};
try {
var e;
if (typeof options === 'undefined') options = {};
if (typeof options.innerHTML !== 'undefined' && typeof options.childNodes !== 'undefined') {
// On passe directement un élément.
options = {element: options};
}
if (typeof opti... | javascript | {
"resource": ""
} |
q37939 | train | function(v) {
if (v === undefined) return this._element;
if (typeof v === 'string') {
v = window.document.querySelector(v);
}
this._element = v;
return this;
} | javascript | {
"resource": ""
} | |
q37940 | train | function() {
var e = this._element;
if (e) {
var p = e.parentNode;
if (p) {
p.removeChild(e);
}
}
return this;
} | javascript | {
"resource": ""
} | |
q37941 | train | function() {
var i, arg;
for (i = 0 ; i < arguments.length ; i++) {
arg = arguments[i];
if (typeof arg === 'number') arg = "" + arg;
if (typeof arg === 'undefined' || typeof arg === 'null'
|| (typeof arg !== 'object' && typeof arg !== 'string')) {
console.error("[Widget.appen... | javascript | {
"resource": ""
} | |
q37942 | train | function(parent) {
if (!parent) return this;
if (typeof parent.append === 'function') {
parent.append(this);
} else if (typeof parent.appendChild === 'function') {
parent.appendChild(this._element);
this.onAppend();
}
return this;
} | javascript | {
"resource": ""
} | |
q37943 | train | function() {
// (!) On préfère retirer les éléments un par un du DOM plutôt que d'utiliser simplement
// this.html("").
// En effet, le code simplifié a des conséquences inattendues dans IE9 et IE10 au moins.
// Le bug des markers qui disparaissaients sur les cartes de Trail-Passion 4 a été corrigé
... | javascript | {
"resource": ""
} | |
q37944 | train | function() {
var e = this._element;
if (!e) return null;
if (typeof e.getBoundingClientRect !== 'function') {
console.error("[wdg.rect] This element has non `getBoundingClientRect` function:", e);
}
var r = e.getBoundingClientRect();
if( typeof r.width === 'undefined' ) r.width = r.right -... | javascript | {
"resource": ""
} | |
q37945 | revert | train | function revert(h, node) {
var subtype = node.referenceType
var suffix = ']'
var contents
var head
var tail
if (subtype === 'collapsed') {
suffix += '[]'
} else if (subtype === 'full') {
suffix += '[' + node.identifier + ']'
}
if (node.type === 'imageReference') {
... | javascript | {
"resource": ""
} |
q37946 | train | function(callback) {
// TODO: don't wait until the end. Instead, emit immediately upon finding the template
if (!templateFile) throw new Error('template not found in stream');
templateFile.data = templateFile.data || {};
files.forEach(function(file) {
var newFile = templateFile.clone();
newFile.data.f... | javascript | {
"resource": ""
} | |
q37947 | registerSpecification | train | function registerSpecification(specification, remoteDN , options , callback){
// Serialize the capability Object
var post_data = {};
post_data[remoteDN] = JSON.parse(specification.to_dict());
post_data = JSON.stringify(post_data);
var proto = https;
var post_options = {
path: SUPERVISOR... | javascript | {
"resource": ""
} |
q37948 | showResults | train | function showResults(redeem , options , callback){
if (typeof redeem !== 'object')
redeem = new mplane.Redemption(redeem);
var post_data = redeem.to_dict();
var post_options = {
path: SUPERVISOR_PATH_SHOW_RESULT,
method: 'POST',
host: options.host,
port: options.p... | javascript | {
"resource": ""
} |
q37949 | showCapabilities | train | function showCapabilities( options, callback){
options.url = 'https://'+options.host+':'+options.port+SUPERVISOR_PATH_SHOW_CAPABILITY;
options.ca = ssl_files.readCaChain(options.caFile);
options.key = ssl_files.readFileContent(options.keyFile);
options.cert = ssl_files.readFileContent(options.certFile)... | javascript | {
"resource": ""
} |
q37950 | info | train | function info(options , callback){
options.url = 'https://'+options.host+':'+options.port+SUPERVISOR_PATH_INFO;
options.key = ssl_files.readFileContent(options.keyFile);
options.cert = ssl_files.readFileContent(options.certFile);
options.ca = ssl_files.readCaChain(options.ca);
request(options, fun... | javascript | {
"resource": ""
} |
q37951 | genReq | train | function genReq (options,cb) {
log(options.verbose,"Starting twitreq ...");
if ( typeof options.protocol === "undefined" ) {
options.protocol = PROTOCOL;
}
if ( typeof options.host === "undefined" ) {
options.host = HOST;
}
if ( typeof options.oAuthSignatureMethod === "undefi... | javascript | {
"resource": ""
} |
q37952 | genQueryString | train | function genQueryString (options) {
if ( !options.queryParams ) {
return "";
}
log(options.verbose,"Now generating query string value ...");
var queryStringParams = [];
Object.keys(options.queryParams).forEach(function (key) {
queryStringParams.push(createEncodedParam(key,options... | javascript | {
"resource": ""
} |
q37953 | percentEncode | train | function percentEncode (value) {
var result = encodeURIComponent(value);
return result.replace(/\!/g, "%21")
.replace(/\'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29")
.replace(/\*/g, "%2A");
} | javascript | {
"resource": ""
} |
q37954 | error | train | function error(err) {
this.log(`${chalk.red(`${err.name.toLowerCase()}:`)} ${err.message}`);
} | javascript | {
"resource": ""
} |
q37955 | status | train | function status(url, code, mod) {
return this.get(url, mod).then(req => req.statusCode === code);
} | javascript | {
"resource": ""
} |
q37956 | Config | train | function Config( defaults, extend, envName )
{
// Constants
// -------------
// test instance uniqueness
this._UID = _.uniqueId('config_')
this._DEFAULTENV = 'default'
// CORE's settings
// ------------------------
// default app configuration
var confDefault = this.getConfigParam( defau... | javascript | {
"resource": ""
} |
q37957 | AsyncRunner | train | function AsyncRunner(times, fn) {
Runner.apply(this, arguments);
this.pause = 0;
this.end = noop;
this.times = times;
} | javascript | {
"resource": ""
} |
q37958 | printMatrix2 | train | function printMatrix2 (m) {
const tStr = m.elements.map(formatPrintNumber);
const matrixString = `
+- -+
| ${tStr[0]} ${tStr[2]} |
| ${tStr[1]} ${tStr[3]} |
+- -+`;
return matrixString;
} | javascript | {
"resource": ""
} |
q37959 | printMatrix3 | train | function printMatrix3 (m) {
const tStr = m.elements.map(formatPrintNumber);
const matrixString = `
+- -+
| ${tStr[0]} ${tStr[3]} ${tStr[6]} |
| ${tStr[1]} ${tStr[4]} ${tStr[7]} |
| ${tStr[2]} ${tStr[5]} ${tStr[8]} |
+- -+`;
return matrixString;
} | javascript | {
"resource": ""
} |
q37960 | xpathFn | train | function xpathFn(token, rootEl, ns) {
var split = token.trim().split('@');
var retVal = rootEl;
var path = split[0].replace(/\/$/, "") || null;
var attr = split[1] || null;
if(path)
retVal = retVal.get(path, ns);
if(attr) {
retVal = retVal ? retVal.attr(attr) : "";
ret... | javascript | {
"resource": ""
} |
q37961 | evalFn | train | function evalFn(token, format_lib) {
var splited = token.trim().split(/[\(\)]/g);
if (splited.length < 3)
return token;
if (!format_lib)
return token
var fnstring = splited[0];
var fnparams = splited.slice(1, splited.length - 1);
var fn = format_lib[fnstring];
if (typeof ... | javascript | {
"resource": ""
} |
q37962 | generateClassNameSubstitutions | train | function generateClassNameSubstitutions(tokens, substitutionPattern, substitutions) {
tokens.forEach((tokenList)=> {
var token = tokenList[0];
generateSubstitution(token, substitutionPattern, substitutions);
});
} | javascript | {
"resource": ""
} |
q37963 | generateSubstitution | train | function generateSubstitution(token, substitutionPattern, substitutions) {
var substitution = substitutionPattern.replace(/{([^}]+)}/ig, (all, group)=> {
switch (group) {
case 'namespace':
return token.namespace;
case 'name':
return token.className;
case 'random':
return ... | javascript | {
"resource": ""
} |
q37964 | Timestamp | train | function Timestamp(message, code_id) {
Error.call(this);
this.message = message || "timestamp out of date";
this.code_id = code_id || null;
this.statusCode = 409;
} | javascript | {
"resource": ""
} |
q37965 | NotReady | train | function NotReady(message, code_id) {
Error.call(this);
this.message = message || "resource is not ready yet";
this.code_id = code_id || null;
this.statusCode = 423;
} | javascript | {
"resource": ""
} |
q37966 | Locked | train | function Locked(message, code_id) {
Error.call(this);
this.message = message || "resource is locked"
this.code_id = code_id || null;
this.statusCode = 423;
} | javascript | {
"resource": ""
} |
q37967 | NeverImplemented | train | function NeverImplemented(message, code_id) {
Error.call(this);
this.message = message || "never will be implemented";
this.code_id = code_id || null;
this.statusCode = 501;
} | javascript | {
"resource": ""
} |
q37968 | SetupRequired | train | function SetupRequired(message, code_id) {
Error.call(this);
this.message = message || "setup required";
this.code_id = code_id || null;
this.statusCode = 500;
} | javascript | {
"resource": ""
} |
q37969 | Internal | train | function Internal(message, code_id) {
Error.call(this);
this.message = message || "internal error";
this.code_id = code_id || null;
this.statusCode = 500;
} | javascript | {
"resource": ""
} |
q37970 | Unavailable | train | function Unavailable(message, code_id) {
Error.call(this);
this.message = message || "temporarily unavailable";
this.code_id = code_id || null;
this.statusCode = 503;
} | javascript | {
"resource": ""
} |
q37971 | train | function() {
var that = this;
var boundEmitComplete = emitComplete.bind(this);
EventEmitter.call(this);
this.middleware = [];
this.server = net.createServer(function(conn) {
var buffer = '';
var info = null;
conn.on('data', function(data) {
buffer += data;
if(!info) {
if(... | javascript | {
"resource": ""
} | |
q37972 | train | function (ppunit, writer) {
writer.useColors = false
BaseReporter.call(this, ppunit, writer)
var self = this
ppunit.on('finish', function () {
writer.write(
self.tag(
'testsuite'
, {
name: 'PPUnit Tests'
, tests: ... | javascript | {
"resource": ""
} | |
q37973 | CouchDB | train | function CouchDB(config, nano) {
if (!config) {
throw new Error("Expected a CouchDB configuration");
}
if (!config.url) {
throw new Error("Expected a url in the CouchDB configuration");
}
if (!config.database) {
throw new Error("Expected a database name in the CouchDB configuration");
}
if (!config.design... | javascript | {
"resource": ""
} |
q37974 | train | function (path) {
var foundPath = self.PathTool.findLibScript(path);
if (foundPath) {
self.scriptList.push(foundPath);
} else {
self.logger.warn('script:%s not found!', path);
}
} | javascript | {
"resource": ""
} | |
q37975 | arrayize | train | function arrayize(values) {
// return empty array if values is empty
if (typeof values === 'undefined' || values === null ) {
return [];
}
// return array of values, converting to array if necessary
return util.isArray(values) ? values : [values];
} | javascript | {
"resource": ""
} |
q37976 | train | function() {
// Combine random and case-specific factors into a base string
var factors = {
creationDate: (new Date()).getTime(),
random: Math.random() * (Math.random() * 1000),
nodeVersion: process.version
};
var basestring = '';
_.each(factors, function (val) {
basestring += val;
});
//... | javascript | {
"resource": ""
} | |
q37977 | train | function (id, options, cb) {
if (arguments.length !== 3) {
cb = options;
options = {};
}
var self = this;
var model = this.get(id);
if (model){
return cb(null, model);
}
function done() {
var model = self.get(id);
if (model) {
if (cb){
cb(null,... | javascript | {
"resource": ""
} | |
q37978 | train | function(err, model, response, options){
if (options.cb){
options.cb(err, model, response);
}
if (err){
model.trigger('error', err, model, options);
}
} | javascript | {
"resource": ""
} | |
q37979 | train | function(fileName) {
//Grab the path package here locally for clarity
var _path = require('path');
//'yada/yada/multi1.html' -> 'multi1'
var name = _path
.basename(
fileName,
_path.extname(fileName));
... | javascript | {
"resource": ""
} | |
q37980 | train | function(name, transformations) {
var synonyms = [];
if (typeof name === 'string' && name) {
transformations = transformations || this.transformations;
if (!Array.isArray(transformations)) {
transformations = Object.keys(transformations);
}
... | javascript | {
"resource": ""
} | |
q37981 | train | function(req, rsp, cb){
fs.readFile(path.resolve(routerPath), function(err, buff){
if (buff) {
var arrs = buff2arrs(buff)
return cb(arrs)
} else {
return cb(null)
}
})
} | javascript | {
"resource": ""
} | |
q37982 | discardIfOverAttempted | train | function discardIfOverAttempted(tasksByName, count) {
if (tasksByName) {
taskUtils.getTasks(tasksByName).forEach(task => {
const n = task.discardIfOverAttempted(maxNumberOfAttempts, true);
if (count) overAttempted += n;
});
}
} | javascript | {
"resource": ""
} |
q37983 | Client | train | function Client (id, apiKey) {
if (!(this instanceof Client)) {
return new Client(id, apiKey);
}
this.endpoint = 'https://www.googleapis.com';
this.apiKey = apiKey;
this.id = id;
} | javascript | {
"resource": ""
} |
q37984 | is_https | train | function is_https(req) {
if(req.headers && req.headers['x-forwarded-proto'] && req.headers['x-forwarded-proto'] === 'https') { return true; }
return (req && req.connection && req.connection.encrypted) ? true : false;
} | javascript | {
"resource": ""
} |
q37985 | train | function(message) {
if (!_.isObject(message)) {
message = {
message: message
};
}
try {
message = JSON.stringify(_.defaultsDeep({}, message, this.config.defaultProps));
} catch (e) {
return this.logger.error('Logmatic - error while parsing log message. Not sending', e);
... | javascript | {
"resource": ""
} | |
q37986 | train | function (script, args, hash) {
this.actionQueue.push(this.webdriverClient.execute.bind(this.webdriverClient, {script: script.toString(), arguments: args}));
this.actionQueue.push(this._setExecuteCb.bind(this, script.toString(), args, hash));
return this;
} | javascript | {
"resource": ""
} | |
q37987 | train | function (script, args, hash, data) {
var deferred = Q.defer();
this.events.emit('driver:message', {key: 'execute', value: JSON.parse(data).value, uuid: hash, hash: hash});
deferred.resolve();
return deferred.promise;
} | javascript | {
"resource": ""
} | |
q37988 | train | function (script, args, timeout, hash) {
this.actionQueue.push(this.webdriverClient.execute.bind(this.webdriverClient, {script: script.toString(), arguments: args}));
this.actionQueue.push(this._waitForCb.bind(this, script.toString(), args, timeout, hash));
return this;
} | javascript | {
"resource": ""
} | |
q37989 | train | function (script, args, timeout, hash, data) {
var deferred = Q.defer();
var ret = JSON.parse(data);
var checker = function (yData) {
if (JSON.parse(yData).value.userRet === true) {
this.events.emit('driver:message', {key: 'waitFor', value: '', uuid: hash, hash: hash});
deferred.resolv... | javascript | {
"resource": ""
} | |
q37990 | onUpgrade | train | function onUpgrade (reverseProxy, proxySocket) {
if (!reverseProxy) {
proxySocket.end();
socket.end();
return;
}
//
// Any incoming data on this WebSocket to the proxy target
// will be written to the `reverseProxy` socket.
//
proxySocket.on('data', listeners.onIncoming = ... | javascript | {
"resource": ""
} |
q37991 | detach | train | function detach() {
proxySocket.destroySoon();
proxySocket.removeListener('end', listeners.onIncomingClose);
proxySocket.removeListener('data', listeners.onIncoming);
reverseProxy.incoming.socket.destroySoon();
reverseProxy.incoming.socket.removeListener('end', listeners.onOutgoingClose);
... | javascript | {
"resource": ""
} |
q37992 | proxyError | train | function proxyError (err) {
reverseProxy.destroy();
process.nextTick(function () {
//
// Destroy the incoming socket in the next tick, in case the error handler
// wants to write to it.
//
socket.destroy();
});
self.emit('webSocketProxyError', req, socket, head);
} | javascript | {
"resource": ""
} |
q37993 | Broker | train | function Broker(options) {
EventEmitter.call(this);
this._exchange = null;
this._queues = {};
this._ctags = {};
this._options = options;
} | javascript | {
"resource": ""
} |
q37994 | ErrorSave | train | function ErrorSave (message) {
Error.call(this);
// Add Information
this.name = 'ErrorSave';
this.type = 'server';
this.status = 500;
if (message) {
this.message = message;
}
} | javascript | {
"resource": ""
} |
q37995 | isRealDirectory | train | function isRealDirectory(p) {
var stats;
try {
stats = fs.statSync(p);
} catch (error) {
// Not a valid path if stat fails.
return false;
}
return (stats.isDirectory());
} | javascript | {
"resource": ""
} |
q37996 | generatePolygon | train | function generatePolygon() {
var coordNumber = getRandomNumber(3, options.maxCoordCount);
var feature = rawFeature();
feature.geometry.type = 'Polygon';
feature.geometry.coordinates = [
[]
];
var firstCoordinate = generateLonLat();
feature.geometry.coordinates[0].push(firstCoordinate);
addCoordin... | javascript | {
"resource": ""
} |
q37997 | generateLineString | train | function generateLineString() {
var coordNumber = getRandomNumber(3, options.maxCoordCount);
var feature = rawFeature();
feature.geometry.type = 'LineString';
addCoordinates(feature.geometry.coordinates, coordNumber);
return feature;
} | javascript | {
"resource": ""
} |
q37998 | generateFeatures | train | function generateFeatures() {
var collection = {
type: 'FeatureCollection',
features: []
};
for (var i = 0; i < options.number; i++) {
collection.features.push(generateFeature(randomType()));
}
return collection;
} | javascript | {
"resource": ""
} |
q37999 | addCoordinates | train | function addCoordinates(coordArray, number) {
for (var i = 0; i < number; i++) {
coordArray.push(generateLonLat());
}
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.