Replace awk with javascript