How to use the lodash.extend function in lodash

To help you get started, we’ve selected a few lodash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github helpers / handlebars-helpers / dist / commonjs / main.js View on Github external
// Source File: ./src/helpers/markdown.js

/**
 * Handlebars Helpers 
 *
 * Copyright (c) 2014 Jon Schlinkert, Brian Woodward, contributors
 * Licensed under the MIT License (MIT)
 */

  options.marked = options.marked || {};

  // Initialize `marked-extras`
  extras.init(options.marked);

  // Extend defaults from `marked-extras` with Gruntfile options
  var markedOpts = _.extend({}, extras.markedDefaults, options.marked);

  // Set marked.js options
  marked.setOptions(markedOpts);

  Library.addHelper('md', function (patterns, context, opts) {
    opts = _.extend({}, options, opts || {});

    _.extend(opts, opts.hash || {});

    var filepath = this;
    var str = file.readFileSync(filepath);
    var page = matter(str);
    var content = page.content;
    var metadata = page.context;

    var data = Handlebars.createFrame({filepath: filepath});
github jc21 / nginx-proxy-manager / manager / src / frontend / js / app / host / redirection_form.js View on Github external
'submit @ui.form': function (e) {
            e.preventDefault();
            let data = _.extend({}, this.ui.form.serializeJSON());

            // Change text true's to bools
            _.map(data, function (val, key) {
                if (val === 'true') {
                    data[key] = true;
                }
            });

            data.type = 'redirection';

            // accept_tos is not required for backend
            delete data.accept_tos;

            if (!data.ssl) {
                delete data.letsencrypt_email;
                delete data.force_ssl;
github twilio / twilio-node / lib / rest / pricing / v1 / messaging / country.js View on Github external
*
 * @param {V1} version - Version of the resource
 * @param {Response} response - Response from the API
 * @param {CountrySolution} solution - Path solution
 *
 * @returns CountryPage
 */
/* jshint ignore:end */
CountryPage = function CountryPage(version, response, solution) {
  // Path Solution
  this._solution = solution;

  Page.prototype.constructor.call(this, version, response, this._solution);
};

_.extend(CountryPage.prototype, Page.prototype);
CountryPage.prototype.constructor = CountryPage;

/* jshint ignore:start */
/**
 * Build an instance of CountryInstance
 *
 * @function getInstance
 * @memberof Twilio.Pricing.V1.MessagingContext.CountryPage#
 *
 * @param {CountryPayload} payload - Payload response from the API
 *
 * @returns CountryInstance
 */
/* jshint ignore:end */
CountryPage.prototype.getInstance = function getInstance(payload) {
  return new CountryInstance(this._version, payload);
github ifandelse / machina.js / src / utils.js View on Github external
parent.apply( this, args );
		};
	}

	// Inherit class (static) properties from parent.
	_.merge( fsm, parent );

	// Set the prototype chain to inherit from `parent`, without calling
	// `parent`'s constructor function.
	Ctor.prototype = parent.prototype;
	fsm.prototype = new Ctor();

	// Add prototype properties (instance properties) to the subclass,
	// if supplied.
	if ( protoProps ) {
		_.extend( fsm.prototype, protoProps );
		_.merge( machObj, _.transform( protoProps, function( accum, val, key ) {
			if ( _machKeys.indexOf( key ) !== -1 ) {
				accum[ key ] = val;
			}
		} ) );
	}

	// Add static properties to the constructor function, if supplied.
	if ( staticProps ) {
		_.merge( fsm, staticProps );
	}

	// Correctly set child's `prototype.constructor`.
	fsm.prototype.constructor = fsm;

	// Set a convenience property in case the parent's prototype is needed later.
github cypress-io / cypress / packages / server / lib / project.js View on Github external
static _mergeDetails (clientProject, project) {
    return _.extend({}, clientProject, project, { state: 'VALID' })
  }
github Rcomian / bunyan-rotating-file-stream / lib / filerotator.js View on Github external
function initialise(startNewFile, callback) {
        if (!initialised) {
            initialised = true;

            async.series([
                fileops.deleteFiles,
                initialiseNewFile({ startNewFile: startNewFile })
            ], function (err) {
                callback(err, stream, streamPath);
            });
        } else {
            callback();
        }
    }

    return _.extend({}, {
        initialise: initialise,
        rotate: rotate,
        end: shutdownCurrentStream
    }, base);
}
github assetgraph / assetgraph-builder / lib / transforms / stripDebug.js View on Github external
return function stripDebug(assetGraph) {
        assetGraph.findAssets(_.extend({type: 'JavaScript'}, queryObj)).forEach(function (javaScript) {
            var isInScopeByIdentifierName = {};
            estraverse.traverse(javaScript.parseTree, {
                enter: function (node, parentNode) {
                    if (node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration') {
                        node.params.forEach(function (param) {
                            if (param.type === 'Identifier') {
                                isInScopeByIdentifierName[param.name] = isInScopeByIdentifierName[param.name] || 0;
                                isInScopeByIdentifierName[param.name] += 1;
                            }
                        });
                    } else if (node.type === 'ExpressionStatement' &&
                        node.expression.type === 'CallExpression' &&
                        node.expression.callee.type === 'MemberExpression' &&
                        node.expression.callee.object.type === 'Identifier' &&
                        node.expression.callee.object.name === 'console' &&
                        !isInScopeByIdentifierName.console
github BedeGaming / orchestra / src / mvc / native / composite-view.js View on Github external
throw new MnError({
          name: 'ChildViewContainerMissingError',
          message: 'The specified "childViewContainer" was not found: ' + containerView.childViewContainer
        });
      }

    } else {
      container = containerView.el;
    }

    containerView.$childViewContainer = container;
    return container;
  },
}

_.extend(CompositeView.prototype, NativeViewMixin);

export default CompositeView;
github darrylwest / simple-node-logger / lib / AbstractAppender.js View on Github external
AbstractAppender.extend = function(child, options) {
    'use strict';

    const parent = new AbstractAppender( options );

    dash.extend( child, parent );

    return parent;
};
github naturalatlas / tilemantle / server / lib / TileMantle.js View on Github external
TileMantle.prototype.preset = function(name) {
	if (!this._presets.hasOwnProperty(name)) {
		var presets = this.config.presets || {};
		var presetConfig = _.extend({}, this.config.preset_defaults, presets[name]);
		this._presets[name] = new TileMantlePreset(name, presetConfig);
	}
	return this._presets[name];
};