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

29 lines (22 loc) 639 B
define(['./forOwn', './size'], function(forOwn, size) { /** * Object reduce */ function reduce(obj, callback, memo, thisObj) { var initial = arguments.length > 2; if (!size(obj) && !initial) { throw new Error('reduce of empty object with no initial value'); } forOwn(obj, function(value, key, list) { if (!initial) { memo = value; initial = true; } else { memo = callback.call(thisObj, memo, value, key, list); } }); return memo; } return reduce; });