Skip to content

Commit

Permalink
Object.values shim (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyka authored and greena13 committed Jan 1, 2020
1 parent 16e66c9 commit bfe9c06
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/const/NonPrintableKeysDictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
*/
import dictionaryFrom from '../utils/object/dictionaryFrom';
import translateToKey from '../vendor/react-dom/translateToKey';
import objectValues from '../utils/object/values';

const NonPrintableKeysDictionary =
dictionaryFrom(Object.values(translateToKey));
dictionaryFrom(objectValues(translateToKey));

export default NonPrintableKeysDictionary;
3 changes: 2 additions & 1 deletion src/lib/config/Configuration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dictionaryFrom from '../../utils/object/dictionaryFrom';
import objectValues from '../../utils/object/values';

/**
* Default configuration values
Expand Down Expand Up @@ -150,7 +151,7 @@ class Configuration {
}

if (customKeyCodes) {
configuration._customKeyNamesDict = dictionaryFrom(Object.values(configuration.customKeyCodes));
configuration._customKeyNamesDict = dictionaryFrom(objectValues(configuration.customKeyCodes));
}

// noinspection JSUnresolvedVariable
Expand Down
6 changes: 4 additions & 2 deletions src/lib/listening/GlobalEventListenerAdaptor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import KeyEventType from '../../const/KeyEventType';
import describeKeyEventType from '../../helpers/logging/describeKeyEventType';
import normalizeEventName from '../../utils/string/normalizeEventName';
import objectValues from '../../utils/object/values';


class GlobalEventListenerAdaptor {
constructor(strategy, {logger}) {
Expand All @@ -20,7 +22,7 @@ class GlobalEventListenerAdaptor {
}

unbindListeners() {
Object.values(KeyEventType).forEach((recordIndex) => {
objectValues(KeyEventType).forEach((recordIndex) => {
const eventName = describeKeyEventType(recordIndex);

delete document[`on${eventName}`];
Expand All @@ -32,7 +34,7 @@ class GlobalEventListenerAdaptor {
}

bindListeners() {
Object.values(KeyEventType).forEach((recordIndex) => {
objectValues(KeyEventType).forEach((recordIndex) => {
const eventName = describeKeyEventType(recordIndex);

document[`on${eventName}`] = (keyEvent) => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/matching/KeyCombinationMatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Configuration from '../config/Configuration';
import size from '../../utils/collection/size';
import keyupIsHiddenByCmd from '../../helpers/resolving-handlers/keyupIsHiddenByCmd';
import lazyLoadAttribute from '../../utils/object/lazyLoadAttribute';
import objectValues from '../../utils/object/values';
import KeyCombinationIterator from '../listening/KeyCombinationIterator';

/**
Expand Down Expand Up @@ -149,7 +150,7 @@ class KeyCombinationMatcher {
* size so that they may be applied in the correct priority order
*/

const combinationsPartitionedBySize = Object.values(this._actionConfigs).reduce((memo, {id, size}) => {
const combinationsPartitionedBySize = objectValues(this._actionConfigs).reduce((memo, {id, size}) => {
if (!memo[size]) {
memo[size] = [];
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/object/values.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default object => Object.keys(object).map(key => object[key]);

0 comments on commit bfe9c06

Please sign in to comment.