_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q52500 | registerUndrier | train | function registerUndrier(constructor, fnc, options) {
var path;
if (typeof constructor == 'function') {
path = constructor.name;
} else {
path = constructor;
}
undriers[path] = {
fnc : fnc,
options : options || {}
};
} | javascript | {
"resource": ""
} |
q52501 | findClass | train | function findClass(value) {
var constructor,
ns;
// Return nothing for falsy values
if (!value) {
return null;
}
// Look for a regular class when it's just a string
if (typeof value == 'string') {
if (exports.Classes[value]) {
return exports.Classes[value];
}
return null;
}
if (value.path)... | javascript | {
"resource": ""
} |
q52502 | regenerateArray | train | function regenerateArray(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var length = current.length,
temp,
i;
for (i = 0; i < length; i++) {
// Only regenerate if it's not yet seen
if (!seen.get(current[i])) {
temp = current_path.slice(0);
temp.push(i);
current[i] ... | javascript | {
"resource": ""
} |
q52503 | regenerateObject | train | function regenerateObject(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var path,
temp,
key;
for (key in current) {
if (current.hasOwnProperty(key)) {
// Only regenerate if it's not already seen
if (!seen.get(current[key])) {
path = current_path.slice(0);
path.pu... | javascript | {
"resource": ""
} |
q52504 | regenerate | train | function regenerate(root, holder, current, seen, retrieve, undry_paths, old, current_path) {
var temp;
if (current && typeof current == 'object') {
// Remember this object has been regenerated already
seen.set(current, true);
if (current instanceof Array) {
return regenerateArray(root, holder, current, se... | javascript | {
"resource": ""
} |
q52505 | getFromOld | train | function getFromOld(old, pieces) {
var length = pieces.length,
result,
path,
rest,
i;
for (i = 0; i < length; i++) {
path = pieces.slice(0, length - i).join('.');
result = old[path];
if (typeof result != 'undefined') {
if (i == 0) {
return result;
}
rest = pieces.slice(pie... | javascript | {
"resource": ""
} |
q52506 | retrieveFromPath | train | function retrieveFromPath(current, keys) {
var length = keys.length,
prev,
key,
i;
// Keys [''] always means the root
if (length == 1 && keys[0] === '') {
return current;
}
for (i = 0; i < length; i++) {
key = keys[i];
// Normalize the key
if (typeof key == 'number') {
// Allow
} el... | javascript | {
"resource": ""
} |
q52507 | fromPath | train | function fromPath(obj, path) {
var pieces,
here,
len,
i;
if (typeof path == 'string') {
pieces = path.split('.');
} else {
pieces = path;
}
here = obj;
// Go over every piece in the path
for (i = 0; i < pieces.length; i++) {
if (here != null) {
if (here.hasOwnProperty(pieces[i])) {
... | javascript | {
"resource": ""
} |
q52508 | setPath | train | function setPath(obj, keys, value, force) {
var here,
i;
here = obj;
for (i = 0; i < keys.length - 1; i++) {
if (here != null) {
if (here.hasOwnProperty(keys[i])) {
here = here[keys[i]];
} else {
if (force && here[keys[i]] == null) {
here[keys[i]] = {};
here = here[keys[i]];
c... | javascript | {
"resource": ""
} |
q52509 | toDryObject | train | function toDryObject(value, replacer) {
var root = {'': value};
return createDryReplacer(root, replacer)(root, '', value);
} | javascript | {
"resource": ""
} |
q52510 | stringify | train | function stringify(value, replacer, space) {
return JSON.stringify(toDryObject(value, replacer), null, space);
} | javascript | {
"resource": ""
} |
q52511 | walk | train | function walk(obj, fnc, result) {
var is_root,
keys,
key,
ret,
i;
if (!result) {
is_root = true;
if (Array.isArray(obj)) {
result = [];
} else {
result = {};
}
}
keys = Object.keys(obj);
for (i = 0; i < keys.length; i++) {
key = keys[i];
if (typeof obj[key] == 'object' &... | javascript | {
"resource": ""
} |
q52512 | parse | train | function parse(object, reviver) {
var undry_paths = new Map(),
retrieve = {},
reviver,
result,
holder,
entry,
temp,
seen,
path,
key,
old = {};
// Create the reviver function
reviver = generateReviver(reviver, undry_paths);
if (typeof object == 'string') {
ob... | javascript | {
"resource": ""
} |
q52513 | train | function () {
var inputs = Array.prototype.slice.call(arguments, 0);
return external.message.apply(this, inputs);
} | javascript | {
"resource": ""
} | |
q52514 | train | function (type, item, hard) {
if (hard) {
return harderTypes[type](getType(item), item);
}
return (getType(item) === simpleTypes[type]);
} | javascript | {
"resource": ""
} | |
q52515 | train | function (type, item) {
switch(type) {
case simpleTypes.undefined:
case simpleTypes.null:
return true;
case simpleTypes.string:
if (item.trim().length === 0) {
return true;
}
return false;
... | javascript | {
"resource": ""
} | |
q52516 | train | function (inputs) {
var props = { };
// Create a function to call with simple and hard types
// This is done so simple types don't need to check for hard types
var generateProps = function (types, hard) {
for (var t in types) {
if (types.hasOwnProperty(t)) {
... | javascript | {
"resource": ""
} | |
q52517 | train | function (types, hard) {
for (var t in types) {
if (types.hasOwnProperty(t)) {
(function (prop) {
Object.defineProperty(props, prop, {
get: function () {
for (var i = 0; i < inputs.length;... | javascript | {
"resource": ""
} | |
q52518 | train | function (obj1, obj2, overwrite) {
if (obj1 === undefined || obj1 === null) { return obj2; };
if (obj2 === undefined || obj2 === null) { return obj1; };
var obj1Type = external.is(obj1).getType();
var obj2Type = external.is(obj2).getType();
var exceptionMsg;
if (accepta... | javascript | {
"resource": ""
} | |
q52519 | train | function(arr, value) {
var inx = arr.indexOf(value);
var endIndex = arr.length - 1;
if (inx !== endIndex) {
var temp = arr[endIndex];
arr[endIndex] = arr[inx];
arr[inx] = temp;
}
arr.pop();
} | javascript | {
"resource": ""
} | |
q52520 | train | function (uses, payload, message) {
var results = [];
var keys = (uses || []);
for (var i = 0; i < forced.length; ++i) {
if (keys.indexOf(forced[i]) === -1) {
keys.push(forced[i]);
}
}
for (var i = 0; i < keys.length; ++i) {
if... | javascript | {
"resource": ""
} | |
q52521 | train | function (uses, payload, message, callback) {
var middles = getMiddlewares(uses, payload, message);
internal.executer(middles).series(function (result) {
return callback(internal.merge.apply(this, [payload].concat(result)));
});
} | javascript | {
"resource": ""
} | |
q52522 | train | function (msgOrIds, payload, callback) {
var ids = (external.is(msgOrIds).array) ? msgOrIds : messageIndex.query(msgOrIds);
if (ids.length > 0) {
var methods = [];
var toDrop = [];
for (var i = 0; i < ids.length; ++i) {
var msg = (external.is(msgOrIds... | javascript | {
"resource": ""
} | |
q52523 | drawToCanvas | train | function drawToCanvas({data, width, height}) {
if (typeof document === 'undefined') return null
var canvas = document.createElement('canvas')
canvas.width = width
canvas.height = height
var context = canvas.getContext('2d')
var idata = context.createImageData(canvas.width, canvas.height)
for ... | javascript | {
"resource": ""
} |
q52524 | inheritsTlSchema | train | function inheritsTlSchema(constructor, superTlSchema) {
var NewType = buildType('abstract', superTlSchema);
util.inherits(constructor, NewType);
constructor.s_ = NewType;
constructor.super_ = NewType.super_;
constructor.util = NewType.util;
constructor.requireTypeByName = NewType.requireTypeByNa... | javascript | {
"resource": ""
} |
q52525 | buildTypeFunction | train | function buildTypeFunction(module, tlSchema) {
var methodName = tlSchema.method;
// Start creating the body of the new Type function
var body =
'\tvar self = arguments.callee;\n' +
'\tvar callback = options.callback;\n' +
'\tvar channel = options.channel;\n' +
'\tif (!channel... | javascript | {
"resource": ""
} |
q52526 | registerTypeById | train | function registerTypeById(type) {
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Register Type \'%s\' by id [%s]', type.typeName, type.id);
}
if(type.id) {
typeById[type.id] = type;
}
return type;
} | javascript | {
"resource": ""
} |
q52527 | requireTypeFromBuffer | train | function requireTypeFromBuffer(buffer) {
var typeId = buffer.slice(0, 4).toString('hex');
var type = typeById[typeId];
if (!type) {
var msg = 'Unable to retrieve a Type by Id [' + typeId + ']';
registryLogger.error(msg);
throw new Error(msg);
}
if (registryLogger.isDebugEnabl... | javascript | {
"resource": ""
} |
q52528 | registerTypeByName | train | function registerTypeByName(type) {
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Register Type \'%s\' by name [%s]', type.id, type.typeName);
}
typeByName[type.typeName] = type;
return type;
} | javascript | {
"resource": ""
} |
q52529 | requireTypeByName | train | function requireTypeByName(typeName) {
var type = typeByName[typeName];
if (!type) {
var msg = 'Unable to retrieve a Type by Name [' + typeName + ']';
registryLogger.error(msg);
throw new Error(msg);
}
if (registryLogger.isDebugEnabled()) {
registryLogger.debug('Require T... | javascript | {
"resource": ""
} |
q52530 | toPrintable | train | function toPrintable(exclude, noColor) {
var str = '{ ' + ( this._typeName ? 'T:' + this._typeName.bold : '');
if (typeof exclude !== 'object') {
noColor = exclude;
exclude = {};
}
for (var prop in this) {
if ('_' !== prop.charAt(0) && exclude[prop] !== true) {
var pa... | javascript | {
"resource": ""
} |
q52531 | stringValue2Buffer | train | function stringValue2Buffer(stringValue, byteLength) {
if ((stringValue).slice(0, 2) === '0x') {
var input = stringValue.slice(2);
var length = input.length;
var buffers = [];
var j = 0;
for (var i = length; i > 0 && j < byteLength; i -= 2) {
buffers.push(new Buff... | javascript | {
"resource": ""
} |
q52532 | buffer2StringValue | train | function buffer2StringValue(buffer) {
var length = buffer.length;
var output = '0x';
for (var i = length; i > 0; i--) {
output += buffer.slice(i - 1, i).toString('hex');
}
return output;
} | javascript | {
"resource": ""
} |
q52533 | HttpViewEngine | train | function HttpViewEngine(context) {
if (this.constructor === HttpViewEngine.prototype.constructor) {
throw new AbstractClassError();
}
/**
* @name HttpViewEngine#context
* @type HttpContext
* @description Gets or sets an instance of HttpContext that represents the current HTTP context.... | javascript | {
"resource": ""
} |
q52534 | isValidPath | train | function isValidPath(path) {
if (path === null || path === undefined) return false;
return typeof path === 'string' && path.length > 0;
} | javascript | {
"resource": ""
} |
q52535 | queryController | train | function queryController(requestUri) {
try {
if (requestUri === undefined)
return null;
//split path
var segments = requestUri.pathname.split('/');
//put an exception for root controller
//maybe this is unnecessary exception but we need to search for root controll... | javascript | {
"resource": ""
} |
q52536 | XmlCommon | train | function XmlCommon() {
//constants
this.DOM_ELEMENT_NODE = 1;
this.DOM_ATTRIBUTE_NODE = 2;
this.DOM_TEXT_NODE = 3;
this.DOM_CDATA_SECTION_NODE = 4;
// noinspection JSUnusedGlobalSymbols
this.DOM_ENTITY_REFERENCE_NODE = 5;
// noinspection JSUnusedGlobalSymbols
this.DOM_ENTITY_NODE = 6... | javascript | {
"resource": ""
} |
q52537 | HttpViewResult | train | function HttpViewResult(name, data)
{
this.name = name;
this.data = data===undefined? []: data;
this.contentType = 'text/html;charset=utf-8';
this.contentEncoding = 'utf8';
} | javascript | {
"resource": ""
} |
q52538 | HttpViewContext | train | function HttpViewContext(context) {
/**
* Gets or sets the body of the current view
* @type {String}
*/
this.body='';
/**
* Gets or sets the title of the page if the view will be fully rendered
* @type {String}
*/
this.title='';
/**
* Gets or sets the view layout p... | javascript | {
"resource": ""
} |
q52539 | sanitizeHtml | train | function sanitizeHtml(html, whitelist) {
return html.replace(/<[^>]*>?/gi, function(tag) {
return tag.match(whitelist) ? tag : '';
});
} | javascript | {
"resource": ""
} |
q52540 | union | train | function union(x, y) {
var obj = {};
for (var i = 0; i < x.length; i++)
obj[x[i]] = x[i];
for (i = 0; i < y.length; i++)
obj[y[i]] = y[i];
var res = [];
for (var k in obj) {
if (obj.hasOwnProperty(k))
res.push(obj[k]);
}... | javascript | {
"resource": ""
} |
q52541 | removeAnchors | train | function removeAnchors(text) {
if(text.charAt(0) == '\x02')
text = text.substr(1);
if(text.charAt(text.length - 1) == '\x03')
text = text.substr(0, text.length - 1);
return text;
} | javascript | {
"resource": ""
} |
q52542 | convertAll | train | function convertAll(text, extra) {
var result = extra.blockGamutHookCallback(text);
// We need to perform these operations since we skip the steps in the converter
result = unescapeSpecialChars(result);
result = result.replace(/~D/g, "$$").replace(/~T/g, "~");
result = extra.prev... | javascript | {
"resource": ""
} |
q52543 | AccessDeniedError | train | function AccessDeniedError(message, innerMessage, model) {
AccessDeniedError.super_.bind(this)('EACCESS', ('Access Denied' || message) , innerMessage, model);
this.statusCode = 401;
} | javascript | {
"resource": ""
} |
q52544 | UniqueConstraintError | train | function UniqueConstraintError(message, innerMessage, model) {
UniqueConstraintError.super_.bind(this)('EUNQ', message || 'A unique constraint violated', innerMessage, model);
} | javascript | {
"resource": ""
} |
q52545 | caseInsensitiveAttribute | train | function caseInsensitiveAttribute(name) {
if (typeof name === 'string') {
if (this[name])
return this[name];
//otherwise make a case insensitive search
var re = new RegExp('^' + name + '$','i');
var p = Object.keys(this).filter(function(x) { return re.test(x); })[0];
... | javascript | {
"resource": ""
} |
q52546 | MethodCallExpression | train | function MethodCallExpression(name, args) {
/**
* Gets or sets the name of this method
* @type {String}
*/
this.name = name;
/**
* Gets or sets an array that represents the method arguments
* @type {Array}
*/
this.args = [];
if (_.isArray(args))
this.args = args... | javascript | {
"resource": ""
} |
q52547 | HttpRoute | train | function HttpRoute(route) {
if (typeof route === 'string') {
this.route = { url:route };
}
else if (typeof route === 'object') {
this.route = route;
}
this.routeData = { };
this.patterns = {
int:function() {
return "^[1-9]([0-9]*)$";
},
boolea... | javascript | {
"resource": ""
} |
q52548 | xpathSort | train | function xpathSort(input, sort) {
if (sort.length === 0) {
return;
}
var sortlist = [];
var i;
for (i = 0; i < input.contextSize(); ++i) {
var node = input.nodelist[i];
var sortitem = {node: node, key: []};
var context = input.clone(node, 0, [node]);
for (var... | javascript | {
"resource": ""
} |
q52549 | xpathEval | train | function xpathEval(select, context, ns) {
var str = select;
if (ns !== undefined) {
if (context.node)
str = context.node.prepare(select, ns);
}
//parse statement
var expr = xpathParse(str);
//and return value
return expr.evaluate(context);
} | javascript | {
"resource": ""
} |
q52550 | DataModelMigration | train | function DataModelMigration() {
/**
* Gets an array that contains the definition of fields that are going to be added
* @type {Array}
*/
this.add = [];
/**
* Gets an array that contains a collection of constraints which are going to be added
* @type {Array}
*/
this.constrai... | javascript | {
"resource": ""
} |
q52551 | removeFromArray | train | function removeFromArray(array, value, opt_notype) {
var shift = 0;
for (var i = 0; i < array.length; ++i) {
if (array[i] === value || (opt_notype && array[i] === value)) {
array.splice(i--, 1);
shift++;
}
}
return shift;
} | javascript | {
"resource": ""
} |
q52552 | DefaultCacheStrategy | train | function DefaultCacheStrategy(app) {
DefaultCacheStrategy.super_.bind(this)(app);
//set absoluteExpiration (from application configuration)
var expiration = CACHE_ABSOLUTE_EXPIRATION;
var absoluteExpiration = LangUtils.parseInt(app.getConfiguration().getSourceAt('settings/cache/absoluteExpiration'));
... | javascript | {
"resource": ""
} |
q52553 | _remove | train | function _remove(key) {
var i = _keys.indexOf(key)
if (i > -1) {
ls.removeItem(key);
_keys.splice(_keys.indexOf(key), 1);
delete _config[key];
}
} | javascript | {
"resource": ""
} |
q52554 | _executeOperation | train | function _executeOperation(operation, values) {
/**
* Run passed method if value passed is not NaN, otherwise throw a TypeError.
*
* @private
* @method _ifValid
*
* @param value {Number}
* A value to check is not NaN before running method on.
*
* @param method {Function}
* ... | javascript | {
"resource": ""
} |
q52555 | parseSubaddress | train | function parseSubaddress(user) {
var parsed = {
username: user
};
if (user.indexOf('+')) {
parsed.username = user.split('+')[0];
parsed.subaddress = user.split('+')[1];
}
return parsed;
} | javascript | {
"resource": ""
} |
q52556 | train | function (bufferRatio) { // (Number) -> LatLngBounds
var sw = this._southWest,
ne = this._northEast,
heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
return new L.LatLngBounds(
new L.LatLng(sw.lat - heightBuffer, sw.ln... | javascript | {
"resource": ""
} | |
q52557 | getAbbr | train | function getAbbr(wofData) {
const iso2 = getPropertyValue(wofData, 'wof:country');
// sometimes there are codes set to XX which cause an exception so check if it's a valid ISO2 code
if (iso2 !== false && iso3166.is2(iso2)) {
return iso3166.to3(iso2);
}
return null;
} | javascript | {
"resource": ""
} |
q52558 | getPropertyValue | train | function getPropertyValue(wofData, property) {
if (wofData.properties.hasOwnProperty(property)) {
// if the value is an array, return the first item
if (wofData.properties[property] instanceof Array) {
return wofData.properties[property][0];
}
// otherwise just return the value as is
retu... | javascript | {
"resource": ""
} |
q52559 | getName | train | function getName(wofData) {
// if this is a US county, use the qs:a2_alt for county
// eg - wof:name = 'Lancaster' and qs:a2_alt = 'Lancaster County', use latter
if (isUsCounty(wofData)) {
return getPropertyValue(wofData, 'qs:a2_alt');
}
// attempt to use the following in order of priority and fallback ... | javascript | {
"resource": ""
} |
q52560 | getOfficialLangName | train | function getOfficialLangName(wofData, langProperty) {
var languages = wofData.properties[langProperty];
// convert to array in case it is just a string
if (!(languages instanceof Array)) {
languages = [languages];
}
if (languages.length > 1) {
logger.silly(`more than one ${langProperty} specified`,
... | javascript | {
"resource": ""
} |
q52561 | messageHandler | train | function messageHandler( msg ) {
switch (msg.type) {
case 'load' : return handleLoadMsg(msg);
case 'search' : return handleSearch(msg);
case 'lookupById': return handleLookupById(msg);
default : logger.error('Unknown message:', msg);
}
} | javascript | {
"resource": ""
} |
q52562 | search | train | function search( latLon ){
var poly = context.adminLookup.search( latLon.longitude, latLon.latitude );
return (poly === undefined) ? {} : poly.properties;
} | javascript | {
"resource": ""
} |
q52563 | extractUsernameFromLink | train | function extractUsernameFromLink(steemitLink) {
if (isValidSteemitLink(steemitLink)) {
const usernamePos = steemitLink.search(/\/@.+\//);
if (usernamePos === -1) return;
const firstPart = steemitLink.slice(usernamePos + 2); // adding 2 to remove "/@"
return firstPart.slice(0, firstPart.search('/'));
... | javascript | {
"resource": ""
} |
q52564 | extractPermlinkFromLink | train | function extractPermlinkFromLink(steemitLink) {
if (isValidSteemitLink(steemitLink)) {
const usernamePos = steemitLink.search(/\/@.+\//);
if (usernamePos === -1) return;
const firstPart = steemitLink.slice(usernamePos + 1); // adding 1 to remove the first "/"
return firstPart.slice(firstPart.search('... | javascript | {
"resource": ""
} |
q52565 | _handleErr | train | function _handleErr (err, callback) {
if (callback) {
return callback(err);
} else if (promisesExist) {
return Promise.reject(err);
} else {
throw new Error(err);
}
} | javascript | {
"resource": ""
} |
q52566 | train | function (options, callback) {
if (!options) {
return _handleErr('Search phrase cannot be empty.', callback);
}
return this._request({
api: options.api || 'gifs',
endpoint: 'search',
query: typeof options === 'string' ? {
q: options
} : options
}, callback);
} | javascript | {
"resource": ""
} | |
q52567 | train | function (id, callback) {
var idIsArr = Array.isArray(id);
if (!id || (idIsArr && id.length === 0)) {
return _handleErr('Id required for id API call', callback);
}
// If an array of Id's was passed, generate a comma delimited string for
// the query string.
if (idIsArr) {
id = id.j... | javascript | {
"resource": ""
} | |
q52568 | train | function (options, callback) {
if (!options) {
return _handleErr('Translate phrase cannot be empty.', callback);
}
return this._request({
api: options.api || 'gifs',
endpoint: 'translate',
query: typeof options === 'string' ? {
s: options
} : options
}, callback);
... | javascript | {
"resource": ""
} | |
q52569 | train | function (options, callback) {
var reqOptions = {
api: (options ? options.api : null) || 'gifs',
endpoint: 'random'
};
if (typeof options === 'string') {
reqOptions.query = {
tag: options
};
} else if (typeof options === 'object') {
reqOptions.query = options;
... | javascript | {
"resource": ""
} | |
q52570 | train | function (options, callback) {
var reqOptions = {
endpoint: 'trending'
};
reqOptions.api = (options ? options.api : null) || 'gifs';
// Cleanup so we don't add this to our query
if (options) {
delete options.api;
}
if (typeof options === 'object' &&
Object.keys(options).... | javascript | {
"resource": ""
} | |
q52571 | train | function (options, callback) {
if (!callback && !promisesExist) {
throw new Error('Callback must be provided if promises are unavailable');
}
var endpoint = '';
if (options.endpoint) {
endpoint = '/' + options.endpoint;
}
var query;
var self = this;
if (typeof options.quer... | javascript | {
"resource": ""
} | |
q52572 | spawnPlayer | train | function spawnPlayer (src, out, loop, initialVolume, showOsd) {
let args = buildArgs(src, out, loop, initialVolume, showOsd);
console.log('args for omxplayer:', args);
let omxProcess = spawn('omxplayer', args);
open = true;
omxProcess.stdin.setEncoding('utf-8');
omxProcess.on('close', updateStatus);
om... | javascript | {
"resource": ""
} |
q52573 | BlinkStick | train | function BlinkStick (device, serialNumber, manufacturer, product) {
if (isWin) {
if (device) {
this.device = new usb.HID(device);
this.serial = serialNumber;
this.manufacturer = manufacturer;
this.product = product;
}
} else {
if (device) ... | javascript | {
"resource": ""
} |
q52574 | _determineReportId | train | function _determineReportId(ledCount)
{
var reportId = 9;
var maxLeds = 64;
if (ledCount < 8 * 3) {
reportId = 6;
maxLeds = 8;
} else if (ledCount < 16 * 3) {
reportId = 7;
maxLeds = 16;
} else if (ledCount < 32 * 3) {
reportId = 8;
maxLeds = 32;
... | javascript | {
"resource": ""
} |
q52575 | getInfoBlock | train | function getInfoBlock (device, location, callback) {
getFeatureReport(location, 33, function (err, buffer) {
if (typeof(err) !== 'undefined')
{
callback(err);
return;
}
var result = '',
i, l;
for (i = 1, l = buffer.length; i < l; i++) {
... | javascript | {
"resource": ""
} |
q52576 | opt | train | function opt(options, name, defaultValue){
return options && options[name]!==undefined ? options[name] : defaultValue;
} | javascript | {
"resource": ""
} |
q52577 | setInfoBlock | train | function setInfoBlock (device, location, data, callback) {
var i,
l = Math.min(data.length, 33),
buffer = new Buffer(33);
buffer[0] = 0;
for (i = 0; i < l; i++) buffer[i + 1] = data.charCodeAt(i);
for (i = l; i < 33; i++) buffer[i + 1] = 0;
setFeatureReport(location, buffer, callback);
} | javascript | {
"resource": ""
} |
q52578 | findBlinkSticks | train | function findBlinkSticks (filter) {
if (filter === undefined) filter = function () { return true; };
var result = [], device, i, devices;
if (isWin) {
devices = usb.devices();
for (i in devices) {
device = devices[i];
if (device.vendorId === VENDOR_ID &&
... | javascript | {
"resource": ""
} |
q52579 | train | function () {
if (isWin) {
var devices = findBlinkSticks();
return devices.length > 0 ? devices[0] : null;
} else {
var device = usb.findByIds(VENDOR_ID, PRODUCT_ID);
if (device) return new BlinkStick(device);
}
} | javascript | {
"resource": ""
} | |
q52580 | train | function (callback) {
var result = [];
var devices = findBlinkSticks();
var i = 0;
var finder = function() {
if (i == devices.length) {
if (callback) callback(result);
} else {
devices[i].getSerial(function (err, serial) {
... | javascript | {
"resource": ""
} | |
q52581 | train | function (serial, callback) {
var result = [];
var devices = findBlinkSticks();
var i = 0;
var finder = function() {
if (i == devices.length) {
if (callback) callback();
} else {
devices[i].getSerial(function (err, serialNumber) ... | javascript | {
"resource": ""
} | |
q52582 | getAllChildSpans | train | function getAllChildSpans(node) {
return (
Array.isArray(node.children)
? node.children
.map(n => (n.spans || []).concat(getAllChildSpans(n)))
.reduce((all, arr) => all.concat(arr))
: []
);
} | javascript | {
"resource": ""
} |
q52583 | compileJavascript | train | function compileJavascript(filePath) {
const jsPath = filePath || 'src';
const babelPath = which.sync('babel');
const outFile =
jsPath.endsWith('.js')
? `--out-file ${jsPath.replace('src/', 'dist/')}`
: `-d dist`;
console.log(chalk.cyan(`compling javascript ${chalk.magenta(jsPath)}`));
cp.exec... | javascript | {
"resource": ""
} |
q52584 | compileLess | train | function compileLess() {
console.log(chalk.cyan(`compiling ${chalk.magenta('src/less/hierplane.less')}`));
cp.execSync(`${which.sync('lessc')} --clean-css --autoprefix="last 2 versions" src/less/hierplane.less dist/static/hierplane.min.css`);
console.log(chalk.green(`wrote ${chalk.magenta('dist/static/hierplane.m... | javascript | {
"resource": ""
} |
q52585 | bundleJavascript | train | function bundleJavascript() {
const bundleEntryPath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.js');
const bundlePath = path.resolve(__dirname, '..', 'dist', 'static', 'hierplane.bundle.js');
// Put together our "bundler", which uses browserify
const browserifyOpts = {
entries: [ bundleEn... | javascript | {
"resource": ""
} |
q52586 | iterator | train | function iterator(since) {
if (stop) {
return;
}
var attr = [];
attr.push({ key: 'since', val: since });
attr.push({ key: 'events', val: events });
req({ method: 'events', endpoint: false, attr: attr }).then(function (eventArr) {
//Check for event count on first request iteration
... | javascript | {
"resource": ""
} |
q52587 | handleReq | train | function handleReq(config) {
var authCheck = csrfTokenCheck();
return function (options, callback) {
if (callback) {
authCheck({ config: config, options: options, callback: callback });
} else {
return new Promise(function (resolve, reject) {
authCheck({
config: config,
... | javascript | {
"resource": ""
} |
q52588 | Parser | train | function Parser(config) {
if (!(this instanceof Parser)) return new Parser(config);
this.config = config;
this.config.on('read', function read(type) {
this[type]();
}.bind(this));
} | javascript | {
"resource": ""
} |
q52589 | Orchestrator | train | function Orchestrator(options) {
if (!(this instanceof Orchestrator)) return new Orchestrator(options);
options = options || {};
this.which = options.which || require('which').sync('haproxy');
this.pid = options.pid || '';
this.pidFile = options.pidFile || '';
this.config = options.config;
this.discover... | javascript | {
"resource": ""
} |
q52590 | property | train | function property(fn, arg) {
var base = [ section, name ];
return {
writable: false,
enumerable: false,
value: function () {
if (arg) base.push(arg);
return fn.apply(self, base.concat(
Array.prototype.slice.apply(arguments)
));
}
... | javascript | {
"resource": ""
} |
q52591 | HAProxy | train | function HAProxy(socket, options) {
if (!(this instanceof HAProxy)) return new HAProxy(socket, options);
options = options || {};
//
// Allow variable arguments, with socket path or just custom options.
//
if ('object' === typeof socket) {
options = socket;
socket = options.socket || null;
}
... | javascript | {
"resource": ""
} |
q52592 | SimpleThumbnailGenerator | train | function SimpleThumbnailGenerator(options, generatorOptions) {
options = options || {};
generatorOptions = generatorOptions || {};
if (!options.manifestFileName) {
throw new Error("manifestFileName required.");
}
if (typeof(options.logger) === "undefined") {
this._logger = Logger.get('SimpleThumbnailGenerato... | javascript | {
"resource": ""
} |
q52593 | train | function(newTempo) {
clock.timeStretch(context.currentTime, [freqEvent1, freqEvent2], currentTempo / newTempo)
currentTempo = newTempo
} | javascript | {
"resource": ""
} | |
q52594 | train | function(track, beatInd) {
var event = clock.callbackAtTime(function(event) {
var bufferNode = soundBank[track].createNode()
bufferNode.start(event.deadline)
}, nextBeatTime(beatInd))
event.repeat(barDur)
event.tolerance({late: 0.01})
beats[track][beatInd] = event
} | javascript | {
"resource": ""
} | |
q52595 | train | function(track) {
var request = new XMLHttpRequest()
request.open('GET', 'sounds/' + track + '.wav', true)
request.responseType = 'arraybuffer'
request.onload = function() {
context.decodeAudioData(request.response, function(buffer) {
var createNode = function() {
var node = context.createBuff... | javascript | {
"resource": ""
} | |
q52596 | moveImports | train | function moveImports(code, imports) {
return code.replace(RE_IMPORTS, function (_, indent, imprt) {
imprt = imprt.trim();
if (imprt.slice(-1) !== ';') {
imprt += ';';
}
imports.push(imprt);
return indent; // keep only the indentation
});
} | javascript | {
"resource": ""
} |
q52597 | clonePugOpts | train | function clonePugOpts(opts, filename) {
return PUGPROPS.reduce((o, p) => {
if (p in opts) {
o[p] = clone(opts[p]);
}
return o;
}, { filename });
} | javascript | {
"resource": ""
} |
q52598 | generateData | train | function generateData() {
var firstDate = new Date();
var dataProvider = [];
for (var i = 0; i < 100; ++i) {
var date = new Date(firstDate.getTime());
date.setDate(i);
dataProvider.push({
date: date,
value: Math.floor(Math.random() * 100)
});
}
return dataProvider;
} | javascript | {
"resource": ""
} |
q52599 | train | function(array) {
this.destination = this.parse(array)
// normalize length of arrays
if (this.value.length != this.destination.length) {
var lastValue = this.value[this.value.length - 1]
, lastDestination = this.destination[this.destination.length - 1]
while(this.value.length > t... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.