@ohos-ports/stdlib-symbol 0.0.0-stage → 0.4.1-beta.1
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/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +205 -2
- package/SECURITY.md +5 -0
- package/async-iterator/README.md +129 -0
- package/async-iterator/docs/repl.txt +16 -0
- package/async-iterator/docs/types/index.d.ts +31 -0
- package/async-iterator/docs/types/test.ts +29 -0
- package/async-iterator/lib/index.js +43 -0
- package/async-iterator/lib/main.js +48 -0
- package/async-iterator/package.json +61 -0
- package/ctor/README.md +143 -0
- package/ctor/docs/repl.txt +27 -0
- package/ctor/docs/types/index.d.ts +34 -0
- package/ctor/docs/types/test.ts +34 -0
- package/ctor/lib/index.js +40 -0
- package/ctor/lib/main.js +28 -0
- package/ctor/package.json +60 -0
- package/docs/types/index.d.ts +116 -0
- package/has-instance/README.md +143 -0
- package/has-instance/docs/repl.txt +18 -0
- package/has-instance/docs/types/index.d.ts +31 -0
- package/has-instance/docs/types/test.ts +29 -0
- package/has-instance/lib/index.js +49 -0
- package/has-instance/lib/main.js +54 -0
- package/has-instance/package.json +57 -0
- package/is-concat-spreadable/README.md +122 -0
- package/is-concat-spreadable/docs/repl.txt +18 -0
- package/is-concat-spreadable/docs/types/index.d.ts +31 -0
- package/is-concat-spreadable/docs/types/test.ts +29 -0
- package/is-concat-spreadable/lib/index.js +46 -0
- package/is-concat-spreadable/lib/main.js +50 -0
- package/is-concat-spreadable/package.json +58 -0
- package/iterator/README.md +164 -0
- package/iterator/docs/repl.txt +16 -0
- package/iterator/docs/types/index.d.ts +31 -0
- package/iterator/docs/types/test.ts +29 -0
- package/iterator/lib/index.js +75 -0
- package/iterator/lib/main.js +79 -0
- package/iterator/package.json +58 -0
- package/lib/index.js +105 -0
- package/package.json +58 -4
- package/replace/README.md +130 -0
- package/replace/docs/repl.txt +18 -0
- package/replace/docs/types/index.d.ts +31 -0
- package/replace/docs/types/test.ts +29 -0
- package/replace/lib/index.js +44 -0
- package/replace/lib/main.js +48 -0
- package/replace/package.json +58 -0
- package/to-primitive/README.md +158 -0
- package/to-primitive/docs/repl.txt +16 -0
- package/to-primitive/docs/types/index.d.ts +30 -0
- package/to-primitive/docs/types/test.ts +29 -0
- package/to-primitive/lib/index.js +57 -0
- package/to-primitive/lib/main.js +63 -0
- package/to-primitive/package.json +61 -0
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
# HasInstanceSymbol
|
|
22
|
+
|
|
23
|
+
> Has instance [symbol][mdn-symbol] which is used to determine if a constructor object recognizes an object as its instance.
|
|
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 HasInstanceSymbol = require( '@stdlib/symbol/has-instance' );
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### HasInstanceSymbol
|
|
44
|
+
|
|
45
|
+
Has instance [`symbol`][mdn-symbol] which is used to determine if a constructor object recognizes an object as its instance.
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
var s = typeof HasInstanceSymbol;
|
|
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
|
+
- The `instanceof` operator uses the following algorithm to determine the return value of `object instanceof constructor`:
|
|
65
|
+
|
|
66
|
+
- If `constructor` has a `[HasInstanceSymbol]()` method, the `instanceof` operator calls the method with `object` as the first argument and returns the result (coerced to a boolean). If `constructor` is not an object or if `constructor[HasInstanceSymbol]` is neither `null`, `undefined`, nor a function, the `instanceof` operator raises an exception.
|
|
67
|
+
- Otherwise, if `constructor` does not have a `[HasInstanceSymbol]()` method (i.e., `constructor[HasInstanceSymbol]` is `null` or `undefined`), the `instanceof` operator determines the result using the same algorithm as `Function.prototype[HasInstanceSymbol]()`. If `constructor` is not a function, the `instanceof` operator raises an exception.
|
|
68
|
+
|
|
69
|
+
</section>
|
|
70
|
+
|
|
71
|
+
<!-- /.notes -->
|
|
72
|
+
|
|
73
|
+
<!-- Package usage examples. -->
|
|
74
|
+
|
|
75
|
+
<section class="examples">
|
|
76
|
+
|
|
77
|
+
## Examples
|
|
78
|
+
|
|
79
|
+
<!-- eslint no-undef: "error" -->
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
var isArray = require( '@stdlib/assert/is-array' );
|
|
83
|
+
var instanceOf = require( '@stdlib/assert/instance-of' );
|
|
84
|
+
var defineProperty = require( '@stdlib/utils/define-property' );
|
|
85
|
+
var HasInstanceSymbol = require( '@stdlib/symbol/has-instance' );
|
|
86
|
+
|
|
87
|
+
function ArrayLike() {
|
|
88
|
+
return {
|
|
89
|
+
'length': 3,
|
|
90
|
+
'0': 4,
|
|
91
|
+
'1': 5,
|
|
92
|
+
'2': 6
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function hasInstance( instance ) {
|
|
97
|
+
return isArray( instance );
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
var x = [ 1, 2, 3 ];
|
|
101
|
+
|
|
102
|
+
defineProperty( ArrayLike, HasInstanceSymbol, {
|
|
103
|
+
'configurable': true,
|
|
104
|
+
'value': null
|
|
105
|
+
});
|
|
106
|
+
console.log( instanceOf( x, ArrayLike ) );
|
|
107
|
+
|
|
108
|
+
defineProperty( ArrayLike, HasInstanceSymbol, {
|
|
109
|
+
'configurable': true,
|
|
110
|
+
'value': hasInstance
|
|
111
|
+
});
|
|
112
|
+
console.log( instanceOf( x, ArrayLike ) );
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
</section>
|
|
116
|
+
|
|
117
|
+
<!-- /.examples -->
|
|
118
|
+
|
|
119
|
+
<!-- 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. -->
|
|
120
|
+
|
|
121
|
+
<section class="references">
|
|
122
|
+
|
|
123
|
+
</section>
|
|
124
|
+
|
|
125
|
+
<!-- /.references -->
|
|
126
|
+
|
|
127
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
128
|
+
|
|
129
|
+
<section class="related">
|
|
130
|
+
|
|
131
|
+
</section>
|
|
132
|
+
|
|
133
|
+
<!-- /.related -->
|
|
134
|
+
|
|
135
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
136
|
+
|
|
137
|
+
<section class="links">
|
|
138
|
+
|
|
139
|
+
[mdn-symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol
|
|
140
|
+
|
|
141
|
+
</section>
|
|
142
|
+
|
|
143
|
+
<!-- /.links -->
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
{{alias}}
|
|
3
|
+
Has instance symbol.
|
|
4
|
+
|
|
5
|
+
This symbol is used to determine whether a constructor object recognizes an
|
|
6
|
+
object as its instance.
|
|
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
|
+
|
|
@@ -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
|
+
* Has instance symbol.
|
|
25
|
+
*
|
|
26
|
+
* ## Notes
|
|
27
|
+
*
|
|
28
|
+
* - This symbol is used to determine whether a constructor object recognizes an object as its instance.
|
|
29
|
+
* - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`.
|
|
30
|
+
*/
|
|
31
|
+
export = Symbol.hasInstance;
|
|
@@ -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 HasInstance = require( './index' );
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// TESTS //
|
|
25
|
+
|
|
26
|
+
// The exported value is the `hasInstance` symbol...
|
|
27
|
+
{
|
|
28
|
+
HasInstance;
|
|
29
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
* Symbol used to determine if a constructor object recognizes an object as its instance.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/symbol/has-instance
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var isArray = require( '@ohos-ports/stdlib-assert/is-array' );
|
|
28
|
+
* var HasInstanceSymbol = require( '@ohos-ports/stdlib-symbol/has-instance' );
|
|
29
|
+
*
|
|
30
|
+
* function ArrayLike() {
|
|
31
|
+
* return {
|
|
32
|
+
* 'length': 3,
|
|
33
|
+
* '0': 1,
|
|
34
|
+
* '1': 2,
|
|
35
|
+
* '2': 3
|
|
36
|
+
* };
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* ArrayLike[ HasInstanceSymbol ] = isArray;
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
// MAIN //
|
|
43
|
+
|
|
44
|
+
var main = require( './main.js' );
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// EXPORTS //
|
|
48
|
+
|
|
49
|
+
module.exports = main;
|
|
@@ -0,0 +1,54 @@
|
|
|
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 hasHasInstanceSymbolSupport = require( '@ohos-ports/stdlib-assert/has-has-instance-symbol-support' ); // eslint-disable-line id-length
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// MAIN //
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Has instance symbol.
|
|
30
|
+
*
|
|
31
|
+
* @name HasInstanceSymbol
|
|
32
|
+
* @constant
|
|
33
|
+
* @type {(symbol|null)}
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* var isArray = require( '@ohos-ports/stdlib-assert/is-array' );
|
|
37
|
+
*
|
|
38
|
+
* function ArrayLike() {
|
|
39
|
+
* return {
|
|
40
|
+
* 'length': 3,
|
|
41
|
+
* '0': 1,
|
|
42
|
+
* '1': 2,
|
|
43
|
+
* '2': 3
|
|
44
|
+
* };
|
|
45
|
+
* };
|
|
46
|
+
*
|
|
47
|
+
* ArrayLike[ HasInstanceSymbol ] = isArray;
|
|
48
|
+
*/
|
|
49
|
+
var HasInstanceSymbol = ( hasHasInstanceSymbolSupport() ) ? Symbol.hasInstance : null; // eslint-disable-line max-len
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// EXPORTS //
|
|
53
|
+
|
|
54
|
+
module.exports = HasInstanceSymbol;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/symbol/has-instance",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Has instance 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
|
+
"instance",
|
|
55
|
+
"instanceof"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
@@ -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
|
+
# IsConcatSpreadableSymbol
|
|
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 -->
|
|
@@ -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
|
+
|
|
@@ -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;
|
|
@@ -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
|
+
}
|
|
@@ -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( '@ohos-ports/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;
|
|
@@ -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( '@ohos-ports/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;
|