@stdlib/object-inverse-by 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md ADDED
@@ -0,0 +1,296 @@
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
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
32
+ # Object Inverse
33
+
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
35
+
36
+ > Invert an object, such that keys become values and values become keys, according to a transform function.
37
+
38
+ <section class="installation">
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @stdlib/object-inverse-by
44
+ ```
45
+
46
+ </section>
47
+
48
+ <section class="usage">
49
+
50
+ ## Usage
51
+
52
+ ```javascript
53
+ var invertBy = require( '@stdlib/object-inverse-by' );
54
+ ```
55
+
56
+ #### invertBy( obj, \[options,] transform )
57
+
58
+ Inverts an object, such that keys become values and values become keys, according to a transform function.
59
+
60
+ ```javascript
61
+ function transform( key, value ) {
62
+ return value;
63
+ }
64
+ var obj = {
65
+ 'a': 'beep',
66
+ 'b': 'boop'
67
+ };
68
+ var out = invertBy( obj, transform );
69
+ // returns { 'beep': 'a', 'boop': 'b' }
70
+ ```
71
+
72
+ The function accepts the following options:
73
+
74
+ - **duplicates**: boolean indicating whether to store keys mapped to duplicate values in arrays. Default: `true`.
75
+
76
+ By default, keys mapped to duplicate values are stored in arrays.
77
+
78
+ ```javascript
79
+ function transform( key, value ) {
80
+ return value;
81
+ }
82
+ var obj = {
83
+ 'a': 'beep',
84
+ 'b': 'beep'
85
+ };
86
+ var out = invertBy( obj, transform );
87
+ // returns { 'beep': [ 'a', 'b' ] }
88
+ ```
89
+
90
+ To **not** allow duplicates, set the `duplicates` option to `false`. The output key-value pair will be the key most recently inserted into the input object.
91
+
92
+ ```javascript
93
+ function transform( key, value ) {
94
+ return value;
95
+ }
96
+ var obj = {};
97
+ obj.a = 'beep';
98
+ obj.b = 'boop';
99
+ obj.c = 'beep'; // inserted after `a`
100
+
101
+ var opts = {
102
+ 'duplicates': false
103
+ };
104
+ var out = invertBy( obj, opts, transform );
105
+ // returns { 'beep': 'c', 'boop': 'b' }
106
+ ```
107
+
108
+ The transform function is provided three arguments:
109
+
110
+ - **key**: object key.
111
+ - **value**: object value corresponding to `key`.
112
+ - **obj**: input object.
113
+
114
+ ```javascript
115
+ function transform( key, value, o ) {
116
+ if ( key === 'name' ) {
117
+ return value;
118
+ }
119
+ return o.name + ':' + value;
120
+ }
121
+ var obj = {
122
+ 'name': 'foo',
123
+ 'a': 'beep',
124
+ 'b': 'boop'
125
+ };
126
+ var out = invertBy( obj, transform );
127
+ // returns { 'foo': 'name', 'foo:beep': 'a', 'foo:boop': 'b' }
128
+ ```
129
+
130
+ </section>
131
+
132
+ <!-- /.usage -->
133
+
134
+ <section class="notes">
135
+
136
+ ## Notes
137
+
138
+ - Beware when providing objects having values which are themselves objects. This function relies on native object serialization (`#toString`) when converting transform function return values to keys.
139
+
140
+ ```javascript
141
+ function transform( key, value ) {
142
+ return value;
143
+ }
144
+ var obj = {
145
+ 'a': [ 1, 2, 3 ],
146
+ 'b': {
147
+ 'c': 'd'
148
+ }
149
+ };
150
+
151
+ var out = invertBy( obj, transform );
152
+ // returns { '1,2,3': 'a', '[object Object]': 'b' }
153
+ ```
154
+
155
+ - In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the [ECMAScript specification][ecma-262-for-in] in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
156
+
157
+ </section>
158
+
159
+ <!-- /.notes -->
160
+
161
+ <section class="examples">
162
+
163
+ ## Examples
164
+
165
+ <!-- eslint no-undef: "error" -->
166
+
167
+ ```javascript
168
+ var objectKeys = require( '@stdlib/utils-keys' );
169
+ var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
170
+ var invertBy = require( '@stdlib/object-inverse-by' );
171
+
172
+ function transform( key, value ) {
173
+ return value;
174
+ }
175
+
176
+ // Create an array of random integers:
177
+ var arr = discreteUniform( 1000, 0, 100, {
178
+ 'dtype': 'generic'
179
+ });
180
+
181
+ // Invert the array to determine value frequency...
182
+ var out = invertBy( arr, transform );
183
+ var keys = objectKeys( out );
184
+
185
+ var i;
186
+ for ( i = 0; i < keys.length; i++ ) {
187
+ if ( out[ i ] ) {
188
+ out[ i ] = out[ i ].length;
189
+ } else {
190
+ out[ i ] = 0;
191
+ }
192
+ }
193
+ console.dir( out );
194
+ ```
195
+
196
+ </section>
197
+
198
+ <!-- /.examples -->
199
+
200
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
201
+
202
+ <section class="related">
203
+
204
+ * * *
205
+
206
+ ## See Also
207
+
208
+ - <span class="package-name">[`@stdlib/object-inverse`][@stdlib/object/inverse]</span><span class="delimiter">: </span><span class="description">invert an object, such that keys become values and values become keys.</span>
209
+
210
+ </section>
211
+
212
+ <!-- /.related -->
213
+
214
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
215
+
216
+
217
+ <section class="main-repo" >
218
+
219
+ * * *
220
+
221
+ ## Notice
222
+
223
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
224
+
225
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
226
+
227
+ #### Community
228
+
229
+ [![Chat][chat-image]][chat-url]
230
+
231
+ ---
232
+
233
+ ## License
234
+
235
+ See [LICENSE][stdlib-license].
236
+
237
+
238
+ ## Copyright
239
+
240
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
241
+
242
+ </section>
243
+
244
+ <!-- /.stdlib -->
245
+
246
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
247
+
248
+ <section class="links">
249
+
250
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/object-inverse-by.svg
251
+ [npm-url]: https://npmjs.org/package/@stdlib/object-inverse-by
252
+
253
+ [test-image]: https://github.com/stdlib-js/object-inverse-by/actions/workflows/test.yml/badge.svg?branch=v0.1.0
254
+ [test-url]: https://github.com/stdlib-js/object-inverse-by/actions/workflows/test.yml?query=branch:v0.1.0
255
+
256
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/object-inverse-by/main.svg
257
+ [coverage-url]: https://codecov.io/github/stdlib-js/object-inverse-by?branch=main
258
+
259
+ <!--
260
+
261
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/object-inverse-by.svg
262
+ [dependencies-url]: https://david-dm.org/stdlib-js/object-inverse-by/main
263
+
264
+ -->
265
+
266
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
267
+ [chat-url]: https://stdlib.zulipchat.com
268
+
269
+ [stdlib]: https://github.com/stdlib-js/stdlib
270
+
271
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
272
+
273
+ [umd]: https://github.com/umdjs/umd
274
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
275
+
276
+ [deno-url]: https://github.com/stdlib-js/object-inverse-by/tree/deno
277
+ [deno-readme]: https://github.com/stdlib-js/object-inverse-by/blob/deno/README.md
278
+ [umd-url]: https://github.com/stdlib-js/object-inverse-by/tree/umd
279
+ [umd-readme]: https://github.com/stdlib-js/object-inverse-by/blob/umd/README.md
280
+ [esm-url]: https://github.com/stdlib-js/object-inverse-by/tree/esm
281
+ [esm-readme]: https://github.com/stdlib-js/object-inverse-by/blob/esm/README.md
282
+ [branches-url]: https://github.com/stdlib-js/object-inverse-by/blob/main/branches.md
283
+
284
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/object-inverse-by/main/LICENSE
285
+
286
+ [ecma-262-for-in]: https://262.ecma-international.org/5.1/#sec-12.6.4
287
+
288
+ <!-- <related-links> -->
289
+
290
+ [@stdlib/object/inverse]: https://www.npmjs.com/package/@stdlib/object-inverse
291
+
292
+ <!-- </related-links> -->
293
+
294
+ </section>
295
+
296
+ <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import invertBy from '../docs/types/index';
3
+ export = invertBy;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var g=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var p=g(function(x,m){
2
+ var q=require('@stdlib/utils-keys/dist'),y=require('@stdlib/assert-is-array/dist'),h=require('@stdlib/assert-is-plain-object/dist'),d=require('@stdlib/assert-is-object-like/dist'),b=require('@stdlib/assert-is-boolean/dist').isPrimitive,O=require('@stdlib/assert-is-function/dist'),f=require('@stdlib/assert-has-own-property/dist'),l=require('@stdlib/error-tools-fmtprodmsg/dist');function E(i,e,w){var s,v,o,r,a,t,u,c,n;if(!d(i))throw new TypeError(l('nullES',i));if(s=!0,arguments.length===2)u=e;else{if(!h(e))throw new TypeError(l('null2V',e));if(f(e,"duplicates")&&(s=e.duplicates,!b(s)))throw new TypeError(l('null2o',"duplicates",s));u=w}if(!O(u))throw new TypeError(l('null3q',u));if(v=q(i),o=v.length,t={},s)for(n=0;n<o;n++){if(r=v[n],a=u(r,i[r],i),!f(t,a)){t[a]=r;continue}c=t[a],y(c)?t[a].push(r):t[a]=[c,r]}else for(n=0;n<o;n++)r=v[n],a=u(r,i[r],i),t[a]=r;return t}m.exports=E
3
+ });var T=p();module.exports=T;
4
+ /** @license Apache-2.0 */
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar objectKeys = require( '@stdlib/utils-keys' );\nvar isArray = require( '@stdlib/assert-is-array' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar isObjectLike = require( '@stdlib/assert-is-object-like' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Inverts an object, such that keys become values and values become keys, according to a transform function.\n*\n* @param {ObjectLike} obj - input object\n* @param {Options} [opts] - function options\n* @param {boolean} [opts.duplicates=true] - boolean indicating whether to store duplicate keys\n* @param {Function} transform - transform function\n* @throws {TypeError} first argument must be object-like\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} last argument must be a function\n* @throws {TypeError} must provide valid options\n* @returns {Object} inverted object\n*\n* @example\n* function transform( key, value ) {\n* return key + value;\n* }\n* var obj = {\n* 'a': 'beep',\n* 'b': 'boop'\n* };\n* var out = invertBy( obj, transform );\n* // returns { 'abeep': 'a', 'bboop': 'b' }\n*\n* @example\n* function transform( key, value ) {\n* return value;\n* }\n* var obj = {\n* 'a': 'beep',\n* 'b': 'beep'\n* };\n* var out = invertBy( obj, transform );\n* // returns { 'beep': [ 'a', 'b' ] }\n*\n* @example\n* function transform( key, value ) {\n* return value;\n* }\n*\n* var obj = {};\n* obj.a = 'beep';\n* obj.b = 'boop';\n* obj.c = 'beep'; // inserted after `a`\n*\n* var opts = {\n* 'duplicates': false\n* };\n* var out = invertBy( obj, opts, transform );\n* // returns { 'beep': 'c', 'boop': 'b' }\n*/\nfunction invertBy( obj, opts, transform ) {\n\tvar allowDupes;\n\tvar keys;\n\tvar len;\n\tvar key;\n\tvar val;\n\tvar out;\n\tvar cb;\n\tvar v;\n\tvar i;\n\tif ( !isObjectLike( obj ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an object (except null). Value: `%s`.', obj ) );\n\t}\n\tallowDupes = true;\n\tif ( arguments.length === 2 ) {\n\t\tcb = opts;\n\t} else {\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\tif ( hasOwnProp( opts, 'duplicates' ) ) {\n\t\t\tallowDupes = opts.duplicates;\n\t\t\tif ( !isBoolean( allowDupes ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'duplicates', allowDupes ) );\n\t\t\t}\n\t\t}\n\t\tcb = transform;\n\t}\n\tif ( !isFunction( cb ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Last argument must be a function. Value: `%s`.', cb ) );\n\t}\n\tkeys = objectKeys( obj );\n\tlen = keys.length;\n\tout = {};\n\tif ( allowDupes ) {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tkey = keys[ i ];\n\t\t\tval = cb( key, obj[ key ], obj );\n\t\t\tif ( !hasOwnProp( out, val ) ) {\n\t\t\t\tout[ val ] = key;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tv = out[ val ];\n\t\t\tif ( isArray( v ) ) {\n\t\t\t\tout[ val ].push( key );\n\t\t\t} else {\n\t\t\t\tout[ val ] = [ v, key ];\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tkey = keys[ i ];\n\t\t\tval = cb( key, obj[ key ], obj );\n\t\t\tout[ val ] = key;\n\t\t}\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = invertBy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Invert an object, such that keys become values and values become keys, according to a transform function.\n*\n* @module @stdlib/object-inverse-by\n*\n* @example\n* var invertBy = require( '@stdlib/object-inverse-by' );\n*\n* function transform( key, value ) {\n* return key + value;\n* }\n* var obj = {\n* 'a': 'beep',\n* 'b': 'boop'\n* };\n* var out = invertBy( obj, transform );\n* // returns { 'abeep': 'a', 'bboop': 'b' }\n*\n* @example\n* var invertBy = require( '@stdlib/object-inverse-by' );\n*\n* function transform( key, value ) {\n* return value;\n* }\n* var obj = {\n* 'a': 'beep',\n* 'b': 'beep'\n* };\n* var out = invertBy( obj, transform );\n* // returns { 'beep': [ 'a', 'b' ] }\n*\n* @example\n* var invertBy = require( '@stdlib/object-inverse-by' );\n*\n* function transform( key, value ) {\n* return value;\n* }\n*\n* var obj = {};\n* obj.a = 'beep';\n* obj.b = 'boop';\n* obj.c = 'beep'; // inserted after `a`\n*\n* var opts = {\n* 'duplicates': false\n* };\n* var out = invertBy( obj, opts, transform );\n* // returns { 'beep': 'c', 'boop': 'b' }\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,oBAAqB,EAC3CC,EAAU,QAAS,yBAA0B,EAC7CC,EAAW,QAAS,gCAAiC,EACrDC,EAAe,QAAS,+BAAgC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAa,QAAS,4BAA6B,EACnDC,EAAa,QAAS,iCAAkC,EACxDC,EAAS,QAAS,uBAAwB,EAwD9C,SAASC,EAAUC,EAAKC,EAAMC,EAAY,CACzC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACJ,GAAK,CAACjB,EAAcM,CAAI,EACvB,MAAM,IAAI,UAAWF,EAAQ,iFAAkFE,CAAI,CAAE,EAGtH,GADAG,EAAa,GACR,UAAU,SAAW,EACzBM,EAAKR,MACC,CACN,GAAK,CAACR,EAAUQ,CAAK,EACpB,MAAM,IAAI,UAAWH,EAAQ,qEAAsEG,CAAK,CAAE,EAE3G,GAAKJ,EAAYI,EAAM,YAAa,IACnCE,EAAaF,EAAK,WACb,CAACN,EAAWQ,CAAW,GAC3B,MAAM,IAAI,UAAWL,EAAQ,+DAAgE,aAAcK,CAAW,CAAE,EAG1HM,EAAKP,CACN,CACA,GAAK,CAACN,EAAYa,CAAG,EACpB,MAAM,IAAI,UAAWX,EAAQ,mEAAoEW,CAAG,CAAE,EAKvG,GAHAL,EAAOb,EAAYS,CAAI,EACvBK,EAAMD,EAAK,OACXI,EAAM,CAAC,EACFL,EACJ,IAAMQ,EAAI,EAAGA,EAAIN,EAAKM,IAAM,CAG3B,GAFAL,EAAMF,EAAMO,CAAE,EACdJ,EAAME,EAAIH,EAAKN,EAAKM,CAAI,EAAGN,CAAI,EAC1B,CAACH,EAAYW,EAAKD,CAAI,EAAI,CAC9BC,EAAKD,CAAI,EAAID,EACb,QACD,CACAI,EAAIF,EAAKD,CAAI,EACRf,EAASkB,CAAE,EACfF,EAAKD,CAAI,EAAE,KAAMD,CAAI,EAErBE,EAAKD,CAAI,EAAI,CAAEG,EAAGJ,CAAI,CAExB,KAEA,KAAMK,EAAI,EAAGA,EAAIN,EAAKM,IACrBL,EAAMF,EAAMO,CAAE,EACdJ,EAAME,EAAIH,EAAKN,EAAKM,CAAI,EAAGN,CAAI,EAC/BQ,EAAKD,CAAI,EAAID,EAGf,OAAOE,CACR,CAKAlB,EAAO,QAAUS,IC3EjB,IAAIa,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "objectKeys", "isArray", "isObject", "isObjectLike", "isBoolean", "isFunction", "hasOwnProp", "format", "invertBy", "obj", "opts", "transform", "allowDupes", "keys", "len", "key", "val", "out", "cb", "v", "i", "main"]
7
+ }
@@ -0,0 +1,160 @@
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
+ * Interface defining function options.
23
+ */
24
+ interface Options {
25
+ /**
26
+ * Boolean indicating whether to store duplicate keys.
27
+ */
28
+ duplicates?: boolean;
29
+ }
30
+
31
+ /**
32
+ * Returns a value for an object element that can be serialized as an object key.
33
+ *
34
+ * @returns key in inverted object
35
+ */
36
+ type Nullary = () => string;
37
+
38
+ /**
39
+ * Returns a value for an object element that can be serialized as an object key.
40
+ *
41
+ * @param key - object key
42
+ * @returns key in inverted object
43
+ */
44
+ type Unary = ( key: string ) => string;
45
+
46
+ /**
47
+ * Returns a value for an object element that can be serialized as an object key.
48
+ *
49
+ * @param key - object key
50
+ * @param value - object value corresponding to `key`
51
+ * @returns key in inverted object
52
+ */
53
+ type Binary = ( key: string, value: any ) => string;
54
+
55
+ /**
56
+ * Returns a value for an object element that can be serialized as an object key.
57
+ *
58
+ * @param key - object key
59
+ * @param value - object value corresponding to `key`
60
+ * @param obj - the input object
61
+ * @returns key in inverted object
62
+ */
63
+ type Ternary = ( key: string, value: any, obj: any ) => string;
64
+
65
+ /**
66
+ * Returns a value for an object element that can be serialized as an object key.
67
+ *
68
+ * @param key - object key
69
+ * @param value - object value corresponding to `key`
70
+ * @param obj - the input object
71
+ * @returns key in inverted object
72
+ */
73
+ type Transform = Nullary | Unary | Binary | Ternary;
74
+
75
+ /**
76
+ * Inverts an object, such that keys become values and values become keys, according to a transform function.
77
+ *
78
+ * ## Notes
79
+ *
80
+ * - The transform function is provided three arguments:
81
+ *
82
+ * - `key`: object key.
83
+ * - `value`: object value corresponding to `key`.
84
+ * - `obj`: the input object.
85
+ *
86
+ * - The value returned by a transform function should be a value which can be serialized as an object key. Hence, beware when providing objects having values which are themselves objects. The function relies on native object serialization (`#toString`) when converting transform function return values to keys.
87
+ *
88
+ * - In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the ECMAScript specification in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
89
+ *
90
+ * @param obj - input object
91
+ * @param transform - transform function
92
+ * @returns inverted object
93
+ *
94
+ * @example
95
+ * function transform( key, value ) {
96
+ * return key + value;
97
+ * }
98
+ * var obj = {
99
+ * 'a': 'beep',
100
+ * 'b': 'boop'
101
+ * };
102
+ * var out = invertBy( obj, transform );
103
+ * // returns { 'abeep': 'a', 'bboop': 'b' }
104
+ *
105
+ * @example
106
+ * function transform( key, value ) {
107
+ * return value;
108
+ * }
109
+ * var obj = {
110
+ * 'a': 'beep',
111
+ * 'b': 'beep'
112
+ * };
113
+ * var out = invertBy( obj, transform );
114
+ * // returns { 'beep': [ 'a', 'b' ] }
115
+ */
116
+ declare function invertBy( obj: any, transform: Transform ): any;
117
+
118
+ /**
119
+ * Inverts an object, such that keys become values and values become keys, according to a transform function.
120
+ *
121
+ * ## Notes
122
+ *
123
+ * - The transform function is provided three arguments:
124
+ *
125
+ * - `key`: object key.
126
+ * - `value`: object value corresponding to `key`.
127
+ * - `obj`: the input object.
128
+ *
129
+ * - The value returned by a transform function should be a value which can be serialized as an object key. Hence, beware when providing objects having values which are themselves objects. The function relies on native object serialization (`#toString`) when converting transform function return values to keys.
130
+ *
131
+ * - In older JavaScript engines, insertion order is not guaranteed, as object key enumeration was not specified according to the ECMAScript specification in earlier editions. In practice, however, most older engines use insertion order to sort an object's keys, thus allowing for deterministic inversion.
132
+ *
133
+ * @param obj - input object
134
+ * @param opts - function options
135
+ * @param opts.duplicates - boolean indicating whether to store duplicate keys (default: true)
136
+ * @param transform - transform function
137
+ * @returns inverted object
138
+ *
139
+ * @example
140
+ * function transform( key, value ) {
141
+ * return value;
142
+ * }
143
+ *
144
+ * var obj = {};
145
+ * obj.a = 'beep';
146
+ * obj.b = 'boop';
147
+ * obj.c = 'beep'; // inserted after `a`
148
+ *
149
+ * var opts = {
150
+ * 'duplicates': false
151
+ * };
152
+ * var out = invertBy( obj, opts, transform );
153
+ * // returns { 'beep': 'c', 'boop': 'b' }
154
+ */
155
+ declare function invertBy( obj: any, opts: Options, transform: Transform ): any;
156
+
157
+
158
+ // EXPORTS //
159
+
160
+ export = invertBy;
package/lib/index.js ADDED
@@ -0,0 +1,78 @@
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
+ /**
22
+ * Invert an object, such that keys become values and values become keys, according to a transform function.
23
+ *
24
+ * @module @stdlib/object-inverse-by
25
+ *
26
+ * @example
27
+ * var invertBy = require( '@stdlib/object-inverse-by' );
28
+ *
29
+ * function transform( key, value ) {
30
+ * return key + value;
31
+ * }
32
+ * var obj = {
33
+ * 'a': 'beep',
34
+ * 'b': 'boop'
35
+ * };
36
+ * var out = invertBy( obj, transform );
37
+ * // returns { 'abeep': 'a', 'bboop': 'b' }
38
+ *
39
+ * @example
40
+ * var invertBy = require( '@stdlib/object-inverse-by' );
41
+ *
42
+ * function transform( key, value ) {
43
+ * return value;
44
+ * }
45
+ * var obj = {
46
+ * 'a': 'beep',
47
+ * 'b': 'beep'
48
+ * };
49
+ * var out = invertBy( obj, transform );
50
+ * // returns { 'beep': [ 'a', 'b' ] }
51
+ *
52
+ * @example
53
+ * var invertBy = require( '@stdlib/object-inverse-by' );
54
+ *
55
+ * function transform( key, value ) {
56
+ * return value;
57
+ * }
58
+ *
59
+ * var obj = {};
60
+ * obj.a = 'beep';
61
+ * obj.b = 'boop';
62
+ * obj.c = 'beep'; // inserted after `a`
63
+ *
64
+ * var opts = {
65
+ * 'duplicates': false
66
+ * };
67
+ * var out = invertBy( obj, opts, transform );
68
+ * // returns { 'beep': 'c', 'boop': 'b' }
69
+ */
70
+
71
+ // MODULES //
72
+
73
+ var main = require( './main.js' );
74
+
75
+
76
+ // EXPORTS //
77
+
78
+ module.exports = main;
package/lib/main.js ADDED
@@ -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( '@stdlib/utils-keys' );
24
+ var isArray = require( '@stdlib/assert-is-array' );
25
+ var isObject = require( '@stdlib/assert-is-plain-object' );
26
+ var isObjectLike = require( '@stdlib/assert-is-object-like' );
27
+ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
28
+ var isFunction = require( '@stdlib/assert-is-function' );
29
+ var hasOwnProp = require( '@stdlib/assert-has-own-property' );
30
+ var format = require( '@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;
package/package.json ADDED
@@ -0,0 +1,87 @@
1
+ {
2
+ "name": "@stdlib/object-inverse-by",
3
+ "version": "0.1.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
+ "doc": "./docs",
19
+ "lib": "./lib",
20
+ "dist": "./dist"
21
+ },
22
+ "types": "./docs/types",
23
+ "scripts": {},
24
+ "homepage": "https://stdlib.io",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git://github.com/stdlib-js/object-inverse-by.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/stdlib-js/stdlib/issues"
31
+ },
32
+ "dependencies": {
33
+ "@stdlib/assert-has-own-property": "^0.2.2",
34
+ "@stdlib/assert-is-array": "^0.2.2",
35
+ "@stdlib/assert-is-boolean": "^0.2.2",
36
+ "@stdlib/assert-is-function": "^0.2.2",
37
+ "@stdlib/assert-is-object-like": "^0.2.2",
38
+ "@stdlib/assert-is-plain-object": "^0.2.2",
39
+ "@stdlib/string-format": "^0.2.2",
40
+ "@stdlib/utils-keys": "^0.2.2",
41
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.2"
42
+ },
43
+ "devDependencies": {},
44
+ "engines": {
45
+ "node": ">=0.10.0",
46
+ "npm": ">2.7.0"
47
+ },
48
+ "os": [
49
+ "aix",
50
+ "darwin",
51
+ "freebsd",
52
+ "linux",
53
+ "macos",
54
+ "openbsd",
55
+ "sunos",
56
+ "win32",
57
+ "windows"
58
+ ],
59
+ "keywords": [
60
+ "stdlib",
61
+ "stdutils",
62
+ "stdutil",
63
+ "utilities",
64
+ "utility",
65
+ "utils",
66
+ "util",
67
+ "inverse",
68
+ "invert",
69
+ "invertby",
70
+ "inverseby",
71
+ "transform",
72
+ "convert",
73
+ "object",
74
+ "obj",
75
+ "object-like",
76
+ "keys",
77
+ "values",
78
+ "bijection",
79
+ "mapping",
80
+ "hash",
81
+ "array"
82
+ ],
83
+ "funding": {
84
+ "type": "opencollective",
85
+ "url": "https://opencollective.com/stdlib"
86
+ }
87
+ }