id int32 0 58k | repo stringlengths 5 67 | path stringlengths 4 116 | func_name stringlengths 0 58 | original_string stringlengths 52 373k | language stringclasses 1
value | code stringlengths 52 373k | code_tokens list | docstring stringlengths 4 11.8k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 86 226 |
|---|---|---|---|---|---|---|---|---|---|---|---|
10,200 | NaturalNode/natural | lib/natural/stemmers/porter_stemmer_fr.js | regions | function regions(token) {
var r1, r2, rv, len;
var i;
r1 = r2 = rv = len = token.length;
// R1 is the region after the first non-vowel following a vowel,
for (var i = 0; i < len - 1 && r1 == len; i++) {
if (isVowel(token[i]) && !isVowel(token[i + 1])) {
r1 = i + 2;
}
}
// Or is the null region at the end of the word if there is no such non-vowel.
// R2 is the region after the first non-vowel following a vowel in R1
for (i = r1; i < len - 1 && r2 == len; i++) {
if (isVowel(token[i]) && !isVowel(token[i + 1])) {
r2 = i + 2;
}
}
// Or is the null region at the end of the word if there is no such non-vowel.
// RV region
var three = token.slice(0, 3);
if (isVowel(token[0]) && isVowel(token[1])) {
rv = 3;
}
if (three === 'par' || three == 'col' || three === 'tap')
rv = 3;
// the region after the first vowel not at the beginning of the word or null
else {
for (i = 1; i < len - 1 && rv == len; i++) {
if (isVowel(token[i])) {
rv = i + 1;
}
}
}
return {
r1: r1,
r2: r2,
rv: rv
};
} | javascript | function regions(token) {
var r1, r2, rv, len;
var i;
r1 = r2 = rv = len = token.length;
// R1 is the region after the first non-vowel following a vowel,
for (var i = 0; i < len - 1 && r1 == len; i++) {
if (isVowel(token[i]) && !isVowel(token[i + 1])) {
r1 = i + 2;
}
}
// Or is the null region at the end of the word if there is no such non-vowel.
// R2 is the region after the first non-vowel following a vowel in R1
for (i = r1; i < len - 1 && r2 == len; i++) {
if (isVowel(token[i]) && !isVowel(token[i + 1])) {
r2 = i + 2;
}
}
// Or is the null region at the end of the word if there is no such non-vowel.
// RV region
var three = token.slice(0, 3);
if (isVowel(token[0]) && isVowel(token[1])) {
rv = 3;
}
if (three === 'par' || three == 'col' || three === 'tap')
rv = 3;
// the region after the first vowel not at the beginning of the word or null
else {
for (i = 1; i < len - 1 && rv == len; i++) {
if (isVowel(token[i])) {
rv = i + 1;
}
}
}
return {
r1: r1,
r2: r2,
rv: rv
};
} | [
"function",
"regions",
"(",
"token",
")",
"{",
"var",
"r1",
",",
"r2",
",",
"rv",
",",
"len",
";",
"var",
"i",
";",
"r1",
"=",
"r2",
"=",
"rv",
"=",
"len",
"=",
"token",
".",
"length",
";",
"// R1 is the region after the first non-vowel following a vowel,"... | Compute r1, r2, rv regions as required by french porter stemmer algorithm
@param {String} token Word to compute regions on
@return {Object} Regions r1, r2, rv as offsets from the begining of the word | [
"Compute",
"r1",
"r2",
"rv",
"regions",
"as",
"required",
"by",
"french",
"porter",
"stemmer",
"algorithm"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_fr.js#L274-L317 |
10,201 | NaturalNode/natural | lib/natural/stemmers/porter_stemmer_fr.js | endsinArr | function endsinArr(token, suffixes) {
var i, longest = '';
for (i = 0; i < suffixes.length; i++) {
if (endsin(token, suffixes[i]) && suffixes[i].length > longest.length)
longest = suffixes[i];
}
return longest;
} | javascript | function endsinArr(token, suffixes) {
var i, longest = '';
for (i = 0; i < suffixes.length; i++) {
if (endsin(token, suffixes[i]) && suffixes[i].length > longest.length)
longest = suffixes[i];
}
return longest;
} | [
"function",
"endsinArr",
"(",
"token",
",",
"suffixes",
")",
"{",
"var",
"i",
",",
"longest",
"=",
"''",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"suffixes",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"endsin",
"(",
"token",
",",... | Return longest matching suffixes for a token or '' if no suffix match
@param {String} token Word to find matching suffix
@param {Array} suffixes Array of suffixes to test matching
@return {String} Longest found matching suffix or '' | [
"Return",
"longest",
"matching",
"suffixes",
"for",
"a",
"token",
"or",
"if",
"no",
"suffix",
"match"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_fr.js#L358-L366 |
10,202 | NaturalNode/natural | lib/natural/phonetics/dm_soundex.js | normalizeLength | function normalizeLength(token, length) {
length = length || 6;
if (token.length < length) {
token += (new Array(length - token.length + 1)).join('0');
}
return token.slice(0, length);
} | javascript | function normalizeLength(token, length) {
length = length || 6;
if (token.length < length) {
token += (new Array(length - token.length + 1)).join('0');
}
return token.slice(0, length);
} | [
"function",
"normalizeLength",
"(",
"token",
",",
"length",
")",
"{",
"length",
"=",
"length",
"||",
"6",
";",
"if",
"(",
"token",
".",
"length",
"<",
"length",
")",
"{",
"token",
"+=",
"(",
"new",
"Array",
"(",
"length",
"-",
"token",
".",
"length",... | Pad right with zeroes or cut excess symbols to fit length | [
"Pad",
"right",
"with",
"zeroes",
"or",
"cut",
"excess",
"symbols",
"to",
"fit",
"length"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/phonetics/dm_soundex.js#L235-L241 |
10,203 | NaturalNode/natural | lib/natural/distance/levenshtein_distance.js | _getMatchStart | function _getMatchStart(distanceMatrix, matchEnd, sourceLength) {
var row = sourceLength;
var column = matchEnd;
var tmpRow;
var tmpColumn;
// match will be empty string
if (matchEnd === 0) { return 0; }
while(row > 1 && column > 1) {
tmpRow = row;
tmpColumn = column;
row = distanceMatrix[tmpRow][tmpColumn].parentCell.row;
column = distanceMatrix[tmpRow][tmpColumn].parentCell.column;
}
return column-1;
} | javascript | function _getMatchStart(distanceMatrix, matchEnd, sourceLength) {
var row = sourceLength;
var column = matchEnd;
var tmpRow;
var tmpColumn;
// match will be empty string
if (matchEnd === 0) { return 0; }
while(row > 1 && column > 1) {
tmpRow = row;
tmpColumn = column;
row = distanceMatrix[tmpRow][tmpColumn].parentCell.row;
column = distanceMatrix[tmpRow][tmpColumn].parentCell.column;
}
return column-1;
} | [
"function",
"_getMatchStart",
"(",
"distanceMatrix",
",",
"matchEnd",
",",
"sourceLength",
")",
"{",
"var",
"row",
"=",
"sourceLength",
";",
"var",
"column",
"=",
"matchEnd",
";",
"var",
"tmpRow",
";",
"var",
"tmpColumn",
";",
"// match will be empty string",
"i... | Walk the path back from the matchEnd to the beginning of the match. Do this by traversing the distanceMatrix as you would a linked list, following going from cell child to parent until reach row 0. | [
"Walk",
"the",
"path",
"back",
"from",
"the",
"matchEnd",
"to",
"the",
"beginning",
"of",
"the",
"match",
".",
"Do",
"this",
"by",
"traversing",
"the",
"distanceMatrix",
"as",
"you",
"would",
"a",
"linked",
"list",
"following",
"going",
"from",
"cell",
"ch... | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/distance/levenshtein_distance.js#L37-L54 |
10,204 | NaturalNode/natural | lib/natural/stemmers/indonesian/prefix_rules.js | runDisambiguator | function runDisambiguator(disambiguateRules, word){
var result = undefined;
for(var i in disambiguateRules){
result = disambiguateRules[i](word);
if(find(result)){
break;
}
}
if(result==undefined){
this.current_word = word;
this.removal = undefined;
return this;
}
return createResultObject(result, word, "DP");
} | javascript | function runDisambiguator(disambiguateRules, word){
var result = undefined;
for(var i in disambiguateRules){
result = disambiguateRules[i](word);
if(find(result)){
break;
}
}
if(result==undefined){
this.current_word = word;
this.removal = undefined;
return this;
}
return createResultObject(result, word, "DP");
} | [
"function",
"runDisambiguator",
"(",
"disambiguateRules",
",",
"word",
")",
"{",
"var",
"result",
"=",
"undefined",
";",
"for",
"(",
"var",
"i",
"in",
"disambiguateRules",
")",
"{",
"result",
"=",
"disambiguateRules",
"[",
"i",
"]",
"(",
"word",
")",
";",
... | Run the array of disambiguate rules on input word | [
"Run",
"the",
"array",
"of",
"disambiguate",
"rules",
"on",
"input",
"word"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/prefix_rules.js#L52-L69 |
10,205 | NaturalNode/natural | lib/natural/stemmers/indonesian/stemmer_id.js | stemPluralWord | function stemPluralWord(plural_word){
var matches = plural_word.match(/^(.*)-(.*)$/);
if(!matches){
return plural_word;
}
words = [matches[1], matches[2]];
//malaikat-malaikat-nya -> malaikat malaikat-nya
suffix = words[1];
suffixes = ["ku", "mu", "nya", "lah", "kah", "tah", "pun"];
matches = words[0].match(/^(.*)-(.*)$/);
if(suffixes.indexOf(suffix) != -1 && matches){
words[0] = matches[1];
words[1] = matches[2] + '-' + suffix;
}
//berbalas-balasan -> balas
rootWord1 = stemSingularWord(words[0]);
rootWord2 = stemSingularWord(words[1]);
//meniru-nirukan -> tiru
if(!find(words[1]) && rootWord2==words[1]){
rootWord2 = stemSingularWord("me" + words[1]);
}
if(rootWord1==rootWord2){
return rootWord1;
}
else{
return plural_word;
}
} | javascript | function stemPluralWord(plural_word){
var matches = plural_word.match(/^(.*)-(.*)$/);
if(!matches){
return plural_word;
}
words = [matches[1], matches[2]];
//malaikat-malaikat-nya -> malaikat malaikat-nya
suffix = words[1];
suffixes = ["ku", "mu", "nya", "lah", "kah", "tah", "pun"];
matches = words[0].match(/^(.*)-(.*)$/);
if(suffixes.indexOf(suffix) != -1 && matches){
words[0] = matches[1];
words[1] = matches[2] + '-' + suffix;
}
//berbalas-balasan -> balas
rootWord1 = stemSingularWord(words[0]);
rootWord2 = stemSingularWord(words[1]);
//meniru-nirukan -> tiru
if(!find(words[1]) && rootWord2==words[1]){
rootWord2 = stemSingularWord("me" + words[1]);
}
if(rootWord1==rootWord2){
return rootWord1;
}
else{
return plural_word;
}
} | [
"function",
"stemPluralWord",
"(",
"plural_word",
")",
"{",
"var",
"matches",
"=",
"plural_word",
".",
"match",
"(",
"/",
"^(.*)-(.*)$",
"/",
")",
";",
"if",
"(",
"!",
"matches",
")",
"{",
"return",
"plural_word",
";",
"}",
"words",
"=",
"[",
"matches",
... | Stem for plural word | [
"Stem",
"for",
"plural",
"word"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L64-L94 |
10,206 | NaturalNode/natural | lib/natural/stemmers/indonesian/stemmer_id.js | stemSingularWord | function stemSingularWord(word){
original_word = word; // Save the original word for reverting later
current_word = word;
// Step 1
if(current_word.length>3){
// Step 2-5
stemmingProcess();
}
// Step 6
if(find(current_word)){
return current_word;
}
else{
return original_word;
}
} | javascript | function stemSingularWord(word){
original_word = word; // Save the original word for reverting later
current_word = word;
// Step 1
if(current_word.length>3){
// Step 2-5
stemmingProcess();
}
// Step 6
if(find(current_word)){
return current_word;
}
else{
return original_word;
}
} | [
"function",
"stemSingularWord",
"(",
"word",
")",
"{",
"original_word",
"=",
"word",
";",
"// Save the original word for reverting later",
"current_word",
"=",
"word",
";",
"// Step 1",
"if",
"(",
"current_word",
".",
"length",
">",
"3",
")",
"{",
"// Step 2-5",
"... | Stem for singular word | [
"Stem",
"for",
"singular",
"word"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L97-L114 |
10,207 | NaturalNode/natural | lib/natural/stemmers/indonesian/stemmer_id.js | loopRestorePrefixes | function loopRestorePrefixes(){
restorePrefix();
var reversed_removals = removals.reverse();
var temp_current_word = current_word;
for(var i in reversed_removals){
current_removal = reversed_removals[i];
if(!isSuffixRemovals(current_removal)){
continue
}
if(current_removal.getRemovedPart() == "kan"){
current_word = current_removal.getResult() + "k";
// Step 4, 5
removePrefixes();
if(find(current_word))
return
current_word = current_removal.getResult() + "kan";
}
else{
current_word = current_removal.getOriginalWord();
}
// Step 4, 5
removePrefixes();
if(find(current_word))
return
current_word = temp_current_word;
}
} | javascript | function loopRestorePrefixes(){
restorePrefix();
var reversed_removals = removals.reverse();
var temp_current_word = current_word;
for(var i in reversed_removals){
current_removal = reversed_removals[i];
if(!isSuffixRemovals(current_removal)){
continue
}
if(current_removal.getRemovedPart() == "kan"){
current_word = current_removal.getResult() + "k";
// Step 4, 5
removePrefixes();
if(find(current_word))
return
current_word = current_removal.getResult() + "kan";
}
else{
current_word = current_removal.getOriginalWord();
}
// Step 4, 5
removePrefixes();
if(find(current_word))
return
current_word = temp_current_word;
}
} | [
"function",
"loopRestorePrefixes",
"(",
")",
"{",
"restorePrefix",
"(",
")",
";",
"var",
"reversed_removals",
"=",
"removals",
".",
"reverse",
"(",
")",
";",
"var",
"temp_current_word",
"=",
"current_word",
";",
"for",
"(",
"var",
"i",
"in",
"reversed_removals... | Loop Restore Prefixes | [
"Loop",
"Restore",
"Prefixes"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L226-L259 |
10,208 | NaturalNode/natural | lib/natural/stemmers/indonesian/stemmer_id.js | precedenceAdjustmentSpecification | function precedenceAdjustmentSpecification(word){
var regex_rules = [
/^be(.*)lah$/,
/^be(.*)an$/,
/^me(.*)i$/,
/^di(.*)i$/,
/^pe(.*)i$/,
/^ter(.*)i$/,
];
for(var i in regex_rules){
if(word.match(regex_rules[i])){
return true;
}
}
return false;
} | javascript | function precedenceAdjustmentSpecification(word){
var regex_rules = [
/^be(.*)lah$/,
/^be(.*)an$/,
/^me(.*)i$/,
/^di(.*)i$/,
/^pe(.*)i$/,
/^ter(.*)i$/,
];
for(var i in regex_rules){
if(word.match(regex_rules[i])){
return true;
}
}
return false;
} | [
"function",
"precedenceAdjustmentSpecification",
"(",
"word",
")",
"{",
"var",
"regex_rules",
"=",
"[",
"/",
"^be(.*)lah$",
"/",
",",
"/",
"^be(.*)an$",
"/",
",",
"/",
"^me(.*)i$",
"/",
",",
"/",
"^di(.*)i$",
"/",
",",
"/",
"^pe(.*)i$",
"/",
",",
"/",
"^... | Check if word require precedence adjustment or not Adjustment means remove prefix then suffix instead of remove suffix then prefix | [
"Check",
"if",
"word",
"require",
"precedence",
"adjustment",
"or",
"not",
"Adjustment",
"means",
"remove",
"prefix",
"then",
"suffix",
"instead",
"of",
"remove",
"suffix",
"then",
"prefix"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/stemmer_id.js#L284-L300 |
10,209 | NaturalNode/natural | lib/natural/stemmers/porter_stemmer.js | attemptReplace | function attemptReplace(token, pattern, replacement, callback) {
var result = null;
if((typeof pattern == 'string') && token.substr(0 - pattern.length) == pattern)
result = token.replace(new RegExp(pattern + '$'), replacement);
else if((pattern instanceof RegExp) && token.match(pattern))
result = token.replace(pattern, replacement);
if(result && callback)
return callback(result);
else
return result;
} | javascript | function attemptReplace(token, pattern, replacement, callback) {
var result = null;
if((typeof pattern == 'string') && token.substr(0 - pattern.length) == pattern)
result = token.replace(new RegExp(pattern + '$'), replacement);
else if((pattern instanceof RegExp) && token.match(pattern))
result = token.replace(pattern, replacement);
if(result && callback)
return callback(result);
else
return result;
} | [
"function",
"attemptReplace",
"(",
"token",
",",
"pattern",
",",
"replacement",
",",
"callback",
")",
"{",
"var",
"result",
"=",
"null",
";",
"if",
"(",
"(",
"typeof",
"pattern",
"==",
"'string'",
")",
"&&",
"token",
".",
"substr",
"(",
"0",
"-",
"patt... | replace a pattern in a word. if a replacement occurs an optional callback can be called to post-process the result. if no match is made NULL is returned. | [
"replace",
"a",
"pattern",
"in",
"a",
"word",
".",
"if",
"a",
"replacement",
"occurs",
"an",
"optional",
"callback",
"can",
"be",
"called",
"to",
"post",
"-",
"process",
"the",
"result",
".",
"if",
"no",
"match",
"is",
"made",
"NULL",
"is",
"returned",
... | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer.js#L53-L65 |
10,210 | NaturalNode/natural | lib/natural/stemmers/porter_stemmer_pt.js | function (start) {
var index = start || 0,
length = this.string.length,
region = length;
while (index < length - 1 && region === length) {
if (this.hasVowelAtIndex(index) && !this.hasVowelAtIndex(index + 1)) {
region = index + 2;
}
index++;
}
return region;
} | javascript | function (start) {
var index = start || 0,
length = this.string.length,
region = length;
while (index < length - 1 && region === length) {
if (this.hasVowelAtIndex(index) && !this.hasVowelAtIndex(index + 1)) {
region = index + 2;
}
index++;
}
return region;
} | [
"function",
"(",
"start",
")",
"{",
"var",
"index",
"=",
"start",
"||",
"0",
",",
"length",
"=",
"this",
".",
"string",
".",
"length",
",",
"region",
"=",
"length",
";",
"while",
"(",
"index",
"<",
"length",
"-",
"1",
"&&",
"region",
"===",
"length... | Marks a region after the first non-vowel following a vowel, or the
null region at the end of the word if there is no such non-vowel.
@param {Object} token Token to stem.
@param {Number} start Start index (defaults to 0).
@param {Number} Region start index. | [
"Marks",
"a",
"region",
"after",
"the",
"first",
"non",
"-",
"vowel",
"following",
"a",
"vowel",
"or",
"the",
"null",
"region",
"at",
"the",
"end",
"of",
"the",
"word",
"if",
"there",
"is",
"no",
"such",
"non",
"-",
"vowel",
"."
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_pt.js#L38-L51 | |
10,211 | NaturalNode/natural | lib/natural/stemmers/porter_stemmer_pt.js | function () {
var rv = this.string.length;
if (rv > 3) {
if (!this.hasVowelAtIndex(1)) {
rv = this.nextVowelIndex(2) + 1;
} else if (this.hasVowelAtIndex(0) && this.hasVowelAtIndex(1)) {
rv = this.nextConsonantIndex(2) + 1;
} else {
rv = 3;
}
}
return rv;
} | javascript | function () {
var rv = this.string.length;
if (rv > 3) {
if (!this.hasVowelAtIndex(1)) {
rv = this.nextVowelIndex(2) + 1;
} else if (this.hasVowelAtIndex(0) && this.hasVowelAtIndex(1)) {
rv = this.nextConsonantIndex(2) + 1;
} else {
rv = 3;
}
}
return rv;
} | [
"function",
"(",
")",
"{",
"var",
"rv",
"=",
"this",
".",
"string",
".",
"length",
";",
"if",
"(",
"rv",
">",
"3",
")",
"{",
"if",
"(",
"!",
"this",
".",
"hasVowelAtIndex",
"(",
"1",
")",
")",
"{",
"rv",
"=",
"this",
".",
"nextVowelIndex",
"(",... | Mark RV.
@param {Object} token Token to stem.
@return {Number} Region start index. | [
"Mark",
"RV",
"."
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/porter_stemmer_pt.js#L59-L75 | |
10,212 | NaturalNode/natural | lib/natural/stemmers/indonesian/removal.js | Removal | function Removal (original_word, result, removedPart, affixType) {
this.original_word = original_word;
this.result = result;
this.removedPart = removedPart
this.affixType = affixType;
} | javascript | function Removal (original_word, result, removedPart, affixType) {
this.original_word = original_word;
this.result = result;
this.removedPart = removedPart
this.affixType = affixType;
} | [
"function",
"Removal",
"(",
"original_word",
",",
"result",
",",
"removedPart",
",",
"affixType",
")",
"{",
"this",
".",
"original_word",
"=",
"original_word",
";",
"this",
".",
"result",
"=",
"result",
";",
"this",
".",
"removedPart",
"=",
"removedPart",
"t... | a list of commonly used words that have little meaning and can be excluded from analysis. | [
"a",
"list",
"of",
"commonly",
"used",
"words",
"that",
"have",
"little",
"meaning",
"and",
"can",
"be",
"excluded",
"from",
"analysis",
"."
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/indonesian/removal.js#L26-L31 |
10,213 | NaturalNode/natural | lib/natural/brill_pos_tagger/lib/Lexicon.js | Lexicon | function Lexicon(language, defaultCategory, defaultCategoryCapitalised) {
switch (language) {
case 'EN':
this.lexicon = englishLexicon;
break;
case 'DU':
this.lexicon = dutchLexicon;
break;
default:
this.lexicon = dutchLexicon;
break;
}
if (defaultCategory) {
this.defaultCategory = defaultCategory;
if (defaultCategoryCapitalised) {
this.defaultCategoryCapitalised = defaultCategoryCapitalised;
}
}
} | javascript | function Lexicon(language, defaultCategory, defaultCategoryCapitalised) {
switch (language) {
case 'EN':
this.lexicon = englishLexicon;
break;
case 'DU':
this.lexicon = dutchLexicon;
break;
default:
this.lexicon = dutchLexicon;
break;
}
if (defaultCategory) {
this.defaultCategory = defaultCategory;
if (defaultCategoryCapitalised) {
this.defaultCategoryCapitalised = defaultCategoryCapitalised;
}
}
} | [
"function",
"Lexicon",
"(",
"language",
",",
"defaultCategory",
",",
"defaultCategoryCapitalised",
")",
"{",
"switch",
"(",
"language",
")",
"{",
"case",
"'EN'",
":",
"this",
".",
"lexicon",
"=",
"englishLexicon",
";",
"break",
";",
"case",
"'DU'",
":",
"thi... | Constructor creates a Lexicon for language | [
"Constructor",
"creates",
"a",
"Lexicon",
"for",
"language"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/brill_pos_tagger/lib/Lexicon.js#L26-L44 |
10,214 | NaturalNode/natural | lib/natural/util/topological.js | function(g) {
this.isDag = true;
this.sorted = topoSort(uniqueVertexs(g.edges()), g.edges());
} | javascript | function(g) {
this.isDag = true;
this.sorted = topoSort(uniqueVertexs(g.edges()), g.edges());
} | [
"function",
"(",
"g",
")",
"{",
"this",
".",
"isDag",
"=",
"true",
";",
"this",
".",
"sorted",
"=",
"topoSort",
"(",
"uniqueVertexs",
"(",
"g",
".",
"edges",
"(",
")",
")",
",",
"g",
".",
"edges",
"(",
")",
")",
";",
"}"
] | a topo sort for a digraph
@param {Digraph} | [
"a",
"topo",
"sort",
"for",
"a",
"digraph"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/util/topological.js#L28-L31 | |
10,215 | NaturalNode/natural | lib/natural/stemmers/lancaster_stemmer.js | applyRuleSection | function applyRuleSection(token, intact) {
var section = token.substr( - 1);
var rules = ruleTable[section];
if (rules) {
for (var i = 0; i < rules.length; i++) {
if ((intact || !rules[i].intact)
// only apply intact rules to intact tokens
&& token.substr(0 - rules[i].pattern.length) == rules[i].pattern) {
// hack off only as much as the rule indicates
var result = token.substr(0, token.length - rules[i].size);
// if the rules wants us to apply an appendage do so
if (rules[i].appendage)
result += rules[i].appendage;
if (acceptable(result)) {
token = result;
// see what the rules wants to do next
if (rules[i].continuation) {
// this rule thinks there still might be stem left. keep at it.
// since we've applied a change we'll pass false in for intact
return applyRuleSection(result, false);
} else {
// the rule thinks we're done stemming. drop out.
return result;
}
}
}
}
}
return token;
} | javascript | function applyRuleSection(token, intact) {
var section = token.substr( - 1);
var rules = ruleTable[section];
if (rules) {
for (var i = 0; i < rules.length; i++) {
if ((intact || !rules[i].intact)
// only apply intact rules to intact tokens
&& token.substr(0 - rules[i].pattern.length) == rules[i].pattern) {
// hack off only as much as the rule indicates
var result = token.substr(0, token.length - rules[i].size);
// if the rules wants us to apply an appendage do so
if (rules[i].appendage)
result += rules[i].appendage;
if (acceptable(result)) {
token = result;
// see what the rules wants to do next
if (rules[i].continuation) {
// this rule thinks there still might be stem left. keep at it.
// since we've applied a change we'll pass false in for intact
return applyRuleSection(result, false);
} else {
// the rule thinks we're done stemming. drop out.
return result;
}
}
}
}
}
return token;
} | [
"function",
"applyRuleSection",
"(",
"token",
",",
"intact",
")",
"{",
"var",
"section",
"=",
"token",
".",
"substr",
"(",
"-",
"1",
")",
";",
"var",
"rules",
"=",
"ruleTable",
"[",
"section",
"]",
";",
"if",
"(",
"rules",
")",
"{",
"for",
"(",
"va... | take a token, look up the applicatble rule section and attempt some stemming! | [
"take",
"a",
"token",
"look",
"up",
"the",
"applicatble",
"rule",
"section",
"and",
"attempt",
"some",
"stemming!"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/stemmers/lancaster_stemmer.js#L34-L68 |
10,216 | NaturalNode/natural | lib/natural/classifiers/maxent/POS/POS_Element.js | currentWord | function currentWord(x) {
if ((x.b.data.wordWindow["0"] === token) &&
(x.a === tag)) {
return 1;
}
return 0;
} | javascript | function currentWord(x) {
if ((x.b.data.wordWindow["0"] === token) &&
(x.a === tag)) {
return 1;
}
return 0;
} | [
"function",
"currentWord",
"(",
"x",
")",
"{",
"if",
"(",
"(",
"x",
".",
"b",
".",
"data",
".",
"wordWindow",
"[",
"\"0\"",
"]",
"===",
"token",
")",
"&&",
"(",
"x",
".",
"a",
"===",
"tag",
")",
")",
"{",
"return",
"1",
";",
"}",
"return",
"0... | Feature for the current word | [
"Feature",
"for",
"the",
"current",
"word"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/classifiers/maxent/POS/POS_Element.js#L37-L43 |
10,217 | NaturalNode/natural | lib/natural/ngrams/ngrams.js | countNgrams | function countNgrams(ngram) {
nrOfNgrams++;
var key = arrayToKey(ngram);
if (!frequencies[key]) {
frequencies[key] = 0;
}
frequencies[key]++;
} | javascript | function countNgrams(ngram) {
nrOfNgrams++;
var key = arrayToKey(ngram);
if (!frequencies[key]) {
frequencies[key] = 0;
}
frequencies[key]++;
} | [
"function",
"countNgrams",
"(",
"ngram",
")",
"{",
"nrOfNgrams",
"++",
";",
"var",
"key",
"=",
"arrayToKey",
"(",
"ngram",
")",
";",
"if",
"(",
"!",
"frequencies",
"[",
"key",
"]",
")",
"{",
"frequencies",
"[",
"key",
"]",
"=",
"0",
";",
"}",
"freq... | Updates the statistics for the new ngram | [
"Updates",
"the",
"statistics",
"for",
"the",
"new",
"ngram"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/ngrams/ngrams.js#L62-L69 |
10,218 | NaturalNode/natural | lib/natural/ngrams/ngrams.js | function(sequence, n, startSymbol, endSymbol, stats) {
var result = [];
frequencies = {};
nrOfNgrams = 0;
if (!_(sequence).isArray()) {
sequence = tokenizer.tokenize(sequence);
}
var count = _.max([0, sequence.length - n + 1]);
// Check for left padding
if(typeof startSymbol !== "undefined" && startSymbol !== null) {
// Create an array of (n) start symbols
var blanks = [];
for(var i = 0 ; i < n ; i++) {
blanks.push(startSymbol);
}
// Create the left padding
for(var p = n - 1 ; p > 0 ; p--) {
// Create a tuple of (p) start symbols and (n - p) words
var ngram = blanks.slice(0, p).concat(sequence.slice(0, n - p));
result.push(ngram);
if (stats) {
countNgrams(ngram);
}
}
}
// Build the complete ngrams
for (var i = 0; i < count; i++) {
var ngram = sequence.slice(i, i + n);
result.push(ngram);
if (stats) {
countNgrams(ngram);
}
}
// Check for right padding
if(typeof endSymbol !== "undefined" && endSymbol !== null) {
// Create an array of (n) end symbols
var blanks = [];
for(var i = 0 ; i < n ; i++) {
blanks.push(endSymbol);
}
// create the right padding
for(var p = n - 1 ; p > 0 ; p--) {
// Create a tuple of (p) start symbols and (n - p) words
var ngram = sequence.slice(sequence.length - p, sequence.length).concat(blanks.slice(0, n - p));
result.push(ngram);
if (stats) {
countNgrams(ngram);
}
}
}
if (stats) {
// Count frequencies
var Nr = {};
Object.keys(frequencies).forEach(function(key) {
if (!Nr[frequencies[key]]) {
Nr[frequencies[key]] = 0;
}
Nr[frequencies[key]]++;
});
// Return the ngrams AND statistics
return {
"ngrams": result,
"frequencies": frequencies,
"Nr": Nr,
"numberOfNgrams": nrOfNgrams
};
}
else { // Do not break existing API of this module
return result;
}
} | javascript | function(sequence, n, startSymbol, endSymbol, stats) {
var result = [];
frequencies = {};
nrOfNgrams = 0;
if (!_(sequence).isArray()) {
sequence = tokenizer.tokenize(sequence);
}
var count = _.max([0, sequence.length - n + 1]);
// Check for left padding
if(typeof startSymbol !== "undefined" && startSymbol !== null) {
// Create an array of (n) start symbols
var blanks = [];
for(var i = 0 ; i < n ; i++) {
blanks.push(startSymbol);
}
// Create the left padding
for(var p = n - 1 ; p > 0 ; p--) {
// Create a tuple of (p) start symbols and (n - p) words
var ngram = blanks.slice(0, p).concat(sequence.slice(0, n - p));
result.push(ngram);
if (stats) {
countNgrams(ngram);
}
}
}
// Build the complete ngrams
for (var i = 0; i < count; i++) {
var ngram = sequence.slice(i, i + n);
result.push(ngram);
if (stats) {
countNgrams(ngram);
}
}
// Check for right padding
if(typeof endSymbol !== "undefined" && endSymbol !== null) {
// Create an array of (n) end symbols
var blanks = [];
for(var i = 0 ; i < n ; i++) {
blanks.push(endSymbol);
}
// create the right padding
for(var p = n - 1 ; p > 0 ; p--) {
// Create a tuple of (p) start symbols and (n - p) words
var ngram = sequence.slice(sequence.length - p, sequence.length).concat(blanks.slice(0, n - p));
result.push(ngram);
if (stats) {
countNgrams(ngram);
}
}
}
if (stats) {
// Count frequencies
var Nr = {};
Object.keys(frequencies).forEach(function(key) {
if (!Nr[frequencies[key]]) {
Nr[frequencies[key]] = 0;
}
Nr[frequencies[key]]++;
});
// Return the ngrams AND statistics
return {
"ngrams": result,
"frequencies": frequencies,
"Nr": Nr,
"numberOfNgrams": nrOfNgrams
};
}
else { // Do not break existing API of this module
return result;
}
} | [
"function",
"(",
"sequence",
",",
"n",
",",
"startSymbol",
",",
"endSymbol",
",",
"stats",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"frequencies",
"=",
"{",
"}",
";",
"nrOfNgrams",
"=",
"0",
";",
"if",
"(",
"!",
"_",
"(",
"sequence",
")",
"... | If stats is true, statistics will be returned | [
"If",
"stats",
"is",
"true",
"statistics",
"will",
"be",
"returned"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/ngrams/ngrams.js#L72-L153 | |
10,219 | NaturalNode/natural | lib/natural/brill_pos_tagger/lib/RuleSet.js | RuleSet | function RuleSet(language) {
var data = englishRuleSet;
DEBUG && console.log(data);
switch (language) {
case 'EN':
data = englishRuleSet;
break;
case 'DU':
data = dutchRuleSet;
break;
}
if (data.rules) {
this.rules = {};
var that = this;
data.rules.forEach(function(ruleString) {
that.addRule(TF_Parser.parse(ruleString));
})
}
DEBUG && console.log(this.rules);
DEBUG && console.log('Brill_POS_Tagger.read_transformation_rules: number of transformation rules read: ' + Object.keys(this.rules).length);
} | javascript | function RuleSet(language) {
var data = englishRuleSet;
DEBUG && console.log(data);
switch (language) {
case 'EN':
data = englishRuleSet;
break;
case 'DU':
data = dutchRuleSet;
break;
}
if (data.rules) {
this.rules = {};
var that = this;
data.rules.forEach(function(ruleString) {
that.addRule(TF_Parser.parse(ruleString));
})
}
DEBUG && console.log(this.rules);
DEBUG && console.log('Brill_POS_Tagger.read_transformation_rules: number of transformation rules read: ' + Object.keys(this.rules).length);
} | [
"function",
"RuleSet",
"(",
"language",
")",
"{",
"var",
"data",
"=",
"englishRuleSet",
";",
"DEBUG",
"&&",
"console",
".",
"log",
"(",
"data",
")",
";",
"switch",
"(",
"language",
")",
"{",
"case",
"'EN'",
":",
"data",
"=",
"englishRuleSet",
";",
"bre... | Constructor takes a language abbreviation and loads the right rule set | [
"Constructor",
"takes",
"a",
"language",
"abbreviation",
"and",
"loads",
"the",
"right",
"rule",
"set"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/brill_pos_tagger/lib/RuleSet.js#L28-L48 |
10,220 | NaturalNode/natural | lib/natural/classifiers/classifier.js | function(docs) {
setTimeout(function() {
self.events.emit('processedBatch', {
size: docs.length,
docs: totalDocs,
batches: numThreads,
index: finished
});
});
for (var j = 0; j < docs.length; j++) {
docFeatures[docs[j].index] = docs[j].features;
}
} | javascript | function(docs) {
setTimeout(function() {
self.events.emit('processedBatch', {
size: docs.length,
docs: totalDocs,
batches: numThreads,
index: finished
});
});
for (var j = 0; j < docs.length; j++) {
docFeatures[docs[j].index] = docs[j].features;
}
} | [
"function",
"(",
"docs",
")",
"{",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"self",
".",
"events",
".",
"emit",
"(",
"'processedBatch'",
",",
"{",
"size",
":",
"docs",
".",
"length",
",",
"docs",
":",
"totalDocs",
",",
"batches",
":",
"numThreads"... | Called when a batch completes processing | [
"Called",
"when",
"a",
"batch",
"completes",
"processing"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/classifiers/classifier.js#L191-L204 | |
10,221 | NaturalNode/natural | lib/natural/classifiers/classifier.js | function(err) {
if (err) {
threadPool.destroy();
return callback(err);
}
for (var j = self.lastAdded; j < totalDocs; j++) {
self.classifier.addExample(docFeatures[j], self.docs[j].label);
self.events.emit('trainedWithDocument', {
index: j,
total: totalDocs,
doc: self.docs[j]
});
self.lastAdded++;
}
self.events.emit('doneTraining', true);
self.classifier.train();
threadPool.destroy();
callback(null);
} | javascript | function(err) {
if (err) {
threadPool.destroy();
return callback(err);
}
for (var j = self.lastAdded; j < totalDocs; j++) {
self.classifier.addExample(docFeatures[j], self.docs[j].label);
self.events.emit('trainedWithDocument', {
index: j,
total: totalDocs,
doc: self.docs[j]
});
self.lastAdded++;
}
self.events.emit('doneTraining', true);
self.classifier.train();
threadPool.destroy();
callback(null);
} | [
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"{",
"threadPool",
".",
"destroy",
"(",
")",
";",
"return",
"callback",
"(",
"err",
")",
";",
"}",
"for",
"(",
"var",
"j",
"=",
"self",
".",
"lastAdded",
";",
"j",
"<",
"totalDocs",
";",
... | Called when all batches finish processing | [
"Called",
"when",
"all",
"batches",
"finish",
"processing"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/classifiers/classifier.js#L207-L228 | |
10,222 | NaturalNode/natural | lib/natural/classifiers/classifier.js | function(batchJson) {
if (abort) return;
threadPool.any.eval('docsToFeatures(' + batchJson + ');', function(err, docs) {
if (err) {
return onError(err);
}
finished++;
if (docs) {
docs = JSON.parse(docs);
setTimeout(onFeaturesResult.bind(null, docs));
}
if (finished >= obsBatches.length) {
setTimeout(onFinished);
}
setTimeout(sendNext);
});
} | javascript | function(batchJson) {
if (abort) return;
threadPool.any.eval('docsToFeatures(' + batchJson + ');', function(err, docs) {
if (err) {
return onError(err);
}
finished++;
if (docs) {
docs = JSON.parse(docs);
setTimeout(onFeaturesResult.bind(null, docs));
}
if (finished >= obsBatches.length) {
setTimeout(onFinished);
}
setTimeout(sendNext);
});
} | [
"function",
"(",
"batchJson",
")",
"{",
"if",
"(",
"abort",
")",
"return",
";",
"threadPool",
".",
"any",
".",
"eval",
"(",
"'docsToFeatures('",
"+",
"batchJson",
"+",
"');'",
",",
"function",
"(",
"err",
",",
"docs",
")",
"{",
"if",
"(",
"err",
")",... | Called to send a batch of docs to the threads | [
"Called",
"to",
"send",
"a",
"batch",
"of",
"docs",
"to",
"the",
"threads"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/classifiers/classifier.js#L360-L380 | |
10,223 | NaturalNode/natural | lib/natural/tfidf/tfidf.js | isEncoding | function isEncoding(encoding) {
if (typeof Buffer.isEncoding !== 'undefined')
return Buffer.isEncoding(encoding);
switch ((encoding + '').toLowerCase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'binary':
case 'base64':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
case 'raw':
return true;
}
return false;
} | javascript | function isEncoding(encoding) {
if (typeof Buffer.isEncoding !== 'undefined')
return Buffer.isEncoding(encoding);
switch ((encoding + '').toLowerCase()) {
case 'hex':
case 'utf8':
case 'utf-8':
case 'ascii':
case 'binary':
case 'base64':
case 'ucs2':
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
case 'raw':
return true;
}
return false;
} | [
"function",
"isEncoding",
"(",
"encoding",
")",
"{",
"if",
"(",
"typeof",
"Buffer",
".",
"isEncoding",
"!==",
"'undefined'",
")",
"return",
"Buffer",
".",
"isEncoding",
"(",
"encoding",
")",
";",
"switch",
"(",
"(",
"encoding",
"+",
"''",
")",
".",
"toLo... | backwards compatibility for < node 0.10 | [
"backwards",
"compatibility",
"for",
"<",
"node",
"0",
".",
"10"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/tfidf/tfidf.js#L67-L85 |
10,224 | NaturalNode/natural | lib/natural/tokenizers/regexp_tokenizer.js | function(options) {
var options = options || {};
this._pattern = options.pattern || this._pattern;
this.discardEmpty = options.discardEmpty || true;
// Match and split on GAPS not the actual WORDS
this._gaps = options.gaps;
if (this._gaps === undefined) {
this._gaps = true;
}
} | javascript | function(options) {
var options = options || {};
this._pattern = options.pattern || this._pattern;
this.discardEmpty = options.discardEmpty || true;
// Match and split on GAPS not the actual WORDS
this._gaps = options.gaps;
if (this._gaps === undefined) {
this._gaps = true;
}
} | [
"function",
"(",
"options",
")",
"{",
"var",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"_pattern",
"=",
"options",
".",
"pattern",
"||",
"this",
".",
"_pattern",
";",
"this",
".",
"discardEmpty",
"=",
"options",
".",
"discardEmpty",
... | Base Class for RegExp Matching | [
"Base",
"Class",
"for",
"RegExp",
"Matching"
] | 01078b695fda3df41de26a7ac589a6478d802f1f | https://github.com/NaturalNode/natural/blob/01078b695fda3df41de26a7ac589a6478d802f1f/lib/natural/tokenizers/regexp_tokenizer.js#L28-L39 | |
10,225 | googlemaps/google-maps-services-js | lib/internal/task.js | setListener | function setListener(callback) {
if (onFinish) {
throw new Error('thenDo/finally called more than once');
}
if (finished) {
onFinish = function() {};
callback(finished.err, finished.result);
} else {
onFinish = function() {
callback(finished.err, finished.result);
};
}
} | javascript | function setListener(callback) {
if (onFinish) {
throw new Error('thenDo/finally called more than once');
}
if (finished) {
onFinish = function() {};
callback(finished.err, finished.result);
} else {
onFinish = function() {
callback(finished.err, finished.result);
};
}
} | [
"function",
"setListener",
"(",
"callback",
")",
"{",
"if",
"(",
"onFinish",
")",
"{",
"throw",
"new",
"Error",
"(",
"'thenDo/finally called more than once'",
")",
";",
"}",
"if",
"(",
"finished",
")",
"{",
"onFinish",
"=",
"function",
"(",
")",
"{",
"}",
... | Sets the listener that will be called with the result of this task, when
finished. This function can be called at most once.
@param {function(?, T)} callback | [
"Sets",
"the",
"listener",
"that",
"will",
"be",
"called",
"with",
"the",
"result",
"of",
"this",
"task",
"when",
"finished",
".",
"This",
"function",
"can",
"be",
"called",
"at",
"most",
"once",
"."
] | 1e20ccc7264e8858723dcf4971d9ad10dc9e5ff2 | https://github.com/googlemaps/google-maps-services-js/blob/1e20ccc7264e8858723dcf4971d9ad10dc9e5ff2/lib/internal/task.js#L108-L120 |
10,226 | googlemaps/google-maps-services-js | lib/internal/make-api-call.js | formatRequestUrl | function formatRequestUrl(path, query, useClientId) {
if (channel) {
query.channel = channel;
}
if (useClientId) {
query.client = clientId;
} else if (key && key.indexOf('AIza') == 0) {
query.key = key;
} else {
throw 'Missing either a valid API key, or a client ID and secret';
}
var requestUrl = url.format({pathname: path, query: query});
// When using client ID, generate and append the signature param.
if (useClientId) {
var secret = new Buffer(clientSecret, 'base64');
var payload = url.parse(requestUrl).path;
var signature = computeSignature(secret, payload);
requestUrl += '&signature=' + encodeURIComponent(signature);
}
return requestUrl;
} | javascript | function formatRequestUrl(path, query, useClientId) {
if (channel) {
query.channel = channel;
}
if (useClientId) {
query.client = clientId;
} else if (key && key.indexOf('AIza') == 0) {
query.key = key;
} else {
throw 'Missing either a valid API key, or a client ID and secret';
}
var requestUrl = url.format({pathname: path, query: query});
// When using client ID, generate and append the signature param.
if (useClientId) {
var secret = new Buffer(clientSecret, 'base64');
var payload = url.parse(requestUrl).path;
var signature = computeSignature(secret, payload);
requestUrl += '&signature=' + encodeURIComponent(signature);
}
return requestUrl;
} | [
"function",
"formatRequestUrl",
"(",
"path",
",",
"query",
",",
"useClientId",
")",
"{",
"if",
"(",
"channel",
")",
"{",
"query",
".",
"channel",
"=",
"channel",
";",
"}",
"if",
"(",
"useClientId",
")",
"{",
"query",
".",
"client",
"=",
"clientId",
";"... | Adds auth information to the query, and formats it into a URL.
@param {string} path
@param {Object} query
@param {boolean} useClientId
@return {string} The formatted URL. | [
"Adds",
"auth",
"information",
"to",
"the",
"query",
"and",
"formats",
"it",
"into",
"a",
"URL",
"."
] | 1e20ccc7264e8858723dcf4971d9ad10dc9e5ff2 | https://github.com/googlemaps/google-maps-services-js/blob/1e20ccc7264e8858723dcf4971d9ad10dc9e5ff2/lib/internal/make-api-call.js#L175-L198 |
10,227 | hgoebl/mobile-detect.js | generate/mobile-detect.template.js | function (key) {
return containsIC(this.userAgents(), key) ||
equalIC(key, this.os()) ||
equalIC(key, this.phone()) ||
equalIC(key, this.tablet()) ||
containsIC(impl.findMatches(impl.mobileDetectRules.utils, this.ua), key);
} | javascript | function (key) {
return containsIC(this.userAgents(), key) ||
equalIC(key, this.os()) ||
equalIC(key, this.phone()) ||
equalIC(key, this.tablet()) ||
containsIC(impl.findMatches(impl.mobileDetectRules.utils, this.ua), key);
} | [
"function",
"(",
"key",
")",
"{",
"return",
"containsIC",
"(",
"this",
".",
"userAgents",
"(",
")",
",",
"key",
")",
"||",
"equalIC",
"(",
"key",
",",
"this",
".",
"os",
"(",
")",
")",
"||",
"equalIC",
"(",
"key",
",",
"this",
".",
"phone",
"(",
... | Global test key against userAgent, os, phone, tablet and some other properties of userAgent string.
@param {String} key the key (case-insensitive) of a userAgent, an operating system, phone or
tablet family.<br>
For a complete list of possible values, see {@link MobileDetect#userAgent},
{@link MobileDetect#os}, {@link MobileDetect#phone}, {@link MobileDetect#tablet}.<br>
Additionally you have following keys:<br>
<br><tt>{{{keys.utils}}}</tt><br>
@returns {boolean} <tt>true</tt> when the given key is one of the defined keys of userAgent, os, phone,
tablet or one of the listed additional keys, otherwise <tt>false</tt>
@function MobileDetect#is | [
"Global",
"test",
"key",
"against",
"userAgent",
"os",
"phone",
"tablet",
"and",
"some",
"other",
"properties",
"of",
"userAgent",
"string",
"."
] | 565480738903b9684ee365f17c888bf9092a5ca3 | https://github.com/hgoebl/mobile-detect.js/blob/565480738903b9684ee365f17c888bf9092a5ca3/generate/mobile-detect.template.js#L602-L608 | |
10,228 | nodeca/js-yaml | lib/js-yaml/dumper.js | isPlainSafe | function isPlainSafe(c) {
// Uses a subset of nb-char - c-flow-indicator - ":" - "#"
// where nb-char ::= c-printable - b-char - c-byte-order-mark.
return isPrintable(c) && c !== 0xFEFF
// - c-flow-indicator
&& c !== CHAR_COMMA
&& c !== CHAR_LEFT_SQUARE_BRACKET
&& c !== CHAR_RIGHT_SQUARE_BRACKET
&& c !== CHAR_LEFT_CURLY_BRACKET
&& c !== CHAR_RIGHT_CURLY_BRACKET
// - ":" - "#"
&& c !== CHAR_COLON
&& c !== CHAR_SHARP;
} | javascript | function isPlainSafe(c) {
// Uses a subset of nb-char - c-flow-indicator - ":" - "#"
// where nb-char ::= c-printable - b-char - c-byte-order-mark.
return isPrintable(c) && c !== 0xFEFF
// - c-flow-indicator
&& c !== CHAR_COMMA
&& c !== CHAR_LEFT_SQUARE_BRACKET
&& c !== CHAR_RIGHT_SQUARE_BRACKET
&& c !== CHAR_LEFT_CURLY_BRACKET
&& c !== CHAR_RIGHT_CURLY_BRACKET
// - ":" - "#"
&& c !== CHAR_COLON
&& c !== CHAR_SHARP;
} | [
"function",
"isPlainSafe",
"(",
"c",
")",
"{",
"// Uses a subset of nb-char - c-flow-indicator - \":\" - \"#\"",
"// where nb-char ::= c-printable - b-char - c-byte-order-mark.",
"return",
"isPrintable",
"(",
"c",
")",
"&&",
"c",
"!==",
"0xFEFF",
"// - c-flow-indicator",
"&&",
... | Simplified test for values allowed after the first character in plain style. | [
"Simplified",
"test",
"for",
"values",
"allowed",
"after",
"the",
"first",
"character",
"in",
"plain",
"style",
"."
] | 665aadda42349dcae869f12040d9b10ef18d12da | https://github.com/nodeca/js-yaml/blob/665aadda42349dcae869f12040d9b10ef18d12da/lib/js-yaml/dumper.js#L192-L205 |
10,229 | nodeca/js-yaml | lib/js-yaml/dumper.js | isPlainSafeFirst | function isPlainSafeFirst(c) {
// Uses a subset of ns-char - c-indicator
// where ns-char = nb-char - s-white.
return isPrintable(c) && c !== 0xFEFF
&& !isWhitespace(c) // - s-white
// - (c-indicator ::=
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
&& c !== CHAR_MINUS
&& c !== CHAR_QUESTION
&& c !== CHAR_COLON
&& c !== CHAR_COMMA
&& c !== CHAR_LEFT_SQUARE_BRACKET
&& c !== CHAR_RIGHT_SQUARE_BRACKET
&& c !== CHAR_LEFT_CURLY_BRACKET
&& c !== CHAR_RIGHT_CURLY_BRACKET
// | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
&& c !== CHAR_SHARP
&& c !== CHAR_AMPERSAND
&& c !== CHAR_ASTERISK
&& c !== CHAR_EXCLAMATION
&& c !== CHAR_VERTICAL_LINE
&& c !== CHAR_GREATER_THAN
&& c !== CHAR_SINGLE_QUOTE
&& c !== CHAR_DOUBLE_QUOTE
// | “%” | “@” | “`”)
&& c !== CHAR_PERCENT
&& c !== CHAR_COMMERCIAL_AT
&& c !== CHAR_GRAVE_ACCENT;
} | javascript | function isPlainSafeFirst(c) {
// Uses a subset of ns-char - c-indicator
// where ns-char = nb-char - s-white.
return isPrintable(c) && c !== 0xFEFF
&& !isWhitespace(c) // - s-white
// - (c-indicator ::=
// “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
&& c !== CHAR_MINUS
&& c !== CHAR_QUESTION
&& c !== CHAR_COLON
&& c !== CHAR_COMMA
&& c !== CHAR_LEFT_SQUARE_BRACKET
&& c !== CHAR_RIGHT_SQUARE_BRACKET
&& c !== CHAR_LEFT_CURLY_BRACKET
&& c !== CHAR_RIGHT_CURLY_BRACKET
// | “#” | “&” | “*” | “!” | “|” | “>” | “'” | “"”
&& c !== CHAR_SHARP
&& c !== CHAR_AMPERSAND
&& c !== CHAR_ASTERISK
&& c !== CHAR_EXCLAMATION
&& c !== CHAR_VERTICAL_LINE
&& c !== CHAR_GREATER_THAN
&& c !== CHAR_SINGLE_QUOTE
&& c !== CHAR_DOUBLE_QUOTE
// | “%” | “@” | “`”)
&& c !== CHAR_PERCENT
&& c !== CHAR_COMMERCIAL_AT
&& c !== CHAR_GRAVE_ACCENT;
} | [
"function",
"isPlainSafeFirst",
"(",
"c",
")",
"{",
"// Uses a subset of ns-char - c-indicator",
"// where ns-char = nb-char - s-white.",
"return",
"isPrintable",
"(",
"c",
")",
"&&",
"c",
"!==",
"0xFEFF",
"&&",
"!",
"isWhitespace",
"(",
"c",
")",
"// - s-white",
"// ... | Simplified test for values allowed as the first character in plain style. | [
"Simplified",
"test",
"for",
"values",
"allowed",
"as",
"the",
"first",
"character",
"in",
"plain",
"style",
"."
] | 665aadda42349dcae869f12040d9b10ef18d12da | https://github.com/nodeca/js-yaml/blob/665aadda42349dcae869f12040d9b10ef18d12da/lib/js-yaml/dumper.js#L208-L236 |
10,230 | nodeca/js-yaml | examples/custom_types.js | Point | function Point(x, y, z) {
this.klass = 'Point';
this.x = x;
this.y = y;
this.z = z;
} | javascript | function Point(x, y, z) {
this.klass = 'Point';
this.x = x;
this.y = y;
this.z = z;
} | [
"function",
"Point",
"(",
"x",
",",
"y",
",",
"z",
")",
"{",
"this",
".",
"klass",
"=",
"'Point'",
";",
"this",
".",
"x",
"=",
"x",
";",
"this",
".",
"y",
"=",
"y",
";",
"this",
".",
"z",
"=",
"z",
";",
"}"
] | Let's define a couple of classes. | [
"Let",
"s",
"define",
"a",
"couple",
"of",
"classes",
"."
] | 665aadda42349dcae869f12040d9b10ef18d12da | https://github.com/nodeca/js-yaml/blob/665aadda42349dcae869f12040d9b10ef18d12da/examples/custom_types.js#L13-L18 |
10,231 | fullstackreact/google-maps-react | dist/lib/arePathsEqual.js | isValidLatLng | function isValidLatLng(elem) {
return elem !== null && (typeof elem === 'undefined' ? 'undefined' : _typeof(elem)) === 'object' && elem.hasOwnProperty('lat') && elem.hasOwnProperty('lng');
} | javascript | function isValidLatLng(elem) {
return elem !== null && (typeof elem === 'undefined' ? 'undefined' : _typeof(elem)) === 'object' && elem.hasOwnProperty('lat') && elem.hasOwnProperty('lng');
} | [
"function",
"isValidLatLng",
"(",
"elem",
")",
"{",
"return",
"elem",
"!==",
"null",
"&&",
"(",
"typeof",
"elem",
"===",
"'undefined'",
"?",
"'undefined'",
":",
"_typeof",
"(",
"elem",
")",
")",
"===",
"'object'",
"&&",
"elem",
".",
"hasOwnProperty",
"(",
... | Helper that checks whether an array consists of objects
with lat and lng properties
@param {object} elem the element to check
@returns {boolean} whether or not it's valid | [
"Helper",
"that",
"checks",
"whether",
"an",
"array",
"consists",
"of",
"objects",
"with",
"lat",
"and",
"lng",
"properties"
] | c70a04f668b644a126071c73b392b6094a430a2a | https://github.com/fullstackreact/google-maps-react/blob/c70a04f668b644a126071c73b392b6094a430a2a/dist/lib/arePathsEqual.js#L60-L62 |
10,232 | ethers-io/ethers.js | utils/units.js | commify | function commify(value) {
var comps = String(value).split('.');
if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === '.' || value === '-.') {
errors.throwError('invalid value', errors.INVALID_ARGUMENT, { argument: 'value', value: value });
}
// Make sure we have at least one whole digit (0 if none)
var whole = comps[0];
var negative = '';
if (whole.substring(0, 1) === '-') {
negative = '-';
whole = whole.substring(1);
}
// Make sure we have at least 1 whole digit with no leading zeros
while (whole.substring(0, 1) === '0') {
whole = whole.substring(1);
}
if (whole === '') {
whole = '0';
}
var suffix = '';
if (comps.length === 2) {
suffix = '.' + (comps[1] || '0');
}
var formatted = [];
while (whole.length) {
if (whole.length <= 3) {
formatted.unshift(whole);
break;
}
else {
var index = whole.length - 3;
formatted.unshift(whole.substring(index));
whole = whole.substring(0, index);
}
}
return negative + formatted.join(',') + suffix;
} | javascript | function commify(value) {
var comps = String(value).split('.');
if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === '.' || value === '-.') {
errors.throwError('invalid value', errors.INVALID_ARGUMENT, { argument: 'value', value: value });
}
// Make sure we have at least one whole digit (0 if none)
var whole = comps[0];
var negative = '';
if (whole.substring(0, 1) === '-') {
negative = '-';
whole = whole.substring(1);
}
// Make sure we have at least 1 whole digit with no leading zeros
while (whole.substring(0, 1) === '0') {
whole = whole.substring(1);
}
if (whole === '') {
whole = '0';
}
var suffix = '';
if (comps.length === 2) {
suffix = '.' + (comps[1] || '0');
}
var formatted = [];
while (whole.length) {
if (whole.length <= 3) {
formatted.unshift(whole);
break;
}
else {
var index = whole.length - 3;
formatted.unshift(whole.substring(index));
whole = whole.substring(0, index);
}
}
return negative + formatted.join(',') + suffix;
} | [
"function",
"commify",
"(",
"value",
")",
"{",
"var",
"comps",
"=",
"String",
"(",
"value",
")",
".",
"split",
"(",
"'.'",
")",
";",
"if",
"(",
"comps",
".",
"length",
">",
"2",
"||",
"!",
"comps",
"[",
"0",
"]",
".",
"match",
"(",
"/",
"^-?[0-... | Some environments have issues with RegEx that contain back-tracking, so we cannot use them. | [
"Some",
"environments",
"have",
"issues",
"with",
"RegEx",
"that",
"contain",
"back",
"-",
"tracking",
"so",
"we",
"cannot",
"use",
"them",
"."
] | 04c92bb8d56658b6af6d740d21c3fb331affb9c5 | https://github.com/ethers-io/ethers.js/blob/04c92bb8d56658b6af6d740d21c3fb331affb9c5/utils/units.js#L58-L94 |
10,233 | ethers-io/ethers.js | contract.js | resolveAddresses | function resolveAddresses(provider, value, paramType) {
if (Array.isArray(paramType)) {
var promises_1 = [];
paramType.forEach(function (paramType, index) {
var v = null;
if (Array.isArray(value)) {
v = value[index];
}
else {
v = value[paramType.name];
}
promises_1.push(resolveAddresses(provider, v, paramType));
});
return Promise.all(promises_1);
}
if (paramType.type === 'address') {
return provider.resolveName(value);
}
if (paramType.type === 'tuple') {
return resolveAddresses(provider, value, paramType.components);
}
// Strips one level of array indexing off the end to recuse into
var isArrayMatch = paramType.type.match(/(.*)(\[[0-9]*\]$)/);
if (isArrayMatch) {
if (!Array.isArray(value)) {
throw new Error('invalid value for array');
}
var promises = [];
var subParamType = {
components: paramType.components,
type: isArrayMatch[1],
};
value.forEach(function (v) {
promises.push(resolveAddresses(provider, v, subParamType));
});
return Promise.all(promises);
}
return Promise.resolve(value);
} | javascript | function resolveAddresses(provider, value, paramType) {
if (Array.isArray(paramType)) {
var promises_1 = [];
paramType.forEach(function (paramType, index) {
var v = null;
if (Array.isArray(value)) {
v = value[index];
}
else {
v = value[paramType.name];
}
promises_1.push(resolveAddresses(provider, v, paramType));
});
return Promise.all(promises_1);
}
if (paramType.type === 'address') {
return provider.resolveName(value);
}
if (paramType.type === 'tuple') {
return resolveAddresses(provider, value, paramType.components);
}
// Strips one level of array indexing off the end to recuse into
var isArrayMatch = paramType.type.match(/(.*)(\[[0-9]*\]$)/);
if (isArrayMatch) {
if (!Array.isArray(value)) {
throw new Error('invalid value for array');
}
var promises = [];
var subParamType = {
components: paramType.components,
type: isArrayMatch[1],
};
value.forEach(function (v) {
promises.push(resolveAddresses(provider, v, subParamType));
});
return Promise.all(promises);
}
return Promise.resolve(value);
} | [
"function",
"resolveAddresses",
"(",
"provider",
",",
"value",
",",
"paramType",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"paramType",
")",
")",
"{",
"var",
"promises_1",
"=",
"[",
"]",
";",
"paramType",
".",
"forEach",
"(",
"function",
"(",
... | Recursively replaces ENS names with promises to resolve the name and stalls until all promises have returned @TODO: Expand this to resolve any promises too | [
"Recursively",
"replaces",
"ENS",
"names",
"with",
"promises",
"to",
"resolve",
"the",
"name",
"and",
"stalls",
"until",
"all",
"promises",
"have",
"returned"
] | 04c92bb8d56658b6af6d740d21c3fb331affb9c5 | https://github.com/ethers-io/ethers.js/blob/04c92bb8d56658b6af6d740d21c3fb331affb9c5/contract.js#L67-L105 |
10,234 | ethers-io/ethers.js | utils/hdnode.js | HDNode | function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) {
errors.checkNew(this, HDNode);
if (constructorGuard !== _constructorGuard) {
throw new Error('HDNode constructor cannot be called directly');
}
if (privateKey) {
var keyPair = new secp256k1_1.KeyPair(privateKey);
properties_1.defineReadOnly(this, 'privateKey', keyPair.privateKey);
properties_1.defineReadOnly(this, 'publicKey', keyPair.compressedPublicKey);
}
else {
properties_1.defineReadOnly(this, 'privateKey', null);
properties_1.defineReadOnly(this, 'publicKey', bytes_1.hexlify(publicKey));
}
properties_1.defineReadOnly(this, 'parentFingerprint', parentFingerprint);
properties_1.defineReadOnly(this, 'fingerprint', bytes_1.hexDataSlice(sha2_1.ripemd160(sha2_1.sha256(this.publicKey)), 0, 4));
properties_1.defineReadOnly(this, 'address', secp256k1_1.computeAddress(this.publicKey));
properties_1.defineReadOnly(this, 'chainCode', chainCode);
properties_1.defineReadOnly(this, 'index', index);
properties_1.defineReadOnly(this, 'depth', depth);
properties_1.defineReadOnly(this, 'mnemonic', mnemonic);
properties_1.defineReadOnly(this, 'path', path);
properties_1.setType(this, 'HDNode');
} | javascript | function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) {
errors.checkNew(this, HDNode);
if (constructorGuard !== _constructorGuard) {
throw new Error('HDNode constructor cannot be called directly');
}
if (privateKey) {
var keyPair = new secp256k1_1.KeyPair(privateKey);
properties_1.defineReadOnly(this, 'privateKey', keyPair.privateKey);
properties_1.defineReadOnly(this, 'publicKey', keyPair.compressedPublicKey);
}
else {
properties_1.defineReadOnly(this, 'privateKey', null);
properties_1.defineReadOnly(this, 'publicKey', bytes_1.hexlify(publicKey));
}
properties_1.defineReadOnly(this, 'parentFingerprint', parentFingerprint);
properties_1.defineReadOnly(this, 'fingerprint', bytes_1.hexDataSlice(sha2_1.ripemd160(sha2_1.sha256(this.publicKey)), 0, 4));
properties_1.defineReadOnly(this, 'address', secp256k1_1.computeAddress(this.publicKey));
properties_1.defineReadOnly(this, 'chainCode', chainCode);
properties_1.defineReadOnly(this, 'index', index);
properties_1.defineReadOnly(this, 'depth', depth);
properties_1.defineReadOnly(this, 'mnemonic', mnemonic);
properties_1.defineReadOnly(this, 'path', path);
properties_1.setType(this, 'HDNode');
} | [
"function",
"HDNode",
"(",
"constructorGuard",
",",
"privateKey",
",",
"publicKey",
",",
"parentFingerprint",
",",
"chainCode",
",",
"index",
",",
"depth",
",",
"mnemonic",
",",
"path",
")",
"{",
"errors",
".",
"checkNew",
"(",
"this",
",",
"HDNode",
")",
... | This constructor should not be called directly.
Please use:
- fromMnemonic
- fromSeed | [
"This",
"constructor",
"should",
"not",
"be",
"called",
"directly",
"."
] | 04c92bb8d56658b6af6d740d21c3fb331affb9c5 | https://github.com/ethers-io/ethers.js/blob/04c92bb8d56658b6af6d740d21c3fb331affb9c5/utils/hdnode.js#L57-L80 |
10,235 | ethers-io/ethers.js | wordlists/lang-ja.js | normalize | function normalize(word) {
var result = '';
for (var i = 0; i < word.length; i++) {
var kana = word[i];
var target = transform[kana];
if (target === false) {
continue;
}
if (target) {
kana = target;
}
result += kana;
}
return result;
} | javascript | function normalize(word) {
var result = '';
for (var i = 0; i < word.length; i++) {
var kana = word[i];
var target = transform[kana];
if (target === false) {
continue;
}
if (target) {
kana = target;
}
result += kana;
}
return result;
} | [
"function",
"normalize",
"(",
"word",
")",
"{",
"var",
"result",
"=",
"''",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"word",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"kana",
"=",
"word",
"[",
"i",
"]",
";",
"var",
"target"... | Normalize words using the transform | [
"Normalize",
"words",
"using",
"the",
"transform"
] | 04c92bb8d56658b6af6d740d21c3fb331affb9c5 | https://github.com/ethers-io/ethers.js/blob/04c92bb8d56658b6af6d740d21c3fb331affb9c5/wordlists/lang-ja.js#L64-L78 |
10,236 | ethers-io/ethers.js | wordlists/lang-ja.js | sortJapanese | function sortJapanese(a, b) {
a = normalize(a);
b = normalize(b);
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
} | javascript | function sortJapanese(a, b) {
a = normalize(a);
b = normalize(b);
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
} | [
"function",
"sortJapanese",
"(",
"a",
",",
"b",
")",
"{",
"a",
"=",
"normalize",
"(",
"a",
")",
";",
"b",
"=",
"normalize",
"(",
"b",
")",
";",
"if",
"(",
"a",
"<",
"b",
")",
"{",
"return",
"-",
"1",
";",
"}",
"if",
"(",
"a",
">",
"b",
")... | Sort how the Japanese list is sorted | [
"Sort",
"how",
"the",
"Japanese",
"list",
"is",
"sorted"
] | 04c92bb8d56658b6af6d740d21c3fb331affb9c5 | https://github.com/ethers-io/ethers.js/blob/04c92bb8d56658b6af6d740d21c3fb331affb9c5/wordlists/lang-ja.js#L80-L90 |
10,237 | ethers-io/ethers.js | utils/secret-storage.js | searchPath | function searchPath(object, path) {
var currentChild = object;
var comps = path.toLowerCase().split('/');
for (var i = 0; i < comps.length; i++) {
// Search for a child object with a case-insensitive matching key
var matchingChild = null;
for (var key in currentChild) {
if (key.toLowerCase() === comps[i]) {
matchingChild = currentChild[key];
break;
}
}
// Didn't find one. :'(
if (matchingChild === null) {
return null;
}
// Now check this child...
currentChild = matchingChild;
}
return currentChild;
} | javascript | function searchPath(object, path) {
var currentChild = object;
var comps = path.toLowerCase().split('/');
for (var i = 0; i < comps.length; i++) {
// Search for a child object with a case-insensitive matching key
var matchingChild = null;
for (var key in currentChild) {
if (key.toLowerCase() === comps[i]) {
matchingChild = currentChild[key];
break;
}
}
// Didn't find one. :'(
if (matchingChild === null) {
return null;
}
// Now check this child...
currentChild = matchingChild;
}
return currentChild;
} | [
"function",
"searchPath",
"(",
"object",
",",
"path",
")",
"{",
"var",
"currentChild",
"=",
"object",
";",
"var",
"comps",
"=",
"path",
".",
"toLowerCase",
"(",
")",
".",
"split",
"(",
"'/'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
... | Search an Object and its children recursively, caselessly. | [
"Search",
"an",
"Object",
"and",
"its",
"children",
"recursively",
"caselessly",
"."
] | 04c92bb8d56658b6af6d740d21c3fb331affb9c5 | https://github.com/ethers-io/ethers.js/blob/04c92bb8d56658b6af6d740d21c3fb331affb9c5/utils/secret-storage.js#L44-L64 |
10,238 | ethers-io/ethers.js | utils/properties.js | setType | function setType(object, type) {
Object.defineProperty(object, '_ethersType', { configurable: false, value: type, writable: false });
} | javascript | function setType(object, type) {
Object.defineProperty(object, '_ethersType', { configurable: false, value: type, writable: false });
} | [
"function",
"setType",
"(",
"object",
",",
"type",
")",
"{",
"Object",
".",
"defineProperty",
"(",
"object",
",",
"'_ethersType'",
",",
"{",
"configurable",
":",
"false",
",",
"value",
":",
"type",
",",
"writable",
":",
"false",
"}",
")",
";",
"}"
] | There are some issues with instanceof with npm link, so we use this to ensure types are what we expect. | [
"There",
"are",
"some",
"issues",
"with",
"instanceof",
"with",
"npm",
"link",
"so",
"we",
"use",
"this",
"to",
"ensure",
"types",
"are",
"what",
"we",
"expect",
"."
] | 04c92bb8d56658b6af6d740d21c3fb331affb9c5 | https://github.com/ethers-io/ethers.js/blob/04c92bb8d56658b6af6d740d21c3fb331affb9c5/utils/properties.js#L21-L23 |
10,239 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | extractString_ | function extractString_(full, start, end) {
var i = (start === '') ? 0 : full.indexOf(start);
var e = end === '' ? full.length : full.indexOf(end, i + start.length);
return full.substring(i + start.length, e);
} | javascript | function extractString_(full, start, end) {
var i = (start === '') ? 0 : full.indexOf(start);
var e = end === '' ? full.length : full.indexOf(end, i + start.length);
return full.substring(i + start.length, e);
} | [
"function",
"extractString_",
"(",
"full",
",",
"start",
",",
"end",
")",
"{",
"var",
"i",
"=",
"(",
"start",
"===",
"''",
")",
"?",
"0",
":",
"full",
".",
"indexOf",
"(",
"start",
")",
";",
"var",
"e",
"=",
"end",
"===",
"''",
"?",
"full",
"."... | Extract the substring from full string, between start string and end string
@param {String} full
@param {String} start
@param {String} end | [
"Extract",
"the",
"substring",
"from",
"full",
"string",
"between",
"start",
"string",
"and",
"end",
"string"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L153-L157 |
10,240 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | augmentObject_ | function augmentObject_(src, dest, force) {
if (src && dest) {
var p;
for (p in src) {
if (force || !(p in dest)) {
dest[p] = src[p];
}
}
}
return dest;
} | javascript | function augmentObject_(src, dest, force) {
if (src && dest) {
var p;
for (p in src) {
if (force || !(p in dest)) {
dest[p] = src[p];
}
}
}
return dest;
} | [
"function",
"augmentObject_",
"(",
"src",
",",
"dest",
",",
"force",
")",
"{",
"if",
"(",
"src",
"&&",
"dest",
")",
"{",
"var",
"p",
";",
"for",
"(",
"p",
"in",
"src",
")",
"{",
"if",
"(",
"force",
"||",
"!",
"(",
"p",
"in",
"dest",
")",
")",... | Add the property of the source object to destination object
if not already exists.
@param {Object} dest
@param {Object} src
@param {Boolean} force
@return {Object} | [
"Add",
"the",
"property",
"of",
"the",
"source",
"object",
"to",
"destination",
"object",
"if",
"not",
"already",
"exists",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L187-L197 |
10,241 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | handleErr_ | function handleErr_(errback, json) {
if (errback && json && json.error) {
errback(json.error);
}
} | javascript | function handleErr_(errback, json) {
if (errback && json && json.error) {
errback(json.error);
}
} | [
"function",
"handleErr_",
"(",
"errback",
",",
"json",
")",
"{",
"if",
"(",
"errback",
"&&",
"json",
"&&",
"json",
".",
"error",
")",
"{",
"errback",
"(",
"json",
".",
"error",
")",
";",
"}",
"}"
] | handle JSON error
@param {Object} errback
@param {Object} json | [
"handle",
"JSON",
"error"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L214-L218 |
10,242 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | formatTimeString_ | function formatTimeString_(time, endTime) {
var ret = '';
if (time) {
ret += (time.getTime() - time.getTimezoneOffset() * 60000);
}
if (endTime) {
ret += ', ' + (endTime.getTime() - endTime.getTimezoneOffset() * 60000);
}
return ret;
} | javascript | function formatTimeString_(time, endTime) {
var ret = '';
if (time) {
ret += (time.getTime() - time.getTimezoneOffset() * 60000);
}
if (endTime) {
ret += ', ' + (endTime.getTime() - endTime.getTimezoneOffset() * 60000);
}
return ret;
} | [
"function",
"formatTimeString_",
"(",
"time",
",",
"endTime",
")",
"{",
"var",
"ret",
"=",
"''",
";",
"if",
"(",
"time",
")",
"{",
"ret",
"+=",
"(",
"time",
".",
"getTime",
"(",
")",
"-",
"time",
".",
"getTimezoneOffset",
"(",
")",
"*",
"60000",
")... | get REST format for 2 time
@param {Date} time
@param {Date} endTime | [
"get",
"REST",
"format",
"for",
"2",
"time"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L224-L233 |
10,243 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | setNodeOpacity_ | function setNodeOpacity_(node, op) {
// closure compiler removed?
op = Math.min(Math.max(op, 0), 1);
if (node) {
var st = node.style;
if (typeof st.opacity !== 'undefined') {
st.opacity = op;
}
if (typeof st.filters !== 'undefined') {
st.filters.alpha.opacity = Math.floor(100 * op);
}
if (typeof st.filter !== 'undefined') {
st.filter = "alpha(opacity:" + Math.floor(op * 100) + ")";
}
}
} | javascript | function setNodeOpacity_(node, op) {
// closure compiler removed?
op = Math.min(Math.max(op, 0), 1);
if (node) {
var st = node.style;
if (typeof st.opacity !== 'undefined') {
st.opacity = op;
}
if (typeof st.filters !== 'undefined') {
st.filters.alpha.opacity = Math.floor(100 * op);
}
if (typeof st.filter !== 'undefined') {
st.filter = "alpha(opacity:" + Math.floor(op * 100) + ")";
}
}
} | [
"function",
"setNodeOpacity_",
"(",
"node",
",",
"op",
")",
"{",
"// closure compiler removed?\r",
"op",
"=",
"Math",
".",
"min",
"(",
"Math",
".",
"max",
"(",
"op",
",",
"0",
")",
",",
"1",
")",
";",
"if",
"(",
"node",
")",
"{",
"var",
"st",
"=",
... | Set opacity of a node.
@param {Node} node
@param {Number} 0-1 | [
"Set",
"opacity",
"of",
"a",
"node",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L240-L255 |
10,244 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | getLayerDefsString_ | function getLayerDefsString_(defs) {
var strDefs = '';
for (var x in defs) {
if (defs.hasOwnProperty(x)) {
if (strDefs.length > 0) {
strDefs += ';';
}
strDefs += (x + ':' + defs[x]);
}
}
return strDefs;
} | javascript | function getLayerDefsString_(defs) {
var strDefs = '';
for (var x in defs) {
if (defs.hasOwnProperty(x)) {
if (strDefs.length > 0) {
strDefs += ';';
}
strDefs += (x + ':' + defs[x]);
}
}
return strDefs;
} | [
"function",
"getLayerDefsString_",
"(",
"defs",
")",
"{",
"var",
"strDefs",
"=",
"''",
";",
"for",
"(",
"var",
"x",
"in",
"defs",
")",
"{",
"if",
"(",
"defs",
".",
"hasOwnProperty",
"(",
"x",
")",
")",
"{",
"if",
"(",
"strDefs",
".",
"length",
">",... | get the layerdef text string from an object literal
@param {Object} defs | [
"get",
"the",
"layerdef",
"text",
"string",
"from",
"an",
"object",
"literal"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L260-L271 |
10,245 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | isOverlay_ | function isOverlay_(obj) {
var o = obj;
if (isArray_(obj) && obj.length > 0) {
o = obj[0];
}
if (isArray_(o) && o.length > 0) {
o = o[0];
}
if (o instanceof G.LatLng || o instanceof G.Marker ||
o instanceof G.Polyline ||
o instanceof G.Polygon ||
o instanceof G.LatLngBounds) {
return true;
}
return false;
} | javascript | function isOverlay_(obj) {
var o = obj;
if (isArray_(obj) && obj.length > 0) {
o = obj[0];
}
if (isArray_(o) && o.length > 0) {
o = o[0];
}
if (o instanceof G.LatLng || o instanceof G.Marker ||
o instanceof G.Polyline ||
o instanceof G.Polygon ||
o instanceof G.LatLngBounds) {
return true;
}
return false;
} | [
"function",
"isOverlay_",
"(",
"obj",
")",
"{",
"var",
"o",
"=",
"obj",
";",
"if",
"(",
"isArray_",
"(",
"obj",
")",
"&&",
"obj",
".",
"length",
">",
"0",
")",
"{",
"o",
"=",
"obj",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"isArray_",
"(",
"o",
... | Is the object an Google Overlay?
@param {Object} obj
@return {Boolean} | [
"Is",
"the",
"object",
"an",
"Google",
"Overlay?"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L346-L361 |
10,246 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | fromGeometryToJSON_ | function fromGeometryToJSON_(geom) {
function fromPointsToJSON(pts) {
var arr = [];
for (var i = 0, c = pts.length; i < c; i++) {
arr.push('[' + pts[i][0] + ',' + pts[i][1] + ']');
}
return '[' + arr.join(',') + ']';
}
function fromLinesToJSON(lines) {
var arr = [];
for (var i = 0, c = lines.length; i < c; i++) {
arr.push(fromPointsToJSON(lines[i]));
}
return '[' + arr.join(',') + ']';
}
var json = '{';
if (geom.x) {
json += 'x:' + geom.x + ',y:' + geom.y;
} else if (geom.xmin) {
json += 'xmin:' + geom.xmin + ',ymin:' + geom.ymin + ',xmax:' + geom.xmax + ',ymax:' + geom.ymax;
} else if (geom.points) {
json += 'points:' + fromPointsToJSON(geom.points);
} else if (geom.paths) {
json += 'paths:' + fromLinesToJSON(geom.paths);
} else if (geom.rings) {
json += 'rings:' + fromLinesToJSON(geom.rings);
}
json += '}';
return json;
} | javascript | function fromGeometryToJSON_(geom) {
function fromPointsToJSON(pts) {
var arr = [];
for (var i = 0, c = pts.length; i < c; i++) {
arr.push('[' + pts[i][0] + ',' + pts[i][1] + ']');
}
return '[' + arr.join(',') + ']';
}
function fromLinesToJSON(lines) {
var arr = [];
for (var i = 0, c = lines.length; i < c; i++) {
arr.push(fromPointsToJSON(lines[i]));
}
return '[' + arr.join(',') + ']';
}
var json = '{';
if (geom.x) {
json += 'x:' + geom.x + ',y:' + geom.y;
} else if (geom.xmin) {
json += 'xmin:' + geom.xmin + ',ymin:' + geom.ymin + ',xmax:' + geom.xmax + ',ymax:' + geom.ymax;
} else if (geom.points) {
json += 'points:' + fromPointsToJSON(geom.points);
} else if (geom.paths) {
json += 'paths:' + fromLinesToJSON(geom.paths);
} else if (geom.rings) {
json += 'rings:' + fromLinesToJSON(geom.rings);
}
json += '}';
return json;
} | [
"function",
"fromGeometryToJSON_",
"(",
"geom",
")",
"{",
"function",
"fromPointsToJSON",
"(",
"pts",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"c",
"=",
"pts",
".",
"length",
";",
"i",
"<",
"c",
";",
"i",... | From ESRI geometry format to JSON String, primarily used in Geometry service
@param {Object} geom | [
"From",
"ESRI",
"geometry",
"format",
"to",
"JSON",
"String",
"primarily",
"used",
"in",
"Geometry",
"service"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L447-L477 |
10,247 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | formatRequestString_ | function formatRequestString_(o) {
var ret;
if (typeof o === 'object') {
if (isArray_(o)) {
ret = [];
for (var i = 0, I = o.length; i < I; i++) {
ret.push(formatRequestString_(o[i]));
}
return '[' + ret.join(',') + ']';
} else if (isOverlay_(o)) {
return fromOverlaysToJSON_(o);
} else if (o.toJSON) {
return o.toJSON();
} else {
ret = '';
for (var x in o) {
if (o.hasOwnProperty(x)) {
if (ret.length > 0) {
ret += ', ';
}
ret += x + ':' + formatRequestString_(o[x]);
}
}
return '{' + ret + '}';
}
}
return o.toString();
} | javascript | function formatRequestString_(o) {
var ret;
if (typeof o === 'object') {
if (isArray_(o)) {
ret = [];
for (var i = 0, I = o.length; i < I; i++) {
ret.push(formatRequestString_(o[i]));
}
return '[' + ret.join(',') + ']';
} else if (isOverlay_(o)) {
return fromOverlaysToJSON_(o);
} else if (o.toJSON) {
return o.toJSON();
} else {
ret = '';
for (var x in o) {
if (o.hasOwnProperty(x)) {
if (ret.length > 0) {
ret += ', ';
}
ret += x + ':' + formatRequestString_(o[x]);
}
}
return '{' + ret + '}';
}
}
return o.toString();
} | [
"function",
"formatRequestString_",
"(",
"o",
")",
"{",
"var",
"ret",
";",
"if",
"(",
"typeof",
"o",
"===",
"'object'",
")",
"{",
"if",
"(",
"isArray_",
"(",
"o",
")",
")",
"{",
"ret",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
",",
... | get string as rest parameter
@param {Object} o | [
"get",
"string",
"as",
"rest",
"parameter"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L572-L599 |
10,248 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | formatParams_ | function formatParams_(params) {
var query = '';
if (params) {
params.f = params.f || 'json';
for (var x in params) {
if (params.hasOwnProperty(x) && params[x] !== null && params[x] !== undefined) { // wont sent undefined.
//jslint complaint about escape cause NN does not support it.
var val = formatRequestString_(params[x]);
query += (query.length > 0?'&':'')+(x + '=' + (escape ? escape(val) : encodeURIComponent(val)));
}
}
}
return query;
} | javascript | function formatParams_(params) {
var query = '';
if (params) {
params.f = params.f || 'json';
for (var x in params) {
if (params.hasOwnProperty(x) && params[x] !== null && params[x] !== undefined) { // wont sent undefined.
//jslint complaint about escape cause NN does not support it.
var val = formatRequestString_(params[x]);
query += (query.length > 0?'&':'')+(x + '=' + (escape ? escape(val) : encodeURIComponent(val)));
}
}
}
return query;
} | [
"function",
"formatParams_",
"(",
"params",
")",
"{",
"var",
"query",
"=",
"''",
";",
"if",
"(",
"params",
")",
"{",
"params",
".",
"f",
"=",
"params",
".",
"f",
"||",
"'json'",
";",
"for",
"(",
"var",
"x",
"in",
"params",
")",
"{",
"if",
"(",
... | Format params to URL string
@param {Object} params | [
"Format",
"params",
"to",
"URL",
"string"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L674-L687 |
10,249 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | callback_ | function callback_(fn, obj) {
var args = [];
for (var i = 2, c = arguments.length; i < c; i++) {
args.push(arguments[i]);
}
return function() {
fn.apply(obj, args);
};
} | javascript | function callback_(fn, obj) {
var args = [];
for (var i = 2, c = arguments.length; i < c; i++) {
args.push(arguments[i]);
}
return function() {
fn.apply(obj, args);
};
} | [
"function",
"callback_",
"(",
"fn",
",",
"obj",
")",
"{",
"var",
"args",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"2",
",",
"c",
"=",
"arguments",
".",
"length",
";",
"i",
"<",
"c",
";",
"i",
"++",
")",
"{",
"args",
".",
"push",
"("... | create a callback closure
@private
@param {Object} fn
@param {Object} obj | [
"create",
"a",
"callback",
"closure"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L694-L702 |
10,250 | googlemaps/v3-utility-library | arcgislink/src/arcgislink.js | setCopyrightInfo_ | function setCopyrightInfo_(map) {
var div = null;
if (map) {
var mvc = map.controls[G.ControlPosition.BOTTOM_RIGHT];
if (mvc) {
for (var i = 0, c = mvc.getLength(); i < c; i++) {
if (mvc.getAt(i).id === 'agsCopyrights') {
div = mvc.getAt(i);
break;
}
}
}
//var callback = callback_(setCopyrightInfo_, null, map);
if (!div) {
div = document.createElement('div');
div.style.fontFamily = 'Arial,sans-serif';
div.style.fontSize = '10px';
div.style.textAlign = 'right';
div.id = 'agsCopyrights';
map.controls[G.ControlPosition.BOTTOM_RIGHT].push(div);
G.event.addListener(map, 'maptypeid_changed', function() {
setCopyrightInfo_(map);
});
}
var ovs = map.agsOverlays;
var cp = [];
var svc, type;
if (ovs) {
for (var i = 0, c = ovs.getLength(); i < c; i++) {
addCopyrightInfo_(cp, ovs.getAt(i).mapService_, map);
}
}
var ovTypes = map.overlayMapTypes;
if (ovTypes) {
for (var i = 0, c = ovTypes.getLength(); i < c; i++) {
type = ovTypes.getAt(i);
if (type instanceof MapType) {
for (var j = 0, cj = type.tileLayers_.length; j < cj; j++) {
addCopyrightInfo_(cp, type.tileLayers_[j].mapService_, map);
}
}
}
}
type = map.mapTypes.get(map.getMapTypeId());
if (type instanceof MapType) {
for (var i = 0, c = type.tileLayers_.length; i < c; i++) {
addCopyrightInfo_(cp, type.tileLayers_[i].mapService_, map);
}
if (type.negative) {
div.style.color = '#ffffff';
} else {
div.style.color = '#000000';
}
}
div.innerHTML = cp.join('<br/>');
}
} | javascript | function setCopyrightInfo_(map) {
var div = null;
if (map) {
var mvc = map.controls[G.ControlPosition.BOTTOM_RIGHT];
if (mvc) {
for (var i = 0, c = mvc.getLength(); i < c; i++) {
if (mvc.getAt(i).id === 'agsCopyrights') {
div = mvc.getAt(i);
break;
}
}
}
//var callback = callback_(setCopyrightInfo_, null, map);
if (!div) {
div = document.createElement('div');
div.style.fontFamily = 'Arial,sans-serif';
div.style.fontSize = '10px';
div.style.textAlign = 'right';
div.id = 'agsCopyrights';
map.controls[G.ControlPosition.BOTTOM_RIGHT].push(div);
G.event.addListener(map, 'maptypeid_changed', function() {
setCopyrightInfo_(map);
});
}
var ovs = map.agsOverlays;
var cp = [];
var svc, type;
if (ovs) {
for (var i = 0, c = ovs.getLength(); i < c; i++) {
addCopyrightInfo_(cp, ovs.getAt(i).mapService_, map);
}
}
var ovTypes = map.overlayMapTypes;
if (ovTypes) {
for (var i = 0, c = ovTypes.getLength(); i < c; i++) {
type = ovTypes.getAt(i);
if (type instanceof MapType) {
for (var j = 0, cj = type.tileLayers_.length; j < cj; j++) {
addCopyrightInfo_(cp, type.tileLayers_[j].mapService_, map);
}
}
}
}
type = map.mapTypes.get(map.getMapTypeId());
if (type instanceof MapType) {
for (var i = 0, c = type.tileLayers_.length; i < c; i++) {
addCopyrightInfo_(cp, type.tileLayers_[i].mapService_, map);
}
if (type.negative) {
div.style.color = '#ffffff';
} else {
div.style.color = '#000000';
}
}
div.innerHTML = cp.join('<br/>');
}
} | [
"function",
"setCopyrightInfo_",
"(",
"map",
")",
"{",
"var",
"div",
"=",
"null",
";",
"if",
"(",
"map",
")",
"{",
"var",
"mvc",
"=",
"map",
".",
"controls",
"[",
"G",
".",
"ControlPosition",
".",
"BOTTOM_RIGHT",
"]",
";",
"if",
"(",
"mvc",
")",
"{... | Find copyright control in the map
@param {Object} map | [
"Find",
"copyright",
"control",
"in",
"the",
"map"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/src/arcgislink.js#L716-L772 |
10,251 | googlemaps/v3-utility-library | arcgislink/examples/simpleags.js | updateTOC | function updateTOC() {
if (ov && svc.hasLoaded()) {
var toc = '';
var scale = 591657527.591555 / (Math.pow(2, map.getZoom()));//591657527.591555 is the scale at level 0
var layers = svc.layers;
for (var i = 0; i < layers.length; i++) {
var layer = layers[i];
var inScale = layer.isInScale(scale);
toc += '<div style="color:' + (inScale ? 'black' : 'gray') + '">';
if (layer.subLayerIds) {
toc += layer.name + '(group)<br/>';
} else {
if (layer.parentLayer) {
toc += ' ';
}
toc += '<input type="checkbox" id="layer' + layer.id + '"';
if (layer.visible) {
toc += ' checked="checked"';
}
if (!inScale || svc.singleFusedMapCache) {
toc += ' disabled="disabled"';
}
toc += ' onclick="setLayerVisibility()">' + layer.name + '<br/>';
}
toc += '</div>';
}
document.getElementById('toc').innerHTML = toc;
}
} | javascript | function updateTOC() {
if (ov && svc.hasLoaded()) {
var toc = '';
var scale = 591657527.591555 / (Math.pow(2, map.getZoom()));//591657527.591555 is the scale at level 0
var layers = svc.layers;
for (var i = 0; i < layers.length; i++) {
var layer = layers[i];
var inScale = layer.isInScale(scale);
toc += '<div style="color:' + (inScale ? 'black' : 'gray') + '">';
if (layer.subLayerIds) {
toc += layer.name + '(group)<br/>';
} else {
if (layer.parentLayer) {
toc += ' ';
}
toc += '<input type="checkbox" id="layer' + layer.id + '"';
if (layer.visible) {
toc += ' checked="checked"';
}
if (!inScale || svc.singleFusedMapCache) {
toc += ' disabled="disabled"';
}
toc += ' onclick="setLayerVisibility()">' + layer.name + '<br/>';
}
toc += '</div>';
}
document.getElementById('toc').innerHTML = toc;
}
} | [
"function",
"updateTOC",
"(",
")",
"{",
"if",
"(",
"ov",
"&&",
"svc",
".",
"hasLoaded",
"(",
")",
")",
"{",
"var",
"toc",
"=",
"''",
";",
"var",
"scale",
"=",
"591657527.591555",
"/",
"(",
"Math",
".",
"pow",
"(",
"2",
",",
"map",
".",
"getZoom",... | Create layer list. | [
"Create",
"layer",
"list",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/examples/simpleags.js#L89-L118 |
10,252 | googlemaps/v3-utility-library | arcgislink/examples/simpleags.js | setLayerVisibility | function setLayerVisibility() {
var layers = svc.layers;
for (var i = 0; i < layers.length; i++) {
var el = document.getElementById('layer' + layers[i].id);
if (el) {
layers[i].visible = (el.checked === true);
}
}
ov.refresh();
} | javascript | function setLayerVisibility() {
var layers = svc.layers;
for (var i = 0; i < layers.length; i++) {
var el = document.getElementById('layer' + layers[i].id);
if (el) {
layers[i].visible = (el.checked === true);
}
}
ov.refresh();
} | [
"function",
"setLayerVisibility",
"(",
")",
"{",
"var",
"layers",
"=",
"svc",
".",
"layers",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"layers",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"el",
"=",
"document",
".",
"getElementById... | Check the visibility of layers and refresh map | [
"Check",
"the",
"visibility",
"of",
"layers",
"and",
"refresh",
"map"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/examples/simpleags.js#L123-L132 |
10,253 | googlemaps/v3-utility-library | ExtDraggableObject/src/ExtDraggableObject.js | mouseMove_ | function mouseMove_(ev) {
var e=ev||event;
currentX_ = formerX_+((e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft))-formerMouseX_);
currentY_ = formerY_+((e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop))-formerMouseY_);
formerX_ = currentX_;
formerY_ = currentY_;
formerMouseX_ = e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft);
formerMouseY_ = e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop);
if (moving_) {
moveTo_(currentX_,currentY_, preventDefault_);
event_.trigger(me, "drag", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e});
}
} | javascript | function mouseMove_(ev) {
var e=ev||event;
currentX_ = formerX_+((e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft))-formerMouseX_);
currentY_ = formerY_+((e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop))-formerMouseY_);
formerX_ = currentX_;
formerY_ = currentY_;
formerMouseX_ = e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft);
formerMouseY_ = e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop);
if (moving_) {
moveTo_(currentX_,currentY_, preventDefault_);
event_.trigger(me, "drag", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e});
}
} | [
"function",
"mouseMove_",
"(",
"ev",
")",
"{",
"var",
"e",
"=",
"ev",
"||",
"event",
";",
"currentX_",
"=",
"formerX_",
"+",
"(",
"(",
"e",
".",
"pageX",
"||",
"(",
"e",
".",
"clientX",
"+",
"document",
".",
"body",
".",
"scrollLeft",
"+",
"documen... | Handles the mousemove event.
@param {event} ev The event data sent by the browser.
@private | [
"Handles",
"the",
"mousemove",
"event",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/ExtDraggableObject/src/ExtDraggableObject.js#L131-L143 |
10,254 | googlemaps/v3-utility-library | ExtDraggableObject/src/ExtDraggableObject.js | mouseDown_ | function mouseDown_(ev) {
var e=ev||event;
setCursor_(true);
event_.trigger(me, "mousedown", e);
if (src.style.position !== "absolute") {
src.style.position = "absolute";
return;
}
formerMouseX_ = e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft);
formerMouseY_ = e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop);
originalX_ = src.offsetLeft;
originalY_ = src.offsetTop;
formerX_ = originalX_;
formerY_ = originalY_;
mouseMoveEvent_ = event_.addDomListener(target_, "mousemove", mouseMove_);
if (src.setCapture) {
src.setCapture();
}
if (e.preventDefault) {
e.preventDefault();
e.stopPropagation();
} else {
e.cancelBubble=true;
e.returnValue=false;
}
moving_ = true;
event_.trigger(me, "dragstart", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e});
} | javascript | function mouseDown_(ev) {
var e=ev||event;
setCursor_(true);
event_.trigger(me, "mousedown", e);
if (src.style.position !== "absolute") {
src.style.position = "absolute";
return;
}
formerMouseX_ = e.pageX||(e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft);
formerMouseY_ = e.pageY||(e.clientY+document.body.scrollTop+document.documentElement.scrollTop);
originalX_ = src.offsetLeft;
originalY_ = src.offsetTop;
formerX_ = originalX_;
formerY_ = originalY_;
mouseMoveEvent_ = event_.addDomListener(target_, "mousemove", mouseMove_);
if (src.setCapture) {
src.setCapture();
}
if (e.preventDefault) {
e.preventDefault();
e.stopPropagation();
} else {
e.cancelBubble=true;
e.returnValue=false;
}
moving_ = true;
event_.trigger(me, "dragstart", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e});
} | [
"function",
"mouseDown_",
"(",
"ev",
")",
"{",
"var",
"e",
"=",
"ev",
"||",
"event",
";",
"setCursor_",
"(",
"true",
")",
";",
"event_",
".",
"trigger",
"(",
"me",
",",
"\"mousedown\"",
",",
"e",
")",
";",
"if",
"(",
"src",
".",
"style",
".",
"po... | Handles the mousedown event.
@param {event} ev The event data sent by the browser.
@private | [
"Handles",
"the",
"mousedown",
"event",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/ExtDraggableObject/src/ExtDraggableObject.js#L150-L177 |
10,255 | googlemaps/v3-utility-library | ExtDraggableObject/src/ExtDraggableObject.js | mouseUp_ | function mouseUp_(ev) {
var e=ev||event;
if (moving_) {
setCursor_(false);
event_.removeListener(mouseMoveEvent_);
if (src.releaseCapture) {
src.releaseCapture();
}
moving_ = false;
event_.trigger(me, "dragend", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e});
}
currentX_ = currentY_ = null;
event_.trigger(me, "mouseup", e);
} | javascript | function mouseUp_(ev) {
var e=ev||event;
if (moving_) {
setCursor_(false);
event_.removeListener(mouseMoveEvent_);
if (src.releaseCapture) {
src.releaseCapture();
}
moving_ = false;
event_.trigger(me, "dragend", {mouseX: formerMouseX_, mouseY: formerMouseY_, startLeft: originalX_, startTop: originalY_, event:e});
}
currentX_ = currentY_ = null;
event_.trigger(me, "mouseup", e);
} | [
"function",
"mouseUp_",
"(",
"ev",
")",
"{",
"var",
"e",
"=",
"ev",
"||",
"event",
";",
"if",
"(",
"moving_",
")",
"{",
"setCursor_",
"(",
"false",
")",
";",
"event_",
".",
"removeListener",
"(",
"mouseMoveEvent_",
")",
";",
"if",
"(",
"src",
".",
... | Handles the mouseup event.
@param {event} ev The event data sent by the browser.
@private | [
"Handles",
"the",
"mouseup",
"event",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/ExtDraggableObject/src/ExtDraggableObject.js#L184-L197 |
10,256 | googlemaps/v3-utility-library | infobox/src/infobox.js | function (e) {
e.returnValue = false;
if (e.preventDefault) {
e.preventDefault();
}
if (!me.enableEventPropagation_) {
cancelHandler(e);
}
} | javascript | function (e) {
e.returnValue = false;
if (e.preventDefault) {
e.preventDefault();
}
if (!me.enableEventPropagation_) {
cancelHandler(e);
}
} | [
"function",
"(",
"e",
")",
"{",
"e",
".",
"returnValue",
"=",
"false",
";",
"if",
"(",
"e",
".",
"preventDefault",
")",
"{",
"e",
".",
"preventDefault",
"(",
")",
";",
"}",
"if",
"(",
"!",
"me",
".",
"enableEventPropagation_",
")",
"{",
"cancelHandle... | This handler ignores the current event in the InfoBox and conditionally prevents the event from being passed on to the map. It is used for the contextmenu event. | [
"This",
"handler",
"ignores",
"the",
"current",
"event",
"in",
"the",
"InfoBox",
"and",
"conditionally",
"prevents",
"the",
"event",
"from",
"being",
"passed",
"on",
"to",
"the",
"map",
".",
"It",
"is",
"used",
"for",
"the",
"contextmenu",
"event",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/infobox/src/infobox.js#L153-L166 | |
10,257 | googlemaps/v3-utility-library | util/docs/template/publish.js | isaTopLevelObject | function isaTopLevelObject($) {return (
($.is("CONSTRUCTOR") && $.name.match(/^[A-Z][A-Za-z]+/)) ||
($.is("FUNCTION") && $.name.match(/^[A-Z][A-Za-z]+/)) ||
$.comment.getTag("enum")[0] ||
$.comment.getTag("interface")[0] ||
$.isNamespace
);} | javascript | function isaTopLevelObject($) {return (
($.is("CONSTRUCTOR") && $.name.match(/^[A-Z][A-Za-z]+/)) ||
($.is("FUNCTION") && $.name.match(/^[A-Z][A-Za-z]+/)) ||
$.comment.getTag("enum")[0] ||
$.comment.getTag("interface")[0] ||
$.isNamespace
);} | [
"function",
"isaTopLevelObject",
"(",
"$",
")",
"{",
"return",
"(",
"(",
"$",
".",
"is",
"(",
"\"CONSTRUCTOR\"",
")",
"&&",
"$",
".",
"name",
".",
"match",
"(",
"/",
"^[A-Z][A-Za-z]+",
"/",
")",
")",
"||",
"(",
"$",
".",
"is",
"(",
"\"FUNCTION\"",
... | Find the top-level objects - class, enum, function, interface, namespace | [
"Find",
"the",
"top",
"-",
"level",
"objects",
"-",
"class",
"enum",
"function",
"interface",
"namespace"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/util/docs/template/publish.js#L26-L32 |
10,258 | googlemaps/v3-utility-library | util/docs/template/publish.js | isaSecondLevelObject | function isaSecondLevelObject ($) {return (
$.comment.getTag("property").length ||
($.is("CONSTRUCTOR") && $.name.match(/^[A-Z][A-Za-z]+$/)) ||
($.is("FUNCTION") && $.name.match(/^[a-z][A-Za-z]+$/)) ||
$.isConstant ||
($.type == "Function" && $.is("OBJECT"))
);} | javascript | function isaSecondLevelObject ($) {return (
$.comment.getTag("property").length ||
($.is("CONSTRUCTOR") && $.name.match(/^[A-Z][A-Za-z]+$/)) ||
($.is("FUNCTION") && $.name.match(/^[a-z][A-Za-z]+$/)) ||
$.isConstant ||
($.type == "Function" && $.is("OBJECT"))
);} | [
"function",
"isaSecondLevelObject",
"(",
"$",
")",
"{",
"return",
"(",
"$",
".",
"comment",
".",
"getTag",
"(",
"\"property\"",
")",
".",
"length",
"||",
"(",
"$",
".",
"is",
"(",
"\"CONSTRUCTOR\"",
")",
"&&",
"$",
".",
"name",
".",
"match",
"(",
"/"... | Find the second-level objects - Properties, Constructor, Methods, Constants, Events | [
"Find",
"the",
"second",
"-",
"level",
"objects",
"-",
"Properties",
"Constructor",
"Methods",
"Constants",
"Events"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/util/docs/template/publish.js#L35-L41 |
10,259 | googlemaps/v3-utility-library | markerclusterer/src/markerclusterer.js | Cluster | function Cluster(markerClusterer) {
this.markerClusterer_ = markerClusterer;
this.map_ = markerClusterer.getMap();
this.gridSize_ = markerClusterer.getGridSize();
this.minClusterSize_ = markerClusterer.getMinClusterSize();
this.averageCenter_ = markerClusterer.isAverageCenter();
this.center_ = null;
this.markers_ = [];
this.bounds_ = null;
this.clusterIcon_ = new ClusterIcon(this, markerClusterer.getStyles(),
markerClusterer.getGridSize());
} | javascript | function Cluster(markerClusterer) {
this.markerClusterer_ = markerClusterer;
this.map_ = markerClusterer.getMap();
this.gridSize_ = markerClusterer.getGridSize();
this.minClusterSize_ = markerClusterer.getMinClusterSize();
this.averageCenter_ = markerClusterer.isAverageCenter();
this.center_ = null;
this.markers_ = [];
this.bounds_ = null;
this.clusterIcon_ = new ClusterIcon(this, markerClusterer.getStyles(),
markerClusterer.getGridSize());
} | [
"function",
"Cluster",
"(",
"markerClusterer",
")",
"{",
"this",
".",
"markerClusterer_",
"=",
"markerClusterer",
";",
"this",
".",
"map_",
"=",
"markerClusterer",
".",
"getMap",
"(",
")",
";",
"this",
".",
"gridSize_",
"=",
"markerClusterer",
".",
"getGridSiz... | A cluster that contains markers.
@param {MarkerClusterer} markerClusterer The markerclusterer that this
cluster is associated with.
@constructor
@ignore | [
"A",
"cluster",
"that",
"contains",
"markers",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/markerclusterer/src/markerclusterer.js#L817-L828 |
10,260 | googlemaps/v3-utility-library | markerclusterer/src/markerclusterer.js | ClusterIcon | function ClusterIcon(cluster, styles, opt_padding) {
cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView);
this.styles_ = styles;
this.padding_ = opt_padding || 0;
this.cluster_ = cluster;
this.center_ = null;
this.map_ = cluster.getMap();
this.div_ = null;
this.sums_ = null;
this.visible_ = false;
this.setMap(this.map_);
} | javascript | function ClusterIcon(cluster, styles, opt_padding) {
cluster.getMarkerClusterer().extend(ClusterIcon, google.maps.OverlayView);
this.styles_ = styles;
this.padding_ = opt_padding || 0;
this.cluster_ = cluster;
this.center_ = null;
this.map_ = cluster.getMap();
this.div_ = null;
this.sums_ = null;
this.visible_ = false;
this.setMap(this.map_);
} | [
"function",
"ClusterIcon",
"(",
"cluster",
",",
"styles",
",",
"opt_padding",
")",
"{",
"cluster",
".",
"getMarkerClusterer",
"(",
")",
".",
"extend",
"(",
"ClusterIcon",
",",
"google",
".",
"maps",
".",
"OverlayView",
")",
";",
"this",
".",
"styles_",
"="... | A cluster icon
@param {Cluster} cluster The cluster to be associated with.
@param {Object} styles An object that has style properties:
'url': (string) The image url.
'height': (number) The image height.
'width': (number) The image width.
'anchor': (Array) The anchor position of the label text.
'textColor': (string) The text color.
'textSize': (number) The text size.
'backgroundPosition: (string) The background postition x, y.
@param {number=} opt_padding Optional padding to apply to the cluster icon.
@constructor
@extends google.maps.OverlayView
@ignore | [
"A",
"cluster",
"icon"
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/markerclusterer/src/markerclusterer.js#L1042-L1055 |
10,261 | googlemaps/v3-utility-library | markerclustererplus/src/markerclusterer.js | Cluster | function Cluster(mc) {
this.markerClusterer_ = mc;
this.map_ = mc.getMap();
this.gridSize_ = mc.getGridSize();
this.minClusterSize_ = mc.getMinimumClusterSize();
this.averageCenter_ = mc.getAverageCenter();
this.markers_ = [];
this.center_ = null;
this.bounds_ = null;
this.clusterIcon_ = new ClusterIcon(this, mc.getStyles());
} | javascript | function Cluster(mc) {
this.markerClusterer_ = mc;
this.map_ = mc.getMap();
this.gridSize_ = mc.getGridSize();
this.minClusterSize_ = mc.getMinimumClusterSize();
this.averageCenter_ = mc.getAverageCenter();
this.markers_ = [];
this.center_ = null;
this.bounds_ = null;
this.clusterIcon_ = new ClusterIcon(this, mc.getStyles());
} | [
"function",
"Cluster",
"(",
"mc",
")",
"{",
"this",
".",
"markerClusterer_",
"=",
"mc",
";",
"this",
".",
"map_",
"=",
"mc",
".",
"getMap",
"(",
")",
";",
"this",
".",
"gridSize_",
"=",
"mc",
".",
"getGridSize",
"(",
")",
";",
"this",
".",
"minClus... | Creates a single cluster that manages a group of proximate markers.
Used internally, do not call this constructor directly.
@constructor
@param {MarkerClusterer} mc The <code>MarkerClusterer</code> object with which this
cluster is associated. | [
"Creates",
"a",
"single",
"cluster",
"that",
"manages",
"a",
"group",
"of",
"proximate",
"markers",
".",
"Used",
"internally",
"do",
"not",
"call",
"this",
"constructor",
"directly",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/markerclustererplus/src/markerclusterer.js#L372-L382 |
10,262 | googlemaps/v3-utility-library | arcgislink/examples/find.js | find | function find(q) {
removeOverlays();
if (iw)
iw.close();
document.getElementById('results').innerHTML = '';
var exact = document.getElementById('exact').checked;
var params = {
returnGeometry: true,
searchText: q,
contains: !exact,
layerIds: [0, 2], // city, state
searchFields: ["CITY_NAME", "NAME", "SYSTEM", "STATE_ABBR", "STATE_NAME"],
sr: 4326
};
service.find(params, processFindResults);
} | javascript | function find(q) {
removeOverlays();
if (iw)
iw.close();
document.getElementById('results').innerHTML = '';
var exact = document.getElementById('exact').checked;
var params = {
returnGeometry: true,
searchText: q,
contains: !exact,
layerIds: [0, 2], // city, state
searchFields: ["CITY_NAME", "NAME", "SYSTEM", "STATE_ABBR", "STATE_NAME"],
sr: 4326
};
service.find(params, processFindResults);
} | [
"function",
"find",
"(",
"q",
")",
"{",
"removeOverlays",
"(",
")",
";",
"if",
"(",
"iw",
")",
"iw",
".",
"close",
"(",
")",
";",
"document",
".",
"getElementById",
"(",
"'results'",
")",
".",
"innerHTML",
"=",
"''",
";",
"var",
"exact",
"=",
"docu... | find results ... | [
"find",
"results",
"..."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/arcgislink/examples/find.js#L24-L39 |
10,263 | googlemaps/v3-utility-library | keydragzoom/src/keydragzoom.js | function (h) {
var computedStyle;
var bw = {};
if (document.defaultView && document.defaultView.getComputedStyle) {
computedStyle = h.ownerDocument.defaultView.getComputedStyle(h, "");
if (computedStyle) {
// The computed styles are always in pixel units (good!)
bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
return bw;
}
} else if (document.documentElement.currentStyle) { // MSIE
if (h.currentStyle) {
// The current styles may not be in pixel units so try to convert (bad!)
bw.top = parseInt(toPixels(h.currentStyle.borderTopWidth), 10) || 0;
bw.bottom = parseInt(toPixels(h.currentStyle.borderBottomWidth), 10) || 0;
bw.left = parseInt(toPixels(h.currentStyle.borderLeftWidth), 10) || 0;
bw.right = parseInt(toPixels(h.currentStyle.borderRightWidth), 10) || 0;
return bw;
}
}
// Shouldn't get this far for any modern browser
bw.top = parseInt(h.style["border-top-width"], 10) || 0;
bw.bottom = parseInt(h.style["border-bottom-width"], 10) || 0;
bw.left = parseInt(h.style["border-left-width"], 10) || 0;
bw.right = parseInt(h.style["border-right-width"], 10) || 0;
return bw;
} | javascript | function (h) {
var computedStyle;
var bw = {};
if (document.defaultView && document.defaultView.getComputedStyle) {
computedStyle = h.ownerDocument.defaultView.getComputedStyle(h, "");
if (computedStyle) {
// The computed styles are always in pixel units (good!)
bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
return bw;
}
} else if (document.documentElement.currentStyle) { // MSIE
if (h.currentStyle) {
// The current styles may not be in pixel units so try to convert (bad!)
bw.top = parseInt(toPixels(h.currentStyle.borderTopWidth), 10) || 0;
bw.bottom = parseInt(toPixels(h.currentStyle.borderBottomWidth), 10) || 0;
bw.left = parseInt(toPixels(h.currentStyle.borderLeftWidth), 10) || 0;
bw.right = parseInt(toPixels(h.currentStyle.borderRightWidth), 10) || 0;
return bw;
}
}
// Shouldn't get this far for any modern browser
bw.top = parseInt(h.style["border-top-width"], 10) || 0;
bw.bottom = parseInt(h.style["border-bottom-width"], 10) || 0;
bw.left = parseInt(h.style["border-left-width"], 10) || 0;
bw.right = parseInt(h.style["border-right-width"], 10) || 0;
return bw;
} | [
"function",
"(",
"h",
")",
"{",
"var",
"computedStyle",
";",
"var",
"bw",
"=",
"{",
"}",
";",
"if",
"(",
"document",
".",
"defaultView",
"&&",
"document",
".",
"defaultView",
".",
"getComputedStyle",
")",
"{",
"computedStyle",
"=",
"h",
".",
"ownerDocume... | Get the widths of the borders of an HTML element.
@param {Node} h The HTML element.
@return {Object} The width object {top, bottom left, right}. | [
"Get",
"the",
"widths",
"of",
"the",
"borders",
"of",
"an",
"HTML",
"element",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/keydragzoom/src/keydragzoom.js#L71-L100 | |
10,264 | googlemaps/v3-utility-library | keydragzoom/src/keydragzoom.js | function (e) {
var posX = 0, posY = 0;
e = e || window.event;
if (typeof e.pageX !== "undefined") {
posX = e.pageX;
posY = e.pageY;
} else if (typeof e.clientX !== "undefined") { // MSIE
posX = e.clientX + scroll.x;
posY = e.clientY + scroll.y;
}
return {
left: posX,
top: posY
};
} | javascript | function (e) {
var posX = 0, posY = 0;
e = e || window.event;
if (typeof e.pageX !== "undefined") {
posX = e.pageX;
posY = e.pageY;
} else if (typeof e.clientX !== "undefined") { // MSIE
posX = e.clientX + scroll.x;
posY = e.clientY + scroll.y;
}
return {
left: posX,
top: posY
};
} | [
"function",
"(",
"e",
")",
"{",
"var",
"posX",
"=",
"0",
",",
"posY",
"=",
"0",
";",
"e",
"=",
"e",
"||",
"window",
".",
"event",
";",
"if",
"(",
"typeof",
"e",
".",
"pageX",
"!==",
"\"undefined\"",
")",
"{",
"posX",
"=",
"e",
".",
"pageX",
"... | Get the position of the mouse relative to the document.
@param {Event} e The mouse event.
@return {Object} The position object {left, top}. | [
"Get",
"the",
"position",
"of",
"the",
"mouse",
"relative",
"to",
"the",
"document",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/keydragzoom/src/keydragzoom.js#L120-L134 | |
10,265 | googlemaps/v3-utility-library | keydragzoom/src/keydragzoom.js | function (h) {
var posX = h.offsetLeft;
var posY = h.offsetTop;
var parent = h.offsetParent;
// Add offsets for all ancestors in the hierarchy
while (parent !== null) {
// Adjust for scrolling elements which may affect the map position.
//
// See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific
//
// "...make sure that every element [on a Web page] with an overflow
// of anything other than visible also has a position style set to
// something other than the default static..."
if (parent !== document.body && parent !== document.documentElement) {
posX -= parent.scrollLeft;
posY -= parent.scrollTop;
}
// See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5
// Example: http://notebook.kulchenko.com/maps/gridmove
var m = parent;
// This is the "normal" way to get offset information:
var moffx = m.offsetLeft;
var moffy = m.offsetTop;
// This covers those cases where a transform is used:
if (!moffx && !moffy && window.getComputedStyle) {
var matrix = document.defaultView.getComputedStyle(m, null).MozTransform ||
document.defaultView.getComputedStyle(m, null).WebkitTransform;
if (matrix) {
if (typeof matrix === "string") {
var parms = matrix.split(",");
moffx += parseInt(parms[4], 10) || 0;
moffy += parseInt(parms[5], 10) || 0;
}
}
}
posX += moffx;
posY += moffy;
parent = parent.offsetParent;
}
return {
left: posX,
top: posY
};
} | javascript | function (h) {
var posX = h.offsetLeft;
var posY = h.offsetTop;
var parent = h.offsetParent;
// Add offsets for all ancestors in the hierarchy
while (parent !== null) {
// Adjust for scrolling elements which may affect the map position.
//
// See http://www.howtocreate.co.uk/tutorials/javascript/browserspecific
//
// "...make sure that every element [on a Web page] with an overflow
// of anything other than visible also has a position style set to
// something other than the default static..."
if (parent !== document.body && parent !== document.documentElement) {
posX -= parent.scrollLeft;
posY -= parent.scrollTop;
}
// See http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/4cb86c0c1037a5e5
// Example: http://notebook.kulchenko.com/maps/gridmove
var m = parent;
// This is the "normal" way to get offset information:
var moffx = m.offsetLeft;
var moffy = m.offsetTop;
// This covers those cases where a transform is used:
if (!moffx && !moffy && window.getComputedStyle) {
var matrix = document.defaultView.getComputedStyle(m, null).MozTransform ||
document.defaultView.getComputedStyle(m, null).WebkitTransform;
if (matrix) {
if (typeof matrix === "string") {
var parms = matrix.split(",");
moffx += parseInt(parms[4], 10) || 0;
moffy += parseInt(parms[5], 10) || 0;
}
}
}
posX += moffx;
posY += moffy;
parent = parent.offsetParent;
}
return {
left: posX,
top: posY
};
} | [
"function",
"(",
"h",
")",
"{",
"var",
"posX",
"=",
"h",
".",
"offsetLeft",
";",
"var",
"posY",
"=",
"h",
".",
"offsetTop",
";",
"var",
"parent",
"=",
"h",
".",
"offsetParent",
";",
"// Add offsets for all ancestors in the hierarchy\r",
"while",
"(",
"parent... | Get the position of an HTML element relative to the document.
@param {Node} h The HTML element.
@return {Object} The position object {left, top}. | [
"Get",
"the",
"position",
"of",
"an",
"HTML",
"element",
"relative",
"to",
"the",
"document",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/keydragzoom/src/keydragzoom.js#L140-L183 | |
10,266 | googlemaps/v3-utility-library | keydragzoom/src/keydragzoom.js | function (obj, vals) {
if (obj && vals) {
for (var x in vals) {
if (vals.hasOwnProperty(x)) {
obj[x] = vals[x];
}
}
}
return obj;
} | javascript | function (obj, vals) {
if (obj && vals) {
for (var x in vals) {
if (vals.hasOwnProperty(x)) {
obj[x] = vals[x];
}
}
}
return obj;
} | [
"function",
"(",
"obj",
",",
"vals",
")",
"{",
"if",
"(",
"obj",
"&&",
"vals",
")",
"{",
"for",
"(",
"var",
"x",
"in",
"vals",
")",
"{",
"if",
"(",
"vals",
".",
"hasOwnProperty",
"(",
"x",
")",
")",
"{",
"obj",
"[",
"x",
"]",
"=",
"vals",
"... | Set the properties of an object to those from another object.
@param {Object} obj The target object.
@param {Object} vals The source object. | [
"Set",
"the",
"properties",
"of",
"an",
"object",
"to",
"those",
"from",
"another",
"object",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/keydragzoom/src/keydragzoom.js#L189-L198 | |
10,267 | googlemaps/v3-utility-library | keydragzoom/src/keydragzoom.js | function (h, op) {
if (typeof op !== "undefined") {
h.style.opacity = op;
}
if (typeof h.style.opacity !== "undefined" && h.style.opacity !== "") {
h.style.filter = "alpha(opacity=" + (h.style.opacity * 100) + ")";
}
} | javascript | function (h, op) {
if (typeof op !== "undefined") {
h.style.opacity = op;
}
if (typeof h.style.opacity !== "undefined" && h.style.opacity !== "") {
h.style.filter = "alpha(opacity=" + (h.style.opacity * 100) + ")";
}
} | [
"function",
"(",
"h",
",",
"op",
")",
"{",
"if",
"(",
"typeof",
"op",
"!==",
"\"undefined\"",
")",
"{",
"h",
".",
"style",
".",
"opacity",
"=",
"op",
";",
"}",
"if",
"(",
"typeof",
"h",
".",
"style",
".",
"opacity",
"!==",
"\"undefined\"",
"&&",
... | Set the opacity. If op is not passed in, this function just performs an MSIE fix.
@param {Node} h The HTML element.
@param {number} op The opacity value (0-1). | [
"Set",
"the",
"opacity",
".",
"If",
"op",
"is",
"not",
"passed",
"in",
"this",
"function",
"just",
"performs",
"an",
"MSIE",
"fix",
"."
] | 66d4921aba3c0d5aa24d5998e485f46c34a6db27 | https://github.com/googlemaps/v3-utility-library/blob/66d4921aba3c0d5aa24d5998e485f46c34a6db27/keydragzoom/src/keydragzoom.js#L204-L211 | |
10,268 | Flipboard/react-canvas | examples/common/touch-emulator.js | Touch | function Touch(target, identifier, pos, deltaX, deltaY) {
deltaX = deltaX || 0;
deltaY = deltaY || 0;
this.identifier = identifier;
this.target = target;
this.clientX = pos.clientX + deltaX;
this.clientY = pos.clientY + deltaY;
this.screenX = pos.screenX + deltaX;
this.screenY = pos.screenY + deltaY;
this.pageX = pos.pageX + deltaX;
this.pageY = pos.pageY + deltaY;
} | javascript | function Touch(target, identifier, pos, deltaX, deltaY) {
deltaX = deltaX || 0;
deltaY = deltaY || 0;
this.identifier = identifier;
this.target = target;
this.clientX = pos.clientX + deltaX;
this.clientY = pos.clientY + deltaY;
this.screenX = pos.screenX + deltaX;
this.screenY = pos.screenY + deltaY;
this.pageX = pos.pageX + deltaX;
this.pageY = pos.pageY + deltaY;
} | [
"function",
"Touch",
"(",
"target",
",",
"identifier",
",",
"pos",
",",
"deltaX",
",",
"deltaY",
")",
"{",
"deltaX",
"=",
"deltaX",
"||",
"0",
";",
"deltaY",
"=",
"deltaY",
"||",
"0",
";",
"this",
".",
"identifier",
"=",
"identifier",
";",
"this",
".... | create an touch point
@constructor
@param target
@param identifier
@param pos
@param deltaX
@param deltaY
@returns {Object} touchPoint | [
"create",
"an",
"touch",
"point"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/examples/common/touch-emulator.js#L52-L64 |
10,269 | Flipboard/react-canvas | examples/common/touch-emulator.js | fakeTouchSupport | function fakeTouchSupport() {
var objs = [window, document.documentElement];
var props = ['ontouchstart', 'ontouchmove', 'ontouchcancel', 'ontouchend'];
for(var o=0; o<objs.length; o++) {
for(var p=0; p<props.length; p++) {
if(objs[o] && objs[o][props[p]] == undefined) {
objs[o][props[p]] = null;
}
}
}
} | javascript | function fakeTouchSupport() {
var objs = [window, document.documentElement];
var props = ['ontouchstart', 'ontouchmove', 'ontouchcancel', 'ontouchend'];
for(var o=0; o<objs.length; o++) {
for(var p=0; p<props.length; p++) {
if(objs[o] && objs[o][props[p]] == undefined) {
objs[o][props[p]] = null;
}
}
}
} | [
"function",
"fakeTouchSupport",
"(",
")",
"{",
"var",
"objs",
"=",
"[",
"window",
",",
"document",
".",
"documentElement",
"]",
";",
"var",
"props",
"=",
"[",
"'ontouchstart'",
",",
"'ontouchmove'",
",",
"'ontouchcancel'",
",",
"'ontouchend'",
"]",
";",
"for... | Simple trick to fake touch event support
this is enough for most libraries like Modernizr and Hammer | [
"Simple",
"trick",
"to",
"fake",
"touch",
"event",
"support",
"this",
"is",
"enough",
"for",
"most",
"libraries",
"like",
"Modernizr",
"and",
"Hammer"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/examples/common/touch-emulator.js#L91-L102 |
10,270 | Flipboard/react-canvas | examples/common/touch-emulator.js | hasTouchSupport | function hasTouchSupport() {
return ("ontouchstart" in window) || // touch events
(window.Modernizr && window.Modernizr.touch) || // modernizr
(navigator.msMaxTouchPoints || navigator.maxTouchPoints) > 2; // pointer events
} | javascript | function hasTouchSupport() {
return ("ontouchstart" in window) || // touch events
(window.Modernizr && window.Modernizr.touch) || // modernizr
(navigator.msMaxTouchPoints || navigator.maxTouchPoints) > 2; // pointer events
} | [
"function",
"hasTouchSupport",
"(",
")",
"{",
"return",
"(",
"\"ontouchstart\"",
"in",
"window",
")",
"||",
"// touch events",
"(",
"window",
".",
"Modernizr",
"&&",
"window",
".",
"Modernizr",
".",
"touch",
")",
"||",
"// modernizr",
"(",
"navigator",
".",
... | we don't have to emulate on a touch device
@returns {boolean} | [
"we",
"don",
"t",
"have",
"to",
"emulate",
"on",
"a",
"touch",
"device"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/examples/common/touch-emulator.js#L108-L112 |
10,271 | Flipboard/react-canvas | examples/common/touch-emulator.js | getActiveTouches | function getActiveTouches(mouseEv, eventName) {
// empty list
if (mouseEv.type == 'mouseup') {
return new TouchList();
}
var touchList = createTouchList(mouseEv);
if(isMultiTouch && mouseEv.type != 'mouseup' && eventName == 'touchend') {
touchList.splice(1, 1);
}
return touchList;
} | javascript | function getActiveTouches(mouseEv, eventName) {
// empty list
if (mouseEv.type == 'mouseup') {
return new TouchList();
}
var touchList = createTouchList(mouseEv);
if(isMultiTouch && mouseEv.type != 'mouseup' && eventName == 'touchend') {
touchList.splice(1, 1);
}
return touchList;
} | [
"function",
"getActiveTouches",
"(",
"mouseEv",
",",
"eventName",
")",
"{",
"// empty list",
"if",
"(",
"mouseEv",
".",
"type",
"==",
"'mouseup'",
")",
"{",
"return",
"new",
"TouchList",
"(",
")",
";",
"}",
"var",
"touchList",
"=",
"createTouchList",
"(",
... | receive all active touches
@param mouseEv
@returns {TouchList} | [
"receive",
"all",
"active",
"touches"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/examples/common/touch-emulator.js#L223-L234 |
10,272 | Flipboard/react-canvas | examples/common/touch-emulator.js | getChangedTouches | function getChangedTouches(mouseEv, eventName) {
var touchList = createTouchList(mouseEv);
// we only want to return the added/removed item on multitouch
// which is the second pointer, so remove the first pointer from the touchList
//
// but when the mouseEv.type is mouseup, we want to send all touches because then
// no new input will be possible
if(isMultiTouch && mouseEv.type != 'mouseup' &&
(eventName == 'touchstart' || eventName == 'touchend')) {
touchList.splice(0, 1);
}
return touchList;
} | javascript | function getChangedTouches(mouseEv, eventName) {
var touchList = createTouchList(mouseEv);
// we only want to return the added/removed item on multitouch
// which is the second pointer, so remove the first pointer from the touchList
//
// but when the mouseEv.type is mouseup, we want to send all touches because then
// no new input will be possible
if(isMultiTouch && mouseEv.type != 'mouseup' &&
(eventName == 'touchstart' || eventName == 'touchend')) {
touchList.splice(0, 1);
}
return touchList;
} | [
"function",
"getChangedTouches",
"(",
"mouseEv",
",",
"eventName",
")",
"{",
"var",
"touchList",
"=",
"createTouchList",
"(",
"mouseEv",
")",
";",
"// we only want to return the added/removed item on multitouch",
"// which is the second pointer, so remove the first pointer from the... | receive a filtered set of touches with only the changed pointers
@param mouseEv
@param eventName
@returns {TouchList} | [
"receive",
"a",
"filtered",
"set",
"of",
"touches",
"with",
"only",
"the",
"changed",
"pointers"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/examples/common/touch-emulator.js#L242-L256 |
10,273 | Flipboard/react-canvas | examples/common/touch-emulator.js | showTouches | function showTouches(ev) {
var touch, i, el, styles;
// first all visible touches
for(i = 0; i < ev.touches.length; i++) {
touch = ev.touches[i];
el = touchElements[touch.identifier];
if(!el) {
el = touchElements[touch.identifier] = document.createElement("div");
document.body.appendChild(el);
}
styles = TouchEmulator.template(touch);
for(var prop in styles) {
el.style[prop] = styles[prop];
}
}
// remove all ended touches
if(ev.type == 'touchend' || ev.type == 'touchcancel') {
for(i = 0; i < ev.changedTouches.length; i++) {
touch = ev.changedTouches[i];
el = touchElements[touch.identifier];
if(el) {
el.parentNode.removeChild(el);
delete touchElements[touch.identifier];
}
}
}
} | javascript | function showTouches(ev) {
var touch, i, el, styles;
// first all visible touches
for(i = 0; i < ev.touches.length; i++) {
touch = ev.touches[i];
el = touchElements[touch.identifier];
if(!el) {
el = touchElements[touch.identifier] = document.createElement("div");
document.body.appendChild(el);
}
styles = TouchEmulator.template(touch);
for(var prop in styles) {
el.style[prop] = styles[prop];
}
}
// remove all ended touches
if(ev.type == 'touchend' || ev.type == 'touchcancel') {
for(i = 0; i < ev.changedTouches.length; i++) {
touch = ev.changedTouches[i];
el = touchElements[touch.identifier];
if(el) {
el.parentNode.removeChild(el);
delete touchElements[touch.identifier];
}
}
}
} | [
"function",
"showTouches",
"(",
"ev",
")",
"{",
"var",
"touch",
",",
"i",
",",
"el",
",",
"styles",
";",
"// first all visible touches",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"ev",
".",
"touches",
".",
"length",
";",
"i",
"++",
")",
"{",
"touch... | show the touchpoints on the screen | [
"show",
"the",
"touchpoints",
"on",
"the",
"screen"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/examples/common/touch-emulator.js#L261-L290 |
10,274 | Flipboard/react-canvas | lib/FrameUtils.js | make | function make (x, y, width, height) {
return new Frame(x, y, width, height);
} | javascript | function make (x, y, width, height) {
return new Frame(x, y, width, height);
} | [
"function",
"make",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"return",
"new",
"Frame",
"(",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
";",
"}"
] | Get a frame object
@param {Number} x
@param {Number} y
@param {Number} width
@param {Number} height
@return {Frame} | [
"Get",
"a",
"frame",
"object"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/FrameUtils.js#L19-L21 |
10,275 | Flipboard/react-canvas | lib/FrameUtils.js | clone | function clone (frame) {
return make(frame.x, frame.y, frame.width, frame.height);
} | javascript | function clone (frame) {
return make(frame.x, frame.y, frame.width, frame.height);
} | [
"function",
"clone",
"(",
"frame",
")",
"{",
"return",
"make",
"(",
"frame",
".",
"x",
",",
"frame",
".",
"y",
",",
"frame",
".",
"width",
",",
"frame",
".",
"height",
")",
";",
"}"
] | Return a cloned frame
@param {Frame} frame
@return {Frame} | [
"Return",
"a",
"cloned",
"frame"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/FrameUtils.js#L38-L40 |
10,276 | Flipboard/react-canvas | lib/FrameUtils.js | intersection | function intersection (frame, otherFrame) {
var x = Math.max(frame.x, otherFrame.x);
var width = Math.min(frame.x + frame.width, otherFrame.x + otherFrame.width);
var y = Math.max(frame.y, otherFrame.y);
var height = Math.min(frame.y + frame.height, otherFrame.y + otherFrame.height);
if (width >= x && height >= y) {
return make(x, y, width - x, height - y);
}
return null;
} | javascript | function intersection (frame, otherFrame) {
var x = Math.max(frame.x, otherFrame.x);
var width = Math.min(frame.x + frame.width, otherFrame.x + otherFrame.width);
var y = Math.max(frame.y, otherFrame.y);
var height = Math.min(frame.y + frame.height, otherFrame.y + otherFrame.height);
if (width >= x && height >= y) {
return make(x, y, width - x, height - y);
}
return null;
} | [
"function",
"intersection",
"(",
"frame",
",",
"otherFrame",
")",
"{",
"var",
"x",
"=",
"Math",
".",
"max",
"(",
"frame",
".",
"x",
",",
"otherFrame",
".",
"x",
")",
";",
"var",
"width",
"=",
"Math",
".",
"min",
"(",
"frame",
".",
"x",
"+",
"fram... | Compute the intersection region between 2 frames.
@param {Frame} frame
@param {Frame} otherFrame
@return {Frame} | [
"Compute",
"the",
"intersection",
"region",
"between",
"2",
"frames",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/FrameUtils.js#L82-L91 |
10,277 | Flipboard/react-canvas | lib/FrameUtils.js | union | function union (frame, otherFrame) {
var x1 = Math.min(frame.x, otherFrame.x);
var x2 = Math.max(frame.x + frame.width, otherFrame.x + otherFrame.width);
var y1 = Math.min(frame.y, otherFrame.y);
var y2 = Math.max(frame.y + frame.height, otherFrame.y + otherFrame.height);
return make(x1, y1, x2 - x1, y2 - y1);
} | javascript | function union (frame, otherFrame) {
var x1 = Math.min(frame.x, otherFrame.x);
var x2 = Math.max(frame.x + frame.width, otherFrame.x + otherFrame.width);
var y1 = Math.min(frame.y, otherFrame.y);
var y2 = Math.max(frame.y + frame.height, otherFrame.y + otherFrame.height);
return make(x1, y1, x2 - x1, y2 - y1);
} | [
"function",
"union",
"(",
"frame",
",",
"otherFrame",
")",
"{",
"var",
"x1",
"=",
"Math",
".",
"min",
"(",
"frame",
".",
"x",
",",
"otherFrame",
".",
"x",
")",
";",
"var",
"x2",
"=",
"Math",
".",
"max",
"(",
"frame",
".",
"x",
"+",
"frame",
"."... | Compute the union of two frames
@param {Frame} frame
@param {Frame} otherFrame
@return {Frame} | [
"Compute",
"the",
"union",
"of",
"two",
"frames"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/FrameUtils.js#L100-L106 |
10,278 | Flipboard/react-canvas | lib/FrameUtils.js | intersects | function intersects (frame, otherFrame) {
return !(otherFrame.x > frame.x + frame.width ||
otherFrame.x + otherFrame.width < frame.x ||
otherFrame.y > frame.y + frame.height ||
otherFrame.y + otherFrame.height < frame.y);
} | javascript | function intersects (frame, otherFrame) {
return !(otherFrame.x > frame.x + frame.width ||
otherFrame.x + otherFrame.width < frame.x ||
otherFrame.y > frame.y + frame.height ||
otherFrame.y + otherFrame.height < frame.y);
} | [
"function",
"intersects",
"(",
"frame",
",",
"otherFrame",
")",
"{",
"return",
"!",
"(",
"otherFrame",
".",
"x",
">",
"frame",
".",
"x",
"+",
"frame",
".",
"width",
"||",
"otherFrame",
".",
"x",
"+",
"otherFrame",
".",
"width",
"<",
"frame",
".",
"x"... | Determine if 2 frames intersect each other
@param {Frame} frame
@param {Frame} otherFrame
@return {Boolean} | [
"Determine",
"if",
"2",
"frames",
"intersect",
"each",
"other"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/FrameUtils.js#L115-L120 |
10,279 | Flipboard/react-canvas | lib/ImageCache.js | function (hash, data) {
this.length++;
this.elements[hash] = {
hash: hash, // Helps identifying
freq: 0,
data: data
};
} | javascript | function (hash, data) {
this.length++;
this.elements[hash] = {
hash: hash, // Helps identifying
freq: 0,
data: data
};
} | [
"function",
"(",
"hash",
",",
"data",
")",
"{",
"this",
".",
"length",
"++",
";",
"this",
".",
"elements",
"[",
"hash",
"]",
"=",
"{",
"hash",
":",
"hash",
",",
"// Helps identifying ",
"freq",
":",
"0",
",",
"data",
":",
"data",
"}",
";",
"}"
] | Push with 0 frequency | [
"Push",
"with",
"0",
"frequency"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/ImageCache.js#L89-L96 | |
10,280 | Flipboard/react-canvas | lib/ImageCache.js | function (src) {
var image = _instancePool.get(src);
if (!image) {
// Awesome LRU
image = new Img(src);
if (_instancePool.length >= kInstancePoolLength) {
_instancePool.popLeastUsed().destructor();
}
_instancePool.push(image.getOriginalSrc(), image);
}
return image;
} | javascript | function (src) {
var image = _instancePool.get(src);
if (!image) {
// Awesome LRU
image = new Img(src);
if (_instancePool.length >= kInstancePoolLength) {
_instancePool.popLeastUsed().destructor();
}
_instancePool.push(image.getOriginalSrc(), image);
}
return image;
} | [
"function",
"(",
"src",
")",
"{",
"var",
"image",
"=",
"_instancePool",
".",
"get",
"(",
"src",
")",
";",
"if",
"(",
"!",
"image",
")",
"{",
"// Awesome LRU",
"image",
"=",
"new",
"Img",
"(",
"src",
")",
";",
"if",
"(",
"_instancePool",
".",
"lengt... | Retrieve an image from the cache
@return {Img} | [
"Retrieve",
"an",
"image",
"from",
"the",
"cache"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/ImageCache.js#L147-L158 | |
10,281 | Flipboard/react-canvas | lib/CanvasUtils.js | drawGradient | function drawGradient(ctx, x1, y1, x2, y2, colorStops, x, y, width, height) {
var grad;
ctx.save();
grad = ctx.createLinearGradient(x1, y1, x2, y2);
colorStops.forEach(function (colorStop) {
grad.addColorStop(colorStop.position, colorStop.color);
});
ctx.fillStyle = grad;
ctx.fillRect(x, y, width, height);
ctx.restore();
} | javascript | function drawGradient(ctx, x1, y1, x2, y2, colorStops, x, y, width, height) {
var grad;
ctx.save();
grad = ctx.createLinearGradient(x1, y1, x2, y2);
colorStops.forEach(function (colorStop) {
grad.addColorStop(colorStop.position, colorStop.color);
});
ctx.fillStyle = grad;
ctx.fillRect(x, y, width, height);
ctx.restore();
} | [
"function",
"drawGradient",
"(",
"ctx",
",",
"x1",
",",
"y1",
",",
"x2",
",",
"y2",
",",
"colorStops",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
")",
"{",
"var",
"grad",
";",
"ctx",
".",
"save",
"(",
")",
";",
"grad",
"=",
"ctx",
".",
... | Draw a linear gradient
@param {CanvasContext} ctx
@param {Number} x1 gradient start-x coordinate
@param {Number} y1 gradient start-y coordinate
@param {Number} x2 gradient end-x coordinate
@param {Number} y2 gradient end-y coordinate
@param {Array} colorStops Array of {(String)color, (Number)position} values
@param {Number} x x-coordinate to begin fill
@param {Number} y y-coordinate to begin fill
@param {Number} width how wide to fill
@param {Number} height how tall to fill | [
"Draw",
"a",
"linear",
"gradient"
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/CanvasUtils.js#L185-L198 |
10,282 | Flipboard/react-canvas | lib/DrawingUtils.js | invalidateBackingStore | function invalidateBackingStore (id) {
for (var i=0, len=_backingStores.length; i < len; i++) {
if (_backingStores[i].id === id) {
_backingStores.splice(i, 1);
break;
}
}
} | javascript | function invalidateBackingStore (id) {
for (var i=0, len=_backingStores.length; i < len; i++) {
if (_backingStores[i].id === id) {
_backingStores.splice(i, 1);
break;
}
}
} | [
"function",
"invalidateBackingStore",
"(",
"id",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"_backingStores",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"_backingStores",
"[",
"i",
"]",
".",
"id",
... | Purge a layer's backing store from the cache.
@param {String} id The layer's backingStoreId | [
"Purge",
"a",
"layer",
"s",
"backing",
"store",
"from",
"the",
"cache",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/DrawingUtils.js#L34-L41 |
10,283 | Flipboard/react-canvas | lib/DrawingUtils.js | getBackingStoreAncestor | function getBackingStoreAncestor (layer) {
while (layer) {
if (layer.backingStoreId) {
return layer;
}
layer = layer.parentLayer;
}
return null;
} | javascript | function getBackingStoreAncestor (layer) {
while (layer) {
if (layer.backingStoreId) {
return layer;
}
layer = layer.parentLayer;
}
return null;
} | [
"function",
"getBackingStoreAncestor",
"(",
"layer",
")",
"{",
"while",
"(",
"layer",
")",
"{",
"if",
"(",
"layer",
".",
"backingStoreId",
")",
"{",
"return",
"layer",
";",
"}",
"layer",
"=",
"layer",
".",
"parentLayer",
";",
"}",
"return",
"null",
";",
... | Find the nearest backing store ancestor for a given layer.
@param {RenderLayer} layer | [
"Find",
"the",
"nearest",
"backing",
"store",
"ancestor",
"for",
"a",
"given",
"layer",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/DrawingUtils.js#L55-L63 |
10,284 | Flipboard/react-canvas | lib/DrawingUtils.js | layerContainsImage | function layerContainsImage (layer, imageUrl) {
// Check the layer itself.
if (layer.type === 'image' && layer.imageUrl === imageUrl) {
return layer;
}
// Check the layer's children.
if (layer.children) {
for (var i=0, len=layer.children.length; i < len; i++) {
if (layerContainsImage(layer.children[i], imageUrl)) {
return layer.children[i];
}
}
}
return false;
} | javascript | function layerContainsImage (layer, imageUrl) {
// Check the layer itself.
if (layer.type === 'image' && layer.imageUrl === imageUrl) {
return layer;
}
// Check the layer's children.
if (layer.children) {
for (var i=0, len=layer.children.length; i < len; i++) {
if (layerContainsImage(layer.children[i], imageUrl)) {
return layer.children[i];
}
}
}
return false;
} | [
"function",
"layerContainsImage",
"(",
"layer",
",",
"imageUrl",
")",
"{",
"// Check the layer itself.",
"if",
"(",
"layer",
".",
"type",
"===",
"'image'",
"&&",
"layer",
".",
"imageUrl",
"===",
"imageUrl",
")",
"{",
"return",
"layer",
";",
"}",
"// Check the ... | Check if a layer is using a given image URL.
@param {RenderLayer} layer
@param {String} imageUrl
@return {Boolean} | [
"Check",
"if",
"a",
"layer",
"is",
"using",
"a",
"given",
"image",
"URL",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/DrawingUtils.js#L72-L88 |
10,285 | Flipboard/react-canvas | lib/DrawingUtils.js | layerContainsFontFace | function layerContainsFontFace (layer, fontFace) {
// Check the layer itself.
if (layer.type === 'text' && layer.fontFace && layer.fontFace.id === fontFace.id) {
return layer;
}
// Check the layer's children.
if (layer.children) {
for (var i=0, len=layer.children.length; i < len; i++) {
if (layerContainsFontFace(layer.children[i], fontFace)) {
return layer.children[i];
}
}
}
return false;
} | javascript | function layerContainsFontFace (layer, fontFace) {
// Check the layer itself.
if (layer.type === 'text' && layer.fontFace && layer.fontFace.id === fontFace.id) {
return layer;
}
// Check the layer's children.
if (layer.children) {
for (var i=0, len=layer.children.length; i < len; i++) {
if (layerContainsFontFace(layer.children[i], fontFace)) {
return layer.children[i];
}
}
}
return false;
} | [
"function",
"layerContainsFontFace",
"(",
"layer",
",",
"fontFace",
")",
"{",
"// Check the layer itself.",
"if",
"(",
"layer",
".",
"type",
"===",
"'text'",
"&&",
"layer",
".",
"fontFace",
"&&",
"layer",
".",
"fontFace",
".",
"id",
"===",
"fontFace",
".",
"... | Check if a layer is using a given FontFace.
@param {RenderLayer} layer
@param {FontFace} fontFace
@return {Boolean} | [
"Check",
"if",
"a",
"layer",
"is",
"using",
"a",
"given",
"FontFace",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/DrawingUtils.js#L97-L113 |
10,286 | Flipboard/react-canvas | lib/DrawingUtils.js | handleImageLoad | function handleImageLoad (imageUrl) {
_backingStores.forEach(function (backingStore) {
if (layerContainsImage(backingStore.layer, imageUrl)) {
invalidateBackingStore(backingStore.id);
}
});
} | javascript | function handleImageLoad (imageUrl) {
_backingStores.forEach(function (backingStore) {
if (layerContainsImage(backingStore.layer, imageUrl)) {
invalidateBackingStore(backingStore.id);
}
});
} | [
"function",
"handleImageLoad",
"(",
"imageUrl",
")",
"{",
"_backingStores",
".",
"forEach",
"(",
"function",
"(",
"backingStore",
")",
"{",
"if",
"(",
"layerContainsImage",
"(",
"backingStore",
".",
"layer",
",",
"imageUrl",
")",
")",
"{",
"invalidateBackingStor... | Invalidates the backing stores for layers which contain an image layer
associated with the given imageUrl.
@param {String} imageUrl | [
"Invalidates",
"the",
"backing",
"stores",
"for",
"layers",
"which",
"contain",
"an",
"image",
"layer",
"associated",
"with",
"the",
"given",
"imageUrl",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/DrawingUtils.js#L121-L127 |
10,287 | Flipboard/react-canvas | lib/DrawingUtils.js | handleFontLoad | function handleFontLoad (fontFace) {
_backingStores.forEach(function (backingStore) {
if (layerContainsFontFace(backingStore.layer, fontFace)) {
invalidateBackingStore(backingStore.id);
}
});
} | javascript | function handleFontLoad (fontFace) {
_backingStores.forEach(function (backingStore) {
if (layerContainsFontFace(backingStore.layer, fontFace)) {
invalidateBackingStore(backingStore.id);
}
});
} | [
"function",
"handleFontLoad",
"(",
"fontFace",
")",
"{",
"_backingStores",
".",
"forEach",
"(",
"function",
"(",
"backingStore",
")",
"{",
"if",
"(",
"layerContainsFontFace",
"(",
"backingStore",
".",
"layer",
",",
"fontFace",
")",
")",
"{",
"invalidateBackingSt... | Invalidates the backing stores for layers which contain a text layer
associated with the given font face.
@param {FontFace} fontFace | [
"Invalidates",
"the",
"backing",
"stores",
"for",
"layers",
"which",
"contain",
"a",
"text",
"layer",
"associated",
"with",
"the",
"given",
"font",
"face",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/DrawingUtils.js#L135-L141 |
10,288 | Flipboard/react-canvas | lib/FontUtils.js | loadFont | function loadFont (fontFace, callback) {
var defaultNode;
var testNode;
var checkFont;
// See if we've previously loaded it.
if (_loadedFonts[fontFace.id]) {
return callback(null);
}
// See if we've previously failed to load it.
if (_failedFonts[fontFace.id]) {
return callback(_failedFonts[fontFace.id]);
}
// System font: assume already loaded.
if (!fontFace.url) {
return callback(null);
}
// Font load is already in progress:
if (_pendingFonts[fontFace.id]) {
_pendingFonts[fontFace.id].callbacks.push(callback);
return;
}
// Create the test <span>'s for measuring.
defaultNode = createTestNode('Helvetica', fontFace.attributes);
testNode = createTestNode(fontFace.family, fontFace.attributes);
document.body.appendChild(testNode);
document.body.appendChild(defaultNode);
_pendingFonts[fontFace.id] = {
startTime: Date.now(),
defaultNode: defaultNode,
testNode: testNode,
callbacks: [callback]
};
// Font watcher
checkFont = function () {
var currWidth = testNode.getBoundingClientRect().width;
var defaultWidth = defaultNode.getBoundingClientRect().width;
var loaded = currWidth !== defaultWidth;
if (loaded) {
handleFontLoad(fontFace, null);
} else {
// Timeout?
if (Date.now() - _pendingFonts[fontFace.id].startTime >= kFontLoadTimeout) {
handleFontLoad(fontFace, true);
} else {
requestAnimationFrame(checkFont);
}
}
};
// Start watching
checkFont();
} | javascript | function loadFont (fontFace, callback) {
var defaultNode;
var testNode;
var checkFont;
// See if we've previously loaded it.
if (_loadedFonts[fontFace.id]) {
return callback(null);
}
// See if we've previously failed to load it.
if (_failedFonts[fontFace.id]) {
return callback(_failedFonts[fontFace.id]);
}
// System font: assume already loaded.
if (!fontFace.url) {
return callback(null);
}
// Font load is already in progress:
if (_pendingFonts[fontFace.id]) {
_pendingFonts[fontFace.id].callbacks.push(callback);
return;
}
// Create the test <span>'s for measuring.
defaultNode = createTestNode('Helvetica', fontFace.attributes);
testNode = createTestNode(fontFace.family, fontFace.attributes);
document.body.appendChild(testNode);
document.body.appendChild(defaultNode);
_pendingFonts[fontFace.id] = {
startTime: Date.now(),
defaultNode: defaultNode,
testNode: testNode,
callbacks: [callback]
};
// Font watcher
checkFont = function () {
var currWidth = testNode.getBoundingClientRect().width;
var defaultWidth = defaultNode.getBoundingClientRect().width;
var loaded = currWidth !== defaultWidth;
if (loaded) {
handleFontLoad(fontFace, null);
} else {
// Timeout?
if (Date.now() - _pendingFonts[fontFace.id].startTime >= kFontLoadTimeout) {
handleFontLoad(fontFace, true);
} else {
requestAnimationFrame(checkFont);
}
}
};
// Start watching
checkFont();
} | [
"function",
"loadFont",
"(",
"fontFace",
",",
"callback",
")",
"{",
"var",
"defaultNode",
";",
"var",
"testNode",
";",
"var",
"checkFont",
";",
"// See if we've previously loaded it.",
"if",
"(",
"_loadedFonts",
"[",
"fontFace",
".",
"id",
"]",
")",
"{",
"retu... | Load a remote font and execute a callback.
@param {FontFace} fontFace The font to Load
@param {Function} callback Function executed upon font Load | [
"Load",
"a",
"remote",
"font",
"and",
"execute",
"a",
"callback",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/FontUtils.js#L27-L86 |
10,289 | Flipboard/react-canvas | lib/layoutNode.js | layoutNode | function layoutNode (root) {
var rootNode = createNode(root);
computeLayout(rootNode);
walkNode(rootNode);
return rootNode;
} | javascript | function layoutNode (root) {
var rootNode = createNode(root);
computeLayout(rootNode);
walkNode(rootNode);
return rootNode;
} | [
"function",
"layoutNode",
"(",
"root",
")",
"{",
"var",
"rootNode",
"=",
"createNode",
"(",
"root",
")",
";",
"computeLayout",
"(",
"rootNode",
")",
";",
"walkNode",
"(",
"rootNode",
")",
";",
"return",
"rootNode",
";",
"}"
] | This computes the CSS layout for a RenderLayer tree and mutates the frame
objects at each node.
@param {Renderlayer} root
@return {Object} | [
"This",
"computes",
"the",
"CSS",
"layout",
"for",
"a",
"RenderLayer",
"tree",
"and",
"mutates",
"the",
"frame",
"objects",
"at",
"each",
"node",
"."
] | 0b71180b4061a55410efb4578df2b65c1bf00a8e | https://github.com/Flipboard/react-canvas/blob/0b71180b4061a55410efb4578df2b65c1bf00a8e/lib/layoutNode.js#L12-L17 |
10,290 | chaijs/chai | lib/chai/utils/inspect.js | function (object) {
if (typeof HTMLElement === 'object') {
return object instanceof HTMLElement;
} else {
return object &&
typeof object === 'object' &&
'nodeType' in object &&
object.nodeType === 1 &&
typeof object.nodeName === 'string';
}
} | javascript | function (object) {
if (typeof HTMLElement === 'object') {
return object instanceof HTMLElement;
} else {
return object &&
typeof object === 'object' &&
'nodeType' in object &&
object.nodeType === 1 &&
typeof object.nodeName === 'string';
}
} | [
"function",
"(",
"object",
")",
"{",
"if",
"(",
"typeof",
"HTMLElement",
"===",
"'object'",
")",
"{",
"return",
"object",
"instanceof",
"HTMLElement",
";",
"}",
"else",
"{",
"return",
"object",
"&&",
"typeof",
"object",
"===",
"'object'",
"&&",
"'nodeType'",... | Returns true if object is a DOM element. | [
"Returns",
"true",
"if",
"object",
"is",
"a",
"DOM",
"element",
"."
] | 6441f3df2f054da988233b0949265122b5849ad8 | https://github.com/chaijs/chai/blob/6441f3df2f054da988233b0949265122b5849ad8/lib/chai/utils/inspect.js#L36-L46 | |
10,291 | pixelcog/parallax.js | parallax.js | Plugin | function Plugin(option) {
return this.each(function () {
var $this = $(this);
var options = typeof option == 'object' && option;
if (this == window || this == document || $this.is('body')) {
Parallax.configure(options);
}
else if (!$this.data('px.parallax')) {
options = $.extend({}, $this.data(), options);
$this.data('px.parallax', new Parallax(this, options));
}
else if (typeof option == 'object')
{
$.extend($this.data('px.parallax'), options);
}
if (typeof option == 'string') {
if(option == 'destroy'){
Parallax.destroy(this);
}else{
Parallax[option]();
}
}
});
} | javascript | function Plugin(option) {
return this.each(function () {
var $this = $(this);
var options = typeof option == 'object' && option;
if (this == window || this == document || $this.is('body')) {
Parallax.configure(options);
}
else if (!$this.data('px.parallax')) {
options = $.extend({}, $this.data(), options);
$this.data('px.parallax', new Parallax(this, options));
}
else if (typeof option == 'object')
{
$.extend($this.data('px.parallax'), options);
}
if (typeof option == 'string') {
if(option == 'destroy'){
Parallax.destroy(this);
}else{
Parallax[option]();
}
}
});
} | [
"function",
"Plugin",
"(",
"option",
")",
"{",
"return",
"this",
".",
"each",
"(",
"function",
"(",
")",
"{",
"var",
"$this",
"=",
"$",
"(",
"this",
")",
";",
"var",
"options",
"=",
"typeof",
"option",
"==",
"'object'",
"&&",
"option",
";",
"if",
"... | Parallax Plugin Definition | [
"Parallax",
"Plugin",
"Definition"
] | 729b1f5e3dd4100e863f011990a1f1f6769fc919 | https://github.com/pixelcog/parallax.js/blob/729b1f5e3dd4100e863f011990a1f1f6769fc919/parallax.js#L366-L390 |
10,292 | babel/babel-loader | src/cache.js | async function(filename, compress) {
const data = await readFile(filename + (compress ? ".gz" : ""));
const content = compress ? await gunzip(data) : data;
return JSON.parse(content.toString());
} | javascript | async function(filename, compress) {
const data = await readFile(filename + (compress ? ".gz" : ""));
const content = compress ? await gunzip(data) : data;
return JSON.parse(content.toString());
} | [
"async",
"function",
"(",
"filename",
",",
"compress",
")",
"{",
"const",
"data",
"=",
"await",
"readFile",
"(",
"filename",
"+",
"(",
"compress",
"?",
"\".gz\"",
":",
"\"\"",
")",
")",
";",
"const",
"content",
"=",
"compress",
"?",
"await",
"gunzip",
... | Read the contents from the compressed file.
@async
@params {String} filename | [
"Read",
"the",
"contents",
"from",
"the",
"compressed",
"file",
"."
] | 5da4fa0c673474ab14bc829f2cbe03e60e437858 | https://github.com/babel/babel-loader/blob/5da4fa0c673474ab14bc829f2cbe03e60e437858/src/cache.js#L35-L40 | |
10,293 | babel/babel-loader | src/cache.js | async function(filename, compress, result) {
const content = JSON.stringify(result);
const data = compress ? await gzip(content) : content;
return await writeFile(filename + (compress ? ".gz" : ""), data);
} | javascript | async function(filename, compress, result) {
const content = JSON.stringify(result);
const data = compress ? await gzip(content) : content;
return await writeFile(filename + (compress ? ".gz" : ""), data);
} | [
"async",
"function",
"(",
"filename",
",",
"compress",
",",
"result",
")",
"{",
"const",
"content",
"=",
"JSON",
".",
"stringify",
"(",
"result",
")",
";",
"const",
"data",
"=",
"compress",
"?",
"await",
"gzip",
"(",
"content",
")",
":",
"content",
";"... | Write contents into a compressed file.
@async
@params {String} filename
@params {String} result | [
"Write",
"contents",
"into",
"a",
"compressed",
"file",
"."
] | 5da4fa0c673474ab14bc829f2cbe03e60e437858 | https://github.com/babel/babel-loader/blob/5da4fa0c673474ab14bc829f2cbe03e60e437858/src/cache.js#L49-L54 | |
10,294 | babel/babel-loader | src/cache.js | function(source, identifier, options) {
const hash = crypto.createHash("md4");
const contents = JSON.stringify({ source, options, identifier });
hash.update(contents);
return hash.digest("hex") + ".json";
} | javascript | function(source, identifier, options) {
const hash = crypto.createHash("md4");
const contents = JSON.stringify({ source, options, identifier });
hash.update(contents);
return hash.digest("hex") + ".json";
} | [
"function",
"(",
"source",
",",
"identifier",
",",
"options",
")",
"{",
"const",
"hash",
"=",
"crypto",
".",
"createHash",
"(",
"\"md4\"",
")",
";",
"const",
"contents",
"=",
"JSON",
".",
"stringify",
"(",
"{",
"source",
",",
"options",
",",
"identifier"... | Build the filename for the cached file
@params {String} source File source code
@params {Object} options Options used
@return {String} | [
"Build",
"the",
"filename",
"for",
"the",
"cached",
"file"
] | 5da4fa0c673474ab14bc829f2cbe03e60e437858 | https://github.com/babel/babel-loader/blob/5da4fa0c673474ab14bc829f2cbe03e60e437858/src/cache.js#L64-L72 | |
10,295 | babel/babel-loader | src/cache.js | async function(directory, params) {
const {
source,
options = {},
cacheIdentifier,
cacheDirectory,
cacheCompression,
} = params;
const file = path.join(directory, filename(source, cacheIdentifier, options));
try {
// No errors mean that the file was previously cached
// we just need to return it
return await read(file, cacheCompression);
} catch (err) {}
const fallback =
typeof cacheDirectory !== "string" && directory !== os.tmpdir();
// Make sure the directory exists.
try {
await mkdirp(directory);
} catch (err) {
if (fallback) {
return handleCache(os.tmpdir(), params);
}
throw err;
}
// Otherwise just transform the file
// return it to the user asap and write it in cache
const result = await transform(source, options);
try {
await write(file, cacheCompression, result);
} catch (err) {
if (fallback) {
// Fallback to tmpdir if node_modules folder not writable
return handleCache(os.tmpdir(), params);
}
throw err;
}
return result;
} | javascript | async function(directory, params) {
const {
source,
options = {},
cacheIdentifier,
cacheDirectory,
cacheCompression,
} = params;
const file = path.join(directory, filename(source, cacheIdentifier, options));
try {
// No errors mean that the file was previously cached
// we just need to return it
return await read(file, cacheCompression);
} catch (err) {}
const fallback =
typeof cacheDirectory !== "string" && directory !== os.tmpdir();
// Make sure the directory exists.
try {
await mkdirp(directory);
} catch (err) {
if (fallback) {
return handleCache(os.tmpdir(), params);
}
throw err;
}
// Otherwise just transform the file
// return it to the user asap and write it in cache
const result = await transform(source, options);
try {
await write(file, cacheCompression, result);
} catch (err) {
if (fallback) {
// Fallback to tmpdir if node_modules folder not writable
return handleCache(os.tmpdir(), params);
}
throw err;
}
return result;
} | [
"async",
"function",
"(",
"directory",
",",
"params",
")",
"{",
"const",
"{",
"source",
",",
"options",
"=",
"{",
"}",
",",
"cacheIdentifier",
",",
"cacheDirectory",
",",
"cacheCompression",
",",
"}",
"=",
"params",
";",
"const",
"file",
"=",
"path",
"."... | Handle the cache
@params {String} directory
@params {Object} params | [
"Handle",
"the",
"cache"
] | 5da4fa0c673474ab14bc829f2cbe03e60e437858 | https://github.com/babel/babel-loader/blob/5da4fa0c673474ab14bc829f2cbe03e60e437858/src/cache.js#L80-L127 | |
10,296 | ecomfe/echarts-gl | src/effect/TemporalSuperSampling.js | function (renderer, camera) {
var viewport = renderer.viewport;
var dpr = viewport.devicePixelRatio || renderer.getDevicePixelRatio();
var width = viewport.width * dpr;
var height = viewport.height * dpr;
var offset = this._haltonSequence[this._frame % this._haltonSequence.length];
var translationMat = new Matrix4();
translationMat.array[12] = (offset[0] * 2.0 - 1.0) / width;
translationMat.array[13] = (offset[1] * 2.0 - 1.0) / height;
Matrix4.mul(camera.projectionMatrix, translationMat, camera.projectionMatrix);
Matrix4.invert(camera.invProjectionMatrix, camera.projectionMatrix);
} | javascript | function (renderer, camera) {
var viewport = renderer.viewport;
var dpr = viewport.devicePixelRatio || renderer.getDevicePixelRatio();
var width = viewport.width * dpr;
var height = viewport.height * dpr;
var offset = this._haltonSequence[this._frame % this._haltonSequence.length];
var translationMat = new Matrix4();
translationMat.array[12] = (offset[0] * 2.0 - 1.0) / width;
translationMat.array[13] = (offset[1] * 2.0 - 1.0) / height;
Matrix4.mul(camera.projectionMatrix, translationMat, camera.projectionMatrix);
Matrix4.invert(camera.invProjectionMatrix, camera.projectionMatrix);
} | [
"function",
"(",
"renderer",
",",
"camera",
")",
"{",
"var",
"viewport",
"=",
"renderer",
".",
"viewport",
";",
"var",
"dpr",
"=",
"viewport",
".",
"devicePixelRatio",
"||",
"renderer",
".",
"getDevicePixelRatio",
"(",
")",
";",
"var",
"width",
"=",
"viewp... | Jitter camera projectionMatrix
@parma {clay.Renderer} renderer
@param {clay.Camera} camera | [
"Jitter",
"camera",
"projectionMatrix"
] | b59058e1b58d682fbbc602c084a86708b350f703 | https://github.com/ecomfe/echarts-gl/blob/b59058e1b58d682fbbc602c084a86708b350f703/src/effect/TemporalSuperSampling.js#L62-L77 | |
10,297 | ecomfe/echarts-gl | src/util/Triangulation.js | intersectEdge | function intersectEdge(x0, y0, x1, y1, x, y) {
if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
return -Infinity;
}
// Ignore horizontal line
if (y1 === y0) {
return -Infinity;
}
var dir = y1 < y0 ? 1 : -1;
var t = (y - y0) / (y1 - y0);
// Avoid winding error when intersection point is the connect point of two line of polygon
if (t === 1 || t === 0) {
dir = y1 < y0 ? 0.5 : -0.5;
}
var x_ = t * (x1 - x0) + x0;
return x_;
} | javascript | function intersectEdge(x0, y0, x1, y1, x, y) {
if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
return -Infinity;
}
// Ignore horizontal line
if (y1 === y0) {
return -Infinity;
}
var dir = y1 < y0 ? 1 : -1;
var t = (y - y0) / (y1 - y0);
// Avoid winding error when intersection point is the connect point of two line of polygon
if (t === 1 || t === 0) {
dir = y1 < y0 ? 0.5 : -0.5;
}
var x_ = t * (x1 - x0) + x0;
return x_;
} | [
"function",
"intersectEdge",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"x",
",",
"y",
")",
"{",
"if",
"(",
"(",
"y",
">",
"y0",
"&&",
"y",
">",
"y1",
")",
"||",
"(",
"y",
"<",
"y0",
"&&",
"y",
"<",
"y1",
")",
")",
"{",
"return",
... | From x,y point cast a ray to right. and intersect with edge x0, y0, x1, y1; Return x value of intersect point | [
"From",
"x",
"y",
"point",
"cast",
"a",
"ray",
"to",
"right",
".",
"and",
"intersect",
"with",
"edge",
"x0",
"y0",
"x1",
"y1",
";",
"Return",
"x",
"value",
"of",
"intersect",
"point"
] | b59058e1b58d682fbbc602c084a86708b350f703 | https://github.com/ecomfe/echarts-gl/blob/b59058e1b58d682fbbc602c084a86708b350f703/src/util/Triangulation.js#L12-L31 |
10,298 | ecomfe/echarts-gl | src/chart/flowGL/FlowGLView.js | function (texture) {
var pixels = texture.pixels;
var width = texture.width;
var height = texture.height;
function fetchPixel(x, y, rg) {
x = Math.max(Math.min(x, width - 1), 0);
y = Math.max(Math.min(y, height - 1), 0);
var idx = (y * (width - 1) + x) * 4;
if (pixels[idx + 3] === 0) {
return false;
}
rg[0] = pixels[idx];
rg[1] = pixels[idx + 1];
return true;
}
function addPixel(a, b, out) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
}
var center = [], left = [], right = [], top = [], bottom = [];
var weight = 0;
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var idx = (y * (width - 1) + x) * 4;
if (pixels[idx + 3] === 0) {
weight = center[0] = center[1] = 0;
if (fetchPixel(x - 1, y, left)) {
weight++; addPixel(left, center, center);
}
if (fetchPixel(x + 1, y, right)) {
weight++; addPixel(right, center, center);
}
if (fetchPixel(x, y - 1, top)) {
weight++; addPixel(top, center, center);
}
if (fetchPixel(x, y + 1, bottom)) {
weight++; addPixel(bottom, center, center);
}
center[0] /= weight;
center[1] /= weight;
// PENDING If overwrite. bilinear interpolation.
pixels[idx] = center[0];
pixels[idx + 1] = center[1];
}
pixels[idx + 3] = 1;
}
}
} | javascript | function (texture) {
var pixels = texture.pixels;
var width = texture.width;
var height = texture.height;
function fetchPixel(x, y, rg) {
x = Math.max(Math.min(x, width - 1), 0);
y = Math.max(Math.min(y, height - 1), 0);
var idx = (y * (width - 1) + x) * 4;
if (pixels[idx + 3] === 0) {
return false;
}
rg[0] = pixels[idx];
rg[1] = pixels[idx + 1];
return true;
}
function addPixel(a, b, out) {
out[0] = a[0] + b[0];
out[1] = a[1] + b[1];
}
var center = [], left = [], right = [], top = [], bottom = [];
var weight = 0;
for (var y = 0; y < height; y++) {
for (var x = 0; x < width; x++) {
var idx = (y * (width - 1) + x) * 4;
if (pixels[idx + 3] === 0) {
weight = center[0] = center[1] = 0;
if (fetchPixel(x - 1, y, left)) {
weight++; addPixel(left, center, center);
}
if (fetchPixel(x + 1, y, right)) {
weight++; addPixel(right, center, center);
}
if (fetchPixel(x, y - 1, top)) {
weight++; addPixel(top, center, center);
}
if (fetchPixel(x, y + 1, bottom)) {
weight++; addPixel(bottom, center, center);
}
center[0] /= weight;
center[1] /= weight;
// PENDING If overwrite. bilinear interpolation.
pixels[idx] = center[0];
pixels[idx + 1] = center[1];
}
pixels[idx + 3] = 1;
}
}
} | [
"function",
"(",
"texture",
")",
"{",
"var",
"pixels",
"=",
"texture",
".",
"pixels",
";",
"var",
"width",
"=",
"texture",
".",
"width",
";",
"var",
"height",
"=",
"texture",
".",
"height",
";",
"function",
"fetchPixel",
"(",
"x",
",",
"y",
",",
"rg"... | PENDING Use grid mesh ? or delaunay triangulation? | [
"PENDING",
"Use",
"grid",
"mesh",
"?",
"or",
"delaunay",
"triangulation?"
] | b59058e1b58d682fbbc602c084a86708b350f703 | https://github.com/ecomfe/echarts-gl/blob/b59058e1b58d682fbbc602c084a86708b350f703/src/chart/flowGL/FlowGLView.js#L180-L230 | |
10,299 | ecomfe/echarts-gl | src/util/ZRTextureAtlasSurface.js | function (el, width, height) {
// FIXME Text element not consider textAlign and textVerticalAlign.
// TODO, inner text, shadow
var rect = el.getBoundingRect();
// FIXME aspect ratio
if (width == null) {
width = rect.width;
}
if (height == null) {
height = rect.height;
}
width *= this.dpr;
height *= this.dpr;
this._fitElement(el, width, height);
// var aspect = el.scale[1] / el.scale[0];
// Adjust aspect ratio to make the text more clearly
// FIXME If height > width, width is useless ?
// width = height * aspect;
// el.position[0] *= aspect;
// el.scale[0] = el.scale[1];
var x = this._x;
var y = this._y;
var canvasWidth = this.width * this.dpr;
var canvasHeight = this.height * this.dpr;
var gap = this.gap;
if (x + width + gap > canvasWidth) {
// Change a new row
x = this._x = 0;
y += this._rowHeight + gap;
this._y = y;
// Reset row height
this._rowHeight = 0;
}
this._x += width + gap;
this._rowHeight = Math.max(this._rowHeight, height);
if (y + height + gap > canvasHeight) {
// There is no space anymore
return null;
}
// Shift the el
el.position[0] += this.offsetX * this.dpr + x;
el.position[1] += this.offsetY * this.dpr + y;
this._zr.add(el);
var coordsOffset = [
this.offsetX / this.width,
this.offsetY / this.height
];
var coords = [
[x / canvasWidth + coordsOffset[0], y / canvasHeight + coordsOffset[1]],
[(x + width) / canvasWidth + coordsOffset[0], (y + height) / canvasHeight + coordsOffset[1]]
];
return coords;
} | javascript | function (el, width, height) {
// FIXME Text element not consider textAlign and textVerticalAlign.
// TODO, inner text, shadow
var rect = el.getBoundingRect();
// FIXME aspect ratio
if (width == null) {
width = rect.width;
}
if (height == null) {
height = rect.height;
}
width *= this.dpr;
height *= this.dpr;
this._fitElement(el, width, height);
// var aspect = el.scale[1] / el.scale[0];
// Adjust aspect ratio to make the text more clearly
// FIXME If height > width, width is useless ?
// width = height * aspect;
// el.position[0] *= aspect;
// el.scale[0] = el.scale[1];
var x = this._x;
var y = this._y;
var canvasWidth = this.width * this.dpr;
var canvasHeight = this.height * this.dpr;
var gap = this.gap;
if (x + width + gap > canvasWidth) {
// Change a new row
x = this._x = 0;
y += this._rowHeight + gap;
this._y = y;
// Reset row height
this._rowHeight = 0;
}
this._x += width + gap;
this._rowHeight = Math.max(this._rowHeight, height);
if (y + height + gap > canvasHeight) {
// There is no space anymore
return null;
}
// Shift the el
el.position[0] += this.offsetX * this.dpr + x;
el.position[1] += this.offsetY * this.dpr + y;
this._zr.add(el);
var coordsOffset = [
this.offsetX / this.width,
this.offsetY / this.height
];
var coords = [
[x / canvasWidth + coordsOffset[0], y / canvasHeight + coordsOffset[1]],
[(x + width) / canvasWidth + coordsOffset[0], (y + height) / canvasHeight + coordsOffset[1]]
];
return coords;
} | [
"function",
"(",
"el",
",",
"width",
",",
"height",
")",
"{",
"// FIXME Text element not consider textAlign and textVerticalAlign.",
"// TODO, inner text, shadow",
"var",
"rect",
"=",
"el",
".",
"getBoundingRect",
"(",
")",
";",
"// FIXME aspect ratio",
"if",
"(",
"widt... | Add shape to atlas
@param {module:zrender/graphic/Displayable} shape
@param {number} width
@param {number} height
@return {Array} | [
"Add",
"shape",
"to",
"atlas"
] | b59058e1b58d682fbbc602c084a86708b350f703 | https://github.com/ecomfe/echarts-gl/blob/b59058e1b58d682fbbc602c084a86708b350f703/src/util/ZRTextureAtlasSurface.js#L75-L141 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.