@stdlib/string-to-grapheme-cluster-iterator 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2023 The Stdlib Authors.
1
+ Copyright (c) 2016-2024 The Stdlib Authors.
package/README.md CHANGED
@@ -18,6 +18,17 @@ limitations under the License.
18
18
 
19
19
  -->
20
20
 
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
21
32
  # graphemeClusters2iterator
22
33
 
23
34
  [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
@@ -209,6 +220,13 @@ while ( true ) {
209
220
 
210
221
  <section class="related">
211
222
 
223
+ * * *
224
+
225
+ ## See Also
226
+
227
+ - <span class="package-name">[`@stdlib/array-to-iterator`][@stdlib/array/to-iterator]</span><span class="delimiter">: </span><span class="description">create an iterator from an array-like object.</span>
228
+ - <span class="package-name">[`@stdlib/string-to-grapheme-cluster-iterator-right`][@stdlib/string/to-grapheme-cluster-iterator-right]</span><span class="delimiter">: </span><span class="description">create an iterator which iterates from right to left over grapheme clusters.</span>
229
+
212
230
  </section>
213
231
 
214
232
  <!-- /.related -->
@@ -239,7 +257,7 @@ See [LICENSE][stdlib-license].
239
257
 
240
258
  ## Copyright
241
259
 
242
- Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
260
+ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
243
261
 
244
262
  </section>
245
263
 
@@ -252,8 +270,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
252
270
  [npm-image]: http://img.shields.io/npm/v/@stdlib/string-to-grapheme-cluster-iterator.svg
253
271
  [npm-url]: https://npmjs.org/package/@stdlib/string-to-grapheme-cluster-iterator
254
272
 
255
- [test-image]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml/badge.svg?branch=v0.0.1
256
- [test-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml?query=branch:v0.0.1
273
+ [test-image]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml/badge.svg?branch=v0.2.0
274
+ [test-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml?query=branch:v0.2.0
257
275
 
258
276
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-to-grapheme-cluster-iterator/main.svg
259
277
  [coverage-url]: https://codecov.io/github/stdlib-js/string-to-grapheme-cluster-iterator?branch=main
@@ -266,7 +284,7 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
266
284
  -->
267
285
 
268
286
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
269
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
287
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
270
288
 
271
289
  [stdlib]: https://github.com/stdlib-js/stdlib
272
290
 
@@ -276,14 +294,25 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
276
294
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
277
295
 
278
296
  [deno-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/tree/deno
297
+ [deno-readme]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/blob/deno/README.md
279
298
  [umd-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/tree/umd
299
+ [umd-readme]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/blob/umd/README.md
280
300
  [esm-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/tree/esm
301
+ [esm-readme]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/blob/esm/README.md
281
302
  [branches-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/blob/main/branches.md
282
303
 
283
304
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/string-to-grapheme-cluster-iterator/main/LICENSE
284
305
 
285
306
  [unicode-text-segmentation]: http://www.unicode.org/reports/tr29/
286
307
 
308
+ <!-- <related-links> -->
309
+
310
+ [@stdlib/array/to-iterator]: https://www.npmjs.com/package/@stdlib/array-to-iterator
311
+
312
+ [@stdlib/string/to-grapheme-cluster-iterator-right]: https://www.npmjs.com/package/@stdlib/string-to-grapheme-cluster-iterator-right
313
+
314
+ <!-- </related-links> -->
315
+
287
316
  </section>
288
317
 
289
318
  <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import graphemeClusters2iterator from '../docs/types/index';
3
+ export = graphemeClusters2iterator;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var p=function(e,t){return function(){return t||e((t={exports:{}}).exports,t),t.exports}};var d=p(function(j,m){
2
+ var f=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),y=require('@stdlib/assert-is-function/dist'),w=require('@stdlib/assert-is-string/dist').isPrimitive,v=require('@stdlib/symbol-iterator/dist'),s=require('@stdlib/string-next-grapheme-cluster-break/dist'),g=require('@stdlib/error-tools-fmtprodmsg/dist');function l(e){var t,a,o,u,r;if(!w(e))throw new TypeError(g('1h1E6',e));if(arguments.length>1){if(u=arguments[1],!y(u))throw new TypeError(g('1h12H',u));t=arguments[2]}return r=0,a={},u?f(a,"next",h):f(a,"next",b),f(a,"return",q),v&&f(a,v,x),a;function h(){var i,n;return o?{done:!0}:(n=s(e,r),n===-1?(o=!0,e.length?{value:u.call(t,e.substring(r),r,e),done:!1}:{done:!0}):(i=u.call(t,e.substring(r,n),r,e),r=n,{value:i,done:!1}))}function b(){var i,n;return o?{done:!0}:(n=s(e,r),n===-1?(o=!0,e.length?{value:e.substring(r),done:!1}:{done:!0}):(i=e.substring(r,n),r=n,{value:i,done:!1}))}function q(i){return o=!0,arguments.length?{value:i,done:!0}:{done:!0}}function x(){return u?l(e,u,t):l(e)}}m.exports=l
3
+ });var F=d();module.exports=F;
4
+ /** @license Apache-2.0 */
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar iteratorSymbol = require( '@stdlib/symbol-iterator' );\nvar nextGraphemeClusterBreak = require( '@stdlib/string-next-grapheme-cluster-break' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an iterator which iterates over each grapheme cluster in a string.\n*\n* @param {string} src - input value\n* @param {Function} [mapFcn] - function to invoke for each iterated value\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} second argument must be a function\n* @returns {Iterator} iterator\n*\n* @example\n* var iter = graphemeClusters2iterator( '\uD83C\uDF37\uD83C\uDF55' );\n*\n* var v = iter.next().value;\n* // returns '\uD83C\uDF37'\n*\n* v = iter.next().value;\n* // returns '\uD83C\uDF55'\n*\n* var bool = iter.next().done;\n* // returns true\n*/\nfunction graphemeClusters2iterator( src ) {\n\tvar thisArg;\n\tvar iter;\n\tvar FLG;\n\tvar fcn;\n\tvar i;\n\tif ( !isString( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be astring. Value: `%s`.', src ) );\n\t}\n\tif ( arguments.length > 1 ) {\n\t\tfcn = arguments[ 1 ];\n\t\tif ( !isFunction( fcn ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', fcn ) );\n\t\t}\n\t\tthisArg = arguments[ 2 ];\n\t}\n\ti = 0;\n\n\t// Create an iterator protocol-compliant object:\n\titer = {};\n\tif ( fcn ) {\n\t\tsetReadOnly( iter, 'next', next1 );\n\t} else {\n\t\tsetReadOnly( iter, 'next', next2 );\n\t}\n\tsetReadOnly( iter, 'return', end );\n\n\t// If an environment supports `Symbol.iterator`, make the iterator iterable:\n\tif ( iteratorSymbol ) {\n\t\tsetReadOnly( iter, iteratorSymbol, factory );\n\t}\n\treturn iter;\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next1() {\n\t\tvar v;\n\t\tvar j;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tj = nextGraphemeClusterBreak( src, i );\n\t\tif ( j === -1 ) {\n\t\t\tFLG = true;\n\t\t\tif ( src.length ) {\n\t\t\t\treturn {\n\t\t\t\t\t'value': fcn.call( thisArg, src.substring( i ), i, src ),\n\t\t\t\t\t'done': false\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = fcn.call( thisArg, src.substring( i, j ), i, src );\n\t\ti = j;\n\t\treturn {\n\t\t\t'value': v,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Returns an iterator protocol-compliant object containing the next iterated value.\n\t*\n\t* @private\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction next2() {\n\t\tvar v;\n\t\tvar j;\n\t\tif ( FLG ) {\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tj = nextGraphemeClusterBreak( src, i );\n\t\tif ( j === -1 ) {\n\t\t\tFLG = true;\n\t\t\tif ( src.length ) {\n\t\t\t\treturn {\n\t\t\t\t\t'value': src.substring( i ),\n\t\t\t\t\t'done': false\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\tv = src.substring( i, j );\n\t\ti = j;\n\t\treturn {\n\t\t\t'value': v,\n\t\t\t'done': false\n\t\t};\n\t}\n\n\t/**\n\t* Finishes an iterator.\n\t*\n\t* @private\n\t* @param {*} [value] - value to return\n\t* @returns {Object} iterator protocol-compliant object\n\t*/\n\tfunction end( value ) {\n\t\tFLG = true;\n\t\tif ( arguments.length ) {\n\t\t\treturn {\n\t\t\t\t'value': value,\n\t\t\t\t'done': true\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t'done': true\n\t\t};\n\t}\n\n\t/**\n\t* Returns a new iterator.\n\t*\n\t* @private\n\t* @returns {Iterator} iterator\n\t*/\n\tfunction factory() {\n\t\tif ( fcn ) {\n\t\t\treturn graphemeClusters2iterator( src, fcn, thisArg );\n\t\t}\n\t\treturn graphemeClusters2iterator( src );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = graphemeClusters2iterator;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2022 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create an iterator which iterates over grapheme clusters.\n*\n* @module @stdlib/string-to-grapheme-cluster-iterator\n*\n* @example\n* var graphemeClusters2iterator = require( '@stdlib/string-to-grapheme-cluster-iterator' );\n*\n* var iter = graphemeClusters2iterator( '\uD83C\uDF37\uD83C\uDF55' );\n*\n* var v = iter.next().value;\n* // returns '\uD83C\uDF37'\n*\n* v = iter.next().value;\n* // returns '\uD83C\uDF55'\n*\n* var bool = iter.next().done;\n* // returns true\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAc,QAAS,uDAAwD,EAC/EC,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAiB,QAAS,yBAA0B,EACpDC,EAA2B,QAAS,4CAA6C,EACjFC,EAAS,QAAS,uBAAwB,EA2B9C,SAASC,EAA2BC,EAAM,CACzC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,CAACV,EAAUK,CAAI,EACnB,MAAM,IAAI,UAAWF,EAAQ,iEAAkEE,CAAI,CAAE,EAEtG,GAAK,UAAU,OAAS,EAAI,CAE3B,GADAI,EAAM,UAAW,CAAE,EACd,CAACV,EAAYU,CAAI,EACrB,MAAM,IAAI,UAAWN,EAAQ,qEAAsEM,CAAI,CAAE,EAE1GH,EAAU,UAAW,CAAE,CACxB,CACA,OAAAI,EAAI,EAGJH,EAAO,CAAC,EACHE,EACJX,EAAaS,EAAM,OAAQI,CAAM,EAEjCb,EAAaS,EAAM,OAAQK,CAAM,EAElCd,EAAaS,EAAM,SAAUM,CAAI,EAG5BZ,GACJH,EAAaS,EAAMN,EAAgBa,CAAQ,EAErCP,EAQP,SAASI,GAAQ,CAChB,IAAII,EACAC,EACJ,OAAKR,EACG,CACN,KAAQ,EACT,GAEDQ,EAAId,EAA0BG,EAAKK,CAAE,EAChCM,IAAM,IACVR,EAAM,GACDH,EAAI,OACD,CACN,MAASI,EAAI,KAAMH,EAASD,EAAI,UAAWK,CAAE,EAAGA,EAAGL,CAAI,EACvD,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,IAEDU,EAAIN,EAAI,KAAMH,EAASD,EAAI,UAAWK,EAAGM,CAAE,EAAGN,EAAGL,CAAI,EACrDK,EAAIM,EACG,CACN,MAASD,EACT,KAAQ,EACT,GACD,CAQA,SAASH,GAAQ,CAChB,IAAIG,EACAC,EACJ,OAAKR,EACG,CACN,KAAQ,EACT,GAEDQ,EAAId,EAA0BG,EAAKK,CAAE,EAChCM,IAAM,IACVR,EAAM,GACDH,EAAI,OACD,CACN,MAASA,EAAI,UAAWK,CAAE,EAC1B,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,IAEDK,EAAIV,EAAI,UAAWK,EAAGM,CAAE,EACxBN,EAAIM,EACG,CACN,MAASD,EACT,KAAQ,EACT,GACD,CASA,SAASF,EAAKI,EAAQ,CAErB,OADAT,EAAM,GACD,UAAU,OACP,CACN,MAASS,EACT,KAAQ,EACT,EAEM,CACN,KAAQ,EACT,CACD,CAQA,SAASH,GAAU,CAClB,OAAKL,EACGL,EAA2BC,EAAKI,EAAKH,CAAQ,EAE9CF,EAA2BC,CAAI,CACvC,CACD,CAKAR,EAAO,QAAUO,ICxJjB,IAAIc,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "setReadOnly", "isFunction", "isString", "iteratorSymbol", "nextGraphemeClusterBreak", "format", "graphemeClusters2iterator", "src", "thisArg", "iter", "FLG", "fcn", "i", "next1", "next2", "end", "factory", "v", "j", "value", "main"]
7
+ }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
@@ -89,7 +89,7 @@ type MapFunction = Nullary | Unary | Binary | Ternary;
89
89
  * var bool = iter.next().done;
90
90
  * // returns true
91
91
  */
92
- declare function graphemeClusters2iterator( src: string, mapFcn?: MapFunction, thisArg?: any ): Iterator; // tslint:disable-line:max-line-length
92
+ declare function graphemeClusters2iterator( src: string, mapFcn?: MapFunction, thisArg?: any ): Iterator;
93
93
 
94
94
 
95
95
  // EXPORTS //
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stdlib/string-to-grapheme-cluster-iterator",
3
- "version": "0.0.1",
4
- "description": "Create an iterator which iterates grapheme clusters.",
3
+ "version": "0.2.0",
4
+ "description": "Create an iterator which iterates over grapheme clusters.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "The Stdlib Authors",
@@ -37,23 +37,25 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/assert-is-function": "^0.0.x",
41
- "@stdlib/assert-is-string": "^0.0.x",
42
- "@stdlib/string-format": "^0.0.x",
43
- "@stdlib/string-next-grapheme-cluster-break": "^0.0.x",
44
- "@stdlib/symbol-iterator": "^0.0.x",
45
- "@stdlib/types": "^0.0.x",
46
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x"
40
+ "@stdlib/assert-is-function": "^0.2.0",
41
+ "@stdlib/assert-is-string": "^0.2.0",
42
+ "@stdlib/string-format": "^0.2.0",
43
+ "@stdlib/string-next-grapheme-cluster-break": "^0.2.0",
44
+ "@stdlib/symbol-iterator": "^0.2.0",
45
+ "@stdlib/types": "^0.3.1",
46
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0",
47
+ "@stdlib/error-tools-fmtprodmsg": "^0.1.1"
47
48
  },
48
49
  "devDependencies": {
49
- "@stdlib/assert-is-iterator-like": "^0.0.x",
50
- "@stdlib/bench": "^0.0.x",
51
- "@stdlib/string-num-grapheme-clusters": "^0.0.x",
52
- "@stdlib/utils-noop": "^0.0.x",
50
+ "@stdlib/assert-is-iterator-like": "^0.2.0",
51
+ "@stdlib/string-num-grapheme-clusters": "^0.1.0",
52
+ "@stdlib/utils-noop": "^0.2.0",
53
53
  "proxyquire": "^2.0.0",
54
54
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
55
55
  "istanbul": "^0.4.1",
56
- "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
56
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git",
57
+ "@stdlib/bench-harness": "^0.1.2",
58
+ "@stdlib/bench": "^0.3.1"
57
59
  },
58
60
  "engines": {
59
61
  "node": ">=0.10.0",
@@ -93,7 +95,7 @@
93
95
  "convert"
94
96
  ],
95
97
  "funding": {
96
- "type": "patreon",
97
- "url": "https://www.patreon.com/athan"
98
+ "type": "opencollective",
99
+ "url": "https://opencollective.com/stdlib"
98
100
  }
99
101
  }
package/docs/repl.txt DELETED
@@ -1,55 +0,0 @@
1
-
2
- {{alias}}( src[, mapFcn[, thisArg]] )
3
- Returns an iterator which iterates over each grapheme cluster in a string.
4
-
5
- When invoked, an input function is provided three arguments:
6
-
7
- - value: grapheme cluster
8
- - index: iterated value index
9
- - src: source string
10
-
11
- If an environment supports Symbol.iterator, the returned iterator is
12
- iterable.
13
-
14
- If an environment supports Symbol.iterator, the function explicitly does not
15
- invoke a string's `@@iterator` method, regardless of whether this method is
16
- defined. To convert a string to an implementation defined iterator, invoke
17
- this method directly.
18
-
19
- Parameters
20
- ----------
21
- src: string
22
- String from which to create the iterator.
23
-
24
- mapFcn: Function (optional)
25
- Function to invoke for each iterated value.
26
-
27
- thisArg: any (optional)
28
- Execution context.
29
-
30
- Returns
31
- -------
32
- iterator: Object
33
- Iterator.
34
-
35
- iterator.next(): Function
36
- Returns an iterator protocol-compliant object containing the next
37
- iterated value (if one exists) and a boolean flag indicating whether the
38
- iterator is finished.
39
-
40
- iterator.return( [value] ): Function
41
- Finishes an iterator and returns a provided value.
42
-
43
- Examples
44
- --------
45
- > var it = {{alias}}( '🌷🍕' );
46
- > var v = it.next().value
47
- '🌷'
48
- > v = it.next().value
49
- '🍕'
50
- > var bool = it.next().done
51
- true
52
-
53
- See Also
54
- --------
55
-
@@ -1,66 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2022 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import graphemeClusters2iterator = require( './index' );
20
-
21
- /**
22
- * Transforms a string.
23
- *
24
- * @param v - iterated value
25
- * @returns new value
26
- */
27
- function transform( v: string ): string {
28
- return v + v;
29
- }
30
-
31
-
32
- // TESTS //
33
-
34
- // The function returns an iterator...
35
- {
36
- graphemeClusters2iterator( 'beep' ); // $ExpectType Iterator
37
- graphemeClusters2iterator( 'beep', transform ); // $ExpectType Iterator
38
- graphemeClusters2iterator( 'beep', transform, {} ); // $ExpectType Iterator
39
- }
40
-
41
- // The compiler throws an error if the function is provided a first argument which is not a string...
42
- {
43
- graphemeClusters2iterator( 123 ); // $ExpectError
44
- graphemeClusters2iterator( true ); // $ExpectError
45
- graphemeClusters2iterator( false ); // $ExpectError
46
- graphemeClusters2iterator( {} ); // $ExpectError
47
- graphemeClusters2iterator( null ); // $ExpectError
48
- graphemeClusters2iterator( undefined ); // $ExpectError
49
- }
50
-
51
- // The compiler throws an error if the function is provided a second argument which is not a map function...
52
- {
53
- graphemeClusters2iterator( 'beep', 'abc' ); // $ExpectError
54
- graphemeClusters2iterator( 'beep', 123 ); // $ExpectError
55
- graphemeClusters2iterator( 'beep', [] ); // $ExpectError
56
- graphemeClusters2iterator( 'beep', {} ); // $ExpectError
57
- graphemeClusters2iterator( 'beep', true ); // $ExpectError
58
- graphemeClusters2iterator( 'beep', false ); // $ExpectError
59
- graphemeClusters2iterator( 'beep', null ); // $ExpectError
60
- }
61
-
62
- // The compiler throws an error if the function is provided an unsupported number of arguments...
63
- {
64
- graphemeClusters2iterator(); // $ExpectError
65
- graphemeClusters2iterator( 'beep', transform, {}, 123 ); // $ExpectError
66
- }