id
int32 0
58k
| repo
stringlengths 5
67
| path
stringlengths 4
116
| func_name
stringlengths 0
58
| original_string
stringlengths 52
373k
| language
stringclasses 1
value | code
stringlengths 52
373k
| code_tokens
list | docstring
stringlengths 4
11.8k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 86
226
|
---|---|---|---|---|---|---|---|---|---|---|---|
45,900 | tdreyno/morlock.js | core/stream.js | attach_ | function attach_() {
var i = 0;
var intervalId = setInterval(function() {
if (outputStream.closed) {
clearInterval(intervalId);
} else {
boundEmit(i++);
}
}, ms);
} | javascript | function attach_() {
var i = 0;
var intervalId = setInterval(function() {
if (outputStream.closed) {
clearInterval(intervalId);
} else {
boundEmit(i++);
}
}, ms);
} | [
"function",
"attach_",
"(",
")",
"{",
"var",
"i",
"=",
"0",
";",
"var",
"intervalId",
"=",
"setInterval",
"(",
"function",
"(",
")",
"{",
"if",
"(",
"outputStream",
".",
"closed",
")",
"{",
"clearInterval",
"(",
"intervalId",
")",
";",
"}",
"else",
"{",
"boundEmit",
"(",
"i",
"++",
")",
";",
"}",
"}",
",",
"ms",
")",
";",
"}"
]
| Lazily subscribes to a timeout event. | [
"Lazily",
"subscribes",
"to",
"a",
"timeout",
"event",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/stream.js#L160-L169 |
45,901 | tdreyno/morlock.js | controllers/scroll-controller.js | ScrollController | function ScrollController(options) {
if (!(this instanceof ScrollController)) {
return new ScrollController(options);
}
Emitter.mixin(this);
options = options || {};
var scrollStream = ScrollStream.create({
scrollTarget: options.scrollTarget
});
Stream.onValue(scrollStream, Util.partial(this.trigger, 'scroll'));
var scrollEndStream = Stream.debounce(
Util.getOption(options.debounceMs, 200),
scrollStream
);
Stream.onValue(scrollEndStream, Util.partial(this.trigger, 'scrollEnd'));
} | javascript | function ScrollController(options) {
if (!(this instanceof ScrollController)) {
return new ScrollController(options);
}
Emitter.mixin(this);
options = options || {};
var scrollStream = ScrollStream.create({
scrollTarget: options.scrollTarget
});
Stream.onValue(scrollStream, Util.partial(this.trigger, 'scroll'));
var scrollEndStream = Stream.debounce(
Util.getOption(options.debounceMs, 200),
scrollStream
);
Stream.onValue(scrollEndStream, Util.partial(this.trigger, 'scrollEnd'));
} | [
"function",
"ScrollController",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ScrollController",
")",
")",
"{",
"return",
"new",
"ScrollController",
"(",
"options",
")",
";",
"}",
"Emitter",
".",
"mixin",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"scrollStream",
"=",
"ScrollStream",
".",
"create",
"(",
"{",
"scrollTarget",
":",
"options",
".",
"scrollTarget",
"}",
")",
";",
"Stream",
".",
"onValue",
"(",
"scrollStream",
",",
"Util",
".",
"partial",
"(",
"this",
".",
"trigger",
",",
"'scroll'",
")",
")",
";",
"var",
"scrollEndStream",
"=",
"Stream",
".",
"debounce",
"(",
"Util",
".",
"getOption",
"(",
"options",
".",
"debounceMs",
",",
"200",
")",
",",
"scrollStream",
")",
";",
"Stream",
".",
"onValue",
"(",
"scrollEndStream",
",",
"Util",
".",
"partial",
"(",
"this",
".",
"trigger",
",",
"'scrollEnd'",
")",
")",
";",
"}"
]
| Provides a familiar OO-style API for tracking scroll events.
@constructor
@param {Object=} options The options passed to the scroll tracker.
@return {Object} The API with a `on` function to attach scrollEnd
callbacks and an `observeElement` function to detect when elements
enter and exist the viewport. | [
"Provides",
"a",
"familiar",
"OO",
"-",
"style",
"API",
"for",
"tracking",
"scroll",
"events",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/controllers/scroll-controller.js#L14-L34 |
45,902 | gwicke/node-web-streams | lib/conversions.js | arrayToWeb | function arrayToWeb(arr) {
return new ReadableStream({
start(controller) {
for (var i = 0; i < arr.length; i++) {
controller.enqueue(arr[i]);
}
controller.close();
}
});
} | javascript | function arrayToWeb(arr) {
return new ReadableStream({
start(controller) {
for (var i = 0; i < arr.length; i++) {
controller.enqueue(arr[i]);
}
controller.close();
}
});
} | [
"function",
"arrayToWeb",
"(",
"arr",
")",
"{",
"return",
"new",
"ReadableStream",
"(",
"{",
"start",
"(",
"controller",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"controller",
".",
"enqueue",
"(",
"arr",
"[",
"i",
"]",
")",
";",
"}",
"controller",
".",
"close",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
]
| ReadableStream wrapping an array.
@param {Array} arr, the array to wrap into a stream.
@return {ReadableStream} | [
"ReadableStream",
"wrapping",
"an",
"array",
"."
]
| 5af50c2e91502d577178d7bd85f9e8b7408ea6e7 | https://github.com/gwicke/node-web-streams/blob/5af50c2e91502d577178d7bd85f9e8b7408ea6e7/lib/conversions.js#L36-L45 |
45,903 | scripting/opml | daveopml.js | copyone | function copyone (name) {
if (metadata !== undefined) { //3/11/18 by DW
var val = metadata [name];
if ((val !== undefined) && (val != null)) {
theOutline [name] = val;
}
}
} | javascript | function copyone (name) {
if (metadata !== undefined) { //3/11/18 by DW
var val = metadata [name];
if ((val !== undefined) && (val != null)) {
theOutline [name] = val;
}
}
} | [
"function",
"copyone",
"(",
"name",
")",
"{",
"if",
"(",
"metadata",
"!==",
"undefined",
")",
"{",
"//3/11/18 by DW",
"var",
"val",
"=",
"metadata",
"[",
"name",
"]",
";",
"if",
"(",
"(",
"val",
"!==",
"undefined",
")",
"&&",
"(",
"val",
"!=",
"null",
")",
")",
"{",
"theOutline",
"[",
"name",
"]",
"=",
"val",
";",
"}",
"}",
"}"
]
| copy elements of the metadata object into the root of the outline | [
"copy",
"elements",
"of",
"the",
"metadata",
"object",
"into",
"the",
"root",
"of",
"the",
"outline"
]
| 1c2b9ca804c48cd9d3be39ac1752663564e979e2 | https://github.com/scripting/opml/blob/1c2b9ca804c48cd9d3be39ac1752663564e979e2/daveopml.js#L253-L260 |
45,904 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/CanvasContext.js | function(image, position, options) {
this._drawOnCanvasContext(options, function(g) {
this._setImageStyles(g, options);
g.drawImage(image, position[0], position[1]);
return true;
});
} | javascript | function(image, position, options) {
this._drawOnCanvasContext(options, function(g) {
this._setImageStyles(g, options);
g.drawImage(image, position[0], position[1]);
return true;
});
} | [
"function",
"(",
"image",
",",
"position",
",",
"options",
")",
"{",
"this",
".",
"_drawOnCanvasContext",
"(",
"options",
",",
"function",
"(",
"g",
")",
"{",
"this",
".",
"_setImageStyles",
"(",
"g",
",",
"options",
")",
";",
"g",
".",
"drawImage",
"(",
"image",
",",
"position",
"[",
"0",
"]",
",",
"position",
"[",
"1",
"]",
")",
";",
"return",
"true",
";",
"}",
")",
";",
"}"
]
| Copies an image to the main canvas.
@param image
the image to copy; it could be an Image or Canvas
@param position
position of the image on the main canvas
@param options
options object containing "data" field to associate with the
image | [
"Copies",
"an",
"image",
"to",
"the",
"main",
"canvas",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/CanvasContext.js#L65-L71 |
|
45,905 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/CanvasContext.js | function(polygon, options) {
// Create new canvas where the polygon should be drawn
this._drawOnCanvasContext(options, function(g) {
options = options || {};
g.beginPath();
for (var i = 0; i < polygon.length; i++) {
var ring = this._simplify(polygon[i]);
if (ring && ring.length) {
var clockwise = (i === 0);
if (GeometryUtils.isClockwise(ring) !== !!clockwise) {
ring.reverse();
}
}
this._trace(g, ring);
}
g.closePath();
this._setFillStyles(g, options);
g.fill();
this._setStrokeStyles(g, options);
g.stroke();
return true;
});
} | javascript | function(polygon, options) {
// Create new canvas where the polygon should be drawn
this._drawOnCanvasContext(options, function(g) {
options = options || {};
g.beginPath();
for (var i = 0; i < polygon.length; i++) {
var ring = this._simplify(polygon[i]);
if (ring && ring.length) {
var clockwise = (i === 0);
if (GeometryUtils.isClockwise(ring) !== !!clockwise) {
ring.reverse();
}
}
this._trace(g, ring);
}
g.closePath();
this._setFillStyles(g, options);
g.fill();
this._setStrokeStyles(g, options);
g.stroke();
return true;
});
} | [
"function",
"(",
"polygon",
",",
"options",
")",
"{",
"// Create new canvas where the polygon should be drawn",
"this",
".",
"_drawOnCanvasContext",
"(",
"options",
",",
"function",
"(",
"g",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"g",
".",
"beginPath",
"(",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"polygon",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"ring",
"=",
"this",
".",
"_simplify",
"(",
"polygon",
"[",
"i",
"]",
")",
";",
"if",
"(",
"ring",
"&&",
"ring",
".",
"length",
")",
"{",
"var",
"clockwise",
"=",
"(",
"i",
"===",
"0",
")",
";",
"if",
"(",
"GeometryUtils",
".",
"isClockwise",
"(",
"ring",
")",
"!==",
"!",
"!",
"clockwise",
")",
"{",
"ring",
".",
"reverse",
"(",
")",
";",
"}",
"}",
"this",
".",
"_trace",
"(",
"g",
",",
"ring",
")",
";",
"}",
"g",
".",
"closePath",
"(",
")",
";",
"this",
".",
"_setFillStyles",
"(",
"g",
",",
"options",
")",
";",
"g",
".",
"fill",
"(",
")",
";",
"this",
".",
"_setStrokeStyles",
"(",
"g",
",",
"options",
")",
";",
"g",
".",
"stroke",
"(",
")",
";",
"return",
"true",
";",
"}",
")",
";",
"}"
]
| Draws polygons with holes on the canvas. | [
"Draws",
"polygons",
"with",
"holes",
"on",
"the",
"canvas",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/CanvasContext.js#L95-L117 |
|
45,906 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/CanvasContext.js | function(coords) {
var tolerance = this.options.tolerance || 0.8;
var enableHighQuality = !!this.options.highQuality;
var points = GeometryUtils.simplify(coords, tolerance,
enableHighQuality);
return points;
} | javascript | function(coords) {
var tolerance = this.options.tolerance || 0.8;
var enableHighQuality = !!this.options.highQuality;
var points = GeometryUtils.simplify(coords, tolerance,
enableHighQuality);
return points;
} | [
"function",
"(",
"coords",
")",
"{",
"var",
"tolerance",
"=",
"this",
".",
"options",
".",
"tolerance",
"||",
"0.8",
";",
"var",
"enableHighQuality",
"=",
"!",
"!",
"this",
".",
"options",
".",
"highQuality",
";",
"var",
"points",
"=",
"GeometryUtils",
".",
"simplify",
"(",
"coords",
",",
"tolerance",
",",
"enableHighQuality",
")",
";",
"return",
"points",
";",
"}"
]
| Simplifies the given line. | [
"Simplifies",
"the",
"given",
"line",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/CanvasContext.js#L140-L146 |
|
45,907 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/CanvasContext.js | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
g.fillStyle = options.fillColor || options.color;
if (options.fillImage) {
g.fillStyle = g.createPattern(options.fillImage, "repeat");
}
g.globalAlpha = options.fillOpacity || options.opacity || 0;
} | javascript | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
g.fillStyle = options.fillColor || options.color;
if (options.fillImage) {
g.fillStyle = g.createPattern(options.fillImage, "repeat");
}
g.globalAlpha = options.fillOpacity || options.opacity || 0;
} | [
"function",
"(",
"g",
",",
"options",
")",
"{",
"var",
"compositeOperation",
"=",
"options",
".",
"compositeOperation",
"||",
"options",
".",
"composition",
"||",
"'source-over'",
";",
"g",
".",
"globalCompositeOperation",
"=",
"compositeOperation",
";",
"// ",
"g",
".",
"fillStyle",
"=",
"options",
".",
"fillColor",
"||",
"options",
".",
"color",
";",
"if",
"(",
"options",
".",
"fillImage",
")",
"{",
"g",
".",
"fillStyle",
"=",
"g",
".",
"createPattern",
"(",
"options",
".",
"fillImage",
",",
"\"repeat\"",
")",
";",
"}",
"g",
".",
"globalAlpha",
"=",
"options",
".",
"fillOpacity",
"||",
"options",
".",
"opacity",
"||",
"0",
";",
"}"
]
| Copies fill styles from the specified style object to the canvas context. | [
"Copies",
"fill",
"styles",
"from",
"the",
"specified",
"style",
"object",
"to",
"the",
"canvas",
"context",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/CanvasContext.js#L158-L167 |
|
45,908 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/CanvasContext.js | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
g.globalAlpha = options.stokeOpacity || options.lineOpacity
|| options.opacity || 0;
g.strokeStyle = options.lineColor || options.color;
g.lineWidth = options.lineWidth || options.width || 0;
g.lineCap = options.lineCap || 'round'; // 'butt|round|square'
g.lineJoin = options.lineJoin || 'round'; // 'miter|round|bevel'
} | javascript | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
g.globalAlpha = options.stokeOpacity || options.lineOpacity
|| options.opacity || 0;
g.strokeStyle = options.lineColor || options.color;
g.lineWidth = options.lineWidth || options.width || 0;
g.lineCap = options.lineCap || 'round'; // 'butt|round|square'
g.lineJoin = options.lineJoin || 'round'; // 'miter|round|bevel'
} | [
"function",
"(",
"g",
",",
"options",
")",
"{",
"var",
"compositeOperation",
"=",
"options",
".",
"compositeOperation",
"||",
"options",
".",
"composition",
"||",
"'source-over'",
";",
"g",
".",
"globalCompositeOperation",
"=",
"compositeOperation",
";",
"// ",
"g",
".",
"globalAlpha",
"=",
"options",
".",
"stokeOpacity",
"||",
"options",
".",
"lineOpacity",
"||",
"options",
".",
"opacity",
"||",
"0",
";",
"g",
".",
"strokeStyle",
"=",
"options",
".",
"lineColor",
"||",
"options",
".",
"color",
";",
"g",
".",
"lineWidth",
"=",
"options",
".",
"lineWidth",
"||",
"options",
".",
"width",
"||",
"0",
";",
"g",
".",
"lineCap",
"=",
"options",
".",
"lineCap",
"||",
"'round'",
";",
"// 'butt|round|square'",
"g",
".",
"lineJoin",
"=",
"options",
".",
"lineJoin",
"||",
"'round'",
";",
"// 'miter|round|bevel'",
"}"
]
| Copies stroke styles from the specified style object to the canvas
context. | [
"Copies",
"stroke",
"styles",
"from",
"the",
"specified",
"style",
"object",
"to",
"the",
"canvas",
"context",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/CanvasContext.js#L173-L183 |
|
45,909 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/CanvasContext.js | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
} | javascript | function(g, options) {
var compositeOperation = options.compositeOperation
|| options.composition || 'source-over';
g.globalCompositeOperation = compositeOperation;//
} | [
"function",
"(",
"g",
",",
"options",
")",
"{",
"var",
"compositeOperation",
"=",
"options",
".",
"compositeOperation",
"||",
"options",
".",
"composition",
"||",
"'source-over'",
";",
"g",
".",
"globalCompositeOperation",
"=",
"compositeOperation",
";",
"//",
"}"
]
| Copies image styles from the specified style object to the canvas
context. | [
"Copies",
"image",
"styles",
"from",
"the",
"specified",
"style",
"object",
"to",
"the",
"canvas",
"context",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/CanvasContext.js#L189-L193 |
|
45,910 | tdreyno/morlock.js | controllers/element-visible-controller.js | ElementVisibleController | function ElementVisibleController(elem, options) {
if (!(this instanceof ElementVisibleController)) {
return new ElementVisibleController(elem, options);
}
Emitter.mixin(this);
options = options || {};
this.elem = elem;
this.buffer = Util.getOption(options.buffer, 0);
this.isVisible = false;
this.rect = null;
this.scrollTarget = options.scrollTarget;
// Auto trigger if the last value on the stream is what we're looking for.
var oldOn = this.on;
this.on = function wrappedOn(eventName, callback, scope) {
oldOn.apply(this, arguments);
if (('enter' === eventName) && this.isVisible) {
scope ? callback.call(scope) : callback();
}
};
var sc = new ScrollController({
scrollTarget: this.scrollTarget
});
sc.on('scroll', this.didScroll, this);
sc.on('scrollEnd', this.recalculatePosition, this);
Stream.onValue(ResizeStream.create(), Util.functionBind(this.didResize, this));
this.viewportRect = {
height: window.innerHeight,
top: 0
};
this.recalculateOffsets();
setTimeout(Util.functionBind(this.recalculateOffsets, this), 100);
} | javascript | function ElementVisibleController(elem, options) {
if (!(this instanceof ElementVisibleController)) {
return new ElementVisibleController(elem, options);
}
Emitter.mixin(this);
options = options || {};
this.elem = elem;
this.buffer = Util.getOption(options.buffer, 0);
this.isVisible = false;
this.rect = null;
this.scrollTarget = options.scrollTarget;
// Auto trigger if the last value on the stream is what we're looking for.
var oldOn = this.on;
this.on = function wrappedOn(eventName, callback, scope) {
oldOn.apply(this, arguments);
if (('enter' === eventName) && this.isVisible) {
scope ? callback.call(scope) : callback();
}
};
var sc = new ScrollController({
scrollTarget: this.scrollTarget
});
sc.on('scroll', this.didScroll, this);
sc.on('scrollEnd', this.recalculatePosition, this);
Stream.onValue(ResizeStream.create(), Util.functionBind(this.didResize, this));
this.viewportRect = {
height: window.innerHeight,
top: 0
};
this.recalculateOffsets();
setTimeout(Util.functionBind(this.recalculateOffsets, this), 100);
} | [
"function",
"ElementVisibleController",
"(",
"elem",
",",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ElementVisibleController",
")",
")",
"{",
"return",
"new",
"ElementVisibleController",
"(",
"elem",
",",
"options",
")",
";",
"}",
"Emitter",
".",
"mixin",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"this",
".",
"elem",
"=",
"elem",
";",
"this",
".",
"buffer",
"=",
"Util",
".",
"getOption",
"(",
"options",
".",
"buffer",
",",
"0",
")",
";",
"this",
".",
"isVisible",
"=",
"false",
";",
"this",
".",
"rect",
"=",
"null",
";",
"this",
".",
"scrollTarget",
"=",
"options",
".",
"scrollTarget",
";",
"// Auto trigger if the last value on the stream is what we're looking for.",
"var",
"oldOn",
"=",
"this",
".",
"on",
";",
"this",
".",
"on",
"=",
"function",
"wrappedOn",
"(",
"eventName",
",",
"callback",
",",
"scope",
")",
"{",
"oldOn",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
";",
"if",
"(",
"(",
"'enter'",
"===",
"eventName",
")",
"&&",
"this",
".",
"isVisible",
")",
"{",
"scope",
"?",
"callback",
".",
"call",
"(",
"scope",
")",
":",
"callback",
"(",
")",
";",
"}",
"}",
";",
"var",
"sc",
"=",
"new",
"ScrollController",
"(",
"{",
"scrollTarget",
":",
"this",
".",
"scrollTarget",
"}",
")",
";",
"sc",
".",
"on",
"(",
"'scroll'",
",",
"this",
".",
"didScroll",
",",
"this",
")",
";",
"sc",
".",
"on",
"(",
"'scrollEnd'",
",",
"this",
".",
"recalculatePosition",
",",
"this",
")",
";",
"Stream",
".",
"onValue",
"(",
"ResizeStream",
".",
"create",
"(",
")",
",",
"Util",
".",
"functionBind",
"(",
"this",
".",
"didResize",
",",
"this",
")",
")",
";",
"this",
".",
"viewportRect",
"=",
"{",
"height",
":",
"window",
".",
"innerHeight",
",",
"top",
":",
"0",
"}",
";",
"this",
".",
"recalculateOffsets",
"(",
")",
";",
"setTimeout",
"(",
"Util",
".",
"functionBind",
"(",
"this",
".",
"recalculateOffsets",
",",
"this",
")",
",",
"100",
")",
";",
"}"
]
| Provides a familiar OO-style API for tracking element position.
@constructor
@param {Element} elem The element to track
@param {Object=} options The options passed to the position tracker.
@return {Object} The API with a `on` function to attach scrollEnd
callbacks and an `observeElement` function to detect when elements
enter and exist the viewport. | [
"Provides",
"a",
"familiar",
"OO",
"-",
"style",
"API",
"for",
"tracking",
"element",
"position",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/controllers/element-visible-controller.js#L17-L58 |
45,911 | simonepri/phc-format | index.js | deserialize | function deserialize(phcstr) {
if (typeof phcstr !== 'string' || phcstr === '') {
throw new TypeError('pchstr must be a non-empty string');
}
if (phcstr[0] !== '$') {
throw new TypeError('pchstr must contain a $ as first char');
}
const fields = phcstr.split('$');
// Remove first empty $
fields.shift();
// Parse Fields
let maxf = 5;
if (!versionRegex.test(fields[1])) maxf--;
if (fields.length > maxf) {
throw new TypeError(
`pchstr contains too many fileds: ${fields.length}/${maxf}`
);
}
// Parse Identifier
const id = fields.shift();
if (!idRegex.test(id)) {
throw new TypeError(`id must satisfy ${idRegex}`);
}
let version;
// Parse Version
if (versionRegex.test(fields[0])) {
version = parseInt(fields.shift().match(versionRegex)[1], 10);
}
let hash;
let salt;
if (b64Regex.test(fields[fields.length - 1])) {
if (fields.length > 1 && b64Regex.test(fields[fields.length - 2])) {
// Parse Hash
hash = Buffer.from(fields.pop(), 'base64');
// Parse Salt
salt = Buffer.from(fields.pop(), 'base64');
} else {
// Parse Salt
salt = Buffer.from(fields.pop(), 'base64');
}
}
// Parse Parameters
let params;
if (fields.length > 0) {
const parstr = fields.pop();
params = keyValtoObj(parstr);
if (!objectKeys(params).every(p => nameRegex.test(p))) {
throw new TypeError(`params names must satisfy ${nameRegex}`);
}
const pv = objectValues(params);
if (!pv.every(v => valueRegex.test(v))) {
throw new TypeError(`params values must satisfy ${valueRegex}`);
}
const pk = objectKeys(params);
// Convert Decimal Strings into Numbers
pk.forEach(k => {
params[k] = decimalRegex.test(params[k])
? parseInt(params[k], 10)
: params[k];
});
}
if (fields.length > 0) {
throw new TypeError(`pchstr contains unrecognized fileds: ${fields}`);
}
// Build the output object
const phcobj = {id};
if (version) phcobj.version = version;
if (params) phcobj.params = params;
if (salt) phcobj.salt = salt;
if (hash) phcobj.hash = hash;
return phcobj;
} | javascript | function deserialize(phcstr) {
if (typeof phcstr !== 'string' || phcstr === '') {
throw new TypeError('pchstr must be a non-empty string');
}
if (phcstr[0] !== '$') {
throw new TypeError('pchstr must contain a $ as first char');
}
const fields = phcstr.split('$');
// Remove first empty $
fields.shift();
// Parse Fields
let maxf = 5;
if (!versionRegex.test(fields[1])) maxf--;
if (fields.length > maxf) {
throw new TypeError(
`pchstr contains too many fileds: ${fields.length}/${maxf}`
);
}
// Parse Identifier
const id = fields.shift();
if (!idRegex.test(id)) {
throw new TypeError(`id must satisfy ${idRegex}`);
}
let version;
// Parse Version
if (versionRegex.test(fields[0])) {
version = parseInt(fields.shift().match(versionRegex)[1], 10);
}
let hash;
let salt;
if (b64Regex.test(fields[fields.length - 1])) {
if (fields.length > 1 && b64Regex.test(fields[fields.length - 2])) {
// Parse Hash
hash = Buffer.from(fields.pop(), 'base64');
// Parse Salt
salt = Buffer.from(fields.pop(), 'base64');
} else {
// Parse Salt
salt = Buffer.from(fields.pop(), 'base64');
}
}
// Parse Parameters
let params;
if (fields.length > 0) {
const parstr = fields.pop();
params = keyValtoObj(parstr);
if (!objectKeys(params).every(p => nameRegex.test(p))) {
throw new TypeError(`params names must satisfy ${nameRegex}`);
}
const pv = objectValues(params);
if (!pv.every(v => valueRegex.test(v))) {
throw new TypeError(`params values must satisfy ${valueRegex}`);
}
const pk = objectKeys(params);
// Convert Decimal Strings into Numbers
pk.forEach(k => {
params[k] = decimalRegex.test(params[k])
? parseInt(params[k], 10)
: params[k];
});
}
if (fields.length > 0) {
throw new TypeError(`pchstr contains unrecognized fileds: ${fields}`);
}
// Build the output object
const phcobj = {id};
if (version) phcobj.version = version;
if (params) phcobj.params = params;
if (salt) phcobj.salt = salt;
if (hash) phcobj.hash = hash;
return phcobj;
} | [
"function",
"deserialize",
"(",
"phcstr",
")",
"{",
"if",
"(",
"typeof",
"phcstr",
"!==",
"'string'",
"||",
"phcstr",
"===",
"''",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'pchstr must be a non-empty string'",
")",
";",
"}",
"if",
"(",
"phcstr",
"[",
"0",
"]",
"!==",
"'$'",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"'pchstr must contain a $ as first char'",
")",
";",
"}",
"const",
"fields",
"=",
"phcstr",
".",
"split",
"(",
"'$'",
")",
";",
"// Remove first empty $",
"fields",
".",
"shift",
"(",
")",
";",
"// Parse Fields",
"let",
"maxf",
"=",
"5",
";",
"if",
"(",
"!",
"versionRegex",
".",
"test",
"(",
"fields",
"[",
"1",
"]",
")",
")",
"maxf",
"--",
";",
"if",
"(",
"fields",
".",
"length",
">",
"maxf",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"fields",
".",
"length",
"}",
"${",
"maxf",
"}",
"`",
")",
";",
"}",
"// Parse Identifier",
"const",
"id",
"=",
"fields",
".",
"shift",
"(",
")",
";",
"if",
"(",
"!",
"idRegex",
".",
"test",
"(",
"id",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"idRegex",
"}",
"`",
")",
";",
"}",
"let",
"version",
";",
"// Parse Version",
"if",
"(",
"versionRegex",
".",
"test",
"(",
"fields",
"[",
"0",
"]",
")",
")",
"{",
"version",
"=",
"parseInt",
"(",
"fields",
".",
"shift",
"(",
")",
".",
"match",
"(",
"versionRegex",
")",
"[",
"1",
"]",
",",
"10",
")",
";",
"}",
"let",
"hash",
";",
"let",
"salt",
";",
"if",
"(",
"b64Regex",
".",
"test",
"(",
"fields",
"[",
"fields",
".",
"length",
"-",
"1",
"]",
")",
")",
"{",
"if",
"(",
"fields",
".",
"length",
">",
"1",
"&&",
"b64Regex",
".",
"test",
"(",
"fields",
"[",
"fields",
".",
"length",
"-",
"2",
"]",
")",
")",
"{",
"// Parse Hash",
"hash",
"=",
"Buffer",
".",
"from",
"(",
"fields",
".",
"pop",
"(",
")",
",",
"'base64'",
")",
";",
"// Parse Salt",
"salt",
"=",
"Buffer",
".",
"from",
"(",
"fields",
".",
"pop",
"(",
")",
",",
"'base64'",
")",
";",
"}",
"else",
"{",
"// Parse Salt",
"salt",
"=",
"Buffer",
".",
"from",
"(",
"fields",
".",
"pop",
"(",
")",
",",
"'base64'",
")",
";",
"}",
"}",
"// Parse Parameters",
"let",
"params",
";",
"if",
"(",
"fields",
".",
"length",
">",
"0",
")",
"{",
"const",
"parstr",
"=",
"fields",
".",
"pop",
"(",
")",
";",
"params",
"=",
"keyValtoObj",
"(",
"parstr",
")",
";",
"if",
"(",
"!",
"objectKeys",
"(",
"params",
")",
".",
"every",
"(",
"p",
"=>",
"nameRegex",
".",
"test",
"(",
"p",
")",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"nameRegex",
"}",
"`",
")",
";",
"}",
"const",
"pv",
"=",
"objectValues",
"(",
"params",
")",
";",
"if",
"(",
"!",
"pv",
".",
"every",
"(",
"v",
"=>",
"valueRegex",
".",
"test",
"(",
"v",
")",
")",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"valueRegex",
"}",
"`",
")",
";",
"}",
"const",
"pk",
"=",
"objectKeys",
"(",
"params",
")",
";",
"// Convert Decimal Strings into Numbers",
"pk",
".",
"forEach",
"(",
"k",
"=>",
"{",
"params",
"[",
"k",
"]",
"=",
"decimalRegex",
".",
"test",
"(",
"params",
"[",
"k",
"]",
")",
"?",
"parseInt",
"(",
"params",
"[",
"k",
"]",
",",
"10",
")",
":",
"params",
"[",
"k",
"]",
";",
"}",
")",
";",
"}",
"if",
"(",
"fields",
".",
"length",
">",
"0",
")",
"{",
"throw",
"new",
"TypeError",
"(",
"`",
"${",
"fields",
"}",
"`",
")",
";",
"}",
"// Build the output object",
"const",
"phcobj",
"=",
"{",
"id",
"}",
";",
"if",
"(",
"version",
")",
"phcobj",
".",
"version",
"=",
"version",
";",
"if",
"(",
"params",
")",
"phcobj",
".",
"params",
"=",
"params",
";",
"if",
"(",
"salt",
")",
"phcobj",
".",
"salt",
"=",
"salt",
";",
"if",
"(",
"hash",
")",
"phcobj",
".",
"hash",
"=",
"hash",
";",
"return",
"phcobj",
";",
"}"
]
| Parses data from a PHC string.
@param {string} phcstr A PHC string to parse.
@return {Object} The object containing the data parsed from the PHC string. | [
"Parses",
"data",
"from",
"a",
"PHC",
"string",
"."
]
| 0e359490bab263577ec80a5cba67803063e1c8d6 | https://github.com/simonepri/phc-format/blob/0e359490bab263577ec80a5cba67803063e1c8d6/index.js#L133-L212 |
45,912 | pthm/redular | index.js | function(options){
var _this = this;
this.handlers = {};
if(!options){
options = {};
}
if(!options.redis){
options.redis = {};
}
this.options = {
id: options.id || shortId.generate(),
autoConfig: options.autoConfig || false,
dataExpiry: options.dataExpiry || 30,
redis: {
port: options.redis.port || 6379,
host: options.redis.host || '127.0.0.1',
redis: options.redis.options || {}
}
};
//Create redis clients
this.redisSub = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
this.redis = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
this.redisInstant = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
//Attempt auto config
if(this.options.autoConfig){
var config = '';
this.redis.config("GET", "notify-keyspace-events", function(err, data){
if(data){
config = data[1];
}
if(config.indexOf('E') == -1){
config += 'E'
}
if(config.indexOf('x') == -1){
config += 'x'
}
_this.redis.config("SET", "notify-keyspace-events", config)
});
}
//Listen to key expiry notifications and handle events
var expiryListener = new RedisEvent(this.redisSub, 'expired', /redular:(.+):(.+):(.+)/);
expiryListener.defineHandler(function(key){
var clientId = key[1];
var eventName = key[2];
var eventId = key[3];
_this.redis.get('redular-data:' + clientId + ':' + eventName + ':' + eventId, function(err, data){
if(data){
data = JSON.parse(data);
}
if(clientId == _this.options.id || clientId == 'global'){
_this.handleEvent(eventName, data);
}
});
});
//Listen to instant events and handle them
this.redisInstant.subscribe('redular:instant');
this.redisInstant.on('message', function(channel, message){
try{
var parsedMessage = JSON.parse(message);
} catch (e){
throw e;
}
if(parsedMessage.client == _this.options.id || parsedMessage.client == 'global') {
_this.handleEvent(parsedMessage.event, parsedMessage.data);
}
});
} | javascript | function(options){
var _this = this;
this.handlers = {};
if(!options){
options = {};
}
if(!options.redis){
options.redis = {};
}
this.options = {
id: options.id || shortId.generate(),
autoConfig: options.autoConfig || false,
dataExpiry: options.dataExpiry || 30,
redis: {
port: options.redis.port || 6379,
host: options.redis.host || '127.0.0.1',
redis: options.redis.options || {}
}
};
//Create redis clients
this.redisSub = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
this.redis = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
this.redisInstant = redis.createClient(this.options.redis.port, this.options.redis.host, this.options.redis.options);
//Attempt auto config
if(this.options.autoConfig){
var config = '';
this.redis.config("GET", "notify-keyspace-events", function(err, data){
if(data){
config = data[1];
}
if(config.indexOf('E') == -1){
config += 'E'
}
if(config.indexOf('x') == -1){
config += 'x'
}
_this.redis.config("SET", "notify-keyspace-events", config)
});
}
//Listen to key expiry notifications and handle events
var expiryListener = new RedisEvent(this.redisSub, 'expired', /redular:(.+):(.+):(.+)/);
expiryListener.defineHandler(function(key){
var clientId = key[1];
var eventName = key[2];
var eventId = key[3];
_this.redis.get('redular-data:' + clientId + ':' + eventName + ':' + eventId, function(err, data){
if(data){
data = JSON.parse(data);
}
if(clientId == _this.options.id || clientId == 'global'){
_this.handleEvent(eventName, data);
}
});
});
//Listen to instant events and handle them
this.redisInstant.subscribe('redular:instant');
this.redisInstant.on('message', function(channel, message){
try{
var parsedMessage = JSON.parse(message);
} catch (e){
throw e;
}
if(parsedMessage.client == _this.options.id || parsedMessage.client == 'global') {
_this.handleEvent(parsedMessage.event, parsedMessage.data);
}
});
} | [
"function",
"(",
"options",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"this",
".",
"handlers",
"=",
"{",
"}",
";",
"if",
"(",
"!",
"options",
")",
"{",
"options",
"=",
"{",
"}",
";",
"}",
"if",
"(",
"!",
"options",
".",
"redis",
")",
"{",
"options",
".",
"redis",
"=",
"{",
"}",
";",
"}",
"this",
".",
"options",
"=",
"{",
"id",
":",
"options",
".",
"id",
"||",
"shortId",
".",
"generate",
"(",
")",
",",
"autoConfig",
":",
"options",
".",
"autoConfig",
"||",
"false",
",",
"dataExpiry",
":",
"options",
".",
"dataExpiry",
"||",
"30",
",",
"redis",
":",
"{",
"port",
":",
"options",
".",
"redis",
".",
"port",
"||",
"6379",
",",
"host",
":",
"options",
".",
"redis",
".",
"host",
"||",
"'127.0.0.1'",
",",
"redis",
":",
"options",
".",
"redis",
".",
"options",
"||",
"{",
"}",
"}",
"}",
";",
"//Create redis clients",
"this",
".",
"redisSub",
"=",
"redis",
".",
"createClient",
"(",
"this",
".",
"options",
".",
"redis",
".",
"port",
",",
"this",
".",
"options",
".",
"redis",
".",
"host",
",",
"this",
".",
"options",
".",
"redis",
".",
"options",
")",
";",
"this",
".",
"redis",
"=",
"redis",
".",
"createClient",
"(",
"this",
".",
"options",
".",
"redis",
".",
"port",
",",
"this",
".",
"options",
".",
"redis",
".",
"host",
",",
"this",
".",
"options",
".",
"redis",
".",
"options",
")",
";",
"this",
".",
"redisInstant",
"=",
"redis",
".",
"createClient",
"(",
"this",
".",
"options",
".",
"redis",
".",
"port",
",",
"this",
".",
"options",
".",
"redis",
".",
"host",
",",
"this",
".",
"options",
".",
"redis",
".",
"options",
")",
";",
"//Attempt auto config",
"if",
"(",
"this",
".",
"options",
".",
"autoConfig",
")",
"{",
"var",
"config",
"=",
"''",
";",
"this",
".",
"redis",
".",
"config",
"(",
"\"GET\"",
",",
"\"notify-keyspace-events\"",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"data",
")",
"{",
"config",
"=",
"data",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"config",
".",
"indexOf",
"(",
"'E'",
")",
"==",
"-",
"1",
")",
"{",
"config",
"+=",
"'E'",
"}",
"if",
"(",
"config",
".",
"indexOf",
"(",
"'x'",
")",
"==",
"-",
"1",
")",
"{",
"config",
"+=",
"'x'",
"}",
"_this",
".",
"redis",
".",
"config",
"(",
"\"SET\"",
",",
"\"notify-keyspace-events\"",
",",
"config",
")",
"}",
")",
";",
"}",
"//Listen to key expiry notifications and handle events",
"var",
"expiryListener",
"=",
"new",
"RedisEvent",
"(",
"this",
".",
"redisSub",
",",
"'expired'",
",",
"/",
"redular:(.+):(.+):(.+)",
"/",
")",
";",
"expiryListener",
".",
"defineHandler",
"(",
"function",
"(",
"key",
")",
"{",
"var",
"clientId",
"=",
"key",
"[",
"1",
"]",
";",
"var",
"eventName",
"=",
"key",
"[",
"2",
"]",
";",
"var",
"eventId",
"=",
"key",
"[",
"3",
"]",
";",
"_this",
".",
"redis",
".",
"get",
"(",
"'redular-data:'",
"+",
"clientId",
"+",
"':'",
"+",
"eventName",
"+",
"':'",
"+",
"eventId",
",",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"data",
")",
"{",
"data",
"=",
"JSON",
".",
"parse",
"(",
"data",
")",
";",
"}",
"if",
"(",
"clientId",
"==",
"_this",
".",
"options",
".",
"id",
"||",
"clientId",
"==",
"'global'",
")",
"{",
"_this",
".",
"handleEvent",
"(",
"eventName",
",",
"data",
")",
";",
"}",
"}",
")",
";",
"}",
")",
";",
"//Listen to instant events and handle them",
"this",
".",
"redisInstant",
".",
"subscribe",
"(",
"'redular:instant'",
")",
";",
"this",
".",
"redisInstant",
".",
"on",
"(",
"'message'",
",",
"function",
"(",
"channel",
",",
"message",
")",
"{",
"try",
"{",
"var",
"parsedMessage",
"=",
"JSON",
".",
"parse",
"(",
"message",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"if",
"(",
"parsedMessage",
".",
"client",
"==",
"_this",
".",
"options",
".",
"id",
"||",
"parsedMessage",
".",
"client",
"==",
"'global'",
")",
"{",
"_this",
".",
"handleEvent",
"(",
"parsedMessage",
".",
"event",
",",
"parsedMessage",
".",
"data",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Node.js scheduling system powered by Redis Keyspace Notifications
@param options {Object}
@constructor | [
"Node",
".",
"js",
"scheduling",
"system",
"powered",
"by",
"Redis",
"Keyspace",
"Notifications"
]
| 571d0430065a521c5b0d5da81fc5ae288fd587ec | https://github.com/pthm/redular/blob/571d0430065a521c5b0d5da81fc5ae288fd587ec/index.js#L11-L87 |
|
45,913 | weexteam/weex-templater | lib/parsers/expression.js | rewrite | function rewrite (raw) {
var c = raw.charAt(0)
var path = raw.slice(1)
if (allowedKeywordsRE.test(path)) {
return raw
} else {
path = path.indexOf('"') > -1
? path.replace(restoreRE, restore)
: path
return c + 'this.' + path
}
} | javascript | function rewrite (raw) {
var c = raw.charAt(0)
var path = raw.slice(1)
if (allowedKeywordsRE.test(path)) {
return raw
} else {
path = path.indexOf('"') > -1
? path.replace(restoreRE, restore)
: path
return c + 'this.' + path
}
} | [
"function",
"rewrite",
"(",
"raw",
")",
"{",
"var",
"c",
"=",
"raw",
".",
"charAt",
"(",
"0",
")",
"var",
"path",
"=",
"raw",
".",
"slice",
"(",
"1",
")",
"if",
"(",
"allowedKeywordsRE",
".",
"test",
"(",
"path",
")",
")",
"{",
"return",
"raw",
"}",
"else",
"{",
"path",
"=",
"path",
".",
"indexOf",
"(",
"'\"'",
")",
">",
"-",
"1",
"?",
"path",
".",
"replace",
"(",
"restoreRE",
",",
"restore",
")",
":",
"path",
"return",
"c",
"+",
"'this.'",
"+",
"path",
"}",
"}"
]
| Path rewrite replacer
@param {String} raw
@return {String} | [
"Path",
"rewrite",
"replacer"
]
| 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/parsers/expression.js#L65-L76 |
45,914 | weexteam/weex-templater | lib/parsers/expression.js | parseExpression | function parseExpression (exp) {
exp = exp.trim()
var res = isSimplePath(exp) && exp.indexOf('[') < 0
// optimized super simple getter
? 'this.' + exp
// dynamic getter
: compileGetter(exp)
return res
} | javascript | function parseExpression (exp) {
exp = exp.trim()
var res = isSimplePath(exp) && exp.indexOf('[') < 0
// optimized super simple getter
? 'this.' + exp
// dynamic getter
: compileGetter(exp)
return res
} | [
"function",
"parseExpression",
"(",
"exp",
")",
"{",
"exp",
"=",
"exp",
".",
"trim",
"(",
")",
"var",
"res",
"=",
"isSimplePath",
"(",
"exp",
")",
"&&",
"exp",
".",
"indexOf",
"(",
"'['",
")",
"<",
"0",
"// optimized super simple getter",
"?",
"'this.'",
"+",
"exp",
"// dynamic getter",
":",
"compileGetter",
"(",
"exp",
")",
"return",
"res",
"}"
]
| Parse an expression into re-written getter.
@param {String} exp
@return {String} | [
"Parse",
"an",
"expression",
"into",
"re",
"-",
"written",
"getter",
"."
]
| 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/parsers/expression.js#L121-L129 |
45,915 | weexteam/weex-templater | lib/parsers/expression.js | isSimplePath | function isSimplePath (exp) {
return pathTestRE.test(exp) &&
// don't treat true/false as paths
!booleanLiteralRE.test(exp) &&
// Math constants e.g. Math.PI, Math.E etc.
exp.slice(0, 5) !== 'Math.'
} | javascript | function isSimplePath (exp) {
return pathTestRE.test(exp) &&
// don't treat true/false as paths
!booleanLiteralRE.test(exp) &&
// Math constants e.g. Math.PI, Math.E etc.
exp.slice(0, 5) !== 'Math.'
} | [
"function",
"isSimplePath",
"(",
"exp",
")",
"{",
"return",
"pathTestRE",
".",
"test",
"(",
"exp",
")",
"&&",
"// don't treat true/false as paths",
"!",
"booleanLiteralRE",
".",
"test",
"(",
"exp",
")",
"&&",
"// Math constants e.g. Math.PI, Math.E etc.",
"exp",
".",
"slice",
"(",
"0",
",",
"5",
")",
"!==",
"'Math.'",
"}"
]
| Check if an expression is a simple path.
@param {String} exp
@return {Boolean} | [
"Check",
"if",
"an",
"expression",
"is",
"a",
"simple",
"path",
"."
]
| 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/parsers/expression.js#L137-L143 |
45,916 | NatalieWolfe/node-promise-pool | lib/PromisePool.js | PromisePool | function PromisePool(opts) {
this._opts = {
// Configuration options
name: opts.name || 'pool',
idleTimeoutMillis: opts.idleTimeoutMillis || 30000,
reapInterval: opts.reapIntervalMillis || 1000,
drainCheckInterval: opts.drainCheckIntervalMillis || 100,
refreshIdle: ('refreshIdle' in opts) ? opts.refreshIdle : true,
returnToHead: opts.returnToHead || false,
max: parseInt(opts.max, 10),
min: parseInt(opts.min, 10),
// Client management methods.
create: opts.create,
destroy: opts.destroy,
validate: opts.validate || function(){ return true; },
onRelease: opts.onRelease
};
this._availableObjects = [];
this._waitingClients = new PriorityQueue(opts.priorityRange || 1);
this._count = 0;
this._removeIdleScheduled = false;
this._removeIdleTimer = null;
this._draining = false;
// Prepare a logger function.
if (opts.log instanceof Function) {
this._log = opts.log;
}
else if (opts.log) {
this._log = _logger.bind(this);
}
else {
this._log = function(){};
}
// Clean up some of the inputs.
this._validate = opts.validate || function(){ return true; };
this._opts.max = Math.max(isNaN(this._opts.max) ? 1 : this._opts.max, 1);
this._opts.min = Math.min(isNaN(this._opts.min) ? 0 : this._opts.min, this._opts.max-1);
// Finally, ensure a minimum number of connections right out of the gate.
_ensureMinimum.call(this);
} | javascript | function PromisePool(opts) {
this._opts = {
// Configuration options
name: opts.name || 'pool',
idleTimeoutMillis: opts.idleTimeoutMillis || 30000,
reapInterval: opts.reapIntervalMillis || 1000,
drainCheckInterval: opts.drainCheckIntervalMillis || 100,
refreshIdle: ('refreshIdle' in opts) ? opts.refreshIdle : true,
returnToHead: opts.returnToHead || false,
max: parseInt(opts.max, 10),
min: parseInt(opts.min, 10),
// Client management methods.
create: opts.create,
destroy: opts.destroy,
validate: opts.validate || function(){ return true; },
onRelease: opts.onRelease
};
this._availableObjects = [];
this._waitingClients = new PriorityQueue(opts.priorityRange || 1);
this._count = 0;
this._removeIdleScheduled = false;
this._removeIdleTimer = null;
this._draining = false;
// Prepare a logger function.
if (opts.log instanceof Function) {
this._log = opts.log;
}
else if (opts.log) {
this._log = _logger.bind(this);
}
else {
this._log = function(){};
}
// Clean up some of the inputs.
this._validate = opts.validate || function(){ return true; };
this._opts.max = Math.max(isNaN(this._opts.max) ? 1 : this._opts.max, 1);
this._opts.min = Math.min(isNaN(this._opts.min) ? 0 : this._opts.min, this._opts.max-1);
// Finally, ensure a minimum number of connections right out of the gate.
_ensureMinimum.call(this);
} | [
"function",
"PromisePool",
"(",
"opts",
")",
"{",
"this",
".",
"_opts",
"=",
"{",
"// Configuration options",
"name",
":",
"opts",
".",
"name",
"||",
"'pool'",
",",
"idleTimeoutMillis",
":",
"opts",
".",
"idleTimeoutMillis",
"||",
"30000",
",",
"reapInterval",
":",
"opts",
".",
"reapIntervalMillis",
"||",
"1000",
",",
"drainCheckInterval",
":",
"opts",
".",
"drainCheckIntervalMillis",
"||",
"100",
",",
"refreshIdle",
":",
"(",
"'refreshIdle'",
"in",
"opts",
")",
"?",
"opts",
".",
"refreshIdle",
":",
"true",
",",
"returnToHead",
":",
"opts",
".",
"returnToHead",
"||",
"false",
",",
"max",
":",
"parseInt",
"(",
"opts",
".",
"max",
",",
"10",
")",
",",
"min",
":",
"parseInt",
"(",
"opts",
".",
"min",
",",
"10",
")",
",",
"// Client management methods.",
"create",
":",
"opts",
".",
"create",
",",
"destroy",
":",
"opts",
".",
"destroy",
",",
"validate",
":",
"opts",
".",
"validate",
"||",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
",",
"onRelease",
":",
"opts",
".",
"onRelease",
"}",
";",
"this",
".",
"_availableObjects",
"=",
"[",
"]",
";",
"this",
".",
"_waitingClients",
"=",
"new",
"PriorityQueue",
"(",
"opts",
".",
"priorityRange",
"||",
"1",
")",
";",
"this",
".",
"_count",
"=",
"0",
";",
"this",
".",
"_removeIdleScheduled",
"=",
"false",
";",
"this",
".",
"_removeIdleTimer",
"=",
"null",
";",
"this",
".",
"_draining",
"=",
"false",
";",
"// Prepare a logger function.",
"if",
"(",
"opts",
".",
"log",
"instanceof",
"Function",
")",
"{",
"this",
".",
"_log",
"=",
"opts",
".",
"log",
";",
"}",
"else",
"if",
"(",
"opts",
".",
"log",
")",
"{",
"this",
".",
"_log",
"=",
"_logger",
".",
"bind",
"(",
"this",
")",
";",
"}",
"else",
"{",
"this",
".",
"_log",
"=",
"function",
"(",
")",
"{",
"}",
";",
"}",
"// Clean up some of the inputs.",
"this",
".",
"_validate",
"=",
"opts",
".",
"validate",
"||",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
";",
"this",
".",
"_opts",
".",
"max",
"=",
"Math",
".",
"max",
"(",
"isNaN",
"(",
"this",
".",
"_opts",
".",
"max",
")",
"?",
"1",
":",
"this",
".",
"_opts",
".",
"max",
",",
"1",
")",
";",
"this",
".",
"_opts",
".",
"min",
"=",
"Math",
".",
"min",
"(",
"isNaN",
"(",
"this",
".",
"_opts",
".",
"min",
")",
"?",
"0",
":",
"this",
".",
"_opts",
".",
"min",
",",
"this",
".",
"_opts",
".",
"max",
"-",
"1",
")",
";",
"// Finally, ensure a minimum number of connections right out of the gate.",
"_ensureMinimum",
".",
"call",
"(",
"this",
")",
";",
"}"
]
| Constructs a new pool with the provided factory options.
@constructor
@classdesc
A resource pooling class with a promise-based API.
@param {PromisePool.Factory} opts
The connection factory which specifies the functionality for the pool. | [
"Constructs",
"a",
"new",
"pool",
"with",
"the",
"provided",
"factory",
"options",
"."
]
| e98208593893ad89af3889c8398eac76a09c20b8 | https://github.com/NatalieWolfe/node-promise-pool/blob/e98208593893ad89af3889c8398eac76a09c20b8/lib/PromisePool.js#L17-L61 |
45,917 | NatalieWolfe/node-promise-pool | lib/PromisePool.js | _ensureMinimum | function _ensureMinimum() {
// Nothing to do if draining.
if (this._draining) {
return Promise.resolve();
}
var diff = this._opts.min - this._count + this.availableLength;
var promises = [];
for (var i = 0; i < diff; ++i) {
promises.push(this.acquire(function(client){ return Promise.resolve(); }));
}
return Promise.all(promises).then(function(){});
} | javascript | function _ensureMinimum() {
// Nothing to do if draining.
if (this._draining) {
return Promise.resolve();
}
var diff = this._opts.min - this._count + this.availableLength;
var promises = [];
for (var i = 0; i < diff; ++i) {
promises.push(this.acquire(function(client){ return Promise.resolve(); }));
}
return Promise.all(promises).then(function(){});
} | [
"function",
"_ensureMinimum",
"(",
")",
"{",
"// Nothing to do if draining.",
"if",
"(",
"this",
".",
"_draining",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
"var",
"diff",
"=",
"this",
".",
"_opts",
".",
"min",
"-",
"this",
".",
"_count",
"+",
"this",
".",
"availableLength",
";",
"var",
"promises",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"diff",
";",
"++",
"i",
")",
"{",
"promises",
".",
"push",
"(",
"this",
".",
"acquire",
"(",
"function",
"(",
"client",
")",
"{",
"return",
"Promise",
".",
"resolve",
"(",
")",
";",
"}",
")",
")",
";",
"}",
"return",
"Promise",
".",
"all",
"(",
"promises",
")",
".",
"then",
"(",
"function",
"(",
")",
"{",
"}",
")",
";",
"}"
]
| Constructs more resources to bring the current count up to the minimum specified in the factory.
@private
@memberof PromisePool
@return {Promise} A promise to create all the resources needed. | [
"Constructs",
"more",
"resources",
"to",
"bring",
"the",
"current",
"count",
"up",
"to",
"the",
"minimum",
"specified",
"in",
"the",
"factory",
"."
]
| e98208593893ad89af3889c8398eac76a09c20b8 | https://github.com/NatalieWolfe/node-promise-pool/blob/e98208593893ad89af3889c8398eac76a09c20b8/lib/PromisePool.js#L216-L229 |
45,918 | NatalieWolfe/node-promise-pool | lib/PromisePool.js | _createResource | function _createResource() {
this._log(
util.format(
'PromisePool._createResource() - creating client - count=%d min=%d max=%d',
this._count, this._opts.min, this._opts.max
),
'verbose'
);
return Promise.resolve(this._opts.create());
} | javascript | function _createResource() {
this._log(
util.format(
'PromisePool._createResource() - creating client - count=%d min=%d max=%d',
this._count, this._opts.min, this._opts.max
),
'verbose'
);
return Promise.resolve(this._opts.create());
} | [
"function",
"_createResource",
"(",
")",
"{",
"this",
".",
"_log",
"(",
"util",
".",
"format",
"(",
"'PromisePool._createResource() - creating client - count=%d min=%d max=%d'",
",",
"this",
".",
"_count",
",",
"this",
".",
"_opts",
".",
"min",
",",
"this",
".",
"_opts",
".",
"max",
")",
",",
"'verbose'",
")",
";",
"return",
"Promise",
".",
"resolve",
"(",
"this",
".",
"_opts",
".",
"create",
"(",
")",
")",
";",
"}"
]
| Constructs a new resource.
@private
@this {PromisePool}
@return {Promise.<PromisePool.Client>} A promise for the to-be created client. | [
"Constructs",
"a",
"new",
"resource",
"."
]
| e98208593893ad89af3889c8398eac76a09c20b8 | https://github.com/NatalieWolfe/node-promise-pool/blob/e98208593893ad89af3889c8398eac76a09c20b8/lib/PromisePool.js#L239-L249 |
45,919 | NatalieWolfe/node-promise-pool | lib/PromisePool.js | _scheduleRemoveIdle | function _scheduleRemoveIdle(){
if (!this._removeIdleScheduled) {
this._removeIdleScheduled = true;
this._removeIdleTimer = setTimeout(_removeIdle.bind(this), this._opts.reapInterval);
}
} | javascript | function _scheduleRemoveIdle(){
if (!this._removeIdleScheduled) {
this._removeIdleScheduled = true;
this._removeIdleTimer = setTimeout(_removeIdle.bind(this), this._opts.reapInterval);
}
} | [
"function",
"_scheduleRemoveIdle",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"_removeIdleScheduled",
")",
"{",
"this",
".",
"_removeIdleScheduled",
"=",
"true",
";",
"this",
".",
"_removeIdleTimer",
"=",
"setTimeout",
"(",
"_removeIdle",
".",
"bind",
"(",
"this",
")",
",",
"this",
".",
"_opts",
".",
"reapInterval",
")",
";",
"}",
"}"
]
| Schedule removal of idle items in the pool.
Only one removal at a time can be scheduled.
@private
@this {PromisePool}
@return {undefined} | [
"Schedule",
"removal",
"of",
"idle",
"items",
"in",
"the",
"pool",
"."
]
| e98208593893ad89af3889c8398eac76a09c20b8 | https://github.com/NatalieWolfe/node-promise-pool/blob/e98208593893ad89af3889c8398eac76a09c20b8/lib/PromisePool.js#L308-L313 |
45,920 | NatalieWolfe/node-promise-pool | lib/PromisePool.js | _objFilter | function _objFilter(obj, eql) {
return function(objWithTimeout){
return (eql ? (obj === objWithTimeout.obj) : (obj !== objWithTimeout.obj));
};
} | javascript | function _objFilter(obj, eql) {
return function(objWithTimeout){
return (eql ? (obj === objWithTimeout.obj) : (obj !== objWithTimeout.obj));
};
} | [
"function",
"_objFilter",
"(",
"obj",
",",
"eql",
")",
"{",
"return",
"function",
"(",
"objWithTimeout",
")",
"{",
"return",
"(",
"eql",
"?",
"(",
"obj",
"===",
"objWithTimeout",
".",
"obj",
")",
":",
"(",
"obj",
"!==",
"objWithTimeout",
".",
"obj",
")",
")",
";",
"}",
";",
"}"
]
| Creates a filter usable for finding a client in the available clients list.
@private
@memberof PromisePool
@param {PromisePool.Client} obj
The client to filter the list for.
@param {bool} eql
Indicates if the test should be for equality (`===`) or not (`!==`).
@return {Function} A function which can be used for array filtering methods. | [
"Creates",
"a",
"filter",
"usable",
"for",
"finding",
"a",
"client",
"in",
"the",
"available",
"clients",
"list",
"."
]
| e98208593893ad89af3889c8398eac76a09c20b8 | https://github.com/NatalieWolfe/node-promise-pool/blob/e98208593893ad89af3889c8398eac76a09c20b8/lib/PromisePool.js#L395-L399 |
45,921 | alykoshin/require-dir-all | index.js | _requireDirAll | function _requireDirAll(originalModule, absDir, options) {
var modules = {};
var files = [];
try {
files = fs.readdirSync(absDir);
} catch (e) {
if (options.throwNoDir) {
throw e;
}
}
for (var length=files.length, i=0; i<length; ++i) {
var reqModule = {};
reqModule.filename = files[i]; // full filename without path
reqModule.ext = path.extname(reqModule.filename); // file extension
reqModule.base = path.basename(reqModule.filename, reqModule.ext); // filename without extension
reqModule.filepath = path.join(absDir, reqModule.filename); // full filename with absolute path
//console.log('reqModule:', reqModule);
// If this is subdirectory, then descend recursively into it (excluding matching patter excludeDirs)
if (fs.statSync(reqModule.filepath).isDirectory() &&
options.recursive &&
! isExcludedDir(reqModule, options.excludeDirs) ) {
// use filename (with extension) instead of base name (without extension)
// to keep complete directory name for directories with '.', like 'dir.1.2.3'
reqModule.name = reqModule.filename;
// go recursively into subdirectory
//if (typeof modules === 'undefined') {
// modules = {};
//}
modules[reqModule.name] = _requireDirAll(originalModule, reqModule.filepath, options);
} else if ( ! isExcludedFileRe(reqModule, options.includeFiles) && !isExcludedFileParent(reqModule, originalModule)) {
reqModule.name = reqModule.base;
reqModule.exports = require(reqModule.filepath);
if (options.map) {
options.map(reqModule);
}
var source = reqModule.exports;
var target = (reqModule.name === 'index' && options.indexAsParent) ? modules : modules && modules[ reqModule.name ];
var sourceIsObject = (typeof source === 'object');
var targetIsObject = (typeof target === 'object');
//var targetUnassigned = (typeof target === 'undefined');
if (sourceIsObject && targetIsObject) {
//if (Object.assign) {
// Object.assign(target, source);
//} else {
deepAssign(target, source);
//}
} else //if (
//(!sourceIsObject && !targetIsObject) || // if source and target both are not objects or...
//(targetUnassigned) // if target is not yet assigned, we may assign any type to it
//)
{
target = source;
//} else {
// console.log('!!!! ' +
// ' source:', source,
// ' target:', target,
// '; sourceIsObject:', sourceIsObject,
// '; targetIsObject:', targetIsObject,
// '; targetUnassigned:', targetUnassigned,
// '');
// throw 'Not possible to mix objects with scalar or array values: ' +
// 'filepath: '+ reqModule.filepath + '; ' +
// 'modules: '+ JSON.stringify(modules) + '; ' +
// 'exports: '+ JSON.stringify(reqModule.exports)
// ;
}
if (reqModule.name === 'index' && options.indexAsParent) {
modules = target;
} else {
//if (typeof modules === 'undefined') {
// modules = {};
//}
modules[ reqModule.name ] = target;
}
}
}
return modules;
} | javascript | function _requireDirAll(originalModule, absDir, options) {
var modules = {};
var files = [];
try {
files = fs.readdirSync(absDir);
} catch (e) {
if (options.throwNoDir) {
throw e;
}
}
for (var length=files.length, i=0; i<length; ++i) {
var reqModule = {};
reqModule.filename = files[i]; // full filename without path
reqModule.ext = path.extname(reqModule.filename); // file extension
reqModule.base = path.basename(reqModule.filename, reqModule.ext); // filename without extension
reqModule.filepath = path.join(absDir, reqModule.filename); // full filename with absolute path
//console.log('reqModule:', reqModule);
// If this is subdirectory, then descend recursively into it (excluding matching patter excludeDirs)
if (fs.statSync(reqModule.filepath).isDirectory() &&
options.recursive &&
! isExcludedDir(reqModule, options.excludeDirs) ) {
// use filename (with extension) instead of base name (without extension)
// to keep complete directory name for directories with '.', like 'dir.1.2.3'
reqModule.name = reqModule.filename;
// go recursively into subdirectory
//if (typeof modules === 'undefined') {
// modules = {};
//}
modules[reqModule.name] = _requireDirAll(originalModule, reqModule.filepath, options);
} else if ( ! isExcludedFileRe(reqModule, options.includeFiles) && !isExcludedFileParent(reqModule, originalModule)) {
reqModule.name = reqModule.base;
reqModule.exports = require(reqModule.filepath);
if (options.map) {
options.map(reqModule);
}
var source = reqModule.exports;
var target = (reqModule.name === 'index' && options.indexAsParent) ? modules : modules && modules[ reqModule.name ];
var sourceIsObject = (typeof source === 'object');
var targetIsObject = (typeof target === 'object');
//var targetUnassigned = (typeof target === 'undefined');
if (sourceIsObject && targetIsObject) {
//if (Object.assign) {
// Object.assign(target, source);
//} else {
deepAssign(target, source);
//}
} else //if (
//(!sourceIsObject && !targetIsObject) || // if source and target both are not objects or...
//(targetUnassigned) // if target is not yet assigned, we may assign any type to it
//)
{
target = source;
//} else {
// console.log('!!!! ' +
// ' source:', source,
// ' target:', target,
// '; sourceIsObject:', sourceIsObject,
// '; targetIsObject:', targetIsObject,
// '; targetUnassigned:', targetUnassigned,
// '');
// throw 'Not possible to mix objects with scalar or array values: ' +
// 'filepath: '+ reqModule.filepath + '; ' +
// 'modules: '+ JSON.stringify(modules) + '; ' +
// 'exports: '+ JSON.stringify(reqModule.exports)
// ;
}
if (reqModule.name === 'index' && options.indexAsParent) {
modules = target;
} else {
//if (typeof modules === 'undefined') {
// modules = {};
//}
modules[ reqModule.name ] = target;
}
}
}
return modules;
} | [
"function",
"_requireDirAll",
"(",
"originalModule",
",",
"absDir",
",",
"options",
")",
"{",
"var",
"modules",
"=",
"{",
"}",
";",
"var",
"files",
"=",
"[",
"]",
";",
"try",
"{",
"files",
"=",
"fs",
".",
"readdirSync",
"(",
"absDir",
")",
";",
"}",
"catch",
"(",
"e",
")",
"{",
"if",
"(",
"options",
".",
"throwNoDir",
")",
"{",
"throw",
"e",
";",
"}",
"}",
"for",
"(",
"var",
"length",
"=",
"files",
".",
"length",
",",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"++",
"i",
")",
"{",
"var",
"reqModule",
"=",
"{",
"}",
";",
"reqModule",
".",
"filename",
"=",
"files",
"[",
"i",
"]",
";",
"// full filename without path",
"reqModule",
".",
"ext",
"=",
"path",
".",
"extname",
"(",
"reqModule",
".",
"filename",
")",
";",
"// file extension",
"reqModule",
".",
"base",
"=",
"path",
".",
"basename",
"(",
"reqModule",
".",
"filename",
",",
"reqModule",
".",
"ext",
")",
";",
"// filename without extension",
"reqModule",
".",
"filepath",
"=",
"path",
".",
"join",
"(",
"absDir",
",",
"reqModule",
".",
"filename",
")",
";",
"// full filename with absolute path",
"//console.log('reqModule:', reqModule);",
"// If this is subdirectory, then descend recursively into it (excluding matching patter excludeDirs)",
"if",
"(",
"fs",
".",
"statSync",
"(",
"reqModule",
".",
"filepath",
")",
".",
"isDirectory",
"(",
")",
"&&",
"options",
".",
"recursive",
"&&",
"!",
"isExcludedDir",
"(",
"reqModule",
",",
"options",
".",
"excludeDirs",
")",
")",
"{",
"// use filename (with extension) instead of base name (without extension)",
"// to keep complete directory name for directories with '.', like 'dir.1.2.3'",
"reqModule",
".",
"name",
"=",
"reqModule",
".",
"filename",
";",
"// go recursively into subdirectory",
"//if (typeof modules === 'undefined') {",
"// modules = {};",
"//}",
"modules",
"[",
"reqModule",
".",
"name",
"]",
"=",
"_requireDirAll",
"(",
"originalModule",
",",
"reqModule",
".",
"filepath",
",",
"options",
")",
";",
"}",
"else",
"if",
"(",
"!",
"isExcludedFileRe",
"(",
"reqModule",
",",
"options",
".",
"includeFiles",
")",
"&&",
"!",
"isExcludedFileParent",
"(",
"reqModule",
",",
"originalModule",
")",
")",
"{",
"reqModule",
".",
"name",
"=",
"reqModule",
".",
"base",
";",
"reqModule",
".",
"exports",
"=",
"require",
"(",
"reqModule",
".",
"filepath",
")",
";",
"if",
"(",
"options",
".",
"map",
")",
"{",
"options",
".",
"map",
"(",
"reqModule",
")",
";",
"}",
"var",
"source",
"=",
"reqModule",
".",
"exports",
";",
"var",
"target",
"=",
"(",
"reqModule",
".",
"name",
"===",
"'index'",
"&&",
"options",
".",
"indexAsParent",
")",
"?",
"modules",
":",
"modules",
"&&",
"modules",
"[",
"reqModule",
".",
"name",
"]",
";",
"var",
"sourceIsObject",
"=",
"(",
"typeof",
"source",
"===",
"'object'",
")",
";",
"var",
"targetIsObject",
"=",
"(",
"typeof",
"target",
"===",
"'object'",
")",
";",
"//var targetUnassigned = (typeof target === 'undefined');",
"if",
"(",
"sourceIsObject",
"&&",
"targetIsObject",
")",
"{",
"//if (Object.assign) {",
"// Object.assign(target, source);",
"//} else {",
"deepAssign",
"(",
"target",
",",
"source",
")",
";",
"//}",
"}",
"else",
"//if (",
"//(!sourceIsObject && !targetIsObject) || // if source and target both are not objects or...",
"//(targetUnassigned) // if target is not yet assigned, we may assign any type to it",
"//)",
"{",
"target",
"=",
"source",
";",
"//} else {",
"// console.log('!!!! ' +",
"// ' source:', source,",
"// ' target:', target,",
"// '; sourceIsObject:', sourceIsObject,",
"// '; targetIsObject:', targetIsObject,",
"// '; targetUnassigned:', targetUnassigned,",
"// '');",
"// throw 'Not possible to mix objects with scalar or array values: ' +",
"// 'filepath: '+ reqModule.filepath + '; ' +",
"// 'modules: '+ JSON.stringify(modules) + '; ' +",
"// 'exports: '+ JSON.stringify(reqModule.exports)",
"// ;",
"}",
"if",
"(",
"reqModule",
".",
"name",
"===",
"'index'",
"&&",
"options",
".",
"indexAsParent",
")",
"{",
"modules",
"=",
"target",
";",
"}",
"else",
"{",
"//if (typeof modules === 'undefined') {",
"// modules = {};",
"//}",
"modules",
"[",
"reqModule",
".",
"name",
"]",
"=",
"target",
";",
"}",
"}",
"}",
"return",
"modules",
";",
"}"
]
| Main function. Recursively go through directories and require modules according to options
@param {object} originalModule
@param {string} absDir
@param {RequireOptions} options
@returns {object}
@private | [
"Main",
"function",
".",
"Recursively",
"go",
"through",
"directories",
"and",
"require",
"modules",
"according",
"to",
"options"
]
| ab891571b3737f4b83f2836fca0530d12e4ee1c3 | https://github.com/alykoshin/require-dir-all/blob/ab891571b3737f4b83f2836fca0530d12e4ee1c3/index.js#L139-L230 |
45,922 | tdreyno/morlock.js | streams/scroll-stream.js | create | function create(options) {
options = options || {};
var scrollParent = (options.scrollTarget && options.scrollTarget.parentNode) || window;
var oldScrollY;
var scrollDirty = true;
var scrollEventsStream = Stream.createFromEvents(scrollParent, 'scroll');
Stream.onValue(scrollEventsStream, function onScrollSetDirtyBit_() {
scrollDirty = true;
});
var rAF = Stream.createFromRAF();
var didChangeOnRAFStream = Stream.filter(function filterDirtyFramesFromRAF_() {
if (!scrollDirty) { return false; }
scrollDirty = false;
var newScrollY = DOM.documentScrollY(scrollParent);
if (oldScrollY !== newScrollY) {
oldScrollY = newScrollY;
return true;
}
return false;
}, rAF);
// It's going to space, will you just give it a second!
Util.defer(Util.partial(Events.dispatchEvent, scrollParent, 'scroll'), 10);
return Stream.map(function getWindowPosition_() {
return oldScrollY;
}, didChangeOnRAFStream);
} | javascript | function create(options) {
options = options || {};
var scrollParent = (options.scrollTarget && options.scrollTarget.parentNode) || window;
var oldScrollY;
var scrollDirty = true;
var scrollEventsStream = Stream.createFromEvents(scrollParent, 'scroll');
Stream.onValue(scrollEventsStream, function onScrollSetDirtyBit_() {
scrollDirty = true;
});
var rAF = Stream.createFromRAF();
var didChangeOnRAFStream = Stream.filter(function filterDirtyFramesFromRAF_() {
if (!scrollDirty) { return false; }
scrollDirty = false;
var newScrollY = DOM.documentScrollY(scrollParent);
if (oldScrollY !== newScrollY) {
oldScrollY = newScrollY;
return true;
}
return false;
}, rAF);
// It's going to space, will you just give it a second!
Util.defer(Util.partial(Events.dispatchEvent, scrollParent, 'scroll'), 10);
return Stream.map(function getWindowPosition_() {
return oldScrollY;
}, didChangeOnRAFStream);
} | [
"function",
"create",
"(",
"options",
")",
"{",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"scrollParent",
"=",
"(",
"options",
".",
"scrollTarget",
"&&",
"options",
".",
"scrollTarget",
".",
"parentNode",
")",
"||",
"window",
";",
"var",
"oldScrollY",
";",
"var",
"scrollDirty",
"=",
"true",
";",
"var",
"scrollEventsStream",
"=",
"Stream",
".",
"createFromEvents",
"(",
"scrollParent",
",",
"'scroll'",
")",
";",
"Stream",
".",
"onValue",
"(",
"scrollEventsStream",
",",
"function",
"onScrollSetDirtyBit_",
"(",
")",
"{",
"scrollDirty",
"=",
"true",
";",
"}",
")",
";",
"var",
"rAF",
"=",
"Stream",
".",
"createFromRAF",
"(",
")",
";",
"var",
"didChangeOnRAFStream",
"=",
"Stream",
".",
"filter",
"(",
"function",
"filterDirtyFramesFromRAF_",
"(",
")",
"{",
"if",
"(",
"!",
"scrollDirty",
")",
"{",
"return",
"false",
";",
"}",
"scrollDirty",
"=",
"false",
";",
"var",
"newScrollY",
"=",
"DOM",
".",
"documentScrollY",
"(",
"scrollParent",
")",
";",
"if",
"(",
"oldScrollY",
"!==",
"newScrollY",
")",
"{",
"oldScrollY",
"=",
"newScrollY",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
",",
"rAF",
")",
";",
"// It's going to space, will you just give it a second!",
"Util",
".",
"defer",
"(",
"Util",
".",
"partial",
"(",
"Events",
".",
"dispatchEvent",
",",
"scrollParent",
",",
"'scroll'",
")",
",",
"10",
")",
";",
"return",
"Stream",
".",
"map",
"(",
"function",
"getWindowPosition_",
"(",
")",
"{",
"return",
"oldScrollY",
";",
"}",
",",
"didChangeOnRAFStream",
")",
";",
"}"
]
| Create a stream of onscroll events, but only calculate their
position on requestAnimationFrame frames.
@param {Element=} options.scrollTarget - Targeted for scroll checking.
@return {Stream} | [
"Create",
"a",
"stream",
"of",
"onscroll",
"events",
"but",
"only",
"calculate",
"their",
"position",
"on",
"requestAnimationFrame",
"frames",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/streams/scroll-stream.js#L12-L47 |
45,923 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/ImageGridIndex.js | function(image, x, y, options) {
var result = false;
var data = options.data;
if (!data)
return result;
var mask = this._getImageMask(image, options);
var imageMaskWidth = this._getMaskX(image.width);
var maskShiftX = this._getMaskX(x);
var maskShiftY = this._getMaskY(y);
for (var i = 0; i < mask.length; i++) {
if (!mask[i])
continue;
var maskX = maskShiftX + (i % imageMaskWidth);
var maskY = maskShiftY + Math.floor(i / imageMaskWidth);
var key = this._getIndexKey(maskX, maskY);
this._addDataToIndex(key, options);
result = true;
}
return result;
} | javascript | function(image, x, y, options) {
var result = false;
var data = options.data;
if (!data)
return result;
var mask = this._getImageMask(image, options);
var imageMaskWidth = this._getMaskX(image.width);
var maskShiftX = this._getMaskX(x);
var maskShiftY = this._getMaskY(y);
for (var i = 0; i < mask.length; i++) {
if (!mask[i])
continue;
var maskX = maskShiftX + (i % imageMaskWidth);
var maskY = maskShiftY + Math.floor(i / imageMaskWidth);
var key = this._getIndexKey(maskX, maskY);
this._addDataToIndex(key, options);
result = true;
}
return result;
} | [
"function",
"(",
"image",
",",
"x",
",",
"y",
",",
"options",
")",
"{",
"var",
"result",
"=",
"false",
";",
"var",
"data",
"=",
"options",
".",
"data",
";",
"if",
"(",
"!",
"data",
")",
"return",
"result",
";",
"var",
"mask",
"=",
"this",
".",
"_getImageMask",
"(",
"image",
",",
"options",
")",
";",
"var",
"imageMaskWidth",
"=",
"this",
".",
"_getMaskX",
"(",
"image",
".",
"width",
")",
";",
"var",
"maskShiftX",
"=",
"this",
".",
"_getMaskX",
"(",
"x",
")",
";",
"var",
"maskShiftY",
"=",
"this",
".",
"_getMaskY",
"(",
"y",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"mask",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"mask",
"[",
"i",
"]",
")",
"continue",
";",
"var",
"maskX",
"=",
"maskShiftX",
"+",
"(",
"i",
"%",
"imageMaskWidth",
")",
";",
"var",
"maskY",
"=",
"maskShiftY",
"+",
"Math",
".",
"floor",
"(",
"i",
"/",
"imageMaskWidth",
")",
";",
"var",
"key",
"=",
"this",
".",
"_getIndexKey",
"(",
"maskX",
",",
"maskY",
")",
";",
"this",
".",
"_addDataToIndex",
"(",
"key",
",",
"options",
")",
";",
"result",
"=",
"true",
";",
"}",
"return",
"result",
";",
"}"
]
| Adds all pixels occupied by the specified image to a data mask associated
with canvas. | [
"Adds",
"all",
"pixels",
"occupied",
"by",
"the",
"specified",
"image",
"to",
"a",
"data",
"mask",
"associated",
"with",
"canvas",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/ImageGridIndex.js#L13-L32 |
|
45,924 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/ImageGridIndex.js | function(image, options) {
var index = options.imageMaskIndex || this.options.imageMaskIndex;
if (!index)
return;
if (typeof index === 'function') {
index = index(image, options);
}
return index;
} | javascript | function(image, options) {
var index = options.imageMaskIndex || this.options.imageMaskIndex;
if (!index)
return;
if (typeof index === 'function') {
index = index(image, options);
}
return index;
} | [
"function",
"(",
"image",
",",
"options",
")",
"{",
"var",
"index",
"=",
"options",
".",
"imageMaskIndex",
"||",
"this",
".",
"options",
".",
"imageMaskIndex",
";",
"if",
"(",
"!",
"index",
")",
"return",
";",
"if",
"(",
"typeof",
"index",
"===",
"'function'",
")",
"{",
"index",
"=",
"index",
"(",
"image",
",",
"options",
")",
";",
"}",
"return",
"index",
";",
"}"
]
| This method maintain an index of image masks associated with the provided
canvas. This method could be overloaded to implement a global index of
image masks. | [
"This",
"method",
"maintain",
"an",
"index",
"of",
"image",
"masks",
"associated",
"with",
"the",
"provided",
"canvas",
".",
"This",
"method",
"could",
"be",
"overloaded",
"to",
"implement",
"a",
"global",
"index",
"of",
"image",
"masks",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/ImageGridIndex.js#L71-L79 |
|
45,925 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/ImageGridIndex.js | function(image) {
var maskWidth = this._getMaskX(image.width);
var maskHeight = this._getMaskY(image.height);
var buf = this._getResizedImageBuffer(image, maskWidth, maskHeight);
var mask = new Array(maskWidth * maskHeight);
for (var y = 0; y < maskHeight; y++) {
for (var x = 0; x < maskWidth; x++) {
var idx = (y * maskWidth + x);
var filled = this._checkFilledPixel(buf, idx);
mask[idx] = filled ? 1 : 0;
}
}
return mask;
} | javascript | function(image) {
var maskWidth = this._getMaskX(image.width);
var maskHeight = this._getMaskY(image.height);
var buf = this._getResizedImageBuffer(image, maskWidth, maskHeight);
var mask = new Array(maskWidth * maskHeight);
for (var y = 0; y < maskHeight; y++) {
for (var x = 0; x < maskWidth; x++) {
var idx = (y * maskWidth + x);
var filled = this._checkFilledPixel(buf, idx);
mask[idx] = filled ? 1 : 0;
}
}
return mask;
} | [
"function",
"(",
"image",
")",
"{",
"var",
"maskWidth",
"=",
"this",
".",
"_getMaskX",
"(",
"image",
".",
"width",
")",
";",
"var",
"maskHeight",
"=",
"this",
".",
"_getMaskY",
"(",
"image",
".",
"height",
")",
";",
"var",
"buf",
"=",
"this",
".",
"_getResizedImageBuffer",
"(",
"image",
",",
"maskWidth",
",",
"maskHeight",
")",
";",
"var",
"mask",
"=",
"new",
"Array",
"(",
"maskWidth",
"*",
"maskHeight",
")",
";",
"for",
"(",
"var",
"y",
"=",
"0",
";",
"y",
"<",
"maskHeight",
";",
"y",
"++",
")",
"{",
"for",
"(",
"var",
"x",
"=",
"0",
";",
"x",
"<",
"maskWidth",
";",
"x",
"++",
")",
"{",
"var",
"idx",
"=",
"(",
"y",
"*",
"maskWidth",
"+",
"x",
")",
";",
"var",
"filled",
"=",
"this",
".",
"_checkFilledPixel",
"(",
"buf",
",",
"idx",
")",
";",
"mask",
"[",
"idx",
"]",
"=",
"filled",
"?",
"1",
":",
"0",
";",
"}",
"}",
"return",
"mask",
";",
"}"
]
| Creates and returns an image mask. | [
"Creates",
"and",
"returns",
"an",
"image",
"mask",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/ImageGridIndex.js#L82-L95 |
|
45,926 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/ImageGridIndex.js | function(image, width, height) {
var g;
if (image.tagName === 'CANVAS' && image.width === width
&& image.height === height) {
g = image.getContext('2d');
} else {
var canvas = this._newCanvas(width, height);
canvas.width = width;
canvas.height = height;
g = canvas.getContext('2d');
g.drawImage(image, 0, 0, width, height);
}
var data = g.getImageData(0, 0, width, height).data;
return data;
} | javascript | function(image, width, height) {
var g;
if (image.tagName === 'CANVAS' && image.width === width
&& image.height === height) {
g = image.getContext('2d');
} else {
var canvas = this._newCanvas(width, height);
canvas.width = width;
canvas.height = height;
g = canvas.getContext('2d');
g.drawImage(image, 0, 0, width, height);
}
var data = g.getImageData(0, 0, width, height).data;
return data;
} | [
"function",
"(",
"image",
",",
"width",
",",
"height",
")",
"{",
"var",
"g",
";",
"if",
"(",
"image",
".",
"tagName",
"===",
"'CANVAS'",
"&&",
"image",
".",
"width",
"===",
"width",
"&&",
"image",
".",
"height",
"===",
"height",
")",
"{",
"g",
"=",
"image",
".",
"getContext",
"(",
"'2d'",
")",
";",
"}",
"else",
"{",
"var",
"canvas",
"=",
"this",
".",
"_newCanvas",
"(",
"width",
",",
"height",
")",
";",
"canvas",
".",
"width",
"=",
"width",
";",
"canvas",
".",
"height",
"=",
"height",
";",
"g",
"=",
"canvas",
".",
"getContext",
"(",
"'2d'",
")",
";",
"g",
".",
"drawImage",
"(",
"image",
",",
"0",
",",
"0",
",",
"width",
",",
"height",
")",
";",
"}",
"var",
"data",
"=",
"g",
".",
"getImageData",
"(",
"0",
",",
"0",
",",
"width",
",",
"height",
")",
".",
"data",
";",
"return",
"data",
";",
"}"
]
| Returns a raw data for the resized image. | [
"Returns",
"a",
"raw",
"data",
"for",
"the",
"resized",
"image",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/ImageGridIndex.js#L109-L123 |
|
45,927 | tdreyno/morlock.js | core/responsive-image.js | applyAspectRatioPadding | function applyAspectRatioPadding(image) {
var ratioPadding = (image.knownDimensions[1] / image.knownDimensions[0]) * 100.0;
DOM.setStyle(image.element, 'paddingBottom', ratioPadding + '%');
} | javascript | function applyAspectRatioPadding(image) {
var ratioPadding = (image.knownDimensions[1] / image.knownDimensions[0]) * 100.0;
DOM.setStyle(image.element, 'paddingBottom', ratioPadding + '%');
} | [
"function",
"applyAspectRatioPadding",
"(",
"image",
")",
"{",
"var",
"ratioPadding",
"=",
"(",
"image",
".",
"knownDimensions",
"[",
"1",
"]",
"/",
"image",
".",
"knownDimensions",
"[",
"0",
"]",
")",
"*",
"100.0",
";",
"DOM",
".",
"setStyle",
"(",
"image",
".",
"element",
",",
"'paddingBottom'",
",",
"ratioPadding",
"+",
"'%'",
")",
";",
"}"
]
| Set a padding percentage which allows the image to scale proportionally.
@param {ResponsiveImage} image The image data. | [
"Set",
"a",
"padding",
"percentage",
"which",
"allows",
"the",
"image",
"to",
"scale",
"proportionally",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/responsive-image.js#L113-L116 |
45,928 | tdreyno/morlock.js | core/responsive-image.js | getBreakpointSizes | function getBreakpointSizes(element) {
var breakpointString = element.getAttribute('data-breakpoints');
var knownSizes = Util.map(function(s) {
return Util.parseInteger(s);
}, breakpointString ? breakpointString.split(',') : []);
if (knownSizes.length <= 0) {
return [0];
} else {
return Util.sortBy(knownSizes, function sortAscending(a, b) {
return b - a;
});
}
} | javascript | function getBreakpointSizes(element) {
var breakpointString = element.getAttribute('data-breakpoints');
var knownSizes = Util.map(function(s) {
return Util.parseInteger(s);
}, breakpointString ? breakpointString.split(',') : []);
if (knownSizes.length <= 0) {
return [0];
} else {
return Util.sortBy(knownSizes, function sortAscending(a, b) {
return b - a;
});
}
} | [
"function",
"getBreakpointSizes",
"(",
"element",
")",
"{",
"var",
"breakpointString",
"=",
"element",
".",
"getAttribute",
"(",
"'data-breakpoints'",
")",
";",
"var",
"knownSizes",
"=",
"Util",
".",
"map",
"(",
"function",
"(",
"s",
")",
"{",
"return",
"Util",
".",
"parseInteger",
"(",
"s",
")",
";",
"}",
",",
"breakpointString",
"?",
"breakpointString",
".",
"split",
"(",
"','",
")",
":",
"[",
"]",
")",
";",
"if",
"(",
"knownSizes",
".",
"length",
"<=",
"0",
")",
"{",
"return",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"Util",
".",
"sortBy",
"(",
"knownSizes",
",",
"function",
"sortAscending",
"(",
"a",
",",
"b",
")",
"{",
"return",
"b",
"-",
"a",
";",
"}",
")",
";",
"}",
"}"
]
| Parse the breakpoints = require(the `data-breakpoints` attribute.
@param {Element} element The source element.
@return {Array} Sorted array of known sizes. | [
"Parse",
"the",
"breakpoints",
"=",
"require",
"(",
"the",
"data",
"-",
"breakpoints",
"attribute",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/responsive-image.js#L123-L137 |
45,929 | tdreyno/morlock.js | core/responsive-image.js | update | function update(image) {
if (image.lazyLoad) {
return;
}
var rect = DOM.getRect(image.element);
var foundBreakpoint;
for (var i = 0; i < image.knownSizes.length; i++) {
var s = image.knownSizes[i];
if (rect.width <= s) {
foundBreakpoint = s;
} else {
break;
}
}
if (!foundBreakpoint) {
foundBreakpoint = image.knownSizes[0];
}
if (foundBreakpoint !== image.currentBreakpoint || !image.hasRunOnce) {
image.currentBreakpoint = foundBreakpoint;
loadImageForBreakpoint(image, image.currentBreakpoint);
}
} | javascript | function update(image) {
if (image.lazyLoad) {
return;
}
var rect = DOM.getRect(image.element);
var foundBreakpoint;
for (var i = 0; i < image.knownSizes.length; i++) {
var s = image.knownSizes[i];
if (rect.width <= s) {
foundBreakpoint = s;
} else {
break;
}
}
if (!foundBreakpoint) {
foundBreakpoint = image.knownSizes[0];
}
if (foundBreakpoint !== image.currentBreakpoint || !image.hasRunOnce) {
image.currentBreakpoint = foundBreakpoint;
loadImageForBreakpoint(image, image.currentBreakpoint);
}
} | [
"function",
"update",
"(",
"image",
")",
"{",
"if",
"(",
"image",
".",
"lazyLoad",
")",
"{",
"return",
";",
"}",
"var",
"rect",
"=",
"DOM",
".",
"getRect",
"(",
"image",
".",
"element",
")",
";",
"var",
"foundBreakpoint",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"image",
".",
"knownSizes",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"s",
"=",
"image",
".",
"knownSizes",
"[",
"i",
"]",
";",
"if",
"(",
"rect",
".",
"width",
"<=",
"s",
")",
"{",
"foundBreakpoint",
"=",
"s",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"foundBreakpoint",
")",
"{",
"foundBreakpoint",
"=",
"image",
".",
"knownSizes",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"foundBreakpoint",
"!==",
"image",
".",
"currentBreakpoint",
"||",
"!",
"image",
".",
"hasRunOnce",
")",
"{",
"image",
".",
"currentBreakpoint",
"=",
"foundBreakpoint",
";",
"loadImageForBreakpoint",
"(",
"image",
",",
"image",
".",
"currentBreakpoint",
")",
";",
"}",
"}"
]
| Detect the current breakpoint and update the element if necessary. | [
"Detect",
"the",
"current",
"breakpoint",
"and",
"update",
"the",
"element",
"if",
"necessary",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/responsive-image.js#L142-L168 |
45,930 | tdreyno/morlock.js | core/responsive-image.js | loadImageForBreakpoint | function loadImageForBreakpoint(image, s) {
var alreadyLoaded = image.loadedSizes[s];
if ('undefined' !== typeof alreadyLoaded) {
setImage(image, alreadyLoaded);
} else {
var img = new Image();
img.onload = function() {
image.loadedSizes[s] = img;
setImage(image, img);
update(image);
image.hasRunOnce = true;
};
// If requesting retina fails
img.onerror = function() {
if (image.hasRetina && !image.hasLoadedFallback) {
image.hasLoadedFallback = true;
var path = image.getPath(image, s, false);
if (path) {
img.src = path;
}
} else {
image.trigger('error', img);
}
};
var path = image.getPath(image, s, image.hasRetina);
if (path) {
img.src = path;
}
}
} | javascript | function loadImageForBreakpoint(image, s) {
var alreadyLoaded = image.loadedSizes[s];
if ('undefined' !== typeof alreadyLoaded) {
setImage(image, alreadyLoaded);
} else {
var img = new Image();
img.onload = function() {
image.loadedSizes[s] = img;
setImage(image, img);
update(image);
image.hasRunOnce = true;
};
// If requesting retina fails
img.onerror = function() {
if (image.hasRetina && !image.hasLoadedFallback) {
image.hasLoadedFallback = true;
var path = image.getPath(image, s, false);
if (path) {
img.src = path;
}
} else {
image.trigger('error', img);
}
};
var path = image.getPath(image, s, image.hasRetina);
if (path) {
img.src = path;
}
}
} | [
"function",
"loadImageForBreakpoint",
"(",
"image",
",",
"s",
")",
"{",
"var",
"alreadyLoaded",
"=",
"image",
".",
"loadedSizes",
"[",
"s",
"]",
";",
"if",
"(",
"'undefined'",
"!==",
"typeof",
"alreadyLoaded",
")",
"{",
"setImage",
"(",
"image",
",",
"alreadyLoaded",
")",
";",
"}",
"else",
"{",
"var",
"img",
"=",
"new",
"Image",
"(",
")",
";",
"img",
".",
"onload",
"=",
"function",
"(",
")",
"{",
"image",
".",
"loadedSizes",
"[",
"s",
"]",
"=",
"img",
";",
"setImage",
"(",
"image",
",",
"img",
")",
";",
"update",
"(",
"image",
")",
";",
"image",
".",
"hasRunOnce",
"=",
"true",
";",
"}",
";",
"// If requesting retina fails",
"img",
".",
"onerror",
"=",
"function",
"(",
")",
"{",
"if",
"(",
"image",
".",
"hasRetina",
"&&",
"!",
"image",
".",
"hasLoadedFallback",
")",
"{",
"image",
".",
"hasLoadedFallback",
"=",
"true",
";",
"var",
"path",
"=",
"image",
".",
"getPath",
"(",
"image",
",",
"s",
",",
"false",
")",
";",
"if",
"(",
"path",
")",
"{",
"img",
".",
"src",
"=",
"path",
";",
"}",
"}",
"else",
"{",
"image",
".",
"trigger",
"(",
"'error'",
",",
"img",
")",
";",
"}",
"}",
";",
"var",
"path",
"=",
"image",
".",
"getPath",
"(",
"image",
",",
"s",
",",
"image",
".",
"hasRetina",
")",
";",
"if",
"(",
"path",
")",
"{",
"img",
".",
"src",
"=",
"path",
";",
"}",
"}",
"}"
]
| Load the requested image.
@param {ResponsiveImage} image The ResponsiveImage instance.
@param {String} s Filename. | [
"Load",
"the",
"requested",
"image",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/responsive-image.js#L183-L218 |
45,931 | tdreyno/morlock.js | core/responsive-image.js | setImage | function setImage(image, img) {
if (!image.hasLoaded) {
image.hasLoaded = true;
setTimeout(function() {
image.element.className += ' loaded';
}, 100);
}
image.trigger('load', img);
if (image.element.tagName.toLowerCase() === 'img') {
return setImageTag(image, img);
} else {
return setDivTag(image, img);
}
} | javascript | function setImage(image, img) {
if (!image.hasLoaded) {
image.hasLoaded = true;
setTimeout(function() {
image.element.className += ' loaded';
}, 100);
}
image.trigger('load', img);
if (image.element.tagName.toLowerCase() === 'img') {
return setImageTag(image, img);
} else {
return setDivTag(image, img);
}
} | [
"function",
"setImage",
"(",
"image",
",",
"img",
")",
"{",
"if",
"(",
"!",
"image",
".",
"hasLoaded",
")",
"{",
"image",
".",
"hasLoaded",
"=",
"true",
";",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"image",
".",
"element",
".",
"className",
"+=",
"' loaded'",
";",
"}",
",",
"100",
")",
";",
"}",
"image",
".",
"trigger",
"(",
"'load'",
",",
"img",
")",
";",
"if",
"(",
"image",
".",
"element",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
"===",
"'img'",
")",
"{",
"return",
"setImageTag",
"(",
"image",
",",
"img",
")",
";",
"}",
"else",
"{",
"return",
"setDivTag",
"(",
"image",
",",
"img",
")",
";",
"}",
"}"
]
| Set the image on the element.
@param {Element} img Image element. | [
"Set",
"the",
"image",
"on",
"the",
"element",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/responsive-image.js#L224-L240 |
45,932 | tdreyno/morlock.js | core/responsive-image.js | setDivTag | function setDivTag(image, img) {
var setElemStyle = DOM.setStyle(image.element);
setElemStyle('backgroundImage', 'url(' + img.src + ')');
if (image.preserveAspectRatio) {
var w, h;
if (image.knownDimensions) {
w = image.knownDimensions[0];
h = image.knownDimensions[1];
} else {
w = img.width;
h = img.height;
}
setElemStyle('backgroundSize', 'cover');
if (image.isFlexible) {
setElemStyle('paddingBottom', ((h / w) * 100.0) + '%');
} else {
setElemStyle('width', w + 'px');
setElemStyle('height', h + 'px');
}
}
} | javascript | function setDivTag(image, img) {
var setElemStyle = DOM.setStyle(image.element);
setElemStyle('backgroundImage', 'url(' + img.src + ')');
if (image.preserveAspectRatio) {
var w, h;
if (image.knownDimensions) {
w = image.knownDimensions[0];
h = image.knownDimensions[1];
} else {
w = img.width;
h = img.height;
}
setElemStyle('backgroundSize', 'cover');
if (image.isFlexible) {
setElemStyle('paddingBottom', ((h / w) * 100.0) + '%');
} else {
setElemStyle('width', w + 'px');
setElemStyle('height', h + 'px');
}
}
} | [
"function",
"setDivTag",
"(",
"image",
",",
"img",
")",
"{",
"var",
"setElemStyle",
"=",
"DOM",
".",
"setStyle",
"(",
"image",
".",
"element",
")",
";",
"setElemStyle",
"(",
"'backgroundImage'",
",",
"'url('",
"+",
"img",
".",
"src",
"+",
"')'",
")",
";",
"if",
"(",
"image",
".",
"preserveAspectRatio",
")",
"{",
"var",
"w",
",",
"h",
";",
"if",
"(",
"image",
".",
"knownDimensions",
")",
"{",
"w",
"=",
"image",
".",
"knownDimensions",
"[",
"0",
"]",
";",
"h",
"=",
"image",
".",
"knownDimensions",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"w",
"=",
"img",
".",
"width",
";",
"h",
"=",
"img",
".",
"height",
";",
"}",
"setElemStyle",
"(",
"'backgroundSize'",
",",
"'cover'",
")",
";",
"if",
"(",
"image",
".",
"isFlexible",
")",
"{",
"setElemStyle",
"(",
"'paddingBottom'",
",",
"(",
"(",
"h",
"/",
"w",
")",
"*",
"100.0",
")",
"+",
"'%'",
")",
";",
"}",
"else",
"{",
"setElemStyle",
"(",
"'width'",
",",
"w",
"+",
"'px'",
")",
";",
"setElemStyle",
"(",
"'height'",
",",
"h",
"+",
"'px'",
")",
";",
"}",
"}",
"}"
]
| Set the image on the div element.
@param {Element} img Image element. | [
"Set",
"the",
"image",
"on",
"the",
"div",
"element",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/responsive-image.js#L254-L278 |
45,933 | tdreyno/morlock.js | core/responsive-image.js | getPath | function getPath(image, s, wantsRetina) {
if (s === 0) { return image.src; }
var parts = image.src.split('.');
var ext = parts.pop();
return parts.join('.') + '-' + s + (wantsRetina ? '@2x' : '') + '.' + ext;
} | javascript | function getPath(image, s, wantsRetina) {
if (s === 0) { return image.src; }
var parts = image.src.split('.');
var ext = parts.pop();
return parts.join('.') + '-' + s + (wantsRetina ? '@2x' : '') + '.' + ext;
} | [
"function",
"getPath",
"(",
"image",
",",
"s",
",",
"wantsRetina",
")",
"{",
"if",
"(",
"s",
"===",
"0",
")",
"{",
"return",
"image",
".",
"src",
";",
"}",
"var",
"parts",
"=",
"image",
".",
"src",
".",
"split",
"(",
"'.'",
")",
";",
"var",
"ext",
"=",
"parts",
".",
"pop",
"(",
")",
";",
"return",
"parts",
".",
"join",
"(",
"'.'",
")",
"+",
"'-'",
"+",
"s",
"+",
"(",
"wantsRetina",
"?",
"'@2x'",
":",
"''",
")",
"+",
"'.'",
"+",
"ext",
";",
"}"
]
| Get the path for the image given the current breakpoints and
browser features.
@param {ResponsiveImage} image The image data.
@param {String} s Requested path.
@param {boolean} wantsRetina If we should look for retina.
@return {String} The resulting path. | [
"Get",
"the",
"path",
"for",
"the",
"image",
"given",
"the",
"current",
"breakpoints",
"and",
"browser",
"features",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/responsive-image.js#L288-L295 |
45,934 | ramakrishnan/db-migrate-cassandra | index.js | function(tableName, columnName, callback) {
var cqlString = util.format('ALTER TABLE %s DROP %s', tableName, columnName);
return this.runSql(cqlString, callback).nodeify(callback);
} | javascript | function(tableName, columnName, callback) {
var cqlString = util.format('ALTER TABLE %s DROP %s', tableName, columnName);
return this.runSql(cqlString, callback).nodeify(callback);
} | [
"function",
"(",
"tableName",
",",
"columnName",
",",
"callback",
")",
"{",
"var",
"cqlString",
"=",
"util",
".",
"format",
"(",
"'ALTER TABLE %s DROP %s'",
",",
"tableName",
",",
"columnName",
")",
";",
"return",
"this",
".",
"runSql",
"(",
"cqlString",
",",
"callback",
")",
".",
"nodeify",
"(",
"callback",
")",
";",
"}"
]
| Remove a column form an existing table
@param string tableName - The name of the table to be altered
@param string columnName - Name of the column to be removed
@param callback | [
"Remove",
"a",
"column",
"form",
"an",
"existing",
"table"
]
| bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8 | https://github.com/ramakrishnan/db-migrate-cassandra/blob/bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8/index.js#L86-L89 |
|
45,935 | ramakrishnan/db-migrate-cassandra | index.js | function(callback) {
var cqlString = 'SELECT * from migrations';
return this.runSql(cqlString)
.then(function(data) {
var sortedData = data.rows.map(function(item) {
item.moment_time = moment(item.ran_on).valueOf();
return item
});
// Order migration records in ascending order.
return sortedData.sort(function(x,y) {
if (x.moment_time > y.moment_time) return -1;
if (x.moment_time < y.moment_time) return 1;
return 0;
})
})
.nodeify(callback);
} | javascript | function(callback) {
var cqlString = 'SELECT * from migrations';
return this.runSql(cqlString)
.then(function(data) {
var sortedData = data.rows.map(function(item) {
item.moment_time = moment(item.ran_on).valueOf();
return item
});
// Order migration records in ascending order.
return sortedData.sort(function(x,y) {
if (x.moment_time > y.moment_time) return -1;
if (x.moment_time < y.moment_time) return 1;
return 0;
})
})
.nodeify(callback);
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"cqlString",
"=",
"'SELECT * from migrations'",
";",
"return",
"this",
".",
"runSql",
"(",
"cqlString",
")",
".",
"then",
"(",
"function",
"(",
"data",
")",
"{",
"var",
"sortedData",
"=",
"data",
".",
"rows",
".",
"map",
"(",
"function",
"(",
"item",
")",
"{",
"item",
".",
"moment_time",
"=",
"moment",
"(",
"item",
".",
"ran_on",
")",
".",
"valueOf",
"(",
")",
";",
"return",
"item",
"}",
")",
";",
"// Order migration records in ascending order.",
"return",
"sortedData",
".",
"sort",
"(",
"function",
"(",
"x",
",",
"y",
")",
"{",
"if",
"(",
"x",
".",
"moment_time",
">",
"y",
".",
"moment_time",
")",
"return",
"-",
"1",
";",
"if",
"(",
"x",
".",
"moment_time",
"<",
"y",
".",
"moment_time",
")",
"return",
"1",
";",
"return",
"0",
";",
"}",
")",
"}",
")",
".",
"nodeify",
"(",
"callback",
")",
";",
"}"
]
| List all existing migrations
@param callback | [
"List",
"all",
"existing",
"migrations"
]
| bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8 | https://github.com/ramakrishnan/db-migrate-cassandra/blob/bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8/index.js#L121-L137 |
|
45,936 | ramakrishnan/db-migrate-cassandra | index.js | function (name, callback) {
var formattedDate = name.split('-')[0].replace('/', '');
formattedDate = moment(formattedDate, 'YYYY-MM-DD HH:mm:ss');
formattedDate = moment(formattedDate).format('YYYY-MM-DD HH:mm:ss');
var command = util.format('INSERT INTO %s (name, ran_on) VALUES (\'%s\', \'%s\')', internals.migrationTable, name, formattedDate);
return this.runSql(command).nodeify(callback);
} | javascript | function (name, callback) {
var formattedDate = name.split('-')[0].replace('/', '');
formattedDate = moment(formattedDate, 'YYYY-MM-DD HH:mm:ss');
formattedDate = moment(formattedDate).format('YYYY-MM-DD HH:mm:ss');
var command = util.format('INSERT INTO %s (name, ran_on) VALUES (\'%s\', \'%s\')', internals.migrationTable, name, formattedDate);
return this.runSql(command).nodeify(callback);
} | [
"function",
"(",
"name",
",",
"callback",
")",
"{",
"var",
"formattedDate",
"=",
"name",
".",
"split",
"(",
"'-'",
")",
"[",
"0",
"]",
".",
"replace",
"(",
"'/'",
",",
"''",
")",
";",
"formattedDate",
"=",
"moment",
"(",
"formattedDate",
",",
"'YYYY-MM-DD HH:mm:ss'",
")",
";",
"formattedDate",
"=",
"moment",
"(",
"formattedDate",
")",
".",
"format",
"(",
"'YYYY-MM-DD HH:mm:ss'",
")",
";",
"var",
"command",
"=",
"util",
".",
"format",
"(",
"'INSERT INTO %s (name, ran_on) VALUES (\\'%s\\', \\'%s\\')'",
",",
"internals",
".",
"migrationTable",
",",
"name",
",",
"formattedDate",
")",
";",
"return",
"this",
".",
"runSql",
"(",
"command",
")",
".",
"nodeify",
"(",
"callback",
")",
";",
"}"
]
| Add a new migration to migrations table
@param string name - Migration file name
@param callback | [
"Add",
"a",
"new",
"migration",
"to",
"migrations",
"table"
]
| bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8 | https://github.com/ramakrishnan/db-migrate-cassandra/blob/bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8/index.js#L144-L150 |
|
45,937 | ramakrishnan/db-migrate-cassandra | index.js | function(migrationName, callback) {
var command = util.format('DELETE FROM %s where name = \'/%s\'', internals.migrationTable, migrationName);
return this.runSql(command).nodeify(callback);
} | javascript | function(migrationName, callback) {
var command = util.format('DELETE FROM %s where name = \'/%s\'', internals.migrationTable, migrationName);
return this.runSql(command).nodeify(callback);
} | [
"function",
"(",
"migrationName",
",",
"callback",
")",
"{",
"var",
"command",
"=",
"util",
".",
"format",
"(",
"'DELETE FROM %s where name = \\'/%s\\''",
",",
"internals",
".",
"migrationTable",
",",
"migrationName",
")",
";",
"return",
"this",
".",
"runSql",
"(",
"command",
")",
".",
"nodeify",
"(",
"callback",
")",
";",
"}"
]
| Deletes a migration
@param migrationName - The name of the migration to be deleted
@param callback | [
"Deletes",
"a",
"migration"
]
| bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8 | https://github.com/ramakrishnan/db-migrate-cassandra/blob/bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8/index.js#L158-L161 |
|
45,938 | ramakrishnan/db-migrate-cassandra | index.js | function(callback) {
var tableOptions = {
'name': 'varchar',
'ran_on': 'timestamp'
};
var constraints = {
'primary_key': 'name'
};
return this.createTable(internals.migrationTable, tableOptions, constraints).nodeify(callback);
} | javascript | function(callback) {
var tableOptions = {
'name': 'varchar',
'ran_on': 'timestamp'
};
var constraints = {
'primary_key': 'name'
};
return this.createTable(internals.migrationTable, tableOptions, constraints).nodeify(callback);
} | [
"function",
"(",
"callback",
")",
"{",
"var",
"tableOptions",
"=",
"{",
"'name'",
":",
"'varchar'",
",",
"'ran_on'",
":",
"'timestamp'",
"}",
";",
"var",
"constraints",
"=",
"{",
"'primary_key'",
":",
"'name'",
"}",
";",
"return",
"this",
".",
"createTable",
"(",
"internals",
".",
"migrationTable",
",",
"tableOptions",
",",
"constraints",
")",
".",
"nodeify",
"(",
"callback",
")",
";",
"}"
]
| Creates a migration table for the current Cassnadra's keyspace
@param callback | [
"Creates",
"a",
"migration",
"table",
"for",
"the",
"current",
"Cassnadra",
"s",
"keyspace"
]
| bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8 | https://github.com/ramakrishnan/db-migrate-cassandra/blob/bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8/index.js#L174-L183 |
|
45,939 | ramakrishnan/db-migrate-cassandra | index.js | function(command, callback) {
var self = this;
return new Promise(function(resolve, reject) {
var prCB = function(err, data) {
if (err) {
log.error(err.message);
log.debug(command);
}
return (err ? reject('err') : resolve(data));
};
self.connection.execute(command, function(err, result) {
prCB(err, result)
});
});
} | javascript | function(command, callback) {
var self = this;
return new Promise(function(resolve, reject) {
var prCB = function(err, data) {
if (err) {
log.error(err.message);
log.debug(command);
}
return (err ? reject('err') : resolve(data));
};
self.connection.execute(command, function(err, result) {
prCB(err, result)
});
});
} | [
"function",
"(",
"command",
",",
"callback",
")",
"{",
"var",
"self",
"=",
"this",
";",
"return",
"new",
"Promise",
"(",
"function",
"(",
"resolve",
",",
"reject",
")",
"{",
"var",
"prCB",
"=",
"function",
"(",
"err",
",",
"data",
")",
"{",
"if",
"(",
"err",
")",
"{",
"log",
".",
"error",
"(",
"err",
".",
"message",
")",
";",
"log",
".",
"debug",
"(",
"command",
")",
";",
"}",
"return",
"(",
"err",
"?",
"reject",
"(",
"'err'",
")",
":",
"resolve",
"(",
"data",
")",
")",
";",
"}",
";",
"self",
".",
"connection",
".",
"execute",
"(",
"command",
",",
"function",
"(",
"err",
",",
"result",
")",
"{",
"prCB",
"(",
"err",
",",
"result",
")",
"}",
")",
";",
"}",
")",
";",
"}"
]
| Function to execute the CQL statement through cassandra-driver execute method.
@param string command - A Cassandra query to run.
@param Object callback | [
"Function",
"to",
"execute",
"the",
"CQL",
"statement",
"through",
"cassandra",
"-",
"driver",
"execute",
"method",
"."
]
| bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8 | https://github.com/ramakrishnan/db-migrate-cassandra/blob/bd843bd8a94d22f9a87c5b0d9ec1781bc05545f8/index.js#L192-L206 |
|
45,940 | arsduo/elm-rings | example-0.19/elm.js | _Markdown_formatOptions | function _Markdown_formatOptions(options) {
function toHighlight(code, lang) {
if (!lang && elm$core$Maybe$isJust(options.defaultHighlighting)) {
lang = options.defaultHighlighting.a;
}
if (
typeof hljs !== "undefined" &&
lang &&
hljs.listLanguages().indexOf(lang) >= 0
) {
return hljs.highlight(lang, code, true).value;
}
return code;
}
var gfm = options.githubFlavored.a;
return {
highlight: toHighlight,
gfm: gfm,
tables: gfm && gfm.tables,
breaks: gfm && gfm.breaks,
sanitize: options.sanitize,
smartypants: options.smartypants
};
} | javascript | function _Markdown_formatOptions(options) {
function toHighlight(code, lang) {
if (!lang && elm$core$Maybe$isJust(options.defaultHighlighting)) {
lang = options.defaultHighlighting.a;
}
if (
typeof hljs !== "undefined" &&
lang &&
hljs.listLanguages().indexOf(lang) >= 0
) {
return hljs.highlight(lang, code, true).value;
}
return code;
}
var gfm = options.githubFlavored.a;
return {
highlight: toHighlight,
gfm: gfm,
tables: gfm && gfm.tables,
breaks: gfm && gfm.breaks,
sanitize: options.sanitize,
smartypants: options.smartypants
};
} | [
"function",
"_Markdown_formatOptions",
"(",
"options",
")",
"{",
"function",
"toHighlight",
"(",
"code",
",",
"lang",
")",
"{",
"if",
"(",
"!",
"lang",
"&&",
"elm$core$Maybe$isJust",
"(",
"options",
".",
"defaultHighlighting",
")",
")",
"{",
"lang",
"=",
"options",
".",
"defaultHighlighting",
".",
"a",
";",
"}",
"if",
"(",
"typeof",
"hljs",
"!==",
"\"undefined\"",
"&&",
"lang",
"&&",
"hljs",
".",
"listLanguages",
"(",
")",
".",
"indexOf",
"(",
"lang",
")",
">=",
"0",
")",
"{",
"return",
"hljs",
".",
"highlight",
"(",
"lang",
",",
"code",
",",
"true",
")",
".",
"value",
";",
"}",
"return",
"code",
";",
"}",
"var",
"gfm",
"=",
"options",
".",
"githubFlavored",
".",
"a",
";",
"return",
"{",
"highlight",
":",
"toHighlight",
",",
"gfm",
":",
"gfm",
",",
"tables",
":",
"gfm",
"&&",
"gfm",
".",
"tables",
",",
"breaks",
":",
"gfm",
"&&",
"gfm",
".",
"breaks",
",",
"sanitize",
":",
"options",
".",
"sanitize",
",",
"smartypants",
":",
"options",
".",
"smartypants",
"}",
";",
"}"
]
| FORMAT OPTIONS FOR MARKED IMPLEMENTATION | [
"FORMAT",
"OPTIONS",
"FOR",
"MARKED",
"IMPLEMENTATION"
]
| a5af4362ff166a61436c6aa72afae454568719bb | https://github.com/arsduo/elm-rings/blob/a5af4362ff166a61436c6aa72afae454568719bb/example-0.19/elm.js#L5958-L5985 |
45,941 | mosaicjs/Leaflet.CanvasDataGrid | src/canvas/ImageUtils.js | function(g, x, y, width, height, radius) {
g.beginPath();
// a
g.moveTo(x + width / 2, y);
// b
g.bezierCurveTo(//
x + width / 2 + radius / 2, y, //
x + width / 2 + radius, y + radius / 2, //
x + width / 2 + radius, y + radius);
// c
g.bezierCurveTo( //
x + width / 2 + radius, y + radius * 2, //
x + width / 2, y + height / 2 + radius / 3, //
x + width / 2, y + height);
// d
g.bezierCurveTo(//
x + width / 2, y + height / 2 + radius / 3, //
x + width / 2 - radius, y + radius * 2, //
x + width / 2 - radius, y + radius);
// e (a)
g.bezierCurveTo(//
x + width / 2 - radius, y + radius / 2, //
x + width / 2 - radius / 2, y + 0, //
x + width / 2, y + 0);
g.closePath();
} | javascript | function(g, x, y, width, height, radius) {
g.beginPath();
// a
g.moveTo(x + width / 2, y);
// b
g.bezierCurveTo(//
x + width / 2 + radius / 2, y, //
x + width / 2 + radius, y + radius / 2, //
x + width / 2 + radius, y + radius);
// c
g.bezierCurveTo( //
x + width / 2 + radius, y + radius * 2, //
x + width / 2, y + height / 2 + radius / 3, //
x + width / 2, y + height);
// d
g.bezierCurveTo(//
x + width / 2, y + height / 2 + radius / 3, //
x + width / 2 - radius, y + radius * 2, //
x + width / 2 - radius, y + radius);
// e (a)
g.bezierCurveTo(//
x + width / 2 - radius, y + radius / 2, //
x + width / 2 - radius / 2, y + 0, //
x + width / 2, y + 0);
g.closePath();
} | [
"function",
"(",
"g",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"radius",
")",
"{",
"g",
".",
"beginPath",
"(",
")",
";",
"// a",
"g",
".",
"moveTo",
"(",
"x",
"+",
"width",
"/",
"2",
",",
"y",
")",
";",
"// b",
"g",
".",
"bezierCurveTo",
"(",
"//",
"x",
"+",
"width",
"/",
"2",
"+",
"radius",
"/",
"2",
",",
"y",
",",
"//",
"x",
"+",
"width",
"/",
"2",
"+",
"radius",
",",
"y",
"+",
"radius",
"/",
"2",
",",
"//",
"x",
"+",
"width",
"/",
"2",
"+",
"radius",
",",
"y",
"+",
"radius",
")",
";",
"// c",
"g",
".",
"bezierCurveTo",
"(",
"//",
"x",
"+",
"width",
"/",
"2",
"+",
"radius",
",",
"y",
"+",
"radius",
"*",
"2",
",",
"//",
"x",
"+",
"width",
"/",
"2",
",",
"y",
"+",
"height",
"/",
"2",
"+",
"radius",
"/",
"3",
",",
"//",
"x",
"+",
"width",
"/",
"2",
",",
"y",
"+",
"height",
")",
";",
"// d",
"g",
".",
"bezierCurveTo",
"(",
"//",
"x",
"+",
"width",
"/",
"2",
",",
"y",
"+",
"height",
"/",
"2",
"+",
"radius",
"/",
"3",
",",
"//",
"x",
"+",
"width",
"/",
"2",
"-",
"radius",
",",
"y",
"+",
"radius",
"*",
"2",
",",
"//",
"x",
"+",
"width",
"/",
"2",
"-",
"radius",
",",
"y",
"+",
"radius",
")",
";",
"// e (a)",
"g",
".",
"bezierCurveTo",
"(",
"//",
"x",
"+",
"width",
"/",
"2",
"-",
"radius",
",",
"y",
"+",
"radius",
"/",
"2",
",",
"//",
"x",
"+",
"width",
"/",
"2",
"-",
"radius",
"/",
"2",
",",
"y",
"+",
"0",
",",
"//",
"x",
"+",
"width",
"/",
"2",
",",
"y",
"+",
"0",
")",
";",
"g",
".",
"closePath",
"(",
")",
";",
"}"
]
| Draws a simple marker on the specified canvas 2d context. | [
"Draws",
"a",
"simple",
"marker",
"on",
"the",
"specified",
"canvas",
"2d",
"context",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/canvas/ImageUtils.js#L6-L31 |
|
45,942 | mosaicjs/Leaflet.CanvasDataGrid | src/data/GeometryUtils.js | simplifyDouglasPeucker | function simplifyDouglasPeucker(points, sqTolerance) {
var len = points.length;
var MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array
: Array;
var markers = new MarkerArray(len);
var first = 0;
var last = len - 1;
var stack = [];
var newPoints = [];
var i;
var maxSqDist;
var sqDist;
var index;
markers[first] = markers[last] = 1;
while (last) {
maxSqDist = 0;
for (i = first + 1; i < last; i++) {
sqDist = getSqSegDist(points[i], points[first],
points[last]);
if (sqDist > maxSqDist) {
index = i;
maxSqDist = sqDist;
}
}
if (maxSqDist > sqTolerance) {
markers[index] = 1;
stack.push(first, index, index, last);
}
last = stack.pop();
first = stack.pop();
}
for (i = 0; i < len; i++) {
if (markers[i])
newPoints.push(points[i]);
}
return newPoints;
} | javascript | function simplifyDouglasPeucker(points, sqTolerance) {
var len = points.length;
var MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array
: Array;
var markers = new MarkerArray(len);
var first = 0;
var last = len - 1;
var stack = [];
var newPoints = [];
var i;
var maxSqDist;
var sqDist;
var index;
markers[first] = markers[last] = 1;
while (last) {
maxSqDist = 0;
for (i = first + 1; i < last; i++) {
sqDist = getSqSegDist(points[i], points[first],
points[last]);
if (sqDist > maxSqDist) {
index = i;
maxSqDist = sqDist;
}
}
if (maxSqDist > sqTolerance) {
markers[index] = 1;
stack.push(first, index, index, last);
}
last = stack.pop();
first = stack.pop();
}
for (i = 0; i < len; i++) {
if (markers[i])
newPoints.push(points[i]);
}
return newPoints;
} | [
"function",
"simplifyDouglasPeucker",
"(",
"points",
",",
"sqTolerance",
")",
"{",
"var",
"len",
"=",
"points",
".",
"length",
";",
"var",
"MarkerArray",
"=",
"typeof",
"Uint8Array",
"!==",
"'undefined'",
"?",
"Uint8Array",
":",
"Array",
";",
"var",
"markers",
"=",
"new",
"MarkerArray",
"(",
"len",
")",
";",
"var",
"first",
"=",
"0",
";",
"var",
"last",
"=",
"len",
"-",
"1",
";",
"var",
"stack",
"=",
"[",
"]",
";",
"var",
"newPoints",
"=",
"[",
"]",
";",
"var",
"i",
";",
"var",
"maxSqDist",
";",
"var",
"sqDist",
";",
"var",
"index",
";",
"markers",
"[",
"first",
"]",
"=",
"markers",
"[",
"last",
"]",
"=",
"1",
";",
"while",
"(",
"last",
")",
"{",
"maxSqDist",
"=",
"0",
";",
"for",
"(",
"i",
"=",
"first",
"+",
"1",
";",
"i",
"<",
"last",
";",
"i",
"++",
")",
"{",
"sqDist",
"=",
"getSqSegDist",
"(",
"points",
"[",
"i",
"]",
",",
"points",
"[",
"first",
"]",
",",
"points",
"[",
"last",
"]",
")",
";",
"if",
"(",
"sqDist",
">",
"maxSqDist",
")",
"{",
"index",
"=",
"i",
";",
"maxSqDist",
"=",
"sqDist",
";",
"}",
"}",
"if",
"(",
"maxSqDist",
">",
"sqTolerance",
")",
"{",
"markers",
"[",
"index",
"]",
"=",
"1",
";",
"stack",
".",
"push",
"(",
"first",
",",
"index",
",",
"index",
",",
"last",
")",
";",
"}",
"last",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"first",
"=",
"stack",
".",
"pop",
"(",
")",
";",
"}",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"if",
"(",
"markers",
"[",
"i",
"]",
")",
"newPoints",
".",
"push",
"(",
"points",
"[",
"i",
"]",
")",
";",
"}",
"return",
"newPoints",
";",
"}"
]
| simplification using optimized Douglas-Peucker algorithm with recursion elimination | [
"simplification",
"using",
"optimized",
"Douglas",
"-",
"Peucker",
"algorithm",
"with",
"recursion",
"elimination"
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/GeometryUtils.js#L250-L296 |
45,943 | mosaicjs/Leaflet.CanvasDataGrid | src/data/GeometryUtils.js | simplify | function simplify(points, tolerance, highestQuality) {
if (points.length <= 1)
return points;
var sqTolerance = tolerance !== undefined ? tolerance * tolerance
: 1;
points = highestQuality ? points : simplifyRadialDist(points,
sqTolerance);
points = simplifyDouglasPeucker(points, sqTolerance);
return points;
} | javascript | function simplify(points, tolerance, highestQuality) {
if (points.length <= 1)
return points;
var sqTolerance = tolerance !== undefined ? tolerance * tolerance
: 1;
points = highestQuality ? points : simplifyRadialDist(points,
sqTolerance);
points = simplifyDouglasPeucker(points, sqTolerance);
return points;
} | [
"function",
"simplify",
"(",
"points",
",",
"tolerance",
",",
"highestQuality",
")",
"{",
"if",
"(",
"points",
".",
"length",
"<=",
"1",
")",
"return",
"points",
";",
"var",
"sqTolerance",
"=",
"tolerance",
"!==",
"undefined",
"?",
"tolerance",
"*",
"tolerance",
":",
"1",
";",
"points",
"=",
"highestQuality",
"?",
"points",
":",
"simplifyRadialDist",
"(",
"points",
",",
"sqTolerance",
")",
";",
"points",
"=",
"simplifyDouglasPeucker",
"(",
"points",
",",
"sqTolerance",
")",
";",
"return",
"points",
";",
"}"
]
| both algorithms combined for awesome performance | [
"both",
"algorithms",
"combined",
"for",
"awesome",
"performance"
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/GeometryUtils.js#L299-L312 |
45,944 | mosaicjs/Leaflet.CanvasDataGrid | src/data/GeometryUtils.js | function(polygons, clipPolygon) {
var result = [];
for (var i = 0; i < polygons.length; i++) {
var r = this.clipPolygon(polygons[i], clipPolygon);
if (r && r.length) {
result.push(r);
}
}
return result;
} | javascript | function(polygons, clipPolygon) {
var result = [];
for (var i = 0; i < polygons.length; i++) {
var r = this.clipPolygon(polygons[i], clipPolygon);
if (r && r.length) {
result.push(r);
}
}
return result;
} | [
"function",
"(",
"polygons",
",",
"clipPolygon",
")",
"{",
"var",
"result",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"polygons",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"r",
"=",
"this",
".",
"clipPolygon",
"(",
"polygons",
"[",
"i",
"]",
",",
"clipPolygon",
")",
";",
"if",
"(",
"r",
"&&",
"r",
".",
"length",
")",
"{",
"result",
".",
"push",
"(",
"r",
")",
";",
"}",
"}",
"return",
"result",
";",
"}"
]
| Returns an interection of a list of polygons with the specified clip
polygon | [
"Returns",
"an",
"interection",
"of",
"a",
"list",
"of",
"polygons",
"with",
"the",
"specified",
"clip",
"polygon"
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/GeometryUtils.js#L402-L411 |
|
45,945 | weexteam/weex-templater | lib/richtext.js | format | function format(node) {
var ret = node.children.map(function (child) {
var val = stringify(child)
val = val.replace(/\"function\s*\(\)\s*{\s*return\s*(.*?)}\"/g, function ($0, $1) {
return $1
}).replace(/\"([^,]*?)\":/g, function ($0, $1) {
return $1 + ': '
}).replace(/(,)(\S)/g, function ($0, $1, $2) {
return $1 + ' ' + $2
}).replace(/\"/g, '\'')
var hasClassList = false
val = val.replace(/classList:\s*\[(.*?)\]/g, function ($0, $1) {
var styleMatch = val.match(/,\s*style:\s*({.*?})/)
hasClassList = true
var classArr = $1.trim().split(/\s*,\s*/).map(function (klass) {
return '_s[' + klass + ']'
})
classArr.unshift(styleMatch && styleMatch[1] ? styleMatch[1] : '{}')
return 'style: (function () { var _s = this._css; return Object.assign(' + classArr.join(', ') + '); }).call(this)'
})
if (hasClassList) {
val = val.replace(/,\s*style:\s*({.*?})/g, '')
}
return val
});
delete node.children
node.attr = node.attr || {}
node.attr.value = eval('(function () {return [' + ret.join(', ') + ']})')
} | javascript | function format(node) {
var ret = node.children.map(function (child) {
var val = stringify(child)
val = val.replace(/\"function\s*\(\)\s*{\s*return\s*(.*?)}\"/g, function ($0, $1) {
return $1
}).replace(/\"([^,]*?)\":/g, function ($0, $1) {
return $1 + ': '
}).replace(/(,)(\S)/g, function ($0, $1, $2) {
return $1 + ' ' + $2
}).replace(/\"/g, '\'')
var hasClassList = false
val = val.replace(/classList:\s*\[(.*?)\]/g, function ($0, $1) {
var styleMatch = val.match(/,\s*style:\s*({.*?})/)
hasClassList = true
var classArr = $1.trim().split(/\s*,\s*/).map(function (klass) {
return '_s[' + klass + ']'
})
classArr.unshift(styleMatch && styleMatch[1] ? styleMatch[1] : '{}')
return 'style: (function () { var _s = this._css; return Object.assign(' + classArr.join(', ') + '); }).call(this)'
})
if (hasClassList) {
val = val.replace(/,\s*style:\s*({.*?})/g, '')
}
return val
});
delete node.children
node.attr = node.attr || {}
node.attr.value = eval('(function () {return [' + ret.join(', ') + ']})')
} | [
"function",
"format",
"(",
"node",
")",
"{",
"var",
"ret",
"=",
"node",
".",
"children",
".",
"map",
"(",
"function",
"(",
"child",
")",
"{",
"var",
"val",
"=",
"stringify",
"(",
"child",
")",
"val",
"=",
"val",
".",
"replace",
"(",
"/",
"\\\"function\\s*\\(\\)\\s*{\\s*return\\s*(.*?)}\\\"",
"/",
"g",
",",
"function",
"(",
"$0",
",",
"$1",
")",
"{",
"return",
"$1",
"}",
")",
".",
"replace",
"(",
"/",
"\\\"([^,]*?)\\\":",
"/",
"g",
",",
"function",
"(",
"$0",
",",
"$1",
")",
"{",
"return",
"$1",
"+",
"': '",
"}",
")",
".",
"replace",
"(",
"/",
"(,)(\\S)",
"/",
"g",
",",
"function",
"(",
"$0",
",",
"$1",
",",
"$2",
")",
"{",
"return",
"$1",
"+",
"' '",
"+",
"$2",
"}",
")",
".",
"replace",
"(",
"/",
"\\\"",
"/",
"g",
",",
"'\\''",
")",
"var",
"hasClassList",
"=",
"false",
"val",
"=",
"val",
".",
"replace",
"(",
"/",
"classList:\\s*\\[(.*?)\\]",
"/",
"g",
",",
"function",
"(",
"$0",
",",
"$1",
")",
"{",
"var",
"styleMatch",
"=",
"val",
".",
"match",
"(",
"/",
",\\s*style:\\s*({.*?})",
"/",
")",
"hasClassList",
"=",
"true",
"var",
"classArr",
"=",
"$1",
".",
"trim",
"(",
")",
".",
"split",
"(",
"/",
"\\s*,\\s*",
"/",
")",
".",
"map",
"(",
"function",
"(",
"klass",
")",
"{",
"return",
"'_s['",
"+",
"klass",
"+",
"']'",
"}",
")",
"classArr",
".",
"unshift",
"(",
"styleMatch",
"&&",
"styleMatch",
"[",
"1",
"]",
"?",
"styleMatch",
"[",
"1",
"]",
":",
"'{}'",
")",
"return",
"'style: (function () { var _s = this._css; return Object.assign('",
"+",
"classArr",
".",
"join",
"(",
"', '",
")",
"+",
"'); }).call(this)'",
"}",
")",
"if",
"(",
"hasClassList",
")",
"{",
"val",
"=",
"val",
".",
"replace",
"(",
"/",
",\\s*style:\\s*({.*?})",
"/",
"g",
",",
"''",
")",
"}",
"return",
"val",
"}",
")",
";",
"delete",
"node",
".",
"children",
"node",
".",
"attr",
"=",
"node",
".",
"attr",
"||",
"{",
"}",
"node",
".",
"attr",
".",
"value",
"=",
"eval",
"(",
"'(function () {return ['",
"+",
"ret",
".",
"join",
"(",
"', '",
")",
"+",
"']})'",
")",
"}"
]
| format richtext root node
- children -> attr.value binding function
@param {Node} node
TODO: support event | [
"format",
"richtext",
"root",
"node",
"-",
"children",
"-",
">",
"attr",
".",
"value",
"binding",
"function"
]
| 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/richtext.js#L17-L47 |
45,946 | weexteam/weex-templater | lib/richtext.js | walkAndFormat | function walkAndFormat(node) {
if (node) {
if (node.append !== 'once') {
if (node.children && node.children.length) {
for (var i = 0, len = node.children.length; i < len; i++) {
walkAndFormat(node.children[i])
}
}
}
else {
format(node)
}
}
} | javascript | function walkAndFormat(node) {
if (node) {
if (node.append !== 'once') {
if (node.children && node.children.length) {
for (var i = 0, len = node.children.length; i < len; i++) {
walkAndFormat(node.children[i])
}
}
}
else {
format(node)
}
}
} | [
"function",
"walkAndFormat",
"(",
"node",
")",
"{",
"if",
"(",
"node",
")",
"{",
"if",
"(",
"node",
".",
"append",
"!==",
"'once'",
")",
"{",
"if",
"(",
"node",
".",
"children",
"&&",
"node",
".",
"children",
".",
"length",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
",",
"len",
"=",
"node",
".",
"children",
".",
"length",
";",
"i",
"<",
"len",
";",
"i",
"++",
")",
"{",
"walkAndFormat",
"(",
"node",
".",
"children",
"[",
"i",
"]",
")",
"}",
"}",
"}",
"else",
"{",
"format",
"(",
"node",
")",
"}",
"}",
"}"
]
| walk all nodes and format richtext root node
@param {Node} node | [
"walk",
"all",
"nodes",
"and",
"format",
"richtext",
"root",
"node"
]
| 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/richtext.js#L54-L67 |
45,947 | waka/gulp-sprockets | src/builders/scss.js | assetHashPath | function assetHashPath(url) {
const parsedUrl = path.parse(url.getValue());
const asset = manifest.getAssetValue(parsedUrl.base);
return compiler.types.String('url("' + asset + '")');
} | javascript | function assetHashPath(url) {
const parsedUrl = path.parse(url.getValue());
const asset = manifest.getAssetValue(parsedUrl.base);
return compiler.types.String('url("' + asset + '")');
} | [
"function",
"assetHashPath",
"(",
"url",
")",
"{",
"const",
"parsedUrl",
"=",
"path",
".",
"parse",
"(",
"url",
".",
"getValue",
"(",
")",
")",
";",
"const",
"asset",
"=",
"manifest",
".",
"getAssetValue",
"(",
"parsedUrl",
".",
"base",
")",
";",
"return",
"compiler",
".",
"types",
".",
"String",
"(",
"'url(\"'",
"+",
"asset",
"+",
"'\")'",
")",
";",
"}"
]
| Return file path from manifest.
@param {String} url .
@return {String} Manifest path. | [
"Return",
"file",
"path",
"from",
"manifest",
"."
]
| cb60c0973b3bc2aa347870aa879ce6f2fa0d5a3f | https://github.com/waka/gulp-sprockets/blob/cb60c0973b3bc2aa347870aa879ce6f2fa0d5a3f/src/builders/scss.js#L18-L22 |
45,948 | waka/gulp-sprockets | src/builders/scss.js | assetPath | function assetPath(url) {
const parsedUrl = path.parse(url.getValue());
return compiler.types.String('url("' + parsedUrl.base + '")');
} | javascript | function assetPath(url) {
const parsedUrl = path.parse(url.getValue());
return compiler.types.String('url("' + parsedUrl.base + '")');
} | [
"function",
"assetPath",
"(",
"url",
")",
"{",
"const",
"parsedUrl",
"=",
"path",
".",
"parse",
"(",
"url",
".",
"getValue",
"(",
")",
")",
";",
"return",
"compiler",
".",
"types",
".",
"String",
"(",
"'url(\"'",
"+",
"parsedUrl",
".",
"base",
"+",
"'\")'",
")",
";",
"}"
]
| Return file path.
@param {String} url .
@return {String} Raw asset path. | [
"Return",
"file",
"path",
"."
]
| cb60c0973b3bc2aa347870aa879ce6f2fa0d5a3f | https://github.com/waka/gulp-sprockets/blob/cb60c0973b3bc2aa347870aa879ce6f2fa0d5a3f/src/builders/scss.js#L30-L33 |
45,949 | dkozar/raycast-dom | build/lookup/evaluateClassName.js | evaluateClassName | function evaluateClassName(sub, element) {
var className = BLANK_STRING + element.className + BLANK_STRING;
sub = BLANK_STRING + sub + BLANK_STRING;
return className && className.indexOf(sub) > -1;
} | javascript | function evaluateClassName(sub, element) {
var className = BLANK_STRING + element.className + BLANK_STRING;
sub = BLANK_STRING + sub + BLANK_STRING;
return className && className.indexOf(sub) > -1;
} | [
"function",
"evaluateClassName",
"(",
"sub",
",",
"element",
")",
"{",
"var",
"className",
"=",
"BLANK_STRING",
"+",
"element",
".",
"className",
"+",
"BLANK_STRING",
";",
"sub",
"=",
"BLANK_STRING",
"+",
"sub",
"+",
"BLANK_STRING",
";",
"return",
"className",
"&&",
"className",
".",
"indexOf",
"(",
"sub",
")",
">",
"-",
"1",
";",
"}"
]
| Checks whether the substring is present within element className
@param sub Substring to check for
@param element DOM element
@returns {*|boolean} | [
"Checks",
"whether",
"the",
"substring",
"is",
"present",
"within",
"element",
"className"
]
| 91eb7ad1fbc4c91f8f3ccca69a33e1083f6d5d98 | https://github.com/dkozar/raycast-dom/blob/91eb7ad1fbc4c91f8f3ccca69a33e1083f6d5d98/build/lookup/evaluateClassName.js#L15-L20 |
45,950 | akonoupakis/mongodb-proxy | lib/Store.js | function () {
OptionsProcessor.apply(this, arguments)
this._single = false
this._cached = false
this._resolved = true
this._query = undefined
this._fields = undefined
this._options = {
limit: 500
}
} | javascript | function () {
OptionsProcessor.apply(this, arguments)
this._single = false
this._cached = false
this._resolved = true
this._query = undefined
this._fields = undefined
this._options = {
limit: 500
}
} | [
"function",
"(",
")",
"{",
"OptionsProcessor",
".",
"apply",
"(",
"this",
",",
"arguments",
")",
"this",
".",
"_single",
"=",
"false",
"this",
".",
"_cached",
"=",
"false",
"this",
".",
"_resolved",
"=",
"true",
"this",
".",
"_query",
"=",
"undefined",
"this",
".",
"_fields",
"=",
"undefined",
"this",
".",
"_options",
"=",
"{",
"limit",
":",
"500",
"}",
"}"
]
| The processor for get actions.
@constructor | [
"The",
"processor",
"for",
"get",
"actions",
"."
]
| d0b3a9f6dea525f6dafdaa3084b7aefd51c7f577 | https://github.com/akonoupakis/mongodb-proxy/blob/d0b3a9f6dea525f6dafdaa3084b7aefd51c7f577/lib/Store.js#L1113-L1125 |
|
45,951 | tdreyno/morlock.js | core/util.js | indexOf | function indexOf(list, item) {
if (NATIVE_ARRAY_INDEXOF) {
return NATIVE_ARRAY_INDEXOF.call(list, item);
}
for (var i = 0; i < list.length; i++) {
if (list[i] === item) {
return i;
}
}
return -1;
} | javascript | function indexOf(list, item) {
if (NATIVE_ARRAY_INDEXOF) {
return NATIVE_ARRAY_INDEXOF.call(list, item);
}
for (var i = 0; i < list.length; i++) {
if (list[i] === item) {
return i;
}
}
return -1;
} | [
"function",
"indexOf",
"(",
"list",
",",
"item",
")",
"{",
"if",
"(",
"NATIVE_ARRAY_INDEXOF",
")",
"{",
"return",
"NATIVE_ARRAY_INDEXOF",
".",
"call",
"(",
"list",
",",
"item",
")",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"list",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"list",
"[",
"i",
"]",
"===",
"item",
")",
"{",
"return",
"i",
";",
"}",
"}",
"return",
"-",
"1",
";",
"}"
]
| Backwards compatible Array.prototype.indexOf
@param {array} list List of items.
@param {object} item Item to search for.
@return {number} Index of match or -1 if not found. | [
"Backwards",
"compatible",
"Array",
".",
"prototype",
".",
"indexOf"
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L44-L56 |
45,952 | tdreyno/morlock.js | core/util.js | throttle | function throttle(f, delay) {
var timeoutId;
var previous = 0;
return function throttleExecute_() {
var args = arguments;
var now = +(new Date());
var remaining = delay - (now - previous);
if (remaining <= 0) {
clearTimeout(timeoutId);
timeoutId = null;
previous = now;
f.apply(null, args);
} else if (!timeoutId) {
timeoutId = setTimeout(function() {
previous = +(new Date());
timeoutId = null;
f.apply(null, args);
}, remaining);
}
};
} | javascript | function throttle(f, delay) {
var timeoutId;
var previous = 0;
return function throttleExecute_() {
var args = arguments;
var now = +(new Date());
var remaining = delay - (now - previous);
if (remaining <= 0) {
clearTimeout(timeoutId);
timeoutId = null;
previous = now;
f.apply(null, args);
} else if (!timeoutId) {
timeoutId = setTimeout(function() {
previous = +(new Date());
timeoutId = null;
f.apply(null, args);
}, remaining);
}
};
} | [
"function",
"throttle",
"(",
"f",
",",
"delay",
")",
"{",
"var",
"timeoutId",
";",
"var",
"previous",
"=",
"0",
";",
"return",
"function",
"throttleExecute_",
"(",
")",
"{",
"var",
"args",
"=",
"arguments",
";",
"var",
"now",
"=",
"+",
"(",
"new",
"Date",
"(",
")",
")",
";",
"var",
"remaining",
"=",
"delay",
"-",
"(",
"now",
"-",
"previous",
")",
";",
"if",
"(",
"remaining",
"<=",
"0",
")",
"{",
"clearTimeout",
"(",
"timeoutId",
")",
";",
"timeoutId",
"=",
"null",
";",
"previous",
"=",
"now",
";",
"f",
".",
"apply",
"(",
"null",
",",
"args",
")",
";",
"}",
"else",
"if",
"(",
"!",
"timeoutId",
")",
"{",
"timeoutId",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"previous",
"=",
"+",
"(",
"new",
"Date",
"(",
")",
")",
";",
"timeoutId",
"=",
"null",
";",
"f",
".",
"apply",
"(",
"null",
",",
"args",
")",
";",
"}",
",",
"remaining",
")",
";",
"}",
"}",
";",
"}"
]
| Throttle a function.
@param {function} f The function.
@param {number} delay The delay in ms.
@return {function} A function which calls the passed-in function throttled. | [
"Throttle",
"a",
"function",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L64-L88 |
45,953 | tdreyno/morlock.js | core/util.js | debounce | function debounce(f, delay) {
var timeoutId = null;
return function debounceExecute_() {
clearTimeout(timeoutId);
var lastArgs = arguments;
timeoutId = setTimeout(function() {
timeoutId = null;
f.apply(null, lastArgs);
}, delay);
};
} | javascript | function debounce(f, delay) {
var timeoutId = null;
return function debounceExecute_() {
clearTimeout(timeoutId);
var lastArgs = arguments;
timeoutId = setTimeout(function() {
timeoutId = null;
f.apply(null, lastArgs);
}, delay);
};
} | [
"function",
"debounce",
"(",
"f",
",",
"delay",
")",
"{",
"var",
"timeoutId",
"=",
"null",
";",
"return",
"function",
"debounceExecute_",
"(",
")",
"{",
"clearTimeout",
"(",
"timeoutId",
")",
";",
"var",
"lastArgs",
"=",
"arguments",
";",
"timeoutId",
"=",
"setTimeout",
"(",
"function",
"(",
")",
"{",
"timeoutId",
"=",
"null",
";",
"f",
".",
"apply",
"(",
"null",
",",
"lastArgs",
")",
";",
"}",
",",
"delay",
")",
";",
"}",
";",
"}"
]
| Debounce a function.
@param {function} f The function.
@param {number} delay The delay in ms.
@return {function} A function which calls the passed-in function debounced. | [
"Debounce",
"a",
"function",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L96-L108 |
45,954 | tdreyno/morlock.js | core/util.js | forEach | function forEach(f, arr) {
if (NATIVE_ARRAY_FOREACH) {
if (arr) {
NATIVE_ARRAY_FOREACH.call(arr, f);
}
return;
}
for (var i = 0; i < arr.length; i++) {
f(arr[i], i, arr);
}
} | javascript | function forEach(f, arr) {
if (NATIVE_ARRAY_FOREACH) {
if (arr) {
NATIVE_ARRAY_FOREACH.call(arr, f);
}
return;
}
for (var i = 0; i < arr.length; i++) {
f(arr[i], i, arr);
}
} | [
"function",
"forEach",
"(",
"f",
",",
"arr",
")",
"{",
"if",
"(",
"NATIVE_ARRAY_FOREACH",
")",
"{",
"if",
"(",
"arr",
")",
"{",
"NATIVE_ARRAY_FOREACH",
".",
"call",
"(",
"arr",
",",
"f",
")",
";",
"}",
"return",
";",
"}",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"arr",
".",
"length",
";",
"i",
"++",
")",
"{",
"f",
"(",
"arr",
"[",
"i",
"]",
",",
"i",
",",
"arr",
")",
";",
"}",
"}"
]
| Loop a function over an object, for side-effects.
@param {object} obj The object.
@param {function} f The function. | [
"Loop",
"a",
"function",
"over",
"an",
"object",
"for",
"side",
"-",
"effects",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L216-L228 |
45,955 | tdreyno/morlock.js | core/util.js | objectKeys | function objectKeys(obj) {
if (!obj) { return null; }
if (Object.keys) {
return Object.keys(obj);
}
var out = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
out.push(key);
}
}
return out;
} | javascript | function objectKeys(obj) {
if (!obj) { return null; }
if (Object.keys) {
return Object.keys(obj);
}
var out = [];
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
out.push(key);
}
}
return out;
} | [
"function",
"objectKeys",
"(",
"obj",
")",
"{",
"if",
"(",
"!",
"obj",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"Object",
".",
"keys",
")",
"{",
"return",
"Object",
".",
"keys",
"(",
"obj",
")",
";",
"}",
"var",
"out",
"=",
"[",
"]",
";",
"for",
"(",
"var",
"key",
"in",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"hasOwnProperty",
"(",
"key",
")",
")",
"{",
"out",
".",
"push",
"(",
"key",
")",
";",
"}",
"}",
"return",
"out",
";",
"}"
]
| Get the keys of an object.
@param {object} obj The object.
@return {array} An array of keys. | [
"Get",
"the",
"keys",
"of",
"an",
"object",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L235-L251 |
45,956 | tdreyno/morlock.js | core/util.js | eq | function eq(a, b, aStack, bStack) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if (a === b) {
return a !== 0 || 1 / a == 1 / b;
}
// A strict comparison is necessary because `null == undefined`.
if (a == null || b == null) {
return a === b;
}
// Compare `[[Class]]` names.
var className = a.toString();
if (className != b.toString()) {
return false;
}
switch (className) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `'5'` is
// equivalent to `new String('5')`.
return a == String(b);
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a == +b;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') {
return false;
}
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted = require(ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (aStack[length] == a) {
return bStack[length] == b;
}
}
// Objects with different constructors are not equivalent, but `Object`s
// = require(different frames are.
var aCtor = a.constructor, bCtor = b.constructor;
if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) &&
isFunction(bCtor) && (bCtor instanceof bCtor)) &&
('constructor' in a && 'constructor' in b)) {
return false;
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
bStack.push(b);
var size = 0, result = true;
// Recursively compare objects and arrays.
if (className == '[object Array]') {
// Compare array lengths to determine if a deep comparison is necessary.
size = a.length;
result = size == b.length;
if (result) {
// Deep compare the contents, ignoring non-numeric properties.
while (size--) {
if (!(result = eq(a[size], b[size], aStack, bStack))) {
break;
}
}
}
} else {
// Deep compare objects.
for (var key in a) {
if (has(a, key)) {
// Count the expected number of properties.
size++;
// Deep compare each member.
if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack))) {
break;
}
}
}
// Ensure that both objects contain the same number of properties.
if (result) {
for (key in b) {
if (has(b, key) && !(size--)) {
break;
}
}
result = !size;
}
}
// Remove the first object = require(the stack of traversed objects.
aStack.pop();
bStack.pop();
return result;
} | javascript | function eq(a, b, aStack, bStack) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if (a === b) {
return a !== 0 || 1 / a == 1 / b;
}
// A strict comparison is necessary because `null == undefined`.
if (a == null || b == null) {
return a === b;
}
// Compare `[[Class]]` names.
var className = a.toString();
if (className != b.toString()) {
return false;
}
switch (className) {
// Strings, numbers, dates, and booleans are compared by value.
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `'5'` is
// equivalent to `new String('5')`.
return a == String(b);
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
// other numeric values.
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a == +b;
// RegExps are compared by their source patterns and flags.
case '[object RegExp]':
return a.source == b.source &&
a.global == b.global &&
a.multiline == b.multiline &&
a.ignoreCase == b.ignoreCase;
}
if (typeof a != 'object' || typeof b != 'object') {
return false;
}
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted = require(ES 5.1 section 15.12.3, abstract operation `JO`.
var length = aStack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (aStack[length] == a) {
return bStack[length] == b;
}
}
// Objects with different constructors are not equivalent, but `Object`s
// = require(different frames are.
var aCtor = a.constructor, bCtor = b.constructor;
if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) &&
isFunction(bCtor) && (bCtor instanceof bCtor)) &&
('constructor' in a && 'constructor' in b)) {
return false;
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
bStack.push(b);
var size = 0, result = true;
// Recursively compare objects and arrays.
if (className == '[object Array]') {
// Compare array lengths to determine if a deep comparison is necessary.
size = a.length;
result = size == b.length;
if (result) {
// Deep compare the contents, ignoring non-numeric properties.
while (size--) {
if (!(result = eq(a[size], b[size], aStack, bStack))) {
break;
}
}
}
} else {
// Deep compare objects.
for (var key in a) {
if (has(a, key)) {
// Count the expected number of properties.
size++;
// Deep compare each member.
if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack))) {
break;
}
}
}
// Ensure that both objects contain the same number of properties.
if (result) {
for (key in b) {
if (has(b, key) && !(size--)) {
break;
}
}
result = !size;
}
}
// Remove the first object = require(the stack of traversed objects.
aStack.pop();
bStack.pop();
return result;
} | [
"function",
"eq",
"(",
"a",
",",
"b",
",",
"aStack",
",",
"bStack",
")",
"{",
"// Identical objects are equal. `0 === -0`, but they aren't identical.",
"// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).",
"if",
"(",
"a",
"===",
"b",
")",
"{",
"return",
"a",
"!==",
"0",
"||",
"1",
"/",
"a",
"==",
"1",
"/",
"b",
";",
"}",
"// A strict comparison is necessary because `null == undefined`.",
"if",
"(",
"a",
"==",
"null",
"||",
"b",
"==",
"null",
")",
"{",
"return",
"a",
"===",
"b",
";",
"}",
"// Compare `[[Class]]` names.",
"var",
"className",
"=",
"a",
".",
"toString",
"(",
")",
";",
"if",
"(",
"className",
"!=",
"b",
".",
"toString",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"switch",
"(",
"className",
")",
"{",
"// Strings, numbers, dates, and booleans are compared by value.",
"case",
"'[object String]'",
":",
"// Primitives and their corresponding object wrappers are equivalent; thus, `'5'` is",
"// equivalent to `new String('5')`.",
"return",
"a",
"==",
"String",
"(",
"b",
")",
";",
"case",
"'[object Number]'",
":",
"// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for",
"// other numeric values.",
"return",
"a",
"!=",
"+",
"a",
"?",
"b",
"!=",
"+",
"b",
":",
"(",
"a",
"==",
"0",
"?",
"1",
"/",
"a",
"==",
"1",
"/",
"b",
":",
"a",
"==",
"+",
"b",
")",
";",
"case",
"'[object Date]'",
":",
"case",
"'[object Boolean]'",
":",
"// Coerce dates and booleans to numeric primitive values. Dates are compared by their",
"// millisecond representations. Note that invalid dates with millisecond representations",
"// of `NaN` are not equivalent.",
"return",
"+",
"a",
"==",
"+",
"b",
";",
"// RegExps are compared by their source patterns and flags.",
"case",
"'[object RegExp]'",
":",
"return",
"a",
".",
"source",
"==",
"b",
".",
"source",
"&&",
"a",
".",
"global",
"==",
"b",
".",
"global",
"&&",
"a",
".",
"multiline",
"==",
"b",
".",
"multiline",
"&&",
"a",
".",
"ignoreCase",
"==",
"b",
".",
"ignoreCase",
";",
"}",
"if",
"(",
"typeof",
"a",
"!=",
"'object'",
"||",
"typeof",
"b",
"!=",
"'object'",
")",
"{",
"return",
"false",
";",
"}",
"// Assume equality for cyclic structures. The algorithm for detecting cyclic",
"// structures is adapted = require(ES 5.1 section 15.12.3, abstract operation `JO`.",
"var",
"length",
"=",
"aStack",
".",
"length",
";",
"while",
"(",
"length",
"--",
")",
"{",
"// Linear search. Performance is inversely proportional to the number of",
"// unique nested structures.",
"if",
"(",
"aStack",
"[",
"length",
"]",
"==",
"a",
")",
"{",
"return",
"bStack",
"[",
"length",
"]",
"==",
"b",
";",
"}",
"}",
"// Objects with different constructors are not equivalent, but `Object`s",
"// = require(different frames are.",
"var",
"aCtor",
"=",
"a",
".",
"constructor",
",",
"bCtor",
"=",
"b",
".",
"constructor",
";",
"if",
"(",
"aCtor",
"!==",
"bCtor",
"&&",
"!",
"(",
"isFunction",
"(",
"aCtor",
")",
"&&",
"(",
"aCtor",
"instanceof",
"aCtor",
")",
"&&",
"isFunction",
"(",
"bCtor",
")",
"&&",
"(",
"bCtor",
"instanceof",
"bCtor",
")",
")",
"&&",
"(",
"'constructor'",
"in",
"a",
"&&",
"'constructor'",
"in",
"b",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Add the first object to the stack of traversed objects.",
"aStack",
".",
"push",
"(",
"a",
")",
";",
"bStack",
".",
"push",
"(",
"b",
")",
";",
"var",
"size",
"=",
"0",
",",
"result",
"=",
"true",
";",
"// Recursively compare objects and arrays.",
"if",
"(",
"className",
"==",
"'[object Array]'",
")",
"{",
"// Compare array lengths to determine if a deep comparison is necessary.",
"size",
"=",
"a",
".",
"length",
";",
"result",
"=",
"size",
"==",
"b",
".",
"length",
";",
"if",
"(",
"result",
")",
"{",
"// Deep compare the contents, ignoring non-numeric properties.",
"while",
"(",
"size",
"--",
")",
"{",
"if",
"(",
"!",
"(",
"result",
"=",
"eq",
"(",
"a",
"[",
"size",
"]",
",",
"b",
"[",
"size",
"]",
",",
"aStack",
",",
"bStack",
")",
")",
")",
"{",
"break",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"// Deep compare objects.",
"for",
"(",
"var",
"key",
"in",
"a",
")",
"{",
"if",
"(",
"has",
"(",
"a",
",",
"key",
")",
")",
"{",
"// Count the expected number of properties.",
"size",
"++",
";",
"// Deep compare each member.",
"if",
"(",
"!",
"(",
"result",
"=",
"has",
"(",
"b",
",",
"key",
")",
"&&",
"eq",
"(",
"a",
"[",
"key",
"]",
",",
"b",
"[",
"key",
"]",
",",
"aStack",
",",
"bStack",
")",
")",
")",
"{",
"break",
";",
"}",
"}",
"}",
"// Ensure that both objects contain the same number of properties.",
"if",
"(",
"result",
")",
"{",
"for",
"(",
"key",
"in",
"b",
")",
"{",
"if",
"(",
"has",
"(",
"b",
",",
"key",
")",
"&&",
"!",
"(",
"size",
"--",
")",
")",
"{",
"break",
";",
"}",
"}",
"result",
"=",
"!",
"size",
";",
"}",
"}",
"// Remove the first object = require(the stack of traversed objects.",
"aStack",
".",
"pop",
"(",
")",
";",
"bStack",
".",
"pop",
"(",
")",
";",
"return",
"result",
";",
"}"
]
| Recursive comparison function for `isEqual`. | [
"Recursive",
"comparison",
"function",
"for",
"isEqual",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L346-L457 |
45,957 | tdreyno/morlock.js | core/util.js | functionBind | function functionBind(f, obj) {
if (NATIVE_FUNCTION_BIND) {
return NATIVE_FUNCTION_BIND.call(f, obj);
}
return function boundFunction_() {
return f.apply(obj, arguments);
};
} | javascript | function functionBind(f, obj) {
if (NATIVE_FUNCTION_BIND) {
return NATIVE_FUNCTION_BIND.call(f, obj);
}
return function boundFunction_() {
return f.apply(obj, arguments);
};
} | [
"function",
"functionBind",
"(",
"f",
",",
"obj",
")",
"{",
"if",
"(",
"NATIVE_FUNCTION_BIND",
")",
"{",
"return",
"NATIVE_FUNCTION_BIND",
".",
"call",
"(",
"f",
",",
"obj",
")",
";",
"}",
"return",
"function",
"boundFunction_",
"(",
")",
"{",
"return",
"f",
".",
"apply",
"(",
"obj",
",",
"arguments",
")",
";",
"}",
";",
"}"
]
| Bind a function's 'this' value.
@param {function} f The function.
@param {object} obj The object.
@return {function} The bound function. | [
"Bind",
"a",
"function",
"s",
"this",
"value",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L491-L499 |
45,958 | tdreyno/morlock.js | core/util.js | partial | function partial(f /*, args*/) {
var args = rest(arguments);
if (NATIVE_FUNCTION_BIND) {
args.unshift(undefined);
return NATIVE_FUNCTION_BIND.apply(f, args);
}
return function partialExecute_() {
var args2 = slice(arguments, 0);
return f.apply(this, args.concat(args2));
};
} | javascript | function partial(f /*, args*/) {
var args = rest(arguments);
if (NATIVE_FUNCTION_BIND) {
args.unshift(undefined);
return NATIVE_FUNCTION_BIND.apply(f, args);
}
return function partialExecute_() {
var args2 = slice(arguments, 0);
return f.apply(this, args.concat(args2));
};
} | [
"function",
"partial",
"(",
"f",
"/*, args*/",
")",
"{",
"var",
"args",
"=",
"rest",
"(",
"arguments",
")",
";",
"if",
"(",
"NATIVE_FUNCTION_BIND",
")",
"{",
"args",
".",
"unshift",
"(",
"undefined",
")",
";",
"return",
"NATIVE_FUNCTION_BIND",
".",
"apply",
"(",
"f",
",",
"args",
")",
";",
"}",
"return",
"function",
"partialExecute_",
"(",
")",
"{",
"var",
"args2",
"=",
"slice",
"(",
"arguments",
",",
"0",
")",
";",
"return",
"f",
".",
"apply",
"(",
"this",
",",
"args",
".",
"concat",
"(",
"args2",
")",
")",
";",
"}",
";",
"}"
]
| Partially apply a function. | [
"Partially",
"apply",
"a",
"function",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/util.js#L504-L516 |
45,959 | mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(options) {
this.options = options || {};
if (typeof this.options.getGeometry === 'function') {
this.getGeometry = this.options.getGeometry;
}
this.setData(this.options.data);
} | javascript | function(options) {
this.options = options || {};
if (typeof this.options.getGeometry === 'function') {
this.getGeometry = this.options.getGeometry;
}
this.setData(this.options.data);
} | [
"function",
"(",
"options",
")",
"{",
"this",
".",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"typeof",
"this",
".",
"options",
".",
"getGeometry",
"===",
"'function'",
")",
"{",
"this",
".",
"getGeometry",
"=",
"this",
".",
"options",
".",
"getGeometry",
";",
"}",
"this",
".",
"setData",
"(",
"this",
".",
"options",
".",
"data",
")",
";",
"}"
]
| Initializes this object and indexes the initial data set. | [
"Initializes",
"this",
"object",
"and",
"indexes",
"the",
"initial",
"data",
"set",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L15-L21 |
|
45,960 | mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(options, callback) {
var that = this;
var data = that._searchInBbox(options.bbox);
callback(null, data);
} | javascript | function(options, callback) {
var that = this;
var data = that._searchInBbox(options.bbox);
callback(null, data);
} | [
"function",
"(",
"options",
",",
"callback",
")",
"{",
"var",
"that",
"=",
"this",
";",
"var",
"data",
"=",
"that",
".",
"_searchInBbox",
"(",
"options",
".",
"bbox",
")",
";",
"callback",
"(",
"null",
",",
"data",
")",
";",
"}"
]
| Loads and returns indexed data contained in the specified bounding box.
@param options.bbox
a bounding box used to search data | [
"Loads",
"and",
"returns",
"indexed",
"data",
"contained",
"in",
"the",
"specified",
"bounding",
"box",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L34-L38 |
|
45,961 | mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(data) {
// Data indexing
this._rtree = rbush(9);
data = data || [];
var array = [];
var that = this;
function index(d) {
var bbox = that._getBoundingBox(d);
if (bbox) {
var key = that._toIndexKey(bbox);
key.data = d;
array.push(key);
}
}
if (typeof data === 'function') {
data = data();
}
if (typeof data.forEach === 'function') {
data.forEach(index);
} else if (data.length) {
for (var i = 0; i < data.length; i++) {
index(data[i]);
}
}
this._rtree.load(array);
} | javascript | function(data) {
// Data indexing
this._rtree = rbush(9);
data = data || [];
var array = [];
var that = this;
function index(d) {
var bbox = that._getBoundingBox(d);
if (bbox) {
var key = that._toIndexKey(bbox);
key.data = d;
array.push(key);
}
}
if (typeof data === 'function') {
data = data();
}
if (typeof data.forEach === 'function') {
data.forEach(index);
} else if (data.length) {
for (var i = 0; i < data.length; i++) {
index(data[i]);
}
}
this._rtree.load(array);
} | [
"function",
"(",
"data",
")",
"{",
"// Data indexing",
"this",
".",
"_rtree",
"=",
"rbush",
"(",
"9",
")",
";",
"data",
"=",
"data",
"||",
"[",
"]",
";",
"var",
"array",
"=",
"[",
"]",
";",
"var",
"that",
"=",
"this",
";",
"function",
"index",
"(",
"d",
")",
"{",
"var",
"bbox",
"=",
"that",
".",
"_getBoundingBox",
"(",
"d",
")",
";",
"if",
"(",
"bbox",
")",
"{",
"var",
"key",
"=",
"that",
".",
"_toIndexKey",
"(",
"bbox",
")",
";",
"key",
".",
"data",
"=",
"d",
";",
"array",
".",
"push",
"(",
"key",
")",
";",
"}",
"}",
"if",
"(",
"typeof",
"data",
"===",
"'function'",
")",
"{",
"data",
"=",
"data",
"(",
")",
";",
"}",
"if",
"(",
"typeof",
"data",
".",
"forEach",
"===",
"'function'",
")",
"{",
"data",
".",
"forEach",
"(",
"index",
")",
";",
"}",
"else",
"if",
"(",
"data",
".",
"length",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"data",
".",
"length",
";",
"i",
"++",
")",
"{",
"index",
"(",
"data",
"[",
"i",
"]",
")",
";",
"}",
"}",
"this",
".",
"_rtree",
".",
"load",
"(",
"array",
")",
";",
"}"
]
| Indexes the specified data array using a RTree index. | [
"Indexes",
"the",
"specified",
"data",
"array",
"using",
"a",
"RTree",
"index",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L41-L66 |
|
45,962 | mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(bbox) {
var coords = this._toIndexKey(bbox);
var array = this._rtree.search(coords);
array = this._sortByDistance(array, bbox);
var result = [];
var filterMultiPoints = !!this.options.filterPoints;
for (var i = 0; i < array.length; i++) {
var arr = array[i];
var r = arr.data;
var geometry = this.getGeometry(r);
var handled = false;
GeoJsonUtils.forEachGeometry(geometry, {
onPoints : function(points) {
if (!handled
&& (!filterMultiPoints || GeometryUtils
.bboxContainsPoints(points, bbox))) {
result.push(r);
handled = true;
}
},
onLines : function(lines) {
if (!handled
&& GeometryUtils.bboxIntersectsLines(lines, bbox)) {
result.push(r);
handled = true;
}
},
onPolygons : function(polygons) {
if (!handled
&& GeometryUtils.bboxIntersectsPolygonsWithHoles(
polygons, bbox)) {
result.push(r);
handled = true;
}
}
});
}
return result;
} | javascript | function(bbox) {
var coords = this._toIndexKey(bbox);
var array = this._rtree.search(coords);
array = this._sortByDistance(array, bbox);
var result = [];
var filterMultiPoints = !!this.options.filterPoints;
for (var i = 0; i < array.length; i++) {
var arr = array[i];
var r = arr.data;
var geometry = this.getGeometry(r);
var handled = false;
GeoJsonUtils.forEachGeometry(geometry, {
onPoints : function(points) {
if (!handled
&& (!filterMultiPoints || GeometryUtils
.bboxContainsPoints(points, bbox))) {
result.push(r);
handled = true;
}
},
onLines : function(lines) {
if (!handled
&& GeometryUtils.bboxIntersectsLines(lines, bbox)) {
result.push(r);
handled = true;
}
},
onPolygons : function(polygons) {
if (!handled
&& GeometryUtils.bboxIntersectsPolygonsWithHoles(
polygons, bbox)) {
result.push(r);
handled = true;
}
}
});
}
return result;
} | [
"function",
"(",
"bbox",
")",
"{",
"var",
"coords",
"=",
"this",
".",
"_toIndexKey",
"(",
"bbox",
")",
";",
"var",
"array",
"=",
"this",
".",
"_rtree",
".",
"search",
"(",
"coords",
")",
";",
"array",
"=",
"this",
".",
"_sortByDistance",
"(",
"array",
",",
"bbox",
")",
";",
"var",
"result",
"=",
"[",
"]",
";",
"var",
"filterMultiPoints",
"=",
"!",
"!",
"this",
".",
"options",
".",
"filterPoints",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"array",
".",
"length",
";",
"i",
"++",
")",
"{",
"var",
"arr",
"=",
"array",
"[",
"i",
"]",
";",
"var",
"r",
"=",
"arr",
".",
"data",
";",
"var",
"geometry",
"=",
"this",
".",
"getGeometry",
"(",
"r",
")",
";",
"var",
"handled",
"=",
"false",
";",
"GeoJsonUtils",
".",
"forEachGeometry",
"(",
"geometry",
",",
"{",
"onPoints",
":",
"function",
"(",
"points",
")",
"{",
"if",
"(",
"!",
"handled",
"&&",
"(",
"!",
"filterMultiPoints",
"||",
"GeometryUtils",
".",
"bboxContainsPoints",
"(",
"points",
",",
"bbox",
")",
")",
")",
"{",
"result",
".",
"push",
"(",
"r",
")",
";",
"handled",
"=",
"true",
";",
"}",
"}",
",",
"onLines",
":",
"function",
"(",
"lines",
")",
"{",
"if",
"(",
"!",
"handled",
"&&",
"GeometryUtils",
".",
"bboxIntersectsLines",
"(",
"lines",
",",
"bbox",
")",
")",
"{",
"result",
".",
"push",
"(",
"r",
")",
";",
"handled",
"=",
"true",
";",
"}",
"}",
",",
"onPolygons",
":",
"function",
"(",
"polygons",
")",
"{",
"if",
"(",
"!",
"handled",
"&&",
"GeometryUtils",
".",
"bboxIntersectsPolygonsWithHoles",
"(",
"polygons",
",",
"bbox",
")",
")",
"{",
"result",
".",
"push",
"(",
"r",
")",
";",
"handled",
"=",
"true",
";",
"}",
"}",
"}",
")",
";",
"}",
"return",
"result",
";",
"}"
]
| Searches resources in the specified bounding box. | [
"Searches",
"resources",
"in",
"the",
"specified",
"bounding",
"box",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L69-L107 |
|
45,963 | mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(array, bbox) {
if (typeof this.options.sort === 'function') {
this._sortByDistance = this.options.sort;
} else {
this._sortByDistance = function(array, bbox) {
var p = bbox[0];
array.sort(function(a, b) {
var d = (a[1] - p[1]) - (b[1] - p[1]);
if (d === 0) {
d = (a[0] - p[0]) - (b[0] - p[0]);
}
return d;
});
return array;
}
}
return this._sortByDistance(array, bbox);
} | javascript | function(array, bbox) {
if (typeof this.options.sort === 'function') {
this._sortByDistance = this.options.sort;
} else {
this._sortByDistance = function(array, bbox) {
var p = bbox[0];
array.sort(function(a, b) {
var d = (a[1] - p[1]) - (b[1] - p[1]);
if (d === 0) {
d = (a[0] - p[0]) - (b[0] - p[0]);
}
return d;
});
return array;
}
}
return this._sortByDistance(array, bbox);
} | [
"function",
"(",
"array",
",",
"bbox",
")",
"{",
"if",
"(",
"typeof",
"this",
".",
"options",
".",
"sort",
"===",
"'function'",
")",
"{",
"this",
".",
"_sortByDistance",
"=",
"this",
".",
"options",
".",
"sort",
";",
"}",
"else",
"{",
"this",
".",
"_sortByDistance",
"=",
"function",
"(",
"array",
",",
"bbox",
")",
"{",
"var",
"p",
"=",
"bbox",
"[",
"0",
"]",
";",
"array",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
"{",
"var",
"d",
"=",
"(",
"a",
"[",
"1",
"]",
"-",
"p",
"[",
"1",
"]",
")",
"-",
"(",
"b",
"[",
"1",
"]",
"-",
"p",
"[",
"1",
"]",
")",
";",
"if",
"(",
"d",
"===",
"0",
")",
"{",
"d",
"=",
"(",
"a",
"[",
"0",
"]",
"-",
"p",
"[",
"0",
"]",
")",
"-",
"(",
"b",
"[",
"0",
"]",
"-",
"p",
"[",
"0",
"]",
")",
";",
"}",
"return",
"d",
";",
"}",
")",
";",
"return",
"array",
";",
"}",
"}",
"return",
"this",
".",
"_sortByDistance",
"(",
"array",
",",
"bbox",
")",
";",
"}"
]
| Sorts the given data array | [
"Sorts",
"the",
"given",
"data",
"array"
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L112-L129 |
|
45,964 | mosaicjs/Leaflet.CanvasDataGrid | src/data/DataProvider.js | function(bbox) {
var a = +bbox[0][0], b = +bbox[0][1], c = +bbox[1][0], d = +bbox[1][1];
return [ Math.min(a, c), Math.min(b, d), Math.max(a, c), Math.max(b, d) ];
} | javascript | function(bbox) {
var a = +bbox[0][0], b = +bbox[0][1], c = +bbox[1][0], d = +bbox[1][1];
return [ Math.min(a, c), Math.min(b, d), Math.max(a, c), Math.max(b, d) ];
} | [
"function",
"(",
"bbox",
")",
"{",
"var",
"a",
"=",
"+",
"bbox",
"[",
"0",
"]",
"[",
"0",
"]",
",",
"b",
"=",
"+",
"bbox",
"[",
"0",
"]",
"[",
"1",
"]",
",",
"c",
"=",
"+",
"bbox",
"[",
"1",
"]",
"[",
"0",
"]",
",",
"d",
"=",
"+",
"bbox",
"[",
"1",
"]",
"[",
"1",
"]",
";",
"return",
"[",
"Math",
".",
"min",
"(",
"a",
",",
"c",
")",
",",
"Math",
".",
"min",
"(",
"b",
",",
"d",
")",
",",
"Math",
".",
"max",
"(",
"a",
",",
"c",
")",
",",
"Math",
".",
"max",
"(",
"b",
",",
"d",
")",
"]",
";",
"}"
]
| This method transforms a bounding box into a key for RTree index. | [
"This",
"method",
"transforms",
"a",
"bounding",
"box",
"into",
"a",
"key",
"for",
"RTree",
"index",
"."
]
| ebf193b12c390ef2b00b6faa2be878751d0b1fc3 | https://github.com/mosaicjs/Leaflet.CanvasDataGrid/blob/ebf193b12c390ef2b00b6faa2be878751d0b1fc3/src/data/DataProvider.js#L134-L137 |
|
45,965 | weexteam/weex-templater | lib/parsers/text.js | parseText | function parseText(text) {
text = text.replace(/\n/g, '')
/* istanbul ignore if */
if (!tagRE.test(text)) {
return null
}
var tokens = []
var lastIndex = tagRE.lastIndex = 0
var match, index, html, value, first, oneTime
/* eslint-disable no-cond-assign */
while (match = tagRE.exec(text)) {
/* eslint-enable no-cond-assign */
index = match.index
// push text token
if (index > lastIndex) {
tokens.push({
value: text.slice(lastIndex, index)
})
}
// tag token
html = htmlRE.test(match[0])
value = html ? match[1] : match[2]
first = value.charCodeAt(0)
oneTime = first === 42 // *
value = oneTime
? value.slice(1)
: value
tokens.push({
tag: true,
value: value.trim(),
html: html,
oneTime: oneTime
})
lastIndex = index + match[0].length
}
if (lastIndex < text.length) {
tokens.push({
value: text.slice(lastIndex)
})
}
return tokens
} | javascript | function parseText(text) {
text = text.replace(/\n/g, '')
/* istanbul ignore if */
if (!tagRE.test(text)) {
return null
}
var tokens = []
var lastIndex = tagRE.lastIndex = 0
var match, index, html, value, first, oneTime
/* eslint-disable no-cond-assign */
while (match = tagRE.exec(text)) {
/* eslint-enable no-cond-assign */
index = match.index
// push text token
if (index > lastIndex) {
tokens.push({
value: text.slice(lastIndex, index)
})
}
// tag token
html = htmlRE.test(match[0])
value = html ? match[1] : match[2]
first = value.charCodeAt(0)
oneTime = first === 42 // *
value = oneTime
? value.slice(1)
: value
tokens.push({
tag: true,
value: value.trim(),
html: html,
oneTime: oneTime
})
lastIndex = index + match[0].length
}
if (lastIndex < text.length) {
tokens.push({
value: text.slice(lastIndex)
})
}
return tokens
} | [
"function",
"parseText",
"(",
"text",
")",
"{",
"text",
"=",
"text",
".",
"replace",
"(",
"/",
"\\n",
"/",
"g",
",",
"''",
")",
"/* istanbul ignore if */",
"if",
"(",
"!",
"tagRE",
".",
"test",
"(",
"text",
")",
")",
"{",
"return",
"null",
"}",
"var",
"tokens",
"=",
"[",
"]",
"var",
"lastIndex",
"=",
"tagRE",
".",
"lastIndex",
"=",
"0",
"var",
"match",
",",
"index",
",",
"html",
",",
"value",
",",
"first",
",",
"oneTime",
"/* eslint-disable no-cond-assign */",
"while",
"(",
"match",
"=",
"tagRE",
".",
"exec",
"(",
"text",
")",
")",
"{",
"/* eslint-enable no-cond-assign */",
"index",
"=",
"match",
".",
"index",
"// push text token",
"if",
"(",
"index",
">",
"lastIndex",
")",
"{",
"tokens",
".",
"push",
"(",
"{",
"value",
":",
"text",
".",
"slice",
"(",
"lastIndex",
",",
"index",
")",
"}",
")",
"}",
"// tag token",
"html",
"=",
"htmlRE",
".",
"test",
"(",
"match",
"[",
"0",
"]",
")",
"value",
"=",
"html",
"?",
"match",
"[",
"1",
"]",
":",
"match",
"[",
"2",
"]",
"first",
"=",
"value",
".",
"charCodeAt",
"(",
"0",
")",
"oneTime",
"=",
"first",
"===",
"42",
"// *",
"value",
"=",
"oneTime",
"?",
"value",
".",
"slice",
"(",
"1",
")",
":",
"value",
"tokens",
".",
"push",
"(",
"{",
"tag",
":",
"true",
",",
"value",
":",
"value",
".",
"trim",
"(",
")",
",",
"html",
":",
"html",
",",
"oneTime",
":",
"oneTime",
"}",
")",
"lastIndex",
"=",
"index",
"+",
"match",
"[",
"0",
"]",
".",
"length",
"}",
"if",
"(",
"lastIndex",
"<",
"text",
".",
"length",
")",
"{",
"tokens",
".",
"push",
"(",
"{",
"value",
":",
"text",
".",
"slice",
"(",
"lastIndex",
")",
"}",
")",
"}",
"return",
"tokens",
"}"
]
| Parse a template text string into an array of tokens.
@param {String} text
@return {Array<Object> | null}
- {String} type
- {String} value
- {Boolean} [html]
- {Boolean} [oneTime] | [
"Parse",
"a",
"template",
"text",
"string",
"into",
"an",
"array",
"of",
"tokens",
"."
]
| 200c1fbeb923b70e304193752fdf1db9802650c7 | https://github.com/weexteam/weex-templater/blob/200c1fbeb923b70e304193752fdf1db9802650c7/lib/parsers/text.js#L16-L57 |
45,966 | tdreyno/morlock.js | core/dom.js | makeViewportGetter_ | function makeViewportGetter_(dimension, inner, client) {
if (testMQ('(min-' + dimension + ':' + window[inner] + 'px)')) {
return function getWindowDimension_() {
return window[inner];
};
} else {
var docElem = document.documentElement;
return function getDocumentDimension_() {
return docElem[client];
};
}
} | javascript | function makeViewportGetter_(dimension, inner, client) {
if (testMQ('(min-' + dimension + ':' + window[inner] + 'px)')) {
return function getWindowDimension_() {
return window[inner];
};
} else {
var docElem = document.documentElement;
return function getDocumentDimension_() {
return docElem[client];
};
}
} | [
"function",
"makeViewportGetter_",
"(",
"dimension",
",",
"inner",
",",
"client",
")",
"{",
"if",
"(",
"testMQ",
"(",
"'(min-'",
"+",
"dimension",
"+",
"':'",
"+",
"window",
"[",
"inner",
"]",
"+",
"'px)'",
")",
")",
"{",
"return",
"function",
"getWindowDimension_",
"(",
")",
"{",
"return",
"window",
"[",
"inner",
"]",
";",
"}",
";",
"}",
"else",
"{",
"var",
"docElem",
"=",
"document",
".",
"documentElement",
";",
"return",
"function",
"getDocumentDimension_",
"(",
")",
"{",
"return",
"docElem",
"[",
"client",
"]",
";",
"}",
";",
"}",
"}"
]
| Return a function which gets the viewport width or height.
@private
@param {String} dimension The dimension to look up.
@param {String} inner The inner dimension.
@param {String} client The client dimension.
@return {function} The getter function. | [
"Return",
"a",
"function",
"which",
"gets",
"the",
"viewport",
"width",
"or",
"height",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/dom.js#L19-L30 |
45,967 | tdreyno/morlock.js | core/dom.js | documentScrollY | function documentScrollY(targetElement) {
if (targetElement && (targetElement !== window)) {
return targetElement.scrollTop;
}
if (detectedIE10_ && (window.pageYOffset != document.documentElement.scrollTop)) {
return document.documentElement.scrollTop;
}
return window.pageYOffset || document.documentElement.scrollTop;
} | javascript | function documentScrollY(targetElement) {
if (targetElement && (targetElement !== window)) {
return targetElement.scrollTop;
}
if (detectedIE10_ && (window.pageYOffset != document.documentElement.scrollTop)) {
return document.documentElement.scrollTop;
}
return window.pageYOffset || document.documentElement.scrollTop;
} | [
"function",
"documentScrollY",
"(",
"targetElement",
")",
"{",
"if",
"(",
"targetElement",
"&&",
"(",
"targetElement",
"!==",
"window",
")",
")",
"{",
"return",
"targetElement",
".",
"scrollTop",
";",
"}",
"if",
"(",
"detectedIE10_",
"&&",
"(",
"window",
".",
"pageYOffset",
"!=",
"document",
".",
"documentElement",
".",
"scrollTop",
")",
")",
"{",
"return",
"document",
".",
"documentElement",
".",
"scrollTop",
";",
"}",
"return",
"window",
".",
"pageYOffset",
"||",
"document",
".",
"documentElement",
".",
"scrollTop",
";",
"}"
]
| Get the document scroll.
@param {Element} targetElement - Optional target element.
@return {number} | [
"Get",
"the",
"document",
"scroll",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/dom.js#L42-L52 |
45,968 | tdreyno/morlock.js | core/dom.js | getRect | function getRect(elem) {
if (elem && !elem.nodeType) {
elem = elem[0];
}
if (!elem || 1 !== elem.nodeType) {
return false;
}
var bounds = elem.getBoundingClientRect();
return {
height: bounds.bottom - bounds.top,
width: bounds.right - bounds.left,
top: bounds.top,
left: bounds.left
};
} | javascript | function getRect(elem) {
if (elem && !elem.nodeType) {
elem = elem[0];
}
if (!elem || 1 !== elem.nodeType) {
return false;
}
var bounds = elem.getBoundingClientRect();
return {
height: bounds.bottom - bounds.top,
width: bounds.right - bounds.left,
top: bounds.top,
left: bounds.left
};
} | [
"function",
"getRect",
"(",
"elem",
")",
"{",
"if",
"(",
"elem",
"&&",
"!",
"elem",
".",
"nodeType",
")",
"{",
"elem",
"=",
"elem",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"!",
"elem",
"||",
"1",
"!==",
"elem",
".",
"nodeType",
")",
"{",
"return",
"false",
";",
"}",
"var",
"bounds",
"=",
"elem",
".",
"getBoundingClientRect",
"(",
")",
";",
"return",
"{",
"height",
":",
"bounds",
".",
"bottom",
"-",
"bounds",
".",
"top",
",",
"width",
":",
"bounds",
".",
"right",
"-",
"bounds",
".",
"left",
",",
"top",
":",
"bounds",
".",
"top",
",",
"left",
":",
"bounds",
".",
"left",
"}",
";",
"}"
]
| Calculate the rectangle of the element with an optional buffer.
@param {Element} elem The element.
@param {number} buffer An extra padding. | [
"Calculate",
"the",
"rectangle",
"of",
"the",
"element",
"with",
"an",
"optional",
"buffer",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/core/dom.js#L59-L76 |
45,969 | wercker/directory-to-object | index.js | dto | function dto(opts, cb) {
opts = 'string' == typeof opts
? {path: opts}
: opts
const path = opts.path || process.cwd()
cb = cb || function(){}
assert.equal(typeof path, 'string')
assert.equal(typeof cb, 'function')
saveDirs(path, {}, function(err, res) {
if (err) return cb(err)
saveFiles(path, opts, res, cb)
})
} | javascript | function dto(opts, cb) {
opts = 'string' == typeof opts
? {path: opts}
: opts
const path = opts.path || process.cwd()
cb = cb || function(){}
assert.equal(typeof path, 'string')
assert.equal(typeof cb, 'function')
saveDirs(path, {}, function(err, res) {
if (err) return cb(err)
saveFiles(path, opts, res, cb)
})
} | [
"function",
"dto",
"(",
"opts",
",",
"cb",
")",
"{",
"opts",
"=",
"'string'",
"==",
"typeof",
"opts",
"?",
"{",
"path",
":",
"opts",
"}",
":",
"opts",
"const",
"path",
"=",
"opts",
".",
"path",
"||",
"process",
".",
"cwd",
"(",
")",
"cb",
"=",
"cb",
"||",
"function",
"(",
")",
"{",
"}",
"assert",
".",
"equal",
"(",
"typeof",
"path",
",",
"'string'",
")",
"assert",
".",
"equal",
"(",
"typeof",
"cb",
",",
"'function'",
")",
"saveDirs",
"(",
"path",
",",
"{",
"}",
",",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
"saveFiles",
"(",
"path",
",",
"opts",
",",
"res",
",",
"cb",
")",
"}",
")",
"}"
]
| directory-to-object @param {Object|String} opts @param {Function} cb | [
"directory",
"-",
"to",
"-",
"object"
]
| ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L10-L25 |
45,970 | wercker/directory-to-object | index.js | saveDirs | function saveDirs(path, obj, cb) {
var currDir = ''
var root = ''
walk.walk(path, walkFn, function(err) {
if (err) return cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if (!baseDir) return next()
if (obj[baseDir]) return next()
if (baseDir != currDir) currDir = baseDir
if (stat.isDirectory()) {
setObject(baseDir, obj, {})
return next()
}
setObject(baseDir, obj, [])
next()
}
} | javascript | function saveDirs(path, obj, cb) {
var currDir = ''
var root = ''
walk.walk(path, walkFn, function(err) {
if (err) return cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if (!baseDir) return next()
if (obj[baseDir]) return next()
if (baseDir != currDir) currDir = baseDir
if (stat.isDirectory()) {
setObject(baseDir, obj, {})
return next()
}
setObject(baseDir, obj, [])
next()
}
} | [
"function",
"saveDirs",
"(",
"path",
",",
"obj",
",",
"cb",
")",
"{",
"var",
"currDir",
"=",
"''",
"var",
"root",
"=",
"''",
"walk",
".",
"walk",
"(",
"path",
",",
"walkFn",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"return",
"cb",
"(",
"err",
")",
"cb",
"(",
"null",
",",
"obj",
")",
"}",
")",
"function",
"walkFn",
"(",
"baseDir",
",",
"filename",
",",
"stat",
",",
"next",
")",
"{",
"if",
"(",
"!",
"root",
")",
"root",
"=",
"baseDir",
"baseDir",
"=",
"stripLeadingSlash",
"(",
"baseDir",
".",
"split",
"(",
"root",
")",
"[",
"1",
"]",
")",
"if",
"(",
"!",
"baseDir",
")",
"return",
"next",
"(",
")",
"if",
"(",
"obj",
"[",
"baseDir",
"]",
")",
"return",
"next",
"(",
")",
"if",
"(",
"baseDir",
"!=",
"currDir",
")",
"currDir",
"=",
"baseDir",
"if",
"(",
"stat",
".",
"isDirectory",
"(",
")",
")",
"{",
"setObject",
"(",
"baseDir",
",",
"obj",
",",
"{",
"}",
")",
"return",
"next",
"(",
")",
"}",
"setObject",
"(",
"baseDir",
",",
"obj",
",",
"[",
"]",
")",
"next",
"(",
")",
"}",
"}"
]
| Save directory structure. @param {String} path @param {Object} obj @param {Function} cb | [
"Save",
"directory",
"structure",
"."
]
| ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L31-L57 |
45,971 | wercker/directory-to-object | index.js | saveFiles | function saveFiles(path, opts, obj, cb) {
const noDot = opts.noDot
var root = ''
walk.walk(path, walkFn, function (err) {
if (err) cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if (stat.isDirectory()) return next()
if (noDot) {
if (/^\./.test(filename)) return next()
}
pushArr(baseDir, obj, filename)
next()
}
} | javascript | function saveFiles(path, opts, obj, cb) {
const noDot = opts.noDot
var root = ''
walk.walk(path, walkFn, function (err) {
if (err) cb(err)
cb(null, obj)
})
function walkFn(baseDir, filename, stat, next) {
if (!root) root = baseDir
baseDir = stripLeadingSlash(baseDir.split(root)[1])
if (stat.isDirectory()) return next()
if (noDot) {
if (/^\./.test(filename)) return next()
}
pushArr(baseDir, obj, filename)
next()
}
} | [
"function",
"saveFiles",
"(",
"path",
",",
"opts",
",",
"obj",
",",
"cb",
")",
"{",
"const",
"noDot",
"=",
"opts",
".",
"noDot",
"var",
"root",
"=",
"''",
"walk",
".",
"walk",
"(",
"path",
",",
"walkFn",
",",
"function",
"(",
"err",
")",
"{",
"if",
"(",
"err",
")",
"cb",
"(",
"err",
")",
"cb",
"(",
"null",
",",
"obj",
")",
"}",
")",
"function",
"walkFn",
"(",
"baseDir",
",",
"filename",
",",
"stat",
",",
"next",
")",
"{",
"if",
"(",
"!",
"root",
")",
"root",
"=",
"baseDir",
"baseDir",
"=",
"stripLeadingSlash",
"(",
"baseDir",
".",
"split",
"(",
"root",
")",
"[",
"1",
"]",
")",
"if",
"(",
"stat",
".",
"isDirectory",
"(",
")",
")",
"return",
"next",
"(",
")",
"if",
"(",
"noDot",
")",
"{",
"if",
"(",
"/",
"^\\.",
"/",
".",
"test",
"(",
"filename",
")",
")",
"return",
"next",
"(",
")",
"}",
"pushArr",
"(",
"baseDir",
",",
"obj",
",",
"filename",
")",
"next",
"(",
")",
"}",
"}"
]
| Save filenames in dir structure. @param {String} path @param {Object} opts @param {Object} obj @param {Function} cb | [
"Save",
"filenames",
"in",
"dir",
"structure",
"."
]
| ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L64-L84 |
45,972 | wercker/directory-to-object | index.js | setObject | function setObject(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
obj = obj[subPath] = obj[subPath] || val
})
} | javascript | function setObject(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
obj = obj[subPath] = obj[subPath] || val
})
} | [
"function",
"setObject",
"(",
"path",
",",
"obj",
",",
"val",
")",
"{",
"path",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"path",
".",
"forEach",
"(",
"function",
"(",
"subPath",
")",
"{",
"obj",
"=",
"obj",
"[",
"subPath",
"]",
"=",
"obj",
"[",
"subPath",
"]",
"||",
"val",
"}",
")",
"}"
]
| Set a nested value on an object. @param {String} path @param {Object} obj @param {Any} value | [
"Set",
"a",
"nested",
"value",
"on",
"an",
"object",
"."
]
| ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L97-L102 |
45,973 | wercker/directory-to-object | index.js | pushArr | function pushArr(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
if (Array.isArray(obj[subPath])) return obj[subPath].push(val)
obj = obj[subPath]
})
} | javascript | function pushArr(path, obj, val) {
path = path.split('/')
path.forEach(function(subPath) {
if (Array.isArray(obj[subPath])) return obj[subPath].push(val)
obj = obj[subPath]
})
} | [
"function",
"pushArr",
"(",
"path",
",",
"obj",
",",
"val",
")",
"{",
"path",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"path",
".",
"forEach",
"(",
"function",
"(",
"subPath",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"obj",
"[",
"subPath",
"]",
")",
")",
"return",
"obj",
"[",
"subPath",
"]",
".",
"push",
"(",
"val",
")",
"obj",
"=",
"obj",
"[",
"subPath",
"]",
"}",
")",
"}"
]
| Push a value to an array nested in an object. @param {String} path @param {Object} opts @param {Object} obj @param {Any} value | [
"Push",
"a",
"value",
"to",
"an",
"array",
"nested",
"in",
"an",
"object",
"."
]
| ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3 | https://github.com/wercker/directory-to-object/blob/ef4b2b3f3cf06243eb533d5dac5cf21d5cf32bc3/index.js#L109-L115 |
45,974 | tdreyno/morlock.js | controllers/scroll-position-controller.js | ScrollPositionController | function ScrollPositionController(targetScrollY) {
if (!(this instanceof ScrollPositionController)) {
return new ScrollPositionController(targetScrollY);
}
Emitter.mixin(this);
var trackerStream = ScrollTrackerStream.create(targetScrollY);
Stream.onValue(trackerStream, Util.partial(this.trigger, 'both'));
var beforeStream = Stream.filterFirst('before', trackerStream);
Stream.onValue(beforeStream, Util.partial(this.trigger, 'before'));
var afterStream = Stream.filterFirst('after', trackerStream);
Stream.onValue(afterStream, Util.partial(this.trigger, 'after'));
} | javascript | function ScrollPositionController(targetScrollY) {
if (!(this instanceof ScrollPositionController)) {
return new ScrollPositionController(targetScrollY);
}
Emitter.mixin(this);
var trackerStream = ScrollTrackerStream.create(targetScrollY);
Stream.onValue(trackerStream, Util.partial(this.trigger, 'both'));
var beforeStream = Stream.filterFirst('before', trackerStream);
Stream.onValue(beforeStream, Util.partial(this.trigger, 'before'));
var afterStream = Stream.filterFirst('after', trackerStream);
Stream.onValue(afterStream, Util.partial(this.trigger, 'after'));
} | [
"function",
"ScrollPositionController",
"(",
"targetScrollY",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ScrollPositionController",
")",
")",
"{",
"return",
"new",
"ScrollPositionController",
"(",
"targetScrollY",
")",
";",
"}",
"Emitter",
".",
"mixin",
"(",
"this",
")",
";",
"var",
"trackerStream",
"=",
"ScrollTrackerStream",
".",
"create",
"(",
"targetScrollY",
")",
";",
"Stream",
".",
"onValue",
"(",
"trackerStream",
",",
"Util",
".",
"partial",
"(",
"this",
".",
"trigger",
",",
"'both'",
")",
")",
";",
"var",
"beforeStream",
"=",
"Stream",
".",
"filterFirst",
"(",
"'before'",
",",
"trackerStream",
")",
";",
"Stream",
".",
"onValue",
"(",
"beforeStream",
",",
"Util",
".",
"partial",
"(",
"this",
".",
"trigger",
",",
"'before'",
")",
")",
";",
"var",
"afterStream",
"=",
"Stream",
".",
"filterFirst",
"(",
"'after'",
",",
"trackerStream",
")",
";",
"Stream",
".",
"onValue",
"(",
"afterStream",
",",
"Util",
".",
"partial",
"(",
"this",
".",
"trigger",
",",
"'after'",
")",
")",
";",
"}"
]
| Provides a familiar OO-style API for tracking scroll position.
@constructor
@param {Element} targetScrollY The position to track.
@return {Object} The API with a `on` function to attach scrollEnd
callbacks and an `observeElement` function to detect when elements
enter and exist the viewport. | [
"Provides",
"a",
"familiar",
"OO",
"-",
"style",
"API",
"for",
"tracking",
"scroll",
"position",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/controllers/scroll-position-controller.js#L14-L29 |
45,975 | tdreyno/morlock.js | streams/scroll-tracker-stream.js | create | function create(targetScrollY) {
var scrollPositionStream = ScrollStream.create();
var overTheLineStream = Stream.create();
var pastScrollY = false;
var firstRun = true;
Stream.onValue(scrollPositionStream, function onScrollTrackPosition_(currentScrollY) {
if ((firstRun || pastScrollY) && (currentScrollY < targetScrollY)) {
pastScrollY = false;
Stream.emit(overTheLineStream, ['before', targetScrollY]);
} else if ((firstRun || !pastScrollY) && (currentScrollY >= targetScrollY)) {
pastScrollY = true;
Stream.emit(overTheLineStream, ['after', targetScrollY]);
}
firstRun = false;
});
return overTheLineStream;
} | javascript | function create(targetScrollY) {
var scrollPositionStream = ScrollStream.create();
var overTheLineStream = Stream.create();
var pastScrollY = false;
var firstRun = true;
Stream.onValue(scrollPositionStream, function onScrollTrackPosition_(currentScrollY) {
if ((firstRun || pastScrollY) && (currentScrollY < targetScrollY)) {
pastScrollY = false;
Stream.emit(overTheLineStream, ['before', targetScrollY]);
} else if ((firstRun || !pastScrollY) && (currentScrollY >= targetScrollY)) {
pastScrollY = true;
Stream.emit(overTheLineStream, ['after', targetScrollY]);
}
firstRun = false;
});
return overTheLineStream;
} | [
"function",
"create",
"(",
"targetScrollY",
")",
"{",
"var",
"scrollPositionStream",
"=",
"ScrollStream",
".",
"create",
"(",
")",
";",
"var",
"overTheLineStream",
"=",
"Stream",
".",
"create",
"(",
")",
";",
"var",
"pastScrollY",
"=",
"false",
";",
"var",
"firstRun",
"=",
"true",
";",
"Stream",
".",
"onValue",
"(",
"scrollPositionStream",
",",
"function",
"onScrollTrackPosition_",
"(",
"currentScrollY",
")",
"{",
"if",
"(",
"(",
"firstRun",
"||",
"pastScrollY",
")",
"&&",
"(",
"currentScrollY",
"<",
"targetScrollY",
")",
")",
"{",
"pastScrollY",
"=",
"false",
";",
"Stream",
".",
"emit",
"(",
"overTheLineStream",
",",
"[",
"'before'",
",",
"targetScrollY",
"]",
")",
";",
"}",
"else",
"if",
"(",
"(",
"firstRun",
"||",
"!",
"pastScrollY",
")",
"&&",
"(",
"currentScrollY",
">=",
"targetScrollY",
")",
")",
"{",
"pastScrollY",
"=",
"true",
";",
"Stream",
".",
"emit",
"(",
"overTheLineStream",
",",
"[",
"'after'",
",",
"targetScrollY",
"]",
")",
";",
"}",
"firstRun",
"=",
"false",
";",
"}",
")",
";",
"return",
"overTheLineStream",
";",
"}"
]
| Create a new Stream containing events which fire when a position has
been scrolled past.
@param {number} targetScrollY The position we are tracking.
@return {Stream} The resulting stream. | [
"Create",
"a",
"new",
"Stream",
"containing",
"events",
"which",
"fire",
"when",
"a",
"position",
"has",
"been",
"scrolled",
"past",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/streams/scroll-tracker-stream.js#L10-L29 |
45,976 | cyrillef/forge.model.derivative-js | src/model/JobPayloadItem.js | function(type) {
var _this = this;
JobSvfOutputPayload.call(_this, type);
JobThumbnailOutputPayload.call(_this, type);
JobStlOutputPayload.call(_this, type);
JobStepOutputPayload.call(_this, type);
JobIgesOutputPayload.call(_this, type);
JobObjOutputPayload.call(_this, type);
} | javascript | function(type) {
var _this = this;
JobSvfOutputPayload.call(_this, type);
JobThumbnailOutputPayload.call(_this, type);
JobStlOutputPayload.call(_this, type);
JobStepOutputPayload.call(_this, type);
JobIgesOutputPayload.call(_this, type);
JobObjOutputPayload.call(_this, type);
} | [
"function",
"(",
"type",
")",
"{",
"var",
"_this",
"=",
"this",
";",
"JobSvfOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"JobThumbnailOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"JobStlOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"JobStepOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"JobIgesOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"JobObjOutputPayload",
".",
"call",
"(",
"_this",
",",
"type",
")",
";",
"}"
]
| The JobPayloadItem model module.
@module model/JobPayloadItem
Constructs a new <code>JobPayloadItem</code>.
Output description object, depends of the type
@alias module:model/JobPayloadItem
@class
@implements module:model/JobSvfOutputPayload
@implements module:model/JobThumbnailOutputPayload
@implements module:model/JobStlOutputPayload
@implements module:model/JobStepOutputPayload
@implements module:model/JobIgesOutputPayload
@implements module:model/JobObjOutputPayload
@param type {module:model/JobObjOutputPayload.TypeEnum} The requested output types. Possible values include `svf`, `thumbnai`, `stl`, `step`, `iges`, or `obj`. For a list of supported types, call the [GET formats](https://developer.autodesk.com/en/docs/model-derivative/v2/reference/http/formats-GET) endpoint. | [
"The",
"JobPayloadItem",
"model",
"module",
"."
]
| 519966c12679820027e623b615868e7b7913cecc | https://github.com/cyrillef/forge.model.derivative-js/blob/519966c12679820027e623b615868e7b7913cecc/src/model/JobPayloadItem.js#L67-L76 |
|
45,977 | tdreyno/morlock.js | controllers/resize-controller.js | ResizeController | function ResizeController(options) {
if (!(this instanceof ResizeController)) {
return new ResizeController(options);
}
Emitter.mixin(this);
options = options || {};
var resizeStream = ResizeStream.create(options);
Stream.onValue(resizeStream, Util.partial(this.trigger, 'resize'));
var debounceMs = Util.getOption(options.debounceMs, 200);
var resizeEndStream = debounceMs <= 0 ? resizeStream : Stream.debounce(
debounceMs,
resizeStream
);
Stream.onValue(resizeEndStream, Util.partial(this.trigger, 'resizeEnd'));
this.destroy = function() {
Stream.close(resizeStream);
this.off('resize');
this.off('resizeEnd');
};
} | javascript | function ResizeController(options) {
if (!(this instanceof ResizeController)) {
return new ResizeController(options);
}
Emitter.mixin(this);
options = options || {};
var resizeStream = ResizeStream.create(options);
Stream.onValue(resizeStream, Util.partial(this.trigger, 'resize'));
var debounceMs = Util.getOption(options.debounceMs, 200);
var resizeEndStream = debounceMs <= 0 ? resizeStream : Stream.debounce(
debounceMs,
resizeStream
);
Stream.onValue(resizeEndStream, Util.partial(this.trigger, 'resizeEnd'));
this.destroy = function() {
Stream.close(resizeStream);
this.off('resize');
this.off('resizeEnd');
};
} | [
"function",
"ResizeController",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"ResizeController",
")",
")",
"{",
"return",
"new",
"ResizeController",
"(",
"options",
")",
";",
"}",
"Emitter",
".",
"mixin",
"(",
"this",
")",
";",
"options",
"=",
"options",
"||",
"{",
"}",
";",
"var",
"resizeStream",
"=",
"ResizeStream",
".",
"create",
"(",
"options",
")",
";",
"Stream",
".",
"onValue",
"(",
"resizeStream",
",",
"Util",
".",
"partial",
"(",
"this",
".",
"trigger",
",",
"'resize'",
")",
")",
";",
"var",
"debounceMs",
"=",
"Util",
".",
"getOption",
"(",
"options",
".",
"debounceMs",
",",
"200",
")",
";",
"var",
"resizeEndStream",
"=",
"debounceMs",
"<=",
"0",
"?",
"resizeStream",
":",
"Stream",
".",
"debounce",
"(",
"debounceMs",
",",
"resizeStream",
")",
";",
"Stream",
".",
"onValue",
"(",
"resizeEndStream",
",",
"Util",
".",
"partial",
"(",
"this",
".",
"trigger",
",",
"'resizeEnd'",
")",
")",
";",
"this",
".",
"destroy",
"=",
"function",
"(",
")",
"{",
"Stream",
".",
"close",
"(",
"resizeStream",
")",
";",
"this",
".",
"off",
"(",
"'resize'",
")",
";",
"this",
".",
"off",
"(",
"'resizeEnd'",
")",
";",
"}",
";",
"}"
]
| Provides a familiar OO-style API for tracking resize events.
@constructor
@param {Object=} options The options passed to the resize tracker.
@return {Object} The API with a `on` function to attach callbacks
to resize events and breakpoint changes. | [
"Provides",
"a",
"familiar",
"OO",
"-",
"style",
"API",
"for",
"tracking",
"resize",
"events",
"."
]
| a1d3f1f177887485b084aa38c91189fd9f9cfedf | https://github.com/tdreyno/morlock.js/blob/a1d3f1f177887485b084aa38c91189fd9f9cfedf/controllers/resize-controller.js#L13-L37 |
45,978 | jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | maybeTriggerImageLoad | function maybeTriggerImageLoad(image, event) {
if (!image.getAttribute('data-loaded') && isElementVisible(image)) {
image.dispatchEvent(event);
return true;
}
return false;
} | javascript | function maybeTriggerImageLoad(image, event) {
if (!image.getAttribute('data-loaded') && isElementVisible(image)) {
image.dispatchEvent(event);
return true;
}
return false;
} | [
"function",
"maybeTriggerImageLoad",
"(",
"image",
",",
"event",
")",
"{",
"if",
"(",
"!",
"image",
".",
"getAttribute",
"(",
"'data-loaded'",
")",
"&&",
"isElementVisible",
"(",
"image",
")",
")",
"{",
"image",
".",
"dispatchEvent",
"(",
"event",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Check if an image is visible and trigger an event if so.
@param {Element} image the image to check
@param {Event} event an event to dispatch if the image is in the viewport
@return {Boolean} true if the image is in the viewport; false if not | [
"Check",
"if",
"an",
"image",
"is",
"visible",
"and",
"trigger",
"an",
"event",
"if",
"so",
"."
]
| d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L54-L62 |
45,979 | jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | loadImage | function loadImage(event) {
var image = event.target;
// Swap in the srcset info and add an attribute to prevent duplicate loads.
image.srcset = image.getAttribute('data-lazyload');
image.setAttribute('data-loaded', true);
} | javascript | function loadImage(event) {
var image = event.target;
// Swap in the srcset info and add an attribute to prevent duplicate loads.
image.srcset = image.getAttribute('data-lazyload');
image.setAttribute('data-loaded', true);
} | [
"function",
"loadImage",
"(",
"event",
")",
"{",
"var",
"image",
"=",
"event",
".",
"target",
";",
"// Swap in the srcset info and add an attribute to prevent duplicate loads.",
"image",
".",
"srcset",
"=",
"image",
".",
"getAttribute",
"(",
"'data-lazyload'",
")",
";",
"image",
".",
"setAttribute",
"(",
"'data-loaded'",
",",
"true",
")",
";",
"}"
]
| This almost seems too easy, but we simply swap in the correct srcset.
@param {Event} event the triggered event
@return {Void} | [
"This",
"almost",
"seems",
"too",
"easy",
"but",
"we",
"simply",
"swap",
"in",
"the",
"correct",
"srcset",
"."
]
| d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L78-L84 |
45,980 | jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | removeLoadingClass | function removeLoadingClass(image, loadingClass) {
var element = image;
var shouldReturn = false;
/*
* Since there may be additional elements wrapping the image (e.g. a link),
* we run a loop to check the image’s ancestors until we either find the
* element with the loading class or hit the `body` element.
*/
while (element.tagName.toLowerCase() !== 'body') {
if (element.classList.contains(loadingClass)) {
element.classList.remove(loadingClass);
shouldReturn = true;
} else {
element = element.parentNode;
}
if (shouldReturn) {
return;
}
}
} | javascript | function removeLoadingClass(image, loadingClass) {
var element = image;
var shouldReturn = false;
/*
* Since there may be additional elements wrapping the image (e.g. a link),
* we run a loop to check the image’s ancestors until we either find the
* element with the loading class or hit the `body` element.
*/
while (element.tagName.toLowerCase() !== 'body') {
if (element.classList.contains(loadingClass)) {
element.classList.remove(loadingClass);
shouldReturn = true;
} else {
element = element.parentNode;
}
if (shouldReturn) {
return;
}
}
} | [
"function",
"removeLoadingClass",
"(",
"image",
",",
"loadingClass",
")",
"{",
"var",
"element",
"=",
"image",
";",
"var",
"shouldReturn",
"=",
"false",
";",
"/*\n * Since there may be additional elements wrapping the image (e.g. a link),\n * we run a loop to check the image’s ancestors until we either find the\n * element with the loading class or hit the `body` element.\n */",
"while",
"(",
"element",
".",
"tagName",
".",
"toLowerCase",
"(",
")",
"!==",
"'body'",
")",
"{",
"if",
"(",
"element",
".",
"classList",
".",
"contains",
"(",
"loadingClass",
")",
")",
"{",
"element",
".",
"classList",
".",
"remove",
"(",
"loadingClass",
")",
";",
"shouldReturn",
"=",
"true",
";",
"}",
"else",
"{",
"element",
"=",
"element",
".",
"parentNode",
";",
"}",
"if",
"(",
"shouldReturn",
")",
"{",
"return",
";",
"}",
"}",
"}"
]
| Remove the loading class from the lazyload wrapper.
@param {Element} image the image being loaded
@param {String} loadingClass the class to remove
@return {Void} | [
"Remove",
"the",
"loading",
"class",
"from",
"the",
"lazyload",
"wrapper",
"."
]
| d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L92-L113 |
45,981 | jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | initialize | function initialize(_ref) {
var _ref$containerClass = _ref.containerClass,
containerClass = _ref$containerClass === undefined ? 'js--lazyload' : _ref$containerClass,
_ref$loadingClass = _ref.loadingClass,
loadingClass = _ref$loadingClass === undefined ? 'js--lazyload--loading' : _ref$loadingClass,
_ref$callback = _ref.callback,
callback = _ref$callback === undefined ? function (e) {
return e;
} : _ref$callback;
// Find all the containers and add the loading class.
var containers = document.getElementsByClassName(containerClass);
[].forEach.call(containers, function (container) {
container.classList.add(loadingClass);
});
// If we get here, `srcset` is supported and we can start processing things.
var images = [].map.call(containers, findImageElement);
// Create a custom event to trigger the event load.
var lazyLoadEvent = new Event('lazyload-init');
// Attach an onload handler to each image.
images.forEach(function (image) {
/*
* Once the image is loaded, we want to remove the loading class so any
* loading animations or other effects can be disabled.
*/
image.addEventListener('load', function (event) {
removeLoadingClass(event.target, loadingClass);
callback(event);
});
/*
* Set up a listener for the custom event that triggers the image load
* handler (which loads the image).
*/
image.addEventListener('lazyload-init', loadImage);
/*
* Check if the image is already in the viewport. If so, load it.
*/
maybeTriggerImageLoad(image, lazyLoadEvent);
});
var loadVisibleImages = checkForImagesToLazyLoad.bind(null, lazyLoadEvent, images);
/*
* Add an event listener when the page is scrolled. To avoid bogging down the
* page, we throttle this call to only run every 100ms.
*/
var scrollHandler = throttle(loadVisibleImages, 100);
window.addEventListener('scroll', scrollHandler);
// Return a function to allow manual checks for images to lazy load.
return loadVisibleImages;
} | javascript | function initialize(_ref) {
var _ref$containerClass = _ref.containerClass,
containerClass = _ref$containerClass === undefined ? 'js--lazyload' : _ref$containerClass,
_ref$loadingClass = _ref.loadingClass,
loadingClass = _ref$loadingClass === undefined ? 'js--lazyload--loading' : _ref$loadingClass,
_ref$callback = _ref.callback,
callback = _ref$callback === undefined ? function (e) {
return e;
} : _ref$callback;
// Find all the containers and add the loading class.
var containers = document.getElementsByClassName(containerClass);
[].forEach.call(containers, function (container) {
container.classList.add(loadingClass);
});
// If we get here, `srcset` is supported and we can start processing things.
var images = [].map.call(containers, findImageElement);
// Create a custom event to trigger the event load.
var lazyLoadEvent = new Event('lazyload-init');
// Attach an onload handler to each image.
images.forEach(function (image) {
/*
* Once the image is loaded, we want to remove the loading class so any
* loading animations or other effects can be disabled.
*/
image.addEventListener('load', function (event) {
removeLoadingClass(event.target, loadingClass);
callback(event);
});
/*
* Set up a listener for the custom event that triggers the image load
* handler (which loads the image).
*/
image.addEventListener('lazyload-init', loadImage);
/*
* Check if the image is already in the viewport. If so, load it.
*/
maybeTriggerImageLoad(image, lazyLoadEvent);
});
var loadVisibleImages = checkForImagesToLazyLoad.bind(null, lazyLoadEvent, images);
/*
* Add an event listener when the page is scrolled. To avoid bogging down the
* page, we throttle this call to only run every 100ms.
*/
var scrollHandler = throttle(loadVisibleImages, 100);
window.addEventListener('scroll', scrollHandler);
// Return a function to allow manual checks for images to lazy load.
return loadVisibleImages;
} | [
"function",
"initialize",
"(",
"_ref",
")",
"{",
"var",
"_ref$containerClass",
"=",
"_ref",
".",
"containerClass",
",",
"containerClass",
"=",
"_ref$containerClass",
"===",
"undefined",
"?",
"'js--lazyload'",
":",
"_ref$containerClass",
",",
"_ref$loadingClass",
"=",
"_ref",
".",
"loadingClass",
",",
"loadingClass",
"=",
"_ref$loadingClass",
"===",
"undefined",
"?",
"'js--lazyload--loading'",
":",
"_ref$loadingClass",
",",
"_ref$callback",
"=",
"_ref",
".",
"callback",
",",
"callback",
"=",
"_ref$callback",
"===",
"undefined",
"?",
"function",
"(",
"e",
")",
"{",
"return",
"e",
";",
"}",
":",
"_ref$callback",
";",
"// Find all the containers and add the loading class.",
"var",
"containers",
"=",
"document",
".",
"getElementsByClassName",
"(",
"containerClass",
")",
";",
"[",
"]",
".",
"forEach",
".",
"call",
"(",
"containers",
",",
"function",
"(",
"container",
")",
"{",
"container",
".",
"classList",
".",
"add",
"(",
"loadingClass",
")",
";",
"}",
")",
";",
"// If we get here, `srcset` is supported and we can start processing things.",
"var",
"images",
"=",
"[",
"]",
".",
"map",
".",
"call",
"(",
"containers",
",",
"findImageElement",
")",
";",
"// Create a custom event to trigger the event load.",
"var",
"lazyLoadEvent",
"=",
"new",
"Event",
"(",
"'lazyload-init'",
")",
";",
"// Attach an onload handler to each image.",
"images",
".",
"forEach",
"(",
"function",
"(",
"image",
")",
"{",
"/*\n * Once the image is loaded, we want to remove the loading class so any\n * loading animations or other effects can be disabled.\n */",
"image",
".",
"addEventListener",
"(",
"'load'",
",",
"function",
"(",
"event",
")",
"{",
"removeLoadingClass",
"(",
"event",
".",
"target",
",",
"loadingClass",
")",
";",
"callback",
"(",
"event",
")",
";",
"}",
")",
";",
"/*\n * Set up a listener for the custom event that triggers the image load\n * handler (which loads the image).\n */",
"image",
".",
"addEventListener",
"(",
"'lazyload-init'",
",",
"loadImage",
")",
";",
"/*\n * Check if the image is already in the viewport. If so, load it.\n */",
"maybeTriggerImageLoad",
"(",
"image",
",",
"lazyLoadEvent",
")",
";",
"}",
")",
";",
"var",
"loadVisibleImages",
"=",
"checkForImagesToLazyLoad",
".",
"bind",
"(",
"null",
",",
"lazyLoadEvent",
",",
"images",
")",
";",
"/*\n * Add an event listener when the page is scrolled. To avoid bogging down the\n * page, we throttle this call to only run every 100ms.\n */",
"var",
"scrollHandler",
"=",
"throttle",
"(",
"loadVisibleImages",
",",
"100",
")",
";",
"window",
".",
"addEventListener",
"(",
"'scroll'",
",",
"scrollHandler",
")",
";",
"// Return a function to allow manual checks for images to lazy load.",
"return",
"loadVisibleImages",
";",
"}"
]
| Initializes the lazyloader and adds the relevant classes and handlers.
@param {String} options.containerClass the lazyloaded image wrapper
@param {String} options.loadingClass the class that signifies loading
@param {Function} options.callback a function to fire on image load
@return {Function} a function to load visible images | [
"Initializes",
"the",
"lazyloader",
"and",
"adds",
"the",
"relevant",
"classes",
"and",
"handlers",
"."
]
| d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L128-L185 |
45,982 | jlengstorf/responsive-lazyload.js | docs/dist/responsive-lazyload.es.js | lazyLoadImages | function lazyLoadImages() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// If we have `srcset` support, initialize the lazyloader.
/* istanbul ignore else: unreasonable to test browser support just for a no-op */
if ('srcset' in document.createElement('img')) {
return initialize(config);
}
// If there’s no support, return a no-op.
/* istanbul ignore next: unreasonable to test browser support just for a no-op */
return function () {
/* no-op */
};
} | javascript | function lazyLoadImages() {
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// If we have `srcset` support, initialize the lazyloader.
/* istanbul ignore else: unreasonable to test browser support just for a no-op */
if ('srcset' in document.createElement('img')) {
return initialize(config);
}
// If there’s no support, return a no-op.
/* istanbul ignore next: unreasonable to test browser support just for a no-op */
return function () {
/* no-op */
};
} | [
"function",
"lazyLoadImages",
"(",
")",
"{",
"var",
"config",
"=",
"arguments",
".",
"length",
">",
"0",
"&&",
"arguments",
"[",
"0",
"]",
"!==",
"undefined",
"?",
"arguments",
"[",
"0",
"]",
":",
"{",
"}",
";",
"// If we have `srcset` support, initialize the lazyloader.",
"/* istanbul ignore else: unreasonable to test browser support just for a no-op */",
"if",
"(",
"'srcset'",
"in",
"document",
".",
"createElement",
"(",
"'img'",
")",
")",
"{",
"return",
"initialize",
"(",
"config",
")",
";",
"}",
"// If there’s no support, return a no-op.",
"/* istanbul ignore next: unreasonable to test browser support just for a no-op */",
"return",
"function",
"(",
")",
"{",
"/* no-op */",
"}",
";",
"}"
]
| The public function to initialize lazyloading
@param {Object} config configuration options (see `initialize()`)
@return {Function} a function to manually check for images to lazy load | [
"The",
"public",
"function",
"to",
"initialize",
"lazyloading"
]
| d375eedd6bf48b1cfa54b301fd77f59198c2ab73 | https://github.com/jlengstorf/responsive-lazyload.js/blob/d375eedd6bf48b1cfa54b301fd77f59198c2ab73/docs/dist/responsive-lazyload.es.js#L192-L206 |
45,983 | djett41/node-feedjett | lib/feedjett.js | FeedJett | function FeedJett (options) {
if (!(this instanceof FeedJett)) {
return new FeedJett(options);
}
TransformStream.call(this);
this._readableState.objectMode = true;
this._readableState.highWaterMark = 16; // max. # of output nodes buffered
this.init();
this.parseOptions(options);
sax.MAX_BUFFER_LENGTH = this.options.MAX_BUFFER_LENGTH;
this.stream = sax.createStream(this.options.strict, {lowercase: true, xmlns: true });
this.stream.on('processinginstruction', this.onProcessingInstruction.bind(this));
this.stream.on('attribute', this.onAttribute.bind(this));
this.stream.on('opentag', this.onOpenTag.bind(this));
this.stream.on('closetag',this.onCloseTag.bind(this));
this.stream.on('text', this.onText.bind(this));
this.stream.on('cdata', this.onText.bind(this));
this.stream.on('end', this.onEnd.bind(this));
this.stream.on('error', this.onSaxError.bind(this));
} | javascript | function FeedJett (options) {
if (!(this instanceof FeedJett)) {
return new FeedJett(options);
}
TransformStream.call(this);
this._readableState.objectMode = true;
this._readableState.highWaterMark = 16; // max. # of output nodes buffered
this.init();
this.parseOptions(options);
sax.MAX_BUFFER_LENGTH = this.options.MAX_BUFFER_LENGTH;
this.stream = sax.createStream(this.options.strict, {lowercase: true, xmlns: true });
this.stream.on('processinginstruction', this.onProcessingInstruction.bind(this));
this.stream.on('attribute', this.onAttribute.bind(this));
this.stream.on('opentag', this.onOpenTag.bind(this));
this.stream.on('closetag',this.onCloseTag.bind(this));
this.stream.on('text', this.onText.bind(this));
this.stream.on('cdata', this.onText.bind(this));
this.stream.on('end', this.onEnd.bind(this));
this.stream.on('error', this.onSaxError.bind(this));
} | [
"function",
"FeedJett",
"(",
"options",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"FeedJett",
")",
")",
"{",
"return",
"new",
"FeedJett",
"(",
"options",
")",
";",
"}",
"TransformStream",
".",
"call",
"(",
"this",
")",
";",
"this",
".",
"_readableState",
".",
"objectMode",
"=",
"true",
";",
"this",
".",
"_readableState",
".",
"highWaterMark",
"=",
"16",
";",
"// max. # of output nodes buffered",
"this",
".",
"init",
"(",
")",
";",
"this",
".",
"parseOptions",
"(",
"options",
")",
";",
"sax",
".",
"MAX_BUFFER_LENGTH",
"=",
"this",
".",
"options",
".",
"MAX_BUFFER_LENGTH",
";",
"this",
".",
"stream",
"=",
"sax",
".",
"createStream",
"(",
"this",
".",
"options",
".",
"strict",
",",
"{",
"lowercase",
":",
"true",
",",
"xmlns",
":",
"true",
"}",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'processinginstruction'",
",",
"this",
".",
"onProcessingInstruction",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'attribute'",
",",
"this",
".",
"onAttribute",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'opentag'",
",",
"this",
".",
"onOpenTag",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'closetag'",
",",
"this",
".",
"onCloseTag",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'text'",
",",
"this",
".",
"onText",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'cdata'",
",",
"this",
".",
"onText",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'end'",
",",
"this",
".",
"onEnd",
".",
"bind",
"(",
"this",
")",
")",
";",
"this",
".",
"stream",
".",
"on",
"(",
"'error'",
",",
"this",
".",
"onSaxError",
".",
"bind",
"(",
"this",
")",
")",
";",
"}"
]
| FeedJett constructor. Most apps will only use one instance.
Exposes a duplex (transform) stream to parse a feed. | [
"FeedJett",
"constructor",
".",
"Most",
"apps",
"will",
"only",
"use",
"one",
"instance",
"."
]
| b205aca7a4f72ee04e6ebbe0591fc8eb9078e073 | https://github.com/djett41/node-feedjett/blob/b205aca7a4f72ee04e6ebbe0591fc8eb9078e073/lib/feedjett.js#L54-L76 |
45,984 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/console.js | Console | function Console(game, messageHistoryCount, elClassName) {
this.el = document.createElement('div');
this.el.className = elClassName || 'console';
this.messageHistoryCount = messageHistoryCount || this.messageHistoryCount;
this.game = game;
} | javascript | function Console(game, messageHistoryCount, elClassName) {
this.el = document.createElement('div');
this.el.className = elClassName || 'console';
this.messageHistoryCount = messageHistoryCount || this.messageHistoryCount;
this.game = game;
} | [
"function",
"Console",
"(",
"game",
",",
"messageHistoryCount",
",",
"elClassName",
")",
"{",
"this",
".",
"el",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"this",
".",
"el",
".",
"className",
"=",
"elClassName",
"||",
"'console'",
";",
"this",
".",
"messageHistoryCount",
"=",
"messageHistoryCount",
"||",
"this",
".",
"messageHistoryCount",
";",
"this",
".",
"game",
"=",
"game",
";",
"}"
]
| Manages the display and history of console messages to the user.
"The troll hits you dealing 10 damage."
"You die."
@class Console
@constructor
@param {Game} game - Game instance this obj is attached to.
@param {Number} [messageHistoryCount=5] - Number of messages to display at once.
@param {String} [elClassName='console'] - Css class name to assign to the console element. | [
"Manages",
"the",
"display",
"and",
"history",
"of",
"console",
"messages",
"to",
"the",
"user",
".",
"The",
"troll",
"hits",
"you",
"dealing",
"10",
"damage",
".",
"You",
"die",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/console.js#L14-L19 |
45,985 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/console.js | function(message){
if(this.el.children.length > this.messageHistoryCount - 1){
var childEl = this.el.childNodes[0];
childEl.remove();
}
var messageEl = document.createElement('div');
messageEl.innerHTML = message;
this.el.appendChild(messageEl);
} | javascript | function(message){
if(this.el.children.length > this.messageHistoryCount - 1){
var childEl = this.el.childNodes[0];
childEl.remove();
}
var messageEl = document.createElement('div');
messageEl.innerHTML = message;
this.el.appendChild(messageEl);
} | [
"function",
"(",
"message",
")",
"{",
"if",
"(",
"this",
".",
"el",
".",
"children",
".",
"length",
">",
"this",
".",
"messageHistoryCount",
"-",
"1",
")",
"{",
"var",
"childEl",
"=",
"this",
".",
"el",
".",
"childNodes",
"[",
"0",
"]",
";",
"childEl",
".",
"remove",
"(",
")",
";",
"}",
"var",
"messageEl",
"=",
"document",
".",
"createElement",
"(",
"'div'",
")",
";",
"messageEl",
".",
"innerHTML",
"=",
"message",
";",
"this",
".",
"el",
".",
"appendChild",
"(",
"messageEl",
")",
";",
"}"
]
| Adds a message to the console.
@method log
@param {String} - Message to be added. | [
"Adds",
"a",
"message",
"to",
"the",
"console",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/console.js#L51-L61 |
|
45,986 | commenthol/debug-level | src/node.js | Log | function Log (name, opts) {
if (!(this instanceof Log)) return new Log(name, opts)
Object.assign(options,
inspectOpts(process.env),
inspectNamespaces(process.env)
)
LogBase.call(this, name, Object.assign({}, options, opts))
const colorFn = (n) => chalk.hex(n)
this.color = selectColor(name, colorFn)
this.levColors = levelColors(colorFn)
if (!this.opts.json) {
this._log = this._logOneLine
}
} | javascript | function Log (name, opts) {
if (!(this instanceof Log)) return new Log(name, opts)
Object.assign(options,
inspectOpts(process.env),
inspectNamespaces(process.env)
)
LogBase.call(this, name, Object.assign({}, options, opts))
const colorFn = (n) => chalk.hex(n)
this.color = selectColor(name, colorFn)
this.levColors = levelColors(colorFn)
if (!this.opts.json) {
this._log = this._logOneLine
}
} | [
"function",
"Log",
"(",
"name",
",",
"opts",
")",
"{",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Log",
")",
")",
"return",
"new",
"Log",
"(",
"name",
",",
"opts",
")",
"Object",
".",
"assign",
"(",
"options",
",",
"inspectOpts",
"(",
"process",
".",
"env",
")",
",",
"inspectNamespaces",
"(",
"process",
".",
"env",
")",
")",
"LogBase",
".",
"call",
"(",
"this",
",",
"name",
",",
"Object",
".",
"assign",
"(",
"{",
"}",
",",
"options",
",",
"opts",
")",
")",
"const",
"colorFn",
"=",
"(",
"n",
")",
"=>",
"chalk",
".",
"hex",
"(",
"n",
")",
"this",
".",
"color",
"=",
"selectColor",
"(",
"name",
",",
"colorFn",
")",
"this",
".",
"levColors",
"=",
"levelColors",
"(",
"colorFn",
")",
"if",
"(",
"!",
"this",
".",
"opts",
".",
"json",
")",
"{",
"this",
".",
"_log",
"=",
"this",
".",
"_logOneLine",
"}",
"}"
]
| creates a new logger
@constructor
@param {String} name - namespace of Logger | [
"creates",
"a",
"new",
"logger"
]
| e310fe5452984d898adfb8f924ac6f9021b05457 | https://github.com/commenthol/debug-level/blob/e310fe5452984d898adfb8f924ac6f9021b05457/src/node.js#L31-L44 |
45,987 | Lanfei/websocket-lib | lib/client.js | ClientSession | function ClientSession(request, socket, head, client) {
Session.call(this, request, socket, head);
/**
* The client instance of this session.
* @type {Client}
*/
this.client = client;
this.state = Session.STATE_OPEN;
this._init();
} | javascript | function ClientSession(request, socket, head, client) {
Session.call(this, request, socket, head);
/**
* The client instance of this session.
* @type {Client}
*/
this.client = client;
this.state = Session.STATE_OPEN;
this._init();
} | [
"function",
"ClientSession",
"(",
"request",
",",
"socket",
",",
"head",
",",
"client",
")",
"{",
"Session",
".",
"call",
"(",
"this",
",",
"request",
",",
"socket",
",",
"head",
")",
";",
"/**\n\t * The client instance of this session.\n\t * @type {Client}\n\t */",
"this",
".",
"client",
"=",
"client",
";",
"this",
".",
"state",
"=",
"Session",
".",
"STATE_OPEN",
";",
"this",
".",
"_init",
"(",
")",
";",
"}"
]
| WebSocket Client Session
@constructor
@extends Session
@param {IncomingMessage} request see {@link Session#request}
@param {Socket} socket see {@link Session#socket}
@param {Buffer} [head] Data that received with headers.
@param {Client} [client] see {@link ClientSession#client} | [
"WebSocket",
"Client",
"Session"
]
| d39f704490fb91b1e2897712b280c0e5ac79e123 | https://github.com/Lanfei/websocket-lib/blob/d39f704490fb91b1e2897712b280c0e5ac79e123/lib/client.js#L131-L143 |
45,988 | CodersBrothers/coolors | coolors.js | coolors | function coolors(msg, config){
if(supportsColor) {
switch (typeof config) {
case 'string':
if(plugins[config]){
msg = plugins[config](msg);
}
break;
case 'object':
var decorators = Object.keys(styles.decorators);
decorators.forEach(function (decorator) {
if (config[decorator]) {
msg = styles.decorators[decorator](msg);
}
});
['text', 'background'].forEach(function (option) {
if (config[option] && styles[option][config[option]]) {
msg = styles[option][config[option]](msg);
}
});
break;
}
}
return msg;
} | javascript | function coolors(msg, config){
if(supportsColor) {
switch (typeof config) {
case 'string':
if(plugins[config]){
msg = plugins[config](msg);
}
break;
case 'object':
var decorators = Object.keys(styles.decorators);
decorators.forEach(function (decorator) {
if (config[decorator]) {
msg = styles.decorators[decorator](msg);
}
});
['text', 'background'].forEach(function (option) {
if (config[option] && styles[option][config[option]]) {
msg = styles[option][config[option]](msg);
}
});
break;
}
}
return msg;
} | [
"function",
"coolors",
"(",
"msg",
",",
"config",
")",
"{",
"if",
"(",
"supportsColor",
")",
"{",
"switch",
"(",
"typeof",
"config",
")",
"{",
"case",
"'string'",
":",
"if",
"(",
"plugins",
"[",
"config",
"]",
")",
"{",
"msg",
"=",
"plugins",
"[",
"config",
"]",
"(",
"msg",
")",
";",
"}",
"break",
";",
"case",
"'object'",
":",
"var",
"decorators",
"=",
"Object",
".",
"keys",
"(",
"styles",
".",
"decorators",
")",
";",
"decorators",
".",
"forEach",
"(",
"function",
"(",
"decorator",
")",
"{",
"if",
"(",
"config",
"[",
"decorator",
"]",
")",
"{",
"msg",
"=",
"styles",
".",
"decorators",
"[",
"decorator",
"]",
"(",
"msg",
")",
";",
"}",
"}",
")",
";",
"[",
"'text'",
",",
"'background'",
"]",
".",
"forEach",
"(",
"function",
"(",
"option",
")",
"{",
"if",
"(",
"config",
"[",
"option",
"]",
"&&",
"styles",
"[",
"option",
"]",
"[",
"config",
"[",
"option",
"]",
"]",
")",
"{",
"msg",
"=",
"styles",
"[",
"option",
"]",
"[",
"config",
"[",
"option",
"]",
"]",
"(",
"msg",
")",
";",
"}",
"}",
")",
";",
"break",
";",
"}",
"}",
"return",
"msg",
";",
"}"
]
| CREATE A COOL LOG
@param {String} msg
@param {String|Object} config | [
"CREATE",
"A",
"COOL",
"LOG"
]
| 3d0d34ba285d156b14a25def5615d8c5c77d2032 | https://github.com/CodersBrothers/coolors/blob/3d0d34ba285d156b14a25def5615d8c5c77d2032/coolors.js#L58-L82 |
45,989 | nodeca/plurals-cldr | index.js | add | function add(locales, rule) {
var i;
rule.c = rule.c ? rule.c.map(unpack) : [ 'other' ];
rule.o = rule.o ? rule.o.map(unpack) : [ 'other' ];
for (i = 0; i < locales.length; i++) {
s[locales[i]] = rule;
}
} | javascript | function add(locales, rule) {
var i;
rule.c = rule.c ? rule.c.map(unpack) : [ 'other' ];
rule.o = rule.o ? rule.o.map(unpack) : [ 'other' ];
for (i = 0; i < locales.length; i++) {
s[locales[i]] = rule;
}
} | [
"function",
"add",
"(",
"locales",
",",
"rule",
")",
"{",
"var",
"i",
";",
"rule",
".",
"c",
"=",
"rule",
".",
"c",
"?",
"rule",
".",
"c",
".",
"map",
"(",
"unpack",
")",
":",
"[",
"'other'",
"]",
";",
"rule",
".",
"o",
"=",
"rule",
".",
"o",
"?",
"rule",
".",
"o",
".",
"map",
"(",
"unpack",
")",
":",
"[",
"'other'",
"]",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"locales",
".",
"length",
";",
"i",
"++",
")",
"{",
"s",
"[",
"locales",
"[",
"i",
"]",
"]",
"=",
"rule",
";",
"}",
"}"
]
| adds given `rule` pluralizer for given `locales` into `storage` | [
"adds",
"given",
"rule",
"pluralizer",
"for",
"given",
"locales",
"into",
"storage"
]
| d93a4f130d0610605ff76761ef8e6abd4271639d | https://github.com/nodeca/plurals-cldr/blob/d93a4f130d0610605ff76761ef8e6abd4271639d/index.js#L108-L117 |
45,990 | jonkemp/css-rules | index.js | extract | function extract(selectorText) {
var attr = 0,
sels = [],
sel = '',
i,
c,
l = selectorText.length;
for (i = 0; i < l; i++) {
c = selectorText.charAt(i);
if (attr) {
if (c === '[' || c === '(') {
attr--;
}
sel += c;
} else if (c === ',') {
sels.push(sel);
sel = '';
} else {
if (c === '[' || c === '(') {
attr++;
}
if (sel.length || (c !== ',' && c !== '\n' && c !== ' ')) {
sel += c;
}
}
}
if (sel.length) {
sels.push(sel);
}
return sels;
} | javascript | function extract(selectorText) {
var attr = 0,
sels = [],
sel = '',
i,
c,
l = selectorText.length;
for (i = 0; i < l; i++) {
c = selectorText.charAt(i);
if (attr) {
if (c === '[' || c === '(') {
attr--;
}
sel += c;
} else if (c === ',') {
sels.push(sel);
sel = '';
} else {
if (c === '[' || c === '(') {
attr++;
}
if (sel.length || (c !== ',' && c !== '\n' && c !== ' ')) {
sel += c;
}
}
}
if (sel.length) {
sels.push(sel);
}
return sels;
} | [
"function",
"extract",
"(",
"selectorText",
")",
"{",
"var",
"attr",
"=",
"0",
",",
"sels",
"=",
"[",
"]",
",",
"sel",
"=",
"''",
",",
"i",
",",
"c",
",",
"l",
"=",
"selectorText",
".",
"length",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"l",
";",
"i",
"++",
")",
"{",
"c",
"=",
"selectorText",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"attr",
")",
"{",
"if",
"(",
"c",
"===",
"'['",
"||",
"c",
"===",
"'('",
")",
"{",
"attr",
"--",
";",
"}",
"sel",
"+=",
"c",
";",
"}",
"else",
"if",
"(",
"c",
"===",
"','",
")",
"{",
"sels",
".",
"push",
"(",
"sel",
")",
";",
"sel",
"=",
"''",
";",
"}",
"else",
"{",
"if",
"(",
"c",
"===",
"'['",
"||",
"c",
"===",
"'('",
")",
"{",
"attr",
"++",
";",
"}",
"if",
"(",
"sel",
".",
"length",
"||",
"(",
"c",
"!==",
"','",
"&&",
"c",
"!==",
"'\\n'",
"&&",
"c",
"!==",
"' '",
")",
")",
"{",
"sel",
"+=",
"c",
";",
"}",
"}",
"}",
"if",
"(",
"sel",
".",
"length",
")",
"{",
"sels",
".",
"push",
"(",
"sel",
")",
";",
"}",
"return",
"sels",
";",
"}"
]
| Returns an array of the selectors.
@license Sizzle CSS Selector Engine - MIT
@param {String} selectorText from cssom
@api public | [
"Returns",
"an",
"array",
"of",
"the",
"selectors",
"."
]
| 7d13cf85f06d80d192189a797ed96df298f9b01d | https://github.com/jonkemp/css-rules/blob/7d13cf85f06d80d192189a797ed96df298f9b01d/index.js#L13-L47 |
45,991 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | MultiObjectManager | function MultiObjectManager(game, ObjectConstructor, width, height) {
this.game = game;
this.ObjectConstructor = ObjectConstructor;
this.objects = [];
this.map = new RL.Array2d();
this.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){
map.set(x, y, []);
});
} | javascript | function MultiObjectManager(game, ObjectConstructor, width, height) {
this.game = game;
this.ObjectConstructor = ObjectConstructor;
this.objects = [];
this.map = new RL.Array2d();
this.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){
map.set(x, y, []);
});
} | [
"function",
"MultiObjectManager",
"(",
"game",
",",
"ObjectConstructor",
",",
"width",
",",
"height",
")",
"{",
"this",
".",
"game",
"=",
"game",
";",
"this",
".",
"ObjectConstructor",
"=",
"ObjectConstructor",
";",
"this",
".",
"objects",
"=",
"[",
"]",
";",
"this",
".",
"map",
"=",
"new",
"RL",
".",
"Array2d",
"(",
")",
";",
"this",
".",
"setSize",
"(",
"width",
",",
"height",
")",
";",
"var",
"map",
"=",
"this",
".",
"map",
";",
"this",
".",
"map",
".",
"each",
"(",
"function",
"(",
"val",
",",
"x",
",",
"y",
")",
"{",
"map",
".",
"set",
"(",
"x",
",",
"y",
",",
"[",
"]",
")",
";",
"}",
")",
";",
"}"
]
| Manages a list of object and their tile positions.
Multiple objects can be at a given tile map coord.
Handles adding, removing, moving objects within the game.
@class MultiObjectManager
@constructor
@param {Game} game - Game instance this `MultiObjectManager` is attached to.
@param {Object} ObjectConstructor - Object constructor used to create new objects with `this.add()`.
@param {Number} [width] - Width of current map in tiles.
@param {Number} [height] - Height of current map in tiles. | [
"Manages",
"a",
"list",
"of",
"object",
"and",
"their",
"tile",
"positions",
".",
"Multiple",
"objects",
"can",
"be",
"at",
"a",
"given",
"tile",
"map",
"coord",
".",
"Handles",
"adding",
"removing",
"moving",
"objects",
"within",
"the",
"game",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L15-L26 |
45,992 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, filter) {
if(filter){
var result = this.map.get(x, y);
if(result){
return result.filter(filter);
}
}
return this.map.get(x, y);
} | javascript | function(x, y, filter) {
if(filter){
var result = this.map.get(x, y);
if(result){
return result.filter(filter);
}
}
return this.map.get(x, y);
} | [
"function",
"(",
"x",
",",
"y",
",",
"filter",
")",
"{",
"if",
"(",
"filter",
")",
"{",
"var",
"result",
"=",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"if",
"(",
"result",
")",
"{",
"return",
"result",
".",
"filter",
"(",
"filter",
")",
";",
"}",
"}",
"return",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"}"
]
| Retrieves all objects at given map tile coord.
@method get
@param {Number} x - The tile map x coord.
@param {Number} y - The tile map y coord.
@param {Function} [filter] - A function to filter the array of objects returned `function(object){ return true }`.
@return {Array} | [
"Retrieves",
"all",
"objects",
"at",
"given",
"map",
"tile",
"coord",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L60-L68 |
|
45,993 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, filter){
var arr = this.map.get(x, y);
if(arr){
if(filter){
for(var i = arr.length - 1; i >= 0; i--){
var item = arr[i];
if(filter(item)){
return item;
}
}
} else {
return arr[arr.length - 1];
}
}
} | javascript | function(x, y, filter){
var arr = this.map.get(x, y);
if(arr){
if(filter){
for(var i = arr.length - 1; i >= 0; i--){
var item = arr[i];
if(filter(item)){
return item;
}
}
} else {
return arr[arr.length - 1];
}
}
} | [
"function",
"(",
"x",
",",
"y",
",",
"filter",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"if",
"(",
"arr",
")",
"{",
"if",
"(",
"filter",
")",
"{",
"for",
"(",
"var",
"i",
"=",
"arr",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"var",
"item",
"=",
"arr",
"[",
"i",
"]",
";",
"if",
"(",
"filter",
"(",
"item",
")",
")",
"{",
"return",
"item",
";",
"}",
"}",
"}",
"else",
"{",
"return",
"arr",
"[",
"arr",
".",
"length",
"-",
"1",
"]",
";",
"}",
"}",
"}"
]
| Retrieves the last object in array at given map tile coord.
@method getLast
@param {Number} x - The tile map x coord.
@param {Number} y - The tile map y coord.
@param {Function} [filter] - A function to filter the object returned at this map tile coord `function(object){ return true }`. The last object in the array the filter matches is returned.
@return {Object} | [
"Retrieves",
"the",
"last",
"object",
"in",
"array",
"at",
"given",
"map",
"tile",
"coord",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L103-L117 |
|
45,994 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, obj) {
if(typeof obj === 'string'){
obj = this.makeNewObjectFromType(obj);
}
obj.game = this.game;
obj.x = x;
obj.y = y;
this.objects.push(obj);
var arr = this.map.get(x, y);
arr.push(obj);
if(obj.onAdd){
obj.onAdd();
}
return obj;
} | javascript | function(x, y, obj) {
if(typeof obj === 'string'){
obj = this.makeNewObjectFromType(obj);
}
obj.game = this.game;
obj.x = x;
obj.y = y;
this.objects.push(obj);
var arr = this.map.get(x, y);
arr.push(obj);
if(obj.onAdd){
obj.onAdd();
}
return obj;
} | [
"function",
"(",
"x",
",",
"y",
",",
"obj",
")",
"{",
"if",
"(",
"typeof",
"obj",
"===",
"'string'",
")",
"{",
"obj",
"=",
"this",
".",
"makeNewObjectFromType",
"(",
"obj",
")",
";",
"}",
"obj",
".",
"game",
"=",
"this",
".",
"game",
";",
"obj",
".",
"x",
"=",
"x",
";",
"obj",
".",
"y",
"=",
"y",
";",
"this",
".",
"objects",
".",
"push",
"(",
"obj",
")",
";",
"var",
"arr",
"=",
"this",
".",
"map",
".",
"get",
"(",
"x",
",",
"y",
")",
";",
"arr",
".",
"push",
"(",
"obj",
")",
";",
"if",
"(",
"obj",
".",
"onAdd",
")",
"{",
"obj",
".",
"onAdd",
"(",
")",
";",
"}",
"return",
"obj",
";",
"}"
]
| Adds an object to the manager at given map tile coord. Multiple objects can be added to the same coord.
@method add
@param {Number} x - Map tile coord x.
@param {Number} y - Map tile coord y.
@param {Object|String} obj - The Object being set at given coords. If `obj` is a string a new Object will be created using `this.makeNewObjectFromType(obj)`.
@return {Object} The added object. | [
"Adds",
"an",
"object",
"to",
"the",
"manager",
"at",
"given",
"map",
"tile",
"coord",
".",
"Multiple",
"objects",
"can",
"be",
"added",
"to",
"the",
"same",
"coord",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L127-L141 |
|
45,995 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(obj) {
var arr = this.map.get(obj.x, obj.y);
var index = arr.indexOf(obj);
arr.splice(index, 1);
index = this.objects.indexOf(obj);
this.objects.splice(index, 1);
if(obj.onRemove){
obj.onRemove();
}
} | javascript | function(obj) {
var arr = this.map.get(obj.x, obj.y);
var index = arr.indexOf(obj);
arr.splice(index, 1);
index = this.objects.indexOf(obj);
this.objects.splice(index, 1);
if(obj.onRemove){
obj.onRemove();
}
} | [
"function",
"(",
"obj",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"map",
".",
"get",
"(",
"obj",
".",
"x",
",",
"obj",
".",
"y",
")",
";",
"var",
"index",
"=",
"arr",
".",
"indexOf",
"(",
"obj",
")",
";",
"arr",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"index",
"=",
"this",
".",
"objects",
".",
"indexOf",
"(",
"obj",
")",
";",
"this",
".",
"objects",
".",
"splice",
"(",
"index",
",",
"1",
")",
";",
"if",
"(",
"obj",
".",
"onRemove",
")",
"{",
"obj",
".",
"onRemove",
"(",
")",
";",
"}",
"}"
]
| Removes an entity from the manager.
@method remove
@param {Obj} obj - The objity to be removed. | [
"Removes",
"an",
"entity",
"from",
"the",
"manager",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L148-L157 |
|
45,996 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, filter){
var arr = this.get(x, y, filter);
for(var i = arr.length - 1; i >= 0; i--){
this.remove(arr[i]);
}
} | javascript | function(x, y, filter){
var arr = this.get(x, y, filter);
for(var i = arr.length - 1; i >= 0; i--){
this.remove(arr[i]);
}
} | [
"function",
"(",
"x",
",",
"y",
",",
"filter",
")",
"{",
"var",
"arr",
"=",
"this",
".",
"get",
"(",
"x",
",",
"y",
",",
"filter",
")",
";",
"for",
"(",
"var",
"i",
"=",
"arr",
".",
"length",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"this",
".",
"remove",
"(",
"arr",
"[",
"i",
"]",
")",
";",
"}",
"}"
]
| Remove all objects from given location.
@method removeAt
@param {Number} x - Tile map x coord.
@param {Number} y - Tile map y coord.
@param {Function} [filter] - A function to filter the objects removed `function(object){ return true }`. | [
"Remove",
"all",
"objects",
"from",
"given",
"location",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L166-L171 |
|
45,997 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(x, y, object) {
this.remove(object);
object.x = x;
object.y = y;
this.add(x, y, object);
} | javascript | function(x, y, object) {
this.remove(object);
object.x = x;
object.y = y;
this.add(x, y, object);
} | [
"function",
"(",
"x",
",",
"y",
",",
"object",
")",
"{",
"this",
".",
"remove",
"(",
"object",
")",
";",
"object",
".",
"x",
"=",
"x",
";",
"object",
".",
"y",
"=",
"y",
";",
"this",
".",
"add",
"(",
"x",
",",
"y",
",",
"object",
")",
";",
"}"
]
| Changes the position of an entity already added to this entityManager.
@method move
@param {Number} x - The new map tile coordinate position of the entity on the x axis.
@param {Number} y - The new map tile coordinate position of the entity on the y axis.
@param {Obj} object - The objectity to be removed. | [
"Changes",
"the",
"position",
"of",
"an",
"entity",
"already",
"added",
"to",
"this",
"entityManager",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L180-L185 |
|
45,998 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function() {
this.objects = [];
this.map.reset();
var map = this.map;
this.map.each(function(val, x, y){
map.set(x, y, []);
});
} | javascript | function() {
this.objects = [];
this.map.reset();
var map = this.map;
this.map.each(function(val, x, y){
map.set(x, y, []);
});
} | [
"function",
"(",
")",
"{",
"this",
".",
"objects",
"=",
"[",
"]",
";",
"this",
".",
"map",
".",
"reset",
"(",
")",
";",
"var",
"map",
"=",
"this",
".",
"map",
";",
"this",
".",
"map",
".",
"each",
"(",
"function",
"(",
"val",
",",
"x",
",",
"y",
")",
"{",
"map",
".",
"set",
"(",
"x",
",",
"y",
",",
"[",
"]",
")",
";",
"}",
")",
";",
"}"
]
| Resets this entityManager.
@method reset | [
"Resets",
"this",
"entityManager",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L191-L198 |
|
45,999 | THEjoezack/BoxPusher | public/js-roguelike-skeleton/src/multi-object-manager.js | function(width, height){
this.map.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){
if(val === void 0){
map.set(x, y, []);
}
});
} | javascript | function(width, height){
this.map.setSize(width, height);
var map = this.map;
this.map.each(function(val, x, y){
if(val === void 0){
map.set(x, y, []);
}
});
} | [
"function",
"(",
"width",
",",
"height",
")",
"{",
"this",
".",
"map",
".",
"setSize",
"(",
"width",
",",
"height",
")",
";",
"var",
"map",
"=",
"this",
".",
"map",
";",
"this",
".",
"map",
".",
"each",
"(",
"function",
"(",
"val",
",",
"x",
",",
"y",
")",
"{",
"if",
"(",
"val",
"===",
"void",
"0",
")",
"{",
"map",
".",
"set",
"(",
"x",
",",
"y",
",",
"[",
"]",
")",
";",
"}",
"}",
")",
";",
"}"
]
| Sets the size of the map to manage objects within.
@method setSize
@param {Number} width - Width of current map in tiles.
@param {Number} height - Height of current map in tiles. | [
"Sets",
"the",
"size",
"of",
"the",
"map",
"to",
"manage",
"objects",
"within",
"."
]
| ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5 | https://github.com/THEjoezack/BoxPusher/blob/ebd506f7e61d10e4d493cf1cad1fbd4b43be28d5/public/js-roguelike-skeleton/src/multi-object-manager.js#L206-L214 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.