Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F8394314
es.string.iterator.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
es.string.iterator.js
View Options
'use strict'
;
var
charAt
=
require
(
'../internals/string-multibyte'
).
charAt
;
var
toString
=
require
(
'../internals/to-string'
);
var
InternalStateModule
=
require
(
'../internals/internal-state'
);
var
defineIterator
=
require
(
'../internals/iterator-define'
);
var
STRING_ITERATOR
=
'String Iterator'
;
var
setInternalState
=
InternalStateModule
.
set
;
var
getInternalState
=
InternalStateModule
.
getterFor
(
STRING_ITERATOR
);
// `String.prototype[@@iterator]` method
// https://tc39.es/ecma262/#sec-string.prototype-@@iterator
defineIterator
(
String
,
'String'
,
function
(
iterated
)
{
setInternalState
(
this
,
{
type
:
STRING_ITERATOR
,
string
:
toString
(
iterated
),
index
:
0
});
// `%StringIteratorPrototype%.next` method
// https://tc39.es/ecma262/#sec-%stringiteratorprototype%.next
},
function
next
()
{
var
state
=
getInternalState
(
this
);
var
string
=
state
.
string
;
var
index
=
state
.
index
;
var
point
;
if
(
index
>=
string
.
length
)
return
{
value
:
undefined
,
done
:
true
};
point
=
charAt
(
string
,
index
);
state
.
index
+=
point
.
length
;
return
{
value
:
point
,
done
:
false
};
});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jun 4, 7:23 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3361278
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment