UNPKG

tastypie

Version:

Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces

34 lines (27 loc) 909 B
var forOwn = require('./forOwn'); var isPlainObject = require('../lang/isPlainObject'); /** * Deeply copy missing properties in the target from the defaults. */ function deepFillIn(target, defaults){ var i = 0, n = arguments.length, obj; while(++i < n) { obj = arguments[i]; if (obj) { // jshint loopfunc: true forOwn(obj, function(newValue, key) { var curValue = target[key]; if (curValue == null) { target[key] = newValue; } else if (isPlainObject(curValue) && isPlainObject(newValue)) { deepFillIn(curValue, newValue); } }); } } return target; } module.exports = deepFillIn;