@stdlib/string-to-grapheme-cluster-iterator 0.0.1 → 0.1.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/CITATION.cff +30 -0
- package/README.md +14 -3
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +1 -1
- package/package.json +16 -15
- package/docs/repl.txt +0 -55
- package/docs/types/test.ts +0 -66
package/CITATION.cff
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: stdlib
|
|
3
|
+
message: >-
|
|
4
|
+
If you use this software, please cite it using the
|
|
5
|
+
metadata from this file.
|
|
6
|
+
|
|
7
|
+
type: software
|
|
8
|
+
|
|
9
|
+
authors:
|
|
10
|
+
- name: The Stdlib Authors
|
|
11
|
+
url: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
12
|
+
|
|
13
|
+
repository-code: https://github.com/stdlib-js/stdlib
|
|
14
|
+
url: https://stdlib.io
|
|
15
|
+
|
|
16
|
+
abstract: |
|
|
17
|
+
Standard library for JavaScript and Node.js.
|
|
18
|
+
|
|
19
|
+
keywords:
|
|
20
|
+
- JavaScript
|
|
21
|
+
- Node.js
|
|
22
|
+
- TypeScript
|
|
23
|
+
- standard library
|
|
24
|
+
- scientific computing
|
|
25
|
+
- numerical computing
|
|
26
|
+
- statistical computing
|
|
27
|
+
|
|
28
|
+
license: Apache-2.0 AND BSL-1.0
|
|
29
|
+
|
|
30
|
+
date-released: 2016
|
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] -->
|
|
@@ -252,8 +263,8 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
252
263
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/string-to-grapheme-cluster-iterator.svg
|
|
253
264
|
[npm-url]: https://npmjs.org/package/@stdlib/string-to-grapheme-cluster-iterator
|
|
254
265
|
|
|
255
|
-
[test-image]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml/badge.svg?branch=v0.0
|
|
256
|
-
[test-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml?query=branch:v0.0
|
|
266
|
+
[test-image]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
267
|
+
[test-url]: https://github.com/stdlib-js/string-to-grapheme-cluster-iterator/actions/workflows/test.yml?query=branch:v0.1.0
|
|
257
268
|
|
|
258
269
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-to-grapheme-cluster-iterator/main.svg
|
|
259
270
|
[coverage-url]: https://codecov.io/github/stdlib-js/string-to-grapheme-cluster-iterator?branch=main
|
|
@@ -266,7 +277,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
|
266
277
|
-->
|
|
267
278
|
|
|
268
279
|
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
269
|
-
[chat-url]: https://gitter.im
|
|
280
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
270
281
|
|
|
271
282
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
272
283
|
|
package/dist/index.d.ts
ADDED
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
|
+
}
|
package/docs/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/string-to-grapheme-cluster-iterator",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "Create an iterator which iterates grapheme clusters.",
|
|
3
|
+
"version": "0.1.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,19 +37,20 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/assert-is-function": "^0.0
|
|
41
|
-
"@stdlib/assert-is-string": "^0.0
|
|
42
|
-
"@stdlib/string-format": "^0.0
|
|
43
|
-
"@stdlib/string-next-grapheme-cluster-break": "^0.0
|
|
44
|
-
"@stdlib/symbol-iterator": "^0.0
|
|
45
|
-
"@stdlib/types": "^0.0
|
|
46
|
-
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.0
|
|
40
|
+
"@stdlib/assert-is-function": "^0.1.0",
|
|
41
|
+
"@stdlib/assert-is-string": "^0.1.0",
|
|
42
|
+
"@stdlib/string-format": "^0.1.0",
|
|
43
|
+
"@stdlib/string-next-grapheme-cluster-break": "^0.1.0",
|
|
44
|
+
"@stdlib/symbol-iterator": "^0.1.0",
|
|
45
|
+
"@stdlib/types": "^0.1.0",
|
|
46
|
+
"@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.0",
|
|
47
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@stdlib/assert-is-iterator-like": "^0.0
|
|
50
|
-
"@stdlib/bench": "^0.0
|
|
51
|
-
"@stdlib/string-num-grapheme-clusters": "^0.0.
|
|
52
|
-
"@stdlib/utils-noop": "^0.0
|
|
50
|
+
"@stdlib/assert-is-iterator-like": "^0.1.0",
|
|
51
|
+
"@stdlib/bench": "^0.1.0",
|
|
52
|
+
"@stdlib/string-num-grapheme-clusters": "^0.0.9",
|
|
53
|
+
"@stdlib/utils-noop": "^0.1.0",
|
|
53
54
|
"proxyquire": "^2.0.0",
|
|
54
55
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
55
56
|
"istanbul": "^0.4.1",
|
|
@@ -93,7 +94,7 @@
|
|
|
93
94
|
"convert"
|
|
94
95
|
],
|
|
95
96
|
"funding": {
|
|
96
|
-
"type": "
|
|
97
|
-
"url": "https://
|
|
97
|
+
"type": "opencollective",
|
|
98
|
+
"url": "https://opencollective.com/stdlib"
|
|
98
99
|
}
|
|
99
100
|
}
|
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
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -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
|
-
}
|