UNPKG

@autorest/common

Version:
32 lines 973 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayify = exports.isDefined = void 0; function isDefined(value) { return value !== undefined && value !== null; } exports.isDefined = isDefined; function isIterable(target) { return !!target && typeof target[Symbol.iterator] === "function"; } /** * Takes a configuration value that can be either an array, a single value or empty and returns an array with all values. * @param value Value to wrap in an array. * @returns Array of all the values. */ function arrayify(value) { if (value === undefined) { return []; } switch (typeof value) { case "string": // Need to do this case as String is iterable. return [value]; case "object": if (isIterable(value)) { return [...value]; } break; } return [value]; } exports.arrayify = arrayify; //# sourceMappingURL=misc.js.map