UNPKG

bootstrap-vue

Version:

BootstrapVue, with over 40 plugins and more than 80 custom components, custom directives, and over 300 icons, provides one of the most comprehensive implementations of Bootstrap v4 components and grid system for Vue.js. With extensive and automated WAI-AR

36 lines (31 loc) 1.25 kB
import { keys } from '../../../utils/object'; import { isDate, isObject, isUndefinedOrNull } from '../../../utils/inspect'; import { toString } from '../../../utils/string'; // Recursively stringifies the values of an object, space separated, in an // SSR safe deterministic way (keys are sorted before stringification) // // ex: // { b: 3, c: { z: 'zzz', d: null, e: 2 }, d: [10, 12, 11], a: 'one' } // becomes // 'one 3 2 zzz 10 12 11' // // Primitives (numbers/strings) are returned as-is // Null and undefined values are filtered out // Dates are converted to their native string format var stringifyObjectValues = function stringifyObjectValues(val) { if (isUndefinedOrNull(val)) { /* istanbul ignore next */ return ''; } // Arrays are also object, and keys just returns the array indexes // Date objects we convert to strings if (isObject(val) && !isDate(val)) { return keys(val).sort() // Sort to prevent SSR issues on pre-rendered sorted tables .filter(function (v) { return !isUndefinedOrNull(v); }) // Ignore undefined/null values .map(function (k) { return stringifyObjectValues(val[k]); }).join(' '); } return toString(val); }; export default stringifyObjectValues;