UNPKG

twing

Version:

First-class Twig engine for Node.js

25 lines (24 loc) 675 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.get = get; const iterator_to_map_1 = require("./iterator-to-map"); const map_like_1 = require("./map-like"); /** * Return the value of a property of an object, providing array to Map conversion. * * @param {any} object * @param {any} property */ function get(object, property) { let result; if ((0, map_like_1.isAMapLike)(object) && object.has(property)) { result = object.get(property); } else { result = object[property]; } if (Array.isArray(result)) { result = (0, iterator_to_map_1.iteratorToMap)(result); } return result; }