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

20 lines (16 loc) 571 B
define(['../array/slice'], function(slice){ /** * internal method used to create other collection modules. */ function makeCollectionMethod(arrMethod, objMethod, defaultReturn) { return function(){ var args = slice(arguments); if (args[0] == null) { return defaultReturn; } // array-like is treated as array return (typeof args[0].length === 'number')? arrMethod.apply(null, args) : objMethod.apply(null, args); }; } return makeCollectionMethod; });