I've just read [Snow White and Rose Red](https://www.goodreads.com/book/show/8249810-snow-white-and-rose-red) by Patricia C. Wrede, and the author has her characters speak in a vaguely Shakespearean manner, presumably to add atmosphere. In particular, her characters use the word "an" to mean "if". For example, one of her characters says:

> 
> “An our ends be Godly, what need we fear?”
> 
> 
> 

to mean (presumably) *If our ends be Godly*. This is a use of "an" that I've seen in the more dubious end of the fantasy literature many times over the decades, but I have never been clear whether the word was used this way in real English.

So my question is whether the use of "an" to mean "if" is an invention of fantasy writers or whether it was used this way in real life, and if so at what period in history and by whom?