Skip to content

Commit

Permalink
fix: remove unnecessary escape chars (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlambie committed Dec 28, 2016
1 parent cfec695 commit 73aad00
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 74 deletions.
2 changes: 1 addition & 1 deletion dadi/lib/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion dadi/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
72 changes: 0 additions & 72 deletions dadi/lib/model/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.