_id stringlengths 2 6 | title stringlengths 0 58 | partition stringclasses 3
values | text stringlengths 52 373k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q56100 | ErrorDisplay | train | function ErrorDisplay(player, options) {
_classCallCheck(this, ErrorDisplay);
var _this = _possibleConstructorReturn(this, _ModalDialog.call(this, player, options));
_this.on(player, 'error', _this.open);
return _this;
} | javascript | {
"resource": ""
} |
q56101 | ModalDialog | train | function ModalDialog(player, options) {
_classCallCheck(this, ModalDialog);
var _this = _possibleConstructorReturn(this, _Component.call(this, player, options));
_this.opened_ = _this.hasBeenOpened_ = _this.hasBeenFilled_ = false;
_this.closeable(!_this.options_.uncloseable);
_this.content(_this.... | javascript | {
"resource": ""
} |
q56102 | loadTrack | train | function loadTrack(src, track) {
var opts = {
uri: src
};
var crossOrigin = (0, _url.isCrossOrigin)(src);
if (crossOrigin) {
opts.cors = crossOrigin;
}
(0, _xhr2['default'])(opts, Fn.bind(this, function (err, response, responseBody) {
if (err) {
return _log2['default'].error(err, respons... | javascript | {
"resource": ""
} |
q56103 | bufferedPercent | train | function bufferedPercent(buffered, duration) {
var bufferedDuration = 0;
var start = void 0;
var end = void 0;
if (!duration) {
return 0;
}
if (!buffered || !buffered.length) {
buffered = (0, _timeRanges.createTimeRange)(0, 0);
}
for (var i = 0; i < buffered.length; i++) {
start = buffere... | javascript | {
"resource": ""
} |
q56104 | createEl | train | function createEl() {
var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'div';
var properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var el = _document2['d... | javascript | {
"resource": ""
} |
q56105 | textContent | train | function textContent(el, text) {
if (typeof el.textContent === 'undefined') {
el.innerText = text;
} else {
el.textContent = text;
}
} | javascript | {
"resource": ""
} |
q56106 | insertElFirst | train | function insertElFirst(child, parent) {
if (parent.firstChild) {
parent.insertBefore(child, parent.firstChild);
} else {
parent.appendChild(child);
}
} | javascript | {
"resource": ""
} |
q56107 | getElData | train | function getElData(el) {
var id = el[elIdAttr];
if (!id) {
id = el[elIdAttr] = Guid.newGUID();
}
if (!elData[id]) {
elData[id] = {};
}
return elData[id];
} | javascript | {
"resource": ""
} |
q56108 | removeElData | train | function removeElData(el) {
var id = el[elIdAttr];
if (!id) {
return;
}
// Remove all stored data
delete elData[id];
// Remove the elIdAttr property from the DOM node
try {
delete el[elIdAttr];
} catch (e) {
if (el.removeAttribute) {
el.removeAttribute(elIdAttr);
} else {
... | javascript | {
"resource": ""
} |
q56109 | hasElClass | train | function hasElClass(element, classToCheck) {
throwIfWhitespace(classToCheck);
if (element.classList) {
return element.classList.contains(classToCheck);
}
return classRegExp(classToCheck).test(element.className);
} | javascript | {
"resource": ""
} |
q56110 | addElClass | train | function addElClass(element, classToAdd) {
if (element.classList) {
element.classList.add(classToAdd);
// Don't need to `throwIfWhitespace` here because `hasElClass` will do it
// in the case of classList not being supported.
} else if (!hasElClass(element, classToAdd)) {
element.className = (eleme... | javascript | {
"resource": ""
} |
q56111 | removeElClass | train | function removeElClass(element, classToRemove) {
if (element.classList) {
element.classList.remove(classToRemove);
} else {
throwIfWhitespace(classToRemove);
element.className = element.className.split(/\s+/).filter(function (c) {
return c !== classToRemove;
}).join(' ');
}
return element... | javascript | {
"resource": ""
} |
q56112 | setElAttributes | train | function setElAttributes(el, attributes) {
Object.getOwnPropertyNames(attributes).forEach(function (attrName) {
var attrValue = attributes[attrName];
if (attrValue === null || typeof attrValue === 'undefined' || attrValue === false) {
el.removeAttribute(attrName);
} else {
el.setAttribute(att... | javascript | {
"resource": ""
} |
q56113 | normalizeContent | train | function normalizeContent(content) {
// First, invoke content if it is a function. If it produces an array,
// that needs to happen before normalization.
if (typeof content === 'function') {
content = content();
}
// Next up, normalize to an array, so one or many items can be normalized,
// filtered, ... | javascript | {
"resource": ""
} |
q56114 | _cleanUpEvents | train | function _cleanUpEvents(elem, type) {
var data = Dom.getElData(elem);
// Remove the events of a particular type if there are none left
if (data.handlers[type].length === 0) {
delete data.handlers[type];
// data.handlers[type] = null;
// Setting to null was causing an error with data.handlers
// ... | javascript | {
"resource": ""
} |
q56115 | off | train | function off(elem, type, fn) {
// Don't want to add a cache object through getElData if not needed
if (!Dom.hasElData(elem)) {
return;
}
var data = Dom.getElData(elem);
// If no events exist, nothing to unbind
if (!data.handlers) {
return;
}
if (Array.isArray(type)) {
return _handleMultip... | javascript | {
"resource": ""
} |
q56116 | trigger | train | function trigger(elem, event, hash) {
// Fetches element data and a reference to the parent (for bubbling).
// Don't want to add a data object to cache for every parent,
// so checking hasElData first.
var elemData = Dom.hasElData(elem) ? Dom.getElData(elem) : {};
var parent = elem.parentNode || elem.ownerDoc... | javascript | {
"resource": ""
} |
q56117 | ParsingError | train | function ParsingError(errorData, message) {
this.name = "ParsingError";
this.code = errorData.code;
this.message = message || errorData.message;
} | javascript | {
"resource": ""
} |
q56118 | parseTimeStamp | train | function parseTimeStamp(input) {
function computeSeconds(h, m, s, f) {
return (h | 0) * 3600 + (m | 0) * 60 + (s | 0) + (f | 0) / 1000;
}
var m = input.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);
if (!m) {
return null;
}
if (m[3]) {
// Timestamp takes the form of [hours]:[min... | javascript | {
"resource": ""
} |
q56119 | train | function(k, dflt, defaultKey) {
if (defaultKey) {
return this.has(k) ? this.values[k] : dflt[defaultKey];
}
return this.has(k) ? this.values[k] : dflt;
} | javascript | {
"resource": ""
} | |
q56120 | train | function(k, v, a) {
for (var n = 0; n < a.length; ++n) {
if (v === a[n]) {
this.set(k, v);
break;
}
}
} | javascript | {
"resource": ""
} | |
q56121 | train | function(k, v) {
var m;
if ((m = v.match(/^([\d]{1,3})(\.[\d]*)?%$/))) {
v = parseFloat(v);
if (v >= 0 && v <= 100) {
this.set(k, v);
return true;
}
}
return false;
} | javascript | {
"resource": ""
} | |
q56122 | consumeTimeStamp | train | function consumeTimeStamp() {
var ts = parseTimeStamp(input);
if (ts === null) {
throw new ParsingError(ParsingError.Errors.BadTimeStamp,
"Malformed timestamp: " + oInput);
}
// Remove time stamp from input.
input = input.replace(/^[^\sa-zA-Z-]+/, "");... | javascript | {
"resource": ""
} |
q56123 | consumeCueSettings | train | function consumeCueSettings(input, cue) {
var settings = new Settings();
parseOptions(input, function (k, v) {
switch (k) {
case "region":
// Find the last region we parsed with the same region id.
for (var i = regionList.length - 1; i >= 0; i--) {
if (region... | javascript | {
"resource": ""
} |
q56124 | createElement | train | function createElement(type, annotation) {
var tagName = TAG_NAME[type];
if (!tagName) {
return null;
}
var element = window.document.createElement(tagName);
element.localName = tagName;
var name = TAG_ANNOTATION[type];
if (name && annotation) {
element[name] = ... | javascript | {
"resource": ""
} |
q56125 | BoxPosition | train | function BoxPosition(obj) {
var isIE8 = (/MSIE\s8\.0/).test(navigator.userAgent);
// Either a BoxPosition was passed in and we need to copy it, or a StyleBox
// was passed in and we need to copy the results of 'getBoundingClientRect'
// as the object returned is readonly. All co-ordinate values are in ... | javascript | {
"resource": ""
} |
q56126 | shouldCompute | train | function shouldCompute(cues) {
for (var i = 0; i < cues.length; i++) {
if (cues[i].hasBeenReset || !cues[i].displayState) {
return true;
}
}
return false;
} | javascript | {
"resource": ""
} |
q56127 | parseRegion | train | function parseRegion(input) {
var settings = new Settings();
parseOptions(input, function (k, v) {
switch (k) {
case "id":
settings.set(k, v);
break;
case "width":
settings.percent(k, v);
break;
case "lines":
... | javascript | {
"resource": ""
} |
q56128 | prettifyJson | train | function prettifyJson(str) {
var json = JSON.parse(str);
return JSON.stringify(json, null, 2);
} | javascript | {
"resource": ""
} |
q56129 | unwrapItems | train | function unwrapItems(schema) {
if (_.isEmpty(schema.items))
schema.items = {};
else {
assert(_.isPlainObject(schema.items[0]));
schema.items = schema.items[0];
}
return schema;
} | javascript | {
"resource": ""
} |
q56130 | init | train | function init(settings) {
var opts = settings || {},
i;
if (opts.onError !== false) {
Canadarm.setUpOnErrorHandler();
}
if (opts.wrapEvents !== false) {
Canadarm.setUpEventListening();
}
if (opts.appenders) {
for (i = 0; i < opts.appenders.length; i++) {
Canadarm.addAppender(opts.ap... | javascript | {
"resource": ""
} |
q56131 | gatherErrors | train | function gatherErrors(level, exception, message, data, appenders) {
var logAttributes = {},
localAppenders = appenders || errorAppenders,
errorAppender, attributeName, attributes, i, key;
// Go over every log appender and add it's attributes so we can log them.
for (i = 0; i < localAppenders.length; i++)... | javascript | {
"resource": ""
} |
q56132 | pushErrors | train | function pushErrors(logAttributes, handlers) {
var localHandlers = handlers || errorHandlers,
errorHandler, i;
// Go over every log handler so we can actually create logs.
for (i = 0; i < localHandlers.length; i++) {
errorHandler = localHandlers[i];
errorHandler(logAttributes);
}
} | javascript | {
"resource": ""
} |
q56133 | customLogEvent | train | function customLogEvent(level) {
// options should contain the appenders and handlers to override the
// global ones defined in errorAppenders, and errorHandlers.
// Used by Canadarm.localWatch to wrap local appender calls.
return function (message, exception, data, settings) {
// If we are are below the ... | javascript | {
"resource": ""
} |
q56134 | consoleLogHandler | train | function consoleLogHandler(logAttributes) {
var logValues = '', key;
if (console) {
// detect IE
if (window.attachEvent) {
// Put attributes into a format that are easy for IE 8 to read.
for (key in logAttributes) {
if (!logAttributes.hasOwnProperty(key)) {
continue;
}... | javascript | {
"resource": ""
} |
q56135 | _onError | train | function _onError(errorMessage, url, lineNumber, columnNumber, exception) {
var onErrorReturn;
// Execute the original window.onerror handler, if any
if (_oldOnError && typeof _oldOnError === 'function') {
onErrorReturn = _oldOnError.apply(this, arguments);
}
Canadarm.fatal(errorMessage, exception, {
... | javascript | {
"resource": ""
} |
q56136 | findStackData | train | function findStackData(stack) {
// If the stack is not in the error we cannot get any information and
// should return immediately.
if (stack === undefined || stack === null) {
return {
'url': Canadarm.constant.UNKNOWN_LOG,
'lineNumber': Canadarm.constant.UNKNOWN_LOG,
'columnNu... | javascript | {
"resource": ""
} |
q56137 | train | function() {
// NOTE: This fixed issue #7
// https://github.com/vowstar/gitbook-plugin-uml/issues/7
// HTML will load after this operation
// Copy images to output folder every time
var book = this;
var output = book.output;
var rootPat... | javascript | {
"resource": ""
} | |
q56138 | processFileByModifiedTime | train | function processFileByModifiedTime(stream, firstPass, basePath, file, cache) {
var newTime = file.stat && file.stat.mtime;
var filePath = basePath ? path.relative(basePath, file.path) : file.path;
var oldTime = cache[filePath];
cache[filePath] = newTime.getTime();
if ((!oldTime && firstPass) || (oldTime && ... | javascript | {
"resource": ""
} |
q56139 | processFileBySha1Hash | train | function processFileBySha1Hash(stream, firstPass, basePath, file, cache) {
// null cannot be hashed
if (file.contents === null) {
// if element is really a file, something weird happened, but it's safer
// to assume it was changed (because we cannot said that it wasn't)
// if it's not a file, we don't c... | javascript | {
"resource": ""
} |
q56140 | build | train | async function build( previousFileSizes ) {
console.log( 'Creating an optimized production build...' );
const filenames = await getFilenames( FILENAMES );
const webpackConfig = await createWebpackConfig( config( filenames ) );
const compiler = webpack( webpackConfig );
return new Promise( ( resolve, reject ) => ... | javascript | {
"resource": ""
} |
q56141 | constructCode | train | function constructCode(code, system, display) {
const codeObj = new models.Concept(system, code, display);
return codeObj;
} | javascript | {
"resource": ""
} |
q56142 | shorthandFromCodesystem | train | function shorthandFromCodesystem(cs) {
if (!cs) {
return '';
}
if (shorthands[cs]) {
return shorthands[cs];
} else if (cs.match(/http:\/\/standardhealthrecord.org\/shr\/[A-Za-z]*\/cs\/(#[A-Za-z]*CS)/)) {
return '';
} else {
return cs;
}
} | javascript | {
"resource": ""
} |
q56143 | formattedCodeFromConcept | train | function formattedCodeFromConcept(concept) {
var formattedConceptCode = `${shorthandFromCodesystem(concept.system)}#${concept.code}`;
if (concept.display) {
formattedConceptCode = `${formattedConceptCode} "${concept.display}"`;
} else if (concept.description) {
formattedConceptCode = `${formattedConceptCo... | javascript | {
"resource": ""
} |
q56144 | train | function( elem, name, isXML ) {
var ret;
return isXML ?
undefined :
(ret = elem.getAttributeNode( name )) && ret.value !== "" ?
ret.value :
null;
} | javascript | {
"resource": ""
} | |
q56145 | train | function( flag, needsFlag ) {
// optIn defaults implicit behavior to weak exclusion
if ( optIn && !modules[ flag ] && !modules[ "+" + flag ] ) {
excluded[ flag ] = false;
}
// explicit or inherited strong exclusion
if ( excluded[ needsFlag ] || modules[ "-" + flag ] ) {
excluded[ f... | javascript | {
"resource": ""
} | |
q56146 | getEachForSource | train | function getEachForSource(source) {
if (source.length < 40) {
return UniqueArrayWrapper.prototype.eachNoCache;
} else if (source.length < 100) {
return UniqueArrayWrapper.prototype.eachArrayCache;
} else {
return UniqueArrayWrapper.prototype.eachSetCache;
}
} | javascript | {
"resource": ""
} |
q56147 | createCallback | train | function createCallback(callback, defaultValue) {
switch (typeof callback) {
case "function":
return callback;
case "string":
return function(e) {
return e[callback];
};
case "object":
return function(e) {
return Lazy(callback).all(function(val... | javascript | {
"resource": ""
} |
q56148 | createSet | train | function createSet(values) {
var set = new Set();
Lazy(values || []).flatten().each(function(e) {
set.add(e);
});
return set;
} | javascript | {
"resource": ""
} |
q56149 | compare | train | function compare(x, y, fn) {
if (typeof fn === "function") {
return compare(fn(x), fn(y));
}
if (x === y) {
return 0;
}
return x > y ? 1 : -1;
} | javascript | {
"resource": ""
} |
q56150 | forEach | train | function forEach(array, fn) {
var i = -1,
len = array.length;
while (++i < len) {
if (fn(array[i], i) === false) {
return false;
}
}
return true;
} | javascript | {
"resource": ""
} |
q56151 | arrayContains | train | function arrayContains(array, element) {
var i = -1,
length = array.length;
// Special handling for NaN
if (element !== element) {
while (++i < length) {
if (array[i] !== array[i]) {
return true;
}
}
return false;
}
while (++i < length) {
i... | javascript | {
"resource": ""
} |
q56152 | arrayContainsBefore | train | function arrayContainsBefore(array, element, index, keyFn) {
var i = -1;
if (keyFn) {
keyFn = createCallback(keyFn);
while (++i < index) {
if (keyFn(array[i]) === keyFn(element)) {
return true;
}
}
} else {
while (++i < index) {
if (array[i] === el... | javascript | {
"resource": ""
} |
q56153 | swap | train | function swap(array, i, j) {
var temp = array[i];
array[i] = array[j];
array[j] = temp;
} | javascript | {
"resource": ""
} |
q56154 | defineSequenceType | train | function defineSequenceType(base, name, overrides) {
/** @constructor */
var ctor = function ctor() {};
// Make this type inherit from the specified base.
ctor.prototype = new base();
// Attach overrides to the new sequence type's prototype.
for (var override in overrides) {
ctor.prototy... | javascript | {
"resource": ""
} |
q56155 | getDirectoriesInURL | train | function getDirectoriesInURL()
{
var trail = document.location.pathname.split( PATH_SEPARATOR );
// check whether last section is a file or a directory
var lastcrumb = trail[trail.length-1];
for( var i = 0; i < FILE_EXTENSIONS.length; i++ )
{
if( lastcrumb.indexOf( FILE_EXTENSIONS[i] ) )
{
// it is, remove... | javascript | {
"resource": ""
} |
q56156 | getCrumbTrail | train | function getCrumbTrail( crumbs )
{
var xhtml = DISPLAY_PREPREND;
for( var i = 0; i < crumbs.length; i++ )
{
xhtml += '<a href="' + crumbs[i][1] + '" >';
xhtml += unescape( crumbs[i][0] ) + '</a>';
if( i != (crumbs.length-1) )
{
xhtml += DISPLAY_SEPARATOR;
}
}
xhtml += DISPLAY_POSTPREND;
return xht... | javascript | {
"resource": ""
} |
q56157 | getCrumbTrailXHTML | train | function getCrumbTrailXHTML( crumbs )
{
var xhtml = '<span class="' + CSS_CLASS_TRAIL + '">';
xhtml += DISPLAY_PREPREND;
for( var i = 0; i < crumbs.length; i++ )
{
xhtml += '<a href="' + crumbs[i][1] + '" class="' + CSS_CLASS_CRUMB + '">';
xhtml += unescape( crumbs[i][0] ) + '</a>';
if( i != (crumbs.length-... | javascript | {
"resource": ""
} |
q56158 | train | function(categoryName) {
// Use default logger if categoryName is not specified or invalid
if (!(typeof categoryName == "string")) {
categoryName = "[default]";
}
if (!Log4js.loggers[categoryName]) {
// Create the logger for this name if it doesn't already exist
Log4js.loggers[categoryName] = new L... | javascript | {
"resource": ""
} | |
q56159 | train | function (element, name, observer) {
if (element.addEventListener) { //DOM event model
element.addEventListener(name, observer, false);
} else if (element.attachEvent) { //M$ event model
element.attachEvent('on' + name, observer);
}
} | javascript | {
"resource": ""
} | |
q56160 | train | function(sArg, defaultLevel) {
if(sArg === null) {
return defaultLevel;
}
if(typeof sArg == "string") {
var s = sArg.toUpperCase();
if(s == "ALL") {return Log4js.Level.ALL;}
if(s == "DEBUG") {return Log4js.Level.DEBUG;}
if(s == "INFO") {return Log4js.Level.INFO;}
if(s ... | javascript | {
"resource": ""
} | |
q56161 | train | function(appender) {
if (appender instanceof Log4js.Appender) {
appender.setLogger(this);
this.appenders.push(appender);
} else {
throw "Not instance of an Appender: " + appender;
}
} | javascript | {
"resource": ""
} | |
q56162 | train | function(appenders) {
//clear first all existing appenders
for(var i = 0; i < this.appenders.length; i++) {
this.appenders[i].doClear();
}
this.appenders = appenders;
for(var j = 0; j < this.appenders.length; j++) {
this.appenders[j].setLogger(this);
}
} | javascript | {
"resource": ""
} | |
q56163 | train | function(logLevel, message, exception) {
var loggingEvent = new Log4js.LoggingEvent(this.category, logLevel,
message, exception, this);
this.loggingEvents.push(loggingEvent);
this.onlog.dispatch(loggingEvent);
} | javascript | {
"resource": ""
} | |
q56164 | train | function(msg, url, line){
var message = "Error in (" + (url || window.location) + ") on line "+ line +" with message (" + msg + ")";
this.log(Log4js.Level.FATAL, message, null);
} | javascript | {
"resource": ""
} | |
q56165 | train | function(logger){
// add listener to the logger methods
logger.onlog.addListener(Log4js.bind(this.doAppend, this));
logger.onclear.addListener(Log4js.bind(this.doClear, this));
this.logger = logger;
} | javascript | {
"resource": ""
} | |
q56166 | train | function(loggingEvent) {
log4jsLogger.trace("> AjaxAppender.append");
if (this.loggingEventMap.length() <= this.threshold || this.isInProgress === true) {
this.loggingEventMap.push(loggingEvent);
}
if(this.loggingEventMap.length() >= this.threshold && this.isInProgress === false) {
//if threshold is ... | javascript | {
"resource": ""
} | |
q56167 | train | function() {
if(this.loggingEventMap.length() >0) {
log4jsLogger.trace("> AjaxAppender.send");
this.isInProgress = true;
var a = [];
for(var i = 0; i < this.loggingEventMap.length() && i < this.threshold; i++) {
a.push(this.layout.format(this.loggingEventMap.pull()));
}
var ... | javascript | {
"resource": ""
} | |
q56168 | train | function() {
log4jsLogger.trace("> AjaxAppender.getXmlHttpRequest");
var httpRequest = false;
try {
if (window.XMLHttpRequest) { // Mozilla, Safari, IE7...
httpRequest = new XMLHttpRequest();
if (httpRequest.overrideMimeType) {
httpRequest.overrideMimeType(this.layout.getContentType());
... | javascript | {
"resource": ""
} | |
q56169 | train | function(ex) {
if (ex) {
var exStr = "\t<log4js:throwable>";
if (ex.message) {
exStr += "\t\t<log4js:message><![CDATA[" + this.escapeCdata(ex.message) + "]]></log4js:message>\n";
}
if (ex.description) {
exStr += "\t\t<log4js:description><![CDATA[" + this.escapeCdata(ex.description) + "]]></lo... | javascript | {
"resource": ""
} | |
q56170 | SlackBot | train | function SlackBot(config) {
this.config = config || {};
this.commands = {};
this.aliases = {};
if (!this.config.structureResponse) {
this.config.structureResponse = function (response) {
return response;
};
}
} | javascript | {
"resource": ""
} |
q56171 | translate | train | function translate(load){
var filename;
//!steal-remove-start
filename = getFilename(load.name);
//!steal-remove-end
var result = parse(load.source, this, zoneOpts);
// Add any import specifiers to the load.
addImportSpecifiers(load, result);
load.metadata.originalSource = load.source;
// ... | javascript | {
"resource": ""
} |
q56172 | ensure_element_id | train | function ensure_element_id(element) {
if (!element.id || element.id === '') {
element.id = config.generate_random_id('ac_element');
return true;
}
return false;
} | javascript | {
"resource": ""
} |
q56173 | _attach | train | function _attach(ngmodel, target_element, options) {
// Element is already attached.
if (current_element === target_element) {
return;
}
// Safe: clear previously attached elements.
if (current_element) {
that.detach();
}
// The element is st... | javascript | {
"resource": ""
} |
q56174 | set_selection | train | function set_selection(i) {
// We use value instead of setting the model's view value
// because we watch the model value and setting it will trigger
// a new suggestion cycle.
var selected = $scope.results[i];
current_element.val(selected.value);
$scope.selected_index = ... | javascript | {
"resource": ""
} |
q56175 | fetchChatList | train | async function fetchChatList() {
return _makeSimulatedNetworkRequest((resolve, reject) => {
resolve(backendStateForLoggedInPerson.chats.map(chat => chat.name));
});
} | javascript | {
"resource": ""
} |
q56176 | fetchChat | train | async function fetchChat(name) {
return _makeSimulatedNetworkRequest((resolve, reject) => {
resolve(
backendStateForLoggedInPerson.chats.find(
chat => chat.name === name
)
);
});
} | javascript | {
"resource": ""
} |
q56177 | sendMessage | train | async function sendMessage({name, message}) {
return _makeSimulatedNetworkRequest((resolve, reject) => {
const chatForName = backendStateForLoggedInPerson.chats.find(
chat => chat.name === name
);
if (chatForName) {
chatForName.messages.push({
name: 'Me',
text: message,
}... | javascript | {
"resource": ""
} |
q56178 | getInverseDependencies | train | function getInverseDependencies(resolutionResponse) {
const cache = new Map();
resolutionResponse.dependencies.forEach(module => {
resolveModuleRequires(resolutionResponse, module).forEach(dependency => {
getModuleDependents(cache, dependency).add(module);
});
});
return cache;
} | javascript | {
"resource": ""
} |
q56179 | copyToClipBoard | train | function copyToClipBoard(content) {
switch (process.platform) {
case 'darwin':
var child = spawn('pbcopy', []);
child.stdin.end(new Buffer(content, 'utf8'));
return true;
case 'win32':
var child = spawn('clip', []);
child.stdin.end(new Buffer(content, 'utf8'));
return true;
default:
... | javascript | {
"resource": ""
} |
q56180 | recurse | train | function recurse (obj, manifest, path, remoteCall) {
for(var name in manifest) (function (name, type) {
var _path = path ? path.concat(name) : [name]
obj[name] =
isObject(type)
? recurse({}, type, _path, remoteCall)
: function () {
return remoteCall(type, _path, [].slice.call(arg... | javascript | {
"resource": ""
} |
q56181 | buildBabelConfig | train | function buildBabelConfig(filename, options) {
const babelRC = getBabelRC(options.projectRoots);
const extraConfig = {
code: false,
filename,
};
let config = Object.assign({}, babelRC, extraConfig);
// Add extra plugins
const extraPlugins = [externalHelpersPlugin];
var inlineRequires = options... | javascript | {
"resource": ""
} |
q56182 | once | train | function once (fn) {
var done = false
return function (err, val) {
if(done) return
done = true
fn(err, val)
}
} | javascript | {
"resource": ""
} |
q56183 | library | train | function library(argv, config, args) {
if (!isValidPackageName(args.name)) {
return Promise.reject(
args.name + ' is not a valid name for a project. Please use a valid ' +
'identifier name (alphanumeric).'
);
}
const root = process.cwd();
const libraries = path.resolve(root, 'Libraries');
... | javascript | {
"resource": ""
} |
q56184 | eject | train | function eject() {
const doesIOSExist = fs.existsSync(path.resolve('ios'));
const doesAndroidExist = fs.existsSync(path.resolve('android'));
if (doesIOSExist && doesAndroidExist) {
console.error(
'Both the iOS and Android folders already exist! Please delete `ios` and/or `android` ' +
'before eje... | javascript | {
"resource": ""
} |
q56185 | copyAndReplace | train | function copyAndReplace(srcPath, destPath, replacements, contentChangedCallback) {
if (fs.lstatSync(srcPath).isDirectory()) {
if (!fs.existsSync(destPath)) {
fs.mkdirSync(destPath);
}
// Not recursive
return;
}
const extension = path.extname(srcPath);
if (binaryExtensions.indexOf(extensio... | javascript | {
"resource": ""
} |
q56186 | BigNumber | train | function BigNumber(number) {
this.numberStr = number.toString();
// not a number
if (isNaN(parseFloat(this.numberStr)) === true
|| isFinite(this.numberStr) === false) {
throw new Error(number + ' is not a number');
}
} | javascript | {
"resource": ""
} |
q56187 | callYarnOrNpm | train | function callYarnOrNpm(yarnCommand, npmCommand) {
let command;
if (isYarnAvailable) {
command = yarnCommand;
} else {
command = npmCommand;
}
const args = command.split(' ');
const cmd = args.shift();
const res = spawnSync(cmd, args, spawnOpts);
return res;
} | javascript | {
"resource": ""
} |
q56188 | link | train | function link(args, config) {
var project;
try {
project = config.getProjectConfig();
} catch (err) {
log.error(
'ERRPACKAGEJSON',
'No package found. Are you sure it\'s a React Native project?'
);
return Promise.reject(err);
}
let packageName = args[0];
// Check if install packa... | javascript | {
"resource": ""
} |
q56189 | addJestToPackageJson | train | function addJestToPackageJson(destinationRoot) {
var packageJSONPath = path.join(destinationRoot, 'package.json');
var packageJSON = JSON.parse(fs.readFileSync(packageJSONPath));
packageJSON.scripts.test = 'jest';
packageJSON.jest = {
preset: 'react-native'
};
fs.writeFileSync(packageJSONPath, JSON.str... | javascript | {
"resource": ""
} |
q56190 | isValidBody | train | function isValidBody(body) {
return (
body === undefined ||
typeof body === 'string' ||
(typeof FormData !== 'undefined' && body instanceof FormData) ||
(typeof URLSearchParams !== 'undefined' && body instanceof URLSearchParams)
);
} | javascript | {
"resource": ""
} |
q56191 | string2utf8Bytes | train | function string2utf8Bytes(s) {
var utf8 = unescape(encodeURIComponent(s)),
len = utf8.length,
bytes = new Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = utf8.charCodeAt(i);
}
return bytes;
} | javascript | {
"resource": ""
} |
q56192 | findPrev | train | function findPrev(type/*: string*/, element/*: Cheerio*/) {
let tries = 5
let prev = element
do {
if (prev.is(type)) {
return prev
}
prev = prev.prev()
}
while (--tries)
return prev
} | javascript | {
"resource": ""
} |
q56193 | findNext | train | function findNext(type, element) {
let tries = 5
let next = element
do {
if (next.is(type)) {
return next
}
next = next.next()
}
while (--tries)
return next
} | javascript | {
"resource": ""
} |
q56194 | smartComment | train | function smartComment(description/*:string*/ = '', links/*: string[]*/ = []) {
const descriptionLines = description.replace(/(.{1,72}\s)\s*?/g, '\n * $1')
const linksLines = links.reduce((acc, link) => (
`${acc} * @see ${link}\n`
), '')
return commentBlock(`*${descriptionLines}\n${linksLines} `)
} | javascript | {
"resource": ""
} |
q56195 | fixImportedSourceMap | train | function fixImportedSourceMap(file, state, callback) {
if (!state.map) {
return callback();
}
state.map.sourcesContent = state.map.sourcesContent || [];
nal.map(state.map.sources, normalizeSourcesAndContent, callback);
function assignSourcesContent(sourceContent, idx) {
state.map.sourcesContent[idx... | javascript | {
"resource": ""
} |
q56196 | FlashWS | train | function FlashWS (options) {
WS.call(this, options);
this.flashPath = options.flashPath;
this.policyPort = options.policyPort;
} | javascript | {
"resource": ""
} |
q56197 | log | train | function log (type) {
return function(){
var str = Array.prototype.join.call(arguments, ' ');
debug('[websocketjs %s] %s', type, str);
};
} | javascript | {
"resource": ""
} |
q56198 | load | train | function load (arr, fn) {
function process (i) {
if (!arr[i]) return fn();
create(arr[i], function () {
process(++i);
});
};
process(0);
} | javascript | {
"resource": ""
} |
q56199 | saveCategoryList | train | function saveCategoryList(categoryObject){
var destinationPath = config.dest + 'db_category_list.json';
grunt.file.write(destinationPath, JSON.stringify(categoryObject, null, 4));
grunt.log.writeln('Prefixed file "' + destinationPath + '" created.');
} | javascript | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.