_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q56300 | train | function (eventType, callback, scope) {
if (callback) {
scope = scope || this;
// get the list for the event
var list = this._eventHandlers[eventType] || (this._eventHandlers[eventType] = []);
// and push the callback functi... | javascript | {
"resource": ""
} | |
q56301 | train | function (attributes, target) {
this.$ = attributes;
this.target = target;
this.isDefaultPrevented = false;
| javascript | {
"resource": ""
} | |
q56302 | train | function () {
this.isDefaultPrevented = true;
if (this.$) {
var e = this.$.orginalEvent;
if (e) {
if (e.preventDefault) {
e.preventDefault();
| javascript | {
"resource": ""
} | |
q56303 | train | function (items, options) {
options = options || {};
_.defaults(options, {
root: null,
query: null,
pageSize: null,
queryParameters: {},
sortParameters: null,
factory: this.$modelFactory || require('... | javascript | {
"resource": ""
} | |
q56304 | train | function (query, options) {
options.$itemsCount = undefined;
var collection = | javascript | {
"resource": ""
} | |
q56305 | train | function (query) {
if (query instanceof Query && query.query.sort) {
if (this.$.query) {
query.query.where = this.$.query.query.where;
}
var options = _.defaults({}, {
query: query,
root: this.getRo... | javascript | {
"resource": ""
} | |
q56306 | train | function (pageIndex, options, callback) {
if (pageIndex < 0) {
throw "pageIndex must be >= 0";
}
var page = this.$pageCache[pageIndex];
if (!page) {
page = this.$pageCache[pageIndex] = new Page(null, this, pageIndex);
}
... | javascript | {
"resource": ""
} | |
q56307 | train | function (field) {
var schemaDefinition = this.schema[field];
if (!schemaDefinition) {
throw "Couldn't find '" + field + "' in schema";
}
var collection = this.get(field);
if (!collection) {
var context = this.getContextForChild... | javascript | {
"resource": ""
} | |
q56308 | train | function (action, options) {
var ret = this.callBase();
if (action === "create" && ret.hasOwnProperty(this.idField) && [this.idField] === null) {
| javascript | {
"resource": ""
} | |
q56309 | train | function (options, callback) {
if (arguments.length === 1 && options instanceof Function) {
callback = options;
options = null;
}
options = options || {};
var self = this;
if (this._fetch.state === FETCHSTATE.LOADING) {
... | javascript | {
"resource": ""
} | |
q56310 | train | function (identifier) {
var idField = this.idField;
if (this.schema.hasOwnProperty(idField)) {
var schemaObject = this.schema[idField];
if (schemaObject.type && schemaObject.type === Number) {
| javascript | {
"resource": ""
} | |
q56311 | train | function (items) {
var c,
j;
if (this.$renderedItems) {
for (j = this.$renderedItems.length - 1; j >= 0; j--) {
c = this.$renderedItems[j];
this.$parent.removeChild(c.component);
c.component.destroy();
... | javascript | {
"resource": ""
} | |
q56312 | train | function (child, index) {
var indexOffset = this._calculateIndexOffsetForChild(child);
| javascript | {
"resource": ""
} | |
q56313 | train | function (item) {
var key = this._getKeyForItem(item),
list = this.$renderedItems;
if (key) {
list = this.$renderedItemsMap[key];
}
if (list) {
var ri;
for (var i = 0; i < list.length; i++) {
... | javascript | {
"resource": ""
} | |
q56314 | train | function (operator, field) {
if (!this.query.where) {
return null;
}
function findExpression(expressions) {
var expression,
ret = null;
for (var i = 0; i < expressions.length; i++) {
expression =... | javascript | {
"resource": ""
} | |
q56315 | train | function (event) {
for (var i = 0; i < this.events.length; i++) {
if (event === this.events[i]) {
return true;
| javascript | {
"resource": ""
} | |
q56316 | train | function (domNode) {
if (domNode.localName) {
return domNode.localName;
}
var localName = LocalNameCache[domNode.tagName];
if (localName) {
return localName;
}
| javascript | {
"resource": ""
} | |
q56317 | train | function (entity, action, options) {
var ret = {},
data = entity.compose(action, options),
schemaDefinition,
schemaType,
isModel = entity instanceof Model,
factory = entity.factory;
for (... | javascript | {
"resource": ""
} | |
q56318 | train | function(object, extra_helpers) {
object = object || {};
this._extra_helpers = extra_helpers;
var v = | javascript | {
"resource": ""
} | |
q56319 | train | function(options, data, helpers) {
if (!helpers) helpers = this._extras;
| javascript | {
"resource": ""
} | |
q56320 | train | function(input, null_text) {
if (input == null || input === undefined) return null_text || '';
if (input instanceof(Date)) return input.toDateString();
| javascript | {
"resource": ""
} | |
q56321 | train | function (path) {
var str = [];
for (var i = 0; i < path.length; i++) {
var el = path[i];
if (el.type === TYPE_VAR) {
str.push(el.name);
| javascript | {
"resource": ""
} | |
q56322 | train | function (event) {
if (!this.$) {
return;
}
for (var i = 0; i < this.$.fnc._attributes.length; i++) {
| javascript | {
"resource": ""
} | |
q56323 | train | function () {
// binding already destroyed?
if (!this.$) {
return;
}
var e;
for (var j = 0; j < this.$events.length; j++) {
e = this.$events[j];
this.$.scope.unbind(e.eventType, e.callback, this);
}
... | javascript | {
"resource": ""
} | |
q56324 | train | function () {
var parameters = [];
for (var i = 0; i < this.$parameters.length; i++) {
var para = this.$parameters[i];
if (para instanceof Binding) {
| javascript | {
"resource": ""
} | |
q56325 | train | function () {
if (this.$subBinding) {
this.$subBinding.invalidateValueCache();
return this.$subBinding.getValue();
} else {
if (this.$cachedValue !== undefined && !this.$jsonObject) {
return this.$cachedValue;
}... | javascript | {
"resource": ""
} | |
q56326 | train | function () {
// get value
var val = this.getContextValue();
var target,
targets = this.$.root.getTargets();
if (targets) {
for (var i = 0; i < targets.length; i++) {
target = targets[i];
if (target.... | javascript | {
"resource": ""
} | |
q56327 | train | function () {
if (this._$source) {
var val, attributes = {}, unsetAttributes = {};
for (var key in this.$) {
if (this.$.hasOwnProperty(key)) {
val = this.$[key];
... | javascript | {
"resource": ""
} | |
q56328 | train | function (attribute, key) {
if (this.inject && this.inject.hasOwnProperty(key)) {
return attribute;
} else if (attribute instanceof Bindable) {
return attribute.clone();
} else if (attribute && (attribute.clone i... | javascript | {
"resource": ""
} | |
q56329 | train | function (key, value, options) {
if (_.isNumber(key)) {
key = String(key);
}
if (_.isString(key)) {
var attributes = {};
attributes[key] = value;
} else {
... | javascript | {
"resource": ""
} | |
q56330 | train | function (authenticationRequest) {
var authenticationProviders = this.$providers,
provider;
for (var i = 0; i < authenticationProviders.length; i++) {
provider = authenticationProviders[i];
| javascript | {
"resource": ""
} | |
q56331 | train | function (context, token, callback) {
var authentication = this.$.dataSource.createEntity(Authentication, token),
self = this;
// setup authentication
this.$stage.$bus.setUp(authentication);
flow()
.seq("authentication", function (cb) {
... | javascript | {
"resource": ""
} | |
q56332 | train | function (authentication, callback) {
/***
* Let's save the authentication and so the user is logged in
*
*/
var token = generateId();
| javascript | {
"resource": ""
} | |
q56333 | train | function (context, callback, checkParents) {
if (this.$parentResource) {
var self = this;
flow()
.seq("parentCollection", function (cb) {
self.$parentResource._findCollection(context, cb);
})
... | javascript | {
"resource": ""
} | |
q56334 | train | function () {
if (this.$processUrl) {
var currentFragment = this._getFragment();
if (currentFragment == this.$fragment) {
return false;
| javascript | {
"resource": ""
} | |
q56335 | train | function (fragment, callback) {
var routeExecutionStack = [];
for (var i = 0; i < this.$routers.length; i++) {
routeExecutionStack = routeExecutionStack.concat(this.$routers[i].generateRoutingStack(fragment));
}
if (routeExecutionStack.length === 0) {
... | javascript | {
"resource": ""
} | |
q56336 | getPlugins | train | function getPlugins(){
var plugins = $p.plugins,
f = function(){};
f.prototype = plugins;
// do not overwrite functions if external definition
f.prototype.compile = plugins.compile || compile;
f.prototype.render | javascript | {
"resource": ""
} |
q56337 | wrapquote | train | function wrapquote(qfn, f){
return function(ctxt){
return qfn('' + | javascript | {
"resource": ""
} |
q56338 | find | train | function find(n, sel){
if(typeof n === 'string'){
sel = n;
n = false;
}
if(typeof document.querySelectorAll !== 'undefined'){
return (n||document).querySelectorAll( sel );
}else{
error('You can test PURE | javascript | {
"resource": ""
} |
q56339 | parseloopspec | train | function parseloopspec(p){
var m = p.match( /^(\w+)\s*<-\s*(\S+)?$/ );
if(m === null){
error('bad loop spec: "' + p + '"');
}
if(m[1] === 'item'){
error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.');
| javascript | {
"resource": ""
} |
q56340 | loopfn | train | function loopfn(name, dselect, inner, sorter, filter){
return function(ctxt){
var a = dselect(ctxt),
old = ctxt[name],
temp = { items : a },
filtered = 0,
length,
strs = [],
buildArg = function(idx, temp, ftr, len){
ctxt.pos = temp.pos = idx;
... | javascript | {
"resource": ""
} |
q56341 | loopgen | train | function loopgen(dom, sel, loop, fns){
var already = false, ls, sorter, filter, prop;
for(prop in loop){
if(loop.hasOwnProperty(prop)){
if(prop === 'sort'){
sorter = loop.sort;
continue;
}else if(prop === 'filter'){
filter = loop.filter;
continue;
... | javascript | {
"resource": ""
} |
q56342 | compiler | train | function compiler(dom, directive, data, ans){
var fns = [];
// autoRendering nodes parsing -> auto-nodes
ans = ans || data && getAutoNodes(dom, data);
if(data){
var j, jj, cspec, n, target, nodes, itersel, node, inner;
// for each auto-nodes
while(ans.length > 0){
cspec = ans[0... | javascript | {
"resource": ""
} |
q56343 | compile | train | function compile(directive, ctxt, template){
var rfn = compiler( ( template || this[0] ).cloneNode(true), directive, ctxt);
return | javascript | {
"resource": ""
} |
q56344 | render | train | function render(ctxt, directive){
var fn = typeof directive === 'function' ? directive : plugins.compile( directive, false, this[0] );
for(var i = 0, ii = this.length; i < ii; i++){ | javascript | {
"resource": ""
} |
q56345 | convert | train | function convert(source) {
let currentKey = "",
currentValue = "",
objectNames = [],
output = {},
parentObj = {},
lines = source.split(NEW_LINE),
splitAt;
let currentObj = output;
let parents = [];
for (let i = 0; i < lines.length; i++) {
let line = lines[i];
if (li... | javascript | {
"resource": ""
} |
q56346 | revert | train | function revert(object) {
let lines = [];
for (let key in object) {
let value = object[key];
if (Array.isArray(value)) {
value.forEach((item) => {
lines.push(`BEGIN:${key}`);
lines.push(revert(item));
lines.push(`END:${key}`);
| javascript | {
"resource": ""
} |
q56347 | run | train | function run(options) {
let files, filePromises = [];
files = options.args || [];
for (let i = 0; i < files.length; i++) {
let file = files[i];
let filePath = path.resolve(cwd, file);
if (!fs.existsSync(filePath)) {
continue;
}
let stat = fs.statSync(filePath);
let ext = path.extn... | javascript | {
"resource": ""
} |
q56348 | train | function () {
if (this.factory.schema) {
this.schema = this.factory.schema;
return;
}
var base = this.base;
while (base.factory.classof(Entity)) {
var baseSchema = base.schema;
... | javascript | {
"resource": ""
} | |
q56349 | train | function (key, scope) {
var value = this.get(key, scope);
if (key && this.schema[key]) {
for (var i = 0; | javascript | {
"resource": ""
} | |
q56350 | train | function (options) {
var ret = {};
for (var k in this.schema) {
if (this.schema.hasOwnProperty(k)) {
| javascript | {
"resource": ""
} | |
q56351 | train | function (entity, options, callback) {
if (entity instanceof Entity) {
entity.validate(options, callback);
} else {
| javascript | {
"resource": ""
} | |
q56352 | train | function(keypath, content, attributes) {
var attrs = {'for': this._attributesForKeyPath(keypath).name}; | javascript | {
"resource": ""
} | |
q56353 | train | function(keypath, attributes) {
attributes = $.extend({type: 'hidden'}, | javascript | {
"resource": ""
} | |
q56354 | train | function(keypath, attributes) {
var current;
attributes = $.extend(this._attributesForKeyPath(keypath), attributes); | javascript | {
"resource": ""
} | |
q56355 | train | function(keypath, value, attributes) {
var selected;
attributes = $.extend(this._attributesForKeyPath(keypath), attributes);
selected = attributes.value;
attributes.value = getStringContent(this.object, value);
if (selected | javascript | {
"resource": ""
} | |
q56356 | train | function (items, options) {
options = options || {};
_.defaults(options, {silent: false, index: this.$items.length});
var index = options.index;
if (!_.isArray(items)) {
items = [items];
}
var item, itemIndex;
for (v... | javascript | {
"resource": ""
} | |
q56357 | train | function (items, options) {
var removed = [];
if (!_.isArray(items)) {
items = [items];
}
var item;
for (var i = 0; i < items.length; i++) {
| javascript | {
"resource": ""
} | |
q56358 | train | function (index, options) {
options = options || {};
if (index > -1 && index < this.$items.length) {
var items = this.$items.splice(index, 1),
item = items[0];
if (options.silent !== true) {
this.trigger('remove', {item: i... | javascript | {
"resource": ""
} | |
q56359 | train | function (items, options) {
items = items || [];
var self = this;
this.each(function (item) {
if (item instanceof EventDispatcher) {
item.unbind('*', self._onItemEvent, self);
item.unbind('change', self._onItemChange, self);
... | javascript | {
"resource": ""
} | |
q56360 | train | function (fnc, scope) {
scope = scope || this;
for (var i = 0; i < this.$items.length; i++) {
| javascript | {
"resource": ""
} | |
q56361 | train | function (fnc, scope) {
scope = scope || this;
var b = false,
items = this.$items,
length = items.length;
for (var i = 0; i < length; i++) {
b = fnc.call(scope, items[i], i, this.$items); | javascript | {
"resource": ""
} | |
q56362 | train | function () {
var attributes = this._cloneAttribute(this.$);
var items = this._cloneAttribute(this.$items);
| javascript | {
"resource": ""
} | |
q56363 | train | function () {
if (this._$source) {
var item, items = [];
for (var i = 0; i < this.$items.length; i++) {
item = this.$items[i];
if (item instanceof Bindable && item.sync()) {
item = item._$source;
... | javascript | {
"resource": ""
} | |
q56364 | train | function (list) {
if (list.size() !== this.size()) {
return false;
}
var isEqual = true,
a, b;
for (var i = 0; i < this.$items.length; i++) {
a = this.$items[i];
b = list.at(i);
if (a instance... | javascript | {
"resource": ""
} | |
q56365 | train | function (moduleName, moduleInstance, callback, routeContext, cachedInstance) {
var self = this;
//noinspection JSValidateTypes
flow()
.seq(function (cb) {
self.$moduleInstance = moduleInstance;
var c... | javascript | {
"resource": ""
} | |
q56366 | train | function (templateName, target, attributes, options) {
if (!this.$container) {
this.$container = this.createComponent(HtmlElement, {"class": this.$.containerClass, "tagName": "div"});
this.$stage.addChild(this.$container);
}
var tooltip = this.getToolt... | javascript | {
"resource": ""
} | |
q56367 | train | function (tooltip, target) {
if (!(tooltip instanceof Tooltip)) {
tooltip = this.getTooltipByNameAndTarget(tooltip, target);
}
if (tooltip) {
| javascript | {
"resource": ""
} | |
q56368 | train | function (templateName, target) {
var tooltip;
for (var i = 0; i < this.$tooltips.length; i++) {
tooltip = this.$tooltips[i];
if | javascript | {
"resource": ""
} | |
q56369 | train | function (xhr) {
this.xhr = xhr;
this.status = xhr.status;
this.$nativeResponseHeaders = xhr.getAllResponseHeaders();
this.responses = {};
var xml = xhr.responseXML;
// Construct response list
if (xml && xml.documentElement) {
| javascript | {
"resource": ""
} | |
q56370 | parse_attribs | train | function parse_attribs(line) {
var attributes = {},
l = line.length,
i, c,
count = 1,
quote = false,
skip = false,
open, close, joiner, seperator,
pair = {
start: 1,
middle: null,
end: null
};
if (!(l > 0 && (line.cha... | javascript | {
"resource": ""
} |
q56371 | parse_interpol | train | function parse_interpol(value) {
var items = [],
pos = 0,
next = 0,
match;
while (true) {
// Match up to embedded string
next = value.substr(pos).search(embedder);
if (next < 0) {
if (pos < value.length) {
items.push(JSON.stringify(value.substr(pos)));... | javascript | {
"resource": ""
} |
q56372 | loadFiles | train | function loadFiles(dir, options) {
var listings = fs.readdirSync(dir)
, options = options || {}
, obj = {};
listings.forEach(function (listing) {
var file = path.join(dir, listing)
, prop = listing.split('.')[0] // probably want regexp or something more robust
, stat = fs.statSync(file);
... | javascript | {
"resource": ""
} |
q56373 | train | function () {
if (arguments.length === 0) {
grunt.warn(strings[options.locale]['translate.param.missing']);
}
var key = arguments[0];
if (!(key in strings[options.locale])) {
| javascript | {
"resource": ""
} | |
q56374 | train | function (params) {
var message = translate(errors[params.caseNum])
.replace('%n', (params.lineNum + 1).toString())
.replace('%p', params.pattern)
.replace('%x', params.start)
.replace('%y', (params.endLineNum + 1).toString())
| javascript | {
"resource": ""
} | |
q56375 | train | function (line, lineNum) {
if (line.trim() === '') {
return;
}
function logAnyDelimiterType(line) {
blocks.forEach(function (blockDef, blockIdx) {
if (blockDef.start.test(line) === true) {
fileStartDelimite... | javascript | {
"resource": ""
} | |
q56376 | train | function(cb) {
fs.exists(potterHome, function(exists) {
if(exists) {
cb(null);
| javascript | {
"resource": ""
} | |
q56377 | train | function(cb) {
fs.exists(path.join(potterHome, 'package.json'), function(exists) {
if(exists) {
cb(null);
| javascript | {
"resource": ""
} | |
q56378 | mapDefinitionsFromModel | train | function mapDefinitionsFromModel(model) {
const definitionMap = [];
/* istanbul ignore else */
if (model && model.definitions) {
debug('Parsing %s definitions', Object.keys(model.definitions).length);
for (const definitionName of Object.keys(model.definitions)) {
| javascript | {
"resource": ""
} |
q56379 | handleGet | train | function handleGet(req, res, sails, | javascript | {
"resource": ""
} |
q56380 | handlePost | train | function handlePost(req, res, sails, params){
var func;
if(!_.isUndefined(params.email)){
func = sendEmail;
}else if(!_.isUndefined(req.session.resetToken) &&
req.session.resetToken &&
!_.isUndefined(params.password)){
func = | javascript | {
"resource": ""
} |
q56381 | sendEmail | train | function sendEmail(req, res, sails, params){
sails.models.auth.findOne({email: params.email}).populate('user').exec(function(err, a){
if(a){
sails.models.resettoken.create({owner: a.id}).exec(function(err, t){
if(err){
return res.serverError(err);
}
sails.models.auth.update... | javascript | {
"resource": ""
} |
q56382 | validateToken | train | function validateToken(req, res, sails, params){
var config = wl.config;
var authConfig = wl.authConfig;
if(params.token){
try{
// decode the token
var _token = jwt.decode(params.token, config.jsonWebTokens.secret);
// set the time of the request
var _reqTime = Date.now();
// I... | javascript | {
"resource": ""
} |
q56383 | isMemberCall | train | function isMemberCall({ callee }, obj, prop) {
return callee.type | javascript | {
"resource": ""
} |
q56384 | train | function () {
var list = slice.call(this.indexes || []);
var i = 0;
list.push(this.mainIndex);
list.push('cid'); | javascript | {
"resource": ""
} | |
q56385 | handlebarsEngine | train | function handlebarsEngine(taskOptions) {
debug('Initializing new instance of hbs');
const handlebars = hbs.create();
/* istanbul ignore else */
if (taskOptions.helpers) {
for (const helper of Object.keys(taskOptions.helpers)) {
debug(' | javascript | {
"resource": ""
} |
q56386 | arrayContainsItem | train | function arrayContainsItem(array, value, options) {
if (array && _.indexOf(array, value) >= 0) {
| javascript | {
"resource": ""
} |
q56387 | compareValues | train | function compareValues(lvalue, operator, rvalue, options) {
const operators = {
'==': function compareEqual(l, r) { return l === r; },
'===': function compareIdentical(l, r) { return l === r; },
'!=': function compareNotEqual(l, r) { return l !== r; },
'<': function compareLessThan(l, r) { return l < ... | javascript | {
"resource": ""
} |
q56388 | lowercaseFirstLetter | train | function lowercaseFirstLetter(options) {
const string = options.fn(this);
| javascript | {
"resource": ""
} |
q56389 | capSplitAndJoin | train | function capSplitAndJoin(joiner, options) {
const string = options.fn(this);
const members | javascript | {
"resource": ""
} |
q56390 | propertyValueExtract | train | function propertyValueExtract(context, name, propName, options) {
if (context[name] === undefined || context[name] === null) {
return options.inverse(context);
| javascript | {
"resource": ""
} |
q56391 | uppercaseFirstLetter | train | function uppercaseFirstLetter(options) {
const string = options.fn(this);
| javascript | {
"resource": ""
} |
q56392 | regex | train | function regex(replacements) {
return {
name: 'regex',
renderChunk(code) {
const magicString = new MagicString(code);
let hasReplacements = false;
replacements.forEach(replacement => {
let [find, replace = ''] = replacement;
if (t... | javascript | {
"resource": ""
} |
q56393 | babel | train | function babel(options = {}) {
return {
name: 'babel',
renderChunk(code) {
options.presets = [['env', { modules: false }]];
| javascript | {
"resource": ""
} |
q56394 | uglify | train | function uglify(options = {}) {
return {
name: 'uglify',
renderChunk(code) {
options.sourceMap = true;
| javascript | {
"resource": ""
} |
q56395 | getGraphqlName | train | function getGraphqlName(g, iri) {
const { prefixes } = g.config;
const localName = getIriLocalName(iri);
const namespaceIri = iri.slice(0, -localName.length);
const prefix = | javascript | {
"resource": ""
} |
q56396 | requireGraphqlRelay | train | function requireGraphqlRelay() {
if (graphqlRelay) return graphqlRelay;
try {
graphqlRelay = require('graphql-relay');
}
catch (ex) {
// Nothing
}
if (!graphqlRelay) {
// Go up until graphql-relay is found
// Inspired by https://www.npmjs.com/package/parent-require
for (let parent = mo... | javascript | {
"resource": ""
} |
q56397 | parseArgs | train | function parseArgs() {
var args = Array.prototype.slice.call(arguments);
var ret = {
query: args[0],
params: [],
options: {},
callback: undefined,
endCallback: undefined
};
args.shift();
// If specified, params must be an array
if (args[0] instanceof Ar... | javascript | {
"resource": ""
} |
q56398 | createArgs | train | function createArgs(args, color) {
var last = args[args.length - 1];
if (args.length > 1 && isObject(last && last.hash)) {
args.pop();
}
if (typeof color === 'string' | javascript | {
"resource": ""
} |
q56399 | switchOutput | train | function switchOutput(type, json) {
if (type[0] === '.') type = type.slice(1);
var result = '';
switch (type) {
case 'md':
result = ''
+ '\n```json\n'
+ json
+ '\n```\n';
break;
case 'html':
result = ''
+ '<div | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.