_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q35100 | train | function()
{
var name = this.getName();
for ( var i = 0 ; i < arguments.length ; i++ )
{
if ( arguments[ i ] == name )
return true;
}
return false;
} | javascript | {
"resource": ""
} | |
q35101 | train | function()
{
var isVisible = ( this.$.offsetHeight || this.$.offsetWidth ) && this.getComputedStyle( 'visibility' ) != 'hidden',
elementWindow,
elementWindowFrame;
// Webkit and Opera report non-zero offsetHeight despite that
// element is inside an invisible iframe. (#4542)
if ( isVisibl... | javascript | {
"resource": ""
} | |
q35102 | train | function()
{
if ( !CKEDITOR.dtd.$removeEmpty[ this.getName() ] )
return false;
var children = this.getChildren();
for ( var i = 0, count = children.count(); i < count; i++ )
{
var child = children.getItem( i );
if ( child.type == CKEDITOR.NODE_ELEMENT && child.data( 'cke-bookmark' ... | javascript | {
"resource": ""
} | |
q35103 | train | function( opacity )
{
if ( CKEDITOR.env.ie )
{
opacity = Math.round( opacity * 100 );
this.setStyle( 'filter', opacity >= 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' );
}
else
this.setStyle( 'opacity', opacity );
} | javascript | {
"resource": ""
} | |
q35104 | train | function()
{
var $ = this.$;
try
{
// In IE, with custom document.domain, it may happen that
// the iframe is not yet available, resulting in "Access
// Denied" for the following property access.
$.contentWindow.document;
}
catch ( e )
{
// Trick to solve this issue... | javascript | {
"resource": ""
} | |
q35105 | train | function( dest, skipAttributes )
{
var attributes = this.$.attributes;
skipAttributes = skipAttributes || {};
for ( var n = 0 ; n < attributes.length ; n++ )
{
var attribute = attributes[n];
// Lowercase attribute name hard rule is broken for
// some attribute on IE, e.g. CHECKED.
... | javascript | {
"resource": ""
} | |
q35106 | train | function( newTag )
{
// If it's already correct exit here.
if ( this.getName() == newTag )
return;
var doc = this.getDocument();
// Create the new node.
var newNode = new CKEDITOR.dom.element( newTag, doc );
// Copy all attributes.
this.copyAttributes( newNode );
// Move ... | javascript | {
"resource": ""
} | |
q35107 | minjs | train | function minjs(config, tools) {
return tools.simpleStream(config, [
config.concat && concat(config.concat),
config.minify && uglify(config.uglifyjs)
])
} | javascript | {
"resource": ""
} |
q35108 | resetStyle | train | function resetStyle( element, prop, resetVal )
{
element.removeStyle( prop );
if ( element.getComputedStyle( prop ) != resetVal )
element.setStyle( prop, resetVal );
} | javascript | {
"resource": ""
} |
q35109 | train | function( id, label, fieldProps )
{
return {
type : 'hbox',
padding : 0,
widths : [ '60%', '40%' ],
children : [
CKEDITOR.tools.extend( {
type : 'text',
id : id,
label : lang[ label ]
}, fieldProps || {}, 1 ),
{
type : 'button',
id : id + 'Choose',
... | javascript | {
"resource": ""
} | |
q35110 | train | function(paths, callback, results, cached) {
results = results || [];
if(!paths.length) {
callback.apply(null, results);
return results;
}
var path = paths.shift();
//what do we do if it's not a string ?
if(typeof path !== 'string') {
... | javascript | {
"resource": ""
} | |
q35111 | train | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just add it
return queue[source].push(callback);
}
//otherwise there is not a queue
//so let's create one
queue[source]... | javascript | {
"resource": ""
} | |
q35112 | train | function(source, callback) {
callback = callback || noop;
//if there's a queue
if (queue[source] instanceof Array) {
//just call the callback
return callback();
}
//otherwise there is not a queue
//so let's create one
queue[source] = [];
... | javascript | {
"resource": ""
} | |
q35113 | train | function(url, success, fail) {
success = success || noop;
fail = fail || noop;
//if there's a queue
if (queue[url] instanceof Array) {
//just add it
return queue[url].push({
success: success,
fail: fail
});
}
... | javascript | {
"resource": ""
} | |
q35114 | train | function(type, event, handler) {
_.parsers.forEach(function(parser) {
type = type.replace(parser[0], function() {
var args = _.slice(arguments, 1);
args.unshift(event, handler);
return parser[1].apply(event, args) || '';
});
});
... | javascript | {
"resource": ""
} | |
q35115 | report | train | function report(error, additionalTags, extra) {
let sentTags = tags ? [].concat(tags) : [];
if (additionalTags) {
sentTags = sentTags.concat(additionalTags);
}
return Promise.resolve(sentTags).then(function(t) {
// Need this wrapping so that our internal implementation can safely throw... | javascript | {
"resource": ""
} |
q35116 | LambdaError | train | function LambdaError(code, message, extra, request) {
Error.captureStackTrace(this, this.constructor);
this.name = 'LambdaError';
this.message = `${code}: ${message}`;
this.code = code;
this.extra = extra;
this.request = request;
// Also capture a native error internally, which
// we ca... | javascript | {
"resource": ""
} |
q35117 | train | function ($element, event, fn) {
var handler = {
$element: $element,
event: event,
fn: fn
};
existingHandlers.push(handler);
return $element.on(event, fn);
} | javascript | {
"resource": ""
} | |
q35118 | VNode | train | function VNode(tagName, attributes, children) {
this.simple = true;
this.tagName = tagName; // non-virtual VText
this.attributes = attributes; // javascript
this.children = new VTree(children);
} | javascript | {
"resource": ""
} |
q35119 | groupFieldsByType | train | function groupFieldsByType(list){
var fields = {};
_.each(list.fields, function(v,k) {
if (! fields.hasOwnProperty(v.type)) fields[v.type] = [];
fields[v.type].push(v);
});
return fields;
} | javascript | {
"resource": ""
} |
q35120 | getBytesWithUnit | train | function getBytesWithUnit(bytes) {
if (isNaN(bytes)) {
return;
}
var units = [ ' bytes', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB' ];
var amountOf2s = Math.floor(Math.log(+bytes) / Math.log(2));
if (amountOf2s < 1) {
amountOf2s = 0;
}
... | javascript | {
"resource": ""
} |
q35121 | renderActionButtons | train | function renderActionButtons() {
$('.manage-resource-container .action-button').each(function (i, action) {
action = $(action);
var type = action.parent().hasClass(FOLDER_TYPE) ? FOLDER_TYPE : "";
var id = action.attr("id"),
dataId = action.parent('.resource-i... | javascript | {
"resource": ""
} |
q35122 | ignoreStream | train | function ignoreStream(strategy) {
if (!(strategy instanceof IgnoreStrategy)) {
strategy = DefaultIgnoreStrategy.INSTANCE;
}
return through.obj(function(chunk, enc, cb) {
strategy.execute(this, chunk).then(function(isIgnored) {
if (!isIgnored) {
cb(null, chunk);
... | javascript | {
"resource": ""
} |
q35123 | train | function( text )
{
var standard = function( text )
{
var span = new CKEDITOR.dom.element( 'span' );
span.setText( text );
return span.getHtml();
};
var fix1 = ( standard( '\n' ).toLowerCase() == '<br>' ) ?
function( text )
{
// #3874 IE and Safari encode line-break in... | javascript | {
"resource": ""
} | |
q35124 | train | function( func, milliseconds, scope, args, ownerWindow )
{
if ( !ownerWindow )
ownerWindow = window;
if ( !scope )
scope = ownerWindow;
return ownerWindow.setTimeout(
function()
{
if ( args )
func.apply( scope, [].concat( args ) ) ;
else
func.apply( scope... | javascript | {
"resource": ""
} | |
q35125 | train | function( ref )
{
var fn = functions[ ref ];
return fn && fn.apply( window, Array.prototype.slice.call( arguments, 1 ) );
} | javascript | {
"resource": ""
} | |
q35126 | returnResponse | train | function returnResponse(res, Handler, data, perfInstance) {
var content = React.renderToString(React.createElement(Handler, { data: data })),
html = '<!DOCTYPE html>' + content;
options.log && log(options.log, 'perf', perfInstance());
res.end(html);
} | javascript | {
"resource": ""
} |
q35127 | train | function(url, callback) {
var parsedUrl = urlparse(url, true);
var method = this._normalizeSpecMethod(this.spec, {
base_url: parsedUrl.protocol +'//' + parsedUrl.hostname,
headers: {},
method: 'GET',
path: parsedUrl.pathname + parsedUrl.search
});
... | javascript | {
"resource": ""
} | |
q35128 | train | function(middleware) {
this.middlewares = this.middlewares.filter(function(element) {
if (element.fun === middleware)
return false;
return true;
});
} | javascript | {
"resource": ""
} | |
q35129 | train | function(methodName, args) {
var method = this.spec.methods[methodName];
if (method.deprecated === true)
console.warn('Method '+ methodName + ' is deprecated.')
var callback = args.pop(); // callback is always at the end
var middleware = args[0];
var params = null... | javascript | {
"resource": ""
} | |
q35130 | train | function(request, callback, response_middlewares) {
var that = this;
request.finalize(function(err, res) {
if (err) callback(err, null);
else that._callResponseMiddlewares(response_middlewares, res, callback);
});
} | javascript | {
"resource": ""
} | |
q35131 | train | function(methodDef, callback, params, payload) {
// check required params
for (var index in methodDef.required_params) {
var requiredParamName = methodDef.required_params[index];
if (!params.hasOwnProperty(requiredParamName)) {
callback(requiredParamName +' param ... | javascript | {
"resource": ""
} | |
q35132 | GenericRestError | train | function GenericRestError (type, status) {
return function Handler (code, message, header) {
return new RestError(type, status, code, message, header)
}
} | javascript | {
"resource": ""
} |
q35133 | train | function(stuff) {
var len = this.str.length;
if (typeof stuff == 'number') {
this.str = this.str.substr(stuff);
} else if (typeof stuff == 'string') {
this.str = this.str.substr(stuff.length);
} else if (stuff instanceof RegExp) {
var m = this.str.match(stuff);
if... | javascript | {
"resource": ""
} | |
q35134 | mergeReferences | train | function mergeReferences (oldRefs, newRefs) {
const _newRefs = _(newRefs);
return _(oldRefs)
.reject(function (oldRef) {
return _newRefs.any(function (newRef) {
return matches(oldRef, newRef);
});
})
.concat(newRefs)
.uniq()
.sort(... | javascript | {
"resource": ""
} |
q35135 | preventAll | train | function preventAll () {
function shield (req) {
req.prevent();
}
measly.on('create', shield);
text(preventButton, 'Shield On..');
preventButton.classList.add('cm-prevent-on');
setTimeout(function () {
measly.off('create', shield);
text(preventButton, 'Prevent for 5s');
... | javascript | {
"resource": ""
} |
q35136 | mainFunction | train | function mainFunction (arg) {
if (typeof arg == 'string') {
return JS2.Parser.parse(arg).toString();
} else if (arg instanceof Array) {
return new JS2.Array(arg);
} else {
return new JS2.Array();
}
} | javascript | {
"resource": ""
} |
q35137 | havePosts | train | function havePosts( error, post ) {
this.debug( 'haveSingle' );
console.log( require( 'util' ).inspect( post, { showHidden: false, colors: true, depth: 4 } ) );
} | javascript | {
"resource": ""
} |
q35138 | train | function( data )
{
if ( iframe )
iframe.remove();
var src =
'document.open();' +
// The document domain must be set any time we
// call document.open().
( isCustomDomain ? ( 'document.domain="' + document.domain + '";' ) : '' ) +
'document.close(... | javascript | {
"resource": ""
} | |
q35139 | blinkCursor | train | function blinkCursor( retry )
{
if ( editor.readOnly )
return;
CKEDITOR.tools.tryThese(
function()
{
editor.document.$.designMode = 'on';
setTimeout( function()
{
editor.document.$.designMode = 'off';
if ( CKEDITOR.currentInstance == editor )
... | javascript | {
"resource": ""
} |
q35140 | train | function( xpath, contextNode )
{
var baseXml = this.baseXml;
if ( contextNode || ( contextNode = baseXml ) )
{
if ( CKEDITOR.env.ie || contextNode.selectSingleNode ) // IE
return contextNode.selectSingleNode( xpath );
else if ( baseXml.evaluate ) // Others
{
var result ... | javascript | {
"resource": ""
} | |
q35141 | train | function( xpath, contextNode )
{
var baseXml = this.baseXml,
nodes = [];
if ( contextNode || ( contextNode = baseXml ) )
{
if ( CKEDITOR.env.ie || contextNode.selectNodes ) // IE
return contextNode.selectNodes( xpath );
else if ( baseXml.evaluate ) // Others
{
var... | javascript | {
"resource": ""
} | |
q35142 | train | function( xpath, contextNode )
{
var node = this.selectSingleNode( xpath, contextNode ),
xml = [];
if ( node )
{
node = node.firstChild;
while ( node )
{
if ( node.xml ) // IE
xml.push( node.xml );
else if ( window.XMLSerializer ) // Others
xml.push( ( new... | javascript | {
"resource": ""
} | |
q35143 | request | train | function request(url, using, fn, disk) {
if ('function' === typeof using) {
disk = fn;
fn = using;
using = null;
}
if (!using) {
if (curl) using = 'curl';
else if (wget) using = 'wget';
else using = 'node';
}
debug('requesting '+ url +' using '+ using);
request[using + ( disk ? 'd'... | javascript | {
"resource": ""
} |
q35144 | extendThis | train | function extendThis() {
var i, ni, objects, object, prop;
objects = arguments;
for (i = 0, ni = objects.length; i < ni; i++) {
object = objects[i];
for (prop in object) {
this[prop] = object[prop];
}
}
return this;
} | javascript | {
"resource": ""
} |
q35145 | defineAndInheritProperties | train | function defineAndInheritProperties(Component, properties) {
var constructor,
descriptor,
property,
propertyDescriptors,
propertyDescriptorHash,
propertyDescriptorQueue;
// Set properties
Component.properties = properties;
// Traverse the chain of constructors and gather all property descriptor... | javascript | {
"resource": ""
} |
q35146 | train | function(name, func, superPrototype) {
return function PseudoClass_setStaticSuper() {
// Store the old super
var previousSuper = this._super;
// Use the method from the superclass' prototype
// This strategy allows monkey patching (modification of superclass prototypes)
this._super = superPrototype[na... | javascript | {
"resource": ""
} | |
q35147 | train | function(properties) {
// If a class-like object is passed as properties.extend, just call extend on it
if (properties && properties.extend)
return properties.extend.extend(properties);
// Otherwise, just create a new class with the passed properties
return PseudoClass.extend(properties);
} | javascript | {
"resource": ""
} | |
q35148 | render | train | function render(q) {
if (!q.length) {
complete();
return;
}
const item = q.shift();
// render HTML file
fs.writeFile(`${item.file}.html`, item.html, err => {
if (err) throw err;
// if prerendering is enabled
if (typeof options.prerender === "object" && options.prerender !== null) {
... | javascript | {
"resource": ""
} |
q35149 | complete | train | function complete() {
quit();
const deleteQueue = [];
fs.readdir(paths.output, (err, files) => {
if (files) {
// lookup array for quick search inside existing component names
const componentsLookup = components.map(item => {
return slugify(item.meta.name);
});
// loop over fi... | javascript | {
"resource": ""
} |
q35150 | removeFile | train | function removeFile(q) {
if (!q.length) {
process.send(true);
return;
}
const file = q.shift();
rimraf(path.resolve(paths.output, file), { read: false }, () => {
removeFile(q);
});
} | javascript | {
"resource": ""
} |
q35151 | slugify | train | function slugify(str) {
return str
.toString()
.toLowerCase()
.replace(/\s+/g, "-") // Replace spaces with -
.replace(/[^\w-]+/g, "") // Remove all non-word chars
.replace(/--+/g, "-") // Replace multiple - with single -
.replace(/^-+/, "") // Trim - from start of text
.replace(/-+$/, "");... | javascript | {
"resource": ""
} |
q35152 | PageScript | train | function PageScript(req) {
var codeList = [], bottomScriptList = [], cacheKey;
/**
* Add plugin load code. Called for each configured plugin on page.
* @param pluginOptions {Object} Plugin options object described in plugin properties
*/
this.addPluginLoad = function (pluginOptions) {
... | javascript | {
"resource": ""
} |
q35153 | renderHTML | train | function renderHTML(callback) {
async.map(codeList, function (locals, n) {
locals.req = req;
ViewHelper.render({
cache: true,
path: SCRIPT_JADE
}, locals, n)
}, function (err, buf) {
if (!err)... | javascript | {
"resource": ""
} |
q35154 | run | train | function run($templateCache) {
angular.forEach(examples, function (example) {
$templateCache.put(example.id + '-template', example.html);
$templateCache.put(example.id + '-description', example.description);
});
} | javascript | {
"resource": ""
} |
q35155 | ExampleCtrl | train | function ExampleCtrl($scope, $timeout) {
var pomo_nonsense = 'The fallacy of disciplinary boundaries thematizes the figuralization of civil society.',
regex = /(of\s.+\sboundaries|eht)/;
$scope.reset = function reset() {
delete $scope.data.pomo_nonsense;
$timeout(function () {
$scope.... | javascript | {
"resource": ""
} |
q35156 | MainCtrl | train | function MainCtrl($scope, $location) {
$scope.select = function select(id) {
$scope.selected = $scope.selected === id ? null : id;
$location.path('/' + id);
};
$scope.examples = examples;
$scope.select($location.path().substring(1) || examples[0].id);
} | javascript | {
"resource": ""
} |
q35157 | code | train | function code($window) {
return {
restrict: 'E',
require: '?ngModel',
/**
*
* @param {$rootScope.Scope} scope Element Scope
* @param {angular.element} element AngularJS element
* @param {$compile.directive.Attributes} attrs AngularJS Attributes object
* @param {N... | javascript | {
"resource": ""
} |
q35158 | detectIntersection | train | function detectIntersection(a, b) {
if (a instanceof Sphere) {
if (b instanceof Sphere) {
return sphereCollisionDetection.sphereVsSphere(a, b);
} else if (b instanceof Aabb) {
return sphereCollisionDetection.sphereVsAabb(a, b);
} else if (b instanceof Capsule) {
return sphereCollisionDet... | javascript | {
"resource": ""
} |
q35159 | convert | train | function convert(program, callback) {
// define no-op callback
if (!callback) {
callback = function (err, blueprint) { }
}
// Read in the file
refparser.parse(program.input, function (err, schema) {
if (err) isMain ? halt(err) : callback(err);
// Read in aglio options
var options = {
t... | javascript | {
"resource": ""
} |
q35160 | check_input | train | function check_input(input, message) {
if (!input) {
error('\n Error: ' + message);
program.outputHelp(colors.red);
process.exit(1);
}
} | javascript | {
"resource": ""
} |
q35161 | adjustPath | train | function adjustPath(builder, path) {
if (builder.protection) {
var pathAndNode = utils.pathAndNode(path);
var nodeName = getProtectedPrefix(builder.protectedId) + pathAndNode.node;
path = utils.join(pathAndNode.path, nodeName);
}
return path;
} | javascript | {
"resource": ""
} |
q35162 | findNode | train | function findNode(children, path, protectedId) {
var prefix = getProtectedPrefix(protectedId);
var i = 0;
var node;
while ((node = children[i++])) {
if (node.indexOf(prefix) === 0) {
return utils.join(path, node);
}
}
return null;
} | javascript | {
"resource": ""
} |
q35163 | findProtectedNode | train | function findProtectedNode(builder, path, callback) {
var zk = builder.client.zk;
var pathAndNode = utils.pathAndNode(path);
zk.getChildren(pathAndNode.path, afterCheck);
function afterCheck(err, children) {
if (err && err.getCode() === Exception.NO_NODE) {
callback();
}
else if (err) {
... | javascript | {
"resource": ""
} |
q35164 | performCreate | train | function performCreate(builder, path, data, callback) {
var client = builder.client;
var zk = client.zk;
var firstTime = true;
client.retryLoop(exec, callback);
function exec(cb) {
if (firstTime && builder.protection) {
findProtectedNode(builder, path, createIfNotExist);
}
else {
cre... | javascript | {
"resource": ""
} |
q35165 | mincss | train | function mincss(config, tools) {
return tools.simpleStream(config, [
config.autoprefixer && autoprefixer(config.autoprefixer),
config.concat && concat(config.concat),
config.minify && csso(config.csso)
])
} | javascript | {
"resource": ""
} |
q35166 | PageRenderer | train | function PageRenderer(req, res) {
var page = req.attrs.page;
Object.defineProperties(this, {
req: {
value: req
},
res: {
value: res
},
page: {
value: _.clone(page)
},
themeDBAction: {
value: DBActions.getInst... | javascript | {
"resource": ""
} |
q35167 | extractFrontmatter | train | function extractFrontmatter(file, filePath, options, grayMatterOptions){
if (utf8(file.contents)) {
var parsed;
try {
parsed = matter(file.contents.toString(), grayMatterOptions);
} catch (e) {
var errMsg = 'Invalid frontmatter in file';
if (filePath !== undefined) errMsg += ": " + file... | javascript | {
"resource": ""
} |
q35168 | frontmatter | train | function frontmatter(opts){
var options = {}, grayMatterOptions = {};
Object.keys(opts || {}).forEach(function(key){
if (key === 'namespace'){
options[key] = opts[key];
} else {
grayMatterOptions[key] = opts[key];
}
});
return each(function(file, filePath){
extractFrontmatter(file, ... | javascript | {
"resource": ""
} |
q35169 | loadPlugin | train | function loadPlugin(id) {
var plugin = PLUGINS[id];
plugin.exec.load(plugin.id, {
id: plugin.id
});
} | javascript | {
"resource": ""
} |
q35170 | bindToClick | train | function bindToClick(selector, handler) {
var elems = document.querySelectorAll(selector);
var i = -1;
var len = elems.length;
while (++i < len) {
elems[i].addEventListener('click', handler);
}
} | javascript | {
"resource": ""
} |
q35171 | sessionDecorator | train | function sessionDecorator() {
// save token header to be used in cookieParserDecorator middleware.
tokenHeaderName = rs.keystone.get('resty token header');
rs.keystone.session = RestySession.factory(rs.keystone);
rs.keystone.set('session', rs.keystone.session.persist);
} | javascript | {
"resource": ""
} |
q35172 | cookieParserDecorator | train | function cookieParserDecorator(req, res, next) {
// run express.cookieParser() only when were not visiting the api.
if (req.isResty) {
// get token from headers.
var token = req.headers[tokenHeaderName] || undefined;
if (token) {
try {
// decode token, it hol... | javascript | {
"resource": ""
} |
q35173 | statusCodes | train | function statusCodes(allowed, ignored, options) {
var stream = new Transform({objectMode: true});
var errored = false;
stream._transform = function (page, _, callback) {
if (errored) return callback(null);
if (ignored && ignored.indexOf(page.statusCode) !== -1) return callback(null);
if (!allowed || ... | javascript | {
"resource": ""
} |
q35174 | ReadWriteLock | train | function ReadWriteLock(client, basePath) {
var readLockDriver = new ReadLockDriver(this);
var writeLockDriver = new SortingLockDriver();
/**
* Read mutex.
*
* @type {Lock}
*/
this.readMutex = new Lock(client, basePath, READ_LOCK_NAME, readLockDriver);
this.readMutex.setMaxLeases(Infinity);
/... | javascript | {
"resource": ""
} |
q35175 | emit | train | function emit() {
if (arguments.length) this.emitted.push(arguments);
while (!this.paused && this.emitted.length && this.readable) {
var emitArgs = this.emitted.shift();
this.emit.apply(this, emitArgs);
if (emitArgs[0] == 'end') {
this.readable = false;
}
}
} | javascript | {
"resource": ""
} |
q35176 | emitLine | train | function emitLine(line, isEnd) {
if (this.filters.every(function(fn) { return fn(line) }))
emit.call(this, 'data', line, !!isEnd);
} | javascript | {
"resource": ""
} |
q35177 | _create | train | function _create(f) {
var c = Object.create(Contract);
c._wrapped = f;
return c;
} | javascript | {
"resource": ""
} |
q35178 | defineProperties | train | function defineProperties(obj) {
Object.defineProperties(obj, {
"pre": {
value: Contract.pre,
configurable: true
},
"post": {
value: Contract.post,
configurable: true
},
"invariant": {
value: Contract.invariant,
... | javascript | {
"resource": ""
} |
q35179 | getHeight | train | async function getHeight(url) {
await page.goto(url);
const height = await page.evaluate(() => {
return document.body.getBoundingClientRect().height;
});
return height;
} | javascript | {
"resource": ""
} |
q35180 | defineTasksForConfig | train | function defineTasksForConfig(taskData) {
// Define gulp tasks (build and optionally watch)
// For the task name:
// - single config, no 'name' key: <callback>
// - single config, 'name' key: <callback>_<name>
// - multiple configs, no 'name' key: <callback>_<index>
const { callback, name, normalizedConfigs... | javascript | {
"resource": ""
} |
q35181 | getTaskCallback | train | function getTaskCallback(callback) {
let result = null
// Get the callback function; throw errors, because we can't log them
// later until we have identified a task name
if (typeof callback === 'function') {
result = callback
} else if (typeof callback === 'string') {
let id = callback.trim()
// ... | javascript | {
"resource": ""
} |
q35182 | train | function (workingDirectory) {
var gitPath = getClosestGitPath(workingDirectory);
if (!gitPath) {
throw new Error('git-hooks must be run inside a git repository');
}
var hooksPath = path.resolve(gitPath, HOOKS_DIRNAME);
var hooksOldPath = path.resolve(gitPath, HOOKS_... | javascript | {
"resource": ""
} | |
q35183 | spawnHook | train | function spawnHook(hookName, args) {
var stats = fs.statSync(hookName);
var command = hookName;
var opts = args;
var hook;
if (isWin32) {
hook = fs.readFileSync(hookName).toString();
if (!require('shebang-regex').test(hook)) {
throw new Error('Cannot find shebang in hook... | javascript | {
"resource": ""
} |
q35184 | getClosestGitPath | train | function getClosestGitPath(currentPath) {
currentPath = currentPath || process.cwd();
var dirnamePath = path.join(currentPath, '.git');
if (fsHelpers.exists(dirnamePath)) {
return dirnamePath;
}
var nextPath = path.resolve(currentPath, '..');
if (nextPath === currentPath) {
r... | javascript | {
"resource": ""
} |
q35185 | train | function(parent, type){
var element = qq.getByClass(parent, this._options.classes[type])[0];
if (!element){
throw new Error('element not found ' + type);
}
return element;
} | javascript | {
"resource": ""
} | |
q35186 | train | function(){
var self = this,
list = this._listElement;
qq.attach(list, 'click', function(e){
e = e || window.event;
var target = e.target || e.srcElement;
if (qq.hasClass(target, self._classes.cancel)){ ... | javascript | {
"resource": ""
} | |
q35187 | train | function(id){
// We can't use following code as the name attribute
// won't be properly registered in IE6, and new window
// on form submit will open
// var iframe = document.createElement('iframe');
// iframe.setAttribute('name', id);
var iframe = qq.toElement('<iframe ... | javascript | {
"resource": ""
} | |
q35188 | _convertStringIfTrue | train | function _convertStringIfTrue(original) {
var str;
if (original && typeof original === "string") {
str = original.toLowerCase().trim();
return (str === "true" || str === "false") ? (str === "true") : original;
}
return original;
} | javascript | {
"resource": ""
} |
q35189 | convertPropsToJson | train | function convertPropsToJson(text) {
var configObject = {};
if (text && text.length) {
// handle multi-line values terminated with a backslash
text = text.replace(/\\\r?\n\s*/g, '');
text.split(/\r?\n/g).forEach(function (line) {
var props,
name,
... | javascript | {
"resource": ""
} |
q35190 | VTree | train | function VTree(body, config) {
var i;
config = extend({ allowJSON: false }, config);
Object.defineProperty(this, 'config', { enumerable: false, value: config });
if (body && body.length) {
for (i=0; i<body.length; i++) {
this.push(body[i]);
}
}
} | javascript | {
"resource": ""
} |
q35191 | train | function(object, options) {
var i, r = [];
for (i in object) {
if (object.hasOwnProperty(i)) {
r = r.concat(options.fn(object[i]));
}
}
return r;
} | javascript | {
"resource": ""
} | |
q35192 | dotsplit | train | function dotsplit (string) {
var idx = -1
var str = compact(normalize(string).split('.'))
var end = str.length
var out = []
while (++idx < end) {
out.push(todots(str[idx]))
}
return out
} | javascript | {
"resource": ""
} |
q35193 | compact | train | function compact (arr) {
var idx = -1
var end = arr.length
var out = []
while (++idx < end) {
if (arr[idx]) out.push(arr[idx])
}
return out
} | javascript | {
"resource": ""
} |
q35194 | readFileCache | train | function readFileCache (path, noCache, cb) {
path = abs(path);
if (typeof noCache === "function") {
cb = noCache;
noCache = false;
}
// TODO: Callback buffering
if (_cache[path] && noCache !== true) {
return cb(null, _cache[path]);
}
read(path, (err, data) => {
... | javascript | {
"resource": ""
} |
q35195 | train | function(options, callback) {
request({
method: 'post',
url: options.url,
headers: {
'Authorization': 'Bearer ' + access_token,
'Content-Type': 'application/x-www-form-urlencoded'
},
form: options.data
},
function(error, response, body) {
callback(error, b... | javascript | {
"resource": ""
} | |
q35196 | reanderPage | train | function reanderPage(Handler, data) {
React.render(React.createElement(Handler, { data: data }), document);
} | javascript | {
"resource": ""
} |
q35197 | train | function(path, params) {
var queryString = this.query_string;
for (var param in params) {
var re = new RegExp(":"+ param)
var found = false;
if (path.search(re) != -1) {
path = path.replace(re, params[param]);
found = true;
... | javascript | {
"resource": ""
} | |
q35198 | train | function(headers, params) {
var newHeaders = {};
for (var header in headers)
newHeaders[header] = headers[header];
for (var param in params) {
var re = new RegExp(":"+ param);
for (var header in newHeaders) {
if (newHeaders[header].search(re) !... | javascript | {
"resource": ""
} | |
q35199 | Peer | train | function Peer (options) {
EventEmitter.call(this)
bindFns(this)
extend(this, options)
var addr = this.address
var hp = addr.split(':')
this.host = hp[0]
this.port = Number(hp[1])
this._deliveryTrackers = []
this.setMaxListeners(0)
this._debug('new peer')
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.