From 552b4a40c30b0f7ca3ac09983c520a71e22930ed Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Wed, 10 Dec 2025 13:04:33 +0530 Subject: [PATCH 1/4] feat: add `object/capitalize-keys` Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/object/capitalize-keys/README.md | 139 +++++++++++++ .../capitalize-keys/benchmark/benchmark.js | 57 ++++++ .../object/capitalize-keys/docs/repl.txt | 28 +++ .../capitalize-keys/docs/types/index.d.ts | 46 +++++ .../object/capitalize-keys/docs/types/test.ts | 33 +++ .../object/capitalize-keys/examples/index.js | 33 +++ .../object/capitalize-keys/lib/index.js | 45 ++++ .../object/capitalize-keys/lib/main.js | 69 +++++++ .../object/capitalize-keys/package.json | 76 +++++++ .../object/capitalize-keys/test/test.js | 193 ++++++++++++++++++ 10 files changed, 719 insertions(+) create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/README.md create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/examples/index.js create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/lib/index.js create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/lib/main.js create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/package.json create mode 100644 lib/node_modules/@stdlib/object/capitalize-keys/test/test.js diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/README.md b/lib/node_modules/@stdlib/object/capitalize-keys/README.md new file mode 100644 index 000000000000..ba83a6f72a6e --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/README.md @@ -0,0 +1,139 @@ + + +# capitalizeKeys + +> Convert the first letter of each object key to uppercase. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var capitalizeKeys = require( '@stdlib/object/capitalize-keys' ); +``` + +#### capitalizeKeys( obj ) + +Converts the first letter of each `object` key to uppercase, mapping the transformed keys to a new `object` having the same values. + +```javascript +var obj1 = { + 'beepBoop': 1, + 'fooBar': 2 +}; + +var obj2 = capitalizeKeys( obj1 ); +// returns { 'BeepBoop': 1, 'FooBar': 2 } +``` + +
+ + + + + +
+ +## Notes + +- The function only transforms **own** properties. Hence, the function does **not** transform inherited properties. +- The function **shallow** copies key values. + +
+ + + + + +
+ +## Examples + + + +```javascript +var capitalizeKeys = require( '@stdlib/object/capitalize-keys' ); + +var obj1 = { + 'aa': 'beep', + 'bb': 'boop', + 'cc': 'foo', + 'dd': 'bar' +}; + +var obj2 = capitalizeKeys( obj1 ); + +console.dir( obj2 ); +// => { 'Aa': 'beep', 'Bb': 'boop', 'Cc': 'foo', 'Dd': 'bar' } +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/benchmark/benchmark.js b/lib/node_modules/@stdlib/object/capitalize-keys/benchmark/benchmark.js new file mode 100644 index 000000000000..ae8eda8838a1 --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/benchmark/benchmark.js @@ -0,0 +1,57 @@ +/** +* @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 capitalizeKeys = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var obj; + var out; + var i; + + obj = { + 'aa': 'beep', + 'bb': 'boop', + 'cc': 'foo', + 'dd': 'bar', + 'ee': randu() + }; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + obj.ee = randu(); + out = capitalizeKeys( obj ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/docs/repl.txt b/lib/node_modules/@stdlib/object/capitalize-keys/docs/repl.txt new file mode 100644 index 000000000000..0c79d16d77fd --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( obj ) + Converts the first letter of each object key to uppercase. + + The function only transforms own properties. Hence, the function does not + transform inherited properties. + + The function shallow copies key values. + + Parameters + ---------- + obj: Object + Source object. + + Returns + ------- + out: Object + New object. + + Examples + -------- + > var obj = { 'aa': 1, 'bb': 2 }; + > var out = {{alias}}( obj ) + { 'Aa': 1, 'Bb': 2 } + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/docs/types/index.d.ts b/lib/node_modules/@stdlib/object/capitalize-keys/docs/types/index.d.ts new file mode 100644 index 000000000000..bcd676beeb88 --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/docs/types/index.d.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. +*/ + +// TypeScript Version: 4.1 + +/** +* Converts the first letter of each object key to uppercase. +* +* ## Notes +* +* - The function only transforms own properties. Hence, the function does not transform inherited properties. +* - The function shallow copies key values. +* +* @param obj - source object +* @returns new object +* +* @example +* var obj1 = { +* 'aa': 1, +* 'bb': 2 +* }; +* +* var obj2 = capitalizeKeys( obj1 ); +* // returns { 'Aa': 1, 'Bb': 2 } +*/ +declare function capitalizeKeys( obj: Object ): Object; + + +// EXPORTS // + +export = capitalizeKeys; diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/docs/types/test.ts b/lib/node_modules/@stdlib/object/capitalize-keys/docs/types/test.ts new file mode 100644 index 000000000000..741e118a8460 --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/docs/types/test.ts @@ -0,0 +1,33 @@ +/* +* @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 capitalizeKeys = require( './index' ); + + +// TESTS // + +// The function returns an object... +{ + capitalizeKeys( { 'a': 1, 'b': 2 } ); // $ExpectType Object +} + +// The compiler throws an error if the function is provided an incorrect number of arguments... +{ + capitalizeKeys(); // $ExpectError + capitalizeKeys( [], 2 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/examples/index.js b/lib/node_modules/@stdlib/object/capitalize-keys/examples/index.js new file mode 100644 index 000000000000..e92bfd6e0b61 --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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 capitalizeKeys = require( './../lib' ); + +var obj1 = { + 'aa': 'beep', + 'bb': 'boop', + 'cc': 'foo', + 'dd': 'bar' +}; + +var obj2 = capitalizeKeys( obj1 ); + +console.dir( obj2 ); +// => { 'Aa': 'beep', 'Bb': 'boop', 'Cc': 'foo', 'Dd': 'bar' } diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/lib/index.js b/lib/node_modules/@stdlib/object/capitalize-keys/lib/index.js new file mode 100644 index 000000000000..42a2ef6b220c --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/lib/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'; + +/** +* Convert the first letter of each object key to uppercase. +* +* @module @stdlib/object/capitalize-keys +* +* @example +* var capitalizeKeys = require( '@stdlib/object/capitalize-keys' ); +* +* var obj1 = { +* 'aa': 1, +* 'bb': 2 +* }; +* +* var obj2 = capitalizeKeys( obj1 ); +* // returns { 'Aa': 1, 'Bb': 2 } +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/lib/main.js b/lib/node_modules/@stdlib/object/capitalize-keys/lib/main.js new file mode 100644 index 000000000000..d8497461bdef --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/lib/main.js @@ -0,0 +1,69 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Converts the first letter of each object key to uppercase. +* +* @param {Object} obj - source object +* @throws {TypeError} must provide an object +* @returns {Object} new object +* +* @example +* var obj1 = { +* 'aa': 1, +* 'bb': 2 +* }; +* +* var obj2 = capitalizeKeys( obj1 ); +* // returns { 'Aa': 1, 'Bb': 2 } +*/ +function capitalizeKeys( obj ) { + var out; + var key; + var k; + if ( typeof obj !== 'object' || obj === null ) { + throw new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', obj ) ); + } + out = {}; + for ( key in obj ) { + if ( hasOwnProp( obj, key ) ) { + if ( key === '' ) { + out[ key ] = obj[ key ]; + } else { + k = key.charAt( 0 ).toUpperCase() + key.slice( 1 ); + out[ k ] = obj[ key ]; + } + } + } + return out; +} + + +// EXPORTS // + +module.exports = capitalizeKeys; diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/package.json b/lib/node_modules/@stdlib/object/capitalize-keys/package.json new file mode 100644 index 000000000000..0f6dafefb475 --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/package.json @@ -0,0 +1,76 @@ +{ + "name": "@stdlib/object/capitalize-keys", + "version": "0.0.0", + "description": "Convert the first letter of each object key to uppercase.", + "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", + "utilities", + "utility", + "utils", + "util", + "map", + "transform", + "capitalize", + "uppercase", + "first", + "copy", + "cp", + "clone", + "extract", + "property", + "props", + "properties", + "keys", + "object", + "array", + "obj" + ] +} diff --git a/lib/node_modules/@stdlib/object/capitalize-keys/test/test.js b/lib/node_modules/@stdlib/object/capitalize-keys/test/test.js new file mode 100644 index 000000000000..71ed12f666c3 --- /dev/null +++ b/lib/node_modules/@stdlib/object/capitalize-keys/test/test.js @@ -0,0 +1,193 @@ +/** +* @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 tape = require( 'tape' ); +var capitalizeKeys = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof capitalizeKeys, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a source object argument which is not an object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + null, + void 0, + true + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + capitalizeKeys( value ); + }; + } +}); + +tape( 'the function uppercases the first letter of each key from a source object, mapping the transformed keys to a destination object having the same key values', function test( t ) { + var expected; + var obj1; + var obj2; + + obj1 = { + '': 0, + 'Beep': 3.14, + ' boop': -1.0, + 'aa': 1, + 'bb': 2, + 'cc': 3, + 'dd': 4, + 'ee': 5 + }; + + obj2 = capitalizeKeys( obj1 ); + + expected = { + '': 0, + 'Beep': 3.14, + ' boop': -1.0, + 'Aa': 1, + 'Bb': 2, + 'Cc': 3, + 'Dd': 4, + 'Ee': 5 + }; + + t.deepEqual( obj2, expected, 'returns expected object' ); + t.end(); +}); + +tape( 'the function ignores inherited properties', function test( t ) { + var expected; + var obj1; + var obj2; + + function Foo() { + this.aa = 1; + this.bb = 2; + this.cc = 3; + this.dd = 4; + this.ee = 5; + return this; + } + + Foo.prototype.ff = 6; + Foo.prototype.gg = 7; + + obj1 = new Foo(); + + obj2 = capitalizeKeys( obj1 ); + + expected = { + 'Aa': 1, + 'Bb': 2, + 'Cc': 3, + 'Dd': 4, + 'Ee': 5 + }; + + t.deepEqual( obj2, expected, 'returns expected object' ); + t.end(); +}); + +tape( 'the function accepts non-plain objects', function test( t ) { + var expected; + var obj1; + var obj2; + + obj1 = [ 0, 1, 2, 3, 4, 5 ]; + + obj2 = capitalizeKeys( obj1 ); + + expected = { + '0': 0, + '1': 1, + '2': 2, + '3': 3, + '4': 4, + '5': 5 + }; + + t.deepEqual( obj2, expected, 'returns expected object' ); + t.end(); +}); + +tape( 'the function shallow copies key values', function test( t ) { + var expected; + var obj1; + var obj2; + + obj1 = { + 'aa': [ 1 ], + 'bb': [ 2 ], + 'cc': [ 3 ], + 'dd': [ 4 ], + 'ee': [ 5 ] + }; + + obj2 = capitalizeKeys( obj1 ); + + expected = { + 'Aa': obj1.aa, + 'Bb': obj1.bb, + 'Cc': obj1.cc, + 'Dd': obj1.dd, + 'Ee': obj1.ee + }; + + t.deepEqual( obj2, expected, 'returns expected object' ); + t.strictEqual( obj2.Aa, obj1.aa, 'returns shallow copy' ); + t.strictEqual( obj2.Bb, obj1.bb, 'returns shallow copy' ); + t.strictEqual( obj2.Cc, obj1.cc, 'returns shallow copy' ); + t.strictEqual( obj2.Dd, obj1.dd, 'returns shallow copy' ); + t.strictEqual( obj2.Ee, obj1.ee, 'returns shallow copy' ); + + t.end(); +}); + +tape( 'if provided an empty object, the function returns an empty object', function test( t ) { + var expected; + var obj1; + var obj2; + + obj1 = {}; + expected = {}; + + obj2 = capitalizeKeys( obj1 ); + + t.deepEqual( obj2, expected, 'returns expected object' ); + t.end(); +}); From f4107b34db32b826041abf64eb6ee3c7f03437f9 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Wed, 10 Dec 2025 13:06:26 +0530 Subject: [PATCH 2/4] remove: remove `capitalizeKeys` from namespace This commit removes the `capitalizeKeys` symbol from the `@stdlib/utils` namespace due to a package migration. BREAKING CHANGE: remove `capitalizeKeys` 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 | 23 ------------------- lib/node_modules/@stdlib/utils/lib/index.js | 9 -------- 2 files changed, 32 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 e7788a598422..45c0a22fd824 100644 --- a/lib/node_modules/@stdlib/utils/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/docs/types/index.d.ts @@ -30,7 +30,6 @@ import bifurcate = require( '@stdlib/utils/bifurcate' ); import bifurcateBy = require( '@stdlib/utils/bifurcate-by' ); import bifurcateIn = require( '@stdlib/utils/bifurcate-in' ); import bifurcateOwn = require( '@stdlib/utils/bifurcate-own' ); -import capitalizeKeys = require( '@stdlib/utils/capitalize-keys' ); import commonKeys = require( '@stdlib/utils/common-keys' ); import commonKeysIn = require( '@stdlib/utils/common-keys-in' ); import compose = require( '@stdlib/utils/compose' ); @@ -577,28 +576,6 @@ interface Namespace { */ bifurcateOwn: typeof bifurcateOwn; - /** - * Converts the first letter of each object key to uppercase. - * - * ## Notes - * - * - The function only transforms own properties. Hence, the function does not transform inherited properties. - * - The function shallow copies key values. - * - * @param obj - source object - * @returns new object - * - * @example - * var obj1 = { - * 'aa': 1, - * 'bb': 2 - * }; - * - * var obj2 = ns.capitalizeKeys( obj1 ); - * // returns { 'Aa': 1, 'Bb': 2 } - */ - capitalizeKeys: typeof capitalizeKeys; - /** * Returns the common own property names of two or more objects. * diff --git a/lib/node_modules/@stdlib/utils/lib/index.js b/lib/node_modules/@stdlib/utils/lib/index.js index b17dc4575c18..e5aa84484937 100644 --- a/lib/node_modules/@stdlib/utils/lib/index.js +++ b/lib/node_modules/@stdlib/utils/lib/index.js @@ -130,15 +130,6 @@ setReadOnly( utils, 'bifurcateIn', require( '@stdlib/utils/bifurcate-in' ) ); */ setReadOnly( utils, 'bifurcateOwn', require( '@stdlib/utils/bifurcate-own' ) ); -/** -* @name capitalizeKeys -* @memberof utils -* @readonly -* @type {Function} -* @see {@link module:@stdlib/utils/capitalize-keys} -*/ -setReadOnly( utils, 'capitalizeKeys', require( '@stdlib/utils/capitalize-keys' ) ); - /** * @name commonKeys * @memberof utils From 33f4db531ade2dcc55646d9b01fdbc34374aee67 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Wed, 10 Dec 2025 13:11:12 +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/c.js | 4 ++-- lib/node_modules/@stdlib/namespace/lib/namespace/u.js | 4 ++-- lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv | 2 +- .../@stdlib/namespace/pkg2related/data/data.csv | 6 +++--- .../@stdlib/namespace/pkg2standalone/data/data.csv | 2 +- .../@stdlib/namespace/standalone2pkg/data/data.csv | 2 +- lib/node_modules/@stdlib/utils/uncapitalize-keys/README.md | 4 ++-- lib/node_modules/@stdlib/utils/uppercase-keys/README.md | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv index 8be5109bab1f..f96bcc9fd7c9 100644 --- a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv @@ -1511,7 +1511,7 @@ buffer2json,"@stdlib/buffer/to-json" BYTE_ORDER,"@stdlib/os/byte-order" camelcase,"@stdlib/string/camelcase" capitalize,"@stdlib/string/capitalize" -capitalizeKeys,"@stdlib/utils/capitalize-keys" +capitalizeKeys,"@stdlib/object/capitalize-keys" CATALAN,"@stdlib/constants/float64/catalan" CBRT_EPS,"@stdlib/constants/float64/cbrt-eps" CDC_NCHS_US_BIRTHS_1969_1988,"@stdlib/datasets/cdc-nchs-us-births-1969-1988" diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/c.js b/lib/node_modules/@stdlib/namespace/lib/namespace/c.js index 0eb17babf2d1..f8bbb3d2a45e 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/c.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/c.js @@ -54,8 +54,8 @@ ns.push({ ns.push({ 'alias': 'capitalizeKeys', - 'path': '@stdlib/utils/capitalize-keys', - 'value': require( '@stdlib/utils/capitalize-keys' ), + 'path': '@stdlib/object/capitalize-keys', + 'value': require( '@stdlib/object/capitalize-keys' ), 'type': 'Function', 'related': [ '@stdlib/utils/uncapitalize-keys', diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/u.js b/lib/node_modules/@stdlib/namespace/lib/namespace/u.js index c14142045aee..a4cb3b2bbb15 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/u.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/u.js @@ -193,7 +193,7 @@ ns.push({ 'value': require( '@stdlib/utils/uncapitalize-keys' ), 'type': 'Function', 'related': [ - '@stdlib/utils/capitalize-keys', + '@stdlib/object/capitalize-keys', '@stdlib/utils/lowercase-keys' ] }); @@ -439,7 +439,7 @@ ns.push({ 'value': require( '@stdlib/utils/uppercase-keys' ), 'type': 'Function', 'related': [ - '@stdlib/utils/capitalize-keys', + '@stdlib/object/capitalize-keys', '@stdlib/utils/lowercase-keys' ] }); diff --git a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv index f660338aa683..0f3be9d75584 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv @@ -1511,7 +1511,7 @@ "@stdlib/os/byte-order",BYTE_ORDER "@stdlib/string/camelcase",camelcase "@stdlib/string/capitalize",capitalize -"@stdlib/utils/capitalize-keys",capitalizeKeys +"@stdlib/object/capitalize-keys",capitalizeKeys "@stdlib/constants/float64/catalan",CATALAN "@stdlib/constants/float64/cbrt-eps",CBRT_EPS "@stdlib/datasets/cdc-nchs-us-births-1969-1988",CDC_NCHS_US_BIRTHS_1969_1988 diff --git a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv index 1a9e75d0033f..c5f486a5bc4e 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv @@ -1511,7 +1511,7 @@ "@stdlib/os/byte-order","@stdlib/assert/is-big-endian,@stdlib/assert/is-little-endian" "@stdlib/string/camelcase","@stdlib/string/constantcase,@stdlib/string/kebabcase,@stdlib/string/pascalcase,@stdlib/string/snakecase" "@stdlib/string/capitalize","@stdlib/string/uncapitalize,@stdlib/string/uppercase" -"@stdlib/utils/capitalize-keys","@stdlib/utils/uncapitalize-keys,@stdlib/utils/uppercase-keys" +"@stdlib/object/capitalize-keys","@stdlib/utils/uncapitalize-keys,@stdlib/utils/uppercase-keys" "@stdlib/constants/float64/catalan","" "@stdlib/constants/float64/cbrt-eps","@stdlib/constants/float64/eps,@stdlib/constants/float64/sqrt-eps" "@stdlib/datasets/cdc-nchs-us-births-1969-1988","@stdlib/datasets/cdc-nchs-us-births-1994-2003,@stdlib/datasets/ssa-us-births-2000-2014" @@ -3108,7 +3108,7 @@ "@stdlib/array/uint32","@stdlib/array/buffer,@stdlib/array/float32,@stdlib/array/float64,@stdlib/array/int16,@stdlib/array/int32,@stdlib/array/int8,@stdlib/array/uint16,@stdlib/array/uint8,@stdlib/array/uint8c" "@stdlib/process/umask","" "@stdlib/string/uncapitalize","@stdlib/string/capitalize,@stdlib/string/lowercase" -"@stdlib/utils/uncapitalize-keys","@stdlib/utils/capitalize-keys,@stdlib/utils/lowercase-keys" +"@stdlib/utils/uncapitalize-keys","@stdlib/object/capitalize-keys,@stdlib/utils/lowercase-keys" "@stdlib/utils/uncurry","@stdlib/utils/curry,@stdlib/utils/uncurry-right" "@stdlib/utils/uncurry-right","@stdlib/utils/curry,@stdlib/utils/curry-right,@stdlib/utils/uncurry" "@stdlib/constants/unicode/max","@stdlib/constants/unicode/max-bmp" @@ -3127,7 +3127,7 @@ "@stdlib/utils/until-each-right","@stdlib/utils/until-each,@stdlib/utils/while-each-right" "@stdlib/utils/unzip","@stdlib/utils/zip" "@stdlib/string/uppercase","@stdlib/string/capitalize,@stdlib/string/lowercase" -"@stdlib/utils/uppercase-keys","@stdlib/utils/capitalize-keys,@stdlib/utils/lowercase-keys" +"@stdlib/utils/uppercase-keys","@stdlib/object/capitalize-keys,@stdlib/utils/lowercase-keys" "@stdlib/datasets/us-states-abbr","@stdlib/datasets/us-states-capitals,@stdlib/datasets/us-states-names" "@stdlib/datasets/us-states-capitals","@stdlib/datasets/us-states-abbr,@stdlib/datasets/us-states-capitals-names,@stdlib/datasets/us-states-names,@stdlib/datasets/us-states-names-capitals" "@stdlib/datasets/us-states-capitals-names","@stdlib/datasets/us-states-capitals,@stdlib/datasets/us-states-names,@stdlib/datasets/us-states-names-capitals" diff --git a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv index bcb679b150c4..b1e07e1dd2dd 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv @@ -1511,7 +1511,7 @@ "@stdlib/os/byte-order","@stdlib/os-byte-order" "@stdlib/string/camelcase","@stdlib/string-camelcase" "@stdlib/string/capitalize","@stdlib/string-capitalize" -"@stdlib/utils/capitalize-keys","@stdlib/utils-capitalize-keys" +"@stdlib/object/capitalize-keys","@stdlib/object-capitalize-keys" "@stdlib/constants/float64/catalan","@stdlib/constants-float64-catalan" "@stdlib/constants/float64/cbrt-eps","@stdlib/constants-float64-cbrt-eps" "@stdlib/datasets/cdc-nchs-us-births-1969-1988","@stdlib/datasets-cdc-nchs-us-births-1969-1988" diff --git a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv index a610ed52fc56..9e24647fe6af 100644 --- a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv @@ -1511,7 +1511,7 @@ "@stdlib/os-byte-order","@stdlib/os/byte-order" "@stdlib/string-camelcase","@stdlib/string/camelcase" "@stdlib/string-capitalize","@stdlib/string/capitalize" -"@stdlib/utils-capitalize-keys","@stdlib/utils/capitalize-keys" +"@stdlib/object-capitalize-keys","@stdlib/object/capitalize-keys" "@stdlib/constants-float64-catalan","@stdlib/constants/float64/catalan" "@stdlib/constants-float64-cbrt-eps","@stdlib/constants/float64/cbrt-eps" "@stdlib/datasets-cdc-nchs-us-births-1969-1988","@stdlib/datasets/cdc-nchs-us-births-1969-1988" diff --git a/lib/node_modules/@stdlib/utils/uncapitalize-keys/README.md b/lib/node_modules/@stdlib/utils/uncapitalize-keys/README.md index 16416233c2d3..e7035fabed5a 100644 --- a/lib/node_modules/@stdlib/utils/uncapitalize-keys/README.md +++ b/lib/node_modules/@stdlib/utils/uncapitalize-keys/README.md @@ -115,7 +115,7 @@ console.dir( obj2 ); ## See Also -- [`@stdlib/utils/capitalize-keys`][@stdlib/utils/capitalize-keys]: convert the first letter of each object key to uppercase. +- [`@stdlib/object/capitalize-keys`][@stdlib/object/capitalize-keys]: convert the first letter of each object key to uppercase. - [`@stdlib/utils/lowercase-keys`][@stdlib/utils/lowercase-keys]: convert each object key to lowercase. @@ -128,7 +128,7 @@ console.dir( obj2 ); -[@stdlib/utils/capitalize-keys]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/capitalize-keys +[@stdlib/object/capitalize-keys]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/object/capitalize-keys [@stdlib/utils/lowercase-keys]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/lowercase-keys diff --git a/lib/node_modules/@stdlib/utils/uppercase-keys/README.md b/lib/node_modules/@stdlib/utils/uppercase-keys/README.md index 1643a39e6830..62856b7235fa 100644 --- a/lib/node_modules/@stdlib/utils/uppercase-keys/README.md +++ b/lib/node_modules/@stdlib/utils/uppercase-keys/README.md @@ -115,7 +115,7 @@ console.dir( obj2 ); ## See Also -- [`@stdlib/utils/capitalize-keys`][@stdlib/utils/capitalize-keys]: convert the first letter of each object key to uppercase. +- [`@stdlib/object/capitalize-keys`][@stdlib/object/capitalize-keys]: convert the first letter of each object key to uppercase. - [`@stdlib/utils/lowercase-keys`][@stdlib/utils/lowercase-keys]: convert each object key to lowercase. @@ -128,7 +128,7 @@ console.dir( obj2 ); -[@stdlib/utils/capitalize-keys]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/capitalize-keys +[@stdlib/object/capitalize-keys]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/object/capitalize-keys [@stdlib/utils/lowercase-keys]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/lowercase-keys From ac119ef9dcb2afda918737eab17bc45540e4a1c0 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Wed, 10 Dec 2025 13:11:47 +0530 Subject: [PATCH 4/4] remove: remove `utils/capitalize-keys` This commit removes `@stdlib/utils/capitalize-keys` in favor of `@stdlib/object/capitalize-keys`. BREAKING CHANGE: remove `utils/capitalize-keys` To migrate, users should update their require/import paths to use `@stdlib/object/capitalize-keys` which provides the same API and implementation. Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/utils/capitalize-keys/README.md | 139 ------------- .../capitalize-keys/benchmark/benchmark.js | 57 ------ .../utils/capitalize-keys/docs/repl.txt | 28 --- .../capitalize-keys/docs/types/index.d.ts | 46 ----- .../utils/capitalize-keys/docs/types/test.ts | 33 --- .../utils/capitalize-keys/examples/index.js | 33 --- .../utils/capitalize-keys/lib/index.js | 45 ---- .../@stdlib/utils/capitalize-keys/lib/main.js | 69 ------- .../utils/capitalize-keys/package.json | 76 ------- .../utils/capitalize-keys/test/test.js | 193 ------------------ 10 files changed, 719 deletions(-) delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/README.md delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/benchmark/benchmark.js delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/docs/repl.txt delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/index.d.ts delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/test.ts delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/examples/index.js delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/lib/index.js delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/lib/main.js delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/package.json delete mode 100644 lib/node_modules/@stdlib/utils/capitalize-keys/test/test.js diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/README.md b/lib/node_modules/@stdlib/utils/capitalize-keys/README.md deleted file mode 100644 index 4c8bbb010105..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/README.md +++ /dev/null @@ -1,139 +0,0 @@ - - -# capitalizeKeys - -> Convert the first letter of each object key to uppercase. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var capitalizeKeys = require( '@stdlib/utils/capitalize-keys' ); -``` - -#### capitalizeKeys( obj ) - -Converts the first letter of each `object` key to uppercase, mapping the transformed keys to a new `object` having the same values. - -```javascript -var obj1 = { - 'beepBoop': 1, - 'fooBar': 2 -}; - -var obj2 = capitalizeKeys( obj1 ); -// returns { 'BeepBoop': 1, 'FooBar': 2 } -``` - -
- - - - - -
- -## Notes - -- The function only transforms **own** properties. Hence, the function does **not** transform inherited properties. -- The function **shallow** copies key values. - -
- - - - - -
- -## Examples - - - -```javascript -var capitalizeKeys = require( '@stdlib/utils/capitalize-keys' ); - -var obj1 = { - 'aa': 'beep', - 'bb': 'boop', - 'cc': 'foo', - 'dd': 'bar' -}; - -var obj2 = capitalizeKeys( obj1 ); - -console.dir( obj2 ); -// => { 'Aa': 'beep', 'Bb': 'boop', 'Cc': 'foo', 'Dd': 'bar' } -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/capitalize-keys/benchmark/benchmark.js deleted file mode 100644 index ae8eda8838a1..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/benchmark/benchmark.js +++ /dev/null @@ -1,57 +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 capitalizeKeys = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var obj; - var out; - var i; - - obj = { - 'aa': 'beep', - 'bb': 'boop', - 'cc': 'foo', - 'dd': 'bar', - 'ee': randu() - }; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj.ee = randu(); - out = capitalizeKeys( obj ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/docs/repl.txt b/lib/node_modules/@stdlib/utils/capitalize-keys/docs/repl.txt deleted file mode 100644 index 0c79d16d77fd..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/docs/repl.txt +++ /dev/null @@ -1,28 +0,0 @@ - -{{alias}}( obj ) - Converts the first letter of each object key to uppercase. - - The function only transforms own properties. Hence, the function does not - transform inherited properties. - - The function shallow copies key values. - - Parameters - ---------- - obj: Object - Source object. - - Returns - ------- - out: Object - New object. - - Examples - -------- - > var obj = { 'aa': 1, 'bb': 2 }; - > var out = {{alias}}( obj ) - { 'Aa': 1, 'Bb': 2 } - - See Also - -------- - diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/index.d.ts deleted file mode 100644 index bcd676beeb88..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/index.d.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. -*/ - -// TypeScript Version: 4.1 - -/** -* Converts the first letter of each object key to uppercase. -* -* ## Notes -* -* - The function only transforms own properties. Hence, the function does not transform inherited properties. -* - The function shallow copies key values. -* -* @param obj - source object -* @returns new object -* -* @example -* var obj1 = { -* 'aa': 1, -* 'bb': 2 -* }; -* -* var obj2 = capitalizeKeys( obj1 ); -* // returns { 'Aa': 1, 'Bb': 2 } -*/ -declare function capitalizeKeys( obj: Object ): Object; - - -// EXPORTS // - -export = capitalizeKeys; diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/test.ts b/lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/test.ts deleted file mode 100644 index 741e118a8460..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/docs/types/test.ts +++ /dev/null @@ -1,33 +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 capitalizeKeys = require( './index' ); - - -// TESTS // - -// The function returns an object... -{ - capitalizeKeys( { 'a': 1, 'b': 2 } ); // $ExpectType Object -} - -// The compiler throws an error if the function is provided an incorrect number of arguments... -{ - capitalizeKeys(); // $ExpectError - capitalizeKeys( [], 2 ); // $ExpectError -} diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/examples/index.js b/lib/node_modules/@stdlib/utils/capitalize-keys/examples/index.js deleted file mode 100644 index e92bfd6e0b61..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/examples/index.js +++ /dev/null @@ -1,33 +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 capitalizeKeys = require( './../lib' ); - -var obj1 = { - 'aa': 'beep', - 'bb': 'boop', - 'cc': 'foo', - 'dd': 'bar' -}; - -var obj2 = capitalizeKeys( obj1 ); - -console.dir( obj2 ); -// => { 'Aa': 'beep', 'Bb': 'boop', 'Cc': 'foo', 'Dd': 'bar' } diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/lib/index.js b/lib/node_modules/@stdlib/utils/capitalize-keys/lib/index.js deleted file mode 100644 index 3040c540ebad..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/lib/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'; - -/** -* Convert the first letter of each object key to uppercase. -* -* @module @stdlib/utils/capitalize-keys -* -* @example -* var capitalizeKeys = require( '@stdlib/utils/capitalize-keys' ); -* -* var obj1 = { -* 'aa': 1, -* 'bb': 2 -* }; -* -* var obj2 = capitalizeKeys( obj1 ); -* // returns { 'Aa': 1, 'Bb': 2 } -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/lib/main.js b/lib/node_modules/@stdlib/utils/capitalize-keys/lib/main.js deleted file mode 100644 index d8497461bdef..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/lib/main.js +++ /dev/null @@ -1,69 +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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Converts the first letter of each object key to uppercase. -* -* @param {Object} obj - source object -* @throws {TypeError} must provide an object -* @returns {Object} new object -* -* @example -* var obj1 = { -* 'aa': 1, -* 'bb': 2 -* }; -* -* var obj2 = capitalizeKeys( obj1 ); -* // returns { 'Aa': 1, 'Bb': 2 } -*/ -function capitalizeKeys( obj ) { - var out; - var key; - var k; - if ( typeof obj !== 'object' || obj === null ) { - throw new TypeError( format( 'invalid argument. Must provide an object. Value: `%s`.', obj ) ); - } - out = {}; - for ( key in obj ) { - if ( hasOwnProp( obj, key ) ) { - if ( key === '' ) { - out[ key ] = obj[ key ]; - } else { - k = key.charAt( 0 ).toUpperCase() + key.slice( 1 ); - out[ k ] = obj[ key ]; - } - } - } - return out; -} - - -// EXPORTS // - -module.exports = capitalizeKeys; diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/package.json b/lib/node_modules/@stdlib/utils/capitalize-keys/package.json deleted file mode 100644 index b7eb50637f8e..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/package.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "@stdlib/utils/capitalize-keys", - "version": "0.0.0", - "description": "Convert the first letter of each object key to uppercase.", - "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", - "utilities", - "utility", - "utils", - "util", - "map", - "transform", - "capitalize", - "uppercase", - "first", - "copy", - "cp", - "clone", - "extract", - "property", - "props", - "properties", - "keys", - "object", - "array", - "obj" - ] -} diff --git a/lib/node_modules/@stdlib/utils/capitalize-keys/test/test.js b/lib/node_modules/@stdlib/utils/capitalize-keys/test/test.js deleted file mode 100644 index 71ed12f666c3..000000000000 --- a/lib/node_modules/@stdlib/utils/capitalize-keys/test/test.js +++ /dev/null @@ -1,193 +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 tape = require( 'tape' ); -var capitalizeKeys = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof capitalizeKeys, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a source object argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - null, - void 0, - true - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - capitalizeKeys( value ); - }; - } -}); - -tape( 'the function uppercases the first letter of each key from a source object, mapping the transformed keys to a destination object having the same key values', function test( t ) { - var expected; - var obj1; - var obj2; - - obj1 = { - '': 0, - 'Beep': 3.14, - ' boop': -1.0, - 'aa': 1, - 'bb': 2, - 'cc': 3, - 'dd': 4, - 'ee': 5 - }; - - obj2 = capitalizeKeys( obj1 ); - - expected = { - '': 0, - 'Beep': 3.14, - ' boop': -1.0, - 'Aa': 1, - 'Bb': 2, - 'Cc': 3, - 'Dd': 4, - 'Ee': 5 - }; - - t.deepEqual( obj2, expected, 'returns expected object' ); - t.end(); -}); - -tape( 'the function ignores inherited properties', function test( t ) { - var expected; - var obj1; - var obj2; - - function Foo() { - this.aa = 1; - this.bb = 2; - this.cc = 3; - this.dd = 4; - this.ee = 5; - return this; - } - - Foo.prototype.ff = 6; - Foo.prototype.gg = 7; - - obj1 = new Foo(); - - obj2 = capitalizeKeys( obj1 ); - - expected = { - 'Aa': 1, - 'Bb': 2, - 'Cc': 3, - 'Dd': 4, - 'Ee': 5 - }; - - t.deepEqual( obj2, expected, 'returns expected object' ); - t.end(); -}); - -tape( 'the function accepts non-plain objects', function test( t ) { - var expected; - var obj1; - var obj2; - - obj1 = [ 0, 1, 2, 3, 4, 5 ]; - - obj2 = capitalizeKeys( obj1 ); - - expected = { - '0': 0, - '1': 1, - '2': 2, - '3': 3, - '4': 4, - '5': 5 - }; - - t.deepEqual( obj2, expected, 'returns expected object' ); - t.end(); -}); - -tape( 'the function shallow copies key values', function test( t ) { - var expected; - var obj1; - var obj2; - - obj1 = { - 'aa': [ 1 ], - 'bb': [ 2 ], - 'cc': [ 3 ], - 'dd': [ 4 ], - 'ee': [ 5 ] - }; - - obj2 = capitalizeKeys( obj1 ); - - expected = { - 'Aa': obj1.aa, - 'Bb': obj1.bb, - 'Cc': obj1.cc, - 'Dd': obj1.dd, - 'Ee': obj1.ee - }; - - t.deepEqual( obj2, expected, 'returns expected object' ); - t.strictEqual( obj2.Aa, obj1.aa, 'returns shallow copy' ); - t.strictEqual( obj2.Bb, obj1.bb, 'returns shallow copy' ); - t.strictEqual( obj2.Cc, obj1.cc, 'returns shallow copy' ); - t.strictEqual( obj2.Dd, obj1.dd, 'returns shallow copy' ); - t.strictEqual( obj2.Ee, obj1.ee, 'returns shallow copy' ); - - t.end(); -}); - -tape( 'if provided an empty object, the function returns an empty object', function test( t ) { - var expected; - var obj1; - var obj2; - - obj1 = {}; - expected = {}; - - obj2 = capitalizeKeys( obj1 ); - - t.deepEqual( obj2, expected, 'returns expected object' ); - t.end(); -});