export function getCSSMinOpts(opts) { return _.defaultsDeep(opts, { advanced: true, agressiveMerging: true, mediaMerging: true, restructuring: true, shorthandCompacting: true, }); }
/** * Extend API object with default filters * @param {Object} filters Custom filters * @param {String[]} exclude list of columns for which default filters should not be applied * @return {Object} */ defaultFilters(filters, exclude = []) { let excludeFilters = []; _.each(exclude, function(excludeColumn){ excludeFilters = _.concat(excludeFilters, [excludeColumn, `${excludeColumn}s`, `not_${excludeColumn}`, `not_${excludeColumn}s`, `null_${excludeColumn}`, `not_null_${excludeColumn}`]); }); return _.defaultsDeep(filters, _.omit(this.filtersAPI, excludeFilters)); };
const parseNode = node => ({ // copy all existing props, applying defaults ..._.defaultsDeep(node, MJMLElementsCollection[node.tagName.substr(3)].defaultMJMLDefinition), // do same to children children: (node.children || []).map(parseNode) })
get config() { if(!this._configCache) { this._configCache = _.defaultsDeep(this._config, this._defaults); } // end if return this._configCache; } // end config
constructor(producer, topic, options) { _.defaultsDeep(options, { objectMode: true }); this._producer = producer; this._topic = topic; super(options); }
export class LanguageProvider extends React.Component { // eslint-disable-line react/prefer-stateless-function render() { const messages = defaultsDeep(this.props.messages[this.props.locale], this.props.messages.en); return ( <IntlProvider locale={this.props.locale} defaultLocale="en" messages={messages}> {React.Children.only(this.props.children)} </IntlProvider> ); }
constructor(defaultConfig) { if (defaultConfig === undefined) { throw new TypeError("Default configuration object is expected as first argument"); } this.config = this.config || {}; _.defaultsDeep(this.config, defaultConfig); }
constructor(opts, logger) { this.opts = _.defaultsDeep(opts, { pathKey: 'method', // default to JSON RPC }) this.isListening = false; this.observed = {}; this.observedPaths = []; this.log = logger; }
module.exports = function(scope, cb) { // Validate custom scope variables which are required by this generator if (!scope.rootPath) { return cb(new Error( 'Missing scope variable: `rootPath`\n' + 'Please make sure it is specified and try again.' )); } // Determine default values based on the available scope _.defaultsDeep(scope, { currentTime: new Date() }); // Take multiple "passes" if necessary _.defaultsDeep(scope, { rootPath: scope.rootPath }); // Remove Gruntfile if exists try { fs.unlinkSync(scope.rootPath + '/Gruntfile.js'); } catch (e) { sails.log.error('Unable to delete \'' + e.path + '\''); } // Remove previous styles folder try { rimraf.sync(scope.rootPath + '/assets/styles'); } catch (e) { sails.log.error('Unable to delete \'' + e.path + '\''); } // Remove gulpfile.js if exists try { fs.unlinkSync(scope.rootPath + '/gulpfile.js'); } catch (e) {} // Remove old `tasks` folder then trigger callback rimraf(scope.rootPath + '/tasks', function () { cb(); }); };
const exec_ = (opts) => { opts = _.defaultsDeep(opts || {}, { state: util.makeStateStub(), browserSession: sinon.createStubInstance(CaptureSession), page: {}, emit: sinon.spy() }); return mkTestStateProc_().exec(opts.state, opts.browserSession, opts.page, opts.emit); };
function configureVhost(name, vhostConfig) { debug('Configuring vhost: %s', name); rascalConfig.vhosts[name] = _.defaultsDeep(vhostConfig, { name: name, namespace: rascalConfig.defaults.vhosts.namespace, publicationChannelPools: rascalConfig.defaults.vhosts.publicationChannelPools, }, { defaults: rascalConfig.defaults.vhosts }); rascalConfig.vhosts[name].namespace = vhostConfig.namespace === true ? uuid() : vhostConfig.namespace; configureConnections(vhostConfig, name); }
_set_uri (value) { const parsed_uri = require('url').parse(value, true); this._uri = parsed_uri.pathname; _.defaultsDeep(this._query, parsed_uri.query); if (parsed_uri.query.before) { this._query.after = null; } else { this._query.before = null; } }
export function generateReq (options = {}) { let defaultReq = { body: {}, query: {}, headers: {}, header: sandbox.stub().returns(null), }; return defaults(options, defaultReq); }
function getProps(props = {}) { const defaultTestProps = { panel: { panelIndex: 'foo1' }, renderEmbeddable: jest.fn(), viewOnlyMode: false, onDestroy: () => {}, embeddableFactory: getEmbeddableFactoryMock(), }; return _.defaultsDeep(props, defaultTestProps); }
var getYoRc = function(config) { config = config || {}; var result = {}; _.defaultsDeep(config, { appname: 'dummyappname', clientFolder: 'client' }); result[this.mixins.getGeneratorFullname()] = config; return result; };
function checkVhost(name, connectionConfig, next) { debug('Asserting vhost: %s', name); var url = format('%s/%s/%s', connectionConfig.management.url, 'api/vhosts', name); var options = _.defaultsDeep({ method: 'GET', url: url }, connectionConfig.management.options); request(options, function(err, res, body) { if (err) return next(err); if (res.statusCode > 400) return next(new Error(format('Failed to check vhost: %s. %s returned status %d', name, connectionConfig.management.loggableUrl, res.statusCode))); return next(); }); }
return through(function (file, enc, cb) { var fileContents = file.contents.toString(); var fileOpts = _.cloneDeep(opts); if (file.sourceMap) { fileOpts = _.defaultsDeep(fileOpts, { codeGenerationOptions: { sourceMap: file.sourceMap.file, sourceMapWithCode: true, sourceContent: fileContents, sourceMapRoot: file.sourceMap.sourceRoot, file: file.path } }); } var instrumenter = new opts.instrumenter(fileOpts); cb = _.once(cb); if (!(file.contents instanceof Buffer)) { return cb(new PluginError(PLUGIN_NAME, 'streams not supported')); } instrumenter.instrument(fileContents, file.path, function (err, code) { if (err) { return cb(new PluginError( PLUGIN_NAME, 'Unable to parse ' + file.path + '\n\n' + err.message + '\n' )); } var sourceMap = instrumenter.lastSourceMap(); if (sourceMap !== null) { applySourceMap(file, sourceMap.toString()); } file.contents = new Buffer(code); // Parse the blank coverage object from the instrumented file and save it // to the global coverage variable to enable reporting on non-required // files, a workaround for // https://github.com/gotwarlost/istanbul/issues/112 if (opts.includeUntested) { var instrumentedSrc = file.contents.toString(); var covStubRE = /\{.*"path".*"fnMap".*"statementMap".*"branchMap".*\}/g; var covStubMatch = covStubRE.exec(instrumentedSrc); if (covStubMatch !== null) { var covStub = JSON.parse(covStubMatch[0]); global[opts.coverageVariable] = global[opts.coverageVariable] || {}; global[opts.coverageVariable][file.path] = covStub; } } return cb(err, file); }); });
test('PATCH /session/account/profile?include=foobar', function (t) { var options = _.defaultsDeep({ url: '/session/account/profile?include=foobar' }, routeOptions) server.inject(options, function (response) { t.is(response.statusCode, 400, 'returns 400 status') t.deepEqual(response.result.errors[0].detail, '?include not allowed', 'returns error message') t.end() }) })
/** * Create a model, or models. Multiple models will be created if "values" is * an array. * * @param modelName The name of the model to create * @param values The model's values * @param options to pass to sequelize * @return Promise */ create(modelName, values, options) { const Model = this._getModel(modelName) const modelOptions = _.defaultsDeep({}, options, _.get(this.app.config, 'footprints.models.options')) if (!Model) { return Promise.reject(new ModelError('E_NOT_FOUND', `${modelName} can't be found`)) } if (modelOptions.populate) { modelOptions.include = this._createIncludeField(Model, modelOptions.populate) } return Model.create(values, modelOptions).catch(manageError) }
BHelper.settings.getAll((settings) => { let curSettings = settings; if (curSettings.BTDSettings) { const cleanedSettings = Object.assign({}, curSettings.BTDSettings); curSettings = cleanedSettings; chrome.storage.sync.clear(); } BHelper.settings.set( defaultsDeep(curSettings, defaultSettings), (newSettings) => { Log(newSettings); if (!newSettings.installed_date) { openWelcomePage(); BHelper.settings.set({ installed_date: new Date().getTime() }); } const oldVersion = (curSettings.installed_version || '').replace( /\./g, '', ); const newVersion = BHelper.getVersion().replace(/\./g, ''); Log('version', BHelper.getVersion()); BHelper.settings.set({ installed_version: String(BHelper.getVersion()) }); if (!oldVersion || Number(oldVersion) !== Number(newVersion)) { BHelper.settings.set({ need_update_banner: true, }); } // We create the context menu item if (newSettings.share_item && newSettings.share_item.enabled) { if (chrome.permissions) { chrome.permissions.contains( { permissions: ['tabs'], }, (hasTabs) => { if (!hasTabs) { return; } createMenuItem(newSettings); }, ); } else { createMenuItem(newSettings); } } }, ); });
it('should assign properties of a source object if missing on the destination object', function() { deepEqual(_.defaultsDeep({ 'a': 1 }, { 'a': 2, 'b': 2 }), { 'a': 1, 'b': 2 }); });
function readTests_(opts) { opts = _.defaultsDeep(opts || {}, { testPaths: [], browsers: [], config: { specs: ['default-spec'] } }); return readTests(opts.testPaths, opts.browsers, makeConfigStub(opts.config)); }
logs (opts = {}) { const options = defaultsDeep(opts, { stdout: true, stderr: true, follow: true }) return new Promise((resolve, reject) => { this.$client.$request.get(`/containers/${this.id}/logs`, { qs: options }) .on('error', (err) => reject(err)) .on('response', (res) => { res.pause() return resolve(res) }) }) }
function configureConnection(vhostConfig, vhostName, connection) { _.defaultsDeep(connection, vhostConfig.defaults.connection); connection.vhost = connection.vhost !== undefined ? connection.vhost : vhostName, connection.auth = connection.auth || connection.user + ':' + connection.password; connection.pathname = connection.vhost === '/' ? '' : connection.vhost; connection.query = connection.options; connection.url = connection.url || url.format(connection); connection.loggableUrl = connection.url.replace(/:[^:]*?@/, ':***@'); connection.index = getConnectionIndex(connection.url); configureManagementConnection(vhostConfig, vhostName, connection); }
constructor (options = {}, _r) { super(); this.push(...options.children || []); this._r = _r; this._cached_lookahead = options._cached_lookahead; defaultsDeep(this, pick(options, keys(INTERNAL_DEFAULTS)), INTERNAL_DEFAULTS); assign(this._query, pick(options, ['before', 'after'])); if (last(options.children) instanceof More) { this._set_more(this.pop()); } }
constructor (options = {}, _r) { super(); this._r = _r; _.assign(this, options.children || []); _.defaultsDeep(this, _.pick(options, _.keys(INTERNAL_DEFAULTS)), INTERNAL_DEFAULTS); _.assign(this._query, _.pick(options, ['before', 'after'])); if (_.last(options.children) instanceof require('./more')) { this._more = this.pop(); this._is_comment_list = true; } }
config.getSettings = function(options) { var d = Q.defer(), defaultOptions = getDefaultOptions(), npmPackageOptions = getNpmPackageOptions(), self = this; self.options = __.defaultsDeep({}, options, { npm: npmPackageOptions }, defaultOptions); // check for specified working directory if(self.options.commands.cwd){ self.process.set('working_directory', path.resolve(self.options.commands.cwd)); } else{ self.process.set('working_directory', process.cwd()); } LOCAL_CONFIG_PATH = path.resolve(self.process.get('working_directory'), 'siteshooter.yml'); // attempting to create a siteshooter.yml file? If not, move on to next excute statement. executeWhen(self.options.commands.init, setSiteshooterFile).then( // skip if creating a siteshooter.yml file executeWhen(!self.options.commands.init, function() { return getSiteshooterFile(function(error, data) { if (error) { if (error.code === 'ENOENT') { d.reject(Error('Missing siteshooter.yml file. Run the following command to create one: \n\n $ siteshooter --init \n\n')); } else { d.reject(Error('Loading siteshooter.yml\n\n' + error + '\n\n')); } } else { Object.assign(self.options, data); } }); })).catch(function(error) { d.reject(error); }).done(function() { d.resolve(self.options); }); return d.promise; };
function initGlobalConfig() { const env = process.env.NODE_ENV; const defaults = _.cloneDeep(require('./config.default')); _.defaultsDeep(config, defaults); config.app.env = env; initGlobalConfigFiles(config); return config; }
test('POST /accounts?include=foobar', function (t) { var options = _.defaultsDeep({ url: '/accounts?include=foobar' }, routeOptions) server.inject(options, function (response) { t.is(response.statusCode, 400, 'returns 400 status') t.deepEqual(response.result.errors[0].detail, 'Allowed value for ?include is \'profile\'', 'returns error message') t.end() }) })
archive (opts = {}) { const options = defaultsDeep(opts, { path: '/' }) return new Promise((resolve, reject) => { this.$client.$request.get(`/containers/${this.id}/archive`, { qs: options }) .on('error', (err) => reject(err)) .on('response', (res) => { res.pause() resolve(res) }) }) }