time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2831B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2022 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # formatTokenize
     22 
     23 > Tokenize a string into an array of string parts and format identifier objects.
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var formatTokenize = require( '@stdlib/string/base/format-tokenize' );
     37 ```
     38 
     39 #### formatTokenize( str )
     40 
     41 Tokenizes a string into an array of string parts and format identifier objects.
     42 
     43 ```javascript
     44 var str = 'Hello, %s! My name is %s.';
     45 var out = formatTokenize( str );
     46 // returns [ 'Hello, ', {...}, '! My name is ', {...}, '.' ]
     47 ``` 
     48 
     49 The format identifier objects have the following properties:
     50 
     51 | property  | description                                                                                         |
     52 | --------- | --------------------------------------------------------------------------------------------------- |
     53 | specifier | format specifier (one of 's', 'c', 'd', 'i', 'u', 'b', 'o', 'x', 'X', 'e', 'E', 'f', 'F', 'g', 'G') |
     54 | flags     | format flags (string with any of '0', ' ', '+', '-', '#')                                           |
     55 | width     | minimum field width (integer or `'*'`)                                                              |
     56 | precision | precision (integer or `'*'`)                                                                        |
     57 | mapping   | positional mapping from format specifier to argument index                                          |
     58 
     59 </section>
     60 
     61 <!-- /.usage -->
     62 
     63 <section class="examples">
     64 
     65 ## Examples
     66 
     67 <!-- eslint no-undef: "error" -->
     68 
     69 ```javascript
     70 var formatTokenize = require( '@stdlib/string/base/format-tokenize' );
     71 
     72 var out = formatTokenize( 'Hello %s!' );
     73 // returns [ 'Hello ', {...}, '!' ]
     74 
     75 out = formatTokenize( 'Pi: ~%.2f' );
     76 // returns [ 'Pi: ~', {...} ]
     77 
     78 out = formatTokenize( 'Multiple flags: %#+s' );
     79 // returns [ 'Foo ', {...} ]
     80 ```
     81 
     82 </section>
     83 
     84 <!-- /.examples -->
     85 
     86 <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
     87 
     88 <section class="related">
     89 
     90 </section>
     91 
     92 <!-- /.related -->
     93 
     94 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     95 
     96 <section class="links">
     97 
     98 </section>
     99 
    100 <!-- /.links -->