_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q37200 | _rel_save_button_start | train | function _rel_save_button_start(){
//
//ll('looks like edge (in cb): ' + eeid);
var qstr ='input:radio[name=' + radio_name + ']:checked';
var rval = jQuery(qstr).val();
// ll('rval: ' + rval);
// // TODO: Should I report this too? Smells a
// // bit like the missing properties with
// // setParameter/s(),
/... | javascript | {
"resource": ""
} |
q37201 | isChild | train | function isChild(child, parent) {
while (child = child.parentNode) {
if (child == parent) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q37202 | isHidden | train | function isHidden(element) {
var parent_styles,
overflow_x,
overflow_y,
overflow,
parent = element.parentNode,
styles;
if (!parent) {
return true;
}
// Always return false for the document element
if (isDocumentElement(parent)) {
return false;
}
// Get the computed styles of the ... | javascript | {
"resource": ""
} |
q37203 | isDocumentElement | train | function isDocumentElement(element) {
if ( element == document.body
|| element.nodeType === 9
|| (element.nodeType == 1 && element.nodeName == 'HTML')) {
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q37204 | collides | train | function collides(element_one, element_two) {
var result,
rect1,
rect2;
if (element_one.nodeName) {
rect1 = element_one.getBoundingClientRect();
} else {
rect1 = element_one;
}
if (element_two.nodeName) {
rect2 = element_two.getBoundingClientRect();
} else {
rect2 = element_two;
}
result =... | javascript | {
"resource": ""
} |
q37205 | elementAtRectPoints | train | function elementAtRectPoints(element, rect) {
var sample;
// Get the first sample
sample = document.elementFromPoint(rect.left, ~~rect.top);
if (sample == element || isChild(element, sample)) {
return true;
}
// Get the second sample
sample = document.elementFromPoint(rect.left, ~~rect.bottom);
if (sampl... | javascript | {
"resource": ""
} |
q37206 | _isVisible | train | function _isVisible(start_element, padding) {
var real_rect,
sample,
result,
rect;
// Check if the start element is in the document
if (!elementInDocument(start_element)) {
return false;
}
// Check if the element is explicitly hidden
if (isHidden(start_element)) {
return false;
}
if (padd... | javascript | {
"resource": ""
} |
q37207 | defineApp | train | function defineApp(app) {
app.use('/foo', function appFoo(req, res) {
if (req.xhr) {
var body = {
foo: 'bar'
};
responseSender.sendJSON(res, body);
} else {
responseSender.sendPage(res, 'Foo', '<h1>Bar!</h1>', 200);
}
});
... | javascript | {
"resource": ""
} |
q37208 | train | function( cb ) {
// If we are running in node.js replace the THREE.js XHRLoader
// with an offline version.
var isBrowser=new Function("try {return this===window;}catch(e){ return false;}"); // browser exclude
if (!isBrowser()) {
// Expose 'THREE' for non-compatible scripts
global.THREE = THREE;
// ... | javascript | {
"resource": ""
} | |
q37209 | hoc | train | function hoc(Component) {
return class HOC extends React.Component {
/**
* Create a new instance of the HOC with state defaults.
*
* @param {Object} props Props passed from other HOCs.
*/
constructor(props) {
super(props);
this.state = {isLoading: false};
}
/**
*... | javascript | {
"resource": ""
} |
q37210 | repeat | train | function repeat(str, amount) {
var s = ''
, i;
for(i = 0;i < amount;i++) {
s += str;
}
return s;
} | javascript | {
"resource": ""
} |
q37211 | train | function(string, start, end) {
var crc = 0
var x = 0;
var y = 0;
crc = crc ^ (-1);
for(var i = start, iTop = end; i < iTop;i++) {
y = (crc ^ string[i]) & 0xFF;
x = table[y];
crc = (crc >>> 8) ^ x;
}
return crc ^ (-1);
} | javascript | {
"resource": ""
} | |
q37212 | train | function(functionCache, hash, functionString, object) {
// Contains the value we are going to set
var value = null;
// Check for cache hit, eval if missing and return cached function
if(functionCache[hash] == null) {
eval("value = " + functionString);
functionCache[hash] = value;
}
// Set the objec... | javascript | {
"resource": ""
} | |
q37213 | train | function() {
// Get the start search index
var i = index;
// Locate the end of the c string
while(buffer[i] !== 0x00 && i < buffer.length) {
i++
}
// If are at the end of the buffer there is a problem with the document
if(i >= buffer.length) throw new Error("Bad BSON Document: illega... | javascript | {
"resource": ""
} | |
q37214 | enableEnvConfig | train | function enableEnvConfig (grunt, opts) {
var options = opts || {};
var cacheConfig = options.cache;
var getRaw = grunt.config.getRaw;
grunt.config.getRaw = function getRawWrapper (prop) {
if (prop) {
prop = grunt.config.getPropString(prop);
var required = propRequire(p... | javascript | {
"resource": ""
} |
q37215 | one_space | train | function one_space(left, right) {
left = left || token;
right = right || next_token;
if (right.id !== '(end)' && !option.white &&
(token.line !== right.line ||
token.thru + 1 !== right.from)) {
warn('expected_space_a_b', right, artifact(token), artifac... | javascript | {
"resource": ""
} |
q37216 | symbol | train | function symbol(s, p) {
var x = syntax[s];
if (!x || typeof x !== 'object') {
syntax[s] = x = {
id: s,
lbp: p || 0,
string: s
};
}
return x;
} | javascript | {
"resource": ""
} |
q37217 | onEntityDraw | train | function onEntityDraw(entity, context) {
context.save();
if (selectionService.isSelected(entity)) {
context.strokeStyle = '#f33';
} else {
context.strokeStyle = '#666';
}
context.strokeRect(
entity.pos.x, entity.pos.y, entity.size.x, entity.size.y);
context.re... | javascript | {
"resource": ""
} |
q37218 | verify | train | function verify(rawMsg, rawSig, rawPub) {
const msg = nacl.util.decodeUTF8(rawMsg);
const sig = nacl.util.decodeBase64(rawSig);
const pub = base58.decode(rawPub);
const m = new Uint8Array(crypto_sign_BYTES + msg.length);
const sm = new Uint8Array(crypto_sign_BYTES + msg.length);
let i;
for (i = 0; i < cry... | javascript | {
"resource": ""
} |
q37219 | require | train | function require(name) {
var module = require.modules[name];
if (!module) throw new Error('failed to require "' + name + '"');
if (!('exports' in module) && typeof module.definition === 'function') {
module.client = module.component = true;
module.definition.call(this, module.exports = {}, module);
d... | javascript | {
"resource": ""
} |
q37220 | Request | train | function Request(path, client, delim) {
if (!(this instanceof Request)) return new Request(path, client);
// init client
this.client = client;
if (!this.client) throw new Error('hyper-path requires a client to be passed as the second argument');
this.delim = delim || '.';
this.parse(path);
this._listen... | javascript | {
"resource": ""
} |
q37221 | firstDefined | train | function firstDefined() {
for (var i = 0, l = arguments.length, v; i < l; i++) {
v = arguments[i];
if (typeof v !== 'undefined') return v;
}
return v;
} | javascript | {
"resource": ""
} |
q37222 | process | train | async function process({inputStream, skip, lineHandler, quiet, throttle}) {
skip = skip || 0;
throttle = throttle || Number.MAX_VALUE;
return await new P((resolve, reject) => {
let cursor = 0;
let concurrency = 0;
const errors = [];
const reader = readline.createInterface({input: inputStream});
... | javascript | {
"resource": ""
} |
q37223 | itemIsValid | train | function itemIsValid(item) {
if (!('isValid' in item)) {
return true;
}
if (_.isFunction(item.isValid)) {
return item.isValid();
}
return false;
} | javascript | {
"resource": ""
} |
q37224 | mine | train | function mine(js) {
var names = [];
var state = 0;
var ident;
var quote;
var name;
var isIdent = /[a-z0-9_.]/i;
var isWhitespace = /[ \r\n\t]/;
function $start(char) {
if (char === "/") {
return $slash;
}
if (char === "'" || char === '"') {
quote = char;
return $string;
}
if... | javascript | {
"resource": ""
} |
q37225 | allocate | train | function allocate(height, length) {
var node = new Array(length);
node.height = height;
if (height > 0) {
node.sizes = new Array(length);
}
return node;
} | javascript | {
"resource": ""
} |
q37226 | saveSlot | train | function saveSlot(aList, bList, index, slot) {
setEither(aList, bList, index, slot);
var isInFirst = (index === 0 || index === aList.sizes.length);
var len = isInFirst ? 0 : getEither(aList.sizes, bList.sizes, index - 1);
setEither(aList.sizes, bList.sizes, index, len + length(slot));
} | javascript | {
"resource": ""
} |
q37227 | start | train | function start() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.START, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TO... | javascript | {
"resource": ""
} |
q37228 | stop | train | function stop() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.STOP, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS... | javascript | {
"resource": ""
} |
q37229 | forceSync | train | function forceSync() {
var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.DONE_PREFIX));
var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.ERROR_PREFIX));
mediator.publish(resultSyncSubscribers.getTopic... | javascript | {
"resource": ""
} |
q37230 | train | function() {
this.colon = false;
HelpDocument.apply(this, arguments);
this.format = fmt.MARKDOWN_FORMAT;
this.vanilla = true;
this.useCustom = true;
// disable columns
this.use = false;
var format = '* `%s`: %s';
var overrides = {
synopsis: '```synopsis\n%s\n```'
}
this.markdown = {};
var co... | javascript | {
"resource": ""
} | |
q37231 | average | train | function average(array) {
var length = array.length;
if (length === 0) {
throw new RangeError("Error");
}
var index = -1;
var result = 0;
while (++index < length) {
result += array[index];
}
return result / length;
} | javascript | {
"resource": ""
} |
q37232 | checkCompilationType | train | function checkCompilationType( config ) {
if ( config.tfw.compile.type === 'firefoxos' ) {
config.tfw.compile.type = 'web';
} else {
config.tfw.compile.type = 'desktop';
}
} | javascript | {
"resource": ""
} |
q37233 | handleStatusChange | train | function handleStatusChange(response) {
if (response.authResponse) {
logResponse(response);
window.location.hash = '#menu';
updateUserInfo(response);
} else {
window.location.hash = '#login';
}
} | javascript | {
"resource": ""
} |
q37234 | displayMealList | train | function displayMealList() {
// Meal list
logResponse("[displayMealList] displaying meal list.");
var tmpl = $("#meal_list_tmpl").html();
var output = Mustache.to_html(tmpl, meals);
$("#meal-list").html(output).listview('refresh');
} | javascript | {
"resource": ""
} |
q37235 | appendChildren | train | function appendChildren(children, el) {
ensureArray(children)
.forEach(append.bind(el));
return el;
} | javascript | {
"resource": ""
} |
q37236 | train | function(scope) {
console.log(
'Before start to process input files:',
scope.files.map(function(file) {
var rulesCount = file.parsed.rules.length;
rulesCount += ' rule' + (rulesCount > 1 ? 's' : '');
return '\n' + rulesCount + ' in ' + fi... | javascript | {
"resource": ""
} | |
q37237 | train | function(scope, config) {
var isAngry = config.mood === 'angry',
isColorExist;
console.log(
'\nProcessing command: ' + scope.command.name
);
if (scope.decl.prop === 'content') {
scope.decl.value = isAngry ?
'"BAD BAD NOT GOOD"' :
... | javascript | {
"resource": ""
} | |
q37238 | dquote | train | function dquote(s) {
var sq = (s.indexOf('\'') >= 0);
var dq = (s.indexOf('"') >= 0);
if (sq && dq) {
s = s.replace(/"/g, '\\"');
dq = false;
}
if (dq) {
s = '\'' + s + '\'';
}
else {
s = '"' + s + '"';
}
return s;
} | javascript | {
"resource": ""
} |
q37239 | train | function (i) {
workers[i] = cluster.fork();
console.log('Creating Worker: ', workers[i].process.pid);
workers[i].on('message', m => {
switch (m.type) {
case 'STARTED':
!starte... | javascript | {
"resource": ""
} | |
q37240 | parseNames | train | function parseNames(filePath, prefix, defaultAppName) {
var appName = this.getAppName(filePath, defaultAppName);
var names = {
appShortName: appName,
appName: this.getAppModuleName(prefix, appName),
isPartial: !!filePath.match(/^.*\.partial\.js/)
};
names.isPage = !names.isPa... | javascript | {
"resource": ""
} |
q37241 | getHtml | train | function getHtml(uipart, options) {
options = options || {};
var me = this;
// if any subviews, add them as dependencies
var model = {
isMobile: options.isMobile,
appName: options.appName,
pageCssId: options.appName + 'PageCssId'
};
var deps = _.extend({
subviews... | javascript | {
"resource": ""
} |
q37242 | ensureRowsDeleted | train | function ensureRowsDeleted(rows) {
async.whilst(
() => rows.length,
(cb) => {
rows[0].del(() => {
sheet.getRows(query_options, (err, _rows) => {
rows = _rows;
cb();
});
});
},
next);
} | javascript | {
"resource": ""
} |
q37243 | train | function () {
var self = this;
// Already destroyed.
if (!self.inQueue)
return;
if (self.heartbeat) {
self.heartbeat.stop();
self.heartbeat = null;
}
if (self.socket) {
self.socket.close();
self.socket._meteorSession = null;
}
// Drop the merge box data ... | javascript | {
"resource": ""
} | |
q37244 | train | function () {
var self = this;
// For the reported client address for a connection to be correct,
// the developer must set the HTTP_FORWARDED_COUNT environment
// variable to an integer representing the number of hops they
// expect in the `x-forwarded-for` header. E.g., set to "1" if the
// s... | javascript | {
"resource": ""
} | |
q37245 | train | function (name, handler, options) {
var self = this;
options = options || {};
if (name && name in self.publish_handlers) {
Meteor._debug("Ignoring duplicate publish named '" + name + "'");
return;
}
if (Package.autopublish && !options.is_auto) {
// They have autopublish on, yet ... | javascript | {
"resource": ""
} | |
q37246 | train | function (exception, context) {
if (!exception || exception instanceof Meteor.Error)
return exception;
// Did the error contain more details that could have been useful if caught in
// server code (or if thrown from non-client-originated code), but also
// provided a "sanitized" version with more context t... | javascript | {
"resource": ""
} | |
q37247 | GitBeat | train | function GitBeat(options) {
var self = this;
var url;
options = options || {};
if (typeof options === 'string') {
url = options;
options = {};
}
this.cwd = path.resolve(options.cwd || '');
this.logger = options.logger || noop;
url = url || options.url;
this.isCloned = false;
if (url) {
... | javascript | {
"resource": ""
} |
q37248 | train | function () {
this._super.onenter ();
this.element.action = "javascript:void(0)";
this._scrollbar ( gui.Client.scrollBarSize );
this._flexboxerize (
this.dom.q ( "label" ),
this.dom.q ( "input" )
);
} | javascript | {
"resource": ""
} | |
q37249 | train | function ( label, input ) {
var avail = this.box.width - label.offsetWidth;
var space = gui.Client.isGecko ? 6 : 4;
input.style.width = avail - space + "px";
} | javascript | {
"resource": ""
} | |
q37250 | train | function(clazz, metaData) {
// Apply clazz interface
if (!clazz.__isClazz) {
_.extend(clazz, this.clazz_interface);
}
// Apply interface common for clazz and its prototype
if (!clazz.__interfaces) {
clazz.__interfaces = [];
clazz.prototype.__... | javascript | {
"resource": ""
} | |
q37251 | train | function() {
var processors = this._processors;
_.each(processors, function(processor, name) {
if (_.isString(processor)) {
processors[name] = meta(processor);
}
});
return processors;
} | javascript | {
"resource": ""
} | |
q37252 | train | function(processors) {
var that = this;
_.each(processors, function(processor, name) {
if (name in that._processors) {
throw new Error('Processor "' + name + '" already exists!');
}
that._processors[name] = processor;
});
return this;
... | javascript | {
"resource": ""
} | |
q37253 | train | function(parent) {
var clazzParent = this;
while (clazzParent) {
if (clazzParent === parent || clazzParent.__name === parent) {
return true;
}
clazzParent = clazzParent.__parent;
}
return false;
... | javascript | {
"resource": ""
} | |
q37254 | train | function(property) {
if (this.hasOwnProperty(property) && !_.isUndefined(this[property])) {
return this[property];
}
if (this.__proto && this.__proto.hasOwnProperty(property) && !_.isUndefined(this.__proto[property])) {
return this.__proto[property];
... | javascript | {
"resource": ""
} | |
q37255 | train | function(property, level /* fields */) {
var propertyContainers = [];
if (this.hasOwnProperty(property)) {
propertyContainers.push(this[property]);
}
if (this.__proto && this.__proto.hasOwnProperty(property)) {
propertyContainers.push(th... | javascript | {
"resource": ""
} | |
q37256 | self | train | function self(collector, container, level, fields, reverse) {
fields = [].concat(fields || []);
_.each(container, function(value, name) {
if (fields[0] && (name !== fields[0])) {
return;
}
if (level > 1 && _.isSimpleObject(val... | javascript | {
"resource": ""
} |
q37257 | train | function(FLEX_HOME, done) {
var playersDir = path.join(FLEX_HOME, 'frameworks', 'libs', 'player');
if (fs.existsSync(playersDir) && fs.statSync(playersDir).isDirectory()) {
var tmpDirRoot = os.tmpdir ? os.tmpdir() : os.tmpDir();
var tmpOldPlayersDir = path.join(tmpDirRoot, 'node-playerglobal');
... | javascript | {
"resource": ""
} | |
q37258 | train | function () {
this._super.onready ();
this.element.tabIndex = 0;
this._doctitle ( location.hash );
this.event.add ( "hashchange", window );
} | javascript | {
"resource": ""
} | |
q37259 | when | train | function when(promises) {
promises = arrayify(promises);
var whenPromise = new PromiseFactory();
var pending = promises.length;
var results = [];
var resolve = function (i) {
return function (val) {
results[i] = val;
pending--;
if (pending === 0) {
whenPromise.resolve(results);
}
};
};
pr... | javascript | {
"resource": ""
} |
q37260 | PromiseFactory | train | function PromiseFactory() {
var deferred = whenjs.defer();
//var timeout = setTimeout(function () { console.log(t, 'Promise timed out')}, 3000);
this.reject = function (err) {
deferred.reject(err);
};
this.resolve = function (val) {
// clearTimeout(timeout);
deferred.resolve(val);
};
this.promise = functio... | javascript | {
"resource": ""
} |
q37261 | asPromise | train | function asPromise (val) {
if (val && typeof val.then === 'function') {
return val;
}
var deferred = new PromiseFactory();
deferred.resolve(val);
return deferred.promise();
} | javascript | {
"resource": ""
} |
q37262 | failures | train | function failures (items) {
var fs = [], i, v;
for (i = 0; i < items.length; i += 1) {
v = items[i];
if (!v.passed_) {
fs.push(v);
}
}
return fs;
} | javascript | {
"resource": ""
} |
q37263 | train | function() {
return this.__all__.reduce(function(all, mixin) {
return mixin instanceof Mixin.__class__ ?
all.concat(mixin.__flatten__()) :
all.concat([mixin]);
}, []);
} | javascript | {
"resource": ""
} | |
q37264 | train | function(reopen, name) {
return function() {
// the `reopen` function that was passed in to this function will continue
// the process of reopening to the function that this is monkey-patching.
// it is not a recursive call.
// the `recursiveReopen` function, on the other hand, is the reopen
// f... | javascript | {
"resource": ""
} | |
q37265 | parseModule | train | function parseModule(fileInfo) {
var moduleName = file2modulename(fileInfo.relativePath);
var sourceFile = new SourceFile(moduleName, fileInfo.content);
var comments = [];
var moduleTree;
var parser = new Parser(sourceFile);
// Configure the parser
parser.handleComment = function(range) {
... | javascript | {
"resource": ""
} |
q37266 | train | function (name, contents, hash) {
this.actionQueue.push(this.webdriverClient.setCookie.bind(this.webdriverClient, {name: name, value: contents}));
this.actionQueue.push(this._setCookieCb.bind(this, name, contents, hash));
return this;
} | javascript | {
"resource": ""
} | |
q37267 | train | function (name, cookie, hash) {
this.actionQueue.push(this.webdriverClient.getCookie.bind(this.webdriverClient, name));
this.actionQueue.push(this._cookieCb.bind(this, name, hash));
return this;
} | javascript | {
"resource": ""
} | |
q37268 | send | train | function send(pool, id, event, message) {
const socket = pool.sockets.connected[id];
if (socket) {
return socket.emit(event, message);
} else {
console.log(`Cannot send ${event} to disconnected socket ${id}`);
}
} | javascript | {
"resource": ""
} |
q37269 | newChannel | train | function newChannel() {
let chan = new Channel();
let result = chan.send.bind(chan);
result._inst = chan;
return result;
} | javascript | {
"resource": ""
} |
q37270 | variance | train | function variance(array) {
var length = array.length;
if (length === 0) {
throw new RangeError('Error');
}
var index = -1;
var mean = 0;
while (++index < length) {
mean += array[index] / length;
}
var result = 0;
for (var i = 0; i < length; i++) {
result += Math.pow(array[i] - mean, 2... | javascript | {
"resource": ""
} |
q37271 | Swig | train | function Swig() {
var opts = (app.config.engines && app.config.engines.swig) || {};
this.options = protos.extend({
cache: false
}, opts);
swig.setDefaults(this.options); // Set options for swig
this.module = swig;
this.multiPart = true;
this.extensions = ['swig', 'swig.html'];
} | javascript | {
"resource": ""
} |
q37272 | train | function(name) {
if (debuggers[name]) {
return debuggers[name];
}
var dbg = function(fmt) {
// if this debugger is not enabled, do nothing.
// Check it every time so we can enable or disable a debugger at runtime.
// It won't be slow.
if (!enableStatus[this._nam... | javascript | {
"resource": ""
} | |
q37273 | train | function(fmt) {
if (fmt instanceof Error) {
return fmt.stack || fmt.message;
} else {
return w.format.apply(this, arguments);
}
} | javascript | {
"resource": ""
} | |
q37274 | train | function(ms) {
var sec = 1000;
var min = 60 * 1000;
var hour = 60 * min;
if (ms >= hour) {
return (ms / hour).toFixed(1) + 'h';
}
if (ms >= min) {
return (ms / min).toFixed(1) + 'm';
}
if (ms >= sec) {
return (ms / sec | 0) + 's';
}
re... | javascript | {
"resource": ""
} | |
q37275 | wxappEntry | train | function wxappEntry() {
const regex = /src\/pages\/([^\/]+)\/[^\.]+.js/;
return {
entry: () => {
let pages = {}
let core = []
glob.sync(`./src/pages/**/*.js`).forEach(x => {
const name = x.match(regex)[1]
const key = `pages/${name}/${name}`
pages[key] = x
})... | javascript | {
"resource": ""
} |
q37276 | setup | train | function setup() {
// check if config directory is given
if( _config_path !== -1 ) {
// get path
var config_path = path.resolve( process.argv[ _config_path + 1 ] );
// check if directory exists and is a valid directory
fs.stat( config_path, function( err, stats ) {
if( err && ... | javascript | {
"resource": ""
} |
q37277 | handleConfigEntry | train | function handleConfigEntry ( defaults, values, parent_name, cb ) {
var entries = Object.keys( defaults ),
c = 0;
var cont = function () { // entry handling function
if( c < entries.length ) {
var key = entries[ c ],
entry = defaults[ key ];
if ( typeof... | javascript | {
"resource": ""
} |
q37278 | train | function (paths, obj, defaultValue = null) {
if (!Array.isArray(paths)) {
throw new Error("paths must be an array of strings");
}
let res = defaultValue;
paths.some(path => {
const result = this.getFlattened(path, obj, defaultValue);
if (result !== de... | javascript | {
"resource": ""
} | |
q37279 | train | function (obj) {
"use strict";
if (Object.getPrototypeOf(obj) !== Object.prototype) {
throw Error("obj must be an Object");
}
return Object.keys(obj)[0] || null;
} | javascript | {
"resource": ""
} | |
q37280 | train | function (key, styles) {
key = camelToKebab(key)
let stylesText = ''
for (const k in styles) {
if (styles.hasOwnProperty(k)) {
stylesText += camelToKebab(k) + ':' + styles[k] + ';'
}
}
const styleText = `@${key}{${stylesText}}`
appendCss(styleText, 'dom-added-rules')
} | javascript | {
"resource": ""
} | |
q37281 | preHandleSrc | train | function preHandleSrc (cssSrc) {
/*
* fix like: .a{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#e6529dda', endColorstr='#e6529dda', GradientType=0)\9;}
* which has two semicolon( : ) will cause parse error.
*/
cssSrc = cssSrc.replac... | javascript | {
"resource": ""
} |
q37282 | train | function (code, language, bare) {
var result;
if (typeof hljs !== 'undefined') {
if (language) {
try {
result = hljs.highlight(language, code, true);
}
catch (e) {
Ember.warn(
'[marked] Failing to highlight some code with language `' + language +
... | javascript | {
"resource": ""
} | |
q37283 | _parseErrors | train | function _parseErrors() {
let errors = [].slice.call(arguments);
let parsed = [];
errors.forEach(err => {
let message = (err instanceof Error) ? err.stack : err.toString();
parsed.push(message);
});
return parsed;
} | javascript | {
"resource": ""
} |
q37284 | _log | train | function _log(message) {
if (cluster.isMaster) {
// write directly to the log file
console.log(_format(message));
}
else {
// send to master
cluster.worker.process.send({
type: "logging",
data: {
message: message,
worker... | javascript | {
"resource": ""
} |
q37285 | BaseView | train | function BaseView (properties, application) {
// note that if application is not defined, this.application will
// default to the default, global application.
this.application = application;
this._onParent = _.bind(this._onParent, this);
SubindableObject.call(this, properties);
/**
* The main app... | javascript | {
"resource": ""
} |
q37286 | train | function (data) {
this.on("change:parent", this._onParent);
// copy the data to this object. Note this shaves a TON
// of time off initializing any view, especially list items if we
// use this method over @setProperties data
if (false) {
for(var key in data) {
this[key] = data[key];
... | javascript | {
"resource": ""
} | |
q37287 | train | function () {
var path = [], cp = this;
while (cp) {
path.unshift(cp.name || cp.constructor.name);
cp = cp.parent;
}
return path.join(".");
} | javascript | {
"resource": ""
} | |
q37288 | train | function () {
// if rendered, then just return the fragment
if (this._rendered) {
return this.section.render();
}
this._rendered = true;
if (this._cleanupJanitor) {
this._cleanupJanitor.dispose();
}
if (!this.section) {
this._createSection();
}
this.willRender(... | javascript | {
"resource": ""
} | |
q37289 | train | function (search) {
if (!this.section) this.render();
var el = noselector(this.section.getChildNodes());
if (arguments.length) {
return el.find(search).andSelf().filter(search);
}
return el;
} | javascript | {
"resource": ""
} | |
q37290 | merge | train | function merge( elem, callback ) {
var old = find( destChildren, elem.name ),
nl;
// merge with old element
if ( old ) {
if ( typeof callback == 'function' ) {
return callback( old );
}
_.merge( old.attribs, elem.attribs );
if ( elem.children ) {
combine( old, elem );
}
// append n... | javascript | {
"resource": ""
} |
q37291 | mergeDoctype | train | function mergeDoctype( elem ) {
merge( elem, function( old ) {
utils.replaceElement( old, elem );
destChildren[ destChildren.indexOf( old ) ] = elem;
} );
} | javascript | {
"resource": ""
} |
q37292 | signup | train | async function signup (username, password, options = {}) {
let { email = null, profile = {}, roles = [] } = options
let user = await User.create({ username, email })
user.sign = await UserSign.create({ user, password })
user.profile = await UserProfile.create({ user, profile })
user.roles = await Us... | javascript | {
"resource": ""
} |
q37293 | signin | train | async function signin (username, password, options = {}) {
let { agent } = options
let user = await User.only({ username })
let sign = user && await UserSign.only({ user })
let valid = sign && await sign.testPassword(password)
if (!valid) {
throw new Error('Signin failed!')
}
await use... | javascript | {
"resource": ""
} |
q37294 | FunctionCompiler | train | function FunctionCompiler() {
var _this;
_classCallCheck(this, FunctionCompiler);
_this = _possibleConstructorReturn(this, _getPrototypeOf(FunctionCompiler).call(this));
/**
* Compile sequence.
* @type {Array<function>}
*/
_this._sequence = [_this._uncomment, _this._validate, _this... | javascript | {
"resource": ""
} |
q37295 | ScriptCompiler | train | function ScriptCompiler() {
var _this4;
_classCallCheck(this, ScriptCompiler);
_this4 = _possibleConstructorReturn(this, _getPrototypeOf(ScriptCompiler).call(this));
_this4.inputs = {};
return _this4;
} | javascript | {
"resource": ""
} |
q37296 | strip | train | function strip(script) {
script = this._stripout(script, '<!--', '-->');
script = this._stripout(script, '/*', '*/');
script = this._stripout(script, '^//', '\n');
return script;
} | javascript | {
"resource": ""
} |
q37297 | Runner | train | function Runner() {
_classCallCheck(this, Runner);
this.firstline = false;
this.lastline = false;
this.firstchar = false;
this.lastchar = false;
this._line = null;
this._index = -1;
} | javascript | {
"resource": ""
} |
q37298 | Output | train | function Output() {
var body = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
_classCallCheck(this, Output);
this.body = body;
this.temp = null;
} | javascript | {
"resource": ""
} |
q37299 | getState | train | function getState(element) {
assertType(element, Node, false, 'Invalid element specified');
let state = element.state || element.getAttribute(Directive.STATE);
if (!state || state === '')
return null;
else
return state;
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.