Skip to content

Commit

Permalink
Switched Map to Set - value doesn't matter
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury Michurin committed Dec 5, 2016
1 parent e1477e5 commit 8f0a228
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions client/components/auto-direction/direction.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,19 +791,19 @@ const LEFT_TO_RIGHT = [
];

const createLookUpMap = ( charactersRangeArray ) => {
const map = new Map();
const set = new Set();

charactersRangeArray.forEach( range => {
for ( let i = range[ 0 ]; i <= range[ 1 ]; i++ ) {
map.set( i, true );
set.add( i );
}
} );

return map;
return set;
};

const RTL_MAP = createLookUpMap( RIGHT_TO_LEFT );
const LTR_MAP = createLookUpMap( LEFT_TO_RIGHT );
const RTL_SET = createLookUpMap( RIGHT_TO_LEFT );
const LTR_SET = createLookUpMap( LEFT_TO_RIGHT );

export const isRTLCharacter = character => RTL_MAP.has( character.charCodeAt( 0 ) );
export const isLTRCharacter = character => LTR_MAP.has( character.charCodeAt( 0 ) );
export const isRTLCharacter = character => RTL_SET.has( character.charCodeAt( 0 ) );
export const isLTRCharacter = character => LTR_SET.has( character.charCodeAt( 0 ) );

0 comments on commit 8f0a228

Please sign in to comment.