From 3c5d099cc7000fdf85995d382809a6fb774059a4 Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Tue, 22 Dec 2015 10:37:18 -0500 Subject: [PATCH] avoid for...of --- src/utils/validateKeys.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/validateKeys.js b/src/utils/validateKeys.js index ec172f5..3ff51cd 100644 --- a/src/utils/validateKeys.js +++ b/src/utils/validateKeys.js @@ -3,8 +3,12 @@ import { keys } from './object.js'; export default function validateKeys ( object, allowedKeys ) { const actualKeys = keys( object ); - for ( let key of actualKeys ) { - if ( allowedKeys.indexOf( key ) < 0 ) { + let i = actualKeys.length; + + while ( i-- ) { + const key = actualKeys[i]; + + if ( allowedKeys.indexOf( key ) === -1 ) { return new Error( `Unexpected key '${ key }' found, expected one of: ${ allowedKeys.join( ', ' ) }` );