_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q15600 | determineAlignment | train | function determineAlignment(tooltip, size) {
var model = tooltip._model;
var chart = tooltip._chart;
var chartArea = tooltip._chart.chartArea;
var xAlign = 'center';
var yAlign = 'center';
if (model.y < size.height) {
yAlign = 'top';
} else if (model.y > (chart.height - size.height)) {
yAlign = 'bottom';
}... | javascript | {
"resource": ""
} |
q15601 | train | function(chart, hook, args) {
var descriptors = this.descriptors(chart);
var ilen = descriptors.length;
var i, descriptor, plugin, params, method;
for (i = 0; i < ilen; ++i) {
descriptor = descriptors[i];
plugin = descriptor.plugin;
method = plugin[hook];
if (typeof method === 'function') {
par... | javascript | {
"resource": ""
} | |
q15602 | train | function(chart) {
var cache = chart.$plugins || (chart.$plugins = {});
if (cache.id === this._cacheId) {
return cache.descriptors;
}
var plugins = [];
var descriptors = [];
var config = (chart && chart.config) || {};
var options = (config.options && config.options.plugins) || {};
this._plugins.conc... | javascript | {
"resource": ""
} | |
q15603 | getBarBounds | train | function getBarBounds(vm) {
var x1, x2, y1, y2, half;
if (isVertical(vm)) {
half = vm.width / 2;
x1 = vm.x - half;
x2 = vm.x + half;
y1 = Math.min(vm.y, vm.base);
y2 = Math.max(vm.y, vm.base);
} else {
half = vm.height / 2;
x1 = Math.min(vm.x, vm.base);
x2 = Math.max(vm.x, vm.base);
y1 = vm.y - ha... | javascript | {
"resource": ""
} |
q15604 | fitWithPointLabels | train | function fitWithPointLabels(scale) {
// Right, this is really confusing and there is a lot of maths going on here
// The gist of the problem is here: https://gist.github.com/nnnick/696cc9c55f4b0beb8fe9
//
// Reaction: https://dl.dropboxusercontent.com/u/34601363/toomuchscience.gif
//
// Solution:
//
// We assu... | javascript | {
"resource": ""
} |
q15605 | train | function(largestPossibleRadius, furthestLimits, furthestAngles) {
var me = this;
var radiusReductionLeft = furthestLimits.l / Math.sin(furthestAngles.l);
var radiusReductionRight = Math.max(furthestLimits.r - me.width, 0) / Math.sin(furthestAngles.r);
var radiusReductionTop = -furthestLimits.t / Math.cos(furthe... | javascript | {
"resource": ""
} | |
q15606 | train | function(datasetIndex) {
var ringWeightOffset = 0;
for (var i = 0; i < datasetIndex; ++i) {
if (this.chart.isDatasetVisible(i)) {
ringWeightOffset += this._getRingWeight(i);
}
}
return ringWeightOffset;
} | javascript | {
"resource": ""
} | |
q15607 | determineUnitForAutoTicks | train | function determineUnitForAutoTicks(minUnit, min, max, capacity) {
var ilen = UNITS.length;
var i, interval, factor;
for (i = UNITS.indexOf(minUnit); i < ilen - 1; ++i) {
interval = INTERVALS[UNITS[i]];
factor = interval.steps ? interval.steps[interval.steps.length - 1] : MAX_INTEGER;
if (interval.common && M... | javascript | {
"resource": ""
} |
q15608 | determineUnitForFormatting | train | function determineUnitForFormatting(scale, ticks, minUnit, min, max) {
var ilen = UNITS.length;
var i, unit;
for (i = ilen - 1; i >= UNITS.indexOf(minUnit); i--) {
unit = UNITS[i];
if (INTERVALS[unit].common && scale._adapter.diff(max, min, unit) >= ticks.length) {
return unit;
}
}
return UNITS[minUnit ... | javascript | {
"resource": ""
} |
q15609 | train | function() {
var me = this;
if (me.margins) {
me.paddingLeft = Math.max(me.paddingLeft - me.margins.left, 0);
me.paddingTop = Math.max(me.paddingTop - me.margins.top, 0);
me.paddingRight = Math.max(me.paddingRight - me.margins.right, 0);
me.paddingBottom = Math.max(me.paddingBottom - me.margins.bottom, ... | javascript | {
"resource": ""
} | |
q15610 | train | function(ticks) {
var me = this;
var isHorizontal = me.isHorizontal();
var optionTicks = me.options.ticks;
var tickCount = ticks.length;
var skipRatio = false;
var maxTicks = optionTicks.maxTicksLimit;
// Total space needed to display all ticks. First and last ticks are
// drawn as their center at end ... | javascript | {
"resource": ""
} | |
q15611 | train | function() {
var me = this;
me._config = helpers.merge({}, [
me.chart.options.datasets[me._type],
me.getDataset(),
], {
merger: function(key, target, source) {
if (key !== '_meta' && key !== 'data') {
helpers._merger(key, target, source);
}
}
});
} | javascript | {
"resource": ""
} | |
q15612 | train | function(value, index, defaultValue) {
return helpers.valueOrDefault(helpers.isArray(value) ? value[index] : value, defaultValue);
} | javascript | {
"resource": ""
} | |
q15613 | train | function(fn, args, thisArg) {
if (fn && typeof fn.call === 'function') {
return fn.apply(thisArg, args);
}
} | javascript | {
"resource": ""
} | |
q15614 | train | function(a0, a1) {
var i, ilen, v0, v1;
if (!a0 || !a1 || a0.length !== a1.length) {
return false;
}
for (i = 0, ilen = a0.length; i < ilen; ++i) {
v0 = a0[i];
v1 = a1[i];
if (v0 instanceof Array && v1 instanceof Array) {
if (!helpers.arrayEquals(v0, v1)) {
return false;
}
} else ... | javascript | {
"resource": ""
} | |
q15615 | train | function(source) {
if (helpers.isArray(source)) {
return source.map(helpers.clone);
}
if (helpers.isObject(source)) {
var target = {};
var keys = Object.keys(source);
var klen = keys.length;
var k = 0;
for (; k < klen; ++k) {
target[keys[k]] = helpers.clone(source[keys[k]]);
}
retur... | javascript | {
"resource": ""
} | |
q15616 | train | function() {
var data = this.chart.data;
return this.options.labels || (this.isHorizontal() ? data.xLabels : data.yLabels) || data.labels;
} | javascript | {
"resource": ""
} | |
q15617 | train | function(e, legendItem) {
var index = legendItem.datasetIndex;
var ci = this.chart;
var meta = ci.getDatasetMeta(index);
// See controller.isDatasetVisible comment
meta.hidden = meta.hidden === null ? !ci.data.datasets[index].hidden : null;
// We hid a dataset ... rerender the chart
ci.update();
... | javascript | {
"resource": ""
} | |
q15618 | getBoxWidth | train | function getBoxWidth(labelOpts, fontSize) {
return labelOpts.usePointStyle && labelOpts.boxWidth > fontSize ?
fontSize :
labelOpts.boxWidth;
} | javascript | {
"resource": ""
} |
q15619 | getNearestItems | train | function getNearestItems(chart, position, intersect, distanceMetric) {
var minDistance = Number.POSITIVE_INFINITY;
var nearestItems = [];
parseVisibleItems(chart, function(element) {
if (intersect && !element.inRange(position.x, position.y)) {
return;
}
var center = element.getCenterPoint();
var distanc... | javascript | {
"resource": ""
} |
q15620 | getDistanceMetricForAxis | train | function getDistanceMetricForAxis(axis) {
var useX = axis.indexOf('x') !== -1;
var useY = axis.indexOf('y') !== -1;
return function(pt1, pt2) {
var deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;
var deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;
return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
};
} | javascript | {
"resource": ""
} |
q15621 | train | function(chart, e, options) {
var position = getRelativePosition(e, chart);
options.axis = options.axis || 'xy';
var distanceMetric = getDistanceMetricForAxis(options.axis);
return getNearestItems(chart, position, options.intersect, distanceMetric);
} | javascript | {
"resource": ""
} | |
q15622 | generateIjmap | train | function generateIjmap(ijmapPath) {
return through2.obj((codepointsFile, encoding, callback) => {
const ijmap = {
icons: codepointsToIjmap(codepointsFile.contents.toString())
};
callback(null, new File({
path: ijmapPath,
contents: new Buffer(JSON.stringify(ijmap), 'utf8')
}));
... | javascript | {
"resource": ""
} |
q15623 | getSvgSpriteConfig | train | function getSvgSpriteConfig(category) {
return {
shape: {
dimension: {
maxWidth: 24,
maxHeight: 24
},
},
mode: {
css : {
bust: false,
dest: './',
sprite: `./svg-sprite-${ category }.svg`,
example: {
dest: `./svg-sprite-${ category... | javascript | {
"resource": ""
} |
q15624 | getCategoryColorPairs | train | function getCategoryColorPairs() {
return _(ICON_CATEGORIES)
.map((category) =>
_.zip(_.times(PNG_COLORS.length, () => category), PNG_COLORS))
.flatten() // flattens 1 level
.value();
} | javascript | {
"resource": ""
} |
q15625 | Server | train | function Server(srv, opts){
if (!(this instanceof Server)) return new Server(srv, opts);
if ('object' == typeof srv && srv instanceof Object && !srv.listen) {
opts = srv;
srv = null;
}
opts = opts || {};
this.nsps = {};
this.parentNsps = new Map();
this.path(opts.path || '/socket.io');
this.serv... | javascript | {
"resource": ""
} |
q15626 | Client | train | function Client(server, conn){
this.server = server;
this.conn = conn;
this.encoder = server.encoder;
this.decoder = new server.parser.Decoder();
this.id = conn.id;
this.request = conn.request;
this.setup();
this.sockets = {};
this.nsps = {};
this.connectBuffer = [];
} | javascript | {
"resource": ""
} |
q15627 | writeToEngine | train | function writeToEngine(encodedPackets) {
if (opts.volatile && !self.conn.transport.writable) return;
for (var i = 0; i < encodedPackets.length; i++) {
self.conn.write(encodedPackets[i], { compress: opts.compress });
}
} | javascript | {
"resource": ""
} |
q15628 | Namespace | train | function Namespace(server, name){
this.name = name;
this.server = server;
this.sockets = {};
this.connected = {};
this.fns = [];
this.ids = 0;
this.rooms = [];
this.flags = {};
this.initAdapter();
} | javascript | {
"resource": ""
} |
q15629 | throttle | train | function throttle(callback, delay) {
var previousCall = new Date().getTime();
return function() {
var time = new Date().getTime();
if ((time - previousCall) >= delay) {
previousCall = time;
callback.apply(null, arguments);
}
};
} | javascript | {
"resource": ""
} |
q15630 | Socket | train | function Socket(nsp, client, query){
this.nsp = nsp;
this.server = nsp.server;
this.adapter = this.nsp.adapter;
this.id = nsp.name !== '/' ? nsp.name + '#' + client.id : client.id;
this.client = client;
this.conn = client.conn;
this.rooms = {};
this.acks = {};
this.connected = true;
this.disconnecte... | javascript | {
"resource": ""
} |
q15631 | train | function() {
var corePath = __dirname + "/../src/core.js",
contents = fs.readFileSync( corePath, "utf8" );
contents = contents.replace( /@VERSION/g, Release.newVersion );
fs.writeFileSync( corePath, contents, "utf8" );
} | javascript | {
"resource": ""
} | |
q15632 | train | function( callback ) {
Release.exec( "grunt", "Grunt command failed" );
Release.exec(
"grunt custom:-ajax,-effects --filename=jquery.slim.js && " +
"grunt remove_map_comment --filename=jquery.slim.js",
"Grunt custom failed"
);
cdn.makeReleaseCopies( Release );
Release._setSrcVersion();
ca... | javascript | {
"resource": ""
} | |
q15633 | train | function() {
// origRepo is not defined if dist was skipped
Release.dir.repo = Release.dir.origRepo || Release.dir.repo;
return npmTags();
} | javascript | {
"resource": ""
} | |
q15634 | clone | train | function clone() {
Release.chdir( Release.dir.base );
Release.dir.dist = Release.dir.base + "/dist";
console.log( "Using distribution repo: ", distRemote );
Release.exec( "git clone " + distRemote + " " + Release.dir.dist,
"Error cloning repo." );
// Distribution always works on master
Release.chdir( R... | javascript | {
"resource": ""
} |
q15635 | generateBower | train | function generateBower() {
return JSON.stringify( {
name: pkg.name,
main: pkg.main,
license: "MIT",
ignore: [
"package.json"
],
keywords: pkg.keywords
}, null, 2 );
} | javascript | {
"resource": ""
} |
q15636 | editReadme | train | function editReadme( readme ) {
var rprev = new RegExp( Release.prevVersion, "g" );
return readme.replace( rprev, Release.newVersion );
} | javascript | {
"resource": ""
} |
q15637 | commit | train | function commit() {
console.log( "Adding files to dist..." );
Release.exec( "git add -A", "Error adding files." );
Release.exec(
"git commit -m \"Release " + Release.newVersion + "\"",
"Error committing files."
);
console.log();
console.log( "Tagging release on dist..." );
Release.exec( "git tag " ... | javascript | {
"resource": ""
} |
q15638 | push | train | function push() {
Release.chdir( Release.dir.dist );
console.log( "Pushing release to dist repo..." );
Release.exec( "git push " + distRemote + " master --tags",
"Error pushing master and tags to git repo." );
// Set repo for npm publish
Release.dir.origRepo = Release.dir.repo;
Release.dir.repo = Relea... | javascript | {
"resource": ""
} |
q15639 | makeReleaseCopies | train | function makeReleaseCopies( Release ) {
shell.mkdir( "-p", cdnFolder );
Object.keys( releaseFiles ).forEach( function( key ) {
var text,
builtFile = releaseFiles[ key ],
unpathedFile = key.replace( /VER/g, Release.newVersion ),
releaseFile = cdnFolder + "/" + unpathedFile;
if ( /\.map$/.test( releaseFi... | javascript | {
"resource": ""
} |
q15640 | finalPropName | train | function finalPropName( name ) {
var final = vendorProps[ name ];
if ( final ) {
return final;
}
if ( name in emptyStyle ) {
return name;
}
return vendorProps[ name ] = vendorPropName( name ) || name;
} | javascript | {
"resource": ""
} |
q15641 | scan | train | function scan () {
rootInstances.length = 0
let inFragment = false
let currentFragment = null
function processInstance (instance) {
if (instance) {
if (rootInstances.indexOf(instance.$root) === -1) {
instance = instance.$root
}
if (instance._isFragment) {
inFragment = true... | javascript | {
"resource": ""
} |
q15642 | walk | train | function walk (node, fn) {
if (node.childNodes) {
for (let i = 0, l = node.childNodes.length; i < l; i++) {
const child = node.childNodes[i]
const stop = fn(child)
if (!stop) {
walk(child, fn)
}
}
}
// also walk shadow DOM
if (node.shadowRoot) {
walk(node.shadowRoot,... | javascript | {
"resource": ""
} |
q15643 | isQualified | train | function isQualified (instance) {
const name = classify(instance.name || getInstanceName(instance)).toLowerCase()
return name.indexOf(filter) > -1
} | javascript | {
"resource": ""
} |
q15644 | mark | train | function mark (instance) {
if (!instanceMap.has(instance.__VUE_DEVTOOLS_UID__)) {
instanceMap.set(instance.__VUE_DEVTOOLS_UID__, instance)
instance.$on('hook:beforeDestroy', function () {
instanceMap.delete(instance.__VUE_DEVTOOLS_UID__)
})
}
} | javascript | {
"resource": ""
} |
q15645 | getInstanceDetails | train | function getInstanceDetails (id) {
const instance = instanceMap.get(id)
if (!instance) {
const vnode = findInstanceOrVnode(id)
if (!vnode) return {}
const data = {
id,
name: getComponentName(vnode.fnOptions),
file: vnode.fnOptions.__file || null,
state: processProps({ $options:... | javascript | {
"resource": ""
} |
q15646 | processState | train | function processState (instance) {
const props = isLegacy
? instance._props
: instance.$options.props
const getters =
instance.$options.vuex &&
instance.$options.vuex.getters
return Object.keys(instance._data)
.filter(key => (
!(props && key in props) &&
!(getters && key in getters... | javascript | {
"resource": ""
} |
q15647 | processComputed | train | function processComputed (instance) {
const computed = []
const defs = instance.$options.computed || {}
// use for...in here because if 'computed' is not defined
// on component, computed properties will be placed in prototype
// and Object.keys does not include
// properties from object's prototype
for (... | javascript | {
"resource": ""
} |
q15648 | processFirebaseBindings | train | function processFirebaseBindings (instance) {
var refs = instance.$firebaseRefs
if (refs) {
return Object.keys(refs).map(key => {
return {
type: 'firebase bindings',
key,
value: instance[key]
}
})
} else {
return []
}
} | javascript | {
"resource": ""
} |
q15649 | processObservables | train | function processObservables (instance) {
var obs = instance.$observables
if (obs) {
return Object.keys(obs).map(key => {
return {
type: 'observables',
key,
value: instance[key]
}
})
} else {
return []
}
} | javascript | {
"resource": ""
} |
q15650 | scrollIntoView | train | function scrollIntoView (instance) {
const rect = getInstanceOrVnodeRect(instance)
if (rect) {
// TODO: Handle this for non-browser environments.
window.scrollBy(0, rect.top + (rect.height - window.innerHeight) / 2)
}
} | javascript | {
"resource": ""
} |
q15651 | onContextMenu | train | function onContextMenu ({ id }) {
if (id === 'vue-inspect-instance') {
const src = `window.__VUE_DEVTOOLS_CONTEXT_MENU_HAS_TARGET__`
chrome.devtools.inspectedWindow.eval(src, function (res, err) {
if (err) {
console.log(err)
}
if (typeof res !== 'undefined' && res) {
panelAc... | javascript | {
"resource": ""
} |
q15652 | panelAction | train | function panelAction (cb, message = null) {
if (created && panelLoaded && panelShown) {
cb()
} else {
pendingAction = cb
message && toast(message)
}
} | javascript | {
"resource": ""
} |
q15653 | injectScript | train | function injectScript (scriptName, cb) {
const src = `
(function() {
var script = document.constructor.prototype.createElement.call(document, 'script');
script.src = "${scriptName}";
document.documentElement.appendChild(script);
script.parentNode.removeChild(script);
})()
`
chrome.... | javascript | {
"resource": ""
} |
q15654 | getFragmentRect | train | function getFragmentRect ({ _fragmentStart, _fragmentEnd }) {
let top, bottom, left, right
util().mapNodeRange(_fragmentStart, _fragmentEnd, function (node) {
let rect
if (node.nodeType === 1 || node.getBoundingClientRect) {
rect = node.getBoundingClientRect()
} else if (node.nodeType === 3 && nod... | javascript | {
"resource": ""
} |
q15655 | getTextRect | train | function getTextRect (node) {
if (!isBrowser) return
if (!range) range = document.createRange()
range.selectNode(node)
return range.getBoundingClientRect()
} | javascript | {
"resource": ""
} |
q15656 | showOverlay | train | function showOverlay ({ width = 0, height = 0, top = 0, left = 0 }, content = []) {
if (!isBrowser) return
overlay.style.width = ~~width + 'px'
overlay.style.height = ~~height + 'px'
overlay.style.top = ~~top + 'px'
overlay.style.left = ~~left + 'px'
overlayContent.innerHTML = ''
content.forEach(child =... | javascript | {
"resource": ""
} |
q15657 | basename | train | function basename (filename, ext) {
return path.basename(
filename.replace(/^[a-zA-Z]:/, '').replace(/\\/g, '/'),
ext
)
} | javascript | {
"resource": ""
} |
q15658 | sanitize | train | function sanitize (data) {
if (
!isPrimitive(data) &&
!Array.isArray(data) &&
!isPlainObject(data)
) {
// handle types that will probably cause issues in
// the structured clone
return Object.prototype.toString.call(data)
} else {
return data
}
} | javascript | {
"resource": ""
} |
q15659 | internalSearchObject | train | function internalSearchObject (obj, searchTerm, seen, depth) {
if (depth > SEARCH_MAX_DEPTH) {
return false
}
let match = false
const keys = Object.keys(obj)
let key, value
for (let i = 0; i < keys.length; i++) {
key = keys[i]
value = obj[key]
match = internalSearchCheck(searchTerm, key, val... | javascript | {
"resource": ""
} |
q15660 | internalSearchArray | train | function internalSearchArray (array, searchTerm, seen, depth) {
if (depth > SEARCH_MAX_DEPTH) {
return false
}
let match = false
let value
for (let i = 0; i < array.length; i++) {
value = array[i]
match = internalSearchCheck(searchTerm, null, value, seen, depth + 1)
if (match) {
break
... | javascript | {
"resource": ""
} |
q15661 | internalSearchCheck | train | function internalSearchCheck (searchTerm, key, value, seen, depth) {
let match = false
let result
if (key === '_custom') {
key = value.display
value = value.value
}
(result = specialTokenToString(value)) && (value = result)
if (key && compare(key, searchTerm)) {
match = true
seen.set(value, ... | javascript | {
"resource": ""
} |
q15662 | createColoredCanvas | train | function createColoredCanvas(color)
{
const canvas = document.createElement('canvas');
canvas.width = 6;
canvas.height = 1;
const context = canvas.getContext('2d');
context.fillStyle = color;
context.fillRect(0, 0, 6, 1);
return canvas;
} | javascript | {
"resource": ""
} |
q15663 | getPt | train | function getPt(n1, n2, perc)
{
const diff = n2 - n1;
return n1 + (diff * perc);
} | javascript | {
"resource": ""
} |
q15664 | uploadGraphics | train | function uploadGraphics(renderer, item)
{
if (item instanceof Graphics)
{
// if the item is not dirty and already has webgl data, then it got prepared or rendered
// before now and we shouldn't waste time updating it again
if (item.dirty || item.clearDirty || !item._webGL[renderer.plugin... | javascript | {
"resource": ""
} |
q15665 | findGraphics | train | function findGraphics(item, queue)
{
if (item instanceof Graphics)
{
queue.push(item);
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q15666 | findMultipleBaseTextures | train | function findMultipleBaseTextures(item, queue)
{
let result = false;
// Objects with multiple textures
if (item && item._textures && item._textures.length)
{
for (let i = 0; i < item._textures.length; i++)
{
if (item._textures[i] instanceof Texture)
{
... | javascript | {
"resource": ""
} |
q15667 | findBaseTexture | train | function findBaseTexture(item, queue)
{
// Objects with textures, like Sprites/Text
if (item instanceof BaseTexture)
{
if (queue.indexOf(item) === -1)
{
queue.push(item);
}
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q15668 | findTexture | train | function findTexture(item, queue)
{
if (item._texture && item._texture instanceof Texture)
{
const texture = item._texture.baseTexture;
if (queue.indexOf(texture) === -1)
{
queue.push(texture);
}
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q15669 | drawText | train | function drawText(helper, item)
{
if (item instanceof Text)
{
// updating text will return early if it is not dirty
item.updateText(true);
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q15670 | calculateTextStyle | train | function calculateTextStyle(helper, item)
{
if (item instanceof TextStyle)
{
const font = item.toFontString();
TextMetrics.measureFont(font);
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q15671 | findText | train | function findText(item, queue)
{
if (item instanceof Text)
{
// push the text style to prepare it - this can be really expensive
if (queue.indexOf(item.style) === -1)
{
queue.push(item.style);
}
// also push the text object so that we can render it (to canvas/... | javascript | {
"resource": ""
} |
q15672 | findTextStyle | train | function findTextStyle(item, queue)
{
if (item instanceof TextStyle)
{
if (queue.indexOf(item) === -1)
{
queue.push(item);
}
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q15673 | getSingleColor | train | function getSingleColor(color)
{
if (typeof color === 'number')
{
return hex2string(color);
}
else if ( typeof color === 'string' )
{
if ( color.indexOf('0x') === 0 )
{
color = color.replace('0x', '#');
}
}
return color;
} | javascript | {
"resource": ""
} |
q15674 | deepCopyProperties | train | function deepCopyProperties(target, source, propertyObj) {
for (const prop in propertyObj) {
if (Array.isArray(source[prop])) {
target[prop] = source[prop].slice();
} else {
target[prop] = source[prop];
}
}
} | javascript | {
"resource": ""
} |
q15675 | mapPremultipliedBlendModes | train | function mapPremultipliedBlendModes()
{
const pm = [];
const npm = [];
for (let i = 0; i < 32; i++)
{
pm[i] = i;
npm[i] = i;
}
pm[BLEND_MODES.NORMAL_NPM] = BLEND_MODES.NORMAL;
pm[BLEND_MODES.ADD_NPM] = BLEND_MODES.ADD;
pm[BLEND_MODES.SCREEN_NPM] = BLEND_MODES.SCREEN;
... | javascript | {
"resource": ""
} |
q15676 | sleuth_fat | train | function sleuth_fat(idx, cnt, sectors, ssz, fat_addrs) {
var q = ENDOFCHAIN;
if(idx === ENDOFCHAIN) {
if(cnt !== 0) throw new Error("DIFAT chain shorter than expected");
} else if(idx !== -1 /*FREESECT*/) {
var sector = sectors[idx], m = (ssz>>>2)-1;
if(!sector) return;
for(var i = 0; i < m; ++i) {
if((q ... | javascript | {
"resource": ""
} |
q15677 | get_sector_list | train | function get_sector_list(sectors, start, fat_addrs, ssz, chkd) {
var buf = [], buf_chain = [];
if(!chkd) chkd = [];
var modulus = ssz - 1, j = 0, jj = 0;
for(j=start; j>=0;) {
chkd[j] = true;
buf[buf.length] = j;
buf_chain.push(sectors[j]);
var addr = fat_addrs[Math.floor(j*4/ssz)];
jj = ((j*4) & modulus)... | javascript | {
"resource": ""
} |
q15678 | make_sector_list | train | function make_sector_list(sectors, dir_start, fat_addrs, ssz) {
var sl = sectors.length, sector_list = ([]);
var chkd = [], buf = [], buf_chain = [];
var modulus = ssz - 1, i=0, j=0, k=0, jj=0;
for(i=0; i < sl; ++i) {
buf = ([]);
k = (i + dir_start); if(k >= sl) k-=sl;
if(chkd[k]) continue;
buf_chain = [];
... | javascript | {
"resource": ""
} |
q15679 | resolveSFCs | train | function resolveSFCs (dirs) {
return dirs.map(
layoutDir => readdirSync(layoutDir)
.filter(filename => filename.endsWith('.vue'))
.map(filename => {
const componentName = getComponentName(filename)
return {
filename,
componentName,
isInternal: isInternal(c... | javascript | {
"resource": ""
} |
q15680 | compile | train | function compile (config) {
return new Promise((resolve, reject) => {
webpack(config, (err, stats) => {
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
stats.toJson().errors.forEach(err => {
console.error(err)
})
reject(new Error(`Failed to comp... | javascript | {
"resource": ""
} |
q15681 | renderHeadTag | train | function renderHeadTag (tag) {
const { tagName, attributes, innerHTML, closeTag } = normalizeHeadTag(tag)
return `<${tagName}${renderAttrs(attributes)}>${innerHTML}${closeTag ? `</${tagName}>` : ``}`
} | javascript | {
"resource": ""
} |
q15682 | renderAttrs | train | function renderAttrs (attrs = {}) {
const keys = Object.keys(attrs)
if (keys.length) {
return ' ' + keys.map(name => `${name}="${escape(attrs[name])}"`).join(' ')
} else {
return ''
}
} | javascript | {
"resource": ""
} |
q15683 | renderPageMeta | train | function renderPageMeta (meta) {
if (!meta) return ''
return meta.map(m => {
let res = `<meta`
Object.keys(m).forEach(key => {
res += ` ${key}="${escape(m[key])}"`
})
return res + `>`
}).join('')
} | javascript | {
"resource": ""
} |
q15684 | CLI | train | async function CLI ({
beforeParse,
afterParse
}) {
const cli = CAC()
beforeParse && await beforeParse(cli)
cli.parse(process.argv)
afterParse && await afterParse(cli)
} | javascript | {
"resource": ""
} |
q15685 | wrapCommand | train | function wrapCommand (fn) {
return (...args) => {
return fn(...args).catch(err => {
console.error(chalk.red(err.stack))
process.exitCode = 1
})
}
} | javascript | {
"resource": ""
} |
q15686 | resolveHost | train | function resolveHost (host) {
const defaultHost = '0.0.0.0'
host = host || defaultHost
const displayHost = host === defaultHost
? 'localhost'
: host
return {
displayHost,
host
}
} | javascript | {
"resource": ""
} |
q15687 | resolvePort | train | async function resolvePort (port) {
const portfinder = require('portfinder')
portfinder.basePort = parseInt(port) || 8080
port = await portfinder.getPortPromise()
return port
} | javascript | {
"resource": ""
} |
q15688 | normalizeWatchFilePath | train | function normalizeWatchFilePath (filepath, baseDir) {
const { isAbsolute, relative } = require('path')
if (isAbsolute(filepath)) {
return relative(baseDir, filepath)
}
return filepath
} | javascript | {
"resource": ""
} |
q15689 | routesCode | train | function routesCode (pages) {
function genRoute ({
path: pagePath,
key: componentName,
frontmatter: {
layout
},
regularPath,
_meta
}) {
let code = `
{
name: ${JSON.stringify(componentName)},
path: ${JSON.stringify(pagePath)},
component: GlobalLayout,
beforeEnter: ... | javascript | {
"resource": ""
} |
q15690 | registerUnknownCommands | train | function registerUnknownCommands (cli, options) {
cli.on('command:*', async () => {
const { args, options: commandoptions } = cli
logger.debug('global_options', options)
logger.debug('cli_options', commandoptions)
logger.debug('cli_args', args)
const [commandName] = args
const sourceDir = ar... | javascript | {
"resource": ""
} |
q15691 | vBindEscape | train | function vBindEscape (strs, ...args) {
return strs.reduce((prev, curr, index) => {
return prev + curr + (index >= args.length
? ''
: `"${JSON.stringify(args[index])
.replace(/"/g, "'")
.replace(/([^\\])(\\\\)*\\'/g, (_, char) => char + '\\u0022')}"`)
}, '')
} | javascript | {
"resource": ""
} |
q15692 | setTargetsValue | train | function setTargetsValue(targets, properties) {
const animatables = getAnimatables(targets);
animatables.forEach(animatable => {
for (let property in properties) {
const value = getFunctionValue(properties[property], animatable);
const target = animatable.target;
const valueUnit = getUnit(valu... | javascript | {
"resource": ""
} |
q15693 | removeTargetsFromAnimations | train | function removeTargetsFromAnimations(targetsArray, animations) {
for (let a = animations.length; a--;) {
if (arrayContains(targetsArray, animations[a].animatable.target)) {
animations.splice(a, 1);
}
}
} | javascript | {
"resource": ""
} |
q15694 | onScroll | train | function onScroll(cb) {
var isTicking = false;
var scrollY = 0;
var body = document.body;
var html = document.documentElement;
var scrollHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
function scroll() {
scrollY = window.scrollY;
if ... | javascript | {
"resource": ""
} |
q15695 | scrollToElement | train | function scrollToElement(el, offset) {
var off = offset || 0;
var rect = el.getBoundingClientRect();
var top = rect.top + off;
var animation = anime({
targets: [document.body, document.documentElement],
scrollTop: '+='+top,
easing: 'easeInOutSine',
duration: 1500
});
// onScroll(animation.pa... | javascript | {
"resource": ""
} |
q15696 | isElementInViewport | train | function isElementInViewport(el, inCB, outCB, rootMargin) {
var margin = rootMargin || '-10%';
function handleIntersect(entries, observer) {
var entry = entries[0];
if (entry.isIntersecting) {
if (inCB && typeof inCB === 'function') inCB(el, entry);
} else {
if (outCB && typeof outCB === 'fu... | javascript | {
"resource": ""
} |
q15697 | getThisBinding | train | function getThisBinding(thisEnvFn, inConstructor) {
return getBinding(thisEnvFn, "this", thisBinding => {
if (!inConstructor || !hasSuperClass(thisEnvFn)) return t.thisExpression();
const supers = new WeakSet();
thisEnvFn.traverse({
Function(child) {
if (child.isArrowFunctionExpression()) r... | javascript | {
"resource": ""
} |
q15698 | getLastStatement | train | function getLastStatement(statement) {
if (!t.isStatement(statement.body)) return statement;
return getLastStatement(statement.body);
} | javascript | {
"resource": ""
} |
q15699 | isInLoop | train | function isInLoop(path) {
const loopOrFunctionParent = path.find(
path => path.isLoop() || path.isFunction(),
);
return loopOrFunctionParent && loopOrFunctionParent.isLoop();
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.