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,800 | googlearchive/node-big-rig | lib/third_party/tracing/base/sorted_array_utils.js | iterateOverIntersectingIntervals | function iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal,
hiVal, cb) {
if (ary.length == 0)
return;
if (loVal > hiVal) return;
var i = findLowIndexInSortedArray(ary, mapLoFn, loVal);
if (i == -1) {
return;
}
if (i > 0) {
var hi = mapLoFn(ary[i - 1]) + mapWidthFn(ary[i - 1], i - 1);
if (hi >= loVal) {
cb(ary[i - 1], i - 1);
}
}
if (i == ary.length) {
return;
}
for (var n = ary.length; i < n; i++) {
var lo = mapLoFn(ary[i]);
if (lo >= hiVal)
break;
cb(ary[i], i);
}
} | javascript | function iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal,
hiVal, cb) {
if (ary.length == 0)
return;
if (loVal > hiVal) return;
var i = findLowIndexInSortedArray(ary, mapLoFn, loVal);
if (i == -1) {
return;
}
if (i > 0) {
var hi = mapLoFn(ary[i - 1]) + mapWidthFn(ary[i - 1], i - 1);
if (hi >= loVal) {
cb(ary[i - 1], i - 1);
}
}
if (i == ary.length) {
return;
}
for (var n = ary.length; i < n; i++) {
var lo = mapLoFn(ary[i]);
if (lo >= hiVal)
break;
cb(ary[i], i);
}
} | [
"function",
"iterateOverIntersectingIntervals",
"(",
"ary",
",",
"mapLoFn",
",",
"mapWidthFn",
",",
"loVal",
",",
"hiVal",
",",
"cb",
")",
"{",
"if",
"(",
"ary",
".",
"length",
"==",
"0",
")",
"return",
";",
"if",
"(",
"loVal",
">",
"hiVal",
")",
"return",
";",
"var",
"i",
"=",
"findLowIndexInSortedArray",
"(",
"ary",
",",
"mapLoFn",
",",
"loVal",
")",
";",
"if",
"(",
"i",
"==",
"-",
"1",
")",
"{",
"return",
";",
"}",
"if",
"(",
"i",
">",
"0",
")",
"{",
"var",
"hi",
"=",
"mapLoFn",
"(",
"ary",
"[",
"i",
"-",
"1",
"]",
")",
"+",
"mapWidthFn",
"(",
"ary",
"[",
"i",
"-",
"1",
"]",
",",
"i",
"-",
"1",
")",
";",
"if",
"(",
"hi",
">=",
"loVal",
")",
"{",
"cb",
"(",
"ary",
"[",
"i",
"-",
"1",
"]",
",",
"i",
"-",
"1",
")",
";",
"}",
"}",
"if",
"(",
"i",
"==",
"ary",
".",
"length",
")",
"{",
"return",
";",
"}",
"for",
"(",
"var",
"n",
"=",
"ary",
".",
"length",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"var",
"lo",
"=",
"mapLoFn",
"(",
"ary",
"[",
"i",
"]",
")",
";",
"if",
"(",
"lo",
">=",
"hiVal",
")",
"break",
";",
"cb",
"(",
"ary",
"[",
"i",
"]",
",",
"i",
")",
";",
"}",
"}"
] | Calls cb for all intervals in the implicit array of intervals
defnied by ary, mapLoFn and mapHiFn that intersect the range
[loVal,hiVal)
This function uses the same scheme as findLowIndexInSortedArray
to define the intervals. The same restrictions on sortedness and
non-overlappingness apply.
@param {Array} ary An array of objects that can be converted into sorted
nonoverlapping ranges [x,y) using the mapLoFn and mapWidth.
@param {function():*} mapLoFn Callback that produces the low value for the
interval represented by an element in the array.
@param {function():*} mapWidthFn Callback that produces the width for the
interval represented by an element in the array.
@param {number} loVal The low value for the search, inclusive.
@param {number} hiVal The high value for the search, non inclusive.
@param {function():*} cb The function to run for intersecting intervals. | [
"Calls",
"cb",
"for",
"all",
"intervals",
"in",
"the",
"implicit",
"array",
"of",
"intervals",
"defnied",
"by",
"ary",
"mapLoFn",
"and",
"mapHiFn",
"that",
"intersect",
"the",
"range",
"[",
"loVal",
"hiVal",
")"
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/sorted_array_utils.js#L199-L226 |
23,801 | googlearchive/node-big-rig | lib/third_party/tracing/base/sorted_array_utils.js | getIntersectingIntervals | function getIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal, hiVal) {
var tmp = [];
iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal, hiVal,
function(d) {
tmp.push(d);
});
return tmp;
} | javascript | function getIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal, hiVal) {
var tmp = [];
iterateOverIntersectingIntervals(ary, mapLoFn, mapWidthFn, loVal, hiVal,
function(d) {
tmp.push(d);
});
return tmp;
} | [
"function",
"getIntersectingIntervals",
"(",
"ary",
",",
"mapLoFn",
",",
"mapWidthFn",
",",
"loVal",
",",
"hiVal",
")",
"{",
"var",
"tmp",
"=",
"[",
"]",
";",
"iterateOverIntersectingIntervals",
"(",
"ary",
",",
"mapLoFn",
",",
"mapWidthFn",
",",
"loVal",
",",
"hiVal",
",",
"function",
"(",
"d",
")",
"{",
"tmp",
".",
"push",
"(",
"d",
")",
";",
"}",
")",
";",
"return",
"tmp",
";",
"}"
] | Non iterative version of iterateOverIntersectingIntervals.
@return {Array} Array of elements in ary that intersect loVal, hiVal. | [
"Non",
"iterative",
"version",
"of",
"iterateOverIntersectingIntervals",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/sorted_array_utils.js#L233-L240 |
23,802 | googlearchive/node-big-rig | lib/third_party/tracing/base/sorted_array_utils.js | findClosestElementInSortedArray | function findClosestElementInSortedArray(ary, mapFn, val, maxDiff) {
if (ary.length === 0)
return null;
var aftIdx = findLowIndexInSortedArray(ary, mapFn, val);
var befIdx = aftIdx > 0 ? aftIdx - 1 : 0;
if (aftIdx === ary.length)
aftIdx -= 1;
var befDiff = Math.abs(val - mapFn(ary[befIdx]));
var aftDiff = Math.abs(val - mapFn(ary[aftIdx]));
if (befDiff > maxDiff && aftDiff > maxDiff)
return null;
var idx = befDiff < aftDiff ? befIdx : aftIdx;
return ary[idx];
} | javascript | function findClosestElementInSortedArray(ary, mapFn, val, maxDiff) {
if (ary.length === 0)
return null;
var aftIdx = findLowIndexInSortedArray(ary, mapFn, val);
var befIdx = aftIdx > 0 ? aftIdx - 1 : 0;
if (aftIdx === ary.length)
aftIdx -= 1;
var befDiff = Math.abs(val - mapFn(ary[befIdx]));
var aftDiff = Math.abs(val - mapFn(ary[aftIdx]));
if (befDiff > maxDiff && aftDiff > maxDiff)
return null;
var idx = befDiff < aftDiff ? befIdx : aftIdx;
return ary[idx];
} | [
"function",
"findClosestElementInSortedArray",
"(",
"ary",
",",
"mapFn",
",",
"val",
",",
"maxDiff",
")",
"{",
"if",
"(",
"ary",
".",
"length",
"===",
"0",
")",
"return",
"null",
";",
"var",
"aftIdx",
"=",
"findLowIndexInSortedArray",
"(",
"ary",
",",
"mapFn",
",",
"val",
")",
";",
"var",
"befIdx",
"=",
"aftIdx",
">",
"0",
"?",
"aftIdx",
"-",
"1",
":",
"0",
";",
"if",
"(",
"aftIdx",
"===",
"ary",
".",
"length",
")",
"aftIdx",
"-=",
"1",
";",
"var",
"befDiff",
"=",
"Math",
".",
"abs",
"(",
"val",
"-",
"mapFn",
"(",
"ary",
"[",
"befIdx",
"]",
")",
")",
";",
"var",
"aftDiff",
"=",
"Math",
".",
"abs",
"(",
"val",
"-",
"mapFn",
"(",
"ary",
"[",
"aftIdx",
"]",
")",
")",
";",
"if",
"(",
"befDiff",
">",
"maxDiff",
"&&",
"aftDiff",
">",
"maxDiff",
")",
"return",
"null",
";",
"var",
"idx",
"=",
"befDiff",
"<",
"aftDiff",
"?",
"befIdx",
":",
"aftIdx",
";",
"return",
"ary",
"[",
"idx",
"]",
";",
"}"
] | Finds the element in the array whose value is closest to |val|.
The same restrictions on sortedness as for findLowIndexInSortedArray apply.
@param {Array} ary An array of arbitrary objects.
@param {function():*} mapFn Callback that produces a key value
from an element in ary.
@param {number} val Value for which to search.
@param {number} maxDiff Maximum allowed difference in value between |val|
and an element's value.
@return {object} Object in the array whose value is closest to |val|, or
null if no object is within range. | [
"Finds",
"the",
"element",
"in",
"the",
"array",
"whose",
"value",
"is",
"closest",
"to",
"|val|",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/sorted_array_utils.js#L256-L274 |
23,803 | googlearchive/node-big-rig | lib/third_party/tracing/base/sorted_array_utils.js | findClosestIntervalInSortedIntervals | function findClosestIntervalInSortedIntervals(ary, mapLoFn, mapHiFn, val,
maxDiff) {
if (ary.length === 0)
return null;
var idx = findLowIndexInSortedArray(ary, mapLoFn, val);
if (idx > 0)
idx -= 1;
var hiInt = ary[idx];
var loInt = hiInt;
if (val > mapHiFn(hiInt) && idx + 1 < ary.length)
loInt = ary[idx + 1];
var loDiff = Math.abs(val - mapLoFn(loInt));
var hiDiff = Math.abs(val - mapHiFn(hiInt));
if (loDiff > maxDiff && hiDiff > maxDiff)
return null;
if (loDiff < hiDiff)
return loInt;
else
return hiInt;
} | javascript | function findClosestIntervalInSortedIntervals(ary, mapLoFn, mapHiFn, val,
maxDiff) {
if (ary.length === 0)
return null;
var idx = findLowIndexInSortedArray(ary, mapLoFn, val);
if (idx > 0)
idx -= 1;
var hiInt = ary[idx];
var loInt = hiInt;
if (val > mapHiFn(hiInt) && idx + 1 < ary.length)
loInt = ary[idx + 1];
var loDiff = Math.abs(val - mapLoFn(loInt));
var hiDiff = Math.abs(val - mapHiFn(hiInt));
if (loDiff > maxDiff && hiDiff > maxDiff)
return null;
if (loDiff < hiDiff)
return loInt;
else
return hiInt;
} | [
"function",
"findClosestIntervalInSortedIntervals",
"(",
"ary",
",",
"mapLoFn",
",",
"mapHiFn",
",",
"val",
",",
"maxDiff",
")",
"{",
"if",
"(",
"ary",
".",
"length",
"===",
"0",
")",
"return",
"null",
";",
"var",
"idx",
"=",
"findLowIndexInSortedArray",
"(",
"ary",
",",
"mapLoFn",
",",
"val",
")",
";",
"if",
"(",
"idx",
">",
"0",
")",
"idx",
"-=",
"1",
";",
"var",
"hiInt",
"=",
"ary",
"[",
"idx",
"]",
";",
"var",
"loInt",
"=",
"hiInt",
";",
"if",
"(",
"val",
">",
"mapHiFn",
"(",
"hiInt",
")",
"&&",
"idx",
"+",
"1",
"<",
"ary",
".",
"length",
")",
"loInt",
"=",
"ary",
"[",
"idx",
"+",
"1",
"]",
";",
"var",
"loDiff",
"=",
"Math",
".",
"abs",
"(",
"val",
"-",
"mapLoFn",
"(",
"loInt",
")",
")",
";",
"var",
"hiDiff",
"=",
"Math",
".",
"abs",
"(",
"val",
"-",
"mapHiFn",
"(",
"hiInt",
")",
")",
";",
"if",
"(",
"loDiff",
">",
"maxDiff",
"&&",
"hiDiff",
">",
"maxDiff",
")",
"return",
"null",
";",
"if",
"(",
"loDiff",
"<",
"hiDiff",
")",
"return",
"loInt",
";",
"else",
"return",
"hiInt",
";",
"}"
] | Finds the closest interval in the implicit array of intervals
defined by ary, mapLoFn and mapHiFn.
This function uses the same scheme as findLowIndexInSortedArray
to define the intervals. The same restrictions on sortedness and
non-overlappingness apply.
@param {Array} ary An array of objects that can be converted into sorted
nonoverlapping ranges [x,y) using the mapLoFn and mapHiFn.
@param {function():*} mapLoFn Callback that produces the low value for the
interval represented by an element in the array.
@param {function():*} mapHiFn Callback that produces the high for the
interval represented by an element in the array.
@param {number} val The value for the search.
@param {number} maxDiff Maximum allowed difference in value between |val|
and an interval's low or high value.
@return {interval} Interval in the array whose high or low value is closest
to |val|, or null if no interval is within range. | [
"Finds",
"the",
"closest",
"interval",
"in",
"the",
"implicit",
"array",
"of",
"intervals",
"defined",
"by",
"ary",
"mapLoFn",
"and",
"mapHiFn",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/sorted_array_utils.js#L296-L321 |
23,804 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(rirs) {
var vacuumIRs = [];
rirs.forEach(function(ir) {
if (ir instanceof tr.e.rail.LoadInteractionRecord ||
ir instanceof tr.e.rail.IdleInteractionRecord)
vacuumIRs.push(ir);
});
if (vacuumIRs.length === 0)
return;
var allAssociatedEvents = tr.model.getAssociatedEvents(rirs);
var unassociatedEvents = tr.model.getUnassociatedEvents(
this.model, allAssociatedEvents);
unassociatedEvents.forEach(function(event) {
if (!(event instanceof tr.model.ThreadSlice))
return;
if (!event.isTopLevel)
return;
for (var iri = 0; iri < vacuumIRs.length; ++iri) {
var ir = vacuumIRs[iri];
if ((event.start >= ir.start) &&
(event.start < ir.end)) {
ir.associatedEvents.addEventSet(event.entireHierarchy);
return;
}
}
});
} | javascript | function(rirs) {
var vacuumIRs = [];
rirs.forEach(function(ir) {
if (ir instanceof tr.e.rail.LoadInteractionRecord ||
ir instanceof tr.e.rail.IdleInteractionRecord)
vacuumIRs.push(ir);
});
if (vacuumIRs.length === 0)
return;
var allAssociatedEvents = tr.model.getAssociatedEvents(rirs);
var unassociatedEvents = tr.model.getUnassociatedEvents(
this.model, allAssociatedEvents);
unassociatedEvents.forEach(function(event) {
if (!(event instanceof tr.model.ThreadSlice))
return;
if (!event.isTopLevel)
return;
for (var iri = 0; iri < vacuumIRs.length; ++iri) {
var ir = vacuumIRs[iri];
if ((event.start >= ir.start) &&
(event.start < ir.end)) {
ir.associatedEvents.addEventSet(event.entireHierarchy);
return;
}
}
});
} | [
"function",
"(",
"rirs",
")",
"{",
"var",
"vacuumIRs",
"=",
"[",
"]",
";",
"rirs",
".",
"forEach",
"(",
"function",
"(",
"ir",
")",
"{",
"if",
"(",
"ir",
"instanceof",
"tr",
".",
"e",
".",
"rail",
".",
"LoadInteractionRecord",
"||",
"ir",
"instanceof",
"tr",
".",
"e",
".",
"rail",
".",
"IdleInteractionRecord",
")",
"vacuumIRs",
".",
"push",
"(",
"ir",
")",
";",
"}",
")",
";",
"if",
"(",
"vacuumIRs",
".",
"length",
"===",
"0",
")",
"return",
";",
"var",
"allAssociatedEvents",
"=",
"tr",
".",
"model",
".",
"getAssociatedEvents",
"(",
"rirs",
")",
";",
"var",
"unassociatedEvents",
"=",
"tr",
".",
"model",
".",
"getUnassociatedEvents",
"(",
"this",
".",
"model",
",",
"allAssociatedEvents",
")",
";",
"unassociatedEvents",
".",
"forEach",
"(",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"(",
"event",
"instanceof",
"tr",
".",
"model",
".",
"ThreadSlice",
")",
")",
"return",
";",
"if",
"(",
"!",
"event",
".",
"isTopLevel",
")",
"return",
";",
"for",
"(",
"var",
"iri",
"=",
"0",
";",
"iri",
"<",
"vacuumIRs",
".",
"length",
";",
"++",
"iri",
")",
"{",
"var",
"ir",
"=",
"vacuumIRs",
"[",
"iri",
"]",
";",
"if",
"(",
"(",
"event",
".",
"start",
">=",
"ir",
".",
"start",
")",
"&&",
"(",
"event",
".",
"start",
"<",
"ir",
".",
"end",
")",
")",
"{",
"ir",
".",
"associatedEvents",
".",
"addEventSet",
"(",
"event",
".",
"entireHierarchy",
")",
";",
"return",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Find all unassociated top-level ThreadSlices. If they start during an Idle or Load IR, then add their entire hierarchy to that IR. | [
"Find",
"all",
"unassociated",
"top",
"-",
"level",
"ThreadSlices",
".",
"If",
"they",
"start",
"during",
"an",
"Idle",
"or",
"Load",
"IR",
"then",
"add",
"their",
"entire",
"hierarchy",
"to",
"that",
"IR",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L184-L215 | |
23,805 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(otherIRs) {
if (this.model.bounds.isEmpty)
return;
var emptyRanges = tr.b.findEmptyRangesBetweenRanges(
tr.b.convertEventsToRanges(otherIRs),
this.model.bounds);
var irs = [];
var model = this.model;
emptyRanges.forEach(function(range) {
// Ignore insignificantly tiny idle ranges.
if (range.max < (range.min + INSIGNIFICANT_MS))
return;
irs.push(new tr.e.rail.IdleInteractionRecord(
model, range.min, range.max - range.min));
});
return irs;
} | javascript | function(otherIRs) {
if (this.model.bounds.isEmpty)
return;
var emptyRanges = tr.b.findEmptyRangesBetweenRanges(
tr.b.convertEventsToRanges(otherIRs),
this.model.bounds);
var irs = [];
var model = this.model;
emptyRanges.forEach(function(range) {
// Ignore insignificantly tiny idle ranges.
if (range.max < (range.min + INSIGNIFICANT_MS))
return;
irs.push(new tr.e.rail.IdleInteractionRecord(
model, range.min, range.max - range.min));
});
return irs;
} | [
"function",
"(",
"otherIRs",
")",
"{",
"if",
"(",
"this",
".",
"model",
".",
"bounds",
".",
"isEmpty",
")",
"return",
";",
"var",
"emptyRanges",
"=",
"tr",
".",
"b",
".",
"findEmptyRangesBetweenRanges",
"(",
"tr",
".",
"b",
".",
"convertEventsToRanges",
"(",
"otherIRs",
")",
",",
"this",
".",
"model",
".",
"bounds",
")",
";",
"var",
"irs",
"=",
"[",
"]",
";",
"var",
"model",
"=",
"this",
".",
"model",
";",
"emptyRanges",
".",
"forEach",
"(",
"function",
"(",
"range",
")",
"{",
"// Ignore insignificantly tiny idle ranges.",
"if",
"(",
"range",
".",
"max",
"<",
"(",
"range",
".",
"min",
"+",
"INSIGNIFICANT_MS",
")",
")",
"return",
";",
"irs",
".",
"push",
"(",
"new",
"tr",
".",
"e",
".",
"rail",
".",
"IdleInteractionRecord",
"(",
"model",
",",
"range",
".",
"min",
",",
"range",
".",
"max",
"-",
"range",
".",
"min",
")",
")",
";",
"}",
")",
";",
"return",
"irs",
";",
"}"
] | Fill in the empty space between IRs with IdleIRs. | [
"Fill",
"in",
"the",
"empty",
"space",
"between",
"IRs",
"with",
"IdleIRs",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L218-L234 | |
23,806 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function() {
function isStartupSlice(slice) {
return slice.title === 'BrowserMainLoop::CreateThreads';
}
var events = this.modelHelper.browserHelper.getAllAsyncSlicesMatching(
isStartupSlice);
var deduper = new tr.model.EventSet();
events.forEach(function(event) {
var sliceGroup = event.parentContainer.sliceGroup;
var slice = sliceGroup && sliceGroup.findFirstSlice();
if (slice)
deduper.push(slice);
});
return deduper.toArray();
} | javascript | function() {
function isStartupSlice(slice) {
return slice.title === 'BrowserMainLoop::CreateThreads';
}
var events = this.modelHelper.browserHelper.getAllAsyncSlicesMatching(
isStartupSlice);
var deduper = new tr.model.EventSet();
events.forEach(function(event) {
var sliceGroup = event.parentContainer.sliceGroup;
var slice = sliceGroup && sliceGroup.findFirstSlice();
if (slice)
deduper.push(slice);
});
return deduper.toArray();
} | [
"function",
"(",
")",
"{",
"function",
"isStartupSlice",
"(",
"slice",
")",
"{",
"return",
"slice",
".",
"title",
"===",
"'BrowserMainLoop::CreateThreads'",
";",
"}",
"var",
"events",
"=",
"this",
".",
"modelHelper",
".",
"browserHelper",
".",
"getAllAsyncSlicesMatching",
"(",
"isStartupSlice",
")",
";",
"var",
"deduper",
"=",
"new",
"tr",
".",
"model",
".",
"EventSet",
"(",
")",
";",
"events",
".",
"forEach",
"(",
"function",
"(",
"event",
")",
"{",
"var",
"sliceGroup",
"=",
"event",
".",
"parentContainer",
".",
"sliceGroup",
";",
"var",
"slice",
"=",
"sliceGroup",
"&&",
"sliceGroup",
".",
"findFirstSlice",
"(",
")",
";",
"if",
"(",
"slice",
")",
"deduper",
".",
"push",
"(",
"slice",
")",
";",
"}",
")",
";",
"return",
"deduper",
".",
"toArray",
"(",
")",
";",
"}"
] | If a thread contains a typical initialization slice, then the first event on that thread is a startup event. | [
"If",
"a",
"thread",
"contains",
"a",
"typical",
"initialization",
"slice",
"then",
"the",
"first",
"event",
"on",
"that",
"thread",
"is",
"a",
"startup",
"event",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L267-L281 | |
23,807 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(lir) {
var createChildEvent = undefined;
lir.renderMainThread.iterateAllEvents(function(event) {
if (event.title !== CREATE_CHILD_TITLE)
return;
if (event.args.child !== lir.routingId)
return;
createChildEvent = event;
});
if (!createChildEvent)
return undefined;
return createChildEvent.args.id;
} | javascript | function(lir) {
var createChildEvent = undefined;
lir.renderMainThread.iterateAllEvents(function(event) {
if (event.title !== CREATE_CHILD_TITLE)
return;
if (event.args.child !== lir.routingId)
return;
createChildEvent = event;
});
if (!createChildEvent)
return undefined;
return createChildEvent.args.id;
} | [
"function",
"(",
"lir",
")",
"{",
"var",
"createChildEvent",
"=",
"undefined",
";",
"lir",
".",
"renderMainThread",
".",
"iterateAllEvents",
"(",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"event",
".",
"title",
"!==",
"CREATE_CHILD_TITLE",
")",
"return",
";",
"if",
"(",
"event",
".",
"args",
".",
"child",
"!==",
"lir",
".",
"routingId",
")",
"return",
";",
"createChildEvent",
"=",
"event",
";",
"}",
")",
";",
"if",
"(",
"!",
"createChildEvent",
")",
"return",
"undefined",
";",
"return",
"createChildEvent",
".",
"args",
".",
"id",
";",
"}"
] | Find the routingId of the createChildFrame event that created the Load IR's RenderFrame. | [
"Find",
"the",
"routingId",
"of",
"the",
"createChildFrame",
"event",
"that",
"created",
"the",
"Load",
"IR",
"s",
"RenderFrame",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L337-L353 | |
23,808 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function() {
var startupEvents = this.getStartupEvents();
var commitLoadEvents =
this.modelHelper.browserHelper.getCommitProvisionalLoadEventsInRange(
this.model.bounds);
var frameEvents = this.getAllFrameEvents();
var startLoadEvents = this.getStartLoadEvents();
var failLoadEvents = this.getFailLoadEvents();
var lirs = [];
// Attach frame events to every startup events.
var startupLIRs = this.findLoadInteractionRecords_(startupEvents,
frameEvents);
this.setIRNames_(LOAD_STARTUP_IR_NAME, startupLIRs);
lirs.push.apply(lirs, startupLIRs);
// Attach frame events to every commit load events.
var successfulLIRs = this.findLoadInteractionRecords_(commitLoadEvents,
frameEvents);
this.setIRNames_(LOAD_SUCCEEDED_IR_NAME, successfulLIRs);
successfulLIRs.forEach(function(lir) {
// If a successful Load IR has a loadFinishedEvent, then it is a main
// frame.
// Drop sub-frame Loads for now.
if (lir.loadFinishedEvent)
lirs.push(lir);
});
// Attach fail load events to every start load events.
var failedLIRs = this.findLoadInteractionRecords_(startLoadEvents,
failLoadEvents);
this.setIRNames_(LOAD_FAILED_IR_NAME, failedLIRs);
failedLIRs.forEach(function(lir) {
// If a failed Load IR has a parentRoutingId, then it is a sub-frame.
// Drop sub-frame Loads for now.
if (lir.parentRoutingId === undefined)
lirs.push(lir);
});
return lirs;
} | javascript | function() {
var startupEvents = this.getStartupEvents();
var commitLoadEvents =
this.modelHelper.browserHelper.getCommitProvisionalLoadEventsInRange(
this.model.bounds);
var frameEvents = this.getAllFrameEvents();
var startLoadEvents = this.getStartLoadEvents();
var failLoadEvents = this.getFailLoadEvents();
var lirs = [];
// Attach frame events to every startup events.
var startupLIRs = this.findLoadInteractionRecords_(startupEvents,
frameEvents);
this.setIRNames_(LOAD_STARTUP_IR_NAME, startupLIRs);
lirs.push.apply(lirs, startupLIRs);
// Attach frame events to every commit load events.
var successfulLIRs = this.findLoadInteractionRecords_(commitLoadEvents,
frameEvents);
this.setIRNames_(LOAD_SUCCEEDED_IR_NAME, successfulLIRs);
successfulLIRs.forEach(function(lir) {
// If a successful Load IR has a loadFinishedEvent, then it is a main
// frame.
// Drop sub-frame Loads for now.
if (lir.loadFinishedEvent)
lirs.push(lir);
});
// Attach fail load events to every start load events.
var failedLIRs = this.findLoadInteractionRecords_(startLoadEvents,
failLoadEvents);
this.setIRNames_(LOAD_FAILED_IR_NAME, failedLIRs);
failedLIRs.forEach(function(lir) {
// If a failed Load IR has a parentRoutingId, then it is a sub-frame.
// Drop sub-frame Loads for now.
if (lir.parentRoutingId === undefined)
lirs.push(lir);
});
return lirs;
} | [
"function",
"(",
")",
"{",
"var",
"startupEvents",
"=",
"this",
".",
"getStartupEvents",
"(",
")",
";",
"var",
"commitLoadEvents",
"=",
"this",
".",
"modelHelper",
".",
"browserHelper",
".",
"getCommitProvisionalLoadEventsInRange",
"(",
"this",
".",
"model",
".",
"bounds",
")",
";",
"var",
"frameEvents",
"=",
"this",
".",
"getAllFrameEvents",
"(",
")",
";",
"var",
"startLoadEvents",
"=",
"this",
".",
"getStartLoadEvents",
"(",
")",
";",
"var",
"failLoadEvents",
"=",
"this",
".",
"getFailLoadEvents",
"(",
")",
";",
"var",
"lirs",
"=",
"[",
"]",
";",
"// Attach frame events to every startup events.",
"var",
"startupLIRs",
"=",
"this",
".",
"findLoadInteractionRecords_",
"(",
"startupEvents",
",",
"frameEvents",
")",
";",
"this",
".",
"setIRNames_",
"(",
"LOAD_STARTUP_IR_NAME",
",",
"startupLIRs",
")",
";",
"lirs",
".",
"push",
".",
"apply",
"(",
"lirs",
",",
"startupLIRs",
")",
";",
"// Attach frame events to every commit load events.",
"var",
"successfulLIRs",
"=",
"this",
".",
"findLoadInteractionRecords_",
"(",
"commitLoadEvents",
",",
"frameEvents",
")",
";",
"this",
".",
"setIRNames_",
"(",
"LOAD_SUCCEEDED_IR_NAME",
",",
"successfulLIRs",
")",
";",
"successfulLIRs",
".",
"forEach",
"(",
"function",
"(",
"lir",
")",
"{",
"// If a successful Load IR has a loadFinishedEvent, then it is a main",
"// frame.",
"// Drop sub-frame Loads for now.",
"if",
"(",
"lir",
".",
"loadFinishedEvent",
")",
"lirs",
".",
"push",
"(",
"lir",
")",
";",
"}",
")",
";",
"// Attach fail load events to every start load events.",
"var",
"failedLIRs",
"=",
"this",
".",
"findLoadInteractionRecords_",
"(",
"startLoadEvents",
",",
"failLoadEvents",
")",
";",
"this",
".",
"setIRNames_",
"(",
"LOAD_FAILED_IR_NAME",
",",
"failedLIRs",
")",
";",
"failedLIRs",
".",
"forEach",
"(",
"function",
"(",
"lir",
")",
"{",
"// If a failed Load IR has a parentRoutingId, then it is a sub-frame.",
"// Drop sub-frame Loads for now.",
"if",
"(",
"lir",
".",
"parentRoutingId",
"===",
"undefined",
")",
"lirs",
".",
"push",
"(",
"lir",
")",
";",
"}",
")",
";",
"return",
"lirs",
";",
"}"
] | Match up RenderFrameImpl events with frame render events. | [
"Match",
"up",
"RenderFrameImpl",
"events",
"with",
"frame",
"render",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L402-L442 | |
23,809 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function() {
var sortedInputEvents = this.getSortedInputEvents();
var protoIRs = this.findProtoIRs(sortedInputEvents);
protoIRs = this.postProcessProtoIRs(protoIRs);
this.checkAllInputEventsHandled(sortedInputEvents, protoIRs);
var irs = [];
var model = this.model;
protoIRs.forEach(function(protoIR) {
var ir = protoIR.createInteractionRecord(model);
if (ir)
irs.push(ir);
});
return irs;
} | javascript | function() {
var sortedInputEvents = this.getSortedInputEvents();
var protoIRs = this.findProtoIRs(sortedInputEvents);
protoIRs = this.postProcessProtoIRs(protoIRs);
this.checkAllInputEventsHandled(sortedInputEvents, protoIRs);
var irs = [];
var model = this.model;
protoIRs.forEach(function(protoIR) {
var ir = protoIR.createInteractionRecord(model);
if (ir)
irs.push(ir);
});
return irs;
} | [
"function",
"(",
")",
"{",
"var",
"sortedInputEvents",
"=",
"this",
".",
"getSortedInputEvents",
"(",
")",
";",
"var",
"protoIRs",
"=",
"this",
".",
"findProtoIRs",
"(",
"sortedInputEvents",
")",
";",
"protoIRs",
"=",
"this",
".",
"postProcessProtoIRs",
"(",
"protoIRs",
")",
";",
"this",
".",
"checkAllInputEventsHandled",
"(",
"sortedInputEvents",
",",
"protoIRs",
")",
";",
"var",
"irs",
"=",
"[",
"]",
";",
"var",
"model",
"=",
"this",
".",
"model",
";",
"protoIRs",
".",
"forEach",
"(",
"function",
"(",
"protoIR",
")",
"{",
"var",
"ir",
"=",
"protoIR",
".",
"createInteractionRecord",
"(",
"model",
")",
";",
"if",
"(",
"ir",
")",
"irs",
".",
"push",
"(",
"ir",
")",
";",
"}",
")",
";",
"return",
"irs",
";",
"}"
] | Find ProtoIRs, post-process them, convert them to real IRs. | [
"Find",
"ProtoIRs",
"post",
"-",
"process",
"them",
"convert",
"them",
"to",
"real",
"IRs",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L445-L459 | |
23,810 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents) {
var protoIRs = [];
forEventTypesIn(sortedInputEvents, KEYBOARD_TYPE_NAMES, function(event) {
var pir = new ProtoIR(ProtoIR.RESPONSE_TYPE, KEYBOARD_IR_NAME);
pir.pushEvent(event);
protoIRs.push(pir);
});
return protoIRs;
} | javascript | function(sortedInputEvents) {
var protoIRs = [];
forEventTypesIn(sortedInputEvents, KEYBOARD_TYPE_NAMES, function(event) {
var pir = new ProtoIR(ProtoIR.RESPONSE_TYPE, KEYBOARD_IR_NAME);
pir.pushEvent(event);
protoIRs.push(pir);
});
return protoIRs;
} | [
"function",
"(",
"sortedInputEvents",
")",
"{",
"var",
"protoIRs",
"=",
"[",
"]",
";",
"forEventTypesIn",
"(",
"sortedInputEvents",
",",
"KEYBOARD_TYPE_NAMES",
",",
"function",
"(",
"event",
")",
"{",
"var",
"pir",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"RESPONSE_TYPE",
",",
"KEYBOARD_IR_NAME",
")",
";",
"pir",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"pir",
")",
";",
"}",
")",
";",
"return",
"protoIRs",
";",
"}"
] | Every keyboard event is a Response. | [
"Every",
"keyboard",
"event",
"is",
"a",
"Response",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L510-L518 | |
23,811 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents) {
var protoIRs = [];
forEventTypesIn(
sortedInputEvents, MOUSE_RESPONSE_TYPE_NAMES, function(event) {
var pir = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSE_IR_NAME);
pir.pushEvent(event);
protoIRs.push(pir);
});
return protoIRs;
} | javascript | function(sortedInputEvents) {
var protoIRs = [];
forEventTypesIn(
sortedInputEvents, MOUSE_RESPONSE_TYPE_NAMES, function(event) {
var pir = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSE_IR_NAME);
pir.pushEvent(event);
protoIRs.push(pir);
});
return protoIRs;
} | [
"function",
"(",
"sortedInputEvents",
")",
"{",
"var",
"protoIRs",
"=",
"[",
"]",
";",
"forEventTypesIn",
"(",
"sortedInputEvents",
",",
"MOUSE_RESPONSE_TYPE_NAMES",
",",
"function",
"(",
"event",
")",
"{",
"var",
"pir",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"RESPONSE_TYPE",
",",
"MOUSE_IR_NAME",
")",
";",
"pir",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"pir",
")",
";",
"}",
")",
";",
"return",
"protoIRs",
";",
"}"
] | Some mouse events can be translated directly into Responses. | [
"Some",
"mouse",
"events",
"can",
"be",
"translated",
"directly",
"into",
"Responses",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L521-L530 | |
23,812 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var prevEvent_ = undefined;
forEventTypesIn(
sortedInputEvents, MOUSE_WHEEL_TYPE_NAMES, function(event) {
// Switch prevEvent in one place so that we can early-return later.
var prevEvent = prevEvent_;
prevEvent_ = event;
if (currentPIR &&
(prevEvent.start + MOUSE_WHEEL_THRESHOLD_MS) >= event.start) {
if (currentPIR.irType === ProtoIR.ANIMATION_TYPE) {
currentPIR.pushEvent(event);
} else {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE,
MOUSEWHEEL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
}
return;
}
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSEWHEEL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
});
return protoIRs;
} | javascript | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var prevEvent_ = undefined;
forEventTypesIn(
sortedInputEvents, MOUSE_WHEEL_TYPE_NAMES, function(event) {
// Switch prevEvent in one place so that we can early-return later.
var prevEvent = prevEvent_;
prevEvent_ = event;
if (currentPIR &&
(prevEvent.start + MOUSE_WHEEL_THRESHOLD_MS) >= event.start) {
if (currentPIR.irType === ProtoIR.ANIMATION_TYPE) {
currentPIR.pushEvent(event);
} else {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE,
MOUSEWHEEL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
}
return;
}
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, MOUSEWHEEL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
});
return protoIRs;
} | [
"function",
"(",
"sortedInputEvents",
")",
"{",
"var",
"protoIRs",
"=",
"[",
"]",
";",
"var",
"currentPIR",
"=",
"undefined",
";",
"var",
"prevEvent_",
"=",
"undefined",
";",
"forEventTypesIn",
"(",
"sortedInputEvents",
",",
"MOUSE_WHEEL_TYPE_NAMES",
",",
"function",
"(",
"event",
")",
"{",
"// Switch prevEvent in one place so that we can early-return later.",
"var",
"prevEvent",
"=",
"prevEvent_",
";",
"prevEvent_",
"=",
"event",
";",
"if",
"(",
"currentPIR",
"&&",
"(",
"prevEvent",
".",
"start",
"+",
"MOUSE_WHEEL_THRESHOLD_MS",
")",
">=",
"event",
".",
"start",
")",
"{",
"if",
"(",
"currentPIR",
".",
"irType",
"===",
"ProtoIR",
".",
"ANIMATION_TYPE",
")",
"{",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"}",
"else",
"{",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"ANIMATION_TYPE",
",",
"MOUSEWHEEL_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"}",
"return",
";",
"}",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"RESPONSE_TYPE",
",",
"MOUSEWHEEL_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"}",
")",
";",
"return",
"protoIRs",
";",
"}"
] | MouseWheel events are caused either by a physical wheel on a physical mouse, or by a touch-drag gesture on a track-pad. The physical wheel causes MouseWheel events that are much more spaced out, and have no chance of hitting 60fps, so they are each turned into separate Response IRs. The track-pad causes MouseWheel events that are much closer together, and are expected to be 60fps, so the first event in a sequence is turned into a Response, and the rest are merged into an Animation. NB this threshold uses the two events' start times, unlike ProtoIR.isNear, which compares the end time of the previous event with the start time of the next. | [
"MouseWheel",
"events",
"are",
"caused",
"either",
"by",
"a",
"physical",
"wheel",
"on",
"a",
"physical",
"mouse",
"or",
"by",
"a",
"touch",
"-",
"drag",
"gesture",
"on",
"a",
"track",
"-",
"pad",
".",
"The",
"physical",
"wheel",
"causes",
"MouseWheel",
"events",
"that",
"are",
"much",
"more",
"spaced",
"out",
"and",
"have",
"no",
"chance",
"of",
"hitting",
"60fps",
"so",
"they",
"are",
"each",
"turned",
"into",
"separate",
"Response",
"IRs",
".",
"The",
"track",
"-",
"pad",
"causes",
"MouseWheel",
"events",
"that",
"are",
"much",
"closer",
"together",
"and",
"are",
"expected",
"to",
"be",
"60fps",
"so",
"the",
"first",
"event",
"in",
"a",
"sequence",
"is",
"turned",
"into",
"a",
"Response",
"and",
"the",
"rest",
"are",
"merged",
"into",
"an",
"Animation",
".",
"NB",
"this",
"threshold",
"uses",
"the",
"two",
"events",
"start",
"times",
"unlike",
"ProtoIR",
".",
"isNear",
"which",
"compares",
"the",
"end",
"time",
"of",
"the",
"previous",
"event",
"with",
"the",
"start",
"time",
"of",
"the",
"next",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L542-L569 | |
23,813 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var sawFirstUpdate = false;
var modelBounds = this.model.bounds;
forEventTypesIn(sortedInputEvents, PINCH_TYPE_NAMES, function(event) {
switch (event.typeName) {
case INPUT_TYPE.PINCH_BEGIN:
if (currentPIR &&
currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
currentPIR.pushEvent(event);
break;
}
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, PINCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
sawFirstUpdate = false;
break;
case INPUT_TYPE.PINCH_UPDATE:
// Like ScrollUpdates, the Begin and the first Update constitute a
// Response, then the rest of the Updates constitute an Animation
// that begins when the Response ends. If the user pauses in the
// middle of an extended pinch gesture, then multiple Animations
// will be created.
if (!currentPIR ||
((currentPIR.irType === ProtoIR.RESPONSE_TYPE) &&
sawFirstUpdate) ||
!currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, PINCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
} else {
currentPIR.pushEvent(event);
sawFirstUpdate = true;
}
break;
case INPUT_TYPE.PINCH_END:
if (currentPIR) {
currentPIR.pushEvent(event);
} else {
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
}
currentPIR = undefined;
break;
}
});
return protoIRs;
} | javascript | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var sawFirstUpdate = false;
var modelBounds = this.model.bounds;
forEventTypesIn(sortedInputEvents, PINCH_TYPE_NAMES, function(event) {
switch (event.typeName) {
case INPUT_TYPE.PINCH_BEGIN:
if (currentPIR &&
currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
currentPIR.pushEvent(event);
break;
}
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, PINCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
sawFirstUpdate = false;
break;
case INPUT_TYPE.PINCH_UPDATE:
// Like ScrollUpdates, the Begin and the first Update constitute a
// Response, then the rest of the Updates constitute an Animation
// that begins when the Response ends. If the user pauses in the
// middle of an extended pinch gesture, then multiple Animations
// will be created.
if (!currentPIR ||
((currentPIR.irType === ProtoIR.RESPONSE_TYPE) &&
sawFirstUpdate) ||
!currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, PINCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
} else {
currentPIR.pushEvent(event);
sawFirstUpdate = true;
}
break;
case INPUT_TYPE.PINCH_END:
if (currentPIR) {
currentPIR.pushEvent(event);
} else {
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
}
currentPIR = undefined;
break;
}
});
return protoIRs;
} | [
"function",
"(",
"sortedInputEvents",
")",
"{",
"var",
"protoIRs",
"=",
"[",
"]",
";",
"var",
"currentPIR",
"=",
"undefined",
";",
"var",
"sawFirstUpdate",
"=",
"false",
";",
"var",
"modelBounds",
"=",
"this",
".",
"model",
".",
"bounds",
";",
"forEventTypesIn",
"(",
"sortedInputEvents",
",",
"PINCH_TYPE_NAMES",
",",
"function",
"(",
"event",
")",
"{",
"switch",
"(",
"event",
".",
"typeName",
")",
"{",
"case",
"INPUT_TYPE",
".",
"PINCH_BEGIN",
":",
"if",
"(",
"currentPIR",
"&&",
"currentPIR",
".",
"isNear",
"(",
"event",
",",
"INPUT_MERGE_THRESHOLD_MS",
")",
")",
"{",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"break",
";",
"}",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"RESPONSE_TYPE",
",",
"PINCH_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"sawFirstUpdate",
"=",
"false",
";",
"break",
";",
"case",
"INPUT_TYPE",
".",
"PINCH_UPDATE",
":",
"// Like ScrollUpdates, the Begin and the first Update constitute a",
"// Response, then the rest of the Updates constitute an Animation",
"// that begins when the Response ends. If the user pauses in the",
"// middle of an extended pinch gesture, then multiple Animations",
"// will be created.",
"if",
"(",
"!",
"currentPIR",
"||",
"(",
"(",
"currentPIR",
".",
"irType",
"===",
"ProtoIR",
".",
"RESPONSE_TYPE",
")",
"&&",
"sawFirstUpdate",
")",
"||",
"!",
"currentPIR",
".",
"isNear",
"(",
"event",
",",
"INPUT_MERGE_THRESHOLD_MS",
")",
")",
"{",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"ANIMATION_TYPE",
",",
"PINCH_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"}",
"else",
"{",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"sawFirstUpdate",
"=",
"true",
";",
"}",
"break",
";",
"case",
"INPUT_TYPE",
".",
"PINCH_END",
":",
"if",
"(",
"currentPIR",
")",
"{",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"}",
"else",
"{",
"var",
"pir",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"IGNORED_TYPE",
")",
";",
"pir",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"pir",
")",
";",
"}",
"currentPIR",
"=",
"undefined",
";",
"break",
";",
"}",
"}",
")",
";",
"return",
"protoIRs",
";",
"}"
] | The PinchBegin and the first PinchUpdate comprise a Response, then the rest of the PinchUpdates comprise an Animation. RRRRRRRAAAAAAAAAAAAAAAAAAAA BBB UUU UUU UUU UUU UUU EEE | [
"The",
"PinchBegin",
"and",
"the",
"first",
"PinchUpdate",
"comprise",
"a",
"Response",
"then",
"the",
"rest",
"of",
"the",
"PinchUpdates",
"comprise",
"an",
"Animation",
".",
"RRRRRRRAAAAAAAAAAAAAAAAAAAA",
"BBB",
"UUU",
"UUU",
"UUU",
"UUU",
"UUU",
"EEE"
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L745-L796 | |
23,814 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var sawFirstMove = false;
forEventTypesIn(sortedInputEvents, TOUCH_TYPE_NAMES, function(event) {
switch (event.typeName) {
case INPUT_TYPE.TOUCH_START:
if (currentPIR) {
// NB: currentPIR will probably be merged with something from
// handlePinchEvents(). Multiple TouchStart events without an
// intervening TouchEnd logically implies that multiple fingers
// are on the screen, so this is probably a pinch gesture.
currentPIR.pushEvent(event);
} else {
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, TOUCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
sawFirstMove = false;
}
break;
case INPUT_TYPE.TOUCH_MOVE:
if (!currentPIR) {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, TOUCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
break;
}
// Like Scrolls and Pinches, the Response is defined to be the
// TouchStart plus the first TouchMove, then the rest of the
// TouchMoves constitute an Animation.
if ((sawFirstMove &&
(currentPIR.irType === ProtoIR.RESPONSE_TYPE)) ||
!currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
// If there's already a touchmove in the currentPIR or it's not
// near event, then finish it and start a new animation.
var prevEnd = currentPIR.end;
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, TOUCH_IR_NAME);
currentPIR.pushEvent(event);
// It's possible for there to be a gap between TouchMoves, but
// that doesn't mean that there should be an Idle IR there.
currentPIR.start = prevEnd;
protoIRs.push(currentPIR);
} else {
currentPIR.pushEvent(event);
sawFirstMove = true;
}
break;
case INPUT_TYPE.TOUCH_END:
if (!currentPIR) {
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
break;
}
if (currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
currentPIR.pushEvent(event);
} else {
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
}
currentPIR = undefined;
break;
}
});
return protoIRs;
} | javascript | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var sawFirstMove = false;
forEventTypesIn(sortedInputEvents, TOUCH_TYPE_NAMES, function(event) {
switch (event.typeName) {
case INPUT_TYPE.TOUCH_START:
if (currentPIR) {
// NB: currentPIR will probably be merged with something from
// handlePinchEvents(). Multiple TouchStart events without an
// intervening TouchEnd logically implies that multiple fingers
// are on the screen, so this is probably a pinch gesture.
currentPIR.pushEvent(event);
} else {
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, TOUCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
sawFirstMove = false;
}
break;
case INPUT_TYPE.TOUCH_MOVE:
if (!currentPIR) {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, TOUCH_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
break;
}
// Like Scrolls and Pinches, the Response is defined to be the
// TouchStart plus the first TouchMove, then the rest of the
// TouchMoves constitute an Animation.
if ((sawFirstMove &&
(currentPIR.irType === ProtoIR.RESPONSE_TYPE)) ||
!currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
// If there's already a touchmove in the currentPIR or it's not
// near event, then finish it and start a new animation.
var prevEnd = currentPIR.end;
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, TOUCH_IR_NAME);
currentPIR.pushEvent(event);
// It's possible for there to be a gap between TouchMoves, but
// that doesn't mean that there should be an Idle IR there.
currentPIR.start = prevEnd;
protoIRs.push(currentPIR);
} else {
currentPIR.pushEvent(event);
sawFirstMove = true;
}
break;
case INPUT_TYPE.TOUCH_END:
if (!currentPIR) {
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
break;
}
if (currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS)) {
currentPIR.pushEvent(event);
} else {
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
}
currentPIR = undefined;
break;
}
});
return protoIRs;
} | [
"function",
"(",
"sortedInputEvents",
")",
"{",
"var",
"protoIRs",
"=",
"[",
"]",
";",
"var",
"currentPIR",
"=",
"undefined",
";",
"var",
"sawFirstMove",
"=",
"false",
";",
"forEventTypesIn",
"(",
"sortedInputEvents",
",",
"TOUCH_TYPE_NAMES",
",",
"function",
"(",
"event",
")",
"{",
"switch",
"(",
"event",
".",
"typeName",
")",
"{",
"case",
"INPUT_TYPE",
".",
"TOUCH_START",
":",
"if",
"(",
"currentPIR",
")",
"{",
"// NB: currentPIR will probably be merged with something from",
"// handlePinchEvents(). Multiple TouchStart events without an",
"// intervening TouchEnd logically implies that multiple fingers",
"// are on the screen, so this is probably a pinch gesture.",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"}",
"else",
"{",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"RESPONSE_TYPE",
",",
"TOUCH_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"sawFirstMove",
"=",
"false",
";",
"}",
"break",
";",
"case",
"INPUT_TYPE",
".",
"TOUCH_MOVE",
":",
"if",
"(",
"!",
"currentPIR",
")",
"{",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"ANIMATION_TYPE",
",",
"TOUCH_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"break",
";",
"}",
"// Like Scrolls and Pinches, the Response is defined to be the",
"// TouchStart plus the first TouchMove, then the rest of the",
"// TouchMoves constitute an Animation.",
"if",
"(",
"(",
"sawFirstMove",
"&&",
"(",
"currentPIR",
".",
"irType",
"===",
"ProtoIR",
".",
"RESPONSE_TYPE",
")",
")",
"||",
"!",
"currentPIR",
".",
"isNear",
"(",
"event",
",",
"INPUT_MERGE_THRESHOLD_MS",
")",
")",
"{",
"// If there's already a touchmove in the currentPIR or it's not",
"// near event, then finish it and start a new animation.",
"var",
"prevEnd",
"=",
"currentPIR",
".",
"end",
";",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"ANIMATION_TYPE",
",",
"TOUCH_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"// It's possible for there to be a gap between TouchMoves, but",
"// that doesn't mean that there should be an Idle IR there.",
"currentPIR",
".",
"start",
"=",
"prevEnd",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"}",
"else",
"{",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"sawFirstMove",
"=",
"true",
";",
"}",
"break",
";",
"case",
"INPUT_TYPE",
".",
"TOUCH_END",
":",
"if",
"(",
"!",
"currentPIR",
")",
"{",
"var",
"pir",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"IGNORED_TYPE",
")",
";",
"pir",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"pir",
")",
";",
"break",
";",
"}",
"if",
"(",
"currentPIR",
".",
"isNear",
"(",
"event",
",",
"INPUT_MERGE_THRESHOLD_MS",
")",
")",
"{",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"}",
"else",
"{",
"var",
"pir",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"IGNORED_TYPE",
")",
";",
"pir",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"pir",
")",
";",
"}",
"currentPIR",
"=",
"undefined",
";",
"break",
";",
"}",
"}",
")",
";",
"return",
"protoIRs",
";",
"}"
] | The TouchStart and the first TouchMove comprise a Response, then the rest of the TouchMoves comprise an Animation. RRRRRRRAAAAAAAAAAAAAAAAAAAA SSS MMM MMM MMM MMM MMM EEE If there are no TouchMove events in between a TouchStart and a TouchEnd, then it's just a Response. RRRRRRR SSS EEE | [
"The",
"TouchStart",
"and",
"the",
"first",
"TouchMove",
"comprise",
"a",
"Response",
"then",
"the",
"rest",
"of",
"the",
"TouchMoves",
"comprise",
"an",
"Animation",
".",
"RRRRRRRAAAAAAAAAAAAAAAAAAAA",
"SSS",
"MMM",
"MMM",
"MMM",
"MMM",
"MMM",
"EEE",
"If",
"there",
"are",
"no",
"TouchMove",
"events",
"in",
"between",
"a",
"TouchStart",
"and",
"a",
"TouchEnd",
"then",
"it",
"s",
"just",
"a",
"Response",
".",
"RRRRRRR",
"SSS",
"EEE"
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L894-L963 | |
23,815 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var sawFirstUpdate = false;
forEventTypesIn(sortedInputEvents, SCROLL_TYPE_NAMES, function(event) {
switch (event.typeName) {
case INPUT_TYPE.SCROLL_BEGIN:
// Always begin a new PIR even if there already is one, unlike
// PinchBegin.
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, SCROLL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
sawFirstUpdate = false;
break;
case INPUT_TYPE.SCROLL_UPDATE:
if (currentPIR) {
if (currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS) &&
((currentPIR.irType === ProtoIR.ANIMATION_TYPE) ||
!sawFirstUpdate)) {
currentPIR.pushEvent(event);
sawFirstUpdate = true;
} else {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE,
SCROLL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
}
} else {
// ScrollUpdate without ScrollBegin.
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, SCROLL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
}
break;
case INPUT_TYPE.SCROLL_END:
if (!currentPIR) {
console.error('ScrollEnd without ScrollUpdate? ' +
'File a bug with this trace!');
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
break;
}
currentPIR.pushEvent(event);
break;
}
});
return protoIRs;
} | javascript | function(sortedInputEvents) {
var protoIRs = [];
var currentPIR = undefined;
var sawFirstUpdate = false;
forEventTypesIn(sortedInputEvents, SCROLL_TYPE_NAMES, function(event) {
switch (event.typeName) {
case INPUT_TYPE.SCROLL_BEGIN:
// Always begin a new PIR even if there already is one, unlike
// PinchBegin.
currentPIR = new ProtoIR(ProtoIR.RESPONSE_TYPE, SCROLL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
sawFirstUpdate = false;
break;
case INPUT_TYPE.SCROLL_UPDATE:
if (currentPIR) {
if (currentPIR.isNear(event, INPUT_MERGE_THRESHOLD_MS) &&
((currentPIR.irType === ProtoIR.ANIMATION_TYPE) ||
!sawFirstUpdate)) {
currentPIR.pushEvent(event);
sawFirstUpdate = true;
} else {
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE,
SCROLL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
}
} else {
// ScrollUpdate without ScrollBegin.
currentPIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, SCROLL_IR_NAME);
currentPIR.pushEvent(event);
protoIRs.push(currentPIR);
}
break;
case INPUT_TYPE.SCROLL_END:
if (!currentPIR) {
console.error('ScrollEnd without ScrollUpdate? ' +
'File a bug with this trace!');
var pir = new ProtoIR(ProtoIR.IGNORED_TYPE);
pir.pushEvent(event);
protoIRs.push(pir);
break;
}
currentPIR.pushEvent(event);
break;
}
});
return protoIRs;
} | [
"function",
"(",
"sortedInputEvents",
")",
"{",
"var",
"protoIRs",
"=",
"[",
"]",
";",
"var",
"currentPIR",
"=",
"undefined",
";",
"var",
"sawFirstUpdate",
"=",
"false",
";",
"forEventTypesIn",
"(",
"sortedInputEvents",
",",
"SCROLL_TYPE_NAMES",
",",
"function",
"(",
"event",
")",
"{",
"switch",
"(",
"event",
".",
"typeName",
")",
"{",
"case",
"INPUT_TYPE",
".",
"SCROLL_BEGIN",
":",
"// Always begin a new PIR even if there already is one, unlike",
"// PinchBegin.",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"RESPONSE_TYPE",
",",
"SCROLL_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"sawFirstUpdate",
"=",
"false",
";",
"break",
";",
"case",
"INPUT_TYPE",
".",
"SCROLL_UPDATE",
":",
"if",
"(",
"currentPIR",
")",
"{",
"if",
"(",
"currentPIR",
".",
"isNear",
"(",
"event",
",",
"INPUT_MERGE_THRESHOLD_MS",
")",
"&&",
"(",
"(",
"currentPIR",
".",
"irType",
"===",
"ProtoIR",
".",
"ANIMATION_TYPE",
")",
"||",
"!",
"sawFirstUpdate",
")",
")",
"{",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"sawFirstUpdate",
"=",
"true",
";",
"}",
"else",
"{",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"ANIMATION_TYPE",
",",
"SCROLL_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"}",
"}",
"else",
"{",
"// ScrollUpdate without ScrollBegin.",
"currentPIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"ANIMATION_TYPE",
",",
"SCROLL_IR_NAME",
")",
";",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"currentPIR",
")",
";",
"}",
"break",
";",
"case",
"INPUT_TYPE",
".",
"SCROLL_END",
":",
"if",
"(",
"!",
"currentPIR",
")",
"{",
"console",
".",
"error",
"(",
"'ScrollEnd without ScrollUpdate? '",
"+",
"'File a bug with this trace!'",
")",
";",
"var",
"pir",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"IGNORED_TYPE",
")",
";",
"pir",
".",
"pushEvent",
"(",
"event",
")",
";",
"protoIRs",
".",
"push",
"(",
"pir",
")",
";",
"break",
";",
"}",
"currentPIR",
".",
"pushEvent",
"(",
"event",
")",
";",
"break",
";",
"}",
"}",
")",
";",
"return",
"protoIRs",
";",
"}"
] | The first ScrollBegin and the first ScrollUpdate comprise a Response, then the rest comprise an Animation. RRRRRRRAAAAAAAAAAAAAAAAAAAA BBB UUU UUU UUU UUU UUU EEE | [
"The",
"first",
"ScrollBegin",
"and",
"the",
"first",
"ScrollUpdate",
"comprise",
"a",
"Response",
"then",
"the",
"rest",
"comprise",
"an",
"Animation",
".",
"RRRRRRRAAAAAAAAAAAAAAAAAAAA",
"BBB",
"UUU",
"UUU",
"UUU",
"UUU",
"UUU",
"EEE"
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L971-L1021 | |
23,816 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents) {
var animationEvents = this.modelHelper.browserHelper.
getAllAsyncSlicesMatching(function(event) {
return ((event.title === CSS_ANIMATION_TITLE) &&
(event.duration > 0));
});
var animationRanges = [];
animationEvents.forEach(function(event) {
animationRanges.push({
min: event.start,
max: event.end,
event: event
});
});
function merge(ranges) {
var protoIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, CSS_IR_NAME);
ranges.forEach(function(range) {
protoIR.pushEvent(range.event);
});
return protoIR;
}
return tr.b.mergeRanges(animationRanges,
ANIMATION_MERGE_THRESHOLD_MS,
merge);
} | javascript | function(sortedInputEvents) {
var animationEvents = this.modelHelper.browserHelper.
getAllAsyncSlicesMatching(function(event) {
return ((event.title === CSS_ANIMATION_TITLE) &&
(event.duration > 0));
});
var animationRanges = [];
animationEvents.forEach(function(event) {
animationRanges.push({
min: event.start,
max: event.end,
event: event
});
});
function merge(ranges) {
var protoIR = new ProtoIR(ProtoIR.ANIMATION_TYPE, CSS_IR_NAME);
ranges.forEach(function(range) {
protoIR.pushEvent(range.event);
});
return protoIR;
}
return tr.b.mergeRanges(animationRanges,
ANIMATION_MERGE_THRESHOLD_MS,
merge);
} | [
"function",
"(",
"sortedInputEvents",
")",
"{",
"var",
"animationEvents",
"=",
"this",
".",
"modelHelper",
".",
"browserHelper",
".",
"getAllAsyncSlicesMatching",
"(",
"function",
"(",
"event",
")",
"{",
"return",
"(",
"(",
"event",
".",
"title",
"===",
"CSS_ANIMATION_TITLE",
")",
"&&",
"(",
"event",
".",
"duration",
">",
"0",
")",
")",
";",
"}",
")",
";",
"var",
"animationRanges",
"=",
"[",
"]",
";",
"animationEvents",
".",
"forEach",
"(",
"function",
"(",
"event",
")",
"{",
"animationRanges",
".",
"push",
"(",
"{",
"min",
":",
"event",
".",
"start",
",",
"max",
":",
"event",
".",
"end",
",",
"event",
":",
"event",
"}",
")",
";",
"}",
")",
";",
"function",
"merge",
"(",
"ranges",
")",
"{",
"var",
"protoIR",
"=",
"new",
"ProtoIR",
"(",
"ProtoIR",
".",
"ANIMATION_TYPE",
",",
"CSS_IR_NAME",
")",
";",
"ranges",
".",
"forEach",
"(",
"function",
"(",
"range",
")",
"{",
"protoIR",
".",
"pushEvent",
"(",
"range",
".",
"event",
")",
";",
"}",
")",
";",
"return",
"protoIR",
";",
"}",
"return",
"tr",
".",
"b",
".",
"mergeRanges",
"(",
"animationRanges",
",",
"ANIMATION_MERGE_THRESHOLD_MS",
",",
"merge",
")",
";",
"}"
] | CSS Animations are merged into Animations when they intersect. | [
"CSS",
"Animations",
"are",
"merged",
"into",
"Animations",
"when",
"they",
"intersect",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L1024-L1051 | |
23,817 | googlearchive/node-big-rig | lib/third_party/tracing/extras/rail/rail_ir_finder.js | function(sortedInputEvents, protoIRs) {
var handledEvents = [];
protoIRs.forEach(function(protoIR) {
protoIR.associatedEvents.forEach(function(event) {
if (handledEvents.indexOf(event) >= 0) {
console.error('double-handled event', event.typeName,
parseInt(event.start), parseInt(event.end), protoIR);
return;
}
handledEvents.push(event);
});
});
sortedInputEvents.forEach(function(event) {
if (handledEvents.indexOf(event) < 0) {
console.error('UNHANDLED INPUT EVENT!',
event.typeName, parseInt(event.start), parseInt(event.end));
}
});
} | javascript | function(sortedInputEvents, protoIRs) {
var handledEvents = [];
protoIRs.forEach(function(protoIR) {
protoIR.associatedEvents.forEach(function(event) {
if (handledEvents.indexOf(event) >= 0) {
console.error('double-handled event', event.typeName,
parseInt(event.start), parseInt(event.end), protoIR);
return;
}
handledEvents.push(event);
});
});
sortedInputEvents.forEach(function(event) {
if (handledEvents.indexOf(event) < 0) {
console.error('UNHANDLED INPUT EVENT!',
event.typeName, parseInt(event.start), parseInt(event.end));
}
});
} | [
"function",
"(",
"sortedInputEvents",
",",
"protoIRs",
")",
"{",
"var",
"handledEvents",
"=",
"[",
"]",
";",
"protoIRs",
".",
"forEach",
"(",
"function",
"(",
"protoIR",
")",
"{",
"protoIR",
".",
"associatedEvents",
".",
"forEach",
"(",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"handledEvents",
".",
"indexOf",
"(",
"event",
")",
">=",
"0",
")",
"{",
"console",
".",
"error",
"(",
"'double-handled event'",
",",
"event",
".",
"typeName",
",",
"parseInt",
"(",
"event",
".",
"start",
")",
",",
"parseInt",
"(",
"event",
".",
"end",
")",
",",
"protoIR",
")",
";",
"return",
";",
"}",
"handledEvents",
".",
"push",
"(",
"event",
")",
";",
"}",
")",
";",
"}",
")",
";",
"sortedInputEvents",
".",
"forEach",
"(",
"function",
"(",
"event",
")",
"{",
"if",
"(",
"handledEvents",
".",
"indexOf",
"(",
"event",
")",
"<",
"0",
")",
"{",
"console",
".",
"error",
"(",
"'UNHANDLED INPUT EVENT!'",
",",
"event",
".",
"typeName",
",",
"parseInt",
"(",
"event",
".",
"start",
")",
",",
"parseInt",
"(",
"event",
".",
"end",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | Check that none of the handlers accidentally ignored an input event. | [
"Check",
"that",
"none",
"of",
"the",
"handlers",
"accidentally",
"ignored",
"an",
"input",
"event",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/rail/rail_ir_finder.js#L1248-L1267 | |
23,818 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/memreclaim_parser.js | MemReclaimParser | function MemReclaimParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('mm_vmscan_kswapd_wake',
MemReclaimParser.prototype.kswapdWake.bind(this));
importer.registerEventHandler('mm_vmscan_kswapd_sleep',
MemReclaimParser.prototype.kswapdSleep.bind(this));
importer.registerEventHandler('mm_vmscan_direct_reclaim_begin',
MemReclaimParser.prototype.reclaimBegin.bind(this));
importer.registerEventHandler('mm_vmscan_direct_reclaim_end',
MemReclaimParser.prototype.reclaimEnd.bind(this));
} | javascript | function MemReclaimParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('mm_vmscan_kswapd_wake',
MemReclaimParser.prototype.kswapdWake.bind(this));
importer.registerEventHandler('mm_vmscan_kswapd_sleep',
MemReclaimParser.prototype.kswapdSleep.bind(this));
importer.registerEventHandler('mm_vmscan_direct_reclaim_begin',
MemReclaimParser.prototype.reclaimBegin.bind(this));
importer.registerEventHandler('mm_vmscan_direct_reclaim_end',
MemReclaimParser.prototype.reclaimEnd.bind(this));
} | [
"function",
"MemReclaimParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'mm_vmscan_kswapd_wake'",
",",
"MemReclaimParser",
".",
"prototype",
".",
"kswapdWake",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'mm_vmscan_kswapd_sleep'",
",",
"MemReclaimParser",
".",
"prototype",
".",
"kswapdSleep",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'mm_vmscan_direct_reclaim_begin'",
",",
"MemReclaimParser",
".",
"prototype",
".",
"reclaimBegin",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'mm_vmscan_direct_reclaim_end'",
",",
"MemReclaimParser",
".",
"prototype",
".",
"reclaimEnd",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux vmscan trace events.
@constructor | [
"Parses",
"linux",
"vmscan",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/memreclaim_parser.js#L21-L32 |
23,819 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/memreclaim_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = kswapdWakeRE.exec(eventBase.details);
if (!event)
return false;
var tgid = parseInt(eventBase.tgid);
var nid = parseInt(event[1]);
var order = parseInt(event[2]);
var kthread = this.importer.getOrCreateKernelThread(
eventBase.threadName, tgid, pid);
if (kthread.openSliceTS) {
if (order > kthread.order) {
kthread.order = order;
}
} else {
kthread.openSliceTS = ts;
kthread.order = order;
}
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = kswapdWakeRE.exec(eventBase.details);
if (!event)
return false;
var tgid = parseInt(eventBase.tgid);
var nid = parseInt(event[1]);
var order = parseInt(event[2]);
var kthread = this.importer.getOrCreateKernelThread(
eventBase.threadName, tgid, pid);
if (kthread.openSliceTS) {
if (order > kthread.order) {
kthread.order = order;
}
} else {
kthread.openSliceTS = ts;
kthread.order = order;
}
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"kswapdWakeRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"tgid",
"=",
"parseInt",
"(",
"eventBase",
".",
"tgid",
")",
";",
"var",
"nid",
"=",
"parseInt",
"(",
"event",
"[",
"1",
"]",
")",
";",
"var",
"order",
"=",
"parseInt",
"(",
"event",
"[",
"2",
"]",
")",
";",
"var",
"kthread",
"=",
"this",
".",
"importer",
".",
"getOrCreateKernelThread",
"(",
"eventBase",
".",
"threadName",
",",
"tgid",
",",
"pid",
")",
";",
"if",
"(",
"kthread",
".",
"openSliceTS",
")",
"{",
"if",
"(",
"order",
">",
"kthread",
".",
"order",
")",
"{",
"kthread",
".",
"order",
"=",
"order",
";",
"}",
"}",
"else",
"{",
"kthread",
".",
"openSliceTS",
"=",
"ts",
";",
"kthread",
".",
"order",
"=",
"order",
";",
"}",
"return",
"true",
";",
"}"
] | Parses memreclaim events and sets up state in the importer. | [
"Parses",
"memreclaim",
"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/memreclaim_parser.js#L56-L78 | |
23,820 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/sync_parser.js | SyncParser | function SyncParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler(
'sync_timeline',
SyncParser.prototype.timelineEvent.bind(this));
importer.registerEventHandler(
'sync_wait',
SyncParser.prototype.syncWaitEvent.bind(this));
importer.registerEventHandler(
'sync_pt',
SyncParser.prototype.syncPtEvent.bind(this));
this.model_ = importer.model_;
} | javascript | function SyncParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler(
'sync_timeline',
SyncParser.prototype.timelineEvent.bind(this));
importer.registerEventHandler(
'sync_wait',
SyncParser.prototype.syncWaitEvent.bind(this));
importer.registerEventHandler(
'sync_pt',
SyncParser.prototype.syncPtEvent.bind(this));
this.model_ = importer.model_;
} | [
"function",
"SyncParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'sync_timeline'",
",",
"SyncParser",
".",
"prototype",
".",
"timelineEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'sync_wait'",
",",
"SyncParser",
".",
"prototype",
".",
"syncWaitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'sync_pt'",
",",
"SyncParser",
".",
"prototype",
".",
"syncPtEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"model_",
"=",
"importer",
".",
"model_",
";",
"}"
] | Parses linux sync trace events.
@constructor | [
"Parses",
"linux",
"sync",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/sync_parser.js#L23-L36 |
23,821 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/sync_parser.js | function(eventName, cpuNumber, pid,
ts, eventBase) {
var event = syncTimelineRE.exec(eventBase.details);
if (!event)
return false;
var thread = this.importer.getOrCreatePseudoThread(event[1]);
if (thread.lastActiveTs !== undefined) {
var duration = ts - thread.lastActiveTs;
var value = thread.lastActiveValue;
if (value == undefined)
value = ' ';
var slice = new tr.model.Slice(
'', value,
ColorScheme.getColorIdForGeneralPurposeString(value),
thread.lastActiveTs, {},
duration);
thread.thread.sliceGroup.pushSlice(slice);
}
thread.lastActiveTs = ts;
thread.lastActiveValue = event[2];
return true;
} | javascript | function(eventName, cpuNumber, pid,
ts, eventBase) {
var event = syncTimelineRE.exec(eventBase.details);
if (!event)
return false;
var thread = this.importer.getOrCreatePseudoThread(event[1]);
if (thread.lastActiveTs !== undefined) {
var duration = ts - thread.lastActiveTs;
var value = thread.lastActiveValue;
if (value == undefined)
value = ' ';
var slice = new tr.model.Slice(
'', value,
ColorScheme.getColorIdForGeneralPurposeString(value),
thread.lastActiveTs, {},
duration);
thread.thread.sliceGroup.pushSlice(slice);
}
thread.lastActiveTs = ts;
thread.lastActiveValue = event[2];
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"syncTimelineRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"thread",
"=",
"this",
".",
"importer",
".",
"getOrCreatePseudoThread",
"(",
"event",
"[",
"1",
"]",
")",
";",
"if",
"(",
"thread",
".",
"lastActiveTs",
"!==",
"undefined",
")",
"{",
"var",
"duration",
"=",
"ts",
"-",
"thread",
".",
"lastActiveTs",
";",
"var",
"value",
"=",
"thread",
".",
"lastActiveValue",
";",
"if",
"(",
"value",
"==",
"undefined",
")",
"value",
"=",
"' '",
";",
"var",
"slice",
"=",
"new",
"tr",
".",
"model",
".",
"Slice",
"(",
"''",
",",
"value",
",",
"ColorScheme",
".",
"getColorIdForGeneralPurposeString",
"(",
"value",
")",
",",
"thread",
".",
"lastActiveTs",
",",
"{",
"}",
",",
"duration",
")",
";",
"thread",
".",
"thread",
".",
"sliceGroup",
".",
"pushSlice",
"(",
"slice",
")",
";",
"}",
"thread",
".",
"lastActiveTs",
"=",
"ts",
";",
"thread",
".",
"lastActiveValue",
"=",
"event",
"[",
"2",
"]",
";",
"return",
"true",
";",
"}"
] | Parses sync events and sets up state in the importer. | [
"Parses",
"sync",
"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/sync_parser.js#L48-L71 | |
23,822 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/i915_parser.js | I915Parser | function I915Parser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('i915_gem_object_create',
I915Parser.prototype.gemObjectCreateEvent.bind(this));
importer.registerEventHandler('i915_gem_object_bind',
I915Parser.prototype.gemObjectBindEvent.bind(this));
importer.registerEventHandler('i915_gem_object_unbind',
I915Parser.prototype.gemObjectBindEvent.bind(this));
importer.registerEventHandler('i915_gem_object_change_domain',
I915Parser.prototype.gemObjectChangeDomainEvent.bind(this));
importer.registerEventHandler('i915_gem_object_pread',
I915Parser.prototype.gemObjectPreadWriteEvent.bind(this));
importer.registerEventHandler('i915_gem_object_pwrite',
I915Parser.prototype.gemObjectPreadWriteEvent.bind(this));
importer.registerEventHandler('i915_gem_object_fault',
I915Parser.prototype.gemObjectFaultEvent.bind(this));
importer.registerEventHandler('i915_gem_object_clflush',
// NB: reuse destroy handler
I915Parser.prototype.gemObjectDestroyEvent.bind(this));
importer.registerEventHandler('i915_gem_object_destroy',
I915Parser.prototype.gemObjectDestroyEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_dispatch',
I915Parser.prototype.gemRingDispatchEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_flush',
I915Parser.prototype.gemRingFlushEvent.bind(this));
importer.registerEventHandler('i915_gem_request',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_add',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_complete',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_retire',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_wait_begin',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_wait_end',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_wait_begin',
I915Parser.prototype.gemRingWaitEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_wait_end',
I915Parser.prototype.gemRingWaitEvent.bind(this));
importer.registerEventHandler('i915_reg_rw',
I915Parser.prototype.regRWEvent.bind(this));
importer.registerEventHandler('i915_flip_request',
I915Parser.prototype.flipEvent.bind(this));
importer.registerEventHandler('i915_flip_complete',
I915Parser.prototype.flipEvent.bind(this));
importer.registerEventHandler('intel_gpu_freq_change',
I915Parser.prototype.gpuFrequency.bind(this));
} | javascript | function I915Parser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('i915_gem_object_create',
I915Parser.prototype.gemObjectCreateEvent.bind(this));
importer.registerEventHandler('i915_gem_object_bind',
I915Parser.prototype.gemObjectBindEvent.bind(this));
importer.registerEventHandler('i915_gem_object_unbind',
I915Parser.prototype.gemObjectBindEvent.bind(this));
importer.registerEventHandler('i915_gem_object_change_domain',
I915Parser.prototype.gemObjectChangeDomainEvent.bind(this));
importer.registerEventHandler('i915_gem_object_pread',
I915Parser.prototype.gemObjectPreadWriteEvent.bind(this));
importer.registerEventHandler('i915_gem_object_pwrite',
I915Parser.prototype.gemObjectPreadWriteEvent.bind(this));
importer.registerEventHandler('i915_gem_object_fault',
I915Parser.prototype.gemObjectFaultEvent.bind(this));
importer.registerEventHandler('i915_gem_object_clflush',
// NB: reuse destroy handler
I915Parser.prototype.gemObjectDestroyEvent.bind(this));
importer.registerEventHandler('i915_gem_object_destroy',
I915Parser.prototype.gemObjectDestroyEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_dispatch',
I915Parser.prototype.gemRingDispatchEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_flush',
I915Parser.prototype.gemRingFlushEvent.bind(this));
importer.registerEventHandler('i915_gem_request',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_add',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_complete',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_retire',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_wait_begin',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_request_wait_end',
I915Parser.prototype.gemRequestEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_wait_begin',
I915Parser.prototype.gemRingWaitEvent.bind(this));
importer.registerEventHandler('i915_gem_ring_wait_end',
I915Parser.prototype.gemRingWaitEvent.bind(this));
importer.registerEventHandler('i915_reg_rw',
I915Parser.prototype.regRWEvent.bind(this));
importer.registerEventHandler('i915_flip_request',
I915Parser.prototype.flipEvent.bind(this));
importer.registerEventHandler('i915_flip_complete',
I915Parser.prototype.flipEvent.bind(this));
importer.registerEventHandler('intel_gpu_freq_change',
I915Parser.prototype.gpuFrequency.bind(this));
} | [
"function",
"I915Parser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_create'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectCreateEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_bind'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectBindEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_unbind'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectBindEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_change_domain'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectChangeDomainEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_pread'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectPreadWriteEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_pwrite'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectPreadWriteEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_fault'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectFaultEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_clflush'",
",",
"// NB: reuse destroy handler",
"I915Parser",
".",
"prototype",
".",
"gemObjectDestroyEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_object_destroy'",
",",
"I915Parser",
".",
"prototype",
".",
"gemObjectDestroyEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_ring_dispatch'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRingDispatchEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_ring_flush'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRingFlushEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_request'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRequestEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_request_add'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRequestEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_request_complete'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRequestEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_request_retire'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRequestEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_request_wait_begin'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRequestEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_request_wait_end'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRequestEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_ring_wait_begin'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRingWaitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_gem_ring_wait_end'",
",",
"I915Parser",
".",
"prototype",
".",
"gemRingWaitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_reg_rw'",
",",
"I915Parser",
".",
"prototype",
".",
"regRWEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_flip_request'",
",",
"I915Parser",
".",
"prototype",
".",
"flipEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'i915_flip_complete'",
",",
"I915Parser",
".",
"prototype",
".",
"flipEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'intel_gpu_freq_change'",
",",
"I915Parser",
".",
"prototype",
".",
"gpuFrequency",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux i915 trace events.
@constructor | [
"Parses",
"linux",
"i915",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/i915_parser.js#L22-L72 |
23,823 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/i915_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /obj=(\w+), size=(\d+)/.exec(eventBase.details);
if (!event)
return false;
var obj = event[1];
var size = parseInt(event[2]);
this.i915GemObjectSlice(ts, eventName, obj,
{
obj: obj,
size: size
});
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /obj=(\w+), size=(\d+)/.exec(eventBase.details);
if (!event)
return false;
var obj = event[1];
var size = parseInt(event[2]);
this.i915GemObjectSlice(ts, eventName, obj,
{
obj: obj,
size: size
});
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"/",
"obj=(\\w+), size=(\\d+)",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"obj",
"=",
"event",
"[",
"1",
"]",
";",
"var",
"size",
"=",
"parseInt",
"(",
"event",
"[",
"2",
"]",
")",
";",
"this",
".",
"i915GemObjectSlice",
"(",
"ts",
",",
"eventName",
",",
"obj",
",",
"{",
"obj",
":",
"obj",
",",
"size",
":",
"size",
"}",
")",
";",
"return",
"true",
";",
"}"
] | Parses i915 driver events and sets up state in the importer. | [
"Parses",
"i915",
"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/i915_parser.js#L141-L154 | |
23,824 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/exynos_parser.js | ExynosParser | function ExynosParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('exynos_busfreq_target_int',
ExynosParser.prototype.busfreqTargetIntEvent.bind(this));
importer.registerEventHandler('exynos_busfreq_target_mif',
ExynosParser.prototype.busfreqTargetMifEvent.bind(this));
importer.registerEventHandler('exynos_page_flip_state',
ExynosParser.prototype.pageFlipStateEvent.bind(this));
} | javascript | function ExynosParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('exynos_busfreq_target_int',
ExynosParser.prototype.busfreqTargetIntEvent.bind(this));
importer.registerEventHandler('exynos_busfreq_target_mif',
ExynosParser.prototype.busfreqTargetMifEvent.bind(this));
importer.registerEventHandler('exynos_page_flip_state',
ExynosParser.prototype.pageFlipStateEvent.bind(this));
} | [
"function",
"ExynosParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'exynos_busfreq_target_int'",
",",
"ExynosParser",
".",
"prototype",
".",
"busfreqTargetIntEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'exynos_busfreq_target_mif'",
",",
"ExynosParser",
".",
"prototype",
".",
"busfreqTargetMifEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'exynos_page_flip_state'",
",",
"ExynosParser",
".",
"prototype",
".",
"pageFlipStateEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux exynos trace events.
@constructor | [
"Parses",
"linux",
"exynos",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/exynos_parser.js#L23-L33 |
23,825 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/exynos_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /frequency=(\d+)/.exec(eventBase.details);
if (!event)
return false;
this.exynosBusfreqSample('INT Frequency', ts, parseInt(event[1]));
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /frequency=(\d+)/.exec(eventBase.details);
if (!event)
return false;
this.exynosBusfreqSample('INT Frequency', ts, parseInt(event[1]));
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"/",
"frequency=(\\d+)",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"this",
".",
"exynosBusfreqSample",
"(",
"'INT Frequency'",
",",
"ts",
",",
"parseInt",
"(",
"event",
"[",
"1",
"]",
")",
")",
";",
"return",
"true",
";",
"}"
] | Parses exynos_busfreq_target_int events and sets up state. | [
"Parses",
"exynos_busfreq_target_int",
"events",
"and",
"sets",
"up",
"state",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/exynos_parser.js#L54-L61 | |
23,826 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/exynos_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /pipe=(\d+), fb=(\d+), state=(.*)/.exec(eventBase.details);
if (!event)
return false;
var pipe = parseInt(event[1]);
var fb = parseInt(event[2]);
var state = event[3];
this.exynosPageFlipStateCloseSlice(ts, pipe, fb,
{
pipe: pipe,
fb: fb
});
if (state !== 'flipped')
this.exynosPageFlipStateOpenSlice(ts, pipe, fb, state);
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = /pipe=(\d+), fb=(\d+), state=(.*)/.exec(eventBase.details);
if (!event)
return false;
var pipe = parseInt(event[1]);
var fb = parseInt(event[2]);
var state = event[3];
this.exynosPageFlipStateCloseSlice(ts, pipe, fb,
{
pipe: pipe,
fb: fb
});
if (state !== 'flipped')
this.exynosPageFlipStateOpenSlice(ts, pipe, fb, state);
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"/",
"pipe=(\\d+), fb=(\\d+), state=(.*)",
"/",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"pipe",
"=",
"parseInt",
"(",
"event",
"[",
"1",
"]",
")",
";",
"var",
"fb",
"=",
"parseInt",
"(",
"event",
"[",
"2",
"]",
")",
";",
"var",
"state",
"=",
"event",
"[",
"3",
"]",
";",
"this",
".",
"exynosPageFlipStateCloseSlice",
"(",
"ts",
",",
"pipe",
",",
"fb",
",",
"{",
"pipe",
":",
"pipe",
",",
"fb",
":",
"fb",
"}",
")",
";",
"if",
"(",
"state",
"!==",
"'flipped'",
")",
"this",
".",
"exynosPageFlipStateOpenSlice",
"(",
"ts",
",",
"pipe",
",",
"fb",
",",
"state",
")",
";",
"return",
"true",
";",
"}"
] | Parses page_flip_state events and sets up state in the importer. | [
"Parses",
"page_flip_state",
"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/exynos_parser.js#L99-L116 | |
23,827 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/irq_parser.js | IrqParser | function IrqParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('irq_handler_entry',
IrqParser.prototype.irqHandlerEntryEvent.bind(this));
importer.registerEventHandler('irq_handler_exit',
IrqParser.prototype.irqHandlerExitEvent.bind(this));
importer.registerEventHandler('softirq_raise',
IrqParser.prototype.softirqRaiseEvent.bind(this));
importer.registerEventHandler('softirq_entry',
IrqParser.prototype.softirqEntryEvent.bind(this));
importer.registerEventHandler('softirq_exit',
IrqParser.prototype.softirqExitEvent.bind(this));
importer.registerEventHandler('ipi_entry',
IrqParser.prototype.ipiEntryEvent.bind(this));
importer.registerEventHandler('ipi_exit',
IrqParser.prototype.ipiExitEvent.bind(this));
} | javascript | function IrqParser(importer) {
Parser.call(this, importer);
importer.registerEventHandler('irq_handler_entry',
IrqParser.prototype.irqHandlerEntryEvent.bind(this));
importer.registerEventHandler('irq_handler_exit',
IrqParser.prototype.irqHandlerExitEvent.bind(this));
importer.registerEventHandler('softirq_raise',
IrqParser.prototype.softirqRaiseEvent.bind(this));
importer.registerEventHandler('softirq_entry',
IrqParser.prototype.softirqEntryEvent.bind(this));
importer.registerEventHandler('softirq_exit',
IrqParser.prototype.softirqExitEvent.bind(this));
importer.registerEventHandler('ipi_entry',
IrqParser.prototype.ipiEntryEvent.bind(this));
importer.registerEventHandler('ipi_exit',
IrqParser.prototype.ipiExitEvent.bind(this));
} | [
"function",
"IrqParser",
"(",
"importer",
")",
"{",
"Parser",
".",
"call",
"(",
"this",
",",
"importer",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'irq_handler_entry'",
",",
"IrqParser",
".",
"prototype",
".",
"irqHandlerEntryEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'irq_handler_exit'",
",",
"IrqParser",
".",
"prototype",
".",
"irqHandlerExitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'softirq_raise'",
",",
"IrqParser",
".",
"prototype",
".",
"softirqRaiseEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'softirq_entry'",
",",
"IrqParser",
".",
"prototype",
".",
"softirqEntryEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'softirq_exit'",
",",
"IrqParser",
".",
"prototype",
".",
"softirqExitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'ipi_entry'",
",",
"IrqParser",
".",
"prototype",
".",
"ipiEntryEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"importer",
".",
"registerEventHandler",
"(",
"'ipi_exit'",
",",
"IrqParser",
".",
"prototype",
".",
"ipiExitEvent",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
] | Parses linux irq trace events.
@constructor | [
"Parses",
"linux",
"irq",
"trace",
"events",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/irq_parser.js#L23-L40 |
23,828 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/irq_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = irqHandlerEntryRE.exec(eventBase.details);
if (!event)
return false;
var irq = parseInt(event[1]);
var name = event[2];
var thread = this.importer.getOrCreatePseudoThread(
'irqs cpu ' + cpuNumber);
thread.lastEntryTs = ts;
thread.irqName = name;
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var event = irqHandlerEntryRE.exec(eventBase.details);
if (!event)
return false;
var irq = parseInt(event[1]);
var name = event[2];
var thread = this.importer.getOrCreatePseudoThread(
'irqs cpu ' + cpuNumber);
thread.lastEntryTs = ts;
thread.irqName = name;
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"event",
"=",
"irqHandlerEntryRE",
".",
"exec",
"(",
"eventBase",
".",
"details",
")",
";",
"if",
"(",
"!",
"event",
")",
"return",
"false",
";",
"var",
"irq",
"=",
"parseInt",
"(",
"event",
"[",
"1",
"]",
")",
";",
"var",
"name",
"=",
"event",
"[",
"2",
"]",
";",
"var",
"thread",
"=",
"this",
".",
"importer",
".",
"getOrCreatePseudoThread",
"(",
"'irqs cpu '",
"+",
"cpuNumber",
")",
";",
"thread",
".",
"lastEntryTs",
"=",
"ts",
";",
"thread",
".",
"irqName",
"=",
"name",
";",
"return",
"true",
";",
"}"
] | Parses irq events and sets up state in the mporter. | [
"Parses",
"irq",
"events",
"and",
"sets",
"up",
"state",
"in",
"the",
"mporter",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/irq_parser.js#L60-L74 | |
23,829 | googlearchive/node-big-rig | lib/third_party/tracing/extras/importer/linux_perf/irq_parser.js | function(eventName, cpuNumber, pid, ts, eventBase) {
var thread = this.importer.getOrCreatePseudoThread(
'irqs cpu ' + cpuNumber);
thread.lastEntryTs = ts;
return true;
} | javascript | function(eventName, cpuNumber, pid, ts, eventBase) {
var thread = this.importer.getOrCreatePseudoThread(
'irqs cpu ' + cpuNumber);
thread.lastEntryTs = ts;
return true;
} | [
"function",
"(",
"eventName",
",",
"cpuNumber",
",",
"pid",
",",
"ts",
",",
"eventBase",
")",
"{",
"var",
"thread",
"=",
"this",
".",
"importer",
".",
"getOrCreatePseudoThread",
"(",
"'irqs cpu '",
"+",
"cpuNumber",
")",
";",
"thread",
".",
"lastEntryTs",
"=",
"ts",
";",
"return",
"true",
";",
"}"
] | Parses ipi events and sets up state in the mporter. | [
"Parses",
"ipi",
"events",
"and",
"sets",
"up",
"state",
"in",
"the",
"mporter",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/extras/importer/linux_perf/irq_parser.js#L143-L149 | |
23,830 | googlearchive/node-big-rig | lib/third_party/tracing/base/base.js | initialize | function initialize() {
if (global.isVinn) {
tr.isVinn = true;
} else if (global.process && global.process.versions.node) {
tr.isNode = true;
} else {
tr.isVinn = false;
tr.isNode = false;
tr.doc = document;
tr.isMac = /Mac/.test(navigator.platform);
tr.isWindows = /Win/.test(navigator.platform);
tr.isChromeOS = /CrOS/.test(navigator.userAgent);
tr.isLinux = /Linux/.test(navigator.userAgent);
}
tr.isHeadless = tr.isVinn || tr.isNode;
} | javascript | function initialize() {
if (global.isVinn) {
tr.isVinn = true;
} else if (global.process && global.process.versions.node) {
tr.isNode = true;
} else {
tr.isVinn = false;
tr.isNode = false;
tr.doc = document;
tr.isMac = /Mac/.test(navigator.platform);
tr.isWindows = /Win/.test(navigator.platform);
tr.isChromeOS = /CrOS/.test(navigator.userAgent);
tr.isLinux = /Linux/.test(navigator.userAgent);
}
tr.isHeadless = tr.isVinn || tr.isNode;
} | [
"function",
"initialize",
"(",
")",
"{",
"if",
"(",
"global",
".",
"isVinn",
")",
"{",
"tr",
".",
"isVinn",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"global",
".",
"process",
"&&",
"global",
".",
"process",
".",
"versions",
".",
"node",
")",
"{",
"tr",
".",
"isNode",
"=",
"true",
";",
"}",
"else",
"{",
"tr",
".",
"isVinn",
"=",
"false",
";",
"tr",
".",
"isNode",
"=",
"false",
";",
"tr",
".",
"doc",
"=",
"document",
";",
"tr",
".",
"isMac",
"=",
"/",
"Mac",
"/",
".",
"test",
"(",
"navigator",
".",
"platform",
")",
";",
"tr",
".",
"isWindows",
"=",
"/",
"Win",
"/",
".",
"test",
"(",
"navigator",
".",
"platform",
")",
";",
"tr",
".",
"isChromeOS",
"=",
"/",
"CrOS",
"/",
".",
"test",
"(",
"navigator",
".",
"userAgent",
")",
";",
"tr",
".",
"isLinux",
"=",
"/",
"Linux",
"/",
".",
"test",
"(",
"navigator",
".",
"userAgent",
")",
";",
"}",
"tr",
".",
"isHeadless",
"=",
"tr",
".",
"isVinn",
"||",
"tr",
".",
"isNode",
";",
"}"
] | Initialization which must be deferred until run-time. | [
"Initialization",
"which",
"must",
"be",
"deferred",
"until",
"run",
"-",
"time",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/base.js#L161-L177 |
23,831 | googlearchive/node-big-rig | lib/third_party/tracing/base/event_target.js | function(type, handler) {
if (!this.listeners_)
this.listeners_ = Object.create(null);
if (!(type in this.listeners_)) {
this.listeners_[type] = [handler];
} else {
var handlers = this.listeners_[type];
if (handlers.indexOf(handler) < 0)
handlers.push(handler);
}
} | javascript | function(type, handler) {
if (!this.listeners_)
this.listeners_ = Object.create(null);
if (!(type in this.listeners_)) {
this.listeners_[type] = [handler];
} else {
var handlers = this.listeners_[type];
if (handlers.indexOf(handler) < 0)
handlers.push(handler);
}
} | [
"function",
"(",
"type",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"this",
".",
"listeners_",
")",
"this",
".",
"listeners_",
"=",
"Object",
".",
"create",
"(",
"null",
")",
";",
"if",
"(",
"!",
"(",
"type",
"in",
"this",
".",
"listeners_",
")",
")",
"{",
"this",
".",
"listeners_",
"[",
"type",
"]",
"=",
"[",
"handler",
"]",
";",
"}",
"else",
"{",
"var",
"handlers",
"=",
"this",
".",
"listeners_",
"[",
"type",
"]",
";",
"if",
"(",
"handlers",
".",
"indexOf",
"(",
"handler",
")",
"<",
"0",
")",
"handlers",
".",
"push",
"(",
"handler",
")",
";",
"}",
"}"
] | Adds an event listener to the target.
@param {string} type The name of the event.
@param {!Function|{handleEvent:Function}} handler The handler for the
event. This is called when the event is dispatched. | [
"Adds",
"an",
"event",
"listener",
"to",
"the",
"target",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/event_target.js#L43-L53 | |
23,832 | googlearchive/node-big-rig | lib/third_party/tracing/base/event_target.js | function(type, handler) {
if (!this.listeners_)
return;
if (type in this.listeners_) {
var handlers = this.listeners_[type];
var index = handlers.indexOf(handler);
if (index >= 0) {
// Clean up if this was the last listener.
if (handlers.length == 1)
delete this.listeners_[type];
else
handlers.splice(index, 1);
}
}
} | javascript | function(type, handler) {
if (!this.listeners_)
return;
if (type in this.listeners_) {
var handlers = this.listeners_[type];
var index = handlers.indexOf(handler);
if (index >= 0) {
// Clean up if this was the last listener.
if (handlers.length == 1)
delete this.listeners_[type];
else
handlers.splice(index, 1);
}
}
} | [
"function",
"(",
"type",
",",
"handler",
")",
"{",
"if",
"(",
"!",
"this",
".",
"listeners_",
")",
"return",
";",
"if",
"(",
"type",
"in",
"this",
".",
"listeners_",
")",
"{",
"var",
"handlers",
"=",
"this",
".",
"listeners_",
"[",
"type",
"]",
";",
"var",
"index",
"=",
"handlers",
".",
"indexOf",
"(",
"handler",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"// Clean up if this was the last listener.",
"if",
"(",
"handlers",
".",
"length",
"==",
"1",
")",
"delete",
"this",
".",
"listeners_",
"[",
"type",
"]",
";",
"else",
"handlers",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"}",
"}",
"}"
] | Removes an event listener from the target.
@param {string} type The name of the event.
@param {!Function|{handleEvent:Function}} handler The handler for the
event. | [
"Removes",
"an",
"event",
"listener",
"from",
"the",
"target",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/event_target.js#L61-L75 | |
23,833 | googlearchive/node-big-rig | lib/third_party/tracing/base/event_target.js | function(event) {
if (!this.listeners_)
return true;
// Since we are using DOM Event objects we need to override some of the
// properties and methods so that we can emulate this correctly.
var self = this;
event.__defineGetter__('target', function() {
return self;
});
var realPreventDefault = event.preventDefault;
event.preventDefault = function() {
realPreventDefault.call(this);
this.rawReturnValue = false;
};
var type = event.type;
var prevented = 0;
if (type in this.listeners_) {
// Clone to prevent removal during dispatch
var handlers = this.listeners_[type].concat();
for (var i = 0, handler; handler = handlers[i]; i++) {
if (handler.handleEvent)
prevented |= handler.handleEvent.call(handler, event) === false;
else
prevented |= handler.call(this, event) === false;
}
}
return !prevented && event.rawReturnValue;
} | javascript | function(event) {
if (!this.listeners_)
return true;
// Since we are using DOM Event objects we need to override some of the
// properties and methods so that we can emulate this correctly.
var self = this;
event.__defineGetter__('target', function() {
return self;
});
var realPreventDefault = event.preventDefault;
event.preventDefault = function() {
realPreventDefault.call(this);
this.rawReturnValue = false;
};
var type = event.type;
var prevented = 0;
if (type in this.listeners_) {
// Clone to prevent removal during dispatch
var handlers = this.listeners_[type].concat();
for (var i = 0, handler; handler = handlers[i]; i++) {
if (handler.handleEvent)
prevented |= handler.handleEvent.call(handler, event) === false;
else
prevented |= handler.call(this, event) === false;
}
}
return !prevented && event.rawReturnValue;
} | [
"function",
"(",
"event",
")",
"{",
"if",
"(",
"!",
"this",
".",
"listeners_",
")",
"return",
"true",
";",
"// Since we are using DOM Event objects we need to override some of the",
"// properties and methods so that we can emulate this correctly.",
"var",
"self",
"=",
"this",
";",
"event",
".",
"__defineGetter__",
"(",
"'target'",
",",
"function",
"(",
")",
"{",
"return",
"self",
";",
"}",
")",
";",
"var",
"realPreventDefault",
"=",
"event",
".",
"preventDefault",
";",
"event",
".",
"preventDefault",
"=",
"function",
"(",
")",
"{",
"realPreventDefault",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"rawReturnValue",
"=",
"false",
";",
"}",
";",
"var",
"type",
"=",
"event",
".",
"type",
";",
"var",
"prevented",
"=",
"0",
";",
"if",
"(",
"type",
"in",
"this",
".",
"listeners_",
")",
"{",
"// Clone to prevent removal during dispatch",
"var",
"handlers",
"=",
"this",
".",
"listeners_",
"[",
"type",
"]",
".",
"concat",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"handler",
";",
"handler",
"=",
"handlers",
"[",
"i",
"]",
";",
"i",
"++",
")",
"{",
"if",
"(",
"handler",
".",
"handleEvent",
")",
"prevented",
"|=",
"handler",
".",
"handleEvent",
".",
"call",
"(",
"handler",
",",
"event",
")",
"===",
"false",
";",
"else",
"prevented",
"|=",
"handler",
".",
"call",
"(",
"this",
",",
"event",
")",
"===",
"false",
";",
"}",
"}",
"return",
"!",
"prevented",
"&&",
"event",
".",
"rawReturnValue",
";",
"}"
] | Dispatches an event and calls all the listeners that are listening to
the type of the event.
@param {!cr.event.Event} event The event to dispatch.
@return {boolean} Whether the default action was prevented. If someone
calls preventDefault on the event object then this returns false. | [
"Dispatches",
"an",
"event",
"and",
"calls",
"all",
"the",
"listeners",
"that",
"are",
"listening",
"to",
"the",
"type",
"of",
"the",
"event",
"."
] | 71748aab8ea166726356c6578a6a1c82e314ca33 | https://github.com/googlearchive/node-big-rig/blob/71748aab8ea166726356c6578a6a1c82e314ca33/lib/third_party/tracing/base/event_target.js#L84-L114 | |
23,834 | gaaiatinc/hapi-openid-connect | lib/authorization/index.js | __verify_client_registration_entries | function __verify_client_registration_entries(authorize_request) {
return new Promise(async (resolve, reject) => {
let error_object = {
error: "unauthorized_client",
error_description: ""
};
try {
if (!authorize_request.client_id || !authorize_request.redirect_uri) {
error_object.error_description = "Incorrect client_id/redirect_uri values";
return reject(error_object);
}
let redirect_url = Url.parse(authorize_request.redirect_uri);
if (redirect_url.protocol.toLowerCase() !== "https:") {
error_object.error_description = "Redirect_uri must use the https protocol.";
return reject(error_object);
}
try {
const client_registry = await client_endpoint
.client_registrar_module
.get_client_registration(authorize_request.client_id);
if (!client_registry || (client_registry.redirect_uri_hostname.trim() !== redirect_url.hostname) || (client_registry.redirect_uri_port.trim() !== redirect_url.port)) {
error_object.error_description = "Incorrect client_id/redirect_uri values";
return reject(error_object);
} else {
return resolve();
}
} catch (err) {
return reject(error_object);
}
} catch (err) {
error_object.error_description = "Incorrect client_id/redirect_uri values";
return reject(error_object);
}
});
} | javascript | function __verify_client_registration_entries(authorize_request) {
return new Promise(async (resolve, reject) => {
let error_object = {
error: "unauthorized_client",
error_description: ""
};
try {
if (!authorize_request.client_id || !authorize_request.redirect_uri) {
error_object.error_description = "Incorrect client_id/redirect_uri values";
return reject(error_object);
}
let redirect_url = Url.parse(authorize_request.redirect_uri);
if (redirect_url.protocol.toLowerCase() !== "https:") {
error_object.error_description = "Redirect_uri must use the https protocol.";
return reject(error_object);
}
try {
const client_registry = await client_endpoint
.client_registrar_module
.get_client_registration(authorize_request.client_id);
if (!client_registry || (client_registry.redirect_uri_hostname.trim() !== redirect_url.hostname) || (client_registry.redirect_uri_port.trim() !== redirect_url.port)) {
error_object.error_description = "Incorrect client_id/redirect_uri values";
return reject(error_object);
} else {
return resolve();
}
} catch (err) {
return reject(error_object);
}
} catch (err) {
error_object.error_description = "Incorrect client_id/redirect_uri values";
return reject(error_object);
}
});
} | [
"function",
"__verify_client_registration_entries",
"(",
"authorize_request",
")",
"{",
"return",
"new",
"Promise",
"(",
"async",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"error_object",
"=",
"{",
"error",
":",
"\"unauthorized_client\"",
",",
"error_description",
":",
"\"\"",
"}",
";",
"try",
"{",
"if",
"(",
"!",
"authorize_request",
".",
"client_id",
"||",
"!",
"authorize_request",
".",
"redirect_uri",
")",
"{",
"error_object",
".",
"error_description",
"=",
"\"Incorrect client_id/redirect_uri values\"",
";",
"return",
"reject",
"(",
"error_object",
")",
";",
"}",
"let",
"redirect_url",
"=",
"Url",
".",
"parse",
"(",
"authorize_request",
".",
"redirect_uri",
")",
";",
"if",
"(",
"redirect_url",
".",
"protocol",
".",
"toLowerCase",
"(",
")",
"!==",
"\"https:\"",
")",
"{",
"error_object",
".",
"error_description",
"=",
"\"Redirect_uri must use the https protocol.\"",
";",
"return",
"reject",
"(",
"error_object",
")",
";",
"}",
"try",
"{",
"const",
"client_registry",
"=",
"await",
"client_endpoint",
".",
"client_registrar_module",
".",
"get_client_registration",
"(",
"authorize_request",
".",
"client_id",
")",
";",
"if",
"(",
"!",
"client_registry",
"||",
"(",
"client_registry",
".",
"redirect_uri_hostname",
".",
"trim",
"(",
")",
"!==",
"redirect_url",
".",
"hostname",
")",
"||",
"(",
"client_registry",
".",
"redirect_uri_port",
".",
"trim",
"(",
")",
"!==",
"redirect_url",
".",
"port",
")",
")",
"{",
"error_object",
".",
"error_description",
"=",
"\"Incorrect client_id/redirect_uri values\"",
";",
"return",
"reject",
"(",
"error_object",
")",
";",
"}",
"else",
"{",
"return",
"resolve",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"reject",
"(",
"error_object",
")",
";",
"}",
"}",
"catch",
"(",
"err",
")",
"{",
"error_object",
".",
"error_description",
"=",
"\"Incorrect client_id/redirect_uri values\"",
";",
"return",
"reject",
"(",
"error_object",
")",
";",
"}",
"}",
")",
";",
"}"
] | This method verifies that the client ID and the redirect URI in the request
match the respective ones in the client registry. If the client ID and
redirect URI do not match the ones in the client registry, then no redirect
is sent at all, this is necessary to prevent reflected attacks. In this
case only an error is returned to the user agent without redirects.
@param {[type]} authorize_request [description]
@return {[type]} [description] | [
"This",
"method",
"verifies",
"that",
"the",
"client",
"ID",
"and",
"the",
"redirect",
"URI",
"in",
"the",
"request",
"match",
"the",
"respective",
"ones",
"in",
"the",
"client",
"registry",
".",
"If",
"the",
"client",
"ID",
"and",
"redirect",
"URI",
"do",
"not",
"match",
"the",
"ones",
"in",
"the",
"client",
"registry",
"then",
"no",
"redirect",
"is",
"sent",
"at",
"all",
"this",
"is",
"necessary",
"to",
"prevent",
"reflected",
"attacks",
".",
"In",
"this",
"case",
"only",
"an",
"error",
"is",
"returned",
"to",
"the",
"user",
"agent",
"without",
"redirects",
"."
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/lib/authorization/index.js#L106-L145 |
23,835 | gaaiatinc/hapi-openid-connect | lib/authorization/index.js | __validate_authorization_request | function __validate_authorization_request(authorize_request) {
return new Promise((resolve, reject) => {
let error_object = {
error: "invlalid_request",
error_description: ""
};
if (authorize_request.state) {
error_object.state = authorize_request.state;
}
if (authorize_request.nonce) {
error_object.nonce = authorize_request.nonce;
}
let openid_scope_found = authorize_request
.scope
.split(" ")
.find((element, idx, arr) => {
if (element.trim() === "openid") {
return true;
}
});
if (!openid_scope_found) {
error_object.error = "invalid_scope";
error_object.error_description = "scope must include openid";
return reject(error_object);
}
if ((!authorize_request.response_type) || (authorize_request.response_type.trim() !== "code")) {
error_object.error = "unsupported_response_type";
error_object.error_description = "Only Authorization Code Flow is supported.";
return reject(error_object);
}
return resolve(authorize_request);
});
} | javascript | function __validate_authorization_request(authorize_request) {
return new Promise((resolve, reject) => {
let error_object = {
error: "invlalid_request",
error_description: ""
};
if (authorize_request.state) {
error_object.state = authorize_request.state;
}
if (authorize_request.nonce) {
error_object.nonce = authorize_request.nonce;
}
let openid_scope_found = authorize_request
.scope
.split(" ")
.find((element, idx, arr) => {
if (element.trim() === "openid") {
return true;
}
});
if (!openid_scope_found) {
error_object.error = "invalid_scope";
error_object.error_description = "scope must include openid";
return reject(error_object);
}
if ((!authorize_request.response_type) || (authorize_request.response_type.trim() !== "code")) {
error_object.error = "unsupported_response_type";
error_object.error_description = "Only Authorization Code Flow is supported.";
return reject(error_object);
}
return resolve(authorize_request);
});
} | [
"function",
"__validate_authorization_request",
"(",
"authorize_request",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"let",
"error_object",
"=",
"{",
"error",
":",
"\"invlalid_request\"",
",",
"error_description",
":",
"\"\"",
"}",
";",
"if",
"(",
"authorize_request",
".",
"state",
")",
"{",
"error_object",
".",
"state",
"=",
"authorize_request",
".",
"state",
";",
"}",
"if",
"(",
"authorize_request",
".",
"nonce",
")",
"{",
"error_object",
".",
"nonce",
"=",
"authorize_request",
".",
"nonce",
";",
"}",
"let",
"openid_scope_found",
"=",
"authorize_request",
".",
"scope",
".",
"split",
"(",
"\" \"",
")",
".",
"find",
"(",
"(",
"element",
",",
"idx",
",",
"arr",
")",
"=>",
"{",
"if",
"(",
"element",
".",
"trim",
"(",
")",
"===",
"\"openid\"",
")",
"{",
"return",
"true",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"openid_scope_found",
")",
"{",
"error_object",
".",
"error",
"=",
"\"invalid_scope\"",
";",
"error_object",
".",
"error_description",
"=",
"\"scope must include openid\"",
";",
"return",
"reject",
"(",
"error_object",
")",
";",
"}",
"if",
"(",
"(",
"!",
"authorize_request",
".",
"response_type",
")",
"||",
"(",
"authorize_request",
".",
"response_type",
".",
"trim",
"(",
")",
"!==",
"\"code\"",
")",
")",
"{",
"error_object",
".",
"error",
"=",
"\"unsupported_response_type\"",
";",
"error_object",
".",
"error_description",
"=",
"\"Only Authorization Code Flow is supported.\"",
";",
"return",
"reject",
"(",
"error_object",
")",
";",
"}",
"return",
"resolve",
"(",
"authorize_request",
")",
";",
"}",
")",
";",
"}"
] | Returns an error descriptor object with the error code if validation fails.
@param {[type]} authorize_request
@return {[type]} | [
"Returns",
"an",
"error",
"descriptor",
"object",
"with",
"the",
"error",
"code",
"if",
"validation",
"fails",
"."
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/lib/authorization/index.js#L153-L191 |
23,836 | gaaiatinc/hapi-openid-connect | sample_app/lib/token_registrar_module/index.js | post_token | function post_token(oidc_token) {
return new Promise((resolve, reject) => {
dbMgr
.updateOne("oidc_token", {
id_token: {
$eq: null
}
}, {
$currentDate: {
expire_on: true
},
$set: oidc_token
}, {upsert: true})
.then((result) => {
if (result.upsertedCount === 1) {
return resolve(result.upsertedId._id);
} else {
return reject(new Error("No oidc_token recoreds inserted"));
}
}, (err) => {
reject(err);
});
});
} | javascript | function post_token(oidc_token) {
return new Promise((resolve, reject) => {
dbMgr
.updateOne("oidc_token", {
id_token: {
$eq: null
}
}, {
$currentDate: {
expire_on: true
},
$set: oidc_token
}, {upsert: true})
.then((result) => {
if (result.upsertedCount === 1) {
return resolve(result.upsertedId._id);
} else {
return reject(new Error("No oidc_token recoreds inserted"));
}
}, (err) => {
reject(err);
});
});
} | [
"function",
"post_token",
"(",
"oidc_token",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"dbMgr",
".",
"updateOne",
"(",
"\"oidc_token\"",
",",
"{",
"id_token",
":",
"{",
"$eq",
":",
"null",
"}",
"}",
",",
"{",
"$currentDate",
":",
"{",
"expire_on",
":",
"true",
"}",
",",
"$set",
":",
"oidc_token",
"}",
",",
"{",
"upsert",
":",
"true",
"}",
")",
".",
"then",
"(",
"(",
"result",
")",
"=>",
"{",
"if",
"(",
"result",
".",
"upsertedCount",
"===",
"1",
")",
"{",
"return",
"resolve",
"(",
"result",
".",
"upsertedId",
".",
"_id",
")",
";",
"}",
"else",
"{",
"return",
"reject",
"(",
"new",
"Error",
"(",
"\"No oidc_token recoreds inserted\"",
")",
")",
";",
"}",
"}",
",",
"(",
"err",
")",
"=>",
"{",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | This function must return a promise, which persists the oidc_token
object, and resolve with the ID for the persisted oidc_token. The
ID can be used later to retrieve the persisted oidc_token.
@param oidc_token
@return oidc_token_id | [
"This",
"function",
"must",
"return",
"a",
"promise",
"which",
"persists",
"the",
"oidc_token",
"object",
"and",
"resolve",
"with",
"the",
"ID",
"for",
"the",
"persisted",
"oidc_token",
".",
"The",
"ID",
"can",
"be",
"used",
"later",
"to",
"retrieve",
"the",
"persisted",
"oidc_token",
"."
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/sample_app/lib/token_registrar_module/index.js#L41-L64 |
23,837 | gaaiatinc/hapi-openid-connect | sample_app/lib/authorization_request_registrar_module/index.js | post_authorization_request | function post_authorization_request(authorization_request) {
return new Promise((resolve, reject) => {
dbMgr
.updateOne("authorization_request", {
client_id: {
$eq: null
}
}, {
$set: authorization_request
}, {upsert: true})
.then((result) => {
if (result.upsertedCount === 1) {
return resolve(result.upsertedId._id);
} else {
return reject(new Error("No authorization recoreds inserted"));
}
}, (err) => {
reject(err);
});
});
} | javascript | function post_authorization_request(authorization_request) {
return new Promise((resolve, reject) => {
dbMgr
.updateOne("authorization_request", {
client_id: {
$eq: null
}
}, {
$set: authorization_request
}, {upsert: true})
.then((result) => {
if (result.upsertedCount === 1) {
return resolve(result.upsertedId._id);
} else {
return reject(new Error("No authorization recoreds inserted"));
}
}, (err) => {
reject(err);
});
});
} | [
"function",
"post_authorization_request",
"(",
"authorization_request",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"dbMgr",
".",
"updateOne",
"(",
"\"authorization_request\"",
",",
"{",
"client_id",
":",
"{",
"$eq",
":",
"null",
"}",
"}",
",",
"{",
"$set",
":",
"authorization_request",
"}",
",",
"{",
"upsert",
":",
"true",
"}",
")",
".",
"then",
"(",
"(",
"result",
")",
"=>",
"{",
"if",
"(",
"result",
".",
"upsertedCount",
"===",
"1",
")",
"{",
"return",
"resolve",
"(",
"result",
".",
"upsertedId",
".",
"_id",
")",
";",
"}",
"else",
"{",
"return",
"reject",
"(",
"new",
"Error",
"(",
"\"No authorization recoreds inserted\"",
")",
")",
";",
"}",
"}",
",",
"(",
"err",
")",
"=>",
"{",
"reject",
"(",
"err",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] | This function must return a promise, which persists the authorization_request
object, and resolve with the ID for the persisted authorization_request. The
ID can be used later to retrieve the persisted authorization_request.
@param authorization_request
@return authorization_request_id | [
"This",
"function",
"must",
"return",
"a",
"promise",
"which",
"persists",
"the",
"authorization_request",
"object",
"and",
"resolve",
"with",
"the",
"ID",
"for",
"the",
"persisted",
"authorization_request",
".",
"The",
"ID",
"can",
"be",
"used",
"later",
"to",
"retrieve",
"the",
"persisted",
"authorization_request",
"."
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/sample_app/lib/authorization_request_registrar_module/index.js#L41-L61 |
23,838 | gaaiatinc/hapi-openid-connect | sample_app/lib/authorization_request_registrar_module/index.js | get_authorization_request | function get_authorization_request(authorization_request_id) {
return new Promise((resolve, reject) => {
dbMgr
.find("authorization_request", {
_id: {
$eq: authorization_request_id
}
}, {limit: 1})
.then((authorize_requests) => {
if (authorize_requests.length > 0) {
return resolve(authorize_requests[0]);
} else {
return reject(new Error("No authorization request records found!"));
}
}, reject);
});
} | javascript | function get_authorization_request(authorization_request_id) {
return new Promise((resolve, reject) => {
dbMgr
.find("authorization_request", {
_id: {
$eq: authorization_request_id
}
}, {limit: 1})
.then((authorize_requests) => {
if (authorize_requests.length > 0) {
return resolve(authorize_requests[0]);
} else {
return reject(new Error("No authorization request records found!"));
}
}, reject);
});
} | [
"function",
"get_authorization_request",
"(",
"authorization_request_id",
")",
"{",
"return",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"dbMgr",
".",
"find",
"(",
"\"authorization_request\"",
",",
"{",
"_id",
":",
"{",
"$eq",
":",
"authorization_request_id",
"}",
"}",
",",
"{",
"limit",
":",
"1",
"}",
")",
".",
"then",
"(",
"(",
"authorize_requests",
")",
"=>",
"{",
"if",
"(",
"authorize_requests",
".",
"length",
">",
"0",
")",
"{",
"return",
"resolve",
"(",
"authorize_requests",
"[",
"0",
"]",
")",
";",
"}",
"else",
"{",
"return",
"reject",
"(",
"new",
"Error",
"(",
"\"No authorization request records found!\"",
")",
")",
";",
"}",
"}",
",",
"reject",
")",
";",
"}",
")",
";",
"}"
] | This function must return a promise, which resolves with the
authorization_request associated with the authorization_request_id argument.
Also, the implementation must check for the time the respective
authorization_request was granted, and reject the promise if the persisted
and/or granted authorizeRequest is older than some configurable duration.
@param authorization_request_id: the authorization_code is used as the id
in this implementation.
@return {[object]} | [
"This",
"function",
"must",
"return",
"a",
"promise",
"which",
"resolves",
"with",
"the",
"authorization_request",
"associated",
"with",
"the",
"authorization_request_id",
"argument",
"."
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/sample_app/lib/authorization_request_registrar_module/index.js#L106-L122 |
23,839 | gaaiatinc/hapi-openid-connect | lib/token/index.js | __send_token_for_authorization_code | async function __send_token_for_authorization_code(request_params, request, h) {
function __process_authorization_code(request_params) {
return authorization_endpoint
.authorization_request_registrar_module
.get_authorization_request(request_params.code);
}
try {
const authorization_request_record = await promiseSequencer([
__process_authorization_header_for_client, __process_authorization_code
], request_params);
if (authorization_request_record.granted) {
if ((authorization_request_record.client_id === request_params.client_id) && (authorization_request_record.redirect_uri === request_params.redirect_uri)) {
//send token for authorization_code grant_type
let oidc_claims = {
audience: [authorization_request_record.client_id],
subject: authorization_request_record.subject
};
if (authorization_request_record.nonce) {
oidc_claims.nonce = authorization_request_record.nonce;
}
return __send_oidc_token(request, h, oidc_claims, token_endpoint.authorization_code_grant_type.token_duration_seconds);
}
}
/**
* if we get here, then either the authorization_code has expired,
* invalid, or used already
*/
return h
.response({"error": "access_denied", "error_description": "Invalid, denied, or expired authorization code"})
.type("application/json")
.code(401);
} catch (err) {
return h
.response({"error": "access_denied", "error_description": "Invalid, denied, expired authorization code, or incorrect Basic authorization header"})
.type("application/json")
.code(401);
}
} | javascript | async function __send_token_for_authorization_code(request_params, request, h) {
function __process_authorization_code(request_params) {
return authorization_endpoint
.authorization_request_registrar_module
.get_authorization_request(request_params.code);
}
try {
const authorization_request_record = await promiseSequencer([
__process_authorization_header_for_client, __process_authorization_code
], request_params);
if (authorization_request_record.granted) {
if ((authorization_request_record.client_id === request_params.client_id) && (authorization_request_record.redirect_uri === request_params.redirect_uri)) {
//send token for authorization_code grant_type
let oidc_claims = {
audience: [authorization_request_record.client_id],
subject: authorization_request_record.subject
};
if (authorization_request_record.nonce) {
oidc_claims.nonce = authorization_request_record.nonce;
}
return __send_oidc_token(request, h, oidc_claims, token_endpoint.authorization_code_grant_type.token_duration_seconds);
}
}
/**
* if we get here, then either the authorization_code has expired,
* invalid, or used already
*/
return h
.response({"error": "access_denied", "error_description": "Invalid, denied, or expired authorization code"})
.type("application/json")
.code(401);
} catch (err) {
return h
.response({"error": "access_denied", "error_description": "Invalid, denied, expired authorization code, or incorrect Basic authorization header"})
.type("application/json")
.code(401);
}
} | [
"async",
"function",
"__send_token_for_authorization_code",
"(",
"request_params",
",",
"request",
",",
"h",
")",
"{",
"function",
"__process_authorization_code",
"(",
"request_params",
")",
"{",
"return",
"authorization_endpoint",
".",
"authorization_request_registrar_module",
".",
"get_authorization_request",
"(",
"request_params",
".",
"code",
")",
";",
"}",
"try",
"{",
"const",
"authorization_request_record",
"=",
"await",
"promiseSequencer",
"(",
"[",
"__process_authorization_header_for_client",
",",
"__process_authorization_code",
"]",
",",
"request_params",
")",
";",
"if",
"(",
"authorization_request_record",
".",
"granted",
")",
"{",
"if",
"(",
"(",
"authorization_request_record",
".",
"client_id",
"===",
"request_params",
".",
"client_id",
")",
"&&",
"(",
"authorization_request_record",
".",
"redirect_uri",
"===",
"request_params",
".",
"redirect_uri",
")",
")",
"{",
"//send token for authorization_code grant_type",
"let",
"oidc_claims",
"=",
"{",
"audience",
":",
"[",
"authorization_request_record",
".",
"client_id",
"]",
",",
"subject",
":",
"authorization_request_record",
".",
"subject",
"}",
";",
"if",
"(",
"authorization_request_record",
".",
"nonce",
")",
"{",
"oidc_claims",
".",
"nonce",
"=",
"authorization_request_record",
".",
"nonce",
";",
"}",
"return",
"__send_oidc_token",
"(",
"request",
",",
"h",
",",
"oidc_claims",
",",
"token_endpoint",
".",
"authorization_code_grant_type",
".",
"token_duration_seconds",
")",
";",
"}",
"}",
"/**\n * if we get here, then either the authorization_code has expired,\n * invalid, or used already\n */",
"return",
"h",
".",
"response",
"(",
"{",
"\"error\"",
":",
"\"access_denied\"",
",",
"\"error_description\"",
":",
"\"Invalid, denied, or expired authorization code\"",
"}",
")",
".",
"type",
"(",
"\"application/json\"",
")",
".",
"code",
"(",
"401",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"h",
".",
"response",
"(",
"{",
"\"error\"",
":",
"\"access_denied\"",
",",
"\"error_description\"",
":",
"\"Invalid, denied, expired authorization code, or incorrect Basic authorization header\"",
"}",
")",
".",
"type",
"(",
"\"application/json\"",
")",
".",
"code",
"(",
"401",
")",
";",
"}",
"}"
] | 5.1. Successful Response
The authorization server issues an access token and optional refresh
token, and constructs the response by adding the following parameters
to the entity-body of the HTTP response with a 200 (OK) status code:
access_token
REQUIRED. The access token issued by the authorization server.
token_type
REQUIRED. The type of the token issued as described in
Section 7.1. Value is case insensitive.
expires_in
RECOMMENDED. The lifetime in seconds of the access token. For
example, the value "3600" denotes that the access token will
expire in one hour from the time the response was generated.
If omitted, the authorization server SHOULD provide the
expiration time via other means or document the default value.
Hardt Standards Track [Page 43]
RFC 6749 OAuth 2.0 October 2012
refresh_token
OPTIONAL. The refresh token, which can be used to obtain new
access tokens using the same authorization grant as described
in Section 6.
scope
OPTIONAL, if identical to the scope requested by the client;
otherwise, REQUIRED. The scope of the access token as
described by Section 3.3.
response:
{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"token_type":"example",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
"example_parameter":"example_value"
}
@param {[type]} request_params [description]
@return {[type]} [description] | [
"5",
".",
"1",
".",
"Successful",
"Response"
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/lib/token/index.js#L245-L289 |
23,840 | gaaiatinc/hapi-openid-connect | lib/token/index.js | __process_authorization_header_for_client | function __process_authorization_header_for_client(request_params) {
return new Promise(async (resolve, reject) => {
try {
const client_account_id = await client_endpoint
.client_registrar_module
.get_client_account_id_for_credentials(request_params.authorization_credentials.username, request_params.authorization_credentials.password);
return resolve(request_params);
} catch (err) {
return reject(new Error("Unauthorized request"));
}
});
} | javascript | function __process_authorization_header_for_client(request_params) {
return new Promise(async (resolve, reject) => {
try {
const client_account_id = await client_endpoint
.client_registrar_module
.get_client_account_id_for_credentials(request_params.authorization_credentials.username, request_params.authorization_credentials.password);
return resolve(request_params);
} catch (err) {
return reject(new Error("Unauthorized request"));
}
});
} | [
"function",
"__process_authorization_header_for_client",
"(",
"request_params",
")",
"{",
"return",
"new",
"Promise",
"(",
"async",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"try",
"{",
"const",
"client_account_id",
"=",
"await",
"client_endpoint",
".",
"client_registrar_module",
".",
"get_client_account_id_for_credentials",
"(",
"request_params",
".",
"authorization_credentials",
".",
"username",
",",
"request_params",
".",
"authorization_credentials",
".",
"password",
")",
";",
"return",
"resolve",
"(",
"request_params",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"reject",
"(",
"new",
"Error",
"(",
"\"Unauthorized request\"",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] | The authorization header credentials will be checked with the clien_registrar.
@param {[type]} request_params [description]
@return {[type]} [description] | [
"The",
"authorization",
"header",
"credentials",
"will",
"be",
"checked",
"with",
"the",
"clien_registrar",
"."
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/lib/token/index.js#L309-L321 |
23,841 | gaaiatinc/hapi-openid-connect | lib/token/index.js | __process_authorization_header_for_user | function __process_authorization_header_for_user(request_params) {
return new Promise(async (resolve, reject) => {
try {
const user_account_id = await user_info_endpoint
.user_account_registrar_module
.get_user_account_id_for_credentials(request_params.authorization_credentials.username, request_params.authorization_credentials.password);
return resolve(request_params);
} catch (err) {
return reject(err);
}
});
} | javascript | function __process_authorization_header_for_user(request_params) {
return new Promise(async (resolve, reject) => {
try {
const user_account_id = await user_info_endpoint
.user_account_registrar_module
.get_user_account_id_for_credentials(request_params.authorization_credentials.username, request_params.authorization_credentials.password);
return resolve(request_params);
} catch (err) {
return reject(err);
}
});
} | [
"function",
"__process_authorization_header_for_user",
"(",
"request_params",
")",
"{",
"return",
"new",
"Promise",
"(",
"async",
"(",
"resolve",
",",
"reject",
")",
"=>",
"{",
"try",
"{",
"const",
"user_account_id",
"=",
"await",
"user_info_endpoint",
".",
"user_account_registrar_module",
".",
"get_user_account_id_for_credentials",
"(",
"request_params",
".",
"authorization_credentials",
".",
"username",
",",
"request_params",
".",
"authorization_credentials",
".",
"password",
")",
";",
"return",
"resolve",
"(",
"request_params",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"return",
"reject",
"(",
"err",
")",
";",
"}",
"}",
")",
";",
"}"
] | The credentials will be checked with the user_registrar.
If no user account matches the credentials, then, the
request is denied.
@param {[type]} request_params [description]
@return {[type]} [description] | [
"The",
"credentials",
"will",
"be",
"checked",
"with",
"the",
"user_registrar",
"."
] | 3f4752323f4043e12311d4a9adb673e1f6952223 | https://github.com/gaaiatinc/hapi-openid-connect/blob/3f4752323f4043e12311d4a9adb673e1f6952223/lib/token/index.js#L332-L343 |
23,842 | reindexio/reindex-js | src/ReindexRelayNetworkLayer.js | formatRequestErrors | function formatRequestErrors(request, errors) {
const CONTEXT_BEFORE = 20;
const CONTEXT_LENGTH = 60;
const queryLines = request.getQueryString().split('\n');
return errors.map(({locations = [], message}, ii) => {
const prefix = (ii + 1) + '. ';
const indent = ' '.repeat(prefix.length);
return (
prefix + message + '\n' +
locations.map(({column, line}) => {
const queryLine = queryLines[line - 1];
const offset = Math.min(column - 1, CONTEXT_BEFORE);
return [
queryLine.substr(column - 1 - offset, CONTEXT_LENGTH),
' '.repeat(offset) + '^^^',
].map(messageLine => indent + messageLine).join('\n');
}).join('\n')
);
}).join('\n');
} | javascript | function formatRequestErrors(request, errors) {
const CONTEXT_BEFORE = 20;
const CONTEXT_LENGTH = 60;
const queryLines = request.getQueryString().split('\n');
return errors.map(({locations = [], message}, ii) => {
const prefix = (ii + 1) + '. ';
const indent = ' '.repeat(prefix.length);
return (
prefix + message + '\n' +
locations.map(({column, line}) => {
const queryLine = queryLines[line - 1];
const offset = Math.min(column - 1, CONTEXT_BEFORE);
return [
queryLine.substr(column - 1 - offset, CONTEXT_LENGTH),
' '.repeat(offset) + '^^^',
].map(messageLine => indent + messageLine).join('\n');
}).join('\n')
);
}).join('\n');
} | [
"function",
"formatRequestErrors",
"(",
"request",
",",
"errors",
")",
"{",
"const",
"CONTEXT_BEFORE",
"=",
"20",
";",
"const",
"CONTEXT_LENGTH",
"=",
"60",
";",
"const",
"queryLines",
"=",
"request",
".",
"getQueryString",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
";",
"return",
"errors",
".",
"map",
"(",
"(",
"{",
"locations",
"=",
"[",
"]",
",",
"message",
"}",
",",
"ii",
")",
"=>",
"{",
"const",
"prefix",
"=",
"(",
"ii",
"+",
"1",
")",
"+",
"'. '",
";",
"const",
"indent",
"=",
"' '",
".",
"repeat",
"(",
"prefix",
".",
"length",
")",
";",
"return",
"(",
"prefix",
"+",
"message",
"+",
"'\\n'",
"+",
"locations",
".",
"map",
"(",
"(",
"{",
"column",
",",
"line",
"}",
")",
"=>",
"{",
"const",
"queryLine",
"=",
"queryLines",
"[",
"line",
"-",
"1",
"]",
";",
"const",
"offset",
"=",
"Math",
".",
"min",
"(",
"column",
"-",
"1",
",",
"CONTEXT_BEFORE",
")",
";",
"return",
"[",
"queryLine",
".",
"substr",
"(",
"column",
"-",
"1",
"-",
"offset",
",",
"CONTEXT_LENGTH",
")",
",",
"' '",
".",
"repeat",
"(",
"offset",
")",
"+",
"'^^^'",
",",
"]",
".",
"map",
"(",
"messageLine",
"=>",
"indent",
"+",
"messageLine",
")",
".",
"join",
"(",
"'\\n'",
")",
";",
"}",
")",
".",
"join",
"(",
"'\\n'",
")",
")",
";",
"}",
")",
".",
"join",
"(",
"'\\n'",
")",
";",
"}"
] | Formats an error response from GraphQL server request. | [
"Formats",
"an",
"error",
"response",
"from",
"GraphQL",
"server",
"request",
"."
] | aa33c9d45239be6e0924aa495844e1d3026eae15 | https://github.com/reindexio/reindex-js/blob/aa33c9d45239be6e0924aa495844e1d3026eae15/src/ReindexRelayNetworkLayer.js#L139-L159 |
23,843 | pillarsjs/pillars | middleware/bodyReader.js | jsonEncoded | function jsonEncoded(gw, callback){
var buffer = '';
var readlength = 0;
var $error = false;
gw.req.on('data', function (chunk) {
if (readlength > gw.content.length){$error = true;}
if (!$error) {
readlength += chunk.length;
buffer += chunk.toString('ascii');
}
});
gw.req.on('end', function () {
if ($error) {
gw.error(400);
} else {
try {
var params = JSON.parse(buffer);
gw.content.params = params;
for(var i=0,k=Object.keys(params),l=k.length;i<l;i++){
gw.params[k[i]]=params[k[i]];
}
callback();
} catch (error) {
gw.error(400);
}
}
});
} | javascript | function jsonEncoded(gw, callback){
var buffer = '';
var readlength = 0;
var $error = false;
gw.req.on('data', function (chunk) {
if (readlength > gw.content.length){$error = true;}
if (!$error) {
readlength += chunk.length;
buffer += chunk.toString('ascii');
}
});
gw.req.on('end', function () {
if ($error) {
gw.error(400);
} else {
try {
var params = JSON.parse(buffer);
gw.content.params = params;
for(var i=0,k=Object.keys(params),l=k.length;i<l;i++){
gw.params[k[i]]=params[k[i]];
}
callback();
} catch (error) {
gw.error(400);
}
}
});
} | [
"function",
"jsonEncoded",
"(",
"gw",
",",
"callback",
")",
"{",
"var",
"buffer",
"=",
"''",
";",
"var",
"readlength",
"=",
"0",
";",
"var",
"$error",
"=",
"false",
";",
"gw",
".",
"req",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"if",
"(",
"readlength",
">",
"gw",
".",
"content",
".",
"length",
")",
"{",
"$error",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"$error",
")",
"{",
"readlength",
"+=",
"chunk",
".",
"length",
";",
"buffer",
"+=",
"chunk",
".",
"toString",
"(",
"'ascii'",
")",
";",
"}",
"}",
")",
";",
"gw",
".",
"req",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"$error",
")",
"{",
"gw",
".",
"error",
"(",
"400",
")",
";",
"}",
"else",
"{",
"try",
"{",
"var",
"params",
"=",
"JSON",
".",
"parse",
"(",
"buffer",
")",
";",
"gw",
".",
"content",
".",
"params",
"=",
"params",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"k",
"=",
"Object",
".",
"keys",
"(",
"params",
")",
",",
"l",
"=",
"k",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"gw",
".",
"params",
"[",
"k",
"[",
"i",
"]",
"]",
"=",
"params",
"[",
"k",
"[",
"i",
"]",
"]",
";",
"}",
"callback",
"(",
")",
";",
"}",
"catch",
"(",
"error",
")",
"{",
"gw",
".",
"error",
"(",
"400",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | JSON-encoded parser. | [
"JSON",
"-",
"encoded",
"parser",
"."
] | 7702fd42d3c07fd0e5605a377b1b51c88d0bdd58 | https://github.com/pillarsjs/pillars/blob/7702fd42d3c07fd0e5605a377b1b51c88d0bdd58/middleware/bodyReader.js#L61-L88 |
23,844 | pillarsjs/pillars | middleware/bodyReader.js | urlEncoded | function urlEncoded(gw, callback){
var buffer = '';
var readlength = 0;
var $error = false;
gw.req.on('data', function (chunk) {
if (readlength > gw.content.length) {$error = true;}
if (!$error) {
readlength += chunk.length;
buffer += chunk.toString('ascii');
}
});
gw.req.on('end', function () {
if ($error) {
gw.error(400);
} else {
var params = gw.constructor.queryHeap(querystring.parse(buffer, '&', '='));
gw.content.params = params;
for(var i=0,k=Object.keys(params),l=k.length;i<l;i++){
gw.params[k[i]]=params[k[i]];
}
callback();
}
});
} | javascript | function urlEncoded(gw, callback){
var buffer = '';
var readlength = 0;
var $error = false;
gw.req.on('data', function (chunk) {
if (readlength > gw.content.length) {$error = true;}
if (!$error) {
readlength += chunk.length;
buffer += chunk.toString('ascii');
}
});
gw.req.on('end', function () {
if ($error) {
gw.error(400);
} else {
var params = gw.constructor.queryHeap(querystring.parse(buffer, '&', '='));
gw.content.params = params;
for(var i=0,k=Object.keys(params),l=k.length;i<l;i++){
gw.params[k[i]]=params[k[i]];
}
callback();
}
});
} | [
"function",
"urlEncoded",
"(",
"gw",
",",
"callback",
")",
"{",
"var",
"buffer",
"=",
"''",
";",
"var",
"readlength",
"=",
"0",
";",
"var",
"$error",
"=",
"false",
";",
"gw",
".",
"req",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"if",
"(",
"readlength",
">",
"gw",
".",
"content",
".",
"length",
")",
"{",
"$error",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"$error",
")",
"{",
"readlength",
"+=",
"chunk",
".",
"length",
";",
"buffer",
"+=",
"chunk",
".",
"toString",
"(",
"'ascii'",
")",
";",
"}",
"}",
")",
";",
"gw",
".",
"req",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"if",
"(",
"$error",
")",
"{",
"gw",
".",
"error",
"(",
"400",
")",
";",
"}",
"else",
"{",
"var",
"params",
"=",
"gw",
".",
"constructor",
".",
"queryHeap",
"(",
"querystring",
".",
"parse",
"(",
"buffer",
",",
"'&'",
",",
"'='",
")",
")",
";",
"gw",
".",
"content",
".",
"params",
"=",
"params",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"k",
"=",
"Object",
".",
"keys",
"(",
"params",
")",
",",
"l",
"=",
"k",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"gw",
".",
"params",
"[",
"k",
"[",
"i",
"]",
"]",
"=",
"params",
"[",
"k",
"[",
"i",
"]",
"]",
";",
"}",
"callback",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] | url-enconded parser. | [
"url",
"-",
"enconded",
"parser",
"."
] | 7702fd42d3c07fd0e5605a377b1b51c88d0bdd58 | https://github.com/pillarsjs/pillars/blob/7702fd42d3c07fd0e5605a377b1b51c88d0bdd58/middleware/bodyReader.js#L92-L115 |
23,845 | pillarsjs/pillars | middleware/bodyReader.js | multipartEncoded | function multipartEncoded(gw, callback){
var upload = new formidable.IncomingForm();
var files = {};
var fields = {};
gw.eventium.on('end',cleanTemp);
upload.uploadDir = tempDirectory;
upload.keepExtensions = true;
upload.onPart = function(part) {
if (part.filename!="") {
upload.handlePart(part);
}
}
upload
.on('progress', function(bytesReceived, bytesExpected) {
var percent_complete = (bytesReceived / bytesExpected) * 100;
})
.on('error', function (error) {gw.error(500,error);})
.on('field', function (field, value) {
if (fields[field]) {
if (!Array.isArray(fields[field])) {fields[field]=[fields[field]];}
fields[field].push(value);
} else {
fields[field]=value;
}
})
.on('file', function(field, file) {
file.ext = file.name.replace(/^.*\./,'');
if (fields[field]) {
if(!Array.isArray(fields[field])){fields[field]=[fields[field]];}
fields[field].push(file);
} else {
fields[field]=file;
}
if (files[field]) {
if (!Array.isArray(files[field])) {files[field]=[files[field]];}
files[field].push(file);
} else {
files[field]=file;
}
})
.on('end', function() {
fields = gw.constructor.queryHeap(fields);
gw.content.params = fields;
for(var i=0,k=Object.keys(fields),l=k.length;i<l;i++){
gw.params[k[i]]=fields[k[i]];
}
gw.files = files;
callback();
})
;
upload.parse(gw.req);
} | javascript | function multipartEncoded(gw, callback){
var upload = new formidable.IncomingForm();
var files = {};
var fields = {};
gw.eventium.on('end',cleanTemp);
upload.uploadDir = tempDirectory;
upload.keepExtensions = true;
upload.onPart = function(part) {
if (part.filename!="") {
upload.handlePart(part);
}
}
upload
.on('progress', function(bytesReceived, bytesExpected) {
var percent_complete = (bytesReceived / bytesExpected) * 100;
})
.on('error', function (error) {gw.error(500,error);})
.on('field', function (field, value) {
if (fields[field]) {
if (!Array.isArray(fields[field])) {fields[field]=[fields[field]];}
fields[field].push(value);
} else {
fields[field]=value;
}
})
.on('file', function(field, file) {
file.ext = file.name.replace(/^.*\./,'');
if (fields[field]) {
if(!Array.isArray(fields[field])){fields[field]=[fields[field]];}
fields[field].push(file);
} else {
fields[field]=file;
}
if (files[field]) {
if (!Array.isArray(files[field])) {files[field]=[files[field]];}
files[field].push(file);
} else {
files[field]=file;
}
})
.on('end', function() {
fields = gw.constructor.queryHeap(fields);
gw.content.params = fields;
for(var i=0,k=Object.keys(fields),l=k.length;i<l;i++){
gw.params[k[i]]=fields[k[i]];
}
gw.files = files;
callback();
})
;
upload.parse(gw.req);
} | [
"function",
"multipartEncoded",
"(",
"gw",
",",
"callback",
")",
"{",
"var",
"upload",
"=",
"new",
"formidable",
".",
"IncomingForm",
"(",
")",
";",
"var",
"files",
"=",
"{",
"}",
";",
"var",
"fields",
"=",
"{",
"}",
";",
"gw",
".",
"eventium",
".",
"on",
"(",
"'end'",
",",
"cleanTemp",
")",
";",
"upload",
".",
"uploadDir",
"=",
"tempDirectory",
";",
"upload",
".",
"keepExtensions",
"=",
"true",
";",
"upload",
".",
"onPart",
"=",
"function",
"(",
"part",
")",
"{",
"if",
"(",
"part",
".",
"filename",
"!=",
"\"\"",
")",
"{",
"upload",
".",
"handlePart",
"(",
"part",
")",
";",
"}",
"}",
"upload",
".",
"on",
"(",
"'progress'",
",",
"function",
"(",
"bytesReceived",
",",
"bytesExpected",
")",
"{",
"var",
"percent_complete",
"=",
"(",
"bytesReceived",
"/",
"bytesExpected",
")",
"*",
"100",
";",
"}",
")",
".",
"on",
"(",
"'error'",
",",
"function",
"(",
"error",
")",
"{",
"gw",
".",
"error",
"(",
"500",
",",
"error",
")",
";",
"}",
")",
".",
"on",
"(",
"'field'",
",",
"function",
"(",
"field",
",",
"value",
")",
"{",
"if",
"(",
"fields",
"[",
"field",
"]",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"fields",
"[",
"field",
"]",
")",
")",
"{",
"fields",
"[",
"field",
"]",
"=",
"[",
"fields",
"[",
"field",
"]",
"]",
";",
"}",
"fields",
"[",
"field",
"]",
".",
"push",
"(",
"value",
")",
";",
"}",
"else",
"{",
"fields",
"[",
"field",
"]",
"=",
"value",
";",
"}",
"}",
")",
".",
"on",
"(",
"'file'",
",",
"function",
"(",
"field",
",",
"file",
")",
"{",
"file",
".",
"ext",
"=",
"file",
".",
"name",
".",
"replace",
"(",
"/",
"^.*\\.",
"/",
",",
"''",
")",
";",
"if",
"(",
"fields",
"[",
"field",
"]",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"fields",
"[",
"field",
"]",
")",
")",
"{",
"fields",
"[",
"field",
"]",
"=",
"[",
"fields",
"[",
"field",
"]",
"]",
";",
"}",
"fields",
"[",
"field",
"]",
".",
"push",
"(",
"file",
")",
";",
"}",
"else",
"{",
"fields",
"[",
"field",
"]",
"=",
"file",
";",
"}",
"if",
"(",
"files",
"[",
"field",
"]",
")",
"{",
"if",
"(",
"!",
"Array",
".",
"isArray",
"(",
"files",
"[",
"field",
"]",
")",
")",
"{",
"files",
"[",
"field",
"]",
"=",
"[",
"files",
"[",
"field",
"]",
"]",
";",
"}",
"files",
"[",
"field",
"]",
".",
"push",
"(",
"file",
")",
";",
"}",
"else",
"{",
"files",
"[",
"field",
"]",
"=",
"file",
";",
"}",
"}",
")",
".",
"on",
"(",
"'end'",
",",
"function",
"(",
")",
"{",
"fields",
"=",
"gw",
".",
"constructor",
".",
"queryHeap",
"(",
"fields",
")",
";",
"gw",
".",
"content",
".",
"params",
"=",
"fields",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"k",
"=",
"Object",
".",
"keys",
"(",
"fields",
")",
",",
"l",
"=",
"k",
".",
"length",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"gw",
".",
"params",
"[",
"k",
"[",
"i",
"]",
"]",
"=",
"fields",
"[",
"k",
"[",
"i",
"]",
"]",
";",
"}",
"gw",
".",
"files",
"=",
"files",
";",
"callback",
"(",
")",
";",
"}",
")",
";",
"upload",
".",
"parse",
"(",
"gw",
".",
"req",
")",
";",
"}"
] | Multipart parser. | [
"Multipart",
"parser",
"."
] | 7702fd42d3c07fd0e5605a377b1b51c88d0bdd58 | https://github.com/pillarsjs/pillars/blob/7702fd42d3c07fd0e5605a377b1b51c88d0bdd58/middleware/bodyReader.js#L119-L172 |
23,846 | mikolalysenko/simplicial-complex | topology.js | dimension | function dimension(cells) {
var d = 0
, max = Math.max
for(var i=0, il=cells.length; i<il; ++i) {
d = max(d, cells[i].length)
}
return d-1
} | javascript | function dimension(cells) {
var d = 0
, max = Math.max
for(var i=0, il=cells.length; i<il; ++i) {
d = max(d, cells[i].length)
}
return d-1
} | [
"function",
"dimension",
"(",
"cells",
")",
"{",
"var",
"d",
"=",
"0",
",",
"max",
"=",
"Math",
".",
"max",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"cells",
".",
"length",
";",
"i",
"<",
"il",
";",
"++",
"i",
")",
"{",
"d",
"=",
"max",
"(",
"d",
",",
"cells",
"[",
"i",
"]",
".",
"length",
")",
"}",
"return",
"d",
"-",
"1",
"}"
] | Returns the dimension of a cell complex | [
"Returns",
"the",
"dimension",
"of",
"a",
"cell",
"complex"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L7-L14 |
23,847 | mikolalysenko/simplicial-complex | topology.js | countVertices | function countVertices(cells) {
var vc = -1
, max = Math.max
for(var i=0, il=cells.length; i<il; ++i) {
var c = cells[i]
for(var j=0, jl=c.length; j<jl; ++j) {
vc = max(vc, c[j])
}
}
return vc+1
} | javascript | function countVertices(cells) {
var vc = -1
, max = Math.max
for(var i=0, il=cells.length; i<il; ++i) {
var c = cells[i]
for(var j=0, jl=c.length; j<jl; ++j) {
vc = max(vc, c[j])
}
}
return vc+1
} | [
"function",
"countVertices",
"(",
"cells",
")",
"{",
"var",
"vc",
"=",
"-",
"1",
",",
"max",
"=",
"Math",
".",
"max",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"cells",
".",
"length",
";",
"i",
"<",
"il",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"cells",
"[",
"i",
"]",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"jl",
"=",
"c",
".",
"length",
";",
"j",
"<",
"jl",
";",
"++",
"j",
")",
"{",
"vc",
"=",
"max",
"(",
"vc",
",",
"c",
"[",
"j",
"]",
")",
"}",
"}",
"return",
"vc",
"+",
"1",
"}"
] | Counts the number of vertices in faces | [
"Counts",
"the",
"number",
"of",
"vertices",
"in",
"faces"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L18-L28 |
23,848 | mikolalysenko/simplicial-complex | topology.js | cloneCells | function cloneCells(cells) {
var ncells = new Array(cells.length)
for(var i=0, il=cells.length; i<il; ++i) {
ncells[i] = cells[i].slice(0)
}
return ncells
} | javascript | function cloneCells(cells) {
var ncells = new Array(cells.length)
for(var i=0, il=cells.length; i<il; ++i) {
ncells[i] = cells[i].slice(0)
}
return ncells
} | [
"function",
"cloneCells",
"(",
"cells",
")",
"{",
"var",
"ncells",
"=",
"new",
"Array",
"(",
"cells",
".",
"length",
")",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"cells",
".",
"length",
";",
"i",
"<",
"il",
";",
"++",
"i",
")",
"{",
"ncells",
"[",
"i",
"]",
"=",
"cells",
"[",
"i",
"]",
".",
"slice",
"(",
"0",
")",
"}",
"return",
"ncells",
"}"
] | Returns a deep copy of cells | [
"Returns",
"a",
"deep",
"copy",
"of",
"cells"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L32-L38 |
23,849 | mikolalysenko/simplicial-complex | topology.js | compareCells | function compareCells(a, b) {
var n = a.length
, t = a.length - b.length
, min = Math.min
if(t) {
return t
}
switch(n) {
case 0:
return 0;
case 1:
return a[0] - b[0];
case 2:
var d = a[0]+a[1]-b[0]-b[1]
if(d) {
return d
}
return min(a[0],a[1]) - min(b[0],b[1])
case 3:
var l1 = a[0]+a[1]
, m1 = b[0]+b[1]
d = l1+a[2] - (m1+b[2])
if(d) {
return d
}
var l0 = min(a[0], a[1])
, m0 = min(b[0], b[1])
, d = min(l0, a[2]) - min(m0, b[2])
if(d) {
return d
}
return min(l0+a[2], l1) - min(m0+b[2], m1)
//TODO: Maybe optimize n=4 as well?
default:
var as = a.slice(0)
as.sort()
var bs = b.slice(0)
bs.sort()
for(var i=0; i<n; ++i) {
t = as[i] - bs[i]
if(t) {
return t
}
}
return 0
}
} | javascript | function compareCells(a, b) {
var n = a.length
, t = a.length - b.length
, min = Math.min
if(t) {
return t
}
switch(n) {
case 0:
return 0;
case 1:
return a[0] - b[0];
case 2:
var d = a[0]+a[1]-b[0]-b[1]
if(d) {
return d
}
return min(a[0],a[1]) - min(b[0],b[1])
case 3:
var l1 = a[0]+a[1]
, m1 = b[0]+b[1]
d = l1+a[2] - (m1+b[2])
if(d) {
return d
}
var l0 = min(a[0], a[1])
, m0 = min(b[0], b[1])
, d = min(l0, a[2]) - min(m0, b[2])
if(d) {
return d
}
return min(l0+a[2], l1) - min(m0+b[2], m1)
//TODO: Maybe optimize n=4 as well?
default:
var as = a.slice(0)
as.sort()
var bs = b.slice(0)
bs.sort()
for(var i=0; i<n; ++i) {
t = as[i] - bs[i]
if(t) {
return t
}
}
return 0
}
} | [
"function",
"compareCells",
"(",
"a",
",",
"b",
")",
"{",
"var",
"n",
"=",
"a",
".",
"length",
",",
"t",
"=",
"a",
".",
"length",
"-",
"b",
".",
"length",
",",
"min",
"=",
"Math",
".",
"min",
"if",
"(",
"t",
")",
"{",
"return",
"t",
"}",
"switch",
"(",
"n",
")",
"{",
"case",
"0",
":",
"return",
"0",
";",
"case",
"1",
":",
"return",
"a",
"[",
"0",
"]",
"-",
"b",
"[",
"0",
"]",
";",
"case",
"2",
":",
"var",
"d",
"=",
"a",
"[",
"0",
"]",
"+",
"a",
"[",
"1",
"]",
"-",
"b",
"[",
"0",
"]",
"-",
"b",
"[",
"1",
"]",
"if",
"(",
"d",
")",
"{",
"return",
"d",
"}",
"return",
"min",
"(",
"a",
"[",
"0",
"]",
",",
"a",
"[",
"1",
"]",
")",
"-",
"min",
"(",
"b",
"[",
"0",
"]",
",",
"b",
"[",
"1",
"]",
")",
"case",
"3",
":",
"var",
"l1",
"=",
"a",
"[",
"0",
"]",
"+",
"a",
"[",
"1",
"]",
",",
"m1",
"=",
"b",
"[",
"0",
"]",
"+",
"b",
"[",
"1",
"]",
"d",
"=",
"l1",
"+",
"a",
"[",
"2",
"]",
"-",
"(",
"m1",
"+",
"b",
"[",
"2",
"]",
")",
"if",
"(",
"d",
")",
"{",
"return",
"d",
"}",
"var",
"l0",
"=",
"min",
"(",
"a",
"[",
"0",
"]",
",",
"a",
"[",
"1",
"]",
")",
",",
"m0",
"=",
"min",
"(",
"b",
"[",
"0",
"]",
",",
"b",
"[",
"1",
"]",
")",
",",
"d",
"=",
"min",
"(",
"l0",
",",
"a",
"[",
"2",
"]",
")",
"-",
"min",
"(",
"m0",
",",
"b",
"[",
"2",
"]",
")",
"if",
"(",
"d",
")",
"{",
"return",
"d",
"}",
"return",
"min",
"(",
"l0",
"+",
"a",
"[",
"2",
"]",
",",
"l1",
")",
"-",
"min",
"(",
"m0",
"+",
"b",
"[",
"2",
"]",
",",
"m1",
")",
"//TODO: Maybe optimize n=4 as well?",
"default",
":",
"var",
"as",
"=",
"a",
".",
"slice",
"(",
"0",
")",
"as",
".",
"sort",
"(",
")",
"var",
"bs",
"=",
"b",
".",
"slice",
"(",
"0",
")",
"bs",
".",
"sort",
"(",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"t",
"=",
"as",
"[",
"i",
"]",
"-",
"bs",
"[",
"i",
"]",
"if",
"(",
"t",
")",
"{",
"return",
"t",
"}",
"}",
"return",
"0",
"}",
"}"
] | Ranks a pair of cells up to permutation | [
"Ranks",
"a",
"pair",
"of",
"cells",
"up",
"to",
"permutation"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L42-L90 |
23,850 | mikolalysenko/simplicial-complex | topology.js | normalize | function normalize(cells, attr) {
if(attr) {
var len = cells.length
var zipped = new Array(len)
for(var i=0; i<len; ++i) {
zipped[i] = [cells[i], attr[i]]
}
zipped.sort(compareZipped)
for(var i=0; i<len; ++i) {
cells[i] = zipped[i][0]
attr[i] = zipped[i][1]
}
return cells
} else {
cells.sort(compareCells)
return cells
}
} | javascript | function normalize(cells, attr) {
if(attr) {
var len = cells.length
var zipped = new Array(len)
for(var i=0; i<len; ++i) {
zipped[i] = [cells[i], attr[i]]
}
zipped.sort(compareZipped)
for(var i=0; i<len; ++i) {
cells[i] = zipped[i][0]
attr[i] = zipped[i][1]
}
return cells
} else {
cells.sort(compareCells)
return cells
}
} | [
"function",
"normalize",
"(",
"cells",
",",
"attr",
")",
"{",
"if",
"(",
"attr",
")",
"{",
"var",
"len",
"=",
"cells",
".",
"length",
"var",
"zipped",
"=",
"new",
"Array",
"(",
"len",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"zipped",
"[",
"i",
"]",
"=",
"[",
"cells",
"[",
"i",
"]",
",",
"attr",
"[",
"i",
"]",
"]",
"}",
"zipped",
".",
"sort",
"(",
"compareZipped",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"cells",
"[",
"i",
"]",
"=",
"zipped",
"[",
"i",
"]",
"[",
"0",
"]",
"attr",
"[",
"i",
"]",
"=",
"zipped",
"[",
"i",
"]",
"[",
"1",
"]",
"}",
"return",
"cells",
"}",
"else",
"{",
"cells",
".",
"sort",
"(",
"compareCells",
")",
"return",
"cells",
"}",
"}"
] | Puts a cell complex into normal order for the purposes of findCell queries | [
"Puts",
"a",
"cell",
"complex",
"into",
"normal",
"order",
"for",
"the",
"purposes",
"of",
"findCell",
"queries"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L98-L115 |
23,851 | mikolalysenko/simplicial-complex | topology.js | unique | function unique(cells) {
if(cells.length === 0) {
return []
}
var ptr = 1
, len = cells.length
for(var i=1; i<len; ++i) {
var a = cells[i]
if(compareCells(a, cells[i-1])) {
if(i === ptr) {
ptr++
continue
}
cells[ptr++] = a
}
}
cells.length = ptr
return cells
} | javascript | function unique(cells) {
if(cells.length === 0) {
return []
}
var ptr = 1
, len = cells.length
for(var i=1; i<len; ++i) {
var a = cells[i]
if(compareCells(a, cells[i-1])) {
if(i === ptr) {
ptr++
continue
}
cells[ptr++] = a
}
}
cells.length = ptr
return cells
} | [
"function",
"unique",
"(",
"cells",
")",
"{",
"if",
"(",
"cells",
".",
"length",
"===",
"0",
")",
"{",
"return",
"[",
"]",
"}",
"var",
"ptr",
"=",
"1",
",",
"len",
"=",
"cells",
".",
"length",
"for",
"(",
"var",
"i",
"=",
"1",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"var",
"a",
"=",
"cells",
"[",
"i",
"]",
"if",
"(",
"compareCells",
"(",
"a",
",",
"cells",
"[",
"i",
"-",
"1",
"]",
")",
")",
"{",
"if",
"(",
"i",
"===",
"ptr",
")",
"{",
"ptr",
"++",
"continue",
"}",
"cells",
"[",
"ptr",
"++",
"]",
"=",
"a",
"}",
"}",
"cells",
".",
"length",
"=",
"ptr",
"return",
"cells",
"}"
] | Removes all duplicate cells in the complex | [
"Removes",
"all",
"duplicate",
"cells",
"in",
"the",
"complex"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L119-L137 |
23,852 | mikolalysenko/simplicial-complex | topology.js | findCell | function findCell(cells, c) {
var lo = 0
, hi = cells.length-1
, r = -1
while (lo <= hi) {
var mid = (lo + hi) >> 1
, s = compareCells(cells[mid], c)
if(s <= 0) {
if(s === 0) {
r = mid
}
lo = mid + 1
} else if(s > 0) {
hi = mid - 1
}
}
return r
} | javascript | function findCell(cells, c) {
var lo = 0
, hi = cells.length-1
, r = -1
while (lo <= hi) {
var mid = (lo + hi) >> 1
, s = compareCells(cells[mid], c)
if(s <= 0) {
if(s === 0) {
r = mid
}
lo = mid + 1
} else if(s > 0) {
hi = mid - 1
}
}
return r
} | [
"function",
"findCell",
"(",
"cells",
",",
"c",
")",
"{",
"var",
"lo",
"=",
"0",
",",
"hi",
"=",
"cells",
".",
"length",
"-",
"1",
",",
"r",
"=",
"-",
"1",
"while",
"(",
"lo",
"<=",
"hi",
")",
"{",
"var",
"mid",
"=",
"(",
"lo",
"+",
"hi",
")",
">>",
"1",
",",
"s",
"=",
"compareCells",
"(",
"cells",
"[",
"mid",
"]",
",",
"c",
")",
"if",
"(",
"s",
"<=",
"0",
")",
"{",
"if",
"(",
"s",
"===",
"0",
")",
"{",
"r",
"=",
"mid",
"}",
"lo",
"=",
"mid",
"+",
"1",
"}",
"else",
"if",
"(",
"s",
">",
"0",
")",
"{",
"hi",
"=",
"mid",
"-",
"1",
"}",
"}",
"return",
"r",
"}"
] | Finds a cell in a normalized cell complex | [
"Finds",
"a",
"cell",
"in",
"a",
"normalized",
"cell",
"complex"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L141-L158 |
23,853 | mikolalysenko/simplicial-complex | topology.js | incidence | function incidence(from_cells, to_cells) {
var index = new Array(from_cells.length)
for(var i=0, il=index.length; i<il; ++i) {
index[i] = []
}
var b = []
for(var i=0, n=to_cells.length; i<n; ++i) {
var c = to_cells[i]
var cl = c.length
for(var k=1, kn=(1<<cl); k<kn; ++k) {
b.length = bits.popCount(k)
var l = 0
for(var j=0; j<cl; ++j) {
if(k & (1<<j)) {
b[l++] = c[j]
}
}
var idx=findCell(from_cells, b)
if(idx < 0) {
continue
}
while(true) {
index[idx++].push(i)
if(idx >= from_cells.length || compareCells(from_cells[idx], b) !== 0) {
break
}
}
}
}
return index
} | javascript | function incidence(from_cells, to_cells) {
var index = new Array(from_cells.length)
for(var i=0, il=index.length; i<il; ++i) {
index[i] = []
}
var b = []
for(var i=0, n=to_cells.length; i<n; ++i) {
var c = to_cells[i]
var cl = c.length
for(var k=1, kn=(1<<cl); k<kn; ++k) {
b.length = bits.popCount(k)
var l = 0
for(var j=0; j<cl; ++j) {
if(k & (1<<j)) {
b[l++] = c[j]
}
}
var idx=findCell(from_cells, b)
if(idx < 0) {
continue
}
while(true) {
index[idx++].push(i)
if(idx >= from_cells.length || compareCells(from_cells[idx], b) !== 0) {
break
}
}
}
}
return index
} | [
"function",
"incidence",
"(",
"from_cells",
",",
"to_cells",
")",
"{",
"var",
"index",
"=",
"new",
"Array",
"(",
"from_cells",
".",
"length",
")",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"index",
".",
"length",
";",
"i",
"<",
"il",
";",
"++",
"i",
")",
"{",
"index",
"[",
"i",
"]",
"=",
"[",
"]",
"}",
"var",
"b",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"n",
"=",
"to_cells",
".",
"length",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"to_cells",
"[",
"i",
"]",
"var",
"cl",
"=",
"c",
".",
"length",
"for",
"(",
"var",
"k",
"=",
"1",
",",
"kn",
"=",
"(",
"1",
"<<",
"cl",
")",
";",
"k",
"<",
"kn",
";",
"++",
"k",
")",
"{",
"b",
".",
"length",
"=",
"bits",
".",
"popCount",
"(",
"k",
")",
"var",
"l",
"=",
"0",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"cl",
";",
"++",
"j",
")",
"{",
"if",
"(",
"k",
"&",
"(",
"1",
"<<",
"j",
")",
")",
"{",
"b",
"[",
"l",
"++",
"]",
"=",
"c",
"[",
"j",
"]",
"}",
"}",
"var",
"idx",
"=",
"findCell",
"(",
"from_cells",
",",
"b",
")",
"if",
"(",
"idx",
"<",
"0",
")",
"{",
"continue",
"}",
"while",
"(",
"true",
")",
"{",
"index",
"[",
"idx",
"++",
"]",
".",
"push",
"(",
"i",
")",
"if",
"(",
"idx",
">=",
"from_cells",
".",
"length",
"||",
"compareCells",
"(",
"from_cells",
"[",
"idx",
"]",
",",
"b",
")",
"!==",
"0",
")",
"{",
"break",
"}",
"}",
"}",
"}",
"return",
"index",
"}"
] | Builds an index for an n-cell. This is more general than dual, but less efficient | [
"Builds",
"an",
"index",
"for",
"an",
"n",
"-",
"cell",
".",
"This",
"is",
"more",
"general",
"than",
"dual",
"but",
"less",
"efficient"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L162-L192 |
23,854 | mikolalysenko/simplicial-complex | topology.js | dual | function dual(cells, vertex_count) {
if(!vertex_count) {
return incidence(unique(skeleton(cells, 0)), cells, 0)
}
var res = new Array(vertex_count)
for(var i=0; i<vertex_count; ++i) {
res[i] = []
}
for(var i=0, len=cells.length; i<len; ++i) {
var c = cells[i]
for(var j=0, cl=c.length; j<cl; ++j) {
res[c[j]].push(i)
}
}
return res
} | javascript | function dual(cells, vertex_count) {
if(!vertex_count) {
return incidence(unique(skeleton(cells, 0)), cells, 0)
}
var res = new Array(vertex_count)
for(var i=0; i<vertex_count; ++i) {
res[i] = []
}
for(var i=0, len=cells.length; i<len; ++i) {
var c = cells[i]
for(var j=0, cl=c.length; j<cl; ++j) {
res[c[j]].push(i)
}
}
return res
} | [
"function",
"dual",
"(",
"cells",
",",
"vertex_count",
")",
"{",
"if",
"(",
"!",
"vertex_count",
")",
"{",
"return",
"incidence",
"(",
"unique",
"(",
"skeleton",
"(",
"cells",
",",
"0",
")",
")",
",",
"cells",
",",
"0",
")",
"}",
"var",
"res",
"=",
"new",
"Array",
"(",
"vertex_count",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"vertex_count",
";",
"++",
"i",
")",
"{",
"res",
"[",
"i",
"]",
"=",
"[",
"]",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"cells",
".",
"length",
";",
"i",
"<",
"len",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"cells",
"[",
"i",
"]",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"cl",
"=",
"c",
".",
"length",
";",
"j",
"<",
"cl",
";",
"++",
"j",
")",
"{",
"res",
"[",
"c",
"[",
"j",
"]",
"]",
".",
"push",
"(",
"i",
")",
"}",
"}",
"return",
"res",
"}"
] | Computes the dual of the mesh. This is basically an optimized version of buildIndex for the situation where from_cells is just the list of vertices | [
"Computes",
"the",
"dual",
"of",
"the",
"mesh",
".",
"This",
"is",
"basically",
"an",
"optimized",
"version",
"of",
"buildIndex",
"for",
"the",
"situation",
"where",
"from_cells",
"is",
"just",
"the",
"list",
"of",
"vertices"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L196-L211 |
23,855 | mikolalysenko/simplicial-complex | topology.js | explode | function explode(cells) {
var result = []
for(var i=0, il=cells.length; i<il; ++i) {
var c = cells[i]
, cl = c.length|0
for(var j=1, jl=(1<<cl); j<jl; ++j) {
var b = []
for(var k=0; k<cl; ++k) {
if((j >>> k) & 1) {
b.push(c[k])
}
}
result.push(b)
}
}
return normalize(result)
} | javascript | function explode(cells) {
var result = []
for(var i=0, il=cells.length; i<il; ++i) {
var c = cells[i]
, cl = c.length|0
for(var j=1, jl=(1<<cl); j<jl; ++j) {
var b = []
for(var k=0; k<cl; ++k) {
if((j >>> k) & 1) {
b.push(c[k])
}
}
result.push(b)
}
}
return normalize(result)
} | [
"function",
"explode",
"(",
"cells",
")",
"{",
"var",
"result",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"cells",
".",
"length",
";",
"i",
"<",
"il",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"cells",
"[",
"i",
"]",
",",
"cl",
"=",
"c",
".",
"length",
"|",
"0",
"for",
"(",
"var",
"j",
"=",
"1",
",",
"jl",
"=",
"(",
"1",
"<<",
"cl",
")",
";",
"j",
"<",
"jl",
";",
"++",
"j",
")",
"{",
"var",
"b",
"=",
"[",
"]",
"for",
"(",
"var",
"k",
"=",
"0",
";",
"k",
"<",
"cl",
";",
"++",
"k",
")",
"{",
"if",
"(",
"(",
"j",
">>>",
"k",
")",
"&",
"1",
")",
"{",
"b",
".",
"push",
"(",
"c",
"[",
"k",
"]",
")",
"}",
"}",
"result",
".",
"push",
"(",
"b",
")",
"}",
"}",
"return",
"normalize",
"(",
"result",
")",
"}"
] | Enumerates all cells in the complex | [
"Enumerates",
"all",
"cells",
"in",
"the",
"complex"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L215-L231 |
23,856 | mikolalysenko/simplicial-complex | topology.js | skeleton | function skeleton(cells, n) {
if(n < 0) {
return []
}
var result = []
, k0 = (1<<(n+1))-1
for(var i=0; i<cells.length; ++i) {
var c = cells[i]
for(var k=k0; k<(1<<c.length); k=bits.nextCombination(k)) {
var b = new Array(n+1)
, l = 0
for(var j=0; j<c.length; ++j) {
if(k & (1<<j)) {
b[l++] = c[j]
}
}
result.push(b)
}
}
return normalize(result)
} | javascript | function skeleton(cells, n) {
if(n < 0) {
return []
}
var result = []
, k0 = (1<<(n+1))-1
for(var i=0; i<cells.length; ++i) {
var c = cells[i]
for(var k=k0; k<(1<<c.length); k=bits.nextCombination(k)) {
var b = new Array(n+1)
, l = 0
for(var j=0; j<c.length; ++j) {
if(k & (1<<j)) {
b[l++] = c[j]
}
}
result.push(b)
}
}
return normalize(result)
} | [
"function",
"skeleton",
"(",
"cells",
",",
"n",
")",
"{",
"if",
"(",
"n",
"<",
"0",
")",
"{",
"return",
"[",
"]",
"}",
"var",
"result",
"=",
"[",
"]",
",",
"k0",
"=",
"(",
"1",
"<<",
"(",
"n",
"+",
"1",
")",
")",
"-",
"1",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cells",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"cells",
"[",
"i",
"]",
"for",
"(",
"var",
"k",
"=",
"k0",
";",
"k",
"<",
"(",
"1",
"<<",
"c",
".",
"length",
")",
";",
"k",
"=",
"bits",
".",
"nextCombination",
"(",
"k",
")",
")",
"{",
"var",
"b",
"=",
"new",
"Array",
"(",
"n",
"+",
"1",
")",
",",
"l",
"=",
"0",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"c",
".",
"length",
";",
"++",
"j",
")",
"{",
"if",
"(",
"k",
"&",
"(",
"1",
"<<",
"j",
")",
")",
"{",
"b",
"[",
"l",
"++",
"]",
"=",
"c",
"[",
"j",
"]",
"}",
"}",
"result",
".",
"push",
"(",
"b",
")",
"}",
"}",
"return",
"normalize",
"(",
"result",
")",
"}"
] | Enumerates all of the n-cells of a cell complex | [
"Enumerates",
"all",
"of",
"the",
"n",
"-",
"cells",
"of",
"a",
"cell",
"complex"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L235-L255 |
23,857 | mikolalysenko/simplicial-complex | topology.js | boundary | function boundary(cells) {
var res = []
for(var i=0,il=cells.length; i<il; ++i) {
var c = cells[i]
for(var j=0,cl=c.length; j<cl; ++j) {
var b = new Array(c.length-1)
for(var k=0, l=0; k<cl; ++k) {
if(k !== j) {
b[l++] = c[k]
}
}
res.push(b)
}
}
return normalize(res)
} | javascript | function boundary(cells) {
var res = []
for(var i=0,il=cells.length; i<il; ++i) {
var c = cells[i]
for(var j=0,cl=c.length; j<cl; ++j) {
var b = new Array(c.length-1)
for(var k=0, l=0; k<cl; ++k) {
if(k !== j) {
b[l++] = c[k]
}
}
res.push(b)
}
}
return normalize(res)
} | [
"function",
"boundary",
"(",
"cells",
")",
"{",
"var",
"res",
"=",
"[",
"]",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"il",
"=",
"cells",
".",
"length",
";",
"i",
"<",
"il",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"cells",
"[",
"i",
"]",
"for",
"(",
"var",
"j",
"=",
"0",
",",
"cl",
"=",
"c",
".",
"length",
";",
"j",
"<",
"cl",
";",
"++",
"j",
")",
"{",
"var",
"b",
"=",
"new",
"Array",
"(",
"c",
".",
"length",
"-",
"1",
")",
"for",
"(",
"var",
"k",
"=",
"0",
",",
"l",
"=",
"0",
";",
"k",
"<",
"cl",
";",
"++",
"k",
")",
"{",
"if",
"(",
"k",
"!==",
"j",
")",
"{",
"b",
"[",
"l",
"++",
"]",
"=",
"c",
"[",
"k",
"]",
"}",
"}",
"res",
".",
"push",
"(",
"b",
")",
"}",
"}",
"return",
"normalize",
"(",
"res",
")",
"}"
] | Computes the boundary of all cells, does not remove duplicates | [
"Computes",
"the",
"boundary",
"of",
"all",
"cells",
"does",
"not",
"remove",
"duplicates"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L259-L274 |
23,858 | mikolalysenko/simplicial-complex | topology.js | connectedComponents_dense | function connectedComponents_dense(cells, vertex_count) {
var labels = new UnionFind(vertex_count)
for(var i=0; i<cells.length; ++i) {
var c = cells[i]
for(var j=0; j<c.length; ++j) {
for(var k=j+1; k<c.length; ++k) {
labels.link(c[j], c[k])
}
}
}
var components = []
, component_labels = labels.ranks
for(var i=0; i<component_labels.length; ++i) {
component_labels[i] = -1
}
for(var i=0; i<cells.length; ++i) {
var l = labels.find(cells[i][0])
if(component_labels[l] < 0) {
component_labels[l] = components.length
components.push([cells[i].slice(0)])
} else {
components[component_labels[l]].push(cells[i].slice(0))
}
}
return components
} | javascript | function connectedComponents_dense(cells, vertex_count) {
var labels = new UnionFind(vertex_count)
for(var i=0; i<cells.length; ++i) {
var c = cells[i]
for(var j=0; j<c.length; ++j) {
for(var k=j+1; k<c.length; ++k) {
labels.link(c[j], c[k])
}
}
}
var components = []
, component_labels = labels.ranks
for(var i=0; i<component_labels.length; ++i) {
component_labels[i] = -1
}
for(var i=0; i<cells.length; ++i) {
var l = labels.find(cells[i][0])
if(component_labels[l] < 0) {
component_labels[l] = components.length
components.push([cells[i].slice(0)])
} else {
components[component_labels[l]].push(cells[i].slice(0))
}
}
return components
} | [
"function",
"connectedComponents_dense",
"(",
"cells",
",",
"vertex_count",
")",
"{",
"var",
"labels",
"=",
"new",
"UnionFind",
"(",
"vertex_count",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cells",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"cells",
"[",
"i",
"]",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"c",
".",
"length",
";",
"++",
"j",
")",
"{",
"for",
"(",
"var",
"k",
"=",
"j",
"+",
"1",
";",
"k",
"<",
"c",
".",
"length",
";",
"++",
"k",
")",
"{",
"labels",
".",
"link",
"(",
"c",
"[",
"j",
"]",
",",
"c",
"[",
"k",
"]",
")",
"}",
"}",
"}",
"var",
"components",
"=",
"[",
"]",
",",
"component_labels",
"=",
"labels",
".",
"ranks",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"component_labels",
".",
"length",
";",
"++",
"i",
")",
"{",
"component_labels",
"[",
"i",
"]",
"=",
"-",
"1",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cells",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"l",
"=",
"labels",
".",
"find",
"(",
"cells",
"[",
"i",
"]",
"[",
"0",
"]",
")",
"if",
"(",
"component_labels",
"[",
"l",
"]",
"<",
"0",
")",
"{",
"component_labels",
"[",
"l",
"]",
"=",
"components",
".",
"length",
"components",
".",
"push",
"(",
"[",
"cells",
"[",
"i",
"]",
".",
"slice",
"(",
"0",
")",
"]",
")",
"}",
"else",
"{",
"components",
"[",
"component_labels",
"[",
"l",
"]",
"]",
".",
"push",
"(",
"cells",
"[",
"i",
"]",
".",
"slice",
"(",
"0",
")",
")",
"}",
"}",
"return",
"components",
"}"
] | Computes connected components for a dense cell complex | [
"Computes",
"connected",
"components",
"for",
"a",
"dense",
"cell",
"complex"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L278-L303 |
23,859 | mikolalysenko/simplicial-complex | topology.js | connectedComponents_sparse | function connectedComponents_sparse(cells) {
var vertices = unique(normalize(skeleton(cells, 0)))
, labels = new UnionFind(vertices.length)
for(var i=0; i<cells.length; ++i) {
var c = cells[i]
for(var j=0; j<c.length; ++j) {
var vj = findCell(vertices, [c[j]])
for(var k=j+1; k<c.length; ++k) {
labels.link(vj, findCell(vertices, [c[k]]))
}
}
}
var components = []
, component_labels = labels.ranks
for(var i=0; i<component_labels.length; ++i) {
component_labels[i] = -1
}
for(var i=0; i<cells.length; ++i) {
var l = labels.find(findCell(vertices, [cells[i][0]]));
if(component_labels[l] < 0) {
component_labels[l] = components.length
components.push([cells[i].slice(0)])
} else {
components[component_labels[l]].push(cells[i].slice(0))
}
}
return components
} | javascript | function connectedComponents_sparse(cells) {
var vertices = unique(normalize(skeleton(cells, 0)))
, labels = new UnionFind(vertices.length)
for(var i=0; i<cells.length; ++i) {
var c = cells[i]
for(var j=0; j<c.length; ++j) {
var vj = findCell(vertices, [c[j]])
for(var k=j+1; k<c.length; ++k) {
labels.link(vj, findCell(vertices, [c[k]]))
}
}
}
var components = []
, component_labels = labels.ranks
for(var i=0; i<component_labels.length; ++i) {
component_labels[i] = -1
}
for(var i=0; i<cells.length; ++i) {
var l = labels.find(findCell(vertices, [cells[i][0]]));
if(component_labels[l] < 0) {
component_labels[l] = components.length
components.push([cells[i].slice(0)])
} else {
components[component_labels[l]].push(cells[i].slice(0))
}
}
return components
} | [
"function",
"connectedComponents_sparse",
"(",
"cells",
")",
"{",
"var",
"vertices",
"=",
"unique",
"(",
"normalize",
"(",
"skeleton",
"(",
"cells",
",",
"0",
")",
")",
")",
",",
"labels",
"=",
"new",
"UnionFind",
"(",
"vertices",
".",
"length",
")",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cells",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"c",
"=",
"cells",
"[",
"i",
"]",
"for",
"(",
"var",
"j",
"=",
"0",
";",
"j",
"<",
"c",
".",
"length",
";",
"++",
"j",
")",
"{",
"var",
"vj",
"=",
"findCell",
"(",
"vertices",
",",
"[",
"c",
"[",
"j",
"]",
"]",
")",
"for",
"(",
"var",
"k",
"=",
"j",
"+",
"1",
";",
"k",
"<",
"c",
".",
"length",
";",
"++",
"k",
")",
"{",
"labels",
".",
"link",
"(",
"vj",
",",
"findCell",
"(",
"vertices",
",",
"[",
"c",
"[",
"k",
"]",
"]",
")",
")",
"}",
"}",
"}",
"var",
"components",
"=",
"[",
"]",
",",
"component_labels",
"=",
"labels",
".",
"ranks",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"component_labels",
".",
"length",
";",
"++",
"i",
")",
"{",
"component_labels",
"[",
"i",
"]",
"=",
"-",
"1",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"cells",
".",
"length",
";",
"++",
"i",
")",
"{",
"var",
"l",
"=",
"labels",
".",
"find",
"(",
"findCell",
"(",
"vertices",
",",
"[",
"cells",
"[",
"i",
"]",
"[",
"0",
"]",
"]",
")",
")",
";",
"if",
"(",
"component_labels",
"[",
"l",
"]",
"<",
"0",
")",
"{",
"component_labels",
"[",
"l",
"]",
"=",
"components",
".",
"length",
"components",
".",
"push",
"(",
"[",
"cells",
"[",
"i",
"]",
".",
"slice",
"(",
"0",
")",
"]",
")",
"}",
"else",
"{",
"components",
"[",
"component_labels",
"[",
"l",
"]",
"]",
".",
"push",
"(",
"cells",
"[",
"i",
"]",
".",
"slice",
"(",
"0",
")",
")",
"}",
"}",
"return",
"components",
"}"
] | Computes connected components for a sparse graph | [
"Computes",
"connected",
"components",
"for",
"a",
"sparse",
"graph"
] | 68ae05a629616d5c737a36d8075ec1b77f5f2935 | https://github.com/mikolalysenko/simplicial-complex/blob/68ae05a629616d5c737a36d8075ec1b77f5f2935/topology.js#L306-L333 |
23,860 | rwaldron/temporal | lib/temporal.js | Task | function Task(entry) {
if (!(this instanceof Task)) {
return new Task(entry);
}
this.called = 0;
this.now = this.calledAt = hrTime();
if (resolutionDivisor !== DEFAULT_RESOLUTION) {
entry.time = ~~(entry.time * (DEFAULT_RESOLUTION / resolutionDivisor));
}
// Side table property definitions
this.isRunnable = true;
this.later = this.now + entry.time;
this.task = entry.task;
this.type = entry.type;
this.time = entry.time;
if (this.later > gLast) {
gLast = this.later;
}
if (!queue[this.later]) {
queue[this.later] = [];
}
// console.log( entry.later, this );
queue[this.later].push(this);
} | javascript | function Task(entry) {
if (!(this instanceof Task)) {
return new Task(entry);
}
this.called = 0;
this.now = this.calledAt = hrTime();
if (resolutionDivisor !== DEFAULT_RESOLUTION) {
entry.time = ~~(entry.time * (DEFAULT_RESOLUTION / resolutionDivisor));
}
// Side table property definitions
this.isRunnable = true;
this.later = this.now + entry.time;
this.task = entry.task;
this.type = entry.type;
this.time = entry.time;
if (this.later > gLast) {
gLast = this.later;
}
if (!queue[this.later]) {
queue[this.later] = [];
}
// console.log( entry.later, this );
queue[this.later].push(this);
} | [
"function",
"Task",
"(",
"entry",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Task",
")",
")",
"{",
"return",
"new",
"Task",
"(",
"entry",
")",
";",
"}",
"this",
".",
"called",
"=",
"0",
";",
"this",
".",
"now",
"=",
"this",
".",
"calledAt",
"=",
"hrTime",
"(",
")",
";",
"if",
"(",
"resolutionDivisor",
"!==",
"DEFAULT_RESOLUTION",
")",
"{",
"entry",
".",
"time",
"=",
"~",
"~",
"(",
"entry",
".",
"time",
"*",
"(",
"DEFAULT_RESOLUTION",
"/",
"resolutionDivisor",
")",
")",
";",
"}",
"// Side table property definitions",
"this",
".",
"isRunnable",
"=",
"true",
";",
"this",
".",
"later",
"=",
"this",
".",
"now",
"+",
"entry",
".",
"time",
";",
"this",
".",
"task",
"=",
"entry",
".",
"task",
";",
"this",
".",
"type",
"=",
"entry",
".",
"type",
";",
"this",
".",
"time",
"=",
"entry",
".",
"time",
";",
"if",
"(",
"this",
".",
"later",
">",
"gLast",
")",
"{",
"gLast",
"=",
"this",
".",
"later",
";",
"}",
"if",
"(",
"!",
"queue",
"[",
"this",
".",
"later",
"]",
")",
"{",
"queue",
"[",
"this",
".",
"later",
"]",
"=",
"[",
"]",
";",
"}",
"// console.log( entry.later, this );",
"queue",
"[",
"this",
".",
"later",
"]",
".",
"push",
"(",
"this",
")",
";",
"}"
] | Task create a temporal task item
@param {Object} entry Options for entry {time, task} | [
"Task",
"create",
"a",
"temporal",
"task",
"item"
] | b87f4975f6db4521a0ea84dcda9dd52091b2f733 | https://github.com/rwaldron/temporal/blob/b87f4975f6db4521a0ea84dcda9dd52091b2f733/lib/temporal.js#L32-L60 |
23,861 | nolanlawson/vdom-as-json | lib/toJson.js | cloneObj | function cloneObj(a,b) {
Object.keys(b).forEach(function(k) {
a[k] = b[k];
});
return a;
} | javascript | function cloneObj(a,b) {
Object.keys(b).forEach(function(k) {
a[k] = b[k];
});
return a;
} | [
"function",
"cloneObj",
"(",
"a",
",",
"b",
")",
"{",
"Object",
".",
"keys",
"(",
"b",
")",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"a",
"[",
"k",
"]",
"=",
"b",
"[",
"k",
"]",
";",
"}",
")",
";",
"return",
"a",
";",
"}"
] | PhantomJS doesn't support Object.assigns, so just implement a clone method here. | [
"PhantomJS",
"doesn",
"t",
"support",
"Object",
".",
"assigns",
"so",
"just",
"implement",
"a",
"clone",
"method",
"here",
"."
] | 8bae1d2c6c30af011bcf1843b32408c410caabd8 | https://github.com/nolanlawson/vdom-as-json/blob/8bae1d2c6c30af011bcf1843b32408c410caabd8/lib/toJson.js#L159-L164 |
23,862 | dvla/dvla_internal_frontend_toolkit | app/assets/javascripts/styleguide/prism-line-numbers.js | function (element) {
var codeStyles = getStyles(element);
var whiteSpace = codeStyles['white-space'];
if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') {
var codeElement = element.querySelector('code');
var lineNumbersWrapper = element.querySelector('.line-numbers-rows');
var lineNumberSizer = element.querySelector('.line-numbers-sizer');
var codeLines = element.textContent.split('\n');
if (!lineNumberSizer) {
lineNumberSizer = document.createElement('span');
lineNumberSizer.className = 'line-numbers-sizer';
codeElement.appendChild(lineNumberSizer);
}
lineNumberSizer.style.display = 'block';
codeLines.forEach(function (line, lineNumber) {
lineNumberSizer.textContent = line || '\n';
var lineSize = lineNumberSizer.getBoundingClientRect().height;
lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px';
});
lineNumberSizer.textContent = '';
lineNumberSizer.style.display = 'none';
}
} | javascript | function (element) {
var codeStyles = getStyles(element);
var whiteSpace = codeStyles['white-space'];
if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') {
var codeElement = element.querySelector('code');
var lineNumbersWrapper = element.querySelector('.line-numbers-rows');
var lineNumberSizer = element.querySelector('.line-numbers-sizer');
var codeLines = element.textContent.split('\n');
if (!lineNumberSizer) {
lineNumberSizer = document.createElement('span');
lineNumberSizer.className = 'line-numbers-sizer';
codeElement.appendChild(lineNumberSizer);
}
lineNumberSizer.style.display = 'block';
codeLines.forEach(function (line, lineNumber) {
lineNumberSizer.textContent = line || '\n';
var lineSize = lineNumberSizer.getBoundingClientRect().height;
lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px';
});
lineNumberSizer.textContent = '';
lineNumberSizer.style.display = 'none';
}
} | [
"function",
"(",
"element",
")",
"{",
"var",
"codeStyles",
"=",
"getStyles",
"(",
"element",
")",
";",
"var",
"whiteSpace",
"=",
"codeStyles",
"[",
"'white-space'",
"]",
";",
"if",
"(",
"whiteSpace",
"===",
"'pre-wrap'",
"||",
"whiteSpace",
"===",
"'pre-line'",
")",
"{",
"var",
"codeElement",
"=",
"element",
".",
"querySelector",
"(",
"'code'",
")",
";",
"var",
"lineNumbersWrapper",
"=",
"element",
".",
"querySelector",
"(",
"'.line-numbers-rows'",
")",
";",
"var",
"lineNumberSizer",
"=",
"element",
".",
"querySelector",
"(",
"'.line-numbers-sizer'",
")",
";",
"var",
"codeLines",
"=",
"element",
".",
"textContent",
".",
"split",
"(",
"'\\n'",
")",
";",
"if",
"(",
"!",
"lineNumberSizer",
")",
"{",
"lineNumberSizer",
"=",
"document",
".",
"createElement",
"(",
"'span'",
")",
";",
"lineNumberSizer",
".",
"className",
"=",
"'line-numbers-sizer'",
";",
"codeElement",
".",
"appendChild",
"(",
"lineNumberSizer",
")",
";",
"}",
"lineNumberSizer",
".",
"style",
".",
"display",
"=",
"'block'",
";",
"codeLines",
".",
"forEach",
"(",
"function",
"(",
"line",
",",
"lineNumber",
")",
"{",
"lineNumberSizer",
".",
"textContent",
"=",
"line",
"||",
"'\\n'",
";",
"var",
"lineSize",
"=",
"lineNumberSizer",
".",
"getBoundingClientRect",
"(",
")",
".",
"height",
";",
"lineNumbersWrapper",
".",
"children",
"[",
"lineNumber",
"]",
".",
"style",
".",
"height",
"=",
"lineSize",
"+",
"'px'",
";",
"}",
")",
";",
"lineNumberSizer",
".",
"textContent",
"=",
"''",
";",
"lineNumberSizer",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"}",
"}"
] | Resizes line numbers spans according to height of line of code
@param {Element} element <pre> element | [
"Resizes",
"line",
"numbers",
"spans",
"according",
"to",
"height",
"of",
"line",
"of",
"code"
] | ce3609613281dbb6c07f23c095c13d827eafb4ad | https://github.com/dvla/dvla_internal_frontend_toolkit/blob/ce3609613281dbb6c07f23c095c13d827eafb4ad/app/assets/javascripts/styleguide/prism-line-numbers.js#L17-L45 | |
23,863 | Happy0/ssb-chess | ctrl/validMovesFinder.js | listenForWorkerResults | function listenForWorkerResults() {
chessWorker.addEventListener('message', (event) => {
const gameId = event.data.reqid.gameRootMessage;
const { ply } = event.data.reqid;
if (event.data.topic === 'dests') {
const destsMapKey = getDestsKey(gameId, ply);
const awaitingDestsObs = get(awaitingWorkerResponses, destsMapKey);
if (awaitingDestsObs) {
const validDests = event.data.payload.dests;
awaitingDestsObs.set(validDests);
delete awaitingWorkerResponses[destsMapKey];
}
} else if (event.data.topic === 'threefoldTest') {
const canDrawKey = getDrawKey(gameId, ply);
const awaitingCanDraw = get(awaitingWorkerResponses, canDrawKey);
if (awaitingCanDraw) {
const canClaimDraw = event.data.payload.threefoldRepetition;
awaitingCanDraw.set(canClaimDraw);
delete awaitingWorkerResponses[canDrawKey];
}
}
});
} | javascript | function listenForWorkerResults() {
chessWorker.addEventListener('message', (event) => {
const gameId = event.data.reqid.gameRootMessage;
const { ply } = event.data.reqid;
if (event.data.topic === 'dests') {
const destsMapKey = getDestsKey(gameId, ply);
const awaitingDestsObs = get(awaitingWorkerResponses, destsMapKey);
if (awaitingDestsObs) {
const validDests = event.data.payload.dests;
awaitingDestsObs.set(validDests);
delete awaitingWorkerResponses[destsMapKey];
}
} else if (event.data.topic === 'threefoldTest') {
const canDrawKey = getDrawKey(gameId, ply);
const awaitingCanDraw = get(awaitingWorkerResponses, canDrawKey);
if (awaitingCanDraw) {
const canClaimDraw = event.data.payload.threefoldRepetition;
awaitingCanDraw.set(canClaimDraw);
delete awaitingWorkerResponses[canDrawKey];
}
}
});
} | [
"function",
"listenForWorkerResults",
"(",
")",
"{",
"chessWorker",
".",
"addEventListener",
"(",
"'message'",
",",
"(",
"event",
")",
"=>",
"{",
"const",
"gameId",
"=",
"event",
".",
"data",
".",
"reqid",
".",
"gameRootMessage",
";",
"const",
"{",
"ply",
"}",
"=",
"event",
".",
"data",
".",
"reqid",
";",
"if",
"(",
"event",
".",
"data",
".",
"topic",
"===",
"'dests'",
")",
"{",
"const",
"destsMapKey",
"=",
"getDestsKey",
"(",
"gameId",
",",
"ply",
")",
";",
"const",
"awaitingDestsObs",
"=",
"get",
"(",
"awaitingWorkerResponses",
",",
"destsMapKey",
")",
";",
"if",
"(",
"awaitingDestsObs",
")",
"{",
"const",
"validDests",
"=",
"event",
".",
"data",
".",
"payload",
".",
"dests",
";",
"awaitingDestsObs",
".",
"set",
"(",
"validDests",
")",
";",
"delete",
"awaitingWorkerResponses",
"[",
"destsMapKey",
"]",
";",
"}",
"}",
"else",
"if",
"(",
"event",
".",
"data",
".",
"topic",
"===",
"'threefoldTest'",
")",
"{",
"const",
"canDrawKey",
"=",
"getDrawKey",
"(",
"gameId",
",",
"ply",
")",
";",
"const",
"awaitingCanDraw",
"=",
"get",
"(",
"awaitingWorkerResponses",
",",
"canDrawKey",
")",
";",
"if",
"(",
"awaitingCanDraw",
")",
"{",
"const",
"canClaimDraw",
"=",
"event",
".",
"data",
".",
"payload",
".",
"threefoldRepetition",
";",
"awaitingCanDraw",
".",
"set",
"(",
"canClaimDraw",
")",
";",
"delete",
"awaitingWorkerResponses",
"[",
"canDrawKey",
"]",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Listens for respones from the chess webworker and updates observables awaiting the response | [
"Listens",
"for",
"respones",
"from",
"the",
"chess",
"webworker",
"and",
"updates",
"observables",
"awaiting",
"the",
"response"
] | 585763cc6c36147f94b73d1715daaf7c05f1c40b | https://github.com/Happy0/ssb-chess/blob/585763cc6c36147f94b73d1715daaf7c05f1c40b/ctrl/validMovesFinder.js#L70-L96 |
23,864 | krasimir/kuker-emitters | lib/__build__/counter.js | wrap | function wrap(set) {
return function (fn, time /* , ...args */) {
var boundArgs = arguments.length > 2;
var args = boundArgs ? slice.call(arguments, 2) : false;
return set(boundArgs ? function () {
// eslint-disable-next-line no-new-func
(typeof fn == 'function' ? fn : Function(fn)).apply(this, args);
} : fn, time);
};
} | javascript | function wrap(set) {
return function (fn, time /* , ...args */) {
var boundArgs = arguments.length > 2;
var args = boundArgs ? slice.call(arguments, 2) : false;
return set(boundArgs ? function () {
// eslint-disable-next-line no-new-func
(typeof fn == 'function' ? fn : Function(fn)).apply(this, args);
} : fn, time);
};
} | [
"function",
"wrap",
"(",
"set",
")",
"{",
"return",
"function",
"(",
"fn",
",",
"time",
"/* , ...args */",
")",
"{",
"var",
"boundArgs",
"=",
"arguments",
".",
"length",
">",
"2",
";",
"var",
"args",
"=",
"boundArgs",
"?",
"slice",
".",
"call",
"(",
"arguments",
",",
"2",
")",
":",
"false",
";",
"return",
"set",
"(",
"boundArgs",
"?",
"function",
"(",
")",
"{",
"// eslint-disable-next-line no-new-func",
"(",
"typeof",
"fn",
"==",
"'function'",
"?",
"fn",
":",
"Function",
"(",
"fn",
")",
")",
".",
"apply",
"(",
"this",
",",
"args",
")",
";",
"}",
":",
"fn",
",",
"time",
")",
";",
"}",
";",
"}"
] | <- dirty ie9- check | [
"<",
"-",
"dirty",
"ie9",
"-",
"check"
] | dea5f638a043e53c5ffb1c5db8d72f4d0bef7f4f | https://github.com/krasimir/kuker-emitters/blob/dea5f638a043e53c5ffb1c5db8d72f4d0bef7f4f/lib/__build__/counter.js#L8184-L8193 |
23,865 | cs01/stator | src/statorgfc.js | function(key_or_new_store, value) {
if (arguments.length === 1) {
// replace the whole store
let new_store = key_or_new_store
for (let k in new_store) {
store.set(k, new_store[k])
}
return
}
let key = key_or_new_store
if (!store._store.hasOwnProperty(key)) {
// use hasOwnProperty for better performance (entrie prototype chain is not traversed)
throw `cannot create new key after initialization (attempted to create ${key})`
}
let oldval = store._store[key]
checkTypeMatch(key, oldval, value)
if (valueHasChanged(oldval, value)) {
let update_store = store._runUserMiddleware(key, oldval, value)
if (update_store) {
store._store[key] = value
store._publishChangeToSubscribers(key, oldval, value)
}
}
} | javascript | function(key_or_new_store, value) {
if (arguments.length === 1) {
// replace the whole store
let new_store = key_or_new_store
for (let k in new_store) {
store.set(k, new_store[k])
}
return
}
let key = key_or_new_store
if (!store._store.hasOwnProperty(key)) {
// use hasOwnProperty for better performance (entrie prototype chain is not traversed)
throw `cannot create new key after initialization (attempted to create ${key})`
}
let oldval = store._store[key]
checkTypeMatch(key, oldval, value)
if (valueHasChanged(oldval, value)) {
let update_store = store._runUserMiddleware(key, oldval, value)
if (update_store) {
store._store[key] = value
store._publishChangeToSubscribers(key, oldval, value)
}
}
} | [
"function",
"(",
"key_or_new_store",
",",
"value",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"// replace the whole store",
"let",
"new_store",
"=",
"key_or_new_store",
"for",
"(",
"let",
"k",
"in",
"new_store",
")",
"{",
"store",
".",
"set",
"(",
"k",
",",
"new_store",
"[",
"k",
"]",
")",
"}",
"return",
"}",
"let",
"key",
"=",
"key_or_new_store",
"if",
"(",
"!",
"store",
".",
"_store",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"// use hasOwnProperty for better performance (entrie prototype chain is not traversed)",
"throw",
"`",
"${",
"key",
"}",
"`",
"}",
"let",
"oldval",
"=",
"store",
".",
"_store",
"[",
"key",
"]",
"checkTypeMatch",
"(",
"key",
",",
"oldval",
",",
"value",
")",
"if",
"(",
"valueHasChanged",
"(",
"oldval",
",",
"value",
")",
")",
"{",
"let",
"update_store",
"=",
"store",
".",
"_runUserMiddleware",
"(",
"key",
",",
"oldval",
",",
"value",
")",
"if",
"(",
"update_store",
")",
"{",
"store",
".",
"_store",
"[",
"key",
"]",
"=",
"value",
"store",
".",
"_publishChangeToSubscribers",
"(",
"key",
",",
"oldval",
",",
"value",
")",
"}",
"}",
"}"
] | set key or keys of store object
@param {str/obj} key_or_new_store: if str, this key is replaced. If obj, all keys of the obj replace store's keys.
@param {any} value: If key was provided, the associated value. The type of the value for this key cannot change. Exceptions to this rule
are to/from null or undefined. Otherwise if you try to change, say, `1` to `'2'`, a type error will occur (int to string is not permitted). | [
"set",
"key",
"or",
"keys",
"of",
"store",
"object"
] | 51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1 | https://github.com/cs01/stator/blob/51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1/src/statorgfc.js#L164-L189 | |
23,866 | cs01/stator | src/statorgfc.js | function(key, oldval, value) {
if (store._changed_keys.indexOf(key) === -1) {
store._changed_keys.push(key)
}
// suppress active timeout (if any)
if (store._debounce_timeout) {
store._clearDebounceTimeout()
}
if (store.options.debounce_ms) {
// delay event emission and set new timeout id
store._debounce_timeout = setTimeout(store._publish, store.options.debounce_ms)
} else {
// publish immediately
store._publish()
}
} | javascript | function(key, oldval, value) {
if (store._changed_keys.indexOf(key) === -1) {
store._changed_keys.push(key)
}
// suppress active timeout (if any)
if (store._debounce_timeout) {
store._clearDebounceTimeout()
}
if (store.options.debounce_ms) {
// delay event emission and set new timeout id
store._debounce_timeout = setTimeout(store._publish, store.options.debounce_ms)
} else {
// publish immediately
store._publish()
}
} | [
"function",
"(",
"key",
",",
"oldval",
",",
"value",
")",
"{",
"if",
"(",
"store",
".",
"_changed_keys",
".",
"indexOf",
"(",
"key",
")",
"===",
"-",
"1",
")",
"{",
"store",
".",
"_changed_keys",
".",
"push",
"(",
"key",
")",
"}",
"// suppress active timeout (if any)",
"if",
"(",
"store",
".",
"_debounce_timeout",
")",
"{",
"store",
".",
"_clearDebounceTimeout",
"(",
")",
"}",
"if",
"(",
"store",
".",
"options",
".",
"debounce_ms",
")",
"{",
"// delay event emission and set new timeout id",
"store",
".",
"_debounce_timeout",
"=",
"setTimeout",
"(",
"store",
".",
"_publish",
",",
"store",
".",
"options",
".",
"debounce_ms",
")",
"}",
"else",
"{",
"// publish immediately",
"store",
".",
"_publish",
"(",
")",
"}",
"}"
] | Emit event to subscribers based on timeout rules
@param key key to change
@param oldval original value (for logging purposes)
@param value new value to assign | [
"Emit",
"event",
"to",
"subscribers",
"based",
"on",
"timeout",
"rules"
] | 51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1 | https://github.com/cs01/stator/blob/51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1/src/statorgfc.js#L218-L235 | |
23,867 | cs01/stator | src/statorgfc.js | function(key) {
if (!store._store_created) {
throw 'cannot get store because is has not been created'
}
if (arguments.length === 0) {
// return the whole store
if (store.options.immutable) {
return Object.assign({}, store._store) // copy entire store by value
} else {
return store._store // return reference to store
}
} else if (arguments.length > 1) {
console.error('unexpected number of arguments')
return
}
if (!store._store.hasOwnProperty(key)) {
throw `attempted to access key that was not set during initialization: ${key}`
}
let ref = store._store[key]
if (store.options.immutable) {
return copyByValue(ref)
} else {
// return the reference
return ref
}
} | javascript | function(key) {
if (!store._store_created) {
throw 'cannot get store because is has not been created'
}
if (arguments.length === 0) {
// return the whole store
if (store.options.immutable) {
return Object.assign({}, store._store) // copy entire store by value
} else {
return store._store // return reference to store
}
} else if (arguments.length > 1) {
console.error('unexpected number of arguments')
return
}
if (!store._store.hasOwnProperty(key)) {
throw `attempted to access key that was not set during initialization: ${key}`
}
let ref = store._store[key]
if (store.options.immutable) {
return copyByValue(ref)
} else {
// return the reference
return ref
}
} | [
"function",
"(",
"key",
")",
"{",
"if",
"(",
"!",
"store",
".",
"_store_created",
")",
"{",
"throw",
"'cannot get store because is has not been created'",
"}",
"if",
"(",
"arguments",
".",
"length",
"===",
"0",
")",
"{",
"// return the whole store",
"if",
"(",
"store",
".",
"options",
".",
"immutable",
")",
"{",
"return",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"store",
".",
"_store",
")",
"// copy entire store by value",
"}",
"else",
"{",
"return",
"store",
".",
"_store",
"// return reference to store",
"}",
"}",
"else",
"if",
"(",
"arguments",
".",
"length",
">",
"1",
")",
"{",
"console",
".",
"error",
"(",
"'unexpected number of arguments'",
")",
"return",
"}",
"if",
"(",
"!",
"store",
".",
"_store",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"throw",
"`",
"${",
"key",
"}",
"`",
"}",
"let",
"ref",
"=",
"store",
".",
"_store",
"[",
"key",
"]",
"if",
"(",
"store",
".",
"options",
".",
"immutable",
")",
"{",
"return",
"copyByValue",
"(",
"ref",
")",
"}",
"else",
"{",
"// return the reference",
"return",
"ref",
"}",
"}"
] | Get reference or value to one of the keys in the current store.
@param key of the store object to get a reference to
@return reference or new object (depending on `immutable` option)
NOTE: The store should *only* be update by calling `store.set(...)`
Throws error if key does not exist in store. | [
"Get",
"reference",
"or",
"value",
"to",
"one",
"of",
"the",
"keys",
"in",
"the",
"current",
"store",
"."
] | 51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1 | https://github.com/cs01/stator/blob/51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1/src/statorgfc.js#L243-L270 | |
23,868 | cs01/stator | src/statorgfc.js | function() {
const changed_keys = store._changed_keys
if (changed_keys.length === 0) {
console.error('no keys were changed, yet we are trying to publish a store change')
return
}
// make sure _changed_keys is reset before executing callbacks
// (if callbacks modify state, the list of keys the callback changed would be wiped out)
store._changed_keys = []
store._clearDebounceTimeout()
store._callback_objs.forEach(obj => obj.callback(changed_keys))
} | javascript | function() {
const changed_keys = store._changed_keys
if (changed_keys.length === 0) {
console.error('no keys were changed, yet we are trying to publish a store change')
return
}
// make sure _changed_keys is reset before executing callbacks
// (if callbacks modify state, the list of keys the callback changed would be wiped out)
store._changed_keys = []
store._clearDebounceTimeout()
store._callback_objs.forEach(obj => obj.callback(changed_keys))
} | [
"function",
"(",
")",
"{",
"const",
"changed_keys",
"=",
"store",
".",
"_changed_keys",
"if",
"(",
"changed_keys",
".",
"length",
"===",
"0",
")",
"{",
"console",
".",
"error",
"(",
"'no keys were changed, yet we are trying to publish a store change'",
")",
"return",
"}",
"// make sure _changed_keys is reset before executing callbacks",
"// (if callbacks modify state, the list of keys the callback changed would be wiped out)",
"store",
".",
"_changed_keys",
"=",
"[",
"]",
"store",
".",
"_clearDebounceTimeout",
"(",
")",
"store",
".",
"_callback_objs",
".",
"forEach",
"(",
"obj",
"=>",
"obj",
".",
"callback",
"(",
"changed_keys",
")",
")",
"}"
] | Run subscribers' callback functions. An array of the changed keys is passed to the callback function.
Be careful how often this is called, since re-rendering components can become expensive. | [
"Run",
"subscribers",
"callback",
"functions",
".",
"An",
"array",
"of",
"the",
"changed",
"keys",
"is",
"passed",
"to",
"the",
"callback",
"function",
".",
"Be",
"careful",
"how",
"often",
"this",
"is",
"called",
"since",
"re",
"-",
"rendering",
"components",
"can",
"become",
"expensive",
"."
] | 51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1 | https://github.com/cs01/stator/blob/51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1/src/statorgfc.js#L275-L287 | |
23,869 | Happy0/ssb-chess-mithril | ui/viewer_perspective/user_location.js | chessAppIsVisible | function chessAppIsVisible() {
const topLevelElementArr = document.getElementsByClassName('ssb-chess-container');
if (!topLevelElementArr || topLevelElementArr.length <= 0) {
return false;
}
const element = topLevelElementArr[0];
return document.hasFocus() && isVisible(element);
} | javascript | function chessAppIsVisible() {
const topLevelElementArr = document.getElementsByClassName('ssb-chess-container');
if (!topLevelElementArr || topLevelElementArr.length <= 0) {
return false;
}
const element = topLevelElementArr[0];
return document.hasFocus() && isVisible(element);
} | [
"function",
"chessAppIsVisible",
"(",
")",
"{",
"const",
"topLevelElementArr",
"=",
"document",
".",
"getElementsByClassName",
"(",
"'ssb-chess-container'",
")",
";",
"if",
"(",
"!",
"topLevelElementArr",
"||",
"topLevelElementArr",
".",
"length",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"const",
"element",
"=",
"topLevelElementArr",
"[",
"0",
"]",
";",
"return",
"document",
".",
"hasFocus",
"(",
")",
"&&",
"isVisible",
"(",
"element",
")",
";",
"}"
] | Returns true if the user can currently see the chess app, and false otherwise.
The user might be in a different tab in the containing application, for example. | [
"Returns",
"true",
"if",
"the",
"user",
"can",
"currently",
"see",
"the",
"chess",
"app",
"and",
"false",
"otherwise",
".",
"The",
"user",
"might",
"be",
"in",
"a",
"different",
"tab",
"in",
"the",
"containing",
"application",
"for",
"example",
"."
] | 5d44624ca7e2109ece84445566ac44ca0d6d168d | https://github.com/Happy0/ssb-chess-mithril/blob/5d44624ca7e2109ece84445566ac44ca0d6d168d/ui/viewer_perspective/user_location.js#L13-L22 |
23,870 | cs01/stator | build/statorgfc.js | _callback | function _callback(changed_keys) {
if (intersection(keys_to_watch_for_changes, changed_keys).length) {
// only update the state if a key we care about has changed
var state_update_obj = {};
keys_to_watch_for_changes.forEach(function (k) {
return state_update_obj[k] = store._store[k];
});
this.setState(state_update_obj);
// if some other custom callback is required by the component
// call that function as well
if (additonal_callback) {
additonal_callback(changed_keys);
}
}
} | javascript | function _callback(changed_keys) {
if (intersection(keys_to_watch_for_changes, changed_keys).length) {
// only update the state if a key we care about has changed
var state_update_obj = {};
keys_to_watch_for_changes.forEach(function (k) {
return state_update_obj[k] = store._store[k];
});
this.setState(state_update_obj);
// if some other custom callback is required by the component
// call that function as well
if (additonal_callback) {
additonal_callback(changed_keys);
}
}
} | [
"function",
"_callback",
"(",
"changed_keys",
")",
"{",
"if",
"(",
"intersection",
"(",
"keys_to_watch_for_changes",
",",
"changed_keys",
")",
".",
"length",
")",
"{",
"// only update the state if a key we care about has changed",
"var",
"state_update_obj",
"=",
"{",
"}",
";",
"keys_to_watch_for_changes",
".",
"forEach",
"(",
"function",
"(",
"k",
")",
"{",
"return",
"state_update_obj",
"[",
"k",
"]",
"=",
"store",
".",
"_store",
"[",
"k",
"]",
";",
"}",
")",
";",
"this",
".",
"setState",
"(",
"state_update_obj",
")",
";",
"// if some other custom callback is required by the component",
"// call that function as well",
"if",
"(",
"additonal_callback",
")",
"{",
"additonal_callback",
"(",
"changed_keys",
")",
";",
"}",
"}",
"}"
] | initialize if not set call this function whenever the store changes | [
"initialize",
"if",
"not",
"set",
"call",
"this",
"function",
"whenever",
"the",
"store",
"changes"
] | 51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1 | https://github.com/cs01/stator/blob/51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1/build/statorgfc.js#L53-L68 |
23,871 | cs01/stator | build/statorgfc.js | getUnwatchedKeys | function getUnwatchedKeys() {
var arr1 = Object.keys(store._store),
arr2 = Object.keys(store._key_to_watcher_subscriptions);
return arr1.filter(function (i) {
return arr2.indexOf(i) === -1;
});
} | javascript | function getUnwatchedKeys() {
var arr1 = Object.keys(store._store),
arr2 = Object.keys(store._key_to_watcher_subscriptions);
return arr1.filter(function (i) {
return arr2.indexOf(i) === -1;
});
} | [
"function",
"getUnwatchedKeys",
"(",
")",
"{",
"var",
"arr1",
"=",
"Object",
".",
"keys",
"(",
"store",
".",
"_store",
")",
",",
"arr2",
"=",
"Object",
".",
"keys",
"(",
"store",
".",
"_key_to_watcher_subscriptions",
")",
";",
"return",
"arr1",
".",
"filter",
"(",
"function",
"(",
"i",
")",
"{",
"return",
"arr2",
".",
"indexOf",
"(",
"i",
")",
"===",
"-",
"1",
";",
"}",
")",
";",
"}"
] | return an array of keys that do not trigger any callbacks when changed, and therefore
probably don't need to be included in the global store | [
"return",
"an",
"array",
"of",
"keys",
"that",
"do",
"not",
"trigger",
"any",
"callbacks",
"when",
"changed",
"and",
"therefore",
"probably",
"don",
"t",
"need",
"to",
"be",
"included",
"in",
"the",
"global",
"store"
] | 51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1 | https://github.com/cs01/stator/blob/51dbdcc97aacc80d07ebdeb6c13a06e12880b9a1/build/statorgfc.js#L203-L209 |
23,872 | nicjansma/resourcetiming-compression.js | src/resourcetiming-compression.js | collectResources | function collectResources(a, obj, tagName) {
Array.prototype
.forEach
.call(a.ownerDocument.getElementsByTagName(tagName), function(r) {
// Get canonical URL
a.href = r.currentSrc || r.src || r.getAttribute("xlink:href") || r.href;
// only get external resource
if (a.href.match(/^https?:\/\//)) {
obj[a.href] = r;
}
});
} | javascript | function collectResources(a, obj, tagName) {
Array.prototype
.forEach
.call(a.ownerDocument.getElementsByTagName(tagName), function(r) {
// Get canonical URL
a.href = r.currentSrc || r.src || r.getAttribute("xlink:href") || r.href;
// only get external resource
if (a.href.match(/^https?:\/\//)) {
obj[a.href] = r;
}
});
} | [
"function",
"collectResources",
"(",
"a",
",",
"obj",
",",
"tagName",
")",
"{",
"Array",
".",
"prototype",
".",
"forEach",
".",
"call",
"(",
"a",
".",
"ownerDocument",
".",
"getElementsByTagName",
"(",
"tagName",
")",
",",
"function",
"(",
"r",
")",
"{",
"// Get canonical URL",
"a",
".",
"href",
"=",
"r",
".",
"currentSrc",
"||",
"r",
".",
"src",
"||",
"r",
".",
"getAttribute",
"(",
"\"xlink:href\"",
")",
"||",
"r",
".",
"href",
";",
"// only get external resource",
"if",
"(",
"a",
".",
"href",
".",
"match",
"(",
"/",
"^https?:\\/\\/",
"/",
")",
")",
"{",
"obj",
"[",
"a",
".",
"href",
"]",
"=",
"r",
";",
"}",
"}",
")",
";",
"}"
] | Collect external resources by tagName
@param {Element} a an anchor element
@param {Object} obj object of resources where the key is the url
@param {string} tagName tag name to collect | [
"Collect",
"external",
"resources",
"by",
"tagName"
] | 623c88b62b06624d0ec7d6e857f7743cbad59996 | https://github.com/nicjansma/resourcetiming-compression.js/blob/623c88b62b06624d0ec7d6e857f7743cbad59996/src/resourcetiming-compression.js#L588-L600 |
23,873 | Happy0/ssb-chess-mithril | index.js | cssFilesToStyleTag | function cssFilesToStyleTag(dom) {
const rootDir = `${__dirname}/`;
const styles = m('div', {}, cssFiles.map(file => m('link', { rel: 'stylesheet', href: rootDir + file })));
m.render(dom, styles);
} | javascript | function cssFilesToStyleTag(dom) {
const rootDir = `${__dirname}/`;
const styles = m('div', {}, cssFiles.map(file => m('link', { rel: 'stylesheet', href: rootDir + file })));
m.render(dom, styles);
} | [
"function",
"cssFilesToStyleTag",
"(",
"dom",
")",
"{",
"const",
"rootDir",
"=",
"`",
"${",
"__dirname",
"}",
"`",
";",
"const",
"styles",
"=",
"m",
"(",
"'div'",
",",
"{",
"}",
",",
"cssFiles",
".",
"map",
"(",
"file",
"=>",
"m",
"(",
"'link'",
",",
"{",
"rel",
":",
"'stylesheet'",
",",
"href",
":",
"rootDir",
"+",
"file",
"}",
")",
")",
")",
";",
"m",
".",
"render",
"(",
"dom",
",",
"styles",
")",
";",
"}"
] | h4cky0 strikes again? mebbe there's a better way? ;x | [
"h4cky0",
"strikes",
"again?",
"mebbe",
"there",
"s",
"a",
"better",
"way?",
";",
"x"
] | 5d44624ca7e2109ece84445566ac44ca0d6d168d | https://github.com/Happy0/ssb-chess-mithril/blob/5d44624ca7e2109ece84445566ac44ca0d6d168d/index.js#L38-L44 |
23,874 | baoshan/wx | demo/public/vendor/smooth-scroll.js | function ( type, time ) {
if ( type == 'easeInQuad' ) return time * time; // accelerating from zero velocity
if ( type == 'easeOutQuad' ) return time * (2 - time); // decelerating to zero velocity
if ( type == 'easeInOutQuad' ) return time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; // acceleration until halfway, then deceleration
if ( type == 'easeInCubic' ) return time * time * time; // accelerating from zero velocity
if ( type == 'easeOutCubic' ) return (--time) * time * time + 1; // decelerating to zero velocity
if ( type == 'easeInOutCubic' ) return time < 0.5 ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1; // acceleration until halfway, then deceleration
if ( type == 'easeInQuart' ) return time * time * time * time; // accelerating from zero velocity
if ( type == 'easeOutQuart' ) return 1 - (--time) * time * time * time; // decelerating to zero velocity
if ( type == 'easeInOutQuart' ) return time < 0.5 ? 8 * time * time * time * time : 1 - 8 * (--time) * time * time * time; // acceleration until halfway, then deceleration
if ( type == 'easeInQuint' ) return time * time * time * time * time; // accelerating from zero velocity
if ( type == 'easeOutQuint' ) return 1 + (--time) * time * time * time * time; // decelerating to zero velocity
if ( type == 'easeInOutQuint' ) return time < 0.5 ? 16 * time * time * time * time * time : 1 + 16 * (--time) * time * time * time * time; // acceleration until halfway, then deceleration
return time; // no easing, no acceleration
} | javascript | function ( type, time ) {
if ( type == 'easeInQuad' ) return time * time; // accelerating from zero velocity
if ( type == 'easeOutQuad' ) return time * (2 - time); // decelerating to zero velocity
if ( type == 'easeInOutQuad' ) return time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; // acceleration until halfway, then deceleration
if ( type == 'easeInCubic' ) return time * time * time; // accelerating from zero velocity
if ( type == 'easeOutCubic' ) return (--time) * time * time + 1; // decelerating to zero velocity
if ( type == 'easeInOutCubic' ) return time < 0.5 ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1; // acceleration until halfway, then deceleration
if ( type == 'easeInQuart' ) return time * time * time * time; // accelerating from zero velocity
if ( type == 'easeOutQuart' ) return 1 - (--time) * time * time * time; // decelerating to zero velocity
if ( type == 'easeInOutQuart' ) return time < 0.5 ? 8 * time * time * time * time : 1 - 8 * (--time) * time * time * time; // acceleration until halfway, then deceleration
if ( type == 'easeInQuint' ) return time * time * time * time * time; // accelerating from zero velocity
if ( type == 'easeOutQuint' ) return 1 + (--time) * time * time * time * time; // decelerating to zero velocity
if ( type == 'easeInOutQuint' ) return time < 0.5 ? 16 * time * time * time * time * time : 1 + 16 * (--time) * time * time * time * time; // acceleration until halfway, then deceleration
return time; // no easing, no acceleration
} | [
"function",
"(",
"type",
",",
"time",
")",
"{",
"if",
"(",
"type",
"==",
"'easeInQuad'",
")",
"return",
"time",
"*",
"time",
";",
"// accelerating from zero velocity",
"if",
"(",
"type",
"==",
"'easeOutQuad'",
")",
"return",
"time",
"*",
"(",
"2",
"-",
"time",
")",
";",
"// decelerating to zero velocity",
"if",
"(",
"type",
"==",
"'easeInOutQuad'",
")",
"return",
"time",
"<",
"0.5",
"?",
"2",
"*",
"time",
"*",
"time",
":",
"-",
"1",
"+",
"(",
"4",
"-",
"2",
"*",
"time",
")",
"*",
"time",
";",
"// acceleration until halfway, then deceleration",
"if",
"(",
"type",
"==",
"'easeInCubic'",
")",
"return",
"time",
"*",
"time",
"*",
"time",
";",
"// accelerating from zero velocity",
"if",
"(",
"type",
"==",
"'easeOutCubic'",
")",
"return",
"(",
"--",
"time",
")",
"*",
"time",
"*",
"time",
"+",
"1",
";",
"// decelerating to zero velocity",
"if",
"(",
"type",
"==",
"'easeInOutCubic'",
")",
"return",
"time",
"<",
"0.5",
"?",
"4",
"*",
"time",
"*",
"time",
"*",
"time",
":",
"(",
"time",
"-",
"1",
")",
"*",
"(",
"2",
"*",
"time",
"-",
"2",
")",
"*",
"(",
"2",
"*",
"time",
"-",
"2",
")",
"+",
"1",
";",
"// acceleration until halfway, then deceleration",
"if",
"(",
"type",
"==",
"'easeInQuart'",
")",
"return",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
";",
"// accelerating from zero velocity",
"if",
"(",
"type",
"==",
"'easeOutQuart'",
")",
"return",
"1",
"-",
"(",
"--",
"time",
")",
"*",
"time",
"*",
"time",
"*",
"time",
";",
"// decelerating to zero velocity",
"if",
"(",
"type",
"==",
"'easeInOutQuart'",
")",
"return",
"time",
"<",
"0.5",
"?",
"8",
"*",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
":",
"1",
"-",
"8",
"*",
"(",
"--",
"time",
")",
"*",
"time",
"*",
"time",
"*",
"time",
";",
"// acceleration until halfway, then deceleration",
"if",
"(",
"type",
"==",
"'easeInQuint'",
")",
"return",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
";",
"// accelerating from zero velocity",
"if",
"(",
"type",
"==",
"'easeOutQuint'",
")",
"return",
"1",
"+",
"(",
"--",
"time",
")",
"*",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
";",
"// decelerating to zero velocity",
"if",
"(",
"type",
"==",
"'easeInOutQuint'",
")",
"return",
"time",
"<",
"0.5",
"?",
"16",
"*",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
":",
"1",
"+",
"16",
"*",
"(",
"--",
"time",
")",
"*",
"time",
"*",
"time",
"*",
"time",
"*",
"time",
";",
"// acceleration until halfway, then deceleration",
"return",
"time",
";",
"// no easing, no acceleration",
"}"
] | Calculate the easing pattern Private method Returns a decimal number | [
"Calculate",
"the",
"easing",
"pattern",
"Private",
"method",
"Returns",
"a",
"decimal",
"number"
] | 80478b48d3c940d40551a9a6928d0fa6d7883fde | https://github.com/baoshan/wx/blob/80478b48d3c940d40551a9a6928d0fa6d7883fde/demo/public/vendor/smooth-scroll.js#L43-L57 | |
23,875 | baoshan/wx | demo/public/vendor/smooth-scroll.js | function ( anchor, headerHeight, offset ) {
var location = 0;
if (anchor.offsetParent) {
do {
location += anchor.offsetTop;
anchor = anchor.offsetParent;
} while (anchor);
}
location = location - headerHeight - offset;
if ( location >= 0 ) {
return location;
} else {
return 0;
}
} | javascript | function ( anchor, headerHeight, offset ) {
var location = 0;
if (anchor.offsetParent) {
do {
location += anchor.offsetTop;
anchor = anchor.offsetParent;
} while (anchor);
}
location = location - headerHeight - offset;
if ( location >= 0 ) {
return location;
} else {
return 0;
}
} | [
"function",
"(",
"anchor",
",",
"headerHeight",
",",
"offset",
")",
"{",
"var",
"location",
"=",
"0",
";",
"if",
"(",
"anchor",
".",
"offsetParent",
")",
"{",
"do",
"{",
"location",
"+=",
"anchor",
".",
"offsetTop",
";",
"anchor",
"=",
"anchor",
".",
"offsetParent",
";",
"}",
"while",
"(",
"anchor",
")",
";",
"}",
"location",
"=",
"location",
"-",
"headerHeight",
"-",
"offset",
";",
"if",
"(",
"location",
">=",
"0",
")",
"{",
"return",
"location",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] | Calculate how far to scroll Private method Returns an integer | [
"Calculate",
"how",
"far",
"to",
"scroll",
"Private",
"method",
"Returns",
"an",
"integer"
] | 80478b48d3c940d40551a9a6928d0fa6d7883fde | https://github.com/baoshan/wx/blob/80478b48d3c940d40551a9a6928d0fa6d7883fde/demo/public/vendor/smooth-scroll.js#L62-L76 | |
23,876 | baoshan/wx | demo/public/vendor/smooth-scroll.js | function () {
return Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
} | javascript | function () {
return Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
} | [
"function",
"(",
")",
"{",
"return",
"Math",
".",
"max",
"(",
"document",
".",
"body",
".",
"scrollHeight",
",",
"document",
".",
"documentElement",
".",
"scrollHeight",
",",
"document",
".",
"body",
".",
"offsetHeight",
",",
"document",
".",
"documentElement",
".",
"offsetHeight",
",",
"document",
".",
"body",
".",
"clientHeight",
",",
"document",
".",
"documentElement",
".",
"clientHeight",
")",
";",
"}"
] | Determine the document's height Private method Returns an integer | [
"Determine",
"the",
"document",
"s",
"height",
"Private",
"method",
"Returns",
"an",
"integer"
] | 80478b48d3c940d40551a9a6928d0fa6d7883fde | https://github.com/baoshan/wx/blob/80478b48d3c940d40551a9a6928d0fa6d7883fde/demo/public/vendor/smooth-scroll.js#L81-L87 | |
23,877 | baoshan/wx | demo/public/vendor/smooth-scroll.js | function ( anchor, url ) {
if ( (url === true || url === 'true') && history.pushState ) {
history.pushState( {pos:anchor.id}, '', anchor );
}
} | javascript | function ( anchor, url ) {
if ( (url === true || url === 'true') && history.pushState ) {
history.pushState( {pos:anchor.id}, '', anchor );
}
} | [
"function",
"(",
"anchor",
",",
"url",
")",
"{",
"if",
"(",
"(",
"url",
"===",
"true",
"||",
"url",
"===",
"'true'",
")",
"&&",
"history",
".",
"pushState",
")",
"{",
"history",
".",
"pushState",
"(",
"{",
"pos",
":",
"anchor",
".",
"id",
"}",
",",
"''",
",",
"anchor",
")",
";",
"}",
"}"
] | Update the URL Private method Runs functions | [
"Update",
"the",
"URL",
"Private",
"method",
"Runs",
"functions"
] | 80478b48d3c940d40551a9a6928d0fa6d7883fde | https://github.com/baoshan/wx/blob/80478b48d3c940d40551a9a6928d0fa6d7883fde/demo/public/vendor/smooth-scroll.js#L117-L121 | |
23,878 | baoshan/wx | demo/public/vendor/smooth-scroll.js | function () {
timeLapsed += 16;
percentage = ( timeLapsed / speed );
percentage = ( percentage > 1 ) ? 1 : percentage;
position = startLocation + ( distance * _easingPattern(easing, percentage) );
window.scrollTo( 0, Math.floor(position) );
_stopAnimateScroll(position, endLocation, animationInterval);
} | javascript | function () {
timeLapsed += 16;
percentage = ( timeLapsed / speed );
percentage = ( percentage > 1 ) ? 1 : percentage;
position = startLocation + ( distance * _easingPattern(easing, percentage) );
window.scrollTo( 0, Math.floor(position) );
_stopAnimateScroll(position, endLocation, animationInterval);
} | [
"function",
"(",
")",
"{",
"timeLapsed",
"+=",
"16",
";",
"percentage",
"=",
"(",
"timeLapsed",
"/",
"speed",
")",
";",
"percentage",
"=",
"(",
"percentage",
">",
"1",
")",
"?",
"1",
":",
"percentage",
";",
"position",
"=",
"startLocation",
"+",
"(",
"distance",
"*",
"_easingPattern",
"(",
"easing",
",",
"percentage",
")",
")",
";",
"window",
".",
"scrollTo",
"(",
"0",
",",
"Math",
".",
"floor",
"(",
"position",
")",
")",
";",
"_stopAnimateScroll",
"(",
"position",
",",
"endLocation",
",",
"animationInterval",
")",
";",
"}"
] | Loop scrolling animation Private method Runs functions | [
"Loop",
"scrolling",
"animation",
"Private",
"method",
"Runs",
"functions"
] | 80478b48d3c940d40551a9a6928d0fa6d7883fde | https://github.com/baoshan/wx/blob/80478b48d3c940d40551a9a6928d0fa6d7883fde/demo/public/vendor/smooth-scroll.js#L169-L176 | |
23,879 | baoshan/wx | demo/public/vendor/smooth-scroll.js | function ( options ) {
// Feature test before initializing
if ( 'querySelector' in document && 'addEventListener' in window && Array.prototype.forEach ) {
// Selectors and variables
options = _mergeObjects( _defaults, options || {} ); // Merge user options with defaults
var toggles = document.querySelectorAll('[data-scroll]'); // Get smooth scroll toggles
// When a toggle is clicked, run the click handler
Array.prototype.forEach.call(toggles, function (toggle, index) {
toggle.addEventListener('click', animateScroll.bind( null, toggle, toggle.getAttribute('href'), options ), false);
});
}
} | javascript | function ( options ) {
// Feature test before initializing
if ( 'querySelector' in document && 'addEventListener' in window && Array.prototype.forEach ) {
// Selectors and variables
options = _mergeObjects( _defaults, options || {} ); // Merge user options with defaults
var toggles = document.querySelectorAll('[data-scroll]'); // Get smooth scroll toggles
// When a toggle is clicked, run the click handler
Array.prototype.forEach.call(toggles, function (toggle, index) {
toggle.addEventListener('click', animateScroll.bind( null, toggle, toggle.getAttribute('href'), options ), false);
});
}
} | [
"function",
"(",
"options",
")",
"{",
"// Feature test before initializing",
"if",
"(",
"'querySelector'",
"in",
"document",
"&&",
"'addEventListener'",
"in",
"window",
"&&",
"Array",
".",
"prototype",
".",
"forEach",
")",
"{",
"// Selectors and variables",
"options",
"=",
"_mergeObjects",
"(",
"_defaults",
",",
"options",
"||",
"{",
"}",
")",
";",
"// Merge user options with defaults",
"var",
"toggles",
"=",
"document",
".",
"querySelectorAll",
"(",
"'[data-scroll]'",
")",
";",
"// Get smooth scroll toggles",
"// When a toggle is clicked, run the click handler",
"Array",
".",
"prototype",
".",
"forEach",
".",
"call",
"(",
"toggles",
",",
"function",
"(",
"toggle",
",",
"index",
")",
"{",
"toggle",
".",
"addEventListener",
"(",
"'click'",
",",
"animateScroll",
".",
"bind",
"(",
"null",
",",
"toggle",
",",
"toggle",
".",
"getAttribute",
"(",
"'href'",
")",
",",
"options",
")",
",",
"false",
")",
";",
"}",
")",
";",
"}",
"}"
] | Initialize Smooth Scroll Public method Runs functions | [
"Initialize",
"Smooth",
"Scroll",
"Public",
"method",
"Runs",
"functions"
] | 80478b48d3c940d40551a9a6928d0fa6d7883fde | https://github.com/baoshan/wx/blob/80478b48d3c940d40551a9a6928d0fa6d7883fde/demo/public/vendor/smooth-scroll.js#L200-L216 | |
23,880 | ota-meshi/eslint-plugin-lodash-template | lib/rules/no-duplicate-attributes.js | report | function report(node) {
const name = node.key
context.report({
node,
loc: node.loc,
messageId: "duplicate",
data: { name },
})
} | javascript | function report(node) {
const name = node.key
context.report({
node,
loc: node.loc,
messageId: "duplicate",
data: { name },
})
} | [
"function",
"report",
"(",
"node",
")",
"{",
"const",
"name",
"=",
"node",
".",
"key",
"context",
".",
"report",
"(",
"{",
"node",
",",
"loc",
":",
"node",
".",
"loc",
",",
"messageId",
":",
"\"duplicate\"",
",",
"data",
":",
"{",
"name",
"}",
",",
"}",
")",
"}"
] | Report warning the given attribute node.
@param {Node} node The attribute node
@returns {void} | [
"Report",
"warning",
"the",
"given",
"attribute",
"node",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/no-duplicate-attributes.js#L33-L41 |
23,881 | ota-meshi/eslint-plugin-lodash-template | lib/rules/no-duplicate-attributes.js | groupByName | function groupByName(attrs) {
const attributes = new Map()
for (const node of attrs) {
const name = node.key
const list =
attributes.get(name) ||
(() => {
const a = []
attributes.set(name, a)
return a
})()
list.push(node)
}
return attributes
} | javascript | function groupByName(attrs) {
const attributes = new Map()
for (const node of attrs) {
const name = node.key
const list =
attributes.get(name) ||
(() => {
const a = []
attributes.set(name, a)
return a
})()
list.push(node)
}
return attributes
} | [
"function",
"groupByName",
"(",
"attrs",
")",
"{",
"const",
"attributes",
"=",
"new",
"Map",
"(",
")",
"for",
"(",
"const",
"node",
"of",
"attrs",
")",
"{",
"const",
"name",
"=",
"node",
".",
"key",
"const",
"list",
"=",
"attributes",
".",
"get",
"(",
"name",
")",
"||",
"(",
"(",
")",
"=>",
"{",
"const",
"a",
"=",
"[",
"]",
"attributes",
".",
"set",
"(",
"name",
",",
"a",
")",
"return",
"a",
"}",
")",
"(",
")",
"list",
".",
"push",
"(",
"node",
")",
"}",
"return",
"attributes",
"}"
] | Group by attribute name
@param {Array} attrs The attribute nodes
@returns {Map} The grouping Map | [
"Group",
"by",
"attribute",
"name"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/no-duplicate-attributes.js#L48-L62 |
23,882 | ota-meshi/eslint-plugin-lodash-template | lib/rules/no-duplicate-attributes.js | equalNode | function equalNode(n1, n2) {
return (
n1.type === n2.type &&
n1.range[0] === n2.range[0] &&
n1.range[1] === n2.range[1]
)
} | javascript | function equalNode(n1, n2) {
return (
n1.type === n2.type &&
n1.range[0] === n2.range[0] &&
n1.range[1] === n2.range[1]
)
} | [
"function",
"equalNode",
"(",
"n1",
",",
"n2",
")",
"{",
"return",
"(",
"n1",
".",
"type",
"===",
"n2",
".",
"type",
"&&",
"n1",
".",
"range",
"[",
"0",
"]",
"===",
"n2",
".",
"range",
"[",
"0",
"]",
"&&",
"n1",
".",
"range",
"[",
"1",
"]",
"===",
"n2",
".",
"range",
"[",
"1",
"]",
")",
"}"
] | Check if the nodes equals.
@param {Node} n1 The node
@param {Node} n2 The node
@returns {boolean} `true` if the nodes equals. | [
"Check",
"if",
"the",
"nodes",
"equals",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/no-duplicate-attributes.js#L70-L76 |
23,883 | ota-meshi/eslint-plugin-lodash-template | lib/rules/no-duplicate-attributes.js | validateNameGroup | function validateNameGroup(nodes, _name) {
if (nodes.length <= 1) {
return
}
for (const target of nodes) {
const node =
microTemplateService.getBranchProcessedHtmlNode(
target,
sourceCode
) || target
const startTag = node.parent
const hasDup = startTag.attributes
.concat(startTag.ignoredAttributes)
.filter(attr => !equalNode(attr, node))
.some(attr =>
microTemplateService.findToken(
nodes,
n =>
n.type === attr.type &&
n.range[0] === attr.range[0] &&
n.range[1] === attr.range[1]
)
)
if (hasDup) {
report(target)
}
}
} | javascript | function validateNameGroup(nodes, _name) {
if (nodes.length <= 1) {
return
}
for (const target of nodes) {
const node =
microTemplateService.getBranchProcessedHtmlNode(
target,
sourceCode
) || target
const startTag = node.parent
const hasDup = startTag.attributes
.concat(startTag.ignoredAttributes)
.filter(attr => !equalNode(attr, node))
.some(attr =>
microTemplateService.findToken(
nodes,
n =>
n.type === attr.type &&
n.range[0] === attr.range[0] &&
n.range[1] === attr.range[1]
)
)
if (hasDup) {
report(target)
}
}
} | [
"function",
"validateNameGroup",
"(",
"nodes",
",",
"_name",
")",
"{",
"if",
"(",
"nodes",
".",
"length",
"<=",
"1",
")",
"{",
"return",
"}",
"for",
"(",
"const",
"target",
"of",
"nodes",
")",
"{",
"const",
"node",
"=",
"microTemplateService",
".",
"getBranchProcessedHtmlNode",
"(",
"target",
",",
"sourceCode",
")",
"||",
"target",
"const",
"startTag",
"=",
"node",
".",
"parent",
"const",
"hasDup",
"=",
"startTag",
".",
"attributes",
".",
"concat",
"(",
"startTag",
".",
"ignoredAttributes",
")",
".",
"filter",
"(",
"attr",
"=>",
"!",
"equalNode",
"(",
"attr",
",",
"node",
")",
")",
".",
"some",
"(",
"attr",
"=>",
"microTemplateService",
".",
"findToken",
"(",
"nodes",
",",
"n",
"=>",
"n",
".",
"type",
"===",
"attr",
".",
"type",
"&&",
"n",
".",
"range",
"[",
"0",
"]",
"===",
"attr",
".",
"range",
"[",
"0",
"]",
"&&",
"n",
".",
"range",
"[",
"1",
"]",
"===",
"attr",
".",
"range",
"[",
"1",
"]",
")",
")",
"if",
"(",
"hasDup",
")",
"{",
"report",
"(",
"target",
")",
"}",
"}",
"}"
] | Validation by attribute name
@param {Array} nodes The attribute nodes
@param {string} _name The attribut name
@returns {void} | [
"Validation",
"by",
"attribute",
"name"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/no-duplicate-attributes.js#L84-L111 |
23,884 | ota-meshi/eslint-plugin-lodash-template | lib/rules/no-duplicate-attributes.js | validateAttrs | function validateAttrs(attrs) {
const attributes = groupByName(attrs)
attributes.forEach((nodes, name) => {
validateNameGroup(nodes, name)
})
} | javascript | function validateAttrs(attrs) {
const attributes = groupByName(attrs)
attributes.forEach((nodes, name) => {
validateNameGroup(nodes, name)
})
} | [
"function",
"validateAttrs",
"(",
"attrs",
")",
"{",
"const",
"attributes",
"=",
"groupByName",
"(",
"attrs",
")",
"attributes",
".",
"forEach",
"(",
"(",
"nodes",
",",
"name",
")",
"=>",
"{",
"validateNameGroup",
"(",
"nodes",
",",
"name",
")",
"}",
")",
"}"
] | Validate attribute nodes
@param {Array} attrs The attribute nodes
@returns {void} | [
"Validate",
"attribute",
"nodes"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/no-duplicate-attributes.js#L118-L123 |
23,885 | ota-meshi/eslint-plugin-lodash-template | tools/lib/load-configs.js | readConfigs | function readConfigs() {
const configsRoot = path.resolve(__dirname, "../../lib/configs")
const result = fs.readdirSync(configsRoot)
const configs = []
for (const name of result) {
const configName = name.replace(/\.js$/u, "")
const configId = `plugin:lodash-template/${configName}`
const configPath = require.resolve(path.join(configsRoot, name))
const config = require(configPath)
configs.push({
name: configName,
configId,
config,
path: configPath,
})
}
return configs
} | javascript | function readConfigs() {
const configsRoot = path.resolve(__dirname, "../../lib/configs")
const result = fs.readdirSync(configsRoot)
const configs = []
for (const name of result) {
const configName = name.replace(/\.js$/u, "")
const configId = `plugin:lodash-template/${configName}`
const configPath = require.resolve(path.join(configsRoot, name))
const config = require(configPath)
configs.push({
name: configName,
configId,
config,
path: configPath,
})
}
return configs
} | [
"function",
"readConfigs",
"(",
")",
"{",
"const",
"configsRoot",
"=",
"path",
".",
"resolve",
"(",
"__dirname",
",",
"\"../../lib/configs\"",
")",
"const",
"result",
"=",
"fs",
".",
"readdirSync",
"(",
"configsRoot",
")",
"const",
"configs",
"=",
"[",
"]",
"for",
"(",
"const",
"name",
"of",
"result",
")",
"{",
"const",
"configName",
"=",
"name",
".",
"replace",
"(",
"/",
"\\.js$",
"/",
"u",
",",
"\"\"",
")",
"const",
"configId",
"=",
"`",
"${",
"configName",
"}",
"`",
"const",
"configPath",
"=",
"require",
".",
"resolve",
"(",
"path",
".",
"join",
"(",
"configsRoot",
",",
"name",
")",
")",
"const",
"config",
"=",
"require",
"(",
"configPath",
")",
"configs",
".",
"push",
"(",
"{",
"name",
":",
"configName",
",",
"configId",
",",
"config",
",",
"path",
":",
"configPath",
",",
"}",
")",
"}",
"return",
"configs",
"}"
] | Get the all configs
@returns {Array} The all configs | [
"Get",
"the",
"all",
"configs"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/tools/lib/load-configs.js#L10-L28 |
23,886 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | getActualLineIndentText | function getActualLineIndentText(line) {
let actualText = actualLineIndentTexts.get(line)
if (actualText === undefined) {
const lineText = getLineText(line)
const index = lineText.search(/\S/u)
if (index >= 0) {
actualText = lineText.slice(0, index)
} else {
actualText = lineText
}
actualLineIndentTexts.set(line, actualText)
}
return actualText
} | javascript | function getActualLineIndentText(line) {
let actualText = actualLineIndentTexts.get(line)
if (actualText === undefined) {
const lineText = getLineText(line)
const index = lineText.search(/\S/u)
if (index >= 0) {
actualText = lineText.slice(0, index)
} else {
actualText = lineText
}
actualLineIndentTexts.set(line, actualText)
}
return actualText
} | [
"function",
"getActualLineIndentText",
"(",
"line",
")",
"{",
"let",
"actualText",
"=",
"actualLineIndentTexts",
".",
"get",
"(",
"line",
")",
"if",
"(",
"actualText",
"===",
"undefined",
")",
"{",
"const",
"lineText",
"=",
"getLineText",
"(",
"line",
")",
"const",
"index",
"=",
"lineText",
".",
"search",
"(",
"/",
"\\S",
"/",
"u",
")",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"actualText",
"=",
"lineText",
".",
"slice",
"(",
"0",
",",
"index",
")",
"}",
"else",
"{",
"actualText",
"=",
"lineText",
"}",
"actualLineIndentTexts",
".",
"set",
"(",
"line",
",",
"actualText",
")",
"}",
"return",
"actualText",
"}"
] | Get the actual indent text of the line which the given line is on.
@param {number} line The line no.
@returns {string} The text of actual indent. | [
"Get",
"the",
"actual",
"indent",
"text",
"of",
"the",
"line",
"which",
"the",
"given",
"line",
"is",
"on",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L209-L222 |
23,887 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | getTopLevelIndentByTemplateTag | function getTopLevelIndentByTemplateTag(templateTag) {
const baseIndentText = getActualLineIndentText(
templateTag.loc.start.line
)
return new ExpectedIndent(
baseIndentText,
options.indentSize * options.startIndent
)
} | javascript | function getTopLevelIndentByTemplateTag(templateTag) {
const baseIndentText = getActualLineIndentText(
templateTag.loc.start.line
)
return new ExpectedIndent(
baseIndentText,
options.indentSize * options.startIndent
)
} | [
"function",
"getTopLevelIndentByTemplateTag",
"(",
"templateTag",
")",
"{",
"const",
"baseIndentText",
"=",
"getActualLineIndentText",
"(",
"templateTag",
".",
"loc",
".",
"start",
".",
"line",
")",
"return",
"new",
"ExpectedIndent",
"(",
"baseIndentText",
",",
"options",
".",
"indentSize",
"*",
"options",
".",
"startIndent",
")",
"}"
] | Calculate correct indentation of the top level in the given template tag.
@param {Token} templateTag The template tag.
@returns {ExpectedIndent} Correct indentation. | [
"Calculate",
"correct",
"indentation",
"of",
"the",
"top",
"level",
"in",
"the",
"given",
"template",
"tag",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L299-L307 |
23,888 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | setOffsetToNodeList | function setOffsetToNodeList(nodeList, leftToken, offset, baseToken) {
for (const t of genCollectNodeList(nodeList, leftToken, null)) {
setOffsetToToken(t, offset, baseToken)
}
} | javascript | function setOffsetToNodeList(nodeList, leftToken, offset, baseToken) {
for (const t of genCollectNodeList(nodeList, leftToken, null)) {
setOffsetToToken(t, offset, baseToken)
}
} | [
"function",
"setOffsetToNodeList",
"(",
"nodeList",
",",
"leftToken",
",",
"offset",
",",
"baseToken",
")",
"{",
"for",
"(",
"const",
"t",
"of",
"genCollectNodeList",
"(",
"nodeList",
",",
"leftToken",
",",
"null",
")",
")",
"{",
"setOffsetToToken",
"(",
"t",
",",
"offset",
",",
"baseToken",
")",
"}",
"}"
] | Set offset the given node list.
@param {Node[]} nodeList The node to process.
@param {Node|null} leftToken The left parenthesis token.
@param {number} offset The offset to set.
@param {Token} baseToken The token of the base offset.
@returns {void} | [
"Set",
"offset",
"the",
"given",
"node",
"list",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L560-L564 |
23,889 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | inTemplateTag | function inTemplateTag(line) {
if (line <= 1) {
return false
}
const lineStartIndex = sourceCode.getIndexFromLoc({
line,
column: 0,
})
return microTemplateService.inTemplateTag(lineStartIndex - 1)
} | javascript | function inTemplateTag(line) {
if (line <= 1) {
return false
}
const lineStartIndex = sourceCode.getIndexFromLoc({
line,
column: 0,
})
return microTemplateService.inTemplateTag(lineStartIndex - 1)
} | [
"function",
"inTemplateTag",
"(",
"line",
")",
"{",
"if",
"(",
"line",
"<=",
"1",
")",
"{",
"return",
"false",
"}",
"const",
"lineStartIndex",
"=",
"sourceCode",
".",
"getIndexFromLoc",
"(",
"{",
"line",
",",
"column",
":",
"0",
",",
"}",
")",
"return",
"microTemplateService",
".",
"inTemplateTag",
"(",
"lineStartIndex",
"-",
"1",
")",
"}"
] | Check whether the line start is in template tag.
@param {number} line The line.
@returns {boolean} `true` if the line start is in template tag. | [
"Check",
"whether",
"the",
"line",
"start",
"is",
"in",
"template",
"tag",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L611-L620 |
23,890 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | validateBaseIndent | function validateBaseIndent(line, actualText, expectedIndent) {
const expectedBaseIndentText = expectedIndent.baseIndentText
if (
expectedBaseIndentText &&
(actualText.length < expectedBaseIndentText.length ||
!actualText.startsWith(expectedBaseIndentText))
) {
context.report({
loc: {
start: { line, column: 0 },
end: {
line,
column: actualText.length,
},
},
messageId: actualText
? "unexpectedBaseIndentation"
: "missingBaseIndentation",
data: {
expected: JSON.stringify(expectedBaseIndentText),
actual: actualText
? JSON.stringify(
actualText.slice(
0,
expectedBaseIndentText.length
)
)
: "",
},
fix: defineFix(line, actualText, expectedIndent),
})
return false
}
return true
} | javascript | function validateBaseIndent(line, actualText, expectedIndent) {
const expectedBaseIndentText = expectedIndent.baseIndentText
if (
expectedBaseIndentText &&
(actualText.length < expectedBaseIndentText.length ||
!actualText.startsWith(expectedBaseIndentText))
) {
context.report({
loc: {
start: { line, column: 0 },
end: {
line,
column: actualText.length,
},
},
messageId: actualText
? "unexpectedBaseIndentation"
: "missingBaseIndentation",
data: {
expected: JSON.stringify(expectedBaseIndentText),
actual: actualText
? JSON.stringify(
actualText.slice(
0,
expectedBaseIndentText.length
)
)
: "",
},
fix: defineFix(line, actualText, expectedIndent),
})
return false
}
return true
} | [
"function",
"validateBaseIndent",
"(",
"line",
",",
"actualText",
",",
"expectedIndent",
")",
"{",
"const",
"expectedBaseIndentText",
"=",
"expectedIndent",
".",
"baseIndentText",
"if",
"(",
"expectedBaseIndentText",
"&&",
"(",
"actualText",
".",
"length",
"<",
"expectedBaseIndentText",
".",
"length",
"||",
"!",
"actualText",
".",
"startsWith",
"(",
"expectedBaseIndentText",
")",
")",
")",
"{",
"context",
".",
"report",
"(",
"{",
"loc",
":",
"{",
"start",
":",
"{",
"line",
",",
"column",
":",
"0",
"}",
",",
"end",
":",
"{",
"line",
",",
"column",
":",
"actualText",
".",
"length",
",",
"}",
",",
"}",
",",
"messageId",
":",
"actualText",
"?",
"\"unexpectedBaseIndentation\"",
":",
"\"missingBaseIndentation\"",
",",
"data",
":",
"{",
"expected",
":",
"JSON",
".",
"stringify",
"(",
"expectedBaseIndentText",
")",
",",
"actual",
":",
"actualText",
"?",
"JSON",
".",
"stringify",
"(",
"actualText",
".",
"slice",
"(",
"0",
",",
"expectedBaseIndentText",
".",
"length",
")",
")",
":",
"\"\"",
",",
"}",
",",
"fix",
":",
"defineFix",
"(",
"line",
",",
"actualText",
",",
"expectedIndent",
")",
",",
"}",
")",
"return",
"false",
"}",
"return",
"true",
"}"
] | Validate base point indentation.
@param {number} line The number of line.
@param {string} actualText The actual indentation text.
@param {ExpectedIndent} expectedIndent The expected indent.
@returns {void} | [
"Validate",
"base",
"point",
"indentation",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L650-L684 |
23,891 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | processNonSpecifier | function processNonSpecifier() {
const secondToken = sourceCode.getFirstToken(node, 1)
if (isLeftBrace(secondToken)) {
setOffsetToToken(
[
secondToken,
sourceCode.getTokenAfter(secondToken),
],
0,
importToken
)
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} else {
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 1 : 0)
)
}
} | javascript | function processNonSpecifier() {
const secondToken = sourceCode.getFirstToken(node, 1)
if (isLeftBrace(secondToken)) {
setOffsetToToken(
[
secondToken,
sourceCode.getTokenAfter(secondToken),
],
0,
importToken
)
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} else {
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 1 : 0)
)
}
} | [
"function",
"processNonSpecifier",
"(",
")",
"{",
"const",
"secondToken",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
",",
"1",
")",
"if",
"(",
"isLeftBrace",
"(",
"secondToken",
")",
")",
"{",
"setOffsetToToken",
"(",
"[",
"secondToken",
",",
"sourceCode",
".",
"getTokenAfter",
"(",
"secondToken",
")",
",",
"]",
",",
"0",
",",
"importToken",
")",
"tokens",
".",
"push",
"(",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"2",
":",
"1",
")",
",",
"// from",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"1",
":",
"0",
")",
"// \"foo\"",
")",
"}",
"else",
"{",
"tokens",
".",
"push",
"(",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"1",
":",
"0",
")",
")",
"}",
"}"
] | Process when the specifier does not exist
@returns {void} | [
"Process",
"when",
"the",
"specifier",
"does",
"not",
"exist"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L1144-L1164 |
23,892 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | processImportDefaultSpecifier | function processImportDefaultSpecifier() {
if (
secondSpecifier &&
secondSpecifier.type === "ImportNamespaceSpecifier"
) {
// There is a pattern:
// import Foo, * as foo from "foo"
tokens.push(
sourceCode.getFirstToken(firstSpecifier), // Foo
sourceCode.getTokenAfter(firstSpecifier), // comma
sourceCode.getFirstToken(secondSpecifier), // *
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} else {
// There are 3 patterns:
// import Foo from "foo"
// import Foo, {} from "foo"
// import Foo, {a} from "foo"
const idToken = sourceCode.getFirstToken(firstSpecifier)
const nextToken = sourceCode.getTokenAfter(
firstSpecifier
)
if (isComma(nextToken)) {
const leftBrace = sourceCode.getTokenAfter(
nextToken
)
const rightBrace = sourceCode.getLastToken(
node,
hasSemi ? 3 : 2
)
setOffsetToToken(
[idToken, nextToken],
1,
importToken
)
setOffsetToToken(leftBrace, 0, idToken)
processNodeList(
node.specifiers.slice(1),
leftBrace,
rightBrace,
1
)
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} else {
tokens.push(
idToken,
nextToken, // from
sourceCode.getTokenAfter(nextToken) // "foo"
)
}
}
} | javascript | function processImportDefaultSpecifier() {
if (
secondSpecifier &&
secondSpecifier.type === "ImportNamespaceSpecifier"
) {
// There is a pattern:
// import Foo, * as foo from "foo"
tokens.push(
sourceCode.getFirstToken(firstSpecifier), // Foo
sourceCode.getTokenAfter(firstSpecifier), // comma
sourceCode.getFirstToken(secondSpecifier), // *
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} else {
// There are 3 patterns:
// import Foo from "foo"
// import Foo, {} from "foo"
// import Foo, {a} from "foo"
const idToken = sourceCode.getFirstToken(firstSpecifier)
const nextToken = sourceCode.getTokenAfter(
firstSpecifier
)
if (isComma(nextToken)) {
const leftBrace = sourceCode.getTokenAfter(
nextToken
)
const rightBrace = sourceCode.getLastToken(
node,
hasSemi ? 3 : 2
)
setOffsetToToken(
[idToken, nextToken],
1,
importToken
)
setOffsetToToken(leftBrace, 0, idToken)
processNodeList(
node.specifiers.slice(1),
leftBrace,
rightBrace,
1
)
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} else {
tokens.push(
idToken,
nextToken, // from
sourceCode.getTokenAfter(nextToken) // "foo"
)
}
}
} | [
"function",
"processImportDefaultSpecifier",
"(",
")",
"{",
"if",
"(",
"secondSpecifier",
"&&",
"secondSpecifier",
".",
"type",
"===",
"\"ImportNamespaceSpecifier\"",
")",
"{",
"// There is a pattern:",
"// import Foo, * as foo from \"foo\"",
"tokens",
".",
"push",
"(",
"sourceCode",
".",
"getFirstToken",
"(",
"firstSpecifier",
")",
",",
"// Foo",
"sourceCode",
".",
"getTokenAfter",
"(",
"firstSpecifier",
")",
",",
"// comma",
"sourceCode",
".",
"getFirstToken",
"(",
"secondSpecifier",
")",
",",
"// *",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"2",
":",
"1",
")",
",",
"// from",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"1",
":",
"0",
")",
"// \"foo\"",
")",
"}",
"else",
"{",
"// There are 3 patterns:",
"// import Foo from \"foo\"",
"// import Foo, {} from \"foo\"",
"// import Foo, {a} from \"foo\"",
"const",
"idToken",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"firstSpecifier",
")",
"const",
"nextToken",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"firstSpecifier",
")",
"if",
"(",
"isComma",
"(",
"nextToken",
")",
")",
"{",
"const",
"leftBrace",
"=",
"sourceCode",
".",
"getTokenAfter",
"(",
"nextToken",
")",
"const",
"rightBrace",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"3",
":",
"2",
")",
"setOffsetToToken",
"(",
"[",
"idToken",
",",
"nextToken",
"]",
",",
"1",
",",
"importToken",
")",
"setOffsetToToken",
"(",
"leftBrace",
",",
"0",
",",
"idToken",
")",
"processNodeList",
"(",
"node",
".",
"specifiers",
".",
"slice",
"(",
"1",
")",
",",
"leftBrace",
",",
"rightBrace",
",",
"1",
")",
"tokens",
".",
"push",
"(",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"2",
":",
"1",
")",
",",
"// from",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"1",
":",
"0",
")",
"// \"foo\"",
")",
"}",
"else",
"{",
"tokens",
".",
"push",
"(",
"idToken",
",",
"nextToken",
",",
"// from",
"sourceCode",
".",
"getTokenAfter",
"(",
"nextToken",
")",
"// \"foo\"",
")",
"}",
"}",
"}"
] | Process when the specifier is ImportDefaultSpecifier
@returns {void} | [
"Process",
"when",
"the",
"specifier",
"is",
"ImportDefaultSpecifier"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L1170-L1225 |
23,893 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | processImportNamespaceSpecifier | function processImportNamespaceSpecifier() {
tokens.push(
sourceCode.getFirstToken(firstSpecifier), // *
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} | javascript | function processImportNamespaceSpecifier() {
tokens.push(
sourceCode.getFirstToken(firstSpecifier), // *
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} | [
"function",
"processImportNamespaceSpecifier",
"(",
")",
"{",
"tokens",
".",
"push",
"(",
"sourceCode",
".",
"getFirstToken",
"(",
"firstSpecifier",
")",
",",
"// *",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"2",
":",
"1",
")",
",",
"// from",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"1",
":",
"0",
")",
"// \"foo\"",
")",
"}"
] | Process when the specifier is ImportNamespaceSpecifier
@returns {void} | [
"Process",
"when",
"the",
"specifier",
"is",
"ImportNamespaceSpecifier"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L1231-L1237 |
23,894 | ota-meshi/eslint-plugin-lodash-template | lib/rules/script-indent.js | processOtherSpecifier | function processOtherSpecifier() {
const leftBrace = sourceCode.getFirstToken(node, 1)
const rightBrace = sourceCode.getLastToken(
node,
hasSemi ? 3 : 2
)
setOffsetToToken(leftBrace, 0, importToken)
processNodeList(node.specifiers, leftBrace, rightBrace, 1)
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} | javascript | function processOtherSpecifier() {
const leftBrace = sourceCode.getFirstToken(node, 1)
const rightBrace = sourceCode.getLastToken(
node,
hasSemi ? 3 : 2
)
setOffsetToToken(leftBrace, 0, importToken)
processNodeList(node.specifiers, leftBrace, rightBrace, 1)
tokens.push(
sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
)
} | [
"function",
"processOtherSpecifier",
"(",
")",
"{",
"const",
"leftBrace",
"=",
"sourceCode",
".",
"getFirstToken",
"(",
"node",
",",
"1",
")",
"const",
"rightBrace",
"=",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"3",
":",
"2",
")",
"setOffsetToToken",
"(",
"leftBrace",
",",
"0",
",",
"importToken",
")",
"processNodeList",
"(",
"node",
".",
"specifiers",
",",
"leftBrace",
",",
"rightBrace",
",",
"1",
")",
"tokens",
".",
"push",
"(",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"2",
":",
"1",
")",
",",
"// from",
"sourceCode",
".",
"getLastToken",
"(",
"node",
",",
"hasSemi",
"?",
"1",
":",
"0",
")",
"// \"foo\"",
")",
"}"
] | Process when the specifier is other
@returns {void} | [
"Process",
"when",
"the",
"specifier",
"is",
"other"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/script-indent.js#L1243-L1255 |
23,895 | ota-meshi/eslint-plugin-lodash-template | lib/rules/html-closing-bracket-spacing.js | getLastLocationInTag | function getLastLocationInTag(node) {
const tagClose = node.tagClose
const text = sourceCode.text.slice(node.range[0], tagClose.range[0])
const index = text.search(/\S\s*$/gu) + node.range[0] + 1
return {
index,
loc: sourceCode.getLocFromIndex(index),
}
} | javascript | function getLastLocationInTag(node) {
const tagClose = node.tagClose
const text = sourceCode.text.slice(node.range[0], tagClose.range[0])
const index = text.search(/\S\s*$/gu) + node.range[0] + 1
return {
index,
loc: sourceCode.getLocFromIndex(index),
}
} | [
"function",
"getLastLocationInTag",
"(",
"node",
")",
"{",
"const",
"tagClose",
"=",
"node",
".",
"tagClose",
"const",
"text",
"=",
"sourceCode",
".",
"text",
".",
"slice",
"(",
"node",
".",
"range",
"[",
"0",
"]",
",",
"tagClose",
".",
"range",
"[",
"0",
"]",
")",
"const",
"index",
"=",
"text",
".",
"search",
"(",
"/",
"\\S\\s*$",
"/",
"gu",
")",
"+",
"node",
".",
"range",
"[",
"0",
"]",
"+",
"1",
"return",
"{",
"index",
",",
"loc",
":",
"sourceCode",
".",
"getLocFromIndex",
"(",
"index",
")",
",",
"}",
"}"
] | Get last location
@param {ASTNode} node The node
@returns {object} The last location | [
"Get",
"last",
"location"
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/html-closing-bracket-spacing.js#L73-L81 |
23,896 | ota-meshi/eslint-plugin-lodash-template | lib/service/comment-directive.js | locationInRangeLoc | function locationInRangeLoc(loc, start, end) {
if (loc.line < start.line || end.line < loc.line) {
return false
}
if (loc.line === start.line) {
if (start.column > loc.column) {
return false
}
}
if (loc.line === end.line) {
if (loc.column >= end.column) {
return false
}
}
return true
} | javascript | function locationInRangeLoc(loc, start, end) {
if (loc.line < start.line || end.line < loc.line) {
return false
}
if (loc.line === start.line) {
if (start.column > loc.column) {
return false
}
}
if (loc.line === end.line) {
if (loc.column >= end.column) {
return false
}
}
return true
} | [
"function",
"locationInRangeLoc",
"(",
"loc",
",",
"start",
",",
"end",
")",
"{",
"if",
"(",
"loc",
".",
"line",
"<",
"start",
".",
"line",
"||",
"end",
".",
"line",
"<",
"loc",
".",
"line",
")",
"{",
"return",
"false",
"}",
"if",
"(",
"loc",
".",
"line",
"===",
"start",
".",
"line",
")",
"{",
"if",
"(",
"start",
".",
"column",
">",
"loc",
".",
"column",
")",
"{",
"return",
"false",
"}",
"}",
"if",
"(",
"loc",
".",
"line",
"===",
"end",
".",
"line",
")",
"{",
"if",
"(",
"loc",
".",
"column",
">=",
"end",
".",
"column",
")",
"{",
"return",
"false",
"}",
"}",
"return",
"true",
"}"
] | Check whether the location is in range location.
@param {object} loc The location.
@param {object} start The start location.
@param {object} end The end location.
@returns {boolean} `true` if the location is in range location. | [
"Check",
"whether",
"the",
"location",
"is",
"in",
"range",
"location",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/service/comment-directive.js#L178-L193 |
23,897 | ota-meshi/eslint-plugin-lodash-template | lib/rules/no-warning-html-comments.js | commentContainsWarningTerm | function commentContainsWarningTerm(comment) {
const matches = []
warningRegExps.forEach((regex, index) => {
if (regex.test(comment)) {
matches.push(warningTerms[index])
}
})
return matches
} | javascript | function commentContainsWarningTerm(comment) {
const matches = []
warningRegExps.forEach((regex, index) => {
if (regex.test(comment)) {
matches.push(warningTerms[index])
}
})
return matches
} | [
"function",
"commentContainsWarningTerm",
"(",
"comment",
")",
"{",
"const",
"matches",
"=",
"[",
"]",
"warningRegExps",
".",
"forEach",
"(",
"(",
"regex",
",",
"index",
")",
"=>",
"{",
"if",
"(",
"regex",
".",
"test",
"(",
"comment",
")",
")",
"{",
"matches",
".",
"push",
"(",
"warningTerms",
"[",
"index",
"]",
")",
"}",
"}",
")",
"return",
"matches",
"}"
] | Checks the specified comment for matches of the configured warning terms and returns the matches.
@param {string} comment The comment which is checked.
@returns {Array} All matched warning terms for this comment. | [
"Checks",
"the",
"specified",
"comment",
"for",
"matches",
"of",
"the",
"configured",
"warning",
"terms",
"and",
"returns",
"the",
"matches",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/rules/no-warning-html-comments.js#L97-L107 |
23,898 | ota-meshi/eslint-plugin-lodash-template | lib/processor/micro-template-processor.js | postprocessForDisableRules | function postprocessForDisableRules(messages, microTemplateService) {
const option = microTemplateService.systemOption || {}
const ignoreRules = DISABLED_RULES.concat(option.ignoreRules || [])
const globals = GLOBALS.concat(option.globals || [])
return messages.filter(message => {
if (ignoreRules.indexOf(message.ruleId) >= 0) {
return false
}
if (
microTemplateService.inTemplate(message) &&
TEMPLATE_DISABLED_RULES.indexOf(message.ruleId) >= 0
) {
return false
}
if (
microTemplateService.inInterpolateOrEscape(message) &&
TMPL_INTERPOLATE_DISABLED_RULES.indexOf(message.ruleId) >= 0
) {
return false
}
if (
microTemplateService.inDelimiterMarks(message) &&
TMPL_DELIMITERS_DISABLED_RULES.indexOf(message.ruleId) >= 0
) {
return false
}
if (message.ruleId === "no-undef") {
if (
globals
.map(g => `'${g}' is not defined.`)
.indexOf(message.message) >= 0
) {
return false
}
}
if (message.ruleId === "quotes") {
if (message.message === "Strings must use doublequote.") {
return false
}
}
return true
})
} | javascript | function postprocessForDisableRules(messages, microTemplateService) {
const option = microTemplateService.systemOption || {}
const ignoreRules = DISABLED_RULES.concat(option.ignoreRules || [])
const globals = GLOBALS.concat(option.globals || [])
return messages.filter(message => {
if (ignoreRules.indexOf(message.ruleId) >= 0) {
return false
}
if (
microTemplateService.inTemplate(message) &&
TEMPLATE_DISABLED_RULES.indexOf(message.ruleId) >= 0
) {
return false
}
if (
microTemplateService.inInterpolateOrEscape(message) &&
TMPL_INTERPOLATE_DISABLED_RULES.indexOf(message.ruleId) >= 0
) {
return false
}
if (
microTemplateService.inDelimiterMarks(message) &&
TMPL_DELIMITERS_DISABLED_RULES.indexOf(message.ruleId) >= 0
) {
return false
}
if (message.ruleId === "no-undef") {
if (
globals
.map(g => `'${g}' is not defined.`)
.indexOf(message.message) >= 0
) {
return false
}
}
if (message.ruleId === "quotes") {
if (message.message === "Strings must use doublequote.") {
return false
}
}
return true
})
} | [
"function",
"postprocessForDisableRules",
"(",
"messages",
",",
"microTemplateService",
")",
"{",
"const",
"option",
"=",
"microTemplateService",
".",
"systemOption",
"||",
"{",
"}",
"const",
"ignoreRules",
"=",
"DISABLED_RULES",
".",
"concat",
"(",
"option",
".",
"ignoreRules",
"||",
"[",
"]",
")",
"const",
"globals",
"=",
"GLOBALS",
".",
"concat",
"(",
"option",
".",
"globals",
"||",
"[",
"]",
")",
"return",
"messages",
".",
"filter",
"(",
"message",
"=>",
"{",
"if",
"(",
"ignoreRules",
".",
"indexOf",
"(",
"message",
".",
"ruleId",
")",
">=",
"0",
")",
"{",
"return",
"false",
"}",
"if",
"(",
"microTemplateService",
".",
"inTemplate",
"(",
"message",
")",
"&&",
"TEMPLATE_DISABLED_RULES",
".",
"indexOf",
"(",
"message",
".",
"ruleId",
")",
">=",
"0",
")",
"{",
"return",
"false",
"}",
"if",
"(",
"microTemplateService",
".",
"inInterpolateOrEscape",
"(",
"message",
")",
"&&",
"TMPL_INTERPOLATE_DISABLED_RULES",
".",
"indexOf",
"(",
"message",
".",
"ruleId",
")",
">=",
"0",
")",
"{",
"return",
"false",
"}",
"if",
"(",
"microTemplateService",
".",
"inDelimiterMarks",
"(",
"message",
")",
"&&",
"TMPL_DELIMITERS_DISABLED_RULES",
".",
"indexOf",
"(",
"message",
".",
"ruleId",
")",
">=",
"0",
")",
"{",
"return",
"false",
"}",
"if",
"(",
"message",
".",
"ruleId",
"===",
"\"no-undef\"",
")",
"{",
"if",
"(",
"globals",
".",
"map",
"(",
"g",
"=>",
"`",
"${",
"g",
"}",
"`",
")",
".",
"indexOf",
"(",
"message",
".",
"message",
")",
">=",
"0",
")",
"{",
"return",
"false",
"}",
"}",
"if",
"(",
"message",
".",
"ruleId",
"===",
"\"quotes\"",
")",
"{",
"if",
"(",
"message",
".",
"message",
"===",
"\"Strings must use doublequote.\"",
")",
"{",
"return",
"false",
"}",
"}",
"return",
"true",
"}",
")",
"}"
] | postprocess for Filter disable rules messages.
@param {Array} messages The base messages.
@param {object} microTemplateService The MicroTemplateService.
@returns {Array} messages The processed messages. | [
"postprocess",
"for",
"Filter",
"disable",
"rules",
"messages",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/processor/micro-template-processor.js#L30-L75 |
23,899 | ota-meshi/eslint-plugin-lodash-template | lib/service/MicroTemplateService.js | tryParseSelector | function tryParseSelector(rawSelector) {
try {
return esquery.parse(rawSelector.replace(/:exit$/u, ""))
} catch (err) {
if (typeof err.offset === "number") {
throw new Error(
`Syntax error in selector "${rawSelector}" at position ${
err.offset
}: ${err.message}`
)
}
throw err
}
} | javascript | function tryParseSelector(rawSelector) {
try {
return esquery.parse(rawSelector.replace(/:exit$/u, ""))
} catch (err) {
if (typeof err.offset === "number") {
throw new Error(
`Syntax error in selector "${rawSelector}" at position ${
err.offset
}: ${err.message}`
)
}
throw err
}
} | [
"function",
"tryParseSelector",
"(",
"rawSelector",
")",
"{",
"try",
"{",
"return",
"esquery",
".",
"parse",
"(",
"rawSelector",
".",
"replace",
"(",
"/",
":exit$",
"/",
"u",
",",
"\"\"",
")",
")",
"}",
"catch",
"(",
"err",
")",
"{",
"if",
"(",
"typeof",
"err",
".",
"offset",
"===",
"\"number\"",
")",
"{",
"throw",
"new",
"Error",
"(",
"`",
"${",
"rawSelector",
"}",
"${",
"err",
".",
"offset",
"}",
"${",
"err",
".",
"message",
"}",
"`",
")",
"}",
"throw",
"err",
"}",
"}"
] | Parses a raw selector string, and throws a useful error if parsing fails.
@param {string} rawSelector A raw AST selector
@returns {Selector} An object (from esquery) describing the matching behavior of this selector
@throws An error if the selector is invalid | [
"Parses",
"a",
"raw",
"selector",
"string",
"and",
"throws",
"a",
"useful",
"error",
"if",
"parsing",
"fails",
"."
] | 9ff820d58da1eea47f12a87939e62a23cc07561d | https://github.com/ota-meshi/eslint-plugin-lodash-template/blob/9ff820d58da1eea47f12a87939e62a23cc07561d/lib/service/MicroTemplateService.js#L16-L29 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.