_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q48800 | getStreamStream | train | function getStreamStream (readable, file) {
return () => {
const counter = new stream.Transform()
counter._transform = function (buf, enc, done) {
file.length += buf.length
this.push(buf)
done()
}
readable.pipe(counter)
return counter
}
} | javascript | {
"resource": ""
} |
q48801 | doReconnect | train | function doReconnect() {
//
// Cleanup and recreate the socket associated
// with this instance.
//
self.retry.waiting = true;
self.socket.removeAllListeners();
self.socket = common.createSocket(self._options);
//
// Cleanup reconnect logic once the socket connects
//
self.s... | javascript | {
"resource": ""
} |
q48802 | tryReconnect | train | function tryReconnect() {
self.retry.retries++;
if (self.retry.retries >= self.retry.max) {
return self.emit('error', new Error('Did not reconnect after maximum retries: ' + self.retry.max));
}
doReconnect();
} | javascript | {
"resource": ""
} |
q48803 | assert | train | function assert(expr) {
if (expr) return;
var stack = callsite();
var call = stack[1];
var file = call.getFileName();
var lineno = call.getLineNumber();
var src = fs.readFileSync(file, 'utf8');
var line = src.split('\n')[lineno-1];
var src = line.match(/assert\((.*)\)/)[1];
var err = new AssertionEr... | javascript | {
"resource": ""
} |
q48804 | add | train | function add(x, y) {
var z = [];
var n = Math.max(x.length, y.length);
var carry = 0;
var i = 0;
while (i < n || carry) {
var xi = i < x.length ? x[i] : 0;
var yi = i < y.length ? y[i] : 0;
var zi = carry + xi + yi;
z.push(zi % 10);
carry = Math.floor(zi / 10);
i++;
}
return z;
} | javascript | {
"resource": ""
} |
q48805 | getPluginPath | train | function getPluginPath(rootPath, plugin) {
// Check in project folder
const pluginPath = path.join(rootPath, PROJECT_PLUGIN_FOLDER_NAME, `${plugin}.js`);
if (fs.existsSync(pluginPath)) {
return pluginPath;
}
// Check in src folder
const srcPath = path.join(__dirname, BUILT_IN_PLUGIN_FOLDER_NAME, `${plu... | javascript | {
"resource": ""
} |
q48806 | findDefaultPlugins | train | function findDefaultPlugins() {
const globPath = path.join(__dirname, BUILT_IN_DEFAULT_PLUGIN_FOLDER_NAME);
if (!fs.existsSync(globPath)) {
return [];
}
return walkSync(globPath, {
directories: false,
globs: [`${MARKBIND_PLUGIN_PREFIX}*.js`],
}).map(file => path.parse(file).name);
} | javascript | {
"resource": ""
} |
q48807 | filterTags | train | function filterTags(tags, content) {
if (!tags) {
return content;
}
const $ = cheerio.load(content, { xmlMode: false });
const tagOperations = tags.map(tag => ({
// Trim leading + or -, replace * with .*, add ^ and $
tagExp: `^${escapeRegExp(tag.replace(/^(\+|-)/g, '')).replace(/\\\*/, '.*')}$`,
... | javascript | {
"resource": ""
} |
q48808 | rimraf | train | function rimraf(dirPath) {
if (fs.existsSync(dirPath)) {
fs.readdirSync(dirPath).forEach((entry) => {
const entryPath = path.join(dirPath, entry);
if (fs.lstatSync(entryPath).isDirectory()) {
rimraf(entryPath);
} else {
fs.unlinkSync(entryPath);
}
});
fs.rmdirSync(d... | javascript | {
"resource": ""
} |
q48809 | createDir | train | function createDir(pathArg) {
const { dir, ext } = path.parse(pathArg);
const dirNames = (ext === '')
? pathArg.split(path.sep)
: dir.split(pathArg.sep);
dirNames.reduce((accumDir, currentdir) => {
const jointDir = path.join(accumDir, currentdir);
if (!fs.existsSync(jointDir)) {
fs.mkdirSyn... | javascript | {
"resource": ""
} |
q48810 | copyDirSync | train | function copyDirSync(src, dest) {
if (fs.lstatSync(src).isDirectory()) {
const files = fs.readdirSync(src);
files.forEach((file) => {
const curSource = path.join(src, file);
const curDest = path.join(dest, file);
if (fs.lstatSync(curSource).isDirectory()) {
if (!fs.existsSync(curDest... | javascript | {
"resource": ""
} |
q48811 | copyDirAsync | train | function copyDirAsync(src, dest) {
if (fs.lstatSync(src).isDirectory()) {
const files = fs.readdirSync(src);
files.forEach((file) => {
const curSource = path.join(src, file);
const curDest = path.join(dest, file);
if (fs.lstatSync(curSource).isDirectory()) {
if (!fs.existsSync(curDes... | javascript | {
"resource": ""
} |
q48812 | generateHeadingSelector | train | function generateHeadingSelector(headingIndexingLevel) {
let headingsSelector = 'h1';
for (let i = 2; i <= headingIndexingLevel; i += 1) {
headingsSelector += `, h${i}`;
}
return headingsSelector;
} | javascript | {
"resource": ""
} |
q48813 | Page | train | function Page(pageConfig) {
this.asset = pageConfig.asset;
this.baseUrl = pageConfig.baseUrl;
this.baseUrlMap = pageConfig.baseUrlMap;
this.content = pageConfig.content || '';
this.faviconUrl = pageConfig.faviconUrl;
this.frontmatterOverride = pageConfig.frontmatter || {};
this.layout = pageConfig.layout;... | javascript | {
"resource": ""
} |
q48814 | generateHeadingSelector | train | function generateHeadingSelector(headingIndexingLevel) {
let headingsSelectors = ['.always-index:header', 'h1'];
for (let i = 2; i <= headingIndexingLevel; i += 1) {
headingsSelectors.push(`h${i}`);
}
headingsSelectors = headingsSelectors.map(selector => `${selector}:not(.no-index)`);
return headingsSelec... | javascript | {
"resource": ""
} |
q48815 | getClosestHeading | train | function getClosestHeading($, headingsSelector, element) {
const prevElements = $(element).prevAll();
for (let i = 0; i < prevElements.length; i += 1) {
const currentElement = $(prevElements[i]);
if (currentElement.is(headingsSelector)) {
return currentElement;
}
const childHeadings = currentE... | javascript | {
"resource": ""
} |
q48816 | extractIncludeVariables | train | function extractIncludeVariables(includeElement, contextVariables) {
const includedVariables = { ...contextVariables };
Object.keys(includeElement.attribs).forEach((attribute) => {
if (!attribute.startsWith('var-')) {
return;
}
const variableName = attribute.replace(/^var-/, '');
if (!included... | javascript | {
"resource": ""
} |
q48817 | extractPageVariables | train | function extractPageVariables(fileName, data, userDefinedVariables, includedVariables) {
const $ = cheerio.load(data);
const pageVariables = { };
$('variable').each(function () {
const variableElement = $(this);
const variableName = variableElement.attr('name');
if (!variableName) {
// eslint-di... | javascript | {
"resource": ""
} |
q48818 | extractImportedVariables | train | function extractImportedVariables(context) {
if (!context.importedVariables) {
return {};
}
const importedVariables = {};
Object.entries(context.importedVariables).forEach(([src, variables]) => {
variables.forEach((variableName) => {
const actualFilePath = utils.isUrl()
? src
: pat... | javascript | {
"resource": ""
} |
q48819 | encode | train | function encode(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { string: false, local: false };
var callback = arguments[2];
// eslint-disable-line
if (_lodash2.default.isUndefined(url) || _lodash2.default.isNull(url) || !_lodash2.default.isString(url)) {
return cal... | javascript | {
"resource": ""
} |
q48820 | decode | train | function decode(imageBuffer) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { filename: 'saved-image' };
var callback = arguments[2];
// eslint-disable-line
if (!_lodash2.default.isBuffer(imageBuffer)) {
return callback(new Error('The image is not a Buffer object type'))... | javascript | {
"resource": ""
} |
q48821 | newDirectoryApi | train | function newDirectoryApi(input, opts, cb) {
var fd = new FormData(), files = [];
var iterate = function(entries, path, resolve) {
var promises = [];
entries.forEach(function(entry) {
promises.push(new Promise(function(resolve) {
if ("getFilesAndDirectories" in entry) {
... | javascript | {
"resource": ""
} |
q48822 | arrayApi | train | function arrayApi(input, opts, cb) {
var fd = new FormData(), files = [];
[].slice.call(input.files).forEach(function(file) {
fd.append(opts.name, file, file.webkitRelativePath || file.name);
files.push(file.webkitRelativePath || file.name);
});
cb(fd, files);
} | javascript | {
"resource": ""
} |
q48823 | entriesApi | train | function entriesApi(items, opts, cb) {
var fd = new FormData(), files = [], rootPromises = [];
function readEntries(entry, reader, oldEntries, cb) {
var dirReader = reader || entry.createReader();
dirReader.readEntries(function(entries) {
var newEntries = oldEntries ? oldEntries.concat(entr... | javascript | {
"resource": ""
} |
q48824 | train | function(axis, theta) {
var x, y, z, s, c, t, tx, ty;
x = axis.x;
y = axis.y;
z = axis.z;
s = Math.sin(theta);
c = Math.cos(theta);
t = 1 - c;
tx = t * x;
ty = t * y;
_TEMP.set(
tx * x + c, tx * y + s * z, tx * z - s * y, 0, tx * y - s * z,
... | javascript | {
"resource": ""
} | |
q48825 | train | function(theta) {
_TEMP.identity();
_TEMP.matrix[1][1] = _TEMP.matrix[2][2] = Math.cos(theta);
_TEMP.matrix[2][1] = Math.sin(theta);
_TEMP.matrix[1][2] = -_TEMP.matrix[2][1];
return this.multiplySelf(_TEMP);
} | javascript | {
"resource": ""
} | |
q48826 | train | function(p) {
var v = this.b.sub(this.a);
var t = p.sub(this.a).dot(v) / v.magSquared();
// Check to see if t is beyond the extents of the line segment
if (t < 0.0) {
return this.a.copy();
} else if (t > 1.0) {
return this.b.copy();
}
// Re... | javascript | {
"resource": ""
} | |
q48827 | train | function(obj_or_mesh,threeMaterials){
var toxiTriangleMesh;
if(arguments.length == 1){ //it needs to be an param object
toxiTriangleMesh = obj_or_mesh.geometry;
threeMaterials = obj_or_mesh.materials;
} else {
toxiTriangleMesh = obj_or_... | javascript | {
"resource": ""
} | |
q48828 | train | function(_p){
var v1 = _p.sub(this.a).normalize(),
v2 = _p.sub(this.b).normalize(),
v3 = _p.sub(this.c).normalize(),
totalAngles = Math.acos(v1.dot(v2));
totalAngles += Math.acos(v2.dot(v3));
totalAngles += Math.acos(v3.dot(v1));
return (mathUtils.abs(totalAngles- mathUtils.TWO_PI) <= 0.01);
} | javascript | {
"resource": ""
} | |
q48829 | train | function(list, q){
for(var i=0, l=list.length; i<l; i++){
if( list[i].equalsWitTolerance(q, 0.001) ){
return true;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q48830 | train | function(iterator, shapeID, closed){
//if first param wasnt passed in as a pjs Iterator, make it one
if(iterator.hasNext === undefined || iterator.next === undefined){
iterator = new this.app.ObjectIterator( iterator );
}
this.gfx.beginShape(shapeID);
for(var v = void(0); iterator.hasNext() && ((v = iter... | javascript | {
"resource": ""
} | |
q48831 | train | function(tri,isFullShape){
var isTriangle = function(){
if(tri.a !== undefined && tri.b !== undefined && tri.c !== undefined){
return (tri.a.x !== undefined);
}
return false;
},
isTriangle3D = function(){
if(isTriangle()){
return (tri.a.z !== undefined);
}
return false;
};
if(isFul... | javascript | {
"resource": ""
} | |
q48832 | train | function(a,b) {
if( hasXY( a ) && hasXY( b ) ){
this.x = mathUtils.clip(this.x, a.x, b.x);
this.y = mathUtils.clip(this.y, a.y, b.y);
} else if( isRect( a ) ){
this.x = mathUtils.clip(this.x, a.x, a.x + a.width);
this.y = mathUtils.clip(this.y, a.y, a.y + a.height);
}
return this;
} | javascript | {
"resource": ""
} | |
q48833 | train | function() {
var mag = this.x * this.x + this.y * this.y;
if (mag > 0) {
mag = 1.0 / Math.sqrt(mag);
this.x *= mag;
this.y *= mag;
}
return this;
} | javascript | {
"resource": ""
} | |
q48834 | train | function(theta) {
var co = Math.cos(theta);
var si = Math.sin(theta);
var xx = co * this.x - si * this.y;
this.y = si * this.x + co * this.y;
this.x = xx;
return this;
} | javascript | {
"resource": ""
} | |
q48835 | train | function(box_or_min, max){
var min;
if( is.AABB( box_or_min ) ){
max = box_or_min.getMax();
min = box_or_min.getMin();
} else {
min = box_or_min;
}
this.x = mathUtils.clip(this.x, min.x, max.x);
this.y = mathUtils.clip(this.y, min.y, max.y);
this.z = mathUtils.clip(this.z, min.z, max.z)... | javascript | {
"resource": ""
} | |
q48836 | train | function(vec){
var cx = this.y * vec.z - vec.y * this.z;
var cy = this.z * vec.x - vec.z * this.x;
this.z = this.x * vec.y - vec.x * this.y;
this.y = cy;
this.x = cx;
return this;
} | javascript | {
"resource": ""
} | |
q48837 | train | function(vec_axis,theta){
var ax = vec_axis.x,
ay = vec_axis.y,
az = vec_axis.z,
ux = ax * this.x,
uy = ax * this.y,
uz = ax * this.z,
vx = ay * this.x,
vy = ay * this.y,
vz = ay * this.z,
wx = az * this.x,
wy = az * this.y,
wz = az * this.z,
si = Math.sin(theta),
... | javascript | {
"resource": ""
} | |
q48838 | train | function(theta){
var co = Math.cos(theta);
var si = Math.sin(theta);
var zz = co *this.z - si * this.y;
this.y = si * this.z + co * this.y;
this.z = zz;
return this;
} | javascript | {
"resource": ""
} | |
q48839 | train | function() {
if (Math.abs(this.x) < 0.5) {
this.x = 0;
} else {
this.x = this.x < 0 ? -1 : 1;
this.y = this.z = 0;
}
if (Math.abs(this.y) < 0.5) {
this.y = 0;
} else {
this.y = this.y < 0 ? -1 : 1;
this.x = this.z = 0;
}
if (Math.abs(this.z) < 0.5) {
this.z = 0;
} els... | javascript | {
"resource": ""
} | |
q48840 | train | function( t ){
var idx;
if( this.colors.size() > 2 ){
idx = Math.floor( this.map.getClippedValueFor(t) + 0.5 );
} else {
idx = t >= this.map.getInputMedian() ? 1 : 0;
}
return this.colors.get(idx);
} | javascript | {
"resource": ""
} | |
q48841 | train | function( src, pixels, offset ){
if( typeof offset !== 'number'){
offset = 0;
} else if ( offset < 0 ){
throw new Error("offset into target pixel array is negative");
}
pixels = pixels || new Array(src.length);
for(var i=0, l=sr... | javascript | {
"resource": ""
} | |
q48842 | train | function( list, q ){
for( var i=0, l=list.length; i<l; i++){
if( list[i].equalsWithTolerance(q, 0.0001) ){
return true;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q48843 | train | function(freq){
if(freq === undefined)freq = 0;
this.phase = (this.phase + freq) % AbstractWave.TWO_PI;
if(this.phase < 0){
this.phase += AbstractWave.TWO_PI;
}
return this.phase;
} | javascript | {
"resource": ""
} | |
q48844 | paramThreeToGL | train | function paramThreeToGL ( p ) {
if ( p === THREE.RepeatWrapping ) return _gl.REPEAT;
if ( p === THREE.ClampToEdgeWrapping ) return _gl.CLAMP_TO_EDGE;
if ( p === THREE.MirroredRepeatWrapping ) return _gl.MIRRORED_REPEAT;
if ( p === THREE.NearestFilter ) return _gl.NEAREST;
if ( p === THREE.NearestMipMapNeare... | javascript | {
"resource": ""
} |
q48845 | prepare | train | function prepare( vector ) {
var vertex = vector.normalize().clone();
vertex.index = that.vertices.push( vertex ) - 1;
// Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle.
var u = azimuth( vector ) / 2 / Math.PI + 0.5;
var v = inclination( vector ) / Math.PI ... | javascript | {
"resource": ""
} |
q48846 | visible | train | function visible( face, vertex ) {
var va = vertices[ face[ 0 ] ];
var vb = vertices[ face[ 1 ] ];
var vc = vertices[ face[ 2 ] ];
var n = normal( va, vb, vc );
// distance from face to origin
var dist = n.dot( va );
return n.dot( vertex ) >= dist;
} | javascript | {
"resource": ""
} |
q48847 | train | function() {
var newSel = [];
var vertices = this.mesh.getVertices();
var l = vertices.length;
for (var i=0;i<l;i++) {
var v = vertices[i];
if (this.selection.indexOf(v) < 0 ) {
newSel.push(v);
}
}
this.selection = newSel;
... | javascript | {
"resource": ""
} | |
q48848 | train | function(points) {
var l = points.length;
for (var i=0;i<l;i++) {
var v = points[i];
this.selection.push( this.mesh.getClosestVertexToPoint(v) );
}
return this;
} | javascript | {
"resource": ""
} | |
q48849 | train | function(sel2) {
this.checkMeshIdentity(sel2.getMesh());
var removeThese = sel2.getSelection();
var i,l = removeThese.length;
for ( i=0; i<l; i++ ) {
this.selection.splice( this.selection.indexOf(removeThese[i]), 1 );
}
return this;
} | javascript | {
"resource": ""
} | |
q48850 | train | function( rc ){
if( is.ColorRange(rc) ){
addAll(this.hueConstraint, rc.hueConstraint);
addAll(this.saturationConstraint, rc.saturationConstraint);
addAll(this.brightnessConstraint, rc.brightnessConstraint);
addAll(this.alphaConstraint, rc.alpha... | javascript | {
"resource": ""
} | |
q48851 | train | function( c ){
var isInRange = this.isValueInConstraint(c.hue(), this.hueConstraint);
isInRange &= this.isValueInConstraint(c.saturation(), this.saturationConstraint);
isInRange &= this.isValueInConstraint(c.brightness(), this.brightnessConstraint);
isInRange &= this.isVa... | javascript | {
"resource": ""
} | |
q48852 | train | function( c, num, variance ){
if( arguments.length < 3 ){
variance = ColorRange.DEFAULT_VARIANCE;
}
if( arguments.length === 1 ){
num = c;
c = undefined;
}
var list = new ColorList();
for( var i=0; i<... | javascript | {
"resource": ""
} | |
q48853 | train | function(min, max){
min = min || 0.0;
max = typeof max === 'number' ? max : 1.0;
// swap if necessary
if(min > max){
var t= max;
max = min;
min = t;
}
this.min = min;
this.max = max;
this.currValue = min;
} | javascript | {
"resource": ""
} | |
q48854 | train | function(a,b,c,n,uvA,uvB,uvC){
//can be 3 args, 4 args, 6 args, or 7 args
//if it was 6 swap vars around,
if( arguments.length == 6 ){
uvC = uvB;
uvB = uvA;
uvA = n;
n = undefined;
}
//7 param method
var va = this.__checkVertex(a);
var vb = this.__checkVertex(b);
var ... | javascript | {
"resource": ""
} | |
q48855 | train | function(m){
var l = m.getFaces().length;
for(var i=0;i<l;i++){
var f = m.getFaces()[i];
this.addFace(f.a,f.b,f.c);
}
return this;
} | javascript | {
"resource": ""
} | |
q48856 | train | function(array) {
array = array || [];
var i = 0;
var l = this.vertices.length;
for (var j=0;j<l;j++) {
var v = this.vertices[j];
array[i++] = v.x;
array[i++] = v.y;
array[i++] = v.z;
}
return array;
} | javascript | {
"resource": ""
} | |
q48857 | train | function(array){
array = array || [];
var n = 0;
for(i=0; i<this.vertices.length; i++){
var v = this.vertices[i];
array[n++] = v.normal.x;
array[n++] = v.normal.y;
array[n++] = v.normal.z;
... | javascript | {
"resource": ""
} | |
q48858 | train | function(array){
array = array || [];
var i = 0;
for(f=0; f<this.faces.length; f++){
var face = this.faces[f];
array[i++] = face.uvA ? face.uvA.x : 0;
array[i++] = face.uvA ? face.uvA.y : 0;
a... | javascript | {
"resource": ""
} | |
q48859 | train | function(vec) {
var matchedVertex = -1;
var l = this.vertices.length;
for(var i=0;i<l;i++)
{
var vert = this.vertices[i];
if(vert.equals(vec))
{
matchedVertex =i;
}
}
return matchedVertex;
} | javascript | {
"resource": ""
} | |
q48860 | train | function(dir, forward) {
forward = forward || Vec3D.Z_AXIS;
return this.transform( Quaternion.getAlignmentQuat(dir, forward).toMatrix4x4(this.matrix), true);
} | javascript | {
"resource": ""
} | |
q48861 | train | function(mat,updateNormals) {
if(updateNormals === undefined){
updateNormals = true;
}
var l = this.vertices.length;
for(var i=0;i<l;i++){
var v = this.vertices[i];
v.set(mat.applyTo(v));
}
if(updateNormals){
this.computeFaceNormals();
}
return this;
} | javascript | {
"resource": ""
} | |
q48862 | train | function(elevation){
if(this.__elevationLength == elevation.length){
for(var i = 0, len = elevation.length; i<len; i++){
this.vertices[i].y = this.elevation[i] = elevation[i];
}
} else {
throw new Error("the given elevation array size does not match terrain");
}
return this;
} | javascript | {
"resource": ""
} | |
q48863 | train | function(x,z,h){
var index = this._getIndex(x,z);
this.elevation[index] = h;
this.vertices[index].y = h;
return this;
} | javascript | {
"resource": ""
} | |
q48864 | train | function( theta, contrast ){
this.contrast = typeof contrast === 'number' ? contrast : 0.25;
this.theta = MathUtils.radians( typeof theta === 'number' ? theta : 10 );
} | javascript | {
"resource": ""
} | |
q48865 | train | function(a,b,c) {
var opts = {
mesh: undefined,
steps: 12,
thetaOffset: 0
};
if(arguments.length == 1 && typeof arguments[0] == 'object'){ //options object
for(var prop in arguments[0]){
opts[prop] = arguments[0][prop];
}
} else if(arguments.length == 2){
opts.steps = arguments[0];
opts... | javascript | {
"resource": ""
} | |
q48866 | train | function(theta) {
while (theta < 0) {
theta += mathUtils.TWO_PI;
}
return this.sinLUT[((theta * this.rad2deg) + this.quadrant) % this.period];
} | javascript | {
"resource": ""
} | |
q48867 | train | function( x, y, z ){
if( hasXYZ( x ) ){
//it was 1 param, it was a vector or object
this.vertices.push( new Vec3D(x) );
} else {
this.vertices.push( new Vec3D(x,y,z) );
}
return this;
} | javascript | {
"resource": ""
} | |
q48868 | train | function( step, doAddFinalVertex ){
if( doAddFinalVertex !== false ){
doAddFinalVertex = true;
}
var uniform = [];
if( this.vertices.length < 3 ){
if( this.vertices.length === 2 ){
new Line3D( this.vertices[0], this.vertices[1])
.splitIntoSegments( uniform, step, true );
if( !doAddFi... | javascript | {
"resource": ""
} | |
q48869 | train | function(p,phi,theta) {
var r = 0;
r += Math.pow(mathUtils.sin(this.m[0] * theta), this.m[1]);
r += Math.pow(mathUtils.cos(this.m[2] * theta), this.m[3]);
r += Math.pow(mathUtils.sin(this.m[4] * phi), this.m[5]);
r += Math.pow(mathUtils.cos(this.m[6] * phi), this.m[7]);
... | javascript | {
"resource": ""
} | |
q48870 | train | function(h, s, v) {
return this.setHSV([ this.hsv[0] + h, this.hsv[1] + s, this.hsv[2] + v ]);
} | javascript | {
"resource": ""
} | |
q48871 | train | function(r, g,b) {
return this.setRGB([this.rgb[0] + r, this.rgb[1] + g, this.rgb[2] + b]);
} | javascript | {
"resource": ""
} | |
q48872 | train | function(c, t) {
if(t === undefined) { t = 0.5; }
var crgb = c.toRGBAArray();
this.rgb[0] += (crgb[0] - this.rgb[0]) * t;
this.rgb[1] += (crgb[1] - this.rgb[1]) * t;
this.rgb[2] += (crgb[2] - this.rgb[2]) * t;
this._alpha += (c._alpha - this._alpha) * t;
return this.setRGB(this.rgb);
} | javascript | {
"resource": ""
} | |
q48873 | train | function(rgba, offset) {
rgba = rgba || [];
offset = offset || 0;
rgba[offset++] = this.rgb[0];
rgba[offset++] = this.rgb[1];
rgba[offset++] = this.rgb[2];
rgba[offset] = this._alpha;
return rgba;
} | javascript | {
"resource": ""
} | |
q48874 | train | function(color){
for( var i=0, l= this.colors.length; i<l; i++){
if( this.colors[i].equals( color ) ){
return true;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q48875 | train | function(){
var r = 0,
g = 0,
b = 0,
a = 0;
this.each(function(c){
r += c.rgb[0];
g += c.rgb[1];
b += c.rgb[2];
a += c.alpha();
});
var num = this.colors.length;
if(num > 0){
return TColor.newRGBA(r / num, g / num, b / num, a / num);
}
return undefined;
} | javascript | {
"resource": ""
} | |
q48876 | train | function(){
var darkest,
minBrightness = Number.MAX_VALUE;
this.each(function(c){
var luma = c.luminance();
if(luma < minBrightness){
darkest = c;
minBrightness = luma;
}
});
return darkest;
} | javascript | {
"resource": ""
} | |
q48877 | train | function(comp, isReversed){
//if a normal ( a, b ) sort function instead of an AccessCriteria,
//wrap it so it can be invoked the same
if( typeof comp === 'function' && typeof comp.compare === 'undefined' ){
comp = { compare: comp };
}
this.colors.sort( comp.compare );
if... | javascript | {
"resource": ""
} | |
q48878 | train | function(proxy, isReversed){
if(arguments.length === 1){
isReversed = arguments[0];
proxy = new HSVDistanceProxy();
}
if(this.colors.length === 0){
return this;
}
// Remove the darkest color from the stack,
// put it in the sorted list as starting element.
var root = this.getDarkest(),
stack... | javascript | {
"resource": ""
} | |
q48879 | train | function(g, x, y, z, w) {
var n = g[0] * x + g[1] * y;
if(z){
n += g[2] * z;
if(w){
n += g[3] * w;
}
}
return n;
} | javascript | {
"resource": ""
} | |
q48880 | make | train | function make( type, setters ){
var name = type + 'Accessor', arry = type.toLowerCase(); //make HSV hsv etc
exports[name] = function( comp ){
this.component = comp;
//compare() could easily be used in incorrect scope, bind it
this.compare = bind( this.compare, this );
};
exports[name].prototype.compar... | javascript | {
"resource": ""
} |
q48881 | train | function(theta_p,theta){
if(arguments.length > 1){
this.theta = theta;
this.rootPos = new Vec2D(theta_p);
} else {
this.rootPos = new Vec2D();
this.theta = theta_p;
}
//due to lack-of int/float types, no support of theta in degrees
} | javascript | {
"resource": ""
} | |
q48882 | train | function( origin ){
var centroid = this.getCentroid();
var delta = origin !== undefined ? origin.sub( centroid ) : centroid.invert();
for( var i=0, l = this.vertices.length; i<l; i++){
this.vertices[i].addSelf( delta );
}
return this;
} | javascript | {
"resource": ""
} | |
q48883 | train | function( count ){
var num = this.vertices.length,
longestID = 0,
maxD = 0,
i = 0,
d,
m;
while( num < count ){
//find longest edge
longestID = 0;
maxD = 0;
... | javascript | {
"resource": ""
} | |
q48884 | train | function(){
var isPositive = false,
num = this.vertices.length,
prev,
next,
d0,
d1,
newIsP;
for( var i = 0; i < num; i++ ){
prev = (i===0) ? num -1 : i - 1;
next = (i=... | javascript | {
"resource": ""
} | |
q48885 | train | function( x1, y1, x2, y2, x3, y3, distance, out ){
var c1 = x2,
d1 = y2,
c2 = x2,
d2 = y2;
var dx1,
dy1,
dist1,
dx2,
dy2,
dist2,
insetX,
... | javascript | {
"resource": ""
} | |
q48886 | train | function( minEdgeLen ){
minEdgeLen *= minEdgeLen;
var vs = this.vertices,
reduced = [],
prev = vs[0],
num = vs.length - 1,
vec;
reduced.push(prev);
for( var i = 0; i < num; i++ ){
vec = vs[i];... | javascript | {
"resource": ""
} | |
q48887 | train | function( tolerance ){
//if tolerance is 0, it will be faster to just use 'equals' method
var equals = tolerance ? 'equalsWithTolerance' : 'equals';
var p, prev, i = 0, num = this.vertices.length;
var last;
for( ; i<num; i++ ){
p = this.vertice... | javascript | {
"resource": ""
} | |
q48888 | train | function(val) {
var t = ((val - this._in.min) / this._interval);
return this.mapFunction.interpolate(0, this.mapRange, t) + this._out.min;
} | javascript | {
"resource": ""
} | |
q48889 | onPlayChange | train | function onPlayChange() {
if (paused !== media.paused) {
paused = media.paused;
$(self.play, { 'aria-label': paused ? lang.play || 'play' : lang.pause || 'pause' });
$(self.playSymbol, { 'aria-hidden': !paused });
$(self.pauseSymbol, { 'aria-hidden': paused });
clearInterval(interval);
if (!pause... | javascript | {
"resource": ""
} |
q48890 | onTimeChange | train | function onTimeChange() {
if (currentTime !== media.currentTime || duration !== media.duration) {
currentTime = media.currentTime;
duration = media.duration || 0;
const currentTimePercentage = currentTime / duration;
const currentTimeCode = timeToTimecode(currentTime);
const remainingTimeCode = timeTo... | javascript | {
"resource": ""
} |
q48891 | onLoadStart | train | function onLoadStart() {
media.removeEventListener('canplaythrough', onCanPlayStart);
$(media, { canplaythrough: onCanPlayStart });
$(self.download, { href: media.src, download: media.src });
onPlayChange();
onVolumeChange();
onFullscreenChange();
onTimeChange();
} | javascript | {
"resource": ""
} |
q48892 | onCanPlayStart | train | function onCanPlayStart() {
media.removeEventListener('canplaythrough', onCanPlayStart);
// dispatch new "canplaystart" event
dispatchCustomEvent(media, 'canplaystart');
if (!paused || media.autoplay) {
media.play();
}
} | javascript | {
"resource": ""
} |
q48893 | onVolumeChange | train | function onVolumeChange() {
const volumePercentage = media.muted ? 0 : media.volume;
const isMuted = !volumePercentage;
$(self.volume, { 'aria-valuenow': volumePercentage, 'aria-valuemin': 0, 'aria-valuemax': 1 });
const dirIsInline = /^(ltr|rtl)$/i.test(volumeDir);
const axisProp = dirIsInline ? 'width' : ... | javascript | {
"resource": ""
} |
q48894 | onDownloadClick | train | function onDownloadClick() {
const a = document.head.appendChild($('a', { download: '', href: media.src }));
a.click();
document.head.removeChild(a);
} | javascript | {
"resource": ""
} |
q48895 | onFullscreenClick | train | function onFullscreenClick() {
if (requestFullscreen) {
if (player === fullscreenElement()) {
// exit fullscreen
exitFullscreen().call(document);
} else {
// enter fullscreen
requestFullscreen.call(player);
// maintain focus in internet explorer
self.fullscreen.focus();
// maintain... | javascript | {
"resource": ""
} |
q48896 | onTimeKeydown | train | function onTimeKeydown(event) {
const { keyCode, shiftKey } = event;
// 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN
if (37 <= keyCode && 40 >= keyCode) {
event.preventDefault();
const isLTR = /^(btt|ltr)$/.test(timeDir);
const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : keyCode - 39;
media... | javascript | {
"resource": ""
} |
q48897 | onVolumeKeydown | train | function onVolumeKeydown(event) {
const { keyCode, shiftKey } = event;
// 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN
if (37 <= keyCode && 40 >= keyCode) {
event.preventDefault();
const isLTR = /^(btt|ltr)$/.test(volumeDir);
const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : isLTR ? 39 - keyCod... | javascript | {
"resource": ""
} |
q48898 | createBindingsTag | train | function createBindingsTag(sourceNode, bindingsSelector) {
if (!bindingsSelector) return sourceNode
return {
...sourceNode,
// inject the selector bindings into the node attributes
attributes: [{
name: bindingsSelector
}, ...getNodeAttributes(sourceNode)]
}
} | javascript | {
"resource": ""
} |
q48899 | createTagWithBindings | train | function createTagWithBindings(sourceNode, sourceFile, sourceCode) {
const bindingsSelector = isRootNode(sourceNode) ? null : createBindingSelector()
const cloneNode = createBindingsTag(sourceNode, bindingsSelector)
const tagOpeningHTML = nodeToString(cloneNode)
switch(true) {
// EACH bindings have prio 1
... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.