UNPKG

@raona/sp

Version:

Raona utilities to work with Sharepoint using pnp/sp

19 lines (18 loc) 732 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Querys an object indicating a dot splitted query * @template T the expected return type (don't lie to the compiler) * @param o Object to get queried * @param query query to use on the object (for example 'a.b.c' will return the value of c that is inside b that is inside a) * @returns the value of the queried property if exists, otherwise undefined */ function queryObject(o, query) { if (typeof o !== 'object' || o === null) return void 0; return query.split('.') .reduce(function (o, k) { return typeof o !== 'undefined' ? o[k] : void 0; }, o); } exports.queryObject = queryObject;