How to use the node.extend function in node

To help you get started, we’ve selected a few node 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 WP-API / node-wpapi / lib / pages.js View on Github external
/**
	 * @property _supportedMethods
	 * @type Array
	 * @private
	 * @default [ 'head', 'get', 'post' ]
	 */
	this._supportedMethods = [ 'head', 'get', 'post' ];

	// Default all .pages() requests to assume a query against the WP API v2 endpoints
	this.namespace( 'wp/v2' );
}

inherit( PagesRequest, CollectionRequest );

// Mixins
extend( PagesRequest.prototype, pick( filters, [
	// Specify that we are requesting a page by its path
	'path'
] ) );

/**
 * A hash table of path keys and regex validators for those path elements
 *
 * @property _pathValidators
 * @type Object
 * @private
 */
PagesRequest.prototype._pathValidators = {

	// No validation on "id", since it can be a string path OR a numeric ID

	/**
github koopjs / koop-core / api / providers / socrata / controller / index.js View on Github external
var extend = require('node.extend'),
  fs = require('fs'),
  crypto = require('crypto'),
  base = require('../../base/controller.js');

// inherit from base controller
var Controller = extend({
  serviceName: 'socrata',

  register: function(req, res){
    if ( !req.body.host ){
      res.send('Must provide a host to register:', 500); 
    } else { 
      Socrata.register( req.body.id, req.body.host, function(err, id){
        if (err) {
          res.send( err, 500);
        } else {
          res.json({ 'serviceId': id });
        }
    });
    }
  },
github jasontbradshaw / irobot / lib / robot.js View on Github external
var passiveCmp = this._emitValueChange('state.mode.passive', true,
      oldSensorData, newSensorData, 'mode:passive');

  var safeCmp = this._emitValueChange('state.mode.safe', true,
      oldSensorData, newSensorData, 'mode:safe');

  var fullCmp = this._emitValueChange('state.mode.full', true,
      oldSensorData, newSensorData, 'mode:full');

  var data = null;
  if ((offCmp.changed && offCmp.value) ||
      (passiveCmp.changed && passiveCmp.value) ||
      (safeCmp.changed && safeCmp.value) ||
      (fullCmp.changed && fullCmp.value)) {
    data = extend({}, newSensorData.state.mode);
    this.emit('mode', data);
  }

  return data;
};
github honeinc / woden / index.js View on Github external
arg = req.url.split( '?' ),
        path = arg.shift( ),
        query = qs.parse( arg.pop( ) ),
        target = query.$url || '',
        key,
        self = this;

    delete query.$url;
    req.url = ( path !== '/' ? path : '' ) + ( Object.keys( query ).length ? ( '?' + qs.stringify( query ) ) : '' );
    req._target = target;

    var settings = this._getSettings( req._target + req.url );
    req._settings = settings;

    if(settings.params && Object.keys( settings.params ).length) {
        query = extend( true, {},
            settings.params, query );

        req.url += req.url.indexOf('?') > -1 ? '&' : '?';
        req.url += qs.stringify( settings.params );
    }

    query = sortObject( query );
    key = settings.getKey( req._target + req.url, query );

    if ( req.method.toLowerCase() === 'options' ) {
        if ( self.options.onOptions ) {
            self.options.onOptions( req, res );
            return;
        }
    }
github redexp / react-separate-template / conv.js View on Github external
function clone(obj) {
    return extend(true, Array.isArray(obj) ? [] : {}, obj);
}
github ionic-team / collide / src / motion / instance.js View on Github external
function Animation(opts) {
  extend(this, opts);
}
github walkdoer / Life-Time-Tracker / tracker / statists / sport.js View on Github external
var regexp = /^(\d+)s(\d+)r$/g,
                            result = regexp.exec(str);
                        if (result.length < 3) {
                            return null;
                        }
                        return {
                            sets: parseInt(result[1], 10),
                            reps: parseInt(result[2], 10)
                        };
                    };
                var setsAndReps = getSetsAndReps(projInfo[1].trim());
                if (setsAndReps === null) {
                    msg.warn('Sport item record is wrong:' + proj + 'in ' +
                            day.date);
                }
                return extend({
                    name: projInfo[0].trim()
                }, setsAndReps);
            }
        });
github galenmaly / lighterpack / server / views.js View on Github external
const renderCategory = function (category, args) {
    let items = '';
    for (const i in category.categoryItems) {
        const categoryItem = category.categoryItems[i];
        const item = category.library.getItemById(categoryItem.itemId);
        extend(item, categoryItem);
        items += renderItem(item, args);
    }

    category.calculateSubtotal();
    category.subtotalWeightDisplay = weightUtils.MgToWeight(category.subtotalWeight, args.totalUnit);
    category.subtotalPriceDisplay = category.subtotalPrice ? category.subtotalPrice.toFixed(2) : '0.00';
    let temp = Vue.util.extend({}, category);
    temp = Vue.util.extend(temp, {
        items, subtotalUnit: args.totalUnit, currencySymbol: args.currencySymbol, showPrices: args.showPrices,
    });

    return Mustache.render(args.categoryTemplate, temp);
};
github jsreport / jsreport / extension / express / lib / routes.js View on Github external
app.post("/api/report", function (req, res, next) {
        res.setTimeout((reporter.options.express || {}).renderTimeout || (20 * 60 * 1000));
        req.template = req.body.template;
        req.data = req.body.data;
        req.options = req.body.options || {};

        extend(true, req.headers, req.body.headers);

        if (!req.template)
            return next("Could not parse report template, aren't you missing content type?");

        reporter.render(req).then(function (response) {
            //copy headers to the final response
            if (response.headers) {
                for (var key in response.headers) {
                    if (response.headers.hasOwnProperty(key))
                        res.setHeader(key, response.headers[key]);
                }
            }

            if (!response.headers["Content-Disposition"] && !req.options["Content-Disposition"]) {
                res.setHeader("Content-Disposition", (req.options.preview ? "inline" : "attachment") + ";filename=report." + response.headers["File-Extension"]);
            }
github filefog / filefog / lib / wrapper / client_wrapper.js View on Github external
ClientWrapper.prototype.setCredentials = function (new_creds) {
        this.credentials = extend(true, this.credentials, new_creds || {});
    };