Browse Source

avoid for...of

gh-384
Rich-Harris 9 years ago
parent
commit
3c5d099cc7
  1. 8
      src/utils/validateKeys.js

8
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( ', ' ) }`
);

Loading…
Cancel
Save