From 0d8ab3336fce2ec74117b68da12e54f9cf5c42f6 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 6 Dec 2025 10:12:27 +0530 Subject: [PATCH 1/4] feat: add `object/move-property` Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/object/move-property/README.md | 144 ++++++++++++++ .../move-property/benchmark/benchmark.js | 66 +++++++ .../object/move-property/docs/repl.txt | 38 ++++ .../move-property/docs/types/index.d.ts | 53 +++++ .../object/move-property/docs/types/test.ts | 46 +++++ .../object/move-property/examples/index.js | 45 +++++ .../@stdlib/object/move-property/lib/index.js | 46 +++++ .../@stdlib/object/move-property/lib/main.js | 74 +++++++ .../@stdlib/object/move-property/package.json | 69 +++++++ .../@stdlib/object/move-property/test/test.js | 184 ++++++++++++++++++ 10 files changed, 765 insertions(+) create mode 100644 lib/node_modules/@stdlib/object/move-property/README.md create mode 100644 lib/node_modules/@stdlib/object/move-property/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/object/move-property/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/object/move-property/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/object/move-property/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/object/move-property/examples/index.js create mode 100644 lib/node_modules/@stdlib/object/move-property/lib/index.js create mode 100644 lib/node_modules/@stdlib/object/move-property/lib/main.js create mode 100644 lib/node_modules/@stdlib/object/move-property/package.json create mode 100644 lib/node_modules/@stdlib/object/move-property/test/test.js diff --git a/lib/node_modules/@stdlib/object/move-property/README.md b/lib/node_modules/@stdlib/object/move-property/README.md new file mode 100644 index 000000000000..b60e28058b28 --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/README.md @@ -0,0 +1,144 @@ + + +# Move Property + +> Move a property from one object to another object. + +
+ +## Usage + +```javascript +var moveProperty = require( '@stdlib/object/move-property' ); +``` + +#### moveProperty( source, prop, target ) + +Moves a property from one `object` to another `object`. + +```javascript +var obj1 = { + 'a': 'b' +}; +var obj2 = {}; + +var bool = moveProperty( obj1, 'a', obj2 ); +// returns true +``` + +If the operation is successful, the function returns `true`; otherwise, `false`. + +```javascript +var obj1 = { + 'a': 'b' +}; +var obj2 = {}; + +var bool = moveProperty( obj1, 'c', obj2 ); +// returns false +``` + +
+ + + +
+ +## Notes + +- A transfer is **shallow**. + + ```javascript + var arr = [ 1, 2, 3 ]; + + var obj1 = { + 'a': arr + }; + var obj2 = {}; + + var bool = moveProperty( obj1, 'a', obj2 ); + console.log( obj2.a === arr ); + // => true + ``` + +- The property is **deleted** from the _source_ `object`. + +- The property's descriptor **is** preserved during transfer. + +- If a _source_ property is **not** `configurable`, the function throws an `Error`, as the property **cannot** be deleted from the _source_ `object`. + +
+ + + +
+ +## Examples + + + +```javascript +var moveProperty = require( '@stdlib/object/move-property' ); + +var obj1 = { + 'beep': 'boop' +}; + +var obj2 = { + 'foo': 'bar' +}; + +var bool = moveProperty( obj1, 'beep', obj2 ); +if ( bool === false ) { + console.log( 'failed to move property' ); +} +console.dir( obj1 ); +/* => + {} +*/ +console.dir( obj2 ); +/* => + { + 'foo': 'bar', + 'beep': 'boop' + } +*/ +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/object/move-property/benchmark/benchmark.js b/lib/node_modules/@stdlib/object/move-property/benchmark/benchmark.js new file mode 100644 index 000000000000..9e3f3b98ac58 --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/benchmark/benchmark.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 randu = require( '@stdlib/random/base/randu' ); +var pkg = require( './../package.json' ).name; +var moveProperty = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var obj1; + var obj2; + var out; + var i; + + obj1 = { + 'A': 'beep', + 'B': 'boop' + }; + obj2 = { + 'foo': 'bar', + 'c': randu() + }; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + obj2.c = randu(); + out = moveProperty( obj2, 'foo', obj1 ); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return an boolean' ); + } + out = moveProperty( obj1, 'foo', obj2 ); + } + b.toc(); + if ( typeof out !== 'boolean' ) { + b.fail( 'should return an boolean' ); + } + if ( typeof obj2.foo !== 'string' ) { + b.fail( 'should move property back to source object' ); + } + if ( obj1.foo ) { + b.fail( 'should delete property' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/object/move-property/docs/repl.txt b/lib/node_modules/@stdlib/object/move-property/docs/repl.txt new file mode 100644 index 000000000000..9b908c75131c --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/docs/repl.txt @@ -0,0 +1,38 @@ + +{{alias}}( source, prop, target ) + Moves a property from one object to another object. + + The property is deleted from the source object and the property's descriptor + is preserved during transfer. + + If a source property is not configurable, the function throws an error, as + the property cannot be deleted from the source object. + + Parameters + ---------- + source: Object + Source object. + + prop: string + Property to move. + + target: Object + Target object. + + Returns + ------- + bool: boolean + Boolean indicating whether operation was successful. + + Examples + -------- + > var obj1 = { 'a': 'b' }; + > var obj2 = {}; + > var bool = {{alias}}( obj1, 'a', obj2 ) + true + > bool = {{alias}}( obj1, 'c', obj2 ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/object/move-property/docs/types/index.d.ts b/lib/node_modules/@stdlib/object/move-property/docs/types/index.d.ts new file mode 100644 index 000000000000..3dcbdbcec16a --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/docs/types/index.d.ts @@ -0,0 +1,53 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 + +/** +* Moves a property from one object to another object. +* +* ## Notes +* +* - The property is deleted from the source object and the property's descriptor is preserved during transfer. +* - If a source property is not configurable, the function throws an error, as the property cannot be deleted from the source object. +* +* @param source - source object +* @param prop - property to move +* @param target - target object +* @returns boolean indicating whether operation was successful +* +* @example +* var obj1 = { 'a': 'b' }; +* var obj2 = {}; +* +* var bool = moveProperty( obj1, 'a', obj2 ); +* // returns true +* +* @example +* var obj1 = { 'a': 'b' }; +* var obj2 = {}; +* +* var bool = moveProperty( obj1, 'c', obj2 ); +* // returns false +*/ +declare function moveProperty( source: any, prop: string, target: any ): boolean; + + +// EXPORTS // + +export = moveProperty; diff --git a/lib/node_modules/@stdlib/object/move-property/docs/types/test.ts b/lib/node_modules/@stdlib/object/move-property/docs/types/test.ts new file mode 100644 index 000000000000..a1ec2c5da5d2 --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/docs/types/test.ts @@ -0,0 +1,46 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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 moveProperty = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + moveProperty( { 'a': 'b' }, 'a', {} ); // $ExpectType boolean + moveProperty( { 'a': 'b' }, 'a', {} ); // $ExpectType boolean +} + +// The compiler throws an error if the function is not provided a string as its second argument... +{ + moveProperty( { 'a': 'b' }, true, {} ); // $ExpectError + moveProperty( { 'a': 'b' }, 3.12, {} ); // $ExpectError + moveProperty( { 'a': 'b' }, false, {} ); // $ExpectError + moveProperty( { 'a': 'b' }, ( x: number ): number => x, {} ); // $ExpectError + moveProperty( { 'a': 'b' }, [], {} ); // $ExpectError + moveProperty( { 'a': 'b' }, {}, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an incorrect number of arguments... +{ + moveProperty(); // $ExpectError + moveProperty( { 'a': 'b' } ); // $ExpectError + moveProperty( { 'a': 'b' }, 'a' ); // $ExpectError + moveProperty( { 'a': 'b' }, 'a', {}, 3.12 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/object/move-property/examples/index.js b/lib/node_modules/@stdlib/object/move-property/examples/index.js new file mode 100644 index 000000000000..929e260ac764 --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/examples/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 moveProperty = require( './../lib' ); + +var obj1 = { + 'beep': 'boop' +}; + +var obj2 = { + 'foo': 'bar' +}; + +var bool = moveProperty( obj1, 'beep', obj2 ); +if ( bool === false ) { + console.log( 'failed to move property' ); +} +console.dir( obj1 ); +/* => + {} +*/ +console.dir( obj2 ); +/* => + { + 'foo': 'bar', + 'beep': 'boop' + } +*/ diff --git a/lib/node_modules/@stdlib/object/move-property/lib/index.js b/lib/node_modules/@stdlib/object/move-property/lib/index.js new file mode 100644 index 000000000000..9813de67a4f5 --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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'; + +/** +* Move a property from one object to another object. +* +* @module @stdlib/object/move-property +* +* @example +* var moveProperty = require( '@stdlib/object/move-property' ); +* +* var obj1 = { 'a': 'b' }; +* var obj2 = {}; +* +* var bool = moveProperty( obj1, 'a', obj2 ); +* // returns true +* +* bool = moveProperty( obj1, 'c', obj2 ); +* // returns false +*/ + +// MODULES // + +var moveProperty = require( './main.js' ); + + +// EXPORTS // + +module.exports = moveProperty; diff --git a/lib/node_modules/@stdlib/object/move-property/lib/main.js b/lib/node_modules/@stdlib/object/move-property/lib/main.js new file mode 100644 index 000000000000..f144b75cde7e --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/lib/main.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 defineProperty = require( '@stdlib/utils/define-property' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Moves a property from one object to another object. +* +* @param {Object} source - source object +* @param {string} prop - property to move +* @param {Object} target - target object +* @throws {TypeError} first argument must be an object +* @throws {TypeError} third argument must be an object +* @returns {boolean} boolean indicating whether operation was successful +* +* @example +* var obj1 = { 'a': 'b' }; +* var obj2 = {}; +* +* var bool = moveProperty( obj1, 'a', obj2 ); +* // returns true +* +* @example +* var obj1 = { 'a': 'b' }; +* var obj2 = {}; +* +* var bool = moveProperty( obj1, 'c', obj2 ); +* // returns false +*/ +function moveProperty( source, prop, target ) { + var desc; + if ( typeof source !== 'object' || source === null ) { + throw new TypeError( format( 'invalid argument. Source argument must be an object. Value: `%s`.', source ) ); + } + if ( typeof target !== 'object' || target === null ) { + throw new TypeError( format( 'invalid argument. Target argument must be an object. Value: `%s`.', target ) ); + } + // TODO: handle case where gOPD is not supported + desc = Object.getOwnPropertyDescriptor( source, prop ); + if ( desc === void 0 ) { + return false; + } + delete source[ prop ]; + defineProperty( target, prop, desc ); + return true; +} + + +// EXPORTS // + +module.exports = moveProperty; diff --git a/lib/node_modules/@stdlib/object/move-property/package.json b/lib/node_modules/@stdlib/object/move-property/package.json new file mode 100644 index 000000000000..f346587b0f0d --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/object/move-property", + "version": "0.0.0", + "description": "Move a property from one object to another object.", + "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", + "stdutils", + "stdutil", + "util", + "utils", + "utility", + "utilities", + "move", + "copy", + "property", + "prop", + "object", + "transfer", + "cp", + "mv", + "obj" + ] +} diff --git a/lib/node_modules/@stdlib/object/move-property/test/test.js b/lib/node_modules/@stdlib/object/move-property/test/test.js new file mode 100644 index 000000000000..4d17226be47d --- /dev/null +++ b/lib/node_modules/@stdlib/object/move-property/test/test.js @@ -0,0 +1,184 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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. +*/ + +/* eslint-disable object-curly-newline */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var defineProperty = require( '@stdlib/utils/define-property' ); +var moveProperty = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof moveProperty, 'function', 'export is a function' ); + t.end(); +}); + +tape( 'if provided a `source` argument which is not an object, the function will throw', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws type error when provided ' + (typeof values[i]) ); + } + t.end(); + function badValue( value ) { + return function badValue() { + moveProperty( value, 'a', {} ); + }; + } +}); + +tape( 'if provided a `target` argument which is not an object, the function will throw', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true, + false + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws type error when provided ' + (typeof values[i]) ); + } + t.end(); + function badValue( value ) { + return function badValue() { + moveProperty( {}, 'a', value ); + }; + } +}); + +tape( 'if unable to move a property, the function returns `false`', function test( t ) { + var bool = moveProperty( {}, 'a', {} ); + t.notOk( bool, 'unable to move property' ); + t.end(); +}); + +tape( 'if moving a property is successful, the function returns `true`', function test( t ) { + var bool = moveProperty({ 'a': 'b' }, 'a', {} ); + t.ok( bool, 'successfully moved property' ); + t.end(); +}); + +tape( 'the function moves property a from one object to another object', function test( t ) { + var obj1 = { 'a': 'b' }; + var obj2 = {}; + var bool = moveProperty( obj1, 'a', obj2 ); + + t.ok( bool, 'successfully moved property' ); + t.deepEqual( obj2, { 'a': 'b' }, 'deep equal' ); + t.deepEqual( obj1, {}, 'deep equal' ); + t.end(); +}); + +tape( 'the function deletes a property from the source object', function test( t ) { + var obj1 = { 'a': 'b' }; + var obj2 = {}; + var bool = moveProperty( obj1, 'a', obj2 ); + + t.ok( bool, 'successfully moved property' ); + t.deepEqual( obj1, {}, 'deep equal' ); + t.end(); +}); + +tape( 'the function preserves property\'s descriptors', function test( t ) { + var obj1 = {}; + var obj2 = {}; + var bool; + var desc; + + desc = { + 'value': 'b', + 'writable': false, + 'configurable': true, + 'enumerable': false + }; + + defineProperty( obj1, 'a', desc ); + + bool = moveProperty( obj1, 'a', obj2 ); + + t.ok( bool, 'successfully moved property' ); + t.deepEqual( obj1, {}, 'deep equal' ); + t.strictEqual( obj2.a, 'b' ); + t.deepEqual( Object.getOwnPropertyDescriptor( obj2, 'a' ), desc, 'descriptors are equal' ); + + t.end(); +}); + +tape( 'if a property cannot be deleted from a source object, the function throws an error', function test( t ) { + var obj1 = {}; + var obj2 = {}; + var desc; + + desc = { + 'value': 'b', + 'writable': false, + 'configurable': false, + 'enumerable': false + }; + + defineProperty( obj1, 'a', desc ); + + t.throws( foo, Error ); + t.end(); + function foo() { + moveProperty( obj1, 'a', obj2 ); + } +}); + +tape( 'the function does not deep copy moved properties', function test( t ) { + var bool; + var obj1; + var obj2; + var arr; + + arr = [ 1, 2, 3 ]; + obj1 = { 'a': arr }; + obj2 = {}; + bool = moveProperty( obj1, 'a', obj2 ); + + t.ok( bool, 'successfully moved property' ); + t.deepEqual( obj2, { 'a': arr }, 'deep equal' ); + t.deepEqual( obj1, {}, 'deep equal' ); + t.strictEqual( obj2.a, arr, 'same reference' ); + + t.end(); +}); From 200beb8ba29476f45f9c2fa4aaec33eadd643a93 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 6 Dec 2025 10:14:53 +0530 Subject: [PATCH 2/4] remove: remove `moveProperty` from namespace This commit removes the `moveProperty` symbol from the `@stdlib/utils` namespace due to a package migration. BREAKING CHANGE: remove `moveProperty` To migrate, users should access the same symbol via the `@stdlib/object` namespace. Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/utils/docs/types/index.d.ts | 30 ------------------- lib/node_modules/@stdlib/utils/lib/index.js | 9 ------ 2 files changed, 39 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/docs/types/index.d.ts index 03c94d10e478..47907b5ad831 100644 --- a/lib/node_modules/@stdlib/utils/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/docs/types/index.d.ts @@ -143,7 +143,6 @@ import map5d = require( '@stdlib/utils/map5d' ); import maskArguments = require( '@stdlib/utils/mask-arguments' ); import memoize = require( '@stdlib/utils/memoize' ); import merge = require( '@stdlib/utils/merge' ); -import moveProperty = require( '@stdlib/utils/move-property' ); import naryFunction = require( '@stdlib/utils/nary-function' ); import nativeClass = require( '@stdlib/utils/native-class' ); import nextTick = require( '@stdlib/utils/next-tick' ); @@ -3902,35 +3901,6 @@ interface Namespace { */ merge: typeof merge; - /** - * Moves a property from one object to another object. - * - * ## Notes - * - * - The property is deleted from the source object and the property's descriptor is preserved during transfer. - * - If a source property is not configurable, the function throws an error, as the property cannot be deleted from the source object. - * - * @param source - source object - * @param prop - property to move - * @param target - target object - * @returns boolean indicating whether operation was successful - * - * @example - * var obj1 = { 'a': 'b' }; - * var obj2 = {}; - * - * var bool = ns.moveProperty( obj1, 'a', obj2 ); - * // returns true - * - * @example - * var obj1 = { 'a': 'b' }; - * var obj2 = {}; - * - * var bool = ns.moveProperty( obj1, 'c', obj2 ); - * // returns false - */ - moveProperty: typeof moveProperty; - /** * Returns a function that applies a specified number of arguments to a provided function. * diff --git a/lib/node_modules/@stdlib/utils/lib/index.js b/lib/node_modules/@stdlib/utils/lib/index.js index 282601af296e..b17dc4575c18 100644 --- a/lib/node_modules/@stdlib/utils/lib/index.js +++ b/lib/node_modules/@stdlib/utils/lib/index.js @@ -1147,15 +1147,6 @@ setReadOnly( utils, 'memoize', require( '@stdlib/utils/memoize' ) ); */ setReadOnly( utils, 'merge', require( '@stdlib/utils/merge' ) ); -/** -* @name moveProperty -* @memberof utils -* @readonly -* @type {Function} -* @see {@link module:@stdlib/utils/move-property} -*/ -setReadOnly( utils, 'moveProperty', require( '@stdlib/utils/move-property' ) ); - /** * @name naryFunction * @memberof utils From eb516fef767255aaabd910a3b79f5fc904acd514 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 6 Dec 2025 10:19:15 +0530 Subject: [PATCH 3/4] refactor: update paths Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv | 2 +- lib/node_modules/@stdlib/namespace/lib/namespace/m.js | 4 ++-- lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv | 2 +- lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv | 2 +- .../@stdlib/namespace/pkg2standalone/data/data.csv | 2 +- .../@stdlib/namespace/standalone2pkg/data/data.csv | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv index 22ed37f41e7e..8be5109bab1f 100644 --- a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv @@ -2565,7 +2565,7 @@ minutesInYear,"@stdlib/time/minutes-in-year" MOBY_DICK,"@stdlib/datasets/moby-dick" MONTH_NAMES_EN,"@stdlib/datasets/month-names-en" MONTHS_IN_YEAR,"@stdlib/constants/time/months-in-year" -moveProperty,"@stdlib/utils/move-property" +moveProperty,"@stdlib/object/move-property" MultiSlice,"@stdlib/slice/multi" namedtypedtuple,"@stdlib/dstructs/named-typed-tuple" NAN,"@stdlib/constants/float64/nan" diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/m.js b/lib/node_modules/@stdlib/namespace/lib/namespace/m.js index 8ae62625a8fc..5163125b258e 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/m.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/m.js @@ -435,8 +435,8 @@ ns.push({ ns.push({ 'alias': 'moveProperty', - 'path': '@stdlib/utils/move-property', - 'value': require( '@stdlib/utils/move-property' ), + 'path': '@stdlib/object/move-property', + 'value': require( '@stdlib/object/move-property' ), 'type': 'Function', 'related': [] }); diff --git a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv index 90d807b0f21f..f660338aa683 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv @@ -2565,7 +2565,7 @@ "@stdlib/datasets/moby-dick",MOBY_DICK "@stdlib/datasets/month-names-en",MONTH_NAMES_EN "@stdlib/constants/time/months-in-year",MONTHS_IN_YEAR -"@stdlib/utils/move-property",moveProperty +"@stdlib/object/move-property",moveProperty "@stdlib/slice/multi",MultiSlice "@stdlib/dstructs/named-typed-tuple",namedtypedtuple "@stdlib/constants/float64/nan",NAN diff --git a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv index 2a9923697e8c..1a9e75d0033f 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv @@ -2565,7 +2565,7 @@ "@stdlib/datasets/moby-dick","" "@stdlib/datasets/month-names-en","" "@stdlib/constants/time/months-in-year","" -"@stdlib/utils/move-property","" +"@stdlib/object/move-property","" "@stdlib/slice/multi","@stdlib/ndarray/ctor,@stdlib/slice/ctor" "@stdlib/dstructs/named-typed-tuple","@stdlib/array/typed" "@stdlib/constants/float64/nan","@stdlib/constants/float32/nan" diff --git a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv index 8a7c9d619703..bcb679b150c4 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv @@ -2565,7 +2565,7 @@ "@stdlib/datasets/moby-dick","@stdlib/datasets-moby-dick" "@stdlib/datasets/month-names-en","@stdlib/datasets-month-names-en" "@stdlib/constants/time/months-in-year","@stdlib/constants-time-months-in-year" -"@stdlib/utils/move-property","@stdlib/utils-move-property" +"@stdlib/object/move-property","@stdlib/object-move-property" "@stdlib/slice/multi","@stdlib/slice-multi" "@stdlib/dstructs/named-typed-tuple","@stdlib/dstructs-named-typed-tuple" "@stdlib/constants/float64/nan","@stdlib/constants-float64-nan" diff --git a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv index 829dfec5e247..a610ed52fc56 100644 --- a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv @@ -2565,7 +2565,7 @@ "@stdlib/datasets-moby-dick","@stdlib/datasets/moby-dick" "@stdlib/datasets-month-names-en","@stdlib/datasets/month-names-en" "@stdlib/constants-time-months-in-year","@stdlib/constants/time/months-in-year" -"@stdlib/utils-move-property","@stdlib/utils/move-property" +"@stdlib/object-move-property","@stdlib/object/move-property" "@stdlib/slice-multi","@stdlib/slice/multi" "@stdlib/dstructs-named-typed-tuple","@stdlib/dstructs/named-typed-tuple" "@stdlib/constants-float64-nan","@stdlib/constants/float64/nan" From bb2d18c9ea5e11a3ec6714f348ada359a2fea5f7 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 6 Dec 2025 10:20:08 +0530 Subject: [PATCH 4/4] remove: remove `utils/move-property` This commit removes `@stdlib/utils/move-property` in favor of `@stdlib/object/move-property`. BREAKING CHANGE: remove `utils/move-property` To migrate, users should update their require/import paths to use `@stdlib/object/move-property` which provides the same API and implementation. Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/utils/move-property/README.md | 144 -------------- .../move-property/benchmark/benchmark.js | 66 ------- .../@stdlib/utils/move-property/docs/repl.txt | 38 ---- .../utils/move-property/docs/types/index.d.ts | 53 ----- .../utils/move-property/docs/types/test.ts | 46 ----- .../utils/move-property/examples/index.js | 45 ----- .../@stdlib/utils/move-property/lib/index.js | 46 ----- .../@stdlib/utils/move-property/lib/main.js | 74 ------- .../@stdlib/utils/move-property/package.json | 69 ------- .../@stdlib/utils/move-property/test/test.js | 184 ------------------ 10 files changed, 765 deletions(-) delete mode 100644 lib/node_modules/@stdlib/utils/move-property/README.md delete mode 100644 lib/node_modules/@stdlib/utils/move-property/benchmark/benchmark.js delete mode 100644 lib/node_modules/@stdlib/utils/move-property/docs/repl.txt delete mode 100644 lib/node_modules/@stdlib/utils/move-property/docs/types/index.d.ts delete mode 100644 lib/node_modules/@stdlib/utils/move-property/docs/types/test.ts delete mode 100644 lib/node_modules/@stdlib/utils/move-property/examples/index.js delete mode 100644 lib/node_modules/@stdlib/utils/move-property/lib/index.js delete mode 100644 lib/node_modules/@stdlib/utils/move-property/lib/main.js delete mode 100644 lib/node_modules/@stdlib/utils/move-property/package.json delete mode 100644 lib/node_modules/@stdlib/utils/move-property/test/test.js diff --git a/lib/node_modules/@stdlib/utils/move-property/README.md b/lib/node_modules/@stdlib/utils/move-property/README.md deleted file mode 100644 index b26d5fc2a0f0..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/README.md +++ /dev/null @@ -1,144 +0,0 @@ - - -# Move Property - -> Move a property from one object to another object. - -
- -## Usage - -```javascript -var moveProperty = require( '@stdlib/utils/move-property' ); -``` - -#### moveProperty( source, prop, target ) - -Moves a property from one `object` to another `object`. - -```javascript -var obj1 = { - 'a': 'b' -}; -var obj2 = {}; - -var bool = moveProperty( obj1, 'a', obj2 ); -// returns true -``` - -If the operation is successful, the function returns `true`; otherwise, `false`. - -```javascript -var obj1 = { - 'a': 'b' -}; -var obj2 = {}; - -var bool = moveProperty( obj1, 'c', obj2 ); -// returns false -``` - -
- - - -
- -## Notes - -- A transfer is **shallow**. - - ```javascript - var arr = [ 1, 2, 3 ]; - - var obj1 = { - 'a': arr - }; - var obj2 = {}; - - var bool = moveProperty( obj1, 'a', obj2 ); - console.log( obj2.a === arr ); - // => true - ``` - -- The property is **deleted** from the _source_ `object`. - -- The property's descriptor **is** preserved during transfer. - -- If a _source_ property is **not** `configurable`, the function throws an `Error`, as the property **cannot** be deleted from the _source_ `object`. - -
- - - -
- -## Examples - - - -```javascript -var moveProperty = require( '@stdlib/utils/move-property' ); - -var obj1 = { - 'beep': 'boop' -}; - -var obj2 = { - 'foo': 'bar' -}; - -var bool = moveProperty( obj1, 'beep', obj2 ); -if ( bool === false ) { - console.log( 'failed to move property' ); -} -console.dir( obj1 ); -/* => - {} -*/ -console.dir( obj2 ); -/* => - { - 'foo': 'bar', - 'beep': 'boop' - } -*/ -``` - -
- - - - - - - - - - - - - - diff --git a/lib/node_modules/@stdlib/utils/move-property/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/move-property/benchmark/benchmark.js deleted file mode 100644 index 9e3f3b98ac58..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/benchmark/benchmark.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 randu = require( '@stdlib/random/base/randu' ); -var pkg = require( './../package.json' ).name; -var moveProperty = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var obj1; - var obj2; - var out; - var i; - - obj1 = { - 'A': 'beep', - 'B': 'boop' - }; - obj2 = { - 'foo': 'bar', - 'c': randu() - }; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj2.c = randu(); - out = moveProperty( obj2, 'foo', obj1 ); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return an boolean' ); - } - out = moveProperty( obj1, 'foo', obj2 ); - } - b.toc(); - if ( typeof out !== 'boolean' ) { - b.fail( 'should return an boolean' ); - } - if ( typeof obj2.foo !== 'string' ) { - b.fail( 'should move property back to source object' ); - } - if ( obj1.foo ) { - b.fail( 'should delete property' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/lib/node_modules/@stdlib/utils/move-property/docs/repl.txt b/lib/node_modules/@stdlib/utils/move-property/docs/repl.txt deleted file mode 100644 index 9b908c75131c..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/docs/repl.txt +++ /dev/null @@ -1,38 +0,0 @@ - -{{alias}}( source, prop, target ) - Moves a property from one object to another object. - - The property is deleted from the source object and the property's descriptor - is preserved during transfer. - - If a source property is not configurable, the function throws an error, as - the property cannot be deleted from the source object. - - Parameters - ---------- - source: Object - Source object. - - prop: string - Property to move. - - target: Object - Target object. - - Returns - ------- - bool: boolean - Boolean indicating whether operation was successful. - - Examples - -------- - > var obj1 = { 'a': 'b' }; - > var obj2 = {}; - > var bool = {{alias}}( obj1, 'a', obj2 ) - true - > bool = {{alias}}( obj1, 'c', obj2 ) - false - - See Also - -------- - diff --git a/lib/node_modules/@stdlib/utils/move-property/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/move-property/docs/types/index.d.ts deleted file mode 100644 index 3dcbdbcec16a..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/docs/types/index.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 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 - -/** -* Moves a property from one object to another object. -* -* ## Notes -* -* - The property is deleted from the source object and the property's descriptor is preserved during transfer. -* - If a source property is not configurable, the function throws an error, as the property cannot be deleted from the source object. -* -* @param source - source object -* @param prop - property to move -* @param target - target object -* @returns boolean indicating whether operation was successful -* -* @example -* var obj1 = { 'a': 'b' }; -* var obj2 = {}; -* -* var bool = moveProperty( obj1, 'a', obj2 ); -* // returns true -* -* @example -* var obj1 = { 'a': 'b' }; -* var obj2 = {}; -* -* var bool = moveProperty( obj1, 'c', obj2 ); -* // returns false -*/ -declare function moveProperty( source: any, prop: string, target: any ): boolean; - - -// EXPORTS // - -export = moveProperty; diff --git a/lib/node_modules/@stdlib/utils/move-property/docs/types/test.ts b/lib/node_modules/@stdlib/utils/move-property/docs/types/test.ts deleted file mode 100644 index a1ec2c5da5d2..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/docs/types/test.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2019 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 moveProperty = require( './index' ); - - -// TESTS // - -// The function returns a boolean... -{ - moveProperty( { 'a': 'b' }, 'a', {} ); // $ExpectType boolean - moveProperty( { 'a': 'b' }, 'a', {} ); // $ExpectType boolean -} - -// The compiler throws an error if the function is not provided a string as its second argument... -{ - moveProperty( { 'a': 'b' }, true, {} ); // $ExpectError - moveProperty( { 'a': 'b' }, 3.12, {} ); // $ExpectError - moveProperty( { 'a': 'b' }, false, {} ); // $ExpectError - moveProperty( { 'a': 'b' }, ( x: number ): number => x, {} ); // $ExpectError - moveProperty( { 'a': 'b' }, [], {} ); // $ExpectError - moveProperty( { 'a': 'b' }, {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an incorrect number of arguments... -{ - moveProperty(); // $ExpectError - moveProperty( { 'a': 'b' } ); // $ExpectError - moveProperty( { 'a': 'b' }, 'a' ); // $ExpectError - moveProperty( { 'a': 'b' }, 'a', {}, 3.12 ); // $ExpectError -} diff --git a/lib/node_modules/@stdlib/utils/move-property/examples/index.js b/lib/node_modules/@stdlib/utils/move-property/examples/index.js deleted file mode 100644 index 929e260ac764..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/examples/index.js +++ /dev/null @@ -1,45 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 moveProperty = require( './../lib' ); - -var obj1 = { - 'beep': 'boop' -}; - -var obj2 = { - 'foo': 'bar' -}; - -var bool = moveProperty( obj1, 'beep', obj2 ); -if ( bool === false ) { - console.log( 'failed to move property' ); -} -console.dir( obj1 ); -/* => - {} -*/ -console.dir( obj2 ); -/* => - { - 'foo': 'bar', - 'beep': 'boop' - } -*/ diff --git a/lib/node_modules/@stdlib/utils/move-property/lib/index.js b/lib/node_modules/@stdlib/utils/move-property/lib/index.js deleted file mode 100644 index f3819911bfe5..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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'; - -/** -* Move a property from one object to another object. -* -* @module @stdlib/utils/move-property -* -* @example -* var moveProperty = require( '@stdlib/utils/move-property' ); -* -* var obj1 = { 'a': 'b' }; -* var obj2 = {}; -* -* var bool = moveProperty( obj1, 'a', obj2 ); -* // returns true -* -* bool = moveProperty( obj1, 'c', obj2 ); -* // returns false -*/ - -// MODULES // - -var moveProperty = require( './main.js' ); - - -// EXPORTS // - -module.exports = moveProperty; diff --git a/lib/node_modules/@stdlib/utils/move-property/lib/main.js b/lib/node_modules/@stdlib/utils/move-property/lib/main.js deleted file mode 100644 index f144b75cde7e..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/lib/main.js +++ /dev/null @@ -1,74 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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 defineProperty = require( '@stdlib/utils/define-property' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Moves a property from one object to another object. -* -* @param {Object} source - source object -* @param {string} prop - property to move -* @param {Object} target - target object -* @throws {TypeError} first argument must be an object -* @throws {TypeError} third argument must be an object -* @returns {boolean} boolean indicating whether operation was successful -* -* @example -* var obj1 = { 'a': 'b' }; -* var obj2 = {}; -* -* var bool = moveProperty( obj1, 'a', obj2 ); -* // returns true -* -* @example -* var obj1 = { 'a': 'b' }; -* var obj2 = {}; -* -* var bool = moveProperty( obj1, 'c', obj2 ); -* // returns false -*/ -function moveProperty( source, prop, target ) { - var desc; - if ( typeof source !== 'object' || source === null ) { - throw new TypeError( format( 'invalid argument. Source argument must be an object. Value: `%s`.', source ) ); - } - if ( typeof target !== 'object' || target === null ) { - throw new TypeError( format( 'invalid argument. Target argument must be an object. Value: `%s`.', target ) ); - } - // TODO: handle case where gOPD is not supported - desc = Object.getOwnPropertyDescriptor( source, prop ); - if ( desc === void 0 ) { - return false; - } - delete source[ prop ]; - defineProperty( target, prop, desc ); - return true; -} - - -// EXPORTS // - -module.exports = moveProperty; diff --git a/lib/node_modules/@stdlib/utils/move-property/package.json b/lib/node_modules/@stdlib/utils/move-property/package.json deleted file mode 100644 index bb71ed997ccb..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/package.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "name": "@stdlib/utils/move-property", - "version": "0.0.0", - "description": "Move a property from one object to another object.", - "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", - "stdutils", - "stdutil", - "util", - "utils", - "utility", - "utilities", - "move", - "copy", - "property", - "prop", - "object", - "transfer", - "cp", - "mv", - "obj" - ] -} diff --git a/lib/node_modules/@stdlib/utils/move-property/test/test.js b/lib/node_modules/@stdlib/utils/move-property/test/test.js deleted file mode 100644 index 4d17226be47d..000000000000 --- a/lib/node_modules/@stdlib/utils/move-property/test/test.js +++ /dev/null @@ -1,184 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2018 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. -*/ - -/* eslint-disable object-curly-newline */ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var defineProperty = require( '@stdlib/utils/define-property' ); -var moveProperty = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof moveProperty, 'function', 'export is a function' ); - t.end(); -}); - -tape( 'if provided a `source` argument which is not an object, the function will throw', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided ' + (typeof values[i]) ); - } - t.end(); - function badValue( value ) { - return function badValue() { - moveProperty( value, 'a', {} ); - }; - } -}); - -tape( 'if provided a `target` argument which is not an object, the function will throw', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true, - false - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws type error when provided ' + (typeof values[i]) ); - } - t.end(); - function badValue( value ) { - return function badValue() { - moveProperty( {}, 'a', value ); - }; - } -}); - -tape( 'if unable to move a property, the function returns `false`', function test( t ) { - var bool = moveProperty( {}, 'a', {} ); - t.notOk( bool, 'unable to move property' ); - t.end(); -}); - -tape( 'if moving a property is successful, the function returns `true`', function test( t ) { - var bool = moveProperty({ 'a': 'b' }, 'a', {} ); - t.ok( bool, 'successfully moved property' ); - t.end(); -}); - -tape( 'the function moves property a from one object to another object', function test( t ) { - var obj1 = { 'a': 'b' }; - var obj2 = {}; - var bool = moveProperty( obj1, 'a', obj2 ); - - t.ok( bool, 'successfully moved property' ); - t.deepEqual( obj2, { 'a': 'b' }, 'deep equal' ); - t.deepEqual( obj1, {}, 'deep equal' ); - t.end(); -}); - -tape( 'the function deletes a property from the source object', function test( t ) { - var obj1 = { 'a': 'b' }; - var obj2 = {}; - var bool = moveProperty( obj1, 'a', obj2 ); - - t.ok( bool, 'successfully moved property' ); - t.deepEqual( obj1, {}, 'deep equal' ); - t.end(); -}); - -tape( 'the function preserves property\'s descriptors', function test( t ) { - var obj1 = {}; - var obj2 = {}; - var bool; - var desc; - - desc = { - 'value': 'b', - 'writable': false, - 'configurable': true, - 'enumerable': false - }; - - defineProperty( obj1, 'a', desc ); - - bool = moveProperty( obj1, 'a', obj2 ); - - t.ok( bool, 'successfully moved property' ); - t.deepEqual( obj1, {}, 'deep equal' ); - t.strictEqual( obj2.a, 'b' ); - t.deepEqual( Object.getOwnPropertyDescriptor( obj2, 'a' ), desc, 'descriptors are equal' ); - - t.end(); -}); - -tape( 'if a property cannot be deleted from a source object, the function throws an error', function test( t ) { - var obj1 = {}; - var obj2 = {}; - var desc; - - desc = { - 'value': 'b', - 'writable': false, - 'configurable': false, - 'enumerable': false - }; - - defineProperty( obj1, 'a', desc ); - - t.throws( foo, Error ); - t.end(); - function foo() { - moveProperty( obj1, 'a', obj2 ); - } -}); - -tape( 'the function does not deep copy moved properties', function test( t ) { - var bool; - var obj1; - var obj2; - var arr; - - arr = [ 1, 2, 3 ]; - obj1 = { 'a': arr }; - obj2 = {}; - bool = moveProperty( obj1, 'a', obj2 ); - - t.ok( bool, 'successfully moved property' ); - t.deepEqual( obj2, { 'a': arr }, 'deep equal' ); - t.deepEqual( obj1, {}, 'deep equal' ); - t.strictEqual( obj2.a, arr, 'same reference' ); - - t.end(); -});