From 73aad00815f16c5acfa9b65e129f75678f8306fb Mon Sep 17 00:00:00 2001 From: James Lambie Date: Wed, 28 Dec 2016 16:10:21 +0800 Subject: [PATCH] fix: remove unnecessary escape chars (again) --- dadi/lib/help.js | 2 +- dadi/lib/index.js | 2 +- dadi/lib/model/utils.js | 72 ----------------------------------------- 3 files changed, 2 insertions(+), 74 deletions(-) diff --git a/dadi/lib/help.js b/dadi/lib/help.js index 51a7f1ed..fc5fb2b5 100755 --- a/dadi/lib/help.js +++ b/dadi/lib/help.js @@ -113,7 +113,7 @@ module.exports.transformQuery = function (obj, type) { case 'String': transformFunction = function (obj) { - var regexParts = obj.match(/\/([^\/]*)\/([i]{0,1})$/) + var regexParts = obj.match(/\/([^/]*)\/([i]{0,1})$/) if (regexParts) { try { diff --git a/dadi/lib/index.js b/dadi/lib/index.js index 5087559b..da3a8fe9 100755 --- a/dadi/lib/index.js +++ b/dadi/lib/index.js @@ -77,7 +77,7 @@ Server.prototype.run = function (done) { // Watch the current directory for a "restart.api" file var watcher = chokidar.watch(process.cwd(), { depth: 1, - ignored: /[\/\\]\./, + ignored: /[/\\]\./, ignoreInitial: true }) diff --git a/dadi/lib/model/utils.js b/dadi/lib/model/utils.js index 6228f53a..76080a26 100644 --- a/dadi/lib/model/utils.js +++ b/dadi/lib/model/utils.js @@ -152,75 +152,3 @@ module.exports = { makeCaseInsensitive: makeCaseInsensitive, processReferenceFieldQuery: processReferenceFieldQuery } - -_.mixin({ - // Get/set the value of a nested property - deep: function (obj, key, value) { - var keys = key.replace(/\[(["']?)([^\1]+?)\1?\]/g, '.$2').replace(/^\./, '').split('.') - var root - var i = 0 - var n = keys.length - - // Set deep value - if (arguments.length > 2) { - root = obj - n-- - - while (i < n) { - key = keys[i++] - obj = obj[key] = _.isObject(obj[key]) ? obj[key] : {} - } - - obj[keys[i]] = value - - value = root - - // Get deep value - } else { - while ((obj = obj[keys[i++]]) != null && i < n) {} - value = i < n ? void 0 : obj - } - - return value - } -}) - -// Usage: -// -// var obj = { -// a: { -// b: { -// c: { -// d: ['e', 'f', 'g'] -// } -// } -// } -// } -// -// Get deep value -// _.deep(obj, 'a.b.c.d[2]'); // 'g' -// -// Set deep value -// _.deep(obj, 'a.b.c.d[2]', 'george') -// -// _.deep(obj, 'a.b.c.d[2]'); // 'george' - -_.mixin({ - pluckDeep: function (obj, key) { - return _.map(obj, function (value) { return _.deep(value, key) }) - } -}) - -// Usage: -// -// var arr = [{ -// deeply: { -// nested: 'foo' -// } -// }, { -// deeply: { -// nested: 'bar' -// } -// }] -// -// _.pluckDeep(arr, 'deeply.nested') // ['foo', 'bar']