repo stringclasses 195 values | path stringlengths 4 99 | func_name stringlengths 0 41 | original_string stringlengths 72 56.1k | language stringclasses 1 value | code stringlengths 72 56.1k | code_tokens listlengths 25 8.12k | docstring stringlengths 2 12.5k | docstring_tokens listlengths 1 449 | sha stringclasses 197 values | url stringlengths 88 186 | partition stringclasses 1 value | summary stringlengths 8 338 | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cytoscape/cytoscape.js | dist/cytoscape.esm.js | LayeredTextureCache | function LayeredTextureCache(renderer) {
var self = this;
var r = self.renderer = renderer;
var cy = r.cy;
self.layersByLevel = {}; // e.g. 2 => [ layer1, layer2, ..., layerN ]
self.firstGet = true;
self.lastInvalidationTime = performanceNow() - 2 * invalidThreshold;
self.skipping = false;
self.eleTxrDeqs = cy.collection();
self.scheduleElementRefinement = util(function () {
self.refineElementTextures(self.eleTxrDeqs);
self.eleTxrDeqs.unmerge(self.eleTxrDeqs);
}, refineEleDebounceTime);
r.beforeRender(function (willDraw, now$$1) {
if (now$$1 - self.lastInvalidationTime <= invalidThreshold) {
self.skipping = true;
} else {
self.skipping = false;
}
}, r.beforeRenderPriorities.lyrTxrSkip);
var qSort = function qSort(a, b) {
return b.reqs - a.reqs;
};
self.layersQueue = new Heap(qSort);
self.setupDequeueing();
} | javascript | function LayeredTextureCache(renderer) {
var self = this;
var r = self.renderer = renderer;
var cy = r.cy;
self.layersByLevel = {}; // e.g. 2 => [ layer1, layer2, ..., layerN ]
self.firstGet = true;
self.lastInvalidationTime = performanceNow() - 2 * invalidThreshold;
self.skipping = false;
self.eleTxrDeqs = cy.collection();
self.scheduleElementRefinement = util(function () {
self.refineElementTextures(self.eleTxrDeqs);
self.eleTxrDeqs.unmerge(self.eleTxrDeqs);
}, refineEleDebounceTime);
r.beforeRender(function (willDraw, now$$1) {
if (now$$1 - self.lastInvalidationTime <= invalidThreshold) {
self.skipping = true;
} else {
self.skipping = false;
}
}, r.beforeRenderPriorities.lyrTxrSkip);
var qSort = function qSort(a, b) {
return b.reqs - a.reqs;
};
self.layersQueue = new Heap(qSort);
self.setupDequeueing();
} | [
"function",
"LayeredTextureCache",
"(",
"renderer",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"r",
"=",
"self",
".",
"renderer",
"=",
"renderer",
";",
"var",
"cy",
"=",
"r",
".",
"cy",
";",
"self",
".",
"layersByLevel",
"=",
"{",
"}",
";",
... | whether to use high quality ele txr requests (generally faster and cheaper in the longterm) var log = function(){ console.log.apply( console, arguments ); }; | [
"whether",
"to",
"use",
"high",
"quality",
"ele",
"txr",
"requests",
"(",
"generally",
"faster",
"and",
"cheaper",
"in",
"the",
"longterm",
")",
"var",
"log",
"=",
"function",
"()",
"{",
"console",
".",
"log",
".",
"apply",
"(",
"console",
"arguments",
"... | ad2051b65e2243cfd953d8b24a8bf95bfa8559e5 | https://github.com/cytoscape/cytoscape.js/blob/ad2051b65e2243cfd953d8b24a8bf95bfa8559e5/dist/cytoscape.esm.js#L26723-L26751 | train | Creates a LayeredTextureCache instance. | [
30522,
3853,
21323,
18209,
5397,
3540,
5403,
1006,
17552,
2121,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
1054,
1027,
2969,
1012,
17552,
2121,
1027,
17552,
2121,
1025,
13075,
22330,
1027,
1054,
1012,
22330,
1025,
2969,
1012,
9014,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wuchangming/spy-debugger | buildin_modules/weinre/web/demo/weinre-demo.js | createDatabase | function createDatabase(tx) {
var schema = "clicks (id integer primary key, date text)"
var sql = "create table if not exists " + schema
tx.executeSql(sql, null, clearDatabase, sqlError);
} | javascript | function createDatabase(tx) {
var schema = "clicks (id integer primary key, date text)"
var sql = "create table if not exists " + schema
tx.executeSql(sql, null, clearDatabase, sqlError);
} | [
"function",
"createDatabase",
"(",
"tx",
")",
"{",
"var",
"schema",
"=",
"\"clicks (id integer primary key, date text)\"",
"var",
"sql",
"=",
"\"create table if not exists \"",
"+",
"schema",
"tx",
".",
"executeSql",
"(",
"sql",
",",
"null",
",",
"clearDatabase",
",... | ------------------------------------------------------------------------------ | [
"------------------------------------------------------------------------------"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/demo/weinre-demo.js#L146-L151 | train | Create the database | [
30522,
3853,
2580,
6790,
15058,
1006,
19067,
1007,
1063,
13075,
8040,
28433,
1027,
1000,
29225,
1006,
8909,
16109,
3078,
3145,
1010,
3058,
3793,
1007,
1000,
13075,
29296,
1027,
1000,
3443,
2795,
2065,
2025,
6526,
1000,
1009,
8040,
28433,
19... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | filterStructural | function filterStructural(bSkipFirstSegment, sMetaPath) {
var aSegments = sMetaPath.split("/");
return aSegments.every(function (sSegment, i) {
return i === 0 && bSkipFirstSegment
|| fnFetchMetadata(
sRootMetaPath + "/" + aSegments.slice(0, i + 1).join("/")
).getResult().$kind === "Property";
});
} | javascript | function filterStructural(bSkipFirstSegment, sMetaPath) {
var aSegments = sMetaPath.split("/");
return aSegments.every(function (sSegment, i) {
return i === 0 && bSkipFirstSegment
|| fnFetchMetadata(
sRootMetaPath + "/" + aSegments.slice(0, i + 1).join("/")
).getResult().$kind === "Property";
});
} | [
"function",
"filterStructural",
"(",
"bSkipFirstSegment",
",",
"sMetaPath",
")",
"{",
"var",
"aSegments",
"=",
"sMetaPath",
".",
"split",
"(",
"\"/\"",
")",
";",
"return",
"aSegments",
".",
"every",
"(",
"function",
"(",
"sSegment",
",",
"i",
")",
"{",
"re... | /*
Filter where only structural properties pass through.
@param {boolean} bSkipFirstSegment
Whether first segment of the path is known to be a structural property
@param {string} sMetaPath
A meta path relative to the cache's root
@returns {boolean}
Whether the given meta path contains only structural properties | [
"/",
"*",
"Filter",
"where",
"only",
"structural",
"properties",
"pass",
"through",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L730-L739 | train | Filter the metadata for the given metadata path | [
30522,
3853,
17736,
18300,
11137,
1006,
18667,
3211,
14376,
18894,
3215,
13910,
3672,
1010,
15488,
12928,
15069,
1007,
1063,
13075,
2004,
13910,
8163,
1027,
15488,
12928,
15069,
1012,
3975,
1006,
1000,
1013,
1000,
1007,
1025,
2709,
2004,
1391... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js | getResolvedBinding | function getResolvedBinding(sValue, oElement, oWithControl, bMandatory,
fnCallIfConstant) {
var vBindingInfo,
oPromise;
Measurement.average(sPerformanceGetResolvedBinding, "", aPerformanceCategories);
try {
vBindingInfo
= BindingParser.complexParser(sValue, oScope, bMandatory, true, true, true)
|| sValue; // in case there is no binding and nothing to unescape
} catch (e) {
return SyncPromise.reject(e);
}
if (vBindingInfo.functionsNotFound) {
if (bMandatory) {
warn(oElement, 'Function name(s)',
vBindingInfo.functionsNotFound.join(", "), 'not found');
}
Measurement.end(sPerformanceGetResolvedBinding);
return null; // treat incomplete bindings as unrelated
}
if (typeof vBindingInfo === "object") {
oPromise = getAny(oWithControl, vBindingInfo, mSettings, oScope,
!oViewInfo.sync);
if (bMandatory && !oPromise) {
warn(oElement, 'Binding not ready');
} else if (oViewInfo.sync && oPromise && oPromise.isPending()) {
error("Async formatter in sync view in " + sValue + " of ", oElement);
}
} else {
oPromise = SyncPromise.resolve(vBindingInfo);
if (fnCallIfConstant) { // string
fnCallIfConstant();
}
}
Measurement.end(sPerformanceGetResolvedBinding);
return oPromise;
} | javascript | function getResolvedBinding(sValue, oElement, oWithControl, bMandatory,
fnCallIfConstant) {
var vBindingInfo,
oPromise;
Measurement.average(sPerformanceGetResolvedBinding, "", aPerformanceCategories);
try {
vBindingInfo
= BindingParser.complexParser(sValue, oScope, bMandatory, true, true, true)
|| sValue; // in case there is no binding and nothing to unescape
} catch (e) {
return SyncPromise.reject(e);
}
if (vBindingInfo.functionsNotFound) {
if (bMandatory) {
warn(oElement, 'Function name(s)',
vBindingInfo.functionsNotFound.join(", "), 'not found');
}
Measurement.end(sPerformanceGetResolvedBinding);
return null; // treat incomplete bindings as unrelated
}
if (typeof vBindingInfo === "object") {
oPromise = getAny(oWithControl, vBindingInfo, mSettings, oScope,
!oViewInfo.sync);
if (bMandatory && !oPromise) {
warn(oElement, 'Binding not ready');
} else if (oViewInfo.sync && oPromise && oPromise.isPending()) {
error("Async formatter in sync view in " + sValue + " of ", oElement);
}
} else {
oPromise = SyncPromise.resolve(vBindingInfo);
if (fnCallIfConstant) { // string
fnCallIfConstant();
}
}
Measurement.end(sPerformanceGetResolvedBinding);
return oPromise;
} | [
"function",
"getResolvedBinding",
"(",
"sValue",
",",
"oElement",
",",
"oWithControl",
",",
"bMandatory",
",",
"fnCallIfConstant",
")",
"{",
"var",
"vBindingInfo",
",",
"oPromise",
";",
"Measurement",
".",
"average",
"(",
"sPerformanceGetResolvedBinding",
",",
"\"\"... | Interprets the given value as a binding and returns the resulting value; takes care
of unescaping and thus also of constant expressions.
@param {string} sValue
an XML DOM attribute value
@param {Element} oElement
the XML DOM element
@param {sap.ui.core.util._with} oWithControl
the "with" control
@param {boolean} bMandatory
whether a binding is actually required (e.g. by a <code>template:if</code>) and not
optional (e.g. for {@link resolveAttributeBinding}); if so, the binding parser
unescapes the given value (which is a prerequisite for constant expressions) and
warnings are logged for functions not found
@param {function} [fnCallIfConstant]
optional function to be called in case the return value is obviously a constant,
not influenced by any binding
@returns {sap.ui.base.SyncPromise|null}
a sync promise which resolves with the property value or is rejected with a
corresponding error (for example, an error thrown by a formatter), or
<code>null</code> in case the binding is not ready (because it refers to a model
which is not available)
@throws {Error}
if a formatter returns a promise in sync mode | [
"Interprets",
"the",
"given",
"value",
"as",
"a",
"binding",
"and",
"returns",
"the",
"resulting",
"value",
";",
"takes",
"care",
"of",
"unescaping",
"and",
"thus",
"also",
"of",
"constant",
"expressions",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/util/XMLPreprocessor.js#L1086-L1125 | train | Returns a promise that resolves to the binding | [
30522,
3853,
2131,
6072,
16116,
8428,
4667,
1006,
17917,
2389,
5657,
1010,
1051,
12260,
3672,
1010,
27593,
8939,
8663,
13181,
2140,
1010,
1038,
2386,
2850,
7062,
1010,
1042,
20909,
6894,
11329,
5644,
5794,
2102,
1007,
1063,
13075,
1058,
842... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/language/XMLUtils.js | _getTagAttributes | function _getTagAttributes(editor, constPos) {
var pos, ctx, ctxPrev, ctxNext, ctxTemp, tagName, exclusionList = [], shouldReplace;
pos = $.extend({}, constPos);
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
// Stop if the cursor is before = or an attribute value.
ctxTemp = $.extend(true, {}, ctx);
if (ctxTemp.token.type === null && regexWhitespace.test(ctxTemp.token.string)) {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if ((ctxTemp.token.type === null && ctxTemp.token.string === "=") ||
ctxTemp.token.type === "string") {
return null;
}
TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctxTemp);
}
}
// Incase an attribute is followed by an equal sign, shouldReplace will be used
// to prevent from appending ="" again.
if (ctxTemp.token.type === "attribute") {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if (ctxTemp.token.type === null && ctxTemp.token.string === "=") {
shouldReplace = true;
}
}
}
// Look-Back and get the attributes and tag name.
pos = $.extend({}, constPos);
ctxPrev = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type && ctxPrev.token.type.indexOf("tag bracket") >= 0) {
// Disallow hints in closed tag and inside tag content
if (ctxPrev.token.string === "</" || ctxPrev.token.string.indexOf(">") !== -1) {
return null;
}
}
// Get attributes.
if (ctxPrev.token.type === "attribute") {
exclusionList.push(ctxPrev.token.string);
}
// Get tag.
if (ctxPrev.token.type === "tag") {
tagName = ctxPrev.token.string;
if (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type === "tag bracket" && ctxPrev.token.string === "<") {
break;
}
return null;
}
}
}
// Look-Ahead and find rest of the attributes.
pos = $.extend({}, constPos);
ctxNext = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.moveNextToken(ctxNext)) {
if (ctxNext.token.type === "string" && ctxNext.token.string === "\"") {
return null;
}
// Stop on closing bracket of its own tag or opening bracket of next tag.
if (ctxNext.token.type === "tag bracket" &&
(ctxNext.token.string.indexOf(">") >= 0 || ctxNext.token.string === "<")) {
break;
}
if (ctxNext.token.type === "attribute" && exclusionList.indexOf(ctxNext.token.string) === -1) {
exclusionList.push(ctxNext.token.string);
}
}
return {
tagName: tagName,
exclusionList: exclusionList,
shouldReplace: shouldReplace
};
} | javascript | function _getTagAttributes(editor, constPos) {
var pos, ctx, ctxPrev, ctxNext, ctxTemp, tagName, exclusionList = [], shouldReplace;
pos = $.extend({}, constPos);
ctx = TokenUtils.getInitialContext(editor._codeMirror, pos);
// Stop if the cursor is before = or an attribute value.
ctxTemp = $.extend(true, {}, ctx);
if (ctxTemp.token.type === null && regexWhitespace.test(ctxTemp.token.string)) {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if ((ctxTemp.token.type === null && ctxTemp.token.string === "=") ||
ctxTemp.token.type === "string") {
return null;
}
TokenUtils.moveSkippingWhitespace(TokenUtils.movePrevToken, ctxTemp);
}
}
// Incase an attribute is followed by an equal sign, shouldReplace will be used
// to prevent from appending ="" again.
if (ctxTemp.token.type === "attribute") {
if (TokenUtils.moveSkippingWhitespace(TokenUtils.moveNextToken, ctxTemp)) {
if (ctxTemp.token.type === null && ctxTemp.token.string === "=") {
shouldReplace = true;
}
}
}
// Look-Back and get the attributes and tag name.
pos = $.extend({}, constPos);
ctxPrev = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type && ctxPrev.token.type.indexOf("tag bracket") >= 0) {
// Disallow hints in closed tag and inside tag content
if (ctxPrev.token.string === "</" || ctxPrev.token.string.indexOf(">") !== -1) {
return null;
}
}
// Get attributes.
if (ctxPrev.token.type === "attribute") {
exclusionList.push(ctxPrev.token.string);
}
// Get tag.
if (ctxPrev.token.type === "tag") {
tagName = ctxPrev.token.string;
if (TokenUtils.movePrevToken(ctxPrev)) {
if (ctxPrev.token.type === "tag bracket" && ctxPrev.token.string === "<") {
break;
}
return null;
}
}
}
// Look-Ahead and find rest of the attributes.
pos = $.extend({}, constPos);
ctxNext = TokenUtils.getInitialContext(editor._codeMirror, pos);
while (TokenUtils.moveNextToken(ctxNext)) {
if (ctxNext.token.type === "string" && ctxNext.token.string === "\"") {
return null;
}
// Stop on closing bracket of its own tag or opening bracket of next tag.
if (ctxNext.token.type === "tag bracket" &&
(ctxNext.token.string.indexOf(">") >= 0 || ctxNext.token.string === "<")) {
break;
}
if (ctxNext.token.type === "attribute" && exclusionList.indexOf(ctxNext.token.string) === -1) {
exclusionList.push(ctxNext.token.string);
}
}
return {
tagName: tagName,
exclusionList: exclusionList,
shouldReplace: shouldReplace
};
} | [
"function",
"_getTagAttributes",
"(",
"editor",
",",
"constPos",
")",
"{",
"var",
"pos",
",",
"ctx",
",",
"ctxPrev",
",",
"ctxNext",
",",
"ctxTemp",
",",
"tagName",
",",
"exclusionList",
"=",
"[",
"]",
",",
"shouldReplace",
";",
"pos",
"=",
"$",
".",
"... | Return the tagName and a list of attributes used by the tag.
@param {!Editor} editor An instance of active editor
@param {!{line: number, ch: number}} constPos The position of cursor in the active editor
@return {!{tagName: string, exclusionList: Array.<string>, shouldReplace: boolean}} | [
"Return",
"the",
"tagName",
"and",
"a",
"list",
"of",
"attributes",
"used",
"by",
"the",
"tag",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/XMLUtils.js#L69-L147 | train | Get the attributes of a tag | [
30522,
3853,
1035,
2131,
15900,
19321,
3089,
8569,
4570,
1006,
3559,
1010,
9530,
3367,
6873,
2015,
1007,
1063,
13075,
13433,
2015,
1010,
14931,
2595,
1010,
14931,
2595,
28139,
2615,
1010,
14931,
2595,
2638,
18413,
1010,
14931,
18413,
6633,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | XPathOptimizer | function XPathOptimizer(newEngine) {
// private
var engine = newEngine;
var namespaceResolver;
var mirror = new MirroredDocument(namespaceResolver);
var finderBuilder = new FinderBuilder();
// keys are full document HTML strings, and values are mappings from
// XPath's to objects which the following fields:
//
// - finder the equivalent finder function for the XPath, for
// single node selection
// - nodeCount the node count for the XPath with respect to the given
// document content
// - node the actual, potentially invalidated, node
// - sourceIndex the value of the sourceIndex attribute of the node at
// time of addition to the cache; this can be used to
// determine if the node has since changed positions
//
var knownOptimizations = new XPathOptimizationCache(100);
/**
* Returns whether this optimizer is capable of optimizing XPath's for the
* given node.
*/
function isOptimizable(node) {
return (node.nodeType == 1);
}
/**
* Returns whether the given XPath evaluates to the given node in the
* test document.
*/
function isXPathValid(xpath, node) {
var contextNode = mirror.getReflection();
return (engine.setDocument(mirror.getReflection())
.selectSingleNode(xpath, contextNode, namespaceResolver) === node);
}
// public
this.setDocument = function(newDocument) {
mirror.setOriginal(newDocument);
return this;
}
/**
* Sets the document object that will be used for test XPath evaluation and
* traversal related to construction of the optimized expression. This
* document will be modified freely by the optimize() operation.
*/
this.setTestDocument = function(newTestDocument) {
mirror.setReflection(newTestDocument);
return this;
};
this.setNamespaceResolver = function(newNamespaceResolver) {
namespaceResolver = newNamespaceResolver;
mirror.setNamespaceResolver(newNamespaceResolver);
return this;
};
/**
* Returns an optimal XPath whose first result is the same as the first
* result of the given XPath, when evaluated on the currently set document.
* If optimization fails, returns the original XPath.
*/
this.getOptimizedFinder = function(xpath, contextNode) {
var originalHtml = mirror.getOriginal().documentElement.innerHTML;
var optimization = knownOptimizations.get(originalHtml, xpath);
if (optimization) {
var finder = optimization.finder;
if (finder) {
// the optimized finder for this document content was found in
// the cache!
safe_log('info', 'Found cached optimized finder for ' + xpath);
return finder;
}
}
mirror.reflect();
if (contextNode) {
contextNode = mirror.getReflectedNode(contextNode);
}
var firstResult = engine.setDocument(mirror.getReflection())
.selectSingleNode(xpath, contextNode, namespaceResolver);
if (! firstResult) {
// either the element doesn't exist, or there was a failure to
// reflect the document accurately
return null;
}
if (isOptimizable(firstResult)) {
var finder = finderBuilder.setDocument(mirror.getReflection())
.build(firstResult);
if (finder) {
safe_log('info', 'Found optimized finder: ' + finder);
if (! optimization) {
optimization = knownOptimizations
.getOrCreate(originalHtml, xpath);
}
optimization.finder = finder;
return finder;
}
}
return null;
};
this.countNodes = function(xpath, contextNode) {
var originalHtml = mirror.getOriginal().documentElement.innerHTML;
var optimization = knownOptimizations.get(originalHtml, xpath);
if (optimization) {
var nodeCount = optimization.nodeCount;
if (nodeCount != null) {
// the node count for the XPath for this document content was
// found in the cache!
safe_log('info', 'Found cached node count for ' + xpath);
return nodeCount;
}
}
mirror.reflect();
if (contextNode) {
contextNode = mirror.getReflectedNode(contextNode);
}
// count the nodes using the test document, and circumvent
// window RPC altogether
var nodeCount = engine.setDocument(mirror.getReflection())
.countNodes(xpath, contextNode, namespaceResolver);
if (! optimization) {
optimization = knownOptimizations.getOrCreate(originalHtml, xpath);
}
optimization.nodeCount = nodeCount;
return nodeCount;
};
this.getKnownOptimizations = function() {
return knownOptimizations;
};
} | javascript | function XPathOptimizer(newEngine) {
// private
var engine = newEngine;
var namespaceResolver;
var mirror = new MirroredDocument(namespaceResolver);
var finderBuilder = new FinderBuilder();
// keys are full document HTML strings, and values are mappings from
// XPath's to objects which the following fields:
//
// - finder the equivalent finder function for the XPath, for
// single node selection
// - nodeCount the node count for the XPath with respect to the given
// document content
// - node the actual, potentially invalidated, node
// - sourceIndex the value of the sourceIndex attribute of the node at
// time of addition to the cache; this can be used to
// determine if the node has since changed positions
//
var knownOptimizations = new XPathOptimizationCache(100);
/**
* Returns whether this optimizer is capable of optimizing XPath's for the
* given node.
*/
function isOptimizable(node) {
return (node.nodeType == 1);
}
/**
* Returns whether the given XPath evaluates to the given node in the
* test document.
*/
function isXPathValid(xpath, node) {
var contextNode = mirror.getReflection();
return (engine.setDocument(mirror.getReflection())
.selectSingleNode(xpath, contextNode, namespaceResolver) === node);
}
// public
this.setDocument = function(newDocument) {
mirror.setOriginal(newDocument);
return this;
}
/**
* Sets the document object that will be used for test XPath evaluation and
* traversal related to construction of the optimized expression. This
* document will be modified freely by the optimize() operation.
*/
this.setTestDocument = function(newTestDocument) {
mirror.setReflection(newTestDocument);
return this;
};
this.setNamespaceResolver = function(newNamespaceResolver) {
namespaceResolver = newNamespaceResolver;
mirror.setNamespaceResolver(newNamespaceResolver);
return this;
};
/**
* Returns an optimal XPath whose first result is the same as the first
* result of the given XPath, when evaluated on the currently set document.
* If optimization fails, returns the original XPath.
*/
this.getOptimizedFinder = function(xpath, contextNode) {
var originalHtml = mirror.getOriginal().documentElement.innerHTML;
var optimization = knownOptimizations.get(originalHtml, xpath);
if (optimization) {
var finder = optimization.finder;
if (finder) {
// the optimized finder for this document content was found in
// the cache!
safe_log('info', 'Found cached optimized finder for ' + xpath);
return finder;
}
}
mirror.reflect();
if (contextNode) {
contextNode = mirror.getReflectedNode(contextNode);
}
var firstResult = engine.setDocument(mirror.getReflection())
.selectSingleNode(xpath, contextNode, namespaceResolver);
if (! firstResult) {
// either the element doesn't exist, or there was a failure to
// reflect the document accurately
return null;
}
if (isOptimizable(firstResult)) {
var finder = finderBuilder.setDocument(mirror.getReflection())
.build(firstResult);
if (finder) {
safe_log('info', 'Found optimized finder: ' + finder);
if (! optimization) {
optimization = knownOptimizations
.getOrCreate(originalHtml, xpath);
}
optimization.finder = finder;
return finder;
}
}
return null;
};
this.countNodes = function(xpath, contextNode) {
var originalHtml = mirror.getOriginal().documentElement.innerHTML;
var optimization = knownOptimizations.get(originalHtml, xpath);
if (optimization) {
var nodeCount = optimization.nodeCount;
if (nodeCount != null) {
// the node count for the XPath for this document content was
// found in the cache!
safe_log('info', 'Found cached node count for ' + xpath);
return nodeCount;
}
}
mirror.reflect();
if (contextNode) {
contextNode = mirror.getReflectedNode(contextNode);
}
// count the nodes using the test document, and circumvent
// window RPC altogether
var nodeCount = engine.setDocument(mirror.getReflection())
.countNodes(xpath, contextNode, namespaceResolver);
if (! optimization) {
optimization = knownOptimizations.getOrCreate(originalHtml, xpath);
}
optimization.nodeCount = nodeCount;
return nodeCount;
};
this.getKnownOptimizations = function() {
return knownOptimizations;
};
} | [
"function",
"XPathOptimizer",
"(",
"newEngine",
")",
"{",
"// private",
"var",
"engine",
"=",
"newEngine",
";",
"var",
"namespaceResolver",
";",
"var",
"mirror",
"=",
"new",
"MirroredDocument",
"(",
"namespaceResolver",
")",
";",
"var",
"finderBuilder",
"=",
"ne... | ///////////////////////////////////////////////////////////////////////////// | [
"/////////////////////////////////////////////////////////////////////////////"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L1609-L1764 | train | The XPath Optimizer class | [
30522,
3853,
26726,
8988,
7361,
3775,
4328,
6290,
1006,
2047,
13159,
3170,
1007,
1063,
1013,
1013,
2797,
13075,
3194,
1027,
2047,
13159,
3170,
1025,
13075,
3415,
15327,
6072,
4747,
6299,
1025,
13075,
5259,
1027,
2047,
22243,
3527,
24894,
47... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
ecomfe/zrender | src/mixin/Eventful.js | function (event, handler) {
var _h = this._$handlers;
if (!event) {
this._$handlers = {};
return this;
}
if (handler) {
if (_h[event]) {
var newList = [];
for (var i = 0, l = _h[event].length; i < l; i++) {
if (_h[event][i].h !== handler) {
newList.push(_h[event][i]);
}
}
_h[event] = newList;
}
if (_h[event] && _h[event].length === 0) {
delete _h[event];
}
}
else {
delete _h[event];
}
return this;
} | javascript | function (event, handler) {
var _h = this._$handlers;
if (!event) {
this._$handlers = {};
return this;
}
if (handler) {
if (_h[event]) {
var newList = [];
for (var i = 0, l = _h[event].length; i < l; i++) {
if (_h[event][i].h !== handler) {
newList.push(_h[event][i]);
}
}
_h[event] = newList;
}
if (_h[event] && _h[event].length === 0) {
delete _h[event];
}
}
else {
delete _h[event];
}
return this;
} | [
"function",
"(",
"event",
",",
"handler",
")",
"{",
"var",
"_h",
"=",
"this",
".",
"_$handlers",
";",
"if",
"(",
"!",
"event",
")",
"{",
"this",
".",
"_$handlers",
"=",
"{",
"}",
";",
"return",
"this",
";",
"}",
"if",
"(",
"handler",
")",
"{",
... | Unbind a event.
@param {string} event The event name.
@param {Function} [handler] The event handler. | [
"Unbind",
"a",
"event",
"."
] | 30321b57cba3149c30eacb0c1e18276f0f001b9f | https://github.com/ecomfe/zrender/blob/30321b57cba3149c30eacb0c1e18276f0f001b9f/src/mixin/Eventful.js#L78-L106 | train | Alien event handler | [
30522,
3853,
1006,
2724,
1010,
28213,
1007,
1063,
13075,
1035,
1044,
1027,
2023,
1012,
1035,
1002,
28213,
2015,
1025,
2065,
1006,
999,
2724,
1007,
1063,
2023,
1012,
1035,
1002,
28213,
2015,
1027,
1063,
1065,
1025,
2709,
2023,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js | function(sPropertyName) {
var oProperty = this._oPropertySet[sPropertyName];
if (oProperty == null) {
throw "no such property with name " + sPropertyName;
}
if (oProperty.extensions != undefined) {
for (var i = -1, oExtension; (oExtension = oProperty.extensions[++i]) !== undefined;) {
if (!oExtension.namespace == odata4analytics.constants.SAP_NAMESPACE) {
continue;
}
if (oExtension.name == "label") {
return oExtension.value;
}
}
}
return null;
} | javascript | function(sPropertyName) {
var oProperty = this._oPropertySet[sPropertyName];
if (oProperty == null) {
throw "no such property with name " + sPropertyName;
}
if (oProperty.extensions != undefined) {
for (var i = -1, oExtension; (oExtension = oProperty.extensions[++i]) !== undefined;) {
if (!oExtension.namespace == odata4analytics.constants.SAP_NAMESPACE) {
continue;
}
if (oExtension.name == "label") {
return oExtension.value;
}
}
}
return null;
} | [
"function",
"(",
"sPropertyName",
")",
"{",
"var",
"oProperty",
"=",
"this",
".",
"_oPropertySet",
"[",
"sPropertyName",
"]",
";",
"if",
"(",
"oProperty",
"==",
"null",
")",
"{",
"throw",
"\"no such property with name \"",
"+",
"sPropertyName",
";",
"}",
"if",... | Get label of the property with specified name (identified by property
metadata annotation sap:label)
@param {string}
sPropertyName Property name
@returns {string} The label string
@public
@function
@name sap.ui.model.analytics.odata4analytics.EntityType#getLabelOfProperty | [
"Get",
"label",
"of",
"the",
"property",
"with",
"specified",
"name",
"(",
"identified",
"by",
"property",
"metadata",
"annotation",
"sap",
":",
"label",
")"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/analytics/odata4analytics.js#L2602-L2619 | train | Returns the value of the extension for the given property. | [
30522,
3853,
1006,
11867,
18981,
15010,
18442,
1007,
1063,
13075,
6728,
18981,
15010,
1027,
2023,
1012,
1035,
6728,
18981,
15010,
13462,
1031,
11867,
18981,
15010,
18442,
1033,
1025,
2065,
1006,
6728,
18981,
15010,
1027,
1027,
19701,
1007,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
lovell/sharp | lib/operation.js | rotate | function rotate (angle, options) {
if (!is.defined(angle)) {
this.options.useExifOrientation = true;
} else if (is.integer(angle) && !(angle % 90)) {
this.options.angle = angle;
} else if (is.number(angle)) {
this.options.rotationAngle = angle;
if (is.object(options) && options.background) {
const backgroundColour = color(options.background);
this.options.rotationBackground = [
backgroundColour.red(),
backgroundColour.green(),
backgroundColour.blue(),
Math.round(backgroundColour.alpha() * 255)
];
}
} else {
throw new Error('Unsupported angle: must be a number.');
}
return this;
} | javascript | function rotate (angle, options) {
if (!is.defined(angle)) {
this.options.useExifOrientation = true;
} else if (is.integer(angle) && !(angle % 90)) {
this.options.angle = angle;
} else if (is.number(angle)) {
this.options.rotationAngle = angle;
if (is.object(options) && options.background) {
const backgroundColour = color(options.background);
this.options.rotationBackground = [
backgroundColour.red(),
backgroundColour.green(),
backgroundColour.blue(),
Math.round(backgroundColour.alpha() * 255)
];
}
} else {
throw new Error('Unsupported angle: must be a number.');
}
return this;
} | [
"function",
"rotate",
"(",
"angle",
",",
"options",
")",
"{",
"if",
"(",
"!",
"is",
".",
"defined",
"(",
"angle",
")",
")",
"{",
"this",
".",
"options",
".",
"useExifOrientation",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"is",
".",
"integer",
"(",... | Rotate the output image by either an explicit angle
or auto-orient based on the EXIF `Orientation` tag.
If an angle is provided, it is converted to a valid positive degree rotation.
For example, `-450` will produce a 270deg rotation.
When rotating by an angle other than a multiple of 90,
the background colour can be provided with the `background` option.
If no angle is provided, it is determined from the EXIF data.
Mirroring is supported and may infer the use of a flip operation.
The use of `rotate` implies the removal of the EXIF `Orientation` tag, if any.
Method order is important when both rotating and extracting regions,
for example `rotate(x).extract(y)` will produce a different result to `extract(y).rotate(x)`.
@example
const pipeline = sharp()
.rotate()
.resize(null, 200)
.toBuffer(function (err, outputBuffer, info) {
// outputBuffer contains 200px high JPEG image data,
// auto-rotated using EXIF Orientation tag
// info.width and info.height contain the dimensions of the resized image
});
readableStream.pipe(pipeline);
@param {Number} [angle=auto] angle of rotation.
@param {Object} [options] - if present, is an Object with optional attributes.
@param {String|Object} [options.background="#000000"] parsed by the [color](https://www.npmjs.org/package/color) module to extract values for red, green, blue and alpha.
@returns {Sharp}
@throws {Error} Invalid parameters | [
"Rotate",
"the",
"output",
"image",
"by",
"either",
"an",
"explicit",
"angle",
"or",
"auto",
"-",
"orient",
"based",
"on",
"the",
"EXIF",
"Orientation",
"tag",
"."
] | 05d76eeadfe54713606a615185b2da047923406b | https://github.com/lovell/sharp/blob/05d76eeadfe54713606a615185b2da047923406b/lib/operation.js#L41-L61 | train | Rotate the image by the given angle. | [
30522,
3853,
24357,
1006,
6466,
1010,
7047,
1007,
1063,
2065,
1006,
999,
2003,
1012,
4225,
1006,
6466,
1007,
1007,
1063,
2023,
1012,
7047,
1012,
2224,
10288,
10128,
10050,
19304,
1027,
2995,
1025,
1065,
2842,
2065,
1006,
2003,
1012,
16109,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/filesystem/impls/appshell/AppshellFileSystem.js | exists | function exists(path, callback) {
stat(path, function (err) {
if (err) {
if (err === FileSystemError.NOT_FOUND) {
callback(null, false);
} else {
callback(err);
}
return;
}
callback(null, true);
});
} | javascript | function exists(path, callback) {
stat(path, function (err) {
if (err) {
if (err === FileSystemError.NOT_FOUND) {
callback(null, false);
} else {
callback(err);
}
return;
}
callback(null, true);
});
} | [
"function",
"exists",
"(",
"path",
",",
"callback",
")",
"{",
"stat",
"(",
"path",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"if",
"(",
"err",
"===",
"FileSystemError",
".",
"NOT_FOUND",
")",
"{",
"callback",
"(",
"null",
"... | Determine whether a file or directory exists at the given path by calling
back asynchronously with either a FileSystemError string or a boolean,
which is true if the file exists and false otherwise. The error will never
be FileSystemError.NOT_FOUND; in that case, there will be no error and the
boolean parameter will be false.
@param {string} path
@param {function(?string, boolean)} callback | [
"Determine",
"whether",
"a",
"file",
"or",
"directory",
"exists",
"at",
"the",
"given",
"path",
"by",
"calling",
"back",
"asynchronously",
"with",
"either",
"a",
"FileSystemError",
"string",
"or",
"a",
"boolean",
"which",
"is",
"true",
"if",
"the",
"file",
"... | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/filesystem/impls/appshell/AppshellFileSystem.js#L257-L270 | train | Check if a file exists | [
30522,
3853,
6526,
1006,
4130,
1010,
2655,
5963,
1007,
1063,
28093,
1006,
4130,
1010,
3853,
1006,
9413,
2099,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
1063,
2065,
1006,
9413,
2099,
1027,
1027,
1027,
6764,
27268,
21382,
18933,
2099,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
MithrilJS/mithril.js | docs/lint.js | traverseDirectory | function traverseDirectory(pathname, callback) {
pathname = pathname.replace(/\\/g, "/")
return new Promise(function(resolve, reject) {
fs.lstat(pathname, function(err, stat) {
if (err) reject(err)
if (stat.isDirectory()) {
fs.readdir(pathname, function(err, pathnames) {
if (err) reject(err)
var promises = []
for (var i = 0; i < pathnames.length; i++) {
pathnames[i] = path.join(pathname, pathnames[i])
promises.push(traverseDirectory(pathnames[i], callback))
}
callback(pathname, stat, pathnames)
resolve(Promise.all(promises))
})
}
else {
callback(pathname, stat)
resolve(pathname)
}
})
})
} | javascript | function traverseDirectory(pathname, callback) {
pathname = pathname.replace(/\\/g, "/")
return new Promise(function(resolve, reject) {
fs.lstat(pathname, function(err, stat) {
if (err) reject(err)
if (stat.isDirectory()) {
fs.readdir(pathname, function(err, pathnames) {
if (err) reject(err)
var promises = []
for (var i = 0; i < pathnames.length; i++) {
pathnames[i] = path.join(pathname, pathnames[i])
promises.push(traverseDirectory(pathnames[i], callback))
}
callback(pathname, stat, pathnames)
resolve(Promise.all(promises))
})
}
else {
callback(pathname, stat)
resolve(pathname)
}
})
})
} | [
"function",
"traverseDirectory",
"(",
"pathname",
",",
"callback",
")",
"{",
"pathname",
"=",
"pathname",
".",
"replace",
"(",
"/",
"\\\\",
"/",
"g",
",",
"\"/\"",
")",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",... | runner | [
"runner"
] | 6d36fe09d129928c6b460720e08d9ed321fcd62b | https://github.com/MithrilJS/mithril.js/blob/6d36fe09d129928c6b460720e08d9ed321fcd62b/docs/lint.js#L152-L175 | train | Traverse a directory | [
30522,
3853,
27797,
7442,
16761,
2100,
1006,
4130,
18442,
1010,
2655,
5963,
1007,
1063,
4130,
18442,
1027,
4130,
18442,
1012,
5672,
1006,
1013,
1032,
1032,
1013,
1043,
1010,
1000,
1013,
1000,
1007,
2709,
2047,
4872,
1006,
3853,
1006,
10663,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
facebook/relay | packages/relay-runtime/store/RelayModernSelector.js | getSingularSelector | function getSingularSelector(
operationVariables: Variables,
fragment: ReaderFragment,
item: mixed,
explicitOwner?: ?OperationDescriptor,
): ?OwnedReaderSelector {
invariant(
typeof item === 'object' && item !== null && !Array.isArray(item),
'RelayModernSelector: Expected value for fragment `%s` to be an object, got ' +
'`%s`.',
fragment.name,
JSON.stringify(item),
);
const dataID = item[ID_KEY];
const fragments = item[FRAGMENTS_KEY];
if (
typeof dataID === 'string' &&
typeof fragments === 'object' &&
fragments !== null &&
typeof fragments[fragment.name] === 'object' &&
fragments[fragment.name] !== null
) {
const argumentVariables = fragments[fragment.name];
// We only use the owner to compute the selector variables if an owner
// was explicitly passed by the caller, for backwards compatibility.
// See TODO(T39494051) for details
if (explicitOwner != null && typeof explicitOwner === 'object') {
const ownerOperationVariables = explicitOwner.variables;
const fragmentVariables = getFragmentVariables(
fragment,
ownerOperationVariables,
/* $FlowFixMe(>=0.98.0 site=www,mobile,react_native_fb,oss) This comment
* suppresses an error found when Flow v0.98 was deployed. To see the
* error delete this comment and run Flow. */
argumentVariables,
);
return {
owner: explicitOwner,
selector: {
dataID,
node: fragment,
variables: fragmentVariables,
},
};
}
// For convenience, we read and pass through the owner if one
// is present in the fragment reference (`item`), but we only
// use the owner to compute the selector variables if an owner was
// explicitly passed by the caller, for backwards compatibility.
// See TODO(T39494051) for details
const owner = explicitOwner ?? item[FRAGMENT_OWNER_KEY] ?? null;
const fragmentVariables = getFragmentVariables(
fragment,
operationVariables,
/* $FlowFixMe(>=0.98.0 site=www,mobile,react_native_fb,oss) This comment
* suppresses an error found when Flow v0.98 was deployed. To see the
* error delete this comment and run Flow. */
argumentVariables,
);
return {
// $FlowFixMe - TODO T39154660
owner: owner,
selector: {
dataID,
node: fragment,
variables: fragmentVariables,
},
};
}
if (__DEV__) {
let stringifiedItem = JSON.stringify(item);
if (stringifiedItem.length > 499) {
stringifiedItem = stringifiedItem.substr(0, 498) + '\u2026';
}
warning(
false,
'RelayModernSelector: Expected object to contain data for fragment `%s`, got ' +
'`%s`. Make sure that the parent operation/fragment included fragment ' +
'`...%s` without `@relay(mask: false)`.',
fragment.name,
stringifiedItem,
fragment.name,
);
}
return null;
} | javascript | function getSingularSelector(
operationVariables: Variables,
fragment: ReaderFragment,
item: mixed,
explicitOwner?: ?OperationDescriptor,
): ?OwnedReaderSelector {
invariant(
typeof item === 'object' && item !== null && !Array.isArray(item),
'RelayModernSelector: Expected value for fragment `%s` to be an object, got ' +
'`%s`.',
fragment.name,
JSON.stringify(item),
);
const dataID = item[ID_KEY];
const fragments = item[FRAGMENTS_KEY];
if (
typeof dataID === 'string' &&
typeof fragments === 'object' &&
fragments !== null &&
typeof fragments[fragment.name] === 'object' &&
fragments[fragment.name] !== null
) {
const argumentVariables = fragments[fragment.name];
// We only use the owner to compute the selector variables if an owner
// was explicitly passed by the caller, for backwards compatibility.
// See TODO(T39494051) for details
if (explicitOwner != null && typeof explicitOwner === 'object') {
const ownerOperationVariables = explicitOwner.variables;
const fragmentVariables = getFragmentVariables(
fragment,
ownerOperationVariables,
/* $FlowFixMe(>=0.98.0 site=www,mobile,react_native_fb,oss) This comment
* suppresses an error found when Flow v0.98 was deployed. To see the
* error delete this comment and run Flow. */
argumentVariables,
);
return {
owner: explicitOwner,
selector: {
dataID,
node: fragment,
variables: fragmentVariables,
},
};
}
// For convenience, we read and pass through the owner if one
// is present in the fragment reference (`item`), but we only
// use the owner to compute the selector variables if an owner was
// explicitly passed by the caller, for backwards compatibility.
// See TODO(T39494051) for details
const owner = explicitOwner ?? item[FRAGMENT_OWNER_KEY] ?? null;
const fragmentVariables = getFragmentVariables(
fragment,
operationVariables,
/* $FlowFixMe(>=0.98.0 site=www,mobile,react_native_fb,oss) This comment
* suppresses an error found when Flow v0.98 was deployed. To see the
* error delete this comment and run Flow. */
argumentVariables,
);
return {
// $FlowFixMe - TODO T39154660
owner: owner,
selector: {
dataID,
node: fragment,
variables: fragmentVariables,
},
};
}
if (__DEV__) {
let stringifiedItem = JSON.stringify(item);
if (stringifiedItem.length > 499) {
stringifiedItem = stringifiedItem.substr(0, 498) + '\u2026';
}
warning(
false,
'RelayModernSelector: Expected object to contain data for fragment `%s`, got ' +
'`%s`. Make sure that the parent operation/fragment included fragment ' +
'`...%s` without `@relay(mask: false)`.',
fragment.name,
stringifiedItem,
fragment.name,
);
}
return null;
} | [
"function",
"getSingularSelector",
"(",
"operationVariables",
":",
"Variables",
",",
"fragment",
":",
"ReaderFragment",
",",
"item",
":",
"mixed",
",",
"explicitOwner",
"?",
":",
"?",
"OperationDescriptor",
",",
")",
":",
"?",
"OwnedReaderSelector",
"{",
"invarian... | @public
Given the result `item` from a parent that fetched `fragment`, creates a
selector that can be used to read the results of that fragment for that item.
Example:
Given two fragments as follows:
```
fragment Parent on User {
id
...Child
}
fragment Child on User {
name
}
```
And given some object `parent` that is the results of `Parent` for id "4",
the results of `Child` can be accessed by first getting a selector and then
using that selector to `lookup()` the results against the environment:
```
const childSelector = getSingularSelector(queryVariables, Child, parent);
const childData = environment.lookup(childSelector).data;
``` | [
"@public"
] | 7fb9be5182b9650637d7b92ead9a42713ac30aa4 | https://github.com/facebook/relay/blob/7fb9be5182b9650637d7b92ead9a42713ac30aa4/packages/relay-runtime/store/RelayModernSelector.js#L59-L149 | train | Returns a selector object for a single fragment. | [
30522,
3853,
4152,
2075,
7934,
11246,
22471,
2953,
1006,
3169,
10755,
19210,
2015,
1024,
10857,
1010,
15778,
1024,
8068,
27843,
21693,
4765,
1010,
8875,
1024,
3816,
1010,
13216,
12384,
2121,
1029,
1024,
1029,
3169,
6155,
23235,
2953,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
laurent22/joplin | Clipper/joplin-webclipper/content_scripts/Readability.js | Readability | function Readability(doc, options) {
// In some older versions, people passed a URI as the first argument. Cope:
if (options && options.documentElement) {
doc = options;
options = arguments[2];
} else if (!doc || !doc.documentElement) {
throw new Error("First argument to Readability constructor should be a document object.");
}
options = options || {};
this._doc = doc;
this._articleTitle = null;
this._articleByline = null;
this._articleDir = null;
this._attempts = [];
// Configurable options
this._debug = !!options.debug;
this._maxElemsToParse = options.maxElemsToParse || this.DEFAULT_MAX_ELEMS_TO_PARSE;
this._nbTopCandidates = options.nbTopCandidates || this.DEFAULT_N_TOP_CANDIDATES;
this._charThreshold = options.charThreshold || this.DEFAULT_CHAR_THRESHOLD;
this._classesToPreserve = this.CLASSES_TO_PRESERVE.concat(options.classesToPreserve || []);
// Start with all flags set
this._flags = this.FLAG_STRIP_UNLIKELYS |
this.FLAG_WEIGHT_CLASSES |
this.FLAG_CLEAN_CONDITIONALLY;
var logEl;
// Control whether log messages are sent to the console
if (this._debug) {
logEl = function(e) {
var rv = e.nodeName + " ";
if (e.nodeType == e.TEXT_NODE) {
return rv + '("' + e.textContent + '")';
}
var classDesc = e.className && ("." + e.className.replace(/ /g, "."));
var elDesc = "";
if (e.id)
elDesc = "(#" + e.id + classDesc + ")";
else if (classDesc)
elDesc = "(" + classDesc + ")";
return rv + elDesc;
};
this.log = function () {
if (typeof dump !== "undefined") {
var msg = Array.prototype.map.call(arguments, function(x) {
return (x && x.nodeName) ? logEl(x) : x;
}).join(" ");
dump("Reader: (Readability) " + msg + "\n");
} else if (typeof console !== "undefined") {
var args = ["Reader: (Readability) "].concat(arguments);
console.log.apply(console, args);
}
};
} else {
this.log = function () {};
}
} | javascript | function Readability(doc, options) {
// In some older versions, people passed a URI as the first argument. Cope:
if (options && options.documentElement) {
doc = options;
options = arguments[2];
} else if (!doc || !doc.documentElement) {
throw new Error("First argument to Readability constructor should be a document object.");
}
options = options || {};
this._doc = doc;
this._articleTitle = null;
this._articleByline = null;
this._articleDir = null;
this._attempts = [];
// Configurable options
this._debug = !!options.debug;
this._maxElemsToParse = options.maxElemsToParse || this.DEFAULT_MAX_ELEMS_TO_PARSE;
this._nbTopCandidates = options.nbTopCandidates || this.DEFAULT_N_TOP_CANDIDATES;
this._charThreshold = options.charThreshold || this.DEFAULT_CHAR_THRESHOLD;
this._classesToPreserve = this.CLASSES_TO_PRESERVE.concat(options.classesToPreserve || []);
// Start with all flags set
this._flags = this.FLAG_STRIP_UNLIKELYS |
this.FLAG_WEIGHT_CLASSES |
this.FLAG_CLEAN_CONDITIONALLY;
var logEl;
// Control whether log messages are sent to the console
if (this._debug) {
logEl = function(e) {
var rv = e.nodeName + " ";
if (e.nodeType == e.TEXT_NODE) {
return rv + '("' + e.textContent + '")';
}
var classDesc = e.className && ("." + e.className.replace(/ /g, "."));
var elDesc = "";
if (e.id)
elDesc = "(#" + e.id + classDesc + ")";
else if (classDesc)
elDesc = "(" + classDesc + ")";
return rv + elDesc;
};
this.log = function () {
if (typeof dump !== "undefined") {
var msg = Array.prototype.map.call(arguments, function(x) {
return (x && x.nodeName) ? logEl(x) : x;
}).join(" ");
dump("Reader: (Readability) " + msg + "\n");
} else if (typeof console !== "undefined") {
var args = ["Reader: (Readability) "].concat(arguments);
console.log.apply(console, args);
}
};
} else {
this.log = function () {};
}
} | [
"function",
"Readability",
"(",
"doc",
",",
"options",
")",
"{",
"// In some older versions, people passed a URI as the first argument. Cope:",
"if",
"(",
"options",
"&&",
"options",
".",
"documentElement",
")",
"{",
"doc",
"=",
"options",
";",
"options",
"=",
"argume... | /*
This code is heavily based on Arc90's readability.js (1.7.1) script
available at: http://code.google.com/p/arc90labs-readability
Public constructor.
@param {HTMLDocument} doc The document to parse.
@param {Object} options The options object. | [
"/",
"*",
"This",
"code",
"is",
"heavily",
"based",
"on",
"Arc90",
"s",
"readability",
".",
"js",
"(",
"1",
".",
"7",
".",
"1",
")",
"script",
"available",
"at",
":",
"http",
":",
"//",
"code",
".",
"google",
".",
"com",
"/",
"p",
"/",
"arc90labs... | beb428b246cecba4630a3ca57b472f43c0933a43 | https://github.com/laurent22/joplin/blob/beb428b246cecba4630a3ca57b472f43c0933a43/Clipper/joplin-webclipper/content_scripts/Readability.js#L28-L87 | train | Constructor for the readability. | [
30522,
3853,
3191,
8010,
1006,
9986,
1010,
7047,
1007,
1063,
1013,
1013,
1999,
2070,
3080,
4617,
1010,
2111,
2979,
1037,
24471,
2072,
2004,
1996,
2034,
6685,
1012,
11997,
1024,
2065,
1006,
7047,
1004,
1004,
7047,
1012,
6254,
12260,
3672,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/cli/server.js | error | function error(err) {
res.statusCode = err.status || 500;
res.end(err.message);
} | javascript | function error(err) {
res.statusCode = err.status || 500;
res.end(err.message);
} | [
"function",
"error",
"(",
"err",
")",
"{",
"res",
".",
"statusCode",
"=",
"err",
".",
"status",
"||",
"500",
";",
"res",
".",
"end",
"(",
"err",
".",
"message",
")",
";",
"}"
] | Render error | [
"Render",
"error"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/cli/server.js#L67-L70 | train | error handler for the server | [
30522,
3853,
7561,
1006,
9413,
2099,
1007,
1063,
24501,
1012,
3570,
16044,
1027,
9413,
2099,
1012,
3570,
1064,
1064,
3156,
1025,
24501,
1012,
2203,
1006,
9413,
2099,
1012,
4471,
1007,
1025,
1065,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js | function (sFetch, bThrow) {
return function () {
var oSyncPromise = this[sFetch].apply(this, arguments);
if (oSyncPromise.isFulfilled()) {
return oSyncPromise.getResult();
} else if (bThrow) {
if (oSyncPromise.isRejected()) {
oSyncPromise.caught();
throw oSyncPromise.getResult();
} else {
throw new Error("Result pending");
}
}
};
} | javascript | function (sFetch, bThrow) {
return function () {
var oSyncPromise = this[sFetch].apply(this, arguments);
if (oSyncPromise.isFulfilled()) {
return oSyncPromise.getResult();
} else if (bThrow) {
if (oSyncPromise.isRejected()) {
oSyncPromise.caught();
throw oSyncPromise.getResult();
} else {
throw new Error("Result pending");
}
}
};
} | [
"function",
"(",
"sFetch",
",",
"bThrow",
")",
"{",
"return",
"function",
"(",
")",
"{",
"var",
"oSyncPromise",
"=",
"this",
"[",
"sFetch",
"]",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"oSyncPromise",
".",
"isFulfilled",
"(",
... | Returns a "get*" method corresponding to the given "fetch*" method.
@param {string} sFetch
A "fetch*" method's name
@param {boolean} [bThrow=false]
Whether the "get*" method throws if the promise is not (yet) fulfilled instead of just
returning <code>undefined</code> (Note:
{@link sap.ui.model.odata.v4.ODataMetaModel#getObject} intentionally never throws
because it is used for data binding)
@returns {function}
A "get*" method returning the "fetch*" method's result or
<code>undefined</code> in case the promise is not (yet) fulfilled | [
"Returns",
"a",
"get",
"*",
"method",
"corresponding",
"to",
"the",
"given",
"fetch",
"*",
"method",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/lib/_Helper.js#L286-L301 | train | Returns a function that will be called when the promise is resolved or rejected. | [
30522,
3853,
1006,
16420,
3388,
2818,
1010,
18411,
8093,
5004,
1007,
1063,
30524,
5562,
1012,
2131,
6072,
11314,
1006,
1007,
1025,
1065,
2842,
2065,
1006,
18411,
8093,
5004,
1007,
1063,
2065,
1006,
9808,
6038,
21906,
21716,
5562,
1012,
2003... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
jhipster/generator-jhipster | generators/aws-containers/aws-client.js | uploadTemplate | function uploadTemplate(bucketName, filename, path) {
return spinner(
new Promise((resolve, reject) =>
fs.stat(path, (error, stats) => {
if (!stats) {
reject(new Error(`File ${chalk.bold(path)} not found`));
}
const upload = s3.upload(
{
Bucket: bucketName,
Key: filename,
Body: fs.createReadStream(path)
},
{
partSize: Math.max(stats.size, S3_MIN_PART_SIZE),
queueSize: 1
}
);
let bar;
upload.on('httpUploadProgress', evt => {
if (!bar && evt.total) {
const total = evt.total / 1000000;
bar = new ProgressBar('uploading [:bar] :percent :etas', {
complete: '=',
incomplete: ' ',
width: 20,
total,
clear: true
});
}
const curr = evt.loaded / 1000000;
bar.tick(curr - bar.curr);
});
return upload
.promise()
.then(resolve)
.catch(reject);
})
)
);
} | javascript | function uploadTemplate(bucketName, filename, path) {
return spinner(
new Promise((resolve, reject) =>
fs.stat(path, (error, stats) => {
if (!stats) {
reject(new Error(`File ${chalk.bold(path)} not found`));
}
const upload = s3.upload(
{
Bucket: bucketName,
Key: filename,
Body: fs.createReadStream(path)
},
{
partSize: Math.max(stats.size, S3_MIN_PART_SIZE),
queueSize: 1
}
);
let bar;
upload.on('httpUploadProgress', evt => {
if (!bar && evt.total) {
const total = evt.total / 1000000;
bar = new ProgressBar('uploading [:bar] :percent :etas', {
complete: '=',
incomplete: ' ',
width: 20,
total,
clear: true
});
}
const curr = evt.loaded / 1000000;
bar.tick(curr - bar.curr);
});
return upload
.promise()
.then(resolve)
.catch(reject);
})
)
);
} | [
"function",
"uploadTemplate",
"(",
"bucketName",
",",
"filename",
",",
"path",
")",
"{",
"return",
"spinner",
"(",
"new",
"Promise",
"(",
"(",
"resolve",
",",
"reject",
")",
"=>",
"fs",
".",
"stat",
"(",
"path",
",",
"(",
"error",
",",
"stats",
")",
... | Upload the template in the S3Bucket
@param bucketName S3 Bucket name to upload the template into
@param filename Name to give to the file in the Bucket
@param path Path to the file
@returns {Promise} | [
"Upload",
"the",
"template",
"in",
"the",
"S3Bucket"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/aws-client.js#L312-L353 | train | Upload a template to the specified bucket | [
30522,
3853,
2039,
11066,
18532,
15725,
1006,
13610,
18442,
1010,
5371,
18442,
1010,
4130,
1007,
1063,
2709,
6714,
3678,
1006,
2047,
4872,
1006,
1006,
10663,
1010,
15454,
1007,
1027,
1028,
1042,
2015,
1012,
28093,
1006,
4130,
1010,
1006,
75... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/colors/colors.js | extractColorOptions | function extractColorOptions(expression) {
var parts = expression.split('-');
var hasTheme = angular.isDefined($mdTheming.THEMES[parts[0]]);
var theme = hasTheme ? parts.splice(0, 1)[0] : $mdTheming.defaultTheme();
return {
theme: theme,
palette: extractPalette(parts, theme),
hue: extractHue(parts, theme),
opacity: parts[2] || 1
};
} | javascript | function extractColorOptions(expression) {
var parts = expression.split('-');
var hasTheme = angular.isDefined($mdTheming.THEMES[parts[0]]);
var theme = hasTheme ? parts.splice(0, 1)[0] : $mdTheming.defaultTheme();
return {
theme: theme,
palette: extractPalette(parts, theme),
hue: extractHue(parts, theme),
opacity: parts[2] || 1
};
} | [
"function",
"extractColorOptions",
"(",
"expression",
")",
"{",
"var",
"parts",
"=",
"expression",
".",
"split",
"(",
"'-'",
")",
";",
"var",
"hasTheme",
"=",
"angular",
".",
"isDefined",
"(",
"$mdTheming",
".",
"THEMES",
"[",
"parts",
"[",
"0",
"]",
"]"... | For the evaluated expression, extract the color parts into a hash map
@param {string} expression color expression like 'red-800', 'red-A200-0.3',
'myTheme-primary', or 'myTheme-primary-400'
@returns {{hue: *, theme: any, palette: *, opacity: (*|string|number)}} | [
"For",
"the",
"evaluated",
"expression",
"extract",
"the",
"color",
"parts",
"into",
"a",
"hash",
"map"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/colors/colors.js#L175-L186 | train | Extract color options from a string | [
30522,
3853,
14817,
18717,
7361,
9285,
1006,
3670,
1007,
1063,
13075,
3033,
1027,
3670,
1012,
3975,
1006,
1005,
1011,
1005,
1007,
1025,
13075,
2038,
10760,
4168,
1027,
16108,
1012,
2003,
3207,
23460,
2094,
1006,
1002,
9108,
10760,
6562,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_CellStyleXF | function parse_CellStyleXF(blob, length, style, opts) {
var o = {};
var a = blob.read_shift(4), b = blob.read_shift(4);
var c = blob.read_shift(4), d = blob.read_shift(2);
o.patternType = XLSFillPattern[c >> 26];
if(!opts.cellStyles) return o;
o.alc = a & 0x07;
o.fWrap = (a >> 3) & 0x01;
o.alcV = (a >> 4) & 0x07;
o.fJustLast = (a >> 7) & 0x01;
o.trot = (a >> 8) & 0xFF;
o.cIndent = (a >> 16) & 0x0F;
o.fShrinkToFit = (a >> 20) & 0x01;
o.iReadOrder = (a >> 22) & 0x02;
o.fAtrNum = (a >> 26) & 0x01;
o.fAtrFnt = (a >> 27) & 0x01;
o.fAtrAlc = (a >> 28) & 0x01;
o.fAtrBdr = (a >> 29) & 0x01;
o.fAtrPat = (a >> 30) & 0x01;
o.fAtrProt = (a >> 31) & 0x01;
o.dgLeft = b & 0x0F;
o.dgRight = (b >> 4) & 0x0F;
o.dgTop = (b >> 8) & 0x0F;
o.dgBottom = (b >> 12) & 0x0F;
o.icvLeft = (b >> 16) & 0x7F;
o.icvRight = (b >> 23) & 0x7F;
o.grbitDiag = (b >> 30) & 0x03;
o.icvTop = c & 0x7F;
o.icvBottom = (c >> 7) & 0x7F;
o.icvDiag = (c >> 14) & 0x7F;
o.dgDiag = (c >> 21) & 0x0F;
o.icvFore = d & 0x7F;
o.icvBack = (d >> 7) & 0x7F;
o.fsxButton = (d >> 14) & 0x01;
return o;
} | javascript | function parse_CellStyleXF(blob, length, style, opts) {
var o = {};
var a = blob.read_shift(4), b = blob.read_shift(4);
var c = blob.read_shift(4), d = blob.read_shift(2);
o.patternType = XLSFillPattern[c >> 26];
if(!opts.cellStyles) return o;
o.alc = a & 0x07;
o.fWrap = (a >> 3) & 0x01;
o.alcV = (a >> 4) & 0x07;
o.fJustLast = (a >> 7) & 0x01;
o.trot = (a >> 8) & 0xFF;
o.cIndent = (a >> 16) & 0x0F;
o.fShrinkToFit = (a >> 20) & 0x01;
o.iReadOrder = (a >> 22) & 0x02;
o.fAtrNum = (a >> 26) & 0x01;
o.fAtrFnt = (a >> 27) & 0x01;
o.fAtrAlc = (a >> 28) & 0x01;
o.fAtrBdr = (a >> 29) & 0x01;
o.fAtrPat = (a >> 30) & 0x01;
o.fAtrProt = (a >> 31) & 0x01;
o.dgLeft = b & 0x0F;
o.dgRight = (b >> 4) & 0x0F;
o.dgTop = (b >> 8) & 0x0F;
o.dgBottom = (b >> 12) & 0x0F;
o.icvLeft = (b >> 16) & 0x7F;
o.icvRight = (b >> 23) & 0x7F;
o.grbitDiag = (b >> 30) & 0x03;
o.icvTop = c & 0x7F;
o.icvBottom = (c >> 7) & 0x7F;
o.icvDiag = (c >> 14) & 0x7F;
o.dgDiag = (c >> 21) & 0x0F;
o.icvFore = d & 0x7F;
o.icvBack = (d >> 7) & 0x7F;
o.fsxButton = (d >> 14) & 0x01;
return o;
} | [
"function",
"parse_CellStyleXF",
"(",
"blob",
",",
"length",
",",
"style",
",",
"opts",
")",
"{",
"var",
"o",
"=",
"{",
"}",
";",
"var",
"a",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
",",
"b",
"=",
"blob",
".",
"read_shift",
"(",
"4",
")",
... | /* [MS-XLS] 2.5.20 2.5.249 TODO: interpret values here | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"5",
".",
"20",
"2",
".",
"5",
".",
"249",
"TODO",
":",
"interpret",
"values",
"here"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6063-L6102 | train | Parse an extended cell style | [
30522,
3853,
11968,
3366,
1035,
4442,
27983,
2595,
2546,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
2806,
1010,
23569,
2015,
1007,
1063,
13075,
1051,
1027,
1063,
1065,
1025,
13075,
1037,
1027,
1038,
4135,
2497,
1012,
3191,
1035,
5670,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
chartjs/Chart.js | src/core/core.tooltip.js | splitNewlines | function splitNewlines(str) {
if ((typeof str === 'string' || str instanceof String) && str.indexOf('\n') > -1) {
return str.split('\n');
}
return str;
} | javascript | function splitNewlines(str) {
if ((typeof str === 'string' || str instanceof String) && str.indexOf('\n') > -1) {
return str.split('\n');
}
return str;
} | [
"function",
"splitNewlines",
"(",
"str",
")",
"{",
"if",
"(",
"(",
"typeof",
"str",
"===",
"'string'",
"||",
"str",
"instanceof",
"String",
")",
"&&",
"str",
".",
"indexOf",
"(",
"'\\n'",
")",
">",
"-",
"1",
")",
"{",
"return",
"str",
".",
"split",
... | Returns array of strings split by newline
@param {string} value - The value to split by newline.
@returns {string[]} value if newline present - Returned from String split() method
@function | [
"Returns",
"array",
"of",
"strings",
"split",
"by",
"newline"
] | f093c36574d290330ed623e60fbd070421c730d5 | https://github.com/chartjs/Chart.js/blob/f093c36574d290330ed623e60fbd070421c730d5/src/core/core.tooltip.js#L197-L202 | train | Split a string into lines | [
30522,
3853,
3975,
2638,
13668,
10586,
1006,
2358,
2099,
30524,
2358,
2099,
1012,
5950,
11253,
1006,
1005,
1032,
1050,
1005,
1007,
1028,
1011,
1015,
1007,
1063,
2709,
2358,
2099,
1012,
3975,
1006,
1005,
1032,
1050,
1005,
1007,
1025,
1065,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jgraph/mxgraph | javascript/mxClient.js | mxCellMarker | function mxCellMarker(graph, validColor, invalidColor, hotspot)
{
mxEventSource.call(this);
if (graph != null)
{
this.graph = graph;
this.validColor = (validColor != null) ? validColor : mxConstants.DEFAULT_VALID_COLOR;
this.invalidColor = (invalidColor != null) ? invalidColor : mxConstants.DEFAULT_INVALID_COLOR;
this.hotspot = (hotspot != null) ? hotspot : mxConstants.DEFAULT_HOTSPOT;
this.highlight = new mxCellHighlight(graph);
}
} | javascript | function mxCellMarker(graph, validColor, invalidColor, hotspot)
{
mxEventSource.call(this);
if (graph != null)
{
this.graph = graph;
this.validColor = (validColor != null) ? validColor : mxConstants.DEFAULT_VALID_COLOR;
this.invalidColor = (invalidColor != null) ? invalidColor : mxConstants.DEFAULT_INVALID_COLOR;
this.hotspot = (hotspot != null) ? hotspot : mxConstants.DEFAULT_HOTSPOT;
this.highlight = new mxCellHighlight(graph);
}
} | [
"function",
"mxCellMarker",
"(",
"graph",
",",
"validColor",
",",
"invalidColor",
",",
"hotspot",
")",
"{",
"mxEventSource",
".",
"call",
"(",
"this",
")",
";",
"if",
"(",
"graph",
"!=",
"null",
")",
"{",
"this",
".",
"graph",
"=",
"graph",
";",
"this"... | Copyright (c) 2006-2015, JGraph Ltd
Copyright (c) 2006-2015, Gaudenz Alder
Class: mxCellMarker
A helper class to process mouse locations and highlight cells.
Helper class to highlight cells. To add a cell marker to an existing graph
for highlighting all cells, the following code is used:
(code)
var marker = new mxCellMarker(graph);
graph.addMouseListener({
mouseDown: function() {},
mouseMove: function(sender, me)
{
marker.process(me);
},
mouseUp: function() {}
});
(end)
Event: mxEvent.MARK
Fires after a cell has been marked or unmarked. The <code>state</code>
property contains the marked <mxCellState> or null if no state is marked.
Constructor: mxCellMarker
Constructs a new cell marker.
Parameters:
graph - Reference to the enclosing <mxGraph>.
validColor - Optional marker color for valid states. Default is
<mxConstants.DEFAULT_VALID_COLOR>.
invalidColor - Optional marker color for invalid states. Default is
<mxConstants.DEFAULT_INVALID_COLOR>.
hotspot - Portion of the width and hight where a state intersects a
given coordinate pair. A value of 0 means always highlight. Default is
<mxConstants.DEFAULT_HOTSPOT>. | [
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"JGraph",
"Ltd",
"Copyright",
"(",
"c",
")",
"2006",
"-",
"2015",
"Gaudenz",
"Alder",
"Class",
":",
"mxCellMarker"
] | 33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44 | https://github.com/jgraph/mxgraph/blob/33911ed7e055c17b74d0367f5f1f6c9ee4b4fd44/javascript/mxClient.js#L71325-L71338 | train | A marker that is used to mark cells in the graph. | [
30522,
3853,
25630,
29109,
19145,
25074,
2099,
1006,
10629,
1010,
9398,
18717,
1010,
19528,
18717,
1010,
2980,
13102,
4140,
1007,
1063,
25630,
18697,
7666,
8162,
3401,
1012,
2655,
1006,
2023,
1007,
1025,
2065,
1006,
10629,
999,
1027,
19701,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/max-len.js | stripTrailingComment | function stripTrailingComment(line, comment) {
// loc.column is zero-indexed
return line.slice(0, comment.loc.start.column).replace(/\s+$/u, "");
} | javascript | function stripTrailingComment(line, comment) {
// loc.column is zero-indexed
return line.slice(0, comment.loc.start.column).replace(/\s+$/u, "");
} | [
"function",
"stripTrailingComment",
"(",
"line",
",",
"comment",
")",
"{",
"// loc.column is zero-indexed",
"return",
"line",
".",
"slice",
"(",
"0",
",",
"comment",
".",
"loc",
".",
"start",
".",
"column",
")",
".",
"replace",
"(",
"/",
"\\s+$",
"/",
"u",... | Gets the line after the comment and any remaining trailing whitespace is
stripped.
@param {string} line The source line with a trailing comment
@param {ASTNode} comment The comment to remove
@returns {string} Line without comment and trailing whitepace | [
"Gets",
"the",
"line",
"after",
"the",
"comment",
"and",
"any",
"remaining",
"trailing",
"whitespace",
"is",
"stripped",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/max-len.js#L193-L197 | train | strip trailing whitespace from comment | [
30522,
3853,
6167,
6494,
16281,
9006,
3672,
1006,
2240,
1010,
7615,
1007,
1063,
1013,
1013,
8840,
2278,
1012,
5930,
2003,
5717,
1011,
25331,
2709,
2240,
1012,
14704,
1006,
1014,
1010,
7615,
1012,
8840,
2278,
1012,
2707,
1012,
5930,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/aws-containers/prompts.js | askCloudFormation | function askCloudFormation() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'input',
name: 'cloudFormationName',
message: "Please enter your stack's name. (must be unique within a region)",
default: this.aws.cloudFormationName || this.baseName,
validate: input => {
if (_.isEmpty(input) || !input.match(CLOUDFORMATION_STACK_NAME)) {
return 'Stack name must contain letters, digits, or hyphens ';
}
return true;
}
}
];
return this.prompt(prompts).then(props => {
const cloudFormationName = props.cloudFormationName;
if (cloudFormationName) {
this.aws.cloudFormationName = cloudFormationName;
while (this.aws.cloudFormationName.includes('_')) {
this.aws.cloudFormationName = _.replace(this.aws.cloudFormationName, '_', '');
}
this.log(`CloudFormation Stack name will be ${this.aws.cloudFormationName}`);
done();
} else {
this.abort = true;
done();
}
});
} | javascript | function askCloudFormation() {
if (this.abort) return null;
const done = this.async();
const prompts = [
{
type: 'input',
name: 'cloudFormationName',
message: "Please enter your stack's name. (must be unique within a region)",
default: this.aws.cloudFormationName || this.baseName,
validate: input => {
if (_.isEmpty(input) || !input.match(CLOUDFORMATION_STACK_NAME)) {
return 'Stack name must contain letters, digits, or hyphens ';
}
return true;
}
}
];
return this.prompt(prompts).then(props => {
const cloudFormationName = props.cloudFormationName;
if (cloudFormationName) {
this.aws.cloudFormationName = cloudFormationName;
while (this.aws.cloudFormationName.includes('_')) {
this.aws.cloudFormationName = _.replace(this.aws.cloudFormationName, '_', '');
}
this.log(`CloudFormation Stack name will be ${this.aws.cloudFormationName}`);
done();
} else {
this.abort = true;
done();
}
});
} | [
"function",
"askCloudFormation",
"(",
")",
"{",
"if",
"(",
"this",
".",
"abort",
")",
"return",
"null",
";",
"const",
"done",
"=",
"this",
".",
"async",
"(",
")",
";",
"const",
"prompts",
"=",
"[",
"{",
"type",
":",
"'input'",
",",
"name",
":",
"'c... | Ask user for CloudFormation name. | [
"Ask",
"user",
"for",
"CloudFormation",
"name",
"."
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/prompts.js#L183-L215 | train | Ask the user to enter the cloudFormation name | [
30522,
3853,
3198,
20464,
19224,
14192,
3370,
1006,
1007,
1063,
2065,
1006,
2023,
1012,
11113,
11589,
1007,
2709,
19701,
1025,
9530,
3367,
2589,
1027,
2023,
1012,
2004,
6038,
2278,
1006,
1007,
1025,
9530,
3367,
25732,
2015,
1027,
1031,
1063... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/JavaScriptCodeHints/main.js | initializeSession | function initializeSession(editor, previousEditor) {
session = new Session(editor);
ScopeManager.handleEditorChange(session, editor.document,
previousEditor ? previousEditor.document : null);
phProvider.setSession(session);
cachedHints = null;
} | javascript | function initializeSession(editor, previousEditor) {
session = new Session(editor);
ScopeManager.handleEditorChange(session, editor.document,
previousEditor ? previousEditor.document : null);
phProvider.setSession(session);
cachedHints = null;
} | [
"function",
"initializeSession",
"(",
"editor",
",",
"previousEditor",
")",
"{",
"session",
"=",
"new",
"Session",
"(",
"editor",
")",
";",
"ScopeManager",
".",
"handleEditorChange",
"(",
"session",
",",
"editor",
".",
"document",
",",
"previousEditor",
"?",
"... | /*
When the editor is changed, reset the hinting session and cached
information, and reject any pending deferred requests.
@param {!Editor} editor - editor context to be initialized.
@param {?Editor} previousEditor - the previous editor. | [
"/",
"*",
"When",
"the",
"editor",
"is",
"changed",
"reset",
"the",
"hinting",
"session",
"and",
"cached",
"information",
"and",
"reject",
"any",
"pending",
"deferred",
"requests",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptCodeHints/main.js#L644-L650 | train | Initialize the session | [
30522,
3853,
3988,
10057,
7971,
3258,
1006,
3559,
1010,
3025,
2098,
15660,
1007,
1063,
5219,
1027,
2047,
5219,
1006,
3559,
1007,
1025,
9531,
24805,
4590,
1012,
5047,
2098,
15660,
22305,
2063,
1006,
5219,
1010,
3559,
1012,
6254,
1010,
3025,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/component/dataZoom/dataZoomProcessor.js | function (ecModel, api) {
ecModel.eachComponent('dataZoom', function (dataZoomModel) {
// We calculate window and reset axis here but not in model
// init stage and not after action dispatch handler, because
// reset should be called after seriesData.restoreData.
dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) {
dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel, api);
});
// Caution: data zoom filtering is order sensitive when using
// percent range and no min/max/scale set on axis.
// For example, we have dataZoom definition:
// [
// {xAxisIndex: 0, start: 30, end: 70},
// {yAxisIndex: 0, start: 20, end: 80}
// ]
// In this case, [20, 80] of y-dataZoom should be based on data
// that have filtered by x-dataZoom using range of [30, 70],
// but should not be based on full raw data. Thus sliding
// x-dataZoom will change both ranges of xAxis and yAxis,
// while sliding y-dataZoom will only change the range of yAxis.
// So we should filter x-axis after reset x-axis immediately,
// and then reset y-axis and filter y-axis.
dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) {
dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel, api);
});
});
ecModel.eachComponent('dataZoom', function (dataZoomModel) {
// Fullfill all of the range props so that user
// is able to get them from chart.getOption().
var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
var percentRange = axisProxy.getDataPercentWindow();
var valueRange = axisProxy.getDataValueWindow();
dataZoomModel.setRawRange({
start: percentRange[0],
end: percentRange[1],
startValue: valueRange[0],
endValue: valueRange[1]
}, true);
});
} | javascript | function (ecModel, api) {
ecModel.eachComponent('dataZoom', function (dataZoomModel) {
// We calculate window and reset axis here but not in model
// init stage and not after action dispatch handler, because
// reset should be called after seriesData.restoreData.
dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) {
dataZoomModel.getAxisProxy(dimNames.name, axisIndex).reset(dataZoomModel, api);
});
// Caution: data zoom filtering is order sensitive when using
// percent range and no min/max/scale set on axis.
// For example, we have dataZoom definition:
// [
// {xAxisIndex: 0, start: 30, end: 70},
// {yAxisIndex: 0, start: 20, end: 80}
// ]
// In this case, [20, 80] of y-dataZoom should be based on data
// that have filtered by x-dataZoom using range of [30, 70],
// but should not be based on full raw data. Thus sliding
// x-dataZoom will change both ranges of xAxis and yAxis,
// while sliding y-dataZoom will only change the range of yAxis.
// So we should filter x-axis after reset x-axis immediately,
// and then reset y-axis and filter y-axis.
dataZoomModel.eachTargetAxis(function (dimNames, axisIndex, dataZoomModel) {
dataZoomModel.getAxisProxy(dimNames.name, axisIndex).filterData(dataZoomModel, api);
});
});
ecModel.eachComponent('dataZoom', function (dataZoomModel) {
// Fullfill all of the range props so that user
// is able to get them from chart.getOption().
var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
var percentRange = axisProxy.getDataPercentWindow();
var valueRange = axisProxy.getDataValueWindow();
dataZoomModel.setRawRange({
start: percentRange[0],
end: percentRange[1],
startValue: valueRange[0],
endValue: valueRange[1]
}, true);
});
} | [
"function",
"(",
"ecModel",
",",
"api",
")",
"{",
"ecModel",
".",
"eachComponent",
"(",
"'dataZoom'",
",",
"function",
"(",
"dataZoomModel",
")",
"{",
"// We calculate window and reset axis here but not in model",
"// init stage and not after action dispatch handler, because",
... | Consider appendData, where filter should be performed. Because data process is in block mode currently, it is not need to worry about that the overallProgress execute every frame. | [
"Consider",
"appendData",
"where",
"filter",
"should",
"be",
"performed",
".",
"Because",
"data",
"process",
"is",
"in",
"block",
"mode",
"currently",
"it",
"is",
"not",
"need",
"to",
"worry",
"about",
"that",
"the",
"overallProgress",
"execute",
"every",
"fra... | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/component/dataZoom/dataZoomProcessor.js#L48-L91 | train | This function is called when data zoom is set to full range | [
30522,
3853,
1006,
14925,
5302,
9247,
1010,
17928,
1007,
1063,
14925,
5302,
9247,
1012,
2169,
9006,
29513,
3372,
1006,
1005,
2951,
23221,
2213,
1005,
1010,
3853,
1006,
2951,
23221,
7382,
10244,
2140,
1007,
1063,
1013,
1013,
2057,
18422,
333... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
wuchangming/spy-debugger | buildin_modules/weinre/web/client/UglifyJS/parse-js.js | is_alphanumeric_char | function is_alphanumeric_char(ch) {
ch = ch.charCodeAt(0);
return (ch >= 48 && ch <= 57) ||
(ch >= 65 && ch <= 90) ||
(ch >= 97 && ch <= 122);
} | javascript | function is_alphanumeric_char(ch) {
ch = ch.charCodeAt(0);
return (ch >= 48 && ch <= 57) ||
(ch >= 65 && ch <= 90) ||
(ch >= 97 && ch <= 122);
} | [
"function",
"is_alphanumeric_char",
"(",
"ch",
")",
"{",
"ch",
"=",
"ch",
".",
"charCodeAt",
"(",
"0",
")",
";",
"return",
"(",
"ch",
">=",
"48",
"&&",
"ch",
"<=",
"57",
")",
"||",
"(",
"ch",
">=",
"65",
"&&",
"ch",
"<=",
"90",
")",
"||",
"(",
... | /* -----[ Tokenizer ]----- | [
"/",
"*",
"-----",
"[",
"Tokenizer",
"]",
"-----"
] | 55c1dda0dff0c44920673711656ddfd7ff03c307 | https://github.com/wuchangming/spy-debugger/blob/55c1dda0dff0c44920673711656ddfd7ff03c307/buildin_modules/weinre/web/client/UglifyJS/parse-js.js#L203-L208 | train | Check if a character is an alphanumeric character | [
30522,
3853,
2003,
1035,
6541,
19172,
22420,
1035,
25869,
1006,
10381,
1007,
1063,
30524,
2709,
1006,
10381,
1028,
1027,
4466,
1004,
1004,
10381,
1026,
1027,
5401,
1007,
1064,
1064,
1006,
10381,
1028,
1027,
3515,
1004,
1004,
10381,
1026,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
postmanlabs/newman | npm/server.js | createRawEchoServer | function createRawEchoServer () {
var server;
server = net.createServer(function (socket) {
socket.on('data', function (chunk) {
if (this.data === undefined) {
this.data = '';
setTimeout(() => {
// Status Line
socket.write('HTTP/1.1 200 ok\r\n');
// Response Headers
socket.write('connection: close\r\n');
socket.write('content-type: text/plain\r\n');
socket.write('raw-request: ' + JSON.stringify(this.data) + '\r\n');
// CRLF
socket.write('\r\n');
// Response Body
if (!this.data.startsWith('HEAD / HTTP/1.1')) {
socket.write(this.data);
}
socket.end();
}, 1000);
}
this.data += chunk.toString();
});
});
server.on('listening', function () {
server.port = this.address().port;
});
enableServerDestroy(server);
return server;
} | javascript | function createRawEchoServer () {
var server;
server = net.createServer(function (socket) {
socket.on('data', function (chunk) {
if (this.data === undefined) {
this.data = '';
setTimeout(() => {
// Status Line
socket.write('HTTP/1.1 200 ok\r\n');
// Response Headers
socket.write('connection: close\r\n');
socket.write('content-type: text/plain\r\n');
socket.write('raw-request: ' + JSON.stringify(this.data) + '\r\n');
// CRLF
socket.write('\r\n');
// Response Body
if (!this.data.startsWith('HEAD / HTTP/1.1')) {
socket.write(this.data);
}
socket.end();
}, 1000);
}
this.data += chunk.toString();
});
});
server.on('listening', function () {
server.port = this.address().port;
});
enableServerDestroy(server);
return server;
} | [
"function",
"createRawEchoServer",
"(",
")",
"{",
"var",
"server",
";",
"server",
"=",
"net",
".",
"createServer",
"(",
"function",
"(",
"socket",
")",
"{",
"socket",
".",
"on",
"(",
"'data'",
",",
"function",
"(",
"chunk",
")",
"{",
"if",
"(",
"this",... | Echo raw request message to test
- Body for HTTP methods like GET, HEAD
- Custom HTTP methods
@example
var s = createRawEchoServer();
s.listen(3000, function() {
console.log(s.port);
s.close();
});
@note For HEAD request, read body from `raw-request` response header | [
"Echo",
"raw",
"request",
"message",
"to",
"test",
"-",
"Body",
"for",
"HTTP",
"methods",
"like",
"GET",
"HEAD",
"-",
"Custom",
"HTTP",
"methods"
] | c05a5a1e82aa3c2021e94ba09e627ba4718af69e | https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/npm/server.js#L20-L60 | train | Create a server that sends raw - echo requests to the remote server | [
30522,
3853,
3443,
2527,
8545,
9905,
8043,
6299,
1006,
1007,
1063,
13075,
8241,
1025,
8241,
1027,
5658,
1012,
9005,
2121,
6299,
1006,
3853,
1006,
22278,
1007,
1063,
22278,
1012,
2006,
1006,
1005,
2951,
1005,
1010,
3853,
1006,
20000,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
summernote/summernote | src/js/base/core/dom.js | splitNode | function splitNode(point, options) {
let isSkipPaddingBlankHTML = options && options.isSkipPaddingBlankHTML;
const isNotSplitEdgePoint = options && options.isNotSplitEdgePoint;
const isDiscardEmptySplits = options && options.isDiscardEmptySplits;
if (isDiscardEmptySplits) {
isSkipPaddingBlankHTML = true;
}
// edge case
if (isEdgePoint(point) && (isText(point.node) || isNotSplitEdgePoint)) {
if (isLeftEdgePoint(point)) {
return point.node;
} else if (isRightEdgePoint(point)) {
return point.node.nextSibling;
}
}
// split #text
if (isText(point.node)) {
return point.node.splitText(point.offset);
} else {
const childNode = point.node.childNodes[point.offset];
const clone = insertAfter(point.node.cloneNode(false), point.node);
appendChildNodes(clone, listNext(childNode));
if (!isSkipPaddingBlankHTML) {
paddingBlankHTML(point.node);
paddingBlankHTML(clone);
}
if (isDiscardEmptySplits) {
if (isEmpty(point.node)) {
remove(point.node);
}
if (isEmpty(clone)) {
remove(clone);
return point.node.nextSibling;
}
}
return clone;
}
} | javascript | function splitNode(point, options) {
let isSkipPaddingBlankHTML = options && options.isSkipPaddingBlankHTML;
const isNotSplitEdgePoint = options && options.isNotSplitEdgePoint;
const isDiscardEmptySplits = options && options.isDiscardEmptySplits;
if (isDiscardEmptySplits) {
isSkipPaddingBlankHTML = true;
}
// edge case
if (isEdgePoint(point) && (isText(point.node) || isNotSplitEdgePoint)) {
if (isLeftEdgePoint(point)) {
return point.node;
} else if (isRightEdgePoint(point)) {
return point.node.nextSibling;
}
}
// split #text
if (isText(point.node)) {
return point.node.splitText(point.offset);
} else {
const childNode = point.node.childNodes[point.offset];
const clone = insertAfter(point.node.cloneNode(false), point.node);
appendChildNodes(clone, listNext(childNode));
if (!isSkipPaddingBlankHTML) {
paddingBlankHTML(point.node);
paddingBlankHTML(clone);
}
if (isDiscardEmptySplits) {
if (isEmpty(point.node)) {
remove(point.node);
}
if (isEmpty(clone)) {
remove(clone);
return point.node.nextSibling;
}
}
return clone;
}
} | [
"function",
"splitNode",
"(",
"point",
",",
"options",
")",
"{",
"let",
"isSkipPaddingBlankHTML",
"=",
"options",
"&&",
"options",
".",
"isSkipPaddingBlankHTML",
";",
"const",
"isNotSplitEdgePoint",
"=",
"options",
"&&",
"options",
".",
"isNotSplitEdgePoint",
";",
... | @method splitNode
split element or #text
@param {BoundaryPoint} point
@param {Object} [options]
@param {Boolean} [options.isSkipPaddingBlankHTML] - default: false
@param {Boolean} [options.isNotSplitEdgePoint] - default: false
@param {Boolean} [options.isDiscardEmptySplits] - default: false
@return {Node} right node of boundaryPoint | [
"@method",
"splitNode"
] | 8dcafb8107453006b905ef697a529c42e76beb3f | https://github.com/summernote/summernote/blob/8dcafb8107453006b905ef697a529c42e76beb3f/src/js/base/core/dom.js#L739-L782 | train | split node by point | [
30522,
3853,
3975,
3630,
3207,
1006,
2391,
1010,
7047,
1007,
1063,
2292,
26354,
3211,
13944,
27027,
28522,
8950,
11039,
19968,
1027,
7047,
1004,
1004,
7047,
1012,
26354,
3211,
13944,
27027,
28522,
8950,
11039,
19968,
1025,
9530,
3367,
3475,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/coord/Axis.js | function (coord) {
var extent = this._extent;
var min = Math.min(extent[0], extent[1]);
var max = Math.max(extent[0], extent[1]);
return coord >= min && coord <= max;
} | javascript | function (coord) {
var extent = this._extent;
var min = Math.min(extent[0], extent[1]);
var max = Math.max(extent[0], extent[1]);
return coord >= min && coord <= max;
} | [
"function",
"(",
"coord",
")",
"{",
"var",
"extent",
"=",
"this",
".",
"_extent",
";",
"var",
"min",
"=",
"Math",
".",
"min",
"(",
"extent",
"[",
"0",
"]",
",",
"extent",
"[",
"1",
"]",
")",
";",
"var",
"max",
"=",
"Math",
".",
"max",
"(",
"e... | If axis extent contain given coord
@param {number} coord
@return {boolean} | [
"If",
"axis",
"extent",
"contain",
"given",
"coord"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/coord/Axis.js#L75-L80 | train | Returns true if the given coordinates are within the current extent of the current image. | [
30522,
3853,
1006,
2522,
8551,
1007,
1063,
13075,
6698,
1027,
2023,
1012,
1035,
6698,
1025,
13075,
8117,
1027,
8785,
1012,
8117,
1006,
6698,
1031,
1014,
1033,
1010,
6698,
1031,
1015,
1033,
1007,
1025,
13075,
4098,
1027,
8785,
1012,
4098,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/signals.js | function (listener, listenerContext, priority) {
validateListener(listener, 'add');
return this._registerListener(listener, false, listenerContext, priority);
} | javascript | function (listener, listenerContext, priority) {
validateListener(listener, 'add');
return this._registerListener(listener, false, listenerContext, priority);
} | [
"function",
"(",
"listener",
",",
"listenerContext",
",",
"priority",
")",
"{",
"validateListener",
"(",
"listener",
",",
"'add'",
")",
";",
"return",
"this",
".",
"_registerListener",
"(",
"listener",
",",
"false",
",",
"listenerContext",
",",
"priority",
")"... | Add a listener to the signal.
@param {Function} listener Signal handler function.
@param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).
@param {Number} [priority] The priority level of the event listener. Listeners with higher priority will be executed before listeners with lower priority. Listeners with same priority level will be executed at the same order as they were added. (default = 0)
@return {SignalBinding} An Object representing the binding between the Signal and listener. | [
"Add",
"a",
"listener",
"to",
"the",
"signal",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/signals.js#L296-L299 | train | Add a listener to the event queue. | [
30522,
3853,
1006,
19373,
1010,
19373,
8663,
18209,
1010,
9470,
1007,
1063,
9398,
3686,
9863,
24454,
1006,
19373,
1010,
1005,
5587,
1005,
1007,
1025,
2709,
2023,
1012,
1035,
4236,
9863,
24454,
1006,
19373,
1010,
6270,
1010,
19373,
8663,
182... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
TryGhost/Ghost | core/server/lib/common/i18n.js | loadThemeTranslations | function loadThemeTranslations() {
// This function is called during theme initialization, and when switching language or theme.
currentLocale = I18n.locale();
activeTheme = settingsCache.get('active_theme');
// Reading file for current locale and active theme and keeping its content in memory
if (activeTheme) {
// Reading translation file for theme .hbs templates.
// Compatibility with both old themes and i18n-capable themes.
// Preventing missing files.
try {
themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', currentLocale + '.json'));
} catch (err) {
themeStrings = undefined;
if (err.code === 'ENOENT') {
if (currentLocale !== 'en') {
logging.warn(`Theme's file locales/${currentLocale}.json not found.`);
}
} else {
throw err;
}
}
if (themeStrings === undefined && currentLocale !== 'en') {
logging.warn('Falling back to locales/en.json.');
try {
themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', 'en.json'));
} catch (err) {
themeStrings = undefined;
if (err.code === 'ENOENT') {
logging.warn('Theme\'s file locales/en.json not found.');
} else {
throw err;
}
}
}
if (themeStrings !== undefined) {
// if translation file is not valid, you will see an error
try {
themeStrings = JSON.parse(themeStrings);
} catch (err) {
themeStrings = undefined;
throw err;
}
}
}
if (themeStrings === undefined) {
// even if empty, themeStrings must be an object for jp.value
themeStrings = {};
}
_private.initializeIntl();
} | javascript | function loadThemeTranslations() {
// This function is called during theme initialization, and when switching language or theme.
currentLocale = I18n.locale();
activeTheme = settingsCache.get('active_theme');
// Reading file for current locale and active theme and keeping its content in memory
if (activeTheme) {
// Reading translation file for theme .hbs templates.
// Compatibility with both old themes and i18n-capable themes.
// Preventing missing files.
try {
themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', currentLocale + '.json'));
} catch (err) {
themeStrings = undefined;
if (err.code === 'ENOENT') {
if (currentLocale !== 'en') {
logging.warn(`Theme's file locales/${currentLocale}.json not found.`);
}
} else {
throw err;
}
}
if (themeStrings === undefined && currentLocale !== 'en') {
logging.warn('Falling back to locales/en.json.');
try {
themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', 'en.json'));
} catch (err) {
themeStrings = undefined;
if (err.code === 'ENOENT') {
logging.warn('Theme\'s file locales/en.json not found.');
} else {
throw err;
}
}
}
if (themeStrings !== undefined) {
// if translation file is not valid, you will see an error
try {
themeStrings = JSON.parse(themeStrings);
} catch (err) {
themeStrings = undefined;
throw err;
}
}
}
if (themeStrings === undefined) {
// even if empty, themeStrings must be an object for jp.value
themeStrings = {};
}
_private.initializeIntl();
} | [
"function",
"loadThemeTranslations",
"(",
")",
"{",
"// This function is called during theme initialization, and when switching language or theme.",
"currentLocale",
"=",
"I18n",
".",
"locale",
"(",
")",
";",
"activeTheme",
"=",
"settingsCache",
".",
"get",
"(",
"'active_them... | Setup i18n support for themes:
- Load proper language file into memory | [
"Setup",
"i18n",
"support",
"for",
"themes",
":",
"-",
"Load",
"proper",
"language",
"file",
"into",
"memory"
] | bb7bb55cf3e60af99ebbc56099928827b58461bc | https://github.com/TryGhost/Ghost/blob/bb7bb55cf3e60af99ebbc56099928827b58461bc/core/server/lib/common/i18n.js#L198-L250 | train | Load theme translations | [
30522,
3853,
7170,
10760,
11368,
5521,
14540,
10708,
1006,
1007,
1063,
1013,
1013,
2023,
3853,
2003,
2170,
2076,
4323,
3988,
3989,
1010,
1998,
2043,
11991,
2653,
2030,
4323,
1012,
2783,
4135,
9289,
2063,
1027,
1045,
15136,
2078,
1012,
2334,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js | BezierCanvas | function BezierCanvas(canvas, bezier, padding) {
this.canvas = canvas;
this.bezier = bezier;
this.padding = this.getPadding(padding);
// Convert to a cartesian coordinate system with axes from 0 to 1
var ctx = this.canvas.getContext("2d"),
p = this.padding;
ctx.scale(canvas.width * (1 - p[1] - p[3]), -canvas.height * 0.5 * (1 - p[0] - p[2]));
ctx.translate(p[3] / (1 - p[1] - p[3]), (-1 - p[0] / (1 - p[0] - p[2])) - 0.5);
} | javascript | function BezierCanvas(canvas, bezier, padding) {
this.canvas = canvas;
this.bezier = bezier;
this.padding = this.getPadding(padding);
// Convert to a cartesian coordinate system with axes from 0 to 1
var ctx = this.canvas.getContext("2d"),
p = this.padding;
ctx.scale(canvas.width * (1 - p[1] - p[3]), -canvas.height * 0.5 * (1 - p[0] - p[2]));
ctx.translate(p[3] / (1 - p[1] - p[3]), (-1 - p[0] / (1 - p[0] - p[2])) - 0.5);
} | [
"function",
"BezierCanvas",
"(",
"canvas",
",",
"bezier",
",",
"padding",
")",
"{",
"this",
".",
"canvas",
"=",
"canvas",
";",
"this",
".",
"bezier",
"=",
"bezier",
";",
"this",
".",
"padding",
"=",
"this",
".",
"getPadding",
"(",
"padding",
")",
";",
... | BezierCanvas object constructor
@param {Element} canvas Inline editor <canvas> element
@param {CubicBezier} bezier Associated CubicBezier object
@param {number|Array.number} padding Element padding | [
"BezierCanvas",
"object",
"constructor"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/InlineTimingFunctionEditor/BezierCurveEditor.js#L79-L90 | train | The BezierCanvas constructor. | [
30522,
3853,
2022,
21548,
9336,
12044,
1006,
10683,
1010,
2022,
21548,
1010,
11687,
4667,
1007,
1063,
2023,
1012,
10683,
1027,
10683,
1025,
2023,
1012,
2022,
21548,
1027,
2022,
21548,
1025,
2023,
1012,
11687,
4667,
1027,
2023,
1012,
2131,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
hakimel/reveal.js | plugin/highlight/highlight.js | function( block, linesToHighlight ) {
linesToHighlight = linesToHighlight || block.getAttribute( 'data-line-numbers' );
if( typeof linesToHighlight === 'string' && linesToHighlight !== '' ) {
linesToHighlight.split( ',' ).forEach( function( lineNumbers ) {
// Avoid failures becase of whitespace
lineNumbers = lineNumbers.replace( /\s/g, '' );
// Ensure that we looking at a valid slide number (1 or 1-2)
if( /^[\d-]+$/.test( lineNumbers ) ) {
lineNumbers = lineNumbers.split( '-' );
var lineStart = lineNumbers[0];
var lineEnd = lineNumbers[1] || lineStart;
[].slice.call( block.querySelectorAll( 'table tr:nth-child(n+'+lineStart+'):nth-child(-n+'+lineEnd+')' ) ).forEach( function( lineElement ) {
lineElement.classList.add( 'highlight-line' );
} );
}
} );
}
} | javascript | function( block, linesToHighlight ) {
linesToHighlight = linesToHighlight || block.getAttribute( 'data-line-numbers' );
if( typeof linesToHighlight === 'string' && linesToHighlight !== '' ) {
linesToHighlight.split( ',' ).forEach( function( lineNumbers ) {
// Avoid failures becase of whitespace
lineNumbers = lineNumbers.replace( /\s/g, '' );
// Ensure that we looking at a valid slide number (1 or 1-2)
if( /^[\d-]+$/.test( lineNumbers ) ) {
lineNumbers = lineNumbers.split( '-' );
var lineStart = lineNumbers[0];
var lineEnd = lineNumbers[1] || lineStart;
[].slice.call( block.querySelectorAll( 'table tr:nth-child(n+'+lineStart+'):nth-child(-n+'+lineEnd+')' ) ).forEach( function( lineElement ) {
lineElement.classList.add( 'highlight-line' );
} );
}
} );
}
} | [
"function",
"(",
"block",
",",
"linesToHighlight",
")",
"{",
"linesToHighlight",
"=",
"linesToHighlight",
"||",
"block",
".",
"getAttribute",
"(",
"'data-line-numbers'",
")",
";",
"if",
"(",
"typeof",
"linesToHighlight",
"===",
"'string'",
"&&",
"linesToHighlight",
... | Visually emphasize specific lines within a code block.
This only works on blocks with line numbering turned on.
@param {HTMLElement} block a <code> block
@param {String} [linesToHighlight] The lines that should be
highlighted in this format:
"1" = highlights line 1
"2,5" = highlights lines 2 & 5
"2,5-7" = highlights lines 2, 5, 6 & 7 | [
"Visually",
"emphasize",
"specific",
"lines",
"within",
"a",
"code",
"block",
".",
"This",
"only",
"works",
"on",
"blocks",
"with",
"line",
"numbering",
"turned",
"on",
"."
] | 33bed47daca3f08c396215415e6ece005970734a | https://github.com/hakimel/reveal.js/blob/33bed47daca3f08c396215415e6ece005970734a/plugin/highlight/highlight.js#L132-L161 | train | Highlights the specified lines | [
30522,
3853,
1006,
3796,
1010,
3210,
3406,
4048,
5603,
7138,
1007,
1063,
3210,
3406,
4048,
5603,
7138,
1027,
3210,
3406,
4048,
5603,
7138,
1064,
1064,
3796,
1012,
2131,
19321,
3089,
8569,
2618,
1006,
1005,
2951,
1011,
2240,
1011,
3616,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/preferences/PreferencesBase.js | function (id, before) {
var defaultScopeOrder = this._defaults.scopeOrder,
index = _.findIndex(defaultScopeOrder, function (id) {
return id === before;
});
if (index > -1) {
defaultScopeOrder.splice(index, 0, id);
} else {
// error
throw new Error("Internal error: scope " + before + " should be in the scope order");
}
} | javascript | function (id, before) {
var defaultScopeOrder = this._defaults.scopeOrder,
index = _.findIndex(defaultScopeOrder, function (id) {
return id === before;
});
if (index > -1) {
defaultScopeOrder.splice(index, 0, id);
} else {
// error
throw new Error("Internal error: scope " + before + " should be in the scope order");
}
} | [
"function",
"(",
"id",
",",
"before",
")",
"{",
"var",
"defaultScopeOrder",
"=",
"this",
".",
"_defaults",
".",
"scopeOrder",
",",
"index",
"=",
"_",
".",
"findIndex",
"(",
"defaultScopeOrder",
",",
"function",
"(",
"id",
")",
"{",
"return",
"id",
"===",... | @private
Adds the scope before the scope specified by before argument. This
function must never be called directly. Use addScope to add scopes to
PreferencesSystem, including from within its implementation.
@param {string} id Id of the scope to add
@param {string} before Id of the scope to add it before | [
"@private"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/preferences/PreferencesBase.js#L1363-L1375 | train | add a new session to the scope order | [
30522,
3853,
1006,
8909,
1010,
2077,
1007,
1063,
13075,
12398,
26127,
8551,
2121,
1027,
2023,
1012,
1035,
12398,
2015,
1012,
9531,
8551,
2121,
1010,
5950,
1027,
1035,
1012,
2424,
22254,
10288,
1006,
12398,
26127,
8551,
2121,
1010,
3853,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/LiveDevelopment/LiveDevelopment.js | _waitForInterstitialPageLoad | function _waitForInterstitialPageLoad() {
var deferred = $.Deferred(),
keepPolling = true,
timer = window.setTimeout(function () {
keepPolling = false;
deferred.reject();
}, 10000); // 10 seconds
/*
* Asynchronously check to see if the interstitial page has
* finished loading; if not, check again until timing out.
*/
function pollInterstitialPage() {
if (keepPolling && Inspector.connected()) {
Inspector.Runtime.evaluate("window.isBracketsLiveDevelopmentInterstitialPageLoaded", function (response) {
var result = response.result;
if (result.type === "boolean" && result.value) {
window.clearTimeout(timer);
deferred.resolve();
} else {
window.setTimeout(pollInterstitialPage, 100);
}
});
} else {
deferred.reject();
}
}
pollInterstitialPage();
return deferred.promise();
} | javascript | function _waitForInterstitialPageLoad() {
var deferred = $.Deferred(),
keepPolling = true,
timer = window.setTimeout(function () {
keepPolling = false;
deferred.reject();
}, 10000); // 10 seconds
/*
* Asynchronously check to see if the interstitial page has
* finished loading; if not, check again until timing out.
*/
function pollInterstitialPage() {
if (keepPolling && Inspector.connected()) {
Inspector.Runtime.evaluate("window.isBracketsLiveDevelopmentInterstitialPageLoaded", function (response) {
var result = response.result;
if (result.type === "boolean" && result.value) {
window.clearTimeout(timer);
deferred.resolve();
} else {
window.setTimeout(pollInterstitialPage, 100);
}
});
} else {
deferred.reject();
}
}
pollInterstitialPage();
return deferred.promise();
} | [
"function",
"_waitForInterstitialPageLoad",
"(",
")",
"{",
"var",
"deferred",
"=",
"$",
".",
"Deferred",
"(",
")",
",",
"keepPolling",
"=",
"true",
",",
"timer",
"=",
"window",
".",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"keepPolling",
"=",
"false",... | @private
Create a promise that resolves when the interstitial page has
finished loading.
@return {jQuery.Promise} Resolves once page is loaded | [
"@private",
"Create",
"a",
"promise",
"that",
"resolves",
"when",
"the",
"interstitial",
"page",
"has",
"finished",
"loading",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/LiveDevelopment.js#L1019-L1050 | train | Wait until the interstitial page has finished loading | [
30522,
3853,
1035,
3524,
29278,
18447,
2545,
3775,
20925,
13704,
11066,
1006,
1007,
1063,
13075,
13366,
28849,
2094,
1027,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1010,
2562,
18155,
2989,
1027,
2995,
1010,
25309,
1027,
3332,
1012,
2275,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
expressjs/express | lib/response.js | onaborted | function onaborted() {
if (done) return;
done = true;
var err = new Error('Request aborted');
err.code = 'ECONNABORTED';
callback(err);
} | javascript | function onaborted() {
if (done) return;
done = true;
var err = new Error('Request aborted');
err.code = 'ECONNABORTED';
callback(err);
} | [
"function",
"onaborted",
"(",
")",
"{",
"if",
"(",
"done",
")",
"return",
";",
"done",
"=",
"true",
";",
"var",
"err",
"=",
"new",
"Error",
"(",
"'Request aborted'",
")",
";",
"err",
".",
"code",
"=",
"'ECONNABORTED'",
";",
"callback",
"(",
"err",
")... | request aborted | [
"request",
"aborted"
] | dc538f6e810bd462c98ee7e6aae24c64d4b1da93 | https://github.com/expressjs/express/blob/dc538f6e810bd462c98ee7e6aae24c64d4b1da93/lib/response.js#L1017-L1024 | train | Called when the connection to the cluster has aborted | [
30522,
3853,
2006,
7875,
15613,
1006,
1007,
1063,
2065,
1006,
2589,
1007,
2709,
1025,
2589,
1027,
2995,
1025,
13075,
9413,
2099,
1027,
2047,
7561,
1006,
1005,
5227,
11113,
15613,
30524,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/service.js | attachMonitoringEmitter | function attachMonitoringEmitter(request) {
var attemptTimestamp; //timestamp marking the beginning of a request attempt
var attemptStartRealTime; //Start time of request attempt. Used to calculating attemptLatency
var attemptLatency; //latency from request sent out to http response reaching SDK
var callStartRealTime; //Start time of API call. Used to calculating API call latency
var attemptCount = 0; //request.retryCount is not reliable here
var region; //region cache region for each attempt since it can be updated in plase (e.g. s3)
var callTimestamp; //timestamp when the request is created
var self = this;
var addToHead = true;
request.on('validate', function () {
callStartRealTime = AWS.util.realClock.now();
callTimestamp = Date.now();
}, addToHead);
request.on('sign', function () {
attemptStartRealTime = AWS.util.realClock.now();
attemptTimestamp = Date.now();
region = request.httpRequest.region;
attemptCount++;
}, addToHead);
request.on('validateResponse', function() {
attemptLatency = Math.round(AWS.util.realClock.now() - attemptStartRealTime);
});
request.addNamedListener('API_CALL_ATTEMPT', 'success', function API_CALL_ATTEMPT() {
var apiAttemptEvent = self.apiAttemptEvent(request);
apiAttemptEvent.Timestamp = attemptTimestamp;
apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0;
apiAttemptEvent.Region = region;
self.emit('apiCallAttempt', [apiAttemptEvent]);
});
request.addNamedListener('API_CALL_ATTEMPT_RETRY', 'retry', function API_CALL_ATTEMPT_RETRY() {
var apiAttemptEvent = self.attemptFailEvent(request);
apiAttemptEvent.Timestamp = attemptTimestamp;
//attemptLatency may not be available if fail before response
attemptLatency = attemptLatency ||
Math.round(AWS.util.realClock.now() - attemptStartRealTime);
apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0;
apiAttemptEvent.Region = region;
self.emit('apiCallAttempt', [apiAttemptEvent]);
});
request.addNamedListener('API_CALL', 'complete', function API_CALL() {
var apiCallEvent = self.apiCallEvent(request);
apiCallEvent.AttemptCount = attemptCount;
if (apiCallEvent.AttemptCount <= 0) return;
apiCallEvent.Timestamp = callTimestamp;
var latency = Math.round(AWS.util.realClock.now() - callStartRealTime);
apiCallEvent.Latency = latency >= 0 ? latency : 0;
var response = request.response;
if (
typeof response.retryCount === 'number' &&
typeof response.maxRetries === 'number' &&
(response.retryCount >= response.maxRetries)
) {
apiCallEvent.MaxRetriesExceeded = 1;
}
self.emit('apiCall', [apiCallEvent]);
});
} | javascript | function attachMonitoringEmitter(request) {
var attemptTimestamp; //timestamp marking the beginning of a request attempt
var attemptStartRealTime; //Start time of request attempt. Used to calculating attemptLatency
var attemptLatency; //latency from request sent out to http response reaching SDK
var callStartRealTime; //Start time of API call. Used to calculating API call latency
var attemptCount = 0; //request.retryCount is not reliable here
var region; //region cache region for each attempt since it can be updated in plase (e.g. s3)
var callTimestamp; //timestamp when the request is created
var self = this;
var addToHead = true;
request.on('validate', function () {
callStartRealTime = AWS.util.realClock.now();
callTimestamp = Date.now();
}, addToHead);
request.on('sign', function () {
attemptStartRealTime = AWS.util.realClock.now();
attemptTimestamp = Date.now();
region = request.httpRequest.region;
attemptCount++;
}, addToHead);
request.on('validateResponse', function() {
attemptLatency = Math.round(AWS.util.realClock.now() - attemptStartRealTime);
});
request.addNamedListener('API_CALL_ATTEMPT', 'success', function API_CALL_ATTEMPT() {
var apiAttemptEvent = self.apiAttemptEvent(request);
apiAttemptEvent.Timestamp = attemptTimestamp;
apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0;
apiAttemptEvent.Region = region;
self.emit('apiCallAttempt', [apiAttemptEvent]);
});
request.addNamedListener('API_CALL_ATTEMPT_RETRY', 'retry', function API_CALL_ATTEMPT_RETRY() {
var apiAttemptEvent = self.attemptFailEvent(request);
apiAttemptEvent.Timestamp = attemptTimestamp;
//attemptLatency may not be available if fail before response
attemptLatency = attemptLatency ||
Math.round(AWS.util.realClock.now() - attemptStartRealTime);
apiAttemptEvent.AttemptLatency = attemptLatency >= 0 ? attemptLatency : 0;
apiAttemptEvent.Region = region;
self.emit('apiCallAttempt', [apiAttemptEvent]);
});
request.addNamedListener('API_CALL', 'complete', function API_CALL() {
var apiCallEvent = self.apiCallEvent(request);
apiCallEvent.AttemptCount = attemptCount;
if (apiCallEvent.AttemptCount <= 0) return;
apiCallEvent.Timestamp = callTimestamp;
var latency = Math.round(AWS.util.realClock.now() - callStartRealTime);
apiCallEvent.Latency = latency >= 0 ? latency : 0;
var response = request.response;
if (
typeof response.retryCount === 'number' &&
typeof response.maxRetries === 'number' &&
(response.retryCount >= response.maxRetries)
) {
apiCallEvent.MaxRetriesExceeded = 1;
}
self.emit('apiCall', [apiCallEvent]);
});
} | [
"function",
"attachMonitoringEmitter",
"(",
"request",
")",
"{",
"var",
"attemptTimestamp",
";",
"//timestamp marking the beginning of a request attempt",
"var",
"attemptStartRealTime",
";",
"//Start time of request attempt. Used to calculating attemptLatency",
"var",
"attemptLatency",... | Attach listeners to request object to fetch metrics of each request
and emit data object through \'ApiCall\' and \'ApiCallAttempt\' events.
@api private | [
"Attach",
"listeners",
"to",
"request",
"object",
"to",
"fetch",
"metrics",
"of",
"each",
"request",
"and",
"emit",
"data",
"object",
"through",
"\\",
"ApiCall",
"\\",
"and",
"\\",
"ApiCallAttempt",
"\\",
"events",
"."
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/service.js#L386-L444 | train | Attaches event listeners to the request object | [
30522,
3853,
22476,
8202,
15660,
23496,
22930,
3334,
1006,
5227,
1007,
1063,
13075,
3535,
7292,
9153,
8737,
1025,
1013,
1013,
2335,
15464,
2361,
10060,
1996,
2927,
1997,
1037,
5227,
3535,
13075,
4740,
7559,
7913,
2389,
7292,
1025,
1013,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/layout/layout.js | buildUpdateFn | function buildUpdateFn(element, className, attrs) {
return function updateAttrValue(fallback) {
if (!needsInterpolation(fallback)) {
// Do not modify the element's attribute value; so
// uses '<ui-layout layout="/api/sidebar.html" />' will not
// be affected. Just update the attrs value.
attrs[attrs.$normalize(className)] = fallback;
}
};
} | javascript | function buildUpdateFn(element, className, attrs) {
return function updateAttrValue(fallback) {
if (!needsInterpolation(fallback)) {
// Do not modify the element's attribute value; so
// uses '<ui-layout layout="/api/sidebar.html" />' will not
// be affected. Just update the attrs value.
attrs[attrs.$normalize(className)] = fallback;
}
};
} | [
"function",
"buildUpdateFn",
"(",
"element",
",",
"className",
",",
"attrs",
")",
"{",
"return",
"function",
"updateAttrValue",
"(",
"fallback",
")",
"{",
"if",
"(",
"!",
"needsInterpolation",
"(",
"fallback",
")",
")",
"{",
"// Do not modify the element's attribu... | Replace current attribute value with fallback value | [
"Replace",
"current",
"attribute",
"value",
"with",
"fallback",
"value"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/layout/layout.js#L460-L469 | train | Build a function that updates the attribute value of the element. | [
30522,
3853,
3857,
6279,
13701,
2546,
2078,
1006,
5783,
1010,
2465,
18442,
1010,
2012,
16344,
2015,
1007,
1063,
2709,
3853,
10651,
19321,
26585,
5657,
1006,
2991,
5963,
1007,
1063,
2065,
1006,
999,
3791,
18447,
2121,
18155,
3370,
1006,
2991... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/LiveDevelopment/MultiBrowserImpl/transports/remote/NodeSocketTransportRemote.js | function (url) {
var self = this;
this._ws = new WebSocket(url);
// One potential source of confusion: the transport sends two "types" of messages -
// these are distinct from the protocol's own messages. This is because this transport
// needs to send an initial "connect" message telling the Brackets side of the transport
// the URL of the page that it's connecting from, distinct from the actual protocol
// message traffic. Actual protocol messages are sent as a JSON payload in a message of
// type "message".
//
// Other transports might not need to do this - for example, a transport that simply
// talks to an iframe within the same process already knows what URL that iframe is
// pointing to, so the only comunication that needs to happen via postMessage() is the
// actual protocol message strings, and no extra wrapping is necessary.
this._ws.onopen = function (event) {
// Send the initial "connect" message to tell the other end what URL we're from.
self._ws.send(JSON.stringify({
type: "connect",
url: global.location.href
}));
console.log("[Brackets LiveDev] Connected to Brackets at " + url);
if (self._callbacks && self._callbacks.connect) {
self._callbacks.connect();
}
};
this._ws.onmessage = function (event) {
console.log("[Brackets LiveDev] Got message: " + event.data);
if (self._callbacks && self._callbacks.message) {
self._callbacks.message(event.data);
}
};
this._ws.onclose = function (event) {
self._ws = null;
if (self._callbacks && self._callbacks.close) {
self._callbacks.close();
}
};
// TODO: onerror
} | javascript | function (url) {
var self = this;
this._ws = new WebSocket(url);
// One potential source of confusion: the transport sends two "types" of messages -
// these are distinct from the protocol's own messages. This is because this transport
// needs to send an initial "connect" message telling the Brackets side of the transport
// the URL of the page that it's connecting from, distinct from the actual protocol
// message traffic. Actual protocol messages are sent as a JSON payload in a message of
// type "message".
//
// Other transports might not need to do this - for example, a transport that simply
// talks to an iframe within the same process already knows what URL that iframe is
// pointing to, so the only comunication that needs to happen via postMessage() is the
// actual protocol message strings, and no extra wrapping is necessary.
this._ws.onopen = function (event) {
// Send the initial "connect" message to tell the other end what URL we're from.
self._ws.send(JSON.stringify({
type: "connect",
url: global.location.href
}));
console.log("[Brackets LiveDev] Connected to Brackets at " + url);
if (self._callbacks && self._callbacks.connect) {
self._callbacks.connect();
}
};
this._ws.onmessage = function (event) {
console.log("[Brackets LiveDev] Got message: " + event.data);
if (self._callbacks && self._callbacks.message) {
self._callbacks.message(event.data);
}
};
this._ws.onclose = function (event) {
self._ws = null;
if (self._callbacks && self._callbacks.close) {
self._callbacks.close();
}
};
// TODO: onerror
} | [
"function",
"(",
"url",
")",
"{",
"var",
"self",
"=",
"this",
";",
"this",
".",
"_ws",
"=",
"new",
"WebSocket",
"(",
"url",
")",
";",
"// One potential source of confusion: the transport sends two \"types\" of messages -",
"// these are distinct from the protocol's own mess... | Connects to the NodeSocketTransport in Brackets at the given WebSocket URL.
@param {string} url | [
"Connects",
"to",
"the",
"NodeSocketTransport",
"in",
"Brackets",
"at",
"the",
"given",
"WebSocket",
"URL",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/LiveDevelopment/MultiBrowserImpl/transports/remote/NodeSocketTransportRemote.js#L68-L108 | train | This is the main function of the protocol connection | [
30522,
3853,
1006,
24471,
2140,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2023,
1012,
1035,
1059,
2015,
1027,
2047,
4773,
6499,
19869,
2102,
1006,
24471,
2140,
1007,
1025,
1013,
1013,
2028,
4022,
3120,
1997,
6724,
1024,
1996,
3665,
10255,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
dimsemenov/PhotoSwipe | src/js/gestures.js | function() {
if(!_currentPoints) {
return;
}
var numPoints = _currentPoints.length;
if(numPoints === 0) {
return;
}
_equalizePoints(p, _currentPoints[0]);
delta.x = p.x - _currPoint.x;
delta.y = p.y - _currPoint.y;
if(_isZooming && numPoints > 1) {
// Handle behaviour for more than 1 point
_currPoint.x = p.x;
_currPoint.y = p.y;
// check if one of two points changed
if( !delta.x && !delta.y && _isEqualPoints(_currentPoints[1], p2) ) {
return;
}
_equalizePoints(p2, _currentPoints[1]);
if(!_zoomStarted) {
_zoomStarted = true;
_shout('zoomGestureStarted');
}
// Distance between two points
var pointsDistance = _calculatePointsDistance(p,p2);
var zoomLevel = _calculateZoomLevel(pointsDistance);
// slightly over the of initial zoom level
if(zoomLevel > self.currItem.initialZoomLevel + self.currItem.initialZoomLevel / 15) {
_wasOverInitialZoom = true;
}
// Apply the friction if zoom level is out of the bounds
var zoomFriction = 1,
minZoomLevel = _getMinZoomLevel(),
maxZoomLevel = _getMaxZoomLevel();
if ( zoomLevel < minZoomLevel ) {
if(_options.pinchToClose && !_wasOverInitialZoom && _startZoomLevel <= self.currItem.initialZoomLevel) {
// fade out background if zooming out
var minusDiff = minZoomLevel - zoomLevel;
var percent = 1 - minusDiff / (minZoomLevel / 1.2);
_applyBgOpacity(percent);
_shout('onPinchClose', percent);
_opacityChanged = true;
} else {
zoomFriction = (minZoomLevel - zoomLevel) / minZoomLevel;
if(zoomFriction > 1) {
zoomFriction = 1;
}
zoomLevel = minZoomLevel - zoomFriction * (minZoomLevel / 3);
}
} else if ( zoomLevel > maxZoomLevel ) {
// 1.5 - extra zoom level above the max. E.g. if max is x6, real max 6 + 1.5 = 7.5
zoomFriction = (zoomLevel - maxZoomLevel) / ( minZoomLevel * 6 );
if(zoomFriction > 1) {
zoomFriction = 1;
}
zoomLevel = maxZoomLevel + zoomFriction * minZoomLevel;
}
if(zoomFriction < 0) {
zoomFriction = 0;
}
// distance between touch points after friction is applied
_currPointsDistance = pointsDistance;
// _centerPoint - The point in the middle of two pointers
_findCenterOfPoints(p, p2, _centerPoint);
// paning with two pointers pressed
_currPanDist.x += _centerPoint.x - _currCenterPoint.x;
_currPanDist.y += _centerPoint.y - _currCenterPoint.y;
_equalizePoints(_currCenterPoint, _centerPoint);
_panOffset.x = _calculatePanOffset('x', zoomLevel);
_panOffset.y = _calculatePanOffset('y', zoomLevel);
_isZoomingIn = zoomLevel > _currZoomLevel;
_currZoomLevel = zoomLevel;
_applyCurrentZoomPan();
} else {
// handle behaviour for one point (dragging or panning)
if(!_direction) {
return;
}
if(_isFirstMove) {
_isFirstMove = false;
// subtract drag distance that was used during the detection direction
if( Math.abs(delta.x) >= DIRECTION_CHECK_OFFSET) {
delta.x -= _currentPoints[0].x - _startPoint.x;
}
if( Math.abs(delta.y) >= DIRECTION_CHECK_OFFSET) {
delta.y -= _currentPoints[0].y - _startPoint.y;
}
}
_currPoint.x = p.x;
_currPoint.y = p.y;
// do nothing if pointers position hasn't changed
if(delta.x === 0 && delta.y === 0) {
return;
}
if(_direction === 'v' && _options.closeOnVerticalDrag) {
if(!_canPan()) {
_currPanDist.y += delta.y;
_panOffset.y += delta.y;
var opacityRatio = _calculateVerticalDragOpacityRatio();
_verticalDragInitiated = true;
_shout('onVerticalDrag', opacityRatio);
_applyBgOpacity(opacityRatio);
_applyCurrentZoomPan();
return ;
}
}
_pushPosPoint(_getCurrentTime(), p.x, p.y);
_moved = true;
_currPanBounds = self.currItem.bounds;
var mainScrollChanged = _panOrMoveMainScroll('x', delta);
if(!mainScrollChanged) {
_panOrMoveMainScroll('y', delta);
_roundPoint(_panOffset);
_applyCurrentZoomPan();
}
}
} | javascript | function() {
if(!_currentPoints) {
return;
}
var numPoints = _currentPoints.length;
if(numPoints === 0) {
return;
}
_equalizePoints(p, _currentPoints[0]);
delta.x = p.x - _currPoint.x;
delta.y = p.y - _currPoint.y;
if(_isZooming && numPoints > 1) {
// Handle behaviour for more than 1 point
_currPoint.x = p.x;
_currPoint.y = p.y;
// check if one of two points changed
if( !delta.x && !delta.y && _isEqualPoints(_currentPoints[1], p2) ) {
return;
}
_equalizePoints(p2, _currentPoints[1]);
if(!_zoomStarted) {
_zoomStarted = true;
_shout('zoomGestureStarted');
}
// Distance between two points
var pointsDistance = _calculatePointsDistance(p,p2);
var zoomLevel = _calculateZoomLevel(pointsDistance);
// slightly over the of initial zoom level
if(zoomLevel > self.currItem.initialZoomLevel + self.currItem.initialZoomLevel / 15) {
_wasOverInitialZoom = true;
}
// Apply the friction if zoom level is out of the bounds
var zoomFriction = 1,
minZoomLevel = _getMinZoomLevel(),
maxZoomLevel = _getMaxZoomLevel();
if ( zoomLevel < minZoomLevel ) {
if(_options.pinchToClose && !_wasOverInitialZoom && _startZoomLevel <= self.currItem.initialZoomLevel) {
// fade out background if zooming out
var minusDiff = minZoomLevel - zoomLevel;
var percent = 1 - minusDiff / (minZoomLevel / 1.2);
_applyBgOpacity(percent);
_shout('onPinchClose', percent);
_opacityChanged = true;
} else {
zoomFriction = (minZoomLevel - zoomLevel) / minZoomLevel;
if(zoomFriction > 1) {
zoomFriction = 1;
}
zoomLevel = minZoomLevel - zoomFriction * (minZoomLevel / 3);
}
} else if ( zoomLevel > maxZoomLevel ) {
// 1.5 - extra zoom level above the max. E.g. if max is x6, real max 6 + 1.5 = 7.5
zoomFriction = (zoomLevel - maxZoomLevel) / ( minZoomLevel * 6 );
if(zoomFriction > 1) {
zoomFriction = 1;
}
zoomLevel = maxZoomLevel + zoomFriction * minZoomLevel;
}
if(zoomFriction < 0) {
zoomFriction = 0;
}
// distance between touch points after friction is applied
_currPointsDistance = pointsDistance;
// _centerPoint - The point in the middle of two pointers
_findCenterOfPoints(p, p2, _centerPoint);
// paning with two pointers pressed
_currPanDist.x += _centerPoint.x - _currCenterPoint.x;
_currPanDist.y += _centerPoint.y - _currCenterPoint.y;
_equalizePoints(_currCenterPoint, _centerPoint);
_panOffset.x = _calculatePanOffset('x', zoomLevel);
_panOffset.y = _calculatePanOffset('y', zoomLevel);
_isZoomingIn = zoomLevel > _currZoomLevel;
_currZoomLevel = zoomLevel;
_applyCurrentZoomPan();
} else {
// handle behaviour for one point (dragging or panning)
if(!_direction) {
return;
}
if(_isFirstMove) {
_isFirstMove = false;
// subtract drag distance that was used during the detection direction
if( Math.abs(delta.x) >= DIRECTION_CHECK_OFFSET) {
delta.x -= _currentPoints[0].x - _startPoint.x;
}
if( Math.abs(delta.y) >= DIRECTION_CHECK_OFFSET) {
delta.y -= _currentPoints[0].y - _startPoint.y;
}
}
_currPoint.x = p.x;
_currPoint.y = p.y;
// do nothing if pointers position hasn't changed
if(delta.x === 0 && delta.y === 0) {
return;
}
if(_direction === 'v' && _options.closeOnVerticalDrag) {
if(!_canPan()) {
_currPanDist.y += delta.y;
_panOffset.y += delta.y;
var opacityRatio = _calculateVerticalDragOpacityRatio();
_verticalDragInitiated = true;
_shout('onVerticalDrag', opacityRatio);
_applyBgOpacity(opacityRatio);
_applyCurrentZoomPan();
return ;
}
}
_pushPosPoint(_getCurrentTime(), p.x, p.y);
_moved = true;
_currPanBounds = self.currItem.bounds;
var mainScrollChanged = _panOrMoveMainScroll('x', delta);
if(!mainScrollChanged) {
_panOrMoveMainScroll('y', delta);
_roundPoint(_panOffset);
_applyCurrentZoomPan();
}
}
} | [
"function",
"(",
")",
"{",
"if",
"(",
"!",
"_currentPoints",
")",
"{",
"return",
";",
"}",
"var",
"numPoints",
"=",
"_currentPoints",
".",
"length",
";",
"if",
"(",
"numPoints",
"===",
"0",
")",
"{",
"return",
";",
"}",
"_equalizePoints",
"(",
"p",
"... | amount of pixels to drag to determine direction of swipe | [
"amount",
"of",
"pixels",
"to",
"drag",
"to",
"determine",
"direction",
"of",
"swipe"
] | 80607e12542a1a54ecefa837649e862b35dffd25 | https://github.com/dimsemenov/PhotoSwipe/blob/80607e12542a1a54ecefa837649e862b35dffd25/src/js/gestures.js#L445-L606 | train | zoom the scene | [
30522,
3853,
1006,
1007,
1063,
2065,
1006,
999,
1035,
2783,
26521,
1007,
1063,
2709,
1025,
1065,
13075,
16371,
8737,
25785,
2015,
1027,
1035,
2783,
26521,
1012,
3091,
1025,
2065,
1006,
16371,
8737,
25785,
2015,
1027,
1027,
1027,
1014,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
google/draco | javascript/example/DRACOLoader.js | function(attributeName, skip) {
var skipDequantization = true;
if (typeof skip !== 'undefined')
skipDequantization = skip;
this.getAttributeOptions(attributeName).skipDequantization =
skipDequantization;
} | javascript | function(attributeName, skip) {
var skipDequantization = true;
if (typeof skip !== 'undefined')
skipDequantization = skip;
this.getAttributeOptions(attributeName).skipDequantization =
skipDequantization;
} | [
"function",
"(",
"attributeName",
",",
"skip",
")",
"{",
"var",
"skipDequantization",
"=",
"true",
";",
"if",
"(",
"typeof",
"skip",
"!==",
"'undefined'",
")",
"skipDequantization",
"=",
"skip",
";",
"this",
".",
"getAttributeOptions",
"(",
"attributeName",
")... | Skips dequantization for a specific attribute.
|attributeName| is the THREE.js name of the given attribute type.
The only currently supported |attributeName| is 'position', more may be
added in future. | [
"Skips",
"dequantization",
"for",
"a",
"specific",
"attribute",
".",
"|attributeName|",
"is",
"the",
"THREE",
".",
"js",
"name",
"of",
"the",
"given",
"attribute",
"type",
".",
"The",
"only",
"currently",
"supported",
"|attributeName|",
"is",
"position",
"more",... | 785c9c4aa2b952236c29ad639901dbbaf216da38 | https://github.com/google/draco/blob/785c9c4aa2b952236c29ad639901dbbaf216da38/javascript/example/DRACOLoader.js#L81-L87 | train | Set the skipDequantization option for the given attribute | [
30522,
3853,
1006,
17961,
18442,
1010,
13558,
1007,
1063,
13075,
13558,
3207,
16211,
16778,
9276,
1027,
2995,
1025,
2065,
1006,
2828,
11253,
13558,
999,
1027,
1027,
1005,
6151,
28344,
1005,
1007,
13558,
3207,
16211,
16778,
9276,
1027,
13558,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
netlify/netlify-cms | packages/netlify-cms-widget-markdown/src/serializers/index.js | markdownToRemarkRemoveTokenizers | function markdownToRemarkRemoveTokenizers({ inlineTokenizers }) {
inlineTokenizers &&
inlineTokenizers.forEach(tokenizer => {
delete this.Parser.prototype.inlineTokenizers[tokenizer];
});
} | javascript | function markdownToRemarkRemoveTokenizers({ inlineTokenizers }) {
inlineTokenizers &&
inlineTokenizers.forEach(tokenizer => {
delete this.Parser.prototype.inlineTokenizers[tokenizer];
});
} | [
"function",
"markdownToRemarkRemoveTokenizers",
"(",
"{",
"inlineTokenizers",
"}",
")",
"{",
"inlineTokenizers",
"&&",
"inlineTokenizers",
".",
"forEach",
"(",
"tokenizer",
"=>",
"{",
"delete",
"this",
".",
"Parser",
".",
"prototype",
".",
"inlineTokenizers",
"[",
... | Remove named tokenizers from the parser, effectively deactivating them. | [
"Remove",
"named",
"tokenizers",
"from",
"the",
"parser",
"effectively",
"deactivating",
"them",
"."
] | 2488556590cbfdcefa626f2f2de01e7a160cf6ee | https://github.com/netlify/netlify-cms/blob/2488556590cbfdcefa626f2f2de01e7a160cf6ee/packages/netlify-cms-widget-markdown/src/serializers/index.js#L85-L90 | train | Remove inline tokenizers from parser prototype | [
30522,
3853,
2928,
7698,
19277,
10665,
28578,
21818,
18715,
18595,
16750,
1006,
1063,
23881,
18715,
18595,
16750,
1065,
1007,
1063,
23881,
18715,
18595,
16750,
1004,
1004,
23881,
18715,
18595,
16750,
1012,
18921,
6776,
1006,
19204,
17629,
1027,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aframevr/aframe | src/components/animation.js | function () {
var config = this.config;
var data = this.data;
var el = this.el;
var key;
var from;
var to;
// Parse coordinates.
from = data.from !== ''
? utils.coordinates.parse(data.from) // If data.from defined, use that.
: getComponentProperty(el, data.property); // If data.from not defined, get on the fly.
to = utils.coordinates.parse(data.to);
if (data.property === PROP_ROTATION) {
toRadians(from);
toRadians(to);
}
// Set to and from.
this.targetsArray.length = 0;
this.targetsArray.push(from);
config.targets = this.targetsArray;
for (key in to) { config[key] = to[key]; }
// If animating object3D transformation, run more optimized updater.
if (data.property === PROP_POSITION || data.property === PROP_ROTATION ||
data.property === PROP_SCALE) {
config.update = (function () {
var lastValue = {};
return function (anim) {
var value = anim.animatables[0].target;
if (data.property === PROP_SCALE) {
value.x = Math.max(0.0001, value.x);
value.y = Math.max(0.0001, value.y);
value.z = Math.max(0.0001, value.z);
}
// For animation timeline.
if (value.x === lastValue.x &&
value.y === lastValue.y &&
value.z === lastValue.z) { return; }
lastValue.x = value.x;
lastValue.y = value.y;
lastValue.z = value.z;
el.object3D[data.property].set(value.x, value.y, value.z);
};
})();
return;
}
// Animating some vector.
config.update = (function () {
var lastValue = {};
return function (anim) {
var value = anim.animatables[0].target;
// Animate rotation through radians.
// For animation timeline.
if (value.x === lastValue.x &&
value.y === lastValue.y &&
value.z === lastValue.z) { return; }
lastValue.x = value.x;
lastValue.y = value.y;
lastValue.z = value.z;
setComponentProperty(el, data.property, value);
};
})();
} | javascript | function () {
var config = this.config;
var data = this.data;
var el = this.el;
var key;
var from;
var to;
// Parse coordinates.
from = data.from !== ''
? utils.coordinates.parse(data.from) // If data.from defined, use that.
: getComponentProperty(el, data.property); // If data.from not defined, get on the fly.
to = utils.coordinates.parse(data.to);
if (data.property === PROP_ROTATION) {
toRadians(from);
toRadians(to);
}
// Set to and from.
this.targetsArray.length = 0;
this.targetsArray.push(from);
config.targets = this.targetsArray;
for (key in to) { config[key] = to[key]; }
// If animating object3D transformation, run more optimized updater.
if (data.property === PROP_POSITION || data.property === PROP_ROTATION ||
data.property === PROP_SCALE) {
config.update = (function () {
var lastValue = {};
return function (anim) {
var value = anim.animatables[0].target;
if (data.property === PROP_SCALE) {
value.x = Math.max(0.0001, value.x);
value.y = Math.max(0.0001, value.y);
value.z = Math.max(0.0001, value.z);
}
// For animation timeline.
if (value.x === lastValue.x &&
value.y === lastValue.y &&
value.z === lastValue.z) { return; }
lastValue.x = value.x;
lastValue.y = value.y;
lastValue.z = value.z;
el.object3D[data.property].set(value.x, value.y, value.z);
};
})();
return;
}
// Animating some vector.
config.update = (function () {
var lastValue = {};
return function (anim) {
var value = anim.animatables[0].target;
// Animate rotation through radians.
// For animation timeline.
if (value.x === lastValue.x &&
value.y === lastValue.y &&
value.z === lastValue.z) { return; }
lastValue.x = value.x;
lastValue.y = value.y;
lastValue.z = value.z;
setComponentProperty(el, data.property, value);
};
})();
} | [
"function",
"(",
")",
"{",
"var",
"config",
"=",
"this",
".",
"config",
";",
"var",
"data",
"=",
"this",
".",
"data",
";",
"var",
"el",
"=",
"this",
".",
"el",
";",
"var",
"key",
";",
"var",
"from",
";",
"var",
"to",
";",
"// Parse coordinates.",
... | Extend x/y/z/w onto the config.
Update vector by modifying object3D. | [
"Extend",
"x",
"/",
"y",
"/",
"z",
"/",
"w",
"onto",
"the",
"config",
".",
"Update",
"vector",
"by",
"modifying",
"object3D",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/components/animation.js#L346-L417 | train | Set the coordinates of the node | [
30522,
3853,
1006,
1007,
1063,
13075,
9530,
8873,
2290,
1027,
2023,
1012,
9530,
8873,
2290,
1025,
13075,
2951,
1027,
2023,
1012,
2951,
1025,
13075,
3449,
1027,
2023,
1012,
3449,
1025,
13075,
3145,
1025,
13075,
2013,
1025,
13075,
2000,
1025,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js | function (oProperty) {
var aMatches,
sName,
sQualifier,
mValueLists = {};
for (sName in oProperty) {
aMatches = rValueList.exec(sName);
if (aMatches){
sQualifier = (aMatches[1] || "").slice(1); // remove leading #
mValueLists[sQualifier] = oProperty[sName];
}
}
return mValueLists;
} | javascript | function (oProperty) {
var aMatches,
sName,
sQualifier,
mValueLists = {};
for (sName in oProperty) {
aMatches = rValueList.exec(sName);
if (aMatches){
sQualifier = (aMatches[1] || "").slice(1); // remove leading #
mValueLists[sQualifier] = oProperty[sName];
}
}
return mValueLists;
} | [
"function",
"(",
"oProperty",
")",
"{",
"var",
"aMatches",
",",
"sName",
",",
"sQualifier",
",",
"mValueLists",
"=",
"{",
"}",
";",
"for",
"(",
"sName",
"in",
"oProperty",
")",
"{",
"aMatches",
"=",
"rValueList",
".",
"exec",
"(",
"sName",
")",
";",
... | Returns the map representing the <code>com.sap.vocabularies.Common.v1.ValueList</code>
annotations of the given property.
@param {object} oProperty the property
@returns {object} map of ValueList annotations contained in oProperty | [
"Returns",
"the",
"map",
"representing",
"the",
"<code",
">",
"com",
".",
"sap",
".",
"vocabularies",
".",
"Common",
".",
"v1",
".",
"ValueList<",
"/",
"code",
">",
"annotations",
"of",
"the",
"given",
"property",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/_ODataMetaModelUtils.js#L786-L801 | train | Returns an object with the value lists of the given property | [
30522,
3853,
1006,
6728,
18981,
15010,
1007,
1063,
13075,
25933,
10649,
2229,
1010,
1055,
18442,
1010,
5490,
8787,
18095,
1010,
19842,
2389,
16284,
5130,
1027,
1063,
1065,
1025,
2005,
1006,
1055,
18442,
1999,
6728,
18981,
15010,
1007,
1063,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
angular/material | src/components/autocomplete/js/autocompleteController.js | disableElementScrollEvents | function disableElementScrollEvents(element) {
function preventDefault(e) {
e.preventDefault();
}
element.on('wheel', preventDefault);
element.on('touchmove', preventDefault);
return function() {
element.off('wheel', preventDefault);
element.off('touchmove', preventDefault);
};
} | javascript | function disableElementScrollEvents(element) {
function preventDefault(e) {
e.preventDefault();
}
element.on('wheel', preventDefault);
element.on('touchmove', preventDefault);
return function() {
element.off('wheel', preventDefault);
element.off('touchmove', preventDefault);
};
} | [
"function",
"disableElementScrollEvents",
"(",
"element",
")",
"{",
"function",
"preventDefault",
"(",
"e",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
"element",
".",
"on",
"(",
"'wheel'",
",",
"preventDefault",
")",
";",
"element",
".",
"on... | Disables scrolling for a specific element | [
"Disables",
"scrolling",
"for",
"a",
"specific",
"element"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/autocomplete/js/autocompleteController.js#L373-L386 | train | Disable element scroll events | [
30522,
3853,
4487,
19150,
12260,
8163,
26775,
14511,
18697,
7666,
1006,
5783,
1007,
1063,
3853,
4652,
3207,
7011,
11314,
1006,
1041,
1007,
1063,
1041,
1012,
4652,
3207,
7011,
11314,
1006,
1007,
1025,
1065,
5783,
1012,
2006,
1006,
1005,
5217... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js | function (oEvent) {
var bShowRuleProperties = true,
oSelectedRule = this.model.getProperty("/selectedRule"),
bAdditionalRulesetsTab = oEvent.getParameter("selectedKey") === "additionalRulesets";
if (bAdditionalRulesetsTab || !oSelectedRule) {
bShowRuleProperties = false;
}
// Ensure we don't make unnecessary requests. The requests will be made only
// the first time the user clicks AdditionalRulesets tab.
if (!this.bAdditionalRulesetsLoaded && bAdditionalRulesetsTab) {
this.rulesViewContainer.setBusyIndicatorDelay(0);
this.rulesViewContainer.setBusy(true);
CommunicationBus.publish(channelNames.GET_NON_LOADED_RULE_SETS, {
loadedRulesets: this._getLoadedRulesets()
});
}
this.getView().getModel().setProperty("/showRuleProperties", bShowRuleProperties);
} | javascript | function (oEvent) {
var bShowRuleProperties = true,
oSelectedRule = this.model.getProperty("/selectedRule"),
bAdditionalRulesetsTab = oEvent.getParameter("selectedKey") === "additionalRulesets";
if (bAdditionalRulesetsTab || !oSelectedRule) {
bShowRuleProperties = false;
}
// Ensure we don't make unnecessary requests. The requests will be made only
// the first time the user clicks AdditionalRulesets tab.
if (!this.bAdditionalRulesetsLoaded && bAdditionalRulesetsTab) {
this.rulesViewContainer.setBusyIndicatorDelay(0);
this.rulesViewContainer.setBusy(true);
CommunicationBus.publish(channelNames.GET_NON_LOADED_RULE_SETS, {
loadedRulesets: this._getLoadedRulesets()
});
}
this.getView().getModel().setProperty("/showRuleProperties", bShowRuleProperties);
} | [
"function",
"(",
"oEvent",
")",
"{",
"var",
"bShowRuleProperties",
"=",
"true",
",",
"oSelectedRule",
"=",
"this",
".",
"model",
".",
"getProperty",
"(",
"\"/selectedRule\"",
")",
",",
"bAdditionalRulesetsTab",
"=",
"oEvent",
".",
"getParameter",
"(",
"\"selecte... | On selecting "Additional RuleSet" tab, start loading Additional RuleSets by brute search.
@param {Event} oEvent TreeTable event | [
"On",
"selecting",
"Additional",
"RuleSet",
"tab",
"start",
"loading",
"Additional",
"RuleSets",
"by",
"brute",
"search",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/controllers/Analysis.controller.js#L405-L425 | train | Handles the user clicks the ruleset tab | [
30522,
3853,
1006,
1051,
18697,
3372,
1007,
1063,
13075,
18667,
14406,
6820,
2571,
21572,
4842,
7368,
1027,
2995,
1010,
9808,
12260,
10985,
6820,
2571,
1027,
2023,
1012,
2944,
1012,
2131,
21572,
4842,
3723,
1006,
1000,
1013,
3479,
6820,
257... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
openlayers/openlayers | src/ol/control/FullScreen.js | exitFullScreen | function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
} | javascript | function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
} | [
"function",
"exitFullScreen",
"(",
")",
"{",
"if",
"(",
"document",
".",
"exitFullscreen",
")",
"{",
"document",
".",
"exitFullscreen",
"(",
")",
";",
"}",
"else",
"if",
"(",
"document",
".",
"msExitFullscreen",
")",
"{",
"document",
".",
"msExitFullscreen",... | Exit fullscreen. | [
"Exit",
"fullscreen",
"."
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/control/FullScreen.js#L255-L263 | train | Exit fullscreen mode | [
30522,
3853,
6164,
3993,
4877,
24410,
1006,
1007,
1063,
2065,
1006,
6254,
1012,
6164,
3993,
4877,
24410,
1007,
1063,
6254,
1012,
6164,
3993,
4877,
24410,
1006,
1007,
1025,
1065,
2842,
2065,
1006,
6254,
1012,
5796,
10288,
4183,
3993,
4877,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js | HTMLEscape | function HTMLEscape(original) {
return original.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
} | javascript | function HTMLEscape(original) {
return original.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
} | [
"function",
"HTMLEscape",
"(",
"original",
")",
"{",
"return",
"original",
".",
"replace",
"(",
"/",
"&",
"/",
"g",
",",
"'&'",
")",
".",
"replace",
"(",
"/",
"<",
"/",
"g",
",",
"'<'",
")",
".",
"replace",
"(",
"/",
">",
"/",
"g",
",",
... | Replaces '&', '<', '>', '"', and ''' characters with their HTML encoding.
@param {string} original The original string.
@return {string} The string with all the characters mentioned above replaced. | [
"Replaces",
"&",
"<",
">",
"and",
"characters",
"with",
"their",
"HTML",
"encoding",
"."
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/netlog_viewer/netlog_viewer/ui_webui_resources_js_util.js#L344-L350 | train | HTMLEscape the given string. | [
30522,
3853,
16129,
2229,
19464,
1006,
2434,
1007,
1063,
2709,
2434,
1012,
5672,
1006,
1013,
1004,
1013,
1043,
1010,
1005,
1004,
23713,
1025,
1005,
1007,
1012,
5672,
1006,
1013,
1026,
1013,
1043,
1010,
1005,
1004,
8318,
1025,
1005,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
pagekit/vue-resource | dist/vue-resource.esm.js | Request | function Request(options$$1) {
this.body = null;
this.params = {};
assign(this, options$$1, {
method: toUpper(options$$1.method || 'GET')
});
if (!(this.headers instanceof Headers)) {
this.headers = new Headers(this.headers);
}
} | javascript | function Request(options$$1) {
this.body = null;
this.params = {};
assign(this, options$$1, {
method: toUpper(options$$1.method || 'GET')
});
if (!(this.headers instanceof Headers)) {
this.headers = new Headers(this.headers);
}
} | [
"function",
"Request",
"(",
"options$$1",
")",
"{",
"this",
".",
"body",
"=",
"null",
";",
"this",
".",
"params",
"=",
"{",
"}",
";",
"assign",
"(",
"this",
",",
"options$$1",
",",
"{",
"method",
":",
"toUpper",
"(",
"options$$1",
".",
"method",
"||"... | HTTP Request. | [
"HTTP",
"Request",
"."
] | fe268fa1d6053ede5f34aef9a11e1a424a70446c | https://github.com/pagekit/vue-resource/blob/fe268fa1d6053ede5f34aef9a11e1a424a70446c/dist/vue-resource.esm.js#L1334-L1346 | train | Construct a new Request | [
30522,
3853,
5227,
1006,
7047,
1002,
1002,
1015,
1007,
1063,
2023,
1012,
2303,
1027,
19701,
1025,
2023,
1012,
11498,
5244,
1027,
1063,
1065,
1025,
23911,
1006,
2023,
1010,
7047,
1002,
1002,
1015,
1010,
1063,
4118,
1024,
2000,
29547,
2099,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
vuejs/vue-devtools | shells/chrome/src/devtools-background.js | onContextMenu | function onContextMenu ({ id }) {
if (id === 'vue-inspect-instance') {
const src = `window.__VUE_DEVTOOLS_CONTEXT_MENU_HAS_TARGET__`
chrome.devtools.inspectedWindow.eval(src, function (res, err) {
if (err) {
console.log(err)
}
if (typeof res !== 'undefined' && res) {
panelAction(() => {
chrome.runtime.sendMessage('vue-get-context-menu-target')
}, 'Open Vue devtools to see component details')
} else {
pendingAction = null
toast('No Vue component was found', 'warn')
}
})
}
} | javascript | function onContextMenu ({ id }) {
if (id === 'vue-inspect-instance') {
const src = `window.__VUE_DEVTOOLS_CONTEXT_MENU_HAS_TARGET__`
chrome.devtools.inspectedWindow.eval(src, function (res, err) {
if (err) {
console.log(err)
}
if (typeof res !== 'undefined' && res) {
panelAction(() => {
chrome.runtime.sendMessage('vue-get-context-menu-target')
}, 'Open Vue devtools to see component details')
} else {
pendingAction = null
toast('No Vue component was found', 'warn')
}
})
}
} | [
"function",
"onContextMenu",
"(",
"{",
"id",
"}",
")",
"{",
"if",
"(",
"id",
"===",
"'vue-inspect-instance'",
")",
"{",
"const",
"src",
"=",
"`",
"`",
"chrome",
".",
"devtools",
".",
"inspectedWindow",
".",
"eval",
"(",
"src",
",",
"function",
"(",
"re... | Page context menu entry | [
"Page",
"context",
"menu",
"entry"
] | 4de4b86388453cd07f0c1bf967d43a4dd4b011c9 | https://github.com/vuejs/vue-devtools/blob/4de4b86388453cd07f0c1bf967d43a4dd4b011c9/shells/chrome/src/devtools-background.js#L56-L74 | train | Handle context menu | [
30522,
3853,
2006,
8663,
18209,
3549,
2226,
1006,
1063,
8909,
1065,
1007,
1063,
2065,
1006,
8909,
1027,
1027,
1027,
1005,
24728,
2063,
1011,
22459,
1011,
6013,
1005,
1007,
1063,
9530,
3367,
5034,
2278,
1027,
1036,
3332,
1012,
1035,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/JavaScriptQuickEdit/main.js | _createInlineEditor | function _createInlineEditor(hostEditor, functionName) {
// Use Tern jump-to-definition helper, if it's available, to find InlineEditor target.
var helper = brackets._jsCodeHintsHelper;
if (helper === null) {
return null;
}
var result = new $.Deferred();
PerfUtils.markStart(PerfUtils.JAVASCRIPT_INLINE_CREATE);
var response = helper();
if (response.hasOwnProperty("promise")) {
response.promise.done(function (jumpResp) {
var resolvedPath = jumpResp.fullPath;
if (resolvedPath) {
// Tern doesn't always return entire function extent.
// Use QuickEdit search now that we know which file to look at.
var fileInfos = [];
fileInfos.push({name: jumpResp.resultFile, fullPath: resolvedPath});
JSUtils.findMatchingFunctions(functionName, fileInfos, true)
.done(function (functions) {
if (functions && functions.length > 0) {
var jsInlineEditor = new MultiRangeInlineEditor(functions);
jsInlineEditor.load(hostEditor);
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.resolve(jsInlineEditor);
} else {
// No matching functions were found
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
}
})
.fail(function () {
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
});
} else { // no result from Tern. Fall back to _findInProject().
_findInProject(functionName).done(function (functions) {
if (functions && functions.length > 0) {
var jsInlineEditor = new MultiRangeInlineEditor(functions);
jsInlineEditor.load(hostEditor);
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.resolve(jsInlineEditor);
} else {
// No matching functions were found
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
}
}).fail(function () {
PerfUtils.finalizeMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
});
}
}).fail(function () {
PerfUtils.finalizeMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
});
}
return result.promise();
} | javascript | function _createInlineEditor(hostEditor, functionName) {
// Use Tern jump-to-definition helper, if it's available, to find InlineEditor target.
var helper = brackets._jsCodeHintsHelper;
if (helper === null) {
return null;
}
var result = new $.Deferred();
PerfUtils.markStart(PerfUtils.JAVASCRIPT_INLINE_CREATE);
var response = helper();
if (response.hasOwnProperty("promise")) {
response.promise.done(function (jumpResp) {
var resolvedPath = jumpResp.fullPath;
if (resolvedPath) {
// Tern doesn't always return entire function extent.
// Use QuickEdit search now that we know which file to look at.
var fileInfos = [];
fileInfos.push({name: jumpResp.resultFile, fullPath: resolvedPath});
JSUtils.findMatchingFunctions(functionName, fileInfos, true)
.done(function (functions) {
if (functions && functions.length > 0) {
var jsInlineEditor = new MultiRangeInlineEditor(functions);
jsInlineEditor.load(hostEditor);
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.resolve(jsInlineEditor);
} else {
// No matching functions were found
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
}
})
.fail(function () {
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
});
} else { // no result from Tern. Fall back to _findInProject().
_findInProject(functionName).done(function (functions) {
if (functions && functions.length > 0) {
var jsInlineEditor = new MultiRangeInlineEditor(functions);
jsInlineEditor.load(hostEditor);
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.resolve(jsInlineEditor);
} else {
// No matching functions were found
PerfUtils.addMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
}
}).fail(function () {
PerfUtils.finalizeMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
});
}
}).fail(function () {
PerfUtils.finalizeMeasurement(PerfUtils.JAVASCRIPT_INLINE_CREATE);
result.reject();
});
}
return result.promise();
} | [
"function",
"_createInlineEditor",
"(",
"hostEditor",
",",
"functionName",
")",
"{",
"// Use Tern jump-to-definition helper, if it's available, to find InlineEditor target.",
"var",
"helper",
"=",
"brackets",
".",
"_jsCodeHintsHelper",
";",
"if",
"(",
"helper",
"===",
"null",... | @private
For unit and performance tests. Allows lookup by function name instead of editor offset .
@param {!Editor} hostEditor
@param {!string} functionName
@return {?$.Promise} synchronously resolved with an InlineWidget, or
{string} if js other than function is detected at pos, or
null if we're not ready to provide anything. | [
"@private",
"For",
"unit",
"and",
"performance",
"tests",
".",
"Allows",
"lookup",
"by",
"function",
"name",
"instead",
"of",
"editor",
"offset",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptQuickEdit/main.js#L115-L182 | train | Creates an InlineEditor instance for the given function name. | [
30522,
3853,
1035,
3443,
2378,
4179,
2098,
15660,
1006,
4354,
15660,
1010,
3853,
18442,
1007,
1063,
1013,
1013,
2224,
28774,
2078,
5376,
1011,
2000,
1011,
6210,
2393,
2121,
1010,
2065,
2009,
1005,
1055,
2800,
1010,
2000,
2424,
23881,
2098,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
wangfupeng1988/wangEditor | src/js/editor/upload/upload-img.js | function (alertInfo, debugInfo) {
const editor = this.editor
const debug = editor.config.debug
const customAlert = editor.config.customAlert
if (debug) {
throw new Error('wangEditor: ' + (debugInfo || alertInfo))
} else {
if (customAlert && typeof customAlert === 'function') {
customAlert(alertInfo)
} else {
alert(alertInfo)
}
}
} | javascript | function (alertInfo, debugInfo) {
const editor = this.editor
const debug = editor.config.debug
const customAlert = editor.config.customAlert
if (debug) {
throw new Error('wangEditor: ' + (debugInfo || alertInfo))
} else {
if (customAlert && typeof customAlert === 'function') {
customAlert(alertInfo)
} else {
alert(alertInfo)
}
}
} | [
"function",
"(",
"alertInfo",
",",
"debugInfo",
")",
"{",
"const",
"editor",
"=",
"this",
".",
"editor",
"const",
"debug",
"=",
"editor",
".",
"config",
".",
"debug",
"const",
"customAlert",
"=",
"editor",
".",
"config",
".",
"customAlert",
"if",
"(",
"d... | 根据 debug 弹出不同的信息 | [
"根据",
"debug",
"弹出不同的信息"
] | b77696f5e81c8ec13d9d341252d6b9fa8a22db18 | https://github.com/wangfupeng1988/wangEditor/blob/b77696f5e81c8ec13d9d341252d6b9fa8a22db18/src/js/editor/upload/upload-img.js#L19-L33 | train | wangEditor alert | [
30522,
3853,
1006,
9499,
2378,
14876,
1010,
2139,
8569,
11528,
14876,
1007,
1063,
9530,
3367,
3559,
1027,
2023,
1012,
3559,
9530,
3367,
2139,
8569,
2290,
1027,
3559,
1012,
9530,
8873,
2290,
1012,
2139,
8569,
2290,
9530,
3367,
7661,
9453,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
aframevr/aframe | src/core/component.js | function () {
var hasComponentChanged;
// Store the previous old data before we calculate the new oldData.
if (this.previousOldData instanceof Object) {
utils.objectPool.clearObject(this.previousOldData);
}
if (this.isObjectBased) {
copyData(this.previousOldData, this.oldData);
} else {
this.previousOldData = this.oldData;
}
hasComponentChanged = !utils.deepEqual(this.oldData, this.data);
// Don't update if properties haven't changed.
// Always update rotation, position, scale.
if (!this.isPositionRotationScale && !hasComponentChanged) { return; }
// Store current data as previous data for future updates.
// Reuse `this.oldData` object to try not to allocate another one.
if (this.oldData instanceof Object) { utils.objectPool.clearObject(this.oldData); }
this.oldData = extendProperties(this.oldData, this.data, this.isObjectBased);
// Update component with the previous old data.
this.update(this.previousOldData);
this.throttledEmitComponentChanged();
} | javascript | function () {
var hasComponentChanged;
// Store the previous old data before we calculate the new oldData.
if (this.previousOldData instanceof Object) {
utils.objectPool.clearObject(this.previousOldData);
}
if (this.isObjectBased) {
copyData(this.previousOldData, this.oldData);
} else {
this.previousOldData = this.oldData;
}
hasComponentChanged = !utils.deepEqual(this.oldData, this.data);
// Don't update if properties haven't changed.
// Always update rotation, position, scale.
if (!this.isPositionRotationScale && !hasComponentChanged) { return; }
// Store current data as previous data for future updates.
// Reuse `this.oldData` object to try not to allocate another one.
if (this.oldData instanceof Object) { utils.objectPool.clearObject(this.oldData); }
this.oldData = extendProperties(this.oldData, this.data, this.isObjectBased);
// Update component with the previous old data.
this.update(this.previousOldData);
this.throttledEmitComponentChanged();
} | [
"function",
"(",
")",
"{",
"var",
"hasComponentChanged",
";",
"// Store the previous old data before we calculate the new oldData.",
"if",
"(",
"this",
".",
"previousOldData",
"instanceof",
"Object",
")",
"{",
"utils",
".",
"objectPool",
".",
"clearObject",
"(",
"this",... | Check if component should fire update and fire update lifecycle handler. | [
"Check",
"if",
"component",
"should",
"fire",
"update",
"and",
"fire",
"update",
"lifecycle",
"handler",
"."
] | 24acc78a7299a4cdfe3ef617f4d40ddf6275c992 | https://github.com/aframevr/aframe/blob/24acc78a7299a4cdfe3ef617f4d40ddf6275c992/src/core/component.js#L392-L420 | train | Updates the component with the new data. | [
30522,
3853,
1006,
1007,
1063,
13075,
2038,
9006,
29513,
3372,
22305,
2098,
1025,
1013,
1013,
3573,
1996,
3025,
2214,
2951,
2077,
2057,
18422,
1996,
2047,
2214,
2850,
2696,
1012,
2065,
1006,
2023,
1012,
3025,
11614,
2850,
2696,
6013,
11253,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/switch-colon-spacing.js | fix | function fix(fixer, left, right, spacing) {
if (commentsExistBetween(left, right)) {
return null;
}
if (spacing) {
return fixer.insertTextAfter(left, " ");
}
return fixer.removeRange([left.range[1], right.range[0]]);
} | javascript | function fix(fixer, left, right, spacing) {
if (commentsExistBetween(left, right)) {
return null;
}
if (spacing) {
return fixer.insertTextAfter(left, " ");
}
return fixer.removeRange([left.range[1], right.range[0]]);
} | [
"function",
"fix",
"(",
"fixer",
",",
"left",
",",
"right",
",",
"spacing",
")",
"{",
"if",
"(",
"commentsExistBetween",
"(",
"left",
",",
"right",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"spacing",
")",
"{",
"return",
"fixer",
".",
"... | Fix the spacing between the given 2 tokens.
@param {RuleFixer} fixer The fixer to fix.
@param {Token} left The left token of fix range.
@param {Token} right The right token of fix range.
@param {boolean} spacing The spacing style. `true` if there should be a space.
@returns {Fix|null} The fix object. | [
"Fix",
"the",
"spacing",
"between",
"the",
"given",
"2",
"tokens",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/switch-colon-spacing.js#L106-L114 | train | Fixes a line between two comments | [
30522,
3853,
8081,
1006,
8081,
2121,
1010,
2187,
1010,
2157,
1010,
12403,
6129,
1007,
1063,
2065,
1006,
7928,
10288,
2923,
20915,
28394,
2078,
1006,
2187,
1010,
2157,
1007,
1007,
1063,
2709,
19701,
1025,
1065,
2065,
1006,
12403,
6129,
1007,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
postmanlabs/newman | lib/run/options.js | function (err, collection) {
if (err) {
return callback(err);
}
// ensure that the collection option is present before starting a run
if (!_.isObject(collection)) {
return callback(new Error(COLLECTION_LOAD_ERROR_MESSAGE));
}
// ensure that the collection reference is an SDK instance
// @todo - should this be handled by config loaders?
collection = new Collection(Collection.isCollection(collection) ?
// if the option contain an instance of collection, we simply clone it for future use
// create a collection in case it is not one. user can send v2 JSON as a source and that will be
// converted to a collection
collection.toJSON() : collection);
callback(null, collection);
} | javascript | function (err, collection) {
if (err) {
return callback(err);
}
// ensure that the collection option is present before starting a run
if (!_.isObject(collection)) {
return callback(new Error(COLLECTION_LOAD_ERROR_MESSAGE));
}
// ensure that the collection reference is an SDK instance
// @todo - should this be handled by config loaders?
collection = new Collection(Collection.isCollection(collection) ?
// if the option contain an instance of collection, we simply clone it for future use
// create a collection in case it is not one. user can send v2 JSON as a source and that will be
// converted to a collection
collection.toJSON() : collection);
callback(null, collection);
} | [
"function",
"(",
"err",
",",
"collection",
")",
"{",
"if",
"(",
"err",
")",
"{",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"// ensure that the collection option is present before starting a run",
"if",
"(",
"!",
"_",
".",
"isObject",
"(",
"collection",
... | The post collection load handler.
@param {?Error} err - An Error instance / null, passed from the collection loader.
@param {Object} collection - The collection / raw JSON object, passed from the collection loader.
@returns {*} | [
"The",
"post",
"collection",
"load",
"handler",
"."
] | c05a5a1e82aa3c2021e94ba09e627ba4718af69e | https://github.com/postmanlabs/newman/blob/c05a5a1e82aa3c2021e94ba09e627ba4718af69e/lib/run/options.js#L180-L199 | train | Load the cache | [
30522,
3853,
1006,
9413,
2099,
1010,
3074,
1007,
1063,
2065,
1006,
9413,
2099,
1007,
1063,
2709,
2655,
5963,
1006,
9413,
2099,
1007,
30524,
1012,
11163,
2497,
20614,
1006,
3074,
1007,
1007,
1063,
2709,
2655,
5963,
1006,
2047,
7561,
1006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SheetJS/js-xlsx | xlsx.js | parse_ws_bin | function parse_ws_bin(data, _opts, idx, rels, wb, themes, styles) {
if(!data) return data;
var opts = _opts || {};
if(!rels) rels = {'!id':{}};
if(DENSE != null && opts.dense == null) opts.dense = DENSE;
var s = (opts.dense ? [] : {});
var ref;
var refguess = {s: {r:2000000, c:2000000}, e: {r:0, c:0} };
var pass = false, end = false;
var row, p, cf, R, C, addr, sstr, rr, cell;
var merges = [];
opts.biff = 12;
opts['!row'] = 0;
var ai = 0, af = false;
var arrayf = [];
var sharedf = {};
var supbooks = opts.supbooks || wb.supbooks || ([[]]);
supbooks.sharedf = sharedf;
supbooks.arrayf = arrayf;
supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x) { return x.name; });
if(!opts.supbooks) {
opts.supbooks = supbooks;
if(wb.Names) for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
}
var colinfo = [], rowinfo = [];
var seencol = false;
recordhopper(data, function ws_parse(val, R_n, RT) {
if(end) return;
switch(RT) {
case 0x0094: /* 'BrtWsDim' */
ref = val; break;
case 0x0000: /* 'BrtRowHdr' */
row = val;
if(opts.sheetRows && opts.sheetRows <= row.r) end=true;
rr = encode_row(R = row.r);
opts['!row'] = row.r;
if(val.hidden || val.hpt || val.level != null) {
if(val.hpt) val.hpx = pt2px(val.hpt);
rowinfo[val.r] = val;
}
break;
case 0x0002: /* 'BrtCellRk' */
case 0x0003: /* 'BrtCellError' */
case 0x0004: /* 'BrtCellBool' */
case 0x0005: /* 'BrtCellReal' */
case 0x0006: /* 'BrtCellSt' */
case 0x0007: /* 'BrtCellIsst' */
case 0x0008: /* 'BrtFmlaString' */
case 0x0009: /* 'BrtFmlaNum' */
case 0x000A: /* 'BrtFmlaBool' */
case 0x000B: /* 'BrtFmlaError' */
p = ({t:val[2]});
switch(val[2]) {
case 'n': p.v = val[1]; break;
case 's': sstr = strs[val[1]]; p.v = sstr.t; p.r = sstr.r; break;
case 'b': p.v = val[1] ? true : false; break;
case 'e': p.v = val[1]; if(opts.cellText !== false) p.w = BErr[p.v]; break;
case 'str': p.t = 's'; p.v = val[1]; break;
}
if((cf = styles.CellXf[val[0].iStyleRef])) safe_format(p,cf.numFmtId,null,opts, themes, styles);
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
else s[encode_col(C) + rr] = p;
if(opts.cellFormula) {
af = false;
for(ai = 0; ai < arrayf.length; ++ai) {
var aii = arrayf[ai];
if(row.r >= aii[0].s.r && row.r <= aii[0].e.r)
if(C >= aii[0].s.c && C <= aii[0].e.c) {
p.F = encode_range(aii[0]); af = true;
}
}
if(!af && val.length > 3) p.f = val[3];
}
if(refguess.s.r > row.r) refguess.s.r = row.r;
if(refguess.s.c > C) refguess.s.c = C;
if(refguess.e.r < row.r) refguess.e.r = row.r;
if(refguess.e.c < C) refguess.e.c = C;
if(opts.cellDates && cf && p.t == 'n' && SSF.is_date(SSF._table[cf.numFmtId])) {
var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); }
}
break;
case 0x0001: /* 'BrtCellBlank' */
if(!opts.sheetStubs || pass) break;
p = ({t:'z',v:undefined});
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
else s[encode_col(C) + rr] = p;
if(refguess.s.r > row.r) refguess.s.r = row.r;
if(refguess.s.c > C) refguess.s.c = C;
if(refguess.e.r < row.r) refguess.e.r = row.r;
if(refguess.e.c < C) refguess.e.c = C;
break;
case 0x00B0: /* 'BrtMergeCell' */
merges.push(val); break;
case 0x01EE: /* 'BrtHLink' */
var rel = rels['!id'][val.relId];
if(rel) {
val.Target = rel.Target;
if(val.loc) val.Target += "#"+val.loc;
val.Rel = rel;
} else if(val.relId == '') {
val.Target = "#" + val.loc;
}
for(R=val.rfx.s.r;R<=val.rfx.e.r;++R) for(C=val.rfx.s.c;C<=val.rfx.e.c;++C) {
if(opts.dense) {
if(!s[R]) s[R] = [];
if(!s[R][C]) s[R][C] = {t:'z',v:undefined};
s[R][C].l = val;
} else {
addr = encode_cell({c:C,r:R});
if(!s[addr]) s[addr] = {t:'z',v:undefined};
s[addr].l = val;
}
}
break;
case 0x01AA: /* 'BrtArrFmla' */
if(!opts.cellFormula) break;
arrayf.push(val);
cell = ((opts.dense ? s[R][C] : s[encode_col(C) + rr]));
cell.f = stringify_formula(val[1], refguess, {r:row.r, c:C}, supbooks, opts);
cell.F = encode_range(val[0]);
break;
case 0x01AB: /* 'BrtShrFmla' */
if(!opts.cellFormula) break;
sharedf[encode_cell(val[0].s)] = val[1];
cell = (opts.dense ? s[R][C] : s[encode_col(C) + rr]);
cell.f = stringify_formula(val[1], refguess, {r:row.r, c:C}, supbooks, opts);
break;
/* identical to 'ColInfo' in XLS */
case 0x003C: /* 'BrtColInfo' */
if(!opts.cellStyles) break;
while(val.e >= val.s) {
colinfo[val.e--] = { width: val.w/256, hidden: !!(val.flags & 0x01) };
if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
process_col(colinfo[val.e+1]);
}
break;
case 0x00A1: /* 'BrtBeginAFilter' */
s['!autofilter'] = { ref:encode_range(val) };
break;
case 0x01DC: /* 'BrtMargins' */
s['!margins'] = val;
break;
case 0x0093: /* 'BrtWsProp' */
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
if(val.name) wb.Sheets[idx].CodeName = val.name;
break;
case 0x0089: /* 'BrtBeginWsView' */
if(!wb.Views) wb.Views = [{}];
if(!wb.Views[0]) wb.Views[0] = {};
if(val.RTL) wb.Views[0].RTL = true;
break;
case 0x01E5: /* 'BrtWsFmtInfo' */
break;
case 0x00AF: /* 'BrtAFilterDateGroupItem' */
case 0x0284: /* 'BrtActiveX' */
case 0x0271: /* 'BrtBigName' */
case 0x0232: /* 'BrtBkHim' */
case 0x018C: /* 'BrtBrk' */
case 0x0458: /* 'BrtCFIcon' */
case 0x047A: /* 'BrtCFRuleExt' */
case 0x01D7: /* 'BrtCFVO' */
case 0x041A: /* 'BrtCFVO14' */
case 0x0289: /* 'BrtCellIgnoreEC' */
case 0x0451: /* 'BrtCellIgnoreEC14' */
case 0x0031: /* 'BrtCellMeta' */
case 0x024D: /* 'BrtCellSmartTagProperty' */
case 0x025F: /* 'BrtCellWatch' */
case 0x0234: /* 'BrtColor' */
case 0x041F: /* 'BrtColor14' */
case 0x00A8: /* 'BrtColorFilter' */
case 0x00AE: /* 'BrtCustomFilter' */
case 0x049C: /* 'BrtCustomFilter14' */
case 0x01F3: /* 'BrtDRef' */
case 0x0040: /* 'BrtDVal' */
case 0x041D: /* 'BrtDVal14' */
case 0x0226: /* 'BrtDrawing' */
case 0x00AB: /* 'BrtDynamicFilter' */
case 0x00A7: /* 'BrtFilter' */
case 0x0499: /* 'BrtFilter14' */
case 0x00A9: /* 'BrtIconFilter' */
case 0x049D: /* 'BrtIconFilter14' */
case 0x0227: /* 'BrtLegacyDrawing' */
case 0x0228: /* 'BrtLegacyDrawingHF' */
case 0x0295: /* 'BrtListPart' */
case 0x027F: /* 'BrtOleObject' */
case 0x01DE: /* 'BrtPageSetup' */
case 0x0097: /* 'BrtPane' */
case 0x0219: /* 'BrtPhoneticInfo' */
case 0x01DD: /* 'BrtPrintOptions' */
case 0x0218: /* 'BrtRangeProtection' */
case 0x044F: /* 'BrtRangeProtection14' */
case 0x02A8: /* 'BrtRangeProtectionIso' */
case 0x0450: /* 'BrtRangeProtectionIso14' */
case 0x0400: /* 'BrtRwDescent' */
case 0x0098: /* 'BrtSel' */
case 0x0297: /* 'BrtSheetCalcProp' */
case 0x0217: /* 'BrtSheetProtection' */
case 0x02A6: /* 'BrtSheetProtectionIso' */
case 0x01F8: /* 'BrtSlc' */
case 0x0413: /* 'BrtSparkline' */
case 0x01AC: /* 'BrtTable' */
case 0x00AA: /* 'BrtTop10Filter' */
case 0x0C00: /* 'BrtUid' */
case 0x0032: /* 'BrtValueMeta' */
case 0x0816: /* 'BrtWebExtension' */
case 0x0415: /* 'BrtWsFmtInfoEx14' */
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */ break;
case 0x0026: /* 'BrtACEnd' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
delete opts.supbooks;
delete opts['!row'];
if(!s["!ref"] && (refguess.s.r < 2000000 || ref && (ref.e.r > 0 || ref.e.c > 0 || ref.s.r > 0 || ref.s.c > 0))) s["!ref"] = encode_range(ref || refguess);
if(opts.sheetRows && s["!ref"]) {
var tmpref = safe_decode_range(s["!ref"]);
if(opts.sheetRows <= +tmpref.e.r) {
tmpref.e.r = opts.sheetRows - 1;
if(tmpref.e.r > refguess.e.r) tmpref.e.r = refguess.e.r;
if(tmpref.e.r < tmpref.s.r) tmpref.s.r = tmpref.e.r;
if(tmpref.e.c > refguess.e.c) tmpref.e.c = refguess.e.c;
if(tmpref.e.c < tmpref.s.c) tmpref.s.c = tmpref.e.c;
s["!fullref"] = s["!ref"];
s["!ref"] = encode_range(tmpref);
}
}
if(merges.length > 0) s["!merges"] = merges;
if(colinfo.length > 0) s["!cols"] = colinfo;
if(rowinfo.length > 0) s["!rows"] = rowinfo;
return s;
} | javascript | function parse_ws_bin(data, _opts, idx, rels, wb, themes, styles) {
if(!data) return data;
var opts = _opts || {};
if(!rels) rels = {'!id':{}};
if(DENSE != null && opts.dense == null) opts.dense = DENSE;
var s = (opts.dense ? [] : {});
var ref;
var refguess = {s: {r:2000000, c:2000000}, e: {r:0, c:0} };
var pass = false, end = false;
var row, p, cf, R, C, addr, sstr, rr, cell;
var merges = [];
opts.biff = 12;
opts['!row'] = 0;
var ai = 0, af = false;
var arrayf = [];
var sharedf = {};
var supbooks = opts.supbooks || wb.supbooks || ([[]]);
supbooks.sharedf = sharedf;
supbooks.arrayf = arrayf;
supbooks.SheetNames = wb.SheetNames || wb.Sheets.map(function(x) { return x.name; });
if(!opts.supbooks) {
opts.supbooks = supbooks;
if(wb.Names) for(var i = 0; i < wb.Names.length; ++i) supbooks[0][i+1] = wb.Names[i];
}
var colinfo = [], rowinfo = [];
var seencol = false;
recordhopper(data, function ws_parse(val, R_n, RT) {
if(end) return;
switch(RT) {
case 0x0094: /* 'BrtWsDim' */
ref = val; break;
case 0x0000: /* 'BrtRowHdr' */
row = val;
if(opts.sheetRows && opts.sheetRows <= row.r) end=true;
rr = encode_row(R = row.r);
opts['!row'] = row.r;
if(val.hidden || val.hpt || val.level != null) {
if(val.hpt) val.hpx = pt2px(val.hpt);
rowinfo[val.r] = val;
}
break;
case 0x0002: /* 'BrtCellRk' */
case 0x0003: /* 'BrtCellError' */
case 0x0004: /* 'BrtCellBool' */
case 0x0005: /* 'BrtCellReal' */
case 0x0006: /* 'BrtCellSt' */
case 0x0007: /* 'BrtCellIsst' */
case 0x0008: /* 'BrtFmlaString' */
case 0x0009: /* 'BrtFmlaNum' */
case 0x000A: /* 'BrtFmlaBool' */
case 0x000B: /* 'BrtFmlaError' */
p = ({t:val[2]});
switch(val[2]) {
case 'n': p.v = val[1]; break;
case 's': sstr = strs[val[1]]; p.v = sstr.t; p.r = sstr.r; break;
case 'b': p.v = val[1] ? true : false; break;
case 'e': p.v = val[1]; if(opts.cellText !== false) p.w = BErr[p.v]; break;
case 'str': p.t = 's'; p.v = val[1]; break;
}
if((cf = styles.CellXf[val[0].iStyleRef])) safe_format(p,cf.numFmtId,null,opts, themes, styles);
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
else s[encode_col(C) + rr] = p;
if(opts.cellFormula) {
af = false;
for(ai = 0; ai < arrayf.length; ++ai) {
var aii = arrayf[ai];
if(row.r >= aii[0].s.r && row.r <= aii[0].e.r)
if(C >= aii[0].s.c && C <= aii[0].e.c) {
p.F = encode_range(aii[0]); af = true;
}
}
if(!af && val.length > 3) p.f = val[3];
}
if(refguess.s.r > row.r) refguess.s.r = row.r;
if(refguess.s.c > C) refguess.s.c = C;
if(refguess.e.r < row.r) refguess.e.r = row.r;
if(refguess.e.c < C) refguess.e.c = C;
if(opts.cellDates && cf && p.t == 'n' && SSF.is_date(SSF._table[cf.numFmtId])) {
var _d = SSF.parse_date_code(p.v); if(_d) { p.t = 'd'; p.v = new Date(_d.y, _d.m-1,_d.d,_d.H,_d.M,_d.S,_d.u); }
}
break;
case 0x0001: /* 'BrtCellBlank' */
if(!opts.sheetStubs || pass) break;
p = ({t:'z',v:undefined});
C = val[0].c;
if(opts.dense) { if(!s[R]) s[R] = []; s[R][C] = p; }
else s[encode_col(C) + rr] = p;
if(refguess.s.r > row.r) refguess.s.r = row.r;
if(refguess.s.c > C) refguess.s.c = C;
if(refguess.e.r < row.r) refguess.e.r = row.r;
if(refguess.e.c < C) refguess.e.c = C;
break;
case 0x00B0: /* 'BrtMergeCell' */
merges.push(val); break;
case 0x01EE: /* 'BrtHLink' */
var rel = rels['!id'][val.relId];
if(rel) {
val.Target = rel.Target;
if(val.loc) val.Target += "#"+val.loc;
val.Rel = rel;
} else if(val.relId == '') {
val.Target = "#" + val.loc;
}
for(R=val.rfx.s.r;R<=val.rfx.e.r;++R) for(C=val.rfx.s.c;C<=val.rfx.e.c;++C) {
if(opts.dense) {
if(!s[R]) s[R] = [];
if(!s[R][C]) s[R][C] = {t:'z',v:undefined};
s[R][C].l = val;
} else {
addr = encode_cell({c:C,r:R});
if(!s[addr]) s[addr] = {t:'z',v:undefined};
s[addr].l = val;
}
}
break;
case 0x01AA: /* 'BrtArrFmla' */
if(!opts.cellFormula) break;
arrayf.push(val);
cell = ((opts.dense ? s[R][C] : s[encode_col(C) + rr]));
cell.f = stringify_formula(val[1], refguess, {r:row.r, c:C}, supbooks, opts);
cell.F = encode_range(val[0]);
break;
case 0x01AB: /* 'BrtShrFmla' */
if(!opts.cellFormula) break;
sharedf[encode_cell(val[0].s)] = val[1];
cell = (opts.dense ? s[R][C] : s[encode_col(C) + rr]);
cell.f = stringify_formula(val[1], refguess, {r:row.r, c:C}, supbooks, opts);
break;
/* identical to 'ColInfo' in XLS */
case 0x003C: /* 'BrtColInfo' */
if(!opts.cellStyles) break;
while(val.e >= val.s) {
colinfo[val.e--] = { width: val.w/256, hidden: !!(val.flags & 0x01) };
if(!seencol) { seencol = true; find_mdw_colw(val.w/256); }
process_col(colinfo[val.e+1]);
}
break;
case 0x00A1: /* 'BrtBeginAFilter' */
s['!autofilter'] = { ref:encode_range(val) };
break;
case 0x01DC: /* 'BrtMargins' */
s['!margins'] = val;
break;
case 0x0093: /* 'BrtWsProp' */
if(!wb.Sheets[idx]) wb.Sheets[idx] = {};
if(val.name) wb.Sheets[idx].CodeName = val.name;
break;
case 0x0089: /* 'BrtBeginWsView' */
if(!wb.Views) wb.Views = [{}];
if(!wb.Views[0]) wb.Views[0] = {};
if(val.RTL) wb.Views[0].RTL = true;
break;
case 0x01E5: /* 'BrtWsFmtInfo' */
break;
case 0x00AF: /* 'BrtAFilterDateGroupItem' */
case 0x0284: /* 'BrtActiveX' */
case 0x0271: /* 'BrtBigName' */
case 0x0232: /* 'BrtBkHim' */
case 0x018C: /* 'BrtBrk' */
case 0x0458: /* 'BrtCFIcon' */
case 0x047A: /* 'BrtCFRuleExt' */
case 0x01D7: /* 'BrtCFVO' */
case 0x041A: /* 'BrtCFVO14' */
case 0x0289: /* 'BrtCellIgnoreEC' */
case 0x0451: /* 'BrtCellIgnoreEC14' */
case 0x0031: /* 'BrtCellMeta' */
case 0x024D: /* 'BrtCellSmartTagProperty' */
case 0x025F: /* 'BrtCellWatch' */
case 0x0234: /* 'BrtColor' */
case 0x041F: /* 'BrtColor14' */
case 0x00A8: /* 'BrtColorFilter' */
case 0x00AE: /* 'BrtCustomFilter' */
case 0x049C: /* 'BrtCustomFilter14' */
case 0x01F3: /* 'BrtDRef' */
case 0x0040: /* 'BrtDVal' */
case 0x041D: /* 'BrtDVal14' */
case 0x0226: /* 'BrtDrawing' */
case 0x00AB: /* 'BrtDynamicFilter' */
case 0x00A7: /* 'BrtFilter' */
case 0x0499: /* 'BrtFilter14' */
case 0x00A9: /* 'BrtIconFilter' */
case 0x049D: /* 'BrtIconFilter14' */
case 0x0227: /* 'BrtLegacyDrawing' */
case 0x0228: /* 'BrtLegacyDrawingHF' */
case 0x0295: /* 'BrtListPart' */
case 0x027F: /* 'BrtOleObject' */
case 0x01DE: /* 'BrtPageSetup' */
case 0x0097: /* 'BrtPane' */
case 0x0219: /* 'BrtPhoneticInfo' */
case 0x01DD: /* 'BrtPrintOptions' */
case 0x0218: /* 'BrtRangeProtection' */
case 0x044F: /* 'BrtRangeProtection14' */
case 0x02A8: /* 'BrtRangeProtectionIso' */
case 0x0450: /* 'BrtRangeProtectionIso14' */
case 0x0400: /* 'BrtRwDescent' */
case 0x0098: /* 'BrtSel' */
case 0x0297: /* 'BrtSheetCalcProp' */
case 0x0217: /* 'BrtSheetProtection' */
case 0x02A6: /* 'BrtSheetProtectionIso' */
case 0x01F8: /* 'BrtSlc' */
case 0x0413: /* 'BrtSparkline' */
case 0x01AC: /* 'BrtTable' */
case 0x00AA: /* 'BrtTop10Filter' */
case 0x0C00: /* 'BrtUid' */
case 0x0032: /* 'BrtValueMeta' */
case 0x0816: /* 'BrtWebExtension' */
case 0x0415: /* 'BrtWsFmtInfoEx14' */
break;
case 0x0023: /* 'BrtFRTBegin' */
pass = true; break;
case 0x0024: /* 'BrtFRTEnd' */
pass = false; break;
case 0x0025: /* 'BrtACBegin' */ break;
case 0x0026: /* 'BrtACEnd' */ break;
default:
if((R_n||"").indexOf("Begin") > 0){/* empty */}
else if((R_n||"").indexOf("End") > 0){/* empty */}
else if(!pass || opts.WTF) throw new Error("Unexpected record " + RT + " " + R_n);
}
}, opts);
delete opts.supbooks;
delete opts['!row'];
if(!s["!ref"] && (refguess.s.r < 2000000 || ref && (ref.e.r > 0 || ref.e.c > 0 || ref.s.r > 0 || ref.s.c > 0))) s["!ref"] = encode_range(ref || refguess);
if(opts.sheetRows && s["!ref"]) {
var tmpref = safe_decode_range(s["!ref"]);
if(opts.sheetRows <= +tmpref.e.r) {
tmpref.e.r = opts.sheetRows - 1;
if(tmpref.e.r > refguess.e.r) tmpref.e.r = refguess.e.r;
if(tmpref.e.r < tmpref.s.r) tmpref.s.r = tmpref.e.r;
if(tmpref.e.c > refguess.e.c) tmpref.e.c = refguess.e.c;
if(tmpref.e.c < tmpref.s.c) tmpref.s.c = tmpref.e.c;
s["!fullref"] = s["!ref"];
s["!ref"] = encode_range(tmpref);
}
}
if(merges.length > 0) s["!merges"] = merges;
if(colinfo.length > 0) s["!cols"] = colinfo;
if(rowinfo.length > 0) s["!rows"] = rowinfo;
return s;
} | [
"function",
"parse_ws_bin",
"(",
"data",
",",
"_opts",
",",
"idx",
",",
"rels",
",",
"wb",
",",
"themes",
",",
"styles",
")",
"{",
"if",
"(",
"!",
"data",
")",
"return",
"data",
";",
"var",
"opts",
"=",
"_opts",
"||",
"{",
"}",
";",
"if",
"(",
... | /* [MS-XLSB] 2.1.7.61 Worksheet | [
"/",
"*",
"[",
"MS",
"-",
"XLSB",
"]",
"2",
".",
"1",
".",
"7",
".",
"61",
"Worksheet"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L13782-L14043 | train | Parse a raw data buffer | [
30522,
3853,
11968,
3366,
1035,
1059,
2015,
1035,
8026,
1006,
2951,
1010,
1035,
23569,
2015,
1010,
8909,
2595,
1010,
2128,
4877,
1010,
25610,
1010,
6991,
1010,
6782,
1007,
1063,
2065,
1006,
999,
2951,
1007,
2709,
2951,
1025,
13075,
23569,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | xlsx.js | parse_ShtProps | function parse_ShtProps(blob, length, opts) {
var def = {area:false};
if(opts.biff != 5) { blob.l += length; return def; }
var d = blob.read_shift(1); blob.l += 3;
if((d & 0x10)) def.area = true;
return def;
} | javascript | function parse_ShtProps(blob, length, opts) {
var def = {area:false};
if(opts.biff != 5) { blob.l += length; return def; }
var d = blob.read_shift(1); blob.l += 3;
if((d & 0x10)) def.area = true;
return def;
} | [
"function",
"parse_ShtProps",
"(",
"blob",
",",
"length",
",",
"opts",
")",
"{",
"var",
"def",
"=",
"{",
"area",
":",
"false",
"}",
";",
"if",
"(",
"opts",
".",
"biff",
"!=",
"5",
")",
"{",
"blob",
".",
"l",
"+=",
"length",
";",
"return",
"def",
... | /* [MS-XLS] 2.4.261 | [
"/",
"*",
"[",
"MS",
"-",
"XLS",
"]",
"2",
".",
"4",
".",
"261"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/xlsx.js#L6531-L6537 | train | ShtProps Parse an object literal | [
30522,
3853,
11968,
3366,
1035,
14021,
25856,
18981,
2015,
1006,
1038,
4135,
2497,
1010,
3091,
1010,
23569,
2015,
1007,
1063,
13075,
13366,
1027,
1063,
2181,
1024,
6270,
1065,
1025,
2065,
1006,
23569,
2015,
1012,
12170,
4246,
999,
30524,
25... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RecordRTC | RecordRTC.js | StereoAudioRecorder | function StereoAudioRecorder(mediaStream, config) {
if (!getTracks(mediaStream, 'audio').length) {
throw 'Your stream has no audio tracks.';
}
config = config || {};
var self = this;
// variables
var leftchannel = [];
var rightchannel = [];
var recording = false;
var recordingLength = 0;
var jsAudioNode;
var numberOfAudioChannels = 2;
/**
* Set sample rates such as 8K or 16K. Reference: http://stackoverflow.com/a/28977136/552182
* @property {number} desiredSampRate - Desired Bits per sample * 1000
* @memberof StereoAudioRecorder
* @instance
* @example
* var recorder = StereoAudioRecorder(mediaStream, {
* desiredSampRate: 16 * 1000 // bits-per-sample * 1000
* });
*/
var desiredSampRate = config.desiredSampRate;
// backward compatibility
if (config.leftChannel === true) {
numberOfAudioChannels = 1;
}
if (config.numberOfAudioChannels === 1) {
numberOfAudioChannels = 1;
}
if (!numberOfAudioChannels || numberOfAudioChannels < 1) {
numberOfAudioChannels = 2;
}
if (!config.disableLogs) {
console.log('StereoAudioRecorder is set to record number of channels: ' + numberOfAudioChannels);
}
// if any Track within the MediaStream is muted or not enabled at any time,
// the browser will only record black frames
// or silence since that is the content produced by the Track
// so we need to stopRecording as soon as any single track ends.
if (typeof config.checkForInactiveTracks === 'undefined') {
config.checkForInactiveTracks = true;
}
function isMediaStreamActive() {
if (config.checkForInactiveTracks === false) {
// always return "true"
return true;
}
if ('active' in mediaStream) {
if (!mediaStream.active) {
return false;
}
} else if ('ended' in mediaStream) { // old hack
if (mediaStream.ended) {
return false;
}
}
return true;
}
/**
* This method records MediaStream.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.record();
*/
this.record = function() {
if (isMediaStreamActive() === false) {
throw 'Please make sure MediaStream is active.';
}
resetVariables();
isAudioProcessStarted = isPaused = false;
recording = true;
if (typeof config.timeSlice !== 'undefined') {
looper();
}
};
function mergeLeftRightBuffers(config, callback) {
function mergeAudioBuffers(config, cb) {
var numberOfAudioChannels = config.numberOfAudioChannels;
// todo: "slice(0)" --- is it causes loop? Should be removed?
var leftBuffers = config.leftBuffers.slice(0);
var rightBuffers = config.rightBuffers.slice(0);
var sampleRate = config.sampleRate;
var internalInterleavedLength = config.internalInterleavedLength;
var desiredSampRate = config.desiredSampRate;
if (numberOfAudioChannels === 2) {
leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);
rightBuffers = mergeBuffers(rightBuffers, internalInterleavedLength);
if (desiredSampRate) {
leftBuffers = interpolateArray(leftBuffers, desiredSampRate, sampleRate);
rightBuffers = interpolateArray(rightBuffers, desiredSampRate, sampleRate);
}
}
if (numberOfAudioChannels === 1) {
leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);
if (desiredSampRate) {
leftBuffers = interpolateArray(leftBuffers, desiredSampRate, sampleRate);
}
}
// set sample rate as desired sample rate
if (desiredSampRate) {
sampleRate = desiredSampRate;
}
// for changing the sampling rate, reference:
// http://stackoverflow.com/a/28977136/552182
function interpolateArray(data, newSampleRate, oldSampleRate) {
var fitCount = Math.round(data.length * (newSampleRate / oldSampleRate));
var newData = [];
var springFactor = Number((data.length - 1) / (fitCount - 1));
newData[0] = data[0];
for (var i = 1; i < fitCount - 1; i++) {
var tmp = i * springFactor;
var before = Number(Math.floor(tmp)).toFixed();
var after = Number(Math.ceil(tmp)).toFixed();
var atPoint = tmp - before;
newData[i] = linearInterpolate(data[before], data[after], atPoint);
}
newData[fitCount - 1] = data[data.length - 1];
return newData;
}
function linearInterpolate(before, after, atPoint) {
return before + (after - before) * atPoint;
}
function mergeBuffers(channelBuffer, rLength) {
var result = new Float64Array(rLength);
var offset = 0;
var lng = channelBuffer.length;
for (var i = 0; i < lng; i++) {
var buffer = channelBuffer[i];
result.set(buffer, offset);
offset += buffer.length;
}
return result;
}
function interleave(leftChannel, rightChannel) {
var length = leftChannel.length + rightChannel.length;
var result = new Float64Array(length);
var inputIndex = 0;
for (var index = 0; index < length;) {
result[index++] = leftChannel[inputIndex];
result[index++] = rightChannel[inputIndex];
inputIndex++;
}
return result;
}
function writeUTFBytes(view, offset, string) {
var lng = string.length;
for (var i = 0; i < lng; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
}
// interleave both channels together
var interleaved;
if (numberOfAudioChannels === 2) {
interleaved = interleave(leftBuffers, rightBuffers);
}
if (numberOfAudioChannels === 1) {
interleaved = leftBuffers;
}
var interleavedLength = interleaved.length;
// create wav file
var resultingBufferLength = 44 + interleavedLength * 2;
var buffer = new ArrayBuffer(resultingBufferLength);
var view = new DataView(buffer);
// RIFF chunk descriptor/identifier
writeUTFBytes(view, 0, 'RIFF');
// RIFF chunk length
// changed "44" to "36" via #401
view.setUint32(4, 36 + interleavedLength * 2, true);
// RIFF type
writeUTFBytes(view, 8, 'WAVE');
// format chunk identifier
// FMT sub-chunk
writeUTFBytes(view, 12, 'fmt ');
// format chunk length
view.setUint32(16, 16, true);
// sample format (raw)
view.setUint16(20, 1, true);
// stereo (2 channels)
view.setUint16(22, numberOfAudioChannels, true);
// sample rate
view.setUint32(24, sampleRate, true);
// byte rate (sample rate * block align)
view.setUint32(28, sampleRate * 2, true);
// block align (channel count * bytes per sample)
view.setUint16(32, numberOfAudioChannels * 2, true);
// bits per sample
view.setUint16(34, 16, true);
// data sub-chunk
// data chunk identifier
writeUTFBytes(view, 36, 'data');
// data chunk length
view.setUint32(40, interleavedLength * 2, true);
// write the PCM samples
var lng = interleavedLength;
var index = 44;
var volume = 1;
for (var i = 0; i < lng; i++) {
view.setInt16(index, interleaved[i] * (0x7FFF * volume), true);
index += 2;
}
if (cb) {
return cb({
buffer: buffer,
view: view
});
}
postMessage({
buffer: buffer,
view: view
});
}
if (config.noWorker) {
mergeAudioBuffers(config, function(data) {
callback(data.buffer, data.view);
});
return;
}
var webWorker = processInWebWorker(mergeAudioBuffers);
webWorker.onmessage = function(event) {
callback(event.data.buffer, event.data.view);
// release memory
URL.revokeObjectURL(webWorker.workerURL);
// kill webworker (or Chrome will kill your page after ~25 calls)
webWorker.terminate();
};
webWorker.postMessage(config);
}
function processInWebWorker(_function) {
var workerURL = URL.createObjectURL(new Blob([_function.toString(),
';this.onmessage = function (eee) {' + _function.name + '(eee.data);}'
], {
type: 'application/javascript'
}));
var worker = new Worker(workerURL);
worker.workerURL = workerURL;
return worker;
}
/**
* This method stops recording MediaStream.
* @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(blob) {
* video.src = URL.createObjectURL(blob);
* });
*/
this.stop = function(callback) {
callback = callback || function() {};
// stop recording
recording = false;
mergeLeftRightBuffers({
desiredSampRate: desiredSampRate,
sampleRate: sampleRate,
numberOfAudioChannels: numberOfAudioChannels,
internalInterleavedLength: recordingLength,
leftBuffers: leftchannel,
rightBuffers: numberOfAudioChannels === 1 ? [] : rightchannel,
noWorker: config.noWorker
}, function(buffer, view) {
/**
* @property {Blob} blob - The recorded blob object.
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(){
* var blob = recorder.blob;
* });
*/
self.blob = new Blob([view], {
type: 'audio/wav'
});
/**
* @property {ArrayBuffer} buffer - The recorded buffer object.
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(){
* var buffer = recorder.buffer;
* });
*/
self.buffer = new ArrayBuffer(view.buffer.byteLength);
/**
* @property {DataView} view - The recorded data-view object.
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(){
* var view = recorder.view;
* });
*/
self.view = view;
self.sampleRate = desiredSampRate || sampleRate;
self.bufferSize = bufferSize;
// recorded audio length
self.length = recordingLength;
isAudioProcessStarted = false;
if (callback) {
callback(self.blob);
}
});
};
if (typeof Storage === 'undefined') {
var Storage = {
AudioContextConstructor: null,
AudioContext: window.AudioContext || window.webkitAudioContext
};
}
if (!Storage.AudioContextConstructor) {
Storage.AudioContextConstructor = new Storage.AudioContext();
}
var context = Storage.AudioContextConstructor;
// creates an audio node from the microphone incoming stream
var audioInput = context.createMediaStreamSource(mediaStream);
var legalBufferValues = [0, 256, 512, 1024, 2048, 4096, 8192, 16384];
/**
* From the spec: This value controls how frequently the audioprocess event is
* dispatched and how many sample-frames need to be processed each call.
* Lower values for buffer size will result in a lower (better) latency.
* Higher values will be necessary to avoid audio breakup and glitches
* The size of the buffer (in sample-frames) which needs to
* be processed each time onprocessaudio is called.
* Legal values are (256, 512, 1024, 2048, 4096, 8192, 16384).
* @property {number} bufferSize - Buffer-size for how frequently the audioprocess event is dispatched.
* @memberof StereoAudioRecorder
* @example
* recorder = new StereoAudioRecorder(mediaStream, {
* bufferSize: 4096
* });
*/
// "0" means, let chrome decide the most accurate buffer-size for current platform.
var bufferSize = typeof config.bufferSize === 'undefined' ? 4096 : config.bufferSize;
if (legalBufferValues.indexOf(bufferSize) === -1) {
if (!config.disableLogs) {
console.log('Legal values for buffer-size are ' + JSON.stringify(legalBufferValues, null, '\t'));
}
}
if (context.createJavaScriptNode) {
jsAudioNode = context.createJavaScriptNode(bufferSize, numberOfAudioChannels, numberOfAudioChannels);
} else if (context.createScriptProcessor) {
jsAudioNode = context.createScriptProcessor(bufferSize, numberOfAudioChannels, numberOfAudioChannels);
} else {
throw 'WebAudio API has no support on this browser.';
}
// connect the stream to the script processor
audioInput.connect(jsAudioNode);
if (!config.bufferSize) {
bufferSize = jsAudioNode.bufferSize; // device buffer-size
}
/**
* The sample rate (in sample-frames per second) at which the
* AudioContext handles audio. It is assumed that all AudioNodes
* in the context run at this rate. In making this assumption,
* sample-rate converters or "varispeed" processors are not supported
* in real-time processing.
* The sampleRate parameter describes the sample-rate of the
* linear PCM audio data in the buffer in sample-frames per second.
* An implementation must support sample-rates in at least
* the range 22050 to 96000.
* @property {number} sampleRate - Buffer-size for how frequently the audioprocess event is dispatched.
* @memberof StereoAudioRecorder
* @example
* recorder = new StereoAudioRecorder(mediaStream, {
* sampleRate: 44100
* });
*/
var sampleRate = typeof config.sampleRate !== 'undefined' ? config.sampleRate : context.sampleRate || 44100;
if (sampleRate < 22050 || sampleRate > 96000) {
// Ref: http://stackoverflow.com/a/26303918/552182
if (!config.disableLogs) {
console.log('sample-rate must be under range 22050 and 96000.');
}
}
if (!config.disableLogs) {
if (config.desiredSampRate) {
console.log('Desired sample-rate: ' + config.desiredSampRate);
}
}
var isPaused = false;
/**
* This method pauses the recording process.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.pause();
*/
this.pause = function() {
isPaused = true;
};
/**
* This method resumes the recording process.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.resume();
*/
this.resume = function() {
if (isMediaStreamActive() === false) {
throw 'Please make sure MediaStream is active.';
}
if (!recording) {
if (!config.disableLogs) {
console.log('Seems recording has been restarted.');
}
this.record();
return;
}
isPaused = false;
};
/**
* This method resets currently recorded data.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.clearRecordedData();
*/
this.clearRecordedData = function() {
config.checkForInactiveTracks = false;
if (recording) {
this.stop(clearRecordedDataCB);
}
clearRecordedDataCB();
};
function resetVariables() {
leftchannel = [];
rightchannel = [];
recordingLength = 0;
isAudioProcessStarted = false;
recording = false;
isPaused = false;
context = null;
self.leftchannel = leftchannel;
self.rightchannel = rightchannel;
self.numberOfAudioChannels = numberOfAudioChannels;
self.desiredSampRate = desiredSampRate;
self.sampleRate = sampleRate;
self.recordingLength = recordingLength;
intervalsBasedBuffers = {
left: [],
right: [],
recordingLength: 0
};
}
function clearRecordedDataCB() {
if (jsAudioNode) {
jsAudioNode.onaudioprocess = null;
jsAudioNode.disconnect();
jsAudioNode = null;
}
if (audioInput) {
audioInput.disconnect();
audioInput = null;
}
resetVariables();
}
// for debugging
this.name = 'StereoAudioRecorder';
this.toString = function() {
return this.name;
};
var isAudioProcessStarted = false;
function onAudioProcessDataAvailable(e) {
if (isPaused) {
return;
}
if (isMediaStreamActive() === false) {
if (!config.disableLogs) {
console.log('MediaStream seems stopped.');
}
jsAudioNode.disconnect();
recording = false;
}
if (!recording) {
if (audioInput) {
audioInput.disconnect();
audioInput = null;
}
return;
}
/**
* This method is called on "onaudioprocess" event's first invocation.
* @method {function} onAudioProcessStarted
* @memberof StereoAudioRecorder
* @example
* recorder.onAudioProcessStarted: function() { };
*/
if (!isAudioProcessStarted) {
isAudioProcessStarted = true;
if (config.onAudioProcessStarted) {
config.onAudioProcessStarted();
}
if (config.initCallback) {
config.initCallback();
}
}
var left = e.inputBuffer.getChannelData(0);
// we clone the samples
var chLeft = new Float32Array(left);
leftchannel.push(chLeft);
if (numberOfAudioChannels === 2) {
var right = e.inputBuffer.getChannelData(1);
var chRight = new Float32Array(right);
rightchannel.push(chRight);
}
recordingLength += bufferSize;
// export raw PCM
self.recordingLength = recordingLength;
if (typeof config.timeSlice !== 'undefined') {
intervalsBasedBuffers.recordingLength += bufferSize;
intervalsBasedBuffers.left.push(chLeft);
if (numberOfAudioChannels === 2) {
intervalsBasedBuffers.right.push(chRight);
}
}
}
jsAudioNode.onaudioprocess = onAudioProcessDataAvailable;
// to prevent self audio to be connected with speakers
if (context.createMediaStreamDestination) {
jsAudioNode.connect(context.createMediaStreamDestination());
} else {
jsAudioNode.connect(context.destination);
}
// export raw PCM
this.leftchannel = leftchannel;
this.rightchannel = rightchannel;
this.numberOfAudioChannels = numberOfAudioChannels;
this.desiredSampRate = desiredSampRate;
this.sampleRate = sampleRate;
self.recordingLength = recordingLength;
// helper for intervals based blobs
var intervalsBasedBuffers = {
left: [],
right: [],
recordingLength: 0
};
// this looper is used to support intervals based blobs (via timeSlice+ondataavailable)
function looper() {
if (!recording || typeof config.ondataavailable !== 'function' || typeof config.timeSlice === 'undefined') {
return;
}
if (intervalsBasedBuffers.left.length) {
mergeLeftRightBuffers({
desiredSampRate: desiredSampRate,
sampleRate: sampleRate,
numberOfAudioChannels: numberOfAudioChannels,
internalInterleavedLength: intervalsBasedBuffers.recordingLength,
leftBuffers: intervalsBasedBuffers.left,
rightBuffers: numberOfAudioChannels === 1 ? [] : intervalsBasedBuffers.right
}, function(buffer, view) {
var blob = new Blob([view], {
type: 'audio/wav'
});
config.ondataavailable(blob);
setTimeout(looper, config.timeSlice);
});
intervalsBasedBuffers = {
left: [],
right: [],
recordingLength: 0
};
} else {
setTimeout(looper, config.timeSlice);
}
}
} | javascript | function StereoAudioRecorder(mediaStream, config) {
if (!getTracks(mediaStream, 'audio').length) {
throw 'Your stream has no audio tracks.';
}
config = config || {};
var self = this;
// variables
var leftchannel = [];
var rightchannel = [];
var recording = false;
var recordingLength = 0;
var jsAudioNode;
var numberOfAudioChannels = 2;
/**
* Set sample rates such as 8K or 16K. Reference: http://stackoverflow.com/a/28977136/552182
* @property {number} desiredSampRate - Desired Bits per sample * 1000
* @memberof StereoAudioRecorder
* @instance
* @example
* var recorder = StereoAudioRecorder(mediaStream, {
* desiredSampRate: 16 * 1000 // bits-per-sample * 1000
* });
*/
var desiredSampRate = config.desiredSampRate;
// backward compatibility
if (config.leftChannel === true) {
numberOfAudioChannels = 1;
}
if (config.numberOfAudioChannels === 1) {
numberOfAudioChannels = 1;
}
if (!numberOfAudioChannels || numberOfAudioChannels < 1) {
numberOfAudioChannels = 2;
}
if (!config.disableLogs) {
console.log('StereoAudioRecorder is set to record number of channels: ' + numberOfAudioChannels);
}
// if any Track within the MediaStream is muted or not enabled at any time,
// the browser will only record black frames
// or silence since that is the content produced by the Track
// so we need to stopRecording as soon as any single track ends.
if (typeof config.checkForInactiveTracks === 'undefined') {
config.checkForInactiveTracks = true;
}
function isMediaStreamActive() {
if (config.checkForInactiveTracks === false) {
// always return "true"
return true;
}
if ('active' in mediaStream) {
if (!mediaStream.active) {
return false;
}
} else if ('ended' in mediaStream) { // old hack
if (mediaStream.ended) {
return false;
}
}
return true;
}
/**
* This method records MediaStream.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.record();
*/
this.record = function() {
if (isMediaStreamActive() === false) {
throw 'Please make sure MediaStream is active.';
}
resetVariables();
isAudioProcessStarted = isPaused = false;
recording = true;
if (typeof config.timeSlice !== 'undefined') {
looper();
}
};
function mergeLeftRightBuffers(config, callback) {
function mergeAudioBuffers(config, cb) {
var numberOfAudioChannels = config.numberOfAudioChannels;
// todo: "slice(0)" --- is it causes loop? Should be removed?
var leftBuffers = config.leftBuffers.slice(0);
var rightBuffers = config.rightBuffers.slice(0);
var sampleRate = config.sampleRate;
var internalInterleavedLength = config.internalInterleavedLength;
var desiredSampRate = config.desiredSampRate;
if (numberOfAudioChannels === 2) {
leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);
rightBuffers = mergeBuffers(rightBuffers, internalInterleavedLength);
if (desiredSampRate) {
leftBuffers = interpolateArray(leftBuffers, desiredSampRate, sampleRate);
rightBuffers = interpolateArray(rightBuffers, desiredSampRate, sampleRate);
}
}
if (numberOfAudioChannels === 1) {
leftBuffers = mergeBuffers(leftBuffers, internalInterleavedLength);
if (desiredSampRate) {
leftBuffers = interpolateArray(leftBuffers, desiredSampRate, sampleRate);
}
}
// set sample rate as desired sample rate
if (desiredSampRate) {
sampleRate = desiredSampRate;
}
// for changing the sampling rate, reference:
// http://stackoverflow.com/a/28977136/552182
function interpolateArray(data, newSampleRate, oldSampleRate) {
var fitCount = Math.round(data.length * (newSampleRate / oldSampleRate));
var newData = [];
var springFactor = Number((data.length - 1) / (fitCount - 1));
newData[0] = data[0];
for (var i = 1; i < fitCount - 1; i++) {
var tmp = i * springFactor;
var before = Number(Math.floor(tmp)).toFixed();
var after = Number(Math.ceil(tmp)).toFixed();
var atPoint = tmp - before;
newData[i] = linearInterpolate(data[before], data[after], atPoint);
}
newData[fitCount - 1] = data[data.length - 1];
return newData;
}
function linearInterpolate(before, after, atPoint) {
return before + (after - before) * atPoint;
}
function mergeBuffers(channelBuffer, rLength) {
var result = new Float64Array(rLength);
var offset = 0;
var lng = channelBuffer.length;
for (var i = 0; i < lng; i++) {
var buffer = channelBuffer[i];
result.set(buffer, offset);
offset += buffer.length;
}
return result;
}
function interleave(leftChannel, rightChannel) {
var length = leftChannel.length + rightChannel.length;
var result = new Float64Array(length);
var inputIndex = 0;
for (var index = 0; index < length;) {
result[index++] = leftChannel[inputIndex];
result[index++] = rightChannel[inputIndex];
inputIndex++;
}
return result;
}
function writeUTFBytes(view, offset, string) {
var lng = string.length;
for (var i = 0; i < lng; i++) {
view.setUint8(offset + i, string.charCodeAt(i));
}
}
// interleave both channels together
var interleaved;
if (numberOfAudioChannels === 2) {
interleaved = interleave(leftBuffers, rightBuffers);
}
if (numberOfAudioChannels === 1) {
interleaved = leftBuffers;
}
var interleavedLength = interleaved.length;
// create wav file
var resultingBufferLength = 44 + interleavedLength * 2;
var buffer = new ArrayBuffer(resultingBufferLength);
var view = new DataView(buffer);
// RIFF chunk descriptor/identifier
writeUTFBytes(view, 0, 'RIFF');
// RIFF chunk length
// changed "44" to "36" via #401
view.setUint32(4, 36 + interleavedLength * 2, true);
// RIFF type
writeUTFBytes(view, 8, 'WAVE');
// format chunk identifier
// FMT sub-chunk
writeUTFBytes(view, 12, 'fmt ');
// format chunk length
view.setUint32(16, 16, true);
// sample format (raw)
view.setUint16(20, 1, true);
// stereo (2 channels)
view.setUint16(22, numberOfAudioChannels, true);
// sample rate
view.setUint32(24, sampleRate, true);
// byte rate (sample rate * block align)
view.setUint32(28, sampleRate * 2, true);
// block align (channel count * bytes per sample)
view.setUint16(32, numberOfAudioChannels * 2, true);
// bits per sample
view.setUint16(34, 16, true);
// data sub-chunk
// data chunk identifier
writeUTFBytes(view, 36, 'data');
// data chunk length
view.setUint32(40, interleavedLength * 2, true);
// write the PCM samples
var lng = interleavedLength;
var index = 44;
var volume = 1;
for (var i = 0; i < lng; i++) {
view.setInt16(index, interleaved[i] * (0x7FFF * volume), true);
index += 2;
}
if (cb) {
return cb({
buffer: buffer,
view: view
});
}
postMessage({
buffer: buffer,
view: view
});
}
if (config.noWorker) {
mergeAudioBuffers(config, function(data) {
callback(data.buffer, data.view);
});
return;
}
var webWorker = processInWebWorker(mergeAudioBuffers);
webWorker.onmessage = function(event) {
callback(event.data.buffer, event.data.view);
// release memory
URL.revokeObjectURL(webWorker.workerURL);
// kill webworker (or Chrome will kill your page after ~25 calls)
webWorker.terminate();
};
webWorker.postMessage(config);
}
function processInWebWorker(_function) {
var workerURL = URL.createObjectURL(new Blob([_function.toString(),
';this.onmessage = function (eee) {' + _function.name + '(eee.data);}'
], {
type: 'application/javascript'
}));
var worker = new Worker(workerURL);
worker.workerURL = workerURL;
return worker;
}
/**
* This method stops recording MediaStream.
* @param {function} callback - Callback function, that is used to pass recorded blob back to the callee.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(blob) {
* video.src = URL.createObjectURL(blob);
* });
*/
this.stop = function(callback) {
callback = callback || function() {};
// stop recording
recording = false;
mergeLeftRightBuffers({
desiredSampRate: desiredSampRate,
sampleRate: sampleRate,
numberOfAudioChannels: numberOfAudioChannels,
internalInterleavedLength: recordingLength,
leftBuffers: leftchannel,
rightBuffers: numberOfAudioChannels === 1 ? [] : rightchannel,
noWorker: config.noWorker
}, function(buffer, view) {
/**
* @property {Blob} blob - The recorded blob object.
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(){
* var blob = recorder.blob;
* });
*/
self.blob = new Blob([view], {
type: 'audio/wav'
});
/**
* @property {ArrayBuffer} buffer - The recorded buffer object.
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(){
* var buffer = recorder.buffer;
* });
*/
self.buffer = new ArrayBuffer(view.buffer.byteLength);
/**
* @property {DataView} view - The recorded data-view object.
* @memberof StereoAudioRecorder
* @example
* recorder.stop(function(){
* var view = recorder.view;
* });
*/
self.view = view;
self.sampleRate = desiredSampRate || sampleRate;
self.bufferSize = bufferSize;
// recorded audio length
self.length = recordingLength;
isAudioProcessStarted = false;
if (callback) {
callback(self.blob);
}
});
};
if (typeof Storage === 'undefined') {
var Storage = {
AudioContextConstructor: null,
AudioContext: window.AudioContext || window.webkitAudioContext
};
}
if (!Storage.AudioContextConstructor) {
Storage.AudioContextConstructor = new Storage.AudioContext();
}
var context = Storage.AudioContextConstructor;
// creates an audio node from the microphone incoming stream
var audioInput = context.createMediaStreamSource(mediaStream);
var legalBufferValues = [0, 256, 512, 1024, 2048, 4096, 8192, 16384];
/**
* From the spec: This value controls how frequently the audioprocess event is
* dispatched and how many sample-frames need to be processed each call.
* Lower values for buffer size will result in a lower (better) latency.
* Higher values will be necessary to avoid audio breakup and glitches
* The size of the buffer (in sample-frames) which needs to
* be processed each time onprocessaudio is called.
* Legal values are (256, 512, 1024, 2048, 4096, 8192, 16384).
* @property {number} bufferSize - Buffer-size for how frequently the audioprocess event is dispatched.
* @memberof StereoAudioRecorder
* @example
* recorder = new StereoAudioRecorder(mediaStream, {
* bufferSize: 4096
* });
*/
// "0" means, let chrome decide the most accurate buffer-size for current platform.
var bufferSize = typeof config.bufferSize === 'undefined' ? 4096 : config.bufferSize;
if (legalBufferValues.indexOf(bufferSize) === -1) {
if (!config.disableLogs) {
console.log('Legal values for buffer-size are ' + JSON.stringify(legalBufferValues, null, '\t'));
}
}
if (context.createJavaScriptNode) {
jsAudioNode = context.createJavaScriptNode(bufferSize, numberOfAudioChannels, numberOfAudioChannels);
} else if (context.createScriptProcessor) {
jsAudioNode = context.createScriptProcessor(bufferSize, numberOfAudioChannels, numberOfAudioChannels);
} else {
throw 'WebAudio API has no support on this browser.';
}
// connect the stream to the script processor
audioInput.connect(jsAudioNode);
if (!config.bufferSize) {
bufferSize = jsAudioNode.bufferSize; // device buffer-size
}
/**
* The sample rate (in sample-frames per second) at which the
* AudioContext handles audio. It is assumed that all AudioNodes
* in the context run at this rate. In making this assumption,
* sample-rate converters or "varispeed" processors are not supported
* in real-time processing.
* The sampleRate parameter describes the sample-rate of the
* linear PCM audio data in the buffer in sample-frames per second.
* An implementation must support sample-rates in at least
* the range 22050 to 96000.
* @property {number} sampleRate - Buffer-size for how frequently the audioprocess event is dispatched.
* @memberof StereoAudioRecorder
* @example
* recorder = new StereoAudioRecorder(mediaStream, {
* sampleRate: 44100
* });
*/
var sampleRate = typeof config.sampleRate !== 'undefined' ? config.sampleRate : context.sampleRate || 44100;
if (sampleRate < 22050 || sampleRate > 96000) {
// Ref: http://stackoverflow.com/a/26303918/552182
if (!config.disableLogs) {
console.log('sample-rate must be under range 22050 and 96000.');
}
}
if (!config.disableLogs) {
if (config.desiredSampRate) {
console.log('Desired sample-rate: ' + config.desiredSampRate);
}
}
var isPaused = false;
/**
* This method pauses the recording process.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.pause();
*/
this.pause = function() {
isPaused = true;
};
/**
* This method resumes the recording process.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.resume();
*/
this.resume = function() {
if (isMediaStreamActive() === false) {
throw 'Please make sure MediaStream is active.';
}
if (!recording) {
if (!config.disableLogs) {
console.log('Seems recording has been restarted.');
}
this.record();
return;
}
isPaused = false;
};
/**
* This method resets currently recorded data.
* @method
* @memberof StereoAudioRecorder
* @example
* recorder.clearRecordedData();
*/
this.clearRecordedData = function() {
config.checkForInactiveTracks = false;
if (recording) {
this.stop(clearRecordedDataCB);
}
clearRecordedDataCB();
};
function resetVariables() {
leftchannel = [];
rightchannel = [];
recordingLength = 0;
isAudioProcessStarted = false;
recording = false;
isPaused = false;
context = null;
self.leftchannel = leftchannel;
self.rightchannel = rightchannel;
self.numberOfAudioChannels = numberOfAudioChannels;
self.desiredSampRate = desiredSampRate;
self.sampleRate = sampleRate;
self.recordingLength = recordingLength;
intervalsBasedBuffers = {
left: [],
right: [],
recordingLength: 0
};
}
function clearRecordedDataCB() {
if (jsAudioNode) {
jsAudioNode.onaudioprocess = null;
jsAudioNode.disconnect();
jsAudioNode = null;
}
if (audioInput) {
audioInput.disconnect();
audioInput = null;
}
resetVariables();
}
// for debugging
this.name = 'StereoAudioRecorder';
this.toString = function() {
return this.name;
};
var isAudioProcessStarted = false;
function onAudioProcessDataAvailable(e) {
if (isPaused) {
return;
}
if (isMediaStreamActive() === false) {
if (!config.disableLogs) {
console.log('MediaStream seems stopped.');
}
jsAudioNode.disconnect();
recording = false;
}
if (!recording) {
if (audioInput) {
audioInput.disconnect();
audioInput = null;
}
return;
}
/**
* This method is called on "onaudioprocess" event's first invocation.
* @method {function} onAudioProcessStarted
* @memberof StereoAudioRecorder
* @example
* recorder.onAudioProcessStarted: function() { };
*/
if (!isAudioProcessStarted) {
isAudioProcessStarted = true;
if (config.onAudioProcessStarted) {
config.onAudioProcessStarted();
}
if (config.initCallback) {
config.initCallback();
}
}
var left = e.inputBuffer.getChannelData(0);
// we clone the samples
var chLeft = new Float32Array(left);
leftchannel.push(chLeft);
if (numberOfAudioChannels === 2) {
var right = e.inputBuffer.getChannelData(1);
var chRight = new Float32Array(right);
rightchannel.push(chRight);
}
recordingLength += bufferSize;
// export raw PCM
self.recordingLength = recordingLength;
if (typeof config.timeSlice !== 'undefined') {
intervalsBasedBuffers.recordingLength += bufferSize;
intervalsBasedBuffers.left.push(chLeft);
if (numberOfAudioChannels === 2) {
intervalsBasedBuffers.right.push(chRight);
}
}
}
jsAudioNode.onaudioprocess = onAudioProcessDataAvailable;
// to prevent self audio to be connected with speakers
if (context.createMediaStreamDestination) {
jsAudioNode.connect(context.createMediaStreamDestination());
} else {
jsAudioNode.connect(context.destination);
}
// export raw PCM
this.leftchannel = leftchannel;
this.rightchannel = rightchannel;
this.numberOfAudioChannels = numberOfAudioChannels;
this.desiredSampRate = desiredSampRate;
this.sampleRate = sampleRate;
self.recordingLength = recordingLength;
// helper for intervals based blobs
var intervalsBasedBuffers = {
left: [],
right: [],
recordingLength: 0
};
// this looper is used to support intervals based blobs (via timeSlice+ondataavailable)
function looper() {
if (!recording || typeof config.ondataavailable !== 'function' || typeof config.timeSlice === 'undefined') {
return;
}
if (intervalsBasedBuffers.left.length) {
mergeLeftRightBuffers({
desiredSampRate: desiredSampRate,
sampleRate: sampleRate,
numberOfAudioChannels: numberOfAudioChannels,
internalInterleavedLength: intervalsBasedBuffers.recordingLength,
leftBuffers: intervalsBasedBuffers.left,
rightBuffers: numberOfAudioChannels === 1 ? [] : intervalsBasedBuffers.right
}, function(buffer, view) {
var blob = new Blob([view], {
type: 'audio/wav'
});
config.ondataavailable(blob);
setTimeout(looper, config.timeSlice);
});
intervalsBasedBuffers = {
left: [],
right: [],
recordingLength: 0
};
} else {
setTimeout(looper, config.timeSlice);
}
}
} | [
"function",
"StereoAudioRecorder",
"(",
"mediaStream",
",",
"config",
")",
"{",
"if",
"(",
"!",
"getTracks",
"(",
"mediaStream",
",",
"'audio'",
")",
".",
"length",
")",
"{",
"throw",
"'Your stream has no audio tracks.'",
";",
"}",
"config",
"=",
"config",
"||... | source code from: http://typedarray.org/wp-content/projects/WebAudioRecorder/script.js https://github.com/mattdiamond/Recorderjs#license-mit ______________________ StereoAudioRecorder.js
StereoAudioRecorder is a standalone class used by {@link RecordRTC} to bring "stereo" audio-recording in chrome.
@summary JavaScript standalone object for stereo audio recording.
@license {@link https://github.com/muaz-khan/RecordRTC#license|MIT}
@author {@link http://www.MuazKhan.com|Muaz Khan}
@typedef StereoAudioRecorder
@class
@example
var recorder = new StereoAudioRecorder(MediaStream, {
sampleRate: 44100,
bufferSize: 4096
});
recorder.record();
recorder.stop(function(blob) {
video.src = URL.createObjectURL(blob);
});
@see {@link https://github.com/muaz-khan/RecordRTC|RecordRTC Source Code}
@param {MediaStream} mediaStream - MediaStream object fetched using getUserMedia API or generated using captureStreamUntilEnded or WebAudio API.
@param {object} config - {sampleRate: 44100, bufferSize: 4096, numberOfAudioChannels: 1, etc.} | [
"source",
"code",
"from",
":",
"http",
":",
"//",
"typedarray",
".",
"org",
"/",
"wp",
"-",
"content",
"/",
"projects",
"/",
"WebAudioRecorder",
"/",
"script",
".",
"js",
"https",
":",
"//",
"github",
".",
"com",
"/",
"mattdiamond",
"/",
"Recorderjs#lice... | 3c6bad427b9da35c1cf617199ed13dda056c38ba | https://github.com/muaz-khan/RecordRTC/blob/3c6bad427b9da35c1cf617199ed13dda056c38ba/RecordRTC.js#L2502-L3189 | train | Stereo Audio recorder | [
30522,
3853,
12991,
19513,
25346,
8586,
8551,
2121,
1006,
2865,
21422,
1010,
9530,
8873,
2290,
1007,
1063,
2065,
1006,
999,
2131,
6494,
10603,
1006,
2865,
21422,
1010,
1005,
5746,
1005,
1007,
1012,
3091,
1007,
1063,
5466,
1005,
2115,
5460,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | third_party/js/mozmill/shared-modules/search.js | function(searchTerm) {
var suggestions = [ ];
var popup = this.getElement({type: "searchBar_autoCompletePopup"});
var treeElem = this.getElement({type: "searchBar_suggestions"});
// Enter search term and wait for the popup
this.type(searchTerm);
this._controller.waitForEval("subject.popup.state == 'open'", TIMEOUT, 100,
{popup: popup.getNode()});
this._controller.waitForElement(treeElem, TIMEOUT);
// Get all suggestions
var tree = treeElem.getNode();
this._controller.waitForEval("subject.tree.view != null", TIMEOUT, 100,
{tree: tree});
for (var i = 0; i < tree.view.rowCount; i ++) {
suggestions.push(tree.view.getCellText(i, tree.columns.getColumnAt(0)));
}
// Close auto-complete popup
this._controller.keypress(popup, "VK_ESCAPE", {});
this._controller.waitForEval("subject.popup.state == 'closed'", TIMEOUT, 100,
{popup: popup.getNode()});
return suggestions;
} | javascript | function(searchTerm) {
var suggestions = [ ];
var popup = this.getElement({type: "searchBar_autoCompletePopup"});
var treeElem = this.getElement({type: "searchBar_suggestions"});
// Enter search term and wait for the popup
this.type(searchTerm);
this._controller.waitForEval("subject.popup.state == 'open'", TIMEOUT, 100,
{popup: popup.getNode()});
this._controller.waitForElement(treeElem, TIMEOUT);
// Get all suggestions
var tree = treeElem.getNode();
this._controller.waitForEval("subject.tree.view != null", TIMEOUT, 100,
{tree: tree});
for (var i = 0; i < tree.view.rowCount; i ++) {
suggestions.push(tree.view.getCellText(i, tree.columns.getColumnAt(0)));
}
// Close auto-complete popup
this._controller.keypress(popup, "VK_ESCAPE", {});
this._controller.waitForEval("subject.popup.state == 'closed'", TIMEOUT, 100,
{popup: popup.getNode()});
return suggestions;
} | [
"function",
"(",
"searchTerm",
")",
"{",
"var",
"suggestions",
"=",
"[",
"]",
";",
"var",
"popup",
"=",
"this",
".",
"getElement",
"(",
"{",
"type",
":",
"\"searchBar_autoCompletePopup\"",
"}",
")",
";",
"var",
"treeElem",
"=",
"this",
".",
"getElement",
... | Returns the search suggestions for the search term | [
"Returns",
"the",
"search",
"suggestions",
"for",
"the",
"search",
"term"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/third_party/js/mozmill/shared-modules/search.js#L674-L700 | train | Get suggestions from the search bar | [
30522,
3853,
1006,
3945,
3334,
2213,
1007,
1063,
13075,
15690,
1027,
1031,
1033,
1025,
13075,
3769,
6279,
1027,
2023,
1012,
2131,
12260,
3672,
1006,
1063,
2828,
1024,
1000,
3945,
8237,
1035,
8285,
9006,
10814,
2618,
16340,
6279,
1000,
1065,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/date/Buddhist.js | toGregorianArguments | function toGregorianArguments(aArgs) {
var oBuddhist, oGregorian;
oBuddhist = {
year: aArgs[0],
month: aArgs[1],
day: aArgs[2] !== undefined ? aArgs[2] : 1
};
oGregorian = toGregorian(oBuddhist);
aArgs[0] = oGregorian.year;
return aArgs;
} | javascript | function toGregorianArguments(aArgs) {
var oBuddhist, oGregorian;
oBuddhist = {
year: aArgs[0],
month: aArgs[1],
day: aArgs[2] !== undefined ? aArgs[2] : 1
};
oGregorian = toGregorian(oBuddhist);
aArgs[0] = oGregorian.year;
return aArgs;
} | [
"function",
"toGregorianArguments",
"(",
"aArgs",
")",
"{",
"var",
"oBuddhist",
",",
"oGregorian",
";",
"oBuddhist",
"=",
"{",
"year",
":",
"aArgs",
"[",
"0",
"]",
",",
"month",
":",
"aArgs",
"[",
"1",
"]",
",",
"day",
":",
"aArgs",
"[",
"2",
"]",
... | Convert arguments array from Buddhist date to gregorian data
@param {object} oBuddhist
@return {int} | [
"Convert",
"arguments",
"array",
"from",
"Buddhist",
"date",
"to",
"gregorian",
"data"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/date/Buddhist.js#L94-L104 | train | Converts arguments to gregorian | [
30522,
3853,
2000,
17603,
20255,
11410,
10623,
27417,
3215,
1006,
9779,
10623,
2015,
1007,
1063,
13075,
27885,
6784,
19114,
3367,
1010,
13958,
2890,
20255,
2937,
1025,
27885,
6784,
19114,
3367,
1027,
1063,
2095,
1024,
9779,
10623,
2015,
1031,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
askmike/gekko | strategies/indicators/LRC.js | linreg | function linreg(values_x, values_y) {
var sum_x = 0;
var sum_y = 0;
var sum_xy = 0;
var sum_xx = 0;
var count = 0;
/*
* We'll use those variables for faster read/write access.
*/
var x = 0;
var y = 0;
var values_length = values_x.length;
if (values_length != values_y.length) {
throw new Error('The parameters values_x and values_y need to have same size!');
}
/*
* Nothing to do.
*/
if (values_length === 0) {
return [ [], [] ];
}
/*
* Calculate the sum for each of the parts necessary.
*/
for (var v = 0; v < values_length; v++) {
x = values_x[v];
y = values_y[v];
sum_x += x;
sum_y += y;
sum_xx += x*x;
sum_xy += x*y;
count++;
}
/*
* Calculate m and b for the formular:
* y = x * m + b
*/
var m = (count*sum_xy - sum_x*sum_y) / (count*sum_xx - sum_x*sum_x);
var b = (sum_y/count) - (m*sum_x)/count;
return [m, b];
} | javascript | function linreg(values_x, values_y) {
var sum_x = 0;
var sum_y = 0;
var sum_xy = 0;
var sum_xx = 0;
var count = 0;
/*
* We'll use those variables for faster read/write access.
*/
var x = 0;
var y = 0;
var values_length = values_x.length;
if (values_length != values_y.length) {
throw new Error('The parameters values_x and values_y need to have same size!');
}
/*
* Nothing to do.
*/
if (values_length === 0) {
return [ [], [] ];
}
/*
* Calculate the sum for each of the parts necessary.
*/
for (var v = 0; v < values_length; v++) {
x = values_x[v];
y = values_y[v];
sum_x += x;
sum_y += y;
sum_xx += x*x;
sum_xy += x*y;
count++;
}
/*
* Calculate m and b for the formular:
* y = x * m + b
*/
var m = (count*sum_xy - sum_x*sum_y) / (count*sum_xx - sum_x*sum_x);
var b = (sum_y/count) - (m*sum_x)/count;
return [m, b];
} | [
"function",
"linreg",
"(",
"values_x",
",",
"values_y",
")",
"{",
"var",
"sum_x",
"=",
"0",
";",
"var",
"sum_y",
"=",
"0",
";",
"var",
"sum_xy",
"=",
"0",
";",
"var",
"sum_xx",
"=",
"0",
";",
"var",
"count",
"=",
"0",
";",
"/*\n * We'll use those... | /*
Least squares linear regression fitting. | [
"/",
"*",
"Least",
"squares",
"linear",
"regression",
"fitting",
"."
] | 0ce9ddd577fa8a22812c02331a494086758dfadf | https://github.com/askmike/gekko/blob/0ce9ddd577fa8a22812c02331a494086758dfadf/strategies/indicators/LRC.js#L54-L100 | train | Calculate the linreg | [
30522,
3853,
11409,
2890,
2290,
1006,
5300,
1035,
1060,
1010,
5300,
1035,
1061,
1007,
1063,
13075,
7680,
1035,
1060,
1027,
1014,
1025,
13075,
7680,
1035,
1061,
1027,
1014,
1025,
13075,
7680,
1035,
1060,
2100,
1027,
1014,
1025,
13075,
7680,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SeleniumHQ/selenium | javascript/selenium-core/scripts/htmlutils.js | function( array, results ) {
var ret = results || [];
if ( array != null ) {
// The window, strings (and functions) also have 'length'
// The extra typeof function check is to prevent crashes
// in Safari 2 (See: #3039)
if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
push.call( ret, array );
} else {
jQuery.merge( ret, array );
}
}
return ret;
} | javascript | function( array, results ) {
var ret = results || [];
if ( array != null ) {
// The window, strings (and functions) also have 'length'
// The extra typeof function check is to prevent crashes
// in Safari 2 (See: #3039)
if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
push.call( ret, array );
} else {
jQuery.merge( ret, array );
}
}
return ret;
} | [
"function",
"(",
"array",
",",
"results",
")",
"{",
"var",
"ret",
"=",
"results",
"||",
"[",
"]",
";",
"if",
"(",
"array",
"!=",
"null",
")",
"{",
"// The window, strings (and functions) also have 'length'",
"// The extra typeof function check is to prevent crashes",
... | results is for internal usage only | [
"results",
"is",
"for",
"internal",
"usage",
"only"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/javascript/selenium-core/scripts/htmlutils.js#L3188-L3203 | train | Returns an array of objects that are not already in the results array. | [
30522,
3853,
1006,
9140,
1010,
3463,
1007,
1063,
13075,
2128,
2102,
1027,
3463,
1064,
1064,
1031,
1033,
1025,
2065,
1006,
9140,
999,
1027,
19701,
1007,
1063,
1013,
1013,
1996,
3332,
1010,
7817,
1006,
1998,
4972,
1007,
2036,
2031,
1005,
30... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.commons/src/sap/ui/commons/MenuBar.js | function(oThis, oEvent, sDir){
oEvent.stopPropagation();
oEvent.preventDefault();
if (!oThis.sCurrentFocusedItemRefId) {
return;
}
var sFollowingFocusItemId = null;
if (oThis.sLastVisibleItemId && ((oThis.sCurrentFocusedItemRefId == oThis.sLastVisibleItemId && sDir == "next") || sDir == "last")) {
sFollowingFocusItemId = oThis.getId() + "-ovrflw";
} else if (oThis.sLastVisibleItemId && oThis.sCurrentFocusedItemRefId == oThis.getId() + "-ovrflw" && sDir == "prev") {
sFollowingFocusItemId = oThis.sLastVisibleItemId;
} else {
var sFoo = sDir + "All";
var bIsJumpToEnd = false;
if (sDir == "first") {
sFoo = "prevAll";
bIsJumpToEnd = true;
} else if (sDir == "last") {
sFoo = "nextAll";
bIsJumpToEnd = true;
}
var jCurrentFocusItem = jQuery(document.getElementById(oThis.sCurrentFocusedItemRefId));
var jFollowingItems = jCurrentFocusItem[sFoo](":visible");
sFollowingFocusItemId = jQuery(jFollowingItems.get(bIsJumpToEnd ? jFollowingItems.length - 1 : 0)).attr("id");
}
if (sFollowingFocusItemId) {
oThis.sCurrentFocusedItemRefId = sFollowingFocusItemId;
document.getElementById(sFollowingFocusItemId).focus();
}
} | javascript | function(oThis, oEvent, sDir){
oEvent.stopPropagation();
oEvent.preventDefault();
if (!oThis.sCurrentFocusedItemRefId) {
return;
}
var sFollowingFocusItemId = null;
if (oThis.sLastVisibleItemId && ((oThis.sCurrentFocusedItemRefId == oThis.sLastVisibleItemId && sDir == "next") || sDir == "last")) {
sFollowingFocusItemId = oThis.getId() + "-ovrflw";
} else if (oThis.sLastVisibleItemId && oThis.sCurrentFocusedItemRefId == oThis.getId() + "-ovrflw" && sDir == "prev") {
sFollowingFocusItemId = oThis.sLastVisibleItemId;
} else {
var sFoo = sDir + "All";
var bIsJumpToEnd = false;
if (sDir == "first") {
sFoo = "prevAll";
bIsJumpToEnd = true;
} else if (sDir == "last") {
sFoo = "nextAll";
bIsJumpToEnd = true;
}
var jCurrentFocusItem = jQuery(document.getElementById(oThis.sCurrentFocusedItemRefId));
var jFollowingItems = jCurrentFocusItem[sFoo](":visible");
sFollowingFocusItemId = jQuery(jFollowingItems.get(bIsJumpToEnd ? jFollowingItems.length - 1 : 0)).attr("id");
}
if (sFollowingFocusItemId) {
oThis.sCurrentFocusedItemRefId = sFollowingFocusItemId;
document.getElementById(sFollowingFocusItemId).focus();
}
} | [
"function",
"(",
"oThis",
",",
"oEvent",
",",
"sDir",
")",
"{",
"oEvent",
".",
"stopPropagation",
"(",
")",
";",
"oEvent",
".",
"preventDefault",
"(",
")",
";",
"if",
"(",
"!",
"oThis",
".",
"sCurrentFocusedItemRefId",
")",
"{",
"return",
";",
"}",
"va... | Focus the next (depending on the given direction) step | [
"Focus",
"the",
"next",
"(",
"depending",
"on",
"the",
"given",
"direction",
")",
"step"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.commons/src/sap/ui/commons/MenuBar.js#L551-L584 | train | This function is called when the user clicks on an item in the list. It is also called by the focusHandler when the item is clicked. | [
30522,
3853,
1006,
27178,
24158,
1010,
1051,
18697,
3372,
1010,
17371,
4313,
1007,
1063,
1051,
18697,
3372,
1012,
2644,
21572,
4502,
12540,
1006,
1007,
1025,
1051,
18697,
3372,
1012,
4652,
3207,
7011,
11314,
1006,
1007,
1025,
2065,
1006,
99... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
akveo/nebular | docs/assets/ghspa.js | resolve | function resolve() {
if (l.search) {
var q = {};
l.search.slice(1).split('&').forEach(function(v) {
var a = v.split('=');
q[a[0]] = a.slice(1).join('=').replace(/~and~/g, '&')
});
if (q.p !== undefined) {
window.history.replaceState(null, null,
repo + (q.p || '') +
(q.q ? ('?' + q.q) : '') +
l.hash
)
}
}
} | javascript | function resolve() {
if (l.search) {
var q = {};
l.search.slice(1).split('&').forEach(function(v) {
var a = v.split('=');
q[a[0]] = a.slice(1).join('=').replace(/~and~/g, '&')
});
if (q.p !== undefined) {
window.history.replaceState(null, null,
repo + (q.p || '') +
(q.q ? ('?' + q.q) : '') +
l.hash
)
}
}
} | [
"function",
"resolve",
"(",
")",
"{",
"if",
"(",
"l",
".",
"search",
")",
"{",
"var",
"q",
"=",
"{",
"}",
";",
"l",
".",
"search",
".",
"slice",
"(",
"1",
")",
".",
"split",
"(",
"'&'",
")",
".",
"forEach",
"(",
"function",
"(",
"v",
")",
"... | /* resolve 404 redirects into internal routes | [
"/",
"*",
"resolve",
"404",
"redirects",
"into",
"internal",
"routes"
] | 6ae213cefd487e3036f933ba24dacf977a0592a5 | https://github.com/akveo/nebular/blob/6ae213cefd487e3036f933ba24dacf977a0592a5/docs/assets/ghspa.js#L38-L53 | train | Resolve the url | [
30522,
3853,
10663,
1006,
1007,
1063,
2065,
1006,
1048,
1012,
3945,
1007,
1063,
13075,
1053,
1027,
1063,
1065,
1025,
1048,
1012,
3945,
1012,
14704,
1006,
1015,
1007,
1012,
3975,
1006,
1005,
1004,
1005,
1007,
1012,
18921,
6776,
1006,
3853,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-use-before-define.js | isForbidden | function isForbidden(variable, reference) {
if (isFunction(variable)) {
return options.functions;
}
if (isOuterClass(variable, reference)) {
return options.classes;
}
if (isOuterVariable(variable, reference)) {
return options.variables;
}
return true;
} | javascript | function isForbidden(variable, reference) {
if (isFunction(variable)) {
return options.functions;
}
if (isOuterClass(variable, reference)) {
return options.classes;
}
if (isOuterVariable(variable, reference)) {
return options.variables;
}
return true;
} | [
"function",
"isForbidden",
"(",
"variable",
",",
"reference",
")",
"{",
"if",
"(",
"isFunction",
"(",
"variable",
")",
")",
"{",
"return",
"options",
".",
"functions",
";",
"}",
"if",
"(",
"isOuterClass",
"(",
"variable",
",",
"reference",
")",
")",
"{",... | Determines whether a given use-before-define case should be reported according to the options.
@param {eslint-scope.Variable} variable The variable that gets used before being defined
@param {eslint-scope.Reference} reference The reference to the variable
@returns {boolean} `true` if the usage should be reported | [
"Determines",
"whether",
"a",
"given",
"use",
"-",
"before",
"-",
"define",
"case",
"should",
"be",
"reported",
"according",
"to",
"the",
"options",
"."
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-use-before-define.js#L177-L188 | train | returns true if variable is forbidden | [
30522,
3853,
2003,
29278,
17062,
4181,
1006,
8023,
1010,
4431,
1007,
1063,
2065,
1006,
2003,
11263,
27989,
1006,
8023,
1007,
1007,
1063,
2709,
7047,
1012,
4972,
1025,
1065,
2065,
1006,
11163,
19901,
26266,
1006,
8023,
1010,
4431,
1007,
1007... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/no-extra-parens.js | checkBinaryLogical | function checkBinaryLogical(node) {
const prec = precedence(node);
const leftPrecedence = precedence(node.left);
const rightPrecedence = precedence(node.right);
const isExponentiation = node.operator === "**";
const shouldSkipLeft = (NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression")) ||
node.left.type === "UnaryExpression" && isExponentiation;
const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression");
if (!shouldSkipLeft && hasExcessParens(node.left) && (leftPrecedence > prec || (leftPrecedence === prec && !isExponentiation))) {
report(node.left);
}
if (!shouldSkipRight && hasExcessParens(node.right) && (rightPrecedence > prec || (rightPrecedence === prec && isExponentiation))) {
report(node.right);
}
} | javascript | function checkBinaryLogical(node) {
const prec = precedence(node);
const leftPrecedence = precedence(node.left);
const rightPrecedence = precedence(node.right);
const isExponentiation = node.operator === "**";
const shouldSkipLeft = (NESTED_BINARY && (node.left.type === "BinaryExpression" || node.left.type === "LogicalExpression")) ||
node.left.type === "UnaryExpression" && isExponentiation;
const shouldSkipRight = NESTED_BINARY && (node.right.type === "BinaryExpression" || node.right.type === "LogicalExpression");
if (!shouldSkipLeft && hasExcessParens(node.left) && (leftPrecedence > prec || (leftPrecedence === prec && !isExponentiation))) {
report(node.left);
}
if (!shouldSkipRight && hasExcessParens(node.right) && (rightPrecedence > prec || (rightPrecedence === prec && isExponentiation))) {
report(node.right);
}
} | [
"function",
"checkBinaryLogical",
"(",
"node",
")",
"{",
"const",
"prec",
"=",
"precedence",
"(",
"node",
")",
";",
"const",
"leftPrecedence",
"=",
"precedence",
"(",
"node",
".",
"left",
")",
";",
"const",
"rightPrecedence",
"=",
"precedence",
"(",
"node",
... | Evaluate binary logicals
@param {ASTNode} node node to evaluate
@returns {void}
@private | [
"Evaluate",
"binary",
"logicals"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/no-extra-parens.js#L410-L425 | train | Check if binary logical expression | [
30522,
3853,
4638,
21114,
23320,
20734,
1006,
13045,
1007,
1063,
9530,
3367,
3653,
2278,
1027,
23359,
1006,
13045,
1007,
1025,
9530,
3367,
2187,
28139,
22119,
5897,
1027,
23359,
1006,
13045,
1012,
2187,
1007,
1025,
9530,
3367,
2157,
28139,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/rules/key-spacing.js | initOptionProperty | function initOptionProperty(toOptions, fromOptions) {
toOptions.mode = fromOptions.mode || "strict";
// Set value of beforeColon
if (typeof fromOptions.beforeColon !== "undefined") {
toOptions.beforeColon = +fromOptions.beforeColon;
} else {
toOptions.beforeColon = 0;
}
// Set value of afterColon
if (typeof fromOptions.afterColon !== "undefined") {
toOptions.afterColon = +fromOptions.afterColon;
} else {
toOptions.afterColon = 1;
}
// Set align if exists
if (typeof fromOptions.align !== "undefined") {
if (typeof fromOptions.align === "object") {
toOptions.align = fromOptions.align;
} else { // "string"
toOptions.align = {
on: fromOptions.align,
mode: toOptions.mode,
beforeColon: toOptions.beforeColon,
afterColon: toOptions.afterColon
};
}
}
return toOptions;
} | javascript | function initOptionProperty(toOptions, fromOptions) {
toOptions.mode = fromOptions.mode || "strict";
// Set value of beforeColon
if (typeof fromOptions.beforeColon !== "undefined") {
toOptions.beforeColon = +fromOptions.beforeColon;
} else {
toOptions.beforeColon = 0;
}
// Set value of afterColon
if (typeof fromOptions.afterColon !== "undefined") {
toOptions.afterColon = +fromOptions.afterColon;
} else {
toOptions.afterColon = 1;
}
// Set align if exists
if (typeof fromOptions.align !== "undefined") {
if (typeof fromOptions.align === "object") {
toOptions.align = fromOptions.align;
} else { // "string"
toOptions.align = {
on: fromOptions.align,
mode: toOptions.mode,
beforeColon: toOptions.beforeColon,
afterColon: toOptions.afterColon
};
}
}
return toOptions;
} | [
"function",
"initOptionProperty",
"(",
"toOptions",
",",
"fromOptions",
")",
"{",
"toOptions",
".",
"mode",
"=",
"fromOptions",
".",
"mode",
"||",
"\"strict\"",
";",
"// Set value of beforeColon",
"if",
"(",
"typeof",
"fromOptions",
".",
"beforeColon",
"!==",
"\"u... | Initializes a single option property from the configuration with defaults for undefined values
@param {Object} toOptions Object to be initialized
@param {Object} fromOptions Object to be initialized from
@returns {Object} The object with correctly initialized options and values | [
"Initializes",
"a",
"single",
"option",
"property",
"from",
"the",
"configuration",
"with",
"defaults",
"for",
"undefined",
"values"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/key-spacing.js#L51-L83 | train | Initialize the options object | [
30522,
3853,
1999,
9956,
16790,
21572,
4842,
3723,
1006,
2205,
16790,
2015,
30524,
2239,
2065,
1006,
2828,
11253,
2013,
7361,
9285,
1012,
2077,
25778,
2239,
999,
1027,
1027,
1000,
6151,
28344,
1000,
1007,
1063,
2205,
16790,
2015,
1012,
2077... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/components/sticky/sticky.js | onScroll | function onScroll() {
var scrollTop = contentEl.prop('scrollTop');
var isScrollingDown = scrollTop > (onScroll.prevScrollTop || 0);
// Store the previous scroll so we know which direction we are scrolling
onScroll.prevScrollTop = scrollTop;
//
// AT TOP (not scrolling)
//
if (scrollTop === 0) {
// If we're at the top, just clear the current item and return
setCurrentItem(null);
return;
}
//
// SCROLLING DOWN (going towards the next item)
//
if (isScrollingDown) {
// If we've scrolled down past the next item's position, sticky it and return
if (self.next && self.next.top <= scrollTop) {
setCurrentItem(self.next);
return;
}
// If the next item is close to the current one, push the current one up out of the way
if (self.current && self.next && self.next.top - scrollTop <= self.next.height) {
translate(self.current, scrollTop + (self.next.top - self.next.height - scrollTop));
return;
}
}
//
// SCROLLING UP (not at the top & not scrolling down; must be scrolling up)
//
if (!isScrollingDown) {
// If we've scrolled up past the previous item's position, sticky it and return
if (self.current && self.prev && scrollTop < self.current.top) {
setCurrentItem(self.prev);
return;
}
// If the next item is close to the current one, pull the current one down into view
if (self.next && self.current && (scrollTop >= (self.next.top - self.current.height))) {
translate(self.current, scrollTop + (self.next.top - scrollTop - self.current.height));
return;
}
}
//
// Otherwise, just move the current item to the proper place (scrolling up or down)
//
if (self.current) {
translate(self.current, scrollTop);
}
} | javascript | function onScroll() {
var scrollTop = contentEl.prop('scrollTop');
var isScrollingDown = scrollTop > (onScroll.prevScrollTop || 0);
// Store the previous scroll so we know which direction we are scrolling
onScroll.prevScrollTop = scrollTop;
//
// AT TOP (not scrolling)
//
if (scrollTop === 0) {
// If we're at the top, just clear the current item and return
setCurrentItem(null);
return;
}
//
// SCROLLING DOWN (going towards the next item)
//
if (isScrollingDown) {
// If we've scrolled down past the next item's position, sticky it and return
if (self.next && self.next.top <= scrollTop) {
setCurrentItem(self.next);
return;
}
// If the next item is close to the current one, push the current one up out of the way
if (self.current && self.next && self.next.top - scrollTop <= self.next.height) {
translate(self.current, scrollTop + (self.next.top - self.next.height - scrollTop));
return;
}
}
//
// SCROLLING UP (not at the top & not scrolling down; must be scrolling up)
//
if (!isScrollingDown) {
// If we've scrolled up past the previous item's position, sticky it and return
if (self.current && self.prev && scrollTop < self.current.top) {
setCurrentItem(self.prev);
return;
}
// If the next item is close to the current one, pull the current one down into view
if (self.next && self.current && (scrollTop >= (self.next.top - self.current.height))) {
translate(self.current, scrollTop + (self.next.top - scrollTop - self.current.height));
return;
}
}
//
// Otherwise, just move the current item to the proper place (scrolling up or down)
//
if (self.current) {
translate(self.current, scrollTop);
}
} | [
"function",
"onScroll",
"(",
")",
"{",
"var",
"scrollTop",
"=",
"contentEl",
".",
"prop",
"(",
"'scrollTop'",
")",
";",
"var",
"isScrollingDown",
"=",
"scrollTop",
">",
"(",
"onScroll",
".",
"prevScrollTop",
"||",
"0",
")",
";",
"// Store the previous scroll s... | As we scroll, push in and select the correct sticky element. | [
"As",
"we",
"scroll",
"push",
"in",
"and",
"select",
"the",
"correct",
"sticky",
"element",
"."
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/components/sticky/sticky.js#L211-L269 | train | The function that is called when the user scrolls the content. | [
30522,
3853,
2006,
11020,
28402,
1006,
1007,
1063,
13075,
17186,
14399,
1027,
4180,
2884,
1012,
17678,
1006,
1005,
17186,
14399,
1005,
1007,
1025,
13075,
26354,
26775,
14511,
2075,
7698,
1027,
17186,
14399,
1028,
1006,
2006,
11020,
28402,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
getinsomnia/insomnia | packages/insomnia-app/app/ui/components/codemirror/extensions/autocomplete.js | replaceHintMatch | function replaceHintMatch(cm, self, data) {
const cur = cm.getCursor();
const from = CodeMirror.Pos(cur.line, cur.ch - data.segment.length);
const to = CodeMirror.Pos(cur.line, cur.ch);
const prevStart = CodeMirror.Pos(from.line, from.ch - 10);
const prevChars = cm.getRange(prevStart, from);
const nextEnd = CodeMirror.Pos(to.line, to.ch + 10);
const nextChars = cm.getRange(to, nextEnd);
let prefix = '';
let suffix = '';
if (data.type === TYPE_VARIABLE && !prevChars.match(/{{[^}]*$/)) {
prefix = '{{ '; // If no closer before
} else if (data.type === TYPE_VARIABLE && prevChars.match(/{{$/)) {
prefix = ' '; // If no space after opener
} else if (data.type === TYPE_TAG && prevChars.match(/{%$/)) {
prefix = ' '; // If no space after opener
} else if (data.type === TYPE_TAG && !prevChars.match(/{%[^%]*$/)) {
prefix = '{% '; // If no closer before
}
if (data.type === TYPE_VARIABLE && !nextChars.match(/^\s*}}/)) {
suffix = ' }}'; // If no closer after
} else if (data.type === TYPE_VARIABLE && nextChars.match(/^}}/)) {
suffix = ' '; // If no space before closer
} else if (data.type === TYPE_TAG && nextChars.match(/^%}/)) {
suffix = ' '; // If no space before closer
} else if (data.type === TYPE_TAG && nextChars.match(/^\s*}/)) {
// Edge case because "%" doesn't auto-close tags so sometimes you end
// up in the scenario of {% foo}
suffix = ' %';
} else if (data.type === TYPE_TAG && !nextChars.match(/^\s*%}/)) {
suffix = ' %}'; // If no closer after
}
cm.replaceRange(`${prefix}${data.text}${suffix}`, from, to);
} | javascript | function replaceHintMatch(cm, self, data) {
const cur = cm.getCursor();
const from = CodeMirror.Pos(cur.line, cur.ch - data.segment.length);
const to = CodeMirror.Pos(cur.line, cur.ch);
const prevStart = CodeMirror.Pos(from.line, from.ch - 10);
const prevChars = cm.getRange(prevStart, from);
const nextEnd = CodeMirror.Pos(to.line, to.ch + 10);
const nextChars = cm.getRange(to, nextEnd);
let prefix = '';
let suffix = '';
if (data.type === TYPE_VARIABLE && !prevChars.match(/{{[^}]*$/)) {
prefix = '{{ '; // If no closer before
} else if (data.type === TYPE_VARIABLE && prevChars.match(/{{$/)) {
prefix = ' '; // If no space after opener
} else if (data.type === TYPE_TAG && prevChars.match(/{%$/)) {
prefix = ' '; // If no space after opener
} else if (data.type === TYPE_TAG && !prevChars.match(/{%[^%]*$/)) {
prefix = '{% '; // If no closer before
}
if (data.type === TYPE_VARIABLE && !nextChars.match(/^\s*}}/)) {
suffix = ' }}'; // If no closer after
} else if (data.type === TYPE_VARIABLE && nextChars.match(/^}}/)) {
suffix = ' '; // If no space before closer
} else if (data.type === TYPE_TAG && nextChars.match(/^%}/)) {
suffix = ' '; // If no space before closer
} else if (data.type === TYPE_TAG && nextChars.match(/^\s*}/)) {
// Edge case because "%" doesn't auto-close tags so sometimes you end
// up in the scenario of {% foo}
suffix = ' %';
} else if (data.type === TYPE_TAG && !nextChars.match(/^\s*%}/)) {
suffix = ' %}'; // If no closer after
}
cm.replaceRange(`${prefix}${data.text}${suffix}`, from, to);
} | [
"function",
"replaceHintMatch",
"(",
"cm",
",",
"self",
",",
"data",
")",
"{",
"const",
"cur",
"=",
"cm",
".",
"getCursor",
"(",
")",
";",
"const",
"from",
"=",
"CodeMirror",
".",
"Pos",
"(",
"cur",
".",
"line",
",",
"cur",
".",
"ch",
"-",
"data",
... | Replace the text in the editor when a hint is selected.
This also makes sure there is whitespace surrounding it
@param cm
@param self
@param data | [
"Replace",
"the",
"text",
"in",
"the",
"editor",
"when",
"a",
"hint",
"is",
"selected",
".",
"This",
"also",
"makes",
"sure",
"there",
"is",
"whitespace",
"surrounding",
"it"
] | e24ce7f7b41246e700c4b9bdb6b34b6652ad589b | https://github.com/getinsomnia/insomnia/blob/e24ce7f7b41246e700c4b9bdb6b34b6652ad589b/packages/insomnia-app/app/ui/components/codemirror/extensions/autocomplete.js#L298-L337 | train | Replace the hint with the correct value | [
30522,
3853,
5672,
10606,
29418,
10649,
1006,
4642,
1010,
2969,
1010,
2951,
1007,
1063,
9530,
3367,
12731,
2099,
1027,
4642,
1012,
2131,
10841,
25301,
2099,
1006,
1007,
1025,
9530,
3367,
2013,
1027,
3642,
14503,
29165,
1012,
13433,
2015,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/StaticServer/StaticServer.js | StaticServer | function StaticServer(config) {
this._nodeDomain = config.nodeDomain;
this._onRequestFilter = this._onRequestFilter.bind(this);
BaseServer.call(this, config);
} | javascript | function StaticServer(config) {
this._nodeDomain = config.nodeDomain;
this._onRequestFilter = this._onRequestFilter.bind(this);
BaseServer.call(this, config);
} | [
"function",
"StaticServer",
"(",
"config",
")",
"{",
"this",
".",
"_nodeDomain",
"=",
"config",
".",
"nodeDomain",
";",
"this",
".",
"_onRequestFilter",
"=",
"this",
".",
"_onRequestFilter",
".",
"bind",
"(",
"this",
")",
";",
"BaseServer",
".",
"call",
"(... | @constructor
@extends {BaseServer}
Live preview server that uses a built-in HTTP server to serve static
and instrumented files.
@param {!{baseUrl: string, root: string, pathResolver: function(string), nodeDomain: NodeDomain}} config
Configuration parameters for this server:
baseUrl - Optional base URL (populated by the current project)
pathResolver - Function to covert absolute native paths to project relative paths
root - Native path to the project root (and base URL)
nodeDomain - An initialized NodeDomain | [
"@constructor",
"@extends",
"{",
"BaseServer",
"}",
"Live",
"preview",
"server",
"that",
"uses",
"a",
"built",
"-",
"in",
"HTTP",
"server",
"to",
"serve",
"static",
"and",
"instrumented",
"files",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/StaticServer/StaticServer.js#L57-L62 | train | StaticServer constructor. | [
30522,
3853,
10763,
8043,
6299,
1006,
9530,
8873,
2290,
1007,
1063,
2023,
1012,
1035,
13045,
9527,
8113,
1027,
9530,
8873,
2290,
1012,
13045,
9527,
8113,
1025,
2023,
1012,
1035,
2006,
2890,
15500,
8873,
21928,
1027,
2023,
1012,
1035,
2006,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
muaz-khan/RecordRTC | RecordRTC.js | function() {
var self = this;
if (typeof indexedDB === 'undefined' || typeof indexedDB.open === 'undefined') {
console.error('IndexedDB API are not available in this browser.');
return;
}
var dbVersion = 1;
var dbName = this.dbName || location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''),
db;
var request = indexedDB.open(dbName, dbVersion);
function createObjectStore(dataBase) {
dataBase.createObjectStore(self.dataStoreName);
}
function putInDB() {
var transaction = db.transaction([self.dataStoreName], 'readwrite');
if (self.videoBlob) {
transaction.objectStore(self.dataStoreName).put(self.videoBlob, 'videoBlob');
}
if (self.gifBlob) {
transaction.objectStore(self.dataStoreName).put(self.gifBlob, 'gifBlob');
}
if (self.audioBlob) {
transaction.objectStore(self.dataStoreName).put(self.audioBlob, 'audioBlob');
}
function getFromStore(portionName) {
transaction.objectStore(self.dataStoreName).get(portionName).onsuccess = function(event) {
if (self.callback) {
self.callback(event.target.result, portionName);
}
};
}
getFromStore('audioBlob');
getFromStore('videoBlob');
getFromStore('gifBlob');
}
request.onerror = self.onError;
request.onsuccess = function() {
db = request.result;
db.onerror = self.onError;
if (db.setVersion) {
if (db.version !== dbVersion) {
var setVersion = db.setVersion(dbVersion);
setVersion.onsuccess = function() {
createObjectStore(db);
putInDB();
};
} else {
putInDB();
}
} else {
putInDB();
}
};
request.onupgradeneeded = function(event) {
createObjectStore(event.target.result);
};
} | javascript | function() {
var self = this;
if (typeof indexedDB === 'undefined' || typeof indexedDB.open === 'undefined') {
console.error('IndexedDB API are not available in this browser.');
return;
}
var dbVersion = 1;
var dbName = this.dbName || location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''),
db;
var request = indexedDB.open(dbName, dbVersion);
function createObjectStore(dataBase) {
dataBase.createObjectStore(self.dataStoreName);
}
function putInDB() {
var transaction = db.transaction([self.dataStoreName], 'readwrite');
if (self.videoBlob) {
transaction.objectStore(self.dataStoreName).put(self.videoBlob, 'videoBlob');
}
if (self.gifBlob) {
transaction.objectStore(self.dataStoreName).put(self.gifBlob, 'gifBlob');
}
if (self.audioBlob) {
transaction.objectStore(self.dataStoreName).put(self.audioBlob, 'audioBlob');
}
function getFromStore(portionName) {
transaction.objectStore(self.dataStoreName).get(portionName).onsuccess = function(event) {
if (self.callback) {
self.callback(event.target.result, portionName);
}
};
}
getFromStore('audioBlob');
getFromStore('videoBlob');
getFromStore('gifBlob');
}
request.onerror = self.onError;
request.onsuccess = function() {
db = request.result;
db.onerror = self.onError;
if (db.setVersion) {
if (db.version !== dbVersion) {
var setVersion = db.setVersion(dbVersion);
setVersion.onsuccess = function() {
createObjectStore(db);
putInDB();
};
} else {
putInDB();
}
} else {
putInDB();
}
};
request.onupgradeneeded = function(event) {
createObjectStore(event.target.result);
};
} | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"if",
"(",
"typeof",
"indexedDB",
"===",
"'undefined'",
"||",
"typeof",
"indexedDB",
".",
"open",
"===",
"'undefined'",
")",
"{",
"console",
".",
"error",
"(",
"'IndexedDB API are not available in thi... | This method must be called once to initialize IndexedDB ObjectStore. Though, it is auto-used internally.
@method
@memberof DiskStorage
@internal
@example
DiskStorage.init(); | [
"This",
"method",
"must",
"be",
"called",
"once",
"to",
"initialize",
"IndexedDB",
"ObjectStore",
".",
"Though",
"it",
"is",
"auto",
"-",
"used",
"internally",
"."
] | 3c6bad427b9da35c1cf617199ed13dda056c38ba | https://github.com/muaz-khan/RecordRTC/blob/3c6bad427b9da35c1cf617199ed13dda056c38ba/RecordRTC.js#L4388-L4456 | train | Create the database | [
30522,
3853,
1006,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
2065,
1006,
2828,
11253,
25331,
18939,
1027,
1027,
1027,
1005,
6151,
28344,
1005,
1064,
1064,
2828,
11253,
25331,
18939,
1012,
2330,
1027,
1027,
1027,
1005,
6151,
28344,
1005,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js | _getElementTreeRightColumnOfListItem | function _getElementTreeRightColumnOfListItem(control, numberOfIssues) {
var splitControlName = control.name.split(".");
var name = splitControlName[splitControlName.length - 1];
var nameSpace = control.name.replace(name, "");
var hideShowClass = (numberOfIssues > 0) ? "showNumbOfIssues" : "hideNumbOfIssues";
return "<tag data-search=\"" + control.name + control.id + "\">" +
"<" +
"<namespace>" + nameSpace + "</namespace>" +
name +
"<attribute> id=\"<attribute-value>" + control.id + "</attribute-value>\"</attribute>" +
">" +
"</tag>" + "<span class = " + hideShowClass + ">[" + numberOfIssues + " issue(s)] </span>";
} | javascript | function _getElementTreeRightColumnOfListItem(control, numberOfIssues) {
var splitControlName = control.name.split(".");
var name = splitControlName[splitControlName.length - 1];
var nameSpace = control.name.replace(name, "");
var hideShowClass = (numberOfIssues > 0) ? "showNumbOfIssues" : "hideNumbOfIssues";
return "<tag data-search=\"" + control.name + control.id + "\">" +
"<" +
"<namespace>" + nameSpace + "</namespace>" +
name +
"<attribute> id=\"<attribute-value>" + control.id + "</attribute-value>\"</attribute>" +
">" +
"</tag>" + "<span class = " + hideShowClass + ">[" + numberOfIssues + " issue(s)] </span>";
} | [
"function",
"_getElementTreeRightColumnOfListItem",
"(",
"control",
",",
"numberOfIssues",
")",
"{",
"var",
"splitControlName",
"=",
"control",
".",
"name",
".",
"split",
"(",
"\".\"",
")",
";",
"var",
"name",
"=",
"splitControlName",
"[",
"splitControlName",
".",... | Create HTML for the right part of the ElementTree list item.
@param {Object} control - JSON object form {ElementTreeOptions.controls}
@returns {string}
@private | [
"Create",
"HTML",
"for",
"the",
"right",
"part",
"of",
"the",
"ElementTree",
"list",
"item",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.support/src/sap/ui/support/supportRules/ui/external/ElementTree.js#L80-L93 | train | Returns the right column of the list item | [
30522,
3853,
1035,
2131,
12260,
3672,
13334,
15950,
25778,
2819,
3630,
10258,
2923,
4221,
2213,
1006,
2491,
1010,
2193,
11253,
14643,
15808,
1007,
1063,
13075,
3975,
8663,
13181,
19666,
14074,
1027,
2491,
1012,
2171,
1012,
3975,
1006,
1000,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dcloudio/mui | examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js | function (i)
{
var self = this;
var req = this._requests[i];
var reqStatus = -1;
try {
if (req.xhr.readyState == 4) {
reqStatus = req.xhr.status;
}
} catch (e) {
Strophe.error("caught an error in _requests[" + i +
"], reqStatus: " + reqStatus);
}
if (typeof(reqStatus) == "undefined") {
reqStatus = -1;
}
// make sure we limit the number of retries
if (req.sends > this._conn.maxRetries) {
this._conn._onDisconnectTimeout();
return;
}
var time_elapsed = req.age();
var primaryTimeout = (!isNaN(time_elapsed) &&
time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait));
var secondaryTimeout = (req.dead !== null &&
req.timeDead() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait));
var requestCompletedWithServerError = (req.xhr.readyState == 4 &&
(reqStatus < 1 ||
reqStatus >= 500));
if (primaryTimeout || secondaryTimeout ||
requestCompletedWithServerError) {
if (secondaryTimeout) {
Strophe.error("Request " +
this._requests[i].id +
" timed out (secondary), restarting");
}
req.abort = true;
req.xhr.abort();
// setting to null fails on IE6, so set to empty function
req.xhr.onreadystatechange = function () {};
this._requests[i] = new Strophe.Request(req.xmlData,
req.origFunc,
req.rid,
req.sends);
req = this._requests[i];
}
if (req.xhr.readyState === 0) {
Strophe.debug("request id " + req.id +
"." + req.sends + " posting");
try {
req.xhr.open("POST", this._conn.service, this._conn.options.sync ? false : true);
req.xhr.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
} catch (e2) {
Strophe.error("XHR open failed.");
if (!this._conn.connected) {
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,
"bad-service");
}
this._conn.disconnect();
return;
}
// Fires the XHR request -- may be invoked immediately
// or on a gradually expanding retry window for reconnects
var sendFunc = function () {
req.date = new Date();
if (self._conn.options.customHeaders){
var headers = self._conn.options.customHeaders;
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
req.xhr.setRequestHeader(header, headers[header]);
}
}
}
req.xhr.send(req.data);
};
// Implement progressive backoff for reconnects --
// First retry (send == 1) should also be instantaneous
if (req.sends > 1) {
// Using a cube of the retry number creates a nicely
// expanding retry window
var backoff = Math.min(Math.floor(Strophe.TIMEOUT * this.wait),
Math.pow(req.sends, 3)) * 1000;
setTimeout(sendFunc, backoff);
} else {
sendFunc();
}
req.sends++;
if (this._conn.xmlOutput !== Strophe.Connection.prototype.xmlOutput) {
if (req.xmlData.nodeName === this.strip && req.xmlData.childNodes.length) {
this._conn.xmlOutput(req.xmlData.childNodes[0]);
} else {
this._conn.xmlOutput(req.xmlData);
}
}
if (this._conn.rawOutput !== Strophe.Connection.prototype.rawOutput) {
this._conn.rawOutput(req.data);
}
} else {
Strophe.debug("_processRequest: " +
(i === 0 ? "first" : "second") +
" request has readyState of " +
req.xhr.readyState);
}
} | javascript | function (i)
{
var self = this;
var req = this._requests[i];
var reqStatus = -1;
try {
if (req.xhr.readyState == 4) {
reqStatus = req.xhr.status;
}
} catch (e) {
Strophe.error("caught an error in _requests[" + i +
"], reqStatus: " + reqStatus);
}
if (typeof(reqStatus) == "undefined") {
reqStatus = -1;
}
// make sure we limit the number of retries
if (req.sends > this._conn.maxRetries) {
this._conn._onDisconnectTimeout();
return;
}
var time_elapsed = req.age();
var primaryTimeout = (!isNaN(time_elapsed) &&
time_elapsed > Math.floor(Strophe.TIMEOUT * this.wait));
var secondaryTimeout = (req.dead !== null &&
req.timeDead() > Math.floor(Strophe.SECONDARY_TIMEOUT * this.wait));
var requestCompletedWithServerError = (req.xhr.readyState == 4 &&
(reqStatus < 1 ||
reqStatus >= 500));
if (primaryTimeout || secondaryTimeout ||
requestCompletedWithServerError) {
if (secondaryTimeout) {
Strophe.error("Request " +
this._requests[i].id +
" timed out (secondary), restarting");
}
req.abort = true;
req.xhr.abort();
// setting to null fails on IE6, so set to empty function
req.xhr.onreadystatechange = function () {};
this._requests[i] = new Strophe.Request(req.xmlData,
req.origFunc,
req.rid,
req.sends);
req = this._requests[i];
}
if (req.xhr.readyState === 0) {
Strophe.debug("request id " + req.id +
"." + req.sends + " posting");
try {
req.xhr.open("POST", this._conn.service, this._conn.options.sync ? false : true);
req.xhr.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
} catch (e2) {
Strophe.error("XHR open failed.");
if (!this._conn.connected) {
this._conn._changeConnectStatus(Strophe.Status.CONNFAIL,
"bad-service");
}
this._conn.disconnect();
return;
}
// Fires the XHR request -- may be invoked immediately
// or on a gradually expanding retry window for reconnects
var sendFunc = function () {
req.date = new Date();
if (self._conn.options.customHeaders){
var headers = self._conn.options.customHeaders;
for (var header in headers) {
if (headers.hasOwnProperty(header)) {
req.xhr.setRequestHeader(header, headers[header]);
}
}
}
req.xhr.send(req.data);
};
// Implement progressive backoff for reconnects --
// First retry (send == 1) should also be instantaneous
if (req.sends > 1) {
// Using a cube of the retry number creates a nicely
// expanding retry window
var backoff = Math.min(Math.floor(Strophe.TIMEOUT * this.wait),
Math.pow(req.sends, 3)) * 1000;
setTimeout(sendFunc, backoff);
} else {
sendFunc();
}
req.sends++;
if (this._conn.xmlOutput !== Strophe.Connection.prototype.xmlOutput) {
if (req.xmlData.nodeName === this.strip && req.xmlData.childNodes.length) {
this._conn.xmlOutput(req.xmlData.childNodes[0]);
} else {
this._conn.xmlOutput(req.xmlData);
}
}
if (this._conn.rawOutput !== Strophe.Connection.prototype.rawOutput) {
this._conn.rawOutput(req.data);
}
} else {
Strophe.debug("_processRequest: " +
(i === 0 ? "first" : "second") +
" request has readyState of " +
req.xhr.readyState);
}
} | [
"function",
"(",
"i",
")",
"{",
"var",
"self",
"=",
"this",
";",
"var",
"req",
"=",
"this",
".",
"_requests",
"[",
"i",
"]",
";",
"var",
"reqStatus",
"=",
"-",
"1",
";",
"try",
"{",
"if",
"(",
"req",
".",
"xhr",
".",
"readyState",
"==",
"4",
... | PrivateFunction: _processRequest
_Private_ function to process a request in the queue.
This function takes requests off the queue and sends them and
restarts dead requests.
Parameters:
(Integer) i - The index of the request in the queue. | [
"PrivateFunction",
":",
"_processRequest",
"_Private_",
"function",
"to",
"process",
"a",
"request",
"in",
"the",
"queue",
"."
] | ff74c90a1671a552f3604b1288bf38a4126312d0 | https://github.com/dcloudio/mui/blob/ff74c90a1671a552f3604b1288bf38a4126312d0/examples/login/libs/easymob-webim-sdk/strophe-custom-2.0.0.js#L4455-L4568 | train | Returns a new instance of the TOTAL_CACHE_RECORD class | [
30522,
3853,
1006,
1045,
1007,
1063,
13075,
2969,
1027,
2023,
1025,
13075,
2128,
4160,
1027,
2023,
1012,
1035,
11186,
1031,
1045,
1033,
1025,
13075,
2128,
4160,
9153,
5809,
1027,
1011,
1015,
1025,
3046,
1063,
2065,
1006,
2128,
4160,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/model/odata/v4/ODataContextBinding.js | getReturnValueContextPath | function getReturnValueContextPath(sPath, sResponsePredicate) {
var sBoundParameterPath = sPath.slice(0, sPath.lastIndexOf("/")),
i = sBoundParameterPath.indexOf("(");
return (i < 0 ? sBoundParameterPath : sPath.slice(0, i)) + sResponsePredicate;
} | javascript | function getReturnValueContextPath(sPath, sResponsePredicate) {
var sBoundParameterPath = sPath.slice(0, sPath.lastIndexOf("/")),
i = sBoundParameterPath.indexOf("(");
return (i < 0 ? sBoundParameterPath : sPath.slice(0, i)) + sResponsePredicate;
} | [
"function",
"getReturnValueContextPath",
"(",
"sPath",
",",
"sResponsePredicate",
")",
"{",
"var",
"sBoundParameterPath",
"=",
"sPath",
".",
"slice",
"(",
"0",
",",
"sPath",
".",
"lastIndexOf",
"(",
"\"/\"",
")",
")",
",",
"i",
"=",
"sBoundParameterPath",
".",... | Returns the path for the return value context. Supports bound operations on an entity or a
collection.
@param {string} sPath
The bindings's path; either a resolved model path or a resource path; for example:
"Artists(ArtistID='42',IsActiveEntity=true)/special.cases.EditAction(...)" or
"/Artists(ArtistID='42',IsActiveEntity=true)/special.cases.EditAction(...)" or
"Artists/special.cases.Create(...)" or "/Artists/special.cases.Create(...)"
@param {string} sResponsePredicate The key predicate of the response entity
@returns {string} The path for the return value context. | [
"Returns",
"the",
"path",
"for",
"the",
"return",
"value",
"context",
".",
"Supports",
"bound",
"operations",
"on",
"an",
"entity",
"or",
"a",
"collection",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/model/odata/v4/ODataContextBinding.js#L44-L49 | train | Returns the context path for the given path and response predicate. | [
30522,
3853,
2131,
13465,
14287,
10175,
5657,
8663,
18209,
15069,
1006,
14690,
2232,
1010,
5034,
2229,
26029,
3366,
28139,
16467,
1007,
1063,
13075,
24829,
28819,
28689,
22828,
15069,
1027,
14690,
2232,
1012,
14704,
1006,
1014,
1010,
14690,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
jhipster/generator-jhipster | generators/aws-containers/aws-client.js | listSubnets | function listSubnets(vpcId) {
const params = {
Filters: [
{
Name: 'vpc-id',
Values: [vpcId]
},
{
Name: 'state',
Values: ['available']
}
]
};
return spinner(
ec2
.describeSubnets(params)
.promise()
.then(data => data.Subnets)
);
} | javascript | function listSubnets(vpcId) {
const params = {
Filters: [
{
Name: 'vpc-id',
Values: [vpcId]
},
{
Name: 'state',
Values: ['available']
}
]
};
return spinner(
ec2
.describeSubnets(params)
.promise()
.then(data => data.Subnets)
);
} | [
"function",
"listSubnets",
"(",
"vpcId",
")",
"{",
"const",
"params",
"=",
"{",
"Filters",
":",
"[",
"{",
"Name",
":",
"'vpc-id'",
",",
"Values",
":",
"[",
"vpcId",
"]",
"}",
",",
"{",
"Name",
":",
"'state'",
",",
"Values",
":",
"[",
"'available'",
... | listSubnets() returns a Promise, which resolves to an array of
Subnets available within the supplied VPC ID
@param vpcId of the VPC with the subnets
@returns {Promise<EC2.Subnet[]>} | [
"listSubnets",
"()",
"returns",
"a",
"Promise",
"which",
"resolves",
"to",
"an",
"array",
"of",
"Subnets",
"available",
"within",
"the",
"supplied",
"VPC",
"ID"
] | f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff | https://github.com/jhipster/generator-jhipster/blob/f76fa8de0818ce6bda6c7b1455942e2a9b0ae3ff/generators/aws-containers/aws-client.js#L169-L188 | train | List all the subnets in a region | [
30522,
3853,
7201,
12083,
22781,
1006,
21210,
6895,
2094,
1007,
1063,
9530,
3367,
11498,
5244,
1027,
1063,
17736,
1024,
1031,
1063,
2171,
1024,
1005,
21210,
2278,
1011,
8909,
1005,
1010,
5300,
1024,
1031,
21210,
6895,
2094,
1033,
1065,
1010... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
GitbookIO/gitbook | lib/output/json/onFinish.js | onFinish | function onFinish(output) {
var book = output.getBook();
var outputRoot = output.getRoot();
if (!book.isMultilingual()) {
return Promise(output);
}
// Get main language
var languages = book.getLanguages();
var mainLanguage = languages.getDefaultLanguage();
// Read the main JSON
return fs.readFile(path.resolve(outputRoot, mainLanguage.getID(), 'README.json'), 'utf8')
// Extend the JSON
.then(function(content) {
var json = JSON.parse(content);
json.languages = JSONUtils.encodeLanguages(languages);
return json;
})
.then(function(json) {
return fs.writeFile(
path.resolve(outputRoot, 'README.json'),
JSON.stringify(json, null, 4)
);
})
.thenResolve(output);
} | javascript | function onFinish(output) {
var book = output.getBook();
var outputRoot = output.getRoot();
if (!book.isMultilingual()) {
return Promise(output);
}
// Get main language
var languages = book.getLanguages();
var mainLanguage = languages.getDefaultLanguage();
// Read the main JSON
return fs.readFile(path.resolve(outputRoot, mainLanguage.getID(), 'README.json'), 'utf8')
// Extend the JSON
.then(function(content) {
var json = JSON.parse(content);
json.languages = JSONUtils.encodeLanguages(languages);
return json;
})
.then(function(json) {
return fs.writeFile(
path.resolve(outputRoot, 'README.json'),
JSON.stringify(json, null, 4)
);
})
.thenResolve(output);
} | [
"function",
"onFinish",
"(",
"output",
")",
"{",
"var",
"book",
"=",
"output",
".",
"getBook",
"(",
")",
";",
"var",
"outputRoot",
"=",
"output",
".",
"getRoot",
"(",
")",
";",
"if",
"(",
"!",
"book",
".",
"isMultilingual",
"(",
")",
")",
"{",
"ret... | Finish the generation
@param {Output}
@return {Output} | [
"Finish",
"the",
"generation"
] | 6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4 | https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/json/onFinish.js#L13-L45 | train | Finish processing the log file | [
30522,
3853,
2006,
16294,
4509,
1006,
6434,
1007,
1063,
13075,
2338,
1027,
6434,
1012,
2131,
8654,
1006,
1007,
1025,
13075,
6434,
3217,
4140,
1027,
6434,
1012,
2131,
3217,
4140,
1006,
1007,
1025,
2065,
1006,
999,
2338,
1012,
2003,
12274,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/delegate/ScrollEnablement.js | function(vElement) {
// check if vElement is a DOM element and if yes convert it to jQuery object
var $Element = vElement instanceof jQuery ? vElement : jQuery(vElement),
oElementPosition = $Element.position(),
$OffsetParent = $Element.offsetParent(),
oAddUpPosition;
while (!$OffsetParent.is(this._$Container)) {
oAddUpPosition = $OffsetParent.position();
oElementPosition.top += oAddUpPosition.top;
oElementPosition.left += oAddUpPosition.left;
$OffsetParent = $OffsetParent.offsetParent();
}
return oElementPosition;
} | javascript | function(vElement) {
// check if vElement is a DOM element and if yes convert it to jQuery object
var $Element = vElement instanceof jQuery ? vElement : jQuery(vElement),
oElementPosition = $Element.position(),
$OffsetParent = $Element.offsetParent(),
oAddUpPosition;
while (!$OffsetParent.is(this._$Container)) {
oAddUpPosition = $OffsetParent.position();
oElementPosition.top += oAddUpPosition.top;
oElementPosition.left += oAddUpPosition.left;
$OffsetParent = $OffsetParent.offsetParent();
}
return oElementPosition;
} | [
"function",
"(",
"vElement",
")",
"{",
"// check if vElement is a DOM element and if yes convert it to jQuery object",
"var",
"$Element",
"=",
"vElement",
"instanceof",
"jQuery",
"?",
"vElement",
":",
"jQuery",
"(",
"vElement",
")",
",",
"oElementPosition",
"=",
"$Element... | Calculates scroll position of a child of a container.
@param {HTMLElement | jQuery} vElement An element(DOM or jQuery) for which the scroll position will be calculated.
@returns {object} Position object.
@protected | [
"Calculates",
"scroll",
"position",
"of",
"a",
"child",
"of",
"a",
"container",
"."
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/delegate/ScrollEnablement.js#L194-L209 | train | Returns the position of the given element | [
30522,
3853,
1006,
2310,
16930,
4765,
1007,
1063,
1013,
1013,
4638,
2065,
2310,
16930,
4765,
2003,
1037,
14383,
5783,
1998,
2065,
2748,
10463,
2009,
2000,
1046,
4226,
2854,
4874,
13075,
1002,
5783,
1027,
2310,
16930,
4765,
6013,
11253,
1046... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SeleniumHQ/selenium | common/src/web/jquery-1.3.2.js | function( event, data, elem, bubbling ) {
// Event object or event type
var type = event.type || event;
if( !bubbling ){
event = typeof event === "object" ?
// jQuery.Event object
event[expando] ? event :
// Object literal
jQuery.extend( jQuery.Event(type), event ) :
// Just the event type (string)
jQuery.Event(type);
if ( type.indexOf("!") >= 0 ) {
event.type = type = type.slice(0, -1);
event.exclusive = true;
}
// Handle a global trigger
if ( !elem ) {
// Don't bubble custom events when global (to avoid too much overhead)
event.stopPropagation();
// Only trigger if we've ever bound an event for it
if ( this.global[type] )
jQuery.each( jQuery.cache, function(){
if ( this.events && this.events[type] )
jQuery.event.trigger( event, data, this.handle.elem );
});
}
// Handle triggering a single element
// don't do events on text and comment nodes
if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
return undefined;
// Clean up in case it is reused
event.result = undefined;
event.target = elem;
// Clone the incoming data, if any
data = jQuery.makeArray(data);
data.unshift( event );
}
event.currentTarget = elem;
// Trigger the event, it is assumed that "handle" is a function
var handle = jQuery.data(elem, "handle");
if ( handle )
handle.apply( elem, data );
// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
event.result = false;
// Trigger the native events (except for clicks on links)
if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
this.triggered = true;
try {
elem[ type ]();
// prevent IE from throwing an error for some hidden elements
} catch (e) {}
}
this.triggered = false;
if ( !event.isPropagationStopped() ) {
var parent = elem.parentNode || elem.ownerDocument;
if ( parent )
jQuery.event.trigger(event, data, parent, true);
}
} | javascript | function( event, data, elem, bubbling ) {
// Event object or event type
var type = event.type || event;
if( !bubbling ){
event = typeof event === "object" ?
// jQuery.Event object
event[expando] ? event :
// Object literal
jQuery.extend( jQuery.Event(type), event ) :
// Just the event type (string)
jQuery.Event(type);
if ( type.indexOf("!") >= 0 ) {
event.type = type = type.slice(0, -1);
event.exclusive = true;
}
// Handle a global trigger
if ( !elem ) {
// Don't bubble custom events when global (to avoid too much overhead)
event.stopPropagation();
// Only trigger if we've ever bound an event for it
if ( this.global[type] )
jQuery.each( jQuery.cache, function(){
if ( this.events && this.events[type] )
jQuery.event.trigger( event, data, this.handle.elem );
});
}
// Handle triggering a single element
// don't do events on text and comment nodes
if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
return undefined;
// Clean up in case it is reused
event.result = undefined;
event.target = elem;
// Clone the incoming data, if any
data = jQuery.makeArray(data);
data.unshift( event );
}
event.currentTarget = elem;
// Trigger the event, it is assumed that "handle" is a function
var handle = jQuery.data(elem, "handle");
if ( handle )
handle.apply( elem, data );
// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
event.result = false;
// Trigger the native events (except for clicks on links)
if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
this.triggered = true;
try {
elem[ type ]();
// prevent IE from throwing an error for some hidden elements
} catch (e) {}
}
this.triggered = false;
if ( !event.isPropagationStopped() ) {
var parent = elem.parentNode || elem.ownerDocument;
if ( parent )
jQuery.event.trigger(event, data, parent, true);
}
} | [
"function",
"(",
"event",
",",
"data",
",",
"elem",
",",
"bubbling",
")",
"{",
"// Event object or event type",
"var",
"type",
"=",
"event",
".",
"type",
"||",
"event",
";",
"if",
"(",
"!",
"bubbling",
")",
"{",
"event",
"=",
"typeof",
"event",
"===",
... | bubbling is internal | [
"bubbling",
"is",
"internal"
] | 38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd | https://github.com/SeleniumHQ/selenium/blob/38d5e4440b2c866a78a1ccb2a18d9795a1bdeafd/common/src/web/jquery-1.3.2.js#L2591-L2663 | train | trigger an event on an element | [
30522,
3853,
1006,
2724,
1010,
2951,
1010,
3449,
6633,
1010,
25054,
1007,
1063,
1013,
1013,
2724,
4874,
2030,
2724,
2828,
13075,
2828,
1027,
2724,
1012,
2828,
1064,
1064,
2724,
1025,
2065,
1006,
999,
25054,
1007,
1063,
2724,
1027,
2828,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
transloadit/uppy | packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi.js | readEntries | function readEntries (directoryReader, oldEntries, callback) {
directoryReader.readEntries(
(entries) => {
const newEntries = [...oldEntries, ...entries]
// According to the FileSystem API spec, readEntries() must be called until it calls the callback with an empty array.
if (entries.length) {
setTimeout(() => {
readEntries(directoryReader, newEntries, callback)
}, 0)
// Done iterating this particular directory
} else {
callback(newEntries)
}
},
// Make sure we resolve on error anyway
() =>
callback(oldEntries)
)
} | javascript | function readEntries (directoryReader, oldEntries, callback) {
directoryReader.readEntries(
(entries) => {
const newEntries = [...oldEntries, ...entries]
// According to the FileSystem API spec, readEntries() must be called until it calls the callback with an empty array.
if (entries.length) {
setTimeout(() => {
readEntries(directoryReader, newEntries, callback)
}, 0)
// Done iterating this particular directory
} else {
callback(newEntries)
}
},
// Make sure we resolve on error anyway
() =>
callback(oldEntries)
)
} | [
"function",
"readEntries",
"(",
"directoryReader",
",",
"oldEntries",
",",
"callback",
")",
"{",
"directoryReader",
".",
"readEntries",
"(",
"(",
"entries",
")",
"=>",
"{",
"const",
"newEntries",
"=",
"[",
"...",
"oldEntries",
",",
"...",
"entries",
"]",
"//... | Recursive function, calls the original callback() when the directory is entirely parsed. @param {function} callback - called with ([ all files and directories in that directoryReader ]) | [
"Recursive",
"function",
"calls",
"the",
"original",
"callback",
"()",
"when",
"the",
"directory",
"is",
"entirely",
"parsed",
"."
] | 7ae18bf992d544a64da998f033258ec09a3de275 | https://github.com/transloadit/uppy/blob/7ae18bf992d544a64da998f033258ec09a3de275/packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi.js#L5-L23 | train | Reads the entries from a directoryReader. | [
30522,
3853,
3191,
4765,
5134,
1006,
14176,
16416,
4063,
1010,
2214,
4765,
5134,
1010,
2655,
5963,
1007,
1063,
14176,
16416,
4063,
1012,
3191,
4765,
5134,
1006,
1006,
10445,
1007,
1027,
1028,
1063,
9530,
3367,
2047,
4765,
5134,
1027,
1031,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SheetJS/js-xlsx | bits/88_write.js | write_zip_type | function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
var o = opts||{};
var z = write_zip(wb, o);
var oopts = {};
if(o.compression) oopts.compression = 'DEFLATE';
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
else switch(o.type) {
case "base64": oopts.type = "base64"; break;
case "binary": oopts.type = "string"; break;
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
case "buffer":
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
} | javascript | function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ {
var o = opts||{};
var z = write_zip(wb, o);
var oopts = {};
if(o.compression) oopts.compression = 'DEFLATE';
if(o.password) oopts.type = has_buf ? "nodebuffer" : "string";
else switch(o.type) {
case "base64": oopts.type = "base64"; break;
case "binary": oopts.type = "string"; break;
case "string": throw new Error("'string' output type invalid for '" + o.bookType + "' files");
case "buffer":
case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break;
default: throw new Error("Unrecognized type " + o.type);
}
var out = z.generate(oopts);
if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o);
if(o.type === "file") return write_dl(o.file, out);
return o.type == "string" ? utf8read(out) : out;
} | [
"function",
"write_zip_type",
"(",
"wb",
"/*:Workbook*/",
",",
"opts",
"/*:?WriteOpts*/",
")",
"/*:any*/",
"{",
"var",
"o",
"=",
"opts",
"||",
"{",
"}",
";",
"var",
"z",
"=",
"write_zip",
"(",
"wb",
",",
"o",
")",
";",
"var",
"oopts",
"=",
"{",
"}",
... | /*global encrypt_agile /*:: declare var encrypt_agile:any; | [
"/",
"*",
"global",
"encrypt_agile",
"/",
"*",
"::",
"declare",
"var",
"encrypt_agile",
":",
"any",
";"
] | 9a6d8a1d3d80c78dad5201fb389316f935279cdc | https://github.com/SheetJS/js-xlsx/blob/9a6d8a1d3d80c78dad5201fb389316f935279cdc/bits/88_write.js#L14-L32 | train | Write the type of the zip file | [
30522,
3853,
4339,
1035,
14101,
1035,
2828,
1006,
25610,
1013,
1008,
1024,
2147,
8654,
1008,
1013,
1010,
23569,
2015,
1013,
1008,
1024,
1029,
4339,
7361,
3215,
1008,
1013,
1007,
1013,
1008,
1024,
2151,
1008,
1013,
1063,
13075,
1051,
1027,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
material-components/material-components-web | scripts/cherry-pick-commits.js | shouldSkipCommit | function shouldSkipCommit(logLine, mode) {
const parsedCommit = parser.sync(logLine.message, parserOpts);
return (parsedCommit.type === 'feat' && mode === 'patch') || // feature commit
parsedCommit.notes.find((note) => note.title === 'BREAKING CHANGE') || // breaking change commit
(parsedCommit.type === 'chore' && parsedCommit.subject === 'Publish'); // Publish (version-rev) commit
} | javascript | function shouldSkipCommit(logLine, mode) {
const parsedCommit = parser.sync(logLine.message, parserOpts);
return (parsedCommit.type === 'feat' && mode === 'patch') || // feature commit
parsedCommit.notes.find((note) => note.title === 'BREAKING CHANGE') || // breaking change commit
(parsedCommit.type === 'chore' && parsedCommit.subject === 'Publish'); // Publish (version-rev) commit
} | [
"function",
"shouldSkipCommit",
"(",
"logLine",
",",
"mode",
")",
"{",
"const",
"parsedCommit",
"=",
"parser",
".",
"sync",
"(",
"logLine",
".",
"message",
",",
"parserOpts",
")",
";",
"return",
"(",
"parsedCommit",
".",
"type",
"===",
"'feat'",
"&&",
"mod... | Returns true if commit should NOT be cherry-picked. | [
"Returns",
"true",
"if",
"commit",
"should",
"NOT",
"be",
"cherry",
"-",
"picked",
"."
] | 9f8b9ae5103ff86de4f6a5cb02e700d6eb851e5f | https://github.com/material-components/material-components-web/blob/9f8b9ae5103ff86de4f6a5cb02e700d6eb851e5f/scripts/cherry-pick-commits.js#L113-L118 | train | Check if the commit is in the correct state | [
30522,
3853,
2323,
5488,
15042,
5358,
22930,
1006,
8833,
4179,
1010,
5549,
1007,
1063,
9530,
3367,
11968,
6924,
9006,
22930,
1027,
11968,
8043,
1012,
26351,
1006,
8833,
4179,
1012,
4471,
1010,
11968,
8043,
7361,
3215,
1007,
1025,
2709,
1006... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
openlayers/openlayers | src/ol/interaction/DoubleClickZoom.js | handleEvent | function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == MapBrowserEventType.DBLCLICK) {
const browserEvent = /** @type {MouseEvent} */ (mapBrowserEvent.originalEvent);
const map = mapBrowserEvent.map;
const anchor = mapBrowserEvent.coordinate;
const delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
const view = map.getView();
zoomByDelta(view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}
return !stopEvent;
} | javascript | function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == MapBrowserEventType.DBLCLICK) {
const browserEvent = /** @type {MouseEvent} */ (mapBrowserEvent.originalEvent);
const map = mapBrowserEvent.map;
const anchor = mapBrowserEvent.coordinate;
const delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
const view = map.getView();
zoomByDelta(view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault();
stopEvent = true;
}
return !stopEvent;
} | [
"function",
"handleEvent",
"(",
"mapBrowserEvent",
")",
"{",
"let",
"stopEvent",
"=",
"false",
";",
"if",
"(",
"mapBrowserEvent",
".",
"type",
"==",
"MapBrowserEventType",
".",
"DBLCLICK",
")",
"{",
"const",
"browserEvent",
"=",
"/** @type {MouseEvent} */",
"(",
... | Handles the {@link module:ol/MapBrowserEvent map browser event} (if it was a
doubleclick) and eventually zooms the map.
@param {import("../MapBrowserEvent.js").default} mapBrowserEvent Map browser event.
@return {boolean} `false` to stop event propagation.
@this {DoubleClickZoom} | [
"Handles",
"the",
"{"
] | f366eaea522388fb575b11010e69d309164baca7 | https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/interaction/DoubleClickZoom.js#L56-L69 | train | Handle mouse click events | [
30522,
3853,
5047,
18697,
3372,
1006,
4949,
12618,
9333,
7869,
15338,
1007,
1063,
2292,
2644,
18697,
3372,
1027,
6270,
1025,
2065,
1006,
4949,
12618,
9333,
7869,
15338,
1012,
2828,
1027,
1027,
4949,
12618,
9333,
7869,
15338,
13874,
1012,
16... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
aws/aws-sdk-js | lib/signers/v4_credentials.js | getSigningKey | function getSigningKey(
credentials,
date,
region,
service,
shouldCache
) {
var credsIdentifier = AWS.util.crypto
.hmac(credentials.secretAccessKey, credentials.accessKeyId, 'base64');
var cacheKey = [credsIdentifier, date, region, service].join('_');
shouldCache = shouldCache !== false;
if (shouldCache && (cacheKey in cachedSecret)) {
return cachedSecret[cacheKey];
}
var kDate = AWS.util.crypto.hmac(
'AWS4' + credentials.secretAccessKey,
date,
'buffer'
);
var kRegion = AWS.util.crypto.hmac(kDate, region, 'buffer');
var kService = AWS.util.crypto.hmac(kRegion, service, 'buffer');
var signingKey = AWS.util.crypto.hmac(kService, v4Identifier, 'buffer');
if (shouldCache) {
cachedSecret[cacheKey] = signingKey;
cacheQueue.push(cacheKey);
if (cacheQueue.length > maxCacheEntries) {
// remove the oldest entry (not the least recently used)
delete cachedSecret[cacheQueue.shift()];
}
}
return signingKey;
} | javascript | function getSigningKey(
credentials,
date,
region,
service,
shouldCache
) {
var credsIdentifier = AWS.util.crypto
.hmac(credentials.secretAccessKey, credentials.accessKeyId, 'base64');
var cacheKey = [credsIdentifier, date, region, service].join('_');
shouldCache = shouldCache !== false;
if (shouldCache && (cacheKey in cachedSecret)) {
return cachedSecret[cacheKey];
}
var kDate = AWS.util.crypto.hmac(
'AWS4' + credentials.secretAccessKey,
date,
'buffer'
);
var kRegion = AWS.util.crypto.hmac(kDate, region, 'buffer');
var kService = AWS.util.crypto.hmac(kRegion, service, 'buffer');
var signingKey = AWS.util.crypto.hmac(kService, v4Identifier, 'buffer');
if (shouldCache) {
cachedSecret[cacheKey] = signingKey;
cacheQueue.push(cacheKey);
if (cacheQueue.length > maxCacheEntries) {
// remove the oldest entry (not the least recently used)
delete cachedSecret[cacheQueue.shift()];
}
}
return signingKey;
} | [
"function",
"getSigningKey",
"(",
"credentials",
",",
"date",
",",
"region",
",",
"service",
",",
"shouldCache",
")",
"{",
"var",
"credsIdentifier",
"=",
"AWS",
".",
"util",
".",
"crypto",
".",
"hmac",
"(",
"credentials",
".",
"secretAccessKey",
",",
"creden... | @api private
@param credentials [Credentials]
@param date [String]
@param region [String]
@param service [String]
@param shouldCache [Boolean]
@return [String] | [
"@api",
"private"
] | c23e5f0edd150f8885267e5f7c8a564f8e6e8562 | https://github.com/aws/aws-sdk-js/blob/c23e5f0edd150f8885267e5f7c8a564f8e6e8562/lib/signers/v4_credentials.js#L54-L88 | train | Get the signing key for the given credentials | [
30522,
3853,
4152,
23773,
2075,
14839,
1006,
22496,
1010,
3058,
1010,
2555,
1010,
2326,
1010,
2323,
3540,
5403,
1007,
1063,
13075,
13675,
2098,
7363,
16778,
8873,
2121,
1027,
22091,
2015,
1012,
21183,
4014,
1012,
19888,
2080,
1012,
20287,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
apache/incubator-echarts | src/chart/treemap/Breadcrumb.js | function (targetNode, layoutParam, textStyleModel) {
for (var node = targetNode; node; node = node.parentNode) {
var text = node.getModel().get('name');
var textRect = textStyleModel.getTextRect(text);
var itemWidth = Math.max(
textRect.width + TEXT_PADDING * 2,
layoutParam.emptyItemWidth
);
layoutParam.totalWidth += itemWidth + ITEM_GAP;
layoutParam.renderList.push({node: node, text: text, width: itemWidth});
}
} | javascript | function (targetNode, layoutParam, textStyleModel) {
for (var node = targetNode; node; node = node.parentNode) {
var text = node.getModel().get('name');
var textRect = textStyleModel.getTextRect(text);
var itemWidth = Math.max(
textRect.width + TEXT_PADDING * 2,
layoutParam.emptyItemWidth
);
layoutParam.totalWidth += itemWidth + ITEM_GAP;
layoutParam.renderList.push({node: node, text: text, width: itemWidth});
}
} | [
"function",
"(",
"targetNode",
",",
"layoutParam",
",",
"textStyleModel",
")",
"{",
"for",
"(",
"var",
"node",
"=",
"targetNode",
";",
"node",
";",
"node",
"=",
"node",
".",
"parentNode",
")",
"{",
"var",
"text",
"=",
"node",
".",
"getModel",
"(",
")",... | Prepare render list and total width
@private | [
"Prepare",
"render",
"list",
"and",
"total",
"width"
] | 4d0ea095dc3929cb6de40c45748826e7999c7aa8 | https://github.com/apache/incubator-echarts/blob/4d0ea095dc3929cb6de40c45748826e7999c7aa8/src/chart/treemap/Breadcrumb.js#L83-L94 | train | This function is called by the layout. render function to calculate the width of the items in the tree | [
30522,
3853,
1006,
4539,
3630,
3207,
1010,
9621,
28689,
2213,
1010,
6981,
27983,
5302,
9247,
1007,
1063,
2005,
1006,
13075,
13045,
1027,
4539,
3630,
3207,
1025,
13045,
1025,
13045,
1027,
13045,
1012,
6687,
3630,
3207,
1007,
1063,
13075,
379... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
adobe/brackets | src/extensions/default/JavaScriptCodeHints/main.js | setJumpSelection | function setJumpSelection(start, end, isFunction) {
/**
* helper function to decide if the tokens on the RHS of an assignment
* look like an identifier, or member expr.
*/
function validIdOrProp(token) {
if (!token) {
return false;
}
if (token.string === ".") {
return true;
}
var type = token.type;
if (type === "variable-2" || type === "variable" || type === "property") {
return true;
}
return false;
}
var madeNewRequest = false;
if (isFunction) {
// When jumping to function defs, follow the chain back
// to get to the original function def
var cursor = {line: end.line, ch: end.ch},
prev = session._getPreviousToken(cursor),
next,
offset;
// see if the selection is preceded by a '.', indicating we're in a member expr
if (prev.string === ".") {
cursor = {line: end.line, ch: end.ch};
next = session.getNextToken(cursor, true);
// check if the next token indicates an assignment
if (next && next.string === "=") {
next = session.getNextToken(cursor, true);
// find the last token of the identifier, or member expr
while (validIdOrProp(next)) {
offset = session.getOffsetFromCursor({line: cursor.line, ch: next.end});
next = session.getNextToken(cursor, false);
}
if (offset) {
// trigger another jump to def based on the offset of the RHS
requestJumpToDef(session, offset);
madeNewRequest = true;
}
}
}
}
// We didn't make a new jump-to-def request, so we can resolve the promise
// and set the selection
if (!madeNewRequest) {
// set the selection
session.editor.setSelection(start, end, true);
result.resolve(true);
}
} | javascript | function setJumpSelection(start, end, isFunction) {
/**
* helper function to decide if the tokens on the RHS of an assignment
* look like an identifier, or member expr.
*/
function validIdOrProp(token) {
if (!token) {
return false;
}
if (token.string === ".") {
return true;
}
var type = token.type;
if (type === "variable-2" || type === "variable" || type === "property") {
return true;
}
return false;
}
var madeNewRequest = false;
if (isFunction) {
// When jumping to function defs, follow the chain back
// to get to the original function def
var cursor = {line: end.line, ch: end.ch},
prev = session._getPreviousToken(cursor),
next,
offset;
// see if the selection is preceded by a '.', indicating we're in a member expr
if (prev.string === ".") {
cursor = {line: end.line, ch: end.ch};
next = session.getNextToken(cursor, true);
// check if the next token indicates an assignment
if (next && next.string === "=") {
next = session.getNextToken(cursor, true);
// find the last token of the identifier, or member expr
while (validIdOrProp(next)) {
offset = session.getOffsetFromCursor({line: cursor.line, ch: next.end});
next = session.getNextToken(cursor, false);
}
if (offset) {
// trigger another jump to def based on the offset of the RHS
requestJumpToDef(session, offset);
madeNewRequest = true;
}
}
}
}
// We didn't make a new jump-to-def request, so we can resolve the promise
// and set the selection
if (!madeNewRequest) {
// set the selection
session.editor.setSelection(start, end, true);
result.resolve(true);
}
} | [
"function",
"setJumpSelection",
"(",
"start",
",",
"end",
",",
"isFunction",
")",
"{",
"/**\n * helper function to decide if the tokens on the RHS of an assignment\n * look like an identifier, or member expr.\n */",
"function",
"validIdOrProp",... | Sets the selection to move the cursor to the result position.
Assumes that the editor has already changed files, if necessary.
Additionally, this will check to see if the selection looks like an
assignment to a member expression - if it is, and the type is a function,
then we will attempt to jump to the RHS of the expression.
'exports.foo = foo'
if the selection is 'foo' in 'exports.foo', then we will attempt to jump to def
on the rhs of the assignment.
@param {number} start - the start of the selection
@param {number} end - the end of the selection
@param {boolean} isFunction - true if we are jumping to the source of a function def | [
"Sets",
"the",
"selection",
"to",
"move",
"the",
"cursor",
"to",
"the",
"result",
"position",
".",
"Assumes",
"that",
"the",
"editor",
"has",
"already",
"changed",
"files",
"if",
"necessary",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/JavaScriptCodeHints/main.js#L781-L839 | train | Set the selection to the next token of the RHS of an assignment or member expr. | [
30522,
3853,
2275,
9103,
25370,
12260,
7542,
1006,
2707,
1010,
2203,
1010,
2003,
11263,
27989,
1007,
1063,
1013,
1008,
1008,
1008,
2393,
2121,
3853,
2000,
5630,
2065,
1996,
19204,
2015,
2006,
1996,
1054,
7898,
1997,
2019,
8775,
1008,
2298,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
dequelabs/axe-core | lib/core/utils/preload-cssom.js | parseCrossOriginStylesheet | function parseCrossOriginStylesheet(url, options, priority) {
const q = axe.utils.queue();
if (!url) {
return q;
}
const axiosOptions = {
method: 'get',
url,
timeout: options.timeout
};
q.defer((resolve, reject) => {
axe.imports
.axios(axiosOptions)
.then(({ data }) =>
resolve(
options.convertDataToStylesheet({
data,
isExternal: true,
priority,
root: options.rootNode,
shadowId: options.shadowId
})
)
)
.catch(reject);
});
return q;
} | javascript | function parseCrossOriginStylesheet(url, options, priority) {
const q = axe.utils.queue();
if (!url) {
return q;
}
const axiosOptions = {
method: 'get',
url,
timeout: options.timeout
};
q.defer((resolve, reject) => {
axe.imports
.axios(axiosOptions)
.then(({ data }) =>
resolve(
options.convertDataToStylesheet({
data,
isExternal: true,
priority,
root: options.rootNode,
shadowId: options.shadowId
})
)
)
.catch(reject);
});
return q;
} | [
"function",
"parseCrossOriginStylesheet",
"(",
"url",
",",
"options",
",",
"priority",
")",
"{",
"const",
"q",
"=",
"axe",
".",
"utils",
".",
"queue",
"(",
")",
";",
"if",
"(",
"!",
"url",
")",
"{",
"return",
"q",
";",
"}",
"const",
"axiosOptions",
"... | Parse cross-origin stylesheets
@param {String} url url from which to fetch stylesheet
@param {Object} options `loadCssom` options
@param {Array<Number>} priority sheet priority | [
"Parse",
"cross",
"-",
"origin",
"stylesheets"
] | 727323c07980e2291575f545444d389fb942906f | https://github.com/dequelabs/axe-core/blob/727323c07980e2291575f545444d389fb942906f/lib/core/utils/preload-cssom.js#L309-L340 | train | Parse cross - origin stylesheet | [
30522,
3853,
11968,
3366,
16458,
10050,
16529,
27983,
4095,
15558,
1006,
24471,
2140,
1010,
7047,
1010,
9470,
1007,
1063,
9530,
3367,
1053,
1027,
12946,
1012,
21183,
12146,
1012,
24240,
1006,
1007,
1025,
2065,
1006,
999,
24471,
2140,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
eslint/eslint | lib/linter.js | createRuleListeners | function createRuleListeners(rule, ruleContext) {
try {
return rule.create(ruleContext);
} catch (ex) {
ex.message = `Error while loading rule '${ruleContext.id}': ${ex.message}`;
throw ex;
}
} | javascript | function createRuleListeners(rule, ruleContext) {
try {
return rule.create(ruleContext);
} catch (ex) {
ex.message = `Error while loading rule '${ruleContext.id}': ${ex.message}`;
throw ex;
}
} | [
"function",
"createRuleListeners",
"(",
"rule",
",",
"ruleContext",
")",
"{",
"try",
"{",
"return",
"rule",
".",
"create",
"(",
"ruleContext",
")",
";",
"}",
"catch",
"(",
"ex",
")",
"{",
"ex",
".",
"message",
"=",
"`",
"${",
"ruleContext",
".",
"id",
... | Runs a rule, and gets its listeners
@param {Rule} rule A normalized rule with a `create` method
@param {Context} ruleContext The context that should be passed to the rule
@returns {Object} A map of selector listeners provided by the rule | [
"Runs",
"a",
"rule",
"and",
"gets",
"its",
"listeners"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/linter.js#L599-L606 | train | Create a listener for a rule | [
30522,
3853,
3443,
6820,
2571,
9863,
24454,
2015,
1006,
3627,
1010,
3627,
8663,
18209,
1007,
1063,
3046,
1063,
2709,
3627,
1012,
3443,
1006,
3627,
8663,
18209,
1007,
1025,
1065,
4608,
1006,
4654,
1007,
1063,
4654,
1012,
4471,
1027,
1036,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/HealthData/HealthDataUtils.js | getUserInstalledTheme | function getUserInstalledTheme() {
var result = new $.Deferred();
var installedTheme = themesPref.get("theme"),
bracketsTheme;
if (installedTheme === "light-theme" || installedTheme === "dark-theme") {
return result.resolve(installedTheme);
}
if (!ExtensionManager.hasDownloadedRegistry) {
ExtensionManager.downloadRegistry().done(function () {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
} else {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
}
return result.promise();
} | javascript | function getUserInstalledTheme() {
var result = new $.Deferred();
var installedTheme = themesPref.get("theme"),
bracketsTheme;
if (installedTheme === "light-theme" || installedTheme === "dark-theme") {
return result.resolve(installedTheme);
}
if (!ExtensionManager.hasDownloadedRegistry) {
ExtensionManager.downloadRegistry().done(function () {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
})
.fail(function () {
result.reject();
});
} else {
bracketsTheme = ExtensionManager.extensions[installedTheme];
if (bracketsTheme && bracketsTheme.installInfo && bracketsTheme.installInfo.locationType === ExtensionManager.LOCATION_USER && bracketsTheme.registryInfo) {
result.resolve(installedTheme);
} else {
result.reject();
}
}
return result.promise();
} | [
"function",
"getUserInstalledTheme",
"(",
")",
"{",
"var",
"result",
"=",
"new",
"$",
".",
"Deferred",
"(",
")",
";",
"var",
"installedTheme",
"=",
"themesPref",
".",
"get",
"(",
"\"theme\"",
")",
",",
"bracketsTheme",
";",
"if",
"(",
"installedTheme",
"==... | Utility function to get the user installed theme which are present in the registry | [
"Utility",
"function",
"to",
"get",
"the",
"user",
"installed",
"theme",
"which",
"are",
"present",
"in",
"the",
"registry"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/HealthData/HealthDataUtils.js#L73-L105 | train | getUserInstalledTheme - Get user installed theme | [
30522,
3853,
2131,
20330,
7076,
9080,
3709,
10760,
4168,
1006,
1007,
1063,
13075,
2765,
1027,
2047,
1002,
1012,
13366,
28849,
2094,
1006,
1007,
1025,
13075,
5361,
10760,
4168,
1027,
6991,
28139,
2546,
1012,
2131,
1006,
1000,
4323,
1000,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
catapult-project/catapult | tracing/tracing_examples/string_convert.js | UTF8ArrToStr | function UTF8ArrToStr (aBytes) {
var sView = "";
for (var nPart, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {
nPart = aBytes[nIdx];
sView += String.fromCharCode(
nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */
/* (nPart - 252 << 32) is not possible in ECMAScript! So...: */
(nPart - 252) * 1073741824 + (aBytes[++nIdx] - 128 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 247 && nPart < 252 && nIdx + 4 < nLen ? /* five bytes */
(nPart - 248 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 239 && nPart < 248 && nIdx + 3 < nLen ? /* four bytes */
(nPart - 240 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 223 && nPart < 240 && nIdx + 2 < nLen ? /* three bytes */
(nPart - 224 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 191 && nPart < 224 && nIdx + 1 < nLen ? /* two bytes */
(nPart - 192 << 6) + aBytes[++nIdx] - 128
: /* nPart < 127 ? */ /* one byte */
nPart
);
}
return sView;
} | javascript | function UTF8ArrToStr (aBytes) {
var sView = "";
for (var nPart, nLen = aBytes.length, nIdx = 0; nIdx < nLen; nIdx++) {
nPart = aBytes[nIdx];
sView += String.fromCharCode(
nPart > 251 && nPart < 254 && nIdx + 5 < nLen ? /* six bytes */
/* (nPart - 252 << 32) is not possible in ECMAScript! So...: */
(nPart - 252) * 1073741824 + (aBytes[++nIdx] - 128 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 247 && nPart < 252 && nIdx + 4 < nLen ? /* five bytes */
(nPart - 248 << 24) + (aBytes[++nIdx] - 128 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 239 && nPart < 248 && nIdx + 3 < nLen ? /* four bytes */
(nPart - 240 << 18) + (aBytes[++nIdx] - 128 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 223 && nPart < 240 && nIdx + 2 < nLen ? /* three bytes */
(nPart - 224 << 12) + (aBytes[++nIdx] - 128 << 6) + aBytes[++nIdx] - 128
: nPart > 191 && nPart < 224 && nIdx + 1 < nLen ? /* two bytes */
(nPart - 192 << 6) + aBytes[++nIdx] - 128
: /* nPart < 127 ? */ /* one byte */
nPart
);
}
return sView;
} | [
"function",
"UTF8ArrToStr",
"(",
"aBytes",
")",
"{",
"var",
"sView",
"=",
"\"\"",
";",
"for",
"(",
"var",
"nPart",
",",
"nLen",
"=",
"aBytes",
".",
"length",
",",
"nIdx",
"=",
"0",
";",
"nIdx",
"<",
"nLen",
";",
"nIdx",
"++",
")",
"{",
"nPart",
"... | /* UTF-8 array to DOMString and vice versa | [
"/",
"*",
"UTF",
"-",
"8",
"array",
"to",
"DOMString",
"and",
"vice",
"versa"
] | 992929ffccac68827869a497f01ee4d653ed4f25 | https://github.com/catapult-project/catapult/blob/992929ffccac68827869a497f01ee4d653ed4f25/tracing/tracing_examples/string_convert.js#L89-L114 | train | Converts an array of bytes to a string | [
30522,
3853,
21183,
2546,
2620,
2906,
5339,
14122,
2099,
1006,
11113,
17250,
2015,
1007,
1063,
13075,
17917,
2666,
2860,
1027,
1000,
1000,
1025,
2005,
1006,
13075,
27937,
8445,
1010,
17953,
2368,
1027,
11113,
17250,
2015,
1012,
3091,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/thirdparty/less.js | function () {
var s = input.charAt(i), important = false, index = i, elemIndex,
elements, elem, e, c, args;
if (s !== '.' && s !== '#') { return; }
save(); // stop us absorbing part of an invalid selector
while (true) {
elemIndex = i;
e = $re(/^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/);
if (!e) {
break;
}
elem = new(tree.Element)(c, e, elemIndex, env.currentFileInfo);
if (elements) { elements.push(elem); } else { elements = [ elem ]; }
c = $char('>');
}
if (elements) {
if ($char('(')) {
args = this.args(true).args;
expectChar(')');
}
if (parsers.important()) {
important = true;
}
if (parsers.end()) {
return new(tree.mixin.Call)(elements, args, index, env.currentFileInfo, important);
}
}
restore();
} | javascript | function () {
var s = input.charAt(i), important = false, index = i, elemIndex,
elements, elem, e, c, args;
if (s !== '.' && s !== '#') { return; }
save(); // stop us absorbing part of an invalid selector
while (true) {
elemIndex = i;
e = $re(/^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/);
if (!e) {
break;
}
elem = new(tree.Element)(c, e, elemIndex, env.currentFileInfo);
if (elements) { elements.push(elem); } else { elements = [ elem ]; }
c = $char('>');
}
if (elements) {
if ($char('(')) {
args = this.args(true).args;
expectChar(')');
}
if (parsers.important()) {
important = true;
}
if (parsers.end()) {
return new(tree.mixin.Call)(elements, args, index, env.currentFileInfo, important);
}
}
restore();
} | [
"function",
"(",
")",
"{",
"var",
"s",
"=",
"input",
".",
"charAt",
"(",
"i",
")",
",",
"important",
"=",
"false",
",",
"index",
"=",
"i",
",",
"elemIndex",
",",
"elements",
",",
"elem",
",",
"e",
",",
"c",
",",
"args",
";",
"if",
"(",
"s",
"... | A Mixin call, with an optional argument list #mixins > .square(#fff); .rounded(4px, black); .button; The `while` loop is there because mixins can be namespaced, but we only support the child and descendant selector for now. | [
"A",
"Mixin",
"call",
"with",
"an",
"optional",
"argument",
"list",
"#mixins",
">",
".",
"square",
"(",
"#fff",
")",
";",
".",
"rounded",
"(",
"4px",
"black",
")",
";",
".",
"button",
";",
"The",
"while",
"loop",
"is",
"there",
"because",
"mixins",
"... | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/thirdparty/less.js#L1112-L1147 | train | parse selector | [
30522,
3853,
1006,
1007,
1063,
13075,
1055,
1027,
7953,
1012,
25869,
4017,
1006,
1045,
1007,
1010,
2590,
1027,
6270,
1010,
5950,
1027,
1045,
1010,
3449,
23238,
13629,
2595,
1010,
3787,
1010,
3449,
6633,
1010,
1041,
1010,
1039,
1010,
12098,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
SAP/openui5 | src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js | function (oViewClass) {
var mViewParameters = {
id: id ? getId(oView, node, id) : undefined,
xmlNode: node,
containingView: oView._oContainingView,
processingMode: oView._sProcessingMode // add processing mode, so it can be propagated to subviews inside the HTML block
};
// running with owner component
if (oView.fnScopedRunWithOwner) {
return oView.fnScopedRunWithOwner(function () {
return new oViewClass(mViewParameters);
});
}
// no owner component
// (or fully sync path, which handles the owner propagation on a higher level)
return new oViewClass(mViewParameters);
} | javascript | function (oViewClass) {
var mViewParameters = {
id: id ? getId(oView, node, id) : undefined,
xmlNode: node,
containingView: oView._oContainingView,
processingMode: oView._sProcessingMode // add processing mode, so it can be propagated to subviews inside the HTML block
};
// running with owner component
if (oView.fnScopedRunWithOwner) {
return oView.fnScopedRunWithOwner(function () {
return new oViewClass(mViewParameters);
});
}
// no owner component
// (or fully sync path, which handles the owner propagation on a higher level)
return new oViewClass(mViewParameters);
} | [
"function",
"(",
"oViewClass",
")",
"{",
"var",
"mViewParameters",
"=",
"{",
"id",
":",
"id",
"?",
"getId",
"(",
"oView",
",",
"node",
",",
"id",
")",
":",
"undefined",
",",
"xmlNode",
":",
"node",
",",
"containingView",
":",
"oView",
".",
"_oContainin... | plain HTML node - create a new View control creates a view instance, but makes sure the new view receives the correct owner component | [
"plain",
"HTML",
"node",
"-",
"create",
"a",
"new",
"View",
"control",
"creates",
"a",
"view",
"instance",
"but",
"makes",
"sure",
"the",
"new",
"view",
"receives",
"the",
"correct",
"owner",
"component"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/core/XMLTemplateProcessor.js#L532-L548 | train | Creates a new view instance | [
30522,
3853,
1006,
1051,
8584,
26266,
1007,
1063,
13075,
19842,
2666,
2860,
28689,
22828,
2015,
1027,
1063,
8909,
1024,
8909,
1029,
2131,
3593,
1006,
1051,
8584,
1010,
13045,
1010,
8909,
1007,
1024,
6151,
28344,
1010,
20950,
3630,
3207,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... | |
eslint/eslint | lib/rules/space-unary-ops.js | checkForSpaces | function checkForSpaces(node) {
const tokens = node.type === "UpdateExpression" && !node.prefix
? sourceCode.getLastTokens(node, 2)
: sourceCode.getFirstTokens(node, 2);
const firstToken = tokens[0];
const secondToken = tokens[1];
if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") {
checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value);
return;
}
const operator = node.prefix ? tokens[0].value : tokens[1].value;
if (overrideExistsForOperator(operator)) {
if (overrideEnforcesSpaces(operator)) {
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
} else {
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
}
} else if (options.nonwords) {
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
} else {
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
}
} | javascript | function checkForSpaces(node) {
const tokens = node.type === "UpdateExpression" && !node.prefix
? sourceCode.getLastTokens(node, 2)
: sourceCode.getFirstTokens(node, 2);
const firstToken = tokens[0];
const secondToken = tokens[1];
if ((node.type === "NewExpression" || node.prefix) && firstToken.type === "Keyword") {
checkUnaryWordOperatorForSpaces(node, firstToken, secondToken, firstToken.value);
return;
}
const operator = node.prefix ? tokens[0].value : tokens[1].value;
if (overrideExistsForOperator(operator)) {
if (overrideEnforcesSpaces(operator)) {
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
} else {
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
}
} else if (options.nonwords) {
verifyNonWordsHaveSpaces(node, firstToken, secondToken);
} else {
verifyNonWordsDontHaveSpaces(node, firstToken, secondToken);
}
} | [
"function",
"checkForSpaces",
"(",
"node",
")",
"{",
"const",
"tokens",
"=",
"node",
".",
"type",
"===",
"\"UpdateExpression\"",
"&&",
"!",
"node",
".",
"prefix",
"?",
"sourceCode",
".",
"getLastTokens",
"(",
"node",
",",
"2",
")",
":",
"sourceCode",
".",
... | Verifies UnaryExpression, UpdateExpression and NewExpression satisfy spacing requirements
@param {ASTnode} node AST node
@returns {void} | [
"Verifies",
"UnaryExpression",
"UpdateExpression",
"and",
"NewExpression",
"satisfy",
"spacing",
"requirements"
] | bc0819c94aad14f7fad3cbc2338ea15658b0f272 | https://github.com/eslint/eslint/blob/bc0819c94aad14f7fad3cbc2338ea15658b0f272/lib/rules/space-unary-ops.js#L281-L306 | train | Checks if a node has spaces | [
30522,
3853,
4638,
29278,
23058,
2015,
1006,
13045,
1007,
1063,
9530,
3367,
19204,
2015,
1027,
13045,
1012,
2828,
1027,
1027,
1027,
1000,
10651,
10288,
20110,
3258,
1000,
1004,
1004,
999,
13045,
1012,
17576,
1029,
3120,
16044,
1012,
2131,
8... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
SAP/openui5 | src/sap.ui.core/src/sap/ui/base/ManagedObjectMetadata.js | Association | function Association(oClass, name, info) {
info = typeof info !== 'object' ? { type: info } : info;
this.name = name;
this.type = info.type || 'sap.ui.core.Control';
this.multiple = info.multiple || false;
this.singularName = this.multiple ? info.singularName || guessSingularName(name) : undefined;
this.deprecated = info.deprecated || false;
this.visibility = info.visibility || 'public';
this.appData = remainder(this, info);
this._oParent = oClass;
this._sUID = 'association:' + name;
this._iKind = this.multiple ? Kind.MULTIPLE_ASSOCIATION : Kind.SINGLE_ASSOCIATION;
var N = capitalize(name);
this._sGetter = 'get' + N;
if ( this.multiple ) {
var N1 = capitalize(this.singularName);
this._sMutator = 'add' + N1;
this._sRemoveMutator = 'remove' + N1;
this._sRemoveAllMutator = 'removeAll' + N;
} else {
this._sMutator = 'set' + N;
this._sRemoveMutator =
this._sRemoveAllMutator = undefined;
}
} | javascript | function Association(oClass, name, info) {
info = typeof info !== 'object' ? { type: info } : info;
this.name = name;
this.type = info.type || 'sap.ui.core.Control';
this.multiple = info.multiple || false;
this.singularName = this.multiple ? info.singularName || guessSingularName(name) : undefined;
this.deprecated = info.deprecated || false;
this.visibility = info.visibility || 'public';
this.appData = remainder(this, info);
this._oParent = oClass;
this._sUID = 'association:' + name;
this._iKind = this.multiple ? Kind.MULTIPLE_ASSOCIATION : Kind.SINGLE_ASSOCIATION;
var N = capitalize(name);
this._sGetter = 'get' + N;
if ( this.multiple ) {
var N1 = capitalize(this.singularName);
this._sMutator = 'add' + N1;
this._sRemoveMutator = 'remove' + N1;
this._sRemoveAllMutator = 'removeAll' + N;
} else {
this._sMutator = 'set' + N;
this._sRemoveMutator =
this._sRemoveAllMutator = undefined;
}
} | [
"function",
"Association",
"(",
"oClass",
",",
"name",
",",
"info",
")",
"{",
"info",
"=",
"typeof",
"info",
"!==",
"'object'",
"?",
"{",
"type",
":",
"info",
"}",
":",
"info",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"type",
"=",
... | ---- Association -----------------------------------------------------------------------
Association info object
@private
@since 1.27.1 | [
"----",
"Association",
"-----------------------------------------------------------------------",
"Association",
"info",
"object"
] | 8a832fca01cb1cdf8df589788e0c5723e2a33c70 | https://github.com/SAP/openui5/blob/8a832fca01cb1cdf8df589788e0c5723e2a33c70/src/sap.ui.core/src/sap/ui/base/ManagedObjectMetadata.js#L654-L678 | train | Constructor for an association | [
30522,
3853,
2523,
1006,
1051,
26266,
1010,
2171,
1010,
18558,
1007,
1063,
18558,
1027,
2828,
11253,
18558,
999,
1027,
1027,
1005,
4874,
1005,
1029,
1063,
2828,
1024,
18558,
1065,
1024,
18558,
1025,
2023,
1012,
2171,
1027,
2171,
1025,
2023,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/language/CSSUtils.js | _getSelectorInFinalCSSForm | function _getSelectorInFinalCSSForm(selectorArray) {
var finalSelectorArray = [""],
parentSelectorArray = [],
group = [];
_.forEach(selectorArray, function (selector) {
selector = _stripAtRules(selector);
group = selector.split(",");
parentSelectorArray = [];
_.forEach(group, function (cs) {
var ampersandIndex = cs.indexOf("&");
_.forEach(finalSelectorArray, function (ps) {
if (ampersandIndex === -1) {
cs = _stripAtRules(cs);
if (ps.length && cs.length) {
ps += " ";
}
ps += cs;
} else {
// Replace all instances of & with regexp
ps = _stripAtRules(cs.replace(/&/g, ps));
}
parentSelectorArray.push(ps);
});
});
finalSelectorArray = parentSelectorArray;
});
return finalSelectorArray.join(", ");
} | javascript | function _getSelectorInFinalCSSForm(selectorArray) {
var finalSelectorArray = [""],
parentSelectorArray = [],
group = [];
_.forEach(selectorArray, function (selector) {
selector = _stripAtRules(selector);
group = selector.split(",");
parentSelectorArray = [];
_.forEach(group, function (cs) {
var ampersandIndex = cs.indexOf("&");
_.forEach(finalSelectorArray, function (ps) {
if (ampersandIndex === -1) {
cs = _stripAtRules(cs);
if (ps.length && cs.length) {
ps += " ";
}
ps += cs;
} else {
// Replace all instances of & with regexp
ps = _stripAtRules(cs.replace(/&/g, ps));
}
parentSelectorArray.push(ps);
});
});
finalSelectorArray = parentSelectorArray;
});
return finalSelectorArray.join(", ");
} | [
"function",
"_getSelectorInFinalCSSForm",
"(",
"selectorArray",
")",
"{",
"var",
"finalSelectorArray",
"=",
"[",
"\"\"",
"]",
",",
"parentSelectorArray",
"=",
"[",
"]",
",",
"group",
"=",
"[",
"]",
";",
"_",
".",
"forEach",
"(",
"selectorArray",
",",
"functi... | Converts the given selector array into the actual CSS selectors similar to
those generated by a CSS preprocessor.
@param {Array.<string>} selectorArray
@return {string} | [
"Converts",
"the",
"given",
"selector",
"array",
"into",
"the",
"actual",
"CSS",
"selectors",
"similar",
"to",
"those",
"generated",
"by",
"a",
"CSS",
"preprocessor",
"."
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/language/CSSUtils.js#L1314-L1341 | train | Get final CSS form selector | [
30522,
3853,
1035,
4152,
12260,
16761,
2378,
16294,
2389,
6169,
22747,
2953,
2213,
1006,
27000,
2906,
9447,
1007,
1063,
13075,
4399,
12260,
16761,
2906,
9447,
1027,
1031,
1000,
1000,
1033,
1010,
3008,
12260,
16761,
2906,
9447,
1027,
1031,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
NervJS/taro | packages/taro/src/internal/_common.js | listCacheDelete | function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key)
if (index < 0) {
return false
}
var lastIndex = data.length - 1
if (index == lastIndex) {
data.pop()
} else {
splice.call(data, index, 1)
}
return true
} | javascript | function listCacheDelete(key) {
var data = this.__data__,
index = assocIndexOf(data, key)
if (index < 0) {
return false
}
var lastIndex = data.length - 1
if (index == lastIndex) {
data.pop()
} else {
splice.call(data, index, 1)
}
return true
} | [
"function",
"listCacheDelete",
"(",
"key",
")",
"{",
"var",
"data",
"=",
"this",
".",
"__data__",
",",
"index",
"=",
"assocIndexOf",
"(",
"data",
",",
"key",
")",
"if",
"(",
"index",
"<",
"0",
")",
"{",
"return",
"false",
"}",
"var",
"lastIndex",
"="... | Removes `key` and its value from the list cache.
@private
@name delete
@memberOf ListCache
@param {string} key The key of the value to remove.
@returns {boolean} Returns `true` if the entry was removed, else `false`. | [
"Removes",
"key",
"and",
"its",
"value",
"from",
"the",
"list",
"cache",
"."
] | 274e76d731d7f158141287e31cbd51f092d472c5 | https://github.com/NervJS/taro/blob/274e76d731d7f158141287e31cbd51f092d472c5/packages/taro/src/internal/_common.js#L273-L287 | train | Delete a cache item | [
30522,
3853,
2862,
3540,
7690,
12260,
2618,
1006,
3145,
1007,
1063,
13075,
2951,
1027,
2023,
1012,
1035,
1035,
2951,
1035,
1035,
1010,
5950,
1027,
4632,
10085,
22254,
10288,
11253,
1006,
2951,
1010,
3145,
1007,
2065,
1006,
5950,
1026,
1014,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular/material | src/core/services/registry/componentRegistry.js | ComponentRegistry | function ComponentRegistry($log, $q) {
var self;
var instances = [];
var pendings = { };
return self = {
/**
* Used to print an error when an instance for a handle isn't found.
*/
notFoundError: function(handle, msgContext) {
$log.error((msgContext || "") + 'No instance found for handle', handle);
},
/**
* Return all registered instances as an array.
*/
getInstances: function() {
return instances;
},
/**
* Get a registered instance.
* @param handle the String handle to look up for a registered instance.
*/
get: function(handle) {
if (!isValidID(handle)) return null;
var i, j, instance;
for (i = 0, j = instances.length; i < j; i++) {
instance = instances[i];
if (instance.$$mdHandle === handle) {
return instance;
}
}
return null;
},
/**
* Register an instance.
* @param instance the instance to register
* @param handle the handle to identify the instance under.
*/
register: function(instance, handle) {
if (!handle) return angular.noop;
instance.$$mdHandle = handle;
instances.push(instance);
resolveWhen();
return deregister;
/**
* Remove registration for an instance
*/
function deregister() {
var index = instances.indexOf(instance);
if (index !== -1) {
instances.splice(index, 1);
}
}
/**
* Resolve any pending promises for this instance
*/
function resolveWhen() {
var dfd = pendings[handle];
if (dfd) {
dfd.forEach(function (promise) {
promise.resolve(instance);
});
delete pendings[handle];
}
}
},
/**
* Async accessor to registered component instance
* If not available then a promise is created to notify
* all listeners when the instance is registered.
*/
when : function(handle) {
if (isValidID(handle)) {
var deferred = $q.defer();
var instance = self.get(handle);
if (instance) {
deferred.resolve(instance);
} else {
if (pendings[handle] === undefined) {
pendings[handle] = [];
}
pendings[handle].push(deferred);
}
return deferred.promise;
}
return $q.reject("Invalid `md-component-id` value.");
}
};
function isValidID(handle){
return handle && (handle !== "");
}
} | javascript | function ComponentRegistry($log, $q) {
var self;
var instances = [];
var pendings = { };
return self = {
/**
* Used to print an error when an instance for a handle isn't found.
*/
notFoundError: function(handle, msgContext) {
$log.error((msgContext || "") + 'No instance found for handle', handle);
},
/**
* Return all registered instances as an array.
*/
getInstances: function() {
return instances;
},
/**
* Get a registered instance.
* @param handle the String handle to look up for a registered instance.
*/
get: function(handle) {
if (!isValidID(handle)) return null;
var i, j, instance;
for (i = 0, j = instances.length; i < j; i++) {
instance = instances[i];
if (instance.$$mdHandle === handle) {
return instance;
}
}
return null;
},
/**
* Register an instance.
* @param instance the instance to register
* @param handle the handle to identify the instance under.
*/
register: function(instance, handle) {
if (!handle) return angular.noop;
instance.$$mdHandle = handle;
instances.push(instance);
resolveWhen();
return deregister;
/**
* Remove registration for an instance
*/
function deregister() {
var index = instances.indexOf(instance);
if (index !== -1) {
instances.splice(index, 1);
}
}
/**
* Resolve any pending promises for this instance
*/
function resolveWhen() {
var dfd = pendings[handle];
if (dfd) {
dfd.forEach(function (promise) {
promise.resolve(instance);
});
delete pendings[handle];
}
}
},
/**
* Async accessor to registered component instance
* If not available then a promise is created to notify
* all listeners when the instance is registered.
*/
when : function(handle) {
if (isValidID(handle)) {
var deferred = $q.defer();
var instance = self.get(handle);
if (instance) {
deferred.resolve(instance);
} else {
if (pendings[handle] === undefined) {
pendings[handle] = [];
}
pendings[handle].push(deferred);
}
return deferred.promise;
}
return $q.reject("Invalid `md-component-id` value.");
}
};
function isValidID(handle){
return handle && (handle !== "");
}
} | [
"function",
"ComponentRegistry",
"(",
"$log",
",",
"$q",
")",
"{",
"var",
"self",
";",
"var",
"instances",
"=",
"[",
"]",
";",
"var",
"pendings",
"=",
"{",
"}",
";",
"return",
"self",
"=",
"{",
"/**\n * Used to print an error when an instance for a handle ... | /*
@private
@ngdoc factory
@name ComponentRegistry
@module material.core.componentRegistry | [
"/",
"*",
"@private",
"@ngdoc",
"factory",
"@name",
"ComponentRegistry",
"@module",
"material",
".",
"core",
".",
"componentRegistry"
] | 84ac558674e73958be84312444c48d9f823f6684 | https://github.com/angular/material/blob/84ac558674e73958be84312444c48d9f823f6684/src/core/services/registry/componentRegistry.js#L19-L124 | train | ComponentRegistry constructor. | [
30522,
3853,
6922,
2890,
24063,
2854,
1006,
1002,
8833,
1010,
1002,
1053,
1007,
1063,
13075,
2969,
1025,
13075,
12107,
1027,
1031,
1033,
1025,
13075,
14223,
2015,
1027,
1063,
1065,
1025,
2709,
2969,
1027,
1063,
1013,
1008,
1008,
1008,
2109,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
uber/deck.gl | modules/layers/src/solid-polygon-layer/polygon.js | isFlatRingClosed | function isFlatRingClosed(positions, size, startIndex, endIndex) {
for (let i = 0; i < size; i++) {
if (positions[startIndex + i] !== positions[endIndex - size + i]) {
return false;
}
}
return true;
} | javascript | function isFlatRingClosed(positions, size, startIndex, endIndex) {
for (let i = 0; i < size; i++) {
if (positions[startIndex + i] !== positions[endIndex - size + i]) {
return false;
}
}
return true;
} | [
"function",
"isFlatRingClosed",
"(",
"positions",
",",
"size",
",",
"startIndex",
",",
"endIndex",
")",
"{",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"if",
"(",
"positions",
"[",
"startIndex",
"+",
"i",
"]"... | Check if a simple flat array is a closed ring
@param {Array} positions - array of numbers
@param {Number} size - size of a position, 2 (xy) or 3 (xyz)
@param {Number} startIndex - start index of the path in the positions array
@param {Number} endIndex - end index of the path in the positions array
@return {Boolean} - true if the simple flat array is a closed ring | [
"Check",
"if",
"a",
"simple",
"flat",
"array",
"is",
"a",
"closed",
"ring"
] | a2010448b7f268bbd03617b812334c68a6b9e5b2 | https://github.com/uber/deck.gl/blob/a2010448b7f268bbd03617b812334c68a6b9e5b2/modules/layers/src/solid-polygon-layer/polygon.js#L73-L80 | train | Check if a flat ring is closed | [
30522,
3853,
2003,
10258,
4017,
4892,
20464,
24768,
1006,
4460,
1010,
2946,
1010,
2707,
22254,
10288,
1010,
2203,
22254,
10288,
1007,
1063,
2005,
1006,
2292,
1045,
1027,
1014,
1025,
1045,
1026,
2946,
1025,
1045,
1009,
1009,
1007,
1063,
2065... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js | initializeState | function initializeState(requester, updateParams) {
var currentRequester = requester || "";
_updateParams = updateParams;
installerPath = path.resolve(updateDir, updateParams.installerName);
postMessageToBrackets(MessageIds.NOTIFY_INITIALIZATION_COMPLETE, currentRequester);
} | javascript | function initializeState(requester, updateParams) {
var currentRequester = requester || "";
_updateParams = updateParams;
installerPath = path.resolve(updateDir, updateParams.installerName);
postMessageToBrackets(MessageIds.NOTIFY_INITIALIZATION_COMPLETE, currentRequester);
} | [
"function",
"initializeState",
"(",
"requester",
",",
"updateParams",
")",
"{",
"var",
"currentRequester",
"=",
"requester",
"||",
"\"\"",
";",
"_updateParams",
"=",
"updateParams",
";",
"installerPath",
"=",
"path",
".",
"resolve",
"(",
"updateDir",
",",
"updat... | Initializes the node with update parameters
@param {object} updateParams - json containing update parameters | [
"Initializes",
"the",
"node",
"with",
"update",
"parameters"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/extensions/default/AutoUpdate/node/AutoUpdateDomain.js#L388-L393 | train | Initialize the state of the project | [
30522,
3853,
3988,
10057,
12259,
1006,
5227,
2121,
1010,
10651,
28689,
5244,
1007,
1063,
13075,
2783,
2890,
15500,
2121,
1027,
5227,
2121,
1064,
1064,
1000,
1000,
1025,
1035,
10651,
28689,
5244,
1027,
10651,
28689,
5244,
1025,
16500,
2121,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
adobe/brackets | src/widgets/StatusBar.js | showBusyIndicator | function showBusyIndicator(updateCursor) {
if (!_init) {
console.error("StatusBar API invoked before status bar created");
return;
}
if (updateCursor) {
_busyCursor = true;
$("*").addClass("busyCursor");
}
$busyIndicator.addClass("spin");
} | javascript | function showBusyIndicator(updateCursor) {
if (!_init) {
console.error("StatusBar API invoked before status bar created");
return;
}
if (updateCursor) {
_busyCursor = true;
$("*").addClass("busyCursor");
}
$busyIndicator.addClass("spin");
} | [
"function",
"showBusyIndicator",
"(",
"updateCursor",
")",
"{",
"if",
"(",
"!",
"_init",
")",
"{",
"console",
".",
"error",
"(",
"\"StatusBar API invoked before status bar created\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"updateCursor",
")",
"{",
"_busyCurso... | Shows the 'busy' indicator
@param {boolean} updateCursor Sets the cursor to "wait" | [
"Shows",
"the",
"busy",
"indicator"
] | d5d00d43602c438266d32b8eda8f8a3ca937b524 | https://github.com/adobe/brackets/blob/d5d00d43602c438266d32b8eda8f8a3ca937b524/src/widgets/StatusBar.js#L58-L70 | train | show busy indicator | [
30522,
3853,
2265,
8286,
25811,
14808,
8844,
1006,
10651,
30524,
10122,
1012,
7561,
1006,
1000,
3570,
8237,
17928,
24959,
2077,
3570,
3347,
2580,
1000,
1007,
1025,
2709,
1025,
1065,
2065,
1006,
10651,
10841,
25301,
2099,
1007,
1063,
1035,
5... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
tgriesser/knex | src/migrate/Migrator.js | validateMigrationList | function validateMigrationList(migrationSource, migrations) {
const all = migrations[0];
const completed = migrations[1];
const diff = getMissingMigrations(migrationSource, completed, all);
if (!isEmpty(diff)) {
throw new Error(
`The migration directory is corrupt, the following files are missing: ${diff.join(
', '
)}`
);
}
} | javascript | function validateMigrationList(migrationSource, migrations) {
const all = migrations[0];
const completed = migrations[1];
const diff = getMissingMigrations(migrationSource, completed, all);
if (!isEmpty(diff)) {
throw new Error(
`The migration directory is corrupt, the following files are missing: ${diff.join(
', '
)}`
);
}
} | [
"function",
"validateMigrationList",
"(",
"migrationSource",
",",
"migrations",
")",
"{",
"const",
"all",
"=",
"migrations",
"[",
"0",
"]",
";",
"const",
"completed",
"=",
"migrations",
"[",
"1",
"]",
";",
"const",
"diff",
"=",
"getMissingMigrations",
"(",
"... | Validates that migrations are present in the appropriate directories. | [
"Validates",
"that",
"migrations",
"are",
"present",
"in",
"the",
"appropriate",
"directories",
"."
] | 6a4fecfe7822442ee5c43d924958eadfe6e17a93 | https://github.com/tgriesser/knex/blob/6a4fecfe7822442ee5c43d924958eadfe6e17a93/src/migrate/Migrator.js#L459-L470 | train | Validate the migration list | [
30522,
3853,
9398,
3686,
4328,
29397,
9863,
1006,
9230,
6499,
3126,
3401,
1010,
9230,
2015,
1007,
1063,
9530,
3367,
2035,
1027,
9230,
2015,
1031,
1014,
1033,
1025,
9530,
3367,
2949,
1027,
9230,
2015,
1031,
1015,
1033,
1025,
9530,
3367,
44... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
grpc/grpc | examples/node/static_codegen/route_guide/route_guide_server.js | getServer | function getServer() {
var server = new grpc.Server();
server.addService(services.RouteGuideService, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
routeChat: routeChat
});
return server;
} | javascript | function getServer() {
var server = new grpc.Server();
server.addService(services.RouteGuideService, {
getFeature: getFeature,
listFeatures: listFeatures,
recordRoute: recordRoute,
routeChat: routeChat
});
return server;
} | [
"function",
"getServer",
"(",
")",
"{",
"var",
"server",
"=",
"new",
"grpc",
".",
"Server",
"(",
")",
";",
"server",
".",
"addService",
"(",
"services",
".",
"RouteGuideService",
",",
"{",
"getFeature",
":",
"getFeature",
",",
"listFeatures",
":",
"listFea... | Get a new server with the handler functions in this file bound to the methods
it serves.
@return {Server} The new server object | [
"Get",
"a",
"new",
"server",
"with",
"the",
"handler",
"functions",
"in",
"this",
"file",
"bound",
"to",
"the",
"methods",
"it",
"serves",
"."
] | cc75d93818410e2b0edd0fa3009a6def9ac403ca | https://github.com/grpc/grpc/blob/cc75d93818410e2b0edd0fa3009a6def9ac403ca/examples/node/static_codegen/route_guide/route_guide_server.js#L209-L218 | train | Returns a new server | [
30522,
3853,
4152,
2121,
6299,
1006,
1007,
1063,
13075,
8241,
1027,
2047,
24665,
15042,
1012,
8241,
30524,
1012,
2799,
28582,
8043,
7903,
2063,
1010,
1063,
2131,
7959,
4017,
5397,
1024,
2131,
7959,
4017,
5397,
1010,
2862,
7959,
4017,
14900,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.