Developing a smart autocomplete javascript library