Skip to content

Commit dfdc04a

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 541a5fc + 289f01d commit dfdc04a

File tree

235 files changed

+1691
-511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+1691
-511
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 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+
// MAIN //
22+
23+
/**
24+
* Returns default options.
25+
*
26+
* @private
27+
* @returns {Object} default options
28+
*
29+
* @example
30+
* var o = defaults();
31+
* // returns {...}
32+
*/
33+
function defaults() {
34+
return {
35+
'highWaterMark': 9007199254740992
36+
};
37+
}
38+
39+
40+
// EXPORTS //
41+
42+
module.exports = defaults;

lib/node_modules/@stdlib/array/pool/lib/defaults.json

-3
This file was deleted.

lib/node_modules/@stdlib/array/pool/lib/factory.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ var reinterpret128 = require( '@stdlib/strided/base/reinterpret-complex128' );
3535
var accessors = require( '@stdlib/array/base/accessors' );
3636
var adtype = require( '@stdlib/array/dtype' );
3737
var format = require( '@stdlib/string/format' );
38-
var copy = require( '@stdlib/utils/copy' );
3938
var ArrayBuffer = require( '@stdlib/array/buffer' );
4039
var ceil = require( '@stdlib/math/base/special/ceil' );
4140
var floor = require( '@stdlib/math/base/special/floor' );
4241
var ceil2 = require( '@stdlib/math/base/special/ceil2' );
4342
var log2 = require( '@stdlib/math/base/special/log2' );
4443
var min = require( '@stdlib/math/base/special/min' );
45-
var defaults = require( './defaults.json' );
44+
var defaults = require( './defaults.js' );
4645
var validate = require( './validate.js' );
4746
var createPool = require( './pool.js' );
4847
var BYTES_PER_ELEMENT = require( './bytes_per_element.json' );
@@ -111,7 +110,7 @@ function factory( options ) {
111110
var opts;
112111
var err;
113112

114-
opts = copy( defaults );
113+
opts = defaults();
115114
if ( arguments.length ) {
116115
err = validate( opts, options );
117116
if ( err ) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2023 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+
# assign
22+
23+
> Copy enumerable own properties from one or more source objects to a target object.
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 assign = require( '@stdlib/object/assign' );
41+
```
42+
43+
#### assign( target, source1\[, source2\[,...,sourceN]] )
44+
45+
Copies enumerable own properties from one or more source objects to a target object.
46+
47+
```javascript
48+
var x = {
49+
'a': 'beep'
50+
};
51+
var y = {
52+
'b': 'boop'
53+
};
54+
55+
var z = assign( x, y );
56+
57+
var bool = ( z === x );
58+
// returns true
59+
```
60+
61+
</section>
62+
63+
<!-- /.usage -->
64+
65+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
66+
67+
<section class="notes">
68+
69+
## Notes
70+
71+
- If a property key is present in multiple sources, the property from the last source that defines the key prevails.
72+
- The target object is mutated.
73+
74+
</section>
75+
76+
<!-- /.notes -->
77+
78+
<!-- Package usage examples. -->
79+
80+
<section class="examples">
81+
82+
## Examples
83+
84+
<!-- eslint no-undef: "error" -->
85+
86+
```javascript
87+
var assign = require( '@stdlib/object/assign' );
88+
89+
var obj1 = {
90+
'name': 'Jane',
91+
'age': 29
92+
};
93+
var obj2 = {
94+
'country': 'US',
95+
'city': 'San Francisco'
96+
};
97+
var obj3 = {
98+
'hobby': 'Reading'
99+
};
100+
101+
var result = assign( obj1, obj2, obj3 );
102+
// returns { 'name': 'Jane', 'age': 29, 'country': 'US', 'city': 'San Francisco', 'hobby': 'Reading' }
103+
```
104+
105+
</section>
106+
107+
<!-- /.examples -->
108+
109+
<!-- 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. -->
110+
111+
<section class="references">
112+
113+
</section>
114+
115+
<!-- /.references -->
116+
117+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
118+
119+
<section class="related">
120+
121+
<!-- /.related -->
122+
123+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
124+
125+
<section class="links">
126+
127+
<!-- <related-links> -->
128+
129+
<!-- </related-links> -->
130+
131+
</section>
132+
133+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 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 bench = require( '@stdlib/bench' );
24+
var isObject = require( '@stdlib/assert/is-object' );
25+
var pkg = require( './../package.json' ).name;
26+
var assign = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var source1;
33+
var source2;
34+
var target;
35+
var out;
36+
var i;
37+
38+
source1 = {
39+
'a': 'beep'
40+
};
41+
source2 = {
42+
'b': 'boop'
43+
};
44+
45+
b.tic();
46+
for ( i = 0; i < b.iterations; i++ ) {
47+
target = {
48+
'a': i
49+
};
50+
out = assign( target, source1, source2 );
51+
if ( !isObject( out ) ) {
52+
b.fail( 'should return an object' );
53+
}
54+
}
55+
b.toc();
56+
if ( out.a !== 'beep' || out.b !== 'boop' ) {
57+
b.fail( 'should assign properties' );
58+
}
59+
b.pass( 'benchmark finished' );
60+
b.end();
61+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{{alias}}( target, ...source )
2+
Copies own enumerable properties from one or more source objects to a target
3+
object.
4+
5+
If a property key is present in multiple sources, the property from the last
6+
source that defines the key prevails.
7+
8+
The target object is mutated.
9+
10+
Parameters
11+
----------
12+
target: Object
13+
Target object.
14+
15+
source: ...Object
16+
Source object(s).
17+
18+
Returns
19+
-------
20+
out: Object
21+
Target object.
22+
23+
Examples
24+
--------
25+
> var obj1 = { 'name': 'John', 'age': 30 }
26+
> var obj2 = { 'country': 'US', 'city': 'San Francisco' }
27+
> var result = {{alias}}( obj1, obj2 )
28+
{ 'name': 'John', 'age': 30, 'country': 'US', 'city': 'San Francisco' }
29+
30+
See Also
31+
--------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 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+
/**
22+
* Copies own enumerable properties from one or more source objects to a target object.
23+
*
24+
* ## Notes
25+
*
26+
* - If a property key is present in multiple sources, the property from the last source that defines the key prevails.
27+
* - The target object is mutated.
28+
*
29+
* @param target - target object
30+
* @param source - source object(s)
31+
* @throws first argument must not be null or undefined
32+
* @returns target object
33+
*
34+
* @example
35+
* var obj1 = {
36+
* 'a': 'beep'
37+
* };
38+
* var obj2 = {
39+
* 'b': 'boop'
40+
* };
41+
*
42+
* var out = assign( obj1, obj2 );
43+
* // returns { 'a': 'beep', 'b': 'boop' }
44+
*/
45+
declare function assign( target: object, ...source: Array<object> ): object;
46+
47+
48+
// EXPORTS //
49+
50+
export = assign;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2023 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+
import assign = require( './index' );
20+
21+
// TESTS //
22+
23+
// The function returns an object...
24+
{
25+
const obj1 = { 'name': 'John' };
26+
assign( obj1 ); // $ExpectType object
27+
}
28+
29+
// The function returns an object after copying properties...
30+
{
31+
const obj1 = { 'name': 'John' };
32+
const obj2 = { 'country': 'US' };
33+
assign( obj1, obj2 ); // $ExpectType object
34+
}
35+
36+
// The compiler throws an error if the function is provided a first argument which is not an object...
37+
{
38+
assign( 'abc' ); // $ExpectError
39+
assign( false ); // $ExpectError
40+
assign( true ); // $ExpectError
41+
assign( null ); // $ExpectError
42+
}
43+
44+
// The compiler throws an error if the function is provided an insufficient number of arguments...
45+
{
46+
assign(); // $ExpectError
47+
}

0 commit comments

Comments
 (0)