StringIterator.cpp 666 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/Utf8View.h>
  7. #include <LibJS/Runtime/GlobalObject.h>
  8. #include <LibJS/Runtime/StringIterator.h>
  9. namespace JS {
  10. StringIterator* StringIterator::create(GlobalObject& global_object, String string)
  11. {
  12. return global_object.heap().allocate<StringIterator>(global_object, move(string), *global_object.string_iterator_prototype());
  13. }
  14. StringIterator::StringIterator(String string, Object& prototype)
  15. : Object(prototype)
  16. , m_string(move(string))
  17. , m_iterator(Utf8View(m_string).begin())
  18. {
  19. }
  20. StringIterator::~StringIterator()
  21. {
  22. }
  23. }