_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q57800 | resolveOutputTarget | train | function resolveOutputTarget(customPath, filename) {
const realPath = path.resolve('.', customPath);
const getPath = tryCatch(
realPath => fs.lstatSync(realPath).isDirectory()
? path.join(realPath, filename)
: realPath,
identity);
return getPath(realPath);
} | javascript | {
"resource": ""
} |
q57801 | objCompare | train | function objCompare(rootObj, objAry) {
var aryLen = objAry.length;
// var rootStr = JSON.stringify(rootObj);
var matchNum = 0;
for (var i = 0; i < aryLen; i++) {
// var compareStr = JSON.stringify(objAry[i]);
var compareObj = objAry[i];
matchNum += rootObj == compareObj ? 1 : 0;
... | javascript | {
"resource": ""
} |
q57802 | serialize | train | function serialize(input) {
const value = JSON.stringify(input);
return value === undefined
? reject(new Error(`Unsupported type ${type(input)}`))
: resolve(value);
} | javascript | {
"resource": ""
} |
q57803 | resolveRungFolder | train | function resolveRungFolder() {
const folder = path.join(os.homedir(), '.rung');
const createIfNotExists = tryCatch(
~(fs.lstatSync(folder).isDirectory()
? resolve()
: reject(new Error('~/.rung is not a directory'))),
~createFolder(folder)
);
return createIfNotExi... | javascript | {
"resource": ""
} |
q57804 | watchChanges | train | function watchChanges(io, params) {
const folder = process.cwd();
return watch(folder, { recursive: true }, () => {
emitInfo('changes detected. Recompiling...');
io.sockets.emit('load');
const start = new Date().getTime();
executeWithParams(params)
.tap(alerts => {
... | javascript | {
"resource": ""
} |
q57805 | startServer | train | function startServer(alerts, params, port, resources) {
const compiledAlerts = compileMarkdown(alerts);
const app = http.createServer((req, res) =>
res.end(resources[req.url] || resources['/index.html']));
const io = listen(app);
io.on('connection', socket => {
emitInfo(`new session for ... | javascript | {
"resource": ""
} |
q57806 | cli | train | function cli(args) {
const { _: [command] } = args;
return getModule(command).default(args)
.catch(err => {
getModule('input').emitError(err.message);
process.exit(1);
});
} | javascript | {
"resource": ""
} |
q57807 | InteractionManager | train | function InteractionManager(stage)
{
/**
* a refference to the stage
*
* @property stage
* @type Stage
*/
this.stage = stage;
/**
* the mouse data
*
* @property mouse
* @type InteractionData
*/
this.mouse = new InteractionData();
/**
* an obje... | javascript | {
"resource": ""
} |
q57808 | RenderTexture | train | function RenderTexture(width, height)
{
EventTarget.call( this );
this.width = width || 100;
this.height = height || 100;
this.identityMatrix = mat3.create();
this.frame = new Rectangle(0, 0, this.width, this.height);
if(globals.gl)
{
this.initWebGL();
}
else
{
... | javascript | {
"resource": ""
} |
q57809 | MovieClip | train | function MovieClip(textures)
{
Sprite.call(this, textures[0]);
/**
* The array of textures that make up the animation
*
* @property textures
* @type Array
*/
this.textures = textures;
/**
* The speed that the MovieClip will play at. Higher is faster, lower is slower
... | javascript | {
"resource": ""
} |
q57810 | AbstractFilter | train | function AbstractFilter(fragmentSrc, uniforms)
{
/**
* An array of passes - some filters contain a few steps this array simply stores the steps in a liniear fashion.
* For example the blur filter has two passes blurX and blurY.
* @property passes
* @type Array an array of filter objects
* @priva... | javascript | {
"resource": ""
} |
q57811 | DisplayObject | train | function DisplayObject()
{
this.last = this;
this.first = this;
/**
* The coordinate of the object relative to the local coordinates of the parent.
*
* @property position
* @type Point
*/
this.position = new Point();
/**
* The scale factor of the object.
*
* ... | javascript | {
"resource": ""
} |
q57812 | train | function (fn, name) {
function proxiedFn() {
'use strict';
var fields = privates.get(this); // jshint ignore:line
return fn.apply(fields, arguments);
}
Object.defineProperty(proxiedFn, 'name', {
value: name,
configurable: true
});
return proxiedFn;
} | javascript | {
"resource": ""
} | |
q57813 | prepareView | train | function prepareView() {
_(this).el = document.createElement('div');
_(this).el.setAttribute('class', 'VirtualScrollingTree');
let contentDiv = `<div class="VirtualScrollingTree-content"></div>`;
_(this).el.innerHTML = `
${_(this).smoothScrolling? '' : contentDiv}
<div class="VirtualSc... | javascript | {
"resource": ""
} |
q57814 | updateViewDimensions | train | function updateViewDimensions(totalItems) {
let visibleItems = Math.floor(_(this).parent.offsetHeight / _(this).itemHeight);
_(this).view.scrollbar.style.height = visibleItems * _(this).itemHeight + 'px';
_(this).view.scrollbarContent.style.height = totalItems * _(this).itemHeight + 'px';
let scro... | javascript | {
"resource": ""
} |
q57815 | getNativeScrollbarWidth | train | function getNativeScrollbarWidth() {
let outer = document.createElement('div');
outer.style.overflowY = 'scroll';
outer.setAttribute('class', _(this).scrollbarClass);
outer.style.visibility = 'hidden';
outer.style.width = '100px';
document.body.appendChild(outer);
let content = document.crea... | javascript | {
"resource": ""
} |
q57816 | requestData | train | function requestData() {
let visible = Math.ceil(_(this).parent.offsetHeight / _(this).itemHeight);
let scrollIndex = Math.floor(_(this).view.scrollbar.scrollTop / _(this).itemHeight);
let request = buildRequest.call(this, scrollIndex, visible);
_(this).request = request;
_(this).onDataFetch(request... | javascript | {
"resource": ""
} |
q57817 | renderItem | train | function renderItem (element, data, updating) {
_(this).onItemRender(element, {
...data.original,
expanded: isExpanded.call(this, data.id),
indent: calculateLevel.call(this, data),
toggle: () => {
// Check to see if this item is expanded or not
let expanded = ... | javascript | {
"resource": ""
} |
q57818 | createItem | train | function createItem (data) {
let itemEl = document.createElement('div');
itemEl.setAttribute('class', 'VirtualScrollingTree-item');
renderItem.call(this, itemEl, data);
return {
id: data.id,
el: itemEl
};
} | javascript | {
"resource": ""
} |
q57819 | forEachExpansion | train | function forEachExpansion(expansions, fn) {
let impl = function(expansions) {
expansions.forEach((expansion) => {
fn(expansion);
impl(expansion.expansions);
});
};
impl(expansions);
} | javascript | {
"resource": ""
} |
q57820 | findExpansion | train | function findExpansion(id) {
let result;
forEachExpansion(_(this).expansions, (expansion) => {
if (expansion.id === id) {
result = expansion;
}
});
return result;
} | javascript | {
"resource": ""
} |
q57821 | collapseItem | train | function collapseItem(data) {
let parentExpansions = findExpansion.call(this, data.parent).expansions;
let index = parentExpansions.findIndex((expansion) => {
return expansion.id === data.id;
});
parentExpansions.splice(index, 1);
} | javascript | {
"resource": ""
} |
q57822 | expandItem | train | function expandItem(data) {
// Cloning to avoid modification of the original data item.
data = JSON.parse(JSON.stringify(data));
if (!data.expansions) {
data.expansions = [];
}
// Expansions are stored in a tree structure.
let obj = findExpansion.call(this, data.parent);
obj.expans... | javascript | {
"resource": ""
} |
q57823 | sortExpansions | train | function sortExpansions() {
let impl = function(expansions) {
expansions.sort((a, b) => {
return a.offset - b.offset;
});
for (let i = 0; i < expansions.length; i++) {
impl(expansions[i].expansions);
}
}
impl(_(this).expansions);
} | javascript | {
"resource": ""
} |
q57824 | calculateExpansions | train | function calculateExpansions() {
let impl = function(expansions, parentStart, parentLevel) {
expansions.forEach((expansion, index) => {
expansion._level = parentLevel;
// We need to calculate the start position of this expansion. The start
// position isn't just the offs... | javascript | {
"resource": ""
} |
q57825 | buildRequest | train | function buildRequest(scrollPos, viewport) {
// Variables
let queries = [];
let requestedTotal = 0;
let expanded = _(this).expansions;
sortExpansions.call(this);
calculateExpansions.call(this);
// One-dimensional collision detection.
// It checks to see if start/end are both either be... | javascript | {
"resource": ""
} |
q57826 | BuildHead | train | function BuildHead(metaObject = {}) {
const metaCopy = Object.assign({}, metaObject);
let finalString = "";
if (metaCopy.title) {
finalString += `<title>${metaCopy.title}</title>`;
}
if (metaCopy.meta) {
throw new Error("WARNING - DEPRECATED: It looks like you're using the old meta ... | javascript | {
"resource": ""
} |
q57827 | findItemInDataForExpansion | train | function findItemInDataForExpansion (label) {
for (let i = 0; i < data.length; i++) {
if (data[i].label === label) {
let item = data[i];
let offset = data.filter(d => d.parent === item.parent).findIndex(d => d.id === item.id);
return {
parent: item.parent... | javascript | {
"resource": ""
} |
q57828 | onDataFetch | train | function onDataFetch(query, resolve) {
let output = [];
query.forEach(function(query) {
let filteredItems = data.filter(function(obj) {
return obj.parent === query.parent;
});
output.push({
parent: query.parent,
items: filteredItems.splice(query.offs... | javascript | {
"resource": ""
} |
q57829 | EmberAddon | train | function EmberAddon() {
var args = [];
var options = {};
console.log("Addon init")
for (var i = 0, l = arguments.length; i < l; i++) {
args.push(arguments[i]);
}
if (args.length === 1) {
options = args[0];
} else if (args.length > 1) {
args.reverse();
option... | javascript | {
"resource": ""
} |
q57830 | Sprite | train | function Sprite(texture)
{
DisplayObjectContainer.call(this);
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the textures origin is the top left
* Setting than anchor to 0.5,0.5 means the textures origin is centered
* Setting the anchor to 1,1 would m... | javascript | {
"resource": ""
} |
q57831 | Texture | train | function Texture(baseTexture, frame)
{
EventTarget.call( this );
if(!frame)
{
this.noFrame = true;
frame = new Rectangle(0,0,1,1);
}
if(baseTexture instanceof Texture)
baseTexture = baseTexture.baseTexture;
/**
* The base texture of this texture
*
* @pro... | javascript | {
"resource": ""
} |
q57832 | BaseTexture | train | function BaseTexture(source, scaleMode)
{
EventTarget.call(this);
/**
* [read-only] The width of the base texture set when the image has loaded
*
* @property width
* @type Number
* @readOnly
*/
this.width = 100;
/**
* [read-only] The height of the base texture set wh... | javascript | {
"resource": ""
} |
q57833 | pointInTriangle | train | function pointInTriangle(px, py, ax, ay, bx, by, cx, cy)
{
var v0x = cx-ax;
var v0y = cy-ay;
var v1x = bx-ax;
var v1y = by-ay;
var v2x = px-ax;
var v2y = py-ay;
var dot00 = v0x*v0x+v0y*v0y;
var dot01 = v0x*v1x+v0y*v1y;
var dot02 = v0x*v2x+v0y*v2y;
var dot11 = v1x*v1x+v1y*v1y;
... | javascript | {
"resource": ""
} |
q57834 | convex | train | function convex(ax, ay, bx, by, cx, cy, sign)
{
return ((ay-by)*(cx-bx) + (bx-ax)*(cy-by) >= 0) === sign;
} | javascript | {
"resource": ""
} |
q57835 | Circle | train | function Circle(x, y, radius)
{
/**
* @property x
* @type Number
* @default 0
*/
this.x = x || 0;
/**
* @property y
* @type Number
* @default 0
*/
this.y = y || 0;
/**
* @property radius
* @type Number
* @default 0
*/
this.radius = ra... | javascript | {
"resource": ""
} |
q57836 | ImageMock | train | function ImageMock() {
var _complete = true;
var _width = 0;
var _height = 0;
var _src = '';
var _onLoad = null;
var _loadTimeoutId;
Object.defineProperties(this, {
complete: {
get: function getComplete() {
return _complete;
},
enumerable: true
},
onload: {
get: function getOnload() {
... | javascript | {
"resource": ""
} |
q57837 | ignore | train | function ignore(fileMeta, opts) {
if (typeof opts.ignore === 'function') {
return opts.ignore(fileMeta, opts);
}
if (typeof opts.ignore === 'string' || Array.isArray(opts.ignore)) {
return micromatch.any(fileMeta.sourceValue, opts.ignore);
}
return false;
} | javascript | {
"resource": ""
} |
q57838 | getFileMeta | train | function getFileMeta(dirname, sourceInputFile, value, opts) {
const parsedUrl = url.parse(value, true);
const filename = decodeURI(parsedUrl.pathname);
const pathname = path.resolve(dirname, filename);
const params = parsedUrl.search || '';
const hash = parsedUrl.hash || '';
// path between the... | javascript | {
"resource": ""
} |
q57839 | processUrl | train | function processUrl(result, decl, node, opts) {
// ignore from the css file by `!`
if (node.value.indexOf('!') === 0) {
node.value = node.value.slice(1);
return Promise.resolve();
}
if (
node.value.indexOf('/') === 0 ||
node.value.indexOf('data:') === 0 ||
node.v... | javascript | {
"resource": ""
} |
q57840 | processDecl | train | function processDecl(result, decl, opts) {
const promises = [];
decl.value = valueParser(decl.value).walk(node => {
if (
node.type !== 'function' ||
node.value !== 'url' ||
node.nodes.length === 0
) {
return;
}
const promise = Pro... | javascript | {
"resource": ""
} |
q57841 | init | train | function init(userOpts = {}) {
const opts = Object.assign(
{
template: '[hash].[ext][query]',
preservePath: false,
hashFunction(contents) {
return crypto
.createHash('sha1')
.update(contents)
.dig... | javascript | {
"resource": ""
} |
q57842 | Stage | train | function Stage(backgroundColor)
{
DisplayObjectContainer.call(this);
/**
* [read-only] Current transform of the object based on world (parent) factors
*
* @property worldTransform
* @type Mat3
* @readOnly
* @private
*/
this.worldTransform = mat3.create();
/**
* ... | javascript | {
"resource": ""
} |
q57843 | AtlasLoader | train | function AtlasLoader(url, crossorigin) {
EventTarget.call(this);
this.url = url;
this.baseUrl = url.replace(/[^\/]*$/, '');
this.crossorigin = crossorigin;
this.loaded = false;
} | javascript | {
"resource": ""
} |
q57844 | addIdToSnapshot | train | function addIdToSnapshot(snapshot) {
var record = snapshot.record;
record.get('store').updateId(record, { id: generateUniqueId() });
return record._createSnapshot();
} | javascript | {
"resource": ""
} |
q57845 | assign | train | function assign(node, token, clone) {
copy(node, token, clone);
ensureNodes(node, clone);
if (token.constructor && token.constructor.name === 'Token') {
copy(node, token.constructor.prototype, clone);
}
} | javascript | {
"resource": ""
} |
q57846 | train | function(a, b) {
let aVal = a[sortField];
let bVal = b[sortField];
return (!aVal && bVal) || (aVal < bVal) ? -1 : (aVal && !bVal) || (aVal > bVal) ? 1 : 0;
} | javascript | {
"resource": ""
} | |
q57847 | containsRelationships | train | function containsRelationships(query) {
let contains = false;
if (query.predicate instanceof SimplePredicate || query.predicate instanceof StringPredicate || query.predicate instanceof DatePredicate) {
contains = Information.parseAttributePath(query.predicate.attributePath).length > 1;
}
if (query.predicat... | javascript | {
"resource": ""
} |
q57848 | filterOptions | train | function filterOptions(options, filter, substitutions) {
// If the filter is blank, return the full list of Options.
if (!filter) {
return options;
}
var cleanFilter = cleanUpText(filter, substitutions);
return options
// Filter out undefined or null Options.
.filter(function (_ref)... | javascript | {
"resource": ""
} |
q57849 | typeaheadSimilarity | train | function typeaheadSimilarity(a, b) {
var aLength = a.length;
var bLength = b.length;
var table = [];
if (!aLength || !bLength) {
return 0;
}
// Ensure `a` isn't shorter than `b`.
if (aLength < bLength) {
var _ref2 = [b, a];
a = _ref2[0];
b = _ref2[1];
}
... | javascript | {
"resource": ""
} |
q57850 | fullStringDistance | train | function fullStringDistance(a, b) {
var aLength = a.length;
var bLength = b.length;
var table = [];
if (!aLength) {
return bLength;
}
if (!bLength) {
return aLength;
}
// Initialize the table axes:
//
// 0 1 2 3 4 ... bLength
// 1
// 2
//
... | javascript | {
"resource": ""
} |
q57851 | cleanUpText | train | function cleanUpText(input, substitutions) {
if (!input) {
return '';
}
// Uppercase and remove all non-alphanumeric, non-accented characters.
// Also remove underscores.
input = input.toUpperCase().replace(/((?=[^\u00E0-\u00FC])\W)|_/g, '');
if (!substitutions) {
return input;... | javascript | {
"resource": ""
} |
q57852 | train | function(red, green, blue, model) {
red = red / 255;
green = green / 255;
blue = blue / 255;
var r = red > 0.04045 ? Math.pow(((red + 0.055) / 1.055), 2.4000000953674316) : red / 12.92;
var g = green > 0.04045 ? Math.pow(((green + 0.055) / 1.055), 2.4000000953674316) : green / 12.92;
var b = blu... | javascript | {
"resource": ""
} | |
q57853 | isInt | train | function isInt(value) {
if (isNaN(value) || exports.isString(value)) {
return false;
}
var x = parseFloat(value);
return (x | 0) === x;
} | javascript | {
"resource": ""
} |
q57854 | isEmpty | train | function isEmpty(obj) {
if (isTrueEmpty(obj)) return true;
if (exports.isRegExp(obj)) {
return false;
} else if (exports.isDate(obj)) {
return false;
} else if (exports.isError(obj)) {
return false;
} else if (exports.isArray(obj)) {
return obj.length === 0;
} else if (exports.isString(obj))... | javascript | {
"resource": ""
} |
q57855 | isExist | train | function isExist(dir) {
dir = path.normalize(dir);
try {
fs.accessSync(dir, fs.R_OK);
return true;
} catch (e) {
return false;
}
} | javascript | {
"resource": ""
} |
q57856 | isFile | train | function isFile(filePath) {
if (!isExist(filePath)) return false;
try {
const stat = fs.statSync(filePath);
return stat.isFile();
} catch (e) {
return false;
}
} | javascript | {
"resource": ""
} |
q57857 | isDirectory | train | function isDirectory(filePath) {
if (!isExist(filePath)) return false;
try {
const stat = fs.statSync(filePath);
return stat.isDirectory();
} catch (e) {
return false;
}
} | javascript | {
"resource": ""
} |
q57858 | chmod | train | function chmod(p, mode) {
try {
fs.chmodSync(p, mode);
return true;
} catch (e) {
return false;
}
} | javascript | {
"resource": ""
} |
q57859 | getdirFiles | train | function getdirFiles(dir, prefix = '') {
dir = path.normalize(dir);
if (!fs.existsSync(dir)) return [];
const files = fs.readdirSync(dir);
let result = [];
files.forEach(item => {
const currentDir = path.join(dir, item);
const stat = fs.statSync(currentDir);
if (stat.isFile()) {
result.push(... | javascript | {
"resource": ""
} |
q57860 | rmdir | train | function rmdir(p, reserve) {
if (!isDirectory(p)) return Promise.resolve();
return fsReaddir(p).then(files => {
const promises = files.map(item => {
const filepath = path.join(p, item);
if (isDirectory(filepath)) return rmdir(filepath, false);
return fsUnlink(filepath);
});
return Prom... | javascript | {
"resource": ""
} |
q57861 | nodeModulePaths | train | function nodeModulePaths(from) {
// guarantee that 'from' is absolute.
from = path.resolve(from);
// note: this approach *only* works when the path is guaranteed
// to be absolute. Doing a fully-edge-case-correct path.split
// that works on both Windows and Posix is non-trivial.
var splitRe = process.plat... | javascript | {
"resource": ""
} |
q57862 | createStatEntry | train | function createStatEntry(file, fullpath, callback) {
fs.lstat(fullpath, function (err, stat) {
var entry = {
name: file
};
if (err) {
entry.err = err;
return callback(entry);
} else {
entry.size = st... | javascript | {
"resource": ""
} |
q57863 | remove | train | function remove(path, fn, callback) {
var meta = {};
resolvePath(path, function (err, realpath) {
if (err) return callback(err);
fn(realpath, function (err) {
if (err) return callback(err);
// Remove metadata
resolv... | javascript | {
"resource": ""
} |
q57864 | resolve | train | function resolve() {
resolvePath(path, function (err, _resolvedPath) {
if (err) {
if (err.code !== "ENOENT") {
return error(err);
}
// If checkSymlinks is on we'll get an ENOENT when creating a new file.
... | javascript | {
"resource": ""
} |
q57865 | consumeStream | train | function consumeStream(stream, callback) {
var chunks = [];
stream.on("data", onData);
stream.on("end", onEnd);
stream.on("error", onError);
function onData(chunk) {
chunks.push(chunk);
}
function onEnd() {
cleanup();
callback(null, chunks.join(""));
}
functio... | javascript | {
"resource": ""
} |
q57866 | evaluate | train | function evaluate(code) {
var exports = {};
var module = { exports: exports };
vm.runInNewContext(code, {
require: require,
exports: exports,
module: module,
console: console,
global: global,
process: process,
Buffer: Buffer,
setTimeout: setTim... | javascript | {
"resource": ""
} |
q57867 | calcEtag | train | function calcEtag(stat) {
return (stat.isFile() ? '': 'W/') + '"' + (stat.ino || 0).toString(36) + "-" + stat.size.toString(36) + "-" + stat.mtime.valueOf().toString(36) + '"';
} | javascript | {
"resource": ""
} |
q57868 | parse_style_json_object | train | function parse_style_json_object(text, options)
{
// remove multiline comments
text = text.replace(/\/\*([\s\S]*?)\*\//g, '')
// ignore curly braces for now.
// maybe support curly braces along with tabulation in future
text = text.replace(/[\{\}]/g, '')
const lines = text.split('\n')
// helper class for deal... | javascript | {
"resource": ""
} |
q57869 | split_into_style_lines_and_children_lines | train | function split_into_style_lines_and_children_lines(lines)
{
// get this node style lines
const style_lines = lines.filter(function(line)
{
// styles always have indentation of 1
if (line.tabs !== 1)
{
return false
}
// detect generic css style line (skip modifier classes and media queries)
const colo... | javascript | {
"resource": ""
} |
q57870 | parse_node_name | train | function parse_node_name(name)
{
// is it a "modifier" style class
let is_a_modifier = false
// detect modifier style classes
if (starts_with(name, '&'))
{
name = name.substring('&'.length)
is_a_modifier = true
}
// support old-school CSS syntax
if (starts_with(name, '.'))
{
name = name.substring('.'.l... | javascript | {
"resource": ""
} |
q57871 | parse_children | train | function parse_children(lines, parent_node_names)
{
// preprocess the lines (filter out comments, blank lines, etc)
lines = filter_lines_for_parsing(lines)
// return empty object if there are no lines to parse
if (lines.length === 0)
{
return {}
}
// parse each child node's lines
return split_lines_by_child... | javascript | {
"resource": ""
} |
q57872 | filter_lines_for_parsing | train | function filter_lines_for_parsing(lines)
{
// filter out blank lines
lines = lines.filter(line => !is_blank(line.line))
lines.forEach(function(line)
{
// remove single line comments
line.line = line.line.replace(/^\s*\/\/.*/, '')
// remove any trailing whitespace
line.line = line.line.trim()
})
return l... | javascript | {
"resource": ""
} |
q57873 | split_lines_by_child_nodes | train | function split_lines_by_child_nodes(lines)
{
// determine lines with indentation = 0 (child node entry lines)
const node_entry_lines = lines.map((line, index) =>
{
return { tabs: line.tabs, index }
})
.filter(line => line.tabs === 0)
.map(line => line.index)
// deduce corresponding child node ending lines
c... | javascript | {
"resource": ""
} |
q57874 | expand_modifier_style_classes | train | function expand_modifier_style_classes(node)
{
const style = get_node_style(node)
const pseudo_classes_and_media_queries_and_keyframes = get_node_pseudo_classes_and_media_queries_and_keyframes(node)
const modifiers = Object.keys(node)
// get all modifier style class nodes
.filter(name => typeof(node[name]) === ... | javascript | {
"resource": ""
} |
q57875 | get_node_style | train | function get_node_style(node)
{
return Object.keys(node)
// get all CSS styles of this style class node
.filter(property => typeof(node[property]) !== 'object')
// for each CSS style of this style class node
.reduce(function(style, style_property)
{
style[style_property] = node[style_property]
return style
}... | javascript | {
"resource": ""
} |
q57876 | get_node_pseudo_classes_and_media_queries_and_keyframes | train | function get_node_pseudo_classes_and_media_queries_and_keyframes(node)
{
return Object.keys(node)
// get all child style classes this style class node,
// which aren't modifiers and are a pseudoclass or a media query or keyframes
.filter(property => typeof(node[property]) === 'object'
&& (is_pseudo_class(proper... | javascript | {
"resource": ""
} |
q57877 | validate_child_style_class_types | train | function validate_child_style_class_types(parent_node_names, names)
{
for (let parent of parent_node_names)
{
// if it's a pseudoclass, it can't contain any style classes
if (is_pseudo_class(parent) && not_empty(names))
{
throw new Error(`A style class declaration "${names[0]}" found inside a pseudoclass "${... | javascript | {
"resource": ""
} |
q57878 | parse_style_class | train | function parse_style_class(lines, node_names)
{
// separate style lines from children lines
const { style_lines, children_lines } = split_into_style_lines_and_children_lines(lines)
// convert style lines info to just text lines
const styles = style_lines.map(line => line.line)
// using this child node's (or thes... | javascript | {
"resource": ""
} |
q57879 | move_up | train | function move_up(object, upside, new_name)
{
let prefix
if (upside)
{
upside[new_name] = object
prefix = `${new_name}_`
}
else
{
upside = object
prefix = ''
}
for (let key of Object.keys(object))
{
const child_object = object[key]
if (is_object(child_object) && !is_pseudo_class(key) && !is_media... | javascript | {
"resource": ""
} |
q57880 | SigningError | train | function SigningError(cause) {
this.code = 'SigningError';
assert.optionalObject(cause);
var msg = 'error signing request';
var args = (cause ? [cause, msg] : [msg]);
WError.apply(this, args);
} | javascript | {
"resource": ""
} |
q57881 | listAllVms | train | function listAllVms(cb) {
var limit = undefined;
var offset = params.offset;
var vms = [];
var stop = false;
async.whilst(
function testAllVmsFetched() {
return !stop;
},
listVms,
function doneFetching(fetchErr) {
... | javascript | {
"resource": ""
} |
q57882 | updateApplication | train | function updateApplication(uuid, opts, callback) {
assert.string(uuid, 'uuid');
assert.object(opts, 'opts');
return (this.put(sprintf('/applications/%s', uuid), opts, callback));
} | javascript | {
"resource": ""
} |
q57883 | createInstanceAsync | train | function createInstanceAsync(service_uuid, opts, callback) {
assert.string(service_uuid, 'service_uuid');
if (typeof (opts) === 'function') {
callback = opts;
opts = {};
}
assert.object(opts, 'opts');
assert.func(callback, 'callback');
opts.service_uuid = service_uuid;
retu... | javascript | {
"resource": ""
} |
q57884 | listInstances | train | function listInstances(search_opts, callback) {
if (arguments.length === 1) {
callback = search_opts;
search_opts = {};
}
var uri = '/instances?' + qs.stringify(search_opts);
return (this.get(uri, callback));
} | javascript | {
"resource": ""
} |
q57885 | reprovisionInstance | train | function reprovisionInstance(uuid, image_uuid, callback) {
assert.string(uuid, 'uuid');
assert.string(image_uuid, 'image_uuid');
var opts = {};
opts.image_uuid = image_uuid;
return (this.put(sprintf('/instances/%s/upgrade', uuid), opts, callback));
} | javascript | {
"resource": ""
} |
q57886 | prettify | train | function prettify (luaCode) {
const lines = luaCode
.split("\n")
.map(line => line.trim());
const { code } = lines.reduce((result, line) => {
const { code, indentation } = result;
let currentIndentation = indentation;
let nextLineIndentation = indentation;
if (indentIncrease.some(entry => ... | javascript | {
"resource": ""
} |
q57887 | buildOptions | train | function buildOptions(i) {
var index = (i + 1);
var isCurrent = i === current;
// Options for each text, arrow and image, using the base options and the index
var text = extend({}, optionsText, {paths: '#jelly-text-' + index + ' path'});
var arrow = extend({}, optionsArrow, {pat... | javascript | {
"resource": ""
} |
q57888 | applyBinds | train | function applyBinds(fns, instance) {
var i,
current;
for (i = fns.length - 1; i >= 0; i -= 1) {
current = instance[fns[i]];
instance[fns[i]] = bind(current, instance);
}
} | javascript | {
"resource": ""
} |
q57889 | doBind | train | function doBind(func) {
/*jshint validthis:true*/
var args = toArray(arguments),
bound;
if (this && !func[$wrapped] && this.$static && this.$static[$class]) {
func = wrapMethod(null, func, this.$self || this.$static);
}
args.splice(1, 0, this);
b... | javascript | {
"resource": ""
} |
q57890 | optimizeConstructor | train | function optimizeConstructor(constructor) {
var tmp = constructor[$class],
canOptimizeConst,
newConstructor,
parentInitialize;
// Check if we can optimize the constructor
if (tmp.efficient) {
canOptimizeConst = constructor.$canOptimizeConst;
... | javascript | {
"resource": ""
} |
q57891 | attemptToExtractStatusCode | train | function attemptToExtractStatusCode(req) {
if (has(req, 'response') && isObject(req.response) &&
has(req.response, 'statusCode')) {
return req.response.statusCode;
} else if (has(req, 'response') && isObject(req.response) &&
isObject(req.response.output)) {
return req.response.output.s... | javascript | {
"resource": ""
} |
q57892 | extractRemoteAddressFromRequest | train | function extractRemoteAddressFromRequest(req) {
if (has(req.headers, 'x-forwarded-for')) {
return req.headers['x-forwarded-for'];
} else if (isObject(req.info)) {
return req.info.remoteAddress;
}
return '';
} | javascript | {
"resource": ""
} |
q57893 | hapiRequestInformationExtractor | train | function hapiRequestInformationExtractor(req) {
var returnObject = new RequestInformationContainer();
if (!isObject(req) || !isObject(req.headers) || isFunction(req) ||
isArray(req)) {
return returnObject;
}
returnObject.setMethod(req.method)
.setUrl(req.url)
.setUserAgent(req.headers[... | javascript | {
"resource": ""
} |
q57894 | addScope | train | function addScope (scope) {
if (!scope) {
return
}
var oldScope = new Set(this.scope.split(' '))
var newScope
// Convert the incoming new scopes to a Set
if (typeof scope === 'string') {
newScope = new Set(scope.split(' '))
} else if (Array.isArray(scope)) {
newScope = new Set(scope)
} else ... | javascript | {
"resource": ""
} |
q57895 | discover | train | function discover () {
var self = this
// construct the uri
var uri = url.parse(this.issuer)
uri.pathname = '.well-known/openid-configuration'
uri = url.format(uri)
var requestOptions = {
url: uri,
method: 'GET',
json: true,
agentOptions: self.agentOptions
}
if (self.proxy) {
reque... | javascript | {
"resource": ""
} |
q57896 | initAdminAPI | train | function initAdminAPI () {
this.clients = {
list: clients.list.bind(this),
get: clients.get.bind(this),
create: clients.create.bind(this),
update: clients.update.bind(this),
delete: clients.delete.bind(this),
roles: {
list: clientRoles.listRoles.bind(this),
add: clientRoles.addRole... | javascript | {
"resource": ""
} |
q57897 | authorizationUri | train | function authorizationUri (options) {
var u = url.parse(this.configuration.authorization_endpoint)
// assign endpoint and ensure options
var endpoint = 'authorize'
if (typeof options === 'string') {
endpoint = options
options = {}
} else if (typeof options === 'object') {
endpoint = options.endpo... | javascript | {
"resource": ""
} |
q57898 | verify | train | function verify (token, options) {
options = options || {}
options.issuer = options.issuer || this.issuer
options.client_id = options.client_id || this.client_id
options.client_secret = options.client_secret || this.client_secret
options.scope = options.scope || this.scope
options.key = options.key || this.... | javascript | {
"resource": ""
} |
q57899 | extractFromObject | train | function extractFromObject(err, errorMessage) {
if (has(err, 'message')) {
errorMessage.setMessage(err.message);
}
if (has(err, 'user')) {
errorMessage.setUser(err.user);
}
if (has(err, 'filePath')) {
errorMessage.setFilePath(err.filePath);
}
if (has(err, 'lineNumber')) {
errorMess... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.