_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q58000 | getActiveFilters | train | function getActiveFilters (req, selectedFilters, data, modelName, cb) {
if (!req) {
throw new Error('req is required.');
}
if (!selectedFilters || !Array.isArray(selectedFilters) || !selectedFilters.length) {
throw new Error('selectedFilters is required and must be of type Array and cannot... | javascript | {
"resource": ""
} |
q58001 | setTabId | train | function setTabId (sections) {
sections.forEach(function (section, sectionIndex) {
if (!Array.isArray(section)) {
return;
}
section.forEach(function (tab, tabIndex) {
// Replace white space from tab.label with "-", make it lowercase and add the index number at the... | javascript | {
"resource": ""
} |
q58002 | renderCell | train | function renderCell (record, field, model, cb) {
let fieldName = (typeof field === 'object') ? field.fieldName : field,
renderer = (model.schema.tree[fieldName] && model.schema.tree[fieldName].ref && linz.api.model.getObjectIdFromRefField(record[fieldName]) instanceof linz.mongoose.Types.ObjectId) ?
... | javascript | {
"resource": ""
} |
q58003 | getOffset | train | function getOffset(offset) {
var symbol = offset.charAt(0);
var time = offset.substring(1).split(':');
var hours = Number.parseInt(time[0], 10) * 60;
var minutes = Number.parseInt(time[1], 10);
var total = Number.parseInt(symbol + (hours + minutes));
... | javascript | {
"resource": ""
} |
q58004 | getConfig | train | function getConfig(options) {
const profileOptions = {
baseUrl: get('pod.url'),
headers: {
'user-agent': `yodata/client (https://yodata.io)`,
'x-api-key': get('pod.secret')
},
hooks: {
beforeRequest: [
logRequest
],
afterResponse: [
parseResponseData
]
}
}
return defaults(options,... | javascript | {
"resource": ""
} |
q58005 | defaultRenderer | train | function defaultRenderer (data, callback) {
linz.api.views.renderPartial('action-record', data, (err, html) => {
if (err) {
return callback(err);
}
return callback(null, html);
});
} | javascript | {
"resource": ""
} |
q58006 | getContext | train | async function getContext(target, contextOptions) {
if (isURL(target)) {
const cdef = await got(target)
.then(response => {
const contentType = response.headers["content-type"]
switch (contentType) {
case 'application/x-yaml':
case 'application/x-yml':
return yaml.load(response.body)
... | javascript | {
"resource": ""
} |
q58007 | form | train | function form (req, modelName, callback, formDsl) {
const formFn = () => new Promise((resolve, reject) => {
const formLabels = labels(modelName);
const schema = get(modelName, true).schema;
if (formDsl && typeof formDsl === 'function') {
return resolve(pluginHelpers.formSettin... | javascript | {
"resource": ""
} |
q58008 | formAsPromise | train | function formAsPromise (req, modelName, formDsl) {
return new Promise((resolve, reject) => {
form(req, modelName, (err, decoratedForm) => {
if (err) {
return reject(err);
}
return resolve(decoratedForm);
}, formDsl);
});
} | javascript | {
"resource": ""
} |
q58009 | list | train | function list (req, modelName, callback) {
return get(modelName, true).getList(req, callback);
} | javascript | {
"resource": ""
} |
q58010 | permissions | train | function permissions (user, modelName, callback) {
return get(modelName, true).getPermissions(user, callback);
} | javascript | {
"resource": ""
} |
q58011 | overview | train | function overview (req, modelName, callback) {
return get(modelName, true).getOverview(req, callback);
} | javascript | {
"resource": ""
} |
q58012 | labels | train | function labels (modelName, callback) {
if (callback) {
return get(modelName, true).getLabels(callback);
}
return get(modelName, true).getLabels();
} | javascript | {
"resource": ""
} |
q58013 | titleField | train | function titleField (modelName, field, callback) {
// Make this a no-op unless the field being evaluated is `'title'`.
if (field !== 'title') {
return callback(null, field);
}
if (get(modelName, true).schema.paths[field]) {
return callback(null, field);
}
model(modelName, (err... | javascript | {
"resource": ""
} |
q58014 | compileContext | train | async function compileContext(target, contextOptions) {
const context = await getContext(target, contextOptions)
return async function (data/** @param {object} */) {
return context.map(data)
}
} | javascript | {
"resource": ""
} |
q58015 | getMaxPackageNameLength | train | function getMaxPackageNameLength (packages)
{
return Object
.keys(packages)
.reduce((max, name) => Math.max(max, name.length), 0);
} | javascript | {
"resource": ""
} |
q58016 | padding | train | function padding (packageName, maxLength)
{
const length = packageName.length;
return (length < maxLength)
? " ".repeat(maxLength - length)
: "";
} | javascript | {
"resource": ""
} |
q58017 | createServer | train | function createServer(port, f) {
f = f || noop;
http.createServer(handler).listen(port, f);
return statusHelper.changeStatus;
} | javascript | {
"resource": ""
} |
q58018 | runKaba | train | function runKaba (opts, isVerbose)
{
try
{
const logger = new Logger(kleur.bgYellow.black(" kaba "));
logger.log("kaba started");
const start = process.hrtime();
const cliConfig = new CliConfig(opts);
/** @type {Kaba} kaba */
const kaba = require(`${process.cwd()... | javascript | {
"resource": ""
} |
q58019 | sendRecursively | train | function sendRecursively(event, currentState, isUnhandledPass) {
var log = this.enableLogging,
eventName = isUnhandledPass ? 'unhandledEvent' : event,
action = currentState[eventName],
contexts, sendRecursiveArguments, actionArguments;
contexts = [].slice.call(arguments, 3);
// Test to see if ... | javascript | {
"resource": ""
} |
q58020 | sendEvent | train | function sendEvent(eventName, sendRecursiveArguments, isUnhandledPass) {
sendRecursiveArguments.unshift(eventName, this.get('currentState'), isUnhandledPass);
return sendRecursively.apply(this, sendRecursiveArguments);
} | javascript | {
"resource": ""
} |
q58021 | changeEntireFormValue | train | function changeEntireFormValue ({model, nextValue, prevValue}) {
return {
value: immutableOnce(recursiveClean(nextValue, model)),
valueChangeSet: getChangeSet(prevValue, nextValue)
}
} | javascript | {
"resource": ""
} |
q58022 | changeNestedFormValue | train | function changeNestedFormValue ({bunsenId, formValue, model, value}) {
const segments = bunsenId.split('.')
const lastSegment = segments.pop()
const isEmpty = _.isEmpty(value) && (Array.isArray(value) || _.isObject(value)) && !(value instanceof File)
// Make sure form value is immutable
formValue = immutable... | javascript | {
"resource": ""
} |
q58023 | unsetProperty | train | function unsetProperty ({bunsenId, formValue, value}) {
const valueChangeSet = new Map()
valueChangeSet.set(bunsenId, {
value,
type: 'unset'
})
return {
value: unset(formValue, bunsenId),
valueChangeSet
}
} | javascript | {
"resource": ""
} |
q58024 | train | function (state, action) {
// Apply coniditions to view cells
let normalized
let view
if (state.unnormalizedModel) {
normalized = normalizeModelAndView({
model: state.unnormalizedModel,
view: action.view
})
view = evaluateViewConditions(normalized.view, state.value)
... | javascript | {
"resource": ""
} | |
q58025 | getCounts | validation | function getCounts(langs = []) {
return {
langs: langs.length,
modelLangs: langs.filter(({ models }) => models && !!models.length).length,
models: langs.map(({ models }) => (models ? models.length : 0)).reduce((a, b) => a + b, 0),
}
} | javascript | {
"resource": ""
} |
q58026 | className | validation | function className(node, value){
var klass = node.className || '',
svg = klass && klass.baseVal !== undefined
if (value === undefined) return svg ? klass.baseVal : klass
svg ? (klass.baseVal = value) : (node.className = value)
} | javascript | {
"resource": ""
} |
q58027 | deserializeValue | validation | function deserializeValue(value) {
try {
return value ?
value == "true" ||
( value == "false" ? false :
value == "null" ? null :
+value + "" == value ? +value :
/^[\[\{]/.test(value) ? $.parseJSON(value) :
value )
: value
} catch(e) {
r... | javascript | {
"resource": ""
} |
q58028 | getHighlightOptions | validation | function getHighlightOptions(config, arg) {
let lang = '';
if (rLang.test(arg)) {
arg = arg.replace(rLang, (match, _lang) => {
lang = _lang;
return '';
});
}
let line_number = config.line_number;
if (rLineNumber.test(arg)) {
arg = arg.replace(rLineNumber, (match, _line_number) => {
... | javascript | {
"resource": ""
} |
q58029 | pipeStream | validation | function pipeStream(...args) {
const src = args.shift();
return new Promise((resolve, reject) => {
let stream = src.on('error', reject);
let target;
while ((target = args.shift()) != null) {
stream = stream.pipe(target).on('error', reject);
}
stream.on('finish', resolve);
stream.on(... | javascript | {
"resource": ""
} |
q58030 | formatNunjucksError | validation | function formatNunjucksError(err, input) {
const match = err.message.match(/Line (\d+), Column \d+/);
if (!match) return err;
const errLine = parseInt(match[1], 10);
if (isNaN(errLine)) return err;
// trim useless info from Nunjucks Error
const splited = err.message.replace('(unknown path)', '').split('\n'... | javascript | {
"resource": ""
} |
q58031 | validation | function (event, context, responseStatus, physicalResourceId, responseData, reason) {
return new Promise((resolve, reject) => {
const https = require('https');
const { URL } = require('url');
var responseBody = JSON.stringify({
Status: responseStatus,
Reason: reason,
PhysicalResourceId:... | javascript | {
"resource": ""
} | |
q58032 | getAdopter | validation | async function getAdopter(name) {
try {
const policyResponse = await ecr.getRepositoryPolicy({ repositoryName: name }).promise();
const policy = JSON.parse(policyResponse.policyText);
// Search the policy for an adopter marker
return (policy.Statement || []).find((x) => x.Action ==... | javascript | {
"resource": ""
} |
q58033 | calculateLineHeight | validation | function calculateLineHeight(model, columnWidths) {
var padding = this.internal.__cell__.padding;
var fontSize = this.internal.__cell__.table_font_size;
var scaleFactor = this.internal.scaleFactor;
return Object.keys(model)
.map(function (value) {return typeof value === 'obj... | javascript | {
"resource": ""
} |
q58034 | makeWorker | validation | function makeWorker(script) {
var URL = window.URL || window.webkitURL;
var Blob = window.Blob;
var Worker = window.Worker;
if (!URL || !Blob || !Worker || !script) {
return null;
}
var blob = new Blob([script]);
var worker = new Worker(URL.createObj... | javascript | {
"resource": ""
} |
q58035 | monkeyPatch | validation | function monkeyPatch() {
return {
transform: (code, id) => {
var file = id.split('/').pop()
// Only one define call per module is allowed by requirejs so
// we have to remove calls that other libraries make
if (file === 'FileSaver.js') {
code = code.replace(/define !== nul... | javascript | {
"resource": ""
} |
q58036 | rawjs | validation | function rawjs(opts) {
opts = opts || {}
return {
transform: (code, id) => {
var variable = opts[id.split('/').pop()]
if (!variable) return code
var keepStr = '/*rollup-keeper-start*/window.tmp=' + variable +
';/*rollup-keeper-end*/'
return code + keepStr
},
t... | javascript | {
"resource": ""
} |
q58037 | validation | function (tagName, opt) {
var el = document.createElement(tagName);
if (opt.className) el.className = opt.className;
if (opt.innerHTML) {
el.innerHTML = opt.innerHTML;
var scripts = el.getElementsByTagName('script');
for (var i = scripts.length; i-- > 0;) {
scripts[i].parentNode.re... | javascript | {
"resource": ""
} | |
q58038 | tr_init | validation | function tr_init() {
l_desc.dyn_tree = dyn_ltree;
l_desc.stat_desc = StaticTree.static_l_desc;
d_desc.dyn_tree = dyn_dtree;
d_desc.stat_desc = StaticTree.static_d_desc;
bl_desc.dyn_tree = bl_tree;
bl_desc.stat_desc = StaticTree.static_bl_desc;
bi_buf = 0;
bi_valid = 0;
last_eob_len = 8; /... | javascript | {
"resource": ""
} |
q58039 | _tr_tally | validation | function _tr_tally(dist, // distance of matched string
lc // match length-MIN_MATCH or unmatched char (if dist==0)
) {
var out_length, in_length, dcode;
that.pending_buf[d_buf + last_lit * 2] = (dist >>> 8) & 0xff;
that.pending_buf[d_buf + last_lit * 2 + 1] = dist & 0xff;
that.pending_buf[l_buf + last_... | javascript | {
"resource": ""
} |
q58040 | compress_block | validation | function compress_block(ltree, dtree) {
var dist; // distance of matched string
var lc; // match length or unmatched char (if dist === 0)
var lx = 0; // running index in l_buf
var code; // the code to send
var extra; // number of extra bits to send
if (last_lit !== 0) {
do {
dist = ((that.pe... | javascript | {
"resource": ""
} |
q58041 | copy_block | validation | function copy_block(buf, // the input data
len, // its length
header // true if block header must be written
) {
bi_windup(); // align on byte boundary
last_eob_len = 8; // enough lookahead for inflate
if (header) {
put_short(len);
put_short(~len);
}
that.pending_buf.set(window.subarray(b... | javascript | {
"resource": ""
} |
q58042 | _tr_stored_block | validation | function _tr_stored_block(buf, // input block
stored_len, // length of input block
eof // true if this is the last block for a file
) {
send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type
copy_block(buf, stored_len, true); // with header
} | javascript | {
"resource": ""
} |
q58043 | validation | function (style) {
var rxRgb = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;
var rxRgba = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/;
var rxTransparent = /transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/;
var r, g, b, a;
if (style.isC... | javascript | {
"resource": ""
} | |
q58044 | validation | function (y) {
if (this.pageWrapYEnabled) {
this.lastBreak = 0;
var manualBreaks = 0;
var autoBreaks = 0;
for (var i = 0; i < this.pageBreaks.length; i++) {
if (y >= this.pageBreaks[i]) {
manualBreaks++;
if (... | javascript | {
"resource": ""
} | |
q58045 | validation | function (ax, ay, bx, by, cx, cy, dx, dy) {
var tobx = bx - ax;
var toby = by - ay;
var tocx = cx - bx;
var tocy = cy - by;
var todx = dx - cx;
var tody = dy - cy;
var precision = 40;
var d, i, px, py, qx, qy, rx, ry, tx, ty, sx, sy, x, y, minx, miny, maxx... | javascript | {
"resource": ""
} | |
q58046 | validation | function (pageInfo) {
var pageNumber = pageInfo !== undefined ? pageInfo.pageNumber : 1;
//set current y position to old margin
var oldPosition = renderer.y;
//render all child nodes of the header element
renderer.y = renderer.pdf.internal.pageSize.getHeight() - renderer.pdf.margins_doc.bottom;
... | javascript | {
"resource": ""
} | |
q58047 | getFont | validation | function getFont(fontName, fontStyle, options) {
var key = undefined,
fontNameLowerCase;
options = options || {};
fontName = fontName !== undefined ? fontName : fonts[activeFontKey].fontName;
fontStyle = fontStyle !== undefined ? fontStyle : fonts[activeFontKey].fontStyle;
fontNa... | javascript | {
"resource": ""
} |
q58048 | calculateFontSpace | validation | function calculateFontSpace(text, formObject, fontSize) {
var font = scope.internal.getFont(formObject.fontName, formObject.fontStyle);
var width = scope.getStringUnitWidth(text, {
font: font,
fontSize: parseFloat(fontSize),
charSpace: 0
}) * parseFloat(fontSize);
var height = scope.ge... | javascript | {
"resource": ""
} |
q58049 | YesPushDown | validation | function YesPushDown(formObject) {
var xobj = createFormXObject(formObject);
var stream = [];
var fontKey = scope.internal.getFont(formObject.fontName, formObject.fontStyle).id;
var encodedColor = scope.__private__.encodeColorString(formObject.color);
var calcRes = calculateX(f... | javascript | {
"resource": ""
} |
q58050 | OffPushDown | validation | function OffPushDown(formObject) {
var xobj = createFormXObject(formObject);
var stream = [];
stream.push("0.749023 g");
stream.push("0 0 " + f2(AcroFormAppearance.internal.getWidth(formObject)) + " " + f2(AcroFormAppearance.internal.getHeight(formObject)) + " re");
stream.push("... | javascript | {
"resource": ""
} |
q58051 | createDefaultAppearanceStream | validation | function createDefaultAppearanceStream(formObject) {
// Set Helvetica to Standard Font (size: auto)
// Color: Black
var fontKey = scope.internal.getFont(formObject.fontName, formObject.fontStyle).id;
var encodedColor = scope.__private__.encodeColorString(formObject.color);
var fontSize =... | javascript | {
"resource": ""
} |
q58052 | splitLongWord | validation | function splitLongWord(word, widths_array, firstLineMaxLen, maxLen) {
var answer = []; // 1st, chop off the piece that can fit on the hanging line.
var i = 0,
l = word.length,
workingLen = 0;
while (i !== l && workingLen + widths_array[i] < firstLineMaxLen) {
workingLen += widths_arr... | javascript | {
"resource": ""
} |
q58053 | splitParagraphIntoLines | validation | function splitParagraphIntoLines(text, maxlen, options) {
// at this time works only on Western scripts, ones with space char
// separating the words. Feel free to expand.
if (!options) {
options = {};
}
var line = [],
lines = [line],
line_length = options.textIndent || 0,
... | javascript | {
"resource": ""
} |
q58054 | bi_flush | validation | function bi_flush() {
if (bi_valid == 16) {
put_short(bi_buf);
bi_buf = 0;
bi_valid = 0;
} else if (bi_valid >= 8) {
put_byte(bi_buf & 0xff);
bi_buf >>>= 8;
bi_valid -= 8;
}
} | javascript | {
"resource": ""
} |
q58055 | GifWriterOutputLZWCodeStream | validation | function GifWriterOutputLZWCodeStream(buf, p, min_code_size, index_stream) {
buf[p++] = min_code_size;
var cur_subblock = p++; // Pointing at the length field.
var clear_code = 1 << min_code_size;
var code_mask = clear_code - 1;
var eoi_code = clear_code + 1;
var next_code = eoi_code + 1;
var cur_code_... | javascript | {
"resource": ""
} |
q58056 | mapArrayBufferViews | validation | function mapArrayBufferViews(ary) {
return ary.map(function(chunk) {
if (chunk.buffer instanceof ArrayBuffer) {
var buf = chunk.buffer;
// if this is a subarray, make a copy so we only
// include the subarray region from the underlying buffer
if (chunk.byteLength !== buf.byteL... | javascript | {
"resource": ""
} |
q58057 | promptUser | validation | function promptUser() {
return inquirer.prompt([
{
type: "list",
name: "env",
message: "Where does your code run?",
default: ["browser"],
choices: [
{ name: "Browser", value: "browser" },
{ name: "Node", value: "node... | javascript | {
"resource": ""
} |
q58058 | validation | function (imgData) {
var doc = new jsPDF();
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50);
doc.addImage(imgData, 'JPEG', 70, 10, 100, 120);
doc.save('output.pdf');
} | javascript | {
"resource": ""
} | |
q58059 | parseId | validation | function parseId(url) {
if (is.empty(url)) {
return null;
}
const regex = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
return url.match(regex) ? RegExp.$2 : url;
} | javascript | {
"resource": ""
} |
q58060 | isSameException | validation | function isSameException(ex1, ex2) {
if (isOnlyOneTruthy(ex1, ex2)) return false;
ex1 = ex1.values[0];
ex2 = ex2.values[0];
if (ex1.type !== ex2.type || ex1.value !== ex2.value) return false; // in case both stacktraces are undefined, we can't decide so default to false
if (isBothUndefined(ex1.stacktrac... | javascript | {
"resource": ""
} |
q58061 | isSameStacktrace | validation | function isSameStacktrace(stack1, stack2) {
if (isOnlyOneTruthy(stack1, stack2)) return false;
var frames1 = stack1.frames;
var frames2 = stack2.frames; // Exit early if stacktrace is malformed
if (frames1 === undefined || frames2 === undefined) return false; // Exit early if frame count differs
if (fr... | javascript | {
"resource": ""
} |
q58062 | fill | validation | function fill(obj, name, replacement, track) {
if (obj == null) return;
var orig = obj[name];
obj[name] = replacement(orig);
obj[name].__raven__ = true;
obj[name].__orig__ = orig;
if (track) {
track.push([obj, name, orig]);
}
} | javascript | {
"resource": ""
} |
q58063 | safeJoin | validation | function safeJoin(input, delimiter) {
if (!isArray(input)) return '';
var output = [];
for (var i = 0; i < input.length; i++) {
try {
output.push(String(input[i]));
} catch (e) {
output.push('[value cannot be serialized]');
}
}
return output.join(delimiter);
} | javascript | {
"resource": ""
} |
q58064 | notifyHandlers | validation | function notifyHandlers(stack, isWindowError) {
var exception = null;
if (isWindowError && !TraceKit.collectWindowErrors) {
return;
}
for (var i in handlers) {
if (handlers.hasOwnProperty(i)) {
try {
handlers[i].apply(null, [stack].concat(_slice.call(arguments, 2)... | javascript | {
"resource": ""
} |
q58065 | traceKitWindowOnError | validation | function traceKitWindowOnError(msg, url, lineNo, colNo, ex) {
var stack = null; // If 'ex' is ErrorEvent, get real Error from inside
var exception = utils.isErrorEvent(ex) ? ex.error : ex; // If 'msg' is ErrorEvent, get real message from inside
var message = utils.isErrorEvent(msg) ? msg.message : msg;... | javascript | {
"resource": ""
} |
q58066 | report | validation | function report(ex, rethrow) {
var args = _slice.call(arguments, 1);
if (lastExceptionStack) {
if (lastException === ex) {
return; // already caught by an inner catch block, ignore
} else {
processLastException();
}
}
var stack = TraceKit.computeStackTrace(ex... | javascript | {
"resource": ""
} |
q58067 | augmentStackTraceWithInitialElement | validation | function augmentStackTraceWithInitialElement(stackInfo, url, lineNo, message) {
var initial = {
url: url,
line: lineNo
};
if (initial.url && initial.line) {
stackInfo.incomplete = false;
if (!initial.func) {
initial.func = UNKNOWN_FUNCTION;
}
if (stac... | javascript | {
"resource": ""
} |
q58068 | computeStackTrace | validation | function computeStackTrace(ex, depth) {
var stack = null;
depth = depth == null ? 0 : +depth;
try {
stack = computeStackTraceFromStackProp(ex);
if (stack) {
return stack;
}
} catch (e) {
if (TraceKit.debug) {
throw e;
}
}
try {
... | javascript | {
"resource": ""
} |
q58069 | _promiseRejectionHandler | validation | function _promiseRejectionHandler(event) {
this._logDebug('debug', 'Raven caught unhandled promise rejection:', event);
this.captureException(event.reason, {
mechanism: {
type: 'onunhandledrejection',
handled: false
}
});
} | javascript | {
"resource": ""
} |
q58070 | captureException | validation | function captureException(ex, options) {
options = objectMerge$1({
trimHeadFrames: 0
}, options ? options : {});
if (isErrorEvent$1(ex) && ex.error) {
// If it is an ErrorEvent with `error` property, extract it to get actual Error
ex = ex.error;
} else if (isDOMError$1(ex) || i... | javascript | {
"resource": ""
} |
q58071 | _breadcrumbEventHandler | validation | function _breadcrumbEventHandler(evtName) {
var self = this;
return function (evt) {
// reset keypress timeout; e.g. triggering a 'click' after
// a 'keypress' will reset the keypress debounce so that a new
// set of keypresses can be recorded
self._keypressTimeout = null; // It's ... | javascript | {
"resource": ""
} |
q58072 | _captureUrlChange | validation | function _captureUrlChange(from, to) {
var parsedLoc = parseUrl$1(this._location.href);
var parsedTo = parseUrl$1(to);
var parsedFrom = parseUrl$1(from); // because onpopstate only tells you the "new" (to) value of location.href, and
// not the previous (from) value, we need to track the value of th... | javascript | {
"resource": ""
} |
q58073 | _isRepeatData | validation | function _isRepeatData(current) {
var last = this._lastData;
if (!last || current.message !== last.message || // defined for captureMessage
current.transaction !== last.transaction // defined for captureException/onerror
) return false; // Stacktrace interface (i.e. from captureMessage)
if (cu... | javascript | {
"resource": ""
} |
q58074 | getDecimalPlaces | validation | function getDecimalPlaces(value) {
var match = "".concat(value).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
if (!match) {
return 0;
}
return Math.max(0, // Number of digits right of decimal point.
(match[1] ? match[1].length : 0) - ( // Adjust for scientific notation.
match[2] ? +match[2] : 0));... | javascript | {
"resource": ""
} |
q58075 | round | validation | function round(number, step) {
if (step < 1) {
var places = getDecimalPlaces(step);
return parseFloat(number.toFixed(places));
}
return Math.round(number / step) * step;
} | javascript | {
"resource": ""
} |
q58076 | RangeTouch | validation | function RangeTouch(target, options) {
_classCallCheck(this, RangeTouch);
if (is.element(target)) {
// An Element is passed, use it directly
this.element = target;
} else if (is.string(target)) {
// A CSS Selector is passed, fetch it from the DOM
this.element = document.query... | javascript | {
"resource": ""
} |
q58077 | setup | validation | function setup(target) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var targets = null;
if (is.empty(target) || is.string(target)) {
targets = Array.from(document.querySelectorAll(is.string(target) ? target : 'input[type="range"]'));
} els... | javascript | {
"resource": ""
} |
q58078 | toggleListener | validation | function toggleListener(element, event, callback) {
var _this = this;
var toggle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var passive = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
var capture = arguments.length > 5 && arguments[5] !== undefi... | javascript | {
"resource": ""
} |
q58079 | on | validation | function on(element) {
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var callback = arguments.length > 2 ? arguments[2] : undefined;
var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
var capture = arguments.length > 4 && arguments[... | javascript | {
"resource": ""
} |
q58080 | once | validation | function once(element) {
var _this2 = this;
var events = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var callback = arguments.length > 2 ? arguments[2] : undefined;
var passive = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
var capture = arguments... | javascript | {
"resource": ""
} |
q58081 | unbindListeners | validation | function unbindListeners() {
if (this && this.eventListeners) {
this.eventListeners.forEach(function (item) {
var element = item.element,
type = item.type,
callback = item.callback,
options = item.options;
element.removeEventListener(type, callback, options);
... | javascript | {
"resource": ""
} |
q58082 | getDeep | validation | function getDeep(object, path) {
return path.split('.').reduce(function (obj, key) {
return obj && obj[key];
}, object);
} | javascript | {
"resource": ""
} |
q58083 | extend | validation | function extend() {
var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
sources[_key - 1] = arguments[_key];
}
if (!sources.length) {
return target;
... | javascript | {
"resource": ""
} |
q58084 | createElement | validation | function createElement(type, attributes, text) {
// Create a new <element>
var element = document.createElement(type); // Set all passed attributes
if (is$1.object(attributes)) {
setAttributes(element, attributes);
} // Add text node
if (is$1.string(text)) {
element.innerText = text;
} //... | javascript | {
"resource": ""
} |
q58085 | insertAfter | validation | function insertAfter(element, target) {
if (!is$1.element(element) || !is$1.element(target)) {
return;
}
target.parentNode.insertBefore(element, target.nextSibling);
} | javascript | {
"resource": ""
} |
q58086 | insertElement | validation | function insertElement(type, parent, attributes, text) {
if (!is$1.element(parent)) {
return;
}
parent.appendChild(createElement(type, attributes, text));
} | javascript | {
"resource": ""
} |
q58087 | emptyElement | validation | function emptyElement(element) {
if (!is$1.element(element)) {
return;
}
var length = element.childNodes.length;
while (length > 0) {
element.removeChild(element.lastChild);
length -= 1;
}
} | javascript | {
"resource": ""
} |
q58088 | getAttributesFromSelector | validation | function getAttributesFromSelector(sel, existingAttributes) {
// For example:
// '.test' to { class: 'test' }
// '#test' to { id: 'test' }
// '[data-test="test"]' to { 'data-test': 'test' }
if (!is$1.string(sel) || is$1.empty(sel)) {
return {};
}
var attributes = {};
var existing = extend(... | javascript | {
"resource": ""
} |
q58089 | toggleClass | validation | function toggleClass(element, className, force) {
if (is$1.nodeList(element)) {
return Array.from(element).map(function (e) {
return toggleClass(e, className, force);
});
}
if (is$1.element(element)) {
var method = 'toggle';
if (typeof force !== 'undefined') {
method = force... | javascript | {
"resource": ""
} |
q58090 | hasClass | validation | function hasClass(element, className) {
return is$1.element(element) && element.classList.contains(className);
} | javascript | {
"resource": ""
} |
q58091 | matches$1 | validation | function matches$1(element, selector) {
function match() {
return Array.from(document.querySelectorAll(selector)).includes(this);
}
var matches = match;
return matches.call(element, selector);
} | javascript | {
"resource": ""
} |
q58092 | trapFocus | validation | function trapFocus() {
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var toggle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (!is$1.element(element)) {
return;
}
var focusable = getElements.call(this, 'button:not(:disable... | javascript | {
"resource": ""
} |
q58093 | setFocus | validation | function setFocus() {
var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var tabFocus = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
if (!is$1.element(element)) {
return;
} // Set regular focus
element.focus({
preventScroll: ... | javascript | {
"resource": ""
} |
q58094 | repaint | validation | function repaint(element) {
setTimeout(function () {
try {
toggleHidden(element, true);
element.offsetHeight; // eslint-disable-line
toggleHidden(element, false);
} catch (e) {// Do nothing
}
}, 0);
} | javascript | {
"resource": ""
} |
q58095 | check | validation | function check(type, provider, playsinline) {
var canPlayInline = browser.isIPhone && playsinline && support.playsinline;
var api = support[type] || provider !== 'html5';
var ui = api && support.rangeInput && (type !== 'video' || !browser.isIPhone || canPlayInline);
return {
api: api,
... | javascript | {
"resource": ""
} |
q58096 | setAspectRatio | validation | function setAspectRatio(input) {
if (!this.isVideo) {
return {};
}
var ratio = getAspectRatio.call(this, input);
var _ref = is$1.array(ratio) ? ratio : [0, 0],
_ref2 = _slicedToArray(_ref, 2),
w = _ref2[0],
h = _ref2[1];
var padding = 100 / w * h;
this.elements.wrapper.sty... | javascript | {
"resource": ""
} |
q58097 | getQualityOptions | validation | function getQualityOptions() {
// Get sizes from <source> elements
return html5.getSources.call(this).map(function (source) {
return Number(source.getAttribute('size'));
}).filter(Boolean);
} | javascript | {
"resource": ""
} |
q58098 | closest | validation | function closest(array, value) {
if (!is$1.array(array) || !array.length) {
return null;
}
return array.reduce(function (prev, curr) {
return Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev;
});
} | javascript | {
"resource": ""
} |
q58099 | replaceAll | validation | function replaceAll() {
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var find = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var replace = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
return input.replace(new RegExp... | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.