aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es6-iterator/string.js
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/es6-iterator/string.js
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/es6-iterator/string.js')
-rw-r--r--node_modules/es6-iterator/string.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/node_modules/es6-iterator/string.js b/node_modules/es6-iterator/string.js
new file mode 100644
index 00000000..48882252
--- /dev/null
+++ b/node_modules/es6-iterator/string.js
@@ -0,0 +1,39 @@
+// Thanks @mathiasbynens
+// http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols
+
+"use strict";
+
+var setPrototypeOf = require("es5-ext/object/set-prototype-of")
+ , d = require("d")
+ , Symbol = require("es6-symbol")
+ , Iterator = require("./");
+
+var defineProperty = Object.defineProperty, StringIterator;
+
+StringIterator = module.exports = function (str) {
+ if (!(this instanceof StringIterator)) throw new TypeError("Constructor requires 'new'");
+ str = String(str);
+ Iterator.call(this, str);
+ defineProperty(this, "__length__", d("", str.length));
+};
+if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator);
+
+// Internal %ArrayIteratorPrototype% doesn't expose its constructor
+delete StringIterator.prototype.constructor;
+
+StringIterator.prototype = Object.create(Iterator.prototype, {
+ _next: d(function () {
+ if (!this.__list__) return undefined;
+ if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++;
+ this._unBind();
+ return undefined;
+ }),
+ _resolve: d(function (i) {
+ var char = this.__list__[i], code;
+ if (this.__nextIndex__ === this.__length__) return char;
+ code = char.charCodeAt(0);
+ if (code >= 0xd800 && code <= 0xdbff) return char + this.__list__[this.__nextIndex__++];
+ return char;
+ })
+});
+defineProperty(StringIterator.prototype, Symbol.toStringTag, d("c", "String Iterator"));