Permalink
Browse files

fix: remove unnecessary escape chars (again)

  • Loading branch information...
jimlambie committed Dec 28, 2016
1 parent cfec695 commit 73aad00815f16c5acfa9b65e129f75678f8306fb
Showing with 2 additions and 74 deletions.
  1. +1 −1 dadi/lib/help.js
  2. +1 −1 dadi/lib/index.js
  3. +0 −72 dadi/lib/model/utils.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 {
@@ -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
})

@@ -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']

0 comments on commit 73aad00

Please sign in to comment.