_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q28200 | processReceivedData | train | function processReceivedData() {
if (dataReceived || queueItem.fetched) {
return;
}
responseBuffer = responseBuffer.slice(0, responseLengthReceived);
dataReceived = true;
timeDataReceived = Date.now();
crawler.queue.update(queueIt... | javascript | {
"resource": ""
} |
q28201 | addPathHandle | train | function addPathHandle($canvas, parent, xProp, yProp) {
var handle = $.extend({
cursors: {
mouseover: 'grab',
mousedown: 'grabbing',
mouseup: 'grab'
}
}, parent.handle, {
// Define constant properties for handle
layer: true,
draggable: true,
x: parent[xProp],
y: parent[yProp],
_parent: paren... | javascript | {
"resource": ""
} |
q28202 | train | function (layer) {
var parent = layer._parent;
if (parent.width + (layer.dx * layer._px) < parent.minWidth) {
parent.width = parent.minWidth;
layer.dx = 0;
}
if (parent.height + (layer.dy * layer._py) < parent.minHeight) {
parent.height = parent.minHeight;
layer.dy = 0;
}
if (!parent... | javascript | {
"resource": ""
} | |
q28203 | addRectHandles | train | function addRectHandles($canvas, parent) {
var handlePlacement = parent.handlePlacement;
// Store current width-to-height ratio
if (parent.aspectRatio === null && parent.height !== 0) {
parent.aspectRatio = parent.width / parent.height;
}
// Optionally add handles to corners
if (handlePlacement === 'corners' ||... | javascript | {
"resource": ""
} |
q28204 | updateRectGuides | train | function updateRectGuides(parent) {
var guide = parent._guide;
if (guide) {
guide.x = parent.x;
guide.y = parent.y;
guide.width = parent.width;
guide.height = parent.height;
guide.fromCenter = parent.fromCenter;
}
} | javascript | {
"resource": ""
} |
q28205 | addRectGuides | train | function addRectGuides($canvas, parent) {
var guideProps, guide;
guideProps = $.extend({}, parent.guide, {
layer: true,
draggable: false,
type: 'rectangle',
handle: null
});
$canvas.addLayer(guideProps);
guide = $canvas.getLayer(-1);
parent._guide = guide;
$canvas.moveLayer(guide, -parent._handles.length... | javascript | {
"resource": ""
} |
q28206 | addPathHandles | train | function addPathHandles($canvas, parent) {
var key, xProp, yProp;
for (key in parent) {
if (Object.prototype.hasOwnProperty.call(parent, key)) {
// If property is a control point
if (key.match(/c?x(\d+)/gi) !== null) {
// Get the x and y coordinates for that control point
xProp = key;
yProp = key.... | javascript | {
"resource": ""
} |
q28207 | updatePathGuides | train | function updatePathGuides(parent) {
var handles = parent._handles,
guides = parent._guides,
handle, h,
guide, g;
if (parent._method === $.fn.drawQuadratic) {
if (handles) {
guide = parent._guide;
if (guide) {
for (h = 0; h < handles.length; h += 1) {
handle = parent._handles[h];
guide['x' ... | javascript | {
"resource": ""
} |
q28208 | addPathGuides | train | function addPathGuides($canvas, parent) {
var handles = parent._handles,
prevHandle, nextHandle, otherHandle,
handle, h,
guide, guideProps;
guideProps = $.extend({}, parent.guide, {
layer: true,
draggable: false,
type: 'line'
});
if (parent._method === $.fn.drawQuadratic) {
$canvas.addLayer(guideProps... | javascript | {
"resource": ""
} |
q28209 | updateRectHandles | train | function updateRectHandles(parent) {
var handle, h;
if (parent._handles) {
// Move handles when dragging
for (h = 0; h < parent._handles.length; h += 1) {
handle = parent._handles[h];
handle.x = parent.x + ((parent.width / 2 * handle._px) + ((parent.fromCenter) ? 0 : parent.width / 2));
handle.y = parent... | javascript | {
"resource": ""
} |
q28210 | updatePathHandles | train | function updatePathHandles(parent) {
var handles = parent._handles,
handle, h;
if (handles) {
// Move handles when dragging
for (h = 0; h < handles.length; h += 1) {
handle = handles[h];
handle.x = parent[handle._xProp] + parent.x;
handle.y = parent[handle._yProp] + parent.y;
}
}
updatePathGuides(p... | javascript | {
"resource": ""
} |
q28211 | addHandles | train | function addHandles(parent) {
var $canvas = $(parent.canvas);
// If parent's list of handles doesn't exist
if (parent._handles === undefined) {
// Create list to store handles
parent._handles = [];
}
if (isRectLayer(parent)) {
// Add four handles to corners of a rectangle/ellipse/image
addRectHandles($ca... | javascript | {
"resource": ""
} |
q28212 | removeHandles | train | function removeHandles(layer) {
var $canvas = $(layer.canvas), handle, h;
if (layer._handles) {
// Remove handles from layer
for (h = 0; h < layer._handles.length; h += 1) {
handle = layer._handles[h];
$canvas.removeLayer(handle);
}
layer._handles.length = 0;
}
} | javascript | {
"resource": ""
} |
q28213 | train | function (layer) {
var $canvas, handle, h;
if (layer._handles) {
$canvas = $(this);
// Remove handles from layer
for (h = 0; h < layer._handles.length; h += 1) {
handle = layer._handles[h];
$canvas.removeLayer(handle);
}
layer._handles.length = 0;
}
} | javascript | {
"resource": ""
} | |
q28214 | train | function (layer, props) {
if (props.handle || objectContainsPathCoords(props)) {
// Add handles if handle property was added
removeHandles(layer);
addHandles(layer);
} else if (props.handle === null) {
removeHandles(layer);
}
if (isRectLayer(layer)) {
// If width/height was changed
if (props.w... | javascript | {
"resource": ""
} | |
q28215 | train | function (layer, fx) {
// If layer is a rectangle or ellipse layer
if (isRectLayer(layer)) {
// If width or height are animated
if (fx.prop === 'width' || fx.prop === 'height' || fx.prop === 'x' || fx.prop === 'y') {
// Update rectangular handles
updateRectHandles(layer);
}
} else if (isPathLayer... | javascript | {
"resource": ""
} | |
q28216 | jCanvasObject | train | function jCanvasObject(args) {
var params = this,
propName;
// Copy the given parameters into new object
for (propName in args) {
// Do not merge defaults into parameters
if (Object.prototype.hasOwnProperty.call(args, propName)) {
params[propName] = args[propName];
}
}
return params;
} | javascript | {
"resource": ""
} |
q28217 | _coerceNumericProps | train | function _coerceNumericProps(props) {
var propName, propType, propValue;
// Loop through all properties in given property map
for (propName in props) {
if (Object.prototype.hasOwnProperty.call(props, propName)) {
propValue = props[propName];
propType = typeOf(propValue);
// If property is non-empty string... | javascript | {
"resource": ""
} |
q28218 | _cloneTransforms | train | function _cloneTransforms(transforms) {
// Clone the object itself
transforms = extendObject({}, transforms);
// Clone the object's masks array
transforms.masks = transforms.masks.slice(0);
return transforms;
} | javascript | {
"resource": ""
} |
q28219 | _saveCanvas | train | function _saveCanvas(ctx, data) {
var transforms;
ctx.save();
transforms = _cloneTransforms(data.transforms);
data.savedTransforms.push(transforms);
} | javascript | {
"resource": ""
} |
q28220 | _restoreCanvas | train | function _restoreCanvas(ctx, data) {
if (data.savedTransforms.length === 0) {
// Reset transformation state if it can't be restored any more
data.transforms = _cloneTransforms(baseTransforms);
} else {
// Restore canvas context
ctx.restore();
// Restore current transform state to the last saved state
data... | javascript | {
"resource": ""
} |
q28221 | _setStyle | train | function _setStyle(canvas, ctx, params, styleName) {
if (params[styleName]) {
if (isFunction(params[styleName])) {
// Handle functions
ctx[styleName] = params[styleName].call(canvas, params);
} else {
// Handle string values
ctx[styleName] = params[styleName];
}
}
} | javascript | {
"resource": ""
} |
q28222 | _setGlobalProps | train | function _setGlobalProps(canvas, ctx, params) {
_setStyle(canvas, ctx, params, 'fillStyle');
_setStyle(canvas, ctx, params, 'strokeStyle');
ctx.lineWidth = params.strokeWidth;
// Optionally round corners for paths
if (params.rounded) {
ctx.lineCap = ctx.lineJoin = 'round';
} else {
ctx.lineCap = params.stroke... | javascript | {
"resource": ""
} |
q28223 | _enableMasking | train | function _enableMasking(ctx, data, params) {
if (params.mask) {
// If jCanvas autosave is enabled
if (params.autosave) {
// Automatically save transformation state by default
_saveCanvas(ctx, data);
}
// Clip the current path
ctx.clip();
// Keep track of current masks
data.transforms.masks.push(par... | javascript | {
"resource": ""
} |
q28224 | _closePath | train | function _closePath(canvas, ctx, params) {
var data;
// Optionally close path
if (params.closed) {
ctx.closePath();
}
if (params.shadowStroke && params.strokeWidth !== 0) {
// Extend the shadow to include the stroke of a drawing
// Add a stroke shadow by stroking before filling
ctx.stroke();
ctx.fill(... | javascript | {
"resource": ""
} |
q28225 | _addLayerEvents | train | function _addLayerEvents($canvas, data, layer) {
var eventName;
// Determine which jCanvas events need to be bound to this layer
for (eventName in jCanvas.events) {
if (Object.prototype.hasOwnProperty.call(jCanvas.events, eventName)) {
// If layer has callback function to complement it
if (layer[eventName] |... | javascript | {
"resource": ""
} |
q28226 | _addLayerEvent | train | function _addLayerEvent($canvas, data, layer, eventName) {
// Use touch events if appropriate
// eventName = _getMouseEventName(eventName);
// Bind event to layer
jCanvas.events[eventName]($canvas, data);
layer._event = true;
} | javascript | {
"resource": ""
} |
q28227 | _enableDrag | train | function _enableDrag($canvas, data, layer) {
var dragHelperEvents, eventName, i;
// Only make layer draggable if necessary
if (layer.draggable || layer.cursors) {
// Organize helper events which enable drag support
dragHelperEvents = ['mousedown', 'mousemove', 'mouseup'];
// Bind each helper event to the can... | javascript | {
"resource": ""
} |
q28228 | _updateLayerName | train | function _updateLayerName($canvas, data, layer, props) {
var nameMap = data.layer.names;
// If layer name is being added, not changed
if (!props) {
props = layer;
} else {
// Remove old layer name entry because layer name has changed
if (props.name !== undefined && isString(layer.name) && layer.name !== p... | javascript | {
"resource": ""
} |
q28229 | _updateLayerGroups | train | function _updateLayerGroups($canvas, data, layer, props) {
var groupMap = data.layer.groups,
group, groupName, g,
index, l;
// If group name is not changing
if (!props) {
props = layer;
} else {
// Remove layer from all of its associated groups
if (props.groups !== undefined && layer.groups !== null) ... | javascript | {
"resource": ""
} |
q28230 | _getIntersectingLayer | train | function _getIntersectingLayer(data) {
var layer, i,
mask, m;
// Store the topmost layer
layer = null;
// Get the topmost layer whose visible area intersects event coordinates
for (i = data.intersecting.length - 1; i >= 0; i -= 1) {
// Get current layer
layer = data.intersecting[i];
// If layer has pre... | javascript | {
"resource": ""
} |
q28231 | _setCursor | train | function _setCursor($canvas, layer, eventType) {
var cursor;
if (layer.cursors) {
// Retrieve cursor from cursors object if it exists
cursor = layer.cursors[eventType];
}
// Prefix any CSS3 cursor
if ($.inArray(cursor, css.cursors) !== -1) {
cursor = css.prefix + cursor;
}
// If cursor is defined
if (curs... | javascript | {
"resource": ""
} |
q28232 | _runEventCallback | train | function _runEventCallback($canvas, layer, eventType, callbacks, arg) {
// Prevent callback from firing recursively
if (callbacks[eventType] && layer._running && !layer._running[eventType]) {
// Signify the start of callback execution for this event
layer._running[eventType] = true;
// Run event callback with t... | javascript | {
"resource": ""
} |
q28233 | _layerCanFireEvent | train | function _layerCanFireEvent(layer, eventType) {
// If events are disable and if
// layer is tangible or event is not tangible
return (!layer.disableEvents &&
(!layer.intangible || $.inArray(eventType, tangibleEvents) === -1));
} | javascript | {
"resource": ""
} |
q28234 | _triggerLayerEvent | train | function _triggerLayerEvent($canvas, data, layer, eventType, arg) {
// If layer can legally fire this event type
if (_layerCanFireEvent(layer, eventType)) {
// Do not set a custom cursor on layer mouseout
if (eventType !== 'mouseout') {
// Update cursor if one is defined for this event
_setCursor($canvas, ... | javascript | {
"resource": ""
} |
q28235 | _parseEndValues | train | function _parseEndValues(canvas, layer, endValues) {
var propName, propValue,
subPropName, subPropValue;
// Loop through all properties in map of end values
for (propName in endValues) {
if (Object.prototype.hasOwnProperty.call(endValues, propName)) {
propValue = endValues[propName];
// If end value is fun... | javascript | {
"resource": ""
} |
q28236 | _removeSubPropAliases | train | function _removeSubPropAliases(layer) {
var propName;
for (propName in layer) {
if (Object.prototype.hasOwnProperty.call(layer, propName)) {
if (propName.indexOf('.') !== -1) {
delete layer[propName];
}
}
}
} | javascript | {
"resource": ""
} |
q28237 | _colorToRgbArray | train | function _colorToRgbArray(color) {
var originalColor, elem,
rgb = [],
multiple = 1;
// Deal with complete transparency
if (color === 'transparent') {
color = 'rgba(0, 0, 0, 0)';
} else if (color.match(/^([a-z]+|#[0-9a-f]+)$/gi)) {
// Deal with hexadecimal colors and color names
elem = document.head;
or... | javascript | {
"resource": ""
} |
q28238 | _animateColor | train | function _animateColor(fx) {
var n = 3,
i;
// Only parse start and end colors once
if (typeOf(fx.start) !== 'array') {
fx.start = _colorToRgbArray(fx.start);
fx.end = _colorToRgbArray(fx.end);
}
fx.now = [];
// If colors are RGBA, animate transparency
if (fx.start[3] !== 1 || fx.end[3] !== 1) {
n = 4;
... | javascript | {
"resource": ""
} |
q28239 | complete | train | function complete($canvas, data, layer) {
return function () {
_showProps(layer);
_removeSubPropAliases(layer);
// Prevent multiple redraw loops
if (!data.animating || data.animated === layer) {
// Redraw layers on last frame
$canvas.drawLayers();
}
// Signify the end of an animation loo... | javascript | {
"resource": ""
} |
q28240 | _supportColorProps | train | function _supportColorProps(props) {
var p;
for (p = 0; p < props.length; p += 1) {
$.fx.step[props[p]] = _animateColor;
}
} | javascript | {
"resource": ""
} |
q28241 | _getMouseEventName | train | function _getMouseEventName(eventName) {
if (maps.mouseEvents[eventName]) {
eventName = maps.mouseEvents[eventName];
}
return eventName;
} | javascript | {
"resource": ""
} |
q28242 | _createEvent | train | function _createEvent(eventName) {
jCanvas.events[eventName] = function ($canvas, data) {
var helperEventName, touchEventName, eventCache;
// Retrieve canvas's event cache
eventCache = data.event;
// Both mouseover/mouseout events will be managed by a single mousemove event
helperEventName = (eventName ==... | javascript | {
"resource": ""
} |
q28243 | _detectEvents | train | function _detectEvents(canvas, ctx, params) {
var layer, data, eventCache, intersects,
transforms, x, y, angle;
// Use the layer object stored by the given parameters object
layer = params._args;
// Canvas must have event bindings
if (layer) {
data = _getCanvasData(canvas);
eventCache = data.event;
if (e... | javascript | {
"resource": ""
} |
q28244 | _addStartArrow | train | function _addStartArrow(canvas, ctx, params, path, x1, y1, x2, y2) {
if (!path._arrowAngleConverted) {
path.arrowAngle *= params._toRad;
path._arrowAngleConverted = true;
}
if (path.startArrow) {
_addArrow(canvas, ctx, params, path, x1, y1, x2, y2);
}
} | javascript | {
"resource": ""
} |
q28245 | _addEndArrow | train | function _addEndArrow(canvas, ctx, params, path, x1, y1, x2, y2) {
if (!path._arrowAngleConverted) {
path.arrowAngle *= params._toRad;
path._arrowAngleConverted = true;
}
if (path.endArrow) {
_addArrow(canvas, ctx, params, path, x1, y1, x2, y2);
}
} | javascript | {
"resource": ""
} |
q28246 | _getVectorX | train | function _getVectorX(params, angle, length) {
angle *= params._toRad;
angle -= (PI / 2);
return (length * cos(angle));
} | javascript | {
"resource": ""
} |
q28247 | _getVectorY | train | function _getVectorY(params, angle, length) {
angle *= params._toRad;
angle -= (PI / 2);
return (length * sin(angle));
} | javascript | {
"resource": ""
} |
q28248 | _measureText | train | function _measureText(canvas, ctx, params, lines) {
var originalSize, curWidth, l,
propCache = caches.propCache;
// Used cached width/height if possible
if (propCache.text === params.text && propCache.fontStyle === params.fontStyle && propCache.fontSize === params.fontSize && propCache.fontFamily === params.fontF... | javascript | {
"resource": ""
} |
q28249 | _wrapText | train | function _wrapText(ctx, params) {
var allText = String(params.text),
// Maximum line width (optional)
maxWidth = params.maxWidth,
// Lines created by manual line breaks (\n)
manualLines = allText.split('\n'),
// All lines created manually and by wrapping
allLines = [],
// Other variables
lines, line, l... | javascript | {
"resource": ""
} |
q28250 | getIntersection | train | function getIntersection(x0, y0, r0, x1, y1, r1) {
var dx = x1 - x0,
dy = y1 - y0,
d = sqrt(pow(dx, 2) + pow(dy, 2)),
a = (pow(d, 2) + pow(r0, 2) - pow(r1, 2)) / (2 * d),
x2 = x0 + (dx * a / d),
y2 = y0 + (dy * a / d),
h = sqrt(pow(r0, 2) - pow(a, 2)),
rx = -dy * (h / d),
ry = dx * (h / d),
xi = x2 +... | javascript | {
"resource": ""
} |
q28251 | getElementName | train | function getElementName (props, tag) {
if (typeof props.id === 'string' && !placeholderRe.test(props.id)) {
return camelCase(props.id)
}
if (typeof props.className === 'string' && !placeholderRe.test(props.className)) {
return camelCase(props.className.split(' ')[0])
}
return tag || 'nanohtml'
} | javascript | {
"resource": ""
} |
q28252 | convertPlaceholders | train | function convertPlaceholders (value) {
// Probably AST nodes.
if (typeof value !== 'string') {
return [value]
}
const items = value.split(placeholderRe)
let placeholder = true
return items.map((item) => {
placeholder = !placeholder
return placeholder ? expres... | javascript | {
"resource": ""
} |
q28253 | buildSitemapIndex | train | function buildSitemapIndex (conf) {
var xml = [];
var lastmod;
xml.push('<?xml version="1.0" encoding="UTF-8"?>');
if (conf.xslUrl) {
xml.push('<?xml-stylesheet type="text/xsl" href="' + conf.xslUrl + '"?>');
}
if (!conf.xmlNs) {
xml.push('<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitema... | javascript | {
"resource": ""
} |
q28254 | Headings | train | function Headings({ toc, path }) {
if (!toc.length) {
return null
}
return (
<ul>
{toc.map(function(item, index) {
const href = `${path}#${item.id}`
return (
<li key={index}>
{item.children.length > 0 && (
<input
... | javascript | {
"resource": ""
} |
q28255 | findInterfaces | train | function findInterfaces (targets) {
if (!targets) targets = []
targets = targets.map(target => target.toLowerCase())
if (process.platform === 'darwin') {
return findInterfacesDarwin(targets)
} else if (process.platform === 'linux') {
return findInterfacesLinux(targets)
} else if (process.platform ==... | javascript | {
"resource": ""
} |
q28256 | getInterfaceMAC | train | function getInterfaceMAC (device) {
if (process.platform === 'darwin' || process.platform === 'linux') {
let output
try {
output = cp.execSync(quote(['ifconfig', device]), { stdio: 'pipe' }).toString()
} catch (err) {
return null
}
const address = MAC_ADDRESS_RE.exec(output)
retur... | javascript | {
"resource": ""
} |
q28257 | setInterfaceMAC | train | function setInterfaceMAC (device, mac, port) {
if (!MAC_ADDRESS_RE.exec(mac)) {
throw new Error(mac + ' is not a valid MAC address')
}
const isWirelessPort = port && port.toLowerCase() === 'wi-fi'
if (process.platform === 'darwin') {
if (isWirelessPort) {
// Turn on the device, assuming it's an ... | javascript | {
"resource": ""
} |
q28258 | tryWindowsKey | train | function tryWindowsKey (key, device, mac) {
// Skip the Properties key to avoid problems with permissions
if (key.indexOf('Properties') > -1) {
return false
}
const networkAdapterKeyPath = new Winreg({
hive: Winreg.HKLM,
key: key
})
// we need to format the MAC a bit for Windows
mac = mac.re... | javascript | {
"resource": ""
} |
q28259 | randomize | train | function randomize (localAdmin) {
// Randomly assign a VM vendor's MAC address prefix, which should
// decrease chance of colliding with existing device's addresses.
const vendors = [
[ 0x00, 0x05, 0x69 ], // VMware
[ 0x00, 0x50, 0x56 ], // VMware
[ 0x00, 0x0C, 0x29 ], // VMware
[ 0x00, 0x16, 0x3... | javascript | {
"resource": ""
} |
q28260 | logOutput | train | function logOutput(options, parts) {
const msg = `${ 'Generated '.blue }${ path.resolve.apply(path, parts).cyan }`
log(options, msg)
} | javascript | {
"resource": ""
} |
q28261 | generate | train | async function generate(options = {}) {
options = Object.assign(DEFAULT_OPTIONS, options)
// Log start
let msg = `Generating font kit from ${ options.paths.length } SVG icons`.yellow
log(options, msg)
// Run validation over options
await validateOptions(options)
if (options.codepoints) {
options.co... | javascript | {
"resource": ""
} |
q28262 | getGeneratorConfig | train | function getGeneratorConfig(options) {
const { tag, classNames } = parseSelector(options.baseSelector)
const config = {
files : options.paths,
dest : options.outputDir,
types : options.types,
codepoints : options.codepointsMap,
startCodepoint : options.startC... | javascript | {
"resource": ""
} |
q28263 | parseSelector | train | function parseSelector(selector = '') {
const tagMatch = selector.match(/^[a-zA-Z0-9='"[\]_-]*/g)
const classNamesMatch = selector.match(/\.[a-zA-Z0-1_-]*/g)
return {
tag: tagMatch ? tagMatch[0] : undefined,
classNames: classNamesMatch ? classNamesMatch.map(cname => cname.substr(1)) : []
}
} | javascript | {
"resource": ""
} |
q28264 | getCssFontsUrl | train | function getCssFontsUrl(options) {
if (options.cssFontsUrl) {
return options.cssFontsUrl
} if (options.cssPath) {
return path.relative(path.dirname(options.cssPath), options.outputDir)
}
return './'
} | javascript | {
"resource": ""
} |
q28265 | getCodepointsMap | train | async function getCodepointsMap(filepath) {
const content = await fsAsync.readFile(filepath)
let codepointsMap
try {
codepointsMap = JSON.parse(content)
} catch (e) {
throw new ValidationError('Codepoints map is invalid JSON')
}
for (let propName in codepointsMap) {
codepointsMap[propName] = N... | javascript | {
"resource": ""
} |
q28266 | getResolvedPath | train | function getResolvedPath(options, type = 'html') {
const explicitPathKey = `${ type }Path`
if (options[explicitPathKey]) {
return path.resolve(options[explicitPathKey])
}
return path.resolve(options.outputDir, `${ options.fontName }.${ type }`)
} | javascript | {
"resource": ""
} |
q28267 | logReport | train | function logReport(options) {
const { outputDir, fontName } = options
// Log font files output
for (let ext of options.types) { logOutput(options, [ outputDir, `${ fontName }.${ ext }` ]) }
// Log HTML file output
if (options.html) {
logOutput(options, [ getResolvedPath(options, 'html') ])
}
// Log... | javascript | {
"resource": ""
} |
q28268 | generateJson | train | async function generateJson(options, generatorResult) {
const jsonPath = (
options.jsonPath ||
`${ path.join(options.outputDir, '/' + options.fontName) }.json`
)
const css = generatorResult.generateCss()
let map = {}
css.replace(CSS_PARSE_REGEX, (match, name, code) => map[name] = code)
await fsAs... | javascript | {
"resource": ""
} |
q28269 | deleteUnspecifiedTypes | train | async function deleteUnspecifiedTypes(options) {
const { outputDir, fontName, types } = options
for (let ext of FONT_TYPES) {
if (types.indexOf(ext) !== -1) { continue }
let filepath = path.resolve(outputDir, `${ fontName }.${ ext }`)
if (await fsAsync.exists(filepath)) {
await fsAsync.unlink(f... | javascript | {
"resource": ""
} |
q28270 | validateOptions | train | async function validateOptions(options) {
// Check that input glob was passed
if (!options.paths.length) {
throw new ValidationError('No paths specified')
}
// Check that output path was passed
if (!options.outputDir) {
throw new ValidationError('Please specify an output directory with -o or --output... | javascript | {
"resource": ""
} |
q28271 | sessionMiddleware | train | function sessionMiddleware(req,res,next) {
return ss.session.strategy.sessionMiddleware? ss.session.strategy.sessionMiddleware(req,res,next) : next();
} | javascript | {
"resource": ""
} |
q28272 | loadFile | train | function loadFile(entry, opts, formatter, cb, errCb) {
var type = entry.assetType || entry.bundle;
formatter = formatter || ss.client.formatters[entry.ext || type];
if (!formatter) {
throw new Error('Unsupported file extension \'.' + entry.ext + '\' when we were expecting some type of ' +
... | javascript | {
"resource": ""
} |
q28273 | train | function(paths) {
function relativePath(p, dirType) {
var relativeStart = p.indexOf('./') === 0 || p.indexOf('../') === 0;
return relativeStart? prefixPath(options.dirs.client,p) : prefixPath(options.dirs[dirType], p);
}
function prefixPath(base,p) {
base = base.replace... | javascript | {
"resource": ""
} | |
q28274 | getSession | train | function getSession(sessions, sessionId) {
var sess = sessions[sessionId]
if (!sess) {
debug('no session in MemoryStore for %s',sessionId);
return;
}
// parse
sess = JSON.parse(sess)
var expires = typeof sess.cookie.expires === 'string' ?
new Date(sess.cookie.expires) :
sess.cookie.expire... | javascript | {
"resource": ""
} |
q28275 | set | train | function set(url, content, mimeType) {
if (url.charAt(0) !== '/') { url = '/'+url; }
var point = getPoint(url) || new KnownPoint(url);
// console.info('new url:',url, mimeType);
point.content = content;
point.mimeType = mimeType;
} | javascript | {
"resource": ""
} |
q28276 | train | function(names, cb) {
if (!cb) {
cb = function() {};
}
if (!session.channels) {
session.channels = [];
}
forceArray(names).forEach(function(name) {
if (session.channels.indexOf(name) === -1) { // clients can only join a channel once
session.channels.push(n... | javascript | {
"resource": ""
} | |
q28277 | train | function(names, cb) {
if (!cb) {
cb = function() {};
}
if (!session.channels) {
session.channels = [];
}
forceArray(names).forEach(function(name) {
var i;
if ((i = session.channels.indexOf(name)) >= 0) {
session.channels.splice(i, 1);
sub... | javascript | {
"resource": ""
} | |
q28278 | isDir | train | function isDir(abspath, found) {
var stat = fs.statSync(abspath),
abspathAry = abspath.split('/'),
data,
file_name;
if (!found) {
found = {dirs: [], files: [] }
}
if (stat.isDirectory() && !isHidden(abspathAry[abspathAry.length - 1])) {
found.dirs.push(abs... | javascript | {
"resource": ""
} |
q28279 | projectOrHereRequire | train | function projectOrHereRequire(id,root) {
try {
return resolve.sync(id, {
package: path.join(root,'package.json'),
paths: [root],
basedir:root
});
} catch(ex) {
// console.error(ex);
}
var here = path.join(__dirname,'..','..');
try {
var p = resolve.sync(id, {
package: path.join(here,'package.j... | javascript | {
"resource": ""
} |
q28280 | resolveAssetLink | train | function resolveAssetLink(client, type) {
var defaultPath = '/assets/' + client.name + '/' + client.id + '.' + type,
pack = options.packedAssets,
link = pack !== undefined ? (pack.cdn !== undefined ? pack.cdn[type] : void 0) : void 0;
if (link) {
if (typeof link === 'function') {
var f... | javascript | {
"resource": ""
} |
q28281 | sendToMultiple | train | function sendToMultiple(send, msg, destinations, type) {
destinations = destinations instanceof Array && destinations || [destinations];
destinations.forEach(function(destination) {
var set, socketIds;
set = subscriptions[type];
if ((socketIds = set.members(destination))) {
return socketIds.slice(... | javascript | {
"resource": ""
} |
q28282 | train | function(all) {
var tasks = all? ['load-api']:['pack-prepare','load-api'];
ss.bundler.forEach(function(bundler){
if (all) {
tasks.push(bundler.client.name + ':pack');
} else if (bundler.packNeeded) {
tasks.push(bundler.client.name + ':pack-needed');
tasks.push(b... | javascript | {
"resource": ""
} | |
q28283 | suggestedId | train | function suggestedId(pth, templatesPath) {
if (pth.indexOf(templatesPath) === 0) {
pth = pth.substring(templatesPath.length + 1);
}
var sp;
sp = pth.split('.');
if (pth.indexOf('.') > 0) {
sp.pop();
}
return sp.join('.').replace(/\//g, '-');
} | javascript | {
"resource": ""
} |
q28284 | onChange | train | function onChange(changedPath, event) {
var _ref = path.extname(changedPath),
action = cssExtensions.indexOf(_ref) >= 0 ? 'updateCSS' : 'reload';
//first change is with delayTime delay , thereafter only once there has been no further changes for guardTime seconds
//validate the change
... | javascript | {
"resource": ""
} |
q28285 | train | function(newOption) {
var k, v, y, _results;
if (typeof newOption !== 'object') {
throw new Error('ss.client.set() takes an object e.g. {liveReload: false}');
}
_results = [];
for (k in newOption) {
if (newOption.hasOwnProperty(k)) {
v = newOption[k];
if... | javascript | {
"resource": ""
} | |
q28286 | train | function(opts) {
if (opts && typeof opts !== 'object') {
throw new Error('Options passed to ss.client.packAssets() must be an object');
}
options.packedAssets = opts || true;
options.servePacked = opts || true;
options.liveReload = false;
// As it's safe to assume we're runn... | javascript | {
"resource": ""
} | |
q28287 | train | function() {
ss.http.cached.loadStatic();
ss.http.cached.loadAssets();
ss.bundler.updateCachedOndemandAssets();
ss.bundler.forEach(function(bundler) {
bundler.updateCachedDevAssets();
});
} | javascript | {
"resource": ""
} | |
q28288 | train | function() {
if (options.servePacked) {
ss.bundler.forEach(function(bundler) {
bundler.useLatestsPackedId();
});
}
ss.bundler.load();
//TODO convert options.dirs to relative paths stripping the lead '/' if present
// Cache instances of code formatters and templat... | javascript | {
"resource": ""
} | |
q28289 | train | function(msg) {
for (var id in openSocketsById) {
if (openSocketsById.hasOwnProperty(id)) {
openSocketsById[id].send('0|' + msg + '|null');
}
}
} | javascript | {
"resource": ""
} | |
q28290 | pattern | train | function pattern (val, pat) {
if (typeof pat !== 'string') { return false }
var match = pat.match(new RegExp('^/(.*?)/([gimy]*)$'));
if (!match) { return false }
return new RegExp(match[1], match[2]).test(val)
} | javascript | {
"resource": ""
} |
q28291 | minlength | train | function minlength (val, min) {
if (typeof val === 'string') {
return isInteger(min, 10) && val.length >= parseInt(min, 10)
} else if (Array.isArray(val)) {
return val.length >= parseInt(min, 10)
} else {
return false
}
} | javascript | {
"resource": ""
} |
q28292 | maxlength | train | function maxlength (val, max) {
if (typeof val === 'string') {
return isInteger(max, 10) && val.length <= parseInt(max, 10)
} else if (Array.isArray(val)) {
return val.length <= parseInt(max, 10)
} else {
return false
}
} | javascript | {
"resource": ""
} |
q28293 | validator | train | function validator (
id,
def
) {
if (def === undefined) {
return Vue.options['validators'][id]
} else {
Vue.options['validators'][id] = def;
if (def === null) {
delete Vue.options['validators']['id'];
}
}
} | javascript | {
"resource": ""
} |
q28294 | addMonitoring | train | function addMonitoring(connection, probe) {
aspect.around(
connection,
'execute',
function(target, methodName, args, probeData) {
// Start the monitoring for the 'execute' method
probe.metricsProbeStart(probeData, methodName, args);
probe.requestProbeStart(probeData, methodName, args);
... | javascript | {
"resource": ""
} |
q28295 | train | function(target, methodName, methodArgs, probeData, rc) {
// If no callback has been used then end the metrics after returning from the method instead
if (aspect.findCallbackArg(methodArgs) === undefined) {
// Need to get request method and URL again
var ri = getRequestItems(methodAr... | javascript | {
"resource": ""
} | |
q28296 | train | function() {
var lvldownObj = target.apply(null, arguments);
lvldownObj._ddProbeAttached_ = true;
aspectLvldownMethod(lvldownObj, methods, that);
return lvldownObj;
} | javascript | {
"resource": ""
} | |
q28297 | train | function(obj, methodName, methodArgs, probeData) {
// Start metrics
that.metricsProbeStart(probeData);
that.requestProbeStart(probeData);
// End metrics
aspect.aroundCallback(
methodArgs,
probeData,
function(target, args, probeData) {
// ... | javascript | {
"resource": ""
} | |
q28298 | done | train | function done(output, options, config, failures, exit) {
return marge.create(output, options)
.then(([ htmlFile, jsonFile ]) => {
if (!htmlFile && !jsonFile) {
log('No files were generated', 'warn', config);
} else {
jsonFile && log(`Report JSON saved to ${jsonFile}`, null, config);
... | javascript | {
"resource": ""
} |
q28299 | Mochawesome | train | function Mochawesome(runner, options) {
// Set the config options
this.config = conf(options);
// Reporter options
const reporterOptions = Object.assign(
{},
(options.reporterOptions || {}),
{
reportFilename: this.config.reportFilename,
saveHtml: this.config.saveHtml,
saveJson: th... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.