terser foldl' implementation