How to use the defaults function from underscore

Find comprehensive JavaScript underscore.defaults code examples handpicked from public code repositorys.

1049
1050
1051
1052
1053
1054
1055
1056
1057
1058

/* extra asyncronous queries like folder-listings */
async.map( _.keys( fields ), function( fieldName, done ) {

    function treeReader( treeOpts, defaults ) {
        _.defaults( treeOpts, defaults );

        k.hierarchy.readFlatHierarchyTree( req.kern.website, treeOpts.root, treeOpts, function( err, tree ) {
            if( err ) return next( err );
            var keyValues = {};
fork icon3
star icon9
watch icon1

+ 11 other calls in file

567
568
569
570
571
572
573
574
575
576
    entryModel,
    Utils.nonCloneable
);

newEntry = _.extend(newEntry, _.pick(entry, entryValidPaths));
newEntry = _.defaults(newEntry, entryDefaults);
newEntry.handler = _.values(EntryType).includes(entry.handler)
    ? entry.handler
    : EntryType.UnkownEntry;
if (isRoot) {
fork icon0
star icon2
watch icon0

+ 3 other calls in file

2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
_.template = function(text, data, settings) {
  var render;
  settings = _.defaults({}, settings, _.templateSettings);

  // Combine delimiters into one regular expression via alternation.
  var matcher = new RegExp([
    (settings.escape || noMatch).source,
fork icon0
star icon2
watch icon0