id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1 value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,600 | anywhichway/tlx | benchmarks/dbmon/lib/monitor.js | startMemMonitor | function startMemMonitor() {
checkInit();
if (performance.memory !== void 0) {
(function () {
var update = function update() {
data.addSample(Math.round(mem.usedJSHeapSize / (1024 * 1024)));
w.addResult(data.calc());
setTimeout(update, 30);
};
var data = new Data();
var w = new MonitorWidget("Memory", "MB", 1 /* HideMin */ | 4 /* HideMean */);
container.appendChild(w.element);
var mem = performance.memory;
update();
})();
}
} | javascript | function startMemMonitor() {
checkInit();
if (performance.memory !== void 0) {
(function () {
var update = function update() {
data.addSample(Math.round(mem.usedJSHeapSize / (1024 * 1024)));
w.addResult(data.calc());
setTimeout(update, 30);
};
var data = new Data();
var w = new MonitorWidget("Memory", "MB", 1 /* HideMin */ | 4 /* HideMean */);
container.appendChild(w.element);
var mem = performance.memory;
update();
})();
}
} | [
"function",
"startMemMonitor",
"(",
")",
"{",
"checkInit",
"(",
")",
";",
"if",
"(",
"performance",
".",
"memory",
"!==",
"void",
"0",
")",
"{",
"(",
"function",
"(",
")",
"{",
"var",
"update",
"=",
"function",
"update",
"(",
")",
"{",
"data",
".",
"addSample",
"(",
"Math",
".",
"round",
"(",
"mem",
".",
"usedJSHeapSize",
"/",
"(",
"1024",
"*",
"1024",
")",
")",
")",
";",
"w",
".",
"addResult",
"(",
"data",
".",
"calc",
"(",
")",
")",
";",
"setTimeout",
"(",
"update",
",",
"30",
")",
";",
"}",
";",
"var",
"data",
"=",
"new",
"Data",
"(",
")",
";",
"var",
"w",
"=",
"new",
"MonitorWidget",
"(",
"\"Memory\"",
",",
"\"MB\"",
",",
"1",
"/* HideMin */",
"|",
"4",
"/* HideMean */",
")",
";",
"container",
".",
"appendChild",
"(",
"w",
".",
"element",
")",
";",
"var",
"mem",
"=",
"performance",
".",
"memory",
";",
"update",
"(",
")",
";",
"}",
")",
"(",
")",
";",
"}",
"}"
] | Start Memory Monitor | [
"Start",
"Memory",
"Monitor"
] | 732bc3828d2333ea757b8772e8e6b7a6b4070637 | https://github.com/anywhichway/tlx/blob/732bc3828d2333ea757b8772e8e6b7a6b4070637/benchmarks/dbmon/lib/monitor.js#L237-L255 |
23,601 | anywhichway/tlx | benchmarks/dbmon/lib/monitor.js | initProfiler | function initProfiler(name) {
checkInit();
var profiler = profilerInstances[name];
if (profiler === void 0) {
profilerInstances[name] = profiler = new Profiler(name, "ms");
container.appendChild(profiler.widget.element);
}
} | javascript | function initProfiler(name) {
checkInit();
var profiler = profilerInstances[name];
if (profiler === void 0) {
profilerInstances[name] = profiler = new Profiler(name, "ms");
container.appendChild(profiler.widget.element);
}
} | [
"function",
"initProfiler",
"(",
"name",
")",
"{",
"checkInit",
"(",
")",
";",
"var",
"profiler",
"=",
"profilerInstances",
"[",
"name",
"]",
";",
"if",
"(",
"profiler",
"===",
"void",
"0",
")",
"{",
"profilerInstances",
"[",
"name",
"]",
"=",
"profiler",
"=",
"new",
"Profiler",
"(",
"name",
",",
"\"ms\"",
")",
";",
"container",
".",
"appendChild",
"(",
"profiler",
".",
"widget",
".",
"element",
")",
";",
"}",
"}"
] | Initialize profiler and insert into container | [
"Initialize",
"profiler",
"and",
"insert",
"into",
"container"
] | 732bc3828d2333ea757b8772e8e6b7a6b4070637 | https://github.com/anywhichway/tlx/blob/732bc3828d2333ea757b8772e8e6b7a6b4070637/benchmarks/dbmon/lib/monitor.js#L283-L290 |
23,602 | caseyyee/aframe-ui-widgets | src/button.js | function (evt) {
var threshold = 30;
if (!this.pressed) {
this.pressed = true;
this.emit('touchdown');
var self = this;
this.interval = setInterval(function() {
var delta = performance.now() - self.lastTime;
if (delta > threshold) {
self.pressed = false;
self.lastTime = 0;
self.emit('touchup');
clearInterval(self.interval);
}
}, threshold);
}
this.lastTime = performance.now();
} | javascript | function (evt) {
var threshold = 30;
if (!this.pressed) {
this.pressed = true;
this.emit('touchdown');
var self = this;
this.interval = setInterval(function() {
var delta = performance.now() - self.lastTime;
if (delta > threshold) {
self.pressed = false;
self.lastTime = 0;
self.emit('touchup');
clearInterval(self.interval);
}
}, threshold);
}
this.lastTime = performance.now();
} | [
"function",
"(",
"evt",
")",
"{",
"var",
"threshold",
"=",
"30",
";",
"if",
"(",
"!",
"this",
".",
"pressed",
")",
"{",
"this",
".",
"pressed",
"=",
"true",
";",
"this",
".",
"emit",
"(",
"'touchdown'",
")",
";",
"var",
"self",
"=",
"this",
";",
"this",
".",
"interval",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"var",
"delta",
"=",
"performance",
".",
"now",
"(",
")",
"-",
"self",
".",
"lastTime",
";",
"if",
"(",
"delta",
">",
"threshold",
")",
"{",
"self",
".",
"pressed",
"=",
"false",
";",
"self",
".",
"lastTime",
"=",
"0",
";",
"self",
".",
"emit",
"(",
"'touchup'",
")",
";",
"clearInterval",
"(",
"self",
".",
"interval",
")",
";",
"}",
"}",
",",
"threshold",
")",
";",
"}",
"this",
".",
"lastTime",
"=",
"performance",
".",
"now",
"(",
")",
";",
"}"
] | handles hand controller collisions | [
"handles",
"hand",
"controller",
"collisions"
] | 44f3538ceee79fa4d5adc381400053b3354a9618 | https://github.com/caseyyee/aframe-ui-widgets/blob/44f3538ceee79fa4d5adc381400053b3354a9618/src/button.js#L125-L142 | |
23,603 | mfix22/gest | src/util.js | readDir | function readDir (dir, regex = /^(?:)$/) {
return new Promise((resolve, reject) =>
fs.readdir(dir, (err, files) => err
? reject(err)
: resolve(Promise.all(files.map(checkFileName.bind(null, dir, regex))))))
.then(values =>
[].concat(...values)
.filter(i => i))
} | javascript | function readDir (dir, regex = /^(?:)$/) {
return new Promise((resolve, reject) =>
fs.readdir(dir, (err, files) => err
? reject(err)
: resolve(Promise.all(files.map(checkFileName.bind(null, dir, regex))))))
.then(values =>
[].concat(...values)
.filter(i => i))
} | [
"function",
"readDir",
"(",
"dir",
",",
"regex",
"=",
"/",
"^(?:)$",
"/",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"fs",
".",
"readdir",
"(",
"dir",
",",
"(",
"err",
",",
"files",
")",
"=>",
"err",
"?",
"reject",
"(",
"err",
")",
":",
"resolve",
"(",
"Promise",
".",
"all",
"(",
"files",
".",
"map",
"(",
"checkFileName",
".",
"bind",
"(",
"null",
",",
"dir",
",",
"regex",
")",
")",
")",
")",
")",
")",
".",
"then",
"(",
"values",
"=>",
"[",
"]",
".",
"concat",
"(",
"...",
"values",
")",
".",
"filter",
"(",
"i",
"=>",
"i",
")",
")",
"}"
] | regex defaults to empty | [
"regex",
"defaults",
"to",
"empty"
] | c15dd6208b97109a73cada617484988c1844241b | https://github.com/mfix22/gest/blob/c15dd6208b97109a73cada617484988c1844241b/src/util.js#L101-L109 |
23,604 | yuanchuan/markdown-preview | lib/check.js | check | function check(filename) {
this.filename = filename && path.resolve(filename) || '';
this.types = [];
this.valid = null;
} | javascript | function check(filename) {
this.filename = filename && path.resolve(filename) || '';
this.types = [];
this.valid = null;
} | [
"function",
"check",
"(",
"filename",
")",
"{",
"this",
".",
"filename",
"=",
"filename",
"&&",
"path",
".",
"resolve",
"(",
"filename",
")",
"||",
"''",
";",
"this",
".",
"types",
"=",
"[",
"]",
";",
"this",
".",
"valid",
"=",
"null",
";",
"}"
] | Initialize a new `check` with the given filename.
@param {String} filename
@api private | [
"Initialize",
"a",
"new",
"check",
"with",
"the",
"given",
"filename",
"."
] | 173c44f7cea1f579fa2d54773579ad80863ea8b9 | https://github.com/yuanchuan/markdown-preview/blob/173c44f7cea1f579fa2d54773579ad80863ea8b9/lib/check.js#L26-L30 |
23,605 | yuanchuan/markdown-preview | lib/server.js | handler | function handler(req, res) {
var parsedUrl = url.parse(req.url)
var callback = qs.parse(parsedUrl.query).callback
var filename = decodeURI(parsedUrl.path.substr(1).split('?')[0])
var basename = path.basename(filename.split('?')[0])
var extname = path.extname(basename)
var response = reswrap(res);
var notfound = function() {
response.writeHead(404, 'text').end('');
};
if (req.method === 'GET' && parsedUrl.pathname === '/jsonp-request') {
if (!!exitCountdown) {
exitCountdown.restart();
}
response
.writeHead(200, 'js')
.end(callback +'('+ R.get('stamp') +')');
return;
}
var serve;
if (/^\/template/.test(parsedUrl.pathname)) {
serve = check(join(__dirname, '..', filename))
} else if (/^\/node_modules/.test(parsedUrl.pathname)) {
serve = check(join(__dirname, '..', filename))
}
if (serve) {
serve.pass(function(name, type) {
response
.writeHead(200, extname.substr(1))
.pipeWith(fs.createReadStream(
path.resolve(name)
))
}).fail(notfound);
return;
}
if (/^\.(md|mkd|markdown|html)$/.test(extname)) {
check(filename)
.pass(function() {
response
.writeHead(200, 'html')
.end(template.render({
title: basename,
highlight: R.get('highlight') || 'default',
theme: getTheme(R.get('css')),
width: R.get('width'),
body: parser.parse(read(path.resolve(filename)))
}));
}).fail(notfound);
return;
}
// Image or some other resources.
check(filename)
.pass(function(name) {
response
.writeHead(200, name)
.pipeWith(fs.createReadStream(name));
}).fail(notfound)
} | javascript | function handler(req, res) {
var parsedUrl = url.parse(req.url)
var callback = qs.parse(parsedUrl.query).callback
var filename = decodeURI(parsedUrl.path.substr(1).split('?')[0])
var basename = path.basename(filename.split('?')[0])
var extname = path.extname(basename)
var response = reswrap(res);
var notfound = function() {
response.writeHead(404, 'text').end('');
};
if (req.method === 'GET' && parsedUrl.pathname === '/jsonp-request') {
if (!!exitCountdown) {
exitCountdown.restart();
}
response
.writeHead(200, 'js')
.end(callback +'('+ R.get('stamp') +')');
return;
}
var serve;
if (/^\/template/.test(parsedUrl.pathname)) {
serve = check(join(__dirname, '..', filename))
} else if (/^\/node_modules/.test(parsedUrl.pathname)) {
serve = check(join(__dirname, '..', filename))
}
if (serve) {
serve.pass(function(name, type) {
response
.writeHead(200, extname.substr(1))
.pipeWith(fs.createReadStream(
path.resolve(name)
))
}).fail(notfound);
return;
}
if (/^\.(md|mkd|markdown|html)$/.test(extname)) {
check(filename)
.pass(function() {
response
.writeHead(200, 'html')
.end(template.render({
title: basename,
highlight: R.get('highlight') || 'default',
theme: getTheme(R.get('css')),
width: R.get('width'),
body: parser.parse(read(path.resolve(filename)))
}));
}).fail(notfound);
return;
}
// Image or some other resources.
check(filename)
.pass(function(name) {
response
.writeHead(200, name)
.pipeWith(fs.createReadStream(name));
}).fail(notfound)
} | [
"function",
"handler",
"(",
"req",
",",
"res",
")",
"{",
"var",
"parsedUrl",
"=",
"url",
".",
"parse",
"(",
"req",
".",
"url",
")",
"var",
"callback",
"=",
"qs",
".",
"parse",
"(",
"parsedUrl",
".",
"query",
")",
".",
"callback",
"var",
"filename",
"=",
"decodeURI",
"(",
"parsedUrl",
".",
"path",
".",
"substr",
"(",
"1",
")",
".",
"split",
"(",
"'?'",
")",
"[",
"0",
"]",
")",
"var",
"basename",
"=",
"path",
".",
"basename",
"(",
"filename",
".",
"split",
"(",
"'?'",
")",
"[",
"0",
"]",
")",
"var",
"extname",
"=",
"path",
".",
"extname",
"(",
"basename",
")",
"var",
"response",
"=",
"reswrap",
"(",
"res",
")",
";",
"var",
"notfound",
"=",
"function",
"(",
")",
"{",
"response",
".",
"writeHead",
"(",
"404",
",",
"'text'",
")",
".",
"end",
"(",
"''",
")",
";",
"}",
";",
"if",
"(",
"req",
".",
"method",
"===",
"'GET'",
"&&",
"parsedUrl",
".",
"pathname",
"===",
"'/jsonp-request'",
")",
"{",
"if",
"(",
"!",
"!",
"exitCountdown",
")",
"{",
"exitCountdown",
".",
"restart",
"(",
")",
";",
"}",
"response",
".",
"writeHead",
"(",
"200",
",",
"'js'",
")",
".",
"end",
"(",
"callback",
"+",
"'('",
"+",
"R",
".",
"get",
"(",
"'stamp'",
")",
"+",
"')'",
")",
";",
"return",
";",
"}",
"var",
"serve",
";",
"if",
"(",
"/",
"^\\/template",
"/",
".",
"test",
"(",
"parsedUrl",
".",
"pathname",
")",
")",
"{",
"serve",
"=",
"check",
"(",
"join",
"(",
"__dirname",
",",
"'..'",
",",
"filename",
")",
")",
"}",
"else",
"if",
"(",
"/",
"^\\/node_modules",
"/",
".",
"test",
"(",
"parsedUrl",
".",
"pathname",
")",
")",
"{",
"serve",
"=",
"check",
"(",
"join",
"(",
"__dirname",
",",
"'..'",
",",
"filename",
")",
")",
"}",
"if",
"(",
"serve",
")",
"{",
"serve",
".",
"pass",
"(",
"function",
"(",
"name",
",",
"type",
")",
"{",
"response",
".",
"writeHead",
"(",
"200",
",",
"extname",
".",
"substr",
"(",
"1",
")",
")",
".",
"pipeWith",
"(",
"fs",
".",
"createReadStream",
"(",
"path",
".",
"resolve",
"(",
"name",
")",
")",
")",
"}",
")",
".",
"fail",
"(",
"notfound",
")",
";",
"return",
";",
"}",
"if",
"(",
"/",
"^\\.(md|mkd|markdown|html)$",
"/",
".",
"test",
"(",
"extname",
")",
")",
"{",
"check",
"(",
"filename",
")",
".",
"pass",
"(",
"function",
"(",
")",
"{",
"response",
".",
"writeHead",
"(",
"200",
",",
"'html'",
")",
".",
"end",
"(",
"template",
".",
"render",
"(",
"{",
"title",
":",
"basename",
",",
"highlight",
":",
"R",
".",
"get",
"(",
"'highlight'",
")",
"||",
"'default'",
",",
"theme",
":",
"getTheme",
"(",
"R",
".",
"get",
"(",
"'css'",
")",
")",
",",
"width",
":",
"R",
".",
"get",
"(",
"'width'",
")",
",",
"body",
":",
"parser",
".",
"parse",
"(",
"read",
"(",
"path",
".",
"resolve",
"(",
"filename",
")",
")",
")",
"}",
")",
")",
";",
"}",
")",
".",
"fail",
"(",
"notfound",
")",
";",
"return",
";",
"}",
"// Image or some other resources.",
"check",
"(",
"filename",
")",
".",
"pass",
"(",
"function",
"(",
"name",
")",
"{",
"response",
".",
"writeHead",
"(",
"200",
",",
"name",
")",
".",
"pipeWith",
"(",
"fs",
".",
"createReadStream",
"(",
"name",
")",
")",
";",
"}",
")",
".",
"fail",
"(",
"notfound",
")",
"}"
] | Http handler for the web server | [
"Http",
"handler",
"for",
"the",
"web",
"server"
] | 173c44f7cea1f579fa2d54773579ad80863ea8b9 | https://github.com/yuanchuan/markdown-preview/blob/173c44f7cea1f579fa2d54773579ad80863ea8b9/lib/server.js#L56-L121 |
23,606 | shannonmoeller/handlebars-wax | index.js | compileFile | function compileFile(module, filename) {
const templateString = fs.readFileSync(filename, 'utf8');
module.exports = handlebars.compile(templateString);
} | javascript | function compileFile(module, filename) {
const templateString = fs.readFileSync(filename, 'utf8');
module.exports = handlebars.compile(templateString);
} | [
"function",
"compileFile",
"(",
"module",
",",
"filename",
")",
"{",
"const",
"templateString",
"=",
"fs",
".",
"readFileSync",
"(",
"filename",
",",
"'utf8'",
")",
";",
"module",
".",
"exports",
"=",
"handlebars",
".",
"compile",
"(",
"templateString",
")",
";",
"}"
] | eslint-disable-line prefer-const | [
"eslint",
"-",
"disable",
"-",
"line",
"prefer",
"-",
"const"
] | cbc6d9d7c6ee5f529b97c942ec3ff2e321a6854c | https://github.com/shannonmoeller/handlebars-wax/blob/cbc6d9d7c6ee5f529b97c942ec3ff2e321a6854c/index.js#L37-L41 |
23,607 | thlorenz/cpuprofilify | example/fibonacci.js | cal_arrayPush | function cal_arrayPush(n) {
function toFib(x, y, z) {
x.push((z < 2) ? z : x[z - 1] + x[z - 2])
return x
}
var arr = Array.apply(null, new Array(n)).reduce(toFib, [])
var len = arr.length
return arr[len - 1] + arr[len - 2]
} | javascript | function cal_arrayPush(n) {
function toFib(x, y, z) {
x.push((z < 2) ? z : x[z - 1] + x[z - 2])
return x
}
var arr = Array.apply(null, new Array(n)).reduce(toFib, [])
var len = arr.length
return arr[len - 1] + arr[len - 2]
} | [
"function",
"cal_arrayPush",
"(",
"n",
")",
"{",
"function",
"toFib",
"(",
"x",
",",
"y",
",",
"z",
")",
"{",
"x",
".",
"push",
"(",
"(",
"z",
"<",
"2",
")",
"?",
"z",
":",
"x",
"[",
"z",
"-",
"1",
"]",
"+",
"x",
"[",
"z",
"-",
"2",
"]",
")",
"return",
"x",
"}",
"var",
"arr",
"=",
"Array",
".",
"apply",
"(",
"null",
",",
"new",
"Array",
"(",
"n",
")",
")",
".",
"reduce",
"(",
"toFib",
",",
"[",
"]",
")",
"var",
"len",
"=",
"arr",
".",
"length",
"return",
"arr",
"[",
"len",
"-",
"1",
"]",
"+",
"arr",
"[",
"len",
"-",
"2",
"]",
"}"
] | Calculate Fibonacci Array Push | [
"Calculate",
"Fibonacci",
"Array",
"Push"
] | ef7a59ecf05b512c398281d45dc84208009bc1ed | https://github.com/thlorenz/cpuprofilify/blob/ef7a59ecf05b512c398281d45dc84208009bc1ed/example/fibonacci.js#L51-L60 |
23,608 | thlorenz/cpuprofilify | index.js | convert | function convert(trace, opts) {
opts = opts || {}
this._map = opts.map
this._opts = xtend({ v8gc: true }, opts, { map: this._map ? 'was supplied' : 'was not supplied' })
this.emit('info', 'Options: %j', this._opts)
this._trace = trace
this._traceLen = trace.length
if (!this._traceLen) {
this.emit('warn', 'Trace was empty, quitting')
return
}
try {
this._traceStart = traceUtil.traceStart(this._trace)
this._converterCtr = getConverter(this._trace, this._traceStart, this._opts.type)
this._resolveTraceInfo()
this._tryResolveSymbols()
this._filterInternals()
var converter = this._converterCtr(this._filtered, this._traceStart, this._opts)
this.emit('info', 'Converting trace of length %d', this._filteredLen)
var converted = converter.convert()
this.emit('info', 'Success!')
return converted
} catch (err) {
this.emit('error', err)
}
} | javascript | function convert(trace, opts) {
opts = opts || {}
this._map = opts.map
this._opts = xtend({ v8gc: true }, opts, { map: this._map ? 'was supplied' : 'was not supplied' })
this.emit('info', 'Options: %j', this._opts)
this._trace = trace
this._traceLen = trace.length
if (!this._traceLen) {
this.emit('warn', 'Trace was empty, quitting')
return
}
try {
this._traceStart = traceUtil.traceStart(this._trace)
this._converterCtr = getConverter(this._trace, this._traceStart, this._opts.type)
this._resolveTraceInfo()
this._tryResolveSymbols()
this._filterInternals()
var converter = this._converterCtr(this._filtered, this._traceStart, this._opts)
this.emit('info', 'Converting trace of length %d', this._filteredLen)
var converted = converter.convert()
this.emit('info', 'Success!')
return converted
} catch (err) {
this.emit('error', err)
}
} | [
"function",
"convert",
"(",
"trace",
",",
"opts",
")",
"{",
"opts",
"=",
"opts",
"||",
"{",
"}",
"this",
".",
"_map",
"=",
"opts",
".",
"map",
"this",
".",
"_opts",
"=",
"xtend",
"(",
"{",
"v8gc",
":",
"true",
"}",
",",
"opts",
",",
"{",
"map",
":",
"this",
".",
"_map",
"?",
"'was supplied'",
":",
"'was not supplied'",
"}",
")",
"this",
".",
"emit",
"(",
"'info'",
",",
"'Options: %j'",
",",
"this",
".",
"_opts",
")",
"this",
".",
"_trace",
"=",
"trace",
"this",
".",
"_traceLen",
"=",
"trace",
".",
"length",
"if",
"(",
"!",
"this",
".",
"_traceLen",
")",
"{",
"this",
".",
"emit",
"(",
"'warn'",
",",
"'Trace was empty, quitting'",
")",
"return",
"}",
"try",
"{",
"this",
".",
"_traceStart",
"=",
"traceUtil",
".",
"traceStart",
"(",
"this",
".",
"_trace",
")",
"this",
".",
"_converterCtr",
"=",
"getConverter",
"(",
"this",
".",
"_trace",
",",
"this",
".",
"_traceStart",
",",
"this",
".",
"_opts",
".",
"type",
")",
"this",
".",
"_resolveTraceInfo",
"(",
")",
"this",
".",
"_tryResolveSymbols",
"(",
")",
"this",
".",
"_filterInternals",
"(",
")",
"var",
"converter",
"=",
"this",
".",
"_converterCtr",
"(",
"this",
".",
"_filtered",
",",
"this",
".",
"_traceStart",
",",
"this",
".",
"_opts",
")",
"this",
".",
"emit",
"(",
"'info'",
",",
"'Converting trace of length %d'",
",",
"this",
".",
"_filteredLen",
")",
"var",
"converted",
"=",
"converter",
".",
"convert",
"(",
")",
"this",
".",
"emit",
"(",
"'info'",
",",
"'Success!'",
")",
"return",
"converted",
"}",
"catch",
"(",
"err",
")",
"{",
"this",
".",
"emit",
"(",
"'error'",
",",
"err",
")",
"}",
"}"
] | Converts the given trace taking according to the given opts.
```
var cpuprofilifier = require('cpuprofilifier')
var cpuprofile = cpuprofilifier().convert(trace)
fs.writeFileSync('/tmp/my.cpuprofile', JSON.stringify(cpuprofile))
```
@name CpuProfilifier::convert
@function
@param {Array.<String>} trace a trace generated via `perf script` or the `profile_1ms.d` DTrace script
@param {Object=} opts
@param {string} opts.map a map containing symbols information, if not given it will be read from /tmp/perf-<pid>.map.
@param {string} opts.type type of input `perf|dtrace`. If not supplied it will be detected.
@param {Boolean} opts.shortStack stacks that have only one line are ignored unless this flag is set
@param {Boolean} opts.optimizationinfo JS optimization info is removed unless this flag is set (default: false)
@param {Boolean} opts.unresolveds unresolved addresses like `0x1a23c` are filtered from the trace unless this flag is set (default: false)
@param {Boolean} opts.sysinternals sysinternals like `__lib_c_start...` are filtered from the trace unless this flag is set (default: false)
@param {Boolean} opts.v8internals v8internals like `v8::internal::...` are filtered from the trace unless this flag is set (default: false)
@param {Boolean} opts.v8gc when v8internals are filtered, garbage collection info is as well unless this flag set (default: true)
@return {Object} an cpuprofile presentation of the given trace | [
"Converts",
"the",
"given",
"trace",
"taking",
"according",
"to",
"the",
"given",
"opts",
"."
] | ef7a59ecf05b512c398281d45dc84208009bc1ed | https://github.com/thlorenz/cpuprofilify/blob/ef7a59ecf05b512c398281d45dc84208009bc1ed/index.js#L53-L84 |
23,609 | enmasseio/evejs | lib/transport/local/LocalTransport.js | LocalTransport | function LocalTransport(config) {
this.id = config && config.id || null;
this.networkId = this.id || null;
this['default'] = config && config['default'] || false;
this.agents = {};
} | javascript | function LocalTransport(config) {
this.id = config && config.id || null;
this.networkId = this.id || null;
this['default'] = config && config['default'] || false;
this.agents = {};
} | [
"function",
"LocalTransport",
"(",
"config",
")",
"{",
"this",
".",
"id",
"=",
"config",
"&&",
"config",
".",
"id",
"||",
"null",
";",
"this",
".",
"networkId",
"=",
"this",
".",
"id",
"||",
"null",
";",
"this",
"[",
"'default'",
"]",
"=",
"config",
"&&",
"config",
"[",
"'default'",
"]",
"||",
"false",
";",
"this",
".",
"agents",
"=",
"{",
"}",
";",
"}"
] | Create a local transport.
@param {Object} config Config can contain the following properties:
- `id: string`. Optional
@constructor | [
"Create",
"a",
"local",
"transport",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/local/LocalTransport.js#L12-L17 |
23,610 | enmasseio/evejs | lib/transport/pubnub/PubNubConnection.js | PubNubConnection | function PubNubConnection(transport, id, receive) {
this.id = id;
this.transport = transport;
// ready state
var me = this;
this.ready = new Promise(function (resolve, reject) {
transport.pubnub.subscribe({
channel: id,
message: function (message) {
receive(message.from, message.message);
},
connect: function () {
resolve(me);
}
});
});
} | javascript | function PubNubConnection(transport, id, receive) {
this.id = id;
this.transport = transport;
// ready state
var me = this;
this.ready = new Promise(function (resolve, reject) {
transport.pubnub.subscribe({
channel: id,
message: function (message) {
receive(message.from, message.message);
},
connect: function () {
resolve(me);
}
});
});
} | [
"function",
"PubNubConnection",
"(",
"transport",
",",
"id",
",",
"receive",
")",
"{",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"transport",
"=",
"transport",
";",
"// ready state",
"var",
"me",
"=",
"this",
";",
"this",
".",
"ready",
"=",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"transport",
".",
"pubnub",
".",
"subscribe",
"(",
"{",
"channel",
":",
"id",
",",
"message",
":",
"function",
"(",
"message",
")",
"{",
"receive",
"(",
"message",
".",
"from",
",",
"message",
".",
"message",
")",
";",
"}",
",",
"connect",
":",
"function",
"(",
")",
"{",
"resolve",
"(",
"me",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"}"
] | A connection. The connection is ready when the property .ready resolves.
@param {PubNubTransport} transport
@param {string | number} id
@param {function} receive
@constructor | [
"A",
"connection",
".",
"The",
"connection",
"is",
"ready",
"when",
"the",
"property",
".",
"ready",
"resolves",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/pubnub/PubNubConnection.js#L13-L30 |
23,611 | enmasseio/evejs | lib/transport/pubnub/PubNubTransport.js | PubNubTransport | function PubNubTransport(config) {
this.id = config.id || null;
this.networkId = config.publish_key || null;
this['default'] = config['default'] || false;
this.pubnub = PUBNUB().init(config);
} | javascript | function PubNubTransport(config) {
this.id = config.id || null;
this.networkId = config.publish_key || null;
this['default'] = config['default'] || false;
this.pubnub = PUBNUB().init(config);
} | [
"function",
"PubNubTransport",
"(",
"config",
")",
"{",
"this",
".",
"id",
"=",
"config",
".",
"id",
"||",
"null",
";",
"this",
".",
"networkId",
"=",
"config",
".",
"publish_key",
"||",
"null",
";",
"this",
"[",
"'default'",
"]",
"=",
"config",
"[",
"'default'",
"]",
"||",
"false",
";",
"this",
".",
"pubnub",
"=",
"PUBNUB",
"(",
")",
".",
"init",
"(",
"config",
")",
";",
"}"
] | Use pubnub as transport
@param {Object} config Config can contain the following properties:
- `id: string`. Optional
- `publish_key: string`. Required
- `subscribe_key: string`. Required
@constructor | [
"Use",
"pubnub",
"as",
"transport"
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/pubnub/PubNubTransport.js#L14-L19 |
23,612 | enmasseio/evejs | lib/transport/distribus/DistribusTransport.js | DistribusTransport | function DistribusTransport(config) {
this.id = config && config.id || null;
this['default'] = config && config['default'] || false;
this.host = config && config.host || new distribus.Host(config);
this.networkId = this.host.networkId; // FIXME: networkId can change when host connects to another host.
} | javascript | function DistribusTransport(config) {
this.id = config && config.id || null;
this['default'] = config && config['default'] || false;
this.host = config && config.host || new distribus.Host(config);
this.networkId = this.host.networkId; // FIXME: networkId can change when host connects to another host.
} | [
"function",
"DistribusTransport",
"(",
"config",
")",
"{",
"this",
".",
"id",
"=",
"config",
"&&",
"config",
".",
"id",
"||",
"null",
";",
"this",
"[",
"'default'",
"]",
"=",
"config",
"&&",
"config",
"[",
"'default'",
"]",
"||",
"false",
";",
"this",
".",
"host",
"=",
"config",
"&&",
"config",
".",
"host",
"||",
"new",
"distribus",
".",
"Host",
"(",
"config",
")",
";",
"this",
".",
"networkId",
"=",
"this",
".",
"host",
".",
"networkId",
";",
"// FIXME: networkId can change when host connects to another host.",
"}"
] | Use distribus as transport
@param {Object} config Config can contain the following properties:
- `id: string`. Optional
- `host: distribus.Host`. Optional
If `host` is not provided,
a new local distribus Host is created.
@constructor | [
"Use",
"distribus",
"as",
"transport"
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/distribus/DistribusTransport.js#L16-L22 |
23,613 | enmasseio/evejs | lib/module/PatternModule.js | PatternModule | function PatternModule(agent, options) {
this.agent = agent;
this.stopPropagation = options && options.stopPropagation || false;
this.receiveOriginal = agent._receive;
this.listeners = [];
} | javascript | function PatternModule(agent, options) {
this.agent = agent;
this.stopPropagation = options && options.stopPropagation || false;
this.receiveOriginal = agent._receive;
this.listeners = [];
} | [
"function",
"PatternModule",
"(",
"agent",
",",
"options",
")",
"{",
"this",
".",
"agent",
"=",
"agent",
";",
"this",
".",
"stopPropagation",
"=",
"options",
"&&",
"options",
".",
"stopPropagation",
"||",
"false",
";",
"this",
".",
"receiveOriginal",
"=",
"agent",
".",
"_receive",
";",
"this",
".",
"listeners",
"=",
"[",
"]",
";",
"}"
] | Create a pattern listener onto an Agent.
A new handler is added to the agents _receiver function.
Creates a Pattern instance with functions `listen` and `unlisten`.
@param {Agent} agent
@param {Object} [options] Optional parameters. Can contain properties:
- stopPropagation: boolean
When false (default), a message
will be delivered at all
matching pattern listeners.
When true, a message will be
be delivered at the first
matching pattern listener only. | [
"Create",
"a",
"pattern",
"listener",
"onto",
"an",
"Agent",
".",
"A",
"new",
"handler",
"is",
"added",
"to",
"the",
"agents",
"_receiver",
"function",
".",
"Creates",
"a",
"Pattern",
"instance",
"with",
"functions",
"listen",
"and",
"unlisten",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/module/PatternModule.js#L17-L22 |
23,614 | enmasseio/evejs | lib/Agent.js | _getModuleConstructor | function _getModuleConstructor(name) {
var constructor = Agent.modules[name];
if (!constructor) {
throw new Error('Unknown module "' + name + '". ' +
'Choose from: ' + Object.keys(Agent.modules).map(JSON.stringify).join(', '));
}
return constructor;
} | javascript | function _getModuleConstructor(name) {
var constructor = Agent.modules[name];
if (!constructor) {
throw new Error('Unknown module "' + name + '". ' +
'Choose from: ' + Object.keys(Agent.modules).map(JSON.stringify).join(', '));
}
return constructor;
} | [
"function",
"_getModuleConstructor",
"(",
"name",
")",
"{",
"var",
"constructor",
"=",
"Agent",
".",
"modules",
"[",
"name",
"]",
";",
"if",
"(",
"!",
"constructor",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Unknown module \"'",
"+",
"name",
"+",
"'\". '",
"+",
"'Choose from: '",
"+",
"Object",
".",
"keys",
"(",
"Agent",
".",
"modules",
")",
".",
"map",
"(",
"JSON",
".",
"stringify",
")",
".",
"join",
"(",
"', '",
")",
")",
";",
"}",
"return",
"constructor",
";",
"}"
] | Get a module constructor by it's name.
Throws an error when the module is not found.
@param {string} name
@return {function} Returns the modules constructor function
@private | [
"Get",
"a",
"module",
"constructor",
"by",
"it",
"s",
"name",
".",
"Throws",
"an",
"error",
"when",
"the",
"module",
"is",
"not",
"found",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/Agent.js#L138-L145 |
23,615 | enmasseio/evejs | lib/transport/Transport.js | Transport | function Transport(config) {
this.id = config && config.id || null;
this['default'] = config && config['default'] || false;
} | javascript | function Transport(config) {
this.id = config && config.id || null;
this['default'] = config && config['default'] || false;
} | [
"function",
"Transport",
"(",
"config",
")",
"{",
"this",
".",
"id",
"=",
"config",
"&&",
"config",
".",
"id",
"||",
"null",
";",
"this",
"[",
"'default'",
"]",
"=",
"config",
"&&",
"config",
"[",
"'default'",
"]",
"||",
"false",
";",
"}"
] | Abstract prototype of a transport
@param {Object} [config]
@constructor | [
"Abstract",
"prototype",
"of",
"a",
"transport"
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/Transport.js#L8-L11 |
23,616 | enmasseio/evejs | lib/module/RequestModule.js | RequestModule | function RequestModule(agent, options) {
this.agent = agent;
this.receiveOriginal = agent._receive;
this.timeout = options && options.timeout || TIMEOUT;
this.queue = [];
} | javascript | function RequestModule(agent, options) {
this.agent = agent;
this.receiveOriginal = agent._receive;
this.timeout = options && options.timeout || TIMEOUT;
this.queue = [];
} | [
"function",
"RequestModule",
"(",
"agent",
",",
"options",
")",
"{",
"this",
".",
"agent",
"=",
"agent",
";",
"this",
".",
"receiveOriginal",
"=",
"agent",
".",
"_receive",
";",
"this",
".",
"timeout",
"=",
"options",
"&&",
"options",
".",
"timeout",
"||",
"TIMEOUT",
";",
"this",
".",
"queue",
"=",
"[",
"]",
";",
"}"
] | ms
Create a Request module.
The module attaches a handler to the agents _receive function.
Creates a Request instance with function `request`.
@param {Agent} agent
@param {Object} [options] Optional parameters. Can contain properties:
- timeout: number A timeout for responses in
milliseconds. 60000 ms by
default. | [
"ms",
"Create",
"a",
"Request",
"module",
".",
"The",
"module",
"attaches",
"a",
"handler",
"to",
"the",
"agents",
"_receive",
"function",
".",
"Creates",
"a",
"Request",
"instance",
"with",
"function",
"request",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/module/RequestModule.js#L19-L24 |
23,617 | enmasseio/evejs | lib/transport/websocket/WebSocketConnection.js | WebSocketConnection | function WebSocketConnection(transport, url, receive) {
this.transport = transport;
this.url = url ? util.normalizeURL(url) : uuid();
this.receive = receive;
this.sockets = {};
this.closed = false;
this.reconnectTimers = {};
// ready state
this.ready = Promise.resolve(this);
} | javascript | function WebSocketConnection(transport, url, receive) {
this.transport = transport;
this.url = url ? util.normalizeURL(url) : uuid();
this.receive = receive;
this.sockets = {};
this.closed = false;
this.reconnectTimers = {};
// ready state
this.ready = Promise.resolve(this);
} | [
"function",
"WebSocketConnection",
"(",
"transport",
",",
"url",
",",
"receive",
")",
"{",
"this",
".",
"transport",
"=",
"transport",
";",
"this",
".",
"url",
"=",
"url",
"?",
"util",
".",
"normalizeURL",
"(",
"url",
")",
":",
"uuid",
"(",
")",
";",
"this",
".",
"receive",
"=",
"receive",
";",
"this",
".",
"sockets",
"=",
"{",
"}",
";",
"this",
".",
"closed",
"=",
"false",
";",
"this",
".",
"reconnectTimers",
"=",
"{",
"}",
";",
"// ready state",
"this",
".",
"ready",
"=",
"Promise",
".",
"resolve",
"(",
"this",
")",
";",
"}"
] | A websocket connection.
@param {WebSocketTransport} transport
@param {string | number | null} url The url of the agent. The url must match
the url of the WebSocket server.
If url is null, a UUID id is generated as url.
@param {function} receive
@constructor | [
"A",
"websocket",
"connection",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/websocket/WebSocketConnection.js#L21-L32 |
23,618 | enmasseio/evejs | lib/module/BabbleModule.js | BabbleModule | function BabbleModule(agent, options) {
// create a new babbler
var babbler = babble.babbler(agent.id);
babbler.connect({
connect: function (params) {},
disconnect: function(token) {},
send: function (to, message) {
agent.send(to, message);
}
});
this.babbler = babbler;
// create a receive function for the agent
var receiveOriginal = agent._receive;
this._receive = function (from, message) {
babbler._receive(message);
// TODO: only propagate to receiveOriginal if the message is not handled by the babbler
return receiveOriginal.call(agent, from, message);
};
} | javascript | function BabbleModule(agent, options) {
// create a new babbler
var babbler = babble.babbler(agent.id);
babbler.connect({
connect: function (params) {},
disconnect: function(token) {},
send: function (to, message) {
agent.send(to, message);
}
});
this.babbler = babbler;
// create a receive function for the agent
var receiveOriginal = agent._receive;
this._receive = function (from, message) {
babbler._receive(message);
// TODO: only propagate to receiveOriginal if the message is not handled by the babbler
return receiveOriginal.call(agent, from, message);
};
} | [
"function",
"BabbleModule",
"(",
"agent",
",",
"options",
")",
"{",
"// create a new babbler",
"var",
"babbler",
"=",
"babble",
".",
"babbler",
"(",
"agent",
".",
"id",
")",
";",
"babbler",
".",
"connect",
"(",
"{",
"connect",
":",
"function",
"(",
"params",
")",
"{",
"}",
",",
"disconnect",
":",
"function",
"(",
"token",
")",
"{",
"}",
",",
"send",
":",
"function",
"(",
"to",
",",
"message",
")",
"{",
"agent",
".",
"send",
"(",
"to",
",",
"message",
")",
";",
"}",
"}",
")",
";",
"this",
".",
"babbler",
"=",
"babbler",
";",
"// create a receive function for the agent",
"var",
"receiveOriginal",
"=",
"agent",
".",
"_receive",
";",
"this",
".",
"_receive",
"=",
"function",
"(",
"from",
",",
"message",
")",
"{",
"babbler",
".",
"_receive",
"(",
"message",
")",
";",
"// TODO: only propagate to receiveOriginal if the message is not handled by the babbler",
"return",
"receiveOriginal",
".",
"call",
"(",
"agent",
",",
"from",
",",
"message",
")",
";",
"}",
";",
"}"
] | Create a Babble module for an agent.
The agents _receive function is wrapped into a new handler.
Creates a Babble instance with function `ask`, `tell`, `listen`, `listenOnce`
@param {Agent} agent
@param {Object} [options] Optional parameters. Not applicable for BabbleModule
@constructor | [
"Create",
"a",
"Babble",
"module",
"for",
"an",
"agent",
".",
"The",
"agents",
"_receive",
"function",
"is",
"wrapped",
"into",
"a",
"new",
"handler",
".",
"Creates",
"a",
"Babble",
"instance",
"with",
"function",
"ask",
"tell",
"listen",
"listenOnce"
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/module/BabbleModule.js#L13-L32 |
23,619 | enmasseio/evejs | lib/transport/websocket/WebSocketTransport.js | WebSocketTransport | function WebSocketTransport(config) {
this.id = config && config.id || null;
this.networkId = this.id || null;
this['default'] = config && config['default'] || false;
this.localShortcut = (config && config.localShortcut === false) ? false : true;
this.reconnectDelay = config && config.reconnectDelay || 10000;
this.httpTransport = config && config.httpTransport;
this.url = config && config.url || null;
this.server = null;
if (this.url != null) {
var urlParts = urlModule.parse(this.url);
if (urlParts.protocol != 'ws:') throw new Error('Invalid protocol, "ws:" expected');
if (this.url.indexOf(':id') == -1) throw new Error('":id" placeholder missing in url');
this.address = urlParts.protocol + '//' + urlParts.host; // the url without path, for example 'ws://localhost:3000'
this.ready = this._initServer(this.url);
}
else {
this.address = null;
this.ready = Promise.resolve(this);
}
this.agents = {}; // WebSocketConnections of all registered agents. The keys are the urls of the agents
} | javascript | function WebSocketTransport(config) {
this.id = config && config.id || null;
this.networkId = this.id || null;
this['default'] = config && config['default'] || false;
this.localShortcut = (config && config.localShortcut === false) ? false : true;
this.reconnectDelay = config && config.reconnectDelay || 10000;
this.httpTransport = config && config.httpTransport;
this.url = config && config.url || null;
this.server = null;
if (this.url != null) {
var urlParts = urlModule.parse(this.url);
if (urlParts.protocol != 'ws:') throw new Error('Invalid protocol, "ws:" expected');
if (this.url.indexOf(':id') == -1) throw new Error('":id" placeholder missing in url');
this.address = urlParts.protocol + '//' + urlParts.host; // the url without path, for example 'ws://localhost:3000'
this.ready = this._initServer(this.url);
}
else {
this.address = null;
this.ready = Promise.resolve(this);
}
this.agents = {}; // WebSocketConnections of all registered agents. The keys are the urls of the agents
} | [
"function",
"WebSocketTransport",
"(",
"config",
")",
"{",
"this",
".",
"id",
"=",
"config",
"&&",
"config",
".",
"id",
"||",
"null",
";",
"this",
".",
"networkId",
"=",
"this",
".",
"id",
"||",
"null",
";",
"this",
"[",
"'default'",
"]",
"=",
"config",
"&&",
"config",
"[",
"'default'",
"]",
"||",
"false",
";",
"this",
".",
"localShortcut",
"=",
"(",
"config",
"&&",
"config",
".",
"localShortcut",
"===",
"false",
")",
"?",
"false",
":",
"true",
";",
"this",
".",
"reconnectDelay",
"=",
"config",
"&&",
"config",
".",
"reconnectDelay",
"||",
"10000",
";",
"this",
".",
"httpTransport",
"=",
"config",
"&&",
"config",
".",
"httpTransport",
";",
"this",
".",
"url",
"=",
"config",
"&&",
"config",
".",
"url",
"||",
"null",
";",
"this",
".",
"server",
"=",
"null",
";",
"if",
"(",
"this",
".",
"url",
"!=",
"null",
")",
"{",
"var",
"urlParts",
"=",
"urlModule",
".",
"parse",
"(",
"this",
".",
"url",
")",
";",
"if",
"(",
"urlParts",
".",
"protocol",
"!=",
"'ws:'",
")",
"throw",
"new",
"Error",
"(",
"'Invalid protocol, \"ws:\" expected'",
")",
";",
"if",
"(",
"this",
".",
"url",
".",
"indexOf",
"(",
"':id'",
")",
"==",
"-",
"1",
")",
"throw",
"new",
"Error",
"(",
"'\":id\" placeholder missing in url'",
")",
";",
"this",
".",
"address",
"=",
"urlParts",
".",
"protocol",
"+",
"'//'",
"+",
"urlParts",
".",
"host",
";",
"// the url without path, for example 'ws://localhost:3000'",
"this",
".",
"ready",
"=",
"this",
".",
"_initServer",
"(",
"this",
".",
"url",
")",
";",
"}",
"else",
"{",
"this",
".",
"address",
"=",
"null",
";",
"this",
".",
"ready",
"=",
"Promise",
".",
"resolve",
"(",
"this",
")",
";",
"}",
"this",
".",
"agents",
"=",
"{",
"}",
";",
"// WebSocketConnections of all registered agents. The keys are the urls of the agents",
"}"
] | Create a web socket transport.
@param {Object} config Config can contain the following properties:
- `id: string`. Optional
- `default: boolean`. Optional
- `url: string`. Optional. If provided,
A WebSocket server is started on given
url.
- `localShortcut: boolean`. Optional. If true
(default), messages to local agents are not
send via WebSocket but delivered immediately
- `reconnectDelay: number` Optional. Delay in
milliseconds for reconnecting a broken
connection. 10000 ms by default. Connections
are only automatically reconnected after
there has been an established connection.
@constructor | [
"Create",
"a",
"web",
"socket",
"transport",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/websocket/WebSocketTransport.js#L29-L56 |
23,620 | enmasseio/evejs | examples/agents/DelayedAgent.js | PlanningAgent | function PlanningAgent(id) {
// execute super constructor
eve.Agent.call(this, id);
// connect to all transports configured by the system
this.connect(eve.system.transports.getAll());
} | javascript | function PlanningAgent(id) {
// execute super constructor
eve.Agent.call(this, id);
// connect to all transports configured by the system
this.connect(eve.system.transports.getAll());
} | [
"function",
"PlanningAgent",
"(",
"id",
")",
"{",
"// execute super constructor",
"eve",
".",
"Agent",
".",
"call",
"(",
"this",
",",
"id",
")",
";",
"// connect to all transports configured by the system",
"this",
".",
"connect",
"(",
"eve",
".",
"system",
".",
"transports",
".",
"getAll",
"(",
")",
")",
";",
"}"
] | DelayedAgent prototype.
This agent uses the eve.system.timer. This timer can be configured to run
in real time, discrete time, or hyper time.
@param {String} id
@constructor
@extend eve.Agent | [
"DelayedAgent",
"prototype",
".",
"This",
"agent",
"uses",
"the",
"eve",
".",
"system",
".",
"timer",
".",
"This",
"timer",
"can",
"be",
"configured",
"to",
"run",
"in",
"real",
"time",
"discrete",
"time",
"or",
"hyper",
"time",
"."
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/examples/agents/DelayedAgent.js#L11-L17 |
23,621 | enmasseio/evejs | lib/transport/amqp/AMQPTransport.js | AMQPTransport | function AMQPTransport(config) {
this.id = config.id || null;
this.url = config.url || (config.host && "amqp://" + config.host) || null;
this['default'] = config['default'] || false;
this.networkId = this.url;
this.connection = null;
this.config = config;
} | javascript | function AMQPTransport(config) {
this.id = config.id || null;
this.url = config.url || (config.host && "amqp://" + config.host) || null;
this['default'] = config['default'] || false;
this.networkId = this.url;
this.connection = null;
this.config = config;
} | [
"function",
"AMQPTransport",
"(",
"config",
")",
"{",
"this",
".",
"id",
"=",
"config",
".",
"id",
"||",
"null",
";",
"this",
".",
"url",
"=",
"config",
".",
"url",
"||",
"(",
"config",
".",
"host",
"&&",
"\"amqp://\"",
"+",
"config",
".",
"host",
")",
"||",
"null",
";",
"this",
"[",
"'default'",
"]",
"=",
"config",
"[",
"'default'",
"]",
"||",
"false",
";",
"this",
".",
"networkId",
"=",
"this",
".",
"url",
";",
"this",
".",
"connection",
"=",
"null",
";",
"this",
".",
"config",
"=",
"config",
";",
"}"
] | Use AMQP as transport
@param {Object} config Config can contain the following properties:
- `id: string`
- `url: string`
- `host: string`
The config must contain either `url` or `host`.
For example: {url: 'amqp://localhost'} or
{host: 'dev.rabbitmq.com'}
@constructor | [
"Use",
"AMQP",
"as",
"transport"
] | f330edd3b637d3b1b5b086d9dd730b13e61a0cc0 | https://github.com/enmasseio/evejs/blob/f330edd3b637d3b1b5b086d9dd730b13e61a0cc0/lib/transport/amqp/AMQPTransport.js#L18-L26 |
23,622 | krampstudio/aja.js | src/aja.js | function(name, data){
var self = this;
var eventCalls = function eventCalls(name, data){
if(events[name] instanceof Array){
events[name].forEach(function(event){
event.call(self, data);
});
}
};
if(typeof name !== 'undefined'){
name = name + '';
var statusPattern = /^([0-9])([0-9x])([0-9x])$/i;
var triggerStatus = name.match(statusPattern);
//HTTP status pattern
if(triggerStatus && triggerStatus.length > 3){
Object.keys(events).forEach(function(eventName){
var listenerStatus = eventName.match(statusPattern);
if(listenerStatus && listenerStatus.length > 3 && //an listener on status
triggerStatus[1] === listenerStatus[1] && //hundreds match exactly
(listenerStatus[2] === 'x' || triggerStatus[2] === listenerStatus[2]) && //tens matches
(listenerStatus[3] === 'x' || triggerStatus[3] === listenerStatus[3])){ //ones matches
eventCalls(eventName, data);
}
});
//or exact matching
} else if(events[name]){
eventCalls(name, data);
}
}
return this;
} | javascript | function(name, data){
var self = this;
var eventCalls = function eventCalls(name, data){
if(events[name] instanceof Array){
events[name].forEach(function(event){
event.call(self, data);
});
}
};
if(typeof name !== 'undefined'){
name = name + '';
var statusPattern = /^([0-9])([0-9x])([0-9x])$/i;
var triggerStatus = name.match(statusPattern);
//HTTP status pattern
if(triggerStatus && triggerStatus.length > 3){
Object.keys(events).forEach(function(eventName){
var listenerStatus = eventName.match(statusPattern);
if(listenerStatus && listenerStatus.length > 3 && //an listener on status
triggerStatus[1] === listenerStatus[1] && //hundreds match exactly
(listenerStatus[2] === 'x' || triggerStatus[2] === listenerStatus[2]) && //tens matches
(listenerStatus[3] === 'x' || triggerStatus[3] === listenerStatus[3])){ //ones matches
eventCalls(eventName, data);
}
});
//or exact matching
} else if(events[name]){
eventCalls(name, data);
}
}
return this;
} | [
"function",
"(",
"name",
",",
"data",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"eventCalls",
"=",
"function",
"eventCalls",
"(",
"name",
",",
"data",
")",
"{",
"if",
"(",
"events",
"[",
"name",
"]",
"instanceof",
"Array",
")",
"{",
"events",
"[",
"name",
"]",
".",
"forEach",
"(",
"function",
"(",
"event",
")",
"{",
"event",
".",
"call",
"(",
"self",
",",
"data",
")",
";",
"}",
")",
";",
"}",
"}",
";",
"if",
"(",
"typeof",
"name",
"!==",
"'undefined'",
")",
"{",
"name",
"=",
"name",
"+",
"''",
";",
"var",
"statusPattern",
"=",
"/",
"^([0-9])([0-9x])([0-9x])$",
"/",
"i",
";",
"var",
"triggerStatus",
"=",
"name",
".",
"match",
"(",
"statusPattern",
")",
";",
"//HTTP status pattern",
"if",
"(",
"triggerStatus",
"&&",
"triggerStatus",
".",
"length",
">",
"3",
")",
"{",
"Object",
".",
"keys",
"(",
"events",
")",
".",
"forEach",
"(",
"function",
"(",
"eventName",
")",
"{",
"var",
"listenerStatus",
"=",
"eventName",
".",
"match",
"(",
"statusPattern",
")",
";",
"if",
"(",
"listenerStatus",
"&&",
"listenerStatus",
".",
"length",
">",
"3",
"&&",
"//an listener on status",
"triggerStatus",
"[",
"1",
"]",
"===",
"listenerStatus",
"[",
"1",
"]",
"&&",
"//hundreds match exactly",
"(",
"listenerStatus",
"[",
"2",
"]",
"===",
"'x'",
"||",
"triggerStatus",
"[",
"2",
"]",
"===",
"listenerStatus",
"[",
"2",
"]",
")",
"&&",
"//tens matches",
"(",
"listenerStatus",
"[",
"3",
"]",
"===",
"'x'",
"||",
"triggerStatus",
"[",
"3",
"]",
"===",
"listenerStatus",
"[",
"3",
"]",
")",
")",
"{",
"//ones matches",
"eventCalls",
"(",
"eventName",
",",
"data",
")",
";",
"}",
"}",
")",
";",
"//or exact matching",
"}",
"else",
"if",
"(",
"events",
"[",
"name",
"]",
")",
"{",
"eventCalls",
"(",
"name",
",",
"data",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | Trigger an event.
This method will be called hardly ever outside Aja itself,
but there is edge cases where it can be useful.
@example aja().trigger('error', new Error('Emergency alert'));
@param {String} name - the name of the event to trigger
@param {*} data - arguments given to the handlers
@returns {Aja} chains | [
"Trigger",
"an",
"event",
".",
"This",
"method",
"will",
"be",
"called",
"hardly",
"ever",
"outside",
"Aja",
"itself",
"but",
"there",
"is",
"edge",
"cases",
"where",
"it",
"can",
"be",
"useful",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L334-L366 | |
23,623 | krampstudio/aja.js | src/aja.js | function(){
var type = data.type || (data.into ? 'html' : 'json');
var url = _buildQuery();
//delegates to ajaGo
if(typeof ajaGo[type] === 'function'){
return ajaGo[type].call(this, url);
}
} | javascript | function(){
var type = data.type || (data.into ? 'html' : 'json');
var url = _buildQuery();
//delegates to ajaGo
if(typeof ajaGo[type] === 'function'){
return ajaGo[type].call(this, url);
}
} | [
"function",
"(",
")",
"{",
"var",
"type",
"=",
"data",
".",
"type",
"||",
"(",
"data",
".",
"into",
"?",
"'html'",
":",
"'json'",
")",
";",
"var",
"url",
"=",
"_buildQuery",
"(",
")",
";",
"//delegates to ajaGo",
"if",
"(",
"typeof",
"ajaGo",
"[",
"type",
"]",
"===",
"'function'",
")",
"{",
"return",
"ajaGo",
"[",
"type",
"]",
".",
"call",
"(",
"this",
",",
"url",
")",
";",
"}",
"}"
] | Trigger the call.
This is the end of your chain loop.
@example aja()
.url('data.json')
.on('200', function(res){
//Yeah !
})
.go(); | [
"Trigger",
"the",
"call",
".",
"This",
"is",
"the",
"end",
"of",
"your",
"chain",
"loop",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L379-L388 | |
23,624 | krampstudio/aja.js | src/aja.js | function(url){
var self = this;
ajaGo._xhr.call(this, url, function processRes(res){
if(res){
try {
res = JSON.parse(res);
} catch(e){
self.trigger('error', e);
return null;
}
}
return res;
});
} | javascript | function(url){
var self = this;
ajaGo._xhr.call(this, url, function processRes(res){
if(res){
try {
res = JSON.parse(res);
} catch(e){
self.trigger('error', e);
return null;
}
}
return res;
});
} | [
"function",
"(",
"url",
")",
"{",
"var",
"self",
"=",
"this",
";",
"ajaGo",
".",
"_xhr",
".",
"call",
"(",
"this",
",",
"url",
",",
"function",
"processRes",
"(",
"res",
")",
"{",
"if",
"(",
"res",
")",
"{",
"try",
"{",
"res",
"=",
"JSON",
".",
"parse",
"(",
"res",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"self",
".",
"trigger",
"(",
"'error'",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"}",
"return",
"res",
";",
"}",
")",
";",
"}"
] | XHR call to url to retrieve JSON
@param {String} url - the url | [
"XHR",
"call",
"to",
"url",
"to",
"retrieve",
"JSON"
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L405-L419 | |
23,625 | krampstudio/aja.js | src/aja.js | function(url){
ajaGo._xhr.call(this, url, function processRes(res){
if(data.into && data.into.length){
[].forEach.call(data.into, function(elt){
elt.innerHTML = res;
});
}
return res;
});
} | javascript | function(url){
ajaGo._xhr.call(this, url, function processRes(res){
if(data.into && data.into.length){
[].forEach.call(data.into, function(elt){
elt.innerHTML = res;
});
}
return res;
});
} | [
"function",
"(",
"url",
")",
"{",
"ajaGo",
".",
"_xhr",
".",
"call",
"(",
"this",
",",
"url",
",",
"function",
"processRes",
"(",
"res",
")",
"{",
"if",
"(",
"data",
".",
"into",
"&&",
"data",
".",
"into",
".",
"length",
")",
"{",
"[",
"]",
".",
"forEach",
".",
"call",
"(",
"data",
".",
"into",
",",
"function",
"(",
"elt",
")",
"{",
"elt",
".",
"innerHTML",
"=",
"res",
";",
"}",
")",
";",
"}",
"return",
"res",
";",
"}",
")",
";",
"}"
] | XHR call to url to retrieve HTML and add it to a container if set.
@param {String} url - the url | [
"XHR",
"call",
"to",
"url",
"to",
"retrieve",
"HTML",
"and",
"add",
"it",
"to",
"a",
"container",
"if",
"set",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L425-L434 | |
23,626 | krampstudio/aja.js | src/aja.js | function(url, processRes){
var self = this;
//iterators
var key, header;
var method = data.method || 'get';
var async = data.sync !== true;
var request = new XMLHttpRequest();
var _data = data.data;
var body = data.body;
var contentType = this.header('Content-Type');
var timeout = data.timeout;
var timeoutId;
var isUrlEncoded;
var openParams;
//guess content type
if(!contentType && _data && _dataInBody()){
this.header('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
contentType = this.header('Content-Type');
}
//if data is used in body, it needs some modifications regarding the content type
if(_data && _dataInBody()){
if(typeof body !== 'string'){
body = '';
}
if(contentType.indexOf('json') > -1){
try {
body = JSON.stringify(_data);
} catch(e){
throw new TypeError('Unable to stringify body\'s content : ' + e.name);
}
} else {
isUrlEncoded = contentType && contentType.indexOf('x-www-form-urlencoded') > 1;
for(key in _data){
if(isUrlEncoded){
body += encodeURIComponent(key) + '=' + encodeURIComponent(_data[key]) + '&';
} else {
body += key + '=' + _data[key] + '\n\r';
}
}
}
}
//open the XHR request
openParams = [method, url, async];
if(data.auth){
openParams.push(data.auth.user);
openParams.push(data.auth.passwd);
}
request.open.apply(request, openParams);
//set the headers
for(header in data.headers){
request.setRequestHeader(header, data.headers[header]);
}
//bind events
request.onprogress = function(e){
if (e.lengthComputable) {
self.trigger('progress', e.loaded / e.total);
}
};
request.onload = function onRequestLoad(){
var response = request.responseText;
if (timeoutId) {
clearTimeout(timeoutId);
}
if(this.status >= 200 && this.status < 300){
if(typeof processRes === 'function'){
response = processRes(response);
}
self.trigger('success', response);
}
self.trigger(this.status, response);
self.trigger('end', response);
};
request.onerror = function onRequestError (err){
if (timeoutId) {
clearTimeout(timeoutId);
}
self.trigger('error', err, arguments);
};
//sets the timeout
if (timeout) {
timeoutId = setTimeout(function() {
self.trigger('timeout', {
type: 'timeout',
expiredAfter: timeout
}, request, arguments);
request.abort();
}, timeout);
}
//send the request
request.send(body);
} | javascript | function(url, processRes){
var self = this;
//iterators
var key, header;
var method = data.method || 'get';
var async = data.sync !== true;
var request = new XMLHttpRequest();
var _data = data.data;
var body = data.body;
var contentType = this.header('Content-Type');
var timeout = data.timeout;
var timeoutId;
var isUrlEncoded;
var openParams;
//guess content type
if(!contentType && _data && _dataInBody()){
this.header('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
contentType = this.header('Content-Type');
}
//if data is used in body, it needs some modifications regarding the content type
if(_data && _dataInBody()){
if(typeof body !== 'string'){
body = '';
}
if(contentType.indexOf('json') > -1){
try {
body = JSON.stringify(_data);
} catch(e){
throw new TypeError('Unable to stringify body\'s content : ' + e.name);
}
} else {
isUrlEncoded = contentType && contentType.indexOf('x-www-form-urlencoded') > 1;
for(key in _data){
if(isUrlEncoded){
body += encodeURIComponent(key) + '=' + encodeURIComponent(_data[key]) + '&';
} else {
body += key + '=' + _data[key] + '\n\r';
}
}
}
}
//open the XHR request
openParams = [method, url, async];
if(data.auth){
openParams.push(data.auth.user);
openParams.push(data.auth.passwd);
}
request.open.apply(request, openParams);
//set the headers
for(header in data.headers){
request.setRequestHeader(header, data.headers[header]);
}
//bind events
request.onprogress = function(e){
if (e.lengthComputable) {
self.trigger('progress', e.loaded / e.total);
}
};
request.onload = function onRequestLoad(){
var response = request.responseText;
if (timeoutId) {
clearTimeout(timeoutId);
}
if(this.status >= 200 && this.status < 300){
if(typeof processRes === 'function'){
response = processRes(response);
}
self.trigger('success', response);
}
self.trigger(this.status, response);
self.trigger('end', response);
};
request.onerror = function onRequestError (err){
if (timeoutId) {
clearTimeout(timeoutId);
}
self.trigger('error', err, arguments);
};
//sets the timeout
if (timeout) {
timeoutId = setTimeout(function() {
self.trigger('timeout', {
type: 'timeout',
expiredAfter: timeout
}, request, arguments);
request.abort();
}, timeout);
}
//send the request
request.send(body);
} | [
"function",
"(",
"url",
",",
"processRes",
")",
"{",
"var",
"self",
"=",
"this",
";",
"//iterators",
"var",
"key",
",",
"header",
";",
"var",
"method",
"=",
"data",
".",
"method",
"||",
"'get'",
";",
"var",
"async",
"=",
"data",
".",
"sync",
"!==",
"true",
";",
"var",
"request",
"=",
"new",
"XMLHttpRequest",
"(",
")",
";",
"var",
"_data",
"=",
"data",
".",
"data",
";",
"var",
"body",
"=",
"data",
".",
"body",
";",
"var",
"contentType",
"=",
"this",
".",
"header",
"(",
"'Content-Type'",
")",
";",
"var",
"timeout",
"=",
"data",
".",
"timeout",
";",
"var",
"timeoutId",
";",
"var",
"isUrlEncoded",
";",
"var",
"openParams",
";",
"//guess content type",
"if",
"(",
"!",
"contentType",
"&&",
"_data",
"&&",
"_dataInBody",
"(",
")",
")",
"{",
"this",
".",
"header",
"(",
"'Content-Type'",
",",
"'application/x-www-form-urlencoded;charset=utf-8'",
")",
";",
"contentType",
"=",
"this",
".",
"header",
"(",
"'Content-Type'",
")",
";",
"}",
"//if data is used in body, it needs some modifications regarding the content type",
"if",
"(",
"_data",
"&&",
"_dataInBody",
"(",
")",
")",
"{",
"if",
"(",
"typeof",
"body",
"!==",
"'string'",
")",
"{",
"body",
"=",
"''",
";",
"}",
"if",
"(",
"contentType",
".",
"indexOf",
"(",
"'json'",
")",
">",
"-",
"1",
")",
"{",
"try",
"{",
"body",
"=",
"JSON",
".",
"stringify",
"(",
"_data",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'Unable to stringify body\\'s content : '",
"+",
"e",
".",
"name",
")",
";",
"}",
"}",
"else",
"{",
"isUrlEncoded",
"=",
"contentType",
"&&",
"contentType",
".",
"indexOf",
"(",
"'x-www-form-urlencoded'",
")",
">",
"1",
";",
"for",
"(",
"key",
"in",
"_data",
")",
"{",
"if",
"(",
"isUrlEncoded",
")",
"{",
"body",
"+=",
"encodeURIComponent",
"(",
"key",
")",
"+",
"'='",
"+",
"encodeURIComponent",
"(",
"_data",
"[",
"key",
"]",
")",
"+",
"'&'",
";",
"}",
"else",
"{",
"body",
"+=",
"key",
"+",
"'='",
"+",
"_data",
"[",
"key",
"]",
"+",
"'\\n\\r'",
";",
"}",
"}",
"}",
"}",
"//open the XHR request",
"openParams",
"=",
"[",
"method",
",",
"url",
",",
"async",
"]",
";",
"if",
"(",
"data",
".",
"auth",
")",
"{",
"openParams",
".",
"push",
"(",
"data",
".",
"auth",
".",
"user",
")",
";",
"openParams",
".",
"push",
"(",
"data",
".",
"auth",
".",
"passwd",
")",
";",
"}",
"request",
".",
"open",
".",
"apply",
"(",
"request",
",",
"openParams",
")",
";",
"//set the headers",
"for",
"(",
"header",
"in",
"data",
".",
"headers",
")",
"{",
"request",
".",
"setRequestHeader",
"(",
"header",
",",
"data",
".",
"headers",
"[",
"header",
"]",
")",
";",
"}",
"//bind events",
"request",
".",
"onprogress",
"=",
"function",
"(",
"e",
")",
"{",
"if",
"(",
"e",
".",
"lengthComputable",
")",
"{",
"self",
".",
"trigger",
"(",
"'progress'",
",",
"e",
".",
"loaded",
"/",
"e",
".",
"total",
")",
";",
"}",
"}",
";",
"request",
".",
"onload",
"=",
"function",
"onRequestLoad",
"(",
")",
"{",
"var",
"response",
"=",
"request",
".",
"responseText",
";",
"if",
"(",
"timeoutId",
")",
"{",
"clearTimeout",
"(",
"timeoutId",
")",
";",
"}",
"if",
"(",
"this",
".",
"status",
">=",
"200",
"&&",
"this",
".",
"status",
"<",
"300",
")",
"{",
"if",
"(",
"typeof",
"processRes",
"===",
"'function'",
")",
"{",
"response",
"=",
"processRes",
"(",
"response",
")",
";",
"}",
"self",
".",
"trigger",
"(",
"'success'",
",",
"response",
")",
";",
"}",
"self",
".",
"trigger",
"(",
"this",
".",
"status",
",",
"response",
")",
";",
"self",
".",
"trigger",
"(",
"'end'",
",",
"response",
")",
";",
"}",
";",
"request",
".",
"onerror",
"=",
"function",
"onRequestError",
"(",
"err",
")",
"{",
"if",
"(",
"timeoutId",
")",
"{",
"clearTimeout",
"(",
"timeoutId",
")",
";",
"}",
"self",
".",
"trigger",
"(",
"'error'",
",",
"err",
",",
"arguments",
")",
";",
"}",
";",
"//sets the timeout",
"if",
"(",
"timeout",
")",
"{",
"timeoutId",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"trigger",
"(",
"'timeout'",
",",
"{",
"type",
":",
"'timeout'",
",",
"expiredAfter",
":",
"timeout",
"}",
",",
"request",
",",
"arguments",
")",
";",
"request",
".",
"abort",
"(",
")",
";",
"}",
",",
"timeout",
")",
";",
"}",
"//send the request",
"request",
".",
"send",
"(",
"body",
")",
";",
"}"
] | Create and send an XHR query.
@param {String} url - the url
@param {Function} processRes - to modify / process the response before sent to events. | [
"Create",
"and",
"send",
"an",
"XHR",
"query",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L441-L546 | |
23,627 | krampstudio/aja.js | src/aja.js | function(url){
var self = this;
var head = document.querySelector('head') || document.querySelector('body');
var async = data.sync !== true;
var script;
if(!head){
throw new Error('Ok, wait a second, you want to load a script, but you don\'t have at least a head or body tag...');
}
script = document.createElement('script');
script.async = async;
script.src = url;
script.onerror = function onScriptError(){
self.trigger('error', arguments);
head.removeChild(script);
};
script.onload = function onScriptLoad(){
self.trigger('success', arguments);
};
head.appendChild(script);
} | javascript | function(url){
var self = this;
var head = document.querySelector('head') || document.querySelector('body');
var async = data.sync !== true;
var script;
if(!head){
throw new Error('Ok, wait a second, you want to load a script, but you don\'t have at least a head or body tag...');
}
script = document.createElement('script');
script.async = async;
script.src = url;
script.onerror = function onScriptError(){
self.trigger('error', arguments);
head.removeChild(script);
};
script.onload = function onScriptLoad(){
self.trigger('success', arguments);
};
head.appendChild(script);
} | [
"function",
"(",
"url",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"head",
"=",
"document",
".",
"querySelector",
"(",
"'head'",
")",
"||",
"document",
".",
"querySelector",
"(",
"'body'",
")",
";",
"var",
"async",
"=",
"data",
".",
"sync",
"!==",
"true",
";",
"var",
"script",
";",
"if",
"(",
"!",
"head",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Ok, wait a second, you want to load a script, but you don\\'t have at least a head or body tag...'",
")",
";",
"}",
"script",
"=",
"document",
".",
"createElement",
"(",
"'script'",
")",
";",
"script",
".",
"async",
"=",
"async",
";",
"script",
".",
"src",
"=",
"url",
";",
"script",
".",
"onerror",
"=",
"function",
"onScriptError",
"(",
")",
"{",
"self",
".",
"trigger",
"(",
"'error'",
",",
"arguments",
")",
";",
"head",
".",
"removeChild",
"(",
"script",
")",
";",
"}",
";",
"script",
".",
"onload",
"=",
"function",
"onScriptLoad",
"(",
")",
"{",
"self",
".",
"trigger",
"(",
"'success'",
",",
"arguments",
")",
";",
"}",
";",
"head",
".",
"appendChild",
"(",
"script",
")",
";",
"}"
] | Loads a script.
This kind of ugly script loading is sometimes used by 3rd part libraries to load
a configured script. For example, to embed google analytics or a twitter button.
@this {Aja} call bound to the Aja context
@param {String} url - the url | [
"Loads",
"a",
"script",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L599-L622 | |
23,628 | krampstudio/aja.js | src/aja.js | _buildQuery | function _buildQuery(){
var url = data.url;
var cache = typeof data.cache !== 'undefined' ? !!data.cache : true;
var queryString = data.queryString || '';
var _data = data.data;
//add a cache buster
if(cache === false){
queryString += '&ajabuster=' + new Date().getTime();
}
url = appendQueryString(url, queryString);
if(_data && !_dataInBody()){
url = appendQueryString(url, _data);
}
return url;
} | javascript | function _buildQuery(){
var url = data.url;
var cache = typeof data.cache !== 'undefined' ? !!data.cache : true;
var queryString = data.queryString || '';
var _data = data.data;
//add a cache buster
if(cache === false){
queryString += '&ajabuster=' + new Date().getTime();
}
url = appendQueryString(url, queryString);
if(_data && !_dataInBody()){
url = appendQueryString(url, _data);
}
return url;
} | [
"function",
"_buildQuery",
"(",
")",
"{",
"var",
"url",
"=",
"data",
".",
"url",
";",
"var",
"cache",
"=",
"typeof",
"data",
".",
"cache",
"!==",
"'undefined'",
"?",
"!",
"!",
"data",
".",
"cache",
":",
"true",
";",
"var",
"queryString",
"=",
"data",
".",
"queryString",
"||",
"''",
";",
"var",
"_data",
"=",
"data",
".",
"data",
";",
"//add a cache buster",
"if",
"(",
"cache",
"===",
"false",
")",
"{",
"queryString",
"+=",
"'&ajabuster='",
"+",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
";",
"}",
"url",
"=",
"appendQueryString",
"(",
"url",
",",
"queryString",
")",
";",
"if",
"(",
"_data",
"&&",
"!",
"_dataInBody",
"(",
")",
")",
"{",
"url",
"=",
"appendQueryString",
"(",
"url",
",",
"_data",
")",
";",
"}",
"return",
"url",
";",
"}"
] | Build the URL to run the request against.
@private
@memberof aja
@returns {String} the URL | [
"Build",
"the",
"URL",
"to",
"run",
"the",
"request",
"against",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L672-L690 |
23,629 | krampstudio/aja.js | src/aja.js | function(params){
var object = {};
if(typeof params === 'string'){
params.replace('?', '').split('&').forEach(function(kv){
var pair = kv.split('=');
if(pair.length === 2){
object[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
});
} else {
object = params;
}
return this.plainObject(object);
} | javascript | function(params){
var object = {};
if(typeof params === 'string'){
params.replace('?', '').split('&').forEach(function(kv){
var pair = kv.split('=');
if(pair.length === 2){
object[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
}
});
} else {
object = params;
}
return this.plainObject(object);
} | [
"function",
"(",
"params",
")",
"{",
"var",
"object",
"=",
"{",
"}",
";",
"if",
"(",
"typeof",
"params",
"===",
"'string'",
")",
"{",
"params",
".",
"replace",
"(",
"'?'",
",",
"''",
")",
".",
"split",
"(",
"'&'",
")",
".",
"forEach",
"(",
"function",
"(",
"kv",
")",
"{",
"var",
"pair",
"=",
"kv",
".",
"split",
"(",
"'='",
")",
";",
"if",
"(",
"pair",
".",
"length",
"===",
"2",
")",
"{",
"object",
"[",
"decodeURIComponent",
"(",
"pair",
"[",
"0",
"]",
")",
"]",
"=",
"decodeURIComponent",
"(",
"pair",
"[",
"1",
"]",
")",
";",
"}",
"}",
")",
";",
"}",
"else",
"{",
"object",
"=",
"params",
";",
"}",
"return",
"this",
".",
"plainObject",
"(",
"object",
")",
";",
"}"
] | Check the queryString, and create an object if a string is given.
@param {String|Object} params
@returns {Object} key/value based queryString
@throws {TypeError} if wrong params type or if the string isn't parseable | [
"Check",
"the",
"queryString",
"and",
"create",
"an",
"object",
"if",
"a",
"string",
"is",
"given",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L786-L800 | |
23,630 | krampstudio/aja.js | src/aja.js | function(functionName){
functionName = this.string(functionName);
if(!/^([a-zA-Z_])([a-zA-Z0-9_\-])+$/.test(functionName)){
throw new TypeError('a valid function name is expected, ' + functionName + ' [' + (typeof functionName) + '] given');
}
return functionName;
} | javascript | function(functionName){
functionName = this.string(functionName);
if(!/^([a-zA-Z_])([a-zA-Z0-9_\-])+$/.test(functionName)){
throw new TypeError('a valid function name is expected, ' + functionName + ' [' + (typeof functionName) + '] given');
}
return functionName;
} | [
"function",
"(",
"functionName",
")",
"{",
"functionName",
"=",
"this",
".",
"string",
"(",
"functionName",
")",
";",
"if",
"(",
"!",
"/",
"^([a-zA-Z_])([a-zA-Z0-9_\\-])+$",
"/",
".",
"test",
"(",
"functionName",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'a valid function name is expected, '",
"+",
"functionName",
"+",
"' ['",
"+",
"(",
"typeof",
"functionName",
")",
"+",
"'] given'",
")",
";",
"}",
"return",
"functionName",
";",
"}"
] | Check if the parameter is a valid JavaScript function name.
@param {String} functionName
@returns {String} same as input if valid
@throws {TypeError} check it's a string and a valid name against the pattern inside. | [
"Check",
"if",
"the",
"parameter",
"is",
"a",
"valid",
"JavaScript",
"function",
"name",
"."
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/src/aja.js#L823-L829 | |
23,631 | krampstudio/aja.js | Gruntfile.js | function(req, res, next) {
if (/aja\.js$/.test(req.url)) {
return res.end(grunt.file.read(coverageDir + '/instrument/src/aja.js'));
}
return next();
} | javascript | function(req, res, next) {
if (/aja\.js$/.test(req.url)) {
return res.end(grunt.file.read(coverageDir + '/instrument/src/aja.js'));
}
return next();
} | [
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"if",
"(",
"/",
"aja\\.js$",
"/",
".",
"test",
"(",
"req",
".",
"url",
")",
")",
"{",
"return",
"res",
".",
"end",
"(",
"grunt",
".",
"file",
".",
"read",
"(",
"coverageDir",
"+",
"'/instrument/src/aja.js'",
")",
")",
";",
"}",
"return",
"next",
"(",
")",
";",
"}"
] | to serve instrumented code to the tests runners | [
"to",
"serve",
"instrumented",
"code",
"to",
"the",
"tests",
"runners"
] | 127aa6d39c73c8b6455ec3de009e1c5da4aa003e | https://github.com/krampstudio/aja.js/blob/127aa6d39c73c8b6455ec3de009e1c5da4aa003e/Gruntfile.js#L61-L66 | |
23,632 | NightfallAlicorn/urban-dictionary | urban-dictionary.js | get | function get (url, callback) {
// https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_http_get_options_callback
http.get(url, (result) => {
const contentType = result.headers['content-type']
const statusCode = result.statusCode
let error
if (statusCode !== 200) {
error = new Error(`Unable to send request for definitions. Status code: '${statusCode}'`)
error.code = 'ERR_REQUEST_SEND'
} else if (contentType.indexOf('application/json') === -1) {
error = new Error(`Content retrieved isn't JSON. Content type: '${contentType}'`)
error.code = 'ERR_RESPONSE_NOT_JSON'
}
if (error) {
// Removes response data to clear up memory.
result.resume()
callback(error)
return
}
result.setEncoding('utf8')
let rawData = ''
result.on('data', (buffer) => {
rawData += buffer
})
result.on('end', () => {
let data = null
let error = null
try {
data = JSON.parse(rawData)
} catch (unusedError) {
// In case somehow the data got set to not null. This is more of a failsafe.
data = null
error = new Error('Failed to parse retrieved Urban Dictionary JSON.')
error.code = 'ERR_JSON_PARSE'
}
callback(error, data)
})
})
} | javascript | function get (url, callback) {
// https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_http_get_options_callback
http.get(url, (result) => {
const contentType = result.headers['content-type']
const statusCode = result.statusCode
let error
if (statusCode !== 200) {
error = new Error(`Unable to send request for definitions. Status code: '${statusCode}'`)
error.code = 'ERR_REQUEST_SEND'
} else if (contentType.indexOf('application/json') === -1) {
error = new Error(`Content retrieved isn't JSON. Content type: '${contentType}'`)
error.code = 'ERR_RESPONSE_NOT_JSON'
}
if (error) {
// Removes response data to clear up memory.
result.resume()
callback(error)
return
}
result.setEncoding('utf8')
let rawData = ''
result.on('data', (buffer) => {
rawData += buffer
})
result.on('end', () => {
let data = null
let error = null
try {
data = JSON.parse(rawData)
} catch (unusedError) {
// In case somehow the data got set to not null. This is more of a failsafe.
data = null
error = new Error('Failed to parse retrieved Urban Dictionary JSON.')
error.code = 'ERR_JSON_PARSE'
}
callback(error, data)
})
})
} | [
"function",
"get",
"(",
"url",
",",
"callback",
")",
"{",
"// https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_http_get_options_callback",
"http",
".",
"get",
"(",
"url",
",",
"(",
"result",
")",
"=>",
"{",
"const",
"contentType",
"=",
"result",
".",
"headers",
"[",
"'content-type'",
"]",
"const",
"statusCode",
"=",
"result",
".",
"statusCode",
"let",
"error",
"if",
"(",
"statusCode",
"!==",
"200",
")",
"{",
"error",
"=",
"new",
"Error",
"(",
"`",
"${",
"statusCode",
"}",
"`",
")",
"error",
".",
"code",
"=",
"'ERR_REQUEST_SEND'",
"}",
"else",
"if",
"(",
"contentType",
".",
"indexOf",
"(",
"'application/json'",
")",
"===",
"-",
"1",
")",
"{",
"error",
"=",
"new",
"Error",
"(",
"`",
"${",
"contentType",
"}",
"`",
")",
"error",
".",
"code",
"=",
"'ERR_RESPONSE_NOT_JSON'",
"}",
"if",
"(",
"error",
")",
"{",
"// Removes response data to clear up memory.",
"result",
".",
"resume",
"(",
")",
"callback",
"(",
"error",
")",
"return",
"}",
"result",
".",
"setEncoding",
"(",
"'utf8'",
")",
"let",
"rawData",
"=",
"''",
"result",
".",
"on",
"(",
"'data'",
",",
"(",
"buffer",
")",
"=>",
"{",
"rawData",
"+=",
"buffer",
"}",
")",
"result",
".",
"on",
"(",
"'end'",
",",
"(",
")",
"=>",
"{",
"let",
"data",
"=",
"null",
"let",
"error",
"=",
"null",
"try",
"{",
"data",
"=",
"JSON",
".",
"parse",
"(",
"rawData",
")",
"}",
"catch",
"(",
"unusedError",
")",
"{",
"// In case somehow the data got set to not null. This is more of a failsafe.",
"data",
"=",
"null",
"error",
"=",
"new",
"Error",
"(",
"'Failed to parse retrieved Urban Dictionary JSON.'",
")",
"error",
".",
"code",
"=",
"'ERR_JSON_PARSE'",
"}",
"callback",
"(",
"error",
",",
"data",
")",
"}",
")",
"}",
")",
"}"
] | Retrieves a JSON parsed object.
@param {string} url The full URL to retrieve from.
@param {function(error, object):void} callback
* argument[0] {error} error
* argument[1] {object} Parsed JSON result. | [
"Retrieves",
"a",
"JSON",
"parsed",
"object",
"."
] | bede6af15644c22841e22c03445e0a697f0fd32f | https://github.com/NightfallAlicorn/urban-dictionary/blob/bede6af15644c22841e22c03445e0a697f0fd32f/urban-dictionary.js#L30-L77 |
23,633 | torifat/flowtype-loader | lib/flowResult.js | difference | function difference(a, b) {
var oldHashes = {};
var errors = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = b.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var error = _step.value;
var hash = JSON.stringify(error.message);
oldHashes[hash] = error;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = a.errors[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _error = _step2.value;
var _hash = JSON.stringify(_error.message);
if (oldHashes[_hash] !== undefined) {
continue;
}
errors.push(JSON.parse(JSON.stringify(_error)));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return {
passed: errors.length === 0,
errors: errors,
flowVersion: a.flowVersion
};
} | javascript | function difference(a, b) {
var oldHashes = {};
var errors = [];
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = b.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var error = _step.value;
var hash = JSON.stringify(error.message);
oldHashes[hash] = error;
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = a.errors[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var _error = _step2.value;
var _hash = JSON.stringify(_error.message);
if (oldHashes[_hash] !== undefined) {
continue;
}
errors.push(JSON.parse(JSON.stringify(_error)));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return {
passed: errors.length === 0,
errors: errors,
flowVersion: a.flowVersion
};
} | [
"function",
"difference",
"(",
"a",
",",
"b",
")",
"{",
"var",
"oldHashes",
"=",
"{",
"}",
";",
"var",
"errors",
"=",
"[",
"]",
";",
"var",
"_iteratorNormalCompletion",
"=",
"true",
";",
"var",
"_didIteratorError",
"=",
"false",
";",
"var",
"_iteratorError",
"=",
"undefined",
";",
"try",
"{",
"for",
"(",
"var",
"_iterator",
"=",
"b",
".",
"errors",
"[",
"Symbol",
".",
"iterator",
"]",
"(",
")",
",",
"_step",
";",
"!",
"(",
"_iteratorNormalCompletion",
"=",
"(",
"_step",
"=",
"_iterator",
".",
"next",
"(",
")",
")",
".",
"done",
")",
";",
"_iteratorNormalCompletion",
"=",
"true",
")",
"{",
"var",
"error",
"=",
"_step",
".",
"value",
";",
"var",
"hash",
"=",
"JSON",
".",
"stringify",
"(",
"error",
".",
"message",
")",
";",
"oldHashes",
"[",
"hash",
"]",
"=",
"error",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"_didIteratorError",
"=",
"true",
";",
"_iteratorError",
"=",
"err",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"!",
"_iteratorNormalCompletion",
"&&",
"_iterator",
".",
"return",
")",
"{",
"_iterator",
".",
"return",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"_didIteratorError",
")",
"{",
"throw",
"_iteratorError",
";",
"}",
"}",
"}",
"var",
"_iteratorNormalCompletion2",
"=",
"true",
";",
"var",
"_didIteratorError2",
"=",
"false",
";",
"var",
"_iteratorError2",
"=",
"undefined",
";",
"try",
"{",
"for",
"(",
"var",
"_iterator2",
"=",
"a",
".",
"errors",
"[",
"Symbol",
".",
"iterator",
"]",
"(",
")",
",",
"_step2",
";",
"!",
"(",
"_iteratorNormalCompletion2",
"=",
"(",
"_step2",
"=",
"_iterator2",
".",
"next",
"(",
")",
")",
".",
"done",
")",
";",
"_iteratorNormalCompletion2",
"=",
"true",
")",
"{",
"var",
"_error",
"=",
"_step2",
".",
"value",
";",
"var",
"_hash",
"=",
"JSON",
".",
"stringify",
"(",
"_error",
".",
"message",
")",
";",
"if",
"(",
"oldHashes",
"[",
"_hash",
"]",
"!==",
"undefined",
")",
"{",
"continue",
";",
"}",
"errors",
".",
"push",
"(",
"JSON",
".",
"parse",
"(",
"JSON",
".",
"stringify",
"(",
"_error",
")",
")",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"_didIteratorError2",
"=",
"true",
";",
"_iteratorError2",
"=",
"err",
";",
"}",
"finally",
"{",
"try",
"{",
"if",
"(",
"!",
"_iteratorNormalCompletion2",
"&&",
"_iterator2",
".",
"return",
")",
"{",
"_iterator2",
".",
"return",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"_didIteratorError2",
")",
"{",
"throw",
"_iteratorError2",
";",
"}",
"}",
"}",
"return",
"{",
"passed",
":",
"errors",
".",
"length",
"===",
"0",
",",
"errors",
":",
"errors",
",",
"flowVersion",
":",
"a",
".",
"flowVersion",
"}",
";",
"}"
] | Returns a result that is a - b | [
"Returns",
"a",
"result",
"that",
"is",
"a",
"-",
"b"
] | 7334a152e215dbd43cd86f7ea18e5cf1d9c5d714 | https://github.com/torifat/flowtype-loader/blob/7334a152e215dbd43cd86f7ea18e5cf1d9c5d714/lib/flowResult.js#L28-L91 |
23,634 | wdamien/node-easel | src/easeljs/filters/ColorFilter.js | function(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset) {
this.initialize(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset);
} | javascript | function(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset) {
this.initialize(redMultiplier, greenMultiplier, blueMultiplier, alphaMultiplier, redOffset, greenOffset, blueOffset, alphaOffset);
} | [
"function",
"(",
"redMultiplier",
",",
"greenMultiplier",
",",
"blueMultiplier",
",",
"alphaMultiplier",
",",
"redOffset",
",",
"greenOffset",
",",
"blueOffset",
",",
"alphaOffset",
")",
"{",
"this",
".",
"initialize",
"(",
"redMultiplier",
",",
"greenMultiplier",
",",
"blueMultiplier",
",",
"alphaMultiplier",
",",
"redOffset",
",",
"greenOffset",
",",
"blueOffset",
",",
"alphaOffset",
")",
";",
"}"
] | Applies a color transform to DisplayObjects.
<h4>Example</h4>
This example draws a red circle, and then transforms it to Blue. This is accomplished by multiplying all the channels
to 0 (except alpha, which is set to 1), and then adding 255 to the blue channel.
var shape = new createjs.Shape().set({x:100,y:100});
shape.graphics.beginFill("#ff0000").drawCircle(0,0,50);
shape.filters = [
new createjs.ColorFilter(0,0,0,1, 0,0,255,0)
];
shape.cache(-50, -50, 100, 100);
See {{#crossLink "Filter"}}{{/crossLink}} for an more information on applying filters.
@class ColorFilter
@param {Number} [redMultiplier=1] The amount to multiply against the red channel. This is a range between 0 and 1.
@param {Number} [greenMultiplier=1] The amount to multiply against the green channel. This is a range between 0 and 1.
@param {Number} [blueMultiplier=1] The amount to multiply against the blue channel. This is a range between 0 and 1.
@param {Number} [alphaMultiplier=1] The amount to multiply against the alpha channel. This is a range between 0 and 1.
@param {Number} [redOffset=0] The amount to add to the red channel after it has been multiplied. This is a range
between -255 and 255.
@param {Number} [greenOffset=0] The amount to add to the green channel after it has been multiplied. This is a range
between -255 and 255.
@param {Number} [blueOffset=0] The amount to add to the blue channel after it has been multiplied. This is a range
between -255 and 255.
@param {Number} [alphaOffset=0] The amount to add to the alpha channel after it has been multiplied. This is a range
between -255 and 255.
@constructor
@extends Filter | [
"Applies",
"a",
"color",
"transform",
"to",
"DisplayObjects",
"."
] | 51a06f359f52f539c97219e4528340ae5d5bae1c | https://github.com/wdamien/node-easel/blob/51a06f359f52f539c97219e4528340ae5d5bae1c/src/easeljs/filters/ColorFilter.js#L71-L73 | |
23,635 | bluejava/zousan | src/zousan.js | resolveClient | function resolveClient(c,arg)
{
if(typeof c.y === "function")
{
try {
var yret = c.y.call(_undefined,arg);
c.p.resolve(yret);
}
catch(err) { c.p.reject(err) }
}
else
c.p.resolve(arg); // pass this along...
} | javascript | function resolveClient(c,arg)
{
if(typeof c.y === "function")
{
try {
var yret = c.y.call(_undefined,arg);
c.p.resolve(yret);
}
catch(err) { c.p.reject(err) }
}
else
c.p.resolve(arg); // pass this along...
} | [
"function",
"resolveClient",
"(",
"c",
",",
"arg",
")",
"{",
"if",
"(",
"typeof",
"c",
".",
"y",
"===",
"\"function\"",
")",
"{",
"try",
"{",
"var",
"yret",
"=",
"c",
".",
"y",
".",
"call",
"(",
"_undefined",
",",
"arg",
")",
";",
"c",
".",
"p",
".",
"resolve",
"(",
"yret",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"c",
".",
"p",
".",
"reject",
"(",
"err",
")",
"}",
"}",
"else",
"c",
".",
"p",
".",
"resolve",
"(",
"arg",
")",
";",
"// pass this along...",
"}"
] | END of prototype function list | [
"END",
"of",
"prototype",
"function",
"list"
] | f295935672f91ac46cf681414491143c0ae4390f | https://github.com/bluejava/zousan/blob/f295935672f91ac46cf681414491143c0ae4390f/src/zousan.js#L246-L258 |
23,636 | bluejava/zousan | src/zousan.js | rp | function rp(p,i)
{
if(!p || typeof p.then !== "function")
p = Zousan.resolve(p);
p.then(
function(yv) { results[i] = yv; rc++; if(rc == pa.length) retP.resolve(results); },
function(nv) { retP.reject(nv); }
);
} | javascript | function rp(p,i)
{
if(!p || typeof p.then !== "function")
p = Zousan.resolve(p);
p.then(
function(yv) { results[i] = yv; rc++; if(rc == pa.length) retP.resolve(results); },
function(nv) { retP.reject(nv); }
);
} | [
"function",
"rp",
"(",
"p",
",",
"i",
")",
"{",
"if",
"(",
"!",
"p",
"||",
"typeof",
"p",
".",
"then",
"!==",
"\"function\"",
")",
"p",
"=",
"Zousan",
".",
"resolve",
"(",
"p",
")",
";",
"p",
".",
"then",
"(",
"function",
"(",
"yv",
")",
"{",
"results",
"[",
"i",
"]",
"=",
"yv",
";",
"rc",
"++",
";",
"if",
"(",
"rc",
"==",
"pa",
".",
"length",
")",
"retP",
".",
"resolve",
"(",
"results",
")",
";",
"}",
",",
"function",
"(",
"nv",
")",
"{",
"retP",
".",
"reject",
"(",
"nv",
")",
";",
"}",
")",
";",
"}"
] | results and resolved count | [
"results",
"and",
"resolved",
"count"
] | f295935672f91ac46cf681414491143c0ae4390f | https://github.com/bluejava/zousan/blob/f295935672f91ac46cf681414491143c0ae4390f/src/zousan.js#L290-L298 |
23,637 | eeue56/elm-static-html | index.js | function(workingDir, elmPackage){
elmPackage['native-modules'] = true;
var sources = elmPackage['source-directories'].map(function(dir){
return path.join(workingDir, dir);
});
sources.push('.');
elmPackage['source-directories'] = sources;
elmPackage['dependencies']["eeue56/elm-html-in-elm"] = "2.0.0 <= v < 3.0.0";
return elmPackage;
} | javascript | function(workingDir, elmPackage){
elmPackage['native-modules'] = true;
var sources = elmPackage['source-directories'].map(function(dir){
return path.join(workingDir, dir);
});
sources.push('.');
elmPackage['source-directories'] = sources;
elmPackage['dependencies']["eeue56/elm-html-in-elm"] = "2.0.0 <= v < 3.0.0";
return elmPackage;
} | [
"function",
"(",
"workingDir",
",",
"elmPackage",
")",
"{",
"elmPackage",
"[",
"'native-modules'",
"]",
"=",
"true",
";",
"var",
"sources",
"=",
"elmPackage",
"[",
"'source-directories'",
"]",
".",
"map",
"(",
"function",
"(",
"dir",
")",
"{",
"return",
"path",
".",
"join",
"(",
"workingDir",
",",
"dir",
")",
";",
"}",
")",
";",
"sources",
".",
"push",
"(",
"'.'",
")",
";",
"elmPackage",
"[",
"'source-directories'",
"]",
"=",
"sources",
";",
"elmPackage",
"[",
"'dependencies'",
"]",
"[",
"\"eeue56/elm-html-in-elm\"",
"]",
"=",
"\"2.0.0 <= v < 3.0.0\"",
";",
"return",
"elmPackage",
";",
"}"
] | fix an elm package file so that it will work with our project and install our deps | [
"fix",
"an",
"elm",
"package",
"file",
"so",
"that",
"it",
"will",
"work",
"with",
"our",
"project",
"and",
"install",
"our",
"deps"
] | e3ad85b0d06c0baabf9c7de38bf98a53e2fb0fae | https://github.com/eeue56/elm-static-html/blob/e3ad85b0d06c0baabf9c7de38bf98a53e2fb0fae/index.js#L152-L163 | |
23,638 | jonschlinkert/object-copy | index.js | has | function has(obj, val) {
val = arrayify(val);
var len = val.length;
if (isObject(obj)) {
for (var key in obj) {
if (val.indexOf(key) > -1) {
return true;
}
}
var keys = nativeKeys(obj);
return has(keys, val);
}
if (Array.isArray(obj)) {
var arr = obj;
while (len--) {
if (arr.indexOf(val[len]) > -1) {
return true;
}
}
return false;
}
throw new TypeError('expected an array or object.');
} | javascript | function has(obj, val) {
val = arrayify(val);
var len = val.length;
if (isObject(obj)) {
for (var key in obj) {
if (val.indexOf(key) > -1) {
return true;
}
}
var keys = nativeKeys(obj);
return has(keys, val);
}
if (Array.isArray(obj)) {
var arr = obj;
while (len--) {
if (arr.indexOf(val[len]) > -1) {
return true;
}
}
return false;
}
throw new TypeError('expected an array or object.');
} | [
"function",
"has",
"(",
"obj",
",",
"val",
")",
"{",
"val",
"=",
"arrayify",
"(",
"val",
")",
";",
"var",
"len",
"=",
"val",
".",
"length",
";",
"if",
"(",
"isObject",
"(",
"obj",
")",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"val",
".",
"indexOf",
"(",
"key",
")",
">",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"}",
"var",
"keys",
"=",
"nativeKeys",
"(",
"obj",
")",
";",
"return",
"has",
"(",
"keys",
",",
"val",
")",
";",
"}",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
")",
")",
"{",
"var",
"arr",
"=",
"obj",
";",
"while",
"(",
"len",
"--",
")",
"{",
"if",
"(",
"arr",
".",
"indexOf",
"(",
"val",
"[",
"len",
"]",
")",
">",
"-",
"1",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}",
"throw",
"new",
"TypeError",
"(",
"'expected an array or object.'",
")",
";",
"}"
] | Returns true if an array has any of the given elements, or an
object has any of the given keys.
```js
has(['a', 'b', 'c'], 'c');
//=> true
has(['a', 'b', 'c'], ['c', 'z']);
//=> true
has({a: 'b', c: 'd'}, ['c', 'z']);
//=> true
```
@param {Object} `obj`
@param {String|Array} `val`
@return {Boolean} | [
"Returns",
"true",
"if",
"an",
"array",
"has",
"any",
"of",
"the",
"given",
"elements",
"or",
"an",
"object",
"has",
"any",
"of",
"the",
"given",
"keys",
"."
] | 45c79022e7b56e2f6456cac9ff44d6876fc7738b | https://github.com/jonschlinkert/object-copy/blob/45c79022e7b56e2f6456cac9ff44d6876fc7738b/index.js#L91-L117 |
23,639 | rictorres/node-rpm-builder | index.js | setupTempDir | function setupTempDir(tmpDir) {
var rpmStructure = ['BUILD', 'BUILDROOT', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS'];
// If the tmpDir exists (probably from previous build), delete it first
if (fsx.existsSync(tmpDir)) {
logger(chalk.cyan('Removing old temporary directory.'));
fsx.removeSync(tmpDir);
}
// Create RPM folder structure
logger(chalk.cyan('Creating RPM directory structure at:'), tmpDir);
_.forEach(rpmStructure, function(dirName) {
fsx.mkdirpSync(path.join(tmpDir, dirName));
});
} | javascript | function setupTempDir(tmpDir) {
var rpmStructure = ['BUILD', 'BUILDROOT', 'RPMS', 'SOURCES', 'SPECS', 'SRPMS'];
// If the tmpDir exists (probably from previous build), delete it first
if (fsx.existsSync(tmpDir)) {
logger(chalk.cyan('Removing old temporary directory.'));
fsx.removeSync(tmpDir);
}
// Create RPM folder structure
logger(chalk.cyan('Creating RPM directory structure at:'), tmpDir);
_.forEach(rpmStructure, function(dirName) {
fsx.mkdirpSync(path.join(tmpDir, dirName));
});
} | [
"function",
"setupTempDir",
"(",
"tmpDir",
")",
"{",
"var",
"rpmStructure",
"=",
"[",
"'BUILD'",
",",
"'BUILDROOT'",
",",
"'RPMS'",
",",
"'SOURCES'",
",",
"'SPECS'",
",",
"'SRPMS'",
"]",
";",
"// If the tmpDir exists (probably from previous build), delete it first",
"if",
"(",
"fsx",
".",
"existsSync",
"(",
"tmpDir",
")",
")",
"{",
"logger",
"(",
"chalk",
".",
"cyan",
"(",
"'Removing old temporary directory.'",
")",
")",
";",
"fsx",
".",
"removeSync",
"(",
"tmpDir",
")",
";",
"}",
"// Create RPM folder structure",
"logger",
"(",
"chalk",
".",
"cyan",
"(",
"'Creating RPM directory structure at:'",
")",
",",
"tmpDir",
")",
";",
"_",
".",
"forEach",
"(",
"rpmStructure",
",",
"function",
"(",
"dirName",
")",
"{",
"fsx",
".",
"mkdirpSync",
"(",
"path",
".",
"join",
"(",
"tmpDir",
",",
"dirName",
")",
")",
";",
"}",
")",
";",
"}"
] | Creates the folder structure needed to create
the RPM package.
@param {String} tmpDir the path where the folder structure will reside | [
"Creates",
"the",
"folder",
"structure",
"needed",
"to",
"create",
"the",
"RPM",
"package",
"."
] | 883b04cab50640b17332d9f51cfb1f2d32c96996 | https://github.com/rictorres/node-rpm-builder/blob/883b04cab50640b17332d9f51cfb1f2d32c96996/index.js#L21-L35 |
23,640 | rictorres/node-rpm-builder | index.js | buildRpm | function buildRpm(buildRoot, specFile, rpmDest, execOpts, cb) {
// Build the RPM package.
var cmd = [
'rpmbuild',
'-bb',
'-vv',
'--buildroot',
buildRoot,
specFile
].join(' ');
logger(chalk.cyan('Executing:'), cmd);
execOpts = execOpts || {};
exec(cmd, execOpts, function rpmbuild(err, stdout) {
if (err) {
return cb(err);
}
if (stdout) {
var rpm = stdout.match(/(\/.+\..+\.rpm)/);
if (rpm && rpm.length > 0) {
var rpmDestination = rpm[0];
if (rpmDest) {
rpmDestination = path.join(rpmDest, path.basename(rpmDestination));
logger(chalk.cyan('Copying RPM package to:'), rpmDestination);
fsx.copySync(rpm[0], rpmDestination);
}
return cb(null, rpmDestination);
}
}
});
} | javascript | function buildRpm(buildRoot, specFile, rpmDest, execOpts, cb) {
// Build the RPM package.
var cmd = [
'rpmbuild',
'-bb',
'-vv',
'--buildroot',
buildRoot,
specFile
].join(' ');
logger(chalk.cyan('Executing:'), cmd);
execOpts = execOpts || {};
exec(cmd, execOpts, function rpmbuild(err, stdout) {
if (err) {
return cb(err);
}
if (stdout) {
var rpm = stdout.match(/(\/.+\..+\.rpm)/);
if (rpm && rpm.length > 0) {
var rpmDestination = rpm[0];
if (rpmDest) {
rpmDestination = path.join(rpmDest, path.basename(rpmDestination));
logger(chalk.cyan('Copying RPM package to:'), rpmDestination);
fsx.copySync(rpm[0], rpmDestination);
}
return cb(null, rpmDestination);
}
}
});
} | [
"function",
"buildRpm",
"(",
"buildRoot",
",",
"specFile",
",",
"rpmDest",
",",
"execOpts",
",",
"cb",
")",
"{",
"// Build the RPM package.",
"var",
"cmd",
"=",
"[",
"'rpmbuild'",
",",
"'-bb'",
",",
"'-vv'",
",",
"'--buildroot'",
",",
"buildRoot",
",",
"specFile",
"]",
".",
"join",
"(",
"' '",
")",
";",
"logger",
"(",
"chalk",
".",
"cyan",
"(",
"'Executing:'",
")",
",",
"cmd",
")",
";",
"execOpts",
"=",
"execOpts",
"||",
"{",
"}",
";",
"exec",
"(",
"cmd",
",",
"execOpts",
",",
"function",
"rpmbuild",
"(",
"err",
",",
"stdout",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"cb",
"(",
"err",
")",
";",
"}",
"if",
"(",
"stdout",
")",
"{",
"var",
"rpm",
"=",
"stdout",
".",
"match",
"(",
"/",
"(\\/.+\\..+\\.rpm)",
"/",
")",
";",
"if",
"(",
"rpm",
"&&",
"rpm",
".",
"length",
">",
"0",
")",
"{",
"var",
"rpmDestination",
"=",
"rpm",
"[",
"0",
"]",
";",
"if",
"(",
"rpmDest",
")",
"{",
"rpmDestination",
"=",
"path",
".",
"join",
"(",
"rpmDest",
",",
"path",
".",
"basename",
"(",
"rpmDestination",
")",
")",
";",
"logger",
"(",
"chalk",
".",
"cyan",
"(",
"'Copying RPM package to:'",
")",
",",
"rpmDestination",
")",
";",
"fsx",
".",
"copySync",
"(",
"rpm",
"[",
"0",
"]",
",",
"rpmDestination",
")",
";",
"}",
"return",
"cb",
"(",
"null",
",",
"rpmDestination",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Runs the rpmbuild tool in a child process.
@param {String} buildRoot where all included files reside
@param {String} specFile path to the file from which the RPM package will be created
@param {String} rpmDest where the .rpm file should be copied to
@param {Function} cb callback function to be executed when the task is done | [
"Runs",
"the",
"rpmbuild",
"tool",
"in",
"a",
"child",
"process",
"."
] | 883b04cab50640b17332d9f51cfb1f2d32c96996 | https://github.com/rictorres/node-rpm-builder/blob/883b04cab50640b17332d9f51cfb1f2d32c96996/index.js#L117-L154 |
23,641 | inikulin/dmn | lib/gen.js | parseIgnoreFile | function parseIgnoreFile(ignoreFile) {
// At first we'll try to determine line endings for ignore file.
// For this we will count \n and \r\n occurrences and choose the one
// which dominates. If we don't have line endings at all we will keep
// default OS line endings.
var lfCount = countOccurrences('\n', ignoreFile.content),
crlfCount = countOccurrences('\r\n', ignoreFile.content);
if (lfCount > 0 || crlfCount > 0)
ignoreFile.eol = lfCount > crlfCount ? '\n' : '\r\n';
ignoreFile.patterns = ignoreFile.content
// Normalize new lines
.replace(/\r\n?/g, '\n')
// Then split content by new line
.split('\n')
// Trim items
.map(function (str) {
return str.trim();
})
// Skip empty strings and comments
.filter(function (str) {
return str && str.indexOf('#') !== 0;
});
} | javascript | function parseIgnoreFile(ignoreFile) {
// At first we'll try to determine line endings for ignore file.
// For this we will count \n and \r\n occurrences and choose the one
// which dominates. If we don't have line endings at all we will keep
// default OS line endings.
var lfCount = countOccurrences('\n', ignoreFile.content),
crlfCount = countOccurrences('\r\n', ignoreFile.content);
if (lfCount > 0 || crlfCount > 0)
ignoreFile.eol = lfCount > crlfCount ? '\n' : '\r\n';
ignoreFile.patterns = ignoreFile.content
// Normalize new lines
.replace(/\r\n?/g, '\n')
// Then split content by new line
.split('\n')
// Trim items
.map(function (str) {
return str.trim();
})
// Skip empty strings and comments
.filter(function (str) {
return str && str.indexOf('#') !== 0;
});
} | [
"function",
"parseIgnoreFile",
"(",
"ignoreFile",
")",
"{",
"// At first we'll try to determine line endings for ignore file.",
"// For this we will count \\n and \\r\\n occurrences and choose the one",
"// which dominates. If we don't have line endings at all we will keep",
"// default OS line endings.",
"var",
"lfCount",
"=",
"countOccurrences",
"(",
"'\\n'",
",",
"ignoreFile",
".",
"content",
")",
",",
"crlfCount",
"=",
"countOccurrences",
"(",
"'\\r\\n'",
",",
"ignoreFile",
".",
"content",
")",
";",
"if",
"(",
"lfCount",
">",
"0",
"||",
"crlfCount",
">",
"0",
")",
"ignoreFile",
".",
"eol",
"=",
"lfCount",
">",
"crlfCount",
"?",
"'\\n'",
":",
"'\\r\\n'",
";",
"ignoreFile",
".",
"patterns",
"=",
"ignoreFile",
".",
"content",
"// Normalize new lines",
".",
"replace",
"(",
"/",
"\\r\\n?",
"/",
"g",
",",
"'\\n'",
")",
"// Then split content by new line",
".",
"split",
"(",
"'\\n'",
")",
"// Trim items",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"return",
"str",
".",
"trim",
"(",
")",
";",
"}",
")",
"// Skip empty strings and comments",
".",
"filter",
"(",
"function",
"(",
"str",
")",
"{",
"return",
"str",
"&&",
"str",
".",
"indexOf",
"(",
"'#'",
")",
"!==",
"0",
";",
"}",
")",
";",
"}"
] | Extract .npmignore file patterns | [
"Extract",
".",
"npmignore",
"file",
"patterns"
] | eda5cadfc5f83aa45062073f2a1ae8e6edc2cb9b | https://github.com/inikulin/dmn/blob/eda5cadfc5f83aa45062073f2a1ae8e6edc2cb9b/lib/gen.js#L43-L72 |
23,642 | inikulin/dmn | lib/clean.js | getCleanTargets | function getCleanTargets() {
var directDeps = targets.map(function (pattern) {
return '*/' + pattern;
}),
indirectDeps = targets.map(function (pattern) {
return '**/node_modules/*/' + pattern;
});
return directDeps.concat(indirectDeps);
} | javascript | function getCleanTargets() {
var directDeps = targets.map(function (pattern) {
return '*/' + pattern;
}),
indirectDeps = targets.map(function (pattern) {
return '**/node_modules/*/' + pattern;
});
return directDeps.concat(indirectDeps);
} | [
"function",
"getCleanTargets",
"(",
")",
"{",
"var",
"directDeps",
"=",
"targets",
".",
"map",
"(",
"function",
"(",
"pattern",
")",
"{",
"return",
"'*/'",
"+",
"pattern",
";",
"}",
")",
",",
"indirectDeps",
"=",
"targets",
".",
"map",
"(",
"function",
"(",
"pattern",
")",
"{",
"return",
"'**/node_modules/*/'",
"+",
"pattern",
";",
"}",
")",
";",
"return",
"directDeps",
".",
"concat",
"(",
"indirectDeps",
")",
";",
"}"
] | Create array of patterns which will be used for cleaning | [
"Create",
"array",
"of",
"patterns",
"which",
"will",
"be",
"used",
"for",
"cleaning"
] | eda5cadfc5f83aa45062073f2a1ae8e6edc2cb9b | https://github.com/inikulin/dmn/blob/eda5cadfc5f83aa45062073f2a1ae8e6edc2cb9b/lib/clean.js#L45-L55 |
23,643 | la-haute-societe/ssh-deploy-release | dist/logger.js | logFatal | function logFatal(message) {
console.log(os.EOL + chalk.red.bold('Fatal error : ' + message));
process.exit(1);
} | javascript | function logFatal(message) {
console.log(os.EOL + chalk.red.bold('Fatal error : ' + message));
process.exit(1);
} | [
"function",
"logFatal",
"(",
"message",
")",
"{",
"console",
".",
"log",
"(",
"os",
".",
"EOL",
"+",
"chalk",
".",
"red",
".",
"bold",
"(",
"'Fatal error : '",
"+",
"message",
")",
")",
";",
"process",
".",
"exit",
"(",
"1",
")",
";",
"}"
] | Log fatal error and exit process
@param message | [
"Log",
"fatal",
"error",
"and",
"exit",
"process"
] | d0e8683f7bd474ba59b3af06b5cefb5e5ff7d669 | https://github.com/la-haute-societe/ssh-deploy-release/blob/d0e8683f7bd474ba59b3af06b5cefb5e5ff7d669/dist/logger.js#L34-L37 |
23,644 | la-haute-societe/ssh-deploy-release | dist/logger.js | logDebug | function logDebug(message) {
if (!debug) {
return;
}
if (!enabled) return;
console.log(os.EOL + chalk.cyan(message));
} | javascript | function logDebug(message) {
if (!debug) {
return;
}
if (!enabled) return;
console.log(os.EOL + chalk.cyan(message));
} | [
"function",
"logDebug",
"(",
"message",
")",
"{",
"if",
"(",
"!",
"debug",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"enabled",
")",
"return",
";",
"console",
".",
"log",
"(",
"os",
".",
"EOL",
"+",
"chalk",
".",
"cyan",
"(",
"message",
")",
")",
";",
"}"
] | Log only if debug is enabled
@param message | [
"Log",
"only",
"if",
"debug",
"is",
"enabled"
] | d0e8683f7bd474ba59b3af06b5cefb5e5ff7d669 | https://github.com/la-haute-societe/ssh-deploy-release/blob/d0e8683f7bd474ba59b3af06b5cefb5e5ff7d669/dist/logger.js#L74-L81 |
23,645 | mikolalysenko/bit-twiddle | twiddle.js | countTrailingZeros | function countTrailingZeros(v) {
var c = 32;
v &= -v;
if (v) c--;
if (v & 0x0000FFFF) c -= 16;
if (v & 0x00FF00FF) c -= 8;
if (v & 0x0F0F0F0F) c -= 4;
if (v & 0x33333333) c -= 2;
if (v & 0x55555555) c -= 1;
return c;
} | javascript | function countTrailingZeros(v) {
var c = 32;
v &= -v;
if (v) c--;
if (v & 0x0000FFFF) c -= 16;
if (v & 0x00FF00FF) c -= 8;
if (v & 0x0F0F0F0F) c -= 4;
if (v & 0x33333333) c -= 2;
if (v & 0x55555555) c -= 1;
return c;
} | [
"function",
"countTrailingZeros",
"(",
"v",
")",
"{",
"var",
"c",
"=",
"32",
";",
"v",
"&=",
"-",
"v",
";",
"if",
"(",
"v",
")",
"c",
"--",
";",
"if",
"(",
"v",
"&",
"0x0000FFFF",
")",
"c",
"-=",
"16",
";",
"if",
"(",
"v",
"&",
"0x00FF00FF",
")",
"c",
"-=",
"8",
";",
"if",
"(",
"v",
"&",
"0x0F0F0F0F",
")",
"c",
"-=",
"4",
";",
"if",
"(",
"v",
"&",
"0x33333333",
")",
"c",
"-=",
"2",
";",
"if",
"(",
"v",
"&",
"0x55555555",
")",
"c",
"-=",
"1",
";",
"return",
"c",
";",
"}"
] | Counts number of trailing zeros | [
"Counts",
"number",
"of",
"trailing",
"zeros"
] | 0c4c32db753108c5ec7e3779d35eb103be8e7ee1 | https://github.com/mikolalysenko/bit-twiddle/blob/0c4c32db753108c5ec7e3779d35eb103be8e7ee1/twiddle.js#L71-L81 |
23,646 | therne/instauuid | index.js | generate | function generate(options) {
options = options || {};
if (typeof options === 'string') options = { type: options };
var type = paramDefault(options.type, 'base64');
var additional = paramDefault(options.additional, 0);
var count = paramDefault(options.countNumber, parseInt(Math.random() * 10000 % 1024));
var rawBuffer = generator.generate(count, additional);
if (type === 'base64') {
// NOTE: this is URL-safe Base64Url format. not pure base64.
// + since UUID is fixed 64bit we don't have to worry about padding(=)
return unLittleEndian(rawBuffer)
.toString('base64')
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
} else if (type === 'hash' || type == 'hex') {
return unLittleEndian(rawBuffer).toString('hex');
} else if (type === 'decimal' || type == 'number') {
return toLong(rawBuffer).toString();
} else if (type === 'long') {
return toLong(rawBuffer);
} else if (type == 'buffer') {
return rawBuffer;
} else if (type == 'buffer_be') {
// to big endian
return unLittleEndian(rawBuffer);
} else if (type == 'raw') {
// OMG, R u serious?
return rawBuffer.toString();
} else throw new TypeError("Unknown encoding: " + type);
} | javascript | function generate(options) {
options = options || {};
if (typeof options === 'string') options = { type: options };
var type = paramDefault(options.type, 'base64');
var additional = paramDefault(options.additional, 0);
var count = paramDefault(options.countNumber, parseInt(Math.random() * 10000 % 1024));
var rawBuffer = generator.generate(count, additional);
if (type === 'base64') {
// NOTE: this is URL-safe Base64Url format. not pure base64.
// + since UUID is fixed 64bit we don't have to worry about padding(=)
return unLittleEndian(rawBuffer)
.toString('base64')
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
} else if (type === 'hash' || type == 'hex') {
return unLittleEndian(rawBuffer).toString('hex');
} else if (type === 'decimal' || type == 'number') {
return toLong(rawBuffer).toString();
} else if (type === 'long') {
return toLong(rawBuffer);
} else if (type == 'buffer') {
return rawBuffer;
} else if (type == 'buffer_be') {
// to big endian
return unLittleEndian(rawBuffer);
} else if (type == 'raw') {
// OMG, R u serious?
return rawBuffer.toString();
} else throw new TypeError("Unknown encoding: " + type);
} | [
"function",
"generate",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"options",
"===",
"'string'",
")",
"options",
"=",
"{",
"type",
":",
"options",
"}",
";",
"var",
"type",
"=",
"paramDefault",
"(",
"options",
".",
"type",
",",
"'base64'",
")",
";",
"var",
"additional",
"=",
"paramDefault",
"(",
"options",
".",
"additional",
",",
"0",
")",
";",
"var",
"count",
"=",
"paramDefault",
"(",
"options",
".",
"countNumber",
",",
"parseInt",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"10000",
"%",
"1024",
")",
")",
";",
"var",
"rawBuffer",
"=",
"generator",
".",
"generate",
"(",
"count",
",",
"additional",
")",
";",
"if",
"(",
"type",
"===",
"'base64'",
")",
"{",
"// NOTE: this is URL-safe Base64Url format. not pure base64.",
"// + since UUID is fixed 64bit we don't have to worry about padding(=)",
"return",
"unLittleEndian",
"(",
"rawBuffer",
")",
".",
"toString",
"(",
"'base64'",
")",
".",
"replace",
"(",
"/",
"\\+",
"/",
"g",
",",
"'-'",
")",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"'_'",
")",
".",
"replace",
"(",
"/",
"=",
"/",
"g",
",",
"''",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'hash'",
"||",
"type",
"==",
"'hex'",
")",
"{",
"return",
"unLittleEndian",
"(",
"rawBuffer",
")",
".",
"toString",
"(",
"'hex'",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'decimal'",
"||",
"type",
"==",
"'number'",
")",
"{",
"return",
"toLong",
"(",
"rawBuffer",
")",
".",
"toString",
"(",
")",
";",
"}",
"else",
"if",
"(",
"type",
"===",
"'long'",
")",
"{",
"return",
"toLong",
"(",
"rawBuffer",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"'buffer'",
")",
"{",
"return",
"rawBuffer",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"'buffer_be'",
")",
"{",
"// to big endian",
"return",
"unLittleEndian",
"(",
"rawBuffer",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"'raw'",
")",
"{",
"// OMG, R u serious?",
"return",
"rawBuffer",
".",
"toString",
"(",
")",
";",
"}",
"else",
"throw",
"new",
"TypeError",
"(",
"\"Unknown encoding: \"",
"+",
"type",
")",
";",
"}"
] | Generate Insta-UUID. | [
"Generate",
"Insta",
"-",
"UUID",
"."
] | cbdd586d38a1fff66520c6c814ab0c2d737536d4 | https://github.com/therne/instauuid/blob/cbdd586d38a1fff66520c6c814ab0c2d737536d4/index.js#L29-L69 |
23,647 | guness/node-xcs | google/Message.js | Message | function Message(messageId) {
if (util.isNullOrUndefined(messageId) || "string" !== typeof(messageId)) {
throw new IllegalArgumentException();
}
/**
* This parameter uniquely identifies a message in an XMPP connection.
*/
this.mMessageId = messageId;
this.mCollapseKey = null;
this.mDelayWhileIdle = null;
this.mTimeToLive = null;
this.mData = null; //Object
this.mDryRun = null;
this.mDeliveryReceiptRequested = false;
this.mPriority = null;
this.mNotification = null;
this.mContentAvailable = false;
this.mMutableContent = false;
this.mBuilded = false;
} | javascript | function Message(messageId) {
if (util.isNullOrUndefined(messageId) || "string" !== typeof(messageId)) {
throw new IllegalArgumentException();
}
/**
* This parameter uniquely identifies a message in an XMPP connection.
*/
this.mMessageId = messageId;
this.mCollapseKey = null;
this.mDelayWhileIdle = null;
this.mTimeToLive = null;
this.mData = null; //Object
this.mDryRun = null;
this.mDeliveryReceiptRequested = false;
this.mPriority = null;
this.mNotification = null;
this.mContentAvailable = false;
this.mMutableContent = false;
this.mBuilded = false;
} | [
"function",
"Message",
"(",
"messageId",
")",
"{",
"if",
"(",
"util",
".",
"isNullOrUndefined",
"(",
"messageId",
")",
"||",
"\"string\"",
"!==",
"typeof",
"(",
"messageId",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"/**\r\n * This parameter uniquely identifies a message in an XMPP connection.\r\n */",
"this",
".",
"mMessageId",
"=",
"messageId",
";",
"this",
".",
"mCollapseKey",
"=",
"null",
";",
"this",
".",
"mDelayWhileIdle",
"=",
"null",
";",
"this",
".",
"mTimeToLive",
"=",
"null",
";",
"this",
".",
"mData",
"=",
"null",
";",
"//Object\r",
"this",
".",
"mDryRun",
"=",
"null",
";",
"this",
".",
"mDeliveryReceiptRequested",
"=",
"false",
";",
"this",
".",
"mPriority",
"=",
"null",
";",
"this",
".",
"mNotification",
"=",
"null",
";",
"this",
".",
"mContentAvailable",
"=",
"false",
";",
"this",
".",
"mMutableContent",
"=",
"false",
";",
"this",
".",
"mBuilded",
"=",
"false",
";",
"}"
] | FCM message.
<p>
Instances of this class should be immutable. In order to accomplish, build method
must be called lastly {@link #build}. Examples:
<pre><code>
var Message = require('node-xcs').Message;
</pre></code>
<strong>Simplest message:</strong>
<pre><code>
var message = new Message("<messageId>").build();
</pre></code>
<strong>Message with optional attributes:</strong>
<pre><code>
var message = new Message("<messageId>")
.collapseKey(collapseKey)
.timeToLive(3)
.delayWhileIdle(true)
.dryRun(true)
.deliveryReceiptRequested(true)
.build();
</pre></code>
<strong>Message with optional attributes and payload data:</strong>
<pre><code>
var message = new Message("<messageId>")
.priority("normal")
.collapseKey(collapseKey)
.timeToLive(3)
.delayWhileIdle(true)
.dryRun(true)
.deliveryReceiptRequested(true)
.addData("key1", "value1")
.addData("key2", "value2")
.build();
</pre></code> | [
"FCM",
"message",
"."
] | 667316e8822275e70c3329ca0553b6e1292eee78 | https://github.com/guness/node-xcs/blob/667316e8822275e70c3329ca0553b6e1292eee78/google/Message.js#L49-L71 |
23,648 | bitgamma/tlv | lib/tlv.js | getTagLength | function getTagLength(tag) {
var lenTag = 4;
while(lenTag > 1) {
var tmpTag = tag >>> ((lenTag - 1) * 8);
if ((tmpTag & 0xFF) != 0x00) {
break;
}
lenTag--;
}
return lenTag;
} | javascript | function getTagLength(tag) {
var lenTag = 4;
while(lenTag > 1) {
var tmpTag = tag >>> ((lenTag - 1) * 8);
if ((tmpTag & 0xFF) != 0x00) {
break;
}
lenTag--;
}
return lenTag;
} | [
"function",
"getTagLength",
"(",
"tag",
")",
"{",
"var",
"lenTag",
"=",
"4",
";",
"while",
"(",
"lenTag",
">",
"1",
")",
"{",
"var",
"tmpTag",
"=",
"tag",
">>>",
"(",
"(",
"lenTag",
"-",
"1",
")",
"*",
"8",
")",
";",
"if",
"(",
"(",
"tmpTag",
"&",
"0xFF",
")",
"!=",
"0x00",
")",
"{",
"break",
";",
"}",
"lenTag",
"--",
";",
"}",
"return",
"lenTag",
";",
"}"
] | Returns the byte length of the given tag.
@param {number} tag
@return {number} | [
"Returns",
"the",
"byte",
"length",
"of",
"the",
"given",
"tag",
"."
] | 81fe19496fa9614caa3d8e53853116c6233d31dc | https://github.com/bitgamma/tlv/blob/81fe19496fa9614caa3d8e53853116c6233d31dc/lib/tlv.js#L314-L328 |
23,649 | bitgamma/tlv | lib/tlv.js | getValueLength | function getValueLength(value, constructed) {
var lenValue = 0;
if (constructed) {
for (var i = 0; i < value.length; i++) {
lenValue = lenValue + value[i].byteLength;
}
} else {
lenValue = value.length;
}
return lenValue;
} | javascript | function getValueLength(value, constructed) {
var lenValue = 0;
if (constructed) {
for (var i = 0; i < value.length; i++) {
lenValue = lenValue + value[i].byteLength;
}
} else {
lenValue = value.length;
}
return lenValue;
} | [
"function",
"getValueLength",
"(",
"value",
",",
"constructed",
")",
"{",
"var",
"lenValue",
"=",
"0",
";",
"if",
"(",
"constructed",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"value",
".",
"length",
";",
"i",
"++",
")",
"{",
"lenValue",
"=",
"lenValue",
"+",
"value",
"[",
"i",
"]",
".",
"byteLength",
";",
"}",
"}",
"else",
"{",
"lenValue",
"=",
"value",
".",
"length",
";",
"}",
"return",
"lenValue",
";",
"}"
] | Returns the byte length of the given value.
Value can be either a Buffer or an array of TLVs.
@param {object} value
@param {boolean} constructed
@return {number} | [
"Returns",
"the",
"byte",
"length",
"of",
"the",
"given",
"value",
".",
"Value",
"can",
"be",
"either",
"a",
"Buffer",
"or",
"an",
"array",
"of",
"TLVs",
"."
] | 81fe19496fa9614caa3d8e53853116c6233d31dc | https://github.com/bitgamma/tlv/blob/81fe19496fa9614caa3d8e53853116c6233d31dc/lib/tlv.js#L338-L350 |
23,650 | bitgamma/tlv | lib/tlv.js | getLengthOfLength | function getLengthOfLength(lenValue, indefiniteLength) {
var lenOfLen;
if (indefiniteLength) {
lenOfLen = 3;
} else if (lenValue > 0x00FFFFFF) {
lenOfLen = 5;
} else if (lenValue > 0x0000FFFF) {
lenOfLen = 4;
} else if (lenValue > 0x000000FF) {
lenOfLen = 3;
} else if (lenValue > 0x0000007F) {
lenOfLen = 2;
} else {
lenOfLen = 1;
}
return lenOfLen
} | javascript | function getLengthOfLength(lenValue, indefiniteLength) {
var lenOfLen;
if (indefiniteLength) {
lenOfLen = 3;
} else if (lenValue > 0x00FFFFFF) {
lenOfLen = 5;
} else if (lenValue > 0x0000FFFF) {
lenOfLen = 4;
} else if (lenValue > 0x000000FF) {
lenOfLen = 3;
} else if (lenValue > 0x0000007F) {
lenOfLen = 2;
} else {
lenOfLen = 1;
}
return lenOfLen
} | [
"function",
"getLengthOfLength",
"(",
"lenValue",
",",
"indefiniteLength",
")",
"{",
"var",
"lenOfLen",
";",
"if",
"(",
"indefiniteLength",
")",
"{",
"lenOfLen",
"=",
"3",
";",
"}",
"else",
"if",
"(",
"lenValue",
">",
"0x00FFFFFF",
")",
"{",
"lenOfLen",
"=",
"5",
";",
"}",
"else",
"if",
"(",
"lenValue",
">",
"0x0000FFFF",
")",
"{",
"lenOfLen",
"=",
"4",
";",
"}",
"else",
"if",
"(",
"lenValue",
">",
"0x000000FF",
")",
"{",
"lenOfLen",
"=",
"3",
";",
"}",
"else",
"if",
"(",
"lenValue",
">",
"0x0000007F",
")",
"{",
"lenOfLen",
"=",
"2",
";",
"}",
"else",
"{",
"lenOfLen",
"=",
"1",
";",
"}",
"return",
"lenOfLen",
"}"
] | Returns the number of bytes needed to encode the given length.
If the length is indefinite, this value takes in account the bytes needed to encode the EOC tag.
@param {number} lenValue
@param {boolean} indefiniteLength
@return {number} | [
"Returns",
"the",
"number",
"of",
"bytes",
"needed",
"to",
"encode",
"the",
"given",
"length",
".",
"If",
"the",
"length",
"is",
"indefinite",
"this",
"value",
"takes",
"in",
"account",
"the",
"bytes",
"needed",
"to",
"encode",
"the",
"EOC",
"tag",
"."
] | 81fe19496fa9614caa3d8e53853116c6233d31dc | https://github.com/bitgamma/tlv/blob/81fe19496fa9614caa3d8e53853116c6233d31dc/lib/tlv.js#L360-L378 |
23,651 | bitgamma/tlv | lib/tlv.js | encodeNumber | function encodeNumber(buf, value, len) {
var index = 0;
while (len > 0) {
var tmpValue = value >>> ((len - 1) * 8);
buf[index++] = tmpValue & 0xFF;
len--;
}
} | javascript | function encodeNumber(buf, value, len) {
var index = 0;
while (len > 0) {
var tmpValue = value >>> ((len - 1) * 8);
buf[index++] = tmpValue & 0xFF;
len--;
}
} | [
"function",
"encodeNumber",
"(",
"buf",
",",
"value",
",",
"len",
")",
"{",
"var",
"index",
"=",
"0",
";",
"while",
"(",
"len",
">",
"0",
")",
"{",
"var",
"tmpValue",
"=",
"value",
">>>",
"(",
"(",
"len",
"-",
"1",
")",
"*",
"8",
")",
";",
"buf",
"[",
"index",
"++",
"]",
"=",
"tmpValue",
"&",
"0xFF",
";",
"len",
"--",
";",
"}",
"}"
] | Encodes the given numeric value in the given Buffer, using the specified number of bytes.
@param {Buffer} buf
@param {number} value
@param {number} len | [
"Encodes",
"the",
"given",
"numeric",
"value",
"in",
"the",
"given",
"Buffer",
"using",
"the",
"specified",
"number",
"of",
"bytes",
"."
] | 81fe19496fa9614caa3d8e53853116c6233d31dc | https://github.com/bitgamma/tlv/blob/81fe19496fa9614caa3d8e53853116c6233d31dc/lib/tlv.js#L387-L395 |
23,652 | bitgamma/tlv | lib/tlv.js | parseTag | function parseTag(buf) {
var index = 0;
var tag = buf[index++];
var constructed = (tag & 0x20) == 0x20;
if ((tag & 0x1F) == 0x1F) {
do {
tag = tag << 8;
tag = tag | buf[index++];
} while((tag & 0x80) == 0x80);
if (index > 4) {
throw new RangeError("The length of the tag cannot be more than 4 bytes in this implementation");
}
}
return { tag: tag, length: index, constructed: constructed };
} | javascript | function parseTag(buf) {
var index = 0;
var tag = buf[index++];
var constructed = (tag & 0x20) == 0x20;
if ((tag & 0x1F) == 0x1F) {
do {
tag = tag << 8;
tag = tag | buf[index++];
} while((tag & 0x80) == 0x80);
if (index > 4) {
throw new RangeError("The length of the tag cannot be more than 4 bytes in this implementation");
}
}
return { tag: tag, length: index, constructed: constructed };
} | [
"function",
"parseTag",
"(",
"buf",
")",
"{",
"var",
"index",
"=",
"0",
";",
"var",
"tag",
"=",
"buf",
"[",
"index",
"++",
"]",
";",
"var",
"constructed",
"=",
"(",
"tag",
"&",
"0x20",
")",
"==",
"0x20",
";",
"if",
"(",
"(",
"tag",
"&",
"0x1F",
")",
"==",
"0x1F",
")",
"{",
"do",
"{",
"tag",
"=",
"tag",
"<<",
"8",
";",
"tag",
"=",
"tag",
"|",
"buf",
"[",
"index",
"++",
"]",
";",
"}",
"while",
"(",
"(",
"tag",
"&",
"0x80",
")",
"==",
"0x80",
")",
";",
"if",
"(",
"index",
">",
"4",
")",
"{",
"throw",
"new",
"RangeError",
"(",
"\"The length of the tag cannot be more than 4 bytes in this implementation\"",
")",
";",
"}",
"}",
"return",
"{",
"tag",
":",
"tag",
",",
"length",
":",
"index",
",",
"constructed",
":",
"constructed",
"}",
";",
"}"
] | Parses the first bytes of the given Buffer as a TLV tag. The tag is returned as an object
containing the tag, its length in bytes and whether it is constructed or not.
@param {Buffer} buf
@return {object} | [
"Parses",
"the",
"first",
"bytes",
"of",
"the",
"given",
"Buffer",
"as",
"a",
"TLV",
"tag",
".",
"The",
"tag",
"is",
"returned",
"as",
"an",
"object",
"containing",
"the",
"tag",
"its",
"length",
"in",
"bytes",
"and",
"whether",
"it",
"is",
"constructed",
"or",
"not",
"."
] | 81fe19496fa9614caa3d8e53853116c6233d31dc | https://github.com/bitgamma/tlv/blob/81fe19496fa9614caa3d8e53853116c6233d31dc/lib/tlv.js#L404-L420 |
23,653 | bitgamma/tlv | lib/tlv.js | parseAllTags | function parseAllTags(buf) {
var result = [];
var element;
while (buf.length > 0) {
element = parseTag(buf);
buf = buf.slice(element.length);
result.push(element.tag);
}
return result;
} | javascript | function parseAllTags(buf) {
var result = [];
var element;
while (buf.length > 0) {
element = parseTag(buf);
buf = buf.slice(element.length);
result.push(element.tag);
}
return result;
} | [
"function",
"parseAllTags",
"(",
"buf",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"element",
";",
"while",
"(",
"buf",
".",
"length",
">",
"0",
")",
"{",
"element",
"=",
"parseTag",
"(",
"buf",
")",
";",
"buf",
"=",
"buf",
".",
"slice",
"(",
"element",
".",
"length",
")",
";",
"result",
".",
"push",
"(",
"element",
".",
"tag",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Parses the entire Buffer as a sequence of TLV tags.
The tags are returned in an array, containing their numeric values.
@param {Buffer} buf
@return {Array} | [
"Parses",
"the",
"entire",
"Buffer",
"as",
"a",
"sequence",
"of",
"TLV",
"tags",
".",
"The",
"tags",
"are",
"returned",
"in",
"an",
"array",
"containing",
"their",
"numeric",
"values",
"."
] | 81fe19496fa9614caa3d8e53853116c6233d31dc | https://github.com/bitgamma/tlv/blob/81fe19496fa9614caa3d8e53853116c6233d31dc/lib/tlv.js#L429-L440 |
23,654 | bitgamma/tlv | lib/tlv.js | encodeTags | function encodeTags(tags) {
var bufLength = 0;
var tagLengths = []
for (var i = 0; i < tags.length; i++) {
var tagLength = getTagLength(tags[i]);
tagLengths.push(tagLength);
bufLength += tagLength;
}
var buf = new Buffer(bufLength);
var slicedBuf = buf;
for (var i = 0; i < tags.length; i++) {
encodeNumber(slicedBuf, tags[i], tagLengths[i]);
slicedBuf = slicedBuf.slice(tagLengths[i]);
}
return buf;
} | javascript | function encodeTags(tags) {
var bufLength = 0;
var tagLengths = []
for (var i = 0; i < tags.length; i++) {
var tagLength = getTagLength(tags[i]);
tagLengths.push(tagLength);
bufLength += tagLength;
}
var buf = new Buffer(bufLength);
var slicedBuf = buf;
for (var i = 0; i < tags.length; i++) {
encodeNumber(slicedBuf, tags[i], tagLengths[i]);
slicedBuf = slicedBuf.slice(tagLengths[i]);
}
return buf;
} | [
"function",
"encodeTags",
"(",
"tags",
")",
"{",
"var",
"bufLength",
"=",
"0",
";",
"var",
"tagLengths",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tags",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"tagLength",
"=",
"getTagLength",
"(",
"tags",
"[",
"i",
"]",
")",
";",
"tagLengths",
".",
"push",
"(",
"tagLength",
")",
";",
"bufLength",
"+=",
"tagLength",
";",
"}",
"var",
"buf",
"=",
"new",
"Buffer",
"(",
"bufLength",
")",
";",
"var",
"slicedBuf",
"=",
"buf",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"tags",
".",
"length",
";",
"i",
"++",
")",
"{",
"encodeNumber",
"(",
"slicedBuf",
",",
"tags",
"[",
"i",
"]",
",",
"tagLengths",
"[",
"i",
"]",
")",
";",
"slicedBuf",
"=",
"slicedBuf",
".",
"slice",
"(",
"tagLengths",
"[",
"i",
"]",
")",
";",
"}",
"return",
"buf",
";",
"}"
] | Encodes an array of tags in a new Buffer.
@param {Array} tags
@return {Buffer} | [
"Encodes",
"an",
"array",
"of",
"tags",
"in",
"a",
"new",
"Buffer",
"."
] | 81fe19496fa9614caa3d8e53853116c6233d31dc | https://github.com/bitgamma/tlv/blob/81fe19496fa9614caa3d8e53853116c6233d31dc/lib/tlv.js#L448-L467 |
23,655 | guness/node-xcs | google/Notification.js | Notification | function Notification(icon) {
if (util.isNullOrUndefined(icon)) {
throw new IllegalArgumentException();
}
this.mTitle = null;
this.mBody = null;
this.mIcon = icon;
this.mSound = "default"; // the only currently supported value
this.mBadge = null;
this.mTag = null;
this.mColor = null;
this.mClickAction = null;
this.mBodyLocKey = null;
this.mBodyLocArgs = null; // array
this.mTitleLocKey = null;
this.mTitleLocArgs = null; // array
this.mBuilded = false;
} | javascript | function Notification(icon) {
if (util.isNullOrUndefined(icon)) {
throw new IllegalArgumentException();
}
this.mTitle = null;
this.mBody = null;
this.mIcon = icon;
this.mSound = "default"; // the only currently supported value
this.mBadge = null;
this.mTag = null;
this.mColor = null;
this.mClickAction = null;
this.mBodyLocKey = null;
this.mBodyLocArgs = null; // array
this.mTitleLocKey = null;
this.mTitleLocArgs = null; // array
this.mBuilded = false;
} | [
"function",
"Notification",
"(",
"icon",
")",
"{",
"if",
"(",
"util",
".",
"isNullOrUndefined",
"(",
"icon",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"this",
".",
"mTitle",
"=",
"null",
";",
"this",
".",
"mBody",
"=",
"null",
";",
"this",
".",
"mIcon",
"=",
"icon",
";",
"this",
".",
"mSound",
"=",
"\"default\"",
";",
"// the only currently supported value\r",
"this",
".",
"mBadge",
"=",
"null",
";",
"this",
".",
"mTag",
"=",
"null",
";",
"this",
".",
"mColor",
"=",
"null",
";",
"this",
".",
"mClickAction",
"=",
"null",
";",
"this",
".",
"mBodyLocKey",
"=",
"null",
";",
"this",
".",
"mBodyLocArgs",
"=",
"null",
";",
"// array\r",
"this",
".",
"mTitleLocKey",
"=",
"null",
";",
"this",
".",
"mTitleLocArgs",
"=",
"null",
";",
"// array\r",
"this",
".",
"mBuilded",
"=",
"false",
";",
"}"
] | FCM message notification part.
<p>
Instances of this class should be immutable. In order to accomplish, build method
must be called lastly. {@link #build}. Examples:
<pre><code>
var Notification = require('node-xcs').Notification;
</pre></code>
<strong>Simplest notification:</strong>
<pre><code>
var notification = new Notification("ic_launcher").build();
</pre></code>
<strong>Notification with optional attributes:</strong>
<pre><code>
var notification = new Notification("ic_launcher")
.title("Hello world!")
.body("Here is a more detailed description")
.build();
</pre></code> | [
"FCM",
"message",
"notification",
"part",
"."
] | 667316e8822275e70c3329ca0553b6e1292eee78 | https://github.com/guness/node-xcs/blob/667316e8822275e70c3329ca0553b6e1292eee78/google/Notification.js#L31-L51 |
23,656 | ngokevin/angle | lib/initcomponent.js | run | function run (answers) {
ls(['LICENSE', 'package.json', 'README.md', 'index.js', 'index.html', 'examples/basic/index.html', 'tests/index.test.js']).forEach(function (file) {
answers.aframeVersion = aframeVersion;
answers.npmName = `aframe-${answers.shortName}-component`;
fs.writeFileSync(file, nunjucks.render(file, answers));
});
} | javascript | function run (answers) {
ls(['LICENSE', 'package.json', 'README.md', 'index.js', 'index.html', 'examples/basic/index.html', 'tests/index.test.js']).forEach(function (file) {
answers.aframeVersion = aframeVersion;
answers.npmName = `aframe-${answers.shortName}-component`;
fs.writeFileSync(file, nunjucks.render(file, answers));
});
} | [
"function",
"run",
"(",
"answers",
")",
"{",
"ls",
"(",
"[",
"'LICENSE'",
",",
"'package.json'",
",",
"'README.md'",
",",
"'index.js'",
",",
"'index.html'",
",",
"'examples/basic/index.html'",
",",
"'tests/index.test.js'",
"]",
")",
".",
"forEach",
"(",
"function",
"(",
"file",
")",
"{",
"answers",
".",
"aframeVersion",
"=",
"aframeVersion",
";",
"answers",
".",
"npmName",
"=",
"`",
"${",
"answers",
".",
"shortName",
"}",
"`",
";",
"fs",
".",
"writeFileSync",
"(",
"file",
",",
"nunjucks",
".",
"render",
"(",
"file",
",",
"answers",
")",
")",
";",
"}",
")",
";",
"}"
] | Do all the string replacements. | [
"Do",
"all",
"the",
"string",
"replacements",
"."
] | 8421f1ca242fe448fd01f2c883489d6178b5b20a | https://github.com/ngokevin/angle/blob/8421f1ca242fe448fd01f2c883489d6178b5b20a/lib/initcomponent.js#L91-L97 |
23,657 | icemobilelab/minosse | lib/parsers.js | loadFileData | function loadFileData(fileName) {
var testConfig = this.testConfig;
if (!testConfig) {
throw new Error('No test configuration found.\n' +
'You can add one by adding a property called `testConfig` to the word object.');
}
var testDataRoot = testConfig.testDataRoot;
if (!testDataRoot) {
throw new Error('No test data root path found.\n' +
'You can add one by adding a property called `testDataRoot` to the test configuration.');
}
var filePath = path.join(testDataRoot, fileName);
this._log.trace({ path: filePath }, 'Loading file.');
//Don't use `require` because that caches the returned object.
var value = require('fs').createReadStream(filePath);
this._log.trace({ loadedData: value }, 'File loaded.');
return value;
} | javascript | function loadFileData(fileName) {
var testConfig = this.testConfig;
if (!testConfig) {
throw new Error('No test configuration found.\n' +
'You can add one by adding a property called `testConfig` to the word object.');
}
var testDataRoot = testConfig.testDataRoot;
if (!testDataRoot) {
throw new Error('No test data root path found.\n' +
'You can add one by adding a property called `testDataRoot` to the test configuration.');
}
var filePath = path.join(testDataRoot, fileName);
this._log.trace({ path: filePath }, 'Loading file.');
//Don't use `require` because that caches the returned object.
var value = require('fs').createReadStream(filePath);
this._log.trace({ loadedData: value }, 'File loaded.');
return value;
} | [
"function",
"loadFileData",
"(",
"fileName",
")",
"{",
"var",
"testConfig",
"=",
"this",
".",
"testConfig",
";",
"if",
"(",
"!",
"testConfig",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No test configuration found.\\n'",
"+",
"'You can add one by adding a property called `testConfig` to the word object.'",
")",
";",
"}",
"var",
"testDataRoot",
"=",
"testConfig",
".",
"testDataRoot",
";",
"if",
"(",
"!",
"testDataRoot",
")",
"{",
"throw",
"new",
"Error",
"(",
"'No test data root path found.\\n'",
"+",
"'You can add one by adding a property called `testDataRoot` to the test configuration.'",
")",
";",
"}",
"var",
"filePath",
"=",
"path",
".",
"join",
"(",
"testDataRoot",
",",
"fileName",
")",
";",
"this",
".",
"_log",
".",
"trace",
"(",
"{",
"path",
":",
"filePath",
"}",
",",
"'Loading file.'",
")",
";",
"//Don't use `require` because that caches the returned object.",
"var",
"value",
"=",
"require",
"(",
"'fs'",
")",
".",
"createReadStream",
"(",
"filePath",
")",
";",
"this",
".",
"_log",
".",
"trace",
"(",
"{",
"loadedData",
":",
"value",
"}",
",",
"'File loaded.'",
")",
";",
"return",
"value",
";",
"}"
] | This function expects a full fileName with extension included! | [
"This",
"function",
"expects",
"a",
"full",
"fileName",
"with",
"extension",
"included!"
] | 05065b6cfefd14198d20f4a87d6dd9bcb75a38d3 | https://github.com/icemobilelab/minosse/blob/05065b6cfefd14198d20f4a87d6dd9bcb75a38d3/lib/parsers.js#L104-L122 |
23,658 | googlearchive/node-big-rig | lib/third_party/tracing/base/units/time_stamp.js | TimeStamp | function TimeStamp(timestamp) {
tr.b.u.Scalar.call(this, timestamp, tr.b.u.Units.timeStampInMs);
} | javascript | function TimeStamp(timestamp) {
tr.b.u.Scalar.call(this, timestamp, tr.b.u.Units.timeStampInMs);
} | [
"function",
"TimeStamp",
"(",
"timestamp",
")",
"{",
"tr",
".",
"b",
".",
"u",
".",
"Scalar",
".",
"call",
"(",
"this",
",",
"timestamp",
",",
"tr",
".",
"b",
".",
"u",
".",
"Units",
".",
"timeStampInMs",
")",
";",
"}"
] | Float wrapper, representing a time stamp, capable of pretty-printing. | [
"Float",
"wrapper",
"representing",
"a",
"time",
"stamp",
"capable",
"of",
"pretty",
"-",
"printing",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/units/time_stamp.js#L16-L18 |
23,659 | googlearchive/node-big-rig | lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js | function(slice, flowEvents) {
var fromOtherInputs = false;
slice.iterateEntireHierarchy(function(subsequentSlice) {
if (fromOtherInputs)
return;
subsequentSlice.inFlowEvents.forEach(function(inflow) {
if (fromOtherInputs)
return;
if (inflow.category.indexOf('input') > -1) {
if (flowEvents.indexOf(inflow) === -1)
fromOtherInputs = true;
}
}, this);
}, this);
return fromOtherInputs;
} | javascript | function(slice, flowEvents) {
var fromOtherInputs = false;
slice.iterateEntireHierarchy(function(subsequentSlice) {
if (fromOtherInputs)
return;
subsequentSlice.inFlowEvents.forEach(function(inflow) {
if (fromOtherInputs)
return;
if (inflow.category.indexOf('input') > -1) {
if (flowEvents.indexOf(inflow) === -1)
fromOtherInputs = true;
}
}, this);
}, this);
return fromOtherInputs;
} | [
"function",
"(",
"slice",
",",
"flowEvents",
")",
"{",
"var",
"fromOtherInputs",
"=",
"false",
";",
"slice",
".",
"iterateEntireHierarchy",
"(",
"function",
"(",
"subsequentSlice",
")",
"{",
"if",
"(",
"fromOtherInputs",
")",
"return",
";",
"subsequentSlice",
".",
"inFlowEvents",
".",
"forEach",
"(",
"function",
"(",
"inflow",
")",
"{",
"if",
"(",
"fromOtherInputs",
")",
"return",
";",
"if",
"(",
"inflow",
".",
"category",
".",
"indexOf",
"(",
"'input'",
")",
">",
"-",
"1",
")",
"{",
"if",
"(",
"flowEvents",
".",
"indexOf",
"(",
"inflow",
")",
"===",
"-",
"1",
")",
"fromOtherInputs",
"=",
"true",
";",
"}",
"}",
",",
"this",
")",
";",
"}",
",",
"this",
")",
";",
"return",
"fromOtherInputs",
";",
"}"
] | Return true if the slice hierarchy is tracked by LatencyInfo of other input latency events. If the slice hierarchy is tracked by both, this function still returns true. | [
"Return",
"true",
"if",
"the",
"slice",
"hierarchy",
"is",
"tracked",
"by",
"LatencyInfo",
"of",
"other",
"input",
"latency",
"events",
".",
"If",
"the",
"slice",
"hierarchy",
"is",
"tracked",
"by",
"both",
"this",
"function",
"still",
"returns",
"true",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js#L267-L286 | |
23,660 | googlearchive/node-big-rig | lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js | function(event, flowEvents) {
if (event.outFlowEvents === undefined ||
event.outFlowEvents.length === 0)
return false;
// Once we fix the bug of flow event binding, there should exist one and
// only one outgoing flow (PostTask) from ScheduleBeginImplFrameDeadline
// and PostComposite.
var flow = event.outFlowEvents[0];
if (flow.category !== POSTTASK_FLOW_EVENT ||
!flow.endSlice)
return false;
var endSlice = flow.endSlice;
if (this.belongToOtherInputs(endSlice.mostTopLevelSlice, flowEvents))
return true;
return false;
} | javascript | function(event, flowEvents) {
if (event.outFlowEvents === undefined ||
event.outFlowEvents.length === 0)
return false;
// Once we fix the bug of flow event binding, there should exist one and
// only one outgoing flow (PostTask) from ScheduleBeginImplFrameDeadline
// and PostComposite.
var flow = event.outFlowEvents[0];
if (flow.category !== POSTTASK_FLOW_EVENT ||
!flow.endSlice)
return false;
var endSlice = flow.endSlice;
if (this.belongToOtherInputs(endSlice.mostTopLevelSlice, flowEvents))
return true;
return false;
} | [
"function",
"(",
"event",
",",
"flowEvents",
")",
"{",
"if",
"(",
"event",
".",
"outFlowEvents",
"===",
"undefined",
"||",
"event",
".",
"outFlowEvents",
".",
"length",
"===",
"0",
")",
"return",
"false",
";",
"// Once we fix the bug of flow event binding, there should exist one and",
"// only one outgoing flow (PostTask) from ScheduleBeginImplFrameDeadline",
"// and PostComposite.",
"var",
"flow",
"=",
"event",
".",
"outFlowEvents",
"[",
"0",
"]",
";",
"if",
"(",
"flow",
".",
"category",
"!==",
"POSTTASK_FLOW_EVENT",
"||",
"!",
"flow",
".",
"endSlice",
")",
"return",
"false",
";",
"var",
"endSlice",
"=",
"flow",
".",
"endSlice",
";",
"if",
"(",
"this",
".",
"belongToOtherInputs",
"(",
"endSlice",
".",
"mostTopLevelSlice",
",",
"flowEvents",
")",
")",
"return",
"true",
";",
"return",
"false",
";",
"}"
] | Return true if |event| triggers slices of other inputs. | [
"Return",
"true",
"if",
"|event|",
"triggers",
"slices",
"of",
"other",
"inputs",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js#L289-L308 | |
23,661 | googlearchive/node-big-rig | lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js | function(event, queue, visited, flowEvents) {
var stopFollowing = false;
var inputAck = false;
event.iterateAllSubsequentSlices(function(slice) {
if (stopFollowing)
return;
// Do not follow TaskQueueManager::RunTask because it causes
// many false events to be included.
if (slice.title === 'TaskQueueManager::RunTask')
return;
// Do not follow ScheduledActionSendBeginMainFrame because the real
// main thread BeginMainFrame is already traced by LatencyInfo flow.
if (slice.title === 'ThreadProxy::ScheduledActionSendBeginMainFrame')
return;
// Do not follow ScheduleBeginImplFrameDeadline that triggers an
// OnBeginImplFrameDeadline that is tracked by another LatencyInfo.
if (slice.title === 'Scheduler::ScheduleBeginImplFrameDeadline') {
if (this.triggerOtherInputs(slice, flowEvents))
return;
}
// Do not follow PostComposite that triggers CompositeImmediately
// that is tracked by another LatencyInfo.
if (slice.title === 'CompositorImpl::PostComposite') {
if (this.triggerOtherInputs(slice, flowEvents))
return;
}
// Stop following the rest of the current slice hierarchy if
// FilterAndSendWebInputEvent occurs after ProcessInputEventAck.
if (slice.title === 'InputRouterImpl::ProcessInputEventAck')
inputAck = true;
if (inputAck &&
slice.title === 'InputRouterImpl::FilterAndSendWebInputEvent')
stopFollowing = true;
this.followCurrentSlice(slice, queue, visited);
}, this);
} | javascript | function(event, queue, visited, flowEvents) {
var stopFollowing = false;
var inputAck = false;
event.iterateAllSubsequentSlices(function(slice) {
if (stopFollowing)
return;
// Do not follow TaskQueueManager::RunTask because it causes
// many false events to be included.
if (slice.title === 'TaskQueueManager::RunTask')
return;
// Do not follow ScheduledActionSendBeginMainFrame because the real
// main thread BeginMainFrame is already traced by LatencyInfo flow.
if (slice.title === 'ThreadProxy::ScheduledActionSendBeginMainFrame')
return;
// Do not follow ScheduleBeginImplFrameDeadline that triggers an
// OnBeginImplFrameDeadline that is tracked by another LatencyInfo.
if (slice.title === 'Scheduler::ScheduleBeginImplFrameDeadline') {
if (this.triggerOtherInputs(slice, flowEvents))
return;
}
// Do not follow PostComposite that triggers CompositeImmediately
// that is tracked by another LatencyInfo.
if (slice.title === 'CompositorImpl::PostComposite') {
if (this.triggerOtherInputs(slice, flowEvents))
return;
}
// Stop following the rest of the current slice hierarchy if
// FilterAndSendWebInputEvent occurs after ProcessInputEventAck.
if (slice.title === 'InputRouterImpl::ProcessInputEventAck')
inputAck = true;
if (inputAck &&
slice.title === 'InputRouterImpl::FilterAndSendWebInputEvent')
stopFollowing = true;
this.followCurrentSlice(slice, queue, visited);
}, this);
} | [
"function",
"(",
"event",
",",
"queue",
",",
"visited",
",",
"flowEvents",
")",
"{",
"var",
"stopFollowing",
"=",
"false",
";",
"var",
"inputAck",
"=",
"false",
";",
"event",
".",
"iterateAllSubsequentSlices",
"(",
"function",
"(",
"slice",
")",
"{",
"if",
"(",
"stopFollowing",
")",
"return",
";",
"// Do not follow TaskQueueManager::RunTask because it causes",
"// many false events to be included.",
"if",
"(",
"slice",
".",
"title",
"===",
"'TaskQueueManager::RunTask'",
")",
"return",
";",
"// Do not follow ScheduledActionSendBeginMainFrame because the real",
"// main thread BeginMainFrame is already traced by LatencyInfo flow.",
"if",
"(",
"slice",
".",
"title",
"===",
"'ThreadProxy::ScheduledActionSendBeginMainFrame'",
")",
"return",
";",
"// Do not follow ScheduleBeginImplFrameDeadline that triggers an",
"// OnBeginImplFrameDeadline that is tracked by another LatencyInfo.",
"if",
"(",
"slice",
".",
"title",
"===",
"'Scheduler::ScheduleBeginImplFrameDeadline'",
")",
"{",
"if",
"(",
"this",
".",
"triggerOtherInputs",
"(",
"slice",
",",
"flowEvents",
")",
")",
"return",
";",
"}",
"// Do not follow PostComposite that triggers CompositeImmediately",
"// that is tracked by another LatencyInfo.",
"if",
"(",
"slice",
".",
"title",
"===",
"'CompositorImpl::PostComposite'",
")",
"{",
"if",
"(",
"this",
".",
"triggerOtherInputs",
"(",
"slice",
",",
"flowEvents",
")",
")",
"return",
";",
"}",
"// Stop following the rest of the current slice hierarchy if",
"// FilterAndSendWebInputEvent occurs after ProcessInputEventAck.",
"if",
"(",
"slice",
".",
"title",
"===",
"'InputRouterImpl::ProcessInputEventAck'",
")",
"inputAck",
"=",
"true",
";",
"if",
"(",
"inputAck",
"&&",
"slice",
".",
"title",
"===",
"'InputRouterImpl::FilterAndSendWebInputEvent'",
")",
"stopFollowing",
"=",
"true",
";",
"this",
".",
"followCurrentSlice",
"(",
"slice",
",",
"queue",
",",
"visited",
")",
";",
"}",
",",
"this",
")",
";",
"}"
] | Follow outgoing flow of subsequentSlices in the current hierarchy. We also handle cases where different inputs interfere with each other. | [
"Follow",
"outgoing",
"flow",
"of",
"subsequentSlices",
"in",
"the",
"current",
"hierarchy",
".",
"We",
"also",
"handle",
"cases",
"where",
"different",
"inputs",
"interfere",
"with",
"each",
"other",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js#L312-L354 | |
23,662 | googlearchive/node-big-rig | lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js | function(event, queue, visited) {
event.outFlowEvents.forEach(function(outflow) {
if ((outflow.category === POSTTASK_FLOW_EVENT ||
outflow.category === IPC_FLOW_EVENT) &&
outflow.endSlice) {
this.associatedEvents_.push(outflow);
var nextEvent = outflow.endSlice.mostTopLevelSlice;
if (!visited.contains(nextEvent)) {
visited.push(nextEvent);
queue.push(nextEvent);
}
}
}, this);
} | javascript | function(event, queue, visited) {
event.outFlowEvents.forEach(function(outflow) {
if ((outflow.category === POSTTASK_FLOW_EVENT ||
outflow.category === IPC_FLOW_EVENT) &&
outflow.endSlice) {
this.associatedEvents_.push(outflow);
var nextEvent = outflow.endSlice.mostTopLevelSlice;
if (!visited.contains(nextEvent)) {
visited.push(nextEvent);
queue.push(nextEvent);
}
}
}, this);
} | [
"function",
"(",
"event",
",",
"queue",
",",
"visited",
")",
"{",
"event",
".",
"outFlowEvents",
".",
"forEach",
"(",
"function",
"(",
"outflow",
")",
"{",
"if",
"(",
"(",
"outflow",
".",
"category",
"===",
"POSTTASK_FLOW_EVENT",
"||",
"outflow",
".",
"category",
"===",
"IPC_FLOW_EVENT",
")",
"&&",
"outflow",
".",
"endSlice",
")",
"{",
"this",
".",
"associatedEvents_",
".",
"push",
"(",
"outflow",
")",
";",
"var",
"nextEvent",
"=",
"outflow",
".",
"endSlice",
".",
"mostTopLevelSlice",
";",
"if",
"(",
"!",
"visited",
".",
"contains",
"(",
"nextEvent",
")",
")",
"{",
"visited",
".",
"push",
"(",
"nextEvent",
")",
";",
"queue",
".",
"push",
"(",
"nextEvent",
")",
";",
"}",
"}",
"}",
",",
"this",
")",
";",
"}"
] | Follow outgoing flow events of the current slice. | [
"Follow",
"outgoing",
"flow",
"events",
"of",
"the",
"current",
"slice",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/chrome/cc/input_latency_async_slice.js#L357-L371 | |
23,663 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/sched_parser.js | SchedParser | function SchedParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('sched_switch',
SchedParser.prototype.schedSwitchEvent.bind(this));
importer.registerEventHandler('sched_wakeup',
SchedParser.prototype.schedWakeupEvent.bind(this));
importer.registerEventHandler('sched_blocked_reason',
SchedParser.prototype.schedBlockedEvent.bind(this));
} | javascript | function SchedParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('sched_switch',
SchedParser.prototype.schedSwitchEvent.bind(this));
importer.registerEventHandler('sched_wakeup',
SchedParser.prototype.schedWakeupEvent.bind(this));
importer.registerEventHandler('sched_blocked_reason',
SchedParser.prototype.schedBlockedEvent.bind(this));
} | [
"function",
"SchedParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'sched_switch'",
",",
"SchedParser",
".",
"prototype",
".",
"schedSwitchEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'sched_wakeup'",
",",
"SchedParser",
".",
"prototype",
".",
"schedWakeupEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'sched_blocked_reason'",
",",
"SchedParser",
".",
"prototype",
".",
"schedBlockedEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux sched trace events.
@constructor | [
"Parses",
"linux",
"sched",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/sched_parser.js#L22-L31 |
23,664 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/sched_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = schedSwitchRE.exec(eventBase.details);
if (!event)
return false;
var prevState = event[4];
var nextComm = event[5];
var nextPid = parseInt(event[6]);
var nextPrio = parseInt(event[7]);
var nextThread = this.importer.threadsByLinuxPid[nextPid];
var nextName;
if (nextThread)
nextName = nextThread.userFriendlyName;
else
nextName = nextComm;
var cpu = this.importer.getOrCreateCpu(cpuNumber);
cpu.switchActiveThread(
ts,
{stateWhenDescheduled: prevState},
nextPid,
nextName,
{
comm: nextComm,
tid: nextPid,
prio: nextPrio
});
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = schedSwitchRE.exec(eventBase.details);
if (!event)
return false;
var prevState = event[4];
var nextComm = event[5];
var nextPid = parseInt(event[6]);
var nextPrio = parseInt(event[7]);
var nextThread = this.importer.threadsByLinuxPid[nextPid];
var nextName;
if (nextThread)
nextName = nextThread.userFriendlyName;
else
nextName = nextComm;
var cpu = this.importer.getOrCreateCpu(cpuNumber);
cpu.switchActiveThread(
ts,
{stateWhenDescheduled: prevState},
nextPid,
nextName,
{
comm: nextComm,
tid: nextPid,
prio: nextPrio
});
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"schedSwitchRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"prevState",
"=",
"event",
"[",
"4",
"]",
";",
"var",
"nextComm",
"=",
"event",
"[",
"5",
"]",
";",
"var",
"nextPid",
"=",
"parseInt",
"(",
"event",
"[",
"6",
"]",
")",
";",
"var",
"nextPrio",
"=",
"parseInt",
"(",
"event",
"[",
"7",
"]",
")",
";",
"var",
"nextThread",
"=",
"this",
".",
"importer",
".",
"threadsByLinuxPid",
"[",
"nextPid",
"]",
";",
"var",
"nextName",
";",
"if",
"(",
"nextThread",
")",
"nextName",
"=",
"nextThread",
".",
"userFriendlyName",
";",
"else",
"nextName",
"=",
"nextComm",
";",
"var",
"cpu",
"=",
"this",
".",
"importer",
".",
"getOrCreateCpu",
"(",
"cpuNumber",
")",
";",
"cpu",
".",
"switchActiveThread",
"(",
"ts",
",",
"{",
"stateWhenDescheduled",
":",
"prevState",
"}",
",",
"nextPid",
",",
"nextName",
",",
"{",
"comm",
":",
"nextComm",
",",
"tid",
":",
"nextPid",
",",
"prio",
":",
"nextPrio",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Parses scheduler events and sets up state in the CPUs of the importer. | [
"Parses",
"scheduler",
"events",
"and",
"sets",
"up",
"state",
"in",
"the",
"CPUs",
"of",
"the",
"importer",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/sched_parser.js#L56-L86 | |
23,665 | googlearchive/node-big-rig | lib/third_party/tracing/base/range.js | function(array, opt_keyFunc, opt_this) {
if (this.isEmpty_)
return [];
// Binary search. |test| is a function that should return true when we
// need to explore the left branch and false to explore the right branch.
function binSearch(test) {
var i0 = 0;
var i1 = array.length;
while (i0 < i1 - 1) {
var i = Math.trunc((i0 + i1) / 2);
if (test(i))
i1 = i; // Explore the left branch.
else
i0 = i; // Explore the right branch.
}
return i1;
}
var keyFunc = opt_keyFunc || tr.b.identity;
function getValue(index) {
return keyFunc.call(opt_this, array[index]);
}
var first = binSearch(function(i) {
return this.min_ === undefined || this.min_ <= getValue(i);
}.bind(this));
var last = binSearch(function(i) {
return this.max_ !== undefined && this.max_ < getValue(i);
}.bind(this));
return array.slice(first, last);
} | javascript | function(array, opt_keyFunc, opt_this) {
if (this.isEmpty_)
return [];
// Binary search. |test| is a function that should return true when we
// need to explore the left branch and false to explore the right branch.
function binSearch(test) {
var i0 = 0;
var i1 = array.length;
while (i0 < i1 - 1) {
var i = Math.trunc((i0 + i1) / 2);
if (test(i))
i1 = i; // Explore the left branch.
else
i0 = i; // Explore the right branch.
}
return i1;
}
var keyFunc = opt_keyFunc || tr.b.identity;
function getValue(index) {
return keyFunc.call(opt_this, array[index]);
}
var first = binSearch(function(i) {
return this.min_ === undefined || this.min_ <= getValue(i);
}.bind(this));
var last = binSearch(function(i) {
return this.max_ !== undefined && this.max_ < getValue(i);
}.bind(this));
return array.slice(first, last);
} | [
"function",
"(",
"array",
",",
"opt_keyFunc",
",",
"opt_this",
")",
"{",
"if",
"(",
"this",
".",
"isEmpty_",
")",
"return",
"[",
"]",
";",
"// Binary search. |test| is a function that should return true when we",
"// need to explore the left branch and false to explore the right branch.",
"function",
"binSearch",
"(",
"test",
")",
"{",
"var",
"i0",
"=",
"0",
";",
"var",
"i1",
"=",
"array",
".",
"length",
";",
"while",
"(",
"i0",
"<",
"i1",
"-",
"1",
")",
"{",
"var",
"i",
"=",
"Math",
".",
"trunc",
"(",
"(",
"i0",
"+",
"i1",
")",
"/",
"2",
")",
";",
"if",
"(",
"test",
"(",
"i",
")",
")",
"i1",
"=",
"i",
";",
"// Explore the left branch.",
"else",
"i0",
"=",
"i",
";",
"// Explore the right branch.",
"}",
"return",
"i1",
";",
"}",
"var",
"keyFunc",
"=",
"opt_keyFunc",
"||",
"tr",
".",
"b",
".",
"identity",
";",
"function",
"getValue",
"(",
"index",
")",
"{",
"return",
"keyFunc",
".",
"call",
"(",
"opt_this",
",",
"array",
"[",
"index",
"]",
")",
";",
"}",
"var",
"first",
"=",
"binSearch",
"(",
"function",
"(",
"i",
")",
"{",
"return",
"this",
".",
"min_",
"===",
"undefined",
"||",
"this",
".",
"min_",
"<=",
"getValue",
"(",
"i",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"var",
"last",
"=",
"binSearch",
"(",
"function",
"(",
"i",
")",
"{",
"return",
"this",
".",
"max_",
"!==",
"undefined",
"&&",
"this",
".",
"max_",
"<",
"getValue",
"(",
"i",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"return",
"array",
".",
"slice",
"(",
"first",
",",
"last",
")",
";",
"}"
] | Returns a slice of the input array that intersects with this range. If
the range does not have a min, it is treated as unbounded from below.
Similarly, if max is undefined, the range is unbounded from above.
@param {Array} array The array of elements to be filtered.
@param {Funcation=} opt_keyFunc A function that extracts a numeric value,
to be used in comparisons, from an element of the array. If not
specified, array elements themselves will be used.
@param {Object=} opt_this An optional this argument to be passed to
opt_keyFunc. | [
"Returns",
"a",
"slice",
"of",
"the",
"input",
"array",
"that",
"intersects",
"with",
"this",
"range",
".",
"If",
"the",
"range",
"does",
"not",
"have",
"a",
"min",
"it",
"is",
"treated",
"as",
"unbounded",
"from",
"below",
".",
"Similarly",
"if",
"max",
"is",
"undefined",
"the",
"range",
"is",
"unbounded",
"from",
"above",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/range.js#L184-L214 | |
23,666 | googlearchive/node-big-rig | lib/third_party/tracing/base/range.js | binSearch | function binSearch(test) {
var i0 = 0;
var i1 = array.length;
while (i0 < i1 - 1) {
var i = Math.trunc((i0 + i1) / 2);
if (test(i))
i1 = i; // Explore the left branch.
else
i0 = i; // Explore the right branch.
}
return i1;
} | javascript | function binSearch(test) {
var i0 = 0;
var i1 = array.length;
while (i0 < i1 - 1) {
var i = Math.trunc((i0 + i1) / 2);
if (test(i))
i1 = i; // Explore the left branch.
else
i0 = i; // Explore the right branch.
}
return i1;
} | [
"function",
"binSearch",
"(",
"test",
")",
"{",
"var",
"i0",
"=",
"0",
";",
"var",
"i1",
"=",
"array",
".",
"length",
";",
"while",
"(",
"i0",
"<",
"i1",
"-",
"1",
")",
"{",
"var",
"i",
"=",
"Math",
".",
"trunc",
"(",
"(",
"i0",
"+",
"i1",
")",
"/",
"2",
")",
";",
"if",
"(",
"test",
"(",
"i",
")",
")",
"i1",
"=",
"i",
";",
"// Explore the left branch.",
"else",
"i0",
"=",
"i",
";",
"// Explore the right branch.",
"}",
"return",
"i1",
";",
"}"
] | Binary search. |test| is a function that should return true when we need to explore the left branch and false to explore the right branch. | [
"Binary",
"search",
".",
"|test|",
"is",
"a",
"function",
"that",
"should",
"return",
"true",
"when",
"we",
"need",
"to",
"explore",
"the",
"left",
"branch",
"and",
"false",
"to",
"explore",
"the",
"right",
"branch",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/range.js#L189-L200 |
23,667 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/drm_parser.js | DrmParser | function DrmParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('drm_vblank_event',
DrmParser.prototype.vblankEvent.bind(this));
} | javascript | function DrmParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('drm_vblank_event',
DrmParser.prototype.vblankEvent.bind(this));
} | [
"function",
"DrmParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'drm_vblank_event'",
",",
"DrmParser",
".",
"prototype",
".",
"vblankEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux drm trace events.
@constructor | [
"Parses",
"linux",
"drm",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/drm_parser.js#L23-L28 |
23,668 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/drm_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /crtc=(\d+), seq=(\d+)/.exec(eventBase.details);
if (!event)
return false;
var crtc = parseInt(event[1]);
var seq = parseInt(event[2]);
this.drmVblankSlice(ts, 'vblank:' + crtc,
{
crtc: crtc,
seq: seq
});
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /crtc=(\d+), seq=(\d+)/.exec(eventBase.details);
if (!event)
return false;
var crtc = parseInt(event[1]);
var seq = parseInt(event[2]);
this.drmVblankSlice(ts, 'vblank:' + crtc,
{
crtc: crtc,
seq: seq
});
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"/",
"crtc=(\\d+), seq=(\\d+)",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"crtc",
"=",
"parseInt",
"(",
"event",
"[",
"1",
"]",
")",
";",
"var",
"seq",
"=",
"parseInt",
"(",
"event",
"[",
"2",
"]",
")",
";",
"this",
".",
"drmVblankSlice",
"(",
"ts",
",",
"'vblank:'",
"+",
"crtc",
",",
"{",
"crtc",
":",
"crtc",
",",
"seq",
":",
"seq",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Parses drm driver events and sets up state in the importer. | [
"Parses",
"drm",
"driver",
"events",
"and",
"sets",
"up",
"state",
"in",
"the",
"importer",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/drm_parser.js#L46-L59 | |
23,669 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/cpufreq_parser.js | CpufreqParser | function CpufreqParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('cpufreq_interactive_up',
CpufreqParser.prototype.cpufreqUpDownEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_down',
CpufreqParser.prototype.cpufreqUpDownEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_already',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_notyet',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_setspeed',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_target',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_boost',
CpufreqParser.prototype.cpufreqBoostUnboostEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_unboost',
CpufreqParser.prototype.cpufreqBoostUnboostEvent.bind(this));
} | javascript | function CpufreqParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('cpufreq_interactive_up',
CpufreqParser.prototype.cpufreqUpDownEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_down',
CpufreqParser.prototype.cpufreqUpDownEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_already',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_notyet',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_setspeed',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_target',
CpufreqParser.prototype.cpufreqTargetEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_boost',
CpufreqParser.prototype.cpufreqBoostUnboostEvent.bind(this));
importer.registerEventHandler('cpufreq_interactive_unboost',
CpufreqParser.prototype.cpufreqBoostUnboostEvent.bind(this));
} | [
"function",
"CpufreqParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_up'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqUpDownEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_down'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqUpDownEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_already'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqTargetEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_notyet'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqTargetEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_setspeed'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqTargetEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_target'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqTargetEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_boost'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqBoostUnboostEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpufreq_interactive_unboost'",
",",
"CpufreqParser",
".",
"prototype",
".",
"cpufreqBoostUnboostEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux cpufreq trace events.
@constructor | [
"Parses",
"linux",
"cpufreq",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/cpufreq_parser.js#L23-L42 |
23,670 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/cpufreq_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var data = splitData(eventBase.details);
this.cpufreqSlice(ts, eventName, data.cpu, data);
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var data = splitData(eventBase.details);
this.cpufreqSlice(ts, eventName, data.cpu, data);
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"data",
"=",
"splitData",
"(",
"eventBase",
".",
"details",
")",
";",
"this",
".",
"cpufreqSlice",
"(",
"ts",
",",
"eventName",
",",
"data",
".",
"cpu",
",",
"data",
")",
";",
"return",
"true",
";",
"}"
] | Parses cpufreq events and sets up state in the importer. | [
"Parses",
"cpufreq",
"events",
"and",
"sets",
"up",
"state",
"in",
"the",
"importer",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/cpufreq_parser.js#L83-L87 | |
23,671 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/power_parser.js | PowerParser | function PowerParser(importer) {
Parser.call(this, importer);
// NB: old-style power events, deprecated
importer.registerEventHandler('power_start',
PowerParser.prototype.powerStartEvent.bind(this));
importer.registerEventHandler('power_frequency',
PowerParser.prototype.powerFrequencyEvent.bind(this));
importer.registerEventHandler('cpu_frequency',
PowerParser.prototype.cpuFrequencyEvent.bind(this));
importer.registerEventHandler('cpu_idle',
PowerParser.prototype.cpuIdleEvent.bind(this));
} | javascript | function PowerParser(importer) {
Parser.call(this, importer);
// NB: old-style power events, deprecated
importer.registerEventHandler('power_start',
PowerParser.prototype.powerStartEvent.bind(this));
importer.registerEventHandler('power_frequency',
PowerParser.prototype.powerFrequencyEvent.bind(this));
importer.registerEventHandler('cpu_frequency',
PowerParser.prototype.cpuFrequencyEvent.bind(this));
importer.registerEventHandler('cpu_idle',
PowerParser.prototype.cpuIdleEvent.bind(this));
} | [
"function",
"PowerParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"// NB: old-style power events, deprecated",
"importer",
".",
"registerEventHandler",
"(",
"'power_start'",
",",
"PowerParser",
".",
"prototype",
".",
"powerStartEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'power_frequency'",
",",
"PowerParser",
".",
"prototype",
".",
"powerFrequencyEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpu_frequency'",
",",
"PowerParser",
".",
"prototype",
".",
"cpuFrequencyEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'cpu_idle'",
",",
"PowerParser",
".",
"prototype",
".",
"cpuIdleEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux power trace events.
@constructor | [
"Parses",
"linux",
"power",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/power_parser.js#L24-L37 |
23,672 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/power_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /type=(\d+) state=(\d) cpu_id=(\d+)/.exec(eventBase.details);
if (!event)
return false;
var targetCpuNumber = parseInt(event[3]);
var cpuState = parseInt(event[2]);
this.cpuStateSlice(ts, targetCpuNumber, event[1], cpuState);
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /type=(\d+) state=(\d) cpu_id=(\d+)/.exec(eventBase.details);
if (!event)
return false;
var targetCpuNumber = parseInt(event[3]);
var cpuState = parseInt(event[2]);
this.cpuStateSlice(ts, targetCpuNumber, event[1], cpuState);
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"/",
"type=(\\d+) state=(\\d) cpu_id=(\\d+)",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"targetCpuNumber",
"=",
"parseInt",
"(",
"event",
"[",
"3",
"]",
")",
";",
"var",
"cpuState",
"=",
"parseInt",
"(",
"event",
"[",
"2",
"]",
")",
";",
"this",
".",
"cpuStateSlice",
"(",
"ts",
",",
"targetCpuNumber",
",",
"event",
"[",
"1",
"]",
",",
"cpuState",
")",
";",
"return",
"true",
";",
"}"
] | Parses power events and sets up state in the importer. | [
"Parses",
"power",
"events",
"and",
"sets",
"up",
"state",
"in",
"the",
"importer",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/power_parser.js#L95-L104 | |
23,673 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/disk_parser.js | DiskParser | function DiskParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('f2fs_write_begin',
DiskParser.prototype.f2fsWriteBeginEvent.bind(this));
importer.registerEventHandler('f2fs_write_end',
DiskParser.prototype.f2fsWriteEndEvent.bind(this));
importer.registerEventHandler('f2fs_sync_file_enter',
DiskParser.prototype.f2fsSyncFileEnterEvent.bind(this));
importer.registerEventHandler('f2fs_sync_file_exit',
DiskParser.prototype.f2fsSyncFileExitEvent.bind(this));
importer.registerEventHandler('ext4_sync_file_enter',
DiskParser.prototype.ext4SyncFileEnterEvent.bind(this));
importer.registerEventHandler('ext4_sync_file_exit',
DiskParser.prototype.ext4SyncFileExitEvent.bind(this));
importer.registerEventHandler('ext4_da_write_begin',
DiskParser.prototype.ext4WriteBeginEvent.bind(this));
importer.registerEventHandler('ext4_da_write_end',
DiskParser.prototype.ext4WriteEndEvent.bind(this));
importer.registerEventHandler('block_rq_issue',
DiskParser.prototype.blockRqIssueEvent.bind(this));
importer.registerEventHandler('block_rq_complete',
DiskParser.prototype.blockRqCompleteEvent.bind(this));
} | javascript | function DiskParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('f2fs_write_begin',
DiskParser.prototype.f2fsWriteBeginEvent.bind(this));
importer.registerEventHandler('f2fs_write_end',
DiskParser.prototype.f2fsWriteEndEvent.bind(this));
importer.registerEventHandler('f2fs_sync_file_enter',
DiskParser.prototype.f2fsSyncFileEnterEvent.bind(this));
importer.registerEventHandler('f2fs_sync_file_exit',
DiskParser.prototype.f2fsSyncFileExitEvent.bind(this));
importer.registerEventHandler('ext4_sync_file_enter',
DiskParser.prototype.ext4SyncFileEnterEvent.bind(this));
importer.registerEventHandler('ext4_sync_file_exit',
DiskParser.prototype.ext4SyncFileExitEvent.bind(this));
importer.registerEventHandler('ext4_da_write_begin',
DiskParser.prototype.ext4WriteBeginEvent.bind(this));
importer.registerEventHandler('ext4_da_write_end',
DiskParser.prototype.ext4WriteEndEvent.bind(this));
importer.registerEventHandler('block_rq_issue',
DiskParser.prototype.blockRqIssueEvent.bind(this));
importer.registerEventHandler('block_rq_complete',
DiskParser.prototype.blockRqCompleteEvent.bind(this));
} | [
"function",
"DiskParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'f2fs_write_begin'",
",",
"DiskParser",
".",
"prototype",
".",
"f2fsWriteBeginEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'f2fs_write_end'",
",",
"DiskParser",
".",
"prototype",
".",
"f2fsWriteEndEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'f2fs_sync_file_enter'",
",",
"DiskParser",
".",
"prototype",
".",
"f2fsSyncFileEnterEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'f2fs_sync_file_exit'",
",",
"DiskParser",
".",
"prototype",
".",
"f2fsSyncFileExitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'ext4_sync_file_enter'",
",",
"DiskParser",
".",
"prototype",
".",
"ext4SyncFileEnterEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'ext4_sync_file_exit'",
",",
"DiskParser",
".",
"prototype",
".",
"ext4SyncFileExitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'ext4_da_write_begin'",
",",
"DiskParser",
".",
"prototype",
".",
"ext4WriteBeginEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'ext4_da_write_end'",
",",
"DiskParser",
".",
"prototype",
".",
"ext4WriteEndEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'block_rq_issue'",
",",
"DiskParser",
".",
"prototype",
".",
"blockRqIssueEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'block_rq_complete'",
",",
"DiskParser",
".",
"prototype",
".",
"blockRqCompleteEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux filesystem and block device trace events.
@constructor | [
"Parses",
"linux",
"filesystem",
"and",
"block",
"device",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/disk_parser.js#L24-L47 |
23,674 | googlearchive/node-big-rig | lib/third_party/tracing/base/interval_tree.js | function(datum) {
var startPosition = this.beginPositionCb_(datum);
var endPosition = this.endPositionCb_(datum);
var node = new IntervalTreeNode(datum,
startPosition, endPosition);
this.size_++;
this.root_ = this.insertNode_(this.root_, node);
this.root_.colour = Colour.BLACK;
return datum;
} | javascript | function(datum) {
var startPosition = this.beginPositionCb_(datum);
var endPosition = this.endPositionCb_(datum);
var node = new IntervalTreeNode(datum,
startPosition, endPosition);
this.size_++;
this.root_ = this.insertNode_(this.root_, node);
this.root_.colour = Colour.BLACK;
return datum;
} | [
"function",
"(",
"datum",
")",
"{",
"var",
"startPosition",
"=",
"this",
".",
"beginPositionCb_",
"(",
"datum",
")",
";",
"var",
"endPosition",
"=",
"this",
".",
"endPositionCb_",
"(",
"datum",
")",
";",
"var",
"node",
"=",
"new",
"IntervalTreeNode",
"(",
"datum",
",",
"startPosition",
",",
"endPosition",
")",
";",
"this",
".",
"size_",
"++",
";",
"this",
".",
"root_",
"=",
"this",
".",
"insertNode_",
"(",
"this",
".",
"root_",
",",
"node",
")",
";",
"this",
".",
"root_",
".",
"colour",
"=",
"Colour",
".",
"BLACK",
";",
"return",
"datum",
";",
"}"
] | Insert events into the interval tree.
@param {Object} datum The object to insert. | [
"Insert",
"events",
"into",
"the",
"interval",
"tree",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/interval_tree.js#L47-L58 | |
23,675 | googlearchive/node-big-rig | lib/third_party/tracing/base/interval_tree.js | function(queryLow, queryHigh) {
this.validateFindArguments_(queryLow, queryHigh);
if (this.root_ === undefined)
return [];
var ret = [];
this.root_.appendIntersectionsInto_(ret, queryLow, queryHigh);
return ret;
} | javascript | function(queryLow, queryHigh) {
this.validateFindArguments_(queryLow, queryHigh);
if (this.root_ === undefined)
return [];
var ret = [];
this.root_.appendIntersectionsInto_(ret, queryLow, queryHigh);
return ret;
} | [
"function",
"(",
"queryLow",
",",
"queryHigh",
")",
"{",
"this",
".",
"validateFindArguments_",
"(",
"queryLow",
",",
"queryHigh",
")",
";",
"if",
"(",
"this",
".",
"root_",
"===",
"undefined",
")",
"return",
"[",
"]",
";",
"var",
"ret",
"=",
"[",
"]",
";",
"this",
".",
"root_",
".",
"appendIntersectionsInto_",
"(",
"ret",
",",
"queryLow",
",",
"queryHigh",
")",
";",
"return",
"ret",
";",
"}"
] | Retrieve all overlapping intervals.
@param {number} queryLow The low value for the intersection interval.
@param {number} queryHigh The high value for the intersection interval.
@return {Array} All [begin, end] pairs inside intersecting intervals. | [
"Retrieve",
"all",
"overlapping",
"intervals",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/interval_tree.js#L147-L155 | |
23,676 | googlearchive/node-big-rig | lib/third_party/tracing/ui/base/overlay.js | function() {
this.classList.add('overlay');
this.parentEl_ = this.ownerDocument.body;
this.visible_ = false;
this.userCanClose_ = true;
this.onKeyDown_ = this.onKeyDown_.bind(this);
this.onClick_ = this.onClick_.bind(this);
this.onFocusIn_ = this.onFocusIn_.bind(this);
this.onDocumentClick_ = this.onDocumentClick_.bind(this);
this.onClose_ = this.onClose_.bind(this);
this.addEventListener('visible-change',
tr.ui.b.Overlay.prototype.onVisibleChange_.bind(this), true);
// Setup the shadow root
var createShadowRoot = this.createShadowRoot ||
this.webkitCreateShadowRoot;
this.shadow_ = createShadowRoot.call(this);
this.shadow_.appendChild(tr.ui.b.instantiateTemplate('#overlay-template',
THIS_DOC));
this.closeBtn_ = this.shadow_.querySelector('close-button');
this.closeBtn_.addEventListener('click', this.onClose_);
this.shadow_
.querySelector('overlay-frame')
.addEventListener('click', this.onClick_);
this.observer_ = new WebKitMutationObserver(
this.didButtonBarMutate_.bind(this));
this.observer_.observe(this.shadow_.querySelector('button-bar'),
{ childList: true });
// title is a variable on regular HTMLElements. However, we want to
// use it for something more useful.
Object.defineProperty(
this, 'title', {
get: function() {
return this.shadow_.querySelector('title').textContent;
},
set: function(title) {
this.shadow_.querySelector('title').textContent = title;
}
});
} | javascript | function() {
this.classList.add('overlay');
this.parentEl_ = this.ownerDocument.body;
this.visible_ = false;
this.userCanClose_ = true;
this.onKeyDown_ = this.onKeyDown_.bind(this);
this.onClick_ = this.onClick_.bind(this);
this.onFocusIn_ = this.onFocusIn_.bind(this);
this.onDocumentClick_ = this.onDocumentClick_.bind(this);
this.onClose_ = this.onClose_.bind(this);
this.addEventListener('visible-change',
tr.ui.b.Overlay.prototype.onVisibleChange_.bind(this), true);
// Setup the shadow root
var createShadowRoot = this.createShadowRoot ||
this.webkitCreateShadowRoot;
this.shadow_ = createShadowRoot.call(this);
this.shadow_.appendChild(tr.ui.b.instantiateTemplate('#overlay-template',
THIS_DOC));
this.closeBtn_ = this.shadow_.querySelector('close-button');
this.closeBtn_.addEventListener('click', this.onClose_);
this.shadow_
.querySelector('overlay-frame')
.addEventListener('click', this.onClick_);
this.observer_ = new WebKitMutationObserver(
this.didButtonBarMutate_.bind(this));
this.observer_.observe(this.shadow_.querySelector('button-bar'),
{ childList: true });
// title is a variable on regular HTMLElements. However, we want to
// use it for something more useful.
Object.defineProperty(
this, 'title', {
get: function() {
return this.shadow_.querySelector('title').textContent;
},
set: function(title) {
this.shadow_.querySelector('title').textContent = title;
}
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"classList",
".",
"add",
"(",
"'overlay'",
")",
";",
"this",
".",
"parentEl_",
"=",
"this",
".",
"ownerDocument",
".",
"body",
";",
"this",
".",
"visible_",
"=",
"false",
";",
"this",
".",
"userCanClose_",
"=",
"true",
";",
"this",
".",
"onKeyDown_",
"=",
"this",
".",
"onKeyDown_",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"onClick_",
"=",
"this",
".",
"onClick_",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"onFocusIn_",
"=",
"this",
".",
"onFocusIn_",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"onDocumentClick_",
"=",
"this",
".",
"onDocumentClick_",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"onClose_",
"=",
"this",
".",
"onClose_",
".",
"bind",
"(",
"this",
")",
";",
"this",
".",
"addEventListener",
"(",
"'visible-change'",
",",
"tr",
".",
"ui",
".",
"b",
".",
"Overlay",
".",
"prototype",
".",
"onVisibleChange_",
".",
"bind",
"(",
"this",
")",
",",
"true",
")",
";",
"// Setup the shadow root",
"var",
"createShadowRoot",
"=",
"this",
".",
"createShadowRoot",
"||",
"this",
".",
"webkitCreateShadowRoot",
";",
"this",
".",
"shadow_",
"=",
"createShadowRoot",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"shadow_",
".",
"appendChild",
"(",
"tr",
".",
"ui",
".",
"b",
".",
"instantiateTemplate",
"(",
"'#overlay-template'",
",",
"THIS_DOC",
")",
")",
";",
"this",
".",
"closeBtn_",
"=",
"this",
".",
"shadow_",
".",
"querySelector",
"(",
"'close-button'",
")",
";",
"this",
".",
"closeBtn_",
".",
"addEventListener",
"(",
"'click'",
",",
"this",
".",
"onClose_",
")",
";",
"this",
".",
"shadow_",
".",
"querySelector",
"(",
"'overlay-frame'",
")",
".",
"addEventListener",
"(",
"'click'",
",",
"this",
".",
"onClick_",
")",
";",
"this",
".",
"observer_",
"=",
"new",
"WebKitMutationObserver",
"(",
"this",
".",
"didButtonBarMutate_",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"observer_",
".",
"observe",
"(",
"this",
".",
"shadow_",
".",
"querySelector",
"(",
"'button-bar'",
")",
",",
"{",
"childList",
":",
"true",
"}",
")",
";",
"// title is a variable on regular HTMLElements. However, we want to",
"// use it for something more useful.",
"Object",
".",
"defineProperty",
"(",
"this",
",",
"'title'",
",",
"{",
"get",
":",
"function",
"(",
")",
"{",
"return",
"this",
".",
"shadow_",
".",
"querySelector",
"(",
"'title'",
")",
".",
"textContent",
";",
"}",
",",
"set",
":",
"function",
"(",
"title",
")",
"{",
"this",
".",
"shadow_",
".",
"querySelector",
"(",
"'title'",
")",
".",
"textContent",
"=",
"title",
";",
"}",
"}",
")",
";",
"}"
] | Initializes the overlay element. | [
"Initializes",
"the",
"overlay",
"element",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/ui/base/overlay.js#L42-L89 | |
23,677 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_interaction_record.js | userFriendlyRailTypeName | function userFriendlyRailTypeName(railTypeName) {
if (railTypeName.length < 6 || railTypeName.indexOf('rail_') != 0)
return railTypeName;
return railTypeName[5].toUpperCase() + railTypeName.slice(6);
} | javascript | function userFriendlyRailTypeName(railTypeName) {
if (railTypeName.length < 6 || railTypeName.indexOf('rail_') != 0)
return railTypeName;
return railTypeName[5].toUpperCase() + railTypeName.slice(6);
} | [
"function",
"userFriendlyRailTypeName",
"(",
"railTypeName",
")",
"{",
"if",
"(",
"railTypeName",
".",
"length",
"<",
"6",
"||",
"railTypeName",
".",
"indexOf",
"(",
"'rail_'",
")",
"!=",
"0",
")",
"return",
"railTypeName",
";",
"return",
"railTypeName",
"[",
"5",
"]",
".",
"toUpperCase",
"(",
")",
"+",
"railTypeName",
".",
"slice",
"(",
"6",
")",
";",
"}"
] | A user friendly name is currently formed by dropping the rail_ prefix and capitalizing. | [
"A",
"user",
"friendly",
"name",
"is",
"currently",
"formed",
"by",
"dropping",
"the",
"rail_",
"prefix",
"and",
"capitalizing",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_interaction_record.js#L196-L200 |
23,678 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_interaction_record.js | railCompare | function railCompare(name1, name2) {
var i1 = RAIL_ORDER.indexOf(name1.toUpperCase());
var i2 = RAIL_ORDER.indexOf(name2.toUpperCase());
if (i1 == -1 && i2 == -1)
return name1.localeCompare(name2);
if (i1 == -1)
return 1; // i2 is a RAIL name but not i1.
if (i2 == -1)
return -1; // i1 is a RAIL name but not i2.
// Two rail names.
return i1 - i2;
} | javascript | function railCompare(name1, name2) {
var i1 = RAIL_ORDER.indexOf(name1.toUpperCase());
var i2 = RAIL_ORDER.indexOf(name2.toUpperCase());
if (i1 == -1 && i2 == -1)
return name1.localeCompare(name2);
if (i1 == -1)
return 1; // i2 is a RAIL name but not i1.
if (i2 == -1)
return -1; // i1 is a RAIL name but not i2.
// Two rail names.
return i1 - i2;
} | [
"function",
"railCompare",
"(",
"name1",
",",
"name2",
")",
"{",
"var",
"i1",
"=",
"RAIL_ORDER",
".",
"indexOf",
"(",
"name1",
".",
"toUpperCase",
"(",
")",
")",
";",
"var",
"i2",
"=",
"RAIL_ORDER",
".",
"indexOf",
"(",
"name2",
".",
"toUpperCase",
"(",
")",
")",
";",
"if",
"(",
"i1",
"==",
"-",
"1",
"&&",
"i2",
"==",
"-",
"1",
")",
"return",
"name1",
".",
"localeCompare",
"(",
"name2",
")",
";",
"if",
"(",
"i1",
"==",
"-",
"1",
")",
"return",
"1",
";",
"// i2 is a RAIL name but not i1.",
"if",
"(",
"i2",
"==",
"-",
"1",
")",
"return",
"-",
"1",
";",
"// i1 is a RAIL name but not i2.",
"// Two rail names.",
"return",
"i1",
"-",
"i2",
";",
"}"
] | Compare two rail type names or rail user-friendly names so they are sorted in R,A,I,L order. Capitalization is ignore. Non rail names are sorted lexicographically after rail names. | [
"Compare",
"two",
"rail",
"type",
"names",
"or",
"rail",
"user",
"-",
"friendly",
"names",
"so",
"they",
"are",
"sorted",
"in",
"R",
"A",
"I",
"L",
"order",
".",
"Capitalization",
"is",
"ignore",
".",
"Non",
"rail",
"names",
"are",
"sorted",
"lexicographically",
"after",
"rail",
"names",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_interaction_record.js#L205-L216 |
23,679 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/workqueue_parser.js | WorkqueueParser | function WorkqueueParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('workqueue_execute_start',
WorkqueueParser.prototype.executeStartEvent.bind(this));
importer.registerEventHandler('workqueue_execute_end',
WorkqueueParser.prototype.executeEndEvent.bind(this));
importer.registerEventHandler('workqueue_queue_work',
WorkqueueParser.prototype.executeQueueWork.bind(this));
importer.registerEventHandler('workqueue_activate_work',
WorkqueueParser.prototype.executeActivateWork.bind(this));
} | javascript | function WorkqueueParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('workqueue_execute_start',
WorkqueueParser.prototype.executeStartEvent.bind(this));
importer.registerEventHandler('workqueue_execute_end',
WorkqueueParser.prototype.executeEndEvent.bind(this));
importer.registerEventHandler('workqueue_queue_work',
WorkqueueParser.prototype.executeQueueWork.bind(this));
importer.registerEventHandler('workqueue_activate_work',
WorkqueueParser.prototype.executeActivateWork.bind(this));
} | [
"function",
"WorkqueueParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'workqueue_execute_start'",
",",
"WorkqueueParser",
".",
"prototype",
".",
"executeStartEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'workqueue_execute_end'",
",",
"WorkqueueParser",
".",
"prototype",
".",
"executeEndEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'workqueue_queue_work'",
",",
"WorkqueueParser",
".",
"prototype",
".",
"executeQueueWork",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'workqueue_activate_work'",
",",
"WorkqueueParser",
".",
"prototype",
".",
"executeActivateWork",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux workqueue trace events.
@constructor | [
"Parses",
"linux",
"workqueue",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/workqueue_parser.js#L23-L34 |
23,680 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/workqueue_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = workqueueExecuteStartRE.exec(eventBase.details);
if (!event)
return false;
var kthread = this.importer.getOrCreateKernelThread(eventBase.threadName,
pid, pid);
kthread.openSliceTS = ts;
kthread.openSlice = event[2];
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = workqueueExecuteStartRE.exec(eventBase.details);
if (!event)
return false;
var kthread = this.importer.getOrCreateKernelThread(eventBase.threadName,
pid, pid);
kthread.openSliceTS = ts;
kthread.openSlice = event[2];
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"workqueueExecuteStartRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"kthread",
"=",
"this",
".",
"importer",
".",
"getOrCreateKernelThread",
"(",
"eventBase",
".",
"threadName",
",",
"pid",
",",
"pid",
")",
";",
"kthread",
".",
"openSliceTS",
"=",
"ts",
";",
"kthread",
".",
"openSlice",
"=",
"event",
"[",
"2",
"]",
";",
"return",
"true",
";",
"}"
] | Parses workqueue events and sets up state in the importer. | [
"Parses",
"workqueue",
"events",
"and",
"sets",
"up",
"state",
"in",
"the",
"importer",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/workqueue_parser.js#L50-L60 | |
23,681 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | LinuxPerfImporter | function LinuxPerfImporter(model, events) {
this.importPriority = 2;
this.model_ = model;
this.events_ = events;
this.newlyAddedClockSyncRecords_ = [];
this.wakeups_ = [];
this.blocked_reasons_ = [];
this.kernelThreadStates_ = {};
this.buildMapFromLinuxPidsToThreads();
this.lines_ = [];
this.pseudoThreadCounter = 1;
this.parsers_ = [];
this.eventHandlers_ = {};
} | javascript | function LinuxPerfImporter(model, events) {
this.importPriority = 2;
this.model_ = model;
this.events_ = events;
this.newlyAddedClockSyncRecords_ = [];
this.wakeups_ = [];
this.blocked_reasons_ = [];
this.kernelThreadStates_ = {};
this.buildMapFromLinuxPidsToThreads();
this.lines_ = [];
this.pseudoThreadCounter = 1;
this.parsers_ = [];
this.eventHandlers_ = {};
} | [
"function",
"LinuxPerfImporter",
"(",
"model",
",",
"events",
")",
"{",
"this",
".",
"importPriority",
"=",
"2",
";",
"this",
".",
"model_",
"=",
"model",
";",
"this",
".",
"events_",
"=",
"events",
";",
"this",
".",
"newlyAddedClockSyncRecords_",
"=",
"[",
"]",
";",
"this",
".",
"wakeups_",
"=",
"[",
"]",
";",
"this",
".",
"blocked_reasons_",
"=",
"[",
"]",
";",
"this",
".",
"kernelThreadStates_",
"=",
"{",
"}",
";",
"this",
".",
"buildMapFromLinuxPidsToThreads",
"(",
")",
";",
"this",
".",
"lines_",
"=",
"[",
"]",
";",
"this",
".",
"pseudoThreadCounter",
"=",
"1",
";",
"this",
".",
"parsers_",
"=",
"[",
"]",
";",
"this",
".",
"eventHandlers_",
"=",
"{",
"}",
";",
"}"
] | Imports linux perf events into a specified model.
@constructor | [
"Imports",
"linux",
"perf",
"events",
"into",
"a",
"specified",
"model",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L53-L66 |
23,682 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function() {
this.threadsByLinuxPid = {};
this.model_.getAllThreads().forEach(
function(thread) {
this.threadsByLinuxPid[thread.tid] = thread;
}.bind(this));
} | javascript | function() {
this.threadsByLinuxPid = {};
this.model_.getAllThreads().forEach(
function(thread) {
this.threadsByLinuxPid[thread.tid] = thread;
}.bind(this));
} | [
"function",
"(",
")",
"{",
"this",
".",
"threadsByLinuxPid",
"=",
"{",
"}",
";",
"this",
".",
"model_",
".",
"getAllThreads",
"(",
")",
".",
"forEach",
"(",
"function",
"(",
"thread",
")",
"{",
"this",
".",
"threadsByLinuxPid",
"[",
"thread",
".",
"tid",
"]",
"=",
"thread",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Precomputes a lookup table from linux pids back to existing
Threads. This is used during importing to add information to each
thread about whether it was running, descheduled, sleeping, et
cetera. | [
"Precomputes",
"a",
"lookup",
"table",
"from",
"linux",
"pids",
"back",
"to",
"existing",
"Threads",
".",
"This",
"is",
"used",
"during",
"importing",
"to",
"add",
"information",
"to",
"each",
"thread",
"about",
"whether",
"it",
"was",
"running",
"descheduled",
"sleeping",
"et",
"cetera",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L326-L332 | |
23,683 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(isSecondaryImport) {
this.parsers_ = this.createParsers_();
this.registerDefaultHandlers_();
this.parseLines();
this.importClockSyncRecords();
var timeShift = this.computeTimeTransform();
if (timeShift === undefined) {
this.model_.importWarning({
type: 'clock_sync',
message: 'Cannot import kernel trace without a clock sync.'
});
return;
}
this.shiftNewlyAddedClockSyncRecords(timeShift);
this.importCpuData(timeShift);
this.buildMapFromLinuxPidsToThreads();
this.buildPerThreadCpuSlicesFromCpuState();
this.computeCpuTimestampsForSlicesAsNeeded();
} | javascript | function(isSecondaryImport) {
this.parsers_ = this.createParsers_();
this.registerDefaultHandlers_();
this.parseLines();
this.importClockSyncRecords();
var timeShift = this.computeTimeTransform();
if (timeShift === undefined) {
this.model_.importWarning({
type: 'clock_sync',
message: 'Cannot import kernel trace without a clock sync.'
});
return;
}
this.shiftNewlyAddedClockSyncRecords(timeShift);
this.importCpuData(timeShift);
this.buildMapFromLinuxPidsToThreads();
this.buildPerThreadCpuSlicesFromCpuState();
this.computeCpuTimestampsForSlicesAsNeeded();
} | [
"function",
"(",
"isSecondaryImport",
")",
"{",
"this",
".",
"parsers_",
"=",
"this",
".",
"createParsers_",
"(",
")",
";",
"this",
".",
"registerDefaultHandlers_",
"(",
")",
";",
"this",
".",
"parseLines",
"(",
")",
";",
"this",
".",
"importClockSyncRecords",
"(",
")",
";",
"var",
"timeShift",
"=",
"this",
".",
"computeTimeTransform",
"(",
")",
";",
"if",
"(",
"timeShift",
"===",
"undefined",
")",
"{",
"this",
".",
"model_",
".",
"importWarning",
"(",
"{",
"type",
":",
"'clock_sync'",
",",
"message",
":",
"'Cannot import kernel trace without a clock sync.'",
"}",
")",
";",
"return",
";",
"}",
"this",
".",
"shiftNewlyAddedClockSyncRecords",
"(",
"timeShift",
")",
";",
"this",
".",
"importCpuData",
"(",
"timeShift",
")",
";",
"this",
".",
"buildMapFromLinuxPidsToThreads",
"(",
")",
";",
"this",
".",
"buildPerThreadCpuSlicesFromCpuState",
"(",
")",
";",
"this",
".",
"computeCpuTimestampsForSlicesAsNeeded",
"(",
")",
";",
"}"
] | Imports the data in this.events_ into model_. | [
"Imports",
"the",
"data",
"in",
"this",
".",
"events_",
"into",
"model_",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L400-L418 | |
23,684 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(state) {
if (wakeup !== undefined) {
midDuration = wakeup.ts - prevSlice.end;
}
if (blocked_reason !== undefined) {
var args = {
'kernel callsite when blocked:' : blocked_reason.caller
};
if (blocked_reason.iowait) {
switch (state) {
case SCHEDULING_STATE.UNINTR_SLEEP:
state = SCHEDULING_STATE.UNINTR_SLEEP_IO;
break;
case SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL:
state = SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL_IO;
break;
case SCHEDULING_STATE.UNINTR_SLEEP_WAKING:
state = SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL_IO;
break;
default:
}
}
slices.push(new tr.model.ThreadTimeSlice(
thread,
state, '', prevSlice.end, args, midDuration));
} else {
slices.push(new tr.model.ThreadTimeSlice(
thread,
state, '', prevSlice.end, {}, midDuration));
}
if (wakeup !== undefined) {
var wakeupDuration = nextSlice.start - wakeup.ts;
var args = {'wakeup from tid': wakeup.fromTid};
slices.push(new tr.model.ThreadTimeSlice(
thread, SCHEDULING_STATE.RUNNABLE, '',
wakeup.ts, args, wakeupDuration));
wakeup = undefined;
}
} | javascript | function(state) {
if (wakeup !== undefined) {
midDuration = wakeup.ts - prevSlice.end;
}
if (blocked_reason !== undefined) {
var args = {
'kernel callsite when blocked:' : blocked_reason.caller
};
if (blocked_reason.iowait) {
switch (state) {
case SCHEDULING_STATE.UNINTR_SLEEP:
state = SCHEDULING_STATE.UNINTR_SLEEP_IO;
break;
case SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL:
state = SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL_IO;
break;
case SCHEDULING_STATE.UNINTR_SLEEP_WAKING:
state = SCHEDULING_STATE.UNINTR_SLEEP_WAKE_KILL_IO;
break;
default:
}
}
slices.push(new tr.model.ThreadTimeSlice(
thread,
state, '', prevSlice.end, args, midDuration));
} else {
slices.push(new tr.model.ThreadTimeSlice(
thread,
state, '', prevSlice.end, {}, midDuration));
}
if (wakeup !== undefined) {
var wakeupDuration = nextSlice.start - wakeup.ts;
var args = {'wakeup from tid': wakeup.fromTid};
slices.push(new tr.model.ThreadTimeSlice(
thread, SCHEDULING_STATE.RUNNABLE, '',
wakeup.ts, args, wakeupDuration));
wakeup = undefined;
}
} | [
"function",
"(",
"state",
")",
"{",
"if",
"(",
"wakeup",
"!==",
"undefined",
")",
"{",
"midDuration",
"=",
"wakeup",
".",
"ts",
"-",
"prevSlice",
".",
"end",
";",
"}",
"if",
"(",
"blocked_reason",
"!==",
"undefined",
")",
"{",
"var",
"args",
"=",
"{",
"'kernel callsite when blocked:'",
":",
"blocked_reason",
".",
"caller",
"}",
";",
"if",
"(",
"blocked_reason",
".",
"iowait",
")",
"{",
"switch",
"(",
"state",
")",
"{",
"case",
"SCHEDULING_STATE",
".",
"UNINTR_SLEEP",
":",
"state",
"=",
"SCHEDULING_STATE",
".",
"UNINTR_SLEEP_IO",
";",
"break",
";",
"case",
"SCHEDULING_STATE",
".",
"UNINTR_SLEEP_WAKE_KILL",
":",
"state",
"=",
"SCHEDULING_STATE",
".",
"UNINTR_SLEEP_WAKE_KILL_IO",
";",
"break",
";",
"case",
"SCHEDULING_STATE",
".",
"UNINTR_SLEEP_WAKING",
":",
"state",
"=",
"SCHEDULING_STATE",
".",
"UNINTR_SLEEP_WAKE_KILL_IO",
";",
"break",
";",
"default",
":",
"}",
"}",
"slices",
".",
"push",
"(",
"new",
"tr",
".",
"model",
".",
"ThreadTimeSlice",
"(",
"thread",
",",
"state",
",",
"''",
",",
"prevSlice",
".",
"end",
",",
"args",
",",
"midDuration",
")",
")",
";",
"}",
"else",
"{",
"slices",
".",
"push",
"(",
"new",
"tr",
".",
"model",
".",
"ThreadTimeSlice",
"(",
"thread",
",",
"state",
",",
"''",
",",
"prevSlice",
".",
"end",
",",
"{",
"}",
",",
"midDuration",
")",
")",
";",
"}",
"if",
"(",
"wakeup",
"!==",
"undefined",
")",
"{",
"var",
"wakeupDuration",
"=",
"nextSlice",
".",
"start",
"-",
"wakeup",
".",
"ts",
";",
"var",
"args",
"=",
"{",
"'wakeup from tid'",
":",
"wakeup",
".",
"fromTid",
"}",
";",
"slices",
".",
"push",
"(",
"new",
"tr",
".",
"model",
".",
"ThreadTimeSlice",
"(",
"thread",
",",
"SCHEDULING_STATE",
".",
"RUNNABLE",
",",
"''",
",",
"wakeup",
".",
"ts",
",",
"args",
",",
"wakeupDuration",
")",
")",
";",
"wakeup",
"=",
"undefined",
";",
"}",
"}"
] | Push a sleep slice onto the slices list, interrupting it with a wakeup if appropriate. | [
"Push",
"a",
"sleep",
"slice",
"onto",
"the",
"slices",
"list",
"interrupting",
"it",
"with",
"a",
"wakeup",
"if",
"appropriate",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L534-L573 | |
23,685 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function() {
var isSecondaryImport = this.model.getClockSyncRecordsNamed(
'ftrace_importer').length !== 0;
var mSyncs = this.model_.getClockSyncRecordsNamed('monotonic');
// If this is a secondary import, and no clock syncing records were
// found, then abort the import. Otherwise, just skip clock alignment.
if (mSyncs.length == 0)
return isSecondaryImport ? undefined : 0;
// Shift all the slice times based on the sync record.
// TODO(skyostil): Compute a scaling factor if we have multiple clock sync
// records.
var sync = mSyncs[0].args;
// NB: parentTS of zero denotes no times-shift; this is
// used when user and kernel event clocks are identical.
if (sync.parentTS == 0 || sync.parentTS == sync.perfTS)
return 0;
return sync.parentTS - sync.perfTS;
} | javascript | function() {
var isSecondaryImport = this.model.getClockSyncRecordsNamed(
'ftrace_importer').length !== 0;
var mSyncs = this.model_.getClockSyncRecordsNamed('monotonic');
// If this is a secondary import, and no clock syncing records were
// found, then abort the import. Otherwise, just skip clock alignment.
if (mSyncs.length == 0)
return isSecondaryImport ? undefined : 0;
// Shift all the slice times based on the sync record.
// TODO(skyostil): Compute a scaling factor if we have multiple clock sync
// records.
var sync = mSyncs[0].args;
// NB: parentTS of zero denotes no times-shift; this is
// used when user and kernel event clocks are identical.
if (sync.parentTS == 0 || sync.parentTS == sync.perfTS)
return 0;
return sync.parentTS - sync.perfTS;
} | [
"function",
"(",
")",
"{",
"var",
"isSecondaryImport",
"=",
"this",
".",
"model",
".",
"getClockSyncRecordsNamed",
"(",
"'ftrace_importer'",
")",
".",
"length",
"!==",
"0",
";",
"var",
"mSyncs",
"=",
"this",
".",
"model_",
".",
"getClockSyncRecordsNamed",
"(",
"'monotonic'",
")",
";",
"// If this is a secondary import, and no clock syncing records were",
"// found, then abort the import. Otherwise, just skip clock alignment.",
"if",
"(",
"mSyncs",
".",
"length",
"==",
"0",
")",
"return",
"isSecondaryImport",
"?",
"undefined",
":",
"0",
";",
"// Shift all the slice times based on the sync record.",
"// TODO(skyostil): Compute a scaling factor if we have multiple clock sync",
"// records.",
"var",
"sync",
"=",
"mSyncs",
"[",
"0",
"]",
".",
"args",
";",
"// NB: parentTS of zero denotes no times-shift; this is",
"// used when user and kernel event clocks are identical.",
"if",
"(",
"sync",
".",
"parentTS",
"==",
"0",
"||",
"sync",
".",
"parentTS",
"==",
"sync",
".",
"perfTS",
")",
"return",
"0",
";",
"return",
"sync",
".",
"parentTS",
"-",
"sync",
".",
"perfTS",
";",
"}"
] | Computes a time transform from perf time to parent time based on the
imported clock sync records.
@return {number} offset from perf time to parent time or undefined if
the necessary sync records were not found. | [
"Computes",
"a",
"time",
"transform",
"from",
"perf",
"time",
"to",
"parent",
"time",
"based",
"on",
"the",
"imported",
"clock",
"sync",
"records",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L648-L667 | |
23,686 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(ts, pid, comm, prio, fromPid) {
// The the pids that get passed in to this function are Linux kernel
// pids, which identify threads. The rest of trace-viewer refers to
// these as tids, so the change of nomenclature happens in the following
// construction of the wakeup object.
this.wakeups_.push({ts: ts, tid: pid, fromTid: fromPid});
} | javascript | function(ts, pid, comm, prio, fromPid) {
// The the pids that get passed in to this function are Linux kernel
// pids, which identify threads. The rest of trace-viewer refers to
// these as tids, so the change of nomenclature happens in the following
// construction of the wakeup object.
this.wakeups_.push({ts: ts, tid: pid, fromTid: fromPid});
} | [
"function",
"(",
"ts",
",",
"pid",
",",
"comm",
",",
"prio",
",",
"fromPid",
")",
"{",
"// The the pids that get passed in to this function are Linux kernel",
"// pids, which identify threads. The rest of trace-viewer refers to",
"// these as tids, so the change of nomenclature happens in the following",
"// construction of the wakeup object.",
"this",
".",
"wakeups_",
".",
"push",
"(",
"{",
"ts",
":",
"ts",
",",
"tid",
":",
"pid",
",",
"fromTid",
":",
"fromPid",
"}",
")",
";",
"}"
] | Records the fact that a pid has become runnable. This data will
eventually get used to derive each thread's timeSlices array. | [
"Records",
"the",
"fact",
"that",
"a",
"pid",
"has",
"become",
"runnable",
".",
"This",
"data",
"will",
"eventually",
"get",
"used",
"to",
"derive",
"each",
"thread",
"s",
"timeSlices",
"array",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L712-L718 | |
23,687 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(ts, pid, iowait, caller) {
// The the pids that get passed in to this function are Linux kernel
// pids, which identify threads. The rest of trace-viewer refers to
// these as tids, so the change of nomenclature happens in the following
// construction of the wakeup object.
this.blocked_reasons_.push({ts: ts, tid: pid, iowait: iowait,
caller: caller});
} | javascript | function(ts, pid, iowait, caller) {
// The the pids that get passed in to this function are Linux kernel
// pids, which identify threads. The rest of trace-viewer refers to
// these as tids, so the change of nomenclature happens in the following
// construction of the wakeup object.
this.blocked_reasons_.push({ts: ts, tid: pid, iowait: iowait,
caller: caller});
} | [
"function",
"(",
"ts",
",",
"pid",
",",
"iowait",
",",
"caller",
")",
"{",
"// The the pids that get passed in to this function are Linux kernel",
"// pids, which identify threads. The rest of trace-viewer refers to",
"// these as tids, so the change of nomenclature happens in the following",
"// construction of the wakeup object.",
"this",
".",
"blocked_reasons_",
".",
"push",
"(",
"{",
"ts",
":",
"ts",
",",
"tid",
":",
"pid",
",",
"iowait",
":",
"iowait",
",",
"caller",
":",
"caller",
"}",
")",
";",
"}"
] | Records the reason why a pid has gone into uninterruptible sleep. | [
"Records",
"the",
"reason",
"why",
"a",
"pid",
"has",
"gone",
"into",
"uninterruptible",
"sleep",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L723-L730 | |
23,688 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(eventName, cpuNumber, pid, ts, eventBase) {
// Check for new-style clock sync records.
var event = /name=(\w+?)\s(.+)/.exec(eventBase.details);
if (event) {
var name = event[1];
var pieces = event[2].split(' ');
var args = {
perfTS: ts
};
for (var i = 0; i < pieces.length; i++) {
var parts = pieces[i].split('=');
if (parts.length != 2)
throw new Error('omgbbq');
args[parts[0]] = parts[1];
}
this.addClockSyncRecord(new ClockSyncRecord(name, ts, args));
return true;
}
// Old-style clock sync records from chromium
event = /parent_ts=(\d+\.?\d*)/.exec(eventBase.details);
if (!event)
return false;
this.addClockSyncRecord(new ClockSyncRecord('monotonic', ts, {
perfTS: ts,
parentTS: event[1] * 1000
}));
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
// Check for new-style clock sync records.
var event = /name=(\w+?)\s(.+)/.exec(eventBase.details);
if (event) {
var name = event[1];
var pieces = event[2].split(' ');
var args = {
perfTS: ts
};
for (var i = 0; i < pieces.length; i++) {
var parts = pieces[i].split('=');
if (parts.length != 2)
throw new Error('omgbbq');
args[parts[0]] = parts[1];
}
this.addClockSyncRecord(new ClockSyncRecord(name, ts, args));
return true;
}
// Old-style clock sync records from chromium
event = /parent_ts=(\d+\.?\d*)/.exec(eventBase.details);
if (!event)
return false;
this.addClockSyncRecord(new ClockSyncRecord('monotonic', ts, {
perfTS: ts,
parentTS: event[1] * 1000
}));
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"// Check for new-style clock sync records.",
"var",
"event",
"=",
"/",
"name=(\\w+?)\\s(.+)",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"event",
")",
"{",
"var",
"name",
"=",
"event",
"[",
"1",
"]",
";",
"var",
"pieces",
"=",
"event",
"[",
"2",
"]",
".",
"split",
"(",
"' '",
")",
";",
"var",
"args",
"=",
"{",
"perfTS",
":",
"ts",
"}",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"pieces",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"parts",
"=",
"pieces",
"[",
"i",
"]",
".",
"split",
"(",
"'='",
")",
";",
"if",
"(",
"parts",
".",
"length",
"!=",
"2",
")",
"throw",
"new",
"Error",
"(",
"'omgbbq'",
")",
";",
"args",
"[",
"parts",
"[",
"0",
"]",
"]",
"=",
"parts",
"[",
"1",
"]",
";",
"}",
"this",
".",
"addClockSyncRecord",
"(",
"new",
"ClockSyncRecord",
"(",
"name",
",",
"ts",
",",
"args",
")",
")",
";",
"return",
"true",
";",
"}",
"// Old-style clock sync records from chromium",
"event",
"=",
"/",
"parent_ts=(\\d+\\.?\\d*)",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"this",
".",
"addClockSyncRecord",
"(",
"new",
"ClockSyncRecord",
"(",
"'monotonic'",
",",
"ts",
",",
"{",
"perfTS",
":",
"ts",
",",
"parentTS",
":",
"event",
"[",
"1",
"]",
"*",
"1000",
"}",
")",
")",
";",
"return",
"true",
";",
"}"
] | Processes a trace_event_clock_sync event. | [
"Processes",
"a",
"trace_event_clock_sync",
"event",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L735-L764 | |
23,689 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(eventName, cpuNumber, pid, ts, eventBase,
threadName) {
// Some profiles end up with a \n\ on the end of each line. Strip it
// before we do the comparisons.
eventBase.details = eventBase.details.replace(/\\n.*$/, '');
var event = /^\s*(\w+):\s*(.*)$/.exec(eventBase.details);
if (!event) {
// Check if the event matches events traced by the Android framework
var tag = eventBase.details.substring(0, 2);
if (tag == 'B|' || tag == 'E' || tag == 'E|' || tag == 'X|' ||
tag == 'C|' || tag == 'S|' || tag == 'F|') {
eventBase.subEventName = 'android';
} else {
return false;
}
} else {
eventBase.subEventName = event[1];
eventBase.details = event[2];
}
var writeEventName = eventName + ':' + eventBase.subEventName;
var handler = this.eventHandlers_[writeEventName];
if (!handler) {
this.model_.importWarning({
type: 'parse_error',
message: 'Unknown trace_marking_write event ' + writeEventName
});
return true;
}
return handler(writeEventName, cpuNumber, pid, ts, eventBase, threadName);
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase,
threadName) {
// Some profiles end up with a \n\ on the end of each line. Strip it
// before we do the comparisons.
eventBase.details = eventBase.details.replace(/\\n.*$/, '');
var event = /^\s*(\w+):\s*(.*)$/.exec(eventBase.details);
if (!event) {
// Check if the event matches events traced by the Android framework
var tag = eventBase.details.substring(0, 2);
if (tag == 'B|' || tag == 'E' || tag == 'E|' || tag == 'X|' ||
tag == 'C|' || tag == 'S|' || tag == 'F|') {
eventBase.subEventName = 'android';
} else {
return false;
}
} else {
eventBase.subEventName = event[1];
eventBase.details = event[2];
}
var writeEventName = eventName + ':' + eventBase.subEventName;
var handler = this.eventHandlers_[writeEventName];
if (!handler) {
this.model_.importWarning({
type: 'parse_error',
message: 'Unknown trace_marking_write event ' + writeEventName
});
return true;
}
return handler(writeEventName, cpuNumber, pid, ts, eventBase, threadName);
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
",",
"threadName",
")",
"{",
"// Some profiles end up with a \\n\\ on the end of each line. Strip it",
"// before we do the comparisons.",
"eventBase",
".",
"details",
"=",
"eventBase",
".",
"details",
".",
"replace",
"(",
"/",
"\\\\n.*$",
"/",
",",
"''",
")",
";",
"var",
"event",
"=",
"/",
"^\\s*(\\w+):\\s*(.*)$",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"{",
"// Check if the event matches events traced by the Android framework",
"var",
"tag",
"=",
"eventBase",
".",
"details",
".",
"substring",
"(",
"0",
",",
"2",
")",
";",
"if",
"(",
"tag",
"==",
"'B|'",
"||",
"tag",
"==",
"'E'",
"||",
"tag",
"==",
"'E|'",
"||",
"tag",
"==",
"'X|'",
"||",
"tag",
"==",
"'C|'",
"||",
"tag",
"==",
"'S|'",
"||",
"tag",
"==",
"'F|'",
")",
"{",
"eventBase",
".",
"subEventName",
"=",
"'android'",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"eventBase",
".",
"subEventName",
"=",
"event",
"[",
"1",
"]",
";",
"eventBase",
".",
"details",
"=",
"event",
"[",
"2",
"]",
";",
"}",
"var",
"writeEventName",
"=",
"eventName",
"+",
"':'",
"+",
"eventBase",
".",
"subEventName",
";",
"var",
"handler",
"=",
"this",
".",
"eventHandlers_",
"[",
"writeEventName",
"]",
";",
"if",
"(",
"!",
"handler",
")",
"{",
"this",
".",
"model_",
".",
"importWarning",
"(",
"{",
"type",
":",
"'parse_error'",
",",
"message",
":",
"'Unknown trace_marking_write event '",
"+",
"writeEventName",
"}",
")",
";",
"return",
"true",
";",
"}",
"return",
"handler",
"(",
"writeEventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
",",
"threadName",
")",
";",
"}"
] | Processes a trace_marking_write event. | [
"Processes",
"a",
"trace_marking_write",
"event",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L769-L801 | |
23,690 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function() {
this.forEachLine(function(text, eventBase, cpuNumber, pid, ts) {
var eventName = eventBase.eventName;
if (eventName !== 'tracing_mark_write' && eventName !== '0')
return;
if (traceEventClockSyncRE.exec(eventBase.details))
this.traceClockSyncEvent(eventName, cpuNumber, pid, ts, eventBase);
if (realTimeClockSyncRE.exec(eventBase.details)) {
// This entry maps realtime to clock_monotonic; store in the model
// so that importers parsing files with realtime timestamps can
// map this back to monotonic.
var match = realTimeClockSyncRE.exec(eventBase.details);
this.model_.realtime_to_monotonic_offset_ms = ts - match[1];
}
if (genericClockSyncRE.exec(eventBase.details))
this.traceClockSyncEvent(eventName, cpuNumber, pid, ts, eventBase);
}.bind(this));
} | javascript | function() {
this.forEachLine(function(text, eventBase, cpuNumber, pid, ts) {
var eventName = eventBase.eventName;
if (eventName !== 'tracing_mark_write' && eventName !== '0')
return;
if (traceEventClockSyncRE.exec(eventBase.details))
this.traceClockSyncEvent(eventName, cpuNumber, pid, ts, eventBase);
if (realTimeClockSyncRE.exec(eventBase.details)) {
// This entry maps realtime to clock_monotonic; store in the model
// so that importers parsing files with realtime timestamps can
// map this back to monotonic.
var match = realTimeClockSyncRE.exec(eventBase.details);
this.model_.realtime_to_monotonic_offset_ms = ts - match[1];
}
if (genericClockSyncRE.exec(eventBase.details))
this.traceClockSyncEvent(eventName, cpuNumber, pid, ts, eventBase);
}.bind(this));
} | [
"function",
"(",
")",
"{",
"this",
".",
"forEachLine",
"(",
"function",
"(",
"text",
",",
"eventBase",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
")",
"{",
"var",
"eventName",
"=",
"eventBase",
".",
"eventName",
";",
"if",
"(",
"eventName",
"!==",
"'tracing_mark_write'",
"&&",
"eventName",
"!==",
"'0'",
")",
"return",
";",
"if",
"(",
"traceEventClockSyncRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
")",
"this",
".",
"traceClockSyncEvent",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
";",
"if",
"(",
"realTimeClockSyncRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
")",
"{",
"// This entry maps realtime to clock_monotonic; store in the model",
"// so that importers parsing files with realtime timestamps can",
"// map this back to monotonic.",
"var",
"match",
"=",
"realTimeClockSyncRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"this",
".",
"model_",
".",
"realtime_to_monotonic_offset_ms",
"=",
"ts",
"-",
"match",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"genericClockSyncRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
")",
"this",
".",
"traceClockSyncEvent",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
";",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Populates model clockSyncRecords with found clock sync markers. | [
"Populates",
"model",
"clockSyncRecords",
"with",
"found",
"clock",
"sync",
"markers",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L806-L823 | |
23,691 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(timeShift) {
this.forEachLine(function(text, eventBase, cpuNumber, pid, ts) {
var eventName = eventBase.eventName;
var handler = this.eventHandlers_[eventName];
if (!handler) {
this.model_.importWarning({
type: 'parse_error',
message: 'Unknown event ' + eventName + ' (' + text + ')'
});
return;
}
ts += timeShift;
if (!handler(eventName, cpuNumber, pid, ts, eventBase)) {
this.model_.importWarning({
type: 'parse_error',
message: 'Malformed ' + eventName + ' event (' + text + ')'
});
}
}.bind(this));
} | javascript | function(timeShift) {
this.forEachLine(function(text, eventBase, cpuNumber, pid, ts) {
var eventName = eventBase.eventName;
var handler = this.eventHandlers_[eventName];
if (!handler) {
this.model_.importWarning({
type: 'parse_error',
message: 'Unknown event ' + eventName + ' (' + text + ')'
});
return;
}
ts += timeShift;
if (!handler(eventName, cpuNumber, pid, ts, eventBase)) {
this.model_.importWarning({
type: 'parse_error',
message: 'Malformed ' + eventName + ' event (' + text + ')'
});
}
}.bind(this));
} | [
"function",
"(",
"timeShift",
")",
"{",
"this",
".",
"forEachLine",
"(",
"function",
"(",
"text",
",",
"eventBase",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
")",
"{",
"var",
"eventName",
"=",
"eventBase",
".",
"eventName",
";",
"var",
"handler",
"=",
"this",
".",
"eventHandlers_",
"[",
"eventName",
"]",
";",
"if",
"(",
"!",
"handler",
")",
"{",
"this",
".",
"model_",
".",
"importWarning",
"(",
"{",
"type",
":",
"'parse_error'",
",",
"message",
":",
"'Unknown event '",
"+",
"eventName",
"+",
"' ('",
"+",
"text",
"+",
"')'",
"}",
")",
";",
"return",
";",
"}",
"ts",
"+=",
"timeShift",
";",
"if",
"(",
"!",
"handler",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
")",
"{",
"this",
".",
"model_",
".",
"importWarning",
"(",
"{",
"type",
":",
"'parse_error'",
",",
"message",
":",
"'Malformed '",
"+",
"eventName",
"+",
"' event ('",
"+",
"text",
"+",
"')'",
"}",
")",
";",
"}",
"}",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Walks the this.events_ structure and creates Cpu objects. | [
"Walks",
"the",
"this",
".",
"events_",
"structure",
"and",
"creates",
"Cpu",
"objects",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L838-L857 | |
23,692 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function() {
var lines = [];
var extractResult = LinuxPerfImporter._extractEventsFromSystraceHTML(
this.events_, true);
if (!extractResult.ok)
extractResult = LinuxPerfImporter._extractEventsFromSystraceMultiHTML(
this.events_, true);
var lines = extractResult.ok ?
extractResult.lines : this.events_.split('\n');
var lineParser = null;
for (var lineNumber = 0; lineNumber < lines.length; ++lineNumber) {
var line = lines[lineNumber].trim();
if (line.length == 0 || /^#/.test(line))
continue;
if (lineParser == null) {
lineParser = autoDetectLineParser(line);
if (lineParser == null) {
this.model_.importWarning({
type: 'parse_error',
message: 'Cannot parse line: ' + line
});
continue;
}
}
var eventBase = lineParser(line);
if (!eventBase) {
this.model_.importWarning({
type: 'parse_error',
message: 'Unrecognized line: ' + line
});
continue;
}
this.lines_.push([
line,
eventBase,
parseInt(eventBase.cpuNumber),
parseInt(eventBase.pid),
parseFloat(eventBase.timestamp) * 1000
]);
}
} | javascript | function() {
var lines = [];
var extractResult = LinuxPerfImporter._extractEventsFromSystraceHTML(
this.events_, true);
if (!extractResult.ok)
extractResult = LinuxPerfImporter._extractEventsFromSystraceMultiHTML(
this.events_, true);
var lines = extractResult.ok ?
extractResult.lines : this.events_.split('\n');
var lineParser = null;
for (var lineNumber = 0; lineNumber < lines.length; ++lineNumber) {
var line = lines[lineNumber].trim();
if (line.length == 0 || /^#/.test(line))
continue;
if (lineParser == null) {
lineParser = autoDetectLineParser(line);
if (lineParser == null) {
this.model_.importWarning({
type: 'parse_error',
message: 'Cannot parse line: ' + line
});
continue;
}
}
var eventBase = lineParser(line);
if (!eventBase) {
this.model_.importWarning({
type: 'parse_error',
message: 'Unrecognized line: ' + line
});
continue;
}
this.lines_.push([
line,
eventBase,
parseInt(eventBase.cpuNumber),
parseInt(eventBase.pid),
parseFloat(eventBase.timestamp) * 1000
]);
}
} | [
"function",
"(",
")",
"{",
"var",
"lines",
"=",
"[",
"]",
";",
"var",
"extractResult",
"=",
"LinuxPerfImporter",
".",
"_extractEventsFromSystraceHTML",
"(",
"this",
".",
"events_",
",",
"true",
")",
";",
"if",
"(",
"!",
"extractResult",
".",
"ok",
")",
"extractResult",
"=",
"LinuxPerfImporter",
".",
"_extractEventsFromSystraceMultiHTML",
"(",
"this",
".",
"events_",
",",
"true",
")",
";",
"var",
"lines",
"=",
"extractResult",
".",
"ok",
"?",
"extractResult",
".",
"lines",
":",
"this",
".",
"events_",
".",
"split",
"(",
"'\\n'",
")",
";",
"var",
"lineParser",
"=",
"null",
";",
"for",
"(",
"var",
"lineNumber",
"=",
"0",
";",
"lineNumber",
"<",
"lines",
".",
"length",
";",
"++",
"lineNumber",
")",
"{",
"var",
"line",
"=",
"lines",
"[",
"lineNumber",
"]",
".",
"trim",
"(",
")",
";",
"if",
"(",
"line",
".",
"length",
"==",
"0",
"||",
"/",
"^#",
"/",
".",
"test",
"(",
"line",
")",
")",
"continue",
";",
"if",
"(",
"lineParser",
"==",
"null",
")",
"{",
"lineParser",
"=",
"autoDetectLineParser",
"(",
"line",
")",
";",
"if",
"(",
"lineParser",
"==",
"null",
")",
"{",
"this",
".",
"model_",
".",
"importWarning",
"(",
"{",
"type",
":",
"'parse_error'",
",",
"message",
":",
"'Cannot parse line: '",
"+",
"line",
"}",
")",
";",
"continue",
";",
"}",
"}",
"var",
"eventBase",
"=",
"lineParser",
"(",
"line",
")",
";",
"if",
"(",
"!",
"eventBase",
")",
"{",
"this",
".",
"model_",
".",
"importWarning",
"(",
"{",
"type",
":",
"'parse_error'",
",",
"message",
":",
"'Unrecognized line: '",
"+",
"line",
"}",
")",
";",
"continue",
";",
"}",
"this",
".",
"lines_",
".",
"push",
"(",
"[",
"line",
",",
"eventBase",
",",
"parseInt",
"(",
"eventBase",
".",
"cpuNumber",
")",
",",
"parseInt",
"(",
"eventBase",
".",
"pid",
")",
",",
"parseFloat",
"(",
"eventBase",
".",
"timestamp",
")",
"*",
"1000",
"]",
")",
";",
"}",
"}"
] | Walks the this.events_ structure and populates this.lines_. | [
"Walks",
"the",
"this",
".",
"events_",
"structure",
"and",
"populates",
"this",
".",
"lines_",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L862-L904 | |
23,693 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js | function(handler) {
for (var i = 0; i < this.lines_.length; ++i) {
var line = this.lines_[i];
handler.apply(this, line);
}
} | javascript | function(handler) {
for (var i = 0; i < this.lines_.length; ++i) {
var line = this.lines_[i];
handler.apply(this, line);
}
} | [
"function",
"(",
"handler",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"lines_",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"line",
"=",
"this",
".",
"lines_",
"[",
"i",
"]",
";",
"handler",
".",
"apply",
"(",
"this",
",",
"line",
")",
";",
"}",
"}"
] | Calls |handler| for every parsed line. | [
"Calls",
"|handler|",
"for",
"every",
"parsed",
"line",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/ftrace_importer.js#L909-L914 | |
23,694 | googlearchive/node-big-rig | lib/third_party/tracing/model/cpu.js | Cpu | function Cpu(kernel, number) {
if (kernel === undefined || number === undefined)
throw new Error('Missing arguments');
this.kernel = kernel;
this.cpuNumber = number;
this.slices = [];
this.counters = {};
this.bounds = new tr.b.Range();
this.samples_ = undefined; // Set during createSubSlices
// Start timestamp of the last active thread.
this.lastActiveTimestamp_ = undefined;
// Identifier of the last active thread. On Linux, it's a pid while on
// Windows it's a thread id.
this.lastActiveThread_ = undefined;
// Name and arguments of the last active thread.
this.lastActiveName_ = undefined;
this.lastActiveArgs_ = undefined;
} | javascript | function Cpu(kernel, number) {
if (kernel === undefined || number === undefined)
throw new Error('Missing arguments');
this.kernel = kernel;
this.cpuNumber = number;
this.slices = [];
this.counters = {};
this.bounds = new tr.b.Range();
this.samples_ = undefined; // Set during createSubSlices
// Start timestamp of the last active thread.
this.lastActiveTimestamp_ = undefined;
// Identifier of the last active thread. On Linux, it's a pid while on
// Windows it's a thread id.
this.lastActiveThread_ = undefined;
// Name and arguments of the last active thread.
this.lastActiveName_ = undefined;
this.lastActiveArgs_ = undefined;
} | [
"function",
"Cpu",
"(",
"kernel",
",",
"number",
")",
"{",
"if",
"(",
"kernel",
"===",
"undefined",
"||",
"number",
"===",
"undefined",
")",
"throw",
"new",
"Error",
"(",
"'Missing arguments'",
")",
";",
"this",
".",
"kernel",
"=",
"kernel",
";",
"this",
".",
"cpuNumber",
"=",
"number",
";",
"this",
".",
"slices",
"=",
"[",
"]",
";",
"this",
".",
"counters",
"=",
"{",
"}",
";",
"this",
".",
"bounds",
"=",
"new",
"tr",
".",
"b",
".",
"Range",
"(",
")",
";",
"this",
".",
"samples_",
"=",
"undefined",
";",
"// Set during createSubSlices",
"// Start timestamp of the last active thread.",
"this",
".",
"lastActiveTimestamp_",
"=",
"undefined",
";",
"// Identifier of the last active thread. On Linux, it's a pid while on",
"// Windows it's a thread id.",
"this",
".",
"lastActiveThread_",
"=",
"undefined",
";",
"// Name and arguments of the last active thread.",
"this",
".",
"lastActiveName_",
"=",
"undefined",
";",
"this",
".",
"lastActiveArgs_",
"=",
"undefined",
";",
"}"
] | The Cpu represents a Cpu from the kernel's point of view.
@constructor | [
"The",
"Cpu",
"represents",
"a",
"Cpu",
"from",
"the",
"kernel",
"s",
"point",
"of",
"view",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/model/cpu.js#L28-L48 |
23,695 | googlearchive/node-big-rig | lib/third_party/tracing/model/cpu.js | function(amount) {
for (var sI = 0; sI < this.slices.length; sI++)
this.slices[sI].start = (this.slices[sI].start + amount);
for (var id in this.counters)
this.counters[id].shiftTimestampsForward(amount);
} | javascript | function(amount) {
for (var sI = 0; sI < this.slices.length; sI++)
this.slices[sI].start = (this.slices[sI].start + amount);
for (var id in this.counters)
this.counters[id].shiftTimestampsForward(amount);
} | [
"function",
"(",
"amount",
")",
"{",
"for",
"(",
"var",
"sI",
"=",
"0",
";",
"sI",
"<",
"this",
".",
"slices",
".",
"length",
";",
"sI",
"++",
")",
"this",
".",
"slices",
"[",
"sI",
"]",
".",
"start",
"=",
"(",
"this",
".",
"slices",
"[",
"sI",
"]",
".",
"start",
"+",
"amount",
")",
";",
"for",
"(",
"var",
"id",
"in",
"this",
".",
"counters",
")",
"this",
".",
"counters",
"[",
"id",
"]",
".",
"shiftTimestampsForward",
"(",
"amount",
")",
";",
"}"
] | Shifts all the timestamps inside this CPU forward by the amount
specified. | [
"Shifts",
"all",
"the",
"timestamps",
"inside",
"this",
"CPU",
"forward",
"by",
"the",
"amount",
"specified",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/model/cpu.js#L101-L106 | |
23,696 | googlearchive/node-big-rig | lib/third_party/tracing/model/cpu.js | function() {
this.bounds.reset();
if (this.slices.length) {
this.bounds.addValue(this.slices[0].start);
this.bounds.addValue(this.slices[this.slices.length - 1].end);
}
for (var id in this.counters) {
this.counters[id].updateBounds();
this.bounds.addRange(this.counters[id].bounds);
}
if (this.samples_ && this.samples_.length) {
this.bounds.addValue(this.samples_[0].start);
this.bounds.addValue(
this.samples_[this.samples_.length - 1].end);
}
} | javascript | function() {
this.bounds.reset();
if (this.slices.length) {
this.bounds.addValue(this.slices[0].start);
this.bounds.addValue(this.slices[this.slices.length - 1].end);
}
for (var id in this.counters) {
this.counters[id].updateBounds();
this.bounds.addRange(this.counters[id].bounds);
}
if (this.samples_ && this.samples_.length) {
this.bounds.addValue(this.samples_[0].start);
this.bounds.addValue(
this.samples_[this.samples_.length - 1].end);
}
} | [
"function",
"(",
")",
"{",
"this",
".",
"bounds",
".",
"reset",
"(",
")",
";",
"if",
"(",
"this",
".",
"slices",
".",
"length",
")",
"{",
"this",
".",
"bounds",
".",
"addValue",
"(",
"this",
".",
"slices",
"[",
"0",
"]",
".",
"start",
")",
";",
"this",
".",
"bounds",
".",
"addValue",
"(",
"this",
".",
"slices",
"[",
"this",
".",
"slices",
".",
"length",
"-",
"1",
"]",
".",
"end",
")",
";",
"}",
"for",
"(",
"var",
"id",
"in",
"this",
".",
"counters",
")",
"{",
"this",
".",
"counters",
"[",
"id",
"]",
".",
"updateBounds",
"(",
")",
";",
"this",
".",
"bounds",
".",
"addRange",
"(",
"this",
".",
"counters",
"[",
"id",
"]",
".",
"bounds",
")",
";",
"}",
"if",
"(",
"this",
".",
"samples_",
"&&",
"this",
".",
"samples_",
".",
"length",
")",
"{",
"this",
".",
"bounds",
".",
"addValue",
"(",
"this",
".",
"samples_",
"[",
"0",
"]",
".",
"start",
")",
";",
"this",
".",
"bounds",
".",
"addValue",
"(",
"this",
".",
"samples_",
"[",
"this",
".",
"samples_",
".",
"length",
"-",
"1",
"]",
".",
"end",
")",
";",
"}",
"}"
] | Updates the range based on the current slices attached to the cpu. | [
"Updates",
"the",
"range",
"based",
"on",
"the",
"current",
"slices",
"attached",
"to",
"the",
"cpu",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/model/cpu.js#L111-L126 | |
23,697 | googlearchive/node-big-rig | lib/third_party/tracing/model/cpu.js | function(end_timestamp, args) {
// Don't generate a slice if the last active thread is the idle task.
if (this.lastActiveThread_ == undefined || this.lastActiveThread_ == 0)
return;
if (end_timestamp < this.lastActiveTimestamp_) {
throw new Error('The end timestamp of a thread running on CPU ' +
this.cpuNumber + ' is before its start timestamp.');
}
// Merge |args| with |this.lastActiveArgs_|. If a key is in both
// dictionaries, the value from |args| is used.
for (var key in args) {
this.lastActiveArgs_[key] = args[key];
}
var duration = end_timestamp - this.lastActiveTimestamp_;
var slice = new tr.model.CpuSlice(
'', this.lastActiveName_,
ColorScheme.getColorIdForGeneralPurposeString(this.lastActiveName_),
this.lastActiveTimestamp_,
this.lastActiveArgs_,
duration);
slice.cpu = this;
this.slices.push(slice);
// Clear the last state.
this.lastActiveTimestamp_ = undefined;
this.lastActiveThread_ = undefined;
this.lastActiveName_ = undefined;
this.lastActiveArgs_ = undefined;
} | javascript | function(end_timestamp, args) {
// Don't generate a slice if the last active thread is the idle task.
if (this.lastActiveThread_ == undefined || this.lastActiveThread_ == 0)
return;
if (end_timestamp < this.lastActiveTimestamp_) {
throw new Error('The end timestamp of a thread running on CPU ' +
this.cpuNumber + ' is before its start timestamp.');
}
// Merge |args| with |this.lastActiveArgs_|. If a key is in both
// dictionaries, the value from |args| is used.
for (var key in args) {
this.lastActiveArgs_[key] = args[key];
}
var duration = end_timestamp - this.lastActiveTimestamp_;
var slice = new tr.model.CpuSlice(
'', this.lastActiveName_,
ColorScheme.getColorIdForGeneralPurposeString(this.lastActiveName_),
this.lastActiveTimestamp_,
this.lastActiveArgs_,
duration);
slice.cpu = this;
this.slices.push(slice);
// Clear the last state.
this.lastActiveTimestamp_ = undefined;
this.lastActiveThread_ = undefined;
this.lastActiveName_ = undefined;
this.lastActiveArgs_ = undefined;
} | [
"function",
"(",
"end_timestamp",
",",
"args",
")",
"{",
"// Don't generate a slice if the last active thread is the idle task.",
"if",
"(",
"this",
".",
"lastActiveThread_",
"==",
"undefined",
"||",
"this",
".",
"lastActiveThread_",
"==",
"0",
")",
"return",
";",
"if",
"(",
"end_timestamp",
"<",
"this",
".",
"lastActiveTimestamp_",
")",
"{",
"throw",
"new",
"Error",
"(",
"'The end timestamp of a thread running on CPU '",
"+",
"this",
".",
"cpuNumber",
"+",
"' is before its start timestamp.'",
")",
";",
"}",
"// Merge |args| with |this.lastActiveArgs_|. If a key is in both",
"// dictionaries, the value from |args| is used.",
"for",
"(",
"var",
"key",
"in",
"args",
")",
"{",
"this",
".",
"lastActiveArgs_",
"[",
"key",
"]",
"=",
"args",
"[",
"key",
"]",
";",
"}",
"var",
"duration",
"=",
"end_timestamp",
"-",
"this",
".",
"lastActiveTimestamp_",
";",
"var",
"slice",
"=",
"new",
"tr",
".",
"model",
".",
"CpuSlice",
"(",
"''",
",",
"this",
".",
"lastActiveName_",
",",
"ColorScheme",
".",
"getColorIdForGeneralPurposeString",
"(",
"this",
".",
"lastActiveName_",
")",
",",
"this",
".",
"lastActiveTimestamp_",
",",
"this",
".",
"lastActiveArgs_",
",",
"duration",
")",
";",
"slice",
".",
"cpu",
"=",
"this",
";",
"this",
".",
"slices",
".",
"push",
"(",
"slice",
")",
";",
"// Clear the last state.",
"this",
".",
"lastActiveTimestamp_",
"=",
"undefined",
";",
"this",
".",
"lastActiveThread_",
"=",
"undefined",
";",
"this",
".",
"lastActiveName_",
"=",
"undefined",
";",
"this",
".",
"lastActiveArgs_",
"=",
"undefined",
";",
"}"
] | Closes the thread running on the CPU. |end_timestamp| is the timestamp
at which the thread was unscheduled. |args| is merged with the arguments
specified when the thread was initially scheduled. | [
"Closes",
"the",
"thread",
"running",
"on",
"the",
"CPU",
".",
"|end_timestamp|",
"is",
"the",
"timestamp",
"at",
"which",
"the",
"thread",
"was",
"unscheduled",
".",
"|args|",
"is",
"merged",
"with",
"the",
"arguments",
"specified",
"when",
"the",
"thread",
"was",
"initially",
"scheduled",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/model/cpu.js#L163-L194 | |
23,698 | googlearchive/node-big-rig | lib/third_party/tracing/model/cpu.js | function(range) {
var stats = {};
function addStatsForFreq(freqSample, index) {
// Counters don't have an explicit end or duration;
// calculate the end by looking at the starting point
// of the next value in the series, or if that doesn't
// exist, assume this frequency is held until the end.
var freqEnd = (index < freqSample.series_.length - 1) ?
freqSample.series_.samples_[index + 1].timestamp : range.max;
var freqRange = tr.b.Range.fromExplicitRange(freqSample.timestamp,
freqEnd);
var intersection = freqRange.findIntersection(range);
if (!(freqSample.value in stats))
stats[freqSample.value] = 0;
stats[freqSample.value] += intersection.duration;
}
var freqCounter = this.getCounter('', 'Clock Frequency');
if (freqCounter !== undefined) {
var freqSeries = freqCounter.getSeries(0);
if (!freqSeries)
return;
tr.b.iterateOverIntersectingIntervals(freqSeries.samples_,
function(x) { return x.timestamp; },
function(x, index) { return index < freqSeries.length - 1 ?
freqSeries.samples_[index + 1].timestamp :
range.max; },
range.min,
range.max,
addStatsForFreq);
}
return stats;
} | javascript | function(range) {
var stats = {};
function addStatsForFreq(freqSample, index) {
// Counters don't have an explicit end or duration;
// calculate the end by looking at the starting point
// of the next value in the series, or if that doesn't
// exist, assume this frequency is held until the end.
var freqEnd = (index < freqSample.series_.length - 1) ?
freqSample.series_.samples_[index + 1].timestamp : range.max;
var freqRange = tr.b.Range.fromExplicitRange(freqSample.timestamp,
freqEnd);
var intersection = freqRange.findIntersection(range);
if (!(freqSample.value in stats))
stats[freqSample.value] = 0;
stats[freqSample.value] += intersection.duration;
}
var freqCounter = this.getCounter('', 'Clock Frequency');
if (freqCounter !== undefined) {
var freqSeries = freqCounter.getSeries(0);
if (!freqSeries)
return;
tr.b.iterateOverIntersectingIntervals(freqSeries.samples_,
function(x) { return x.timestamp; },
function(x, index) { return index < freqSeries.length - 1 ?
freqSeries.samples_[index + 1].timestamp :
range.max; },
range.min,
range.max,
addStatsForFreq);
}
return stats;
} | [
"function",
"(",
"range",
")",
"{",
"var",
"stats",
"=",
"{",
"}",
";",
"function",
"addStatsForFreq",
"(",
"freqSample",
",",
"index",
")",
"{",
"// Counters don't have an explicit end or duration;",
"// calculate the end by looking at the starting point",
"// of the next value in the series, or if that doesn't",
"// exist, assume this frequency is held until the end.",
"var",
"freqEnd",
"=",
"(",
"index",
"<",
"freqSample",
".",
"series_",
".",
"length",
"-",
"1",
")",
"?",
"freqSample",
".",
"series_",
".",
"samples_",
"[",
"index",
"+",
"1",
"]",
".",
"timestamp",
":",
"range",
".",
"max",
";",
"var",
"freqRange",
"=",
"tr",
".",
"b",
".",
"Range",
".",
"fromExplicitRange",
"(",
"freqSample",
".",
"timestamp",
",",
"freqEnd",
")",
";",
"var",
"intersection",
"=",
"freqRange",
".",
"findIntersection",
"(",
"range",
")",
";",
"if",
"(",
"!",
"(",
"freqSample",
".",
"value",
"in",
"stats",
")",
")",
"stats",
"[",
"freqSample",
".",
"value",
"]",
"=",
"0",
";",
"stats",
"[",
"freqSample",
".",
"value",
"]",
"+=",
"intersection",
".",
"duration",
";",
"}",
"var",
"freqCounter",
"=",
"this",
".",
"getCounter",
"(",
"''",
",",
"'Clock Frequency'",
")",
";",
"if",
"(",
"freqCounter",
"!==",
"undefined",
")",
"{",
"var",
"freqSeries",
"=",
"freqCounter",
".",
"getSeries",
"(",
"0",
")",
";",
"if",
"(",
"!",
"freqSeries",
")",
"return",
";",
"tr",
".",
"b",
".",
"iterateOverIntersectingIntervals",
"(",
"freqSeries",
".",
"samples_",
",",
"function",
"(",
"x",
")",
"{",
"return",
"x",
".",
"timestamp",
";",
"}",
",",
"function",
"(",
"x",
",",
"index",
")",
"{",
"return",
"index",
"<",
"freqSeries",
".",
"length",
"-",
"1",
"?",
"freqSeries",
".",
"samples_",
"[",
"index",
"+",
"1",
"]",
".",
"timestamp",
":",
"range",
".",
"max",
";",
"}",
",",
"range",
".",
"min",
",",
"range",
".",
"max",
",",
"addStatsForFreq",
")",
";",
"}",
"return",
"stats",
";",
"}"
] | Returns the frequency statistics for this CPU;
the returned object contains the frequencies as keys,
and the duration at this frequency in milliseconds as the value,
for the range that was specified. | [
"Returns",
"the",
"frequency",
"statistics",
"for",
"this",
"CPU",
";",
"the",
"returned",
"object",
"contains",
"the",
"frequencies",
"as",
"keys",
"and",
"the",
"duration",
"at",
"this",
"frequency",
"in",
"milliseconds",
"as",
"the",
"value",
"for",
"the",
"range",
"that",
"was",
"specified",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/model/cpu.js#L214-L250 | |
23,699 | googlearchive/node-big-rig | lib/third_party/tracing/model/flow_event.js | FlowEvent | function FlowEvent(category, id, title, colorId, start, args, opt_duration) {
tr.model.TimedEvent.call(this, start);
this.category = category || '';
this.title = title;
this.colorId = colorId;
this.start = start;
this.args = args;
this.id = id;
this.startSlice = undefined;
this.endSlice = undefined;
this.startStackFrame = undefined;
this.endStackFrame = undefined;
if (opt_duration !== undefined)
this.duration = opt_duration;
} | javascript | function FlowEvent(category, id, title, colorId, start, args, opt_duration) {
tr.model.TimedEvent.call(this, start);
this.category = category || '';
this.title = title;
this.colorId = colorId;
this.start = start;
this.args = args;
this.id = id;
this.startSlice = undefined;
this.endSlice = undefined;
this.startStackFrame = undefined;
this.endStackFrame = undefined;
if (opt_duration !== undefined)
this.duration = opt_duration;
} | [
"function",
"FlowEvent",
"(",
"category",
",",
"id",
",",
"title",
",",
"colorId",
",",
"start",
",",
"args",
",",
"opt_duration",
")",
"{",
"tr",
".",
"model",
".",
"TimedEvent",
".",
"call",
"(",
"this",
",",
"start",
")",
";",
"this",
".",
"category",
"=",
"category",
"||",
"''",
";",
"this",
".",
"title",
"=",
"title",
";",
"this",
".",
"colorId",
"=",
"colorId",
";",
"this",
".",
"start",
"=",
"start",
";",
"this",
".",
"args",
"=",
"args",
";",
"this",
".",
"id",
"=",
"id",
";",
"this",
".",
"startSlice",
"=",
"undefined",
";",
"this",
".",
"endSlice",
"=",
"undefined",
";",
"this",
".",
"startStackFrame",
"=",
"undefined",
";",
"this",
".",
"endStackFrame",
"=",
"undefined",
";",
"if",
"(",
"opt_duration",
"!==",
"undefined",
")",
"this",
".",
"duration",
"=",
"opt_duration",
";",
"}"
] | A Flow represents an interval of time plus parameters associated
with that interval.
@constructor | [
"A",
"Flow",
"represents",
"an",
"interval",
"of",
"time",
"plus",
"parameters",
"associated",
"with",
"that",
"interval",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/model/flow_event.js#L22-L41 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.