|
| 1 | +<!-- |
| 2 | +
|
| 3 | +@license Apache-2.0 |
| 4 | +
|
| 5 | +Copyright (c) 2026 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 | +# SplitSymbol |
| 22 | + |
| 23 | +> Split [symbol][mdn-symbol] which is used to define a custom string splitting behavior. |
| 24 | +
|
| 25 | +<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> |
| 26 | + |
| 27 | +<section class="intro"> |
| 28 | + |
| 29 | +</section> |
| 30 | + |
| 31 | +<!-- /.intro --> |
| 32 | + |
| 33 | +<!-- Package usage documentation. --> |
| 34 | + |
| 35 | +<section class="usage"> |
| 36 | + |
| 37 | +## Usage |
| 38 | + |
| 39 | +```javascript |
| 40 | +var SplitSymbol = require( '@stdlib/symbol/split' ); |
| 41 | +``` |
| 42 | + |
| 43 | +#### SplitSymbol |
| 44 | + |
| 45 | +Split [`symbol`][mdn-symbol] which is used to define a custom string splitting behavior. |
| 46 | + |
| 47 | +```javascript |
| 48 | +var s = typeof SplitSymbol; |
| 49 | +// e.g., returns 'symbol' |
| 50 | +``` |
| 51 | + |
| 52 | +</section> |
| 53 | + |
| 54 | +<!-- /.usage --> |
| 55 | + |
| 56 | +<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 57 | + |
| 58 | +<section class="notes"> |
| 59 | + |
| 60 | +</section> |
| 61 | + |
| 62 | +<!-- /.notes --> |
| 63 | + |
| 64 | +<!-- Package usage examples. --> |
| 65 | + |
| 66 | +<section class="examples"> |
| 67 | + |
| 68 | +## Examples |
| 69 | + |
| 70 | +<!-- eslint no-undef: "error" --> |
| 71 | + |
| 72 | +```javascript |
| 73 | +var SplitSymbol = require( '@stdlib/symbol/split' ); |
| 74 | + |
| 75 | +var str; |
| 76 | +var obj; |
| 77 | +var parts; |
| 78 | + |
| 79 | +function splitHandler() { |
| 80 | + return [ 'beep', 'boop' ]; |
| 81 | +} |
| 82 | + |
| 83 | +if ( SplitSymbol ) { |
| 84 | + str = 'beep-boop'; |
| 85 | + obj = {}; |
| 86 | + obj[ SplitSymbol ] = splitHandler; |
| 87 | + parts = str.split( obj ); |
| 88 | + console.log( parts ); |
| 89 | + // => [ 'beep', 'boop' ] |
| 90 | +} |
| 91 | +``` |
| 92 | + |
| 93 | +</section> |
| 94 | + |
| 95 | +<!-- /.examples --> |
| 96 | + |
| 97 | +<!-- Section to include cited references. If references are cited in the above section, this section should be included. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 98 | + |
| 99 | +<section class="references"> |
| 100 | + |
| 101 | +</section> |
| 102 | + |
| 103 | +<!-- /.references --> |
| 104 | + |
| 105 | +<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated based on metadata in the package.json file. --> |
| 106 | + |
| 107 | +<section class="related"> |
| 108 | + |
| 109 | +</section> |
| 110 | + |
| 111 | +<!-- /.related --> |
| 112 | + |
| 113 | +<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> |
| 114 | + |
| 115 | +<section class="links"> |
| 116 | + |
| 117 | +[mdn-symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol |
| 118 | + |
| 119 | +</section> |
| 120 | + |
| 121 | +<!-- /.links --> |
0 commit comments