Created
February 15, 2016 09:23
-
-
Save pascalvree/764eee3d6cc34ae58cae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var equals = function(left, right) { return left == right } | |
var isAnObject = function(left) { return !isAnArray(left) && equals(typeof left, "object"); } | |
var isAnArray = function(left) { return Array.isArray(left); } | |
var isEmpty = function(left) { return left == undefined || items == null; } | |
var Apply = function(left, right) { | |
var result = undefined; | |
if(isAnObject(left)) { | |
result = { }; | |
Object.keys(left).forEach(function(key) { result[key] = left[key]; }); | |
Object.keys(right).forEach(function(key) { result[key] = right[key]; }); | |
} | |
if(isAnArray(left)) { | |
result = [ ]; | |
left.forEach(function(item) { result.push(item); }); | |
right.forEach(function(item) { result.push(item); }); | |
} | |
return result; | |
} | |
module.exports = { | |
Apply: Apply, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment