@ohos-ports/stdlib-object 0.0.0-stage → 0.4.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +1 -0
  3. package/README.md +262 -2
  4. package/SECURITY.md +5 -0
  5. package/any-in-by/README.md +217 -0
  6. package/any-in-by/docs/repl.txt +41 -0
  7. package/any-in-by/docs/types/index.d.ts +102 -0
  8. package/any-in-by/docs/types/test.ts +53 -0
  9. package/any-in-by/lib/index.js +50 -0
  10. package/any-in-by/lib/main.js +75 -0
  11. package/any-in-by/package.json +66 -0
  12. package/any-own-by/README.md +221 -0
  13. package/any-own-by/docs/repl.txt +43 -0
  14. package/any-own-by/docs/types/index.d.ts +101 -0
  15. package/any-own-by/docs/types/test.ts +63 -0
  16. package/any-own-by/lib/index.js +46 -0
  17. package/any-own-by/lib/main.js +77 -0
  18. package/any-own-by/package.json +70 -0
  19. package/assign/README.md +139 -0
  20. package/assign/docs/repl.txt +34 -0
  21. package/assign/docs/types/index.d.ts +113 -0
  22. package/assign/docs/types/test.ts +47 -0
  23. package/assign/lib/builtin.js +55 -0
  24. package/assign/lib/has_object_assign.js +33 -0
  25. package/assign/lib/index.js +52 -0
  26. package/assign/lib/polyfill.js +86 -0
  27. package/assign/package.json +64 -0
  28. package/assign-in/README.md +145 -0
  29. package/assign-in/docs/repl.txt +34 -0
  30. package/assign-in/docs/types/index.d.ts +175 -0
  31. package/assign-in/docs/types/test.ts +44 -0
  32. package/assign-in/lib/index.js +54 -0
  33. package/assign-in/lib/main.js +92 -0
  34. package/assign-in/package.json +60 -0
  35. package/bifurcate-in/README.md +298 -0
  36. package/bifurcate-in/docs/repl.txt +68 -0
  37. package/bifurcate-in/docs/types/index.d.ts +189 -0
  38. package/bifurcate-in/docs/types/test.ts +97 -0
  39. package/bifurcate-in/lib/index.js +106 -0
  40. package/bifurcate-in/lib/main.js +148 -0
  41. package/bifurcate-in/lib/return_keys.js +81 -0
  42. package/bifurcate-in/lib/return_pairs.js +87 -0
  43. package/bifurcate-in/lib/return_values.js +87 -0
  44. package/bifurcate-in/lib/validate.js +76 -0
  45. package/bifurcate-in/package.json +72 -0
  46. package/bifurcate-own/README.md +255 -0
  47. package/bifurcate-own/docs/repl.txt +63 -0
  48. package/bifurcate-own/docs/types/index.d.ts +183 -0
  49. package/bifurcate-own/docs/types/test.ts +97 -0
  50. package/bifurcate-own/lib/index.js +87 -0
  51. package/bifurcate-own/lib/main.js +127 -0
  52. package/bifurcate-own/lib/return_keys.js +81 -0
  53. package/bifurcate-own/lib/return_pairs.js +87 -0
  54. package/bifurcate-own/lib/return_values.js +87 -0
  55. package/bifurcate-own/lib/validate.js +76 -0
  56. package/bifurcate-own/package.json +71 -0
  57. package/capitalize-keys/README.md +139 -0
  58. package/capitalize-keys/docs/repl.txt +28 -0
  59. package/capitalize-keys/docs/types/index.d.ts +46 -0
  60. package/capitalize-keys/docs/types/test.ts +33 -0
  61. package/capitalize-keys/lib/index.js +45 -0
  62. package/capitalize-keys/lib/main.js +69 -0
  63. package/capitalize-keys/package.json +76 -0
  64. package/common-keys/README.md +125 -0
  65. package/common-keys/docs/repl.txt +29 -0
  66. package/common-keys/docs/types/index.d.ts +70 -0
  67. package/common-keys/docs/types/test.ts +33 -0
  68. package/common-keys/lib/index.js +51 -0
  69. package/common-keys/lib/main.js +106 -0
  70. package/common-keys/package.json +70 -0
  71. package/common-keys-in/README.md +125 -0
  72. package/common-keys-in/docs/repl.txt +29 -0
  73. package/common-keys-in/docs/types/index.d.ts +70 -0
  74. package/common-keys-in/docs/types/test.ts +33 -0
  75. package/common-keys-in/lib/index.js +51 -0
  76. package/common-keys-in/lib/main.js +106 -0
  77. package/common-keys-in/package.json +72 -0
  78. package/ctor/README.md +536 -0
  79. package/ctor/docs/repl.txt +592 -0
  80. package/ctor/docs/types/index.d.ts +56 -0
  81. package/ctor/docs/types/test.ts +33 -0
  82. package/ctor/lib/index.js +54 -0
  83. package/ctor/lib/main.js +58 -0
  84. package/ctor/package.json +58 -0
  85. package/deep-get/README.md +181 -0
  86. package/deep-get/docs/repl.txt +63 -0
  87. package/deep-get/docs/types/index.d.ts +125 -0
  88. package/deep-get/docs/types/test.ts +109 -0
  89. package/deep-get/lib/defaults.js +38 -0
  90. package/deep-get/lib/dget.js +57 -0
  91. package/deep-get/lib/factory.js +94 -0
  92. package/deep-get/lib/index.js +58 -0
  93. package/deep-get/lib/main.js +101 -0
  94. package/deep-get/lib/validate.js +66 -0
  95. package/deep-get/package.json +68 -0
  96. package/deep-set/README.md +273 -0
  97. package/deep-set/docs/repl.txt +87 -0
  98. package/deep-set/docs/types/index.d.ts +180 -0
  99. package/deep-set/docs/types/test.ts +134 -0
  100. package/deep-set/lib/defaults.js +39 -0
  101. package/deep-set/lib/dset.js +80 -0
  102. package/deep-set/lib/factory.js +99 -0
  103. package/deep-set/lib/index.js +58 -0
  104. package/deep-set/lib/main.js +120 -0
  105. package/deep-set/lib/validate.js +74 -0
  106. package/deep-set/package.json +69 -0
  107. package/docs/types/index.d.ts +964 -0
  108. package/every-in-by/README.md +156 -0
  109. package/every-in-by/docs/repl.txt +43 -0
  110. package/every-in-by/docs/types/index.d.ts +83 -0
  111. package/every-in-by/docs/types/test.ts +60 -0
  112. package/every-in-by/lib/index.js +51 -0
  113. package/every-in-by/lib/main.js +70 -0
  114. package/every-in-by/package.json +67 -0
  115. package/every-own-by/README.md +223 -0
  116. package/every-own-by/docs/repl.txt +43 -0
  117. package/every-own-by/docs/types/index.d.ts +102 -0
  118. package/every-own-by/docs/types/test.ts +62 -0
  119. package/every-own-by/lib/index.js +46 -0
  120. package/every-own-by/lib/main.js +77 -0
  121. package/every-own-by/package.json +68 -0
  122. package/for-in/README.md +218 -0
  123. package/for-in/docs/repl.txt +44 -0
  124. package/for-in/docs/types/index.d.ts +65 -0
  125. package/for-in/docs/types/test.ts +50 -0
  126. package/for-in/lib/index.js +54 -0
  127. package/for-in/lib/main.js +82 -0
  128. package/for-in/package.json +74 -0
  129. package/for-own/README.md +209 -0
  130. package/for-own/docs/repl.txt +49 -0
  131. package/for-own/docs/types/index.d.ts +63 -0
  132. package/for-own/docs/types/test.ts +50 -0
  133. package/for-own/lib/index.js +50 -0
  134. package/for-own/lib/main.js +85 -0
  135. package/for-own/package.json +71 -0
  136. package/inverse/README.md +163 -0
  137. package/inverse/docs/repl.txt +53 -0
  138. package/inverse/docs/types/index.d.ts +66 -0
  139. package/inverse/docs/types/test.ts +60 -0
  140. package/inverse/lib/index.js +59 -0
  141. package/inverse/lib/main.js +123 -0
  142. package/inverse/package.json +69 -0
  143. package/inverse-by/README.md +205 -0
  144. package/inverse-by/docs/repl.txt +67 -0
  145. package/inverse-by/docs/types/index.d.ts +160 -0
  146. package/inverse-by/docs/types/test.ts +81 -0
  147. package/inverse-by/lib/index.js +78 -0
  148. package/inverse-by/lib/main.js +148 -0
  149. package/inverse-by/package.json +75 -0
  150. package/lib/index.js +276 -0
  151. package/lowercase-keys/README.md +139 -0
  152. package/lowercase-keys/docs/repl.txt +28 -0
  153. package/lowercase-keys/docs/types/index.d.ts +46 -0
  154. package/lowercase-keys/docs/types/test.ts +33 -0
  155. package/lowercase-keys/lib/index.js +45 -0
  156. package/lowercase-keys/lib/main.js +63 -0
  157. package/lowercase-keys/package.json +74 -0
  158. package/move-property/README.md +144 -0
  159. package/move-property/docs/repl.txt +38 -0
  160. package/move-property/docs/types/index.d.ts +53 -0
  161. package/move-property/docs/types/test.ts +46 -0
  162. package/move-property/lib/index.js +46 -0
  163. package/move-property/lib/main.js +74 -0
  164. package/move-property/package.json +69 -0
  165. package/none-in-by/README.md +241 -0
  166. package/none-in-by/docs/repl.txt +42 -0
  167. package/none-in-by/docs/types/index.d.ts +101 -0
  168. package/none-in-by/docs/types/test.ts +61 -0
  169. package/none-in-by/lib/index.js +46 -0
  170. package/none-in-by/lib/main.js +71 -0
  171. package/none-in-by/package.json +68 -0
  172. package/none-own-by/README.md +177 -0
  173. package/none-own-by/docs/repl.txt +42 -0
  174. package/none-own-by/docs/types/index.d.ts +102 -0
  175. package/none-own-by/docs/types/test.ts +61 -0
  176. package/none-own-by/lib/index.js +50 -0
  177. package/none-own-by/lib/main.js +75 -0
  178. package/none-own-by/package.json +68 -0
  179. package/package.json +66 -4
  180. package/some-in-by/README.md +232 -0
  181. package/some-in-by/docs/repl.txt +45 -0
  182. package/some-in-by/docs/types/index.d.ts +104 -0
  183. package/some-in-by/docs/types/test.ts +66 -0
  184. package/some-in-by/lib/index.js +46 -0
  185. package/some-in-by/lib/main.js +87 -0
  186. package/some-in-by/package.json +75 -0
  187. package/some-own-by/README.md +251 -0
  188. package/some-own-by/docs/repl.txt +45 -0
  189. package/some-own-by/docs/types/index.d.ts +103 -0
  190. package/some-own-by/docs/types/test.ts +66 -0
  191. package/some-own-by/lib/index.js +46 -0
  192. package/some-own-by/lib/main.js +85 -0
  193. package/some-own-by/package.json +72 -0
  194. package/uncapitalize-keys/README.md +139 -0
  195. package/uncapitalize-keys/docs/repl.txt +28 -0
  196. package/uncapitalize-keys/docs/types/index.d.ts +46 -0
  197. package/uncapitalize-keys/docs/types/test.ts +33 -0
  198. package/uncapitalize-keys/lib/index.js +45 -0
  199. package/uncapitalize-keys/lib/main.js +69 -0
  200. package/uncapitalize-keys/package.json +76 -0
  201. package/uppercase-keys/README.md +139 -0
  202. package/uppercase-keys/docs/repl.txt +28 -0
  203. package/uppercase-keys/docs/types/index.d.ts +46 -0
  204. package/uppercase-keys/docs/types/test.ts +33 -0
  205. package/uppercase-keys/lib/index.js +45 -0
  206. package/uppercase-keys/lib/main.js +63 -0
  207. package/uppercase-keys/package.json +74 -0
