underscore-plus
Advanced tools
Comparing version 1.3.0 to 1.4.0
(function() { | ||
var isEqual, modifierKeyMap, plus, shiftKeyMap, _, | ||
var isEqual, macModifierKeyMap, nonMacModifierKeyMap, plus, shiftKeyMap, _, | ||
__slice = [].slice; | ||
@@ -7,3 +7,3 @@ | ||
modifierKeyMap = { | ||
macModifierKeyMap = { | ||
cmd: '\u2318', | ||
@@ -21,2 +21,15 @@ ctrl: '\u2303', | ||
nonMacModifierKeyMap = { | ||
cmd: 'Cmd', | ||
ctrl: 'Ctrl', | ||
alt: 'Alt', | ||
option: 'Alt', | ||
shift: 'Shift', | ||
enter: 'Enter', | ||
left: 'Left', | ||
right: 'Right', | ||
up: 'Up', | ||
down: 'Down' | ||
}; | ||
shiftKeyMap = { | ||
@@ -92,2 +105,3 @@ '~': '`', | ||
deepClone: function(object) { | ||
var _this = this; | ||
if (_.isArray(object)) { | ||
@@ -98,7 +112,5 @@ return object.map(function(value) { | ||
} else if (_.isObject(object)) { | ||
return plus.mapObject(object, (function(_this) { | ||
return function(key, value) { | ||
return [key, plus.deepClone(value)]; | ||
}; | ||
})(this)); | ||
return plus.mapObject(object, function(key, value) { | ||
return [key, plus.deepClone(value)]; | ||
}); | ||
} else { | ||
@@ -163,6 +175,11 @@ return object; | ||
}, | ||
humanizeKey: function(key) { | ||
humanizeKey: function(key, platform) { | ||
var modifierKeyMap; | ||
if (platform == null) { | ||
platform = process.platform; | ||
} | ||
if (!key) { | ||
return key; | ||
} | ||
modifierKeyMap = platform === 'darwin' ? macModifierKeyMap : nonMacModifierKeyMap; | ||
if (modifierKeyMap[key]) { | ||
@@ -177,7 +194,14 @@ return modifierKeyMap[key]; | ||
} else { | ||
return key; | ||
if (platform === 'darwin') { | ||
return key; | ||
} else { | ||
return plus.capitalize(key); | ||
} | ||
} | ||
}, | ||
humanizeKeystroke: function(keystroke) { | ||
humanizeKeystroke: function(keystroke, platform) { | ||
var humanizedKeystrokes, index, key, keys, keystrokes, splitKeystroke, _i, _j, _len, _len1; | ||
if (platform == null) { | ||
platform = process.platform; | ||
} | ||
if (!keystroke) { | ||
@@ -198,6 +222,12 @@ return keystroke; | ||
if (key) { | ||
keys.push(plus.humanizeKey(key)); | ||
keys.push(plus.humanizeKey(key, platform)); | ||
} | ||
} | ||
humanizedKeystrokes.push(_.uniq(_.flatten(keys)).join('')); | ||
keys = _.uniq(_.flatten(keys)); | ||
if (platform === 'darwin') { | ||
keys = keys.join(''); | ||
} else { | ||
keys = keys.join('+'); | ||
} | ||
humanizedKeystrokes.push(keys); | ||
} | ||
@@ -204,0 +234,0 @@ return humanizedKeystrokes.join(' '); |
{ | ||
"name": "underscore-plus", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Underscore plus additional utilities", | ||
@@ -5,0 +5,0 @@ "licenses": [ |
@@ -1,2 +0,2 @@ | ||
# underscore-plus [![Build Status](https://travis-ci.org/atom/underscore-plus.png?branch=master)](https://travis-ci.org/atom/underscore-plus) | ||
# underscore-plus [![Build Status](https://travis-ci.org/atom/underscore-plus.svg?branch=master)](https://travis-ci.org/atom/underscore-plus) | ||
@@ -3,0 +3,0 @@ Takes the great [underscore](http://underscorejs.org/) library and adds a few |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16605
5
505