@salesforce/apex-node
Version:
Salesforce JS library for Apex
36 lines • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.determineType = exports.getArrayEntries = exports.getObjectEntries = exports.getComplexEntries = exports.getPrimitiveEntries = void 0;
/*
* Copyright (c) 2023, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
const narrowing_1 = require("../narrowing");
const getPrimitiveEntries = (obj) => {
return Object.entries(obj).filter((entry) => (0, narrowing_1.isPrimitive)(entry[1]));
};
exports.getPrimitiveEntries = getPrimitiveEntries;
const getComplexEntries = (obj) => {
return Object.entries(obj).filter((entry) => !(0, narrowing_1.isPrimitive)(entry[1]));
};
exports.getComplexEntries = getComplexEntries;
const getObjectEntries = (obj) => {
return Object.entries(obj).filter((entry) => (0, narrowing_1.isObject)(entry[1]) && !(0, narrowing_1.isArray)(obj));
};
exports.getObjectEntries = getObjectEntries;
const getArrayEntries = (obj) => {
return Object.entries(obj).filter((entry) => (0, narrowing_1.isArray)(entry[1]));
};
exports.getArrayEntries = getArrayEntries;
const determineType = (value) => {
if (Array.isArray(value)) {
return value.map((val) => typeof val);
}
else {
return typeof value;
}
};
exports.determineType = determineType;
//# sourceMappingURL=utils.js.map