swc/bundler/tests/.cache/deno/6b760120f9dd7fdb90bc9557d2e270ddf84db232.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

49 lines
1.2 KiB
TypeScript

// Loaded from https://deno.land/x/ramda@v0.27.2/source/invertObj.js
import _curry1 from './internal/_curry1.js';
import keys from './keys.js';
/**
* Returns a new object with the keys of the given object as values, and the
* values of the given object, which are coerced to strings, as keys. Note
* that the last key found is preferred when handling the same value.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Object
* @sig {s: x} -> {x: s}
* @param {Object} obj The object or array to invert
* @return {Object} out A new object
* @see R.invert
* @example
*
* const raceResults = {
* first: 'alice',
* second: 'jake'
* };
* R.invertObj(raceResults);
* //=> { 'alice': 'first', 'jake':'second' }
*
* // Alternatively:
* const raceResults = ['alice', 'jake'];
* R.invertObj(raceResults);
* //=> { 'alice': '0', 'jake':'1' }
*/
var invertObj = _curry1(function invertObj(obj) {
var props = keys(obj);
var len = props.length;
var idx = 0;
var out = {};
while (idx < len) {
var key = props[idx];
out[obj[key]] = key;
idx += 1;
}
return out;
});
export default invertObj;