Skip to content

Commit 1f2af74

Browse files
committed
feat: add symbol/is-concat-spreadable
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent aad9fb9 commit 1f2af74

File tree

9 files changed

+441
-0
lines changed

9 files changed

+441
-0
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 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+
# Concat Spreadable Symbol
22+
23+
> Concat spreadable [symbol][mdn-symbol] which specifies whether an array-like object should be flattened to its array elements during concatenation.
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 IsConcatSpreadableSymbol = require( '@stdlib/symbol/is-concat-spreadable' );
41+
```
42+
43+
#### IsConcatSpreadableSymbol
44+
45+
Concat spreadable [`symbol`][mdn-symbol] which specifies whether an array-like object should be flattened to its array elements during concatenation.
46+
47+
```javascript
48+
var s = typeof IsConcatSpreadableSymbol;
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+
## Notes
61+
62+
- The [symbol][mdn-symbol] is only supported in environments which support [symbols][mdn-symbol]. In non-supporting environments, the value is `null`.
63+
64+
</section>
65+
66+
<!-- /.notes -->
67+
68+
<!-- Package usage examples. -->
69+
70+
<section class="examples">
71+
72+
## Examples
73+
74+
<!-- eslint no-undef: "error" -->
75+
76+
```javascript
77+
var IsConcatSpreadableSymbol = require( '@stdlib/symbol/is-concat-spreadable' );
78+
79+
var x = [ 1, 2, 3 ];
80+
var y = {
81+
'length': 3,
82+
'0': 4,
83+
'1': 5,
84+
'2': 6
85+
};
86+
87+
y[ IsConcatSpreadableSymbol ] = true;
88+
console.log( x.concat( y ) );
89+
90+
y[ IsConcatSpreadableSymbol ] = false;
91+
console.log( x.concat( y ) );
92+
```
93+
94+
</section>
95+
96+
<!-- /.examples -->
97+
98+
<!-- 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. -->
99+
100+
<section class="references">
101+
102+
</section>
103+
104+
<!-- /.references -->
105+
106+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
107+
108+
<section class="related">
109+
110+
</section>
111+
112+
<!-- /.related -->
113+
114+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
115+
116+
<section class="links">
117+
118+
[mdn-symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
119+
120+
</section>
121+
122+
<!-- /.links -->
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
{{alias}}
3+
Concat spreadable symbol.
4+
5+
This symbol specifies whether an array-like object should be flattened to
6+
its elements during concatenation.
7+
8+
The symbol is only supported in ES6/ES2015+ environments. For non-supporting
9+
environments, the value is `null`.
10+
11+
Examples
12+
--------
13+
> var s = {{alias}}
14+
e.g., <symbol>
15+
16+
See Also
17+
--------
18+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
// TypeScript Version: 4.1
20+
21+
// EXPORTS //
22+
23+
/**
24+
* Concat spreadable symbol.
25+
*
26+
* ## Notes
27+
*
28+
* - This symbol specifies whether an array-like object should be flattened to its array elements during concatenation.
29+
* - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`.
30+
*/
31+
export = Symbol.isConcatSpreadable;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
/* eslint-disable @typescript-eslint/no-unused-expressions */
20+
21+
import IsConcatSpreadable = require( './index' );
22+
23+
24+
// TESTS //
25+
26+
// The exported value is the `isConcatSpreadable` symbol...
27+
{
28+
IsConcatSpreadable;
29+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
'use strict';
20+
21+
var IsConcatSpreadableSymbol = require( './../lib' );
22+
23+
var x = [ 1, 2, 3 ];
24+
var y = {
25+
'length': 3,
26+
'0': 4,
27+
'1': 5,
28+
'2': 6
29+
};
30+
31+
y[ IsConcatSpreadableSymbol ] = true;
32+
console.log( x.concat( y ) );
33+
34+
y[ IsConcatSpreadableSymbol ] = false;
35+
console.log( x.concat( y ) );
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
'use strict';
20+
21+
/**
22+
* Concat spreadable symbol.
23+
*
24+
* @module @stdlib/symbol/is-concat-spreadable
25+
*
26+
* @example
27+
* var IsConcatSpreadableSymbol = require( '@stdlib/symbol/is-concat-spreadable' );
28+
*
29+
* var x = {
30+
* 'length': 3,
31+
* '0': 1,
32+
* '1': 2,
33+
* '2': 3
34+
* };
35+
*
36+
* x[ IsConcatSpreadableSymbol ] = true;
37+
*/
38+
39+
// MAIN //
40+
41+
var main = require( './main.js' );
42+
43+
44+
// EXPORTS //
45+
46+
module.exports = main;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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+
'use strict';
20+
21+
// MODULES //
22+
23+
var hasIsConcatSpreadableSymbolSupport = require( '@stdlib/assert/has-is-concat-spreadable-symbol-support' ); // eslint-disable-line id-length
24+
25+
26+
// MAIN //
27+
28+
/**
29+
* Concat spreadable symbol.
30+
*
31+
* @name IsConcatSpreadableSymbol
32+
* @constant
33+
* @type {(symbol|null)}
34+
*
35+
* @example
36+
* var x = {
37+
* 'length': 3,
38+
* '0': 1,
39+
* '1': 2,
40+
* '2': 3
41+
* };
42+
*
43+
* x[ IsConcatSpreadableSymbol ] = true;
44+
*/
45+
var IsConcatSpreadableSymbol = ( hasIsConcatSpreadableSymbolSupport() ) ? Symbol.isConcatSpreadable : null; // eslint-disable-line max-len
46+
47+
48+
// EXPORTS //
49+
50+
module.exports = IsConcatSpreadableSymbol;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "@stdlib/symbol/is-concat-spreadable",
3+
"version": "0.0.0",
4+
"description": "Concat spreadable symbol.",
5+
"license": "Apache-2.0",
6+
"author": {
7+
"name": "The Stdlib Authors",
8+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9+
},
10+
"contributors": [
11+
{
12+
"name": "The Stdlib Authors",
13+
"url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14+
}
15+
],
16+
"main": "./lib",
17+
"directories": {
18+
"doc": "./docs",
19+
"example": "./examples",
20+
"lib": "./lib",
21+
"test": "./test"
22+
},
23+
"types": "./docs/types",
24+
"scripts": {},
25+
"homepage": "https://github.com/stdlib-js/stdlib",
26+
"repository": {
27+
"type": "git",
28+
"url": "git://github.com/stdlib-js/stdlib.git"
29+
},
30+
"bugs": {
31+
"url": "https://github.com/stdlib-js/stdlib/issues"
32+
},
33+
"dependencies": {},
34+
"devDependencies": {},
35+
"engines": {
36+
"node": ">=0.10.0",
37+
"npm": ">2.7.0"
38+
},
39+
"os": [
40+
"aix",
41+
"darwin",
42+
"freebsd",
43+
"linux",
44+
"macos",
45+
"openbsd",
46+
"sunos",
47+
"win32",
48+
"windows"
49+
],
50+
"keywords": [
51+
"stdlib",
52+
"symbol",
53+
"sym",
54+
"concat",
55+
"array",
56+
"concatenation"
57+
]
58+
}

0 commit comments

Comments
 (0)