-
-
Notifications
You must be signed in to change notification settings - Fork 968
feat: add symbol/split
#8498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: add symbol/split
#8498
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <!- | ||
| @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. | ||
| --> | ||
|
|
||
| # Symbol.split | ||
|
|
||
| > The well-known symbol `Symbol.split`. | ||
| <section class="usage"> | ||
|
|
||
| ## Usage | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file does not currently match project conventions. |
||
|
|
||
| ```javascript | ||
| var hasSplitSupport = require( '@stdlib/assert/has-symbol-support' )(); | ||
| var split = require( '@stdlib/symbol/split' ); | ||
|
|
||
| var bool = ( typeof split === 'symbol' ); | ||
| // returns <boolean> | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.usage --> | ||
|
|
||
| <section class="examples"> | ||
|
|
||
| ## Examples | ||
|
|
||
| <!-- eslint no-undef: "error" --> | ||
|
|
||
| ```javascript | ||
| var hasSplitSupport = require( '@stdlib/assert/has-symbol-support' )(); | ||
| var split = require( '@stdlib/symbol/split' ); | ||
|
|
||
| if ( hasSplitSupport ) { | ||
| console.log( split === Symbol.split ); | ||
| // => true | ||
| } else { | ||
| console.log( '@stdlib/symbol/split' ); | ||
| } | ||
| ``` | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.examples --> | ||
|
|
||
| <!-- 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"> | ||
|
|
||
| </section> | ||
|
|
||
| <!-- /.links --> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * @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'; | ||
|
|
||
| // MAIN // | ||
|
|
||
| /** | ||
|
Check failure on line 23 in lib/node_modules/@stdlib/symbol/split/lib/browser.js
|
||
| * The well-known symbol `@@split`. | ||
| * | ||
| * @constant | ||
| * @name SPLIT | ||
| * @type {symbol} | ||
| * @see [MDN]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split} | ||
| * @default Symbol.split | ||
| */ | ||
| var SPLIT = ( typeof Symbol === 'function' && typeof Symbol.split === 'symbol' ) ? Symbol.split : '@@split'; // eslint-disable-line no-undef | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see other packages exposing symbols. This is not how we implement them. |
||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = SPLIT; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * @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'; | ||
|
|
||
| // MAIN // | ||
|
|
||
| /** | ||
| * The well-known symbol `@@split`. | ||
| * | ||
| * @constant | ||
| * @name SPLIT | ||
| * @type {symbol} | ||
| * @see [MDN]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/split} | ||
| * @default Symbol.split | ||
| */ | ||
| var SPLIT = ( typeof Symbol === 'function' && typeof Symbol.split === 'symbol' ) ? Symbol.split : '@@split'; // eslint-disable-line no-undef | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment. |
||
|
|
||
|
|
||
| // EXPORTS // | ||
|
|
||
| module.exports = SPLIT; | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,79 @@ | ||||
| { | ||||
| "name": "@stdlib/symbol/split", | ||||
| "version": "0.0.0", | ||||
| "description": "The well-known symbol `Symbol.split`. ", | ||||
| "license": "Apache-2.0", | ||||
| "author": { | ||||
| "name": "The Stdlib Authors", | ||||
| "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" | ||||
| }, | ||||
| "contributors": [ | ||||
| { | ||||
| "name": "The Stdlib Authors", | ||||
| "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" | ||||
| } | ||||
| ], | ||||
| "main": "./lib", | ||||
| "directories": { | ||||
| "doc": "./docs", | ||||
| "example": "./examples", | ||||
| "lib": "./lib", | ||||
| "test": "./test" | ||||
| }, | ||||
| "scripts": { | ||||
| "test": "make test", | ||||
| "test-cov": "make test-cov", | ||||
| "examples": "make examples" | ||||
|
Comment on lines
+24
to
+26
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should not be here. It is not clear why you added these. |
||||
| }, | ||||
| "homepage": "https://github.com/stdlib-js/stdlib", | ||||
| "repository": { | ||||
| "type": "git", | ||||
| "url": "git://github.com/stdlib-js/stdlib.git" | ||||
| }, | ||||
| "bugs": { | ||||
| "url": "https://github.com/stdlib-js/stdlib/issues" | ||||
| }, | ||||
| "dependencies": {}, | ||||
| "devDependencies": { | ||||
| "@stdlib/assert/has-symbol-support": "^0.0.0" | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed. |
||||
| }, | ||||
| "engines": { | ||||
| "node": ">=0.10.0", | ||||
| "npm": ">2.7.0" | ||||
| }, | ||||
| "os": [ | ||||
| "aix", | ||||
| "darwin", | ||||
| "freebsd", | ||||
| "linux", | ||||
| "macos", | ||||
| "openbsd", | ||||
| "posix", | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Why was this added? This isn't an OS. |
||||
| "sunos", | ||||
| "win32", | ||||
| "windows" | ||||
| ], | ||||
| "keywords": [ | ||||
| "stdlib", | ||||
| "stdtypes", | ||||
| "types", | ||||
| "utils", | ||||
| "util", | ||||
| "utilities", | ||||
| "utility", | ||||
| "es6", | ||||
| "es2015", | ||||
| "ecmascript", | ||||
| "symbol", | ||||
| "symbols", | ||||
| "split", | ||||
| "regexp", | ||||
| "regex", | ||||
| "regexp.split", | ||||
| "string.split" | ||||
| ], | ||||
| "__stdlib__": {}, | ||||
| "browser": { | ||||
| "./lib/main.js": "./lib/browser.js" | ||||
| } | ||||
| } | ||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /** | ||
| * @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 tape = require( 'tape' ); | ||
| var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' )(); | ||
| var SPLIT = require( './../lib' ); | ||
|
|
||
|
|
||
| // TESTS // | ||
|
|
||
| tape( 'main export is a symbol or string', function test( t ) { | ||
| t.ok( typeof SPLIT === 'symbol' || typeof SPLIT === 'string', 'main export is a symbol or string' ); | ||
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'if environment has `Symbol` support, the export is a symbol', function test( t ) { | ||
| if ( hasSymbolSupport ) { | ||
| t.equal( typeof SPLIT, 'symbol', 'is a symbol' ); | ||
| } | ||
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'if environment does not have `Symbol` support, the export is a string', function test( t ) { | ||
| if ( !hasSymbolSupport ) { | ||
| t.equal( typeof SPLIT, 'string', 'is a string' ); | ||
| } | ||
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the export equals `Symbol.split` if environment has `Symbol` support', function test( t ) { | ||
| if ( hasSymbolSupport ) { | ||
| t.equal( SPLIT, Symbol.split, 'equals Symbol.split' ); | ||
| } | ||
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the export equals `'@@split'` if environment does not have `Symbol` support', function test( t ) { | ||
| if ( !hasSymbolSupport ) { | ||
| t.equal( SPLIT, '@@split', 'equals @@split' ); | ||
| } | ||
| t.end(); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not desired.