Skip to content

Commit 4ea3d81

Browse files
committed
Add string tooling sub-namespace
1 parent 1c3302c commit 4ea3d81

File tree

7 files changed

+338
-0
lines changed

7 files changed

+338
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2021 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+
# Tools
22+
23+
> Standard library string utility tools.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var tools = require( '@stdlib/string/tools' );
31+
```
32+
33+
#### tools
34+
35+
Standard library string utility tools.
36+
37+
```javascript
38+
var o = tools;
39+
// returns {...}
40+
```
41+
42+
The namespace contains the following:
43+
44+
<!-- <toc pattern="*"> -->
45+
46+
<!-- </toc> -->
47+
48+
</section>
49+
50+
<!-- /.usage -->
51+
52+
<section class="examples">
53+
54+
## Examples
55+
56+
<!-- TODO: better examples -->
57+
58+
<!-- eslint no-undef: "error" -->
59+
60+
```javascript
61+
var objectKeys = require( '@stdlib/utils/keys' );
62+
var tools = require( '@stdlib/string/tools' );
63+
64+
console.log( objectKeys( tools ) );
65+
```
66+
67+
</section>
68+
69+
<!-- /.examples -->
70+
71+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
72+
73+
<section class="related">
74+
75+
</section>
76+
77+
<!-- /.related -->
78+
79+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
80+
81+
<section class="links">
82+
83+
<!-- <toc-links> -->
84+
85+
<!-- </toc-links> -->
86+
87+
</section>
88+
89+
<!-- /.links -->
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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: 2.0
20+
21+
/* tslint:disable:max-line-length */
22+
/* tslint:disable:max-file-line-count */
23+
24+
import grapheme = require( '@stdlib/string/tools/grapheme-cluster-break' );
25+
26+
/**
27+
* Interface describing the `tools` namespace.
28+
*/
29+
interface Namespace {
30+
/**
31+
* Grapheme cluster break tooling.
32+
*/
33+
grapheme: typeof grapheme;
34+
}
35+
36+
/**
37+
* Standard library string utility tools.
38+
*/
39+
declare var ns: Namespace;
40+
41+
42+
// EXPORTS //
43+
44+
export = ns;
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) 2021 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+
/* tslint:disable:no-unused-expression */
20+
21+
import tools = require( './index' );
22+
23+
24+
// TESTS //
25+
26+
// The exported value is the expected interface...
27+
{
28+
tools; // $ExpectType Namespace
29+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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 objectKeys = require( '@stdlib/utils/keys' );
22+
var ns = require( './../lib' );
23+
24+
console.log( objectKeys( ns ) );
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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+
* When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
23+
*/
24+
25+
// MODULES //
26+
27+
var setReadOnly = require( '@stdlib/utils/define-read-only-property' );
28+
29+
30+
// MAIN //
31+
32+
/**
33+
* Top-level namespace.
34+
*
35+
* @namespace tools
36+
*/
37+
var tools = {};
38+
39+
/**
40+
* @name grapheme
41+
* @memberof tools
42+
* @readonly
43+
* @type {Function}
44+
* @see {@link module:@stdlib/string/tools/grapheme-cluster-break
45+
*/
46+
setReadOnly( tools, 'grapheme', require( '@stdlib/string/tools/grapheme-cluster-break' ) );
47+
48+
49+
// EXPORTS //
50+
51+
module.exports = tools;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"name": "@stdlib/string/tools",
3+
"version": "0.0.0",
4+
"description": "Standard library string utility tools.",
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+
"lib": "./lib",
20+
"test": "./test"
21+
},
22+
"types": "./docs/types",
23+
"scripts": {},
24+
"homepage": "https://github.com/stdlib-js/stdlib",
25+
"repository": {
26+
"type": "git",
27+
"url": "git://github.com/stdlib-js/stdlib.git"
28+
},
29+
"bugs": {
30+
"url": "https://github.com/stdlib-js/stdlib/issues"
31+
},
32+
"dependencies": {},
33+
"devDependencies": {},
34+
"engines": {
35+
"node": ">=0.10.0",
36+
"npm": ">2.7.0"
37+
},
38+
"os": [
39+
"aix",
40+
"darwin",
41+
"freebsd",
42+
"linux",
43+
"macos",
44+
"openbsd",
45+
"sunos",
46+
"win32",
47+
"windows"
48+
],
49+
"keywords": [
50+
"stdlib",
51+
"stdstring",
52+
"string",
53+
"str",
54+
"utilities",
55+
"utility",
56+
"utils",
57+
"util",
58+
"tool",
59+
"tools"
60+
]
61+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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 tape = require( 'tape' );
24+
var objectKeys = require( '@stdlib/utils/keys' );
25+
var ns = require( './../lib' );
26+
27+
28+
// TESTS //
29+
30+
tape( 'main export is an object', function test( t ) {
31+
t.ok( true, __filename );
32+
t.equal( typeof ns, 'object', 'main export is an object' );
33+
t.end();
34+
});
35+
36+
tape( 'the exported object contains string utility tools', function test( t ) {
37+
var keys = objectKeys( ns );
38+
t.equal( keys.length > 0, true, 'has keys' );
39+
t.end();
40+
});

0 commit comments

Comments
 (0)