_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 27 233k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q47800 | baseForOwnRight | train | function baseForOwnRight(object, callback) {
var props = keys(object),
length = props.length;
while (length--) {
var key = props[length];
| javascript | {
"resource": ""
} |
q47801 | baseMerge | train | function baseMerge(object, source, callback, stackA, stackB) {
(isArray(source) ? baseEach : baseForOwn)(source, function(source, key) {
var found,
isArr,
result = source,
value = object[key];
if (source && ((isArr = isArray(source)) || isPlainObject(source))) ... | javascript | {
"resource": ""
} |
q47802 | createAggregator | train | function createAggregator(setter, retArray) {
return function(collection, callback, thisArg) {
var result = retArray ? [[], []] : {};
callback = lodash.createCallback(callback, thisArg, 3);
if (isArray(collection)) {
var index = -1,
length = collection.length;
... | javascript | {
"resource": ""
} |
q47803 | createIterator | train | function createIterator(options) {
options.shadowedProps = shadowedProps;
options.support = support;
// create the function factory
var factory = Function(
'errorClass, errorProto, hasOwnProperty, isArguments, isObject, objectProto, ' +
'nonEnumProps, stringClass, stringProt... | javascript | {
"resource": ""
} |
q47804 | getHolders | train | function getHolders(array) {
var index = -1,
length = array.length,
result = [];
while (++index < length) {
| javascript | {
"resource": ""
} |
q47805 | sample | train | function sample(collection, n, guard) {
if (collection && typeof collection.length != 'number') {
collection = values(collection);
} else if (support.unindexedChars && isString(collection)) {
collection = collection.split('');
}
if (n == null || guard) {
| javascript | {
"resource": ""
} |
q47806 | partialRight | train | function partialRight(func) {
if (func) {
var arity = func[expando] ? func[expando][2] : func.length,
partialRightArgs = slice(arguments, 1);
arity -= partialRightArgs.length;
| javascript | {
"resource": ""
} |
q47807 | functions | train | function functions(object) {
var result = [];
baseForIn(object, function(value, key) {
if (isFunction(value)) {
| javascript | {
"resource": ""
} |
q47808 | matches | train | function matches(source) {
source || (source = {});
var props = keys(source),
key = props[0],
a = source[key];
// fast path the common case of providing an object with a single
// property containing a primitive value
if (props.length == 1 && a === a && !isObject(a)) ... | javascript | {
"resource": ""
} |
q47809 | mixin | train | function mixin(object, source, options) {
var chain = true,
methodNames = source && functions(source);
if (!source || (!options && !methodNames.length)) {
if (options == null) {
options = source;
}
source = object;
object = lodash;
methodNames = f... | javascript | {
"resource": ""
} |
q47810 | result | train | function result(object, key, defaultValue) {
var value = object == null ? undefined : object[key];
if (typeof value == 'undefined') {
| javascript | {
"resource": ""
} |
q47811 | train | function(obj, name, callback) {
var listeningTo = this._listeningTo;
if (!listeningTo) return this;
var remove = !name && !callback;
if (!callback && typeof name === 'object') callback = this;
| javascript | {
"resource": ""
} | |
q47812 | train | function(namespace, key) {
key = JSON.stringify(key);
| javascript | {
"resource": ""
} | |
q47813 | train | function(namespace, key) {
var ckey = Cache.key(namespace, key);
var ctime = (new Date()).getTime();
var v = Storage.get(ckey);
if (v == null) {
return null;
} else {
if (v.expiration == -1 || v.expiration > ctime) {
... | javascript | {
"resource": ""
} | |
q47814 | train | function(namespace, key) {
var ckey = Cache.key(namespace, key); | javascript | {
"resource": ""
} | |
q47815 | train | function(namespace, key, value, expiration) {
var ckey = Cache.key(namespace, key);
var ctime = (new Date()).getTime();
if (expiration > 0) {
expiration = ctime + expiration * 1000;
} else {
expiration = -1;
}
| javascript | {
"resource": ""
} | |
q47816 | train | function() {
var s = Storage.storage();
if (s == null) {
return false;
}
| javascript | {
"resource": ""
} | |
q47817 | train | function(namespace) {
var ncache = {};
_.each(cache_methods, function(method) {
ncache[method] | javascript | {
"resource": ""
} | |
q47818 | train | function() {
if (!this.available) return;
if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {
this.trigger("update");
}
| javascript | {
"resource": ""
} | |
q47819 | train | function(state) {
if (state == this.state) return;
this.state = | javascript | {
"resource": ""
} | |
q47820 | train | function(title) {
if (this._preTitle.length > 0) title = this._preTitle + " " + title;
if (_.size(title) == | javascript | {
"resource": ""
} | |
q47821 | train | function(name, value, metaName) {
if (_.isObject(name)) {
_.each(name, function(value, name) {
this.meta(name, value);
}, this);
return;
}
if (metaName == null) metaName = "name";
| javascript | {
"resource": ""
} | |
q47822 | train | function(rel, href, mimetype) {
if (_.isObject(rel)) {
_.each(rel, function(value, name) {
this.link(name, value);
}, this);
return;
}
var mt = this.$('link[rel="'+rel+'"]');
| javascript | {
"resource": ""
} | |
q47823 | train | function(value, absolute) {
var mt = this.$('title');
if (mt.length === 0) {
mt = $("<title>", {}).appendTo(this.$el);
}
if (value != null) {
this._title = value;
| javascript | {
"resource": ""
} | |
q47824 | train | function(index, follow) {
if (_.isNull(follow)) follow = index;
var value = "";
value = index ? "index" : "noindex";
| javascript | {
"resource": ""
} | |
q47825 | train | function() {
if (this.started) {
logging.warn("routing history already started");
return false;
}
var self = this;
var $window = $(window);
var rootUrl | javascript | {
"resource": ""
} | |
q47826 | train | function(route, args) {
url = urls.route(route, args);
logging.log("navigate to ", url);
| javascript | {
"resource": ""
} | |
q47827 | train | function(route, name) {
var handler;
if (_.isObject(route) && !_.isRegExp(route)) {
_.each(route, function(callback, route) {
this.route(route, callback);
}, this);
return this;
}
handler = this[name];
... | javascript | {
"resource": ""
} | |
q47828 | train | function(models, options) {
options = _.defaults(options || {}, {
totalCount: false
});
// Manage {list:[], n:0} for infinite list
if (_.size(models) == 2
&& models.list != null && models.n != null) {
this._totalCount = models.... | javascript | {
"resource": ""
} | |
q47829 | train | function(model, options) {
var index;
if (_.isArray(model)) {
_.each(model, function(m) {
this.remove(m, options);
}, this);
return this;
}
options = _.defaults(options || {}, {
silent: ... | javascript | {
"resource": ""
} | |
q47830 | train | function(model, options) {
model = this._prepareModel(model, options);
| javascript | {
"resource": ""
} | |
q47831 | train | function(options) {
this.queue.defer(function() {
options = _.defaults(options || {}, {
refresh: false
});
var d, self = this;
if (this.options.loader == null) return this;
if (options.refresh) {
... | javascript | {
"resource": ""
} | |
q47832 | train | function(method, properties) {
if (this.methods[method]) throw "Method already define for this backend: "+method;
properties.id = method;
| javascript | {
"resource": ""
} | |
q47833 | train | function(method, sId) {
sId = sId || method;
sId = this.options.prefix+"."+sId;
return this.addMethod(method, {
fallback: function(args, options, method) {
return Storage.get(sId+"."+method);
| javascript | {
"resource": ""
} | |
q47834 | train | function(method) {
return _.find(this.methods, function(handler) {
return | javascript | {
"resource": ""
} | |
q47835 | train | function(method, args, options) {
var that = this, methodHandler;
options = options || {};
var handler = this.getHandler(method);
if (!handler) return Q.reject(new Error("No handler found for method: "+method));
// Is offline
if (!Offline.isConn... | javascript | {
"resource": ""
} | |
q47836 | train | function (url, protocol, hostname, port) {
var match = text.xdRegExp.exec(url),
uProtocol, uHostName, uPort;
if (!match) {
return true;
}
uProtocol = match[2];
uHostName = match[3];
u... | javascript | {
"resource": ""
} | |
q47837 | train | function(cls, options) {
var d = Q.defer();
cls = cls || DialogView;
var diag = new cls(options);
diag.once("close", function(result, e) {
if (result != null) {
d.resolve(result);
} else {
d.reject(... | javascript | {
"resource": ""
} | |
q47838 | train | function(title, message, defaultmsg) {
return Dialogs.open(null, {
"title": title,
"message": message,
"dialog": "prompt",
"default": | javascript | {
"resource": ""
} | |
q47839 | train | function(title, message, choices, defaultChoice) {
return Dialogs.open(null, {
"title": title,
"message": message,
"dialog": "select",
"default": defaultChoice, | javascript | {
"resource": ""
} | |
q47840 | train | function(title, message) {
if (!message) {
message = title;
title = null;
}
return Dialogs.open(null, {
| javascript | {
"resource": ""
} | |
q47841 | train | function(err) {
Dialogs.alert("Error:", err.message || err);
| javascript | {
"resource": ""
} | |
q47842 | dfl | train | function dfl(a, b, c) {
switch (arguments.length) {
case 2: return a != null ? a | javascript | {
"resource": ""
} |
q47843 | setProjection | train | function setProjection( element, options ) {
var width = options.width || element.offsetWidth;
var height = options.height || element.offsetHeight;
var projection, path;
if ( options && typeof options.scope === 'undefined') {
options.scope = 'world';
}
if ( options.scope === 'usa' ) {
| javascript | {
"resource": ""
} |
q47844 | addLegend | train | function addLegend(layer, data, options) {
data = data || {};
if ( !this.options.fills ) {
return;
}
var html = '<dl>';
var label = '';
if ( data.legendTitle ) {
html = '<h2>' + data.legendTitle + '</h2>' + html;
}
for ( var fillKey in this.options.fills ) {
if ( fill... | javascript | {
"resource": ""
} |
q47845 | defaults | train | function defaults(obj) {
Array.prototype.slice.call(arguments, 1).forEach(function(source) {
if (source) {
for (var prop in source) {
| javascript | {
"resource": ""
} |
q47846 | train | function(data) {
var that = this;
data = data || this.toJSON();
return api.execute("put:report/"+this.get("id"), data)
.then(function(_data) {
| javascript | {
"resource": ""
} | |
q47847 | train | function() {
var that = this;
return api.execute("get:alerts")
.then(function(data) {
| javascript | {
"resource": ""
} | |
q47848 | train | function(r) {
r = r.toJSON? r.toJSON() : r;
this.report.del("visualizations", { silent: true });
this.report.set(r);
| javascript | {
"resource": ""
} | |
q47849 | train | function() {
var that = this;
return that.reports.loadAll()
.then(function() {
return dialogs.select(
i18n.t("reports.select.title"),
i18n.t("reports.select.message"),
| javascript | {
"resource": ""
} | |
q47850 | train | function() {
var that = this;
return dialogs.fields(i18n.t("reports.create.title"), {
"title": {
label: i18n.t("reports.create.fields.title"),
type: "text"
| javascript | {
"resource": ""
} | |
q47851 | train | function() {
var that = this;
return dialogs.fields(i18n.t("reports.edit.title"), {
"title": {
label: i18n.t("reports.edit.fields.title"),
type: "text"
| javascript | {
"resource": ""
} | |
q47852 | train | function() {
var that = this;
return dialogs.confirm(i18n.t("reports.remove.title"))
.then(function() {
return that.report.remove();
})
.then(function() {
| javascript | {
"resource": ""
} | |
q47853 | train | function() {
var that = this;
return api.execute("get:types")
.then(function(types) {
return dialogs.fields(i18n.t("visualization.create.title"), {
"eventName": {
'label': i18n.t("visualization.create.fields.eventName"),
... | javascript | {
"resource": ""
} | |
q47854 | train | function(e) {
if (e) e.preventDefault();
var that = this;
return api.execute("get:types")
.fail(dialogs.error)
.then(function(events) {
return dialogs.fields(i18n.t("alerts.create.title"), {
"title": {
... | javascript | {
"resource": ""
} | |
q47855 | parseArgs | train | function parseArgs () {
// Configure the argument parser
yargs
.option("schema", {
type: "boolean",
default: true,
})
.option("spec", {
type: "boolean",
default: true,
})
.option("o", {
alias: "outfile",
type: "string",
normalize: true,
})
.optio... | javascript | {
"resource": ""
} |
q47856 | bundle | train | function bundle (file, options) {
api.bundle(file, options)
.then((bundled) => {
if (options.outfile) {
console.log("Created %s from %s", options.outfile, file);
}
| javascript | {
"resource": ""
} |
q47857 | errorHandler | train | function errorHandler (err) {
let errorMessage = process.env.DEBUG ? err.stack : err.message; | javascript | {
"resource": ""
} |
q47858 | toYAML | train | function toYAML (api, spaces, wrap) {
const jsYaml = require("js-yaml");
return jsYaml.dump(api, {
| javascript | {
"resource": ""
} |
q47859 | makeBundleJS | train | function makeBundleJS(psModule) {
const bundleOutput = psModule.options.bundleOutput;
const name = psModule.name;
const srcDir = psModule.srcDir;
const escaped = jsStringEscape(path.relative(srcDir, | javascript | {
"resource": ""
} |
q47860 | makeJS | train | function makeJS(psModule, psModuleMap, js) {
const requireRE = /require\(['"]\.\.\/([\w\.]+)(?:\/index\.js)?['"]\)/g;
const foreignRE = /require\(['"]\.\/foreign(?:\.js)?['"]\)/g;
const name = psModule.name;
const imports = psModuleMap[name].imports;
var replacedImports = [];
const result = js
.rep... | javascript | {
"resource": ""
} |
q47861 | addClass | train | function addClass(className) {
if (typeof className === 'undefined') {
return this;
}
const classes = className.split(' ');
for (let i = 0; i < | javascript | {
"resource": ""
} |
q47862 | transform | train | function transform(transform) {
for (let i = 0; i < this.length; i += 1) {
const elStyle = this[i].style;
elStyle.webkitTransform = | javascript | {
"resource": ""
} |
q47863 | each | train | function each(callback) {
// Don't bother continuing without a callback
if (!callback) return this;
// Iterate over the current collection
for (let i = 0; i < this.length; i += 1) {
// If the callback returns false
| javascript | {
"resource": ""
} |
q47864 | train | function (el, e) {
var value = can.trim(el.val());
if (e.keyCode === ENTER_KEY && value !== '') {
new Models.Todo({
text : value,
| javascript | {
"resource": ""
} | |
q47865 | train | function (list, e, item) {
this.options.todos.push(item);
// Reset the filter so that you always see your | javascript | {
"resource": ""
} | |
q47866 | train | function () {
// Remove the `selected` class from the old link and add it to the link for the current location | javascript | {
"resource": ""
} | |
q47867 | train | function (el) {
var value = can.trim(el.val()),
todo = el.closest('.todo').data('todo');
// If we don't have a todo we don't need | javascript | {
"resource": ""
} | |
q47868 | train | function (el) {
var toggle = el.prop('checked');
can.each(this.options.todos, | javascript | {
"resource": ""
} | |
q47869 | train | function () {
for (var i = this.options.todos.length - 1, todo; i > -1 && (todo = this.options.todos[i]); i--) {
| javascript | {
"resource": ""
} | |
q47870 | train | function( type, options, element ) {
options || (options = {});
var create = Syn.create,
setup = create[type] && create[type].setup,
kind = key.test(type) ? 'key' : (page.test(type) ? "page" : "mouse"),
createType = create[type] || {},
createKind = create[kind],
event, ret, autoPrevent, dispa... | javascript | {
"resource": ""
} | |
q47871 | train | function( type, options, element ) {
//check if options is character or has character
options = typeof options != "object" ? {
character: options
} : options;
//don't change the orignial
options = h.extend({}, options)
if ( options.character ) {
h.extend(options, Syn.key.options(optio... | javascript | {
"resource": ""
} | |
q47872 | train | function (elems, context) {
var oldFragment = $.buildFragment,
ret;
elems = [elems];
// Set context per 1.8 logic
context = context || document;
context = !context.nodeType && context[0] || context;
context = context.ownerDocument | javascript | {
"resource": ""
} | |
q47873 | train | function (content) {
// Convert bad values into empty strings
var isInvalid = content === null || content === undefined || (isNaN(content) && ("" + content === 'NaN'));
| javascript | {
"resource": ""
} | |
q47874 | train | function (s) {
return s.replace(strColons, '/').replace(strWords, | javascript | {
"resource": ""
} | |
q47875 | train | function (str, data, remove) {
var obs = [];
obs.push(str.replace(strReplacer, function (whole, inside) {
// Convert inside to type.
var ob = can.getObject(inside, data, remove === undefined ? remove : !remove);
if (ob === undefined) {
... | javascript | {
"resource": ""
} | |
q47876 | train | function (result) {
var frag = can.buildFragment(result, document.body);
// If we have an empty frag... | javascript | {
"resource": ""
} | |
q47877 | train | function (src) {
return can.map(src.toString().split(/\/|\./g), function (part) {
// | javascript | {
"resource": ""
} | |
q47878 | train | function (url, async) {
var suffix = url.match(/\.[\w\d]+$/),
type,
// If we are reading a script element for the content of the template,
// `el` will be set to that script element.
el,
// A unique identifier for the view (used... | javascript | {
"resource": ""
} | |
q47879 | train | function () {
for (var name in observing) {
var ob = observing[name];
ob.observe.obj.unbind(ob.observe.attr, onchanged);
| javascript | {
"resource": ""
} | |
q47880 | train | function (ev) {
// If the compute is no longer bound (because the same change event led to an unbind)
// then do not call getValueAndBind, or we will leak bindings.
if (computeState && !computeState.bound) {
return;
}
if... | javascript | {
"resource": ""
} | |
q47881 | train | function () {
var info = getValueAndObserved(getterSetter, context),
newObserveSet = info.observed;
var value = info.value;
matched = !matched;
// go through every attribute read by this observe
can.each(newObserveSet,... | javascript | {
"resource": ""
} | |
q47882 | train | function (el, parentNode) {
// updates the text of the text node
update = function (newVal) {
node.nodeValue = "" + newVal;
teardownCheck(node.parentNode);
};
var parent = getParentNode(el, p... | javascript | {
"resource": ""
} | |
q47883 | train | function (span, parentNode) {
// updates the elements with the new content
update = function (newVal) {
// is this still part of the DOM?
var attached = nodes[0].parentNode;
// update the nodes in the DOM wit... | javascript | {
"resource": ""
} | |
q47884 | train | function (val) {
// create the fragment, but don't hook it up
// we need to insert it into the document first
var frag = can.view.frag(val, parentNode),
// keep a reference to each node
newNod... | javascript | {
"resource": ""
} | |
q47885 | getStartDate | train | function getStartDate(date, minDate, maxDate) {
let startDate = startOfDay(date);
if (minDate) {
const minDateNormalized = startOfDay(minDate);
if (isBefore(startDate, minDateNormalized)) { | javascript | {
"resource": ""
} |
q47886 | fillFrontWeek | train | function fillFrontWeek({
firstDayOfMonth,
minDate,
maxDate,
selectedDates,
firstDayOfWeek,
showOutsideDays
}) {
const dates = [];
let firstDay = (firstDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
if (showOutsideDays) {
const lastDayOfPrevMonth = addDays(firstDayOfMonth, -1);
const prevDate ... | javascript | {
"resource": ""
} |
q47887 | fillBackWeek | train | function fillBackWeek({
lastDayOfMonth,
minDate,
maxDate,
selectedDates,
firstDayOfWeek,
showOutsideDays
}) {
const dates = [];
let lastDay = (lastDayOfMonth.getDay() + 7 - firstDayOfWeek) % 7;
if (showOutsideDays) {
const firstDayOfNextMonth = addDays(lastDayOfMonth, 1);
const nextDateMonth ... | javascript | {
"resource": ""
} |
q47888 | getWeeks | train | function getWeeks(dates) {
const weeksLength = Math.ceil(dates.length / 7);
const weeks = [];
for (let i = 0; i < weeksLength; i++) {
weeks[i] = [];
| javascript | {
"resource": ""
} |
q47889 | isSelected | train | function isSelected(selectedDates, date) {
selectedDates = Array.isArray(selectedDates)
? selectedDates
: [selectedDates];
return selectedDates.some(selectedDate => {
if (
selectedDate instanceof Date && | javascript | {
"resource": ""
} |
q47890 | isSelectable | train | function isSelectable(minDate, maxDate, date) {
if (
(minDate && isBefore(date, | javascript | {
"resource": ""
} |
q47891 | extendPreventingOverrides | train | function extendPreventingOverrides (a, b) {
Object.keys(b).forEach(addContentFromBtoA)
return a
function addContentFromBtoA (key) | javascript | {
"resource": ""
} |
q47892 | t | train | function t (template, data) {
for (var key in data) {
template | javascript | {
"resource": ""
} |
q47893 | getValuesAsList | train | function getValuesAsList(value) {
return (
value
.replace(/ +/g, ' ') // remove all extraneous spaces
.split(' ')
.map(i => i.trim()) // get rid of extra space before/after each item
.filter(Boolean) // get rid of empty strings
// join items which are within parenthese
// lucki... | javascript | {
"resource": ""
} |
q47894 | handleQuartetValues | train | function handleQuartetValues(value) {
const splitValues = getValuesAsList(value)
if (splitValues.length <= 3 || splitValues.length > 4) {
return value
}
| javascript | {
"resource": ""
} |
q47895 | convert | train | function convert(object) {
return Object.keys(object).reduce((newObj, originalKey) => {
let originalValue = object[originalKey]
if (isString(originalValue)) {
// you're welcome to later code 😺
originalValue = originalValue.trim()
}
// Some properties should never be transformed
if (i... | javascript | {
"resource": ""
} |
q47896 | convertProperty | train | function convertProperty(originalKey, originalValue) {
const isNoFlip = /\/\*\s?@noflip\s?\*\//.test(originalValue)
const key = isNoFlip ? originalKey : getPropertyDoppelganger(originalKey)
| javascript | {
"resource": ""
} |
q47897 | getValueDoppelganger | train | function getValueDoppelganger(key, originalValue) {
/* eslint complexity:[2, 9] */ // let's try to keep the complexity down... If we have to do this much more, let's break this up
if (isNullOrUndefined(originalValue) || isBoolean(originalValue)) {
return originalValue
}
if (isObject(originalValue)) {
r... | javascript | {
"resource": ""
} |
q47898 | selectOSTab | train | function selectOSTab(target, osName) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get ... | javascript | {
"resource": ""
} |
q47899 | showSignUpForm | train | function showSignUpForm() {
var modal = document.getElementById('downloadModal');
// Make sure modal is in the body, not where it was originally deployed.
$("body").append($(modal))
// Get the button that opens the modal
var btn = document.getElementById("downloadBtn");
// Get the <span> element that closes ... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.