Repository URL to install this package:
|
Version:
2.0.1 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const toPairs_1 = require("../array/pairs/toPairs");
const isPairs_1 = require("../array/pairs/isPairs");
const isObj_1 = require("../obj/check/isObj");
const isMap_1 = require("./isMap");
const fromPairsToMap_1 = require("./fromPairsToMap");
// Nil => empty(Map)
// Map => identity(Map) // can also clone map this way too, an entity for Map
// Pairs => Map
// Array => Map
// Obj => Array => Map
/**
* @since 5.0.0-beta.9
* @memberOf cast
*
* @param {*} x anything => Map
* @return {Map}
*
* @example
* isMap(toMap({eh: true})) //=> true
* toMap({eh: true}).has('eh') //=> true
*/
const toMap = (x) => {
// if (isNil(x)) return new Map()
if (isMap_1.default(x))
return x;
else if (isPairs_1.isPairs(x))
return fromPairsToMap_1.default(x);
else if (isObj_1.default(x))
return fromPairsToMap_1.default(toPairs_1.default(x));
else
return new Map();
};
exports.default = toMap;
//# sourceMappingURL=toMap.js.map