_id
stringlengths
2
6
title
stringlengths
0
58
partition
stringclasses
3 values
text
stringlengths
52
373k
language
stringclasses
1 value
meta_information
dict
q50800
processItem
train
function processItem(params) { var nestedMenu = extractNestedMenu(params); // if html property is not defined, fallback to text, otherwise use default text // if first item in the item array is a function then invoke .call() // if first item is a string, then text should be the ...
javascript
{ "resource": "" }
q50801
renderContextMenu
train
function renderContextMenu (params) { /// <summary>Render context menu recursively.</summary> // Destructuring: var $scope = params.$scope; var event = params.event; var options = params.options; var modelValue = params.modelValue; var level = param...
javascript
{ "resource": "" }
q50802
removeContextMenus
train
function removeContextMenus (level) { while (_contextMenus.length && (!level || _contextMenus.length > level)) { var cm = _contextMenus.pop(); $rootScope.$broadcast(ContextMenuEvents.ContextMenuClosed, { context: _clickedElement, contextMenu: cm }); cm.remove(); }...
javascript
{ "resource": "" }
q50803
resolveBoolOrFunc
train
function resolveBoolOrFunc(a, params, defaultValue) { var item = params.item; var $scope = params.$scope; var event = params.event; var modelValue = params.modelValue; defaultValue = isBoolean(defaultValue) ? defaultValue : true; if (isBoolean(a)) { ...
javascript
{ "resource": "" }
q50804
ModuleDef
train
function ModuleDef (path) { this.path = path; this.friendlyPath = path; util.splitPath(path, this); this.directory = util.resolve(ENV.getCwd(), this.directory); }
javascript
{ "resource": "" }
q50805
loadModule
train
function loadModule (baseLoader, fromDir, fromFile, item, opts) { var modulePath = item.from; var possibilities = util.resolveModulePath(modulePath, fromDir); for (var i = 0, p; p = possibilities[i]; ++i) { var path = possibilities[i].path; if (!opts.reload && (path in jsio.__modules))...
javascript
{ "resource": "" }
q50806
train
function() { var packageName; var parentFolderName = path.basename(path.resolve('..')); var isSubPackage = parentFolderName === 'node_modules'; var isLocalDepsAvailable = fs.existsSync('node_modules/grunt-autoprefixer') && fs.existsSync('node_modules/grunt-contrib-cssmin'); if (isSubPackage && !isL...
javascript
{ "resource": "" }
q50807
train
function (req, res, parseObj) { var data = {}; var body = req.body; var reqID = body.id || req.query.id; var cats = body.cats || req.query.cats; var reqFilter = body.filter || req.query.filter; var reqFilterOut = body.filterOut || req.query.filterOut; var parsedData = parseObj; var msgD...
javascript
{ "resource": "" }
q50808
train
function (req, res, parseObj) { var data = {}; var body = req.body; var reqID = body.id || req.query.id; var reqSections = body.sections || req.query.sections; var sections = reqSections ? reqSections.split(',') : undefined; var parsedData = parseObj; var msgDataNotFound = 'API: HTML data n...
javascript
{ "resource": "" }
q50809
train
function (req, res, dataPath) { var body = req.body; var data = body.data; var dataUnflatten = body.unflatten; if (dataUnflatten) { data = unflatten(data, { delimiter: '/', overwrite: 'root' }); } htmlTree.writeDataFile(data, true, dataPath, function(err, finalData){ if (err ||...
javascript
{ "resource": "" }
q50810
train
function (req, res, dataPath) { var body = req.body; var reqID = body.id || req.query.id; htmlTree.deleteFromDataFile(dataPath, reqID, function(err, finalData){ if (err || !finalData) { res.status(config.statusCodes.error).json({ message: err }); } el...
javascript
{ "resource": "" }
q50811
train
function() { var navHash = utils.parseNavHash(); openSpoiler($(navHash)); //Close other closed by default sections for (var i = 0; i < sectionsOnPage.length; i++) { var t = $(sectionsOnPage[i]); var tID = t.attr('id'); if...
javascript
{ "resource": "" }
q50812
train
function(config, data) { var isNewInstance = !context; context = context || this; context.data = data ? data : initialBlocksData; if (!isNewInstance) { context.render(); return context; } var modulesOptions = context.options.modulesOptions; modulesOptions.modalBox = $.e...
javascript
{ "resource": "" }
q50813
train
function() { new Css('/source/assets/js/lib/prism/prism.css', 'core'); var selection = onlyStatic ? $('.source_section pre[class*="src-"].source_visible > code') : $('.source_section pre[class*="src-"] > code'); selection.each(function () { var _this =...
javascript
{ "resource": "" }
q50814
train
function() { $('.source_container').on('click', '.' + SourceCodeToggle, function (e) { e.preventDefault(); var codeCnt = $(this).closest('.' + SourceCode); codeCnt.toggleClass(SourceCodeMin); }); }
javascript
{ "resource": "" }
q50815
train
function () { var headersLength = sourceHeaders.length; var minDistance = Number.MAX_VALUE; var closestHeader = -1; var fileNameInUrl = filename === '' ? '' : filename + '.' + extension; if ((document.body.scrollTop || document.documentElement.scrollTop) < hashThreshold) { if (!!window.location.h...
javascript
{ "resource": "" }
q50816
train
function(options, section, option, value) { var req = {url: this.urlPrefix + "/_config/"}; if (section) { req.url += encodeURIComponent(section) + "/"; if (option) { req.url += encodeURIComponent(option); } } if (value === null) { req.type = "DELETE"; ...
javascript
{ "resource": "" }
q50817
train
function(options) { $.extend(options, {successStatus: 202}); ajax({ type: "POST", url: this.uri + "_compact", data: "", processData: false }, options, "The database could not be compacted" ); }
javascript
{ "resource": "" }
q50818
getChangesSince
train
function getChangesSince() { var opts = $.extend({heartbeat : 10 * 1000}, options, { feed : "longpoll", since : since }); ajax( {url: db.uri + "_changes"+encodeOptions(opts)}, options, "Error connecting to "+db.uri...
javascript
{ "resource": "" }
q50819
train
function(docId, options, ajaxOptions) { options = options || {}; if (db_opts.attachPrevRev || options.attachPrevRev) { $.extend(options, { beforeSuccess : function(req, doc) { rawDocs[doc._id] = { rev : doc._rev, raw : req...
javascript
{ "resource": "" }
q50820
train
function(doc, options) { options = options || {}; var db = this; var beforeSend = fullCommit(options); if (doc._id === undefined) { var method = "POST"; var uri = this.uri; } else { var method = "PUT"; var uri = this.uri +...
javascript
{ "resource": "" }
q50821
train
function(docs, options) { var beforeSend = fullCommit(options); $.extend(options, {successStatus: 201, beforeSend : beforeSend}); ajax({ type: "POST", url: this.uri + "_bulk_docs" + encodeOptions(options), contentType: "application/json", data: toJ...
javascript
{ "resource": "" }
q50822
train
function(docs, options){ docs.docs = $.each( docs.docs, function(i, doc){ doc._deleted = true; } ); $.extend(options, {successStatus: 201}); ajax({ type: "POST", url: this.uri + "_bulk_docs" + encodeOptions(options...
javascript
{ "resource": "" }
q50823
train
function(propName, options, ajaxOptions) { ajax({url: this.uri + propName + encodeOptions(options)}, options, "The property could not be retrieved", ajaxOptions ); }
javascript
{ "resource": "" }
q50824
train
function(propName, propValue, options, ajaxOptions) { ajax({ type: "PUT", url: this.uri + propName + encodeOptions(options), data : JSON.stringify(propValue) }, options, "The property could not be updated", ajaxOptions ...
javascript
{ "resource": "" }
q50825
train
function(source, target, ajaxOptions, repOpts) { repOpts = $.extend({source: source, target: target}, repOpts); if (repOpts.continuous && !repOpts.cancel) { ajaxOptions.successStatus = 202; } ajax({ type: "POST", url: this.urlPrefix + "/_replicate", data: JSON.stringi...
javascript
{ "resource": "" }
q50826
train
function(cacheNum) { if (cacheNum === undefined) { cacheNum = 1; } if (!uuidCache.length) { ajax({url: this.urlPrefix + "/_uuids", data: {count: cacheNum}, async: false}, { success: function(resp) { uuidCache = resp.uuids; } ...
javascript
{ "resource": "" }
q50827
askAndroidPrompt
train
function askAndroidPrompt() { prompt.get({ name: 'using_android', description: 'Are you using Android (y/n)', default: 'y' }, function(err, result) { if (err) { return console.log(err); } mergeConfig(result); askAndroidPromptResult(result); ...
javascript
{ "resource": "" }
q50828
promptQuestions
train
function promptQuestions() { prompt.get([{ name: 'api_key', description: 'Your Fabric API Key', default: '' }, { name: 'api_secret', description: 'Your Fabric API Secret', default: '' }], function(err, result) { if (err) { return console.lo...
javascript
{ "resource": "" }
q50829
writePodFile
train
function writePodFile(result) { if (!fs.existsSync(directories.ios)) { fs.mkdirSync(directories.ios); } try { fs.writeFileSync(directories.ios + '/Podfile', `use_frameworks! pod 'Fabric', '${FABRIC_IOS_FABRIC}' pod 'Crashlytics', '${FABRIC_IOS_CRASHLYTICS}' # Crashlytics works be...
javascript
{ "resource": "" }
q50830
writeGradleFile
train
function writeGradleFile() { if (!fs.existsSync(directories.android)) { fs.mkdirSync(directories.android); } try { fs.writeFileSync(directories.android + '/include.gradle', ` android { } buildscript { repositories { maven { url 'https://maven.fabric.io/public' } } } re...
javascript
{ "resource": "" }
q50831
writeFabricServiceGradleHook
train
function writeFabricServiceGradleHook(config) { console.log("Install Fabric-build-gradle hook."); try { if (!fs.existsSync(path.join(appRoot, "hooks"))) { fs.mkdirSync(path.join(appRoot, "hooks")); } if (!fs.existsSync(path.join(appRoot, "hooks", "after-prepare"))) { ...
javascript
{ "resource": "" }
q50832
defer
train
function defer(fn) { var nextTick = typeof setImmediate == 'function' ? setImmediate : ( typeof process == 'object' && typeof process.nextTick == 'function' ? process.nextTick : null ); if (nextTick) { nextTick(fn); } else { setTimeout(fn, 0); } }
javascript
{ "resource": "" }
q50833
readFile
train
function readFile (archive, name, opts, cb) { if (typeof opts === 'function') { cb = opts opts = {} } return maybe(cb, async function () { opts = opts || {} if (typeof opts === 'string') { opts = { encoding: opts } } opts.encoding = toValidEncoding(opts.encoding) // check that ...
javascript
{ "resource": "" }
q50834
readdir
train
function readdir (archive, name, opts, cb) { if (typeof opts === 'function') { cb = opts opts = {} } opts = opts || {} return maybe(cb, async function () { // options var recursive = (opts && !!opts.recursive) // run first readdir var promise = new Promise((resolve, reject) => { ...
javascript
{ "resource": "" }
q50835
exportArchiveToFilesystem
train
function exportArchiveToFilesystem (opts, cb) { return maybe(cb, async function () { assert(opts && typeof opts === 'object', 'opts object is required') // core arguments, dstPath and srcArchive var srcArchive = opts.srcArchive var dstPath = opts.dstPath assert(srcArchive && typeof srcArchive ===...
javascript
{ "resource": "" }
q50836
readManifest
train
function readManifest (archive, cb) { return maybe(cb, async function () { var data = await readFile(archive, DAT_MANIFEST_FILENAME) data = JSON.parse(data.toString()) if (data.links) data.links = massageLinks(data.links) return data }) }
javascript
{ "resource": "" }
q50837
writeManifest
train
function writeManifest (archive, manifest, cb) { manifest = generateManifest(manifest) return writeFile(archive, DAT_MANIFEST_FILENAME, JSON.stringify(manifest, null, 2), cb) }
javascript
{ "resource": "" }
q50838
updateManifest
train
function updateManifest (archive, updates, cb) { return maybe(cb, async function () { var manifest try { manifest = await readManifest(archive) } catch (e) { manifest = {} } Object.assign(manifest, generateManifest(updates)) return writeManifest(archive, manifest) }) }
javascript
{ "resource": "" }
q50839
generateManifest
train
function generateManifest (manifest = {}) { var { url, title, description, type, author, links, web_root, fallback_page } = manifest if (isString(url)) manifest.url = url else delete manifest.url if (isString(title)) manifest.title = title else delete manifest.title if (isString(description)) manifest.descr...
javascript
{ "resource": "" }
q50840
stat
train
function stat (archive, name, cb) { return maybe(cb, new Promise((resolve, reject) => { // run stat operation archive.stat(name, (err, st) => { if (err) reject(toBeakerError(err, 'stat')) else { // read download status st.downloaded = 0 if (!archive.key) { // fs, ...
javascript
{ "resource": "" }
q50841
Version
train
function Version(major, minor, micro, build) { if (typeof major === "number" && major % 1 === 0) this._major = major; else throw new Error("Invalid major version number '" + major + "'"); if (typeof minor === "number" && minor % 1 === 0) this._minor = minor; else throw ...
javascript
{ "resource": "" }
q50842
initMembers
train
function initMembers(rootPath) { this._rootPath = rootPath; ShellJS.mkdir(this._rootPath); this._appPath = this._rootPath + Path.sep + "app"; ShellJS.mkdir(this._appPath); this._logPath = Path.join(OS.tmpdir(), "crosswalk-app-tools-" + this._packageId); ShellJS.mkdir(this._logPath); // P...
javascript
{ "resource": "" }
q50843
TemplateFile
train
function TemplateFile(path) { this._buffer = FS.readFileSync(path, {"encoding": "utf8"}); if (!this._buffer || this._buffer.length === 0) { throw new Error("Could not read " + path); } }
javascript
{ "resource": "" }
q50844
OutputTee
train
function OutputTee(logfileOutput, terminalOutput) { this._outputs = []; this._outputs[_OUTPUT_TEE_LOGFILE] = logfileOutput; this._outputs[_OUTPUT_TEE_TERMINAL] = terminalOutput; }
javascript
{ "resource": "" }
q50845
WinPlatform
train
function WinPlatform(PlatformBase, baseData) { // Create base instance. var instance = new PlatformBase(baseData); // Override manually, because Object.extend() is not yet available on node. var names = Object.getOwnPropertyNames(WinPlatform.prototype); for (var i = 0; i < names.length; i++) { ...
javascript
{ "resource": "" }
q50846
CrosswalkZip
train
function CrosswalkZip(path) { this._adm = new AdmZip(path); // Derive root entry name from the filename var base = Path.basename(path, ".zip"); this._root = base + "/"; // Extract version var version = base.split("-")[1]; var numbers = version.split("."); this._version = new Version(+...
javascript
{ "resource": "" }
q50847
AndroidPlatform
train
function AndroidPlatform(PlatformBase, baseData) { // Create base instance. var instance = new PlatformBase(baseData); var o = instance.output; // Override manually, because Object.extend() is not yet available on node. var names = Object.getOwnPropertyNames(AndroidPlatform.prototype); for (va...
javascript
{ "resource": "" }
q50848
CrosswalkDir
train
function CrosswalkDir(path) { this._path = path; this._root = "./"; var versionFilePath = Path.join(path, "VERSION"); if (ShellJS.test("-f", versionFilePath)) { this._version = Version.createFromFile(versionFilePath); } else { this._version = Version.createFromPath(path); } ...
javascript
{ "resource": "" }
q50849
Download01Org
train
function Download01Org(application, platform, channel) { this._application = application; if (Download01Org.PLATFORMS.indexOf(platform) == -1) { throw new Error("Unknown platform " + platform); } this._platform = platform; if (Download01Org.CHANNELS.indexOf(channel) == -1) { throw...
javascript
{ "resource": "" }
q50850
LogfileOutput
train
function LogfileOutput(path) { this._path = path; var options = { flags: "w", mode: 0600 }; FS.writeFileSync(this._path, ""); /* TODO if (!this._fp) { throw new FileCreationFailed("Could not open file " + path); } */ }
javascript
{ "resource": "" }
q50851
PlatformInfo
train
function PlatformInfo(PlatformCtor, platformId) { this._Ctor = PlatformCtor; this._platformId = platformId; // Prefix all platform-specific args with the platform name var argSpec = PlatformCtor.getArgs ? PlatformCtor.getArgs() : {}; this._argSpec = {}; for (var cmd in argSpec) { var c...
javascript
{ "resource": "" }
q50852
CommandParser
train
function CommandParser(output, argv) { this._output = output; if (!(argv instanceof Array)) { throw new TypeError("CommandParser(argv) must be of type Array."); } this._argv = argv; }
javascript
{ "resource": "" }
q50853
AndroidManifest
train
function AndroidManifest(output, path) { this._output = output; this._path = path; var doc = this.read(); this._package = doc.documentElement.getAttribute("package"); this._versionCode = doc.documentElement.getAttribute("android:versionCode"); this._versionName = doc.documentElement.getAttribu...
javascript
{ "resource": "" }
q50854
WixSDK
train
function WixSDK(rootPath, manifest, output) { this._rootPath = rootPath; this._manifest = manifest; this._output = output; this._existing_ids = {}; }
javascript
{ "resource": "" }
q50855
installExtensionDlls
train
function installExtensionDlls(source_dir_path, dest_folder_object) { var app_files = readDir.readSync(source_dir_path); app_files.forEach(function (name) { var suffix = name.substring(name.length - ".dll".length); if (suffix && suffix.toLowerCase() === ".dll") { ...
javascript
{ "resource": "" }
q50856
updateObjWith
train
function updateObjWith (obj, upd) { for (const key in upd) { obj[key] = upd[key] } return obj }
javascript
{ "resource": "" }
q50857
inferRAMLTypeName
train
function inferRAMLTypeName (fileName) { const cleanName = fileName.replace(/^.*[\\/]/, '') const filename = cleanName.split('.')[0] return capitalize(filename) }
javascript
{ "resource": "" }
q50858
dt2jsCLI
train
function dt2jsCLI (ramlFile, ramlTypeName) { const rootFileDir = ramlFile.split(path.sep).slice(0, -1).join(path.sep) const ramlData = fs.readFileSync(ramlFile).toString() dt2js.setBasePath(rootFileDir) return dt2js.dt2js(ramlData, ramlTypeName) }
javascript
{ "resource": "" }
q50859
js2dtCLI
train
function js2dtCLI (jsonFile, ramlTypeName) { const jsonData = fs.readFileSync(jsonFile).toString() if (ramlTypeName != null) { const raml = js2dt.js2dt(jsonData, ramlTypeName) return `#%RAML 1.0 Library\n${yaml.safeDump({ types: raml }, { 'noRefs': true })}` } else { const typeName = 'this__should__b...
javascript
{ "resource": "" }
q50860
getRAMLContext
train
function getRAMLContext (ramlData, rootFileDir) { rootFileDir = rootFileDir || '.' const ast = yap.load(ramlData) const libraries = extractLibraries(ast, rootFileDir) const jsContent = {} traverse(jsContent, ast, rootFileDir, libraries) return jsContent.types }
javascript
{ "resource": "" }
q50861
destringify
train
function destringify (val) { if (!isNaN(Number(val))) return Number(val) if (val === 'true') return true if (val === 'false') return false return val }
javascript
{ "resource": "" }
q50862
traverse
train
function traverse (obj, ast, rootFileDir, libraries) { function recurse (keys, currentNode, nodeFileDir) { if (currentNode.key) { keys = keys.concat([currentNode.key.value]) } // kind 5 is an include if (currentNode.value && currentNode.value.kind === 5) { const location = currentNode.valu...
javascript
{ "resource": "" }
q50863
dt2js
train
function dt2js (ramlData, typeName) { const ctx = getRAMLContext(ramlData, basePath) if (!(ctx instanceof Object)) throw new Error('Invalid RAML data') if (ctx[typeName] === undefined) throw new Error('type ' + typeName + ' does not exist') const expanded = expandedForm(ctx[typeName], ctx) const canonical =...
javascript
{ "resource": "" }
q50864
processArray
train
function processArray (arr, reqStack) { const accum = [] arr.forEach(function (el) { accum.push(schemaForm(el, reqStack)) }) return accum }
javascript
{ "resource": "" }
q50865
convertType
train
function convertType (data) { switch (data.type) { case 'union': // If union of arrays if (Array.isArray(data.anyOf) && data.anyOf[0].type === 'array') { const items = data.anyOf.map(function (e) { return e.items }) data.items = { anyOf: [] } data.items.anyOf = items da...
javascript
{ "resource": "" }
q50866
convertFileType
train
function convertFileType (data) { data['type'] = 'string' data['media'] = { 'binaryEncoding': 'binary' } if (data.fileTypes) { data['media']['anyOf'] = [] data.fileTypes.forEach(function (el) { data['media']['anyOf'].push({ 'mediaType': el }) }) delete data.fileTypes } return data }
javascript
{ "resource": "" }
q50867
convertDateType
train
function convertDateType (data) { switch (data.type) { case 'date-only': data['type'] = 'string' data['pattern'] = constants.dateOnlyPattern break case 'time-only': data['type'] = 'string' data['pattern'] = constants.timeOnlyPattern break case 'datetime-only': dat...
javascript
{ "resource": "" }
q50868
convertPatternProperties
train
function convertPatternProperties (data) { Object.keys(data.properties).map(function (key) { if (/^\/.*\/$/.test(key)) { data.patternProperties = data.patternProperties || {} const stringRegex = key.slice(1, -1) data.patternProperties[stringRegex] = data.properties[key] delete data.propert...
javascript
{ "resource": "" }
q50869
processNested
train
function processNested (data, reqStack) { const updateWith = {} for (const key in data) { const val = data[key] if (val instanceof Array) { updateWith[key] = processArray(val, reqStack) continue } if (val instanceof Object) { updateWith[key] = schemaForm(val, reqStack, key) ...
javascript
{ "resource": "" }
q50870
schemaForm
train
function schemaForm (data, reqStack = [], prop) { if (!(data instanceof Object)) { return data } const lastEl = reqStack[reqStack.length - 1] if (data.type && data.required !== false && lastEl && prop) { if (lastEl.props.indexOf(prop) > -1 && (prop[0] + prop[prop.length - 1]) !== '//') { lastEl.re...
javascript
{ "resource": "" }
q50871
js2dt
train
function js2dt (jsonData, typeName) { const data = JSON.parse(jsonData) const raml = new RamlConverter(data, typeName).toRaml() return raml }
javascript
{ "resource": "" }
q50872
convertAdditionalProperties
train
function convertAdditionalProperties (data, additionalProperties) { if (additionalProperties !== undefined) { let val = data if (typeof additionalProperties === 'boolean') val = additionalProperties if (typeof additionalProperties === 'object' && Object.keys(additionalProperties).length === 0) val = true ...
javascript
{ "resource": "" }
q50873
convertFileType
train
function convertFileType (data) { data['type'] = 'file' const anyOf = data.media.anyOf if (anyOf && anyOf.length > 0) { data['fileTypes'] = [] anyOf.forEach(function (el) { if (el.mediaType) { data.fileTypes.push(el.mediaType) } }) if (data.fileTypes.length < 1) { delete ...
javascript
{ "resource": "" }
q50874
convertDateType
train
function convertDateType (data) { if (!(data.type === 'string' && data.pattern)) { return data } const pattern = data.pattern delete data.pattern switch (pattern) { case constants.dateOnlyPattern: data['type'] = 'date-only' break case constants.timeOnlyPattern: data['type'] = 'ti...
javascript
{ "resource": "" }
q50875
convertDefinedFormat
train
function convertDefinedFormat (data) { if (!(data.type === 'string' && data.format)) { return data } const format = data.format delete data.format switch (format) { case 'date-time': data['pattern'] = constants.FORMAT_REGEXPS['date-time'] break case 'email': data['pattern'] = con...
javascript
{ "resource": "" }
q50876
convertPatternProperties
train
function convertPatternProperties (data) { if (!data.patternProperties) { return data } data.properties = data.properties || {} const patternProperties = data.patternProperties delete data.patternProperties Object.keys(patternProperties).map(function (pattern) { data.properties['/' + pattern + '/'] ...
javascript
{ "resource": "" }
q50877
useThrottle
train
function useThrottle(fun, timeout, changes) { if (changes === void 0) { changes = []; } // Create the ref to store timer. var timer = react_1.useRef(null); function cancel() { if (timer.current) { clearTimeout(timer.current); timer.current = null; } } // R...
javascript
{ "resource": "" }
q50878
initLoadingState
train
function initLoadingState(btnEl) { if (cfg.btnLoadingClass && !cfg.addClassToCurrentBtnOnly) { btnEl.addClass(cfg.btnLoadingClass); } if (cfg.disableBtn && !cfg.disableCurrentBtnOnly) { btnEl.attr('disabled', 'disabled'); } }
javascript
{ "resource": "" }
q50879
handleLoadingFinished
train
function handleLoadingFinished(btnEl) { if ((!cfg.minDuration || minDurationTimeoutDone) && promiseDone) { if (cfg.btnLoadingClass) { btnEl.removeClass(cfg.btnLoadingClass); } if (cfg.disableBtn && !scope.ngDisabled) { btnEl.removeAttr('disabled'...
javascript
{ "resource": "" }
q50880
initPromiseWatcher
train
function initPromiseWatcher(watchExpressionForPromise, btnEl) { // watch promise to resolve or fail scope.$watch(watchExpressionForPromise, function (mVal) { minDurationTimeoutDone = false; promiseDone = false; // create timeout if option is set if (c...
javascript
{ "resource": "" }
q50881
addHandlersForCurrentBtnOnly
train
function addHandlersForCurrentBtnOnly(btnEl) { // handle current button only options via click if (cfg.addClassToCurrentBtnOnly) { btnEl.on(cfg.CLICK_EVENT, function () { btnEl.addClass(cfg.btnLoadingClass); }); } if (cfg.disableCurrentBtnOn...
javascript
{ "resource": "" }
q50882
getSubmitBtnChildren
train
function getSubmitBtnChildren(formEl) { var submitBtnEls = []; var allButtonEls = formEl.find(angularPromiseButtons.config.BTN_SELECTOR); for (var i = 0; i < allButtonEls.length; i++) { var btnEl = allButtonEls[i]; if (angular.element(btnEl) .attr('ty...
javascript
{ "resource": "" }
q50883
sanitizeOptions
train
function sanitizeOptions(userOptions) { userOptions = userOptions || {}; let options = { index: getIndexValue(userOptions) } if(userOptions.index){ // required to not interfere with serve-static delete userOptions.index; } if (typeof (userOptions.enableBrotli) !== "und...
javascript
{ "resource": "" }
q50884
setupCompressions
train
function setupCompressions() { //register all provided compressions if (opts.customCompressions && opts.customCompressions.length > 0) { for (var i = 0; i < opts.customCompressions.length; i++) { var customCompression = opts.customCompressions[i]; registerComp...
javascript
{ "resource": "" }
q50885
convertToCompressedRequest
train
function convertToCompressedRequest(req, res, compression) { var type = mime.lookup(req.path); var charset = mime.charsets.lookup(type); var search = req.url.split('?').splice(1).join('?'); if (search !== "") { search = "?" + search; } req.url = req.path + c...
javascript
{ "resource": "" }
q50886
findAvailableCompressionForFile
train
function findAvailableCompressionForFile(compressionList, acceptedEncoding) { if (acceptedEncoding) { for (var i = 0; i < compressionList.length; i++) { if (acceptedEncoding.indexOf(compressionList[i].encodingName) >= 0) { return compressionList[i]; ...
javascript
{ "resource": "" }
q50887
findAllCompressionFiles
train
function findAllCompressionFiles(fs, folderPath) { // check if folder exists if (!fs.existsSync(folderPath)) return; var files = fs.readdirSync(folderPath); //iterate all files in the current folder for (var i = 0; i < files.length; i++) { var filePath = fo...
javascript
{ "resource": "" }
q50888
addAllMatchingCompressionsToFile
train
function addAllMatchingCompressionsToFile(fileName, fullFilePath) { for (var i = 0; i < compressions.length; i++) { if (fileName.endsWith(compressions[i].fileExtension)) { addCompressionToFile(fullFilePath, compressions[i]); return; } } }
javascript
{ "resource": "" }
q50889
addCompressionToFile
train
function addCompressionToFile(filePath, compression) { var srcFilePath = filePath.replace(rootFolder, "").replace(compression.fileExtension, ""); var existingFile = files[srcFilePath]; if (!existingFile) { files[srcFilePath] = { compressions: [compression] }; } else { ...
javascript
{ "resource": "" }
q50890
registerCompression
train
function registerCompression(encodingName, fileExtension) { if (!findCompressionByName(encodingName)) compressions.push(new Compression(encodingName, fileExtension)); }
javascript
{ "resource": "" }
q50891
findCompressionByName
train
function findCompressionByName(encodingName) { for (var i = 0; i < compressions.length; i++) { if (compressions[i].encodingName === encodingName) return compressions[i]; } return null; }
javascript
{ "resource": "" }
q50892
initClientRendered
train
function initClientRendered(widgetDefs, document) { // Ensure that event handlers to handle delegating events are // always attached before initializing any widgets eventDelegation.init(); document = document || window.document; for (var i=0,len=widgetDefs.length; i<len; i++) { var widgetDe...
javascript
{ "resource": "" }
q50893
train
function(type, targetMethod, elId) { if (!targetMethod) { // The event handler method is allowed to be conditional. At render time if the target // method is null then we do not attach any direct event listeners. return; } if (!this.domEvents) { ...
javascript
{ "resource": "" }
q50894
Widget
train
function Widget(id, document) { EventEmitter.call(this); this.id = id; this.el = null; this.bodyEl = null; this.state = null; this.__subscriptions = null; this.__evHandles = null; this.__lifecycleState = null; this.__customEvents = null; this.__scope = null; this.__dirty = fa...
javascript
{ "resource": "" }
q50895
getExistingWidget
train
function getExistingWidget(id, type) { var existingEl = document.getElementById(id); var existingWidget; if (existingEl && (existingWidget = existingEl.__widget) && existingWidget.__type === type) { return existingWidget; } return null; }
javascript
{ "resource": "" }
q50896
getIEEvent
train
function getIEEvent() { var event = window.event; // add event.target event.target = event.target || event.srcElement; event.preventDefault = event.preventDefault || function() { event.returnValue = false; }; event.stopPropagation = event.stopPropagation || function() { event.c...
javascript
{ "resource": "" }
q50897
_createLatLngs
train
function _createLatLngs(line, from) { if (line.geometries[0] && line.geometries[0].coords[0]) { /** * stores how many times arc is broken over 180 longitude * @type {number} */ let wrap = from.lng - line.geometries[0].coords[0][0] - 360; return line.geometries ...
javascript
{ "resource": "" }
q50898
promptIfMainTheme
train
function promptIfMainTheme(env) { return new Promise((resolve, reject) => { const c = config.shopify[env] if (!c.api_key) { console.log(chalk.yellow(`The "${env}" environment in config/shopify.yml does not specify an "api_key". Skipping check for if is main theme.`)) resolve() return } ...
javascript
{ "resource": "" }
q50899
hash_password
train
function hash_password(plain_text, salt, callback) { // Get the crypto library. const crypto = require("crypto") // These should be a *slow* as possible, higher = slower. // Slow it down until you tweak a bounce change. const password_iterations = process.env.PW_GEN_PW_ITERS || 4096 // Password length and...
javascript
{ "resource": "" }