mirror of https://github.com/lukechilds/rollup.git
Rich Harris
9 years ago
3 changed files with 53 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||
import { keys } from './object.js'; |
|||
|
|||
export default function validateKeys ( object, allowedKeys ) { |
|||
const actualKeys = keys( object ); |
|||
|
|||
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…
Reference in new issue