@@ -0,0 +1,148 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ // MODULES //
22
+
23
+ var objectKeys = require( '@ohos-ports/stdlib-utils/keys' );
24
+ var isArray = require( '@ohos-ports/stdlib-assert/is-array' );
25
+ var isObject = require( '@ohos-ports/stdlib-assert/is-plain-object' );
26
+ var isObjectLike = require( '@ohos-ports/stdlib-assert/is-object-like' );
27
+ var isBoolean = require( '@ohos-ports/stdlib-assert/is-boolean' ).isPrimitive;
28
+ var isFunction = require( '@ohos-ports/stdlib-assert/is-function' );
29
+ var hasOwnProp = require( '@ohos-ports/stdlib-assert/has-own-property' );
30
+ var format = require( '@ohos-ports/stdlib-string/format' );
31
+
32
+
33
+ // MAIN //
34
+
35
+ /**
36
+ * Inverts an object, such that keys become values and values become keys, according to a transform function.
37
+ *
38
+ * @param {ObjectLike} obj - input object
39
+ * @param {Options} [opts] - function options
40
+ * @param {boolean} [opts.duplicates=true] - boolean indicating whether to store duplicate keys
41
+ * @param {Function} transform - transform function
42
+ * @throws {TypeError} first argument must be object-like
43
+ * @throws {TypeError} options argument must be an object
44
+ * @throws {TypeError} last argument must be a function
45
+ * @throws {TypeError} must provide valid options
46
+ * @returns {Object} inverted object
47
+ *
48
+ * @example
49
+ * function transform( key, value ) {
50
+ * return key + value;
51
+ * }
52
+ * var obj = {
53
+ * 'a': 'beep',
54
+ * 'b': 'boop'
55
+ * };
56
+ * var out = invertBy( obj, transform );
57
+ * // returns { 'abeep': 'a', 'bboop': 'b' }
58
+ *
59
+ * @example
60
+ * function transform( key, value ) {
61
+ * return value;
62
+ * }
63
+ * var obj = {
64
+ * 'a': 'beep',
65
+ * 'b': 'beep'
66
+ * };
67
+ * var out = invertBy( obj, transform );
68
+ * // returns { 'beep': [ 'a', 'b' ] }
69
+ *
70
+ * @example
71
+ * function transform( key, value ) {
72
+ * return value;
73
+ * }
74
+ *
75
+ * var obj = {};
76
+ * obj.a = 'beep';
77
+ * obj.b = 'boop';
78
+ * obj.c = 'beep'; // inserted after `a`
79
+ *
80
+ * var opts = {
81
+ * 'duplicates': false
82
+ * };
83
+ * var out = invertBy( obj, opts, transform );
84
+ * // returns { 'beep': 'c', 'boop': 'b' }
85
+ */
86
+ function invertBy( obj, opts, transform ) {
87
+ var allowDupes;
88
+ var keys;
89
+ var len;
90
+ var key;
91
+ var val;
92
+ var out;
93
+ var cb;
94
+ var v;
95
+ var i;
96
+ if ( !isObjectLike( obj ) ) {
97
+ throw new TypeError( format( 'invalid argument. First argument must be an object (except null). Value: `%s`.', obj ) );
98
+ }
99
+ allowDupes = true;
100
+ if ( arguments.length === 2 ) {
101
+ cb = opts;
102
+ } else {
103
+ if ( !isObject( opts ) ) {
104
+ throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );
105
+ }
106
+ if ( hasOwnProp( opts, 'duplicates' ) ) {
107
+ allowDupes = opts.duplicates;
108
+ if ( !isBoolean( allowDupes ) ) {
109
+ throw new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'duplicates', allowDupes ) );
110
+ }
111
+ }
112
+ cb = transform;
113
+ }
114
+ if ( !isFunction( cb ) ) {
115
+ throw new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) );
116
+ }
117
+ keys = objectKeys( obj );
118
+ len = keys.length;
119
+ out = {};
120
+ if ( allowDupes ) {
121
+ for ( i = 0; i < len; i++ ) {
122
+ key = keys[ i ];
123
+ val = cb( key, obj[ key ], obj );
124
+ if ( !hasOwnProp( out, val ) ) {
125
+ out[ val ] = key;
126
+ continue;
127
+ }
128
+ v = out[ val ];
129
+ if ( isArray( v ) ) {
130
+ out[ val ].push( key );
131
+ } else {
132
+ out[ val ] = [ v, key ];
133
+ }
134
+ }
135
+ } else {
136
+ for ( i = 0; i < len; i++ ) {
137
+ key = keys[ i ];
138
+ val = cb( key, obj[ key ], obj );
139
+ out[ val ] = key;
140
+ }
141
+ }
142
+ return out;
143
+ }
144
+
145
+
146
+ // EXPORTS //
147
+
148
+ module.exports = invertBy;
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@stdlib/object/inverse-by",
3
+ "version": "0.0.0",
4
+ "description": "Invert an object, such that keys become values and values become keys, according to a transform function.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "directories": {
18
+ "benchmark": "./benchmark",
19
+ "doc": "./docs",
20
+ "example": "./examples",
21
+ "lib": "./lib",
22
+ "test": "./test"
23
+ },
24
+ "types": "./docs/types",
25
+ "scripts": {},
26
+ "homepage": "https://github.com/stdlib-js/stdlib",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git://github.com/stdlib-js/stdlib.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/stdlib-js/stdlib/issues"
33
+ },
34
+ "dependencies": {},
35
+ "devDependencies": {},
36
+ "engines": {
37
+ "node": ">=0.10.0",
38
+ "npm": ">2.7.0"
39
+ },
40
+ "os": [
41
+ "aix",
42
+ "darwin",
43
+ "freebsd",
44
+ "linux",
45
+ "macos",
46
+ "openbsd",
47
+ "sunos",
48
+ "win32",
49
+ "windows"
50
+ ],
51
+ "keywords": [
52
+ "stdlib",
53
+ "stdutils",
54
+ "stdutil",
55
+ "utilities",
56
+ "utility",
57
+ "utils",
58
+ "util",
59
+ "inverse",
60
+ "invert",
61
+ "invertby",
62
+ "inverseby",
63
+ "transform",
64
+ "convert",
65
+ "object",
66
+ "obj",
67
+ "object-like",
68
+ "keys",
69
+ "values",
70
+ "bijection",
71
+ "mapping",
72
+ "hash",
73
+ "array"
74
+ ]
75
+ }
package/lib/index.js ADDED
@@ -0,0 +1,276 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2022 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ 'use strict';
20
+
21
+ /*
22
+ * When adding modules to the namespace, ensure that they are added in alphabetical order according to module name.
23
+ */
24
+
25
+ // MODULES //
26
+
27
+ var setReadOnly = require( '@ohos-ports/stdlib-utils/define-read-only-property' );
28
+
29
+
30
+ // MAIN //
31
+
32
+ /**
33
+ * Top-level namespace.
34
+ *
35
+ * @namespace ns
36
+ */
37
+ var ns = {};
38
+
39
+ /**
40
+ * @name anyInBy
41
+ * @memberof ns
42
+ * @readonly
43
+ * @type {Function}
44
+ * @see {@link module:@stdlib/object/any-in-by}
45
+ */
46
+ setReadOnly( ns, 'anyInBy', require( './../any-in-by' ) );
47
+
48
+ /**
49
+ * @name anyOwnBy
50
+ * @memberof ns
51
+ * @readonly
52
+ * @type {Function}
53
+ * @see {@link module:@stdlib/object/any-own-by}
54
+ */
55
+ setReadOnly( ns, 'anyOwnBy', require( './../any-own-by' ) );
56
+
57
+ /**
58
+ * @name assign
59
+ * @memberof ns
60
+ * @readonly
61
+ * @type {Function}
62
+ * @see {@link module:@stdlib/object/assign}
63
+ */
64
+ setReadOnly( ns, 'assign', require( './../assign' ) );
65
+
66
+ /**
67
+ * @name assignIn
68
+ * @memberof ns
69
+ * @readonly
70
+ * @type {Function}
71
+ * @see {@link module:@stdlib/object/assign-in}
72
+ */
73
+ setReadOnly( ns, 'assignIn', require( './../assign-in' ) );
74
+
75
+ /**
76
+ * @name bifurcateIn
77
+ * @memberof ns
78
+ * @readonly
79
+ * @type {Function}
80
+ * @see {@link module:@stdlib/object/bifurcate-in}
81
+ */
82
+ setReadOnly( ns, 'bifurcateIn', require( './../bifurcate-in' ) );
83
+
84
+ /**
85
+ * @name bifurcateOwn
86
+ * @memberof ns
87
+ * @readonly
88
+ * @type {Function}
89
+ * @see {@link module:@stdlib/object/bifurcate-own}
90
+ */
91
+ setReadOnly( ns, 'bifurcateOwn', require( './../bifurcate-own' ) );
92
+
93
+ /**
94
+ * @name capitalizeKeys
95
+ * @memberof ns
96
+ * @readonly
97
+ * @type {Function}
98
+ * @see {@link module:@stdlib/object/capitalize-keys}
99
+ */
100
+ setReadOnly( ns, 'capitalizeKeys', require( './../capitalize-keys' ) );
101
+
102
+ /**
103
+ * @name commonKeys
104
+ * @memberof ns
105
+ * @readonly
106
+ * @type {Function}
107
+ * @see {@link module:@stdlib/object/common-keys}
108
+ */
109
+ setReadOnly( ns, 'commonKeys', require( './../common-keys' ) );
110
+
111
+ /**
112
+ * @name commonKeysIn
113
+ * @memberof ns
114
+ * @readonly
115
+ * @type {Function}
116
+ * @see {@link module:@stdlib/object/common-keys-in}
117
+ */
118
+ setReadOnly( ns, 'commonKeysIn', require( './../common-keys-in' ) );
119
+
120
+ /**
121
+ * @name Object
122
+ * @memberof ns
123
+ * @readonly
124
+ * @type {Function}
125
+ * @see {@link module:@stdlib/object/ctor}
126
+ */
127
+ setReadOnly( ns, 'Object', require( './../ctor' ) );
128
+
129
+ /**
130
+ * @name deepGet
131
+ * @memberof ns
132
+ * @readonly
133
+ * @type {Function}
134
+ * @see {@link module:@stdlib/object/deep-get}
135
+ */
136
+ setReadOnly( ns, 'deepGet', require( './../deep-get' ) );
137
+
138
+ /**
139
+ * @name deepSet
140
+ * @memberof ns
141
+ * @readonly
142
+ * @type {Function}
143
+ * @see {@link module:@stdlib/object/deep-set}
144
+ */
145
+ setReadOnly( ns, 'deepSet', require( './../deep-set' ) );
146
+
147
+ /**
148
+ * @name everyInBy
149
+ * @memberof ns
150
+ * @readonly
151
+ * @type {Function}
152
+ * @see {@link module:@stdlib/object/every-in-by}
153
+ */
154
+ setReadOnly( ns, 'everyInBy', require( './../every-in-by' ) );
155
+
156
+ /**
157
+ * @name everyOwnBy
158
+ * @memberof ns
159
+ * @readonly
160
+ * @type {Function}
161
+ * @see {@link module:@stdlib/object/every-own-by}
162
+ */
163
+ setReadOnly( ns, 'everyOwnBy', require( './../every-own-by' ) );
164
+
165
+ /**
166
+ * @name forIn
167
+ * @memberof ns
168
+ * @readonly
169
+ * @type {Function}
170
+ * @see {@link module:@stdlib/object/for-in}
171
+ */
172
+ setReadOnly( ns, 'forIn', require( './../for-in' ) );
173
+
174
+ /**
175
+ * @name forOwn
176
+ * @memberof ns
177
+ * @readonly
178
+ * @type {Function}
179
+ * @see {@link module:@stdlib/object/for-own}
180
+ */
181
+ setReadOnly( ns, 'forOwn', require( './../for-own' ) );
182
+
183
+ /**
184
+ * @name inverse
185
+ * @memberof ns
186
+ * @readonly
187
+ * @type {Function}
188
+ * @see {@link module:@stdlib/object/inverse}
189
+ */
190
+ setReadOnly( ns, 'inverse', require( './../inverse' ) );
191
+
192
+ /**
193
+ * @name inverseBy
194
+ * @memberof ns
195
+ * @readonly
196
+ * @type {Function}
197
+ * @see {@link module:@stdlib/object/inverse-by}
198
+ */
199
+ setReadOnly( ns, 'inverseBy', require( './../inverse-by' ) );
200
+
201
+ /**
202
+ * @name lowercaseKeys
203
+ * @memberof ns
204
+ * @readonly
205
+ * @type {Function}
206
+ * @see {@link module:@stdlib/object/lowercase-keys}
207
+ */
208
+ setReadOnly( ns, 'lowercaseKeys', require( './../lowercase-keys' ) );
209
+
210
+ /**
211
+ * @name moveProperty
212
+ * @memberof ns
213
+ * @readonly
214
+ * @type {Function}
215
+ * @see {@link module:@stdlib/object/move-property}
216
+ */
217
+ setReadOnly( ns, 'moveProperty', require( './../move-property' ) );
218
+
219
+ /**
220
+ * @name noneInBy
221
+ * @memberof ns
222
+ * @readonly
223
+ * @type {Function}
224
+ * @see {@link module:@stdlib/object/none-in-by}
225
+ */
226
+ setReadOnly( ns, 'noneInBy', require( './../none-in-by' ) );
227
+
228
+ /**
229
+ * @name noneOwnBy
230
+ * @memberof ns
231
+ * @readonly
232
+ * @type {Function}
233
+ * @see {@link module:@stdlib/object/none-own-by}
234
+ */
235
+ setReadOnly( ns, 'noneOwnBy', require( './../none-own-by' ) );
236
+
237
+ /**
238
+ * @name someInBy
239
+ * @memberof ns
240
+ * @readonly
241
+ * @type {Function}
242
+ * @see {@link module:@stdlib/object/some-in-by}
243
+ */
244
+ setReadOnly( ns, 'someInBy', require( './../some-in-by' ) );
245
+
246
+ /**
247
+ * @name someOwnBy
248
+ * @memberof ns
249
+ * @readonly
250
+ * @type {Function}
251
+ * @see {@link module:@stdlib/object/some-own-by}
252
+ */
253
+ setReadOnly( ns, 'someOwnBy', require( './../some-own-by' ) );
254
+
255
+ /**
256
+ * @name uncapitalizeKeys
257
+ * @memberof ns
258
+ * @readonly
259
+ * @type {Function}
260
+ * @see {@link module:@stdlib/object/uncapitalize-keys}
261
+ */
262
+ setReadOnly( ns, 'uncapitalizeKeys', require( './../uncapitalize-keys' ) );
263
+
264
+ /**
265
+ * @name uppercaseKeys
266
+ * @memberof ns
267
+ * @readonly
268
+ * @type {Function}
269
+ * @see {@link module:@stdlib/object/uppercase-keys}
270
+ */
271
+ setReadOnly( ns, 'uppercaseKeys', require( './../uppercase-keys' ) );
272
+
273
+
274
+ // EXPORTS //
275
+
276
+ module.exports = ns;
@@ -0,0 +1,139 @@
1
+ <!--
2
+
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2018 The Stdlib Authors.
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+
19
+ -->
20
+
21
+ # lowercaseKeys
22
+
23
+ > Convert each object key to lowercase.
24
+
25
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26
+
27
+ <section class="intro">
28
+
29
+ </section>
30
+
31
+ <!-- /.intro -->
32
+
33
+ <!-- Package usage documentation. -->
34
+
35
+ <section class="usage">
36
+
37
+ ## Usage
38
+
39
+ ```javascript
40
+ var lowercaseKeys = require( '@stdlib/object/lowercase-keys' );
41
+ ```
42
+
43
+ #### lowercaseKeys( obj )
44
+
45
+ Converts each `object` key to lowercase, mapping the transformed keys to a new `object` having the same values.
46
+
47
+ ```javascript
48
+ var obj1 = {
49
+ 'A': 1,
50
+ 'B': 2
51
+ };
52
+
53
+ var obj2 = lowercaseKeys( obj1 );
54
+ // returns { 'a': 1, 'b': 2 }
55
+ ```
56
+
57
+ </section>
58
+
59
+ <!-- /.usage -->
60
+
61
+ <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
62
+
63
+ <section class="notes">
64
+
65
+ ## Notes
66
+
67
+ - The function only transforms **own** properties. Hence, the function does **not** transform inherited properties.
68
+ - The function **shallow** copies key values.
69
+
70
+ </section>
71
+
72
+ <!-- /.notes -->
73
+
74
+ <!-- Package usage examples. -->
75
+
76
+ <section class="examples">
77
+
78
+ ## Examples
79
+
80
+ <!-- eslint no-undef: "error" -->
81
+
82
+ ```javascript
83
+ var lowercaseKeys = require( '@stdlib/object/lowercase-keys' );
84
+
85
+ var obj1 = {
86
+ 'A': 'beep',
87
+ 'B': 'boop',
88
+ 'C': 'foo',
89
+ 'D': 'bar'
90
+ };
91
+
92
+ var obj2 = lowercaseKeys( obj1 );
93
+
94
+ console.dir( obj2 );
95
+ // => { 'a': 'beep', 'b': 'boop', 'c': 'foo', 'd': 'bar' }
96
+ ```
97
+
98
+ </section>
99
+
100
+ <!-- /.examples -->
101
+
102
+ <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
103
+
104
+ <section class="references">
105
+
106
+ </section>
107
+
108
+ <!-- /.references -->
109
+
110
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
111
+
112
+ <section class="related">
113
+
114
+ * * *
115
+
116
+ ## See Also
117
+
118
+ - <span class="package-name">[`@stdlib/object/uncapitalize-keys`][@stdlib/object/uncapitalize-keys]</span><span class="delimiter">: </span><span class="description">convert the first letter of each object key to lowercase.</span>
119
+ - <span class="package-name">[`@stdlib/object/uppercase-keys`][@stdlib/object/uppercase-keys]</span><span class="delimiter">: </span><span class="description">convert each object key to uppercase.</span>
120
+
121
+ </section>
122
+
123
+ <!-- /.related -->
124
+
125
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
126
+
127
+ <section class="links">
128
+
129
+ <!-- <related-links> -->
130
+
131
+ [@stdlib/object/uncapitalize-keys]: https://github.com/stdlib-js/object/tree/main/uncapitalize-keys
132
+
133
+ [@stdlib/object/uppercase-keys]: https://github.com/stdlib-js/object/tree/main/uppercase-keys
134
+
135
+ <!-- </related-links> -->
136
+
137
+ </section>
138
+
139
+ <!-- /.links -->
@@ -0,0 +1,28 @@
1
+
2
+ {{alias}}( obj )
3
+ Converts each object key to lowercase.
4
+
5
+ The function only transforms own properties. Hence, the function does not
6
+ transform inherited properties.
7
+
8
+ The function shallow copies key values.
9
+
10
+ Parameters
11
+ ----------
12
+ obj: Object
13
+ Source object.
14
+
15
+ Returns
16
+ -------
17
+ out: Object
18
+ New object.
19
+
20
+ Examples
21
+ --------
22
+ > var obj = { 'A': 1, 'B': 2 };
23
+ > var out = {{alias}}( obj )
24
+ { 'a': 1, 'b': 2 }
25
+
26
+ See Also
27
+ --------
28
+
@@ -0,0 +1,46 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2019 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ // TypeScript Version: 4.1
20
+
21
+ /**
22
+ * Converts each object key to lowercase.
23
+ *
24
+ * ## Notes
25
+ *
26
+ * - The function only transforms own properties. Hence, the function does not transform inherited properties.
27
+ * - The function shallow copies key values.
28
+ *
29
+ * @param obj - source object
30
+ * @returns new object
31
+ *
32
+ * @example
33
+ * var obj1 = {
34
+ * 'A': 1,
35
+ * 'B': 2
36
+ * };
37
+ *
38
+ * var obj2 = lowercaseKeys( obj1 );
39
+ * // returns { 'a': 1, 'b': 2 }
40
+ */
41
+ declare function lowercaseKeys( obj: Object ): Object;
42
+
43
+
44
+ // EXPORTS //
45
+
46
+ export = lowercaseKeys;