ladybird/Userland/Libraries/LibJS/Runtime/StringIterator.cpp

25 lines
626 B
C++
Raw Normal View History

2020-07-12 03:23:01 +00:00
/*
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
2020-07-12 03:23:01 +00:00
*
* SPDX-License-Identifier: BSD-2-Clause
2020-07-12 03:23:01 +00:00
*/
#include <AK/Utf8View.h>
#include <LibJS/Runtime/GlobalObject.h>
#include <LibJS/Runtime/StringIterator.h>
2020-07-12 03:23:01 +00:00
namespace JS {
StringIterator* StringIterator::create(GlobalObject& global_object, String string)
{
return global_object.heap().allocate<StringIterator>(global_object, move(string), *global_object.string_iterator_prototype());
2020-07-12 03:23:01 +00:00
}
StringIterator::StringIterator(String string, Object& prototype)
2020-07-12 03:23:01 +00:00
: Object(prototype)
, m_string(move(string))
, m_iterator(Utf8View(m_string).begin())
{
}
}