_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q26000 | parseInput | train | function parseInput(str, idx) {
var raw = String(str || '');
var sliced = raw.slice(0, idx);
var sections = sliced.split('|');
var prefix = sections.slice(0, sections.length - 1) || [];
prefix.push('');
prefix = prefix.join('|');
var suffix = getSuffix(raw.slice(idx));
var context = sections[sections.le... | javascript | {
"resource": ""
} |
q26001 | parseMatchSection | train | function parseMatchSection(input) {
var parts = (input.context || '').split(' ');
var last = parts.pop();
var beforeLast = strip(parts[parts.length - 1] || '').trim();
if (beforeLast.slice(0, 1) === '-') {
input.option = beforeLast;
}
input.context = last;
input.prefix = (input.prefix || '') + parts.j... | javascript | {
"resource": ""
} |
q26002 | getCommandNames | train | function getCommandNames(cmds) {
var commands = _.map(cmds, '_name');
commands = commands.concat.apply(commands, _.map(cmds, '_aliases'));
commands.sort();
return commands;
} | javascript | {
"resource": ""
} |
q26003 | getMatchData | train | function getMatchData(input, cb) {
var string = input.context;
var cmd = input.match;
var midOption = String(string).trim().slice(0, 1) === '-';
var afterOption = input.option !== undefined;
if (midOption === true && !cmd._allowUnknownOptions) {
var results = [];
for (var i = 0; i < cmd.options.length... | javascript | {
"resource": ""
} |
q26004 | train | function (str, cb) {
var self = this;
var input = parseInput(str, this.parent.ui._activePrompt.screen.rl.cursor);
var commands = getCommandNames(this.parent.commands);
var vorpalMatch = getMatch(input.context, commands, {ignoreSlashes: true});
var freezeTabs = false;
function end(str) {
v... | javascript | {
"resource": ""
} | |
q26005 | filterData | train | function filterData(str, data) {
data = data || [];
var ctx = String(str || '').trim();
var slashParts = ctx.split('/');
ctx = slashParts.pop();
var wordParts = String(ctx).trim().split(' ');
var res = data.filter(function (item) {
return (strip(item).slice(0, ctx.length) === ctx);
});
res = res.map... | javascript | {
"resource": ""
} |
q26006 | getSuffix | train | function getSuffix(suffix) {
suffix = (suffix.slice(0, 1) === ' ') ?
suffix :
suffix.replace(/.+?(?=\s)/, '');
suffix = suffix.slice(1, suffix.length);
return suffix;
} | javascript | {
"resource": ""
} |
q26007 | getMatchObject | train | function getMatchObject(input, commands) {
var len = input.context.length;
var trimmed = String(input.context).replace(/^\s+/g, '');
var prefix = new Array((len - trimmed.length) + 1).join(' ');
var match;
var suffix;
commands.forEach(function (cmd) {
var nextChar = trimmed.substr(cmd.length, 1);
if... | javascript | {
"resource": ""
} |
q26008 | PixelWalker | train | function PixelWalker(firstPoint, pixel_path) {
// go clockwise starting first point
var points = [];
points.push(firstPoint);
var moveHorizontal = true; // alternate horizontal and vertical movements to form pixel heart
pixel_path.forEach(function (p) {
var previous_point = points[points... | javascript | {
"resource": ""
} |
q26009 | Heart | train | function Heart(desired_width) {
var points = PixelWalker(STARTING_POINT, path);
var pathModel = new makerjs.models.ConnectTheDots(true, points);
if (typeof desired_width != 'undefined') {
var scale = desired_width / HEART_WIDTH;
makerjs.model.scale(pathModel, scale);
}
return pathMo... | javascript | {
"resource": ""
} |
q26010 | complete2 | train | function complete2() {
//reset any calls to document.write
resetLog();
//reinstate alert
window.alert = originalAlert;
var originalFn = parent.makerjs.exporter.toSVG;
var captureExportedModel;
parent.makerjs.exporter.toSVG = function (i... | javascript | {
"resource": ""
} |
q26011 | plugin | train | function plugin (Vue, options = {}) {
if (plugin.installed) {
return
}
plugin.installed = true
// install components
Vue.use(ArcgisRestSource, options)
Vue.use(BingmapsSource, options)
Vue.use(CircleGeom, options)
Vue.use(CircleStyle, options)
Vue.use(ClusterSource, options)
Vue.use(DrawInterac... | javascript | {
"resource": ""
} |
q26012 | getBoundingBox | train | function getBoundingBox() {
if (!bounds) return // client does not want to restrict movement
if (typeof bounds === 'boolean') {
// for boolean type we use parent container bounds
var ownerRect = owner.getBoundingClientRect()
var sceneWidth = ownerRect.width
var sceneHeight = ownerRect.h... | javascript | {
"resource": ""
} |
q26013 | train | function(source) {
var copy, i, len, prop;
if (typeof source !== "object" || source == null || typeof source.nodeType === "number") {
copy = source;
} else if (typeof source.length === "number") {
copy = [];
for (i = 0, len = source.length; i < len; i++) {
if (_hasOwn.call(source, ... | javascript | {
"resource": ""
} | |
q26014 | train | function(obj) {
if (obj) {
for (var prop in obj) {
if (_hasOwn.call(obj, prop)) {
delete obj[prop];
}
}
}
return obj;
} | javascript | {
"resource": ""
} | |
q26015 | train | function(el, ancestorEl) {
if (el && el.nodeType === 1 && el.ownerDocument && ancestorEl && (ancestorEl.nodeType === 1 && ancestorEl.ownerDocument && ancestorEl.ownerDocument === el.ownerDocument || ancestorEl.nodeType === 9 && !ancestorEl.ownerDocument && ancestorEl === el.ownerDocument)) {
do {
if (... | javascript | {
"resource": ""
} | |
q26016 | train | function(url) {
var dir;
if (typeof url === "string" && url) {
dir = url.split("#")[0].split("?")[0];
dir = url.slice(0, url.lastIndexOf("/") + 1);
}
return dir;
} | javascript | {
"resource": ""
} | |
q26017 | train | function() {
var jsPath, scripts, i;
if (_document.currentScript && (jsPath = _document.currentScript.src)) {
return jsPath;
}
scripts = _document.getElementsByTagName("script");
if (scripts.length === 1) {
return scripts[0].src || undefined;
}
if ("readyState" in (scripts[0] || ... | javascript | {
"resource": ""
} | |
q26018 | train | function() {
var isWindowsRegex = /win(dows|[\s]?(nt|me|ce|xp|vista|[\d]+))/i;
return !!_navigator && (isWindowsRegex.test(_navigator.appVersion || "") || isWindowsRegex.test(_navigator.platform || "") || (_navigator.userAgent || "").indexOf("Windows") !== -1);
} | javascript | {
"resource": ""
} | |
q26019 | train | function(options) {
if (typeof options === "object" && options && !("length" in options)) {
_keys(options).forEach(function(prop) {
if (/^(?:forceHandCursor|title|zIndex|bubbleEvents|fixLineEndings)$/.test(prop)) {
_globalConfig[prop] = options[prop];
} else if (_flashState.bridge ==... | javascript | {
"resource": ""
} | |
q26020 | train | function() {
_detectSandbox();
return {
browser: _extend(_pick(_navigator, [ "userAgent", "platform", "appName", "appVersion" ]), {
isSupported: _isBrowserSupported()
}),
flash: _omit(_flashState, [ "bridge" ]),
zeroclipboard: {
version: ZeroClipboard.version,
con... | javascript | {
"resource": ""
} | |
q26021 | train | function() {
return !!(_flashState.sandboxed || _flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
} | javascript | {
"resource": ""
} | |
q26022 | train | function(eventType, listener) {
var i, len, events, added = {};
if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
_keys(eventType... | javascript | {
"resource": ""
} | |
q26023 | train | function(eventType, listener) {
var i, len, foundIndex, events, perEventHandlers;
if (arguments.length === 0) {
events = _keys(_handlers);
} else if (typeof eventType === "string" && eventType) {
events = eventType.toLowerCase().split(/\s+/);
} else if (typeof eventType === "object" && event... | javascript | {
"resource": ""
} | |
q26024 | train | function(eventType) {
var copy;
if (typeof eventType === "string" && eventType) {
copy = _deepCopy(_handlers[eventType]) || null;
} else {
copy = _deepCopy(_handlers);
}
return copy;
} | javascript | {
"resource": ""
} | |
q26025 | train | function(event) {
var eventCopy, returnVal, tmp;
event = _createEvent(event);
if (!event) {
return;
}
if (_preprocessEvent(event)) {
return;
}
if (event.type === "ready" && _flashState.overdue === true) {
return ZeroClipboard.emit({
type: "error",
name: "fla... | javascript | {
"resource": ""
} | |
q26026 | train | function() {
var swfPath = _globalConfig.swfPath || "", swfPathFirstTwoChars = swfPath.slice(0, 2), swfProtocol = swfPath.slice(0, swfPath.indexOf("://") + 1);
return swfPathFirstTwoChars === "\\\\" ? "file:" : swfPathFirstTwoChars === "//" || swfProtocol === "" ? _window.location.protocol : swfProtocol;
} | javascript | {
"resource": ""
} | |
q26027 | train | function() {
var maxWait, swfProtocol, previousState = _flashState.sandboxed;
if (!_isBrowserSupported()) {
_flashState.ready = false;
ZeroClipboard.emit({
type: "error",
name: "browser-unsupported"
});
return;
}
_detectSandbox();
if (typeof _flashState.ready ... | javascript | {
"resource": ""
} | |
q26028 | train | function(format, data) {
var dataObj;
if (typeof format === "object" && format && typeof data === "undefined") {
dataObj = format;
ZeroClipboard.clearData();
} else if (typeof format === "string" && format) {
dataObj = {};
dataObj[format] = data;
} else {
return;
}
... | javascript | {
"resource": ""
} | |
q26029 | train | function(format) {
if (typeof format === "undefined") {
_deleteOwnProperties(_clipData);
_clipDataFormatMap = null;
} else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
delete _clipData[format];
}
} | javascript | {
"resource": ""
} | |
q26030 | train | function(format) {
if (typeof format === "undefined") {
return _deepCopy(_clipData);
} else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
return _clipData[format];
}
} | javascript | {
"resource": ""
} | |
q26031 | train | function(event) {
var eventType;
if (typeof event === "string" && event) {
eventType = event;
event = {};
} else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
eventType = event.type;
}
if (!eventType) {
return;
}
eventType =... | javascript | {
"resource": ""
} | |
q26032 | train | function(targetEl) {
var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
} | javascript | {
"resource": ""
} | |
q26033 | train | function(event) {
if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
var srcElement = event.target;
var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
var toElement = event.type === "_mouseout" && event.relatedTarget ... | javascript | {
"resource": ""
} | |
q26034 | train | function(func, context, args, async) {
if (async) {
_setTimeout(function() {
func.apply(context, args);
}, 0);
} else {
func.apply(context, args);
}
} | javascript | {
"resource": ""
} | |
q26035 | train | function(event) {
var isSandboxed = null;
if (_pageIsFramed === false || event && event.type === "error" && event.name && _errorsThatOnlyOccurAfterFlashLoads.indexOf(event.name) !== -1) {
isSandboxed = false;
}
return isSandboxed;
} | javascript | {
"resource": ""
} | |
q26036 | train | function(aftercopyEvent) {
if (aftercopyEvent.errors && aftercopyEvent.errors.length > 0) {
var errorEvent = _deepCopy(aftercopyEvent);
_extend(errorEvent, {
type: "error",
name: "clipboard-error"
});
delete errorEvent.success;
_setTimeout(function() {
ZeroClipb... | javascript | {
"resource": ""
} | |
q26037 | train | function(event) {
if (!(event && typeof event.type === "string" && event)) {
return;
}
var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
view: doc.defaultView || _window,
canBubble: true,
cancelable: true,
detail: event.type =... | javascript | {
"resource": ""
} | |
q26038 | train | function() {
var container = _document.createElement("div");
container.id = _globalConfig.containerId;
container.className = _globalConfig.containerClass;
container.style.position = "absolute";
container.style.left = "0px";
container.style.top = "-9999px";
container.style.width = "1px";
... | javascript | {
"resource": ""
} | |
q26039 | train | function() {
var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
if (!flashBridge) {
var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
var flashvars = _vars... | javascript | {
"resource": ""
} | |
q26040 | train | function() {
var flashBridge = _flashState.bridge;
if (flashBridge) {
var htmlBridge = _getHtmlBridge(flashBridge);
if (htmlBridge) {
if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
flashBridge.style.display = "none";
(function removeSwfFromIE()... | javascript | {
"resource": ""
} | |
q26041 | train | function(clipData) {
var newClipData = {}, formatMap = {};
if (!(typeof clipData === "object" && clipData)) {
return;
}
for (var dataFormat in clipData) {
if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
switc... | javascript | {
"resource": ""
} | |
q26042 | train | function(options) {
var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
if (options.trustedDomains) {
if (typeof options.trustedDomains === "string") {
domains = [ options.trustedDomains ];
} else if (typeof options.trustedDomains === "object" && "length" in options.trustedDo... | javascript | {
"resource": ""
} | |
q26043 | train | function(element, value) {
var c, cl, className, classNames = [];
if (typeof value === "string" && value) {
classNames = value.split(/\s+/);
}
if (element && element.nodeType === 1 && classNames.length > 0) {
className = (" " + (element.className || "") + " ").replace(/[\t\r\n\f]/g, " ");
... | javascript | {
"resource": ""
} | |
q26044 | train | function(el) {
var pos = {
left: 0,
top: 0,
width: 0,
height: 0
};
if (el.getBoundingClientRect) {
var elRect = el.getBoundingClientRect();
var pageXOffset = _window.pageXOffset;
var pageYOffset = _window.pageYOffset;
var leftBorderWidth = _document.documentEl... | javascript | {
"resource": ""
} | |
q26045 | train | function() {
var htmlBridge;
if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
var pos = _getElementPosition(_currentElement);
_extend(htmlBridge.style, {
width: pos.width + "px",
height: pos.height + "px",
top: pos.top + "px",
left: pos.left... | javascript | {
"resource": ""
} | |
q26046 | train | function(enabled) {
if (_flashState.ready === true) {
if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
_flashState.bridge.setHandCursor(enabled);
} else {
_flashState.ready = false;
}
}
} | javascript | {
"resource": ""
} | |
q26047 | train | function(val) {
if (/^(?:auto|inherit)$/.test(val)) {
return val;
}
var zIndex;
if (typeof val === "number" && !_isNaN(val)) {
zIndex = val;
} else if (typeof val === "string") {
zIndex = _getSafeZIndex(_parseInt(val, 10));
}
return typeof zIndex === "number" ? zIndex : "au... | javascript | {
"resource": ""
} | |
q26048 | train | function(content) {
var replaceRegex = /(\r\n|\r|\n)/g;
if (typeof content === "string" && _globalConfig.fixLineEndings === true) {
if (_isWindows()) {
if (/((^|[^\r])\n|\r([^\n]|$))/.test(content)) {
content = content.replace(replaceRegex, "\r\n");
}
} else if (/\r/.test(c... | javascript | {
"resource": ""
} | |
q26049 | train | function(doNotReassessFlashSupport) {
var effectiveScriptOrigin, frame, frameError, previousState = _flashState.sandboxed, isSandboxed = null;
doNotReassessFlashSupport = doNotReassessFlashSupport === true;
if (_pageIsFramed === false) {
isSandboxed = false;
} else {
try {
frame = wi... | javascript | {
"resource": ""
} | |
q26050 | parseFlashVersion | train | function parseFlashVersion(desc) {
var matches = desc.match(/[\d]+/g);
matches.length = 3;
return matches.join(".");
} | javascript | {
"resource": ""
} |
q26051 | train | function(elements) {
var meta, client = this;
client.id = "" + _clientIdCounter++;
meta = {
instance: client,
elements: [],
handlers: {},
coreWildcardHandler: function(event) {
return client.emit(event);
}
};
_clientMeta[client.id] = meta;
if (elements) {
... | javascript | {
"resource": ""
} | |
q26052 | train | function(eventType, listener) {
var i, len, events, added = {}, client = this, meta = _clientMeta[client.id], handlers = meta && meta.handlers;
if (!meta) {
throw new Error("Attempted to add new listener(s) to a destroyed ZeroClipboard client instance");
}
if (typeof eventType === "string" && even... | javascript | {
"resource": ""
} | |
q26053 | train | function(eventType, listener) {
var i, len, foundIndex, events, perEventHandlers, client = this, meta = _clientMeta[client.id], handlers = meta && meta.handlers;
if (!handlers) {
return client;
}
if (arguments.length === 0) {
events = _keys(handlers);
} else if (typeof eventType === "str... | javascript | {
"resource": ""
} | |
q26054 | train | function(eventType) {
var copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
if (handlers) {
if (typeof eventType === "string" && eventType) {
copy = handlers[eventType] ? handlers[eventType].slice(0) : [];
} else {
copy = _deepCopy(handlers);
}
... | javascript | {
"resource": ""
} | |
q26055 | train | function(event) {
var eventCopy, client = this;
if (_clientShouldEmit.call(client, event)) {
if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
event = _extend({}, event);
}
eventCopy = _extend({}, _createEvent(event), {
client: client
... | javascript | {
"resource": ""
} | |
q26056 | train | function(elements) {
if (!_clientMeta[this.id]) {
throw new Error("Attempted to clip element(s) to a destroyed ZeroClipboard client instance");
}
elements = _prepClip(elements);
for (var i = 0; i < elements.length; i++) {
if (_hasOwn.call(elements, i) && elements[i] && elements[i].nodeType =... | javascript | {
"resource": ""
} | |
q26057 | train | function(elements) {
var meta = _clientMeta[this.id];
if (!meta) {
return this;
}
var clippedElements = meta.elements;
var arrayIndex;
if (typeof elements === "undefined") {
elements = clippedElements.slice(0);
} else {
elements = _prepClip(elements);
}
for (var i =... | javascript | {
"resource": ""
} | |
q26058 | train | function() {
var meta = _clientMeta[this.id];
if (!meta) {
return;
}
this.unclip();
this.off();
ZeroClipboard.off("*", meta.coreWildcardHandler);
delete _clientMeta[this.id];
} | javascript | {
"resource": ""
} | |
q26059 | train | function(event) {
var meta = _clientMeta[this.id];
if (!(typeof event === "object" && event && event.type && meta)) {
return;
}
var async = _shouldPerformAsync(event);
var wildcardTypeHandlers = meta && meta.handlers["*"] || [];
var specificTypeHandlers = meta && meta.handlers[event.type] ... | javascript | {
"resource": ""
} | |
q26060 | train | function(element) {
if (!(element && element.nodeType === 1)) {
return;
}
var _suppressMouseEvents = function(event) {
if (!(event || (event = _window.event))) {
return;
}
if (event._source !== "js") {
event.stopImmediatePropagation();
event.preventDefault();
... | javascript | {
"resource": ""
} | |
q26061 | train | function(element) {
if (!(element && element.nodeType === 1)) {
return;
}
var mouseHandlers = _mouseHandlers[element.zcClippingId];
if (!(typeof mouseHandlers === "object" && mouseHandlers)) {
return;
}
var key, val, mouseEvents = [ "move", "leave", "enter", "out", "over" ];
for ... | javascript | {
"resource": ""
} | |
q26062 | decode | train | function decode(data) {
var languageCodeLength = (data[0] & 0x3F), // 6 LSBs
languageCode = data.slice(1, 1 + languageCodeLength),
utf16 = (data[0] & 0x80) !== 0; // assuming UTF-16BE
// TODO need to deal with UTF in the future
// console.log("lang " + languageCode + (utf16 ? " utf16" : " ... | javascript | {
"resource": ""
} |
q26063 | encode | train | function encode(text, lang, encoding) {
// ISO/IANA language code, but we're not enforcing
if (!lang) { lang = 'en'; }
var encoded = util.stringToBytes(lang + text);
encoded.unshift(lang.length);
return encoded;
} | javascript | {
"resource": ""
} |
q26064 | train | function (text, languageCode, id) {
var payload = textHelper.encodePayload(text, languageCode);
if (!id) { id = []; }
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_TEXT, id, payload);
} | javascript | {
"resource": ""
} | |
q26065 | train | function (uri, id) {
var payload = uriHelper.encodePayload(uri);
if (!id) { id = []; }
return ndef.record(ndef.TNF_WELL_KNOWN, ndef.RTD_URI, id, payload);
} | javascript | {
"resource": ""
} | |
q26066 | train | function (uri, payload, id) {
if (!id) { id = []; }
if (!payload) { payload = []; }
return ndef.record(ndef.TNF_ABSOLUTE_URI, uri, id, payload);
} | javascript | {
"resource": ""
} | |
q26067 | train | function (mimeType, payload, id) {
if (!id) { id = []; }
return ndef.record(ndef.TNF_MIME_MEDIA, mimeType, id, payload);
} | javascript | {
"resource": ""
} | |
q26068 | train | function (ndefRecords, id) {
var payload = [];
if (!id) { id = []; }
if (ndefRecords)
{
// make sure we have an array of something like NDEF records before encoding
if (ndefRecords[0] instanceof Object && ndefRecords[0].hasOwnProperty('tnf')) {
p... | javascript | {
"resource": ""
} | |
q26069 | train | function (ndefRecords) {
var encoded = [],
tnf_byte,
record_type,
payload_length,
id_length,
i,
mb, me, // messageBegin, messageEnd
cf = false, // chunkFlag TODO implement
sr, // boolean shortRecord
il; ... | javascript | {
"resource": ""
} | |
q26070 | train | function (ndefBytes) {
// ndefBytes can be an array of bytes e.g. [0x03, 0x31, 0xd1] or a Buffer
var bytes;
// if (ndefBytes instanceof Buffer) {
// // get an array of bytes
// bytes = Array.prototype.slice.call(ndefBytes, 0);
// } else if (ndefBytes instanceof A... | javascript | {
"resource": ""
} | |
q26071 | train | function (tnf_byte) {
return {
mb: (tnf_byte & 0x80) !== 0,
me: (tnf_byte & 0x40) !== 0,
cf: (tnf_byte & 0x20) !== 0,
sr: (tnf_byte & 0x10) !== 0,
il: (tnf_byte & 0x8) !== 0,
tnf: (tnf_byte & 0x7)
};
} | javascript | {
"resource": ""
} | |
q26072 | train | function (mb, me, cf, sr, il, tnf) {
var value = tnf;
if (mb) {
value = value | 0x80;
}
if (me) {
value = value | 0x40;
}
// note if cf: me, mb, li must be false and tnf must be 0x6
if (cf) {
value = value | 0x20;
}
... | javascript | {
"resource": ""
} | |
q26073 | s | train | function s(bytes) {
if (typeof(bytes) === 'string') {
return bytes;
}
return bytes.reduce(function (acc, byte) {
return acc + String.fromCharCode(byte);
}, '')
// return new Buffer(bytes).toString();
} | javascript | {
"resource": ""
} |
q26074 | decode | train | function decode(data) {
var prefix = protocols[data[0]];
if (!prefix) { // 36 to 255 should be ""
prefix = "";
}
return prefix + util.bytesToString(data.slice(1));
} | javascript | {
"resource": ""
} |
q26075 | encode | train | function encode(uri) {
var prefix,
protocolCode,
encoded;
// check each protocol, unless we've found a match
// "urn:" is the one exception where we need to keep checking
// slice so we don't check ""
protocols.slice(1).forEach(function(protocol) {
... | javascript | {
"resource": ""
} |
q26076 | bytesToHexString | train | function bytesToHexString(bytes) {
var dec, hexstring, bytesAsHexString = "";
for (var i = 0; i < bytes.length; i++) {
if (bytes[i] >= 0) {
dec = bytes[i];
} else {
dec = 256 + bytes[i];
}
hexstring = dec.toString(16);
// zero padding
if (hexstring... | javascript | {
"resource": ""
} |
q26077 | toHex | train | function toHex(i) {
var hex;
if (i < 0) {
i += 256;
}
hex = i.toString(16);
// zero padding
if (hex.length == 1) {
hex = "0" + hex;
}
return hex;
} | javascript | {
"resource": ""
} |
q26078 | Authentication | train | function Authentication(auth0, options) {
// If we have two arguments, the first one is a WebAuth instance, so we assign that
// if not, it's an options object and then we should use that as options instead
// this is here because we don't want to break people coming from v8
if (arguments.length === 2) {
th... | javascript | {
"resource": ""
} |
q26079 | train | function() {
var applyTouchMove = function(difference_x, difference_y) {
$this.scrollTop($this.scrollTop() - difference_y);
$this.scrollLeft($this.scrollLeft() - difference_x);
// update bar position
updateBarSizeAndPosition();
};
... | javascript | {
"resource": ""
} | |
q26080 | train | function( obj1, obj2 ) {
var newObj = {};
if ( obj1 ) {
this.inheritAttrs( newObj, this.cloneObj( obj1 ) );
}
if ( obj2 ) {
this.inheritAttrs( newObj, obj2 );
}
return newObj;
} | javascript | {
"resource": ""
} | |
q26081 | train | function() {
if ( $ ) {
Array.prototype.unshift.apply( arguments, [true, {}] );
return $.extend.apply( $, arguments );
}
else {
return UTIL.createMerge.apply( this, arguments );
}
} | javascript | {
"resource": ""
} | |
q26082 | train | function (jsonConfig, treeId ) {
/**
* @param {object} jsonConfig
* @param {number} treeId
* @returns {Tree}
*/
this.reset = function( jsonConfig, treeId ) {
this.initJsonConfig = jsonConfig;
this.initTreeId = treeId;
t... | javascript | {
"resource": ""
} | |
q26083 | train | function( node, level ) {
node.leftNeighborId = this.lastNodeOnLevel[level];
if ( node.leftNeighborId ) {
node.leftNeighbor().rightNeighborId = node.id;
}
this.lastNodeOnLevel[level] = node.id;
return this;
} | javascript | {
"resource": ""
} | |
q26084 | train | function( nodeStructure, id, parentId, tree, stackParentId ) {
this.reset( nodeStructure, id, parentId, tree, stackParentId );
} | javascript | {
"resource": ""
} | |
q26085 | train | function() {
var orientation = this.getTreeConfig().rootOrientation;
if ( this.pseudo ) {
// prevents separating the subtrees
return ( -this.getTreeConfig().subTeeSeparation );
}
if ( orientation === 'NORTH' || orientation === 'SO... | javascript | {
"resource": ""
} | |
q26086 | train | function(startPoint) {
var orient = this.Tree().CONFIG.rootOrientation, point = {};
if ( this.stackParentId ) { // return different end point if node is a stacked child
if ( orient === 'NORTH' || orient === 'SOUTH' ) {
orient = 'WEST';
}... | javascript | {
"resource": ""
} | |
q26087 | train | function( jsonConfig, callback, jQuery ) {
if ( jsonConfig instanceof Array ) {
jsonConfig = JSONconfig.make( jsonConfig );
}
// optional
if ( jQuery ) {
$ = jQuery;
}
this.tree = TreeStore.createTree( jsonConfig );
this.tree.p... | javascript | {
"resource": ""
} | |
q26088 | uniq | train | function uniq(el, arr){
arr = arr && arr.join ? arr : [];
if (!el) return arr.join(' > ');
if (9 == el.nodeType) return arr.join(' > ');
if (1 != el.nodeType) return arr.join(' > ');
arr.unshift(selector(el));
if (el.id) return arr.join(' > ');
return uniq(el.parentNode, arr);
} | javascript | {
"resource": ""
} |
q26089 | selector | train | function selector(el){
var classname = trim(el.className.baseVal ? el.className.baseVal : el.className);
var i = el.parentNode && 9 == el.parentNode.nodeType ? -1 : index(el);
return el.tagName.toLowerCase()
+ (el.id ? '#' + el.id : '')
+ (classname ? classname.replace(/^| +/g, '.') : '')
+ (~i ? ':n... | javascript | {
"resource": ""
} |
q26090 | _clearGeneratorConfig | train | function _clearGeneratorConfig(app, generator) {
if (generator === '*') {
globalConfig.removeAll();
} else {
globalConfig.remove(generator);
}
console.log('Global config has been successfully cleared');
app.navigate('home');
} | javascript | {
"resource": ""
} |
q26091 | parserFor | train | function parserFor(rules) {
// Sorts rules in order of increasing order, then
// ascending rule name in case of ties.
let ruleList = Object.keys(rules);
/* istanbul ignore next */
if (process.env.NODE_ENV !== 'production') {
ruleList.forEach(function(type) {
let order = rules[type].order;
if ... | javascript | {
"resource": ""
} |
q26092 | inlineRegex | train | function inlineRegex(regex) {
return function match(source, state) {
if (state.inline) {
return regex.exec(source);
} else {
return null;
}
};
} | javascript | {
"resource": ""
} |
q26093 | parseSimpleInline | train | function parseSimpleInline(parse, content, state) {
const isCurrentlyInline = state.inline || false;
const isCurrentlySimple = state.simple || false;
state.inline = false;
state.simple = true;
const result = parse(content, state);
state.inline = isCurrentlyInline;
state.simple = isCurrentlySimple;
retur... | javascript | {
"resource": ""
} |
q26094 | train | function(){
res.type('.html');
res.send(_render(tpl, css, {
code: httpStatusCode,
title: pageData.title,
message: pageData.message,
footer: opt.footer
}))
} | javascript | {
"resource": ""
} | |
q26095 | renderTemplate | train | function renderTemplate(template, css, data={}){
// assign css
data.inlinecss = css;
// render template - use custom escape function to handle linebreaks!
return _ejs.render(template, data, {
escape: function(text){
if (!text){
return '';
}
... | javascript | {
"resource": ""
} |
q26096 | readJSONFile | train | async function readJSONFile(filename){
// load file
let raw = await _fs.readFile(filename, 'utf8');
// strip single line js comments
raw = raw.replace(/^\s*\/\/.*$/gm, '');
// parse text
return JSON.parse(raw);
} | javascript | {
"resource": ""
} |
q26097 | log | train | function log(key, value, message, errorLevel = 1) {
const error = {};
// looks for the original item that caused the error
error.entries = colorsSrc.entires.filter((entry) => {
return entry[key] === value;
});
error.message = message;
error.errorLevel = errorLevel;
errors.push(error);
} | javascript | {
"resource": ""
} |
q26098 | commandConvert | train | function commandConvert(command, env, normalize = false) {
if (!isWindows()) {
return command
}
const envUnixRegex = /\$(\w+)|\${(\w+)}/g // $my_var or ${my_var}
const convertedCmd = command.replace(envUnixRegex, (match, $1, $2) => {
const varName = $1 || $2
// In Windows, non-existent variables are... | javascript | {
"resource": ""
} |
q26099 | checkJasmineStatus | train | function checkJasmineStatus() {
// Only inject the source once.
if (jasmineFound) {
return;
}
var found = page.evaluate(function () {
return "jasmine" in window && jasmine.getEnv;
});
if (!found) {
return;
}
jasmineFound = true;
injectReporter();
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.