_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q4700
bcscale
train
function bcscale(scale) { scale = parseInt(scale, 10); if (isNaN(scale)) { return false; } if (scale < 0) { return false; } libbcmath.scale = scale; return true; }
javascript
{ "resource": "" }
q4701
bcdiv
train
function bcdiv(left_operand, right_operand, scale) { var first, second, result; if (typeof(scale) == 'undefined') { scale = libbcmath.scale; } scale = ((scale < 0) ? 0 : scale); // create objects first = libbcmath.bc_init_num(); second = libbcmath.bc_init_num(); result = ...
javascript
{ "resource": "" }
q4702
bcmul
train
function bcmul(left_operand, right_operand, scale) { var first, second, result; if (typeof(scale) == 'undefined') { scale = libbcmath.scale; } scale = ((scale < 0) ? 0 : scale); // create objects first = libbcmath.bc_init_num(); second = libbcmath.bc_init_num(); result = ...
javascript
{ "resource": "" }
q4703
ensureAnArray
train
function ensureAnArray (arr) { if (Object.prototype.toString.call(arr) === '[object Array]') { return arr; } else if (arr === null || arr === void 0) { return []; } else { return [arr]; } }
javascript
{ "resource": "" }
q4704
renderTouches
train
function renderTouches(touches, element) { touches.forEach(function(touch) { var el = document.createElement('div'); el.style.width = '20px'; el.style.height = '20px'; el.style.background = 'red'; el.style.position = 'fixed'; el.style.top =...
javascript
{ "resource": "" }
q4705
trigger
train
function trigger(touches, element, type) { return Simulator.events[Simulator.type].trigger(touches, element, type); }
javascript
{ "resource": "" }
q4706
train
function(msg, errno) { if (output && config.file) { output.close() } if (msg) { stderr.writeLine(msg) } return phantom.exit(errno || 1) }
javascript
{ "resource": "" }
q4707
train
function() { this.n_sign = null; // sign this.n_len = null; /* (int) The number of digits before the decimal point. */ this.n_scale = null; /* (int) The number of digits after the decimal point. */ //this.n_refs = null; /* (int) The number of pointers to this number. */ //this.n...
javascript
{ "resource": "" }
q4708
train
function(str) { var p; p = str.indexOf('.'); if (p==-1) { return libbcmath.bc_str2num(str, 0); } else { return libbcmath.bc_str2num(str, (str.length-p)); } }
javascript
{ "resource": "" }
q4709
train
function(r, ptr, chr, len) { var i; for (i=0;i<len;i++) { r[ptr+i] = chr; } }
javascript
{ "resource": "" }
q4710
train
function(num) { var count; // int var nptr; // int /* Quick check. */ //if (num == BCG(_zero_)) return TRUE; /* Initialize */ count = num.n_len + num.n_scale; nptr = 0; //num->n_value; /* The check */ while ((count > 0) && (num.n_value[nptr++] =...
javascript
{ "resource": "" }
q4711
Conf
train
function Conf(config, _pg) { if (typeof config === 'string') config = {connectionString: config}; this._config = config; this._pg = _pg || pg; this._pool = this._pg.Pool(config); }
javascript
{ "resource": "" }
q4712
train
function (tweets, search, includeHighlighted) { var updated = [], tmp, i = 0; if (typeof search == 'string') { search = this.format(search); } for (i = 0; i < tweets.length; i++) { if (this.match(tweets[i], search, includeHighlighted)) { updated.push(twe...
javascript
{ "resource": "" }
q4713
train
function(){ angular.element(document.querySelector('body')).removeClass('jr_active jr_overlay_show'); removeJoyride(); scope.joyride.current = 0; scope.joyride.transitionStep = true; if (typeof scope.joyride.config.onFinish === "function") { scope.joyride.co...
javascript
{ "resource": "" }
q4714
train
function (connection, collections, cb) { if (!connection.identity) return cb(Errors.IdentityMissing); if (connections[connection.identity]) return cb(Errors.IdentityDuplicate); // Store the connection connections[connection.identity] = { config: connection, collections: collect...
javascript
{ "resource": "" }
q4715
train
function(cb) { var collection = connectionObject.collections[collectionName]; if (!collection) return cb(Errors.CollectionNotRegistered); collection.dropTable(function(err) { // ignore "table does not exist" error if (err && err.code === 8704) return cb(...
javascript
{ "resource": "" }
q4716
addDropdownToMenu
train
function addDropdownToMenu(dropdownName, routerName, glyphiconName, enableTranslation, clientFramework) { let navbarPath; try { if (clientFramework === 'angular1') { navbarPath = `${CLIENT_MAIN_SRC_DIR}app/layouts/navbar/navbar.html`; jhipsterUtils.rewriteFile({ f...
javascript
{ "resource": "" }
q4717
addPageSetsModule
train
function addPageSetsModule(clientFramework) { let appModulePath; try { if (clientFramework !== 'angular1') { appModulePath = `${CLIENT_MAIN_SRC_DIR}app/app.module.ts`; const fullPath = path.join(process.cwd(), appModulePath); let args = { file: appMod...
javascript
{ "resource": "" }
q4718
trigger_service_login
train
function trigger_service_login (msg, respond) { var seneca = this if (!msg.user) { return respond(null, {ok: false, why: 'no-user'}) } var user_data = msg.user var q = {} if (user_data.identifier) { q[msg.service + '_id'] = user_data.identifier user_data[msg.service + '_id'] ...
javascript
{ "resource": "" }
q4719
readPackageJSON
train
function readPackageJSON () { var pkg = JSON.parse(require('fs').readFileSync('./package.json')); var dependencies = pkg.dependencies ? Object.keys(pkg.dependencies) : []; var peerDependencies = pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : []; return { name: pkg.name, deps: dependencies.concat(pe...
javascript
{ "resource": "" }
q4720
initTasks
train
function initTasks (gulp, config) { var pkg = readPackageJSON(); var name = capitalize(camelCase(config.component.pkgName || pkg.name)); config = defaults(config, { aliasify: pkg.aliasify }); config.component = defaults(config.component, { pkgName: pkg.name, dependencies: pkg.deps, name: name, src: 'src', ...
javascript
{ "resource": "" }
q4721
makeOptionsObj
train
function makeOptionsObj(port, host, inUse, retryTimeMs, timeOutMs) { var opts = {}; opts.port = port; opts.host = host; opts.inUse = inUse; opts.retryTimeMs = retryTimeMs; opts.timeOutMs = timeOutMs; return opts; }
javascript
{ "resource": "" }
q4722
cmd_logout
train
function cmd_logout (msg, respond) { var req = msg.req$ // get token from request req.seneca.act("role: 'auth', get: 'token'", {tokenkey: options.tokenkey}, function (err, clienttoken) { if (err) { return req.seneca.act('role: auth, do: respond', {err: err, action: 'logout', req: req}, respon...
javascript
{ "resource": "" }
q4723
extract
train
function extract(str, options, tranformFn) { let extractor = new Extractor(options, tranformFn); return extractor.extract(str); }
javascript
{ "resource": "" }
q4724
train
function( grunt, options, callback ) { this.callback = callback; this.diffCount = 0; this.grunt = grunt; this.options = options; this.options.indexPath = this.getIndexPath(); this.pictureCount = 0; if ( typeof options.template === 'string' ) { this.template...
javascript
{ "resource": "" }
q4725
train
function(treeType) { if (treeType === 'vendor') { // The treeForVendor returns a different value based on whether or not // this addon is a nested dependency return caclculateCacheKeyForTree(treeType, this, [!this.parent.parent]); } else { return this._super.cacheKeyForTree.call(this, tr...
javascript
{ "resource": "" }
q4726
train
function(elem) { this.getOffset._offset = $(elem).offset(); if (Garnish.$scrollContainer[0] !== Garnish.$win[0]) { this.getOffset._offset.top += Garnish.$scrollContainer.scrollTop(); this.getOffset._offset.left += Garnish.$scrollContainer.scrollLeft(); } return ...
javascript
{ "resource": "" }
q4727
train
function(source, target) { var $source = $(source), $target = $(target); $target.css({ fontFamily: $source.css('fontFamily'), fontSize: $source.css('fontSize'), fontWeight: $source.css('fontWeight'), letterSpacing: $source.css('letterSpacing')...
javascript
{ "resource": "" }
q4728
train
function() { Garnish.getBodyScrollTop._scrollTop = document.body.scrollTop; if (Garnish.getBodyScrollTop._scrollTop < 0) { Garnish.getBodyScrollTop._scrollTop = 0; } else { Garnish.getBodyScrollTop._maxScrollTop = Garnish.$bod.outerHeight() - Garnish.$win.height(...
javascript
{ "resource": "" }
q4729
train
function(container, elem) { var $elem; if (typeof elem === 'undefined') { $elem = $(container); $container = $elem.scrollParent(); } else { var $container = $(container); $elem = $(elem); } if ($container.prop('nodeName') ...
javascript
{ "resource": "" }
q4730
train
function(elem, prop) { var $elem = $(elem); if (!prop) { prop = 'margin-left'; } var startingPoint = parseInt($elem.css(prop)); if (isNaN(startingPoint)) { startingPoint = 0; } for (var i = 0; i <= Garnish.SHAKE_STEPS; i++) { ...
javascript
{ "resource": "" }
q4731
train
function(container) { var postData = {}, arrayInputCounters = {}, $inputs = Garnish.findInputs(container); var inputName; for (var i = 0; i < $inputs.length; i++) { var $input = $inputs.eq(i); if ($input.prop('disabled')) { conti...
javascript
{ "resource": "" }
q4732
train
function(ev) { ev.preventDefault(); this.realMouseX = ev.pageX; this.realMouseY = ev.pageY; if (this.settings.axis !== Garnish.Y_AXIS) { this.mouseX = ev.pageX; } if (this.settings.axis !== Garnish.X_AXIS) { this....
javascript
{ "resource": "" }
q4733
train
function($newDraggee) { if (!$newDraggee.length) { return; } if (!this.settings.collapseDraggees) { var oldLength = this.$draggee.length; } this.$draggee = $(this.$draggee.toArray().concat($newDraggee.toArray())); ...
javascript
{ "resource": "" }
q4734
train
function() { this._returningHelpersToDraggees = true; for (var i = 0; i < this.helpers.length; i++) { var $draggee = this.$draggee.eq(i), $helper = this.helpers[i]; $draggee.css({ display: this.draggeeDisplay, ...
javascript
{ "resource": "" }
q4735
train
function() { // Has the mouse moved? if (this.mouseX !== this.lastMouseX || this.mouseY !== this.lastMouseY) { // Get the new target helper positions for (this._updateHelperPos._i = 0; this._updateHelperPos._i < this.helpers.length; this._updateHelperPos._i++) { ...
javascript
{ "resource": "" }
q4736
train
function(i) { return { left: this.getHelperTargetX() + (this.settings.helperSpacingX * i), top: this.getHelperTargetY() + (this.settings.helperSpacingY * i) }; }
javascript
{ "resource": "" }
q4737
train
function() { for (var i = 0; i < this.helpers.length; i++) { (function($draggeeHelper) { $draggeeHelper.velocity('fadeOut', { duration: Garnish.FX_DURATION, complete: function() { $draggeeHelper.r...
javascript
{ "resource": "" }
q4738
train
function(bodyContents) { // Cleanup this.$main.html(''); if (this.$header) { this.$hud.removeClass('has-header'); this.$header.remove(); this.$header = null; } if (this.$footer) { this.$hud.remo...
javascript
{ "resource": "" }
q4739
train
function($item, preventScroll) { if (preventScroll) { var scrollLeft = Garnish.$doc.scrollLeft(), scrollTop = Garnish.$doc.scrollTop(); $item.focus(); window.scrollTo(scrollLeft, scrollTop); } else { ...
javascript
{ "resource": "" }
q4740
train
function(ev) { // ignore right clicks if (ev.which !== Garnish.PRIMARY_CLICK) { return; } // Enfore the filter if (this.settings.filter && !$(ev.target).is(this.settings.filter)) { return; } var $item =...
javascript
{ "resource": "" }
q4741
train
function(item) { var $handle = $.data(item, 'select-handle'); if ($handle) { $handle.removeData('select-item'); this.removeAllListeners($handle); } $.removeData(item, 'select'); $.removeData(item, 'select-handle'); ...
javascript
{ "resource": "" }
q4742
loadCurrentVersion
train
function loadCurrentVersion (options, context) { return new Extension(options, context).read() .then(function (response) { let version = response.sys.version; options.version = version; return options; }); }
javascript
{ "resource": "" }
q4743
train
function(err) { notify.onError({ title: "Garnish", message: "Error: <%= error.message %>", sound: "Beep" })(err); console.log( 'plumber error!' ); this.emit('end'); }
javascript
{ "resource": "" }
q4744
all
train
function all(subreddit) { const eventEmitter = new EventEmitter(); function emitRandomImage(subreddit) { randomPuppy(subreddit).then(imageUrl => { eventEmitter.emit('data', imageUrl + '#' + subreddit); if (eventEmitter.listeners('data').length) { setTimeout(() =>...
javascript
{ "resource": "" }
q4745
train
function(dbOrUri, stream, callback) { if (arguments.length === 2) { callback = stream; stream = undefined; } if (!stream) { stream = process.stdout; } var db; var out = stream; var endOfCollection = crypto.pseudoRandomBytes(8).toString('base64'); write({ type: 'mo...
javascript
{ "resource": "" }
q4746
escapes
train
function escapes(options) { var settings = options || {} if (settings.commonmark) { return commonmark } return settings.gfm ? gfm : defaults }
javascript
{ "resource": "" }
q4747
parseModifiers
train
function parseModifiers(packet, bits) { /* eslint-disable no-bitwise */ /* eslint-disable no-param-reassign */ packet.modifiers.l_control = ((bits & 1) !== 0); packet.modifiers.l_shift = ((bits & 2) !== 0); packet.modifiers.l_alt = ((bits & 4) !== 0); packet.modifiers.l_meta = ((bits & 8) !== 0); packet.m...
javascript
{ "resource": "" }
q4748
parseKeyCodes
train
function parseKeyCodes(arr, keys) { if (typeof keys !== 'object') { return false; } keys.forEach((key) => { if (key > 3) { arr.keyCodes.push(key); } }); return true; }
javascript
{ "resource": "" }
q4749
parseErrorState
train
function parseErrorState(packet, state) { let states = 0; state.forEach((s) => { if (s === 1) { states += 1; } }); if (states >= 6) { packet.errorStatus = true; // eslint-disable-line no-param-reassign } }
javascript
{ "resource": "" }
q4750
stack
train
function stack(e) { return { toString: function() { // first line is err.message, which we already show, so start from // second line return e.stack.substr(e.stack.indexOf('\n')); }, toJSON: function() { return stacktrace.parse(e); } }; }
javascript
{ "resource": "" }
q4751
getFirstHeader
train
function getFirstHeader (req, header) { const value = req.headers[header] return (Array.isArray(value) ? value[0] : value).split(', ')[0] }
javascript
{ "resource": "" }
q4752
Application
train
function Application(ctx, config) { // validate params if (!ctx && !config) { // both empty ctx = document; config = {}; } else if (Utils.isNode(config)) { // reverse order of arguments var tmpConfig = config; config = ctx; ctx = tmpConfig; } else if (!Utils.isNode(ctx) && !config) { // only confi...
javascript
{ "resource": "" }
q4753
train
function (options, callback) { LOG.debug('preauth#createPreauth called'); LOG.debug('Validating options'); try { options = new preauthOptions.CreatePreauth().validate(options); } catch (err) { if (err.name === 'InvalidOption') { LOG.error('In...
javascript
{ "resource": "" }
q4754
loadCss
train
function loadCss() { var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, application.cssFile); var applicationCss; if (FSA.fileExists(cssFileName)) { FSA.readText(cssFileName, function (r) { applicationCss = r; }); //noinspection JSUnusedAssignment application.cssSelec...
javascript
{ "resource": "" }
q4755
loadPageCss
train
function loadPageCss(cssFile) { var cssFileName; // Eliminate the ./ on the file if present so that we can add the full path if (cssFile.startsWith("./")) { cssFile = cssFile.substring(2); } if (cssFile.startsWith(UpdaterSingleton.currentAppPath())) { cssFileName = cssFile; } e...
javascript
{ "resource": "" }
q4756
ResponseApi
train
function ResponseApi(constructorOptions) { LOG.debug('Instantiating new response object'); LOG.debug('Validating options'); try { this.options = new responseOptions.Constructor().validate(constructorOptions); } catch (err) { LOG.error('Received error: %s', err); ...
javascript
{ "resource": "" }
q4757
wrapFieldsWithMiddleware
train
function wrapFieldsWithMiddleware(type, deepWrap = true, typeMet = {}) { if (!type) { return; } let fields = type._fields; typeMet[type.name] = true; for (let label in fields) { let field = fields[label]; if (field && !typeMet[field.type.name]) { if (!!field && typeof field == 'object') { ...
javascript
{ "resource": "" }
q4758
reloadPage
train
function reloadPage(page, isModal) { if (!LiveEditSingleton.enabled()) { return; } var t = frameCommon.topmost(); if (!t) { return; } if (!page) { if (!t.currentEntry || !t.currentEntry.entry) { return; } page = t.currentEntry.entry.moduleNa...
javascript
{ "resource": "" }
q4759
isWatching
train
function isWatching(fileName) { for (var i=0;i<watching.length;i++) { if (fileName.endsWith(watching[i])) { return true; } } //noinspection RedundantIfStatementJS if (fileName.toLowerCase().lastIndexOf("restart.livesync") === (fileName.length - 16)) { return true; ...
javascript
{ "resource": "" }
q4760
normalPushADB
train
function normalPushADB(fileName, options, callback) { if (typeof options === "function") { callback = options; options = null; } var srcFile = fileName; if (options && typeof options.srcFile === "string") { srcFile = options.srcFile; } var check = false; if (options ...
javascript
{ "resource": "" }
q4761
getWatcher
train
function getWatcher(dir) { return function (event, fileName) { if (event === "rename") { verifyWatches(); if (fileName) { if (!fs.existsSync(dir + fileName)) { return; } var dirStat; try { dirStat = fs.statSync(dir +...
javascript
{ "resource": "" }
q4762
setupWatchers
train
function setupWatchers(path) { // We want to track the watchers now and return if we are already watching this folder if (watchingFolders[path]) { return; } watchingFolders[path] = fs.watch(path, getWatcher(path + "/")); watchingFolders[path].on('error', function() { verifyWatches(); }); var fileL...
javascript
{ "resource": "" }
q4763
CommunicationApi
train
function CommunicationApi(constructorOptions) { LOG.debug('Instantiating communication API'); LOG.debug('Validating constructor options'); // Sanitize option eventually throwing an InvalidOption try { this.options = new communicationOptions.Constructor().validate(constructorOptio...
javascript
{ "resource": "" }
q4764
RequestApi
train
function RequestApi(constructorOptions) { LOG.debug('Instantiating new Request object'); LOG.debug('Validating options'); try { this.options = new requestOptions.Constructor().validate(constructorOptions); } catch (err) { LOG.error('Received error: %s', err); th...
javascript
{ "resource": "" }
q4765
round
train
function round(num, dec) { var pow = Math.pow(10, dec); return Math.round(num * pow) / pow; }
javascript
{ "resource": "" }
q4766
jsonEncoder
train
function jsonEncoder(input, path) { var output = new Stream(); output.readable = true; var first = true; input.on("data", function (entry) { if (path) { entry.href = path + entry.name; var mime = entry.linkStat ? entry.linkStat.mime : entry.mime; if (mime && mime.match(/(di...
javascript
{ "resource": "" }
q4767
train
function (options) { var result = { type: options.actionType }; if (options.channelName) { result.channel = options.channelName } if (options.eventName) { result.event = options.eventName } if (options.data) { result.data = options.data } if (options.additionalParams) { result.addi...
javascript
{ "resource": "" }
q4768
_characterFromEvent
train
function _characterFromEvent(e) { // for keypress events we should return the character as is if (e.type == 'keypress') { var character = String.fromCharCode(e.which); // if the shift key is not pressed then it is safe to assume // that we want the character to be l...
javascript
{ "resource": "" }
q4769
_eventModifiers
train
function _eventModifiers(e) { var modifiers = []; if (e.shiftKey) { modifiers.push('shift'); } if (e.altKey) { modifiers.push('alt'); } if (e.ctrlKey) { modifiers.push('ctrl'); } if (e.metaKey) { modifier...
javascript
{ "resource": "" }
q4770
_pickBestAction
train
function _pickBestAction(key, modifiers, action) { // if no action was picked in we should try to pick the one // that we think would work best for this key if (!action) { action = _getReverseMap()[key] ? 'keydown' : 'keypress'; } // modifier keys don't work as expe...
javascript
{ "resource": "" }
q4771
_resetSequences
train
function _resetSequences(doNotReset) { doNotReset = doNotReset || {}; var activeSequences = false, key; for (key in _sequenceLevels) { if (doNotReset[key]) { activeSequences = true; continue; } ...
javascript
{ "resource": "" }
q4772
_handleKeyEvent
train
function _handleKeyEvent(e) { // normalize e.which for key events // @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion if (typeof e.which !== 'number') { e.which = e.keyCode; } var character = _cha...
javascript
{ "resource": "" }
q4773
_bindSingle
train
function _bindSingle(combination, callback, action, sequenceName, level) { // store a direct mapped reference for use with Mousetrap.trigger self._directMap[combination + ':' + action] = callback; // make sure multiple spaces in a row become a single space combination =...
javascript
{ "resource": "" }
q4774
train
function(remoteWindow, remoteOrigin) { this.remoteWindow = remoteWindow; this.remoteOrigin = remoteOrigin; this.timeout = 3000; this.handshaken = false; this.handshake = pinkySwearPromise(); this._id = 0; this._queue = []; this._sent = {}; var _this = this; window.addEventListe...
javascript
{ "resource": "" }
q4775
train
function () { var args = arguments; var len = names.length; if (this instanceof ctr) { if (args.length !== len) { throw new Error( 'Unexpected number of arguments for ' + ctr.className + ': ' + 'got ' + args.length + ', but need ' + len + '.' ); ...
javascript
{ "resource": "" }
q4776
train
function () { var ctr = this.constructor; var names = ctr.__names__; var args = [], i = 0, n, val; for (; n = names[i]; i++) { val = this[n]; args[i] = val instanceof adt.__Base__ ? val.clone() : adt.nativeClone(val); } return ctr.apply(null, args...
javascript
{ "resource": "" }
q4777
train
function (that) { var ctr = this.constructor; if (this === that) return true; if (!(that instanceof ctr)) return false; var names = ctr.__names__; var i = 0, len = names.length; var vala, valb, n; for (; i < len; i++) { n = names[i], vala = this[n], valb = that[n]; ...
javascript
{ "resource": "" }
q4778
train
function (field) { var ctr = this.constructor; var names = ctr.__names__; var constraints = ctr.__constraints__; if (typeof field === 'number') { if (field < 0 || field > names.length - 1) { throw new Error('Field index out of range: ' + field); } field = names[...
javascript
{ "resource": "" }
q4779
addOrder
train
function addOrder (that) { if (that.constructor) that = that.constructor; that.__order__ = order++; return that; }
javascript
{ "resource": "" }
q4780
makeRequire
train
function makeRequire(relModuleMap, enableBuildCallback, altRequire) { var modRequire = makeContextModuleFunc(altRequire || context.require, relModuleMap, enableBuildCallback); mixin(modRequire, { nameToUrl: makeContextModuleFunc(context.nameToUrl, relModuleMap), ...
javascript
{ "resource": "" }
q4781
makeArgCallback
train
function makeArgCallback(manager, i) { return function (value) { //Only do the work if it has not been done //already for a dependency. Cycle breaking //logic in forceExec could mean this function //is called more than once for a given dependen...
javascript
{ "resource": "" }
q4782
addWait
train
function addWait(manager) { if (!waiting[manager.id]) { waiting[manager.id] = manager; waitAry.push(manager); context.waitCount += 1; } }
javascript
{ "resource": "" }
q4783
toAstArray
train
function toAstArray(ary) { var output = [ 'array', [] ], i, item; for (i = 0; (item = ary[i]); i++) { output[1].push([ 'string', item ]); } return output; }
javascript
{ "resource": "" }
q4784
train
function (fileContents, fileName) { //Uglify's ast generation removes comments, so just convert to ast, //then back to source code to get rid of comments. return uglify.uglify.gen_code(uglify.parser.parse(fileContents), true); }
javascript
{ "resource": "" }
q4785
makeWriteFile
train
function makeWriteFile(anonDefRegExp, namespaceWithDot, layer) { function writeFile(name, contents) { logger.trace('Saving plugin-optimized file: ' + name); file.saveUtf8File(name, contents); } writeFile.asModule = function (moduleName, fileName, contents) { ...
javascript
{ "resource": "" }
q4786
setBaseUrl
train
function setBaseUrl(fileName) { //Use the file name's directory as the baseUrl if available. dir = fileName.replace(/\\/g, '/'); if (dir.indexOf('/') !== -1) { dir = dir.split('/'); dir.pop(); dir = dir.join('/'); exec("require({baseUrl: '" + dir +...
javascript
{ "resource": "" }
q4787
validateCompoundWithType
train
function validateCompoundWithType(attribute, values) { for(var i in values) { var value = values[i]; if(typeof(value) !== 'object') { errors.push([attribute + '-' + i, "not-an-object"]); } else if(! value.type) { ...
javascript
{ "resource": "" }
q4788
train
function(key, value) { console.log('add attribute', key, value); if(! value) { return; } if(VCard.multivaluedKeys[key]) { if(this[key]) { console.log('multivalued push'); this[key].push(value) ...
javascript
{ "resource": "" }
q4789
train
function(aDate, bDate, addSub) { if(typeof(addSub) == 'undefined') { addSub = true }; if(! aDate) { return bDate; } if(! bDate) { return aDate; } var a = Number(aDate); var b = Number(bDate); var c = addSub ? a + b : a - b; return new D...
javascript
{ "resource": "" }
q4790
train
function(str){ str = (str || "").toString(); str = str.replace(/\=(?:\r?\n|$)/g, ""); var str2 = ""; for(var i=0, len = str.length; i<len; i++){ chr = str.charAt(i); if(chr == "=" && (hex = str.substr(i+1, 2)) && /[\da-fA-F]{2}/.test(hex)){...
javascript
{ "resource": "" }
q4791
addParentNodeInterfaceToPrototype
train
function addParentNodeInterfaceToPrototype(p) { Object.defineProperty(p, "firstElementChild", { get: function firstElementChild() { var el = this.firstChild; while (el && el.nodeType !== 1) { el = el.nextSibling; } return el; }, }); Object.definePropert...
javascript
{ "resource": "" }
q4792
addChildrenToPrototype
train
function addChildrenToPrototype(p) { // Unfortunately, it is not possible to emulate the liveness of the // HTMLCollection this property *should* provide. Object.defineProperty(p, "children", { get: function children() { var ret = []; var el = this.firstElementChild; while (el)...
javascript
{ "resource": "" }
q4793
captureConfigObject
train
function captureConfigObject(config) { let captured; const require = {}; require.config = function _config(conf) { captured = conf; }; let wedConfig; // eslint-disable-next-line no-unused-vars function define(name, obj) { if (wedConfig !== undefined) { throw new Error("more than one define...
javascript
{ "resource": "" }
q4794
_reset
train
function _reset() { terminating = false; if (termination_timeout) { termination_window.clearTimeout(termination_timeout); termination_timeout = undefined; } $modal.off(); $modal.modal("hide"); $modal.remove(); }
javascript
{ "resource": "" }
q4795
showModal
train
function showModal(saveMessages, errorMessage) { $(document.body).append($modal); $modal.find(".save-messages")[0].innerHTML = saveMessages; $modal.find(".error-message")[0].textContent = errorMessage; $modal.on("hide.bs.modal.modal", function hidden() { $modal.remove(); window.location.relo...
javascript
{ "resource": "" }
q4796
lazyCache
train
function lazyCache(requireFn) { var cache = {}; return function proxy(name, alias) { var key = alias; // camel-case the module `name` if `alias` is not defined if (typeof key !== 'string') { key = camelcase(name); } // create a getter to lazily invoke the module the first time it's call...
javascript
{ "resource": "" }
q4797
getDestinationDir
train
function getDestinationDir(vFile) { if (vFile.data.destinationDir) { return vFile.data.destinationDir; } return vFile.dirname; }
javascript
{ "resource": "" }
q4798
parseUrl
train
function parseUrl(url, normalize = false) { if (typeof url !== "string" || !url.trim()) { throw new Error("Invalid url.") } if (normalize) { if (typeof normalize !== "object") { normalize = { stripFragment: false } } url = normalizeUrl(...
javascript
{ "resource": "" }
q4799
train
function(query, data, successCallback, failureCallback) { if(typeof successCallback != "function") successCallback = function(){}; if(typeof failureCallback != "function") failureCallback = function(){ return _throw(new jSQL_Error("0054")); }; var i, l, remaining; if(!Array.isArray(data[0])) data = [data]...
javascript
{ "resource": "" }