Skip to content

Instantly share code, notes, and snippets.

@pascalvree
Created February 15, 2016 09:23
Show Gist options
  • Save pascalvree/764eee3d6cc34ae58cae to your computer and use it in GitHub Desktop.
Save pascalvree/764eee3d6cc34ae58cae to your computer and use it in GitHub Desktop.
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