From 7ad66dc40c0725342761387e39f0595c10cedc9a Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 13 May 2017 19:56:12 +0000 Subject: [PATCH] remove lodash --- node_modules/c9/has-internal-domain.js | 9 ++------ plugins/c9.core/settings.js | 32 +++++++++++++++++++++----- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/node_modules/c9/has-internal-domain.js b/node_modules/c9/has-internal-domain.js index 56dc4da6..59feb85e 100644 --- a/node_modules/c9/has-internal-domain.js +++ b/node_modules/c9/has-internal-domain.js @@ -7,17 +7,12 @@ if (typeof define === "undefined") { define(function(require, exports, module) { "use strict"; - var _ = require("lodash"); - var internalDomain = ['c9.io', 'cloud9beta.com']; function hasInternalDomain(email) { if (!email) return false; - - var emailElements = email.split("@"); - var emailDomain = emailElements[emailElements.length - 1]; - - return _.contains(internalDomain, emailDomain); + var emailDomain = email.split("@").pop(); + return internalDomain.indexOf(emailDomain) != -1; } module.exports = hasInternalDomain; diff --git a/plugins/c9.core/settings.js b/plugins/c9.core/settings.js index 44affaff..7ac6b0e5 100644 --- a/plugins/c9.core/settings.js +++ b/plugins/c9.core/settings.js @@ -15,7 +15,6 @@ define(function(require, exports, module) { var api = imports.api; var info = imports.info; var util = imports.util; - var _ = require("lodash"); var join = require("path").join; @@ -346,17 +345,14 @@ define(function(require, exports, module) { } function update(type, json, ud) { - // Do nothing if they are the same - if (_.isEqual(model[type], json)) - return; - userData = ud; // Compare key/values (assume source has same keys as target) (function recur(source, target, base) { for (var prop in source) { if (prop == "json()") { - setJson(base, source[prop]); + if (!target || !isEqual(source[prop], target[prop])) + setJson(base, source[prop]); } else if (typeof source[prop] == "object") { if (!target[prop]) target[prop] = {}; @@ -371,6 +367,30 @@ define(function(require, exports, module) { userData = null; } + function isEqual(a, b) { + var typeA = typeof a; + var typeB = typeof b; + if (typeA != typeB) return false; + if (!a || typeA !== "object") + return a == b; + if (Array.isArray(a)) { + if (!Array.isArray(b)) return false; + if (a.length != b.length) return false; + for (var i = 0; i < a.length; i++) { + if (!isEqual(a[i], b[i])) return false; + } + } + else { + var aKeys = Object.keys(a); + var bKeys = Object.keys(b); + if (aKeys.length != bKeys.length) return false; + for (var i = 0; i < aKeys.length; i++) { + if (!isEqual(a[aKeys[i]], b[aKeys[i]])) return false; + } + } + return true; + } + function setNode(query, value) { return set(query, value, true); }