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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
jsrmath/sharp11 | lib/mehegan.js | function (key, n) {
var int;
var numeral;
try {
int = key.getInterval(n);
} catch (err) {
try {
int = key.getInterval(n.clean());
} catch (err2) {
int = key.getInterval(n.toggleAccidental());
}
}
// Although dim7, for example, is a valid interval, we don't want a bbVII in our s... | javascript | function (key, n) {
var int;
var numeral;
try {
int = key.getInterval(n);
} catch (err) {
try {
int = key.getInterval(n.clean());
} catch (err2) {
int = key.getInterval(n.toggleAccidental());
}
}
// Although dim7, for example, is a valid interval, we don't want a bbVII in our s... | [
"function",
"(",
"key",
",",
"n",
")",
"{",
"var",
"int",
";",
"var",
"numeral",
";",
"try",
"{",
"int",
"=",
"key",
".",
"getInterval",
"(",
"n",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"try",
"{",
"int",
"=",
"key",
".",
"getInterval",
... | Given a key and a note, return a roman numeral representing the note | [
"Given",
"a",
"key",
"and",
"a",
"note",
"return",
"a",
"roman",
"numeral",
"representing",
"the",
"note"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/mehegan.js#L36-L61 | train | |
jsrmath/sharp11 | lib/mehegan.js | function (numeral) {
var matches = numeral.match(/([b#]?)([iIvV]+)/);
var halfSteps = interval.parse(_.indexOf(romanNumeral, matches[2]).toString()).halfSteps();
if (matches[1] === 'b') halfSteps -= 1;
if (matches[1] === '#') halfSteps += 1;
return halfSteps;
} | javascript | function (numeral) {
var matches = numeral.match(/([b#]?)([iIvV]+)/);
var halfSteps = interval.parse(_.indexOf(romanNumeral, matches[2]).toString()).halfSteps();
if (matches[1] === 'b') halfSteps -= 1;
if (matches[1] === '#') halfSteps += 1;
return halfSteps;
} | [
"function",
"(",
"numeral",
")",
"{",
"var",
"matches",
"=",
"numeral",
".",
"match",
"(",
"/",
"([b#]?)([iIvV]+)",
"/",
")",
";",
"var",
"halfSteps",
"=",
"interval",
".",
"parse",
"(",
"_",
".",
"indexOf",
"(",
"romanNumeral",
",",
"matches",
"[",
"2... | Given a roman numeral, return the number of half steps | [
"Given",
"a",
"roman",
"numeral",
"return",
"the",
"number",
"of",
"half",
"steps"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/mehegan.js#L64-L72 | train | |
jsrmath/sharp11 | lib/mehegan.js | function (numeral, quality) {
// Roman numeral representing chord
this.numeral = numeral;
// Chord quality: M, m, x, o, ø, s
this.quality = quality;
if (!_.contains(['M', 'm', 'x', 'o', 'ø', 's'], quality)) {
throw new Error('Invalid chord quality');
}
// The number of half-steps between the key and... | javascript | function (numeral, quality) {
// Roman numeral representing chord
this.numeral = numeral;
// Chord quality: M, m, x, o, ø, s
this.quality = quality;
if (!_.contains(['M', 'm', 'x', 'o', 'ø', 's'], quality)) {
throw new Error('Invalid chord quality');
}
// The number of half-steps between the key and... | [
"function",
"(",
"numeral",
",",
"quality",
")",
"{",
"// Roman numeral representing chord",
"this",
".",
"numeral",
"=",
"numeral",
";",
"// Chord quality: M, m, x, o, ø, s",
"this",
".",
"quality",
"=",
"quality",
";",
"if",
"(",
"!",
"_",
".",
"contains",
"("... | A roman numeral symbol representing a chord using the Mehegan system | [
"A",
"roman",
"numeral",
"symbol",
"representing",
"a",
"chord",
"using",
"the",
"Mehegan",
"system"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/mehegan.js#L80-L97 | train | |
jsrmath/sharp11 | lib/mehegan.js | function (key, ch) {
key = note.create(key || 'C');
ch = chord.create(ch);
return new Mehegan(getNumeral(key, ch.root), getQuality(ch));
} | javascript | function (key, ch) {
key = note.create(key || 'C');
ch = chord.create(ch);
return new Mehegan(getNumeral(key, ch.root), getQuality(ch));
} | [
"function",
"(",
"key",
",",
"ch",
")",
"{",
"key",
"=",
"note",
".",
"create",
"(",
"key",
"||",
"'C'",
")",
";",
"ch",
"=",
"chord",
".",
"create",
"(",
"ch",
")",
";",
"return",
"new",
"Mehegan",
"(",
"getNumeral",
"(",
"key",
",",
"ch",
"."... | Create a Mehegan symbol given a key and a chord | [
"Create",
"a",
"Mehegan",
"symbol",
"given",
"a",
"key",
"and",
"a",
"chord"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/mehegan.js#L100-L105 | train | |
jsrmath/sharp11 | lib/mehegan.js | function (mehegan, cache) {
if (mehegan instanceof Mehegan) return mehegan;
// If no cache is provided, return string as Mehegan symbol
if (!cache) return fromString(mehegan);
// Otherwise, try to retrieve symbol from cache, creating a new symbol if it's not found
if (!cache[mehegan]) cache[mehegan] = fromS... | javascript | function (mehegan, cache) {
if (mehegan instanceof Mehegan) return mehegan;
// If no cache is provided, return string as Mehegan symbol
if (!cache) return fromString(mehegan);
// Otherwise, try to retrieve symbol from cache, creating a new symbol if it's not found
if (!cache[mehegan]) cache[mehegan] = fromS... | [
"function",
"(",
"mehegan",
",",
"cache",
")",
"{",
"if",
"(",
"mehegan",
"instanceof",
"Mehegan",
")",
"return",
"mehegan",
";",
"// If no cache is provided, return string as Mehegan symbol",
"if",
"(",
"!",
"cache",
")",
"return",
"fromString",
"(",
"mehegan",
"... | Given a Mehegan symbol, return the Mehegan symbol Given a Mehegan string, return it as a Mehegan symbol If a cache is given, will store and retrieve symbols based on string | [
"Given",
"a",
"Mehegan",
"symbol",
"return",
"the",
"Mehegan",
"symbol",
"Given",
"a",
"Mehegan",
"string",
"return",
"it",
"as",
"a",
"Mehegan",
"symbol",
"If",
"a",
"cache",
"is",
"given",
"will",
"store",
"and",
"retrieve",
"symbols",
"based",
"on",
"st... | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/mehegan.js#L136-L145 | train | |
jsrmath/sharp11 | lib/interval.js | function (interval) {
var quality;
var number;
if (interval instanceof Interval) return interval;
quality = interval.replace(/\d/g, ''); // Remove digits
number = parseInt(interval.replace(/\D/g, ''), 10); // Remove non-digits
if (!quality) { // No quality given, assume major or perfect
quality = isP... | javascript | function (interval) {
var quality;
var number;
if (interval instanceof Interval) return interval;
quality = interval.replace(/\d/g, ''); // Remove digits
number = parseInt(interval.replace(/\D/g, ''), 10); // Remove non-digits
if (!quality) { // No quality given, assume major or perfect
quality = isP... | [
"function",
"(",
"interval",
")",
"{",
"var",
"quality",
";",
"var",
"number",
";",
"if",
"(",
"interval",
"instanceof",
"Interval",
")",
"return",
"interval",
";",
"quality",
"=",
"interval",
".",
"replace",
"(",
"/",
"\\d",
"/",
"g",
",",
"''",
")",
... | Parse a string and return an interval object | [
"Parse",
"a",
"string",
"and",
"return",
"an",
"interval",
"object"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/interval.js#L43-L57 | train | |
jsrmath/sharp11 | lib/scale.js | function (scale, note) {
return _.findIndex(scale.scale, function (scaleNote) {
return scaleNote.enharmonic(note);
});
} | javascript | function (scale, note) {
return _.findIndex(scale.scale, function (scaleNote) {
return scaleNote.enharmonic(note);
});
} | [
"function",
"(",
"scale",
",",
"note",
")",
"{",
"return",
"_",
".",
"findIndex",
"(",
"scale",
".",
"scale",
",",
"function",
"(",
"scaleNote",
")",
"{",
"return",
"scaleNote",
".",
"enharmonic",
"(",
"note",
")",
";",
"}",
")",
";",
"}"
] | Return index of note in scale | [
"Return",
"index",
"of",
"note",
"in",
"scale"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/scale.js#L94-L98 | train | |
jsrmath/sharp11 | lib/chord.js | function (chord) {
var noteRegex = '[A-Ga-g][#b]{0,2}';
var root = chord.match(new RegExp('^' + noteRegex))[0];
var bass = null;
var symbol;
root = note.create(root);
// Strip note, strip spaces, strip bass
symbol = chord.replace(/[\s]/g, '')
.replace(new RegExp('^' + noteRegex), '')
... | javascript | function (chord) {
var noteRegex = '[A-Ga-g][#b]{0,2}';
var root = chord.match(new RegExp('^' + noteRegex))[0];
var bass = null;
var symbol;
root = note.create(root);
// Strip note, strip spaces, strip bass
symbol = chord.replace(/[\s]/g, '')
.replace(new RegExp('^' + noteRegex), '')
... | [
"function",
"(",
"chord",
")",
"{",
"var",
"noteRegex",
"=",
"'[A-Ga-g][#b]{0,2}'",
";",
"var",
"root",
"=",
"chord",
".",
"match",
"(",
"new",
"RegExp",
"(",
"'^'",
"+",
"noteRegex",
")",
")",
"[",
"0",
"]",
";",
"var",
"bass",
"=",
"null",
";",
"... | Parse a chord symbol and return root, chord, bass | [
"Parse",
"a",
"chord",
"symbol",
"and",
"return",
"root",
"chord",
"bass"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/chord.js#L10-L27 | train | |
jsrmath/sharp11 | lib/chord.js | function (interval) {
return _.find(notes, function (n) {
return root.transpose(interval).enharmonic(n);
});
} | javascript | function (interval) {
return _.find(notes, function (n) {
return root.transpose(interval).enharmonic(n);
});
} | [
"function",
"(",
"interval",
")",
"{",
"return",
"_",
".",
"find",
"(",
"notes",
",",
"function",
"(",
"n",
")",
"{",
"return",
"root",
".",
"transpose",
"(",
"interval",
")",
".",
"enharmonic",
"(",
"n",
")",
";",
"}",
")",
";",
"}"
] | Return true if interval is present in this chord | [
"Return",
"true",
"if",
"interval",
"is",
"present",
"in",
"this",
"chord"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/chord.js#L183-L187 | train | |
jsrmath/sharp11 | lib/chord.js | function (root, bass, intervals) {
var chord = _.chain(intervals)
.map(function (quality, number) {
var int;
if (quality) {
// #9 is stored as b10, so special case this
if (number === 10 && quality === 'm') {
int = interval.create(9, 'aug');
}
else {
... | javascript | function (root, bass, intervals) {
var chord = _.chain(intervals)
.map(function (quality, number) {
var int;
if (quality) {
// #9 is stored as b10, so special case this
if (number === 10 && quality === 'm') {
int = interval.create(9, 'aug');
}
else {
... | [
"function",
"(",
"root",
",",
"bass",
",",
"intervals",
")",
"{",
"var",
"chord",
"=",
"_",
".",
"chain",
"(",
"intervals",
")",
".",
"map",
"(",
"function",
"(",
"quality",
",",
"number",
")",
"{",
"var",
"int",
";",
"if",
"(",
"quality",
")",
"... | Return an array of notes in a chord | [
"Return",
"an",
"array",
"of",
"notes",
"in",
"a",
"chord"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/chord.js#L364-L397 | train | |
jsrmath/sharp11 | lib/chord.js | function (root, symbol, bass) {
var name = root.name + symbol;
var octave = bass ? bass.octave : root.octave;
if (bass) name += '/' + bass.name;
return new Chord(name, octave);
} | javascript | function (root, symbol, bass) {
var name = root.name + symbol;
var octave = bass ? bass.octave : root.octave;
if (bass) name += '/' + bass.name;
return new Chord(name, octave);
} | [
"function",
"(",
"root",
",",
"symbol",
",",
"bass",
")",
"{",
"var",
"name",
"=",
"root",
".",
"name",
"+",
"symbol",
";",
"var",
"octave",
"=",
"bass",
"?",
"bass",
".",
"octave",
":",
"root",
".",
"octave",
";",
"if",
"(",
"bass",
")",
"name",... | Make a chord object given root, symbol, bass | [
"Make",
"a",
"chord",
"object",
"given",
"root",
"symbol",
"bass"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/chord.js#L400-L406 | train | |
jsrmath/sharp11 | lib/chord.js | function (scales, chord) {
// Exclude scales with a particular interval
var exclude = function (int) {
scales = _.filter(scales, function (scale) {
return !scale.hasInterval(int);
});
};
// Add a scale at a particular index
var include = function (index, scaleId) {
scales.splice(index, 0, s... | javascript | function (scales, chord) {
// Exclude scales with a particular interval
var exclude = function (int) {
scales = _.filter(scales, function (scale) {
return !scale.hasInterval(int);
});
};
// Add a scale at a particular index
var include = function (index, scaleId) {
scales.splice(index, 0, s... | [
"function",
"(",
"scales",
",",
"chord",
")",
"{",
"// Exclude scales with a particular interval",
"var",
"exclude",
"=",
"function",
"(",
"int",
")",
"{",
"scales",
"=",
"_",
".",
"filter",
"(",
"scales",
",",
"function",
"(",
"scale",
")",
"{",
"return",
... | Given an ordered list of scales and a chord symbol, optimize order | [
"Given",
"an",
"ordered",
"list",
"of",
"scales",
"and",
"a",
"chord",
"symbol",
"optimize",
"order"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/chord.js#L409-L440 | train | |
jsrmath/sharp11 | lib/chord.js | function (index, scaleId) {
scales.splice(index, 0, scale.create(chord.root, scaleId));
} | javascript | function (index, scaleId) {
scales.splice(index, 0, scale.create(chord.root, scaleId));
} | [
"function",
"(",
"index",
",",
"scaleId",
")",
"{",
"scales",
".",
"splice",
"(",
"index",
",",
"0",
",",
"scale",
".",
"create",
"(",
"chord",
".",
"root",
",",
"scaleId",
")",
")",
";",
"}"
] | Add a scale at a particular index | [
"Add",
"a",
"scale",
"at",
"a",
"particular",
"index"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/chord.js#L418-L420 | train | |
jsrmath/sharp11 | lib/chord.js | function (obj, octave) {
var lastNote = obj.chord[0];
obj.chord = _.map(obj.chord, function (n) {
// Every time a note is "lower" than the last note, we're in a new octave
if (n.lowerThan(lastNote)) octave += 1;
// As a side-effect, update the octaves for root and bass
if (n.enharmonic(obj.root)) ... | javascript | function (obj, octave) {
var lastNote = obj.chord[0];
obj.chord = _.map(obj.chord, function (n) {
// Every time a note is "lower" than the last note, we're in a new octave
if (n.lowerThan(lastNote)) octave += 1;
// As a side-effect, update the octaves for root and bass
if (n.enharmonic(obj.root)) ... | [
"function",
"(",
"obj",
",",
"octave",
")",
"{",
"var",
"lastNote",
"=",
"obj",
".",
"chord",
"[",
"0",
"]",
";",
"obj",
".",
"chord",
"=",
"_",
".",
"map",
"(",
"obj",
".",
"chord",
",",
"function",
"(",
"n",
")",
"{",
"// Every time a note is \"l... | Given a chord object and an octave number, assign appropriate octave numbers to notes | [
"Given",
"a",
"chord",
"object",
"and",
"an",
"octave",
"number",
"assign",
"appropriate",
"octave",
"numbers",
"to",
"notes"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/chord.js#L443-L461 | train | |
jsrmath/sharp11 | lib/midi.js | function (num, totalBytes) {
var numBytes = Math.floor(Math.log(num) / Math.log(0xff)) + 1;
var buffer = new Buffer(totalBytes);
buffer.fill(0);
buffer.writeUIntBE(num, totalBytes - numBytes, numBytes);
return buffer;
} | javascript | function (num, totalBytes) {
var numBytes = Math.floor(Math.log(num) / Math.log(0xff)) + 1;
var buffer = new Buffer(totalBytes);
buffer.fill(0);
buffer.writeUIntBE(num, totalBytes - numBytes, numBytes);
return buffer;
} | [
"function",
"(",
"num",
",",
"totalBytes",
")",
"{",
"var",
"numBytes",
"=",
"Math",
".",
"floor",
"(",
"Math",
".",
"log",
"(",
"num",
")",
"/",
"Math",
".",
"log",
"(",
"0xff",
")",
")",
"+",
"1",
";",
"var",
"buffer",
"=",
"new",
"Buffer",
"... | Return a number in a buffer padded to have a certain number of bytes | [
"Return",
"a",
"number",
"in",
"a",
"buffer",
"padded",
"to",
"have",
"a",
"certain",
"number",
"of",
"bytes"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L14-L22 | train | |
jsrmath/sharp11 | lib/midi.js | function (format, numTracks) {
var chunklen = padNumber(6, 4); // MIDI header is always 6 bytes long
var ntracks = padNumber(numTracks, 2);
var tickdiv = padNumber(ticksPerBeat, 2);
format = padNumber(format, 2); // Usually format 1 MIDI file (multuple overlayed tracks)
return Buffer.concat([midiHeader, chun... | javascript | function (format, numTracks) {
var chunklen = padNumber(6, 4); // MIDI header is always 6 bytes long
var ntracks = padNumber(numTracks, 2);
var tickdiv = padNumber(ticksPerBeat, 2);
format = padNumber(format, 2); // Usually format 1 MIDI file (multuple overlayed tracks)
return Buffer.concat([midiHeader, chun... | [
"function",
"(",
"format",
",",
"numTracks",
")",
"{",
"var",
"chunklen",
"=",
"padNumber",
"(",
"6",
",",
"4",
")",
";",
"// MIDI header is always 6 bytes long",
"var",
"ntracks",
"=",
"padNumber",
"(",
"numTracks",
",",
"2",
")",
";",
"var",
"tickdiv",
"... | Given a number of tracks, return a MIDI header | [
"Given",
"a",
"number",
"of",
"tracks",
"return",
"a",
"MIDI",
"header"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L45-L52 | train | |
jsrmath/sharp11 | lib/midi.js | function (settings) {
var tempo = 60e6 / settings.tempo; // Microseconds per beat
var setTempo = Buffer.concat([new Buffer([0, 0xFF, 0x51, 0x03]), padNumber(tempo, 3)]);
var length = setTempo.length + trackFooter.length;
return Buffer.concat([trackHeader, padNumber(length, 4), setTempo, trackFooter]);
} | javascript | function (settings) {
var tempo = 60e6 / settings.tempo; // Microseconds per beat
var setTempo = Buffer.concat([new Buffer([0, 0xFF, 0x51, 0x03]), padNumber(tempo, 3)]);
var length = setTempo.length + trackFooter.length;
return Buffer.concat([trackHeader, padNumber(length, 4), setTempo, trackFooter]);
} | [
"function",
"(",
"settings",
")",
"{",
"var",
"tempo",
"=",
"60e6",
"/",
"settings",
".",
"tempo",
";",
"// Microseconds per beat",
"var",
"setTempo",
"=",
"Buffer",
".",
"concat",
"(",
"[",
"new",
"Buffer",
"(",
"[",
"0",
",",
"0xFF",
",",
"0x51",
","... | Return a buffer with a MIDI track that sets the tempo | [
"Return",
"a",
"buffer",
"with",
"a",
"MIDI",
"track",
"that",
"sets",
"the",
"tempo"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L55-L61 | train | |
jsrmath/sharp11 | lib/midi.js | function (deltaTime, on, channel, note, velocity) {
var status = on ? 0x90 : 0x80;
status += channel;
deltaTime = makeVLQ(deltaTime);
return Buffer.concat([deltaTime, new Buffer([status, note, velocity])]);
} | javascript | function (deltaTime, on, channel, note, velocity) {
var status = on ? 0x90 : 0x80;
status += channel;
deltaTime = makeVLQ(deltaTime);
return Buffer.concat([deltaTime, new Buffer([status, note, velocity])]);
} | [
"function",
"(",
"deltaTime",
",",
"on",
",",
"channel",
",",
"note",
",",
"velocity",
")",
"{",
"var",
"status",
"=",
"on",
"?",
"0x90",
":",
"0x80",
";",
"status",
"+=",
"channel",
";",
"deltaTime",
"=",
"makeVLQ",
"(",
"deltaTime",
")",
";",
"retu... | Make a MIDI note event | [
"Make",
"a",
"MIDI",
"note",
"event"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L70-L77 | train | |
jsrmath/sharp11 | lib/midi.js | function (deltaTime, on, firstChannel, chord, velocity) {
var arr = [];
// Make note event for first note after appropriate time
arr.push(makeNoteEvent(deltaTime, on, firstChannel, noteValue(_.first(chord)), velocity));
// Make note event for rest of the notes
_.each(_.rest(chord), function (note, i) {
... | javascript | function (deltaTime, on, firstChannel, chord, velocity) {
var arr = [];
// Make note event for first note after appropriate time
arr.push(makeNoteEvent(deltaTime, on, firstChannel, noteValue(_.first(chord)), velocity));
// Make note event for rest of the notes
_.each(_.rest(chord), function (note, i) {
... | [
"function",
"(",
"deltaTime",
",",
"on",
",",
"firstChannel",
",",
"chord",
",",
"velocity",
")",
"{",
"var",
"arr",
"=",
"[",
"]",
";",
"// Make note event for first note after appropriate time",
"arr",
".",
"push",
"(",
"makeNoteEvent",
"(",
"deltaTime",
",",
... | Make a multiple MIDI note events for a given chord | [
"Make",
"a",
"multiple",
"MIDI",
"note",
"events",
"for",
"a",
"given",
"chord"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L80-L92 | train | |
jsrmath/sharp11 | lib/midi.js | function (duration, settings) {
// If there's no swing ratio, assume straight eighths
var ratio = settings && settings.swingRatio ? settings.swingRatio : 1;
return Math.round(ticksPerBeat * duration.value(ratio));
} | javascript | function (duration, settings) {
// If there's no swing ratio, assume straight eighths
var ratio = settings && settings.swingRatio ? settings.swingRatio : 1;
return Math.round(ticksPerBeat * duration.value(ratio));
} | [
"function",
"(",
"duration",
",",
"settings",
")",
"{",
"// If there's no swing ratio, assume straight eighths",
"var",
"ratio",
"=",
"settings",
"&&",
"settings",
".",
"swingRatio",
"?",
"settings",
".",
"swingRatio",
":",
"1",
";",
"return",
"Math",
".",
"round"... | Given a note duration, return the time delta | [
"Given",
"a",
"note",
"duration",
"return",
"the",
"time",
"delta"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L95-L99 | train | |
jsrmath/sharp11 | lib/midi.js | function (notes, settings) {
var restBuffer = 0;
var events = _.reduce(notes, function (arr, obj) {
var time = noteLength(obj.duration, settings);
if (obj.note) {
arr.push(makeNoteEvent(restBuffer, true, 0, noteValue(obj.note), settings.noteVelocity)); // On
arr.push(makeNoteEvent(time, false,... | javascript | function (notes, settings) {
var restBuffer = 0;
var events = _.reduce(notes, function (arr, obj) {
var time = noteLength(obj.duration, settings);
if (obj.note) {
arr.push(makeNoteEvent(restBuffer, true, 0, noteValue(obj.note), settings.noteVelocity)); // On
arr.push(makeNoteEvent(time, false,... | [
"function",
"(",
"notes",
",",
"settings",
")",
"{",
"var",
"restBuffer",
"=",
"0",
";",
"var",
"events",
"=",
"_",
".",
"reduce",
"(",
"notes",
",",
"function",
"(",
"arr",
",",
"obj",
")",
"{",
"var",
"time",
"=",
"noteLength",
"(",
"obj",
".",
... | Given note list, return a buffer containing note events | [
"Given",
"note",
"list",
"return",
"a",
"buffer",
"containing",
"note",
"events"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L107-L126 | train | |
jsrmath/sharp11 | lib/midi.js | function (chords, settings) {
var events = _.reduce(chords, function (arr, obj) {
var time = noteLength(obj.duration, settings);
var chord = obj.chord.inOctave(settings.chordOctave).chord;
arr.push(makeChordEvent(0, true, 1, chord, settings.chordVelocity)); // On
arr.push(makeChordEvent(time, false, ... | javascript | function (chords, settings) {
var events = _.reduce(chords, function (arr, obj) {
var time = noteLength(obj.duration, settings);
var chord = obj.chord.inOctave(settings.chordOctave).chord;
arr.push(makeChordEvent(0, true, 1, chord, settings.chordVelocity)); // On
arr.push(makeChordEvent(time, false, ... | [
"function",
"(",
"chords",
",",
"settings",
")",
"{",
"var",
"events",
"=",
"_",
".",
"reduce",
"(",
"chords",
",",
"function",
"(",
"arr",
",",
"obj",
")",
"{",
"var",
"time",
"=",
"noteLength",
"(",
"obj",
".",
"duration",
",",
"settings",
")",
"... | Given chord data, return a buffer containing note events | [
"Given",
"chord",
"data",
"return",
"a",
"buffer",
"containing",
"note",
"events"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L129-L141 | train | |
jsrmath/sharp11 | lib/midi.js | function (notes, settings) {
var noteEvents = makeNoteEvents(notes, settings);
var setPatch = makePatchEvent(0, settings.melodyPatch);
var length = setPatch.length + noteEvents.length + trackFooter.length;
return Buffer.concat([trackHeader, padNumber(length, 4), setPatch, noteEvents, trackFooter]);
} | javascript | function (notes, settings) {
var noteEvents = makeNoteEvents(notes, settings);
var setPatch = makePatchEvent(0, settings.melodyPatch);
var length = setPatch.length + noteEvents.length + trackFooter.length;
return Buffer.concat([trackHeader, padNumber(length, 4), setPatch, noteEvents, trackFooter]);
} | [
"function",
"(",
"notes",
",",
"settings",
")",
"{",
"var",
"noteEvents",
"=",
"makeNoteEvents",
"(",
"notes",
",",
"settings",
")",
";",
"var",
"setPatch",
"=",
"makePatchEvent",
"(",
"0",
",",
"settings",
".",
"melodyPatch",
")",
";",
"var",
"length",
... | Return a buffer with a melody track | [
"Return",
"a",
"buffer",
"with",
"a",
"melody",
"track"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L144-L150 | train | |
jsrmath/sharp11 | lib/midi.js | function (chords, settings) {
var chordEvents = makeChordEvents(chords, settings);
// Set all channels
var setPatches = _.reduce(_.range(0xf), function (buffer, channel) {
return Buffer.concat([buffer, makePatchEvent(channel, settings.chordPatch)]);
}, new Buffer(0));
var length = setPatches.length + ch... | javascript | function (chords, settings) {
var chordEvents = makeChordEvents(chords, settings);
// Set all channels
var setPatches = _.reduce(_.range(0xf), function (buffer, channel) {
return Buffer.concat([buffer, makePatchEvent(channel, settings.chordPatch)]);
}, new Buffer(0));
var length = setPatches.length + ch... | [
"function",
"(",
"chords",
",",
"settings",
")",
"{",
"var",
"chordEvents",
"=",
"makeChordEvents",
"(",
"chords",
",",
"settings",
")",
";",
"// Set all channels",
"var",
"setPatches",
"=",
"_",
".",
"reduce",
"(",
"_",
".",
"range",
"(",
"0xf",
")",
",... | Return a buffer with a chord track | [
"Return",
"a",
"buffer",
"with",
"a",
"chord",
"track"
] | 4f5857c40535b1bccc102ffdcc42a086e213016a | https://github.com/jsrmath/sharp11/blob/4f5857c40535b1bccc102ffdcc42a086e213016a/lib/midi.js#L153-L164 | train | |
vaneenige/unswitch | src/index.js | getAxesPosition | function getAxesPosition(axes, buttons) {
if (axes.length === 10) {
return Math.round(axes[9] / (2 / 7) + 3.5);
}
const [right, left, down, up] = [...buttons].reverse();
const buttonValues = [up, right, down, left]
.map((pressed, i) => (pressed.value ? i * 2 : false))
.filter(val => val !== false);
... | javascript | function getAxesPosition(axes, buttons) {
if (axes.length === 10) {
return Math.round(axes[9] / (2 / 7) + 3.5);
}
const [right, left, down, up] = [...buttons].reverse();
const buttonValues = [up, right, down, left]
.map((pressed, i) => (pressed.value ? i * 2 : false))
.filter(val => val !== false);
... | [
"function",
"getAxesPosition",
"(",
"axes",
",",
"buttons",
")",
"{",
"if",
"(",
"axes",
".",
"length",
"===",
"10",
")",
"{",
"return",
"Math",
".",
"round",
"(",
"axes",
"[",
"9",
"]",
"/",
"(",
"2",
"/",
"7",
")",
"+",
"3.5",
")",
";",
"}",
... | Get the axes position based based on browser.
@param {array} axes
@param {array} buttons | [
"Get",
"the",
"axes",
"position",
"based",
"based",
"on",
"browser",
"."
] | 88e073bce1e35e4faa536b912827cd2b2db238c5 | https://github.com/vaneenige/unswitch/blob/88e073bce1e35e4faa536b912827cd2b2db238c5/src/index.js#L8-L19 | train |
vaneenige/unswitch | src/index.js | Unswitch | function Unswitch(settings) {
const buttonState = {};
let axesPosition = 8;
for (let i = buttonMappings.length - 1; i >= 0; i -= 1) {
buttonState[buttonMappings[i]] = { pressed: false };
}
this.update = () => {
const gamepads = navigator.getGamepads();
for (let i = Object.keys(gamepads).length -... | javascript | function Unswitch(settings) {
const buttonState = {};
let axesPosition = 8;
for (let i = buttonMappings.length - 1; i >= 0; i -= 1) {
buttonState[buttonMappings[i]] = { pressed: false };
}
this.update = () => {
const gamepads = navigator.getGamepads();
for (let i = Object.keys(gamepads).length -... | [
"function",
"Unswitch",
"(",
"settings",
")",
"{",
"const",
"buttonState",
"=",
"{",
"}",
";",
"let",
"axesPosition",
"=",
"8",
";",
"for",
"(",
"let",
"i",
"=",
"buttonMappings",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"-=",
"1",
... | Create an instance of Unswitch.
@param {object} settings | [
"Create",
"an",
"instance",
"of",
"Unswitch",
"."
] | 88e073bce1e35e4faa536b912827cd2b2db238c5 | https://github.com/vaneenige/unswitch/blob/88e073bce1e35e4faa536b912827cd2b2db238c5/src/index.js#L25-L66 | train |
perropicante/connect-redirecthost | lib/redirectHost.js | createHandler | function createHandler(to, except, pathFunc, protocol) {
return function(req, res, next) {
var host = req.hostname || '';
var url = req.url;
if (host in except) {
next();
} else {
var target = new URIjs(pathFunc(host, url))
.host(to)
... | javascript | function createHandler(to, except, pathFunc, protocol) {
return function(req, res, next) {
var host = req.hostname || '';
var url = req.url;
if (host in except) {
next();
} else {
var target = new URIjs(pathFunc(host, url))
.host(to)
... | [
"function",
"createHandler",
"(",
"to",
",",
"except",
",",
"pathFunc",
",",
"protocol",
")",
"{",
"return",
"function",
"(",
"req",
",",
"res",
",",
"next",
")",
"{",
"var",
"host",
"=",
"req",
".",
"hostname",
"||",
"''",
";",
"var",
"url",
"=",
... | Creates the middleware to handle the redirect
@param {String} to
@param {Array} except
@return {Function} middleware function(req, res, next)
@api private | [
"Creates",
"the",
"middleware",
"to",
"handle",
"the",
"redirect"
] | 212b9ffda68534f4644d3eed95c55958ccc29c00 | https://github.com/perropicante/connect-redirecthost/blob/212b9ffda68534f4644d3eed95c55958ccc29c00/lib/redirectHost.js#L136-L152 | train |
warehouseai/cdnup | index.js | CDNUp | function CDNUp(bucket, options) {
options = options || {};
this.sharding = !!options.sharding;
this.urls = arrayify(options.url || options.urls);
this.mime = options.mime || {};
this.check = options.check;
this.bucket = bucket;
this.client = pkgcloud.storage.createClient(options.pkgcloud || {});
this.a... | javascript | function CDNUp(bucket, options) {
options = options || {};
this.sharding = !!options.sharding;
this.urls = arrayify(options.url || options.urls);
this.mime = options.mime || {};
this.check = options.check;
this.bucket = bucket;
this.client = pkgcloud.storage.createClient(options.pkgcloud || {});
this.a... | [
"function",
"CDNUp",
"(",
"bucket",
",",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"sharding",
"=",
"!",
"!",
"options",
".",
"sharding",
";",
"this",
".",
"urls",
"=",
"arrayify",
"(",
"options",
".",
"url",
... | CDNup is our CDN management API.
Options:
- sharding: Use DNS sharding.
- env: Optional forced environment.
- url/urls: Array or string of a URL that we use to build our assets URLs
- mime: Custom lookup object.
@constructor
@param {String} bucket bucket location of where you want the files to be stored.
@param {Obj... | [
"CDNup",
"is",
"our",
"CDN",
"management",
"API",
"."
] | 208e90b8236fdd52d8f90685522ef56047a30fc4 | https://github.com/warehouseai/cdnup/blob/208e90b8236fdd52d8f90685522ef56047a30fc4/index.js#L24-L35 | train |
warehouseai/cdnup | index.js | arrayify | function arrayify(urls) {
var tmp = Array.isArray(urls) ? urls : [urls];
return tmp.filter(Boolean);
} | javascript | function arrayify(urls) {
var tmp = Array.isArray(urls) ? urls : [urls];
return tmp.filter(Boolean);
} | [
"function",
"arrayify",
"(",
"urls",
")",
"{",
"var",
"tmp",
"=",
"Array",
".",
"isArray",
"(",
"urls",
")",
"?",
"urls",
":",
"[",
"urls",
"]",
";",
"return",
"tmp",
".",
"filter",
"(",
"Boolean",
")",
";",
"}"
] | Force a single string to an array if necessary | [
"Force",
"a",
"single",
"string",
"to",
"an",
"array",
"if",
"necessary"
] | 208e90b8236fdd52d8f90685522ef56047a30fc4 | https://github.com/warehouseai/cdnup/blob/208e90b8236fdd52d8f90685522ef56047a30fc4/index.js#L143-L146 | train |
cloudkick/whiskey | lib/gen_makefile.js | generateMakefile | function generateMakefile(testFiles, targetPath, callback) {
var template = new templates.Template('Makefile.magic');
var fullPath = path.join(targetPath, 'Makefile');
var context = {
test_files: testFiles.join(' \\\n ')
};
if (path.existsSync(fullPath)) {
callback(new Error(sprintf('File "%s" alread... | javascript | function generateMakefile(testFiles, targetPath, callback) {
var template = new templates.Template('Makefile.magic');
var fullPath = path.join(targetPath, 'Makefile');
var context = {
test_files: testFiles.join(' \\\n ')
};
if (path.existsSync(fullPath)) {
callback(new Error(sprintf('File "%s" alread... | [
"function",
"generateMakefile",
"(",
"testFiles",
",",
"targetPath",
",",
"callback",
")",
"{",
"var",
"template",
"=",
"new",
"templates",
".",
"Template",
"(",
"'Makefile.magic'",
")",
";",
"var",
"fullPath",
"=",
"path",
".",
"join",
"(",
"targetPath",
",... | Generate and write a Makefile with Whiskey related targets.
@param {Array} testFiles Test files.
@param {String} targetPath path where a generated Makefile is saved.
@param {Function} callback Callback called with (err). | [
"Generate",
"and",
"write",
"a",
"Makefile",
"with",
"Whiskey",
"related",
"targets",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/gen_makefile.js#L16-L39 | train |
1999/sklad | lib/sklad.js | checkSavedData | function checkSavedData(dbName, objStore, data) {
const keyValueContainer = Object.prototype.isPrototypeOf.call(skladKeyValueContainer, data);
const value = keyValueContainer ? data.value : data;
const objStoreMeta = objStoresMeta.get(dbName).get(objStore.name);
let key = keyValueContainer ? data.key : ... | javascript | function checkSavedData(dbName, objStore, data) {
const keyValueContainer = Object.prototype.isPrototypeOf.call(skladKeyValueContainer, data);
const value = keyValueContainer ? data.value : data;
const objStoreMeta = objStoresMeta.get(dbName).get(objStore.name);
let key = keyValueContainer ? data.key : ... | [
"function",
"checkSavedData",
"(",
"dbName",
",",
"objStore",
",",
"data",
")",
"{",
"const",
"keyValueContainer",
"=",
"Object",
".",
"prototype",
".",
"isPrototypeOf",
".",
"call",
"(",
"skladKeyValueContainer",
",",
"data",
")",
";",
"const",
"value",
"=",
... | Checks data before saving it in the object store
@return {Boolean} false if saved data type is incorrect, otherwise {Array} object store function arguments | [
"Checks",
"data",
"before",
"saving",
"it",
"in",
"the",
"object",
"store"
] | 6aa3479b4e9704e7ca0ed2f0fcf050440ca823b1 | https://github.com/1999/sklad/blob/6aa3479b4e9704e7ca0ed2f0fcf050440ca823b1/lib/sklad.js#L68-L93 | train |
1999/sklad | lib/sklad.js | checkContainingStores | function checkContainingStores(objStoreNames) {
return objStoreNames.every(function (storeName) {
return (indexOf.call(this.database.objectStoreNames, storeName) !== -1);
}, this);
} | javascript | function checkContainingStores(objStoreNames) {
return objStoreNames.every(function (storeName) {
return (indexOf.call(this.database.objectStoreNames, storeName) !== -1);
}, this);
} | [
"function",
"checkContainingStores",
"(",
"objStoreNames",
")",
"{",
"return",
"objStoreNames",
".",
"every",
"(",
"function",
"(",
"storeName",
")",
"{",
"return",
"(",
"indexOf",
".",
"call",
"(",
"this",
".",
"database",
".",
"objectStoreNames",
",",
"store... | Check whether database contains all needed stores
@param {Array<String>} objStoreNames
@return {Boolean} | [
"Check",
"whether",
"database",
"contains",
"all",
"needed",
"stores"
] | 6aa3479b4e9704e7ca0ed2f0fcf050440ca823b1 | https://github.com/1999/sklad/blob/6aa3479b4e9704e7ca0ed2f0fcf050440ca823b1/lib/sklad.js#L101-L105 | train |
1999/sklad | lib/sklad.js | getObjStoresMeta | function getObjStoresMeta(db, objStoreNames) {
const dbMeta = objStoresMeta.get(db.name);
const promises = [];
objStoreNames.forEach(objStoreName => {
if (dbMeta.has(objStoreName)) {
return;
}
const promise = new Promise(resolve => {
const transaction = db.t... | javascript | function getObjStoresMeta(db, objStoreNames) {
const dbMeta = objStoresMeta.get(db.name);
const promises = [];
objStoreNames.forEach(objStoreName => {
if (dbMeta.has(objStoreName)) {
return;
}
const promise = new Promise(resolve => {
const transaction = db.t... | [
"function",
"getObjStoresMeta",
"(",
"db",
",",
"objStoreNames",
")",
"{",
"const",
"dbMeta",
"=",
"objStoresMeta",
".",
"get",
"(",
"db",
".",
"name",
")",
";",
"const",
"promises",
"=",
"[",
"]",
";",
"objStoreNames",
".",
"forEach",
"(",
"objStoreName",... | autoIncrement is broken in IE family. Run this transaction to get its value
on every object store
@param {IDBDatabase} db
@param {Array<String>} objStoreNames
@return {Promise}
@see http://stackoverflow.com/questions/35682165/indexeddb-in-ie11-edge-why-is-objstore-autoincrement-undefined
@see https://connect.microsof... | [
"autoIncrement",
"is",
"broken",
"in",
"IE",
"family",
".",
"Run",
"this",
"transaction",
"to",
"get",
"its",
"value",
"on",
"every",
"object",
"store"
] | 6aa3479b4e9704e7ca0ed2f0fcf050440ca823b1 | https://github.com/1999/sklad/blob/6aa3479b4e9704e7ca0ed2f0fcf050440ca823b1/lib/sklad.js#L118-L189 | train |
leonardpauli/docs | design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js | createProgram | function createProgram(
gl, shaders, opt_attribs, opt_locations, opt_errorCallback) {
var errFn = opt_errorCallback || error;
var program = gl.createProgram();
shaders.forEach(function(shader) {
gl.attachShader(program, shader);
});
if (opt_attribs) {
opt_attribs.forEach(function(a... | javascript | function createProgram(
gl, shaders, opt_attribs, opt_locations, opt_errorCallback) {
var errFn = opt_errorCallback || error;
var program = gl.createProgram();
shaders.forEach(function(shader) {
gl.attachShader(program, shader);
});
if (opt_attribs) {
opt_attribs.forEach(function(a... | [
"function",
"createProgram",
"(",
"gl",
",",
"shaders",
",",
"opt_attribs",
",",
"opt_locations",
",",
"opt_errorCallback",
")",
"{",
"var",
"errFn",
"=",
"opt_errorCallback",
"||",
"error",
";",
"var",
"program",
"=",
"gl",
".",
"createProgram",
"(",
")",
"... | Creates a program, attaches shaders, binds attrib locations, links the
program and calls useProgram.
@param {WebGLShader[]} shaders The shaders to attach
@param {string[]} [opt_attribs] An array of attribs names. Locations will be assigned by index if not passed in
@param {number[]} [opt_locations] The locations for th... | [
"Creates",
"a",
"program",
"attaches",
"shaders",
"binds",
"attrib",
"locations",
"links",
"the",
"program",
"and",
"calls",
"useProgram",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js#L124-L152 | train |
leonardpauli/docs | design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js | getBindPointForSamplerType | function getBindPointForSamplerType(gl, type) {
if (type === gl.SAMPLER_2D) return gl.TEXTURE_2D; // eslint-disable-line
if (type === gl.SAMPLER_CUBE) return gl.TEXTURE_CUBE_MAP; // eslint-disable-line
return undefined;
} | javascript | function getBindPointForSamplerType(gl, type) {
if (type === gl.SAMPLER_2D) return gl.TEXTURE_2D; // eslint-disable-line
if (type === gl.SAMPLER_CUBE) return gl.TEXTURE_CUBE_MAP; // eslint-disable-line
return undefined;
} | [
"function",
"getBindPointForSamplerType",
"(",
"gl",
",",
"type",
")",
"{",
"if",
"(",
"type",
"===",
"gl",
".",
"SAMPLER_2D",
")",
"return",
"gl",
".",
"TEXTURE_2D",
";",
"// eslint-disable-line",
"if",
"(",
"type",
"===",
"gl",
".",
"SAMPLER_CUBE",
")",
... | Returns the corresponding bind point for a given sampler type | [
"Returns",
"the",
"corresponding",
"bind",
"point",
"for",
"a",
"given",
"sampler",
"type"
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js#L246-L250 | train |
leonardpauli/docs | design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js | getExtensionWithKnownPrefixes | function getExtensionWithKnownPrefixes(gl, name) {
for (var ii = 0; ii < browserPrefixes.length; ++ii) {
var prefixedName = browserPrefixes[ii] + name;
var ext = gl.getExtension(prefixedName);
if (ext) {
return ext;
}
}
return undefined;
} | javascript | function getExtensionWithKnownPrefixes(gl, name) {
for (var ii = 0; ii < browserPrefixes.length; ++ii) {
var prefixedName = browserPrefixes[ii] + name;
var ext = gl.getExtension(prefixedName);
if (ext) {
return ext;
}
}
return undefined;
} | [
"function",
"getExtensionWithKnownPrefixes",
"(",
"gl",
",",
"name",
")",
"{",
"for",
"(",
"var",
"ii",
"=",
"0",
";",
"ii",
"<",
"browserPrefixes",
".",
"length",
";",
"++",
"ii",
")",
"{",
"var",
"prefixedName",
"=",
"browserPrefixes",
"[",
"ii",
"]",
... | Given an extension name like WEBGL_compressed_texture_s3tc
returns the supported version extension, like
WEBKIT_WEBGL_compressed_teture_s3tc
@param {string} name Name of extension to look for
@return {WebGLExtension} The extension or undefined if not
found.
@memberOf module:webgl-utils | [
"Given",
"an",
"extension",
"name",
"like",
"WEBGL_compressed_texture_s3tc",
"returns",
"the",
"supported",
"version",
"extension",
"like",
"WEBKIT_WEBGL_compressed_teture_s3tc"
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js#L745-L754 | train |
leonardpauli/docs | design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js | resizeCanvasToDisplaySize | function resizeCanvasToDisplaySize(canvas, multiplier) {
multiplier = multiplier || 1;
var width = canvas.clientWidth * multiplier | 0;
var height = canvas.clientHeight * multiplier | 0;
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = heigh... | javascript | function resizeCanvasToDisplaySize(canvas, multiplier) {
multiplier = multiplier || 1;
var width = canvas.clientWidth * multiplier | 0;
var height = canvas.clientHeight * multiplier | 0;
if (canvas.width !== width || canvas.height !== height) {
canvas.width = width;
canvas.height = heigh... | [
"function",
"resizeCanvasToDisplaySize",
"(",
"canvas",
",",
"multiplier",
")",
"{",
"multiplier",
"=",
"multiplier",
"||",
"1",
";",
"var",
"width",
"=",
"canvas",
".",
"clientWidth",
"*",
"multiplier",
"|",
"0",
";",
"var",
"height",
"=",
"canvas",
".",
... | Resize a canvas to match the size its displayed.
@param {HTMLCanvasElement} canvas The canvas to resize.
@param {number} [multiplier] amount to multiply by.
Pass in window.devicePixelRatio for native pixels.
@return {boolean} true if the canvas was resized.
@memberOf module:webgl-utils | [
"Resize",
"a",
"canvas",
"to",
"match",
"the",
"size",
"its",
"displayed",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js#L764-L774 | train |
leonardpauli/docs | design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js | getNumElementsFromNonIndexedArrays | function getNumElementsFromNonIndexedArrays(arrays) {
var key = Object.keys(arrays)[0];
var array = arrays[key];
if (isArrayBuffer(array)) {
return array.numElements;
} else {
return array.data.length / array.numComponents;
}
} | javascript | function getNumElementsFromNonIndexedArrays(arrays) {
var key = Object.keys(arrays)[0];
var array = arrays[key];
if (isArrayBuffer(array)) {
return array.numElements;
} else {
return array.data.length / array.numComponents;
}
} | [
"function",
"getNumElementsFromNonIndexedArrays",
"(",
"arrays",
")",
"{",
"var",
"key",
"=",
"Object",
".",
"keys",
"(",
"arrays",
")",
"[",
"0",
"]",
";",
"var",
"array",
"=",
"arrays",
"[",
"key",
"]",
";",
"if",
"(",
"isArrayBuffer",
"(",
"array",
... | tries to get the number of elements from a set of arrays. | [
"tries",
"to",
"get",
"the",
"number",
"of",
"elements",
"from",
"a",
"set",
"of",
"arrays",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js#L979-L987 | train |
leonardpauli/docs | design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js | createBuffersFromArrays | function createBuffersFromArrays(gl, arrays) {
var buffers = { };
Object.keys(arrays).forEach(function(key) {
var type = key === "indices" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;
var array = makeTypedArray(arrays[key], name);
buffers[key] = createBufferFromTypedArray(gl, array, type);
... | javascript | function createBuffersFromArrays(gl, arrays) {
var buffers = { };
Object.keys(arrays).forEach(function(key) {
var type = key === "indices" ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER;
var array = makeTypedArray(arrays[key], name);
buffers[key] = createBufferFromTypedArray(gl, array, type);
... | [
"function",
"createBuffersFromArrays",
"(",
"gl",
",",
"arrays",
")",
"{",
"var",
"buffers",
"=",
"{",
"}",
";",
"Object",
".",
"keys",
"(",
"arrays",
")",
".",
"forEach",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"type",
"=",
"key",
"===",
"\"in... | Creates buffers from typed arrays
Given something like this
var arrays = {
positions: [1, 2, 3],
normals: [0, 0, 1],
}
returns something like
buffers = {
positions: WebGLBuffer,
normals: WebGLBuffer,
}
If the buffer is named 'indices' it will be made an ELEMENT_ARRAY_BUFFER.
@param {WebGLRenderingContext} gl A We... | [
"Creates",
"buffers",
"from",
"typed",
"arrays"
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js#L1159-L1175 | train |
leonardpauli/docs | design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js | drawBufferInfo | function drawBufferInfo(gl, bufferInfo, primitiveType, count, offset) {
var indices = bufferInfo.indices;
primitiveType = primitiveType === undefined ? gl.TRIANGLES : primitiveType;
var numElements = count === undefined ? bufferInfo.numElements : count;
offset = offset === undefined ? offset : 0;
if... | javascript | function drawBufferInfo(gl, bufferInfo, primitiveType, count, offset) {
var indices = bufferInfo.indices;
primitiveType = primitiveType === undefined ? gl.TRIANGLES : primitiveType;
var numElements = count === undefined ? bufferInfo.numElements : count;
offset = offset === undefined ? offset : 0;
if... | [
"function",
"drawBufferInfo",
"(",
"gl",
",",
"bufferInfo",
",",
"primitiveType",
",",
"count",
",",
"offset",
")",
"{",
"var",
"indices",
"=",
"bufferInfo",
".",
"indices",
";",
"primitiveType",
"=",
"primitiveType",
"===",
"undefined",
"?",
"gl",
".",
"TRI... | Calls `gl.drawElements` or `gl.drawArrays`, whichever is appropriate
normally you'd call `gl.drawElements` or `gl.drawArrays` yourself
but calling this means if you switch from indexed data to non-indexed
data you don't have to remember to update your draw call.
@param {WebGLRenderingContext} gl A WebGLRenderingConte... | [
"Calls",
"gl",
".",
"drawElements",
"or",
"gl",
".",
"drawArrays",
"whichever",
"is",
"appropriate"
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/design/gpu-programming/webgl/experiment/game-of-life/external/webgl-utils.js#L1191-L1201 | train |
jose-pleonasm/py-logging | core/logging.js | getLogger | function getLogger(name) {
name = name || '';
if (!name) {
return Manager.root;
} else {
return Manager.getLogger(name);
}
} | javascript | function getLogger(name) {
name = name || '';
if (!name) {
return Manager.root;
} else {
return Manager.getLogger(name);
}
} | [
"function",
"getLogger",
"(",
"name",
")",
"{",
"name",
"=",
"name",
"||",
"''",
";",
"if",
"(",
"!",
"name",
")",
"{",
"return",
"Manager",
".",
"root",
";",
"}",
"else",
"{",
"return",
"Manager",
".",
"getLogger",
"(",
"name",
")",
";",
"}",
"}... | Return a logger with the specified name, creating it if necessary.
If no name is specified, return the root logger.
@function
@memberof module:py-logging
@param {string} [name]
@return {Logger} | [
"Return",
"a",
"logger",
"with",
"the",
"specified",
"name",
"creating",
"it",
"if",
"necessary",
".",
"If",
"no",
"name",
"is",
"specified",
"return",
"the",
"root",
"logger",
"."
] | 598f41284311ea6a837d4ba56236301abe689b09 | https://github.com/jose-pleonasm/py-logging/blob/598f41284311ea6a837d4ba56236301abe689b09/core/logging.js#L672-L680 | train |
basisjs/basisjs-tools-build | lib/common/files.js | function(filename){
// resolve by symlink if possible
for (var from in this.symlinks)
if (filename.indexOf(from) === 0 && (filename === from || filename[from.length] === '/'))
return this.symlinks[from] + filename.substr(from.length);
return path.resolve(this.fsBaseURI, filename.replace(/^[\\... | javascript | function(filename){
// resolve by symlink if possible
for (var from in this.symlinks)
if (filename.indexOf(from) === 0 && (filename === from || filename[from.length] === '/'))
return this.symlinks[from] + filename.substr(from.length);
return path.resolve(this.fsBaseURI, filename.replace(/^[\\... | [
"function",
"(",
"filename",
")",
"{",
"// resolve by symlink if possible",
"for",
"(",
"var",
"from",
"in",
"this",
".",
"symlinks",
")",
"if",
"(",
"filename",
".",
"indexOf",
"(",
"from",
")",
"===",
"0",
"&&",
"(",
"filename",
"===",
"from",
"||",
"f... | Returns absolute filesystem filename.
@param {string} filename
@return {string} | [
"Returns",
"absolute",
"filesystem",
"filename",
"."
] | 177018ab31b225cddb6a184693fe4746512e7af1 | https://github.com/basisjs/basisjs-tools-build/blob/177018ab31b225cddb6a184693fe4746512e7af1/lib/common/files.js#L320-L327 | train | |
basisjs/basisjs-tools-build | lib/common/files.js | function(fileRef){
var filename;
var file;
if (fileRef instanceof File)
{
file = fileRef;
filename = file.filename;
}
else
{
filename = abspath(this.baseURI, fileRef);
file = this.map[filename];
if (!file)
{
this.flow.warn({
file: filen... | javascript | function(fileRef){
var filename;
var file;
if (fileRef instanceof File)
{
file = fileRef;
filename = file.filename;
}
else
{
filename = abspath(this.baseURI, fileRef);
file = this.map[filename];
if (!file)
{
this.flow.warn({
file: filen... | [
"function",
"(",
"fileRef",
")",
"{",
"var",
"filename",
";",
"var",
"file",
";",
"if",
"(",
"fileRef",
"instanceof",
"File",
")",
"{",
"file",
"=",
"fileRef",
";",
"filename",
"=",
"file",
".",
"filename",
";",
"}",
"else",
"{",
"filename",
"=",
"ab... | Remove a file from manager and break all links between files.
@param {File|string} fileRef File name or File instance to be removed. | [
"Remove",
"a",
"file",
"from",
"manager",
"and",
"break",
"all",
"links",
"between",
"files",
"."
] | 177018ab31b225cddb6a184693fe4746512e7af1 | https://github.com/basisjs/basisjs-tools-build/blob/177018ab31b225cddb6a184693fe4746512e7af1/lib/common/files.js#L511-L551 | train | |
rrharvey/grunt-file-blocks | tasks/fileblocks.js | function(data, options) {
var configs = [];
if (_.isArray(data)) {
data.forEach(function(block) {
configs.push(new BlockConfig(block.name, block, options));
});
} else if (_.isPlainObject(data)) {
_.forOwn(data, function(value, name) {
configs.push(new BlockConfig(name, va... | javascript | function(data, options) {
var configs = [];
if (_.isArray(data)) {
data.forEach(function(block) {
configs.push(new BlockConfig(block.name, block, options));
});
} else if (_.isPlainObject(data)) {
_.forOwn(data, function(value, name) {
configs.push(new BlockConfig(name, va... | [
"function",
"(",
"data",
",",
"options",
")",
"{",
"var",
"configs",
"=",
"[",
"]",
";",
"if",
"(",
"_",
".",
"isArray",
"(",
"data",
")",
")",
"{",
"data",
".",
"forEach",
"(",
"function",
"(",
"block",
")",
"{",
"configs",
".",
"push",
"(",
"... | Normalize and return block configurations from the Gruntfile.
@param {Object[]|Object.<string, object>} blocks - The block configurations from the Gruntfile.
@returns {BlockConfig[]} | [
"Normalize",
"and",
"return",
"block",
"configurations",
"from",
"the",
"Gruntfile",
"."
] | c1e3bfcb33df76ca820de580da3864085bfaed44 | https://github.com/rrharvey/grunt-file-blocks/blob/c1e3bfcb33df76ca820de580da3864085bfaed44/tasks/fileblocks.js#L25-L41 | train | |
jose-pleonasm/py-logging | core/handlers.js | ConsoleHandler | function ConsoleHandler(level, grouping, collapsed) {
grouping = typeof grouping !== 'undefined' ? grouping : true;
collapsed = typeof collapsed !== 'undefined' ? collapsed : false;
Handler.call(this, level);
this._grouping = grouping;
this._groupMethod = collapsed ? 'groupCollapsed' : 'group';
this._openGroup ... | javascript | function ConsoleHandler(level, grouping, collapsed) {
grouping = typeof grouping !== 'undefined' ? grouping : true;
collapsed = typeof collapsed !== 'undefined' ? collapsed : false;
Handler.call(this, level);
this._grouping = grouping;
this._groupMethod = collapsed ? 'groupCollapsed' : 'group';
this._openGroup ... | [
"function",
"ConsoleHandler",
"(",
"level",
",",
"grouping",
",",
"collapsed",
")",
"{",
"grouping",
"=",
"typeof",
"grouping",
"!==",
"'undefined'",
"?",
"grouping",
":",
"true",
";",
"collapsed",
"=",
"typeof",
"collapsed",
"!==",
"'undefined'",
"?",
"collap... | Console handler.
@constructor ConsoleHandler
@extends Handler
@param {number} [level]
@param {boolean} [grouping=true]
@param {boolean} [collapsed=false] | [
"Console",
"handler",
"."
] | 598f41284311ea6a837d4ba56236301abe689b09 | https://github.com/jose-pleonasm/py-logging/blob/598f41284311ea6a837d4ba56236301abe689b09/core/handlers.js#L81-L90 | train |
lbdremy/scrapinode | lib/error/scrapinode-error.js | ScrapinodeError | function ScrapinodeError(message){
Error.call(this);
Error.captureStackTrace(this,arguments.callee);
this.name = 'ScrapinodeError';
this.message = message;
} | javascript | function ScrapinodeError(message){
Error.call(this);
Error.captureStackTrace(this,arguments.callee);
this.name = 'ScrapinodeError';
this.message = message;
} | [
"function",
"ScrapinodeError",
"(",
"message",
")",
"{",
"Error",
".",
"call",
"(",
"this",
")",
";",
"Error",
".",
"captureStackTrace",
"(",
"this",
",",
"arguments",
".",
"callee",
")",
";",
"this",
".",
"name",
"=",
"'ScrapinodeError'",
";",
"this",
"... | Create a new `ScrapinodeError`
@constructor
@inherit {Error}
@api private | [
"Create",
"a",
"new",
"ScrapinodeError"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/error/scrapinode-error.js#L21-L26 | train |
jose-pleonasm/py-logging | nodekit/index.js | FileHandler | function FileHandler(filename, mode, encoding, delay) {
mode = mode || 'a';
encoding = typeof encoding !== 'undefined' ? encoding : 'utf8';
delay = typeof delay !== 'undefined' ? delay : false;
/**
* @private
* @type {string}
*/
this._filename = filename;
/**
* @private
* @type {string}
*/
this._mo... | javascript | function FileHandler(filename, mode, encoding, delay) {
mode = mode || 'a';
encoding = typeof encoding !== 'undefined' ? encoding : 'utf8';
delay = typeof delay !== 'undefined' ? delay : false;
/**
* @private
* @type {string}
*/
this._filename = filename;
/**
* @private
* @type {string}
*/
this._mo... | [
"function",
"FileHandler",
"(",
"filename",
",",
"mode",
",",
"encoding",
",",
"delay",
")",
"{",
"mode",
"=",
"mode",
"||",
"'a'",
";",
"encoding",
"=",
"typeof",
"encoding",
"!==",
"'undefined'",
"?",
"encoding",
":",
"'utf8'",
";",
"delay",
"=",
"type... | File handler.
@constructor FileHandler
@extends StreamHandler
@param {string} filename
@param {string} [mode=a]
{@link https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback}
@param {string} [encoding=utf8]
{@link https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings}
@param {boolean} [... | [
"File",
"handler",
"."
] | 598f41284311ea6a837d4ba56236301abe689b09 | https://github.com/jose-pleonasm/py-logging/blob/598f41284311ea6a837d4ba56236301abe689b09/nodekit/index.js#L127-L157 | train |
jose-pleonasm/py-logging | nodekit/index.js | RotatingFileHandler | function RotatingFileHandler(filename, mode, maxBytes, backupCount,
encoding, delay) {
mode = mode || 'a';
maxBytes = typeof maxBytes !== 'undefined' ? maxBytes : 0;
backupCount = typeof backupCount !== 'undefined' ? backupCount : 0;
encoding = typeof encoding !== 'undefined' ? encoding... | javascript | function RotatingFileHandler(filename, mode, maxBytes, backupCount,
encoding, delay) {
mode = mode || 'a';
maxBytes = typeof maxBytes !== 'undefined' ? maxBytes : 0;
backupCount = typeof backupCount !== 'undefined' ? backupCount : 0;
encoding = typeof encoding !== 'undefined' ? encoding... | [
"function",
"RotatingFileHandler",
"(",
"filename",
",",
"mode",
",",
"maxBytes",
",",
"backupCount",
",",
"encoding",
",",
"delay",
")",
"{",
"mode",
"=",
"mode",
"||",
"'a'",
";",
"maxBytes",
"=",
"typeof",
"maxBytes",
"!==",
"'undefined'",
"?",
"maxBytes"... | Handler for logging to a set of files, which switches from one file
to the next when the current file reaches a certain size.
@constructor RotatingFileHandler
@extends FileHandler
@param {string} filename
@param {string} [mode=a]
{@link https://nodejs.org/api/fs.html#fs_fs_open_path_flags_mode_callback}
@param {number... | [
"Handler",
"for",
"logging",
"to",
"a",
"set",
"of",
"files",
"which",
"switches",
"from",
"one",
"file",
"to",
"the",
"next",
"when",
"the",
"current",
"file",
"reaches",
"a",
"certain",
"size",
"."
] | 598f41284311ea6a837d4ba56236301abe689b09 | https://github.com/jose-pleonasm/py-logging/blob/598f41284311ea6a837d4ba56236301abe689b09/nodekit/index.js#L205-L236 | train |
somesocks/vet | dist/utils/accepts.js | accepts | function accepts(func, validator, message) {
message = messageBuilder(message || 'vet/utils/accepts error!');
return function wrapper(){
var args = arguments;
if (validator.apply(this, args)) {
return func.apply(this, args);
} else {
throw new Error(message.apply(this, args));
}
};
} | javascript | function accepts(func, validator, message) {
message = messageBuilder(message || 'vet/utils/accepts error!');
return function wrapper(){
var args = arguments;
if (validator.apply(this, args)) {
return func.apply(this, args);
} else {
throw new Error(message.apply(this, args));
}
};
} | [
"function",
"accepts",
"(",
"func",
",",
"validator",
",",
"message",
")",
"{",
"message",
"=",
"messageBuilder",
"(",
"message",
"||",
"'vet/utils/accepts error!'",
")",
";",
"return",
"function",
"wrapper",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
"... | Wraps a function in a validator which checks its arguments, and throws an error if the arguments are bad.
@param func - the function to wrap
@param validator - the validator function. This gets passed the arguments as an array
@param message - an optional message string to pass into the error thrown
@returns a wrappe... | [
"Wraps",
"a",
"function",
"in",
"a",
"validator",
"which",
"checks",
"its",
"arguments",
"and",
"throws",
"an",
"error",
"if",
"the",
"arguments",
"are",
"bad",
"."
] | 4557abeb6a8b470cb4a5823a2cc802c825ef29ef | https://github.com/somesocks/vet/blob/4557abeb6a8b470cb4a5823a2cc802c825ef29ef/dist/utils/accepts.js#L18-L29 | train |
phovea/generator-phovea | generators/init-product/templates/plain/build.js | toRepoUrl | function toRepoUrl(url) {
if (url.startsWith('git@')) {
if (argv.useSSH) {
return url;
}
// have an ssh url need an http url
const m = url.match(/(https?:\/\/([^/]+)\/|git@(.+):)([\w\d-_/]+)(.git)?/);
return `https://${m[3]}/${m[4]}.git`;
}
if (url.startsWith('http')) {
if (!argv.use... | javascript | function toRepoUrl(url) {
if (url.startsWith('git@')) {
if (argv.useSSH) {
return url;
}
// have an ssh url need an http url
const m = url.match(/(https?:\/\/([^/]+)\/|git@(.+):)([\w\d-_/]+)(.git)?/);
return `https://${m[3]}/${m[4]}.git`;
}
if (url.startsWith('http')) {
if (!argv.use... | [
"function",
"toRepoUrl",
"(",
"url",
")",
"{",
"if",
"(",
"url",
".",
"startsWith",
"(",
"'git@'",
")",
")",
"{",
"if",
"(",
"argv",
".",
"useSSH",
")",
"{",
"return",
"url",
";",
"}",
"// have an ssh url need an http url",
"const",
"m",
"=",
"url",
".... | generates a repo url to clone depending on the argv.useSSH option
@param {string} url the repo url either in git@ for https:// form
@returns the clean repo url | [
"generates",
"a",
"repo",
"url",
"to",
"clone",
"depending",
"on",
"the",
"argv",
".",
"useSSH",
"option"
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/generators/init-product/templates/plain/build.js#L57-L81 | train |
phovea/generator-phovea | generators/init-product/templates/plain/build.js | guessUserName | function guessUserName(repo) {
// extract the host
const host = repo.match(/:\/\/([^/]+)/)[1];
const hostClean = host.replace(/\./g, '_').toUpperCase();
// e.g. GITHUB_COM_CREDENTIALS
const envVar = process.env[`${hostClean}_CREDENTIALS`];
if (envVar) {
return envVar;
}
return process.env.PHOVEA_GIT... | javascript | function guessUserName(repo) {
// extract the host
const host = repo.match(/:\/\/([^/]+)/)[1];
const hostClean = host.replace(/\./g, '_').toUpperCase();
// e.g. GITHUB_COM_CREDENTIALS
const envVar = process.env[`${hostClean}_CREDENTIALS`];
if (envVar) {
return envVar;
}
return process.env.PHOVEA_GIT... | [
"function",
"guessUserName",
"(",
"repo",
")",
"{",
"// extract the host",
"const",
"host",
"=",
"repo",
".",
"match",
"(",
"/",
":\\/\\/([^/]+)",
"/",
")",
"[",
"1",
"]",
";",
"const",
"hostClean",
"=",
"host",
".",
"replace",
"(",
"/",
"\\.",
"/",
"g... | guesses the credentials environment variable based on the given repository hostname
@param {string} repo | [
"guesses",
"the",
"credentials",
"environment",
"variable",
"based",
"on",
"the",
"given",
"repository",
"hostname"
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/generators/init-product/templates/plain/build.js#L87-L97 | train |
phovea/generator-phovea | generators/init-product/templates/plain/build.js | spawn | function spawn(cmd, args, opts) {
const spawn = require('child_process').spawn;
const _ = require('lodash');
return new Promise((resolve, reject) => {
const p = spawn(cmd, typeof args === 'string' ? args.split(' ') : args, _.merge({stdio: argv.quiet ? ['ignore', 'pipe', 'pipe'] : ['ignore', 1, 2]}, opts));
... | javascript | function spawn(cmd, args, opts) {
const spawn = require('child_process').spawn;
const _ = require('lodash');
return new Promise((resolve, reject) => {
const p = spawn(cmd, typeof args === 'string' ? args.split(' ') : args, _.merge({stdio: argv.quiet ? ['ignore', 'pipe', 'pipe'] : ['ignore', 1, 2]}, opts));
... | [
"function",
"spawn",
"(",
"cmd",
",",
"args",
",",
"opts",
")",
"{",
"const",
"spawn",
"=",
"require",
"(",
"'child_process'",
")",
".",
"spawn",
";",
"const",
"_",
"=",
"require",
"(",
"'lodash'",
")",
";",
"return",
"new",
"Promise",
"(",
"(",
"res... | spawns a child process
@param cmd command as array
@param args arguments
@param opts options
@returns a promise with the result code or a reject with the error string | [
"spawns",
"a",
"child",
"process"
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/generators/init-product/templates/plain/build.js#L190-L216 | train |
phovea/generator-phovea | generators/init-product/templates/plain/build.js | npm | function npm(cwd, cmd) {
console.log(cwd, chalk.blue('running npm', cmd));
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
return spawn(npm, (cmd || 'install').split(' '), {cwd, env});
} | javascript | function npm(cwd, cmd) {
console.log(cwd, chalk.blue('running npm', cmd));
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
return spawn(npm, (cmd || 'install').split(' '), {cwd, env});
} | [
"function",
"npm",
"(",
"cwd",
",",
"cmd",
")",
"{",
"console",
".",
"log",
"(",
"cwd",
",",
"chalk",
".",
"blue",
"(",
"'running npm'",
",",
"cmd",
")",
")",
";",
"const",
"npm",
"=",
"process",
".",
"platform",
"===",
"'win32'",
"?",
"'npm.cmd'",
... | run npm with the given args
@param cwd working directory
@param cmd the command to execute as a string
@return {*} | [
"run",
"npm",
"with",
"the",
"given",
"args"
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/generators/init-product/templates/plain/build.js#L224-L228 | train |
phovea/generator-phovea | generators/init-product/templates/plain/build.js | docker | function docker(cwd, cmd) {
console.log(cwd, chalk.blue('running docker', cmd));
return spawn('docker', (cmd || 'build .').split(' '), {cwd, env});
} | javascript | function docker(cwd, cmd) {
console.log(cwd, chalk.blue('running docker', cmd));
return spawn('docker', (cmd || 'build .').split(' '), {cwd, env});
} | [
"function",
"docker",
"(",
"cwd",
",",
"cmd",
")",
"{",
"console",
".",
"log",
"(",
"cwd",
",",
"chalk",
".",
"blue",
"(",
"'running docker'",
",",
"cmd",
")",
")",
";",
"return",
"spawn",
"(",
"'docker'",
",",
"(",
"cmd",
"||",
"'build .'",
")",
"... | runs docker command
@param cwd
@param cmd
@return {*} | [
"runs",
"docker",
"command"
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/generators/init-product/templates/plain/build.js#L236-L239 | train |
phovea/generator-phovea | generators/init-product/templates/plain/build.js | yo | function yo(generator, options, cwd) {
const yeoman = require('yeoman-environment');
// call yo internally
const yeomanEnv = yeoman.createEnv([], {cwd, env}, quiet ? createQuietTerminalAdapter() : undefined);
yeomanEnv.register(require.resolve('generator-phovea/generators/' + generator), 'phovea:' + generator);... | javascript | function yo(generator, options, cwd) {
const yeoman = require('yeoman-environment');
// call yo internally
const yeomanEnv = yeoman.createEnv([], {cwd, env}, quiet ? createQuietTerminalAdapter() : undefined);
yeomanEnv.register(require.resolve('generator-phovea/generators/' + generator), 'phovea:' + generator);... | [
"function",
"yo",
"(",
"generator",
",",
"options",
",",
"cwd",
")",
"{",
"const",
"yeoman",
"=",
"require",
"(",
"'yeoman-environment'",
")",
";",
"// call yo internally",
"const",
"yeomanEnv",
"=",
"yeoman",
".",
"createEnv",
"(",
"[",
"]",
",",
"{",
"cw... | runs yo internally
@param generator
@param options
@param cwd | [
"runs",
"yo",
"internally"
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/generators/init-product/templates/plain/build.js#L295-L309 | train |
Strider-CD/strider-simple-runner | lib/jobqueue.js | function (job, config, callback) {
var task = {
job: job,
config: config,
callback: callback || function () {
}
};
task.id = task.job._id;
// Tasks with identical keys will be prevented from being scheduled concurrently.
task.key = task.job.project + branchFromJob(task.job)... | javascript | function (job, config, callback) {
var task = {
job: job,
config: config,
callback: callback || function () {
}
};
task.id = task.job._id;
// Tasks with identical keys will be prevented from being scheduled concurrently.
task.key = task.job.project + branchFromJob(task.job)... | [
"function",
"(",
"job",
",",
"config",
",",
"callback",
")",
"{",
"var",
"task",
"=",
"{",
"job",
":",
"job",
",",
"config",
":",
"config",
",",
"callback",
":",
"callback",
"||",
"function",
"(",
")",
"{",
"}",
"}",
";",
"task",
".",
"id",
"=",
... | Add a job to the end of the queue. If the queue is not currently saturated, immediately schedule a task to handle the new job. If a callback is provided, call it when this job's task completes. | [
"Add",
"a",
"job",
"to",
"the",
"end",
"of",
"the",
"queue",
".",
"If",
"the",
"queue",
"is",
"not",
"currently",
"saturated",
"immediately",
"schedule",
"a",
"task",
"to",
"handle",
"the",
"new",
"job",
".",
"If",
"a",
"callback",
"is",
"provided",
"c... | 6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218 | https://github.com/Strider-CD/strider-simple-runner/blob/6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218/lib/jobqueue.js#L23-L42 | train | |
Strider-CD/strider-simple-runner | lib/jobqueue.js | function () {
var self = this;
// See how much capacity we have left to fill.
var launchCount = this.concurrency - Object.keys(this.active).length;
// Identify up to launchCount eligible tasks, giving priority to those earlier in the queue.
var offset = 0;
var launchTasks = [];
while (laun... | javascript | function () {
var self = this;
// See how much capacity we have left to fill.
var launchCount = this.concurrency - Object.keys(this.active).length;
// Identify up to launchCount eligible tasks, giving priority to those earlier in the queue.
var offset = 0;
var launchTasks = [];
while (laun... | [
"function",
"(",
")",
"{",
"var",
"self",
"=",
"this",
";",
"// See how much capacity we have left to fill.",
"var",
"launchCount",
"=",
"this",
".",
"concurrency",
"-",
"Object",
".",
"keys",
"(",
"this",
".",
"active",
")",
".",
"length",
";",
"// Identify u... | Launch the asynchronous handler function for each eligible waiting task until the queue is saturated. | [
"Launch",
"the",
"asynchronous",
"handler",
"function",
"for",
"each",
"eligible",
"waiting",
"task",
"until",
"the",
"queue",
"is",
"saturated",
"."
] | 6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218 | https://github.com/Strider-CD/strider-simple-runner/blob/6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218/lib/jobqueue.js#L46-L96 | train | |
Strider-CD/strider-simple-runner | lib/jobqueue.js | function (id) {
for (var key in this.active) {
if (this.active.hasOwnProperty(key) && this.active[key].id === id) {
return true;
}
}
return false;
} | javascript | function (id) {
for (var key in this.active) {
if (this.active.hasOwnProperty(key) && this.active[key].id === id) {
return true;
}
}
return false;
} | [
"function",
"(",
"id",
")",
"{",
"for",
"(",
"var",
"key",
"in",
"this",
".",
"active",
")",
"{",
"if",
"(",
"this",
".",
"active",
".",
"hasOwnProperty",
"(",
"key",
")",
"&&",
"this",
".",
"active",
"[",
"key",
"]",
".",
"id",
"===",
"id",
")... | Return true if "id" corresponds to the job ID of an active job. | [
"Return",
"true",
"if",
"id",
"corresponds",
"to",
"the",
"job",
"ID",
"of",
"an",
"active",
"job",
"."
] | 6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218 | https://github.com/Strider-CD/strider-simple-runner/blob/6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218/lib/jobqueue.js#L104-L111 | train | |
Janpot/gulp-htmlbuild | example/gulpfile.js | function (opts) {
var paths = es.through();
var files = es.through();
paths.pipe(es.writeArray(function (err, srcs) {
gulp.src(srcs, opts).pipe(files);
}));
return es.duplex(paths, files);
} | javascript | function (opts) {
var paths = es.through();
var files = es.through();
paths.pipe(es.writeArray(function (err, srcs) {
gulp.src(srcs, opts).pipe(files);
}));
return es.duplex(paths, files);
} | [
"function",
"(",
"opts",
")",
"{",
"var",
"paths",
"=",
"es",
".",
"through",
"(",
")",
";",
"var",
"files",
"=",
"es",
".",
"through",
"(",
")",
";",
"paths",
".",
"pipe",
"(",
"es",
".",
"writeArray",
"(",
"function",
"(",
"err",
",",
"srcs",
... | pipe a glob stream into this and receive a gulp file stream | [
"pipe",
"a",
"glob",
"stream",
"into",
"this",
"and",
"receive",
"a",
"gulp",
"file",
"stream"
] | 00a3428a3c4537873e40f9180b2c6f56c4a851ee | https://github.com/Janpot/gulp-htmlbuild/blob/00a3428a3c4537873e40f9180b2c6f56c4a851ee/example/gulpfile.js#L10-L19 | train | |
Janpot/gulp-htmlbuild | example/gulpfile.js | function (block) {
es.readArray([
'<!--',
' processed by htmlbuild',
'-->'
].map(function (str) {
return block.indent + str;
})).pipe(block);
} | javascript | function (block) {
es.readArray([
'<!--',
' processed by htmlbuild',
'-->'
].map(function (str) {
return block.indent + str;
})).pipe(block);
} | [
"function",
"(",
"block",
")",
"{",
"es",
".",
"readArray",
"(",
"[",
"'<!--'",
",",
"' processed by htmlbuild'",
",",
"'-->'",
"]",
".",
"map",
"(",
"function",
"(",
"str",
")",
"{",
"return",
"block",
".",
"indent",
"+",
"str",
";",
"}",
")",
")",... | add a header with this target | [
"add",
"a",
"header",
"with",
"this",
"target"
] | 00a3428a3c4537873e40f9180b2c6f56c4a851ee | https://github.com/Janpot/gulp-htmlbuild/blob/00a3428a3c4537873e40f9180b2c6f56c4a851ee/example/gulpfile.js#L63-L71 | train | |
rrharvey/grunt-file-blocks | lib/fileprocessor.js | function (template) {
var pattern = _.template(template)(fileReplace);
pattern = pattern.replace(/\//g, '\\/');
pattern = pattern.replace(/\s+/g, '\\s*');
pattern = '\\s*' + pattern + '\\s*';
return new RegExp(pattern);
} | javascript | function (template) {
var pattern = _.template(template)(fileReplace);
pattern = pattern.replace(/\//g, '\\/');
pattern = pattern.replace(/\s+/g, '\\s*');
pattern = '\\s*' + pattern + '\\s*';
return new RegExp(pattern);
} | [
"function",
"(",
"template",
")",
"{",
"var",
"pattern",
"=",
"_",
".",
"template",
"(",
"template",
")",
"(",
"fileReplace",
")",
";",
"pattern",
"=",
"pattern",
".",
"replace",
"(",
"/",
"\\/",
"/",
"g",
",",
"'\\\\/'",
")",
";",
"pattern",
"=",
... | Convert the template into a RegExp that can capture the file name.
@param {string} template
@returns {RegExp} A regular expression that can capture the file name. | [
"Convert",
"the",
"template",
"into",
"a",
"RegExp",
"that",
"can",
"capture",
"the",
"file",
"name",
"."
] | c1e3bfcb33df76ca820de580da3864085bfaed44 | https://github.com/rrharvey/grunt-file-blocks/blob/c1e3bfcb33df76ca820de580da3864085bfaed44/lib/fileprocessor.js#L29-L35 | train | |
rrharvey/grunt-file-blocks | lib/fileprocessor.js | function (line, block) {
if (!block.template) {
return;
}
var regex = getRegExp(block.template);
var match = regex.exec(line);
return match ? match[1] : match;
} | javascript | function (line, block) {
if (!block.template) {
return;
}
var regex = getRegExp(block.template);
var match = regex.exec(line);
return match ? match[1] : match;
} | [
"function",
"(",
"line",
",",
"block",
")",
"{",
"if",
"(",
"!",
"block",
".",
"template",
")",
"{",
"return",
";",
"}",
"var",
"regex",
"=",
"getRegExp",
"(",
"block",
".",
"template",
")",
";",
"var",
"match",
"=",
"regex",
".",
"exec",
"(",
"l... | Parse the file name from the line if it exists.
@param {string} line - A line from the file.
@param {Block} block - The replacement block object.
@returns {string} The file name if it exists. | [
"Parse",
"the",
"file",
"name",
"from",
"the",
"line",
"if",
"it",
"exists",
"."
] | c1e3bfcb33df76ca820de580da3864085bfaed44 | https://github.com/rrharvey/grunt-file-blocks/blob/c1e3bfcb33df76ca820de580da3864085bfaed44/lib/fileprocessor.js#L43-L51 | train | |
lbdremy/scrapinode | lib/defaults/index.js | scrapDescription | function scrapDescription(window){
var $ = window.$;
var descriptions = [];
// Open Graph protocol by Facebook <meta property="og:description" content="(*)"/>
$('meta[property="og:description"]').each(function(){
var content = $(this).attr('content');
if(content) descriptions.push(content);
... | javascript | function scrapDescription(window){
var $ = window.$;
var descriptions = [];
// Open Graph protocol by Facebook <meta property="og:description" content="(*)"/>
$('meta[property="og:description"]').each(function(){
var content = $(this).attr('content');
if(content) descriptions.push(content);
... | [
"function",
"scrapDescription",
"(",
"window",
")",
"{",
"var",
"$",
"=",
"window",
".",
"$",
";",
"var",
"descriptions",
"=",
"[",
"]",
";",
"// Open Graph protocol by Facebook <meta property=\"og:description\" content=\"(*)\"/>",
"$",
"(",
"'meta[property=\"og:descripti... | Retrieve descriptions of the page
@param {Object} window - object representating the window
@return {Array}
@api public | [
"Retrieve",
"descriptions",
"of",
"the",
"page"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/defaults/index.js#L43-L75 | train |
lbdremy/scrapinode | lib/defaults/index.js | isValidExtension | function isValidExtension(src){
var extension = src.split('.').pop();
var isValid = ENUM_INVALID_EXTENSIONS[extension] === false ? false : true;
return isValid;
} | javascript | function isValidExtension(src){
var extension = src.split('.').pop();
var isValid = ENUM_INVALID_EXTENSIONS[extension] === false ? false : true;
return isValid;
} | [
"function",
"isValidExtension",
"(",
"src",
")",
"{",
"var",
"extension",
"=",
"src",
".",
"split",
"(",
"'.'",
")",
".",
"pop",
"(",
")",
";",
"var",
"isValid",
"=",
"ENUM_INVALID_EXTENSIONS",
"[",
"extension",
"]",
"===",
"false",
"?",
"false",
":",
... | Check if the extension is considered valid
@param {String} src - url of the image
@return {Boolean} true if valid, false otherwise
@api private | [
"Check",
"if",
"the",
"extension",
"is",
"considered",
"valid"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/defaults/index.js#L92-L96 | train |
lbdremy/scrapinode | lib/defaults/index.js | scrapImage | function scrapImage(window){
var $ = window.$;
var url = window.url;
var thumbs = [];
var thumbsRejected = [];
var title = scrapTitle(window);
var addToThumbs = function(image,beginning){
var src = $(image).attr('src');
if(src && isValidExtension(src) ){
src = utils.toURL(src,url... | javascript | function scrapImage(window){
var $ = window.$;
var url = window.url;
var thumbs = [];
var thumbsRejected = [];
var title = scrapTitle(window);
var addToThumbs = function(image,beginning){
var src = $(image).attr('src');
if(src && isValidExtension(src) ){
src = utils.toURL(src,url... | [
"function",
"scrapImage",
"(",
"window",
")",
"{",
"var",
"$",
"=",
"window",
".",
"$",
";",
"var",
"url",
"=",
"window",
".",
"url",
";",
"var",
"thumbs",
"=",
"[",
"]",
";",
"var",
"thumbsRejected",
"=",
"[",
"]",
";",
"var",
"title",
"=",
"scr... | Retrieve image urls on the page
@param {Object} window -
@return {Array}
@api public | [
"Retrieve",
"image",
"urls",
"on",
"the",
"page"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/defaults/index.js#L106-L169 | train |
lbdremy/scrapinode | lib/defaults/index.js | scrapTitle | function scrapTitle(window){
var $ = window.$;
var url = window.location.href;
// Tags or attributes whom can contain a nice title for the page
var titleTag = $('title').text().trim();
var metaTitleTag = $('meta[name="title"]').attr('content');
var openGraphTitle = $('meta[property="og:title"]').att... | javascript | function scrapTitle(window){
var $ = window.$;
var url = window.location.href;
// Tags or attributes whom can contain a nice title for the page
var titleTag = $('title').text().trim();
var metaTitleTag = $('meta[name="title"]').attr('content');
var openGraphTitle = $('meta[property="og:title"]').att... | [
"function",
"scrapTitle",
"(",
"window",
")",
"{",
"var",
"$",
"=",
"window",
".",
"$",
";",
"var",
"url",
"=",
"window",
".",
"location",
".",
"href",
";",
"// Tags or attributes whom can contain a nice title for the page",
"var",
"titleTag",
"=",
"$",
"(",
"... | Retrieve the more appropriate title of the page
@param {Object} window -
@return {String} title of the page
@api public | [
"Retrieve",
"the",
"more",
"appropriate",
"title",
"of",
"the",
"page"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/defaults/index.js#L179-L203 | train |
lbdremy/scrapinode | lib/defaults/index.js | scrapVideo | function scrapVideo(window){
var $ = window.$;
var url = window.location.href;
var thumbs = [];
// Open Graph protocol by Facebook: <meta property="og:video" content="(*)"/>
$('meta').each(function(){
var property = $(this).attr('property');
var content = $(this).attr('content');
if(pr... | javascript | function scrapVideo(window){
var $ = window.$;
var url = window.location.href;
var thumbs = [];
// Open Graph protocol by Facebook: <meta property="og:video" content="(*)"/>
$('meta').each(function(){
var property = $(this).attr('property');
var content = $(this).attr('content');
if(pr... | [
"function",
"scrapVideo",
"(",
"window",
")",
"{",
"var",
"$",
"=",
"window",
".",
"$",
";",
"var",
"url",
"=",
"window",
".",
"location",
".",
"href",
";",
"var",
"thumbs",
"=",
"[",
"]",
";",
"// Open Graph protocol by Facebook: <meta property=\"og:video\" c... | Retrieve the video urls on the page
@param {Object} window -
@return {Array}
@api public | [
"Retrieve",
"the",
"video",
"urls",
"on",
"the",
"page"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/defaults/index.js#L213-L233 | train |
phovea/generator-phovea | utils/pip.js | parseRequirements | function parseRequirements(file) {
if (!file) {
return {};
}
file = file.trim();
if (file === '') {
return {};
}
const versions = {};
file.split('\n').forEach((line) => {
line = line.trim();
if (line.startsWith('-e')) {
// editable special dependency
const branchSeparator = li... | javascript | function parseRequirements(file) {
if (!file) {
return {};
}
file = file.trim();
if (file === '') {
return {};
}
const versions = {};
file.split('\n').forEach((line) => {
line = line.trim();
if (line.startsWith('-e')) {
// editable special dependency
const branchSeparator = li... | [
"function",
"parseRequirements",
"(",
"file",
")",
"{",
"if",
"(",
"!",
"file",
")",
"{",
"return",
"{",
"}",
";",
"}",
"file",
"=",
"file",
".",
"trim",
"(",
")",
";",
"if",
"(",
"file",
"===",
"''",
")",
"{",
"return",
"{",
"}",
";",
"}",
"... | Created by Samuel Gratzl on 05.04.2017. | [
"Created",
"by",
"Samuel",
"Gratzl",
"on",
"05",
".",
"04",
".",
"2017",
"."
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/utils/pip.js#L5-L37 | train |
cloudkick/whiskey | lib/util.js | function(func, context, args, callback) {
try {
func.apply(context, args);
}
catch (err) {}
if (callback) {
callback();
}
} | javascript | function(func, context, args, callback) {
try {
func.apply(context, args);
}
catch (err) {}
if (callback) {
callback();
}
} | [
"function",
"(",
"func",
",",
"context",
",",
"args",
",",
"callback",
")",
"{",
"try",
"{",
"func",
".",
"apply",
"(",
"context",
",",
"args",
")",
";",
"}",
"catch",
"(",
"err",
")",
"{",
"}",
"if",
"(",
"callback",
")",
"{",
"callback",
"(",
... | Call a function and ignore any error thrown.
@param {Function} func Function to call.
@param {Object} context Context in which the function is called.
@param {Array} Function argument
@param {Function} callback Optional callback which is called at the end. | [
"Call",
"a",
"function",
"and",
"ignore",
"any",
"error",
"thrown",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/util.js#L59-L68 | train | |
cloudkick/whiskey | lib/util.js | fireOnce | function fireOnce(fn) {
var fired = false;
return function wrapped() {
if (!fired) {
fired = true;
fn.apply(null, arguments);
}
};
} | javascript | function fireOnce(fn) {
var fired = false;
return function wrapped() {
if (!fired) {
fired = true;
fn.apply(null, arguments);
}
};
} | [
"function",
"fireOnce",
"(",
"fn",
")",
"{",
"var",
"fired",
"=",
"false",
";",
"return",
"function",
"wrapped",
"(",
")",
"{",
"if",
"(",
"!",
"fired",
")",
"{",
"fired",
"=",
"true",
";",
"fn",
".",
"apply",
"(",
"null",
",",
"arguments",
")",
... | Wrap a function so that the original function will only be called once,
regardless of how many times the wrapper is called.
@param {Function} fn The to wrap.
@return {Function} A function which will call fn the first time it is called. | [
"Wrap",
"a",
"function",
"so",
"that",
"the",
"original",
"function",
"will",
"only",
"be",
"called",
"once",
"regardless",
"of",
"how",
"many",
"times",
"the",
"wrapper",
"is",
"called",
"."
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/util.js#L299-L307 | train |
leonardpauli/docs | app/api/external/google/drive/example/script.js | handleClientLoad | function handleClientLoad() {
(async ()=> {
await config.load()
await config.api.google.load()
gapi.load('client:auth2', initClient)
})().catch(console.error)
} | javascript | function handleClientLoad() {
(async ()=> {
await config.load()
await config.api.google.load()
gapi.load('client:auth2', initClient)
})().catch(console.error)
} | [
"function",
"handleClientLoad",
"(",
")",
"{",
"(",
"async",
"(",
")",
"=>",
"{",
"await",
"config",
".",
"load",
"(",
")",
"await",
"config",
".",
"api",
".",
"google",
".",
"load",
"(",
")",
"gapi",
".",
"load",
"(",
"'client:auth2'",
",",
"initCli... | On load, called to load the auth2 library and API client library. | [
"On",
"load",
"called",
"to",
"load",
"the",
"auth2",
"library",
"and",
"API",
"client",
"library",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/app/api/external/google/drive/example/script.js#L34-L40 | train |
leonardpauli/docs | app/api/external/google/drive/example/script.js | initClient | function initClient() {
gapi.client.init({
apiKey: config.api.google.web.key,
clientId: config.api.google.web.client_id,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle ... | javascript | function initClient() {
gapi.client.init({
apiKey: config.api.google.web.key,
clientId: config.api.google.web.client_id,
discoveryDocs: DISCOVERY_DOCS,
scope: SCOPES
}).then(function () {
// Listen for sign-in state changes.
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle ... | [
"function",
"initClient",
"(",
")",
"{",
"gapi",
".",
"client",
".",
"init",
"(",
"{",
"apiKey",
":",
"config",
".",
"api",
".",
"google",
".",
"web",
".",
"key",
",",
"clientId",
":",
"config",
".",
"api",
".",
"google",
".",
"web",
".",
"client_i... | Initializes the API client library and sets up sign-in state
listeners. | [
"Initializes",
"the",
"API",
"client",
"library",
"and",
"sets",
"up",
"sign",
"-",
"in",
"state",
"listeners",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/app/api/external/google/drive/example/script.js#L46-L63 | train |
leonardpauli/docs | app/api/external/google/drive/example/script.js | updateSigninStatus | function updateSigninStatus(isSignedIn) {
if (isSignedIn) {
authorizeButton.style.display = 'none';
signoutButton.style.display = 'block';
listFiles();
} else {
authorizeButton.style.display = 'block';
signoutButton.style.display = 'none';
}
} | javascript | function updateSigninStatus(isSignedIn) {
if (isSignedIn) {
authorizeButton.style.display = 'none';
signoutButton.style.display = 'block';
listFiles();
} else {
authorizeButton.style.display = 'block';
signoutButton.style.display = 'none';
}
} | [
"function",
"updateSigninStatus",
"(",
"isSignedIn",
")",
"{",
"if",
"(",
"isSignedIn",
")",
"{",
"authorizeButton",
".",
"style",
".",
"display",
"=",
"'none'",
";",
"signoutButton",
".",
"style",
".",
"display",
"=",
"'block'",
";",
"listFiles",
"(",
")",
... | Called when the signed in status changes, to update the UI
appropriately. After a sign-in, the API is called. | [
"Called",
"when",
"the",
"signed",
"in",
"status",
"changes",
"to",
"update",
"the",
"UI",
"appropriately",
".",
"After",
"a",
"sign",
"-",
"in",
"the",
"API",
"is",
"called",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/app/api/external/google/drive/example/script.js#L69-L78 | train |
leonardpauli/docs | app/api/external/google/drive/example/script.js | appendPre | function appendPre(message) {
var pre = document.getElementById('content');
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
} | javascript | function appendPre(message) {
var pre = document.getElementById('content');
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
} | [
"function",
"appendPre",
"(",
"message",
")",
"{",
"var",
"pre",
"=",
"document",
".",
"getElementById",
"(",
"'content'",
")",
";",
"var",
"textContent",
"=",
"document",
".",
"createTextNode",
"(",
"message",
"+",
"'\\n'",
")",
";",
"pre",
".",
"appendCh... | Append a pre element to the body containing the given message
as its text node. Used to display the results of the API call.
@param {string} message Text to be placed in pre element. | [
"Append",
"a",
"pre",
"element",
"to",
"the",
"body",
"containing",
"the",
"given",
"message",
"as",
"its",
"text",
"node",
".",
"Used",
"to",
"display",
"the",
"results",
"of",
"the",
"API",
"call",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/app/api/external/google/drive/example/script.js#L100-L104 | train |
leonardpauli/docs | app/api/external/google/drive/example/script.js | listFiles | function listFiles() {
gapi.client.drive.files.list({
'pageSize': 10,
'fields': "nextPageToken, files(id, name)"
}).then(function(response) {
appendPre('Files:');
var files = response.result.files;
if (files && files.length > 0) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
appe... | javascript | function listFiles() {
gapi.client.drive.files.list({
'pageSize': 10,
'fields': "nextPageToken, files(id, name)"
}).then(function(response) {
appendPre('Files:');
var files = response.result.files;
if (files && files.length > 0) {
for (var i = 0; i < files.length; i++) {
var file = files[i];
appe... | [
"function",
"listFiles",
"(",
")",
"{",
"gapi",
".",
"client",
".",
"drive",
".",
"files",
".",
"list",
"(",
"{",
"'pageSize'",
":",
"10",
",",
"'fields'",
":",
"\"nextPageToken, files(id, name)\"",
"}",
")",
".",
"then",
"(",
"function",
"(",
"response",
... | Print files. | [
"Print",
"files",
"."
] | 9f6180f28635f6acfc84e21572e85b333f4aa88d | https://github.com/leonardpauli/docs/blob/9f6180f28635f6acfc84e21572e85b333f4aa88d/app/api/external/google/drive/example/script.js#L109-L125 | train |
jose-pleonasm/py-logging | core/Formatter.js | Formatter | function Formatter(format, timeFormat) {
format = format || '%(message)';
timeFormat = timeFormat || '%Y-%m-%d %H:%M:%S';
/**
* @private
* @type {string}
*/
this._format = format;
/**
* @private
* @type {string}
*/
this._timeFormat = timeFormat;
} | javascript | function Formatter(format, timeFormat) {
format = format || '%(message)';
timeFormat = timeFormat || '%Y-%m-%d %H:%M:%S';
/**
* @private
* @type {string}
*/
this._format = format;
/**
* @private
* @type {string}
*/
this._timeFormat = timeFormat;
} | [
"function",
"Formatter",
"(",
"format",
",",
"timeFormat",
")",
"{",
"format",
"=",
"format",
"||",
"'%(message)'",
";",
"timeFormat",
"=",
"timeFormat",
"||",
"'%Y-%m-%d %H:%M:%S'",
";",
"/**\n\t * @private\n\t * @type {string}\n\t */",
"this",
".",
"_format",
"=",
... | Default formatter.
@constructor Formatter
@param {string} [format]
@param {string} [timeFormat] | [
"Default",
"formatter",
"."
] | 598f41284311ea6a837d4ba56236301abe689b09 | https://github.com/jose-pleonasm/py-logging/blob/598f41284311ea6a837d4ba56236301abe689b09/core/Formatter.js#L10-L25 | train |
cronvel/kung-fig | lib/kfgStringify.js | stringifyString | function stringifyString( v , runtime , isTemplateSentence ) {
var maybeDollar = '' ;
if ( isTemplateSentence ) {
if ( v.key ) {
v = v.key ;
maybeDollar = '$' ;
}
else {
runtime.str += runtime.depth ? ' <Sentence>' : '<Sentence>' ;
return ;
}
}
if ( runtime.preferQuotes ) {
return stringifyS... | javascript | function stringifyString( v , runtime , isTemplateSentence ) {
var maybeDollar = '' ;
if ( isTemplateSentence ) {
if ( v.key ) {
v = v.key ;
maybeDollar = '$' ;
}
else {
runtime.str += runtime.depth ? ' <Sentence>' : '<Sentence>' ;
return ;
}
}
if ( runtime.preferQuotes ) {
return stringifyS... | [
"function",
"stringifyString",
"(",
"v",
",",
"runtime",
",",
"isTemplateSentence",
")",
"{",
"var",
"maybeDollar",
"=",
"''",
";",
"if",
"(",
"isTemplateSentence",
")",
"{",
"if",
"(",
"v",
".",
"key",
")",
"{",
"v",
"=",
"v",
".",
"key",
";",
"mayb... | no control chars except newline and tab | [
"no",
"control",
"chars",
"except",
"newline",
"and",
"tab"
] | a862c37237a283b4c0a4a5ff0bde6617d77104eb | https://github.com/cronvel/kung-fig/blob/a862c37237a283b4c0a4a5ff0bde6617d77104eb/lib/kfgStringify.js#L154-L174 | train |
Strider-CD/strider-simple-runner | lib/index.js | t | function t(time, done) {
if (arguments.length === 1) {
done = time;
time = 2000;
}
var error = new Error(`Callback took too long (max: ${time})`);
var waiting = true;
var timeout = setTimeout(function () {
if (!waiting) return;
waiting = false;
done(error);
}, time);
function handler... | javascript | function t(time, done) {
if (arguments.length === 1) {
done = time;
time = 2000;
}
var error = new Error(`Callback took too long (max: ${time})`);
var waiting = true;
var timeout = setTimeout(function () {
if (!waiting) return;
waiting = false;
done(error);
}, time);
function handler... | [
"function",
"t",
"(",
"time",
",",
"done",
")",
"{",
"if",
"(",
"arguments",
".",
"length",
"===",
"1",
")",
"{",
"done",
"=",
"time",
";",
"time",
"=",
"2000",
";",
"}",
"var",
"error",
"=",
"new",
"Error",
"(",
"`",
"${",
"time",
"}",
"`",
... | timeout for callbacks. Helps to kill misbehaving plugins, etc | [
"timeout",
"for",
"callbacks",
".",
"Helps",
"to",
"kill",
"misbehaving",
"plugins",
"etc"
] | 6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218 | https://github.com/Strider-CD/strider-simple-runner/blob/6784fcfa605abf21fe3dc6ddd5d2a2f5e98a6218/lib/index.js#L18-L40 | train |
lbdremy/scrapinode | lib/browser.js | getRequest | function getRequest(options,callback){
var destroyed = false;
var req = request.get(options.url)
.set(options.headers)
.timeout(options.timeout)
.redirects(options.redirects)
.buffer(false)
.end(function(err,res){
if(err && !err.status) return onError(err);
... | javascript | function getRequest(options,callback){
var destroyed = false;
var req = request.get(options.url)
.set(options.headers)
.timeout(options.timeout)
.redirects(options.redirects)
.buffer(false)
.end(function(err,res){
if(err && !err.status) return onError(err);
... | [
"function",
"getRequest",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"destroyed",
"=",
"false",
";",
"var",
"req",
"=",
"request",
".",
"get",
"(",
"options",
".",
"url",
")",
".",
"set",
"(",
"options",
".",
"headers",
")",
".",
"timeout",
"(... | Send an HTTP GET request to `options.url`
@param {Object} options - configuration of the HTTP GET request
@param {String} options.headers - set of headers
@param {Number} options.timeout - timeout
@param {Number} options.redirects - number of times the request will follow redirection instructions
@param {Number} optio... | [
"Send",
"an",
"HTTP",
"GET",
"request",
"to",
"options",
".",
"url"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/browser.js#L66-L117 | train |
lbdremy/scrapinode | lib/browser.js | buildDOM | function buildDOM(body,engine,url,callback){
if(!body){
return callback(new ScrapinodeError('The HTTP response contains an empty body: "' + body +'"'));
}
if(engine === 'jsdom' || engine === 'jsdom+zepto'){
var library = engine === 'jsdom+zepto' ? zepto : jquery;
try{
js... | javascript | function buildDOM(body,engine,url,callback){
if(!body){
return callback(new ScrapinodeError('The HTTP response contains an empty body: "' + body +'"'));
}
if(engine === 'jsdom' || engine === 'jsdom+zepto'){
var library = engine === 'jsdom+zepto' ? zepto : jquery;
try{
js... | [
"function",
"buildDOM",
"(",
"body",
",",
"engine",
",",
"url",
",",
"callback",
")",
"{",
"if",
"(",
"!",
"body",
")",
"{",
"return",
"callback",
"(",
"new",
"ScrapinodeError",
"(",
"'The HTTP response contains an empty body: \"'",
"+",
"body",
"+",
"'\"'",
... | Build a DOM representation of the given HTML `body`
@param {String} body - html page
@param {String} engine - name of the engine used to generate the DOM
@param {String} url - url of the page containing the given `body`
@param {Function} callback -
@api private | [
"Build",
"a",
"DOM",
"representation",
"of",
"the",
"given",
"HTML",
"body"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/browser.js#L129-L167 | train |
lbdremy/scrapinode | lib/browser.js | isImage | function isImage(headers){
var regexImage = /image\//i;
var contentType = headers ? headers['content-type'] : '';
return regexImage.test(contentType);
} | javascript | function isImage(headers){
var regexImage = /image\//i;
var contentType = headers ? headers['content-type'] : '';
return regexImage.test(contentType);
} | [
"function",
"isImage",
"(",
"headers",
")",
"{",
"var",
"regexImage",
"=",
"/",
"image\\/",
"/",
"i",
";",
"var",
"contentType",
"=",
"headers",
"?",
"headers",
"[",
"'content-type'",
"]",
":",
"''",
";",
"return",
"regexImage",
".",
"test",
"(",
"conten... | Check if the content of the HTTP body is an image
@param {Object} headers -
@return {Boolean}
@api private | [
"Check",
"if",
"the",
"content",
"of",
"the",
"HTTP",
"body",
"is",
"an",
"image"
] | c172c36fed7cce22516f3edbd71287c79ce6a4e2 | https://github.com/lbdremy/scrapinode/blob/c172c36fed7cce22516f3edbd71287c79ce6a4e2/lib/browser.js#L213-L217 | train |
jonschlinkert/map-schema | index.js | Schema | function Schema(options) {
this.options = options || {};
this.data = new Data();
this.isSchema = true;
this.utils = utils;
this.initSchema();
this.addFields(this.options);
var only = utils.arrayify(this.options.pick || this.options.only);
utils.define(this.options, 'only', only);
} | javascript | function Schema(options) {
this.options = options || {};
this.data = new Data();
this.isSchema = true;
this.utils = utils;
this.initSchema();
this.addFields(this.options);
var only = utils.arrayify(this.options.pick || this.options.only);
utils.define(this.options, 'only', only);
} | [
"function",
"Schema",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"data",
"=",
"new",
"Data",
"(",
")",
";",
"this",
".",
"isSchema",
"=",
"true",
";",
"this",
".",
"utils",
"=",
"utils",
";... | Create a new `Schema` with the given `options`.
```js
var schema = new Schema()
.field('name', 'string')
.field('version', 'string')
.field('license', 'string')
.field('licenses', 'array', {
normalize: function(val, key, config) {
// convert license array to `license` string
config.license = val[0].type;
delete config... | [
"Create",
"a",
"new",
"Schema",
"with",
"the",
"given",
"options",
"."
] | 08e11847e83ab91aa7460f6ee2249a64967a5d29 | https://github.com/jonschlinkert/map-schema/blob/08e11847e83ab91aa7460f6ee2249a64967a5d29/index.js#L44-L53 | train |
phovea/generator-phovea | generators/workspace/index.js | rewriteDockerCompose | function rewriteDockerCompose(compose) {
const services = compose.services;
if (!services) {
return compose;
}
const host = services._host;
delete services._host;
Object.keys(services).forEach((k) => {
if (!isHelperContainer(k)) {
mergeWith(services[k], host);
}
});
return compose;
} | javascript | function rewriteDockerCompose(compose) {
const services = compose.services;
if (!services) {
return compose;
}
const host = services._host;
delete services._host;
Object.keys(services).forEach((k) => {
if (!isHelperContainer(k)) {
mergeWith(services[k], host);
}
});
return compose;
} | [
"function",
"rewriteDockerCompose",
"(",
"compose",
")",
"{",
"const",
"services",
"=",
"compose",
".",
"services",
";",
"if",
"(",
"!",
"services",
")",
"{",
"return",
"compose",
";",
"}",
"const",
"host",
"=",
"services",
".",
"_host",
";",
"delete",
"... | rewrite the compose by inlining _host to all services not containing a dash, such that both api and celery have the same entry
@param compose | [
"rewrite",
"the",
"compose",
"by",
"inlining",
"_host",
"to",
"all",
"services",
"not",
"containing",
"a",
"dash",
"such",
"that",
"both",
"api",
"and",
"celery",
"have",
"the",
"same",
"entry"
] | 913f21a458d1468b9319e3b1e796ec09f7e8e9fc | https://github.com/phovea/generator-phovea/blob/913f21a458d1468b9319e3b1e796ec09f7e8e9fc/generators/workspace/index.js#L29-L42 | train |
basisjs/basisjs-tools-build | lib/extract/js/index.js | function(token, this_, args, scope){
//fconsole.log('extend', arguments);
if (this.file.jsScope == basisScope)
{
var arg0 = token.arguments[0];
if (arg0 && arg0.type == 'Identifier' && arg0.name == 'Object')
flow.exit('Too old basis.js (prior 1.0) detected! Curre... | javascript | function(token, this_, args, scope){
//fconsole.log('extend', arguments);
if (this.file.jsScope == basisScope)
{
var arg0 = token.arguments[0];
if (arg0 && arg0.type == 'Identifier' && arg0.name == 'Object')
flow.exit('Too old basis.js (prior 1.0) detected! Curre... | [
"function",
"(",
"token",
",",
"this_",
",",
"args",
",",
"scope",
")",
"{",
"//fconsole.log('extend', arguments);",
"if",
"(",
"this",
".",
"file",
".",
"jsScope",
"==",
"basisScope",
")",
"{",
"var",
"arg0",
"=",
"token",
".",
"arguments",
"[",
"0",
"]... | basis.object.extend | [
"basis",
".",
"object",
".",
"extend"
] | 177018ab31b225cddb6a184693fe4746512e7af1 | https://github.com/basisjs/basisjs-tools-build/blob/177018ab31b225cddb6a184693fe4746512e7af1/lib/extract/js/index.js#L604-L616 | train | |
basisjs/basisjs-tools-build | lib/extract/js/index.js | function(token, this_, args){
//fconsole.log('getNamespace', arguments);
var namespace = args[0];
if (namespace && namespace.type == 'Literal')
{
var ns = getNamespace(namespace.value);
token.obj = ns.obj;
token.ref_ = ns.ref_;
if (args[1])
... | javascript | function(token, this_, args){
//fconsole.log('getNamespace', arguments);
var namespace = args[0];
if (namespace && namespace.type == 'Literal')
{
var ns = getNamespace(namespace.value);
token.obj = ns.obj;
token.ref_ = ns.ref_;
if (args[1])
... | [
"function",
"(",
"token",
",",
"this_",
",",
"args",
")",
"{",
"//fconsole.log('getNamespace', arguments);",
"var",
"namespace",
"=",
"args",
"[",
"0",
"]",
";",
"if",
"(",
"namespace",
"&&",
"namespace",
".",
"type",
"==",
"'Literal'",
")",
"{",
"var",
"n... | basis.namespace | [
"basis",
".",
"namespace"
] | 177018ab31b225cddb6a184693fe4746512e7af1 | https://github.com/basisjs/basisjs-tools-build/blob/177018ab31b225cddb6a184693fe4746512e7af1/lib/extract/js/index.js#L626-L637 | train | |
CartoDB/tangram-cartocss | src/translate.js | getReferenceIndexedByCSS | function getReferenceIndexedByCSS(ref) {
var newRef = {};
for (var symb in ref.symbolizers) {
for (var property in ref.symbolizers[symb]) {
newRef[ref.symbolizers[symb][property].css] = ref.symbolizers[symb][property];
}
}
return newRef;
} | javascript | function getReferenceIndexedByCSS(ref) {
var newRef = {};
for (var symb in ref.symbolizers) {
for (var property in ref.symbolizers[symb]) {
newRef[ref.symbolizers[symb][property].css] = ref.symbolizers[symb][property];
}
}
return newRef;
} | [
"function",
"getReferenceIndexedByCSS",
"(",
"ref",
")",
"{",
"var",
"newRef",
"=",
"{",
"}",
";",
"for",
"(",
"var",
"symb",
"in",
"ref",
".",
"symbolizers",
")",
"{",
"for",
"(",
"var",
"property",
"in",
"ref",
".",
"symbolizers",
"[",
"symb",
"]",
... | getReferenceIndexedByCSS returns a reference based on ref indexed by the CSS property name instead of the reference original property name it does a shallow copy of each property, therefore, it's possible to change the returned reference by changing the original one, don't do it | [
"getReferenceIndexedByCSS",
"returns",
"a",
"reference",
"based",
"on",
"ref",
"indexed",
"by",
"the",
"CSS",
"property",
"name",
"instead",
"of",
"the",
"reference",
"original",
"property",
"name",
"it",
"does",
"a",
"shallow",
"copy",
"of",
"each",
"property",... | df5f15c01d24bb284510dbf7cf464c5c26059e4d | https://github.com/CartoDB/tangram-cartocss/blob/df5f15c01d24bb284510dbf7cf464c5c26059e4d/src/translate.js#L6-L14 | train |
CartoDB/tangram-cartocss | src/translate.js | getOpacityOverride | function getOpacityOverride(sceneDrawGroup, isFill) {
var opacity;
if (isFill) {
opacity = sceneDrawGroup._hidden['opacity:fill'];
} else {
opacity = sceneDrawGroup._hidden['opacity:outline'];
}
if (sceneDrawGroup._hidden['opacity:general'] !== undefined) {
opacity = sceneDra... | javascript | function getOpacityOverride(sceneDrawGroup, isFill) {
var opacity;
if (isFill) {
opacity = sceneDrawGroup._hidden['opacity:fill'];
} else {
opacity = sceneDrawGroup._hidden['opacity:outline'];
}
if (sceneDrawGroup._hidden['opacity:general'] !== undefined) {
opacity = sceneDra... | [
"function",
"getOpacityOverride",
"(",
"sceneDrawGroup",
",",
"isFill",
")",
"{",
"var",
"opacity",
";",
"if",
"(",
"isFill",
")",
"{",
"opacity",
"=",
"sceneDrawGroup",
".",
"_hidden",
"[",
"'opacity:fill'",
"]",
";",
"}",
"else",
"{",
"opacity",
"=",
"sc... | Returns the final opacity override selecting between fill-opacity and outline-opacity. Returned value can be a float or a function string to be called at Tangram's runtime if the override is active A falseable value will be returned if the override is not active | [
"Returns",
"the",
"final",
"opacity",
"override",
"selecting",
"between",
"fill",
"-",
"opacity",
"and",
"outline",
"-",
"opacity",
".",
"Returned",
"value",
"can",
"be",
"a",
"float",
"or",
"a",
"function",
"string",
"to",
"be",
"called",
"at",
"Tangram",
... | df5f15c01d24bb284510dbf7cf464c5c26059e4d | https://github.com/CartoDB/tangram-cartocss/blob/df5f15c01d24bb284510dbf7cf464c5c26059e4d/src/translate.js#L40-L51 | train |
CartoDB/tangram-cartocss | src/translate.js | getFunctionFromDefaultAndShaderValue | function getFunctionFromDefaultAndShaderValue(sceneDrawGroup, ccssProperty, defaultValue, shaderValue) {
if (referenceCSS[ccssProperty].type === 'color') {
defaultValue = `'${color.normalize(defaultValue, tangramReference)}'`;
}
var fn = `var _value=${defaultValue};`;
shaderValue.js.forEach(func... | javascript | function getFunctionFromDefaultAndShaderValue(sceneDrawGroup, ccssProperty, defaultValue, shaderValue) {
if (referenceCSS[ccssProperty].type === 'color') {
defaultValue = `'${color.normalize(defaultValue, tangramReference)}'`;
}
var fn = `var _value=${defaultValue};`;
shaderValue.js.forEach(func... | [
"function",
"getFunctionFromDefaultAndShaderValue",
"(",
"sceneDrawGroup",
",",
"ccssProperty",
",",
"defaultValue",
",",
"shaderValue",
")",
"{",
"if",
"(",
"referenceCSS",
"[",
"ccssProperty",
"]",
".",
"type",
"===",
"'color'",
")",
"{",
"defaultValue",
"=",
"`... | Returns a function string that sets the value to the default one and then executes the shader value code | [
"Returns",
"a",
"function",
"string",
"that",
"sets",
"the",
"value",
"to",
"the",
"default",
"one",
"and",
"then",
"executes",
"the",
"shader",
"value",
"code"
] | df5f15c01d24bb284510dbf7cf464c5c26059e4d | https://github.com/CartoDB/tangram-cartocss/blob/df5f15c01d24bb284510dbf7cf464c5c26059e4d/src/translate.js#L84-L103 | train |
CartoDB/tangram-cartocss | src/translate.js | translateValue | function translateValue(sceneDrawGroup, ccssProperty, ccssValue) {
if (ccssProperty.indexOf('comp-op') >= 0) {
switch (ccssValue) {
case 'src-over':
return 'overlay';
case 'plus':
return 'add';
default:
return ccssValue;
... | javascript | function translateValue(sceneDrawGroup, ccssProperty, ccssValue) {
if (ccssProperty.indexOf('comp-op') >= 0) {
switch (ccssValue) {
case 'src-over':
return 'overlay';
case 'plus':
return 'add';
default:
return ccssValue;
... | [
"function",
"translateValue",
"(",
"sceneDrawGroup",
",",
"ccssProperty",
",",
"ccssValue",
")",
"{",
"if",
"(",
"ccssProperty",
".",
"indexOf",
"(",
"'comp-op'",
")",
">=",
"0",
")",
"{",
"switch",
"(",
"ccssValue",
")",
"{",
"case",
"'src-over'",
":",
"r... | Translates a ccssValue from the reference standard to the Tangram standard | [
"Translates",
"a",
"ccssValue",
"from",
"the",
"reference",
"standard",
"to",
"the",
"Tangram",
"standard"
] | df5f15c01d24bb284510dbf7cf464c5c26059e4d | https://github.com/CartoDB/tangram-cartocss/blob/df5f15c01d24bb284510dbf7cf464c5c26059e4d/src/translate.js#L106-L127 | train |
CartoDB/tangram-cartocss | src/translate.js | getFilterFn | function getFilterFn(layer, symbolizer) {
const symbolizers = Object.keys(layer.shader)
.filter(property => layer.shader[property].symbolizer === symbolizer);
//No need to set a callback when at least one property is not filtered (i.e. it always activates the symbolizer)
const alwaysActive = symbol... | javascript | function getFilterFn(layer, symbolizer) {
const symbolizers = Object.keys(layer.shader)
.filter(property => layer.shader[property].symbolizer === symbolizer);
//No need to set a callback when at least one property is not filtered (i.e. it always activates the symbolizer)
const alwaysActive = symbol... | [
"function",
"getFilterFn",
"(",
"layer",
",",
"symbolizer",
")",
"{",
"const",
"symbolizers",
"=",
"Object",
".",
"keys",
"(",
"layer",
".",
"shader",
")",
".",
"filter",
"(",
"property",
"=>",
"layer",
".",
"shader",
"[",
"property",
"]",
".",
"symboliz... | Returns a function string that dynamically filters symbolizer based on conditional properties | [
"Returns",
"a",
"function",
"string",
"that",
"dynamically",
"filters",
"symbolizer",
"based",
"on",
"conditional",
"properties"
] | df5f15c01d24bb284510dbf7cf464c5c26059e4d | https://github.com/CartoDB/tangram-cartocss/blob/df5f15c01d24bb284510dbf7cf464c5c26059e4d/src/translate.js#L165-L183 | train |
stealjs/steal-conditional | conditional.js | getGlob | function getGlob() {
if (isNode) {
return loader.import("@node-require", { name: module.id })
.then(function(nodeRequire) {
return nodeRequire("glob");
});
}
return Promise.resolve();
} | javascript | function getGlob() {
if (isNode) {
return loader.import("@node-require", { name: module.id })
.then(function(nodeRequire) {
return nodeRequire("glob");
});
}
return Promise.resolve();
} | [
"function",
"getGlob",
"(",
")",
"{",
"if",
"(",
"isNode",
")",
"{",
"return",
"loader",
".",
"import",
"(",
"\"@node-require\"",
",",
"{",
"name",
":",
"module",
".",
"id",
"}",
")",
".",
"then",
"(",
"function",
"(",
"nodeRequire",
")",
"{",
"retur... | get some node modules through @node-require which is a noop in the browser | [
"get",
"some",
"node",
"modules",
"through"
] | 04e1c363d5af183aef52c6cb5a75762ca69fc5bf | https://github.com/stealjs/steal-conditional/blob/04e1c363d5af183aef52c6cb5a75762ca69fc5bf/conditional.js#L36-L45 | train |
stealjs/steal-conditional | conditional.js | getModuleName | function getModuleName(nameWithConditional, variation) {
var modName;
var conditionIndex = nameWithConditional.search(conditionalRegEx);
// look for any "/" after the condition
var lastSlashIndex = nameWithConditional.indexOf("/",
nameWithConditional.indexOf("}"));
// substitution of a folder name
... | javascript | function getModuleName(nameWithConditional, variation) {
var modName;
var conditionIndex = nameWithConditional.search(conditionalRegEx);
// look for any "/" after the condition
var lastSlashIndex = nameWithConditional.indexOf("/",
nameWithConditional.indexOf("}"));
// substitution of a folder name
... | [
"function",
"getModuleName",
"(",
"nameWithConditional",
",",
"variation",
")",
"{",
"var",
"modName",
";",
"var",
"conditionIndex",
"=",
"nameWithConditional",
".",
"search",
"(",
"conditionalRegEx",
")",
";",
"// look for any \"/\" after the condition",
"var",
"lastSl... | Returns the bundle module name for a string substitution
@param {string} nameWithConditional The module identifier including the condition
@param {string} variation A match of the glob pattern
@return {string} The bundle module name | [
"Returns",
"the",
"bundle",
"module",
"name",
"for",
"a",
"string",
"substitution"
] | 04e1c363d5af183aef52c6cb5a75762ca69fc5bf | https://github.com/stealjs/steal-conditional/blob/04e1c363d5af183aef52c6cb5a75762ca69fc5bf/conditional.js#L57-L74 | train |
stealjs/steal-conditional | conditional.js | function(m) {
var conditionValue = (typeof m === "object") ?
readMemberExpression(conditionExport, m) : m;
if (substitution) {
if (typeof conditionValue !== "string") {
throw new TypeError(
"The condition value for " +
conditionalMatch[0] +
" doesn't resolve to a ... | javascript | function(m) {
var conditionValue = (typeof m === "object") ?
readMemberExpression(conditionExport, m) : m;
if (substitution) {
if (typeof conditionValue !== "string") {
throw new TypeError(
"The condition value for " +
conditionalMatch[0] +
" doesn't resolve to a ... | [
"function",
"(",
"m",
")",
"{",
"var",
"conditionValue",
"=",
"(",
"typeof",
"m",
"===",
"\"object\"",
")",
"?",
"readMemberExpression",
"(",
"conditionExport",
",",
"m",
")",
":",
"m",
";",
"if",
"(",
"substitution",
")",
"{",
"if",
"(",
"typeof",
"co... | !steal-remove-end | [
"!steal",
"-",
"remove",
"-",
"end"
] | 04e1c363d5af183aef52c6cb5a75762ca69fc5bf | https://github.com/stealjs/steal-conditional/blob/04e1c363d5af183aef52c6cb5a75762ca69fc5bf/conditional.js#L341-L381 | train | |
jose-pleonasm/py-logging | core/Handler.js | Handler | function Handler(level) {
level = level || Logger.NOTSET;
if (Logger.getLevelName(level) === '') {
throw new Error('Argument 1 of Handler.constructor has unsupported'
+ ' value \'' + level + '\'');
}
Filterer.call(this);
/**
* @private
* @type {number}
*/
this._level = level;
/**
* @private
* ... | javascript | function Handler(level) {
level = level || Logger.NOTSET;
if (Logger.getLevelName(level) === '') {
throw new Error('Argument 1 of Handler.constructor has unsupported'
+ ' value \'' + level + '\'');
}
Filterer.call(this);
/**
* @private
* @type {number}
*/
this._level = level;
/**
* @private
* ... | [
"function",
"Handler",
"(",
"level",
")",
"{",
"level",
"=",
"level",
"||",
"Logger",
".",
"NOTSET",
";",
"if",
"(",
"Logger",
".",
"getLevelName",
"(",
"level",
")",
"===",
"''",
")",
"{",
"throw",
"new",
"Error",
"(",
"'Argument 1 of Handler.constructor ... | An abstract handler.
@constructor Handler
@extends Filterer
@param {number} [level=NOTSET] | [
"An",
"abstract",
"handler",
"."
] | 598f41284311ea6a837d4ba56236301abe689b09 | https://github.com/jose-pleonasm/py-logging/blob/598f41284311ea6a837d4ba56236301abe689b09/core/Handler.js#L12-L33 | train |
sasaplus1/ltsv.js | cjs/parser.js | baseParse | function baseParse(text, strict) {
const lines = String(text).replace(/(?:\r?\n)+$/, '').split(/\r?\n/);
const records = [];
for (let i = 0, len = lines.length; i < len; ++i) {
records[i] = baseParseLine(lines[i], strict);
}
return records;
} | javascript | function baseParse(text, strict) {
const lines = String(text).replace(/(?:\r?\n)+$/, '').split(/\r?\n/);
const records = [];
for (let i = 0, len = lines.length; i < len; ++i) {
records[i] = baseParseLine(lines[i], strict);
}
return records;
} | [
"function",
"baseParse",
"(",
"text",
",",
"strict",
")",
"{",
"const",
"lines",
"=",
"String",
"(",
"text",
")",
".",
"replace",
"(",
"/",
"(?:\\r?\\n)+$",
"/",
",",
"''",
")",
".",
"split",
"(",
"/",
"\\r?\\n",
"/",
")",
";",
"const",
"records",
... | parse LTSV text.
@private
@param {string} text
@param {boolean} strict
@returns {Object[]} | [
"parse",
"LTSV",
"text",
"."
] | 66eb96de5957905260864912e796f08e49ff222c | https://github.com/sasaplus1/ltsv.js/blob/66eb96de5957905260864912e796f08e49ff222c/cjs/parser.js#L61-L70 | train |
sasaplus1/ltsv.js | cjs/parser.js | baseParseLine | function baseParseLine(line, strict) {
const fields = String(line).replace(/(?:\r?\n)+$/, '').split('\t');
const record = {};
for (let i = 0, len = fields.length; i < len; ++i) {
const _splitField = splitField(fields[i], strict),
label = _splitField.label,
value = _splitField.value;
... | javascript | function baseParseLine(line, strict) {
const fields = String(line).replace(/(?:\r?\n)+$/, '').split('\t');
const record = {};
for (let i = 0, len = fields.length; i < len; ++i) {
const _splitField = splitField(fields[i], strict),
label = _splitField.label,
value = _splitField.value;
... | [
"function",
"baseParseLine",
"(",
"line",
",",
"strict",
")",
"{",
"const",
"fields",
"=",
"String",
"(",
"line",
")",
".",
"replace",
"(",
"/",
"(?:\\r?\\n)+$",
"/",
",",
"''",
")",
".",
"split",
"(",
"'\\t'",
")",
";",
"const",
"record",
"=",
"{",
... | parse LTSV record.
@private
@param {string} line
@param {boolean} strict
@returns {Object} | [
"parse",
"LTSV",
"record",
"."
] | 66eb96de5957905260864912e796f08e49ff222c | https://github.com/sasaplus1/ltsv.js/blob/66eb96de5957905260864912e796f08e49ff222c/cjs/parser.js#L81-L94 | train |
darrylwest/simple-node-db | examples/create-new-order.js | function(params) {
const order = this;
if (!params) {
params = {};
}
// the standards attributes
this.id = params.id;
this.dateCreated = params.dateCreated;
this.lastUpdated = params.lastUpdated;
this.version = params.version;
this.customer = params.customer;
this.orde... | javascript | function(params) {
const order = this;
if (!params) {
params = {};
}
// the standards attributes
this.id = params.id;
this.dateCreated = params.dateCreated;
this.lastUpdated = params.lastUpdated;
this.version = params.version;
this.customer = params.customer;
this.orde... | [
"function",
"(",
"params",
")",
"{",
"const",
"order",
"=",
"this",
";",
"if",
"(",
"!",
"params",
")",
"{",
"params",
"=",
"{",
"}",
";",
"}",
"// the standards attributes",
"this",
".",
"id",
"=",
"params",
".",
"id",
";",
"this",
".",
"dateCreated... | define the Order and Order Item objects | [
"define",
"the",
"Order",
"and",
"Order",
"Item",
"objects"
] | a456a653ef062a07bd6c5217c46000ac00ecf408 | https://github.com/darrylwest/simple-node-db/blob/a456a653ef062a07bd6c5217c46000ac00ecf408/examples/create-new-order.js#L15-L43 | train | |
bootprint/customize | index.js | customOverrider | function customOverrider (a, b, propertyName) {
if (b == null) {
return a
}
if (a == null) {
// Invoke default overrider
return undefined
}
// Some objects have custom overriders
if (b._customize_custom_overrider && b._customize_custom_overrider instanceof Function) {
return b._customize_c... | javascript | function customOverrider (a, b, propertyName) {
if (b == null) {
return a
}
if (a == null) {
// Invoke default overrider
return undefined
}
// Some objects have custom overriders
if (b._customize_custom_overrider && b._customize_custom_overrider instanceof Function) {
return b._customize_c... | [
"function",
"customOverrider",
"(",
"a",
",",
"b",
",",
"propertyName",
")",
"{",
"if",
"(",
"b",
"==",
"null",
")",
"{",
"return",
"a",
"}",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"// Invoke default overrider",
"return",
"undefined",
"}",
"// Some obje... | Customize has predefined override rules for merging configs.
* If the overriding object has a `_customize_custom_overrider` function-property,
it isk called to perform the merger.
* Arrays are concatenated
* Promises are resolved and the results are merged
@param a the overridden value
@param b the overriding value
... | [
"Customize",
"has",
"predefined",
"override",
"rules",
"for",
"merging",
"configs",
"."
] | 0ea0c2c7a600cb6f4ea310e7c0a07f02ce8add18 | https://github.com/bootprint/customize/blob/0ea0c2c7a600cb6f4ea310e7c0a07f02ce8add18/index.js#L343-L371 | train |
cronvel/kung-fig | lib/kfgCommon.js | MultiLine | function MultiLine( type , fold , applicable , options ) {
this.type = type ;
this.fold = !! fold ;
this.applicable = !! applicable ;
this.options = options ;
this.lines = [] ;
} | javascript | function MultiLine( type , fold , applicable , options ) {
this.type = type ;
this.fold = !! fold ;
this.applicable = !! applicable ;
this.options = options ;
this.lines = [] ;
} | [
"function",
"MultiLine",
"(",
"type",
",",
"fold",
",",
"applicable",
",",
"options",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"fold",
"=",
"!",
"!",
"fold",
";",
"this",
".",
"applicable",
"=",
"!",
"!",
"applicable",
";",
"th... | An object to ease multi-line scalar values | [
"An",
"object",
"to",
"ease",
"multi",
"-",
"line",
"scalar",
"values"
] | a862c37237a283b4c0a4a5ff0bde6617d77104eb | https://github.com/cronvel/kung-fig/blob/a862c37237a283b4c0a4a5ff0bde6617d77104eb/lib/kfgCommon.js#L47-L53 | train |
cloudkick/whiskey | lib/common.js | function(callback) {
self._getConnection(function(err, connection) {
if (err) {
callback(new Error('Unable to establish connection with the master ' +
'process'));
return;
}
self._connection = connection;
callback();
});
} | javascript | function(callback) {
self._getConnection(function(err, connection) {
if (err) {
callback(new Error('Unable to establish connection with the master ' +
'process'));
return;
}
self._connection = connection;
callback();
});
} | [
"function",
"(",
"callback",
")",
"{",
"self",
".",
"_getConnection",
"(",
"function",
"(",
"err",
",",
"connection",
")",
"{",
"if",
"(",
"err",
")",
"{",
"callback",
"(",
"new",
"Error",
"(",
"'Unable to establish connection with the master '",
"+",
"'proces... | Obtain the connection | [
"Obtain",
"the",
"connection"
] | 25739d420526bc78881493b335a5174a0fb56e8f | https://github.com/cloudkick/whiskey/blob/25739d420526bc78881493b335a5174a0fb56e8f/lib/common.js#L333-L344 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.