Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/node_modules/@stdlib/symbol/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ setReadOnly( ns, 'IteratorSymbol', require( '@stdlib/symbol/iterator' ) );
*/
setReadOnly( ns, 'ReplaceSymbol', require( '@stdlib/symbol/replace' ) );

/**
* @name SplitSymbol
* @memberof ns
* @readonly
* @type {(symbol|null)}
* @see {@link module:@stdlib/symbol/split}
*/
setReadOnly( ns, 'SplitSymbol', require( '@stdlib/symbol/split' ) );

/**
* @name ToPrimitiveSymbol
* @memberof ns
Expand Down
130 changes: 130 additions & 0 deletions lib/node_modules/@stdlib/symbol/split/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<!--

@license Apache-2.0

Copyright (c) 2025 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# SplitSymbol

> [Symbol][mdn-symbol] which specifies a method that splits a string at the indices that match a regular expression.

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var SplitSymbol = require( '@stdlib/symbol/split' );
```

#### SplitSymbol

[`symbol`][mdn-symbol] which specifies a method that splits a string at the indices that match a regular expression.

```javascript
var s = typeof SplitSymbol;
// e.g., returns 'symbol'
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

## Notes

- The [symbol][mdn-symbol] is only supported in environments which support [symbols][mdn-symbol]. In non-supporting environments, the value is `null`.
- When calling `String.prototype.split` and the `separator` argument is an object with a `[SplitSymbol]()` method, this method is called with the target string and limit as arguments.

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var defineProperty = require( '@stdlib/utils/define-property' );
var SplitSymbol = require( '@stdlib/symbol/split' );

function splitter( str ) {
return str.split( '-' );
}

var obj = {};

defineProperty( obj, SplitSymbol, {
'configurable': true,
'value': null
});

var str = 'a-b-c-d-e';
console.log( str.split( obj ) );

defineProperty( obj, SplitSymbol, {
'configurable': true,
'value': splitter
});
console.log( str.split( obj ) );
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

[mdn-symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol

</section>

<!-- /.links -->
18 changes: 18 additions & 0 deletions lib/node_modules/@stdlib/symbol/split/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

{{alias}}
Split symbol.

This symbol specifies a method that splits a string at the indices that
match a regular expression.

The symbol is only supported in ES6/ES2015+ environments. For non-supporting
environments, the value is `null`.

Examples
--------
> var s = {{alias}}
e.g., <symbol>

See Also
--------

31 changes: 31 additions & 0 deletions lib/node_modules/@stdlib/symbol/split/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 4.1

// EXPORTS //

/**
* Split symbol.
*
* ## Notes
*
* - This symbol specifies a method that splits a string at the indices that match a regular expression.
* - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`.
*/
export = Symbol.split;
29 changes: 29 additions & 0 deletions lib/node_modules/@stdlib/symbol/split/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/* eslint-disable @typescript-eslint/no-unused-expressions */

import Split = require( './index' );


// TESTS //

// The exported value is the `split` symbol...
{
Split;
}
42 changes: 42 additions & 0 deletions lib/node_modules/@stdlib/symbol/split/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var defineProperty = require( '@stdlib/utils/define-property' );
var SplitSymbol = require( './../lib' );

function splitter( str ) {
return str.split( '-' );
}

var obj = {};

defineProperty( obj, SplitSymbol, {
'configurable': true,
'value': null
});

var str = 'a-b-c-d-e';
console.log( str.split( obj ) );

defineProperty( obj, SplitSymbol, {
'configurable': true,
'value': splitter
});
console.log( str.split( obj ) );
44 changes: 44 additions & 0 deletions lib/node_modules/@stdlib/symbol/split/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

/**
* Symbol which specifies a method that splits a string at the indices that match a regular expression.
*
* @module @stdlib/symbol/split
*
* @example
* var SplitSymbol = require( '@stdlib/symbol/split' );
*
* function splitter( str, limit ) {
* return str.split( '-', limit );
* }
*
* var obj = {};
* obj[ SplitSymbol ] = splitter;
*/

// MAIN //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
48 changes: 48 additions & 0 deletions lib/node_modules/@stdlib/symbol/split/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2025 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var hasSplitSymbolSupport = require( '@stdlib/assert/has-split-symbol-support' );


// MAIN //

/**
* Split symbol.
*
* @name SplitSymbol
* @constant
* @type {(symbol|null)}
*
* @example
* function splitter( str, limit ) {
* return str.split( '-', limit );
* }
*
* var obj = {};
* obj[ SplitSymbol ] = splitter;
*/
var SplitSymbol = ( hasSplitSymbolSupport() ) ? Symbol.split : null;


// EXPORTS //

module.exports = SplitSymbol;
Loading