_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q25900 | inclination | train | function inclination( vector ) {
return Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );
} | javascript | {
"resource": ""
} |
q25901 | _mergeListInfo | train | function _mergeListInfo(list) {
var arr = [];
var info = {};
for(var i=0,len=list.length; i<len; i++) {
arr.push('<li data-value="'+list[i].value+'">' + list[i].name + '</li>');
info[i] = list[i].list ? _mergeListInfo(list[i].list) : {length: 0}... | javascript | {
"resource": ""
} |
q25902 | Redis | train | function Redis(nsp){
Adapter.call(this, nsp);
this.uid = uid;
this.prefix = prefix;
this.requestsTimeout = requestsTimeout;
this.channel = prefix + '#' + nsp.name + '#';
this.requestChannel = prefix + '-request#' + this.nsp.name + '#';
this.responseChannel = prefix + '-response#' + this.ns... | javascript | {
"resource": ""
} |
q25903 | Dummy | train | function Dummy() {
"use strict";
this.colorize = function colorize(text, styleName, pad) {
return text;
};
this.format = function format(text, style, pad){
return text;
};
} | javascript | {
"resource": ""
} |
q25904 | generateClassName | train | function generateClassName(classname) {
"use strict";
classname = (classname || "").replace(phantom.casperPath, "").trim();
var script = classname || phantom.casperScript || "";
if (script.indexOf(fs.workingDirectory) === 0) {
script = script.substring(fs.workingDirectory.length + 1);
}
... | javascript | {
"resource": ""
} |
q25905 | printHelp | train | function printHelp() {
/* global slimer */
var engine = phantom.casperEngine === 'slimerjs' ? slimer : phantom;
var version = [engine.version.major, engine.version.minor, engine.version.patch].join('.');
return __terminate([
'CasperJS version ' + phantom.casperVersion.toStrin... | javascript | {
"resource": ""
} |
q25906 | check | train | function check() {
if (links[currentLink] && currentLink < upTo) {
this.echo('--- Link ' + currentLink + ' ---');
start.call(this, links[currentLink]);
addLinks.call(this, links[currentLink]);
currentLink++;
this.run(check);
} else {
this.echo("All done.");
... | javascript | {
"resource": ""
} |
q25907 | castArgument | train | function castArgument(arg) {
"use strict";
if (arg.match(/^-?\d+$/)) {
return parseInt(arg, 10);
} else if (arg.match(/^-?\d+\.\d+$/)) {
return parseFloat(arg);
} else if (arg.match(/^(true|false)$/i)) {
return arg.trim().toLowerCase() === "true" ? true : false;
} else {
... | javascript | {
"resource": ""
} |
q25908 | betterTypeOf | train | function betterTypeOf(input) {
"use strict";
switch (input) {
case undefined:
return 'undefined';
case null:
return 'null';
default:
try {
var type = Object.prototype.toString.call(input).match(/^\[object\s(.*)\]$/)[1].toLowerCase();
... | javascript | {
"resource": ""
} |
q25909 | betterInstanceOf | train | function betterInstanceOf(input, constructor) {
"use strict";
/*eslint eqeqeq:0 */
if (typeof input == 'undefined' || input == null) {
return false;
}
var inputToTest = input;
while (inputToTest != null) {
if (inputToTest == constructor.prototype) {
return true;
}
... | javascript | {
"resource": ""
} |
q25910 | cleanUrl | train | function cleanUrl(url) {
"use strict";
if (url.toLowerCase().indexOf('http') !== 0) {
return url;
}
var a = document.createElement('a');
a.href = url;
return a.href;
} | javascript | {
"resource": ""
} |
q25911 | computeModifier | train | function computeModifier(modifierString, modifiers) {
"use strict";
var modifier = 0,
checkKey = function(key) {
if (key in modifiers) return;
throw new CasperError(format('%s is not a supported key modifier', key));
};
if (!modifierString) return modifier;
var ke... | javascript | {
"resource": ""
} |
q25912 | equals | train | function equals(v1, v2) {
"use strict";
if (isFunction(v1)) {
return v1.toString() === v2.toString();
}
// with Gecko, instanceof is not enough to test object
if (v1 instanceof Object || isObject(v1)) {
if (!(v2 instanceof Object || isObject(v2)) ||
Object.keys(v1).length... | javascript | {
"resource": ""
} |
q25913 | fillBlanks | train | function fillBlanks(text, pad) {
"use strict";
pad = pad || 80;
if (text.length < pad) {
text += new Array(pad - text.length + 1).join(' ');
}
return text;
} | javascript | {
"resource": ""
} |
q25914 | getPropertyPath | train | function getPropertyPath(obj, path) {
"use strict";
if (!isObject(obj) || !isString(path)) {
return undefined;
}
var value = obj;
path.split('.').forEach(function(property) {
if (typeof value === "object" && property in value) {
value = value[property];
} else {
... | javascript | {
"resource": ""
} |
q25915 | indent | train | function indent(string, nchars, prefix) {
"use strict";
return string.split('\n').map(function(line) {
return (prefix || '') + new Array(nchars).join(' ') + line;
}).join('\n');
} | javascript | {
"resource": ""
} |
q25916 | isClipRect | train | function isClipRect(value) {
"use strict";
return isType(value, "cliprect") || (
isObject(value) &&
isNumber(value.top) && isNumber(value.left) &&
isNumber(value.width) && isNumber(value.height)
);
} | javascript | {
"resource": ""
} |
q25917 | isType | train | function isType(what, typeName) {
"use strict";
if (typeof typeName !== "string" || !typeName) {
throw new CasperError("You must pass isType() a typeName string");
}
return betterTypeOf(what).toLowerCase() === typeName.toLowerCase();
} | javascript | {
"resource": ""
} |
q25918 | isValidSelector | train | function isValidSelector(value) {
"use strict";
if (isString(value)) {
try {
// phantomjs env has a working document object, let's use it
document.querySelector(value);
} catch(e) {
if ('name' in e && (e.name === 'SYNTAX_ERR' || e.name === 'SyntaxError')) {
... | javascript | {
"resource": ""
} |
q25919 | mergeObjectsInGecko | train | function mergeObjectsInGecko(origin, add, opts) {
"use strict";
var options = opts || {},
keepReferences = options.keepReferences;
for (var p in add) {
if (isPlainObject(add[p])) {
if (isPlainObject(origin[p])) {
origin[p] = mergeObjects(origin[p], add[p]);
... | javascript | {
"resource": ""
} |
q25920 | serialize | train | function serialize(value, indent) {
"use strict";
if (isArray(value)) {
value = value.map(function _map(prop) {
return isFunction(prop) ? prop.toString().replace(/\s{2,}/, '') : prop;
});
}
return JSON.stringify(value, null, indent);
} | javascript | {
"resource": ""
} |
q25921 | unique | train | function unique(array) {
"use strict";
var o = {},
r = [];
for (var i = 0, len = array.length; i !== len; i++) {
var d = array[i];
if (typeof o[d] === "undefined") {
o[d] = 1;
r[r.length] = d;
}
}
return r;
} | javascript | {
"resource": ""
} |
q25922 | versionToString | train | function versionToString(version) {
if (isObject(version)) {
try {
return [version.major, version.minor, version.patch].join('.');
} catch (e) {}
}
return version;
} | javascript | {
"resource": ""
} |
q25923 | matchEngine | train | function matchEngine(matchSpec) {
if (Array !== matchSpec.constructor) {
matchSpec = [matchSpec];
}
var idx;
var len = matchSpec.length;
var engineName = phantom.casperEngine;
var engineVersion = phantom.version;
for (idx = 0; idx < len; ++idx) {
var match = matchSpec[idx];... | javascript | {
"resource": ""
} |
q25924 | schedule | train | function schedule(expression, func, options) {
let task = createTask(expression, func, options);
storage.save(task);
return task;
} | javascript | {
"resource": ""
} |
q25925 | getImageNaturalSizes | train | function getImageNaturalSizes(image, callback) {
var newImage = document.createElement('img');
// Modern browsers (except Safari)
if (image.naturalWidth && !IS_SAFARI) {
callback(image.naturalWidth, image.naturalHeight);
return newImage;
}
var body = document.body || document.documentElement;
new... | javascript | {
"resource": ""
} |
q25926 | onViewed | train | function onViewed() {
var imageData = _this.imageData;
title.textContent = alt + ' (' + imageData.naturalWidth + ' \xD7 ' + imageData.naturalHeight + ')';
} | javascript | {
"resource": ""
} |
q25927 | prev | train | function prev() {
var loop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var index = this.index - 1;
if (index < 0) {
index = loop ? this.length - 1 : 0;
}
this.view(index);
return this;
} | javascript | {
"resource": ""
} |
q25928 | next | train | function next() {
var loop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var maxIndex = this.length - 1;
var index = this.index + 1;
if (index > maxIndex) {
index = loop ? 0 : maxIndex;
}
this.view(index);
return this;
} | javascript | {
"resource": ""
} |
q25929 | move | train | function move(offsetX, offsetY) {
var imageData = this.imageData;
this.moveTo(isUndefined(offsetX) ? offsetX : imageData.left + Number(offsetX), isUndefined(offsetY) ? offsetY : imageData.top + Number(offsetY));
return this;
} | javascript | {
"resource": ""
} |
q25930 | moveTo | train | function moveTo(x) {
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
var imageData = this.imageData;
x = Number(x);
y = Number(y);
if (this.viewed && !this.played && this.options.movable) {
var changed = false;
if (isNumber(x)) {
imageData.left ... | javascript | {
"resource": ""
} |
q25931 | zoom | train | function zoom(ratio) {
var hasTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var _originalEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var imageData = this.imageData;
ratio = Number(ratio);
if (ratio < 0) {
ratio =... | javascript | {
"resource": ""
} |
q25932 | zoomTo | train | function zoomTo(ratio) {
var hasTooltip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var _originalEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var _zoomable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
... | javascript | {
"resource": ""
} |
q25933 | rotateTo | train | function rotateTo(degree) {
var imageData = this.imageData;
degree = Number(degree);
if (isNumber(degree) && this.viewed && !this.played && this.options.rotatable) {
imageData.rotate = degree;
this.renderImage();
}
return this;
} | javascript | {
"resource": ""
} |
q25934 | scale | train | function scale(scaleX) {
var scaleY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scaleX;
var imageData = this.imageData;
scaleX = Number(scaleX);
scaleY = Number(scaleY);
if (this.viewed && !this.played && this.options.scalable) {
var changed = false;
if (isN... | javascript | {
"resource": ""
} |
q25935 | play | train | function play() {
var _this2 = this;
var fullscreen = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
if (!this.isShown || this.played) {
return this;
}
var options = this.options,
player = this.player;
var onLoad = this.loadImage.bind(this);
var ... | javascript | {
"resource": ""
} |
q25936 | tooltip | train | function tooltip() {
var _this6 = this;
var options = this.options,
tooltipBox = this.tooltipBox,
imageData = this.imageData;
if (!this.viewed || this.played || !options.tooltip) {
return this;
}
tooltipBox.textContent = Math.round(imageData.ratio * 100) + '%';
if (!th... | javascript | {
"resource": ""
} |
q25937 | update | train | function update() {
var element = this.element,
options = this.options,
isImg = this.isImg;
// Destroy viewer if the target image was deleted
if (isImg && !element.parentNode) {
return this.destroy();
}
var images = [];
forEach(isImg ? [element] : element.querySelectorA... | javascript | {
"resource": ""
} |
q25938 | destroy | train | function destroy() {
var element = this.element,
options = this.options;
if (!getData(element, NAMESPACE)) {
return this;
}
this.destroyed = true;
if (this.ready) {
if (this.played) {
this.stop();
}
if (options.inline) {
if (this.fulled) {
... | javascript | {
"resource": ""
} |
q25939 | Viewer | train | function Viewer(element) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
classCallCheck(this, Viewer);
if (!element || element.nodeType !== 1) {
throw new Error('The first argument is required and must be an element.');
}
this.element = element;
th... | javascript | {
"resource": ""
} |
q25940 | read | train | function read(element) {
// normalized style
var style = {
alignContent: 'stretch',
alignItems: 'stretch',
alignSelf: 'auto',
borderBottomStyle: 'none',
borderBottomWidth: 0,
borderLeftStyle: 'none',
borderLeftWidth: 0,
borderRightStyle: 'none',
borderRightWidth: 0,
borderTopStyle: 'none',
borde... | javascript | {
"resource": ""
} |
q25941 | fitPreviewToContent | train | function fitPreviewToContent() {
var iframeDoc = preview.contentDocument || preview.contentWindow.document;
setPreviewHeight(iframeDoc.body.offsetHeight);
} | javascript | {
"resource": ""
} |
q25942 | postEmbedHeightToViewer | train | function postEmbedHeightToViewer() {
var newHeight = document.getElementById('tabinterface').clientHeight;
if (newHeight < MIN_IFRAME_HEIGHT) {
console.log('embed height too small, reset height to 100px');
newHeight = MIN_IFRAME_HEIGHT;
}
// Tell the viewer about the new size
window.parent.postMessage... | javascript | {
"resource": ""
} |
q25943 | offlineImage | train | function offlineImage(name, width, height) {
return
`<?xml version="1.0"?>
<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg" version="1.1">
<g fill="none" fill-rule="evenodd"><path fill="#F8BBD0" d="M0 0h${width}v${height}H0z"/></g>
<text text-anchor=... | javascript | {
"resource": ""
} |
q25944 | onMessageReceivedSubscriptionState | train | function onMessageReceivedSubscriptionState() {
let retrievedPushSubscription = null;
self.registration.pushManager.getSubscription()
.then(pushSubscription => {
retrievedPushSubscription = pushSubscription;
if (!pushSubscription) {
return null;
} else... | javascript | {
"resource": ""
} |
q25945 | persistSubscriptionLocally | train | function persistSubscriptionLocally(subscription) {
let subscriptionJSON = JSON.stringify(subscription);
idb.open('web-push-db', 1).then(db => {
let tx = db.transaction(['web-push-subcription'], 'readwrite');
tx.objectStore('web-push-subcription').put({
id: 1,
data: subsc... | javascript | {
"resource": ""
} |
q25946 | urlB64ToUint8Array | train | function urlB64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');
const rawData = self.atob(base64);
const outputArray = new Uint8Array(rawData.length);
for (l... | javascript | {
"resource": ""
} |
q25947 | generateEmbeds | train | function generateEmbeds(config) {
glob(config.src + '/**/*.html', {}, (err, files) => {
files.forEach(file => generateEmbed(config, file));
});
} | javascript | {
"resource": ""
} |
q25948 | generateEmbed | train | function generateEmbed(config, file) {
const targetPath = path.join(config.destDir, path.relative(config.src, file));
const document = parseDocument(file);
const sampleSections = document.sections.filter(
s => s.inBody && !s.isEmptyCodeSection()
);
sampleSections.forEach((section, index) => {
highligh... | javascript | {
"resource": ""
} |
q25949 | highlight | train | function highlight(code) {
return new Promise((resolve, reject) => {
pygmentize({ lang: 'html', format: 'html' }, code, function (err, result) {
if (err) {
console.log(err);
reject(err);
} else {
resolve(result.toString());
};
});
});
} | javascript | {
"resource": ""
} |
q25950 | generate | train | function generate(file, template, context, minifyResult) {
let string = template.render(context, {
'styles.css': templates.styles,
'embed.js': templates.embedJs
});
if (minifyResult) {
string = minify(string, {
caseSensitive: true,
collapseWhitespace: true,
html5: true,
minifyC... | javascript | {
"resource": ""
} |
q25951 | addFlag | train | function addFlag() {
const filename = arguments[0];
const postfix = [].slice.call(arguments, 1).join('.');
return filename.replace('.html', '.' + postfix + '.html');
} | javascript | {
"resource": ""
} |
q25952 | generateTemplate | train | function generateTemplate(context) {
let _page;
let _phantom;
phantom.create([], { logLevel: 'error' }).then(function (ph) {
_phantom = ph;
ph.createPage()
.then(page => {
_page = page;
const url = path.join(context.config.destRoot, context.sample.embed);
return _page.propert... | javascript | {
"resource": ""
} |
q25953 | UTF8Decoder | train | function UTF8Decoder(options) {
var fatal = options.fatal;
var /** @type {number} */ utf8_code_point = 0,
/** @type {number} */ utf8_bytes_needed = 0,
/** @type {number} */ utf8_bytes_seen = 0,
/** @type {number} */ utf8_lower_boundary = 0;
/**
* @param {ByteInputStream} byte_pointer The byt... | javascript | {
"resource": ""
} |
q25954 | GBKDecoder | train | function GBKDecoder(gb18030, options) {
var fatal = options.fatal;
var /** @type {number} */ gbk_first = 0x00,
/** @type {number} */ gbk_second = 0x00,
/** @type {number} */ gbk_third = 0x00;
/**
* @param {ByteInputStream} byte_pointer The byte stream to decode.
* @return {?number} The next code... | javascript | {
"resource": ""
} |
q25955 | HZGB2312Decoder | train | function HZGB2312Decoder(options) {
var fatal = options.fatal;
var /** @type {boolean} */ hzgb2312 = false,
/** @type {number} */ hzgb2312_lead = 0x00;
/**
* @param {ByteInputStream} byte_pointer The byte stream to decode.
* @return {?number} The next code point decoded, or null if not enough
* ... | javascript | {
"resource": ""
} |
q25956 | Big5Decoder | train | function Big5Decoder(options) {
var fatal = options.fatal;
var /** @type {number} */ big5_lead = 0x00,
/** @type {?number} */ big5_pending = null;
/**
* @param {ByteInputStream} byte_pointer The byte steram to decode.
* @return {?number} The next code point decoded, or null if not enough
* dat... | javascript | {
"resource": ""
} |
q25957 | EUCJPDecoder | train | function EUCJPDecoder(options) {
var fatal = options.fatal;
var /** @type {number} */ eucjp_first = 0x00,
/** @type {number} */ eucjp_second = 0x00;
/**
* @param {ByteInputStream} byte_pointer The byte stream to decode.
* @return {?number} The next code point decoded, or null if not enough
* da... | javascript | {
"resource": ""
} |
q25958 | ShiftJISDecoder | train | function ShiftJISDecoder(options) {
var fatal = options.fatal;
var /** @type {number} */ shiftjis_lead = 0x00;
/**
* @param {ByteInputStream} byte_pointer The byte stream to decode.
* @return {?number} The next code point decoded, or null if not enough
* data exists in the input stream to decode a co... | javascript | {
"resource": ""
} |
q25959 | EUCKRDecoder | train | function EUCKRDecoder(options) {
var fatal = options.fatal;
var /** @type {number} */ euckr_lead = 0x00;
/**
* @param {ByteInputStream} byte_pointer The byte stream to decode.
* @return {?number} The next code point decoded, or null if not enough
* data exists in the input stream to decode a complete... | javascript | {
"resource": ""
} |
q25960 | UTF16Decoder | train | function UTF16Decoder(utf16_be, options) {
var fatal = options.fatal;
var /** @type {?number} */ utf16_lead_byte = null,
/** @type {?number} */ utf16_lead_surrogate = null;
/**
* @param {ByteInputStream} byte_pointer The byte stream to decode.
* @return {?number} The next code point decoded, or null i... | javascript | {
"resource": ""
} |
q25961 | train | function () {
var scopes = fs.readdirSync('./test_scopes').filter(function (filename) {
return filename[0] !== '.';
});
var config = {
options: {
color: false,
interactive: false
}
};
// Create a sub config for each test scope
for (var idx in scopes) {
var... | javascript | {
"resource": ""
} | |
q25962 | train | function () {
angular.forEach(translateAttr, function (translationId, attributeName) {
if (!translationId) {
return;
}
previousAttributes[attributeName] = true;
// if translation id starts with '.' and translateNamespace given, prepend namespace
if ... | javascript | {
"resource": ""
} | |
q25963 | train | function () {
return $http(
angular.extend({
method : 'GET',
url : self.parseUrl(self.urlTemplate || urlTemplate, lang)
},
$httpOptions)
);
} | javascript | {
"resource": ""
} | |
q25964 | train | function() {
ws = new SockJS(location.pathname.split("index")[0] + 'socket');
ws.onopen = function() {
console.log("CONNECTED");
if (!inIframe) {
document.getElementById("footer").innerHTML = "<font color='#494'>"+ibmfoot+"</font>";
}
ws.send(JSON.stringify({action:"c... | javascript | {
"resource": ""
} | |
q25965 | doTidyUp | train | function doTidyUp(l) {
var d = parseInt(Date.now()/1000);
for (var m in markers) {
if ((l && (l == markers[m].lay)) || typeof markers[m].ts != "undefined") {
if ((l && (l == markers[m].lay)) || (markers[m].hasOwnProperty("ts") && (Number(markers[m].ts) < d) && (markers[m].lay !== "_drawing")... | javascript | {
"resource": ""
} |
q25966 | doSearch | train | function doSearch() {
var value = document.getElementById('search').value;
marks = [];
marksIndex = 0;
for (var key in markers) {
if ( (~(key.toLowerCase()).indexOf(value.toLowerCase())) && (mb.contains(markers[key].getLatLng()))) {
marks.push(markers[key]);
}
if (mar... | javascript | {
"resource": ""
} |
q25967 | moveToMarks | train | function moveToMarks() {
if (marks.length > marksIndex) {
var m = marks[marksIndex];
map.setView(m.getLatLng(), map.getZoom());
m.openPopup();
marksIndex++;
setTimeout(moveToMarks, 2500);
}
} | javascript | {
"resource": ""
} |
q25968 | clearSearch | train | function clearSearch() {
var value = document.getElementById('search').value;
marks = [];
marksIndex = 0;
for (var key in markers) {
if ( (~(key.toLowerCase()).indexOf(value.toLowerCase())) && (mb.contains(markers[key].getLatLng()))) {
marks.push(markers[key]);
}
}
re... | javascript | {
"resource": ""
} |
q25969 | setMarker | train | function setMarker(data) {
var rightmenu = function(m) {
// customise right click context menu
var rightcontext = "";
if (polygons[data.name] == undefined) {
rightcontext = "<button id='delbutton' onclick='delMarker(\""+data.name+"\",true);'>Delete</button>";
}
e... | javascript | {
"resource": ""
} |
q25970 | doGeojson | train | function doGeojson(g) {
console.log("GEOJSON",g);
if (!basemaps["geojson"]) {
var opt = { style: function(feature) {
var st = { stroke:true, color:"#910000", weight:2, fill:true, fillColor:"#910000", fillOpacity:0.3 };
if (feature.hasOwnProperty("properties")) {
... | javascript | {
"resource": ""
} |
q25971 | train | function(newState){
// when called with no args, it's a getter
if (arguments.length === 0) {
return this._currentState.stateName;
}
// activate by name
if(typeof newState == 'string'){
this._activateStateNamed(newState);
// activate by index
} else if (typeof newState == 'num... | javascript | {
"resource": ""
} | |
q25972 | State | train | function State(template, easyButton){
this.title = template.title;
this.stateName = template.stateName ? template.stateName : 'unnamed-state';
// build the wrapper
this.icon = L.DomUtil.create('span', '');
L.DomUtil.addClass(this.icon, 'button-state state-' + this.stateName.replace(/(^\s*|\s*$)/g,''));
t... | javascript | {
"resource": ""
} |
q25973 | webpackImporter | train | function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
function dirContextFrom(fileContext) {
return path.dirname(
// The first file is 'stdin' when we're using the data option
fileContext === 'stdin' ? resourcePath : fileContext
);
}
// eslint-disable-next-line no-shadow
... | javascript | {
"resource": ""
} |
q25974 | proxyCustomImporters | train | function proxyCustomImporters(importer, resourcePath) {
return [].concat(importer).map(
// eslint-disable-next-line no-shadow
(importer) =>
function customImporter() {
return importer.apply(
this,
// eslint-disable-next-line prefer-rest-params
Array.from(arguments).... | javascript | {
"resource": ""
} |
q25975 | normalizeOptions | train | function normalizeOptions(loaderContext, content, webpackImporter) {
const options = cloneDeep(utils.getOptions(loaderContext)) || {};
const { resourcePath } = loaderContext;
// allow opt.functions to be configured WRT loaderContext
if (typeof options.functions === 'function') {
options.functions = options... | javascript | {
"resource": ""
} |
q25976 | importsToResolve | train | function importsToResolve(url) {
const request = utils.urlToRequest(url);
// Keep in mind: ext can also be something like '.datepicker' when the true extension is omitted and the filename contains a dot.
// @see https://github.com/webpack-contrib/sass-loader/issues/167
const ext = path.extname(request);
if (... | javascript | {
"resource": ""
} |
q25977 | sassLoader | train | function sassLoader(content) {
const callback = this.async();
const isSync = typeof callback !== 'function';
const self = this;
const { resourcePath } = this;
function addNormalizedDependency(file) {
// node-sass returns POSIX paths
self.dependency(path.normalize(file));
}
if (isSync) {
thro... | javascript | {
"resource": ""
} |
q25978 | getRenderFuncFromSassImpl | train | function getRenderFuncFromSassImpl(module) {
const { info } = module;
const components = info.split('\t');
if (components.length < 2) {
throw new Error(`Unknown Sass implementation "${info}".`);
}
const [implementation, version] = components;
if (!semver.valid(version)) {
throw new Error(`Invalid... | javascript | {
"resource": ""
} |
q25979 | token | train | function token(input) {
let token;
if (typeof input === "string") {
token = input;
} else if (Buffer.isBuffer(input)) {
token = input.toString("hex");
}
token = token.replace(/[^0-9a-f]/gi, "");
if (token.length === 0) {
throw new Error("Token has invalid length");
}
return token;
} | javascript | {
"resource": ""
} |
q25980 | Notification | train | function Notification (payload) {
this.encoding = "utf8";
this.payload = {};
this.compiled = false;
this.aps = {};
this.expiry = 0;
this.priority = 10;
if (payload) {
for(let key in payload) {
if (payload.hasOwnProperty(key)) {
this[key] = payload[key];
}
}
}
} | javascript | {
"resource": ""
} |
q25981 | invalidDoc | train | function invalidDoc(doc) {
if (doc.query) {
if (typeof doc.query.type != "string") return ".query.type must be a string";
if (doc.query.start && !isPosition(doc.query.start)) return ".query.start must be a position";
if (doc.query.end && !isPosition(doc.query.end)) return ".query.end must be a pos... | javascript | {
"resource": ""
} |
q25982 | clean | train | function clean(obj) {
for (var prop in obj) if (obj[prop] == null) delete obj[prop];
return obj;
} | javascript | {
"resource": ""
} |
q25983 | compareCompletions | train | function compareCompletions(a, b) {
if (typeof a != "string") { a = a.name; b = b.name; }
var aUp = /^[A-Z]/.test(a), bUp = /^[A-Z]/.test(b);
if (aUp == bUp) return a < b ? -1 : a == b ? 0 : 1;
else return aUp ? 1 : -1;
} | javascript | {
"resource": ""
} |
q25984 | train | function() {
var
activeText = text.active || $module.data(metadata.storedText),
inactiveText = text.inactive || $module.data(metadata.storedText)
;
if( module.is.textEnabled() ) {
if( module.is.active() && activeText) {
mo... | javascript | {
"resource": ""
} | |
q25985 | train | function(errors) {
var
html = '<ul class="list">'
;
$.each(errors, function(index, value) {
html += '<li>' + value + '</li>';
});
html += '</ul>';
return $(html);
} | javascript | {
"resource": ""
} | |
q25986 | train | function(value, regExp) {
if(regExp instanceof RegExp) {
return value.match(regExp);
}
var
regExpParts = regExp.match($.fn.form.settings.regExp.flags),
flags
;
// regular expression specified as /baz/gi (flags)
if(regExpParts) {
regExp = (regExpParts.l... | javascript | {
"resource": ""
} | |
q25987 | train | function(value, range) {
var
intRegExp = $.fn.form.settings.regExp.integer,
min,
max,
parts
;
if( !range || ['', '..'].indexOf(range) !== -1) {
// do nothing
}
else if(range.indexOf('..') == -1) {
if(intRegExp.test(range)) {
min = m... | javascript | {
"resource": ""
} | |
q25988 | train | function(value, identifier) {
var
$form = $(this),
matchingValue
;
if( $('[data-validate="'+ identifier +'"]').length > 0 ) {
matchingValue = $('[data-validate="'+ identifier +'"]').val();
}
else if($('#' + identifier).length > 0) {
matchingValue = $('#' + i... | javascript | {
"resource": ""
} | |
q25989 | train | function(select) {
var
placeholder = select.placeholder || false,
values = select.values || {},
html = ''
;
html += '<i class="dropdown icon"></i>';
if(select.placeholder) {
html += '<div class="default text">' + placeholder + '</div>';
}
else {
html +=... | javascript | {
"resource": ""
} | |
q25990 | train | function(response, fields) {
var
values = response[fields.values] || {},
html = ''
;
$.each(values, function(index, option) {
var
maybeText = (option[fields.text])
? 'data-text="' + option[fields.text] + '"'
: '',
maybeDisabled = (option[fields.disable... | javascript | {
"resource": ""
} | |
q25991 | train | function(source, id, url) {
module.debug('Changing video to ', source, id, url);
$module
.data(metadata.source, source)
.data(metadata.id, id)
;
if(url) {
$module.data(metadata.url, url);
}
else {
$module.removeD... | javascript | {
"resource": ""
} | |
q25992 | train | function() {
if(settings.throttle) {
clearTimeout(module.timer);
module.timer = setTimeout(function() {
$context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]);
}, settings.throttle);
}
else {
... | javascript | {
"resource": ""
} | |
q25993 | Session | train | function Session(options) {
options = options || {};
this.id = options.id || this._guid();
this.parent = options.parent || undefined;
this.authenticating = options.authenticating || false;
this.authenticated = options.authenticated || undefined;
this.user = options.user || 'guest';
this.host = options.hos... | javascript | {
"resource": ""
} |
q25994 | Vorpal | train | function Vorpal() {
if (!(this instanceof Vorpal)) {
return new Vorpal();
}
// Program version
// Exposed through vorpal.version(str);
this._version = '';
// Program title
this._title = '';
// Program description
this._description = '';
// Program baner
this._banner = '';
// Command lin... | javascript | {
"resource": ""
} |
q25995 | Command | train | function Command(name, parent) {
if (!(this instanceof Command)) {
return new Command();
}
this.commands = [];
this.options = [];
this._args = [];
this._aliases = [];
this._name = name;
this._relay = false;
this._hidden = false;
this._parent = parent;
this._mode = false;
this._catch = false;... | javascript | {
"resource": ""
} |
q25996 | _camelcase | train | function _camelcase(flag) {
return flag.split('-').reduce(function (str, word) {
return str + word[0].toUpperCase() + word.slice(1);
});
} | javascript | {
"resource": ""
} |
q25997 | handleTabCounts | train | function handleTabCounts(str, freezeTabs) {
var result;
if (_.isArray(str)) {
this._tabCtr += 1;
if (this._tabCtr > 1) {
result = str.length === 0 ? undefined : str;
}
} else {
this._tabCtr = freezeTabs === true ? this._tabCtr + 1 : 0;
result = str;
}
return result;
} | javascript | {
"resource": ""
} |
q25998 | getMatch | train | function getMatch(ctx, data, options) {
// Look for a command match, eliminating and then
// re-introducing leading spaces.
var len = ctx.length;
var trimmed = ctx.replace(/^\s+/g, '');
var match = autocomplete.match(trimmed, data.slice(), options);
if (_.isArray(match)) {
return match;
}
var prefix... | javascript | {
"resource": ""
} |
q25999 | assembleInput | train | function assembleInput(input) {
if (_.isArray(input.context)) {
return input.context;
}
var result = (input.prefix || '') + (input.context || '') + (input.suffix || '');
return strip(result);
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.