_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q12400 | lowerCSSInfo | train | function lowerCSSInfo(docDom) {
// read index file, and getting target ts files.
var $scripts = $(docDom).find('link[rel="stylesheet"][href]');
$scripts.each(function () {
| javascript | {
"resource": ""
} |
q12401 | sanitize | train | function sanitize(uri, options) {
options = extend({}, this.options, options);
return new Promise(function(accept, reject) {
var result = {href: null},
isFile, hasProtocol, loadFile, base;
if (uri == null || typeof uri !== 'string') {
reject('Sanitize failure, invalid URI: ' + stringValue(ur... | javascript | {
"resource": ""
} |
q12402 | http | train | function http(url, options) {
return request(url, extend({}, this.options.http, options))
.then(function(response) {
| javascript | {
"resource": ""
} |
q12403 | compile | train | function compile(path, callback) {
if (/\.luax/.test(path)) {
// Load already compiled bytecode
loadBytecode(path);
}
if (/\.lua$/.test(path)) {
luaToBytecode(path, function (err, newpath) {
if (err) return callback(err);
loadBytecode(newpath);
});
}
function loadBytecode(path) {
... | javascript | {
"resource": ""
} |
q12404 | Electronify | train | function Electronify(path, options) {
if (!_isReady) {
app.on("ready", () => Electronify(path, options));
return app;
}
// Defaults
var bwOpts = ul.merge(options, {
width: 800
| javascript | {
"resource": ""
} |
q12405 | _createFPS | train | function _createFPS(context) {
// Render FPS in right-top
var modifier = new Modifier({
align: [1, 0],
origin: [1, 0],
size: [100, 50]
});
| javascript | {
"resource": ""
} |
q12406 | isJSON | train | function isJSON(body) {
if (!body) return false;
if ('string' == typeof body) return false;
if ('function' == typeof body.pipe) return | javascript | {
"resource": ""
} |
q12407 | _createPhotoMarker | train | function _createPhotoMarker(photo) {
var randomAngle = (Math.PI / 180) * (10 - (Math.random() * 20));
var marker = {
mapModifier: new MapModifier({
mapView: mapView,
position: photo.loc
}),
modifier: new StateModifier({
... | javascript | {
"resource": ""
} |
q12408 | _elementIsChildOfMapView | train | function _elementIsChildOfMapView(element) {
if (element.className.indexOf('fm-mapview') >= 0) | javascript | {
"resource": ""
} |
q12409 | TabDirectiveController | train | function TabDirectiveController ($scope) {
var ctrl = this;
ctrl.isActive = function isActive () {
return !!$scope.isActive;
};
ctrl.activate = function activate () {
$scope.tabsCtrl.activate($scope);
| javascript | {
"resource": ""
} |
q12410 | init | train | function init() {
require('dotenv').load();
app.port = process.env.PORT || 3002;
// Default route
app.get('/', function (req, res) {
res.json({
name: 'League of Legends eSports API',
version: "0.9.0",
author: "Robert Manolea ... | javascript | {
"resource": ""
} |
q12411 | vPagesDirectiveController | train | function vPagesDirectiveController ($scope) {
var ctrl = this;
$scope.pages = [];
ctrl.getPagesId = function getPagesId () {
return $scope.id;
};
ctrl.getPageByIndex = function (index) {
return $scope.pages[index];
};
ctrl.getPageIndex = function (page) {
return $scope.pages.indexOf(page);... | javascript | {
"resource": ""
} |
q12412 | parseOutput | train | function parseOutput(str, callback) {
var blocks = str.split('\n\n');
var wifis = [];
var err = null;
try {
if (blocks.length < 2) {
// 2nd try, with \r\n
blocks = str.split('\r\n\r\n')
}
if (!blocks || blocks.length === 1) {
// No WiFis found
return callback(null, []);
... | javascript | {
"resource": ""
} |
q12413 | PageDirectiveController | train | function PageDirectiveController ($scope) {
var ctrl = this;
ctrl.isActive = function isActive () {
return !!$scope.isActive;
};
ctrl.activate = function activate () {
$scope.pagesCtrl.activate($scope);
| javascript | {
"resource": ""
} |
q12414 | initTools | train | function initTools(callback) {
// When a command is not found, an error is issued and async would finish. Therefore we pack
// the error into the result and check it later on.
async.parallel([
function (cb) {
exec(airport.detector, function (err) {
cb(null, {err: err, scanner: airport}
... | javascript | {
"resource": ""
} |
q12415 | scanNetworks | train | function scanNetworks(callback) {
exec(scanner.cmdLine, function (err, stdout) {
if (err) {
callback(err, null);
| javascript | {
"resource": ""
} |
q12416 | train | function (callback) {
if (!scanner) {
initTools(function (err, s) {
if (err) {
| javascript | {
"resource": ""
} | |
q12417 | TOC | train | function TOC(enabled){
if (!(this instanceof TOC)) return new TOC(enabled);
this.enabled = !!enabled;
| javascript | {
"resource": ""
} |
q12418 | Strategy | train | function Strategy(options, verifyPublic) {
if (typeof options == 'function') {
verifyPublic = options;
options = {};
}
if (!verifyPublic) throw new Error('OAuth | javascript | {
"resource": ""
} |
q12419 | newToken | train | function newToken(){ // check if the client has all the tokens
var allRetrieved = true;
var tokens = client.getTokens();
['auth', 'gvx', 'rnr'].forEach(function(type){
if(!tokens.hasOwnProperty(type)){
allRetrieved = false;
}
});
if(allRetrieved){ | javascript | {
"resource": ""
} |
q12420 | getConfigFromBabel | train | function getConfigFromBabel(start, babelrc = '.babelrc') {
if (start === '/') return [];
const packageJSONPath = path.join(start, 'package.json');
const packageJSON = require(packageJSONPath);
const babelConfig = packageJSON.babel;
if (babelConfig) {
const pluginConfig = babelConfig.plugins... | javascript | {
"resource": ""
} |
q12421 | train | function($scope, element, attrs, ctrl) {
$scope.popoverClass = attrs.popoverClass;
$scope.dropDirection = attrs.direction || 'bottom';
var left, top;
var trigger = document.querySelector('#'+$scope.trigger);
var target = document.querySelec... | javascript | {
"resource": ""
} | |
q12422 | train | function(trigger, target){
target.classList.toggle('hide');
var targetWidth = target.offsetWidth;
var targetHeight = target.offsetHeight;
target.classList.toggle('hide');
var triggerWidth = trigger.offsetWidth;
... | javascript | {
"resource": ""
} | |
q12423 | train | function(trigger){
var triggerId;
if(trigger)
triggerId = trigger.getAttribute('id');
var allPopovers = trigger != undefined ? document.querySelectorAll('.ng-popover:not([trigger="'+triggerId+'"])') : document.querySelectorAll('.ng-popover');
for(var i =0; i<allPopovers.leng... | javascript | {
"resource": ""
} | |
q12424 | heapify | train | function heapify(heap, i) {
var l = getLeft(i);
var r = getRight(i);
var smallest = i;
if (l < heap.list.length &&
heap.compare(heap.list[l], heap.list[i]) < 0) {
smallest = l;
}
if (r < | javascript | {
"resource": ""
} |
q12425 | buildHeapFromNodeArray | train | function buildHeapFromNodeArray(heap, nodeArray) {
heap.list = nodeArray;
for (var | javascript | {
"resource": ""
} |
q12426 | train | function() {
var this_ = this;
this.msg = (typeof this.options.select_message == 'string'?
document.getElementById(this.options.select_message):
this.options.select_message);
this.close_button = this.get_close_button();
this.msg_autoclose = null;
... | javascript | {
"resource": ""
} | |
q12427 | train | function () {
var body = this.body;
var el = this.el;
el.setAttribute('position', body.position);
| javascript | {
"resource": ""
} | |
q12428 | train | function(numclasses) {
for (var i = numclasses.length; i--;) {
var numclass = numclasses[i];
var spans = byClassName(this.selectable, numclass);
var closewrap = firstWithClass(spans[spans.length - 1], 'closewrap');
| javascript | {
"resource": ""
} | |
q12429 | create | train | function create(type, constructor) {
return function scale() {
var s = constructor();
if (!s.invertRange) {
s.invertRange = s.invert ? invertRange(s)
| javascript | {
"resource": ""
} |
q12430 | parserFabric | train | function parserFabric(mode, format) {
return function (value, parseFn) {
parseFn = parseFn || moment_1.utc;
if (value === null || value === undefined || value === "") {
return null;
}
| javascript | {
"resource": ""
} |
q12431 | runAndWatch | train | function runAndWatch(watchPattern, initialValue, task) {
gulp.watch(watchPattern, | javascript | {
"resource": ""
} |
q12432 | lintFiles | train | function lintFiles(pattern, strict, configs) {
const linter = new eslint.CLIEngine(configs);
const report = linter.executeOnFiles([pattern]);
const formatter = linter.getFormatter();
console.log(formatter(report.results)); | javascript | {
"resource": ""
} |
q12433 | forEach | train | function forEach(parameters, dIt = global.it, dDescribe = global.describe) {
const it = makeTestCaseDefiner(parameters, dIt);
it.skip = makeParameterizedSkip(parameters, dIt);
| javascript | {
"resource": ""
} |
q12434 | makeParameterizedOnly | train | function makeParameterizedOnly(parameters, defaultIt) {
return function(title, test) {
const it = makeTestCaseDefiner(parameters, | javascript | {
"resource": ""
} |
q12435 | monthCalendar | train | function monthCalendar(date) {
var start = date.clone().startOf("month").startOf("week").startOf("day");
var end = date.clone().endOf("month").endOf("week").startOf("day");
| javascript | {
"resource": ""
} |
q12436 | daysOfWeek | train | function daysOfWeek() {
var result = [];
for (var weekday = 0; weekday < 7; weekday++) {
| javascript | {
"resource": ""
} |
q12437 | assignDeclarationToGlobal | train | function assignDeclarationToGlobal(state, nodes, declaration) {
var filenameNoExt = getFilenameNoExt(state.file.opts.filename); | javascript | {
"resource": ""
} |
q12438 | assignToGlobal | train | function assignToGlobal(expr, nodes, expression) {
createGlobal(expr, nodes);
if (!t.isExpression(expression)) {
expression = t.toExpression(expression);
}
| javascript | {
"resource": ""
} |
q12439 | createGlobal | train | function createGlobal(expr, nodes, opt_namedPartial) {
var exprs = [];
while (t.isMemberExpression(expr)) {
exprs.push(expr);
expr = expr.object;
}
var currGlobalName = '';
for (var i = exprs.length - 2; opt_namedPartial ? i >= 0 : i > 0; i--) {
currGlobalName += '.' + exprs[i].pr... | javascript | {
"resource": ""
} |
q12440 | getGlobalExpression | train | function getGlobalExpression(state, filePath, name, opt_isWildcard) {
assertFilenameRequired(state.file.opts.filename);
var globalName = state.opts.globalName;
var id;
if (typeof globalName === 'function') {
id = globalName(state, filePath, name, opt_isWildcard);
}
else {
if (name ... | javascript | {
"resource": ""
} |
q12441 | removeExtensions | train | function removeExtensions(filename) {
var extension = path.extname(filename);
while (extension !== '') {
| javascript | {
"resource": ""
} |
q12442 | train | function(nodePath) {
createdGlobals = {};
filenameNoExtCache = null;
var node = nodePath.node;
var contents = node.body;
node.body = [t.expressionStatement(t.callExpression(
t.memberExpression(
| javascript | {
"resource": ""
} | |
q12443 | train | function(nodePath, state) {
var replacements = [];
if ( nodePath.node.source.value.match(/^[\./]/) ) {
nodePath.node.specifiers.forEach(function(specifier) {
var expr = getGlobalExpression(
state,
removeExtensions(nodePath.node.source.value),
... | javascript | {
"resource": ""
} | |
q12444 | train | function(nodePath, state) {
var replacements = [];
var expr = getGlobalExpression(state, getFilenameNoExt(state.file.opts.filename));
var expression = nodePath.node.declaration;
if (expression.id &&
(t.isFunctionDeclaration(expression) || t.isClassDeclaration(expression))) {
... | javascript | {
"resource": ""
} | |
q12445 | train | function(nodePath, state) {
var replacements = [];
var node = nodePath.node;
if (node.declaration) {
replacements.push(node.declaration);
if (t.isVariableDeclaration(node.declaration)) {
node.declaration.declarations.forEach(assignDeclarationToGlobal.bind(null, st... | javascript | {
"resource": ""
} | |
q12446 | defineAttributes | train | function defineAttributes(object, attributes) {
if (object instanceof Parse.Object) {
if (!(attributes instanceof Array)) attributes = Array.prototype.slice.call(arguments, 1);
attributes.forEach(function (attribute) {
Object.defineProperty(object, attribute, {
get: function () {
... | javascript | {
"resource": ""
} |
q12447 | wrapParsePromise | train | function wrapParsePromise(promise, parsePromise) {
['_rejected', '_rejectedCallbacks', '_resolved', '_resolvedCallbacks', '_result', 'reject', 'resolve']
.forEach(function (prop) {
promise[prop] = parsePromise[prop];
});
['_continueWith', '_thenRunCallbacks', 'always', 'done', 'fa... | javascript | {
"resource": ""
} |
q12448 | wrap | train | function wrap(func) {
return function wrappedParsePromise() {
var args = Array.prototype.slice.call(arguments, 0);
var parsePromise = func.apply(this, args);
var | javascript | {
"resource": ""
} |
q12449 | wrapObject | train | function wrapObject(object, methods) {
if (!(methods instanceof Array)) methods = Array.prototype.slice.call(arguments, | javascript | {
"resource": ""
} |
q12450 | eatUnquoted | train | function eatUnquoted(stream) {
const start = stream.pos;
if (stream.eatWhile(isUnquoted)) { | javascript | {
"resource": ""
} |
q12451 | doSubmit | train | function doSubmit() {
// make sure form attrs are set
var t = $form.attr('target'), a = $form.attr('action');
// update form attrs in IE friendly way
form.setAttribute('target',id);
if (!method) {
form.setAttribute('method', 'POST');
... | javascript | {
"resource": ""
} |
q12452 | checkState | train | function checkState() {
try {
var state = getDoc(io).readyState;
log('state = ' + state);
if (state && state.toLowerCase() == 'uninitialized')
setTimeout(checkState,50);
}
catch(e) {
... | javascript | {
"resource": ""
} |
q12453 | doAjaxSubmit | train | function doAjaxSubmit(e) {
/*jshint validthis:true */
var options = e.data;
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed | javascript | {
"resource": ""
} |
q12454 | train | function (properties, rule, options) {
var signature = rule.selector || rule.params;
var name = signature.match(customPropertyPattern).shift().replace(propertyKeyDelimiter, '').trim();
var parameters = signature.replace(customPropertyPattern, '').match(parametersPattern).map(function (parameter) {
return para... | javascript | {
"resource": ""
} | |
q12455 | train | function (customProperty, declaration) {
customProperty.declarations.forEach(function (customDeclaration) {
// No need to copy value here as replace will copy value
var value = customDeclaration.value;
// Replace parameter variables with user given values
customDeclaration.variables.forEach(function ... | javascript | {
"resource": ""
} | |
q12456 | abort | train | function abort(options = {}) {
if (process.platform !== 'win32' && process.platform !== 'linux') {
throw new Error('Unsupported OS (only Windows and Linux are supported)!');
}
let cmdarguments = ['shutdown'];
if (process.platform === 'win32') {
cmdarguments.push('-a'); // a... | javascript | {
"resource": ""
} |
q12457 | setTimer | train | function setTimer(timervalue) {
let cmdarguments = [];
if (process.platform === 'linux' ) {
if (timervalue) {
cmdarguments.push(timervalue.toString());
} else {
cmdarguments.push('now');
}
}
if (process.platform === 'darwin') {
if... | javascript | {
"resource": ""
} |
q12458 | getActualTarget | train | function getActualTarget() {
var scrollX = window.scrollX,
scrollY = window.scrollY;
// IE is stupid and doesn't support scrollX/Y
if(scrollX === undefined){
scrollX = d.body.scrollLeft;
| javascript | {
"resource": ""
} |
q12459 | defaultLogger | train | function defaultLogger() {
if(!_defaultLogger) {
var prefix = 'master';
if(cluster.worker) {
prefix = 'work ' + cluster.worker.id;
}
| javascript | {
"resource": ""
} |
q12460 | typeOf | train | function typeOf(value) {
var s = typeof value;
if(s === 'object') {
if(value) {
if(value instanceof Array) {
| javascript | {
"resource": ""
} |
q12461 | treatAs | train | function treatAs(value) {
var s = typeof value;
if(s === 'object') {
if(value) {
return Object.prototype.toString.call(value).match(/^\[object\s(.*)\]$/)[1];
| javascript | {
"resource": ""
} |
q12462 | toInteger | train | function toInteger(val) {
var v = +val;// toNumber conversion
if(isNaN(v)) {
return 0;
}
if(v | javascript | {
"resource": ""
} |
q12463 | UnknownReference | train | function UnknownReference(id, prop, missing) {
this._id = id;
| javascript | {
"resource": ""
} |
q12464 | train | function (obj, prop, value) {
shared.utils.dassert(getTracker(obj) === this);
| javascript | {
"resource": ""
} | |
q12465 | train | function (obj) {
shared.utils.dassert(getTracker(obj) === this);
this._rev += 1;
this._type | javascript | {
"resource": ""
} | |
q12466 | MongoStore | train | function MongoStore(options) {
if (typeof options === "undefined") { options = {
}; }
_super.call(this);
this._logger = shared.utils.defaultLogger();
// Database stuff
this._collection = null;
... | javascript | {
"resource": ""
} |
q12467 | saveFile | train | function saveFile(html) {
fs.outputFile(options.outputFile, html, function(err, data) {
if (err) {
console.log(error('ERROR!'));
console.dir(err);
process.exit(1);
| javascript | {
"resource": ""
} |
q12468 | doTemplating | train | function doTemplating(json) {
// Adding '#styleguide .hljs pre' to highlight css, to override common used styling for 'pre'
highlightSource = highlightSource.replace('.hljs {', '#styleguide .hljs pre, .hljs {');
handlebars.registerPartial("jquery", '<script>\n' + jqSource+ '\n</script>');
handlebars.registerPartia... | javascript | {
"resource": ""
} |
q12469 | Seeker | train | function Seeker(cron, now) {
if (cron.parts === null) {
throw new Error('No schedule found');
}
var date;
if (cron.options.timezone) {
date = moment.tz(now, cron.options.timezone);
} else {
date = moment(now);
}
if (!date.isValid()) {
throw new Error('Invalid date provided');
}
if (dat... | javascript | {
"resource": ""
} |
q12470 | train | function(parts, date, reverse) {
var operation = 'add';
var reset = 'startOf';
if (reverse) {
operation = 'subtract';
reset = 'endOf';
date.subtract(1, 'minute'); // Ensure prev and next cannot be same time
}
var retry = 24;
while (--retry) {
shiftMonth(parts, date, operation, reset);
va... | javascript | {
"resource": ""
} | |
q12471 | DebugLog | train | function DebugLog(msg)
{
console.log("[PSN] :: | javascript | {
"resource": ""
} |
q12472 | GetHeaders | train | function GetHeaders(additional_headers)
{
var ret_headers = {};
// clone default headers into our return object (parsed)
for(var key in headers)
{
ret_headers[key] = ParseStaches(headers[key]);
}
// add accept-language header based on our language
ret_headers['Accept-Language'] = auth_obj.npLanguage ... | javascript | {
"resource": ""
} |
q12473 | GetOAuthData | train | function GetOAuthData(additional_fields)
{
var ret_fields = {};
// clone base oauth settings
for(var key in oauth_settings)
{
ret_fields[key] = ParseStaches(oauth_settings[key]);
}
// add additional fields (if supplied)
if (additional_fields) for(var | javascript | {
"resource": ""
} |
q12474 | URLGET | train | function URLGET(url, fields, method, callback)
{
// method variable is optional
if (typeof method == "function")
{
callback = method;
method = "GET";
}
_URLGET(url, fields, GetHeaders({"Access-Control-Request-Method": method}), method, function(err, body) {
if (err)
{
// got error, bounce it... | javascript | {
"resource": ""
} |
q12475 | Login | train | function Login(callback)
{
Log("Making OAuth Request...");
// start OAuth request (use our internal GET function as this is different!)
_URLGET(
// URL
urls.login_base + "/2.0/oauth/authorize",
// query string
GetOAuthData({
response_type: "code",
service_entity: "urn:service-entity:psn",
... | javascript | {
"resource": ""
} |
q12476 | GetAccessToken | train | function GetAccessToken(callback)
{
// do we have a refresh token? Or do we need to login from scratch?
if (auth_obj.refresh_token)
{
// we have a refresh token!
Log("Refreshing session...");
if (!auth_obj.refresh_token)
{
if (callback) callback("No refresh token found!");
return;
}
/... | javascript | {
"resource": ""
} |
q12477 | GetUserData | train | function GetUserData(callback)
{
Log("Fetching user profile data");
// get the current user's data
parent.Get("https://vl.api.np.km.playstation.net/vl/api/v1/mobile/users/me/info", {}, function(error, data)
{
if (error)
{
Log("Error fetching user profile: " + error);
if (callback) callback("Erro... | javascript | {
"resource": ""
} |
q12478 | CheckTokens | train | function CheckTokens(callback, token_fetch)
{
// build list of tokens we're missing
var todo = [];
// force token_fetch to an array
token_fetch = [].concat(token_fetch);
// make sure we're actually logged in first
if (!auth_obj.auth_code)
{
Log("Need to login - no auth token found");
todo.push({n... | javascript | {
"resource": ""
} |
q12479 | train | function()
{
var func = todo.shift();
if (!func)
{
// all done!
if (callback) callback(false);
return;
}
if (token_fetch.indexOf(func.func) >= 0)
{
// if we're actually calling a token fetch function, skip!
process.nextTick(step);
}
else
{
func.func(... | javascript | {
"resource": ""
} | |
q12480 | MakePSNRequest | train | function MakePSNRequest(method, url, fields, callback, token_fetch)
{
// use fields var as callback if it's missed out
if (typeof fields == "function")
{
token_fetch = false;
callback = fields;
fields = {};
}
else if (typeof method == "function")
{
token_fetch = false;
callback = method;
}... | javascript | {
"resource": ""
} |
q12481 | Ready | train | function Ready()
{
if (options.autoconnect)
{
// make a connection request immediately (optional)
parent.GetPSN(true, function() {
| javascript | {
"resource": ""
} |
q12482 | squaredEuclideanDistance | train | function squaredEuclideanDistance (point1, point2) {
var result = 0,
i = 0;
for (; i < point1.length; i++) {
| javascript | {
"resource": ""
} |
q12483 | getNeighbourhood | train | function getNeighbourhood (dimensionNumber) {
var neighbourhood = moore(2, dimensionNumber),
origin = [],
dimension;
for (dimension = 0; dimension < dimensionNumber; dimension++) {
origin.push(0);
}
neighbourhood.push(origin);
// sort by ascending distance to optimize prox... | javascript | {
"resource": ""
} |
q12484 | provide | train | function provide() {
if (console) console.warn('@provide is now deprecated. | javascript | {
"resource": ""
} |
q12485 | parseNodeValue | train | function parseNodeValue(node) {
const childNodes = node && node.childNodes && [...node.childNodes];
if (!childNodes) {
return {};
}
// Trying to find and parse CDATA as JSON
const cdatas = childNodes.filter((childNode) => childNode.nodeName === '#cdata-section');
if (cdatas && cdatas.length > 0) {
... | javascript | {
"resource": ""
} |
q12486 | parseXMLNode | train | function parseXMLNode(node) {
const parsedNode = {
attributes: {},
children: {},
value: {},
};
parsedNode.value = parseNodeValue(node);
if (node.attributes) {
[...node.attributes].forEach((nodeAttr) => {
if (nodeAttr.nodeName && nodeAttr.nodeValue !== undefined && nodeAttr.nodeValue !== ... | javascript | {
"resource": ""
} |
q12487 | async | train | function async(makeGenerator) {
return () => {
const generator = makeGenerator(...arguments);
function handle(result) {
// result => { done: [Boolean], value: [Object] }
if (result.done) {
return Promise.resolve(result.value);
}
return Promise.resolve(result.value).then(res =... | javascript | {
"resource": ""
} |
q12488 | runMultiple | train | function runMultiple(input, options) {
return new Promise((resolve, reject) => {
let commands = input;
// set default options
const defaultOpts = {
cwd: process.cwd(),
verbose: DEFAULT_VERBOSE,
mode: SEQUENTIAL,
logger: console.log,
};
// set global options
const globa... | javascript | {
"resource": ""
} |
q12489 | itemsForCounter | train | function itemsForCounter(flushInterval, host, key, value) {
const avg = value / (flushInterval / 1000); // calculate "per second" | javascript | {
"resource": ""
} |
q12490 | itemsForTimer | train | function itemsForTimer(percentiles, host, key, data) {
const values = data.sort((a, b) => (a - b));
const count = values.length;
const min = values[0];
const max = values[count - 1];
let mean = min;
let maxAtThreshold = max;
const items = [
{
host,
key: `${key}[lower]`,
value: min ... | javascript | {
"resource": ""
} |
q12491 | flush | train | function flush(targetBuilder, sender, flushInterval, timestamp, metrics) {
debug(`starting flush for timestamp ${timestamp}`);
const flushStart = tsNow();
const handle = (processor, stat, value) => {
try {
const { host, key } = targetBuilder(stat);
processor(host, key, value).forEach((item) => {
... | javascript | {
"resource": ""
} |
q12492 | status | train | function status(writeCb) {
Object.keys(stats).forEach((stat) | javascript | {
"resource": ""
} |
q12493 | init | train | function init(startupTime, config, events, l) {
logger = l;
let targetBuilder;
if (config.zabbixTargetHostname) {
targetBuilder = targetStatic.bind(undefined, config.zabbixTargetHostname);
} else {
targetBuilder = targetDecode;
}
const sender = new ZabbixSender({
host: config.zabbixHost || 'lo... | javascript | {
"resource": ""
} |
q12494 | collectProperties | train | function collectProperties(groups, properties) {
var collection = {};
for (var key in groups) {
if (Array.isArray(groups[key])) {
collection[key] = groups[key].reduce(function(coll, item) {
properties.forEach(function(prop) {
if (!coll[prop]) coll[prop] = [];
coll[prop] = | javascript | {
"resource": ""
} |
q12495 | fileUriToPath | train | function fileUriToPath (uri) {
if ('string' != typeof uri ||
uri.length <= 7 ||
'file://' != uri.substring(0, 7)) {
throw new TypeError('must pass in a file:// URI to convert to a file path');
}
var rest = decodeURI(uri.substring(7));
var firstSlash = rest.indexOf('/');
var host = rest.substr... | javascript | {
"resource": ""
} |
q12496 | parseHeaders | train | function parseHeaders() {
var str = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
var lines = str.split(/\r?\n/);
var fields = {};
var index = undefined;
var line = undefined;
var field = undefined;
var val = undefined;
lines.pop(); // trailing CRLF
for (var i = 0, len = ... | javascript | {
"resource": ""
} |
q12497 | buildHashTimeLockContract | train | function buildHashTimeLockContract(network, xHash, destH160Addr, revokerH160Addr, lockTime) {
const bitcoinNetwork = bitcoin.networks[network];
const redeemScript = bitcoin.script.compile([
bitcoin.opcodes.OP_IF,
bitcoin.opcodes.OP_SHA256,
Buffer.from(xHash, 'hex'),
bitcoin.opcodes.OP_EQUALVERIFY,
... | javascript | {
"resource": ""
} |
q12498 | hashForRedeemSig | train | function hashForRedeemSig(network, txid, address, value, redeemScript) {
const tx = btcUtil.buildIncompleteRedeem(network, txid, address, value);
const sigHash = tx.hashForSignature(
0,
new | javascript | {
"resource": ""
} |
q12499 | hashForRevokeSig | train | function hashForRevokeSig(network, txid, address, value, lockTime, redeemScript) {
const tx = btcUtil.buildIncompleteRevoke(network, txid, address, value, lockTime);
const sigHash = tx.hashForSignature(
0,
| javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.