From d8003de703b5bc69997da0950a1040445b762943 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Wed, 26 Feb 2025 06:49:27 +0000
Subject: [PATCH 1/5] feat: add string/base/slice-grapheme-clusters
---
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: passed
- 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
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
---
.../base/slice-grapheme-clusters/README.md | 128 +++++++++++++++
.../benchmark/benchmark.js | 57 +++++++
.../slice-grapheme-clusters/docs/repl.txt | 34 ++++
.../docs/types/index.d.ts | 47 ++++++
.../docs/types/test.ts | 72 +++++++++
.../slice-grapheme-clusters/examples/index.js | 36 +++++
.../base/slice-grapheme-clusters/lib/index.js | 49 ++++++
.../base/slice-grapheme-clusters/lib/main.js | 114 ++++++++++++++
.../base/slice-grapheme-clusters/package.json | 67 ++++++++
.../base/slice-grapheme-clusters/test/test.js | 149 ++++++++++++++++++
10 files changed, 753 insertions(+)
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/benchmark/benchmark.js
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/examples/index.js
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/index.js
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/package.json
create mode 100644 lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md
new file mode 100644
index 000000000000..40d388d53320
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md
@@ -0,0 +1,128 @@
+
+
+# sliceGraphemeClusters
+
+> Slice a string based on grapheme cluster (i.e., user-perceived character) indices.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var sliceGraphemeClusters = require( '@stdlib/string/base/slice-grapheme-clusters' );
+```
+
+#### sliceGraphemeClusters( str, start, end )
+
+Slices a string based on grapheme cluster (i.e., user-perceived character) indices.
+
+```javascript
+var out = sliceGraphemeClusters( 'Hello World', 0, 5 );
+// returns 'Hello'
+
+out = sliceGraphemeClusters( '๐๐๐', 0, 2 );
+// returns '๐๐'
+
+out = sliceGraphemeClusters( 'ๅ
ญไนฆ/ๅ
ญๆธ', 1, 5 );
+// returns 'ไนฆ/ๅ
ญๆธ'
+
+out = sliceGraphemeClusters( '๐ท๐๐๐ฟ', 1, 2 );
+// returns '๐'
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+## Examples
+
+```javascript
+var sliceGraphemeClusters = require( '@stdlib/string/base/slice-grapheme-clusters' );
+
+console.log( sliceGraphemeClusters( 'Hello World', 0, 5 ) );
+// => 'Hello'
+
+console.log( sliceGraphemeClusters( 'Hello World', -5, -1 ) );
+// => 'Worl'
+
+console.log( sliceGraphemeClusters( '๐๐๐', 0, 2 ) );
+// => '๐๐'
+
+console.log( sliceGraphemeClusters( 'ๅ
ญไนฆ/ๅ
ญๆธ', 1, 5 ) );
+// => 'ไนฆ/ๅ
ญๆธ'
+
+console.log( sliceGraphemeClusters( '๐จโ๐ฉโ๐งโ๐ฆ๐จโ๐ฉโ๐งโ๐ฆ๐จโ๐ฉโ๐งโ๐ฆ', 0, 2 ) );
+// => '๐จโ๐ฉโ๐งโ๐ฆ๐จโ๐ฉโ๐งโ๐ฆ'
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/benchmark/benchmark.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/benchmark/benchmark.js
new file mode 100644
index 000000000000..9e9c7cec8419
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/benchmark/benchmark.js
@@ -0,0 +1,57 @@
+/**
+* @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 bench = require( '@stdlib/bench' );
+var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
+var pkg = require( './../package.json' ).name;
+var sliceGraphemeClusters = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg, function benchmark( b ) {
+ var values;
+ var out;
+ var i;
+
+ values = [
+ 'Iรฑtรซrnรขtiรดnร lizรฆtiรธn',
+ 'presidential election',
+ '๐ถ๐ฎ๐ท๐ฐ๐ธ',
+ 'Hello ๐ World',
+ 'เค
เคจเฅเคเฅเคเฅเคฆ'
+ ];
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = sliceGraphemeClusters( values[ i%values.length ], 1, 3 );
+ if ( typeof out !== 'string' ) {
+ b.fail( 'should return a string' );
+ }
+ }
+ b.toc();
+ if ( !isString( out ) ) {
+ b.fail( 'should return a string' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt
new file mode 100644
index 000000000000..d2e2e2dc3619
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt
@@ -0,0 +1,34 @@
+
+{{alias}}( str, start[, end] )
+ Slices a string based on grapheme cluster (i.e., user-perceived character)
+ indices.
+
+ Parameters
+ ----------
+ str: string
+ Input string.
+
+ start: integer
+ The `ith` grapheme cluster to start a slice (inclusive).
+
+ end: integer (optional)
+ The `jth` grapheme cluster to end a slice (exclusive).
+
+ Returns
+ -------
+ out: string
+ Output string.
+
+ Examples
+ --------
+ > var out = {{alias}}( 'beep', 0, 2 )
+ 'be'
+ > out = {{alias}}( 'Boop', 1, 3 )
+ 'oo'
+ > out = {{alias}}( 'foo bar', 4, 7 )
+ 'bar'
+ > out = {{alias}}( '๐ถ๐ฎ๐ท๐ฐ๐ธ', 0, 2 )
+ '๐ถ๐ฎ'
+
+ See Also
+ --------
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts
new file mode 100644
index 000000000000..daebd3303b39
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts
@@ -0,0 +1,47 @@
+/*
+* @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
+
+/**
+* Slices a string based on grapheme cluster (i.e., user-perceived character) indices.
+*
+* @param str - input string
+* @param start - the `ith` grapheme cluster to start a slice (inclusive)
+* @param end - the `jth` grapheme cluster to end a slice (exclusive)
+* @returns output string
+*
+* @example
+* var out = sliceGraphemeClusters( 'Hello World', 0, 5 );
+* // returns 'Hello'
+*
+* out = sliceGraphemeClusters( '๐๐๐', 0, 2 );
+* // returns '๐๐'
+*
+* out = sliceGraphemeClusters( 'เค
เคจเฅเคเฅเคเฅเคฆ', 1, 3 );
+* // returns 'เคจเฅ'
+*
+* out = sliceGraphemeClusters( 'Hello World', -5, -1 );
+* // returns 'World'
+*/
+declare function sliceGraphemeClusters( str: string, start: number, end: number ): string;
+
+
+// EXPORTS //
+
+export = sliceGraphemeClusters;
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts
new file mode 100644
index 000000000000..036ed9567cfe
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts
@@ -0,0 +1,72 @@
+/*
+* @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.
+*/
+
+import sliceGraphemeClusters = require( './index' );
+
+
+// TESTS //
+
+// The function returns a string...
+{
+ sliceGraphemeClusters( 'beep', 0, 2 ); // $ExpectType string
+ sliceGraphemeClusters( 'Boop', 1, 3 ); // $ExpectType string
+ sliceGraphemeClusters( 'foo bar', 4, 7 ); // $ExpectType string
+ sliceGraphemeClusters( '๐ถ๐ฎ๐ท๐ฐ๐ธ', 1, 3 ); // $ExpectType string
+ sliceGraphemeClusters( '๐ถ๐ฎ๐ท๐ฐ๐ธ', -3, -1 ); // $ExpectType string
+}
+
+// The compiler throws an error if the function is provided a value other than a string...
+{
+ sliceGraphemeClusters( true, 1, 2 ); // $ExpectError
+ sliceGraphemeClusters( false, 1, 2 ); // $ExpectError
+ sliceGraphemeClusters( null, 1, 2 ); // $ExpectError
+ sliceGraphemeClusters( undefined, 1, 2 ); // $ExpectError
+ sliceGraphemeClusters( 5, 1, 2 ); // $ExpectError
+ sliceGraphemeClusters( [], 1, 2 ); // $ExpectError
+ sliceGraphemeClusters( {}, 1, 2 ); // $ExpectError
+ sliceGraphemeClusters( ( x: number ): number => x, 1, 2 ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a second argument that is not a number...
+{
+ sliceGraphemeClusters( 'abc', true, 2 ); // $ExpectError
+ sliceGraphemeClusters( 'abc', false, 2 ); // $ExpectError
+ sliceGraphemeClusters( 'abc', null, 2 ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 'abc', 2 ); // $ExpectError
+ sliceGraphemeClusters( 'abc', [], 2 ); // $ExpectError
+ sliceGraphemeClusters( 'abc', {}, 2 ); // $ExpectError
+ sliceGraphemeClusters( 'abc', ( x: number ): number => x, 2 ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a third argument that is not a number...
+{
+ sliceGraphemeClusters( 'abc', 1, true ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 1, false ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 1, null ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 1, 'abc' ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 1, [] ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 1, {} ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 1, ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ sliceGraphemeClusters(); // $ExpectError
+ sliceGraphemeClusters( 'abc' ); // $ExpectError
+ sliceGraphemeClusters( 'abc', 1, 2, {} ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/examples/index.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/examples/index.js
new file mode 100644
index 000000000000..c3d88355e9fa
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/examples/index.js
@@ -0,0 +1,36 @@
+/**
+* @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 sliceGraphemeClusters = require( './../lib' );
+
+console.log( sliceGraphemeClusters( 'Hello World', 0, 5 ) );
+// => 'Hello'
+
+console.log( sliceGraphemeClusters( 'Hello World', -5, -1 ) );
+// => 'Worl'
+
+console.log( sliceGraphemeClusters( '๐๐๐', 0, 2 ) );
+// => '๐๐'
+
+console.log( sliceGraphemeClusters( 'ๅ
ญไนฆ/ๅ
ญๆธ', 1, 5 ) );
+// => 'ไนฆ/ๅ
ญๆธ'
+
+console.log( sliceGraphemeClusters( '๐จโ๐ฉโ๐งโ๐ฆ๐จโ๐ฉโ๐งโ๐ฆ๐จโ๐ฉโ๐งโ๐ฆ', 0, 2 ) );
+// => '๐จโ๐ฉโ๐งโ๐ฆ๐จโ๐ฉโ๐งโ๐ฆ'
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/index.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/index.js
new file mode 100644
index 000000000000..d33d427481a8
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/index.js
@@ -0,0 +1,49 @@
+/**
+* @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';
+
+/**
+* Slice a string based on grapheme cluster (i.e., user-perceived character) indices.
+*
+* @module @stdlib/string/base/slice-grapheme-clusters
+*
+* @example
+* var sliceGraphemeClusters = require( '@stdlib/string/base/slice-grapheme-clusters' );
+*
+* var out = sliceGraphemeClusters( 'Hello World', 0, 5 );
+* // returns 'Hello'
+*
+* out = sliceGraphemeClusters( '๐๐๐', 0, 2 );
+* // returns '๐๐'
+*
+* out = sliceGraphemeClusters( 'เค
เคจเฅเคเฅเคเฅเคฆ', 1, 3 );
+* // returns 'เคจเฅเคเฅ'
+*
+* out = sliceGraphemeClusters( 'Hello World', -5, -1 );
+* // returns 'Worl'
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
new file mode 100644
index 000000000000..dc4d991d0862
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
@@ -0,0 +1,114 @@
+/**
+* @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 nextGraphemeClusterBreak = require( '@stdlib/string/next-grapheme-cluster-break' );
+var numGraphemeClusters = require( '@stdlib/string/num-grapheme-clusters' );
+var max = require( '@stdlib/math/base/special/max' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Slice a string based on grapheme cluster (i.e., user-perceived character) indices.
+*
+* @param {string} str - input string
+* @param {integer} start - the `ith` grapheme cluster to start a slice (inclusive)
+* @param {integer} end - the `jth` grapheme cluster to end a slice (exclusive)
+* @throws {TypeError} function must be provided exactly 3 arguments
+* @returns {string} output string
+*
+* @example
+* var out = sliceGraphemeClusters( 'Hello World', 0, 5 );
+* // returns 'Hello'
+*
+* out = sliceGraphemeClusters( '๐๐๐', 0, 2 );
+* // returns '๐๐'
+*
+* out = sliceGraphemeClusters( 'เค
เคจเฅเคเฅเคเฅเคฆ', 1, 3 );
+* // returns 'เคจเฅเคเฅ'
+*
+* out = sliceGraphemeClusters( 'Hello World', -5, -1 );
+* // returns 'Worl'
+*/
+function sliceGraphemeClusters( str, start, end ) {
+ var numClusters;
+ var result;
+ var idx;
+ var brk;
+ var i;
+
+ if ( arguments.length !== 3 ) {
+ throw new TypeError( format( 'invalid invocation. Function must be provided exactly %d arguments.', 3 ) );
+ }
+
+ if ( str === '' ) {
+ return '';
+ }
+
+ numClusters = numGraphemeClusters( str );
+
+ if ( start < 0 ) {
+ start = max( start + numClusters, 0 );
+ }
+
+ if ( end < 0 ) {
+ end = max( end + numClusters, 0 );
+ }
+
+ if ( start >= numClusters || start >= end ) {
+ return '';
+ }
+
+ if ( end > numClusters ) {
+ end = numClusters;
+ }
+
+ result = '';
+ idx = 0;
+ i = 0;
+
+ while ( idx < str.length ) {
+ brk = nextGraphemeClusterBreak( str, idx );
+ if ( brk === -1 ) {
+ brk = str.length;
+ }
+
+ if ( i >= start && i < end ) {
+ result += str.substring( idx, brk );
+ }
+
+ idx = brk;
+ i += 1;
+
+ if ( i >= end ) {
+ break;
+ }
+ }
+
+ return result;
+}
+
+
+// EXPORTS //
+
+module.exports = sliceGraphemeClusters;
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/package.json b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/package.json
new file mode 100644
index 000000000000..24f482d0fee6
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "@stdlib/string/base/slice-grapheme-clusters",
+ "version": "0.0.0",
+ "description": "Slice a string based on grapheme cluster (i.e., user-perceived character) indices.",
+ "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": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "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": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdstring",
+ "utilities",
+ "utility",
+ "utils",
+ "util",
+ "string",
+ "str",
+ "slice",
+ "substring",
+ "substr",
+ "unicode",
+ "grapheme",
+ "emojis"
+ ]
+}
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
new file mode 100644
index 000000000000..6ec2e0511bf1
--- /dev/null
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
@@ -0,0 +1,149 @@
+/**
+* @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 sliceGraphemeClusters = require( './../lib' );
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof sliceGraphemeClusters, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function has an arity of 3', function test( t ) {
+ t.strictEqual( sliceGraphemeClusters.length, 3, 'the function has an arity of 3' );
+ t.end();
+});
+
+tape( 'the function throws an error if provided an unsupported number of arguments', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ [ 'foo', 1 ],
+ [ 'bar' ],
+ [ 'beep', 1, 3, 5 ]
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue.apply( null, values[i] ), TypeError, 'throws an error when provided unsupported number of arguments' );
+ }
+ t.end();
+
+ function badValue() {
+ return function badValue() {
+ sliceGraphemeClusters.apply( null, arguments );
+ };
+ }
+});
+
+tape( 'the function returns an empty string if provided an empty input string', function test( t ) {
+ var out;
+
+ out = sliceGraphemeClusters( '', 0, 1 );
+ t.strictEqual( out, '', 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function returns an empty string if starting index is greater than or equal to ending index', function test( t ) {
+ var out;
+
+ out = sliceGraphemeClusters( 'hello', 2, 2 );
+ t.strictEqual( out, '', 'returns expected value' );
+
+ out = sliceGraphemeClusters( 'hello', 3, 2 );
+ t.strictEqual( out, '', 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function returns an empty string if starting index is greater than or equal to string length', function test( t ) {
+ var out;
+
+ out = sliceGraphemeClusters( 'hello', 5, 6 );
+ t.strictEqual( out, '', 'returns expected value' );
+
+ out = sliceGraphemeClusters( 'hello', 10, 12 );
+ t.strictEqual( out, '', 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function slices an input string based on grapheme cluster indices', function test( t ) {
+ var out;
+
+ out = sliceGraphemeClusters( 'hello', 0, 3 );
+ t.strictEqual( out, 'hel', 'returns expected value' );
+
+ out = sliceGraphemeClusters( '๐ท๐๐๐ฟ', 1, 2 );
+ t.strictEqual( out, '๐', 'returns expected value' );
+
+ out = sliceGraphemeClusters( 'เค
เคจเฅเคเฅเคเฅเคฆ', 1, 5 );
+ t.strictEqual( out, 'เคจเฅเคเฅเคเฅเคฆ', 'returns expected value' );
+
+ out = sliceGraphemeClusters( 'ๅ
ญไนฆ/ๅ
ญๆธ', 1, 5 );
+ t.strictEqual( out, 'ไนฆ/ๅ
ญๆธ', 'returns expected value' );
+
+ out = sliceGraphemeClusters( '๐๏ธ๐ท', 1, 2 );
+ t.strictEqual( out, '๐ท', 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function supports providing negative indices', function test( t ) {
+ var out;
+
+ out = sliceGraphemeClusters( 'hello', -5, -2 );
+ t.strictEqual( out, 'hel', 'returns expected value' );
+
+ out = sliceGraphemeClusters( '๐ท๐๐๐ฟ', -2, -1 );
+ t.strictEqual( out, '๐', 'returns expected value' );
+
+ out = sliceGraphemeClusters( 'เค
เคจเฅเคเฅเคเฅเคฆ', -4, -1 );
+ t.strictEqual( out, 'เคจเฅเคเฅเคเฅ', 'returns expected value' );
+
+ out = sliceGraphemeClusters( 'ๅ
ญไนฆ/ๅ
ญๆธ', -3, 5 );
+ t.strictEqual( out, '/ๅ
ญๆธ', 'returns expected value' );
+
+ out = sliceGraphemeClusters( '๐๏ธ๐ท', -1, 2 );
+ t.strictEqual( out, '๐ท', 'returns expected value' );
+
+ t.end();
+});
+
+tape( 'the function truncates the end index to the string length', function test( t ) {
+ var out;
+
+ out = sliceGraphemeClusters( 'hello', 0, 10 );
+ t.strictEqual( out, 'hello', 'returns expected value' );
+
+ out = sliceGraphemeClusters( 'ๅ
ญไนฆ/ๅ
ญๆธ', 1, 10 );
+ t.strictEqual( out, 'ไนฆ/ๅ
ญๆธ', 'returns expected value' );
+
+ out = sliceGraphemeClusters( '๐๏ธ๐ท', 0, 5 );
+ t.strictEqual( out, '๐๏ธ๐ท', 'returns expected value' );
+
+ t.end();
+});
From 77bf03d697c20ff360672ce609428667dd247632 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Fri, 28 Feb 2025 07:03:29 +0000
Subject: [PATCH 2/5] refactor: add args docs, fix repl, remove input
validation
---
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: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- 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: na
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: passed
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: passed
---
---
.../base/slice-grapheme-clusters/README.md | 6 +++++
.../slice-grapheme-clusters/docs/repl.txt | 4 ++--
.../docs/types/test.ts | 2 +-
.../base/slice-grapheme-clusters/lib/main.js | 6 -----
.../base/slice-grapheme-clusters/test/test.js | 22 -------------------
5 files changed, 9 insertions(+), 31 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md
index 40d388d53320..d236fdf720ae 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/README.md
@@ -58,6 +58,12 @@ out = sliceGraphemeClusters( '๐ท๐๐๐ฟ', 1, 2 );
// returns '๐'
```
+The function accepts the following arguments:
+
+- **str**: input string.
+- **start**: the `ith` grapheme cluster to start a slice (inclusive).
+- **end**: the `jth` grapheme cluster to end a slice (exclusive).
+
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt
index d2e2e2dc3619..58dca427a3df 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/repl.txt
@@ -1,5 +1,5 @@
-{{alias}}( str, start[, end] )
+{{alias}}( str, start, end )
Slices a string based on grapheme cluster (i.e., user-perceived character)
indices.
@@ -11,7 +11,7 @@
start: integer
The `ith` grapheme cluster to start a slice (inclusive).
- end: integer (optional)
+ end: integer
The `jth` grapheme cluster to end a slice (exclusive).
Returns
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts
index 036ed9567cfe..45ee98156ef9 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/test.ts
@@ -30,7 +30,7 @@ import sliceGraphemeClusters = require( './index' );
sliceGraphemeClusters( '๐ถ๐ฎ๐ท๐ฐ๐ธ', -3, -1 ); // $ExpectType string
}
-// The compiler throws an error if the function is provided a value other than a string...
+// The compiler throws an error if the function is provided a first argument that is not a string...
{
sliceGraphemeClusters( true, 1, 2 ); // $ExpectError
sliceGraphemeClusters( false, 1, 2 ); // $ExpectError
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
index dc4d991d0862..95f7ba0991b1 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
@@ -23,7 +23,6 @@
var nextGraphemeClusterBreak = require( '@stdlib/string/next-grapheme-cluster-break' );
var numGraphemeClusters = require( '@stdlib/string/num-grapheme-clusters' );
var max = require( '@stdlib/math/base/special/max' );
-var format = require( '@stdlib/string/format' );
// MAIN //
@@ -34,7 +33,6 @@ var format = require( '@stdlib/string/format' );
* @param {string} str - input string
* @param {integer} start - the `ith` grapheme cluster to start a slice (inclusive)
* @param {integer} end - the `jth` grapheme cluster to end a slice (exclusive)
-* @throws {TypeError} function must be provided exactly 3 arguments
* @returns {string} output string
*
* @example
@@ -57,10 +55,6 @@ function sliceGraphemeClusters( str, start, end ) {
var brk;
var i;
- if ( arguments.length !== 3 ) {
- throw new TypeError( format( 'invalid invocation. Function must be provided exactly %d arguments.', 3 ) );
- }
-
if ( str === '' ) {
return '';
}
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
index 6ec2e0511bf1..5d404e91b42e 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
@@ -37,28 +37,6 @@ tape( 'the function has an arity of 3', function test( t ) {
t.end();
});
-tape( 'the function throws an error if provided an unsupported number of arguments', function test( t ) {
- var values;
- var i;
-
- values = [
- [ 'foo', 1 ],
- [ 'bar' ],
- [ 'beep', 1, 3, 5 ]
- ];
-
- for ( i = 0; i < values.length; i++ ) {
- t.throws( badValue.apply( null, values[i] ), TypeError, 'throws an error when provided unsupported number of arguments' );
- }
- t.end();
-
- function badValue() {
- return function badValue() {
- sliceGraphemeClusters.apply( null, arguments );
- };
- }
-});
-
tape( 'the function returns an empty string if provided an empty input string', function test( t ) {
var out;
From fa73af6143ec87b98cca933dbee64f506246c126 Mon Sep 17 00:00:00 2001
From: Athan
Date: Sat, 15 Mar 2025 02:36:32 -0700
Subject: [PATCH 3/5] refactor: use other dep
Signed-off-by: Athan
---
.../@stdlib/string/base/slice-grapheme-clusters/lib/main.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
index 95f7ba0991b1..fb829405f850 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
@@ -22,7 +22,7 @@
var nextGraphemeClusterBreak = require( '@stdlib/string/next-grapheme-cluster-break' );
var numGraphemeClusters = require( '@stdlib/string/num-grapheme-clusters' );
-var max = require( '@stdlib/math/base/special/max' );
+var max = require( '@stdlib/math/base/special/fast/max' );
// MAIN //
From f81045391b671e069da70fe1741d10cd29ea866e Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Sat, 15 Mar 2025 10:45:34 +0000
Subject: [PATCH 4/5] refactor: apply suggestions from code review
---
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: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- 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: na
- task: lint_license_headers
status: passed
---
---
.../docs/types/index.d.ts | 4 +--
.../base/slice-grapheme-clusters/lib/main.js | 13 +------
.../base/slice-grapheme-clusters/test/test.js | 34 +++++++++++++++++--
3 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts
index daebd3303b39..541305ad60ab 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/docs/types/index.d.ts
@@ -34,10 +34,10 @@
* // returns '๐๐'
*
* out = sliceGraphemeClusters( 'เค
เคจเฅเคเฅเคเฅเคฆ', 1, 3 );
-* // returns 'เคจเฅ'
+* // returns 'เคจเฅเคเฅ'
*
* out = sliceGraphemeClusters( 'Hello World', -5, -1 );
-* // returns 'World'
+* // returns 'Worl'
*/
declare function sliceGraphemeClusters( str: string, start: number, end: number ): string;
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
index fb829405f850..02956908637a 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/lib/main.js
@@ -28,7 +28,7 @@ var max = require( '@stdlib/math/base/special/fast/max' );
// MAIN //
/**
-* Slice a string based on grapheme cluster (i.e., user-perceived character) indices.
+* Slices a string based on grapheme cluster (i.e., user-perceived character) indices.
*
* @param {string} str - input string
* @param {integer} start - the `ith` grapheme cluster to start a slice (inclusive)
@@ -58,47 +58,36 @@ function sliceGraphemeClusters( str, start, end ) {
if ( str === '' ) {
return '';
}
-
numClusters = numGraphemeClusters( str );
-
if ( start < 0 ) {
start = max( start + numClusters, 0 );
}
-
if ( end < 0 ) {
end = max( end + numClusters, 0 );
}
-
if ( start >= numClusters || start >= end ) {
return '';
}
-
if ( end > numClusters ) {
end = numClusters;
}
-
result = '';
idx = 0;
i = 0;
-
while ( idx < str.length ) {
brk = nextGraphemeClusterBreak( str, idx );
if ( brk === -1 ) {
brk = str.length;
}
-
if ( i >= start && i < end ) {
result += str.substring( idx, brk );
}
-
idx = brk;
i += 1;
-
if ( i >= end ) {
break;
}
}
-
return result;
}
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
index 5d404e91b42e..1d362d514486 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
@@ -45,7 +45,7 @@ tape( 'the function returns an empty string if provided an empty input string',
t.end();
});
-tape( 'the function returns an empty string if starting index is greater than or equal to ending index', function test( t ) {
+tape( 'the function returns an empty string if the starting index is greater than or equal to the ending index', function test( t ) {
var out;
out = sliceGraphemeClusters( 'hello', 2, 2 );
@@ -57,7 +57,7 @@ tape( 'the function returns an empty string if starting index is greater than or
t.end();
});
-tape( 'the function returns an empty string if starting index is greater than or equal to string length', function test( t ) {
+tape( 'the function returns an empty string if the starting index is greater than or equal to the string length', function test( t ) {
var out;
out = sliceGraphemeClusters( 'hello', 5, 6 );
@@ -90,6 +90,21 @@ tape( 'the function slices an input string based on grapheme cluster indices', f
t.end();
});
+tape('the function slices an input string based on grapheme cluster indices (skin-tone emojis)', function test(t) {
+ var out;
+
+ out = sliceGraphemeClusters('๐ท๐จโ๐ฉโ๐งโ๐ฆ๐๐ฟ', 1, 2);
+ t.strictEqual(out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value');
+
+ out = sliceGraphemeClusters('๐๏ธ๐จโ๐ฉโ๐งโ๐ฆ', 1, 2);
+ t.strictEqual(out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value');
+
+ out = sliceGraphemeClusters('๐๐พ๐คฆ๐ฝโโ๏ธ๐ง๐ฟ', 1, 2);
+ t.strictEqual(out, '๐คฆ๐ฝโโ๏ธ', 'returns expected value');
+
+ t.end();
+});
+
tape( 'the function supports providing negative indices', function test( t ) {
var out;
@@ -111,6 +126,21 @@ tape( 'the function supports providing negative indices', function test( t ) {
t.end();
});
+tape('the function supports providing negative indices (skin-tone emojis)', function test(t) {
+ var out;
+
+ out = sliceGraphemeClusters( '๐ท๐จโ๐ฉโ๐งโ๐ฆ๐๐ฟ', -2, -1 );
+ t.strictEqual( out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value' );
+
+ out = sliceGraphemeClusters( '๐๏ธ๐จโ๐ฉโ๐งโ๐ฆ', -1, 4 );
+ t.strictEqual( out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value' );
+
+ out = sliceGraphemeClusters( '๐๐พ๐คฆ๐ฝโโ๏ธ๐ง๐ฟโ๐ฆฑ', -2, -1 );
+ t.strictEqual( out, '๐คฆ๐ฝโโ๏ธ', 'returns expected value' );
+
+ t.end();
+});
+
tape( 'the function truncates the end index to the string length', function test( t ) {
var out;
From 14a16798cee4ba2f719eb4119a9c3d5151eec3e5 Mon Sep 17 00:00:00 2001
From: Athan
Date: Sat, 15 Mar 2025 03:50:59 -0700
Subject: [PATCH 5/5] Apply suggestions from code review
Signed-off-by: Athan
---
.../base/slice-grapheme-clusters/test/test.js | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
index 1d362d514486..f93167a085c9 100644
--- a/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
+++ b/lib/node_modules/@stdlib/string/base/slice-grapheme-clusters/test/test.js
@@ -90,17 +90,17 @@ tape( 'the function slices an input string based on grapheme cluster indices', f
t.end();
});
-tape('the function slices an input string based on grapheme cluster indices (skin-tone emojis)', function test(t) {
+tape( 'the function slices an input string based on grapheme cluster indices (skin-tone emojis)', function test( t ) {
var out;
- out = sliceGraphemeClusters('๐ท๐จโ๐ฉโ๐งโ๐ฆ๐๐ฟ', 1, 2);
- t.strictEqual(out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value');
+ out = sliceGraphemeClusters( '๐ท๐จโ๐ฉโ๐งโ๐ฆ๐๐ฟ', 1, 2 );
+ t.strictEqual( out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value' );
- out = sliceGraphemeClusters('๐๏ธ๐จโ๐ฉโ๐งโ๐ฆ', 1, 2);
- t.strictEqual(out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value');
+ out = sliceGraphemeClusters( '๐๏ธ๐จโ๐ฉโ๐งโ๐ฆ', 1, 2 );
+ t.strictEqual( out, '๐จโ๐ฉโ๐งโ๐ฆ', 'returns expected value' );
- out = sliceGraphemeClusters('๐๐พ๐คฆ๐ฝโโ๏ธ๐ง๐ฟ', 1, 2);
- t.strictEqual(out, '๐คฆ๐ฝโโ๏ธ', 'returns expected value');
+ out = sliceGraphemeClusters( '๐๐พ๐คฆ๐ฝโโ๏ธ๐ง๐ฟ', 1, 2 );
+ t.strictEqual( out, '๐คฆ๐ฝโโ๏ธ', 'returns expected value' );
t.end();
});
@@ -126,7 +126,7 @@ tape( 'the function supports providing negative indices', function test( t ) {
t.end();
});
-tape('the function supports providing negative indices (skin-tone emojis)', function test(t) {
+tape( 'the function supports providing negative indices (skin-tone emojis)', function test( t ) {
var out;
out = sliceGraphemeClusters( '๐ท๐จโ๐ฉโ๐งโ๐ฆ๐๐ฟ', -2, -1 );