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 (26 loc) 873 B
var hasOwn = require('./hasOwn'); var every = require('./every'); var isObject = require('../lang/isObject'); var is = require('../lang/is'); // Makes a function to compare the object values from the specified compare // operation callback. function makeCompare(callback) { return function(value, key) { return hasOwn(this, key) && callback(value, this[key]); }; } function checkProperties(value, key) { return hasOwn(this, key); } /** * Checks if two objects have the same keys and values. */ function equals(a, b, callback) { callback = callback || is; if (!isObject(a) || !isObject(b)) { return callback(a, b); } return (every(a, makeCompare(callback), b) && every(b, checkProperties, a)); } module.exports = equals;