Skip to content

Commit 2e9b95a

Browse files
committed
Add namespace files
1 parent d58b8e1 commit 2e9b95a

File tree

7 files changed

+358
-0
lines changed

7 files changed

+358
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 math tools.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var ns = require( '@stdlib/math/tools' );
31+
```
32+
33+
#### ns
34+
35+
Standard library math tools.
36+
37+
```javascript
38+
var o = ns;
39+
// returns {...}
40+
```
41+
42+
</section>
43+
44+
<!-- /.usage -->
45+
46+
<section class="examples">
47+
48+
## Examples
49+
50+
<!-- TODO: better examples -->
51+
52+
<!-- eslint no-undef: "error" -->
53+
54+
```javascript
55+
var objectKeys = require( '@stdlib/utils/keys' );
56+
var ns = require( '@stdlib/math/tools' );
57+
58+
console.log( objectKeys( ns ) );
59+
```
60+
61+
</section>
62+
63+
<!-- /.examples -->
64+
65+
<section class="links">
66+
67+
<!-- <toc-links> -->
68+
69+
<!-- </toc-links> -->
70+
71+
</section>
72+
73+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 unary = require( '@stdlib/math/tools/unary' );
25+
26+
/**
27+
* Interface describing the `tools` namespace.
28+
*/
29+
interface Namespace {
30+
/**
31+
* Returns a function which dispatches to specified functions based on input argument types.
32+
*
33+
* @param table - resolution table object
34+
* @throws must provide valid table fields
35+
* @throws table field values must be array-like objects having an even number of elements
36+
* @throws table field values must consist of dtype-function pairs
37+
* @returns dispatch function
38+
*
39+
* @example
40+
* var nabs = require( `@stdlib/math/base/special/abs` );
41+
* var dabs = require( `@stdlib/math/strided/special/dabs` );
42+
* var sabs = require( `@stdlib/math/strided/special/sabs` );
43+
* var gabs = require( `@stdlib/math/strided/special/abs` );
44+
* var Float64Array = require( `@stdlib/array/float64` );
45+
*
46+
* var table = {
47+
* 'scalar': [
48+
* 'number', nabs
49+
* ],
50+
* 'array': [
51+
* 'float64', dabs,
52+
* 'float32', sabs,
53+
* 'generic', gabs
54+
* ],
55+
* 'ndarray': [
56+
* 'float64', dabs.ndarray,
57+
* 'float32', sabs.ndarray,
58+
* 'generic', gabs.ndarray
59+
* ]
60+
* };
61+
*
62+
* var abs = ns.unary( table );
63+
*
64+
* var x = new Float64Array( [ -1.0, -2.0, -3.0 ] );
65+
* var y = abs( x );
66+
* // returns <Float64Array>[ 1.0, 2.0, 3.0 ]
67+
*/
68+
unary: typeof unary;
69+
}
70+
71+
/**
72+
* Standard library math tools.
73+
*/
74+
declare var ns: Namespace;
75+
76+
77+
// EXPORTS //
78+
79+
export = ns;
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+
}
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 ) );
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 ns
36+
*/
37+
var ns = {};
38+
39+
/**
40+
* @name unary
41+
* @memberof ns
42+
* @readonly
43+
* @type {Namespace}
44+
* @see {@link module:@stdlib/math/tools/unary}
45+
*/
46+
setReadOnly( ns, 'unary', require( '@stdlib/math/tools/unary' ) );
47+
48+
49+
// EXPORTS //
50+
51+
module.exports = ns;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "@stdlib/math/tools",
3+
"version": "0.0.0",
4+
"description": "Standard library math 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+
"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+
"stdmath",
53+
"standard",
54+
"library",
55+
"std",
56+
"lib",
57+
"tooling",
58+
"tools",
59+
"math",
60+
"mathematics"
61+
]
62+
}
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 base math 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)