Skip to content

Commit e070a4a

Browse files
committed
Refactor to not use utils/copy
1 parent 85afdc3 commit e070a4a

File tree

18 files changed

+190
-44
lines changed

18 files changed

+190
-44
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
function defaults() {
30+
return {
31+
'sep': '.'
32+
};
33+
}
34+
35+
36+
// EXPORTS //
37+
38+
module.exports = defaults;

lib/node_modules/@stdlib/utils/deep-get/lib/defaults.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

lib/node_modules/@stdlib/utils/deep-get/lib/factory.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isArray = require( '@stdlib/assert/is-array' );
2525
var isObjectLike = require( '@stdlib/assert/is-object-like' );
2626
var format = require( '@stdlib/string/format' );
27-
var copy = require( '@stdlib/utils/copy' );
2827
var validate = require( './validate.js' );
29-
var defaults = require( './defaults.json' );
28+
var defaults = require( './defaults.js' );
3029
var dget = require( './dget.js' );
3130

3231

@@ -57,7 +56,7 @@ function factory( path, options ) {
5756
if ( !isStr && !isArray( path ) ) {
5857
throw new TypeError( format( 'invalid argument. Key path must be a string or a key array. Value: `%s`.', path ) );
5958
}
60-
opts = copy( defaults );
59+
opts = defaults();
6160
if ( arguments.length > 1 ) {
6261
err = validate( opts, options );
6362
if ( err ) {

lib/node_modules/@stdlib/utils/deep-get/lib/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ var isObjectLike = require( '@stdlib/assert/is-object-like' );
2424
var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2525
var isArray = require( '@stdlib/assert/is-array' );
2626
var format = require( '@stdlib/string/format' );
27-
var copy = require( '@stdlib/utils/copy' );
2827
var validate = require( './validate.js' );
29-
var defaults = require( './defaults.json' );
28+
var defaults = require( './defaults.js' );
3029
var dget = require( './dget.js' );
3130

3231

@@ -81,7 +80,7 @@ function deepGet( obj, path, options ) {
8180
if ( !isStr && !isArray( path ) ) {
8281
throw new TypeError( format( 'invalid argument. Key path must be a string or a key array. Value: `%s`.', path ) );
8382
}
84-
opts = copy( defaults );
83+
opts = defaults();
8584
if ( arguments.length > 2 ) {
8685
err = validate( opts, options );
8786
if ( err ) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
function defaults() {
30+
return {
31+
'copy': true,
32+
'sep': '.'
33+
};
34+
}
35+
36+
37+
// EXPORTS //
38+
39+
module.exports = defaults;

lib/node_modules/@stdlib/utils/deep-pluck/lib/defaults.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/node_modules/@stdlib/utils/deep-pluck/lib/main.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
var deepGet = require( '@stdlib/utils/deep-get' ).factory;
2424
var isArray = require( '@stdlib/assert/is-array' );
2525
var format = require( '@stdlib/string/format' );
26-
var copy = require( '@stdlib/utils/copy' );
27-
var defaults = require( './defaults.json' );
26+
var defaults = require( './defaults.js' );
2827
var validate = require( './validate.js' );
2928

3029

@@ -92,7 +91,7 @@ function deepPluck( arr, path, options ) {
9291
if ( !isArray( arr ) ) {
9392
throw new TypeError( format( 'invalid argument. First argument must be an array. Value: `%s`.', arr ) );
9493
}
95-
opts = copy( defaults );
94+
opts = defaults();
9695
if ( arguments.length > 2 ) {
9796
err = validate( opts, options );
9897
if ( err ) {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
function defaults() {
30+
return {
31+
'create': false,
32+
'sep': '.'
33+
};
34+
}
35+
36+
37+
// EXPORTS //
38+
39+
module.exports = defaults;

lib/node_modules/@stdlib/utils/deep-set/lib/defaults.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

lib/node_modules/@stdlib/utils/deep-set/lib/factory.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ var isString = require( '@stdlib/assert/is-string' ).isPrimitive;
2424
var isArray = require( '@stdlib/assert/is-array' );
2525
var isObjectLike = require( '@stdlib/assert/is-object-like' );
2626
var format = require( '@stdlib/string/format' );
27-
var copy = require( '@stdlib/utils/copy' );
2827
var validate = require( './validate.js' );
29-
var defaults = require( './defaults.json' );
28+
var defaults = require( './defaults.js' );
3029
var dset = require( './dset.js' );
3130

3231

@@ -60,7 +59,7 @@ function factory( path, options ) {
6059
if ( !isStr && !isArray( path ) ) {
6160
throw new TypeError( format( 'invalid argument. Key path must be a string or a key array. Value: `%s`.', path ) );
6261
}
63-
opts = copy( defaults );
62+
opts = defaults();
6463
if ( arguments.length > 1 ) {
6564
err = validate( opts, options );
6665
if ( err ) {

0 commit comments

Comments
 (0)