Codota Logo For Javascript
defaults
Code IndexAdd Codota to your IDE (free)

How to use
defaults
function
in
lodash

Best JavaScript code snippets using lodash.defaults(Showing top 12 results out of 315)

origin: RisingStack/trace-nodejs

function sendMessageWrapper (agent, original) {
 return function (channel, Method, fields, Properties, props, content) {
  var traceHeaders = {
   'x-client-send': String(microtime.now()),
   'x-parent': String(agent.getServiceKey())
  }
  debug.info('amqplib.sendMessageWrapper', 'sending instrumented message...')
  defaults(fields.headers, traceHeaders)

  return original.apply(this, arguments)
 }
}
origin: antonio-jscrambler/simpleJscramblerClientExample

// sign params, add signature. Return the created payload
function signedParams(method, path, host, keys, params = {}) {
 params = defaults(clone(params), {
  access_key: keys.accessKey,
  timestamp: new Date().toISOString()
 });
 params.signature = generateHmacSignature(method, path, host, keys, params);
 return params;
}
origin: Radrw/strapi-pro

Object.keys(this.middleware).reduce((acc, current) => {
   // Try to find the settings in the current environment, then in the main configurations.
   const currentSettings = merge(get(cloneDeep(this.middleware[current]), ['defaults', current], {}), flattenMiddlewaresConfig[current] || this.config.currentEnvironment[current] || this.config[current]);
   acc[current] = !isObject(currentSettings) ? {} : currentSettings;

   if (!acc[current].hasOwnProperty('enabled')) {
    this.log.warn(`(middleware:${current}) wasn't loaded due to missing key \`enabled\` in the configuration`);
   }

   // Ensure that enabled key exist by forcing to false.
   defaults(acc[current], { enabled : false });

   return acc;
  }, {})
origin: frapontillo/node-rdp

function getRdpFileContent(config) {
 defaults(config, mapping);
 var rdpConfigText = '';
 for (var key in config) {
  if (mappingStructure[key].name) {
   rdpConfigText += mappingStructure[key].name + mappingStructure[key].fn(config[key]) + '\n';
  }
 }
 return rdpConfigText;
}
origin: usabilityhub/rails-erb-loader

function webpack3Compiler (config) {
 return webpack({
  entry: './test/erb/' + config.file,
  module: {
   loaders: [
    {
     test: /\.erb$/,
     loader: './index',
     options: defaults({}, config, {
      dependenciesRoot: './test/dependencies',
      timeoutMs: 2000
     })
    }
   ]
  },
  output: {
   filename: './output.js'
  }
 })
}
origin: Radrw/strapi-pro

Object.keys(this.hook).reduce((acc, current) => {
   // Try to find the settings in the current environment, then in the main configurations.
   const currentSettings = flattenHooksConfig[current] || this.config[current];

   if (isString(currentSettings)) {
    acc[current] = currentSettings;
   } else {
    acc[current] = !isObject(currentSettings) ? {} : currentSettings;

    if (!acc[current].hasOwnProperty('enabled')) {
     this.log.warn(`(hook:${current}) wasn't loaded due to missing key \`enabled\` in the configuration`);
    }

    // Ensure that enabled key exist by forcing to false.
    defaults(acc[current], { enabled : false });
   }

   return acc;
  }, {})
origin: shebinleo/pdf2html

const pages = (filePath, options, callback) => {
 if (typeof options === 'function') {
  callback = options
  options = {}
 }

 if (typeof callback !== 'function') return

 options = defaults(options || {}, { text: false })

 debug('Converts PDF to HTML pages')
 html(filePath, (err, html) => {
  if (err) return callback(err)

  const $ = cheerio.load(html)
  const pages = []
  const $pages = $('.page')
  $pages.each((index) => {
   const $page = $pages.eq(index)
   pages.push(options.text ? $page.text().trim() : $page.html())
  })

  return callback(null, pages)
 })
}
origin: ryrudnev/spa-react-redux-example

const createApiNormalizer = ({ endpoint: baseUrl }) => flow(
 defaults({
  method: 'GET',
  headers: {
   'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
  },
 }),
 mapParams({
  currentPage: 'page',
  sizePerPage: 'per-page',
 }),
 toJson(['filter']),
 accumulate('query', [
  'fields',
  'sort',
  'filter',
  'expand',
  'page',
  'per-page',
 ]),
 normalizeEndpoint(baseUrl),
 normalizeBody,
 pick([
  'endpoint',
  'method',
  'body',
  'headers',
  'credentials',
 ]),
)
origin: Radrw/strapi-pro

middlewareCategories.reduce((acc, index) => {
   const current = merge(this.config.currentEnvironment[index], {
    public: defaults(this.config.public, {
     enabled: true
    }),
    favicon: defaults(this.config.favicon, {
     enabled: true
    })
   });

   if (isObject(current)) {
    acc = merge(acc, current);
   } else {
    acc[index] = current;
   }

   return acc;
  }, {})
origin: mrijk/speculaas

function withGen(spec, genFn) {
  return defaults(omit(specize(spec), 'gen'), {gen: genFn});
}
origin: shebinleo/pdf2html

const runPDFBox = (filePath, options, callback) => {
 options = defaults(options || {}, { page: 1, imageType: 'png', width: 160, height: 226 })
 const uri = new URI(filePath)
origin: usabilityhub/rails-erb-loader

function webpack4Compiler (config) {
 return webpack({
  entry: './test/erb/' + config.file,
  mode: 'development',
  module: {
   rules: [
    {
     test: /\.erb$/,
     loader: './index',
     options: defaults({}, config, {
      dependenciesRoot: './test/dependencies',
      timeoutMs: 2000
     })
    }
   ]
  },
  output: {
   path: __dirname,
   filename: 'output.js'
  }
 })
}
lodash(npm)defaults

Most used lodash functions

  • LoDashStatic.map
    Creates an array of values by running each element in collection through iteratee. The iteratee is
  • LoDashStatic.isEmpty
    Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string
  • LoDashStatic.forEach
    Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked wit
  • LoDashStatic.find
    Iterates over elements of collection, returning the first element predicate returns truthy for.
  • LoDashStatic.pick
    Creates an object composed of the picked `object` properties.
  • LoDashStatic.get,
  • LoDashStatic.isArray,
  • LoDashStatic.filter,
  • LoDashStatic.merge,
  • LoDashStatic.isString,
  • LoDashStatic.isFunction,
  • LoDashStatic.assign,
  • LoDashStatic.extend,
  • LoDashStatic.includes,
  • LoDashStatic.keys,
  • LoDashStatic.cloneDeep,
  • LoDashStatic.uniq,
  • LoDashStatic.isObject,
  • LoDashStatic.omit

Popular in JavaScript

  • readable-stream
    Streams3, a user-land copy of the stream library from Node.js
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • mocha
    simple, flexible, fun test framework
  • redis
    Redis client library
  • mongodb
    The official MongoDB driver for Node.js
  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • ms
    Tiny millisecond conversion utility
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • js-yaml
    YAML 1.2 parser and serializer
  • Top plugins for WebStorm
    The challenge is finding the best plugins for JavaScript development on Intellij IDEs. Who wants to sit there and go over hundreds of plugins to pick the best?
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJavascript Code Index
Get Codota for your IDE now