@stdlib/string-for-each 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 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
  # forEach
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] -->
@@ -202,8 +213,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
202
213
  [npm-image]: http://img.shields.io/npm/v/@stdlib/string-for-each.svg
203
214
  [npm-url]: https://npmjs.org/package/@stdlib/string-for-each
204
215
 
205
- [test-image]: https://github.com/stdlib-js/string-for-each/actions/workflows/test.yml/badge.svg?branch=v0.0.1
206
- [test-url]: https://github.com/stdlib-js/string-for-each/actions/workflows/test.yml?query=branch:v0.0.1
216
+ [test-image]: https://github.com/stdlib-js/string-for-each/actions/workflows/test.yml/badge.svg?branch=v0.1.0
217
+ [test-url]: https://github.com/stdlib-js/string-for-each/actions/workflows/test.yml?query=branch:v0.1.0
207
218
 
208
219
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/string-for-each/main.svg
209
220
  [coverage-url]: https://codecov.io/github/stdlib-js/string-for-each?branch=main
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import forEach from '../docs/types/index';
3
+ export = forEach;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var d=function(a,e){return function(){return e||a((e={exports:{}}).exports,e),e.exports}};var l=d(function(P,v){
2
+ var f=require('@stdlib/assert-is-function/dist'),c=require('@stdlib/assert-is-string/dist').isPrimitive,m=require('@stdlib/assert-is-plain-object/dist'),g=require('@stdlib/assert-has-own-property/dist'),h=require('@stdlib/array-base-assert-contains/dist').factory,q=require('@stdlib/string-base-for-each/dist'),w=require('@stdlib/string-base-for-each-code-point/dist'),E=require('@stdlib/string-base-for-each-grapheme-cluster/dist'),n=require('@stdlib/error-tools-fmtprodmsg/dist'),s=["grapheme","code_point","code_unit"],p={grapheme:E,code_point:w,code_unit:q},b=h(s);function y(a,e,t){var u,o,i,r;if(!c(a))throw new TypeError(n('1gr3F',a));if(i={mode:"grapheme"},o=arguments.length,o===2)r=e,e=null;else if(o===3)m(e)?r=t:(r=e,e=null,u=t);else{if(!m(e))throw new TypeError(n('1gr2V',e));r=t,u=arguments[3]}if(!f(r))throw new TypeError(n('1gr2b',r));if(e&&g(e,"mode")&&(i.mode=e.mode,!b(i.mode)))throw new TypeError(n('1grE1',"mode",s.join('", "'),i.mode));return p[i.mode](a,r,u),a}v.exports=y
3
+ });var C=l();module.exports=C;
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) 2023 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 isFunction = require( '@stdlib/assert-is-function' );\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isPlainObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar contains = require( '@stdlib/array-base-assert-contains' ).factory;\nvar forEachCodeUnit = require( '@stdlib/string-base-for-each' );\nvar forEachCodePoint = require( '@stdlib/string-base-for-each-code-point' );\nvar forEachGraphemeCluster = require( '@stdlib/string-base-for-each-grapheme-cluster' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar MODES = [ 'grapheme', 'code_point', 'code_unit' ];\nvar FCNS = {\n\t'grapheme': forEachGraphemeCluster,\n\t'code_point': forEachCodePoint,\n\t'code_unit': forEachCodeUnit\n};\nvar isMode = contains( MODES );\n\n\n// MAIN //\n\n/**\n* Invokes a function for each character in a string.\n*\n* @param {string} str - input string\n* @param {Options} [options] - options\n* @param {string} [options.mode=\"grapheme\"] - type of \"character\" over which to iterate (must be either `grapheme`, `code_point`, or `code_unit`)\n* @param {Function} clbk - function to invoke\n* @param {*} [thisArg] - execution context\n* @throws {TypeError} first argument must be a string\n* @throws {TypeError} callback argument must be a function\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {string} input string\n*\n* @example\n* function log( value, index ) {\n* console.log( '%d: %s', index, value );\n* }\n*\n* forEach( 'Hello', log );\n*/\nfunction forEach( str, options, clbk ) {\n\tvar thisArg;\n\tvar nargs;\n\tvar opts;\n\tvar cb;\n\tif ( !isString( str ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be a string. Value: `%s`.', str ) );\n\t}\n\topts = {\n\t\t'mode': 'grapheme'\n\t};\n\tnargs = arguments.length;\n\tif ( nargs === 2 ) {\n\t\tcb = options;\n\t\toptions = null;\n\t} else if ( nargs === 3 ) {\n\t\tif ( isPlainObject( options ) ) {\n\t\t\tcb = clbk;\n\t\t} else {\n\t\t\tcb = options;\n\t\t\toptions = null;\n\t\t\tthisArg = clbk;\n\t\t}\n\t} else { // nargs === 4\n\t\tif ( !isPlainObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\tcb = clbk;\n\t\tthisArg = arguments[ 3 ];\n\t}\n\tif ( !isFunction( cb ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );\n\t}\n\tif ( options ) {\n\t\tif ( hasOwnProp( options, 'mode' ) ) {\n\t\t\topts.mode = options.mode;\n\t\t\tif ( !isMode( opts.mode ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Value: `%s`.', 'mode', MODES.join( '\", \"' ), opts.mode ) );\n\t\t\t}\n\t\t}\n\t}\n\tFCNS[ opts.mode ]( str, cb, thisArg );\n\treturn str;\n}\n\n\n// EXPORTS //\n\nmodule.exports = forEach;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 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* Invoke a function for each character in a string.\n*\n* @module @stdlib/string-for-each\n*\n* @example\n* var forEach = require( '@stdlib/string-for-each' );\n*\n* function log( value, index ) {\n* console.log( '%d: %s', index, value );\n* }\n*\n* forEach( 'Hello', log );\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,EAAa,QAAS,4BAA6B,EACnDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAa,QAAS,iCAAkC,EACxDC,EAAW,QAAS,oCAAqC,EAAE,QAC3DC,EAAkB,QAAS,8BAA+B,EAC1DC,EAAmB,QAAS,yCAA0C,EACtEC,EAAyB,QAAS,+CAAgD,EAClFC,EAAS,QAAS,uBAAwB,EAK1CC,EAAQ,CAAE,WAAY,aAAc,WAAY,EAChDC,EAAO,CACV,SAAYH,EACZ,WAAcD,EACd,UAAaD,CACd,EACIM,EAASP,EAAUK,CAAM,EA0B7B,SAASG,EAASC,EAAKC,EAASC,EAAO,CACtC,IAAIC,EACAC,EACAC,EACAC,EACJ,GAAK,CAAClB,EAAUY,CAAI,EACnB,MAAM,IAAI,UAAWL,EAAQ,kEAAmEK,CAAI,CAAE,EAMvG,GAJAK,EAAO,CACN,KAAQ,UACT,EACAD,EAAQ,UAAU,OACbA,IAAU,EACdE,EAAKL,EACLA,EAAU,aACCG,IAAU,EAChBf,EAAeY,CAAQ,EAC3BK,EAAKJ,GAELI,EAAKL,EACLA,EAAU,KACVE,EAAUD,OAEL,CACN,GAAK,CAACb,EAAeY,CAAQ,EAC5B,MAAM,IAAI,UAAWN,EAAQ,qEAAsEM,CAAQ,CAAE,EAE9GK,EAAKJ,EACLC,EAAU,UAAW,CAAE,CACxB,CACA,GAAK,CAAChB,EAAYmB,CAAG,EACpB,MAAM,IAAI,UAAWX,EAAQ,uEAAwEW,CAAG,CAAE,EAE3G,GAAKL,GACCX,EAAYW,EAAS,MAAO,IAChCI,EAAK,KAAOJ,EAAQ,KACf,CAACH,EAAQO,EAAK,IAAK,GACvB,MAAM,IAAI,UAAWV,EAAQ,+EAAgF,OAAQC,EAAM,KAAM,MAAO,EAAGS,EAAK,IAAK,CAAE,EAI1J,OAAAR,EAAMQ,EAAK,IAAK,EAAGL,EAAKM,EAAIH,CAAQ,EAC7BH,CACR,CAKAd,EAAO,QAAUa,IC9EjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isFunction", "isString", "isPlainObject", "hasOwnProp", "contains", "forEachCodeUnit", "forEachCodePoint", "forEachGraphemeCluster", "format", "MODES", "FCNS", "isMode", "forEach", "str", "options", "clbk", "thisArg", "nargs", "opts", "cb", "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
  /**
22
22
  * Interface describing function options.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/string-for-each",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "description": "Invoke a function for each character in a string.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,19 +37,20 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/array-base-assert-contains": "^0.0.1",
41
- "@stdlib/assert-has-own-property": "^0.0.7",
42
- "@stdlib/assert-is-function": "^0.0.8",
43
- "@stdlib/assert-is-plain-object": "^0.0.7",
44
- "@stdlib/assert-is-string": "^0.0.8",
45
- "@stdlib/string-base-for-each": "^0.0.1",
46
- "@stdlib/string-base-for-each-code-point": "^0.0.1",
47
- "@stdlib/string-base-for-each-grapheme-cluster": "^0.0.1",
48
- "@stdlib/string-format": "^0.0.3"
40
+ "@stdlib/array-base-assert-contains": "^0.1.0",
41
+ "@stdlib/assert-has-own-property": "^0.1.0",
42
+ "@stdlib/assert-is-function": "^0.1.0",
43
+ "@stdlib/assert-is-plain-object": "^0.1.0",
44
+ "@stdlib/assert-is-string": "^0.1.0",
45
+ "@stdlib/string-base-for-each": "^0.1.0",
46
+ "@stdlib/string-base-for-each-code-point": "^0.1.0",
47
+ "@stdlib/string-base-for-each-grapheme-cluster": "^0.1.0",
48
+ "@stdlib/string-format": "^0.1.0",
49
+ "@stdlib/error-tools-fmtprodmsg": "^0.1.0"
49
50
  },
50
51
  "devDependencies": {
51
- "@stdlib/bench": "^0.0.12",
52
- "@stdlib/utils-noop": "^0.0.14",
52
+ "@stdlib/bench": "^0.1.0",
53
+ "@stdlib/utils-noop": "^0.1.0",
53
54
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
54
55
  "istanbul": "^0.4.1",
55
56
  "tap-min": "git+https://github.com/Planeshifter/tap-min.git"